mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-10-01 08:27:30 +08:00
[bsp/Infineon] Fix PWM macro mismatches left by the CHx_PORTy rename (#11802)
* [bsp/Infineon] Fix PWM macro mismatches left by the CHx_PORTy rename
Commit e5382cb733 renamed the PWM table guards in drv_pwm.c to the
CHx_PORTy convention but only adapted the psoc6-evk Kconfig, leaving
several mismatches behind:
- The psoc6-evaluationkit-062S2 slider sample still tested the old
flat name BSP_USING_PWM0_PORT0 while the board Kconfig defines
BSP_USING_PWM0_CH0_PORT0, so the PWM init was compiled out.
- The PORT13 entry was renamed to BSP_USING_PWM0_CH7_PORT13, a macro
that no Kconfig defines, and the channel is wrong anyway:
PWM0_CH3_PORT13_CONFIG carries .channel = 3, PORT13 sits under the
PWM0 CH3 menu, and the slider demo selects CH3 + PORT13.
- The PSOC62 template and five psoc6 boards (cy8ckit-062-BLE,
cy8ckit-062-WIFI-BT, cy8ckit-062S2-43012, cy8ckit-062s4,
cy8cproto-062S3-4343W) still define the old flat names.
Fix all of them by migrating the evaluationkit sample to
BSP_USING_PWM0_CH0_PORT0 and renaming the PORT13 group to
BSP_USING_PWM0_CH3_PORT13 across drv_pwm.c, the PSOC62 template and
the five boards' Kconfigs/slider samples, so Kconfig, driver table
and samples match again.
Note: the sibling guards BSP_USING_PWM0_CH7_PORT2/5/7/9/10/12 are
still not generated by these boards' Kconfigs; left untouched for a
separate discussion.
* style: format code with clang-format [skip ci]
This commit is contained in:
@@ -29,8 +29,7 @@ struct ifx_pwm
|
||||
rt_uint8_t gpio;
|
||||
};
|
||||
|
||||
static struct ifx_pwm ifx_pwm_obj[] =
|
||||
{
|
||||
static struct ifx_pwm ifx_pwm_obj[] = {
|
||||
#ifdef BSP_USING_PWM0_CH0_PORT0
|
||||
PWM0_CH0_PORT0_CONFIG,
|
||||
#endif
|
||||
@@ -75,7 +74,7 @@ static struct ifx_pwm ifx_pwm_obj[] =
|
||||
PWM0_CH7_PORT12_CONFIG,
|
||||
#endif
|
||||
|
||||
#ifdef BSP_USING_PWM0_CH7_PORT13
|
||||
#ifdef BSP_USING_PWM0_CH3_PORT13
|
||||
PWM0_CH3_PORT13_CONFIG,
|
||||
#endif
|
||||
};
|
||||
@@ -89,12 +88,12 @@ static rt_err_t drv_pwm_enable(cyhal_pwm_t *htim, struct rt_pwm_configuration *c
|
||||
{
|
||||
if (!enable)
|
||||
{
|
||||
htim->tcpwm.resource.channel_num = channel;
|
||||
htim->tcpwm.resource.channel_num = channel;
|
||||
cyhal_pwm_stop(htim);
|
||||
}
|
||||
else
|
||||
{
|
||||
htim->tcpwm.resource.channel_num = channel;
|
||||
htim->tcpwm.resource.channel_num = channel;
|
||||
cyhal_pwm_start(htim);
|
||||
}
|
||||
}
|
||||
@@ -163,7 +162,7 @@ static rt_err_t drv_pwm_control(struct rt_device_pwm *device, int cmd, void *arg
|
||||
}
|
||||
}
|
||||
|
||||
static struct rt_pwm_ops drv_ops = {drv_pwm_control};
|
||||
static struct rt_pwm_ops drv_ops = { drv_pwm_control };
|
||||
|
||||
static rt_err_t ifx_hw_pwm_init(struct ifx_pwm *device)
|
||||
{
|
||||
@@ -218,7 +217,7 @@ __exit:
|
||||
}
|
||||
INIT_BOARD_EXPORT(rt_hw_pwm_init);
|
||||
|
||||
#define PWM_DEV_NAME "pwm0"
|
||||
#define PWM_DEV_NAME "pwm0"
|
||||
#define PWM_DEV_CHANNEL 4
|
||||
|
||||
struct rt_device_pwm *pwm_dev;
|
||||
|
||||
@@ -61,8 +61,8 @@ menu "On-chip Peripheral Drivers"
|
||||
bool "Enable PWM0 channel3"
|
||||
default n
|
||||
if BSP_USING_PWM0_CH3
|
||||
config BSP_USING_PWM0_PORT13
|
||||
bool "Enable PWM0-PORT13 output pwm"
|
||||
config BSP_USING_PWM0_CH3_PORT13
|
||||
bool "Enable PWM0-CH3-PORT13 output pwm"
|
||||
default n
|
||||
endif
|
||||
menuconfig BSP_USING_PWM0_CH7
|
||||
|
||||
@@ -14,16 +14,16 @@
|
||||
#ifdef BSP_USING_SLIDER
|
||||
#include "cycfg_capsense.h"
|
||||
|
||||
#define CAPSENSE_INTR_PRIORITY (7u)
|
||||
#define EZI2C_INTR_PRIORITY (6u)
|
||||
#define CAPSENSE_INTR_PRIORITY (7u)
|
||||
#define EZI2C_INTR_PRIORITY (6u)
|
||||
|
||||
/* Allowed duty cycle for maximum brightness */
|
||||
#define LED_MAX_BRIGHTNESS (100u)
|
||||
#define LED_MAX_BRIGHTNESS (100u)
|
||||
|
||||
/* Allowed duty cycle for minimum brightness*/
|
||||
#define LED_MIN_BRIGHTNESS (0u)
|
||||
#define LED_MIN_BRIGHTNESS (0u)
|
||||
|
||||
#define GET_DUTY_CYCLE(x) (1 * 1000 * 1000 - x * 10 * 1000)
|
||||
#define GET_DUTY_CYCLE(x) (1 * 1000 * 1000 - x * 10 * 1000)
|
||||
|
||||
typedef enum
|
||||
{
|
||||
@@ -40,11 +40,11 @@ typedef struct
|
||||
static rt_sem_t trans_done_semphr = RT_NULL;
|
||||
|
||||
#ifndef RT_USING_PWM
|
||||
#error You need enable PWM to use this sample
|
||||
#error You need enable PWM to use this sample
|
||||
#else
|
||||
#define PWM_DEV_NAME "pwm0"
|
||||
#define PWM_DEV_CHANNEL 3
|
||||
static struct rt_device_pwm *pwm_dev;
|
||||
#define PWM_DEV_NAME "pwm0"
|
||||
#define PWM_DEV_CHANNEL 3
|
||||
static struct rt_device_pwm *pwm_dev;
|
||||
#endif
|
||||
|
||||
static void capsense_isr(void)
|
||||
@@ -68,8 +68,7 @@ static uint32_t initialize_capsense(void)
|
||||
uint32_t status = CYRET_SUCCESS;
|
||||
|
||||
/* CapSense interrupt configuration parameters */
|
||||
static const cy_stc_sysint_t capSense_intr_config =
|
||||
{
|
||||
static const cy_stc_sysint_t capSense_intr_config = {
|
||||
.intrSrc = csd_interrupt_IRQn,
|
||||
.intrPriority = CAPSENSE_INTR_PRIORITY,
|
||||
};
|
||||
@@ -127,7 +126,7 @@ void Slider_Init(void)
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef BSP_USING_PWM0_PORT13
|
||||
#ifdef BSP_USING_PWM0_CH3_PORT13
|
||||
/* Initiate PWM*/
|
||||
pwm_dev = (struct rt_device_pwm *)rt_device_find(PWM_DEV_NAME);
|
||||
|
||||
@@ -162,20 +161,19 @@ static void process_touch(void)
|
||||
bool led_update_req = false;
|
||||
|
||||
static uint16_t slider_pos_prev;
|
||||
static led_data_t led_data = {LED_ON, LED_MAX_BRIGHTNESS};
|
||||
static led_data_t led_data = { LED_ON, LED_MAX_BRIGHTNESS };
|
||||
|
||||
/* Get slider status */
|
||||
slider_touch_info = Cy_CapSense_GetTouchInfo(
|
||||
CY_CAPSENSE_LINEARSLIDER0_WDGT_ID, &cy_capsense_context);
|
||||
CY_CAPSENSE_LINEARSLIDER0_WDGT_ID, &cy_capsense_context);
|
||||
slider_touch_status = slider_touch_info->numPosition;
|
||||
slider_pos = slider_touch_info->ptrPosition->x;
|
||||
|
||||
/* Detect the new touch on slider */
|
||||
if ((RT_NULL != slider_touch_status) &&
|
||||
(slider_pos != slider_pos_prev))
|
||||
(slider_pos != slider_pos_prev))
|
||||
{
|
||||
led_data.brightness = (slider_pos * 100)
|
||||
/ cy_capsense_context.ptrWdConfig[CY_CAPSENSE_LINEARSLIDER0_WDGT_ID].xResolution;
|
||||
led_data.brightness = (slider_pos * 100) / cy_capsense_context.ptrWdConfig[CY_CAPSENSE_LINEARSLIDER0_WDGT_ID].xResolution;
|
||||
|
||||
led_update_req = true;
|
||||
}
|
||||
|
||||
@@ -61,8 +61,8 @@ menu "On-chip Peripheral Drivers"
|
||||
bool "Enable PWM0 channel3"
|
||||
default n
|
||||
if BSP_USING_PWM0_CH3
|
||||
config BSP_USING_PWM0_PORT13
|
||||
bool "Enable PWM0-PORT13 output pwm"
|
||||
config BSP_USING_PWM0_CH3_PORT13
|
||||
bool "Enable PWM0-CH3-PORT13 output pwm"
|
||||
default n
|
||||
endif
|
||||
menuconfig BSP_USING_PWM0_CH7
|
||||
|
||||
@@ -14,16 +14,16 @@
|
||||
#ifdef BSP_USING_SLIDER
|
||||
#include "cycfg_capsense.h"
|
||||
|
||||
#define CAPSENSE_INTR_PRIORITY (7u)
|
||||
#define EZI2C_INTR_PRIORITY (6u)
|
||||
#define CAPSENSE_INTR_PRIORITY (7u)
|
||||
#define EZI2C_INTR_PRIORITY (6u)
|
||||
|
||||
/* Allowed duty cycle for maximum brightness */
|
||||
#define LED_MAX_BRIGHTNESS (100u)
|
||||
#define LED_MAX_BRIGHTNESS (100u)
|
||||
|
||||
/* Allowed duty cycle for minimum brightness*/
|
||||
#define LED_MIN_BRIGHTNESS (0u)
|
||||
#define LED_MIN_BRIGHTNESS (0u)
|
||||
|
||||
#define GET_DUTY_CYCLE(x) (1 * 1000 * 1000 - x * 10 * 1000)
|
||||
#define GET_DUTY_CYCLE(x) (1 * 1000 * 1000 - x * 10 * 1000)
|
||||
|
||||
typedef enum
|
||||
{
|
||||
@@ -40,11 +40,11 @@ typedef struct
|
||||
static rt_sem_t trans_done_semphr = RT_NULL;
|
||||
|
||||
#ifndef RT_USING_PWM
|
||||
#error You need enable PWM to use this sample
|
||||
#error You need enable PWM to use this sample
|
||||
#else
|
||||
#define PWM_DEV_NAME "pwm0"
|
||||
#define PWM_DEV_CHANNEL 3
|
||||
static struct rt_device_pwm *pwm_dev;
|
||||
#define PWM_DEV_NAME "pwm0"
|
||||
#define PWM_DEV_CHANNEL 3
|
||||
static struct rt_device_pwm *pwm_dev;
|
||||
#endif
|
||||
|
||||
static void capsense_isr(void)
|
||||
@@ -68,8 +68,7 @@ static uint32_t initialize_capsense(void)
|
||||
uint32_t status = CYRET_SUCCESS;
|
||||
|
||||
/* CapSense interrupt configuration parameters */
|
||||
static const cy_stc_sysint_t capSense_intr_config =
|
||||
{
|
||||
static const cy_stc_sysint_t capSense_intr_config = {
|
||||
.intrSrc = csd_interrupt_IRQn,
|
||||
.intrPriority = CAPSENSE_INTR_PRIORITY,
|
||||
};
|
||||
@@ -127,7 +126,7 @@ void Slider_Init(void)
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef BSP_USING_PWM0_PORT13
|
||||
#ifdef BSP_USING_PWM0_CH3_PORT13
|
||||
/* Initiate PWM*/
|
||||
pwm_dev = (struct rt_device_pwm *)rt_device_find(PWM_DEV_NAME);
|
||||
|
||||
@@ -162,20 +161,19 @@ static void process_touch(void)
|
||||
bool led_update_req = false;
|
||||
|
||||
static uint16_t slider_pos_prev;
|
||||
static led_data_t led_data = {LED_ON, LED_MAX_BRIGHTNESS};
|
||||
static led_data_t led_data = { LED_ON, LED_MAX_BRIGHTNESS };
|
||||
|
||||
/* Get slider status */
|
||||
slider_touch_info = Cy_CapSense_GetTouchInfo(
|
||||
CY_CAPSENSE_LINEARSLIDER0_WDGT_ID, &cy_capsense_context);
|
||||
CY_CAPSENSE_LINEARSLIDER0_WDGT_ID, &cy_capsense_context);
|
||||
slider_touch_status = slider_touch_info->numPosition;
|
||||
slider_pos = slider_touch_info->ptrPosition->x;
|
||||
|
||||
/* Detect the new touch on slider */
|
||||
if ((RT_NULL != slider_touch_status) &&
|
||||
(slider_pos != slider_pos_prev))
|
||||
(slider_pos != slider_pos_prev))
|
||||
{
|
||||
led_data.brightness = (slider_pos * 100)
|
||||
/ cy_capsense_context.ptrWdConfig[CY_CAPSENSE_LINEARSLIDER0_WDGT_ID].xResolution;
|
||||
led_data.brightness = (slider_pos * 100) / cy_capsense_context.ptrWdConfig[CY_CAPSENSE_LINEARSLIDER0_WDGT_ID].xResolution;
|
||||
|
||||
led_update_req = true;
|
||||
}
|
||||
|
||||
@@ -61,8 +61,8 @@ menu "On-chip Peripheral Drivers"
|
||||
bool "Enable PWM0 channel3"
|
||||
default n
|
||||
if BSP_USING_PWM0_CH3
|
||||
config BSP_USING_PWM0_PORT13
|
||||
bool "Enable PWM0-PORT13 output pwm"
|
||||
config BSP_USING_PWM0_CH3_PORT13
|
||||
bool "Enable PWM0-CH3-PORT13 output pwm"
|
||||
default n
|
||||
endif
|
||||
menuconfig BSP_USING_PWM0_CH7
|
||||
|
||||
@@ -14,16 +14,16 @@
|
||||
#ifdef BSP_USING_SLIDER
|
||||
#include "cycfg_capsense.h"
|
||||
|
||||
#define CAPSENSE_INTR_PRIORITY (7u)
|
||||
#define EZI2C_INTR_PRIORITY (6u)
|
||||
#define CAPSENSE_INTR_PRIORITY (7u)
|
||||
#define EZI2C_INTR_PRIORITY (6u)
|
||||
|
||||
/* Allowed duty cycle for maximum brightness */
|
||||
#define LED_MAX_BRIGHTNESS (100u)
|
||||
#define LED_MAX_BRIGHTNESS (100u)
|
||||
|
||||
/* Allowed duty cycle for minimum brightness*/
|
||||
#define LED_MIN_BRIGHTNESS (0u)
|
||||
#define LED_MIN_BRIGHTNESS (0u)
|
||||
|
||||
#define GET_DUTY_CYCLE(x) (1 * 1000 * 1000 - x * 10 * 1000)
|
||||
#define GET_DUTY_CYCLE(x) (1 * 1000 * 1000 - x * 10 * 1000)
|
||||
|
||||
typedef enum
|
||||
{
|
||||
@@ -40,11 +40,11 @@ typedef struct
|
||||
static rt_sem_t trans_done_semphr = RT_NULL;
|
||||
|
||||
#ifndef RT_USING_PWM
|
||||
#error You need enable PWM to use this sample
|
||||
#error You need enable PWM to use this sample
|
||||
#else
|
||||
#define PWM_DEV_NAME "pwm0"
|
||||
#define PWM_DEV_CHANNEL 3
|
||||
static struct rt_device_pwm *pwm_dev;
|
||||
#define PWM_DEV_NAME "pwm0"
|
||||
#define PWM_DEV_CHANNEL 3
|
||||
static struct rt_device_pwm *pwm_dev;
|
||||
#endif
|
||||
|
||||
static void capsense_isr(void)
|
||||
@@ -68,8 +68,7 @@ static uint32_t initialize_capsense(void)
|
||||
uint32_t status = CYRET_SUCCESS;
|
||||
|
||||
/* CapSense interrupt configuration parameters */
|
||||
static const cy_stc_sysint_t capSense_intr_config =
|
||||
{
|
||||
static const cy_stc_sysint_t capSense_intr_config = {
|
||||
.intrSrc = csd_interrupt_IRQn,
|
||||
.intrPriority = CAPSENSE_INTR_PRIORITY,
|
||||
};
|
||||
@@ -127,7 +126,7 @@ void Slider_Init(void)
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef BSP_USING_PWM0_PORT13
|
||||
#ifdef BSP_USING_PWM0_CH3_PORT13
|
||||
/* Initiate PWM*/
|
||||
pwm_dev = (struct rt_device_pwm *)rt_device_find(PWM_DEV_NAME);
|
||||
|
||||
@@ -162,20 +161,19 @@ static void process_touch(void)
|
||||
bool led_update_req = false;
|
||||
|
||||
static uint16_t slider_pos_prev;
|
||||
static led_data_t led_data = {LED_ON, LED_MAX_BRIGHTNESS};
|
||||
static led_data_t led_data = { LED_ON, LED_MAX_BRIGHTNESS };
|
||||
|
||||
/* Get slider status */
|
||||
slider_touch_info = Cy_CapSense_GetTouchInfo(
|
||||
CY_CAPSENSE_LINEARSLIDER0_WDGT_ID, &cy_capsense_context);
|
||||
CY_CAPSENSE_LINEARSLIDER0_WDGT_ID, &cy_capsense_context);
|
||||
slider_touch_status = slider_touch_info->numPosition;
|
||||
slider_pos = slider_touch_info->ptrPosition->x;
|
||||
|
||||
/* Detect the new touch on slider */
|
||||
if ((RT_NULL != slider_touch_status) &&
|
||||
(slider_pos != slider_pos_prev))
|
||||
(slider_pos != slider_pos_prev))
|
||||
{
|
||||
led_data.brightness = (slider_pos * 100)
|
||||
/ cy_capsense_context.ptrWdConfig[CY_CAPSENSE_LINEARSLIDER0_WDGT_ID].xResolution;
|
||||
led_data.brightness = (slider_pos * 100) / cy_capsense_context.ptrWdConfig[CY_CAPSENSE_LINEARSLIDER0_WDGT_ID].xResolution;
|
||||
|
||||
led_update_req = true;
|
||||
}
|
||||
|
||||
@@ -61,8 +61,8 @@ menu "On-chip Peripheral Drivers"
|
||||
bool "Enable PWM0 channel3"
|
||||
default n
|
||||
if BSP_USING_PWM0_CH3
|
||||
config BSP_USING_PWM0_PORT13
|
||||
bool "Enable PWM0-PORT13 output pwm"
|
||||
config BSP_USING_PWM0_CH3_PORT13
|
||||
bool "Enable PWM0-CH3-PORT13 output pwm"
|
||||
default n
|
||||
endif
|
||||
menuconfig BSP_USING_PWM0_CH7
|
||||
@@ -270,7 +270,7 @@ menu "Board extended module Drivers"
|
||||
select BSP_USING_PWM
|
||||
select BSP_USING_PWM0
|
||||
select BSP_USING_PWM0_CH3
|
||||
select BSP_USING_PWM0_PORT13
|
||||
select BSP_USING_PWM0_CH3_PORT13
|
||||
default n
|
||||
endif
|
||||
|
||||
|
||||
@@ -14,16 +14,16 @@
|
||||
#ifdef BSP_USING_SLIDER
|
||||
#include "cycfg_capsense.h"
|
||||
|
||||
#define CAPSENSE_INTR_PRIORITY (7u)
|
||||
#define EZI2C_INTR_PRIORITY (6u)
|
||||
#define CAPSENSE_INTR_PRIORITY (7u)
|
||||
#define EZI2C_INTR_PRIORITY (6u)
|
||||
|
||||
/* Allowed duty cycle for maximum brightness */
|
||||
#define LED_MAX_BRIGHTNESS (100u)
|
||||
#define LED_MAX_BRIGHTNESS (100u)
|
||||
|
||||
/* Allowed duty cycle for minimum brightness*/
|
||||
#define LED_MIN_BRIGHTNESS (0u)
|
||||
#define LED_MIN_BRIGHTNESS (0u)
|
||||
|
||||
#define GET_DUTY_CYCLE(x) (1 * 1000 * 1000 - x * 10 * 1000)
|
||||
#define GET_DUTY_CYCLE(x) (1 * 1000 * 1000 - x * 10 * 1000)
|
||||
|
||||
typedef enum
|
||||
{
|
||||
@@ -41,11 +41,11 @@ static rt_sem_t trans_done_semphr = RT_NULL;
|
||||
static rt_thread_t sld_thread = RT_NULL;
|
||||
|
||||
#ifndef RT_USING_PWM
|
||||
#error You need enable PWM to use this sample
|
||||
#error You need enable PWM to use this sample
|
||||
#else
|
||||
#define PWM_DEV_NAME "pwm0"
|
||||
#define PWM_DEV_CHANNEL 3
|
||||
static struct rt_device_pwm *pwm_dev;
|
||||
#define PWM_DEV_NAME "pwm0"
|
||||
#define PWM_DEV_CHANNEL 3
|
||||
static struct rt_device_pwm *pwm_dev;
|
||||
#endif
|
||||
|
||||
static void capsense_isr(void)
|
||||
@@ -69,8 +69,7 @@ static uint32_t initialize_capsense(void)
|
||||
uint32_t status = CYRET_SUCCESS;
|
||||
|
||||
/* CapSense interrupt configuration parameters */
|
||||
static const cy_stc_sysint_t capSense_intr_config =
|
||||
{
|
||||
static const cy_stc_sysint_t capSense_intr_config = {
|
||||
.intrSrc = csd_interrupt_IRQn,
|
||||
.intrPriority = CAPSENSE_INTR_PRIORITY,
|
||||
};
|
||||
@@ -128,7 +127,7 @@ void Slider_Init(void)
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef BSP_USING_PWM0_PORT13
|
||||
#ifdef BSP_USING_PWM0_CH3_PORT13
|
||||
/* Initiate PWM*/
|
||||
pwm_dev = (struct rt_device_pwm *)rt_device_find(PWM_DEV_NAME);
|
||||
|
||||
@@ -163,20 +162,19 @@ static void process_touch(void)
|
||||
bool led_update_req = false;
|
||||
|
||||
static uint16_t slider_pos_prev;
|
||||
static led_data_t led_data = {LED_ON, LED_MAX_BRIGHTNESS};
|
||||
static led_data_t led_data = { LED_ON, LED_MAX_BRIGHTNESS };
|
||||
|
||||
/* Get slider status */
|
||||
slider_touch_info = Cy_CapSense_GetTouchInfo(
|
||||
CY_CAPSENSE_LINEARSLIDER0_WDGT_ID, &cy_capsense_context);
|
||||
CY_CAPSENSE_LINEARSLIDER0_WDGT_ID, &cy_capsense_context);
|
||||
slider_touch_status = slider_touch_info->numPosition;
|
||||
slider_pos = slider_touch_info->ptrPosition->x;
|
||||
|
||||
/* Detect the new touch on slider */
|
||||
if ((RT_NULL != slider_touch_status) &&
|
||||
(slider_pos != slider_pos_prev))
|
||||
(slider_pos != slider_pos_prev))
|
||||
{
|
||||
led_data.brightness = (slider_pos * 100)
|
||||
/ cy_capsense_context.ptrWdConfig[CY_CAPSENSE_LINEARSLIDER0_WDGT_ID].xResolution;
|
||||
led_data.brightness = (slider_pos * 100) / cy_capsense_context.ptrWdConfig[CY_CAPSENSE_LINEARSLIDER0_WDGT_ID].xResolution;
|
||||
|
||||
led_update_req = true;
|
||||
}
|
||||
|
||||
@@ -61,8 +61,8 @@ menu "On-chip Peripheral Drivers"
|
||||
bool "Enable PWM0 channel3"
|
||||
default n
|
||||
if BSP_USING_PWM0_CH3
|
||||
config BSP_USING_PWM0_PORT13
|
||||
bool "Enable PWM0-PORT13 output pwm"
|
||||
config BSP_USING_PWM0_CH3_PORT13
|
||||
bool "Enable PWM0-CH3-PORT13 output pwm"
|
||||
default n
|
||||
endif
|
||||
menuconfig BSP_USING_PWM0_CH7
|
||||
|
||||
@@ -14,16 +14,16 @@
|
||||
#ifdef BSP_USING_SLIDER
|
||||
#include "cycfg_capsense.h"
|
||||
|
||||
#define CAPSENSE_INTR_PRIORITY (7u)
|
||||
#define EZI2C_INTR_PRIORITY (6u)
|
||||
#define CAPSENSE_INTR_PRIORITY (7u)
|
||||
#define EZI2C_INTR_PRIORITY (6u)
|
||||
|
||||
/* Allowed duty cycle for maximum brightness */
|
||||
#define LED_MAX_BRIGHTNESS (100u)
|
||||
#define LED_MAX_BRIGHTNESS (100u)
|
||||
|
||||
/* Allowed duty cycle for minimum brightness*/
|
||||
#define LED_MIN_BRIGHTNESS (0u)
|
||||
#define LED_MIN_BRIGHTNESS (0u)
|
||||
|
||||
#define GET_DUTY_CYCLE(x) (1 * 1000 * 1000 - x * 10 * 1000)
|
||||
#define GET_DUTY_CYCLE(x) (1 * 1000 * 1000 - x * 10 * 1000)
|
||||
|
||||
typedef enum
|
||||
{
|
||||
@@ -40,11 +40,11 @@ typedef struct
|
||||
static rt_sem_t trans_done_semphr = RT_NULL;
|
||||
|
||||
#ifndef RT_USING_PWM
|
||||
#error You need enable PWM to use this sample
|
||||
#error You need enable PWM to use this sample
|
||||
#else
|
||||
#define PWM_DEV_NAME "pwm0"
|
||||
#define PWM_DEV_CHANNEL 3
|
||||
static struct rt_device_pwm *pwm_dev;
|
||||
#define PWM_DEV_NAME "pwm0"
|
||||
#define PWM_DEV_CHANNEL 3
|
||||
static struct rt_device_pwm *pwm_dev;
|
||||
#endif
|
||||
|
||||
static void capsense_isr(void)
|
||||
@@ -68,8 +68,7 @@ static uint32_t initialize_capsense(void)
|
||||
uint32_t status = CYRET_SUCCESS;
|
||||
|
||||
/* CapSense interrupt configuration parameters */
|
||||
static const cy_stc_sysint_t capSense_intr_config =
|
||||
{
|
||||
static const cy_stc_sysint_t capSense_intr_config = {
|
||||
.intrSrc = csd_interrupt_IRQn,
|
||||
.intrPriority = CAPSENSE_INTR_PRIORITY,
|
||||
};
|
||||
@@ -127,7 +126,7 @@ void Slider_Init(void)
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef BSP_USING_PWM0_PORT13
|
||||
#ifdef BSP_USING_PWM0_CH3_PORT13
|
||||
/* Initiate PWM*/
|
||||
pwm_dev = (struct rt_device_pwm *)rt_device_find(PWM_DEV_NAME);
|
||||
|
||||
@@ -162,20 +161,19 @@ static void process_touch(void)
|
||||
bool led_update_req = false;
|
||||
|
||||
static uint16_t slider_pos_prev;
|
||||
static led_data_t led_data = {LED_ON, LED_MAX_BRIGHTNESS};
|
||||
static led_data_t led_data = { LED_ON, LED_MAX_BRIGHTNESS };
|
||||
|
||||
/* Get slider status */
|
||||
slider_touch_info = Cy_CapSense_GetTouchInfo(
|
||||
CY_CAPSENSE_LINEARSLIDER0_WDGT_ID, &cy_capsense_context);
|
||||
CY_CAPSENSE_LINEARSLIDER0_WDGT_ID, &cy_capsense_context);
|
||||
slider_touch_status = slider_touch_info->numPosition;
|
||||
slider_pos = slider_touch_info->ptrPosition->x;
|
||||
|
||||
/* Detect the new touch on slider */
|
||||
if ((RT_NULL != slider_touch_status) &&
|
||||
(slider_pos != slider_pos_prev))
|
||||
(slider_pos != slider_pos_prev))
|
||||
{
|
||||
led_data.brightness = (slider_pos * 100)
|
||||
/ cy_capsense_context.ptrWdConfig[CY_CAPSENSE_LINEARSLIDER0_WDGT_ID].xResolution;
|
||||
led_data.brightness = (slider_pos * 100) / cy_capsense_context.ptrWdConfig[CY_CAPSENSE_LINEARSLIDER0_WDGT_ID].xResolution;
|
||||
|
||||
led_update_req = true;
|
||||
}
|
||||
|
||||
@@ -61,8 +61,8 @@ menu "On-chip Peripheral Drivers"
|
||||
bool "Enable PWM0 channel3"
|
||||
default n
|
||||
if BSP_USING_PWM0_CH3
|
||||
config BSP_USING_PWM0_PORT13
|
||||
bool "Enable PWM0-PORT13 output pwm"
|
||||
config BSP_USING_PWM0_CH3_PORT13
|
||||
bool "Enable PWM0-CH3-PORT13 output pwm"
|
||||
default n
|
||||
endif
|
||||
menuconfig BSP_USING_PWM0_CH7
|
||||
@@ -270,7 +270,7 @@ menu "Board extended module Drivers"
|
||||
select BSP_USING_PWM
|
||||
select BSP_USING_PWM0
|
||||
select BSP_USING_PWM0_CH3
|
||||
select BSP_USING_PWM0_PORT13
|
||||
select BSP_USING_PWM0_CH3_PORT13
|
||||
default n
|
||||
endif
|
||||
|
||||
|
||||
@@ -14,16 +14,16 @@
|
||||
#ifdef BSP_USING_SLIDER
|
||||
#include "cycfg_capsense.h"
|
||||
|
||||
#define CAPSENSE_INTR_PRIORITY (7u)
|
||||
#define EZI2C_INTR_PRIORITY (6u)
|
||||
#define CAPSENSE_INTR_PRIORITY (7u)
|
||||
#define EZI2C_INTR_PRIORITY (6u)
|
||||
|
||||
/* Allowed duty cycle for maximum brightness */
|
||||
#define LED_MAX_BRIGHTNESS (100u)
|
||||
#define LED_MAX_BRIGHTNESS (100u)
|
||||
|
||||
/* Allowed duty cycle for minimum brightness*/
|
||||
#define LED_MIN_BRIGHTNESS (0u)
|
||||
#define LED_MIN_BRIGHTNESS (0u)
|
||||
|
||||
#define GET_DUTY_CYCLE(x) (1 * 1000 * 1000 - x * 10 * 1000)
|
||||
#define GET_DUTY_CYCLE(x) (1 * 1000 * 1000 - x * 10 * 1000)
|
||||
|
||||
typedef enum
|
||||
{
|
||||
@@ -41,11 +41,11 @@ static rt_sem_t trans_done_semphr = RT_NULL;
|
||||
static rt_thread_t sld_thread = RT_NULL;
|
||||
|
||||
#ifndef RT_USING_PWM
|
||||
#error You need enable PWM to use this sample
|
||||
#error You need enable PWM to use this sample
|
||||
#else
|
||||
#define PWM_DEV_NAME "pwm0"
|
||||
#define PWM_DEV_CHANNEL 3
|
||||
static struct rt_device_pwm *pwm_dev;
|
||||
#define PWM_DEV_NAME "pwm0"
|
||||
#define PWM_DEV_CHANNEL 3
|
||||
static struct rt_device_pwm *pwm_dev;
|
||||
#endif
|
||||
|
||||
static void capsense_isr(void)
|
||||
@@ -69,8 +69,7 @@ static uint32_t initialize_capsense(void)
|
||||
uint32_t status = CYRET_SUCCESS;
|
||||
|
||||
/* CapSense interrupt configuration parameters */
|
||||
static const cy_stc_sysint_t capSense_intr_config =
|
||||
{
|
||||
static const cy_stc_sysint_t capSense_intr_config = {
|
||||
.intrSrc = csd_interrupt_IRQn,
|
||||
.intrPriority = CAPSENSE_INTR_PRIORITY,
|
||||
};
|
||||
@@ -128,7 +127,7 @@ void Slider_Init(void)
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef BSP_USING_PWM0_PORT13
|
||||
#ifdef BSP_USING_PWM0_CH3_PORT13
|
||||
/* Initiate PWM*/
|
||||
pwm_dev = (struct rt_device_pwm *)rt_device_find(PWM_DEV_NAME);
|
||||
|
||||
@@ -163,20 +162,19 @@ static void process_touch(void)
|
||||
bool led_update_req = false;
|
||||
|
||||
static uint16_t slider_pos_prev;
|
||||
static led_data_t led_data = {LED_ON, LED_MAX_BRIGHTNESS};
|
||||
static led_data_t led_data = { LED_ON, LED_MAX_BRIGHTNESS };
|
||||
|
||||
/* Get slider status */
|
||||
slider_touch_info = Cy_CapSense_GetTouchInfo(
|
||||
CY_CAPSENSE_LINEARSLIDER0_WDGT_ID, &cy_capsense_context);
|
||||
CY_CAPSENSE_LINEARSLIDER0_WDGT_ID, &cy_capsense_context);
|
||||
slider_touch_status = slider_touch_info->numPosition;
|
||||
slider_pos = slider_touch_info->ptrPosition->x;
|
||||
|
||||
/* Detect the new touch on slider */
|
||||
if ((RT_NULL != slider_touch_status) &&
|
||||
(slider_pos != slider_pos_prev))
|
||||
(slider_pos != slider_pos_prev))
|
||||
{
|
||||
led_data.brightness = (slider_pos * 100)
|
||||
/ cy_capsense_context.ptrWdConfig[CY_CAPSENSE_LINEARSLIDER0_WDGT_ID].xResolution;
|
||||
led_data.brightness = (slider_pos * 100) / cy_capsense_context.ptrWdConfig[CY_CAPSENSE_LINEARSLIDER0_WDGT_ID].xResolution;
|
||||
|
||||
led_update_req = true;
|
||||
}
|
||||
|
||||
@@ -14,16 +14,16 @@
|
||||
#ifdef BSP_USING_SLIDER
|
||||
#include "cycfg_capsense.h"
|
||||
|
||||
#define CAPSENSE_INTR_PRIORITY (7u)
|
||||
#define EZI2C_INTR_PRIORITY (6u)
|
||||
#define CAPSENSE_INTR_PRIORITY (7u)
|
||||
#define EZI2C_INTR_PRIORITY (6u)
|
||||
|
||||
/* Allowed duty cycle for maximum brightness */
|
||||
#define LED_MAX_BRIGHTNESS (100u)
|
||||
#define LED_MAX_BRIGHTNESS (100u)
|
||||
|
||||
/* Allowed duty cycle for minimum brightness*/
|
||||
#define LED_MIN_BRIGHTNESS (0u)
|
||||
#define LED_MIN_BRIGHTNESS (0u)
|
||||
|
||||
#define GET_DUTY_CYCLE(x) (1 * 1000 * 1000 - x * 10 * 1000)
|
||||
#define GET_DUTY_CYCLE(x) (1 * 1000 * 1000 - x * 10 * 1000)
|
||||
|
||||
typedef enum
|
||||
{
|
||||
@@ -41,11 +41,11 @@ static rt_sem_t trans_done_semphr = RT_NULL;
|
||||
static rt_thread_t sld_thread = RT_NULL;
|
||||
|
||||
#ifndef RT_USING_PWM
|
||||
#error You need enable PWM to use this sample
|
||||
#error You need enable PWM to use this sample
|
||||
#else
|
||||
#define PWM_DEV_NAME "pwm0"
|
||||
#define PWM_DEV_CHANNEL 0
|
||||
static struct rt_device_pwm *pwm_dev;
|
||||
#define PWM_DEV_NAME "pwm0"
|
||||
#define PWM_DEV_CHANNEL 0
|
||||
static struct rt_device_pwm *pwm_dev;
|
||||
#endif
|
||||
|
||||
static void capsense_isr(void)
|
||||
@@ -69,8 +69,7 @@ static uint32_t initialize_capsense(void)
|
||||
uint32_t status = CYRET_SUCCESS;
|
||||
|
||||
/* CapSense interrupt configuration parameters */
|
||||
static const cy_stc_sysint_t capSense_intr_config =
|
||||
{
|
||||
static const cy_stc_sysint_t capSense_intr_config = {
|
||||
.intrSrc = csd_interrupt_IRQn,
|
||||
.intrPriority = CAPSENSE_INTR_PRIORITY,
|
||||
};
|
||||
@@ -128,7 +127,7 @@ void Slider_Init(void)
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef BSP_USING_PWM0_PORT0
|
||||
#ifdef BSP_USING_PWM0_CH0_PORT0
|
||||
/* Initiate PWM*/
|
||||
pwm_dev = (struct rt_device_pwm *)rt_device_find(PWM_DEV_NAME);
|
||||
|
||||
@@ -163,20 +162,19 @@ static void process_touch(void)
|
||||
bool led_update_req = false;
|
||||
|
||||
static uint16_t slider_pos_prev;
|
||||
static led_data_t led_data = {LED_ON, LED_MAX_BRIGHTNESS};
|
||||
static led_data_t led_data = { LED_ON, LED_MAX_BRIGHTNESS };
|
||||
|
||||
/* Get slider status */
|
||||
slider_touch_info = Cy_CapSense_GetTouchInfo(
|
||||
CY_CAPSENSE_LINEARSLIDER0_WDGT_ID, &cy_capsense_context);
|
||||
CY_CAPSENSE_LINEARSLIDER0_WDGT_ID, &cy_capsense_context);
|
||||
slider_touch_status = slider_touch_info->numPosition;
|
||||
slider_pos = slider_touch_info->ptrPosition->x;
|
||||
|
||||
/* Detect the new touch on slider */
|
||||
if ((RT_NULL != slider_touch_status) &&
|
||||
(slider_pos != slider_pos_prev))
|
||||
(slider_pos != slider_pos_prev))
|
||||
{
|
||||
led_data.brightness = (slider_pos * 100)
|
||||
/ cy_capsense_context.ptrWdConfig[CY_CAPSENSE_LINEARSLIDER0_WDGT_ID].xResolution;
|
||||
led_data.brightness = (slider_pos * 100) / cy_capsense_context.ptrWdConfig[CY_CAPSENSE_LINEARSLIDER0_WDGT_ID].xResolution;
|
||||
|
||||
led_update_req = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user