You are on page 1of 2

1 TFT9341_String(1,150,"Write Data

");
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

1 if(cur_page >= (pageCount - 1))


break;
2
}
3
TFT9341_String(1,176,"Done!");
4
HAL_GPIO_WritePin(GPIOG,
5 GPIO_PIN_13, GPIO_PIN_SET);

HAL_GPIO_WritePin(GPIOG,
GPIO_PIN_14, GPIO_PIN_SET);

Well, the time has finally come to check our work.


The PC program, as I think you understand, I have finalized and you can also download it
from the link at the bottom of this page.
Let's launch our program, respectively, having first collected our code for the controller and
flashed it, and first, as always, we count the service information so that the buttons we need
become active.
As we see on the display, information about the beginning and end of the process appeared
almost instantly due to its fast response

You might also like