Skip to content

Commit

Permalink
[Infineon] Update P6 assets to latest tag along BT API changes (#20850)
Browse files Browse the repository at this point in the history
  • Loading branch information
praveenCY authored and web-flow committed Jul 18, 2022
1 parent 3d2e23a commit 03589a8
Show file tree
Hide file tree
Showing 41 changed files with 580 additions and 312 deletions.
2 changes: 1 addition & 1 deletion examples/all-clusters-app/p6/include/ButtonHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ class ButtonHandler

private:
static void GpioInit(void);
static void lightbuttonIsr(void * handler_arg, cyhal_gpio_event_t event);
static void light_button_callback(void * handler_arg, cyhal_gpio_event_t event);
static void TimerCallback(TimerHandle_t xTimer);
};
7 changes: 5 additions & 2 deletions examples/all-clusters-app/p6/src/ButtonHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,14 @@ void ButtonHandler::GpioInit(void)
}

/* Configure GPIO interrupt. */
cyhal_gpio_register_callback(APP_LIGHT_BUTTON, lightbuttonIsr, NULL);
static cyhal_gpio_callback_data_t light_button_cbdata;
light_button_cbdata.callback = light_button_callback;
light_button_cbdata.callback_arg = NULL;
cyhal_gpio_register_callback(APP_LIGHT_BUTTON, &light_button_cbdata);
cyhal_gpio_enable_event(APP_LIGHT_BUTTON, CYHAL_GPIO_IRQ_FALL, GPIO_INTERRUPT_PRIORITY, true);
}

void ButtonHandler::lightbuttonIsr(void * handler_arg, cyhal_gpio_event_t event)
void ButtonHandler::light_button_callback(void * handler_arg, cyhal_gpio_event_t event)
{
portBASE_TYPE taskWoken = pdFALSE;
xTimerStartFromISR(buttonTimer, &taskWoken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ class ButtonHandler

private:
static void GpioInit(void);
static void lightbuttonIsr(void * handler_arg, cyhal_gpio_event_t event);
static void light_button_callback(void * handler_arg, cyhal_gpio_event_t event);
static void TimerCallback(TimerHandle_t xTimer);
};
7 changes: 5 additions & 2 deletions examples/all-clusters-minimal-app/p6/src/ButtonHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,14 @@ void ButtonHandler::GpioInit(void)
}

/* Configure GPIO interrupt. */
cyhal_gpio_register_callback(APP_LIGHT_BUTTON, lightbuttonIsr, NULL);
static cyhal_gpio_callback_data_t light_button_cbdata;
light_button_cbdata.callback = light_button_callback;
light_button_cbdata.callback_arg = NULL;
cyhal_gpio_register_callback(APP_LIGHT_BUTTON, &light_button_cbdata);
cyhal_gpio_enable_event(APP_LIGHT_BUTTON, CYHAL_GPIO_IRQ_FALL, GPIO_INTERRUPT_PRIORITY, true);
}

void ButtonHandler::lightbuttonIsr(void * handler_arg, cyhal_gpio_event_t event)
void ButtonHandler::light_button_callback(void * handler_arg, cyhal_gpio_event_t event)
{
portBASE_TYPE taskWoken = pdFALSE;
xTimerStartFromISR(buttonTimer, &taskWoken);
Expand Down
4 changes: 2 additions & 2 deletions examples/lighting-app/p6/include/ButtonHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class ButtonHandler

private:
static void GpioInit(void);
static void lockbuttonIsr(void * handler_arg, cyhal_gpio_event_t event);
static void functionbuttonIsr(void * handler_arg, cyhal_gpio_event_t event);
static void light_button_callback(void * handler_arg, cyhal_gpio_event_t event);
static void func_button_callback(void * handler_arg, cyhal_gpio_event_t event);
static void TimerCallback(TimerHandle_t xTimer);
};
3 changes: 3 additions & 0 deletions examples/lighting-app/p6/include/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
#define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR 0xF00
#endif

// define Device type based on the application
#define CHIP_DEVICE_CONFIG_DEVICE_TYPE 257 // 0x0101 Dimmable Bulb

// For convenience, Chip Security Test Mode can be enabled and the
// requirement for authentication in various protocols can be disabled.
//
Expand Down
14 changes: 10 additions & 4 deletions examples/lighting-app/p6/src/ButtonHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,24 @@ void ButtonHandler::GpioInit(void)
printf(" cyhal_gpio_init failed for APP_FUNCTION_BUTTON\r\n");
}
/* Configure GPIO interrupt. */
cyhal_gpio_register_callback(APP_LIGHT_BUTTON, lockbuttonIsr, NULL);
cyhal_gpio_register_callback(APP_FUNCTION_BUTTON, functionbuttonIsr, NULL);
static cyhal_gpio_callback_data_t light_button_cbdata;
static cyhal_gpio_callback_data_t func_button_cbdata;
light_button_cbdata.callback = light_button_callback;
light_button_cbdata.callback_arg = NULL;
cyhal_gpio_register_callback(APP_LIGHT_BUTTON, &light_button_cbdata);
func_button_cbdata.callback = func_button_callback;
func_button_cbdata.callback_arg = NULL;
cyhal_gpio_register_callback(APP_FUNCTION_BUTTON, &func_button_cbdata);
cyhal_gpio_enable_event(APP_LIGHT_BUTTON, CYHAL_GPIO_IRQ_FALL, GPIO_INTERRUPT_PRIORITY, true);
cyhal_gpio_enable_event(APP_FUNCTION_BUTTON, CYHAL_GPIO_IRQ_FALL, GPIO_INTERRUPT_PRIORITY, true);
}
void ButtonHandler::lockbuttonIsr(void * handler_arg, cyhal_gpio_event_t event)
void ButtonHandler::light_button_callback(void * handler_arg, cyhal_gpio_event_t event)
{
portBASE_TYPE taskWoken = pdFALSE;
xTimerStartFromISR(buttonTimers[APP_LIGHT_BUTTON_IDX], &taskWoken);
}

void ButtonHandler::functionbuttonIsr(void * handler_arg, cyhal_gpio_event_t event)
void ButtonHandler::func_button_callback(void * handler_arg, cyhal_gpio_event_t event)
{
portBASE_TYPE taskWoken = pdFALSE;
xTimerStartFromISR(buttonTimers[APP_FUNCTION_BUTTON_IDX], &taskWoken);
Expand Down
4 changes: 2 additions & 2 deletions examples/lock-app/p6/include/ButtonHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class ButtonHandler

private:
static void GpioInit(void);
static void lockbuttonIsr(void * handler_arg, cyhal_gpio_event_t event);
static void functionbuttonIsr(void * handler_arg, cyhal_gpio_event_t event);
static void lock_button_callback(void * handler_arg, cyhal_gpio_event_t event);
static void func_button_callback(void * handler_arg, cyhal_gpio_event_t event);
static void TimerCallback(TimerHandle_t xTimer);
};
3 changes: 3 additions & 0 deletions examples/lock-app/p6/include/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
#endif
#define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR 0xF00

// define Device type based on the application
#define CHIP_DEVICE_CONFIG_DEVICE_TYPE 10 // 0x00A Door lock

// For convenience, Chip Security Test Mode can be enabled and the
// requirement for authentication in various protocols can be disabled.
//
Expand Down
14 changes: 10 additions & 4 deletions examples/lock-app/p6/src/ButtonHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,24 @@ void ButtonHandler::GpioInit(void)
printf(" cyhal_gpio_init failed for APP_FUNCTION_BUTTON\r\n");
}
/* Configure GPIO interrupt. */
cyhal_gpio_register_callback(APP_LOCK_BUTTON, lockbuttonIsr, NULL);
cyhal_gpio_register_callback(APP_FUNCTION_BUTTON, functionbuttonIsr, NULL);
static cyhal_gpio_callback_data_t lock_button_cbdata;
static cyhal_gpio_callback_data_t func_button_cbdata;
lock_button_cbdata.callback = lock_button_callback;
lock_button_cbdata.callback_arg = NULL;
cyhal_gpio_register_callback(APP_LOCK_BUTTON, &lock_button_cbdata);
func_button_cbdata.callback = func_button_callback;
func_button_cbdata.callback_arg = NULL;
cyhal_gpio_register_callback(APP_FUNCTION_BUTTON, &func_button_cbdata);
cyhal_gpio_enable_event(APP_LOCK_BUTTON, CYHAL_GPIO_IRQ_FALL, GPIO_INTERRUPT_PRIORITY, true);
cyhal_gpio_enable_event(APP_FUNCTION_BUTTON, CYHAL_GPIO_IRQ_FALL, GPIO_INTERRUPT_PRIORITY, true);
}
void ButtonHandler::lockbuttonIsr(void * handler_arg, cyhal_gpio_event_t event)
void ButtonHandler::lock_button_callback(void * handler_arg, cyhal_gpio_event_t event)
{
portBASE_TYPE taskWoken = pdFALSE;
xTimerStartFromISR(buttonTimers[APP_LOCK_BUTTON_IDX], &taskWoken);
}

void ButtonHandler::functionbuttonIsr(void * handler_arg, cyhal_gpio_event_t event)
void ButtonHandler::func_button_callback(void * handler_arg, cyhal_gpio_event_t event)
{
portBASE_TYPE taskWoken = pdFALSE;
xTimerStartFromISR(buttonTimers[APP_FUNCTION_BUTTON_IDX], &taskWoken);
Expand Down
4 changes: 2 additions & 2 deletions examples/ota-requestor-app/p6/include/ButtonHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ButtonHandler

private:
static void GpioInit(void);
static void lockbuttonIsr(void * handler_arg, cyhal_gpio_event_t event);
static void functionbuttonIsr(void * handler_arg, cyhal_gpio_event_t event);
static void update_button_callback(void * handler_arg, cyhal_gpio_event_t event);
static void func_button_callback(void * handler_arg, cyhal_gpio_event_t event);
static void TimerCallback(TimerHandle_t xTimer);
};
19 changes: 15 additions & 4 deletions examples/ota-requestor-app/p6/src/ButtonHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,30 @@ void ButtonHandler::GpioInit(void)
printf(" cyhal_gpio_init failed for APP_FUNCTION_BUTTON\r\n");
}
/* Configure GPIO interrupt. */
cyhal_gpio_register_callback(APP_UPDATE_BUTTON, lockbuttonIsr, NULL);
cyhal_gpio_register_callback(APP_FUNCTION_BUTTON, functionbuttonIsr, NULL);
static cyhal_gpio_callback_data_t update_button_cbdata;
static cyhal_gpio_callback_data_t func_button_cbdata;

/* Register for Update Button */
update_button_cbdata.callback = update_button_callback;
update_button_cbdata.callback_arg = NULL;
cyhal_gpio_register_callback(APP_UPDATE_BUTTON, &update_button_cbdata);

/* Register for Function Button for factory reset */
func_button_cbdata.callback = func_button_callback;
func_button_cbdata.callback_arg = NULL;
cyhal_gpio_register_callback(APP_FUNCTION_BUTTON, &func_button_cbdata);

cyhal_gpio_enable_event(APP_UPDATE_BUTTON, CYHAL_GPIO_IRQ_FALL, GPIO_INTERRUPT_PRIORITY, true);
cyhal_gpio_enable_event(APP_FUNCTION_BUTTON, CYHAL_GPIO_IRQ_FALL, GPIO_INTERRUPT_PRIORITY, true);
}

void ButtonHandler::lockbuttonIsr(void * handler_arg, cyhal_gpio_event_t event)
void ButtonHandler::update_button_callback(void * handler_arg, cyhal_gpio_event_t event)
{
portBASE_TYPE taskWoken = pdFALSE;
xTimerStartFromISR(buttonTimers[APP_UPDATE_BUTTON_IDX], &taskWoken);
}

void ButtonHandler::functionbuttonIsr(void * handler_arg, cyhal_gpio_event_t event)
void ButtonHandler::func_button_callback(void * handler_arg, cyhal_gpio_event_t event)
{
portBASE_TYPE taskWoken = pdFALSE;
xTimerStartFromISR(buttonTimers[APP_FUNCTION_BUTTON_IDX], &taskWoken);
Expand Down
12 changes: 5 additions & 7 deletions examples/platform/p6/LEDWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,11 @@ void LEDWidget::Init(int ledNum)
mLedNum = ledNum;
mState = 0;
mbrightness = LED_MAX_BRIGHTNESS;
if (CY_RSLT_SUCCESS != cyhal_pwm_init(&pwm_led, (cyhal_gpio_t) ledNum, NULL))
{
printf("LED PWM Init failed!");
}
if (CY_RSLT_SUCCESS != cyhal_pwm_set_duty_cycle(&pwm_led, GET_DUTY_CYCLE(LED_MAX_BRIGHTNESS), PWM_LED_FREQ_HZ))

if (CY_RSLT_SUCCESS !=
cyhal_gpio_init((cyhal_gpio_t) ledNum, CYHAL_GPIO_DIR_OUTPUT, CYHAL_GPIO_DRIVE_STRONG, CYBSP_LED_STATE_OFF))
{
printf("PWM failed to set dutycycle!");
printf("GPIO Init failed for Led %d \r\n", ledNum);
}
}

Expand Down Expand Up @@ -110,7 +108,7 @@ void LEDWidget::DoSet(bool state)
{
if (mState != state)
{
(state) ? PWM_start() : PWM_stop();
cyhal_gpio_write((cyhal_gpio_t) mLedNum, ((state) ? CYBSP_LED_STATE_ON : CYBSP_LED_STATE_OFF));
}
mState = state;
}
Expand Down
Loading

0 comments on commit 03589a8

Please sign in to comment.