diff --git a/app/MDK-ARM/app.uvguix.29643 b/app/MDK-ARM/app.uvguix.29643 index bf2c697..99af49f 100644 --- a/app/MDK-ARM/app.uvguix.29643 +++ b/app/MDK-ARM/app.uvguix.29643 @@ -93,8 +93,8 @@ 0 1 - -1 - -1 + -32000 + -32000 -1 diff --git a/usersrc/usermain.c b/usersrc/usermain.c index a921507..84f7fd8 100644 --- a/usersrc/usermain.c +++ b/usersrc/usermain.c @@ -8,13 +8,13 @@ #define READ_CMD 0x80 #define SPI_TIMEOUT_VALUE 1000 -#define SPI_CS_1() HAL_GPIO_WritePin(SEL_GPIO_Port, SEL_Pin, GPIO_PIN_SET) /* */ -#define SPI_CS_0() HAL_GPIO_WritePin(SEL_GPIO_Port, SEL_Pin, GPIO_PIN_RESET) /* */ -#define SPI_SCK_1() HAL_GPIO_WritePin(CLK_GPIO_Port, CLK_Pin, GPIO_PIN_SET) /* SCK = 1 */ -#define SPI_SCK_0() HAL_GPIO_WritePin(CLK_GPIO_Port, CLK_Pin, GPIO_PIN_RESET) /* SCK = 0 */ -#define SPI_MOSI_1() HAL_GPIO_WritePin(MOSI_GPIO_Port, MOSI_Pin, GPIO_PIN_SET) /* MOSI = 1 */ -#define SPI_MOSI_0() HAL_GPIO_WritePin(MOSI_GPIO_Port, MOSI_Pin, GPIO_PIN_RESET) /* MOSI = 0 */ -#define SPI_READ_MISO() HAL_GPIO_ReadPin(MISO_GPIO_Port, MISO_Pin) /* 读MISO口线状态 */ +#define SPI_CS_1() HAL_GPIO_WritePin(SEL_GPIO_Port, SEL_Pin, GPIO_PIN_SET) /* */ +#define SPI_CS_0() HAL_GPIO_WritePin(SEL_GPIO_Port, SEL_Pin, GPIO_PIN_RESET) /* */ +#define SPI_SCK_1() HAL_GPIO_WritePin(CLK_GPIO_Port, CLK_Pin, GPIO_PIN_SET) /* SCK = 1 */ +#define SPI_SCK_0() HAL_GPIO_WritePin(CLK_GPIO_Port, CLK_Pin, GPIO_PIN_RESET) /* SCK = 0 */ +#define SPI_MOSI_1() HAL_GPIO_WritePin(MOSI_GPIO_Port, MOSI_Pin, GPIO_PIN_SET) /* MOSI = 1 */ +#define SPI_MOSI_0() HAL_GPIO_WritePin(MOSI_GPIO_Port, MOSI_Pin, GPIO_PIN_RESET) /* MOSI = 0 */ +#define SPI_READ_MISO() HAL_GPIO_ReadPin(MISO_GPIO_Port, MISO_Pin) /* 读MISO口线状态 */ #define Dummy_Byte 0xFF // 读取时MISO发送的数据,可以为任意数据 @@ -32,8 +32,8 @@ typedef enum uint8_t table[SPI_TYPE_NUMBER][spi_table_type_size] = { {1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1}, // sel - {1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, // sck - {1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, // mosi + {1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, // sck + {1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, // mosi {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, // miso }; @@ -77,7 +77,7 @@ void set_spi_table_sck(uint8_t startoff) { table[SPI_SCK_TYPE][i] = 1; } - else if (i >= startoff && i < (startoff + 32)) + else if (i >= startoff && i < (startoff + 16)) { (clocklevel) ? (table[SPI_SCK_TYPE][i] = 1) : (table[SPI_SCK_TYPE][i] = 0); @@ -108,8 +108,8 @@ void set_spi_table_mosi(uint8_t startoff, uint8_t txdata) } else if ((i >= startoff + 16) && (i < (startoff + 32))) { - table[SPI_MOSI_TYPE][i] = 0; - table[SPI_MOSI_TYPE][i + 1] = 0; + table[SPI_MOSI_TYPE][i] = 1; + table[SPI_MOSI_TYPE][i + 1] = 1; } else { @@ -126,8 +126,8 @@ void dotable(uint8_t txdata) int mosi_startoff = 4; set_spi_table_sel(sel_startoff); - set_spi_table_sck(clock_startoff); - set_spi_table_mosi(mosi_startoff, txdata); + // set_spi_table_sck(clock_startoff); + // set_spi_table_mosi(mosi_startoff, txdata); for (size_t i = 0; i < spi_table_type_size; i++) {