野火RA6M5开发板 IIC-OLED测试学习
野火RA6M5开发板,这里我使用的时SCI模块里面的SCL5 SDA5 ,配置引脚为P805,P513,配置的过程主要是在官方的e2studio去配置的,简单的点几下就可以了 具体参考下面的博客 野火RA6M5开发板,这里我使用的时SCI模块里面的SCL5 SDA5 ,配置引脚为P805,P513
- //--------------------------------------------------------------------------------------------------
- // 函数头文件 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
- //--------------------------------------------------------------------------------------------------
- #include "hal_data.h"
- #include "oled.h"
- #include "bmp.h"
- #include "bsp_debug_uart.h"
- #include "bsp_led.h"
- FSP_CPP_HEADER
- void R_BSP_WarmStart(bsp_warm_start_event_t event);
- FSP_CPP_FOOTER
- /* Callback function */
- i2c_master_event_t i2c_event = I2C_MASTER_EVENT_ABORTED;
- void sci_i2c_master_callback(i2c_master_callback_args_t *p_args)
- {
- i2c_event = I2C_MASTER_EVENT_ABORTED;
- if (NULL != p_args)
- {
- /* capture callback event for validating the i2c transfer event*/
- i2c_event = p_args->event;
- }
- }
- fsp_err_t err = FSP_SUCCESS;
- uint32_t timeout_ms = 1000;
- void Hardware_init(void)
- {
- Debug_UART4_Init(); // SCI4 UART 调试串口初始化
- printf("Debug-UART4-Init OK \r\n");
- LED_Init();
- printf("LED_Init OK \r\n");
- printf("IIC-Config OK \r\n");
- /* Initialize the I2C module */
- err = R_SCI_I2C_Open(&g_i2c5_ctrl, &g_i2c5_cfg);
- /* Handle any errors. This function should be defined by the user. */
- assert(FSP_SUCCESS == err);
- printf("IIC-Config OK \r\n");
- OLED_Init(); //初始化OLED
- OLED_Clear();
- printf("oled-Init OK \r\n");
- }
- /*******************************************************************************************************************//**
- * main() is generated by the RA Configuration editor and is used to generate threads if an RTOS is used. This function
- * is called by main() when no RTOS is used.
- **********************************************************************************************************************/
- void hal_entry(void)
- {
- /* TODO: add your own code here */
- Hardware_init();
- printf("RA6M5-Board-Init OK \r\n");
- while(1)
- {
- LED1_ON; // LED1亮
- LED2_ON; // LED2亮
- LED3_ON; // LED3亮
- R_BSP_SoftwareDelay(500, BSP_DELAY_UNITS_MILLISECONDS); //延时1秒
- LED1_OFF; // LED1灭
- LED2_OFF; // LED2灭
- LED3_OFF; // LED3灭
- R_BSP_SoftwareDelay(500, BSP_DELAY_UNITS_MILLISECONDS); //延时1秒
-
- printf("oled-Init OK \r\n");
- OLED_ShowCHinese(0,0,0);//瑞
- OLED_ShowCHinese(16,0,1);//萨
- OLED_ShowCHinese(32,0,5);//电
- OLED_ShowCHinese(48,0,6);//子
- OLED_ShowString(60,0,"Renesas",16);
- OLED_ShowNum(0,2,2023,4,16);//显示ASCII字符的码值
- OLED_ShowCHinese(32,2,2);//中文字->年
- OLED_ShowNum(48,2,5,2,16);//显示ASCII字符的码值
- OLED_ShowCHinese(64,2,3);//中文字->月
- OLED_ShowNum(80,2,12,2,16);//显示ASCII字符的码值
- OLED_ShowCHinese(96,2,4);//中文字->日
- OLED_ShowString(0,4,"By2023-CoderEnd",12);
- OLED_ShowString(0,5,"Embedfire-Board",12);
- OLED_ShowString(0,6,"R7FA6M5BH3CFC",16);
- R_BSP_SoftwareDelay(4, BSP_DELAY_UNITS_SECONDS); //延时1秒
- OLED_Clear();
- OLED_DrawBMP(0,0,64,8,BMP1);
- R_BSP_SoftwareDelay(4, BSP_DELAY_UNITS_SECONDS); //延时1秒
- OLED_Clear();
- }
- #if BSP_TZ_SECURE_BUILD
- /* Enter non-secure code */
- R_BSP_NonSecureEnter();
- #endif
- }
- /*******************************************************************************************************************//**
- * This function is called at various points during the startup process. This implementation uses the event that is
- * called right before main() to set up the pins.
- *
- * @param[in] event Where at in the start up process the code is currently at
- **********************************************************************************************************************/
- void R_BSP_WarmStart(bsp_warm_start_event_t event)
- {
- if (BSP_WARM_START_RESET == event)
- {
- #if BSP_FEATURE_FLASH_LP_VERSION != 0
- /* Enable reading from data flash. */
- R_FACI_LP->DFLCTL = 1U;
- /* Would normally have to wait tDSTOP(6us) for data flash recovery. Placing the enable here, before clock and
- * C runtime initialization, should negate the need for a delay since the initialization will typically take more than 6us. */
- #endif
- }
- if (BSP_WARM_START_POST_C == event)
- {
- /* C runtime environment and system clocks are setup. */
- /* Configure pins. */
- R_IOPORT_Open (&g_ioport_ctrl, g_ioport.p_cfg);
- }
- }
- #if BSP_TZ_SECURE_BUILD
- BSP_CMSE_NONSECURE_ENTRY void template_nonsecure_callable ();
- /* Trustzone Secure Projects require at least one nonsecure callable function in order to build (Remove this if it is not required to build). */
- BSP_CMSE_NONSECURE_ENTRY void template_nonsecure_callable ()
- {
- }
- #endif
复制代码 开发板测试效果图
|