Professional Documents
Culture Documents
Ss4 Magazine
Ss4 Magazine
");
2
pageCount = *(unsigned
3 int*)(rx_buf);
4 pageSize = *(unsigned
int*)(rx_buf + 4);
5
dt1[0] = 0xAA;
HAL_UART_Transmit(&huart1,(uint8_t*)dt1
,1,0x1000);
Then we will add an endless loop, in which we will receive from the computer the number of
the page to be written, the bytes of the page, write these bytes into the chip and send the
computer a command to finish writing the page, and if this is the last page, then we will exit the
endless loop.
1
HAL_UART_Transmit(&huart1,(uint8_t*)dt1
2 ,1,0x1000);
3 while(1)
4 {
5
HAL_UART_Receive(&huart1,(uint8_t*)rx_b
6
uf,4,0x1000);
7
cur_page = *(unsigned
8 int*)(rx_buf);
9
HAL_UART_Receive(&huart1,(uint8_t*)rx_b
10 uf,256,0x1000);
11 W25_Write_Page(rx_buf,
cur_page, 0, pageSize);
dt1[0] = 0xEE;
HAL_UART_Transmit(&huart1,(uint8_t*)dt1
,1,0x1000);
if(cur_page >= (pageCount - 1))
break;
After this cycle, as usual, we will report the end of the process and light the LEDs
HAL_GPIO_WritePin(GPIOG,
GPIO_PIN_14, GPIO_PIN_SET);