spimaster
Dependencies: mbed SDFileSystem
Revision 3:4c39249bcd56, committed 2021-12-05
- Comitter:
- yutation
- Date:
- Sun Dec 05 05:11:38 2021 +0000
- Parent:
- 2:6d633bb5c09d
- Commit message:
- spimaster
Changed in this revision
SDspimaster.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 6d633bb5c09d -r 4c39249bcd56 SDspimaster.cpp --- a/SDspimaster.cpp Sun Dec 05 03:05:32 2021 +0000 +++ b/SDspimaster.cpp Sun Dec 05 05:11:38 2021 +0000 @@ -32,7 +32,8 @@ const uint8_t NO_ERROR =0; //the variable below should be replaced by a specific pin -// the name is the same as the data sheet of spimaster +// the names are the same the as the spimaster port name +// i and o are the input of output of spimaster instead of the mbed. uint8_t clk_i; uint8_t address_i; @@ -40,30 +41,45 @@ uint8_t data_o; uint8_t write_en; uint8_t rst_i; +uint8_t strobe_i; +uint8_t ack_o; SDspimaster::SDspimaster(const char* name) : FATFileSystem(name), _is_initialized(0) { + clk_i = 1; rst_i = 1; + rst_i = 1; + clk_i = 0; + clk_i = 1; + clk_i = 0; rst_i = 0; + strobe_i = 0; + clk_i = 1; + clk_i = 0; + } void read_reg(uint8_t addr, uint8_t* value){ - clk_i = 1; write_en = 0; address_i = addr; + strobe_i = 1; + clk_i = 1; + *value = data_o; clk_i = 0; - *value = data_o; + + } void write_reg(uint8_t addr, uint8_t value){ - clk_i = 1; address_i = addr; data_i = value; write_en = 1; + strobe_i = 1; + clk_i = 1; clk_i = 0; }