本帖最后由 forgot 于 2023-11-11 17:57 编辑
为了对CW32L031 StartKit开发板实现拓展功能开发,决定采用OLED液晶显示SPI FLASH、I2C EEPROM、和ADC的测试过程; 首先在工程中添加OLED相关的.c和.h文件,在main中添加OLED_Configuration();OLED_Init();初始化函数; 因为采用的是PB12和PB13作为OLED的I2C线进行模拟时序,所以要增加这两个GPIO的初始化相关函数; #define OLED_SCLK_Clr() PB12_SETLOW();
#define OLED_SCLK_Set() PB12_SETHIGH();
#define OLED_SDIN_Clr() PB13_SETLOW();
#define OLED_SDIN_Set() PB13_SETHIGH();
添加.c相关文件:
还需要增加.h的路径:
在while(1)中各个TEST位置加入OLED信息打印,保留原来的串口LOG打印; OLED_Poweron();
while(1)
{
gKey2Status = 0;
//wait key is press
do
{
/* Toggle LED */
LED1_TOG;
SysTickDelay(1000); //1s.
}while (gKey2Status == 0);
//test start
printf("\r\nCW32F030 StartKit Board Test\r\n");
OLED_Show(0,"SPI TEST START","FLASH");
SPI_FLASH_Test();
SysTickDelay(1000);
OLED_Show(0,"I2C TEST START","EEPROM");
I2C_Test();
SysTickDelay(1000);
OLED_Show(0,"ADC TEST START","PA00");
ADC_Test();
SysTickDelay(1000);
OLED_Show(0,"TEST END","bbs.21ic.com");
printf("\r\nCW32F030 StartKit Board Test OK\r\n");
for(uint8_t j = 0; j < 3; j++)
{
LED1_OFF;
SysTickDelay(100);
LED1_ON;
SysTickDelay(100);
}
}
开机OLED显示,后面启动测试每隔开1S测试一个功能;
开机显示: **************** CW32L031 StartKit ****************
通过按钮启动测试后,先显示: SPI TEST START FLASH
间隔1s
FLASH测试完成之后显示: I2C TEST START EEPROM 间隔1s
EEPROM测试完成之后显示: ADC TEST START PA00 间隔1s
最后显示: TEST END
bbs.21ic.com
|