CN102520889A - Method for converting secure digital (SD) interface to serial peripheral interface (SPI), controller and embedded device - Google Patents
Method for converting secure digital (SD) interface to serial peripheral interface (SPI), controller and embedded device Download PDFInfo
- Publication number
- CN102520889A CN102520889A CN2011104447701A CN201110444770A CN102520889A CN 102520889 A CN102520889 A CN 102520889A CN 2011104447701 A CN2011104447701 A CN 2011104447701A CN 201110444770 A CN201110444770 A CN 201110444770A CN 102520889 A CN102520889 A CN 102520889A
- Authority
- CN
- China
- Prior art keywords
- read
- equipment
- instruction
- write instruction
- write
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Images
Abstract
The invention relates to a method for converting a secure digital (SD) interface to a serial peripheral interface (SPI), which includes the following steps: receiving instructions; judging whether the received instructions are reading/writing instructions, obtaining logical addresses of the reading/writing instructions and a preset logical address range of SD device reading/writing instructions on yes judgment result; and judging whether the logical addresses of the reading/writing instructions are in the preset logical address range of the SD device reading/writing instructions, and performing reading/writing operation on an SPI device according to the reading/writing instructions on no judgment result. In addition, a controller and an embedded device are provided. The method for converting the SD interface to the SPI, the controller and the embedded device achieve reading/writing operation on an SPI device through the SD interface, and cost is reduced due to the fact that merely the SD interface instead of the SPI is needed to be arranged on the controller.
Description
[technical field]
The present invention relates to field of embedded technology, particularly a kind of SD interface changes method, controller and the embedded device of SPI interface.
[background technology]
SPI (Serial Peripheral Bus) bus is a synchronous serial Peripheral Interface, its allow controller CPU and various peripheral interface device with serial mode communicate, exchange message.Spi bus has characteristics such as interface line is few, communication efficiency height.SPI equipment has the SPI interface, often all has the SPI interface like WIFI (Wireless Fidelity, Wireless Fidelity) module.SD (Secure Digital Memory Card, safe digital card) interface is the SD memory card interface protocol of standard, and SD equipment generally has the SD interface.
On an embedded equipment; Often have WIFI (Wireless Fidelity with SPI interface; Wireless Fidelity) module and SD (Secure Digital Memory Card; Safe digital card) the SD equipment of interface so needs the controller of embedded equipment to have SD interface and SPI interface simultaneously.The controller of embedded equipment has SD interface and SPI interface simultaneously makes circuit complicated; And realize having the also complicacy very of circuit of WIFI module of SD equipment and the SPI interface of SD interface simultaneously, cause the cost of controller of embedded equipment and embedded equipment higher like this.
[summary of the invention]
Based on this, be necessary to provide a kind of SD interface that can reduce cost to change the method for SPI interface.
A kind of SD interface changes the method for SPI interface, may further comprise the steps:
Receive instruction;
Judge whether the instruction that receives is read/write instruction, if then obtain the logical address of said read/write instruction and the ranges of logical addresses of presetting to SD equipment read/write instruction;
Whether the logical address of judging said read/write instruction in the preset ranges of logical addresses to SD equipment read/write instruction, if not, then carries out read/write operation according to said read/write instruction to SPI equipment.
Preferably; It is characterized in that; The logical address of judging said read/write instruction not preset to the step in the ranges of logical addresses of SD equipment read/write instruction after; Also comprise step: judge whether to have the authority of SPI equipment being carried out read/write operation, if then SPI equipment is carried out read/write operation according to said read/write instruction.
Preferably, also comprise step: when the instruction that judge to receive during for read/write instruction, according to said instruction to SD equipment executable operations.
Preferably, also comprise step: when the logical address of judging said read/write instruction preset to the ranges of logical addresses of SD equipment read/write instruction in the time, according to said read/write instruction SD equipment is carried out read/write operation.
In addition, also be necessary to provide a kind of controller that can reduce cost.
A kind of controller comprises:
The SD interface is used for receiving or sending instruction;
Judge module is used to judge whether the instruction of reception is read/write instruction;
Acquisition module is used for when the instruction of judging reception is read/write instruction, obtains the logical address and the preset ranges of logical addresses to SD equipment read/write instruction of said read/write instruction;
Said judge module, whether the logical address that also is used to judge said read/write instruction is in the preset ranges of logical addresses to SD equipment read/write instruction;
Execution module, be used for when the logical address of judging said read/write instruction not preset to the ranges of logical addresses of SD equipment read/write instruction in the time, according to said read/write instruction SPI equipment is carried out read/write operation.
Preferably; Said judge module also is used to judge whether to have the authority of SPI equipment being carried out read/write operation; Said execution module also be used for judge have SPI equipment carried out the authority of read/write operation after, according to said read/write instruction SPI equipment is carried out read/write operation.
Preferably, said execution module also is used for when the instruction that judge to receive during for read/write instruction, according to said instruction to SD equipment executable operations.
Preferably, said execution module also be used for when the logical address of judging said read/write instruction preset to the ranges of logical addresses of SD equipment read/write instruction in the time, according to said read/write instruction SD equipment is carried out read/write operation.
In addition, also be necessary to provide a kind of embedded equipment that can reduce cost.
A kind of embedded equipment comprises controller, and said controller comprises:
The SD interface is used for receiving instruction;
Judge module is used to judge whether the instruction of reception is read/write instruction;
Acquisition module is used for when the instruction of judging reception is read/write instruction, obtains the logical address and the preset ranges of logical addresses to SD equipment read/write instruction of said read/write instruction;
Said judge module, whether the logical address that also is used to judge said read/write instruction is in the preset ranges of logical addresses to SD equipment read/write instruction;
Execution module, be used for when the logical address of judging said read/write instruction not preset to the ranges of logical addresses of SD equipment read/write instruction in the time, according to said read/write instruction SPI equipment is carried out read/write operation.
Preferably, also comprise memory device, said memory device is used to store the preset ranges of logical addresses to SD equipment read/write instruction, and the acquisition module of said controller obtains the preset ranges of logical addresses to SD equipment read/write instruction from said memory device.
Above-mentioned SD interface changes method, controller and the embedded equipment of SPI interface, receives instruction, judges that this instructs to after the read/write instruction; The logical address of further judging this read/write instruction not preset to the ranges of logical addresses of SD equipment read/write instruction in the time; According to this read/write instruction SPI equipment is carried out read/write operation, thereby realized read/write operation, so only need to establish the SD interface at controller to SPI equipment through the SD interface; Need not establish the SPI interface, reduce cost.
[description of drawings]
Fig. 1 is the process flow diagram that the SD interface changes the method for SPI interface among the embodiment;
Fig. 2 is the process flow diagram that the SD interface changes the method for SPI interface among another embodiment;
Fig. 3 is the inner structure synoptic diagram of an embodiment middle controller;
Fig. 4 is the inner structure synoptic diagram of embedded equipment among the embodiment;
Fig. 5 is embedded equipment and SD equipment and the mutual synoptic diagram of SPI equipment among the embodiment.
[embodiment]
Below in conjunction with concrete embodiment and accompanying drawing technical scheme is carried out detailed description.
As shown in Figure 1, in one embodiment, a kind of SD interface changes the method for SPI interface, may further comprise the steps:
Step S110 receives instruction.
Concrete, receive the instruction that the user triggers through controller.This instruction can be read/write instruction, other instructions except that read/write instruction.
Step S120 judges whether the instruction that receives is read/write instruction, if, execution in step S130, if not, execution in step S170.
In the present embodiment,, then obtain the logical address and the preset ranges of logical addresses of this read/write instruction to SD equipment read/write instruction if the instruction that receives is a read/write instruction.Concrete; Read instruction can be the SD agreement read block instruction CMD17 (reading single); What write command can be the SD agreement writes block instruction CMD24 (writing single); Read block instruction CMD17 and be merely a concrete example that reads instruction, write the concrete example that block instruction CMD24 is merely write command, but read/write instruction of the present invention is not limited to this.Ranges of logical addresses to SD equipment read/write instruction can preestablish as required, is 0FFF to 5FFF like ranges of logical addresses.If the instruction that receives is not a read/write instruction, then SD equipment is carried out corresponding operation according to this instruction.
Step S130 obtains the logical address of this read/write instruction and the ranges of logical addresses of presetting to SD equipment read/write instruction.
In the present embodiment; The preset ranges of logical addresses to SD equipment read/write instruction is meant the effective ranges of logical addresses of SD equipment being carried out the read/write instruction of read/write operation, and the read/write instruction in this ranges of logical addresses can't not realize SD equipment is carried out read/write operation.The ranges of logical addresses to SD equipment read/write instruction that can adopt memory device, stores to preset.
Step S140, the logical address of judging this read/write instruction whether in preset ranges of logical addresses to SD equipment read/write instruction, if not, execution in step S150, if, execution in step S160.
In the present embodiment; Whether the logical address of the read/write instruction that judge to receive is in the ranges of logical addresses of preset instruction to SD equipment read/write; Can the logical address of the read/write instruction that receives be compared with the maximal value and the minimum value of ranges of logical addresses respectively; If the logical address of the read/write instruction of this reception is greater than the minimum value of ranges of logical addresses and less than the maximal value of ranges of logical addresses, the logical address of the read/write instruction that then should receive is in this ranges of logical addresses.
When the logical address of the read/write instruction that receives is not in this ranges of logical addresses, SPI equipment is carried out read/write operation according to this read/write instruction; When the logical address of the read/write instruction that receives is in this ranges of logical addresses, SD equipment is carried out read/write operation according to this read/write instruction.
Step S150 carries out read/write operation according to this read/write instruction to SPI equipment.
In the present embodiment, SPI equipment carried out read/write operation after, finish.
Step S160 carries out read/write operation according to this read/write instruction to SD equipment.
In the present embodiment, SD equipment carried out read/write operation after, finish.
Step S170 instructs to SD equipment executable operations according to this.
In the present embodiment, when instruction is not read/write instruction, SD equipment is carried out corresponding operation according to this instruction.
In addition, in other embodiments, step S160 and step S170 can not carry out.
In one embodiment, SD equipment can be the SD card with SD interface, and SPI equipment can be the WIFI module with SPI interface, can both be integrated, and promptly has the SD card of WIFI module.
As shown in Figure 2, in one embodiment, above-mentioned SD interface changes the method for SPI interface, before step S150, also comprises:
Step S142 judges whether to have the authority of SPI equipment being carried out read/write operation, if, execution in step S150 then.
In the present embodiment; Preestablished the authority of SPI equipment being carried out read/write operation; Judge read/write instruction not in the time, judge whether to have the authority of SPI equipment being carried out read/write operation, can improve security the SPI device access to the ranges of logical addresses of SD equipment read/write instruction.
As shown in Figure 3, in one embodiment, a kind of controller 10 comprises SD interface 110, judge module 120, acquisition module 130 and execution module 140.Wherein:
Judge module 120 is used to judge whether the instruction of reception is read/write instruction.In the present embodiment, if the instruction that receives is a read/write instruction, then acquisition module 130 obtains the logical address and the preset ranges of logical addresses to SD equipment read/write instruction of this read/write instruction.Concrete; Read instruction can be the SD agreement read block instruction CMD17 (reading single); What write command can be the SD agreement writes block instruction CMD24 (writing single); Read block instruction CMD17 and be merely a concrete example that reads instruction, write the concrete example that block instruction CMD24 is merely write command, but read/write instruction of the present invention is not limited to this.Ranges of logical addresses to SD equipment read/write instruction can preestablish as required, is 0FFF to 5FFF like ranges of logical addresses.If the instruction that receives is not a read/write instruction, then execution module 140 is carried out corresponding operation according to this instruction to SD equipment.Judge module 120 is used to also to judge that the logical address of this read/write instruction is whether in the preset ranges of logical addresses to SD equipment read/write instruction.In the present embodiment; The preset ranges of logical addresses to SD equipment read/write instruction is meant the effective ranges of logical addresses of SD equipment being carried out the read/write instruction of read/write operation, and the read/write instruction in this ranges of logical addresses can't not realize SD equipment is carried out read/write operation.
Concrete; Whether the logical address that judge module 120 is judged the read/write instruction that receives is in the ranges of logical addresses of preset instruction to SD equipment read/write; Can the logical address of the read/write instruction that receives be compared with the maximal value and the minimum value of ranges of logical addresses respectively; If the logical address of the read/write instruction of this reception is greater than the minimum value of ranges of logical addresses and less than the maximal value of ranges of logical addresses, the logical address of the read/write instruction that then should receive is in this ranges of logical addresses.
Further; In one embodiment; Judge module 120 also is used to judge whether to have the authority of SPI equipment being carried out read/write operation; Execution module 140 also be used for judge have SPI equipment carried out the authority of read/write operation after, according to this read/write instruction SPI equipment is carried out read/write operation.Preestablished the authority of SPI equipment being carried out read/write operation; Judge read/write instruction not in the time to the ranges of logical addresses of SD equipment read/write instruction; Judge whether to have the authority of SPI equipment being carried out read/write operation, can improve security the SPI device access.
In one embodiment, SD equipment can be the SD card with SD interface, and SPI equipment can be the WIFI equipment with SPI interface.Can the WIFI equipment with SPI interface be coexisted through controller 10 with SD interface and the SD card with SD interface, thereby make SD card with SD interface and WIFI equipment realize the unification of read write command through the SD interface of controller 10 with SPI interface.In addition, can the SD interface of SD equipment and the SPI interface of SPI equipment be realized unification through software, promptly realize both integrated, as have the SD card of WIFI module.
In one embodiment, as shown in Figure 4, a kind of embedded equipment 1 comprises above-mentioned controller 10 and memory device 20.Memory device 20 is used to store the preset ranges of logical addresses to SD equipment read/write instruction, and the acquisition module 130 of controller 10 obtains the preset ranges of logical addresses to SD equipment read/write instruction from memory device 20.
In other embodiments, can not comprise memory device 20 in the above-mentioned embedded equipment 1.
In one embodiment; As shown in Figure 5; Embedded equipment 1 has the SD interface, and SD equipment 2 has the SD interface, and SPI equipment 3 has the SPI interface; Embedded equipment 1 is read and write SD equipment 2, SPI equipment 3 through the SD interface, thereby avoids embedded equipment 1 need have SD interface and SPI interface simultaneously.Concrete, the SD interface of embedded equipment 1 is arranged on its controller 10.In addition, can with SD equipment with SPI equipment integration be in the same place, as have the SD card of WIFI module.
Above-mentioned SD interface changes method, controller and the embedded equipment of SPI interface, receives instruction, judges that this instructs to after the read/write instruction; The logical address of further judging this read/write instruction not preset to the ranges of logical addresses of SD equipment read/write instruction in the time; According to this read/write instruction SPI equipment is carried out read/write operation, thereby realized read/write operation, so only need to establish the SD interface at controller to SPI equipment through the SD interface; Need not establish the SPI interface, reduce cost.
In addition, detect the authority that SPI equipment is carried out read/write operation, improved security the SPI operation of equipment; On embedded equipment, both be provided with SD equipment; When being provided with SPI equipment again, can realize read/write operation, also can realize read/write operation SPI equipment to SD equipment through the SD interface of controller; Saved the SPI interface; Reduce corresponding electron device, made circuit structure simple, reduced cost.
The above embodiment has only expressed several kinds of embodiments of the present invention, and it describes comparatively concrete and detailed, but can not therefore be interpreted as the restriction to claim of the present invention.Should be pointed out that for the person of ordinary skill of the art under the prerequisite that does not break away from the present invention's design, can also make some distortion and improvement, these all belong to protection scope of the present invention.Therefore, the protection domain of patent of the present invention should be as the criterion with accompanying claims.
Claims (10)
1. a SD interface changes the method for SPI interface, may further comprise the steps:
Receive instruction;
Judge whether the instruction that receives is read/write instruction, if then obtain the logical address of said read/write instruction and the ranges of logical addresses of presetting to SD equipment read/write instruction;
Whether the logical address of judging said read/write instruction in the preset ranges of logical addresses to SD equipment read/write instruction, if not, then carries out read/write operation according to said read/write instruction to SPI equipment.
2. SD interface according to claim 1 changes the method for SPI interface; It is characterized in that; It is characterized in that, the logical address of judging said read/write instruction not preset to the step in the ranges of logical addresses of SD equipment read/write instruction after, also comprise step: judge whether to have the authority of SPI equipment being carried out read/write operation; If then SPI equipment is carried out read/write operation according to said read/write instruction.
3. SD interface according to claim 1 changes the method for SPI interface, it is characterized in that, also comprises step: when judging that the instruction that receives is for read/write instruction, according to said instruction to SD equipment executable operations.
4. SD interface according to claim 1 changes the method for SPI interface; It is characterized in that; Also comprise step: when the logical address of judging said read/write instruction preset to the ranges of logical addresses of SD equipment read/write instruction in the time, according to said read/write instruction SD equipment is carried out read/write operation.
5. a controller is characterized in that, comprising:
The SD interface is used for receiving or sending instruction;
Judge module is used to judge whether the instruction of reception is read/write instruction;
Acquisition module is used for when the instruction of judging reception is read/write instruction, obtains the logical address and the preset ranges of logical addresses to SD equipment read/write instruction of said read/write instruction;
Said judge module, whether the logical address that also is used to judge said read/write instruction is in the preset ranges of logical addresses to SD equipment read/write instruction;
Execution module, be used for when the logical address of judging said read/write instruction not preset to the ranges of logical addresses of SD equipment read/write instruction in the time, according to said read/write instruction SPI equipment is carried out read/write operation.
6. controller according to claim 5; It is characterized in that; Said judge module also is used to judge whether to have the authority of SPI equipment being carried out read/write operation; Said execution module also be used for judge have SPI equipment carried out the authority of read/write operation after, according to said read/write instruction SPI equipment is carried out read/write operation.
7. controller according to claim 5 is characterized in that, said execution module also is used for when the instruction that judge to receive during for read/write instruction, according to said instruction to SD equipment executable operations.
8. controller according to claim 5; It is characterized in that; Said execution module also be used for when the logical address of judging said read/write instruction preset to the ranges of logical addresses of SD equipment read/write instruction in the time, according to said read/write instruction SD equipment is carried out read/write operation.
9. an embedded equipment is characterized in that, comprises like each described controller in the claim 5 to 8.
10. embedded equipment according to claim 9; It is characterized in that; Also comprise memory device; Said memory device is used to store the preset ranges of logical addresses to SD equipment read/write instruction, and the acquisition module of said controller obtains the preset ranges of logical addresses to SD equipment read/write instruction from said memory device.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201110444770.1A CN102520889B (en) | 2011-12-27 | 2011-12-27 | Method for converting secure digital (SD) interface to serial peripheral interface (SPI), controller and embedded device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201110444770.1A CN102520889B (en) | 2011-12-27 | 2011-12-27 | Method for converting secure digital (SD) interface to serial peripheral interface (SPI), controller and embedded device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN102520889A true CN102520889A (en) | 2012-06-27 |
CN102520889B CN102520889B (en) | 2014-09-17 |
Family
ID=46291834
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201110444770.1A Active CN102520889B (en) | 2011-12-27 | 2011-12-27 | Method for converting secure digital (SD) interface to serial peripheral interface (SPI), controller and embedded device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN102520889B (en) |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20070083939A1 (en) * | 2005-10-07 | 2007-04-12 | Fruhauf Serge F | Secure universal serial bus (USB) storage device and method |
CN102136046A (en) * | 2010-12-29 | 2011-07-27 | 上海爱信诺航芯电子科技有限公司 | High-speed low-power consumption safe secure digital (SD) card communicating method |
-
2011
- 2011-12-27 CN CN201110444770.1A patent/CN102520889B/en active Active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20070083939A1 (en) * | 2005-10-07 | 2007-04-12 | Fruhauf Serge F | Secure universal serial bus (USB) storage device and method |
CN102136046A (en) * | 2010-12-29 | 2011-07-27 | 上海爱信诺航芯电子科技有限公司 | High-speed low-power consumption safe secure digital (SD) card communicating method |
Also Published As
Publication number | Publication date |
---|---|
CN102520889B (en) | 2014-09-17 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN105471481B (en) | System and method for bluetooth pairing with a set of bluetooth devices | |
CN107800708B (en) | Vehicle-mounted machine account automatic login method and vehicle-mounted machine device | |
JP6088664B2 (en) | Method for realizing selection of secure element in short-range wireless communication, mobile terminal, and POS machine | |
EP4037359A1 (en) | Network access control method and apparatus | |
US9094782B2 (en) | Information-processing apparatus and computer-readable medium for wireless connection setting | |
EP2402863A2 (en) | Wireless internet access device, SD control chip, and method for data communication | |
CN103065107A (en) | Method and device of achieving non-contact card swiping application | |
CN104461749A (en) | Application program synchronization method and device of multi-system terminal and terminal | |
CN106535090B (en) | Bluetooth device and intelligent device pairing method and Bluetooth device | |
US20140298054A1 (en) | Information processing apparatus capable of connecting to network in power saving state, method of controlling the same, and storage medium | |
WO2010112368A3 (en) | Method for reading attributes from an id token via a mobile radio connection | |
CN104270740B (en) | A kind of detection method of neck T cards and SIM card altogether | |
EP2538729A1 (en) | Method for controlling network connection of wireless network device and associated wireless network device | |
CN104572485A (en) | Allocation method and device of memory shared by two systems | |
CN102520889B (en) | Method for converting secure digital (SD) interface to serial peripheral interface (SPI), controller and embedded device | |
CN104639723A (en) | User data terminal and smart system | |
CN111386513B (en) | Data processing method, device and system chip | |
CN114830699A (en) | Method for establishing ISO link and BLE equipment | |
CN110460567B (en) | Identity authentication method and device | |
TW201308227A (en) | Data processing and storage device | |
CN103037536A (en) | Wireless network device and connection method thereof | |
CN201498000U (en) | Chip based fingerprint Key board | |
WO2012151950A1 (en) | Method and terminal for enhancing terminal-to-card compatibility | |
JP2009027452A (en) | Mobile terminal mail system, mobile terminal mail control method, and mobile terminal mail control program | |
US20130014268A1 (en) | Storage device and storage method |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
C14 | Grant of patent or utility model | ||
GR01 | Patent grant | ||
C41 | Transfer of patent application or patent right or utility model | ||
TR01 | Transfer of patent right |
Effective date of registration: 20160516 Address after: 518000, Guangdong, Nanshan District hi tech Industrial Park, No. 1, No. 8 financial base, 5 floor, E, F, Shenzhen Patentee after: SHENZHEN DAMAI TECHNOLOGY CO., LTD. Address before: 518057, Guangdong, Nanshan District Province, Shenzhen Road, No. 8 financial services technology innovation base, 8 floor, A, B, C, D, E,, F1 Patentee before: Shenzhen jiangbolong Electronic Co., Ltd. |