[bsp][renesas] rtduino supports the soft spi switch to pwm function
1.修改drv_gpio.c:R_IOPORT_Open()函数只需执行一次,修改位置为init时执行 2.默认HMI-Board使能rtduino后支持soft spi,通过switch_pwm可切换为pwm功能
This commit is contained in:
parent
5cfa9c6390
commit
4ceffbf06a
|
@ -114,14 +114,6 @@ static void ra_pin_map_init(void)
|
|||
static void ra_pin_mode(rt_device_t dev, rt_base_t pin, rt_uint8_t mode)
|
||||
{
|
||||
fsp_err_t err;
|
||||
/* Initialize the IOPORT module and configure the pins */
|
||||
err = R_IOPORT_Open(&g_ioport_ctrl, &g_bsp_pin_cfg);
|
||||
|
||||
if (err != FSP_SUCCESS)
|
||||
{
|
||||
LOG_E("GPIO open failed");
|
||||
return;
|
||||
}
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
|
@ -335,6 +327,17 @@ int rt_hw_pin_init(void)
|
|||
ra_irq_tab_init();
|
||||
ra_pin_map_init();
|
||||
#endif
|
||||
|
||||
fsp_err_t err;
|
||||
/* Initialize the IOPORT module and configure the pins */
|
||||
err = R_IOPORT_Open(&g_ioport_ctrl, &g_bsp_pin_cfg);
|
||||
|
||||
if (err != FSP_SUCCESS)
|
||||
{
|
||||
LOG_E("GPIO open failed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return rt_device_pin_register("pin", &_ra_pin_ops, RT_NULL);
|
||||
}
|
||||
|
||||
|
|
|
@ -47,3 +47,25 @@ const pin_map_t pin_map_table[]=
|
|||
{A4, BSP_IO_PORT_05_PIN_08, "adc0", 20}, /* ADC */
|
||||
{A5, BSP_IO_PORT_00_PIN_14, "adc0", 5} /* ADC */
|
||||
};
|
||||
|
||||
static ioport_instance_ctrl_t g_pwm_ioport_ctrl;
|
||||
static const ioport_pin_cfg_t g_pwm_pin_cfg_data[] = {
|
||||
{
|
||||
.pin = BSP_IO_PORT_05_PIN_12,
|
||||
.pin_cfg = ((uint32_t) IOPORT_CFG_PERIPHERAL_PIN | (uint32_t) IOPORT_PERIPHERAL_GPT1)
|
||||
},
|
||||
};
|
||||
|
||||
static const ioport_cfg_t g_pwm_pin_cfg = {
|
||||
.number_of_pins = sizeof(g_pwm_pin_cfg_data)/sizeof(ioport_pin_cfg_t),
|
||||
.p_pin_cfg_data = &g_pwm_pin_cfg_data[0],
|
||||
};
|
||||
|
||||
void switchToPWM(const char *device_name)
|
||||
{
|
||||
if(!rt_strcmp(device_name, "pwm0"))
|
||||
{
|
||||
R_IOPORT_Open(&g_pwm_ioport_ctrl, &g_pwm_pin_cfg);
|
||||
LOG_I("D11 will switch from SPI to PWM");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue