TL-LED

  • 2024-10-05
  • 发表了主题帖: 【瑞萨RA8D1板卡】 LCD显示测试

    测试LCD显示屏。   一、电路图部分   LCD相关的引脚定义   二、配置LCD显示屏参数   2.1、添加显示屏组件   2.2、设置参数   2.2.1、设置显示屏分辨率和颜色格式   2.2.2、设置显示屏时序 根据显示屏参数,设置时序   三、程序部分   hal_entry.c /* * Copyright (c) 2020 - 2024 Renesas Electronics Corporation and/or its affiliates * * SPDX-License-Identifier: BSD-3-Clause */ #include "hal_data.h" #include "led/led.h" #include "debug_uart/bsp_debug_uart.h" #include "sdram/board_sdram.h" //#include "ospi_flash/bsp_ospi_flash.h" #include "common_utils.h" #include "glcdc_ep.h" fsp_err_t err; void R_BSP_WarmStart(bsp_warm_start_event_t event); /* Variables to store resolution information */ uint16_t g_hz_size, g_vr_size; /* Variables used for buffer usage */ uint32_t g_buffer_size; uint8_t * g_p_single_buffer, * g_p_double_buffer; /* User defined functions */ #ifndef BOARD_RA8D1_CPKCOR static void screen_display(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color); #else static void screen_display(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint32_t color); #endif static void color_band_display(void); /*******************************************************************************************************************//** * [url=home.php?mod=space&uid=159083]@brief[/url] Blinky example application * * Blinks all leds at a rate of 1 second using the software delay function provided by the BSP. * **********************************************************************************************************************/ void hal_entry (void) { fsp_err_t err = FSP_SUCCESS; fsp_pack_version_t version = {RESET_VALUE}; R_FSP_VersionGet(&version); init_led(); Debug_UART3_Init(); bsp_sdram_init(); /* Get LCDC configuration */ g_hz_size = (g_display_cfg.input[0].hsize); g_vr_size = (g_display_cfg.input[0].vsize); /* Initialize buffer pointers */ g_buffer_size = (uint32_t) (g_hz_size * g_vr_size * BYTES_PER_PIXEL); g_p_single_buffer = (uint8_t *) g_display_cfg.input[0].p_base; /* Double buffer for drawing color bands with good quality */ g_p_double_buffer = g_p_single_buffer + g_buffer_size; /* Initialize GLCDC driver */ err = R_GLCDC_Open(&g_display_ctrl, &g_display_cfg); /* Start GLCDC display output */ err = R_GLCDC_Start(&g_display_ctrl); /* Clear LCD screen using appropriate co-ordinates */ screen_display((uint16_t)X1_CO_ORDINATE, (uint16_t)Y1_CO_ORDINATE, g_hz_size, g_vr_size, BLACK); /* Display color bands on LCD screen */ color_band_display(); while (1) { /* Delay */ //R_BSP_SoftwareDelay(delay, bsp_delay_units); R_BSP_SoftwareDelay(100, BSP_DELAY_UNITS_MILLISECONDS); led201_on(); R_BSP_SoftwareDelay(100, BSP_DELAY_UNITS_MILLISECONDS); led201_off(); } } #ifndef BOARD_RA8D1_CPKCOR static void screen_display(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color) { /*Declare local variables */ uint16_t start_x, start_y, display_length, display_height; uint32_t start_addr; /* Assign co-ordinate values and calculate start address */ start_x = x1; start_y = y1; start_addr = (uint32_t)((start_x * BYTES_PER_PIXEL) + (start_y * g_hz_size* BYTES_PER_PIXEL)); /* Calculate display box length and height */ display_length = (uint16_t)((x2 - x1) * BYTES_PER_PIXEL); display_height = (y2 - y1); /* Display required color band */ for(uint16_t ver_value = Y1_CO_ORDINATE; ver_value < (display_height - INC_DEC_VALUE); ver_value++) { for(uint32_t hor_value = start_addr; hor_value < (start_addr + display_length); hor_value += BYTES_PER_PIXEL) { *(uint16_t *) (g_p_single_buffer + hor_value) = color; *(uint16_t *) (g_p_double_buffer + hor_value) = color; } start_addr = (uint32_t)(start_addr + (g_hz_size * BYTES_PER_PIXEL)); } } #else static void screen_display(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint32_t color) { /*Declare local variables */ uint16_t start_x, start_y, display_length, display_height; uint32_t start_addr; /* Assign co-ordinate values and calculate start address */ start_x = x1; start_y = y1; start_addr = (uint32_t)((start_x * BYTES_PER_PIXEL) + (start_y * g_hz_size* BYTES_PER_PIXEL)); /* Calculate display box length and height */ display_length = (uint16_t)((x2 - x1) * BYTES_PER_PIXEL); display_height = (y2 - y1); /* Display required color band */ for(uint16_t ver_value = Y1_CO_ORDINATE; ver_value < (display_height - INC_DEC_VALUE); ver_value++) { for(uint32_t hor_value = start_addr; hor_value < (start_addr + display_length); hor_value += BYTES_PER_PIXEL) { *(uint32_t *) (g_p_single_buffer + hor_value) = color; *(uint32_t *) (g_p_double_buffer + hor_value) = color; } start_addr = (uint32_t)(start_addr + (g_hz_size * BYTES_PER_PIXEL)); } } #endif /*******************************************************************************************************************//** * @brief This function display eight color band horizontally on Graphical LCD . * @param[IN] None * @retval None ***********************************************************************************************************************/ static void color_band_display(void) { #ifndef BOARD_RA8D1_CPKCOR uint16_t color[COLOR_BAND_COUNT]= {RED, GREEN, BLUE, BLACK, WHITE, YELLOW, MAGENTA, CYAN}; #else uint32_t color[COLOR_BAND_COUNT]= {RED, GREEN, BLUE, BLACK, WHITE, YELLOW, MAGENTA, CYAN}; #endif uint16_t width = g_vr_size/COLOR_BAND_COUNT; for (uint8_t display_count = RESET_VALUE; display_count < COLOR_BAND_COUNT; display_count++) { screen_display((uint16_t)X1_CO_ORDINATE, (display_count * width), g_hz_size, (uint16_t)(((display_count * width) + width) + INC_DEC_VALUE), color[display_count]); } } /*******************************************************************************************************************//** * 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(&IOPORT_CFG_CTRL, &IOPORT_CFG_NAME); } }   四、运行结果   运行后,显示屏显示  

  • 2024-09-23
  • 发表了主题帖: 【瑞萨RA8D1板卡】 AT25SF128 FLASH读写测试

    测试AT25SF128 FLASH读写。   一、硬件电路图 开发板AT25SF128部分电路图   二、软件配置   2.1、添加SPI   2.2、配置SPI引脚   2.3、根据FLASH芯片设置此参数   三、程序代码   3.1、main.c #include "hal_data.h" #include "led/led.h" #include "debug_uart/bsp_debug_uart.h" #include "sdram/board_sdram.h" #include "ospi_flash/bsp_ospi_flash.h" #include "common_utils.h" fsp_err_t err; void R_BSP_WarmStart(bsp_warm_start_event_t event); /*******************************************************************************************************************//** * [url=home.php?mod=space&uid=159083]@brief[/url] Blinky example application * * Blinks all leds at a rate of 1 second using the software delay function provided by the BSP. * **********************************************************************************************************************/ void hal_entry (void) { fsp_err_t err = FSP_SUCCESS; fsp_pack_version_t version = {RESET_VALUE}; uint32_t flash_id = RESET_VALUE; uint8_t * p_ospi_b_address = NULL; init_led(); Debug_UART3_Init(); //bsp_sdram_init(); err = ospi_b_init(); /* Read Flash device ID */ err = ospi_b_read_device_id(&flash_id); printf("ID:%lx\r\n",flash_id); /* 选择Flash 测试地址 */ p_ospi_b_address = OSPI_B_APP_ADDRESS(OSPI_B_SECTOR_FIRST); /* Flash 读写操作测试 */ ospi_b_operation(p_ospi_b_address); while (1) { R_BSP_SoftwareDelay(100, BSP_DELAY_UNITS_MILLISECONDS); led201_on(); R_BSP_SoftwareDelay(100, BSP_DELAY_UNITS_MILLISECONDS); led201_off(); } }   3.2、bsp_ospi_flash.c #include "ospi_flash/bsp_ospi_flash.h" #include "stdio.h" #include "ospi_flash/ospi_b_commands.h" #include "common_utils.h" extern spi_flash_direct_transfer_t g_ospi_b_direct_transfer [OSPI_B_TRANSFER_MAX]; /* Global variables */ uint8_t g_read_data [OSPI_B_APP_DATA_SIZE] = {RESET_VALUE}; const uint8_t g_write_data [OSPI_B_APP_DATA_SIZE] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, }; fsp_err_t ospi_b_read_device_id (uint32_t * const p_id) { fsp_err_t err = FSP_SUCCESS; spi_flash_direct_transfer_t transfer = {RESET_VALUE}; /* Read and check flash device ID */ transfer = g_ospi_b_direct_transfer[OSPI_B_TRANSFER_READ_DEVICE_ID_SPI]; err = R_OSPI_B_DirectTransfer(&g_ospi_flash_ctrl, &transfer, SPI_FLASH_DIRECT_TRANSFER_DIR_READ); if(err!=FSP_SUCCESS) { printf("R_OSPI_B_DirectTransfer API FAILED \r\n"); } /* Get flash device ID */ *p_id = transfer.data; return err; } /*******************************************************************************************************************//** * @brief This functions enables write and verify the read data. * @param None * @retval FSP_SUCCESS Upon successful operation * @retval FSP_ERR_ABORTED Upon incorrect read data. * @retval Any Other Error code apart from FSP_SUCCESS Unsuccessful operation **********************************************************************************************************************/ static fsp_err_t ospi_b_write_enable (void) { fsp_err_t err = FSP_SUCCESS; spi_flash_direct_transfer_t transfer = {RESET_VALUE}; /* Transfer write enable command */ transfer = g_ospi_b_direct_transfer[OSPI_B_TRANSFER_WRITE_ENABLE_SPI]; err = R_OSPI_B_DirectTransfer(&g_ospi_flash_ctrl, &transfer, SPI_FLASH_DIRECT_TRANSFER_DIR_WRITE); /* Read Status Register */ transfer = g_ospi_b_direct_transfer[OSPI_B_TRANSFER_READ_STATUS_SPI]; err = R_OSPI_B_DirectTransfer(&g_ospi_flash_ctrl, &transfer, SPI_FLASH_DIRECT_TRANSFER_DIR_READ); /* Check Write Enable bit in Status Register */ if(OSPI_B_WEN_BIT_MASK != (transfer.data & OSPI_B_WEN_BIT_MASK)) { printf("Write enable FAILED\r\n"); } return err; } /*******************************************************************************************************************//** * @brief This function wait until OSPI operation completes. * @param[in] timeout Maximum waiting time * @retval FSP_SUCCESS Upon successful wait OSPI operating * @retval FSP_ERR_TIMEOUT Upon time out * @retval Any Other Error code apart from FSP_SUCCESS Unsuccessful operation. **********************************************************************************************************************/ static fsp_err_t ospi_b_wait_operation (uint32_t timeout) { fsp_err_t err = FSP_SUCCESS; spi_flash_status_t status = {RESET_VALUE}; status.write_in_progress = true; while (status.write_in_progress) { /* Get device status */ R_OSPI_B_StatusGet(&g_ospi_flash_ctrl, &status); if(RESET_VALUE == timeout) { printf("OSPI time out occurred\r\n"); } R_BSP_SoftwareDelay(1, OSPI_B_TIME_UNIT); timeout --; } return err; } /********************************************************************************************************************** * @brief This function performs an erase sector operation on the flash device. * @param[in] *p_address Pointer to flash device memory address * @param[out] *p_time Pointer will be used to store execute time * @retval FSP_SUCCESS Upon successful erase operation * @retval Any Other Error code apart from FSP_SUCCESS Unsuccessful operation **********************************************************************************************************************/ static fsp_err_t ospi_b_erase_operation (uint8_t * const p_address) { fsp_err_t err = FSP_SUCCESS; uint32_t sector_size = RESET_VALUE; uint32_t erase_timeout = RESET_VALUE; /* Check sector size according to input address pointer, described in S28HS512T data sheet */ if(OSPI_B_SECTOR_4K_END_ADDRESS < (uint32_t)p_address) { sector_size = OSPI_B_SECTOR_SIZE_256K; erase_timeout = OSPI_B_TIME_ERASE_256K; } else { sector_size = OSPI_B_SECTOR_SIZE_4K; erase_timeout = OSPI_B_TIME_ERASE_4K; } /* Performs erase sector */ err = R_OSPI_B_Erase(&g_ospi_flash_ctrl, p_address, sector_size); /* Wait till operation completes */ err = ospi_b_wait_operation(erase_timeout); return err; } /********************************************************************************************************************** * @brief This function performs an write operation on the flash device. * @param[in] *p_address Pointer to flash device memory address * @param[out] *p_time Pointer will be used to store execute time * @retval FSP_SUCCESS Upon successful write operation * @retval Any Other Error code apart from FSP_SUCCESS Unsuccessful operation **********************************************************************************************************************/ static fsp_err_t ospi_b_write_operation (uint8_t * const p_address) { fsp_err_t err = FSP_SUCCESS; /* Erase sector before write data to flash device */ err = ospi_b_erase_operation(p_address); /* Write data to flash device */ err = R_OSPI_B_Write(&g_ospi_flash_ctrl, g_write_data, p_address, OSPI_B_APP_DATA_SIZE); /* Wait until write operation completes */ err = ospi_b_wait_operation(OSPI_B_TIME_WRITE); return err; } /********************************************************************************************************************** * @brief This function performs an read operation on the flash device. * @param[in] *p_address Pointer to flash device memory address * @param[out] *p_time Pointer will be used to store execute time * @retval FSP_SUCCESS Upon successful read operation * @retval Any Other Error code apart from FSP_SUCCESS Unsuccessful operation **********************************************************************************************************************/ static fsp_err_t ospi_b_read_operation (uint8_t * const p_address) { fsp_err_t err = FSP_SUCCESS; /* Clean read buffer */ memset(&g_read_data, RESET_VALUE, OSPI_B_APP_DATA_SIZE); /* Read data from flash device */ memcpy(&g_read_data, p_address, OSPI_B_APP_DATA_SIZE); return err; } /*******************************************************************************************************************//** * @brief This functions initializes OSPI module and Flash device. * @param None * @retval FSP_SUCCESS Upon successful initialization of OSPI module and Flash device * @retval Any Other Error code apart from FSP_SUCCESS Unsuccessful open **********************************************************************************************************************/ fsp_err_t ospi_b_init (void) { /* By default, the flash device is in SPI mode, so it is necessary to open the OSPI module in SPI mode */ fsp_err_t err = FSP_SUCCESS; /* Open OSPI module */ err = R_OSPI_B_Open(&g_ospi_flash_ctrl, &g_ospi_flash_cfg); /* Switch OSPI module to 1S-1S-1S mode to configure flash device */ err = R_OSPI_B_SpiProtocolSet(&g_ospi_flash_ctrl, SPI_FLASH_PROTOCOL_EXTENDED_SPI); /* Reset flash device by driving OM_RESET pin */ R_XSPI->LIOCTL_b.RSTCS0 = 0; R_BSP_SoftwareDelay(OSPI_B_TIME_RESET_PULSE, OSPI_B_TIME_UNIT); R_XSPI->LIOCTL_b.RSTCS0 = 1; R_BSP_SoftwareDelay(OSPI_B_TIME_RESET_SETUP, OSPI_B_TIME_UNIT); /* Transfer write enable command */ err = ospi_b_write_enable(); return err; } fsp_err_t ospi_b_operation (uint8_t * p_address) { fsp_err_t err = FSP_SUCCESS; uint16_t i = 0; err = ospi_b_erase_operation(p_address); if(err==FSP_SUCCESS) { printf("Write %d bytes completed successfully\r\n", (int)(OSPI_B_APP_DATA_SIZE)); } else { printf("Write operation failure\r\n"); } printf("Write Data:\r\n"); for(i=0;i<=OSPI_B_APP_DATA_SIZE-1;i++) { printf("%d ",g_write_data[i]); } err = ospi_b_read_operation (p_address); if(err==FSP_SUCCESS) { /* Print execution time */ printf("\r\nRead %d bytes completed successfully\r\n", (int)(OSPI_B_APP_DATA_SIZE)); } else { printf("\r\nRead operation failure\r\n"); } printf("Read Data:\r\n"); for(i=0;i<=sizeof(g_read_data)-1;i++) { printf("%d ",g_read_data[i]); } if(RESET_VALUE == memcmp(&g_read_data, &g_write_data, (size_t)OSPI_B_APP_DATA_SIZE)) { printf("\r\nData read matched data written\r\n"); printf("flash读写数据成功\r\n"); } else { printf("\r\nData read does not match data written\r\n"); printf("flash读写数据失败\r\n"); } /* Performs OSPI erase operation */ err = ospi_b_erase_operation(p_address); if(err==FSP_SUCCESS) { /* Print execution time */ printf("Erase sector completed successfully\r\n"); } else { printf("erase operation failure\r\n"); } return err; }   四、运行结果   读写数据测试结果  

  • 回复了主题帖: 【匠芯创D133CBS】 RS485通信测试

    yangjiaxu 发表于 2024-9-23 09:40 也就是进入到me,配置串口1为rs485 compact io 即可是么?这个我配置成功了,并且我用的是官方的原hellow ... 我是复制例程的代码,在此基础上修改,重新命名的。

  • 回复了主题帖: 【匠芯创D133CBS】 RS485通信测试

    yangjiaxu 发表于 2024-9-23 00:20 大佬,这个例程我也试了一下,但是用串口ttl发送test_uart_sample提示我没有这个命令,是我这个函数没包含 ... 默认例程是没有打开的,需要在menuconfig中,打开此例程。

  • 2024-09-11
  • 发表了主题帖: 【匠芯创D133CBS】I2C驱动OLED显示屏

    本帖最后由 TL-LED 于 2024-9-11 23:33 编辑 测试I2C接口,驱动OLED显示屏。   一、硬件电路   电路板上方面外部连接的I2C端口就是J11插件对应的I2C0。 1.1、I2C0接口电路图部分 1.2、硬件连接图   二、配置I2C   2.1、打开I2C0   2.2、使能I2C驱动调试和例程   三、配置第三方库   3.1、选择SSD1306库   3.2、选择I2C0和使能测试例程   选择完成后 ,执行命令pkgs --update跟新库文件 下载完成后,会在packages目录下找到源文件   四、程序   4.1、ssd1306_tests.c /* * Copyright (c) 2020, RudyLo <luhuadong@163.com> * * SPDX-License-Identifier: MIT License * * Change Logs: * Date Author Notes * 2020-11-15 luhuadong the first version */ #include <rtthread.h> #include <rtdevice.h> #include <board.h> #include <string.h> #include <stdio.h> #include "ssd1306.h" #include "ssd1306_tests.h" void ssd1306_TestBorder() { ssd1306_Fill(Black); uint32_t start = rt_tick_get(); uint32_t end = start; uint8_t x = 0; uint8_t y = 0; do { ssd1306_DrawPixel(x, y, Black); if((y == 0) && (x < 127)) x++; else if((x == 127) && (y < 63)) y++; else if((y == 63) && (x > 0)) x--; else y--; ssd1306_DrawPixel(x, y, White); ssd1306_UpdateScreen(); rt_thread_mdelay(5); end = rt_tick_get(); } while((end - start) < 8000); rt_thread_mdelay(1000); } void ssd1306_TestFonts() { ssd1306_Fill(Black); ssd1306_SetCursor(2, 0); ssd1306_WriteString("Font 16x26", Font_16x26, White); ssd1306_SetCursor(2, 26); ssd1306_WriteString("Font 11x18", Font_11x18, White); ssd1306_SetCursor(2, 26+18); ssd1306_WriteString("Font 7x10", Font_7x10, White); ssd1306_SetCursor(2, 26+18+10); ssd1306_WriteString("Font 6x8", Font_6x8, White); ssd1306_UpdateScreen(); } void ssd1306_TestFPS() { ssd1306_Fill(White); uint32_t start = rt_tick_get(); uint32_t end = start; int fps = 0; char message[] = "ABCDEFGHIJK"; ssd1306_SetCursor(2,0); ssd1306_WriteString("Testing...", Font_11x18, Black); do { ssd1306_SetCursor(2, 18); ssd1306_WriteString(message, Font_11x18, Black); ssd1306_UpdateScreen(); char ch = message[0]; memmove(message, message+1, sizeof(message)-2); message[sizeof(message)-2] = ch; fps++; end = rt_tick_get(); } while((end - start) < 5000); rt_thread_mdelay(1000); char buff[64]; fps = (float)fps / ((end - start) / 1000.0); snprintf(buff, sizeof(buff), "~%d FPS", fps); ssd1306_Fill(White); ssd1306_SetCursor(2, 18); ssd1306_WriteString(buff, Font_11x18, Black); ssd1306_UpdateScreen(); } void ssd1306_TestLine() { ssd1306_Line(1,1,SSD1306_WIDTH - 1,SSD1306_HEIGHT - 1,White); ssd1306_Line(SSD1306_WIDTH - 1,1,1,SSD1306_HEIGHT - 1,White); ssd1306_UpdateScreen(); return; } void ssd1306_TestRectangle() { uint32_t delta; for(delta = 0; delta < 5; delta ++) { ssd1306_DrawRectangle(1 + (5*delta),1 + (5*delta) ,SSD1306_WIDTH-1 - (5*delta),SSD1306_HEIGHT-1 - (5*delta),White); } ssd1306_UpdateScreen(); return; } void ssd1306_TestCircle() { uint32_t delta; for(delta = 0; delta < 5; delta ++) { ssd1306_DrawCircle(20* delta+30, 30, 10, White); } ssd1306_UpdateScreen(); return; } void ssd1306_TestArc() { ssd1306_DrawArc(30, 30, 30, 20, 270, White); ssd1306_UpdateScreen(); return; } void ssd1306_TestPolyline() { SSD1306_VERTEX loc_vertex[] = { {35,40}, {40,20}, {45,28}, {50,10}, {45,16}, {50,10}, {53,16} }; ssd1306_Polyline(loc_vertex,sizeof(loc_vertex)/sizeof(loc_vertex[0]),White); ssd1306_UpdateScreen(); return; } void ssd1306_TestAll() { ssd1306_Init(); ssd1306_TestFPS(); rt_thread_mdelay(3000); ssd1306_TestBorder(); ssd1306_TestFonts(); rt_thread_mdelay(3000); ssd1306_Fill(Black); ssd1306_TestRectangle(); ssd1306_TestLine(); rt_thread_mdelay(3000); ssd1306_Fill(Black); ssd1306_TestPolyline(); rt_thread_mdelay(3000); ssd1306_Fill(Black); ssd1306_TestArc(); rt_thread_mdelay(3000); ssd1306_Fill(Black); ssd1306_TestCircle(); rt_thread_mdelay(3000); ssd1306_Fill(Black); ssd1306_SetCursor(0, 0); ssd1306_WriteString("MCU:D133CBS", Font_11x18, White); ssd1306_SetCursor(0, 20); ssd1306_WriteString("I2C:OLED", Font_11x18, White); ssd1306_UpdateScreen(); rt_thread_mdelay(3000); } #ifdef FINSH_USING_MSH MSH_CMD_EXPORT(ssd1306_TestAll, test ssd1306 oled driver); #endif   4.2、ssd1306_tests.h /* * Copyright (c) 2020, RudyLo <luhuadong@163.com> * * SPDX-License-Identifier: MIT License * * Change Logs: * Date Author Notes * 2020-11-15 luhuadong the first version */ #ifndef __SSD1306_TEST_H__ #define __SSD1306_TEST_H__ #include <_ansi.h> _BEGIN_STD_C void ssd1306_TestBorder(void); void ssd1306_TestFonts(void); void ssd1306_TestFPS(void); void ssd1306_TestAll(void); void ssd1306_TestLine(void); void ssd1306_TestRectangle(void); void ssd1306_TestCircle(void); void ssd1306_TestArc(void); void ssd1306_TestPolyline(void); _END_STD_C #endif // __SSD1306_TEST_H__   五、程序运行   下载程序后,串口终端执行ssd1306_TestAll,显示如下视频 [localvideo]611fe0121d6af809710bcba4fb4516db[/localvideo]  

  • 2024-09-07
  • 发表了主题帖: 【匠芯创D133CBS】linux编译环境搭建

      一、下载源码   1.1、获取源码 执行命令:root@ThinkPad:/opt# git clone https://gitee.com/artinchip/luban-lite.git   1.2、更新资源库   1.3、安装scons root@ThinkPad:/opt/luban-lite# cd tools/env/local_pkgs/ root@ThinkPad:/opt/luban-lite/tools/env/local_pkgs# tar xvf scons-3.1.2.tar.gz root@ThinkPad:/opt/luban-lite/tools/env/local_pkgs/scons-3.1.2# python3 setup.py install   1.4、安装 pycryptodomex root@ThinkPad:/opt/luban-lite# apt-get install pip root@ThinkPad:/opt/luban-lite# cd tools/env/local_pkgs/ root@ThinkPad:/opt/luban-lite/tools/env/local_pkgs# tar xvf pycryptodomex-3.11.0.tar.gz root@ThinkPad:/opt/luban-lite/tools/env/local_pkgs/pycryptodomex-3.11.0# python3 setup.py install   二、编译SDK root@ThinkPad:/opt/luban-lite# scons --list-def root@ThinkPad:/opt/luban-lite# scons --apply-def=11   root@ThinkPad:/opt/luban-lite# scons   编译成功  

  • 2024-09-02
  • 发表了主题帖: 【匠芯创D133CBS】以太网接口测试

    按照教程来学习下开发板以太网接口的测试。   一、硬件电路   以太网接口部分电路图 二、以太网配置 2.1、以太网接口配置   2.2、协议配置   使能ping   三、运行结果   编译后,下载到开发板,测试以太网同通信如下:   3.1、网络连接 上电后,串口打印出网络信息和网络连接状态   3.2、ping网络IP   ping局域网IP地址成功      

  • 2024-09-01
  • 发表了主题帖: 【匠芯创D133CBS】 RTC测试

    RTC时钟测试。   一、硬件部分   CPU内部集成RTC部分,需要外接晶振,电路部分如下:     二、程序部分   rtc.c //rtc.c #include <stdio.h> #include <stdlib.h> #include <string.h> #include <getopt.h> #include <sys/time.h> #include <rtthread.h> #include "rtdevice.h" #include <aic_core.h> #include "hal_adcim.h" #include "aic_log.h" #include "hal_gpai.h" #define AIC_RTC_NAME "rtc" time_t timestamp; static void rtc_read_hdl(void *parmeter) { while (1) { struct tm *tm_local = localtime(&timestamp); // 转换为本地时间 // 打印日期和时间 rt_kprintf("current date and time: %d-%02d-%02d %02d:%02d:%02d\n", tm_local->tm_year + 1900, tm_local->tm_mon + 1, tm_local->tm_mday, tm_local->tm_hour, tm_local->tm_min, tm_local->tm_sec); rt_thread_mdelay(1000); } } int test_rtc_sample(void) { rt_thread_t rtc_thread; rt_device_t rtc_dev = RT_NULL; rt_err_t ret; rtc_dev = rt_device_find(AIC_RTC_NAME); if(rtc_dev == RT_NULL) { rt_kprintf("Failed to open %s device\n", AIC_RTC_NAME); return -RT_ERROR; } ret = rt_device_control(rtc_dev, RT_DEVICE_CTRL_RTC_GET_TIME, &timestamp); if(ret != RT_EOK) { rt_kprintf("get time fail\n"); return -RT_ERROR; } rtc_thread = rt_thread_create( "test_rtc", rtc_read_hdl, "rtc", 2048, RT_THREAD_PRIORITY_MAX/2, 25); if(rtc_thread != RT_NULL) { rt_thread_startup(rtc_thread); } return RT_EOK; } MSH_CMD_EXPORT_ALIAS(test_rtc_sample, test_rtc_sample, rtc device sample);   三、运行结果 读取RTC日期和时间,通过串口打印输出   3.1、设置时间 执行 date 2024 09 01 22 08 00,设置目前时间   3.2、运行例程 执行例程 test_rtc_sample,串口输出读取的日期和时间  

  • 2024-08-31
  • 发表了主题帖: 【匠芯创D133CBS】 RS485通信测试

    测试板卡上的RS485通信,通过命令来控制蜂鸣器开关。   一、硬件电路图   RS485部分电路图   二、外设配置   RS485采用2线制通信,在串口配置成RS485方式,配置如下: 2.1、使能串口1   2.2、选择RS485两线模式   三、程序   3.1、uart.c //uart.c #include <getopt.h> #include <string.h> #include <rtthread.h> #include <aic_core.h> #include "beep.h" #define SAMPLE_UART_NAME "uart1" #define TIMEOUT_NONE -4096 static struct rt_semaphore rx_sem; static rt_device_t serial; static char str_send[] = "https://www.eeworld.com.cn/\n"; uint8_t g_recv_max = 128; static int g_uart_test_result = 1; static int g_exit = 0; static int g_timeout = TIMEOUT_NONE; static rt_timer_t uart1_rx_timeout = RT_NULL; char str_receive[128 + 1] = {0}; typedef struct { uint8_t buf[128]; uint8_t len; uint8_t rx_over; } uart_rx_dat_t; uart_rx_dat_t uart1_rx_dat = { 0 }; static void uart1_rx_timeout_cb(void *p) { rt_timer_stop(uart1_rx_timeout); rt_kprintf("read_length: %d \n", uart1_rx_dat.len); uart1_rx_dat.rx_over = RT_TRUE; } rt_err_t uart1_input(rt_device_t dev, rt_size_t size) { char ch; //rt_sem_release(&rx_sem); if(rt_device_read(serial, -1, &ch, 1)==1) { uart1_rx_dat.buf[uart1_rx_dat.len++] = ch; rt_timer_start(uart1_rx_timeout); } return RT_EOK; } void serial_uart1_thread_entry(void *parameter) { uint8_t jx=0; char ch; int ret = 0; int cnt = 0; static int timeout_time = 0; static uint8_t rx_one_byte_flag = 1; while (1) { if(uart1_rx_dat.rx_over == RT_TRUE) { uart1_rx_dat.rx_over = RT_FALSE; rt_kprintf("read_dat: "); for(jx=0; jx<uart1_rx_dat.len; jx++) { rt_kprintf("%02x ", uart1_rx_dat.buf[jx]); } rt_kprintf("\n"); uart1_rx_dat.len=0; if( uart1_rx_dat.buf[0]==0xff & uart1_rx_dat.buf[1]==0x2a) { if(uart1_rx_dat.buf[2]==0x01) { beep_on(); } else if(uart1_rx_dat.buf[2]==0x00) { beep_off(); } } } rt_thread_mdelay(5); } } int test_uart_sample(int argc, char *argv[]) { int c = 0; rt_err_t ret = RT_EOK; static rt_uint8_t open_cnt = 0; //查找串口设备 serial = rt_device_find(SAMPLE_UART_NAME); if (!serial) { rt_kprintf("find %s failed!\n", SAMPLE_UART_NAME); return -RT_ERROR; } //初始化信号量 rt_sem_init(&rx_sem, "rx_sem", 0, RT_IPC_FLAG_FIFO); //打开串口设备 ret = rt_device_open(serial, RT_DEVICE_OFLAG_RDWR | RT_DEVICE_FLAG_INT_RX); if (ret != RT_EOK) { rt_kprintf("open %s failed : %d !\n", SAMPLE_UART_NAME, ret); return -RT_ERROR; } //设置接收回调函数 rt_device_set_rx_indicate(serial, uart1_input); rt_device_write(serial, 0, str_send, (sizeof(str_send) - 1)); //创建 serial 线程 rt_thread_t thread = rt_thread_create("serial", serial_uart1_thread_entry, RT_NULL, 1024*2, 26, 10); if (thread != RT_NULL) { rt_thread_startup(thread); } else { rt_device_close(serial); return -RT_ERROR; } //创建接收超时定时器 uart1_rx_timeout = rt_timer_create("serial_timer", uart1_rx_timeout_cb, RT_NULL, 50, RT_TIMER_FLAG_PERIODIC); return ret; } MSH_CMD_EXPORT(test_uart_sample, Uart Test);   四、程序运行   下载程序后,串口发送控制命令 4.1、执行测试命令   4.2、打开蜂鸣器   4.3、关闭蜂鸣器  

  • 2024-08-29
  • 发表了主题帖: 【匠芯创D133CBS】 PWM驱动蜂鸣器

    本帖最后由 TL-LED 于 2024-8-29 20:25 编辑 测试PWM方式驱动蜂鸣器。   一、硬件电路部分   开发板使用的蜂鸣器是无源器件,需要外加脉冲信号驱动,常用的是PWM信号,此处连接到MCU的PWM1端口。 1.1、蜂鸣器部分电路图   1.2、蜂鸣器参数 从参数看,蜂鸣器的工作频率在2.7KHz   二、程序部分   2.1、beep.c //beep.c #include <stdlib.h> #include <string.h> #include <getopt.h> #include <sys/time.h> #include <rtthread.h> #include "rtdevice.h" #include "aic_core.h" #include "aic_hal_gpio.h" #define PWM_DEV_NAME "pwm" #define PWM_DEV_CHANNEL 1 /* PWM通道 */ struct rt_device_pwm *pwm_dev; void beep_on(void) { rt_pwm_set(pwm_dev, PWM_DEV_CHANNEL, 370000, 185000); rt_pwm_enable(pwm_dev, PWM_DEV_CHANNEL); } void beep_off(void) { rt_pwm_set(pwm_dev, PWM_DEV_CHANNEL, 370000, 185000); rt_pwm_disable(pwm_dev, PWM_DEV_CHANNEL); } void beep_change_pulse(uint32_t val) { rt_pwm_set(pwm_dev, PWM_DEV_CHANNEL, 370000, val); rt_pwm_enable(pwm_dev, PWM_DEV_CHANNEL); } static void beep_hdl(void *parmeter) { static rt_err_t result; while (1) { rt_thread_mdelay(1); } } static void test_beep_sample(void) { rt_thread_t beep_thread; /* 查找设备 */ pwm_dev = (struct rt_device_pwm *)rt_device_find(PWM_DEV_NAME); if (pwm_dev == RT_NULL) { rt_kprintf("pwm sample run failed! can't find %s device!\n", PWM_DEV_NAME); return RT_ERROR; } //创建线程 beep_thread = rt_thread_create( "test_beep", beep_hdl, "pwm1", 2048, RT_THREAD_PRIORITY_MAX/2, 25); if(beep_thread != RT_NULL) { rt_thread_startup(beep_thread); } return RT_EOK; rt_pwm_disable(pwm_dev, PWM_DEV_CHANNEL); } INIT_APP_EXPORT(test_beep_sample); MSH_CMD_EXPORT(test_beep_sample, beep device sample);   2.2、beep.h #ifndef __BEEP_H__ #define __BEEP_H__ void beep_off(void); void beep_on(void); void beep_change_pulse(uint32_t val); #endif   三、界面   3.1、BEEP控制界面   3.2、界面文件   四、配置项目 4.1、使能PWM1   五、运行结果   下载程序后,复位开发板运行 5.1、测试PWM1波形   5.2、界面控制 点击蜂鸣器来控制开关,滑块来控制PWM占空比。 [localvideo]4d935373cf6a5bc46d5814ccc5d23fbb[/localvideo]  

  • 2024-08-28
  • 发表了主题帖: 【匠芯创D133CBS】 LVGL测试

    本帖最后由 TL-LED 于 2024-8-28 00:08 编辑 测试D133开发板的LVGL显示组件。   一、LVGL显示界面设计   1.1、GUI-Guider软件设计界面 使用GUI-Guider软件设计界面,这里为了测试,随意放置一些组件。   1.2、生成C代码 点击此处生成C代码   生成的项目文件 后面的测试需要用到上面红框的两个文件夹的文件   二、添加LVGL应用到项目   此步骤参考教程中的LVGL添加应用。 2.1、将上面的文件复制到创建的应用文件下   2.2、打开应用  2.3、代码 aic_ui.c /* * Copyright (C) 2022-2023 ArtinChip Technology Co., Ltd. * Authors: Ning Fang <ning.fang@artinchip.com> */ #include "lvgl.h" #include "aic_ui.h" #include "aic_osal.h" #ifdef AIC_LVGL_TEST #include "test/generated/gui_guider.h" #include "test/generated/events_init.h" lv_ui guider_ui; #endif #ifdef AIC_LVGL_TEST_DEMO #include "test_demo/thread/test_thread.h" #include "test_demo/ui/test_ui.h" #endif void aic_ui_init() { /* qc test demo is only for aic internal qc testing, please ignore it. */ #ifdef LPKG_USING_LVGL_VSCODE extern void vscode_ui_init(); vscode_ui_init(); return; #endif #ifdef AIC_LVGL_BASE_DEMO #include "base_ui.h" base_ui_init(); #endif #ifdef AIC_LVGL_METER_DEMO #include "meter_ui.h" meter_ui_init(); #endif #ifdef AIC_LVGL_LAUNCHER_DEMO extern void launcher_ui_init(); launcher_ui_init(); #endif #ifdef AIC_LVGL_MUSIC_DEMO extern void lv_demo_music(void); //lv_demo_music(); lv_demo_music(); #endif #ifdef AIC_LVGL_TEST_DEMO test_thread(); test_ui_init(); #endif #ifdef AIC_LVGL_TEST setup_ui(&guider_ui); events_init(&guider_ui); #endif #ifdef AIC_LVGL_DASHBOARD_DEMO extern void dashboard_ui_init(void); dashboard_ui_init(); #endif #ifdef AIC_LVGL_SHOWCASE_DEMO extern void showcase_demo_init(void); showcase_demo_init(); #endif #ifdef AIC_LVGL_ELEVATOR_DEMO #include "elevator_ui.h" elevator_ui_init(); #endif #ifdef AIC_LVGL_SLIDE_DEMO extern void slide_ui_init(void); slide_ui_init(); #endif #ifdef AIC_LVGL_SIMPLE_PLAYER_DEMO extern void simple_player_ui_init(void); simple_player_ui_init(); #endif return; }   三、运行   编译后,下载程序到开发板运行 [localvideo]41f3514bf42cbddf1c0efa573de8edb2[/localvideo]  

  • 2024-08-25
  • 发表了主题帖: 【匠芯创D133CBS】 ADC测试

    通过ADC按键来测试ADC输入。   一、硬件电路   ADC按键部分电路 PA2对应GPADC2功能   二、程序部分   adc.c //adc.c #include <stdio.h> #include <stdlib.h> #include <string.h> #include <getopt.h> #include <sys/time.h> #include <rtthread.h> #include "rtdevice.h" #include <aic_core.h> #include "hal_adcim.h" #include "aic_log.h" #include "hal_gpai.h" /* Global macro and variables */ #define AIC_GPAI_NAME "gpai" /* The default voltages are set to D21x->3.0V, D31x、D12x->2.5V */ #define AIC_GPAI_DEFAULT_VOLTAGE 3.3 #define AIC_GPAI_VOLTAGE_ACCURACY 10000 #define AIC_GPAI_FIFO_MAX_DEPTH 32 static rt_adc_device_t gpai_dev; static int g_sample_num = -1; static u32 g_cal_param; struct aic_gpai_ch_info ch_info = {0}; float def_voltage = AIC_GPAI_DEFAULT_VOLTAGE; static int test_adc_hdl(void) { int c; int ret; u32 ch = 0; int adc_val; int voltage = -1; int scale = AIC_GPAI_VOLTAGE_ACCURACY; ch_info.chan_id = 2; //采样通道2 ch_info.mode = AIC_GPAI_MODE_PERIOD; //单次采样 def_voltage = 2.5; //参考电压2.5V g_sample_num = 1000; gpai_dev = (rt_adc_device_t)rt_device_find(AIC_GPAI_NAME); if (!gpai_dev) { rt_kprintf("Failed to open %s device\n", AIC_GPAI_NAME); return -RT_ERROR; } ret = rt_adc_control(gpai_dev, RT_ADC_CMD_GET_MODE, (void *)&ch_info); if (ret) { rt_kprintf("Failed to get GPAI mode\n"); return -RT_ERROR; } g_cal_param = hal_adcim_auto_calibration(); rt_adc_enable(gpai_dev, ch_info.chan_id); rt_adc_control(gpai_dev, RT_ADC_CMD_GET_CH_INFO, (void *)&ch_info); aicos_msleep(10); adc_val = ch_info.adc_values[0]; if (adc_val) { voltage = hal_adcim_adc2voltage(adc_val, g_cal_param, AIC_GPAI_VOLTAGE_ACCURACY, def_voltage); rt_kprintf("GPAI voltage:%d.%04d v\n", voltage / scale, voltage % scale); } return voltage; } static void adc_read_hdl(void *parmeter) { while (1) { test_adc_hdl(); rt_thread_mdelay(100); } } int test_adc_sample(void) { rt_thread_t adc_thread; adc_thread = rt_thread_create( "test_adc", adc_read_hdl, "adc2", 2048, RT_THREAD_PRIORITY_MAX/2, 25); if(adc_thread != RT_NULL) { rt_thread_startup(adc_thread); } return RT_EOK; } MSH_CMD_EXPORT_ALIAS(test_adc_sample, test_adc_sample, gpai device sample);   三、配置ADC   3.1、打开ADC2   3.2、打开添加的测试例程   四、执行结果   下载程序后运行 4.1、按下UP按键,ADC电压值   4.2、按下DOWN按键,ADC电压值 4.3、按下LEFT按键,ADC电压值 4.4、按下RIGHT按键,ADC电压值  

  • 发表了主题帖: 【匠芯创D133CBS】 CAN通信收发测试

    本帖最后由 TL-LED 于 2024-8-25 14:42 编辑 测试开发板的CAN通信。   一、硬件电路   1.1、CAN简介   CAN 是一种广泛应用于汽车控制系统和一般工业环境中的区域网络总线。作为一款多主机、多广播的通信协议,CAN 以其高可靠性和卓越的错误检测能力而著称。D133芯片CAN特性: • 支持 CAN2.0A 和 CAN2.0B 协议 • 支持 11 位标准格式标识符和 29 位扩展格式标识符 • 可编程通信速率最高可达 1 Mbps • 支持多种操作模式:正常模式、只听模式、自测模式、休眠模式、复位模式 • 支持接收过滤器,支持两种过滤模式 • 64 bytes 缓冲器 • 支持错误检测与处理:错误计数、错误报警阈值可配置、错误捕获、仲裁丢失捕获   1.2、CAN通信部分 1.3、连接CAN调试卡     二、程序   2.1、驱动程序 CAN的驱动程序,厂家已经移植好了,在开发板的BSP文件下。 • bsp/artinchip/drv/can/drv_can.c,CAN 模块 driver 层源码 • bsp/artinchip/hal/can/aic_hal_can.c,CAN 模块 hal 层源码 • bsp/artinchip/include/hal/aic_hal_can.h,CAN 模块 hal 层头文件   2.2、应用程序 can.c //can.c #include <stdio.h> #include <stdlib.h> #include <string.h> #include <rtthread.h> #include "rtdevice.h" #include <aic_core.h> #include "aic_hal_can.h" static rt_device_t can_dev; #define CAN_DEV_NAME "can0" #define CAN_RX_FILTER_ENABLE 0 static struct rt_semaphore rx_sem; u8 can_rx_flag = 0; static rt_err_t can_rx_call(rt_device_t dev, rt_size_t size) { rt_sem_release(&rx_sem); return RT_EOK; } static void can_rx_thread(void *parameter) { int i; rt_size_t size; struct rt_can_msg rxmsg = {0}; struct rt_can_msg txmsg = {0}; while (1) { rt_sem_take(&rx_sem, RT_WAITING_FOREVER); rxmsg.hdr = -1; size = rt_device_read(can_dev, 0, &rxmsg, sizeof(rxmsg)); if (!size) { rt_kprintf("CAN read error\n"); break; } rt_kprintf("%s received msg:\nID: 0x%x ", CAN_DEV_NAME, rxmsg.id); if (rxmsg.len) rt_kprintf("DATA: "); for (i = 0; i < rxmsg.len; i++) { rt_kprintf("%02x ", rxmsg.data[i]); } rt_kprintf("\n"); txmsg.id = rxmsg.id+1; if (txmsg.id > 0x7FF) txmsg.ide = 1; else txmsg.ide = 0; txmsg.len = rxmsg.len; txmsg.rtr = rxmsg.rtr;//CAN_FRAME_TYPE_DATA; for(i=0;i<8;i++) { txmsg.data[i]=rxmsg.data[i]; } size = rt_device_write(can_dev, 0, &txmsg, sizeof(txmsg)); if (size != sizeof(txmsg)) { rt_kprintf("can dev write data failed!\n"); break; } } rt_device_close(can_dev); } int test_can_rx_hdl(void) { rt_err_t ret = 0; rt_thread_t thread; if (!can_rx_flag) { //查找CAN设备 can_dev = rt_device_find(CAN_DEV_NAME); if (!can_dev) { rt_kprintf("find %s failed!\n", CAN_DEV_NAME); return -RT_ERROR; } //打开CAN设备 ret = rt_device_open(can_dev, RT_DEVICE_FLAG_INT_TX | RT_DEVICE_FLAG_INT_RX); if (ret) { rt_kprintf("%s open failed!\n", CAN_DEV_NAME); return -RT_ERROR; } //设置CAN波特率 ret = rt_device_control(can_dev, RT_CAN_CMD_SET_BAUD, (void *)CAN1MBaud); if (ret) { rt_kprintf("%s set baudrate failed!\n", CAN_DEV_NAME); ret = -RT_ERROR; goto __exit; } //使能CAN接收中断 rt_device_control(can_dev, RT_DEVICE_CTRL_SET_INT, NULL); #if CAN_RX_FILTER_ENABLE /* config can rx filter */ struct rt_can_filter_item items[1] = { //Only receive standard data frame with ID 0x100~0x1FF RT_CAN_FILTER_ITEM_INIT(0x100, 0, 0, 0, 0x700, RT_NULL, RT_NULL), }; struct rt_can_filter_config cfg = {1, 1, items}; ret = rt_device_control(g_can_rx_dev, RT_CAN_CMD_SET_FILTER, &cfg); #endif rt_device_set_rx_indicate(can_dev, can_rx_call); rt_sem_init(&rx_sem, "can_rx_sem", 0, RT_IPC_FLAG_PRIO); thread = rt_thread_create("can_rx_thread", can_rx_thread, RT_NULL, 2048, 25, 10); if (thread != RT_NULL) { rt_thread_startup(thread); } else { rt_kprintf("create can_rx thread failed!\n"); ret = -RT_ERROR; } can_rx_flag = 1; rt_kprintf("The %s received thread is ready...\n", CAN_DEV_NAME); } else { rt_kprintf("The %s received thread is running...\n", CAN_DEV_NAME); } rt_device_control(can_dev, RT_CAN_CMD_SET_MODE, (void *)CAN_NORMAL_MODE); return RT_EOK; __exit: rt_device_close(can_dev); return ret; } static int test_can_sample(int argc, char *argv[]) { test_can_rx_hdl(); return 0; } MSH_CMD_EXPORT_ALIAS(test_can_sample, test_can_sample, can device loopback sample);   三、运行结果   程序编译后,下载到开发板运行 3.1、开发板串口执行命令:test_can_sample   3.2、CAN调试卡发送数据,开发板接收后,将ID+1返回数据给开发板。  

  • 2024-08-13
  • 发表了主题帖: 【匠芯创D133CBS】 GPIO输入测试

    本帖最后由 TL-LED 于 2024-8-13 09:00 编辑 通过板子上的按键K3来测试GPIO输入中断。   一、硬件部分   K3按键电路图   二、程序部分   2.1、添加测试目录 在peripheral下添加测试test目录,创建key测试测试代码   2.2、key.c //key.c #include <stdlib.h> #include <string.h> #include <getopt.h> #include <sys/time.h> #include <rtthread.h> #include "rtdevice.h" #include "aic_core.h" #include "aic_hal_gpio.h" #define INPUT_KEY_PIN "PD.15" static void key_irq_handler(void *args) { printf("按键进入中断\n"); } static void test_key_sample(void) { u32 key_pin_num; key_pin_num = rt_pin_get(INPUT_KEY_PIN); rt_pin_mode(key_pin_num, PIN_MODE_INPUT_PULLUP); rt_pin_attach_irq(key_pin_num, PIN_IRQ_MODE_RISING_FALLING,key_irq_handler, RT_NULL); rt_pin_irq_enable(key_pin_num, PIN_IRQ_ENABLE); } MSH_CMD_EXPORT(test_key_sample, key device sample);   三、编译项目   3.1、选择创建的key测试选项 执行 scons --menuconfig    3.2、编译   四、运行   下载程序后,复位开发板 执行test_key_sample,按下K3进入中断。  

  • 2024-08-11
  • 回复了主题帖: 【匠芯创D133CBS】 开箱及搭建Baremetal开发环境

    lemonboard 发表于 2024-8-10 10:04 这显示屏做得还挺花哨的啊 显示做的挺不错的

  • 2024-08-10
  • 发表了主题帖: 【匠芯创D133CBS】 开箱及搭建Baremetal开发环境

    本帖最后由 TL-LED 于 2024-8-10 07:33 编辑 一、开箱   1.1、开发板的外包装 打开快递包装里面开发板的包装,感觉运输容易把屏幕损坏。   1.2、开发板电路板背面 板子的布局和做工是不错的,像是专为HMI定制的主板,预留的外设接口不是很多,要是测试外设功能,需要想办法自己引线啦。   1.3、开发板出产演示视频片段 [localvideo]c1018c8e1191542088ffd4b461c79b82[/localvideo]   二、搭建Baremetal开发环境   Baremetal 是 ArtInChip 的嵌入式裸机系统。可以实现简单的代码满足裸机系统的开发。   2.1、下载SDK 下载地址:git clone https://gitee.com/artinchip/baremetal.git   2.2、生成Eclipse工程 SDK下载完成后,运行windows命令win_cmd 执行 scons --target=eclipse生成Eclipse工程   2.3、生成Eclipse sdk工程   执行命令来生成一个完整的 Eclipse SDK 软件包 scons --target=eclipse_sdk   执行命令后,会在output下生成Eclipse工程。   2.4、下载Eclipse IDE  Baremetal 支持使用 Eclipse IDE 来进行调试 下载地址:https://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/2023-03/R/eclipse-embedcpp-2023-03-R-win32-x86_64.zip 下载完成后,解压文件,直接运行软件   2.5、导入eclipse工程   在上面生成了两个工程,这个理选择第一次生成的工程文件   2.6、编译工程   编译完成后,在下面文件下生成目标文件   三、烧写固件   将上面编译生成的 img固件烧写到开发板 打开固件后,连接USB,下载U-BOOT和复位按键,进入下载模式,软件会显示设备已连接。   烧写完成后,提示结果。   四、运行   烧写完成后,设备自动重启启动   4.1、显示屏显示 显示屏显示的是动画,我这里只截取了图片   4.2、串口输出  

  • 2024-08-06
  • 回复了主题帖: 测评入围名单: 工业级智能控制MCU 匠芯创D133CBS,追加了3块

    个人信息无误,确认可以完成测评分享计划

  • 2024-08-05
  • 回复了主题帖: 【兆易GD32H759I-EVAL】以太网测试

           

  • 2024-08-04
  • 回复了主题帖: 【瑞萨RA8D1板卡】 SDRAM读写测试

    Jacktang 发表于 2024-8-4 09:08 代码好长 测试结果是正确的吧 测试正常的,使用官网的测试例程。

  • 回复了主题帖: 【瑞萨RA8D1板卡】 核心板转接板

    秦天qintian0303 发表于 2024-8-3 19:21 没在转接板上直接弄个屏幕啊,再弄个模块板就太厚了 习惯转接成直插件,方便插拔,后面再设计接口底板

统计信息

已有1070人来访过

  • 芯积分:1543
  • 好友:3
  • 主题:225
  • 回复:185

留言

你需要登录后才可以留言 登录 | 注册


现在还没有留言