this is my code in a mcu for spi ///////////////////////////////SPI0…
Jump to turn (9)
- 1this is my code in a mcu for spi ///////////////////////////////SPI0 write:regad
- 2char CRCen = "1"; warning: initialization of ‘char’ from ‘char ’ makes integer f
- 3char CRCen = “1”; warning: initialization of ‘char’ from ‘char ’ makes integer f
- 4#include #include #include #include #define regvalsize 2 // Define the size of t
- 5#include #include #include #include #define regvalsize 1 // Define the size of t
- 6#include #include #include #include #define regvalsize 1 // Define the size of t
- 7if (MFS == '1') { spiWrites[0] |= 0x01; // Set the first bit for FS } else { spi
- 8#include #include #include #include #define regvalsize 1 // Define the size of t
- 9getchar in c
- User
this is my code in a mcu for spi
///////////////////////////////SPI0 write:reg_add(2)+1+Value(2)+1+CRC(1)% void SPI_write(char* string){ uint8_t reg_ad = strtoul(Data_Read(0,string,";"), NULL, 16); uint32_t reg_val = strtoul(Data_Read(1,string,";"), NULL, 16); char CRC_en = *Data_Read(2,string,";");
codeuint8_t spi_Write[reg_val_size]; uint8_t spi_Write_s[reg_val_size+1]; for (uint8_t i = 0; i < reg_val_size; i++){ spi_Write[reg_val_size - i - 1] = (reg_val >> (8 * i)) & 0xFF; } for (int x = reg_val_size; x >= 0; x--){ spi_Write_s[x + 1] = spi_Write[x]; } spi_Write_s[0] = reg_ad; spi_Write_s[0] = spi_Write_s[0] << 1; spi_Write_s[0] |= 0x01; SPI_WriteReg(SPI0, spi_Write_s, reg_val_size + 1); printf("0x%x is written to register 0x%x \n\r", reg_val, reg_ad);}
I would like to use a online compilar to check this code, reg ad is 0x08 and reg_val is 0x12, could you generate it for me
- Assistant