161010_bug fix multi byte read
Dependencies: mbed
Fork of 161006_BDK_EEPROM by
Diff: main.cpp
- Branch:
- KSS
- Revision:
- 8:1921f56f6ee6
- Parent:
- 7:45b16ef560a9
- Child:
- 9:a9de8d19d55a
--- a/main.cpp Fri Oct 07 08:15:21 2016 +0000 +++ b/main.cpp Mon Oct 10 07:50:36 2016 +0000 @@ -1,3 +1,13 @@ +// firmware for CBEF746 +// ======== SPI Slave Pin +// PA5 - SCK +// PA6 - MISO +// PA7 - MOSI +// PA14 - SEL +// ======== I2C Pin for TPM +// PB9 - SDA +// PB8 - SCL + #include "mbed.h" #define DEBUG_SPI @@ -6,18 +16,24 @@ #define PRINTD(arg1,arg2...) printf(arg1,##arg2) #endif - +// ======== SPI Slave Pin define +/* +#define SPI_SCLK PA_5 +#define SPI_MISO PA_6 +#define SPI_MOSI PA_7 +#define SPI_SSEL PA_14 +*/ #define SPI_MOSI PA_7 #define SPI_MISO PA_6 #define SPI_SCLK PA_5 #define SPI_SSEL PA_4 -#define EEPROM_WREN 0x06 // Write Enable -#define EEPROM_WRDI 0x04 // Write Disable -#define EEPROM_RDSR 0x05 // Read Status Register -#define EEPROM_WRSR 0x01 // Write Status Register -#define EEPROM_READ 0x03 // Read EEPROM Memory -#define EEPROM_WRITE 0x02 // Write EEPROM Memory +#define EEPROM_WREN 0x06 // Write Enable +#define EEPROM_WRDI 0x04 // Write Disable +#define EEPROM_RDSR 0x05 // Read Status Register +#define EEPROM_WRSR 0x01 // Write Status Register +#define EEPROM_READ 0x03 // Read EEPROM Memory +#define EEPROM_WRITE 0x02 // Write EEPROM Memory #define EEPROM_MULTIREAD 0x07 // Read Multibyte EEPROM Memory SPISlave spi_slave(SPI_MOSI, SPI_MISO, SPI_SCLK, SPI_SSEL); // MOSI, MISO, SCLK(CLK), SSEL(CS)=NC @@ -224,18 +240,17 @@ // EEPROM_MULTIREAD.. while(!spi_slave.receive()); eepAddr = spi_slave.read(); - printf("[DEBUG] [M to S] eepAddr=0x%02x\n",eepAddr++); + //printf("[DEBUG] [M to S] eepAddr=0x%02x\n",eepAddr); - for(int i=0;i<7;i++) + for(int i=0;i<5;i++) { - //spi_slave.reply( eepBuf[eepAddr] ); - spi_slave.reply( i ); + spi_slave.reply( eepBuf[eepAddr++] ); + //++eepAddr; //printf("[0x%02x] ",spiMulti); - pc_serial.printf("."); - } - pc_serial.printf("\n"); + + printf("[DEBUG] [M to S] eepAddr=0x%02x\n",eepAddr++); break;