[Infineon]Add slider driver demo
This commit is contained in:
parent
8552d061c2
commit
4aa38e3d86
|
@ -95,7 +95,7 @@ static void irq_callback(void *callback_arg, cyhal_gpio_event_t event)
|
|||
|
||||
cyhal_gpio_callback_data_t irq_cb_data;
|
||||
|
||||
static void ifx_pin_mode(rt_device_t dev, rt_base_t pin, rt_base_t mode)
|
||||
static void ifx_pin_mode(rt_device_t dev, rt_base_t pin, rt_uint8_t mode)
|
||||
{
|
||||
rt_uint16_t gpio_pin;
|
||||
|
||||
|
@ -132,7 +132,7 @@ static void ifx_pin_mode(rt_device_t dev, rt_base_t pin, rt_base_t mode)
|
|||
}
|
||||
}
|
||||
|
||||
static void ifx_pin_write(rt_device_t dev, rt_base_t pin, rt_base_t value)
|
||||
static void ifx_pin_write(rt_device_t dev, rt_base_t pin, rt_uint8_t value)
|
||||
{
|
||||
rt_uint16_t gpio_pin;
|
||||
|
||||
|
@ -148,7 +148,7 @@ static void ifx_pin_write(rt_device_t dev, rt_base_t pin, rt_base_t value)
|
|||
cyhal_gpio_write(gpio_pin, value);
|
||||
}
|
||||
|
||||
static int ifx_pin_read(rt_device_t dev, rt_base_t pin)
|
||||
static rt_int8_t ifx_pin_read(struct rt_device *device, rt_base_t pin)
|
||||
{
|
||||
rt_uint16_t gpio_pin;
|
||||
|
||||
|
@ -164,8 +164,8 @@ static int ifx_pin_read(rt_device_t dev, rt_base_t pin)
|
|||
return cyhal_gpio_read(gpio_pin);
|
||||
}
|
||||
|
||||
static rt_err_t ifx_pin_attach_irq(struct rt_device *device, rt_int32_t pin,
|
||||
rt_uint32_t mode, void (*hdr)(void *args), void *args)
|
||||
static rt_err_t ifx_pin_attach_irq(struct rt_device *device, rt_base_t pin,
|
||||
rt_uint8_t mode, void (*hdr)(void *args), void *args)
|
||||
{
|
||||
rt_uint16_t gpio_port;
|
||||
rt_uint16_t gpio_pin;
|
||||
|
@ -207,7 +207,7 @@ static rt_err_t ifx_pin_attach_irq(struct rt_device *device, rt_int32_t pin,
|
|||
return RT_EOK;
|
||||
}
|
||||
|
||||
static rt_err_t ifx_pin_dettach_irq(struct rt_device *device, rt_int32_t pin)
|
||||
static rt_err_t ifx_pin_dettach_irq(struct rt_device *device, rt_base_t pin)
|
||||
{
|
||||
rt_uint16_t gpio_port;
|
||||
rt_uint16_t gpio_pin;
|
||||
|
@ -241,7 +241,7 @@ static rt_err_t ifx_pin_dettach_irq(struct rt_device *device, rt_int32_t pin)
|
|||
}
|
||||
|
||||
static rt_err_t ifx_pin_irq_enable(struct rt_device *device, rt_base_t pin,
|
||||
rt_uint32_t enabled)
|
||||
rt_uint8_t enabled)
|
||||
{
|
||||
rt_uint16_t gpio_port;
|
||||
rt_uint16_t gpio_pin;
|
||||
|
|
|
@ -31,8 +31,8 @@ struct ifx_pwm
|
|||
|
||||
static struct ifx_pwm ifx_pwm_obj[] =
|
||||
{
|
||||
#ifdef BSP_USING_PWM0_PORT13
|
||||
PWM0_CH3_PORT13_CONFIG,
|
||||
#ifdef BSP_USING_PWM0_PORT0
|
||||
PWM0_CH0_PORT0_CONFIG,
|
||||
#endif
|
||||
|
||||
#ifdef BSP_USING_PWM0_PORT2
|
||||
|
@ -58,6 +58,10 @@ static struct ifx_pwm ifx_pwm_obj[] =
|
|||
#ifdef BSP_USING_PWM0_PORT12
|
||||
PWM0_CH7_PORT12_CONFIG,
|
||||
#endif
|
||||
|
||||
#ifdef BSP_USING_PWM0_PORT13
|
||||
PWM0_CH3_PORT13_CONFIG,
|
||||
#endif
|
||||
};
|
||||
|
||||
static rt_err_t drv_pwm_enable(cyhal_pwm_t *htim, struct rt_pwm_configuration *configuration, rt_bool_t enable)
|
||||
|
@ -165,26 +169,13 @@ static rt_err_t ifx_hw_pwm_init(struct ifx_pwm *device)
|
|||
|
||||
RT_ASSERT(device != RT_NULL);
|
||||
|
||||
/* config pwm channel */
|
||||
if (device->channel == 0x03)
|
||||
if (cyhal_pwm_init_adv(device->pwm_obj, device->gpio, NC, CYHAL_PWM_LEFT_ALIGN, true, 0u, false, RT_NULL) != RT_EOK)
|
||||
{
|
||||
if (cyhal_pwm_init_adv(device->pwm_obj, device->gpio, NC, CYHAL_PWM_LEFT_ALIGN, true, 0u, false, RT_NULL) != RT_EOK)
|
||||
{
|
||||
LOG_E("%s channel3 config failed", device->name);
|
||||
result = -RT_ERROR;
|
||||
goto __exit;
|
||||
}
|
||||
}
|
||||
/* config pwm channel */
|
||||
if (device->channel == 0x07)
|
||||
{
|
||||
if (cyhal_pwm_init_adv(device->pwm_obj, device->gpio, NC, CYHAL_PWM_LEFT_ALIGN, true, 0u, false, RT_NULL) != RT_EOK)
|
||||
{
|
||||
LOG_E("%s channel7 config failed", device->name);
|
||||
result = -RT_ERROR;
|
||||
goto __exit;
|
||||
}
|
||||
LOG_E("%s channel%d config failed", device->name, device->channel);
|
||||
result = -RT_ERROR;
|
||||
goto __exit;
|
||||
}
|
||||
|
||||
__exit:
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -22,12 +22,12 @@ extern "C"
|
|||
#define MAX_PERIOD 65535
|
||||
|
||||
#ifdef BSP_USING_PWM0
|
||||
#ifndef PWM0_CH3_PORT13_CONFIG
|
||||
#define PWM0_CH3_PORT13_CONFIG \
|
||||
#ifndef PWM0_CH0_PORT0_CONFIG
|
||||
#define PWM0_CH0_PORT0_CONFIG \
|
||||
{ \
|
||||
.name = "pwm0", \
|
||||
.channel = 3, \
|
||||
.gpio = GET_PIN(13, 7), \
|
||||
.channel = 0, \
|
||||
.gpio = GET_PIN(0, 0), \
|
||||
}
|
||||
#endif /* PWM0_CH7_PORT2_CONFIG */
|
||||
|
||||
|
@ -84,6 +84,15 @@ extern "C"
|
|||
.gpio = GET_PIN(12, 6), \
|
||||
}
|
||||
#endif /* PWM0_CH7_PORT12_CONFIG */
|
||||
|
||||
#ifndef PWM0_CH3_PORT13_CONFIG
|
||||
#define PWM0_CH3_PORT13_CONFIG \
|
||||
{ \
|
||||
.name = "pwm0", \
|
||||
.channel = 3, \
|
||||
.gpio = GET_PIN(13, 7), \
|
||||
}
|
||||
#endif /* PWM0_CH3_PORT13_CONFIG */
|
||||
#endif /* BSP_USING_PWM0 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
#include "drv_gpio.h"
|
||||
|
||||
#define LED_PIN GET_PIN(0, 0)
|
||||
#define LED_PIN GET_PIN(0, 1)
|
||||
|
||||
int main(void)
|
||||
{
|
||||
|
|
|
@ -60,12 +60,12 @@ menu "On-chip Peripheral Drivers"
|
|||
bool "Enable timer0 output pwm"
|
||||
default n
|
||||
if BSP_USING_PWM0
|
||||
menuconfig BSP_USING_PWM0_CH3
|
||||
bool "Enable PWM0 channel3"
|
||||
menuconfig BSP_USING_PWM0_CH0
|
||||
bool "Enable PWM0 channel0"
|
||||
default n
|
||||
if BSP_USING_PWM0_CH3
|
||||
config BSP_USING_PWM0_PORT13
|
||||
bool "Enable PWM0-PORT13 output pwm"
|
||||
if BSP_USING_PWM0_CH0
|
||||
config BSP_USING_PWM0_PORT0
|
||||
bool "Enable PWM0-PORT0 output pwm"
|
||||
default n
|
||||
endif
|
||||
menuconfig BSP_USING_PWM0_CH7
|
||||
|
@ -263,6 +263,10 @@ menu "Board extended module Drivers"
|
|||
|
||||
config BSP_USING_SLIDER
|
||||
bool "Enable Slider Demo"
|
||||
select BSP_USING_PWM
|
||||
select BSP_USING_PWM0
|
||||
select BSP_USING_PWM0_CH0
|
||||
select BSP_USING_PWM0_PORT0
|
||||
default n
|
||||
|
||||
menuconfig BSP_USING_RW007
|
||||
|
|
|
@ -44,7 +44,7 @@ static rt_thread_t sld_thread = RT_NULL;
|
|||
#error You need enable PWM to use this sample
|
||||
#else
|
||||
#define PWM_DEV_NAME "pwm0"
|
||||
#define PWM_DEV_CHANNEL 3
|
||||
#define PWM_DEV_CHANNEL 0
|
||||
static struct rt_device_pwm *pwm_dev;
|
||||
#endif
|
||||
|
||||
|
@ -128,7 +128,7 @@ void Slider_Init(void)
|
|||
return;
|
||||
}
|
||||
|
||||
#ifdef BSP_USING_PWM0_PORT13
|
||||
#ifdef BSP_USING_PWM0_PORT0
|
||||
/* Initiate PWM*/
|
||||
pwm_dev = (struct rt_device_pwm *)rt_device_find(PWM_DEV_NAME);
|
||||
|
||||
|
|
Loading…
Reference in New Issue