mirror of https://github.com/ARMmbed/mbed-os.git
Simplify BSP contents
Remove some (Cypress-proprietary) BSP interfaces and hardware initialization from the BSPs which is better implemented by a library or application firmware. Move some remaining functionality from common to the individual targets.pull/11542/head
parent
4ec3ad1850
commit
70590006cb
|
@ -1,9 +1,9 @@
|
|||
/***************************************************************************//**
|
||||
* \file CY8CKIT-062S2-43012/cybsp.c
|
||||
* \file cybsp.c
|
||||
*
|
||||
* Description:
|
||||
* Provides APIs for interacting with the hardware contained on the Cypress
|
||||
* CY8CKIT-062S2-43012 pioneer kit.
|
||||
* Provides initialization code for starting up the hardware contained on the
|
||||
* Cypress board.
|
||||
*
|
||||
********************************************************************************
|
||||
* \copyright
|
||||
|
@ -32,6 +32,15 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* The sysclk deep sleep callback is recommended to be the last callback that
|
||||
* is executed before entry into deep sleep mode and the first one upon
|
||||
* exit the deep sleep mode.
|
||||
* Doing so minimizes the time spent on low power mode entry and exit.
|
||||
*/
|
||||
#ifndef CYBSP_SYSCLK_PM_CALLBACK_ORDER
|
||||
#define CYBSP_SYSCLK_PM_CALLBACK_ORDER (255u)
|
||||
#endif
|
||||
|
||||
#if defined(CYBSP_WIFI_CAPABLE)
|
||||
static cyhal_sdio_t sdio_obj;
|
||||
|
||||
|
@ -41,6 +50,29 @@ cyhal_sdio_t* cybsp_get_wifi_sdio_obj(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Registers a power management callback that prepares the clock system
|
||||
* for entering deep sleep mode and restore the clocks upon wakeup from deep sleep.
|
||||
* NOTE: This is called automatically as part of \ref cybsp_init
|
||||
*/
|
||||
static cy_rslt_t cybsp_register_sysclk_pm_callback(void)
|
||||
{
|
||||
cy_rslt_t result = CY_RSLT_SUCCESS;
|
||||
static cy_stc_syspm_callback_params_t cybsp_sysclk_pm_callback_param = {NULL, NULL};
|
||||
static cy_stc_syspm_callback_t cybsp_sysclk_pm_callback = {
|
||||
.callback = &Cy_SysClk_DeepSleepCallback,
|
||||
.type = CY_SYSPM_DEEPSLEEP,
|
||||
.callbackParams = &cybsp_sysclk_pm_callback_param,
|
||||
.order = CYBSP_SYSCLK_PM_CALLBACK_ORDER
|
||||
};
|
||||
|
||||
if (!Cy_SysPm_RegisterCallback(&cybsp_sysclk_pm_callback))
|
||||
{
|
||||
result = CYBSP_RSLT_ERR_SYSCLK_PM_CALLBACK;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
cy_rslt_t cybsp_init(void)
|
||||
{
|
||||
/* Setup hardware manager to track resource usage then initialize all system (clock/power) board configuration */
|
||||
|
@ -52,38 +84,6 @@ cy_rslt_t cybsp_init(void)
|
|||
result = cybsp_register_sysclk_pm_callback();
|
||||
}
|
||||
|
||||
#ifndef __MBED__
|
||||
if (CY_RSLT_SUCCESS == result)
|
||||
{
|
||||
/* Initialize User LEDs */
|
||||
/* Reserves: CYBSP_USER_LED1 */
|
||||
result |= cybsp_led_init(CYBSP_USER_LED1);
|
||||
/* Reserves: CYBSP_USER_LED2 */
|
||||
result |= cybsp_led_init(CYBSP_USER_LED2);
|
||||
/* Reserves: CYBSP_USER_LED3 */
|
||||
result |= cybsp_led_init(CYBSP_USER_LED3);
|
||||
/* Reserves: CYBSP_USER_LED4 */
|
||||
result |= cybsp_led_init(CYBSP_USER_LED4);
|
||||
/* Reserves: CYBSP_USER_LED5 */
|
||||
result |= cybsp_led_init(CYBSP_USER_LED5);
|
||||
/* Initialize User Buttons */
|
||||
/* Reserves: CYBSP_USER_BTN1 */
|
||||
result |= cybsp_btn_init(CYBSP_USER_BTN1);
|
||||
/* Reserves: CYBSP_USER_BTN2 */
|
||||
result |= cybsp_btn_init(CYBSP_USER_BTN2);
|
||||
|
||||
CY_ASSERT(CY_RSLT_SUCCESS == result);
|
||||
|
||||
/* Initialize retargetting stdio to 'DEBUG_UART' peripheral */
|
||||
if (CY_RSLT_SUCCESS == result)
|
||||
{
|
||||
/* Reserves: CYBSP_DEBUG_UART_RX, CYBSP_DEBUG_UART_TX, CYBSP_DEBUG_UART_RTS, CYBSP_DEBUG_UART_CTS
|
||||
* corresponding SCB instance and one of available clock dividers */
|
||||
result = cybsp_retarget_init();
|
||||
}
|
||||
}
|
||||
#endif /* __MBED__ */
|
||||
|
||||
#if defined(CYBSP_WIFI_CAPABLE)
|
||||
/* Initialize SDIO interface. This must be done before other HAL API calls as some SDIO implementations require
|
||||
* specific peripheral instances.
|
||||
|
@ -107,8 +107,9 @@ cy_rslt_t cybsp_init(void)
|
|||
#endif /* defined(CYBSP_WIFI_CAPABLE) */
|
||||
|
||||
/* CYHAL_HWMGR_RSLT_ERR_INUSE error code could be returned if any needed for BSP resource was reserved by
|
||||
* user previously. Please review the Device Configurator (design.modus) and the BSP reservation list
|
||||
* (cyreservedresources.list) to make sure no resources are reserved by both. */
|
||||
* user previously. Please review the Device Configurator (design.modus) and the BSP reservation list
|
||||
* (cyreservedresources.list) to make sure no resources are reserved by both.
|
||||
*/
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
/***************************************************************************//**
|
||||
* \file CY8CKIT-062S2-43012/cybsp.h
|
||||
* \file cybsp.h
|
||||
*
|
||||
* Description:
|
||||
* Provides APIs for interacting with the hardware contained on the Cypress
|
||||
* CY8CKIT-062S2-43012 pioneer kit.
|
||||
* \brief
|
||||
* Basic API for setting up boards containing a Cypress MCU.
|
||||
*
|
||||
********************************************************************************
|
||||
* \copyright
|
||||
|
@ -25,21 +24,25 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "cy_result.h"
|
||||
#include "cybsp_types.h"
|
||||
#include "cybsp_core.h"
|
||||
#if defined(CYBSP_WIFI_CAPABLE)
|
||||
#include "cyhal_sdio.h"
|
||||
#endif
|
||||
#ifndef __MBED__
|
||||
#include "cybsp_retarget.h"
|
||||
#include "cybsp_serial_flash.h"
|
||||
#include "cybsp_rgb_led.h"
|
||||
#endif /* __MBED__ */
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \addtogroup group_bsp_macros Macros
|
||||
* \{
|
||||
*/
|
||||
|
||||
/** Failed to configure sysclk power management callback */
|
||||
#define CYBSP_RSLT_ERR_SYSCLK_PM_CALLBACK (CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_ABSTRACTION_BSP, 0))
|
||||
|
||||
/** \} group_bsp_macros */
|
||||
|
||||
/**
|
||||
* \addtogroup group_bsp_functions Functions
|
||||
|
|
|
@ -25,256 +25,221 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "cyhal.h"
|
||||
#include "cyhal_pin_package.h"
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* \addtogroup group_bsp_pin_state Pin States
|
||||
* \{
|
||||
*/
|
||||
|
||||
/** Pin state for the LED on. */
|
||||
#define CYBSP_LED_STATE_ON (0U)
|
||||
/** Pin state for the LED off. */
|
||||
#define CYBSP_LED_STATE_OFF (1U)
|
||||
|
||||
/** Pin state for when a button is pressed. */
|
||||
#define CYBSP_BTN_PRESSED (0U)
|
||||
/** Pin state for when a button is released. */
|
||||
#define CYBSP_BTN_OFF (1U)
|
||||
|
||||
/** \} group_bsp_pin_state */
|
||||
|
||||
|
||||
/**
|
||||
* \addtogroup group_bsp_pins Pin Mappings
|
||||
* \{
|
||||
*/
|
||||
|
||||
// Arduino connector namings
|
||||
/** Arduino A0 */
|
||||
#define CYBSP_A0 P10_0
|
||||
/** Arduino A1 */
|
||||
#define CYBSP_A1 P10_1
|
||||
/** Arduino A2 */
|
||||
#define CYBSP_A2 P10_2
|
||||
/** Arduino A3 */
|
||||
#define CYBSP_A3 P10_3
|
||||
/** Arduino A4 */
|
||||
#define CYBSP_A4 P10_4
|
||||
/** Arduino A5 */
|
||||
#define CYBSP_A5 P10_5
|
||||
/** Arduino D0 */
|
||||
#define CYBSP_D0 P5_0
|
||||
/** Arduino D1 */
|
||||
#define CYBSP_D1 P5_1
|
||||
/** Arduino D2 */
|
||||
#define CYBSP_D2 P5_2
|
||||
/** Arduino D3 */
|
||||
#define CYBSP_D3 P5_3
|
||||
/** Arduino D4 */
|
||||
#define CYBSP_D4 P5_4
|
||||
/** Arduino D5 */
|
||||
#define CYBSP_D5 P5_5
|
||||
/** Arduino D6 */
|
||||
#define CYBSP_D6 P5_6
|
||||
/** Arduino D7 */
|
||||
#define CYBSP_D7 P0_2
|
||||
/** Arduino D8 */
|
||||
#define CYBSP_D8 P13_0
|
||||
/** Arduino D9 */
|
||||
#define CYBSP_D9 P13_1
|
||||
/** Arduino D10 */
|
||||
#define CYBSP_D10 P12_3
|
||||
/** Arduino D11 */
|
||||
#define CYBSP_D11 P12_0
|
||||
/** Arduino D12 */
|
||||
#define CYBSP_D12 P12_1
|
||||
/** Arduino D13 */
|
||||
#define CYBSP_D13 P12_2
|
||||
/** Arduino D14 */
|
||||
#define CYBSP_D14 P6_1
|
||||
/** Arduino D15 */
|
||||
#define CYBSP_D15 P6_0
|
||||
|
||||
|
||||
/** Pin: WCO input */
|
||||
#define CYBSP_WCO_IN P0_0
|
||||
/** Pin: WCO output */
|
||||
#define CYBSP_WCO_OUT P0_1
|
||||
|
||||
/** Pin: WIFI SDIO D0 */
|
||||
/* Corresponds to: ioss[0].port[2].pin[0], sdhc[0] */
|
||||
#define CYBSP_WIFI_SDIO_D0 P2_0
|
||||
/** Pin: WIFI SDIO D1 */
|
||||
/* Corresponds to: ioss[0].port[2].pin[1], sdhc[0] */
|
||||
#define CYBSP_WIFI_SDIO_D1 P2_1
|
||||
/** Pin: WIFI SDIO D2 */
|
||||
/* Corresponds to: ioss[0].port[2].pin[2], sdhc[0] */
|
||||
#define CYBSP_WIFI_SDIO_D2 P2_2
|
||||
/** Pin: WIFI SDIO D3 */
|
||||
/* Corresponds to: ioss[0].port[2].pin[3], sdhc[0] */
|
||||
#define CYBSP_WIFI_SDIO_D3 P2_3
|
||||
/** Pin: WIFI SDIO CMD */
|
||||
/* Corresponds to: ioss[0].port[2].pin[4], sdhc[0] */
|
||||
#define CYBSP_WIFI_SDIO_CMD P2_4
|
||||
/** Pin: WIFI SDIO CLK */
|
||||
/* Corresponds to: ioss[0].port[2].pin[5], sdhc[0] */
|
||||
#define CYBSP_WIFI_SDIO_CLK P2_5
|
||||
/** Pin: WIFI ON */
|
||||
/* Corresponds to: ioss[0].port[2].pin[6], sdhc[0] */
|
||||
#define CYBSP_WIFI_WL_REG_ON P2_6
|
||||
/** Pin: WIFI Host Wakeup */
|
||||
#define CYBSP_WIFI_HOST_WAKE P4_1
|
||||
|
||||
/** Pin: BT UART RX */
|
||||
#define CYBSP_BT_UART_RX P3_0
|
||||
/** Pin: BT UART TX */
|
||||
#define CYBSP_BT_UART_TX P3_1
|
||||
/** Pin: BT UART RTS */
|
||||
#define CYBSP_BT_UART_RTS P3_2
|
||||
/** Pin: BT UART CTS */
|
||||
#define CYBSP_BT_UART_CTS P3_3
|
||||
/** Pin: BT Power */
|
||||
#define CYBSP_BT_POWER P3_4
|
||||
/** Pin: BT Host Wakeup */
|
||||
#define CYBSP_BT_HOST_WAKE P4_0
|
||||
/** Pin: BT Device Wakeup */
|
||||
#define CYBSP_BT_DEVICE_WAKE P3_5
|
||||
|
||||
/** Pin: UART RX */
|
||||
/* Corresponds to: ioss[0].port[5].pin[0], scb[5] */
|
||||
#define CYBSP_DEBUG_UART_RX P5_0
|
||||
/** Pin: UART TX */
|
||||
/* Corresponds to: ioss[0].port[5].pin[1], scb[5] */
|
||||
#define CYBSP_DEBUG_UART_TX P5_1
|
||||
/** Pin: UART RX */
|
||||
/* Corresponds to: ioss[0].port[5].pin[2], scb[5] */
|
||||
#define CYBSP_DEBUG_UART_RTS P5_2
|
||||
/** Pin: UART TX */
|
||||
/* Corresponds to: ioss[0].port[5].pin[3], scb[5] */
|
||||
#define CYBSP_DEBUG_UART_CTS P5_3
|
||||
|
||||
/** Pin: I2C SCL */
|
||||
#define CYBSP_I2C_SCL P6_0
|
||||
/** Pin: I2C SDA */
|
||||
#define CYBSP_I2C_SDA P6_1
|
||||
|
||||
/** Pin: SWO */
|
||||
#define CYBSP_SWO P6_4
|
||||
/** Pin: SWDIO */
|
||||
#define CYBSP_SWDIO P6_6
|
||||
/** Pin: SWDCK */
|
||||
#define CYBSP_SWDCK P6_7
|
||||
|
||||
/** Pin: CapSesnse RX */
|
||||
#define CYBSP_CSD_RX P1_0
|
||||
/** Pin: CapSesnse CINA */
|
||||
#define CYBSP_CINA P7_1
|
||||
/** Pin: CapSesnse CINB */
|
||||
#define CYBSP_CINB P7_2
|
||||
/** Pin: CapSesnse CMOD */
|
||||
#define CYBSP_CMOD P7_7
|
||||
/** Pin: CapSesnse Button 0 */
|
||||
#define CYBSP_CSD_BTN0 P8_1
|
||||
/** Pin: CapSesnse Button 1 */
|
||||
#define CYBSP_CSD_BTN1 P8_2
|
||||
/** Pin: CapSesnse Slider 0 */
|
||||
#define CYBSP_CSD_SLD0 P8_3
|
||||
/** Pin: CapSesnse Slider 1 */
|
||||
#define CYBSP_CSD_SLD1 P8_4
|
||||
/** Pin: CapSesnse Slider 2 */
|
||||
#define CYBSP_CSD_SLD2 P8_5
|
||||
/** Pin: CapSesnse Slider 3 */
|
||||
#define CYBSP_CSD_SLD3 P8_6
|
||||
/** Pin: CapSesnse Slider 4 */
|
||||
#define CYBSP_CSD_SLD4 P8_7
|
||||
|
||||
/** Pin: QUAD SPI SS */
|
||||
#define CYBSP_QSPI_SS P11_2
|
||||
/** Pin: QUAD SPI D3 */
|
||||
#define CYBSP_QSPI_D3 P11_3
|
||||
/** Pin: QUAD SPI D2 */
|
||||
#define CYBSP_QSPI_D2 P11_4
|
||||
/** Pin: QUAD SPI D1 */
|
||||
#define CYBSP_QSPI_D1 P11_5
|
||||
/** Pin: QUAD SPI D0 */
|
||||
#define CYBSP_QSPI_D0 P11_6
|
||||
/** Pin: QUAD SPI SCK */
|
||||
#define CYBSP_QSPI_SCK P11_7
|
||||
|
||||
/** Host-wake GPIO drive mode */
|
||||
#define CYBSP_WIFI_HOST_WAKE_GPIO_DM CYHAL_GPIO_DRIVE_ANALOG
|
||||
/** Host-wake IRQ event */
|
||||
#define CYBSP_WIFI_HOST_WAKE_IRQ_EVENT CYHAL_GPIO_IRQ_RISE
|
||||
|
||||
/** BSP user LED reference designator to pin mapping */
|
||||
#define LED9_R P11_1
|
||||
/** BSP user LED reference designator to pin mapping */
|
||||
#define LED8_O P1_5
|
||||
/** BSP user LED reference designator to pin mapping */
|
||||
#define LED5_RGB_R P1_1
|
||||
/** BSP user LED reference designator to pin mapping */
|
||||
#define LED5_RGB_G P0_5
|
||||
/** BSP user LED reference designator to pin mapping */
|
||||
#define LED5_RGB_B P7_3
|
||||
|
||||
/** BSP LED defines by LED color */
|
||||
#define CYBSP_LED_RED LED5_RGB_R
|
||||
/** BSP LED defines by LED color */
|
||||
#define CYBSP_LED_GREEN LED5_RGB_G
|
||||
/** BSP LED defines by LED color */
|
||||
#define CYBSP_LED_BLUE LED5_RGB_B
|
||||
/** BSP LED defines by LED color */
|
||||
#define CYBSP_LED_ORANGE LED8
|
||||
|
||||
|
||||
/** BSP user button reference designator to pin mapping */
|
||||
#define SW2 P0_4
|
||||
/** BSP user button reference designator to pin mapping */
|
||||
#define SW4 P1_4
|
||||
|
||||
|
||||
/** \} group_bsp_cy8ckit_pins */
|
||||
|
||||
/**
|
||||
* \addtogroup group_bsp_enums Enumerated Types
|
||||
* \addtogroup group_bsp_pins_led LED Pins
|
||||
* \{
|
||||
*/
|
||||
|
||||
/** Enum defining the different states for the LED. */
|
||||
typedef enum
|
||||
{
|
||||
CYBSP_LED_STATE_ON = 0,
|
||||
CYBSP_LED_STATE_OFF = 1,
|
||||
} cybsp_led_state_t;
|
||||
/** LED 8; User LED1 (orange) */
|
||||
#define CYBSP_LED8 (P1_5)
|
||||
/** LED 9; User LED2 (red) */
|
||||
#define CYBSP_LED9 (P11_1)
|
||||
/** LED 5: RGB LED - Red; User LED3 */
|
||||
#define CYBSP_LED_RGB_RED (P1_1)
|
||||
/** LED 5: RGB LED - Green; User LED4 */
|
||||
#define CYBSP_LED_RGB_GREEN (P0_5)
|
||||
/** LED 5: RGB LED - Blue; User LED5 */
|
||||
#define CYBSP_LED_RGB_BLUE (P7_3)
|
||||
|
||||
/** Enum defining the different states for a button. */
|
||||
typedef enum
|
||||
{
|
||||
CYBSP_BTN_PRESSED = 0,
|
||||
CYBSP_BTN_OFF = 1,
|
||||
} cybsp_btn_state_t;
|
||||
/** LED 8; User LED1 (orange) */
|
||||
#define CYBSP_USER_LED1 (CYBSP_LED8)
|
||||
/** LED 9; User LED2 (red) */
|
||||
#define CYBSP_USER_LED2 (CYBSP_LED9)
|
||||
/** LED 5: RGB LED - Red; User LED3 */
|
||||
#define CYBSP_USER_LED3 (CYBSP_LED_RGB_RED)
|
||||
/** LED 5: RGB LED - Green; User LED4 */
|
||||
#define CYBSP_USER_LED4 (CYBSP_LED_RGB_GREEN)
|
||||
/** LED 5: RGB LED - Blue; User LED5 */
|
||||
#define CYBSP_USER_LED5 (CYBSP_LED_RGB_BLUE)
|
||||
/** LED 8; User LED1 (orange) */
|
||||
#define CYBSP_USER_LED (CYBSP_USER_LED1)
|
||||
|
||||
/** \} group_bsp_pins_led */
|
||||
|
||||
|
||||
/** Enum defining the different user LEDs available on the board. */
|
||||
typedef enum
|
||||
{
|
||||
CYBSP_LED_RGB_RED = LED5_RGB_R,
|
||||
CYBSP_LED_RGB_GREEN = LED5_RGB_G,
|
||||
CYBSP_LED_RGB_BLUE = LED5_RGB_B,
|
||||
/**
|
||||
* \addtogroup group_bsp_pins_btn Button Pins
|
||||
* \{
|
||||
*/
|
||||
|
||||
/* Corresponds to: ioss[0].port[11].pin[1] */
|
||||
CYBSP_USER_LED1 = LED9_R,
|
||||
/* Corresponds to: ioss[0].port[1].pin[5] */
|
||||
CYBSP_USER_LED2 = LED8_O,
|
||||
/* Corresponds to: ioss[0].port[1].pin[1] */
|
||||
CYBSP_USER_LED3 = CYBSP_LED_RGB_RED,
|
||||
/* Corresponds to: ioss[0].port[0].pin[5] */
|
||||
CYBSP_USER_LED4 = CYBSP_LED_RGB_GREEN,
|
||||
/* Corresponds to: ioss[0].port[7].pin[3] */
|
||||
CYBSP_USER_LED5 = CYBSP_LED_RGB_BLUE,
|
||||
CYBSP_USER_LED = CYBSP_USER_LED1,
|
||||
} cybsp_led_t;
|
||||
/** Switch 2; User Button 1 */
|
||||
#define CYBSP_SW2 (P0_4)
|
||||
/** Switch 4; User Button 2 */
|
||||
#define CYBSP_SW4 (P1_4)
|
||||
|
||||
/** Switch 2; User Button 1 */
|
||||
#define CYBSP_USER_BTN1 (CYBSP_SW2)
|
||||
/** Switch 4; User Button 2 */
|
||||
#define CYBSP_USER_BTN2 (CYBSP_SW4)
|
||||
/** Switch 2; User Button 1 */
|
||||
#define CYBSP_USER_BTN (CYBSP_USER_BTN1)
|
||||
|
||||
/** \} group_bsp_pins_btn */
|
||||
|
||||
|
||||
/** Enum defining the different user buttons available on the board. */
|
||||
typedef enum
|
||||
{
|
||||
/* Corresponds to: ioss[0].port[0].pin[4] */
|
||||
CYBSP_USER_BTN1 = SW2,
|
||||
/* Corresponds to: ioss[0].port[1].pin[4] */
|
||||
CYBSP_USER_BTN2 = SW4,
|
||||
CYBSP_USER_BTN = CYBSP_USER_BTN1,
|
||||
} cybsp_btn_t;
|
||||
/**
|
||||
* \addtogroup group_bsp_pins_comm Communication Pins
|
||||
* \{
|
||||
*/
|
||||
|
||||
/** Pin: WIFI SDIO D0 */
|
||||
#define CYBSP_WIFI_SDIO_D0 (P2_0)
|
||||
/** Pin: WIFI SDIO D1 */
|
||||
#define CYBSP_WIFI_SDIO_D1 (P2_1)
|
||||
/** Pin: WIFI SDIO D2 */
|
||||
#define CYBSP_WIFI_SDIO_D2 (P2_2)
|
||||
/** Pin: WIFI SDIO D3 */
|
||||
#define CYBSP_WIFI_SDIO_D3 (P2_3)
|
||||
/** Pin: WIFI SDIO CMD */
|
||||
#define CYBSP_WIFI_SDIO_CMD (P2_4)
|
||||
/** Pin: WIFI SDIO CLK */
|
||||
#define CYBSP_WIFI_SDIO_CLK (P2_5)
|
||||
/** Pin: WIFI ON */
|
||||
#define CYBSP_WIFI_WL_REG_ON (P2_6)
|
||||
/** Pin: WIFI Host Wakeup */
|
||||
#define CYBSP_WIFI_HOST_WAKE (P4_1)
|
||||
|
||||
/** Pin: BT UART RX */
|
||||
#define CYBSP_BT_UART_RX (P3_0)
|
||||
/** Pin: BT UART TX */
|
||||
#define CYBSP_BT_UART_TX (P3_1)
|
||||
/** Pin: BT UART RTS */
|
||||
#define CYBSP_BT_UART_RTS (P3_2)
|
||||
/** Pin: BT UART CTS */
|
||||
#define CYBSP_BT_UART_CTS (P3_3)
|
||||
|
||||
/** Pin: BT Power */
|
||||
#define CYBSP_BT_POWER (P3_4)
|
||||
/** Pin: BT Host Wakeup */
|
||||
#define CYBSP_BT_HOST_WAKE (P4_0)
|
||||
/** Pin: BT Device Wakeup */
|
||||
#define CYBSP_BT_DEVICE_WAKE (P3_5)
|
||||
|
||||
/** Pin: UART RX */
|
||||
#define CYBSP_DEBUG_UART_RX (P5_0)
|
||||
/** Pin: UART TX */
|
||||
#define CYBSP_DEBUG_UART_TX (P5_1)
|
||||
/** Pin: UART RX */
|
||||
#define CYBSP_DEBUG_UART_RTS (P5_2)
|
||||
/** Pin: UART TX */
|
||||
#define CYBSP_DEBUG_UART_CTS (P5_3)
|
||||
|
||||
/** Pin: I2C SCL */
|
||||
#define CYBSP_I2C_SCL (P6_0)
|
||||
/** Pin: I2C SDA */
|
||||
#define CYBSP_I2C_SDA (P6_1)
|
||||
|
||||
/** Pin: SWO */
|
||||
#define CYBSP_SWO (P6_4)
|
||||
/** Pin: SWDIO */
|
||||
#define CYBSP_SWDIO (P6_6)
|
||||
/** Pin: SWDCK */
|
||||
#define CYBSP_SWDCK (P6_7)
|
||||
|
||||
/** Pin: QUAD SPI SS */
|
||||
#define CYBSP_QSPI_SS (P11_2)
|
||||
/** Pin: QUAD SPI D3 */
|
||||
#define CYBSP_QSPI_D3 (P11_3)
|
||||
/** Pin: QUAD SPI D2 */
|
||||
#define CYBSP_QSPI_D2 (P11_4)
|
||||
/** Pin: QUAD SPI D1 */
|
||||
#define CYBSP_QSPI_D1 (P11_5)
|
||||
/** Pin: QUAD SPI D0 */
|
||||
#define CYBSP_QSPI_D0 (P11_6)
|
||||
/** Pin: QUAD SPI SCK */
|
||||
#define CYBSP_QSPI_SCK (P11_7)
|
||||
|
||||
/** Host-wake GPIO drive mode */
|
||||
#define CYBSP_WIFI_HOST_WAKE_GPIO_DM (CYHAL_GPIO_DRIVE_ANALOG)
|
||||
/** Host-wake IRQ event */
|
||||
#define CYBSP_WIFI_HOST_WAKE_IRQ_EVENT (CYHAL_GPIO_IRQ_RISE)
|
||||
|
||||
/** \} group_bsp_pins_comm */
|
||||
|
||||
|
||||
/** \} group_bsp_enums */
|
||||
/**
|
||||
* \addtogroup group_bsp_pins_arduino Arduino Header Pins
|
||||
* \{
|
||||
*/
|
||||
|
||||
/** Arduino A0 */
|
||||
#define CYBSP_A0 P10_0
|
||||
/** Arduino A1 */
|
||||
#define CYBSP_A1 P10_1
|
||||
/** Arduino A2 */
|
||||
#define CYBSP_A2 P10_2
|
||||
/** Arduino A3 */
|
||||
#define CYBSP_A3 P10_3
|
||||
/** Arduino A4 */
|
||||
#define CYBSP_A4 P10_4
|
||||
/** Arduino A5 */
|
||||
#define CYBSP_A5 P10_5
|
||||
/** Arduino D0 */
|
||||
#define CYBSP_D0 (P5_0)
|
||||
/** Arduino D1 */
|
||||
#define CYBSP_D1 (P5_1)
|
||||
/** Arduino D2 */
|
||||
#define CYBSP_D2 (P5_2)
|
||||
/** Arduino D3 */
|
||||
#define CYBSP_D3 (P5_3)
|
||||
/** Arduino D4 */
|
||||
#define CYBSP_D4 (P5_4)
|
||||
/** Arduino D5 */
|
||||
#define CYBSP_D5 (P5_5)
|
||||
/** Arduino D6 */
|
||||
#define CYBSP_D6 (P5_6)
|
||||
/** Arduino D7 */
|
||||
#define CYBSP_D7 (P0_2)
|
||||
/** Arduino D8 */
|
||||
#define CYBSP_D8 (P13_0)
|
||||
/** Arduino D9 */
|
||||
#define CYBSP_D9 (P13_1)
|
||||
/** Arduino D10 */
|
||||
#define CYBSP_D10 (P12_3)
|
||||
/** Arduino D11 */
|
||||
#define CYBSP_D11 (P12_0)
|
||||
/** Arduino D12 */
|
||||
#define CYBSP_D12 (P12_1)
|
||||
/** Arduino D13 */
|
||||
#define CYBSP_D13 (P12_2)
|
||||
/** Arduino D14 */
|
||||
#define CYBSP_D14 (P6_1)
|
||||
/** Arduino D15 */
|
||||
#define CYBSP_D15 (P6_0)
|
||||
|
||||
/** \} group_bsp_pins_arduino */
|
||||
|
||||
/** \} group_bsp_pins */
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
/***************************************************************************//**
|
||||
* \file CY8CKIT-062-BLE/cybsp.c
|
||||
* \file cybsp.c
|
||||
*
|
||||
* Description:
|
||||
* Provides basic hardware initialization for the CY8CKIT-062-BLE pioneer kit.
|
||||
* Provides initialization code for starting up the hardware contained on the
|
||||
* Cypress board.
|
||||
*
|
||||
********************************************************************************
|
||||
* \copyright
|
||||
|
@ -31,6 +32,15 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* The sysclk deep sleep callback is recommended to be the last callback that
|
||||
* is executed before entry into deep sleep mode and the first one upon
|
||||
* exit the deep sleep mode.
|
||||
* Doing so minimizes the time spent on low power mode entry and exit.
|
||||
*/
|
||||
#ifndef CYBSP_SYSCLK_PM_CALLBACK_ORDER
|
||||
#define CYBSP_SYSCLK_PM_CALLBACK_ORDER (255u)
|
||||
#endif
|
||||
|
||||
#if defined(CYBSP_WIFI_CAPABLE)
|
||||
static cyhal_sdio_t sdio_obj;
|
||||
|
||||
|
@ -40,6 +50,29 @@ cyhal_sdio_t* cybsp_get_wifi_sdio_obj(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Registers a power management callback that prepares the clock system
|
||||
* for entering deep sleep mode and restore the clocks upon wakeup from deep sleep.
|
||||
* NOTE: This is called automatically as part of \ref cybsp_init
|
||||
*/
|
||||
static cy_rslt_t cybsp_register_sysclk_pm_callback(void)
|
||||
{
|
||||
cy_rslt_t result = CY_RSLT_SUCCESS;
|
||||
static cy_stc_syspm_callback_params_t cybsp_sysclk_pm_callback_param = {NULL, NULL};
|
||||
static cy_stc_syspm_callback_t cybsp_sysclk_pm_callback = {
|
||||
.callback = &Cy_SysClk_DeepSleepCallback,
|
||||
.type = CY_SYSPM_DEEPSLEEP,
|
||||
.callbackParams = &cybsp_sysclk_pm_callback_param,
|
||||
.order = CYBSP_SYSCLK_PM_CALLBACK_ORDER
|
||||
};
|
||||
|
||||
if (!Cy_SysPm_RegisterCallback(&cybsp_sysclk_pm_callback))
|
||||
{
|
||||
result = CYBSP_RSLT_ERR_SYSCLK_PM_CALLBACK;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
cy_rslt_t cybsp_init(void)
|
||||
{
|
||||
/* Setup hardware manager to track resource usage then initialize all system (clock/power) board configuration */
|
||||
|
@ -59,29 +92,6 @@ cy_rslt_t cybsp_init(void)
|
|||
*/
|
||||
if (CY_RSLT_SUCCESS == result)
|
||||
{
|
||||
/* Initialize User LEDs */
|
||||
/* Reserves: CYBSP_USER_LED1 */
|
||||
result |= cybsp_led_init(CYBSP_USER_LED1);
|
||||
/* Reserves: CYBSP_USER_LED2 */
|
||||
result |= cybsp_led_init(CYBSP_USER_LED2);
|
||||
/* Reserves: CYBSP_USER_LED3 */
|
||||
result |= cybsp_led_init(CYBSP_USER_LED3);
|
||||
/* Reserves: CYBSP_USER_LED4 */
|
||||
result |= cybsp_led_init(CYBSP_USER_LED4);
|
||||
/* Reserves: CYBSP_USER_LED5 */
|
||||
result |= cybsp_led_init(CYBSP_USER_LED5);
|
||||
/* Initialize User Buttons */
|
||||
/* Reserves: CYBSP_USER_BTN1 */
|
||||
result |= cybsp_btn_init(CYBSP_USER_BTN1);
|
||||
CY_ASSERT(CY_RSLT_SUCCESS == result);
|
||||
|
||||
/* Initialize retargetting stdio to 'DEBUG_UART' peripheral */
|
||||
if (CY_RSLT_SUCCESS == result)
|
||||
{
|
||||
/* Reserves: CYBSP_DEBUG_UART_RX, CYBSP_DEBUG_UART_TX, corresponding SCB instance and one of available
|
||||
* clock dividers */
|
||||
result = cybsp_retarget_init();
|
||||
}
|
||||
/* Reserves: CYBSP_WIFI_SDIO, CYBSP_WIFI_SDIO_D0, CYBSP_WIFI_SDIO_D1, CYBSP_WIFI_SDIO_D2, CYBSP_WIFI_SDIO_D3
|
||||
* CYBSP_WIFI_SDIO_CMD and CYBSP_WIFI_SDIO_CLK.
|
||||
*/
|
||||
|
@ -97,8 +107,9 @@ cy_rslt_t cybsp_init(void)
|
|||
#endif /* defined(CYBSP_WIFI_CAPABLE) */
|
||||
|
||||
/* CYHAL_HWMGR_RSLT_ERR_INUSE error code could be returned if any needed for BSP resource was reserved by
|
||||
* user previously. Please review the Device Configurator (design.modus) and the BSP reservation list
|
||||
* (cyreservedresources.list) to make sure no resources are reserved by both. */
|
||||
* user previously. Please review the Device Configurator (design.modus) and the BSP reservation list
|
||||
* (cyreservedresources.list) to make sure no resources are reserved by both.
|
||||
*/
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
/***************************************************************************//**
|
||||
* \file CY8CKIT-062-BLE/cybsp.h
|
||||
* \file cybsp.h
|
||||
*
|
||||
* Description:
|
||||
* Provides APIs for interacting with the hardware contained on the Cypress
|
||||
* CY8CKIT-062-BLE pioneer kit.
|
||||
* \brief
|
||||
* Basic API for setting up boards containing a Cypress MCU.
|
||||
*
|
||||
********************************************************************************
|
||||
* \copyright
|
||||
|
@ -25,22 +24,39 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "cy_result.h"
|
||||
#include "cybsp_types.h"
|
||||
#include "cybsp_core.h"
|
||||
#ifndef __MBED__
|
||||
#include "cybsp_retarget.h"
|
||||
#include "cybsp_serial_flash.h"
|
||||
#include "cybsp_rgb_led.h"
|
||||
#endif /* __MBED__ */
|
||||
#if defined(CYBSP_WIFI_CAPABLE)
|
||||
#include "cyhal_sdio.h"
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \addtogroup group_bsp_macros Macros
|
||||
* \{
|
||||
*/
|
||||
|
||||
/** Failed to configure sysclk power management callback */
|
||||
#define CYBSP_RSLT_ERR_SYSCLK_PM_CALLBACK (CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_ABSTRACTION_BSP, 0))
|
||||
|
||||
/** \} group_bsp_macros */
|
||||
|
||||
/**
|
||||
* \addtogroup group_bsp_functions Functions
|
||||
* \{
|
||||
*/
|
||||
|
||||
/**
|
||||
* \brief Initialize all hardware on the board
|
||||
* \returns CY_RSLT_SUCCESS if the board is sucessfully initialized, if there is
|
||||
* a problem initializing any hardware it returns an error code specific
|
||||
* to the hardware module that had a problem.
|
||||
*/
|
||||
cy_rslt_t cybsp_init(void);
|
||||
|
||||
#if defined(CYBSP_WIFI_CAPABLE)
|
||||
/**
|
||||
* \brief Get the initialized sdio object used for communicating with the WiFi Chip.
|
||||
|
|
|
@ -31,172 +31,168 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* \addtogroup group_bsp_pin_state Pin States
|
||||
* \{
|
||||
*/
|
||||
|
||||
/** Pin state for the LED on. */
|
||||
#define CYBSP_LED_STATE_ON (0U)
|
||||
/** Pin state for the LED off. */
|
||||
#define CYBSP_LED_STATE_OFF (1U)
|
||||
|
||||
/** Pin state for when a button is pressed. */
|
||||
#define CYBSP_BTN_PRESSED (0U)
|
||||
/** Pin state for when a button is released. */
|
||||
#define CYBSP_BTN_OFF (1U)
|
||||
|
||||
/** \} group_bsp_pin_state */
|
||||
|
||||
|
||||
/**
|
||||
* \addtogroup group_bsp_pins Pin Mappings
|
||||
* \{
|
||||
*/
|
||||
|
||||
// Arduino connector namings
|
||||
/** Arduino A0 */
|
||||
#define CYBSP_A0 P10_0
|
||||
/** Arduino A1 */
|
||||
#define CYBSP_A1 P10_1
|
||||
/** Arduino A2 */
|
||||
#define CYBSP_A2 P10_2
|
||||
/** Arduino A3 */
|
||||
#define CYBSP_A3 P10_3
|
||||
/** Arduino A4 */
|
||||
#define CYBSP_A4 P10_4
|
||||
/** Arduino A5 */
|
||||
#define CYBSP_A5 P10_5
|
||||
/** Arduino D0 */
|
||||
#define CYBSP_D0 P5_0
|
||||
/** Arduino D1 */
|
||||
#define CYBSP_D1 P5_1
|
||||
/** Arduino D2 */
|
||||
#define CYBSP_D2 P5_2
|
||||
/** Arduino D3 */
|
||||
#define CYBSP_D3 P5_3
|
||||
/** Arduino D4 */
|
||||
#define CYBSP_D4 P5_4
|
||||
/** Arduino D5 */
|
||||
#define CYBSP_D5 P5_5
|
||||
/** Arduino D6 */
|
||||
#define CYBSP_D6 P5_6
|
||||
/** Arduino D7 */
|
||||
#define CYBSP_D7 P0_2
|
||||
/** Arduino D8 */
|
||||
#define CYBSP_D8 P13_0
|
||||
/** Arduino D9 */
|
||||
#define CYBSP_D9 P13_1
|
||||
/** Arduino D10 */
|
||||
#define CYBSP_D10 P12_3
|
||||
/** Arduino D11 */
|
||||
#define CYBSP_D11 P12_0
|
||||
/** Arduino D12 */
|
||||
#define CYBSP_D12 P12_1
|
||||
/** Arduino D13 */
|
||||
#define CYBSP_D13 P12_2
|
||||
/** Arduino D14 */
|
||||
#define CYBSP_D14 P6_1
|
||||
/** Arduino D15 */
|
||||
#define CYBSP_D15 P6_0
|
||||
|
||||
// Generic signal names
|
||||
/** Pin: WCO input */
|
||||
#define CYBSP_WCO_IN P0_0
|
||||
/** Pin: WCO output */
|
||||
#define CYBSP_WCO_OUT P0_1
|
||||
|
||||
/** Pin: UART RX */
|
||||
/* Corresponds to: ioss[0].port[5].pin[0], scb[5] */
|
||||
#define CYBSP_DEBUG_UART_RX P5_0
|
||||
/** Pin: UART TX */
|
||||
/* Corresponds to: ioss[0].port[5].pin[1], scb[5] */
|
||||
#define CYBSP_DEBUG_UART_TX P5_1
|
||||
|
||||
/** Pin: I2C SCL */
|
||||
#define CYBSP_I2C_SCL P6_0
|
||||
/** Pin: I2C SDA */
|
||||
#define CYBSP_I2C_SDA P6_1
|
||||
|
||||
/** Pin: SWO */
|
||||
#define CYBSP_SWO P6_4
|
||||
/** Pin: SWDIO */
|
||||
#define CYBSP_SWDIO P6_6
|
||||
/** Pin: SWDCK */
|
||||
#define CYBSP_SWDCK P6_7
|
||||
|
||||
/** Pin: CapSesnse TX */
|
||||
#define CYBSP_CSD_TX P1_0
|
||||
/** Pin: CapSesnse CINA */
|
||||
#define CYBSP_CINA P7_1
|
||||
/** Pin: CapSesnse CINB */
|
||||
#define CYBSP_CINB P7_2
|
||||
/** Pin: CapSesnse CMOD */
|
||||
#define CYBSP_CMOD P7_7
|
||||
/** Pin: CapSesnse Button 0 */
|
||||
#define CYBSP_CSD_BTN0 P8_1
|
||||
/** Pin: CapSesnse Button 1 */
|
||||
#define CYBSP_CSD_BTN1 P8_2
|
||||
/** Pin: CapSesnse Slider 0 */
|
||||
#define CYBSP_CSD_SLD0 P8_3
|
||||
/** Pin: CapSesnse Slider 1 */
|
||||
#define CYBSP_CSD_SLD1 P8_4
|
||||
/** Pin: CapSesnse Slider 2 */
|
||||
#define CYBSP_CSD_SLD2 P8_5
|
||||
/** Pin: CapSesnse Slider 3 */
|
||||
#define CYBSP_CSD_SLD3 P8_6
|
||||
/** Pin: CapSesnse Slider 4 */
|
||||
#define CYBSP_CSD_SLD4 P8_7
|
||||
|
||||
/** Pin: QUAD SPI SS */
|
||||
#define CYBSP_QSPI_SS P11_2
|
||||
/** Pin: QUAD SPI D3 */
|
||||
#define CYBSP_QSPI_D3 P11_3
|
||||
/** Pin: QUAD SPI D2 */
|
||||
#define CYBSP_QSPI_D2 P11_4
|
||||
/** Pin: QUAD SPI D1 */
|
||||
#define CYBSP_QSPI_D1 P11_5
|
||||
/** Pin: QUAD SPI D0 */
|
||||
#define CYBSP_QSPI_D0 P11_6
|
||||
/** Pin: QUAD SPI SCK */
|
||||
#define CYBSP_QSPI_SCK P11_7
|
||||
|
||||
/** \} group_bsp_pins */
|
||||
|
||||
/**
|
||||
* \addtogroup group_bsp_enums Enumerated Types
|
||||
* \addtogroup group_bsp_pins_led LED Pins
|
||||
* \{
|
||||
*/
|
||||
|
||||
/** Enum defining the different states for the LED. */
|
||||
typedef enum
|
||||
{
|
||||
CYBSP_LED_STATE_ON = 0,
|
||||
CYBSP_LED_STATE_OFF = 1,
|
||||
} cybsp_led_state_t;
|
||||
/** LED 8; User LED1 */
|
||||
#define CYBSP_LED8 (P1_5)
|
||||
/** LED 9; User LED2 */
|
||||
#define CYBSP_LED9 (P13_7)
|
||||
/** LED 5: RGB LED - Red; User LED3 */
|
||||
#define CYBSP_LED_RGB_RED (P0_3)
|
||||
/** LED 5: RGB LED - Green; User LED4 */
|
||||
#define CYBSP_LED_RGB_GREEN (P1_1)
|
||||
/** LED 5: RGB LED - Blue; User LED5 */
|
||||
#define CYBSP_LED_RGB_BLUE (P11_1)
|
||||
|
||||
/** Enum defining the different states for a button. */
|
||||
typedef enum
|
||||
{
|
||||
CYBSP_BTN_PRESSED = 0,
|
||||
CYBSP_BTN_OFF = 1,
|
||||
} cybsp_btn_state_t;
|
||||
/** LED 8; User LED1 */
|
||||
#define CYBSP_USER_LED1 (CYBSP_LED8)
|
||||
/** LED 9; User LED2 */
|
||||
#define CYBSP_USER_LED2 (CYBSP_LED9)
|
||||
/** LED 5: RGB LED - Red; User LED3 */
|
||||
#define CYBSP_USER_LED3 (CYBSP_LED_RGB_RED)
|
||||
/** LED 5: RGB LED - Green; User LED4 */
|
||||
#define CYBSP_USER_LED4 (CYBSP_LED_RGB_GREEN)
|
||||
/** LED 5: RGB LED - Blue; User LED5 */
|
||||
#define CYBSP_USER_LED5 (CYBSP_LED_RGB_BLUE)
|
||||
/** LED 8; User LED1 */
|
||||
#define CYBSP_USER_LED (CYBSP_USER_LED1)
|
||||
|
||||
/** Enum defining the different LED pins on the board. */
|
||||
typedef enum
|
||||
{
|
||||
CYBSP_LED9 = P13_7,
|
||||
CYBSP_LED8 = P1_5,
|
||||
CYBSP_LED_RGB_RED = P0_3,
|
||||
CYBSP_LED_RGB_GREEN = P1_1,
|
||||
CYBSP_LED_RGB_BLUE = P11_1,
|
||||
/** \} group_bsp_pins_led */
|
||||
|
||||
/* Corresponds to: ioss[0].port[1].pin[5] */
|
||||
CYBSP_USER_LED1 = CYBSP_LED8,
|
||||
/* Corresponds to: ioss[0].port[13].pin[7] */
|
||||
CYBSP_USER_LED2 = CYBSP_LED9,
|
||||
/* Corresponds to: ioss[0].port[0].pin[3] */
|
||||
CYBSP_USER_LED3 = CYBSP_LED_RGB_RED,
|
||||
/* Corresponds to: ioss[0].port[1].pin[1] */
|
||||
CYBSP_USER_LED4 = CYBSP_LED_RGB_GREEN,
|
||||
/* Corresponds to: ioss[0].port[11].pin[1] */
|
||||
CYBSP_USER_LED5 = CYBSP_LED_RGB_BLUE,
|
||||
CYBSP_USER_LED = CYBSP_USER_LED1,
|
||||
} cybsp_led_t;
|
||||
/**
|
||||
* \addtogroup group_bsp_pins_btn Button Pins
|
||||
* \{
|
||||
*/
|
||||
|
||||
/** Enum defining the different button pins on the board. */
|
||||
typedef enum
|
||||
{
|
||||
CYBSP_SW2 = P0_4,
|
||||
/** Switch 2; User Button 1 */
|
||||
#define CYBSP_SW2 (P0_4)
|
||||
|
||||
/* Corresponds to: ioss[0].port[0].pin[4] */
|
||||
CYBSP_USER_BTN1 = CYBSP_SW2,
|
||||
CYBSP_USER_BTN = CYBSP_USER_BTN1,
|
||||
} cybsp_btn_t;
|
||||
/** Switch 2; User Button 1 */
|
||||
#define CYBSP_USER_BTN1 (CYBSP_SW2)
|
||||
/** Switch 2; User Button 1 */
|
||||
#define CYBSP_USER_BTN (CYBSP_USER_BTN1)
|
||||
|
||||
/** \} group_bsp_enums */
|
||||
/** \} group_bsp_pins_btn */
|
||||
|
||||
|
||||
/**
|
||||
* \addtogroup group_bsp_pins_comm Communication Pins
|
||||
* \{
|
||||
*/
|
||||
|
||||
/** Pin: UART RX */
|
||||
#define CYBSP_DEBUG_UART_RX (P5_0)
|
||||
/** Pin: UART TX */
|
||||
#define CYBSP_DEBUG_UART_TX (P5_1)
|
||||
|
||||
/** Pin: I2C SCL */
|
||||
#define CYBSP_I2C_SCL (P6_0)
|
||||
/** Pin: I2C SDA */
|
||||
#define CYBSP_I2C_SDA (P6_1)
|
||||
|
||||
/** Pin: SWO */
|
||||
#define CYBSP_SWO (P6_4)
|
||||
/** Pin: SWDIO */
|
||||
#define CYBSP_SWDIO (P6_6)
|
||||
/** Pin: SWDCK */
|
||||
#define CYBSP_SWDCK (P6_7)
|
||||
|
||||
/** Pin: QUAD SPI SS */
|
||||
#define CYBSP_QSPI_SS (P11_2)
|
||||
/** Pin: QUAD SPI D3 */
|
||||
#define CYBSP_QSPI_D3 (P11_3)
|
||||
/** Pin: QUAD SPI D2 */
|
||||
#define CYBSP_QSPI_D2 (P11_4)
|
||||
/** Pin: QUAD SPI D1 */
|
||||
#define CYBSP_QSPI_D1 (P11_5)
|
||||
/** Pin: QUAD SPI D0 */
|
||||
#define CYBSP_QSPI_D0 (P11_6)
|
||||
/** Pin: QUAD SPI SCK */
|
||||
#define CYBSP_QSPI_SCK (P11_7)
|
||||
|
||||
/** \} group_bsp_pins_comm */
|
||||
|
||||
|
||||
/**
|
||||
* \addtogroup group_bsp_pins_arduino Arduino Header Pins
|
||||
* \{
|
||||
*/
|
||||
|
||||
/** Arduino A0 */
|
||||
#define CYBSP_A0 P10_0
|
||||
/** Arduino A1 */
|
||||
#define CYBSP_A1 P10_1
|
||||
/** Arduino A2 */
|
||||
#define CYBSP_A2 P10_2
|
||||
/** Arduino A3 */
|
||||
#define CYBSP_A3 P10_3
|
||||
/** Arduino A4 */
|
||||
#define CYBSP_A4 P10_4
|
||||
/** Arduino A5 */
|
||||
#define CYBSP_A5 P10_5
|
||||
/** Arduino D0 */
|
||||
#define CYBSP_D0 (P5_0)
|
||||
/** Arduino D1 */
|
||||
#define CYBSP_D1 (P5_1)
|
||||
/** Arduino D2 */
|
||||
#define CYBSP_D2 (P5_2)
|
||||
/** Arduino D3 */
|
||||
#define CYBSP_D3 (P5_3)
|
||||
/** Arduino D4 */
|
||||
#define CYBSP_D4 (P5_4)
|
||||
/** Arduino D5 */
|
||||
#define CYBSP_D5 (P5_5)
|
||||
/** Arduino D6 */
|
||||
#define CYBSP_D6 (P5_6)
|
||||
/** Arduino D7 */
|
||||
#define CYBSP_D7 (P0_2)
|
||||
/** Arduino D8 */
|
||||
#define CYBSP_D8 (P13_0)
|
||||
/** Arduino D9 */
|
||||
#define CYBSP_D9 (P13_1)
|
||||
/** Arduino D10 */
|
||||
#define CYBSP_D10 (P12_3)
|
||||
/** Arduino D11 */
|
||||
#define CYBSP_D11 (P12_0)
|
||||
/** Arduino D12 */
|
||||
#define CYBSP_D12 (P12_1)
|
||||
/** Arduino D13 */
|
||||
#define CYBSP_D13 (P12_2)
|
||||
/** Arduino D14 */
|
||||
#define CYBSP_D14 (P6_1)
|
||||
/** Arduino D15 */
|
||||
#define CYBSP_D15 (P6_0)
|
||||
|
||||
/** \} group_bsp_pins_arduino */
|
||||
|
||||
/** \} group_bsp_pins */
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/***************************************************************************//**
|
||||
* \file CY8CKIT-062-WIFI-BT/cybsp.c
|
||||
* \file cybsp.c
|
||||
*
|
||||
* Description:
|
||||
* Provides APIs for interacting with the hardware contained on the Cypress
|
||||
* CY8CKIT-062-WIFI-BT pioneer kit.
|
||||
* Provides initialization code for starting up the hardware contained on the
|
||||
* Cypress board.
|
||||
*
|
||||
********************************************************************************
|
||||
* \copyright
|
||||
|
@ -32,6 +32,15 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* The sysclk deep sleep callback is recommended to be the last callback that
|
||||
* is executed before entry into deep sleep mode and the first one upon
|
||||
* exit the deep sleep mode.
|
||||
* Doing so minimizes the time spent on low power mode entry and exit.
|
||||
*/
|
||||
#ifndef CYBSP_SYSCLK_PM_CALLBACK_ORDER
|
||||
#define CYBSP_SYSCLK_PM_CALLBACK_ORDER (255u)
|
||||
#endif
|
||||
|
||||
#if defined(CYBSP_WIFI_CAPABLE)
|
||||
static cyhal_sdio_t sdio_obj;
|
||||
|
||||
|
@ -41,6 +50,29 @@ cyhal_sdio_t* cybsp_get_wifi_sdio_obj(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Registers a power management callback that prepares the clock system
|
||||
* for entering deep sleep mode and restore the clocks upon wakeup from deep sleep.
|
||||
* NOTE: This is called automatically as part of \ref cybsp_init
|
||||
*/
|
||||
static cy_rslt_t cybsp_register_sysclk_pm_callback(void)
|
||||
{
|
||||
cy_rslt_t result = CY_RSLT_SUCCESS;
|
||||
static cy_stc_syspm_callback_params_t cybsp_sysclk_pm_callback_param = {NULL, NULL};
|
||||
static cy_stc_syspm_callback_t cybsp_sysclk_pm_callback = {
|
||||
.callback = &Cy_SysClk_DeepSleepCallback,
|
||||
.type = CY_SYSPM_DEEPSLEEP,
|
||||
.callbackParams = &cybsp_sysclk_pm_callback_param,
|
||||
.order = CYBSP_SYSCLK_PM_CALLBACK_ORDER
|
||||
};
|
||||
|
||||
if (!Cy_SysPm_RegisterCallback(&cybsp_sysclk_pm_callback))
|
||||
{
|
||||
result = CYBSP_RSLT_ERR_SYSCLK_PM_CALLBACK;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
cy_rslt_t cybsp_init(void)
|
||||
{
|
||||
/* Setup hardware manager to track resource usage then initialize all system (clock/power) board configuration */
|
||||
|
@ -52,35 +84,6 @@ cy_rslt_t cybsp_init(void)
|
|||
result = cybsp_register_sysclk_pm_callback();
|
||||
}
|
||||
|
||||
#ifndef __MBED__
|
||||
if (CY_RSLT_SUCCESS == result)
|
||||
{
|
||||
/* Initialize User LEDs */
|
||||
/* Reserves: CYBSP_USER_LED1 */
|
||||
result |= cybsp_led_init(CYBSP_USER_LED1);
|
||||
/* Reserves: CYBSP_USER_LED2 */
|
||||
result |= cybsp_led_init(CYBSP_USER_LED2);
|
||||
/* Reserves: CYBSP_USER_LED3 */
|
||||
result |= cybsp_led_init(CYBSP_USER_LED3);
|
||||
/* Reserves: CYBSP_USER_LED4 */
|
||||
result |= cybsp_led_init(CYBSP_USER_LED4);
|
||||
/* Reserves: CYBSP_USER_LED5 */
|
||||
result |= cybsp_led_init(CYBSP_USER_LED5);
|
||||
/* Initialize User Buttons */
|
||||
/* Reserves: CYBSP_USER_BTN1 */
|
||||
result |= cybsp_btn_init(CYBSP_USER_BTN1);
|
||||
CY_ASSERT(CY_RSLT_SUCCESS == result);
|
||||
|
||||
/* Initialize retargetting stdio to 'DEBUG_UART' peripheral */
|
||||
if (CY_RSLT_SUCCESS == result)
|
||||
{
|
||||
/* Reserves: CYBSP_DEBUG_UART_RX, CYBSP_DEBUG_UART_TX, corresponding SCB instance
|
||||
* and one of available clock dividers */
|
||||
result = cybsp_retarget_init();
|
||||
}
|
||||
}
|
||||
#endif /* __MBED__ */
|
||||
|
||||
#if defined(CYBSP_WIFI_CAPABLE)
|
||||
/* Initialize SDIO interface. This must be done before other HAL API calls as some SDIO implementations require
|
||||
* specific peripheral instances.
|
||||
|
@ -104,8 +107,9 @@ cy_rslt_t cybsp_init(void)
|
|||
#endif /* defined(CYBSP_WIFI_CAPABLE) */
|
||||
|
||||
/* CYHAL_HWMGR_RSLT_ERR_INUSE error code could be returned if any needed for BSP resource was reserved by
|
||||
* user previously. Please review the Device Configurator (design.modus) and the BSP reservation list
|
||||
* (cyreservedresources.list) to make sure no resources are reserved by both. */
|
||||
* user previously. Please review the Device Configurator (design.modus) and the BSP reservation list
|
||||
* (cyreservedresources.list) to make sure no resources are reserved by both.
|
||||
*/
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
/***************************************************************************//**
|
||||
* \file CY8CKIT-062-WIFI-BT/cybsp.h
|
||||
* \file cybsp.h
|
||||
*
|
||||
* Description:
|
||||
* Provides APIs for interacting with the hardware contained on the Cypress
|
||||
* CY8CKIT-062-WIFI-BT pioneer kit.
|
||||
* \brief
|
||||
* Basic API for setting up boards containing a Cypress MCU.
|
||||
*
|
||||
********************************************************************************
|
||||
* \copyright
|
||||
|
@ -25,27 +24,38 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "cy_result.h"
|
||||
#include "cybsp_types.h"
|
||||
#include "cybsp_core.h"
|
||||
#if defined(CYBSP_WIFI_CAPABLE)
|
||||
#include "cyhal_sdio.h"
|
||||
#endif
|
||||
#ifndef __MBED__
|
||||
#include "cybsp_retarget.h"
|
||||
#include "cybsp_serial_flash.h"
|
||||
#include "cybsp_rgb_led.h"
|
||||
#endif /* __MBED__ */
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// HAL HW configuration data
|
||||
extern cyhal_qspi_t cybsp_qspi;
|
||||
extern cyhal_uart_t cybsp_bt_uart;
|
||||
extern cyhal_uart_t cybsp_debug_uart;
|
||||
extern cyhal_i2c_t cybsp_i2c;
|
||||
extern cyhal_rtc_t cybsp_rtc;
|
||||
/**
|
||||
* \addtogroup group_bsp_macros Macros
|
||||
* \{
|
||||
*/
|
||||
|
||||
/** Failed to configure sysclk power management callback */
|
||||
#define CYBSP_RSLT_ERR_SYSCLK_PM_CALLBACK (CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_ABSTRACTION_BSP, 0))
|
||||
|
||||
/** \} group_bsp_macros */
|
||||
|
||||
/**
|
||||
* \addtogroup group_bsp_functions Functions
|
||||
* \{
|
||||
*/
|
||||
|
||||
/**
|
||||
* \brief Initialize all hardware on the board
|
||||
* \returns CY_RSLT_SUCCESS if the board is sucessfully initialized, if there is
|
||||
* a problem initializing any hardware it returns an error code specific
|
||||
* to the hardware module that had a problem.
|
||||
*/
|
||||
cy_rslt_t cybsp_init(void);
|
||||
|
||||
#if defined(CYBSP_WIFI_CAPABLE)
|
||||
/**
|
||||
|
|
|
@ -25,223 +25,213 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "cyhal.h"
|
||||
#include "cyhal_pin_package.h"
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* \addtogroup group_bsp_pin_state Pin States
|
||||
* \{
|
||||
*/
|
||||
|
||||
/** Pin state for the LED on. */
|
||||
#define CYBSP_LED_STATE_ON (0U)
|
||||
/** Pin state for the LED off. */
|
||||
#define CYBSP_LED_STATE_OFF (1U)
|
||||
|
||||
/** Pin state for when a button is pressed. */
|
||||
#define CYBSP_BTN_PRESSED (0U)
|
||||
/** Pin state for when a button is released. */
|
||||
#define CYBSP_BTN_OFF (1U)
|
||||
|
||||
/** \} group_bsp_pin_state */
|
||||
|
||||
|
||||
/**
|
||||
* \addtogroup group_bsp_pins Pin Mappings
|
||||
* \{
|
||||
*/
|
||||
|
||||
// Arduino connector namings
|
||||
/** Arduino A0 */
|
||||
#define CYBSP_A0 P10_0
|
||||
/** Arduino A1 */
|
||||
#define CYBSP_A1 P10_1
|
||||
/** Arduino A2 */
|
||||
#define CYBSP_A2 P10_2
|
||||
/** Arduino A3 */
|
||||
#define CYBSP_A3 P10_3
|
||||
/** Arduino A4 */
|
||||
#define CYBSP_A4 P10_4
|
||||
/** Arduino A5 */
|
||||
#define CYBSP_A5 P10_5
|
||||
/** Arduino D0 */
|
||||
#define CYBSP_D0 P5_0
|
||||
/** Arduino D1 */
|
||||
#define CYBSP_D1 P5_1
|
||||
/** Arduino D2 */
|
||||
#define CYBSP_D2 P5_2
|
||||
/** Arduino D3 */
|
||||
#define CYBSP_D3 P5_3
|
||||
/** Arduino D4 */
|
||||
#define CYBSP_D4 P5_4
|
||||
/** Arduino D5 */
|
||||
#define CYBSP_D5 P5_5
|
||||
/** Arduino D6 */
|
||||
#define CYBSP_D6 P5_6
|
||||
/** Arduino D7 */
|
||||
#define CYBSP_D7 P0_2
|
||||
/** Arduino D8 */
|
||||
#define CYBSP_D8 P13_0
|
||||
/** Arduino D9 */
|
||||
#define CYBSP_D9 P13_1
|
||||
/** Arduino D10 */
|
||||
#define CYBSP_D10 P12_3
|
||||
/** Arduino D11 */
|
||||
#define CYBSP_D11 P12_0
|
||||
/** Arduino D12 */
|
||||
#define CYBSP_D12 P12_1
|
||||
/** Arduino D13 */
|
||||
#define CYBSP_D13 P12_2
|
||||
/** Arduino D14 */
|
||||
#define CYBSP_D14 P6_1
|
||||
/** Arduino D15 */
|
||||
#define CYBSP_D15 P6_0
|
||||
|
||||
// Generic signal names
|
||||
/** Pin: WCO input */
|
||||
#define CYBSP_WCO_IN P0_0
|
||||
/** Pin: WCO output */
|
||||
#define CYBSP_WCO_OUT P0_1
|
||||
|
||||
/** Pin: WIFI SDIO D0 */
|
||||
/* Corresponds to: ioss[0].port[2].pin[0], udb[0] */
|
||||
#define CYBSP_WIFI_SDIO_D0 P2_0
|
||||
/** Pin: WIFI SDIO D1 */
|
||||
/* Corresponds to: ioss[0].port[2].pin[1], udb[0] */
|
||||
#define CYBSP_WIFI_SDIO_D1 P2_1
|
||||
/** Pin: WIFI SDIO D2 */
|
||||
/* Corresponds to: ioss[0].port[2].pin[2], udb[0] */
|
||||
#define CYBSP_WIFI_SDIO_D2 P2_2
|
||||
/** Pin: WIFI SDIO D3 */
|
||||
/* Corresponds to: ioss[0].port[2].pin[3], udb[0] */
|
||||
#define CYBSP_WIFI_SDIO_D3 P2_3
|
||||
/** Pin: WIFI SDIO CMD */
|
||||
/* Corresponds to: ioss[0].port[2].pin[4], udb[0] */
|
||||
#define CYBSP_WIFI_SDIO_CMD P2_4
|
||||
/** Pin: WIFI SDIO CLK */
|
||||
/* Corresponds to: ioss[0].port[2].pin[5], udb[0] */
|
||||
#define CYBSP_WIFI_SDIO_CLK P2_5
|
||||
/** Pin: WIFI ON */
|
||||
/* Corresponds to: ioss[0].port[2].pin[6], udb[0] */
|
||||
#define CYBSP_WIFI_WL_REG_ON P2_6
|
||||
/** Pin: WIFI Host Wakeup */
|
||||
#define CYBSP_WIFI_HOST_WAKE P2_7
|
||||
|
||||
/** Pin: BT UART RX */
|
||||
#define CYBSP_BT_UART_RX P3_0
|
||||
/** Pin: BT UART TX */
|
||||
#define CYBSP_BT_UART_TX P3_1
|
||||
/** Pin: BT UART RTS */
|
||||
#define CYBSP_BT_UART_RTS P3_2
|
||||
/** Pin: BT UART CTS */
|
||||
#define CYBSP_BT_UART_CTS P3_3
|
||||
|
||||
/** Pin: BT Power */
|
||||
#define CYBSP_BT_POWER P3_4
|
||||
/** Pin: BT Host Wakeup */
|
||||
#define CYBSP_BT_HOST_WAKE P3_5
|
||||
/** Pin: BT Device Wakeup */
|
||||
#define CYBSP_BT_DEVICE_WAKE P4_0
|
||||
|
||||
/** Pin: UART RX */
|
||||
/* Corresponds to: ioss[0].port[5].pin[0], scb[5] */
|
||||
#define CYBSP_DEBUG_UART_RX P5_0
|
||||
/** Pin: UART TX */
|
||||
/* Corresponds to: ioss[0].port[5].pin[1], scb[5] */
|
||||
#define CYBSP_DEBUG_UART_TX P5_1
|
||||
|
||||
/** Pin: I2C SCL */
|
||||
#define CYBSP_I2C_SCL P6_0
|
||||
/** Pin: I2C SDA */
|
||||
#define CYBSP_I2C_SDA P6_1
|
||||
|
||||
/** Pin: SWO */
|
||||
#define CYBSP_SWO P6_4
|
||||
/** Pin: SWDIO */
|
||||
#define CYBSP_SWDIO P6_6
|
||||
/** Pin: SWDCK */
|
||||
#define CYBSP_SWDCK P6_7
|
||||
|
||||
/** Pin: CapSesnse TX */
|
||||
#define CYBSP_CSD_TX P1_0
|
||||
/** Pin: CapSesnse CINA */
|
||||
#define CYBSP_CINA P7_1
|
||||
/** Pin: CapSesnse CINB */
|
||||
#define CYBSP_CINB P7_2
|
||||
/** Pin: CapSesnse CMOD */
|
||||
#define CYBSP_CMOD P7_7
|
||||
/** Pin: CapSesnse Button 0 */
|
||||
#define CYBSP_CSD_BTN0 P8_1
|
||||
/** Pin: CapSesnse Button 1 */
|
||||
#define CYBSP_CSD_BTN1 P8_2
|
||||
/** Pin: CapSesnse Slider 0 */
|
||||
#define CYBSP_CSD_SLD0 P8_3
|
||||
/** Pin: CapSesnse Slider 1 */
|
||||
#define CYBSP_CSD_SLD1 P8_4
|
||||
/** Pin: CapSesnse Slider 2 */
|
||||
#define CYBSP_CSD_SLD2 P8_5
|
||||
/** Pin: CapSesnse Slider 3 */
|
||||
#define CYBSP_CSD_SLD3 P8_6
|
||||
/** Pin: CapSesnse Slider 4 */
|
||||
#define CYBSP_CSD_SLD4 P8_7
|
||||
|
||||
/** Pin: QUAD SPI SS */
|
||||
#define CYBSP_QSPI_SS P11_2
|
||||
/** Pin: QUAD SPI D3 */
|
||||
#define CYBSP_QSPI_D3 P11_3
|
||||
/** Pin: QUAD SPI D2 */
|
||||
#define CYBSP_QSPI_D2 P11_4
|
||||
/** Pin: QUAD SPI D1 */
|
||||
#define CYBSP_QSPI_D1 P11_5
|
||||
/** Pin: QUAD SPI D0 */
|
||||
#define CYBSP_QSPI_D0 P11_6
|
||||
/** Pin: QUAD SPI SCK */
|
||||
#define CYBSP_QSPI_SCK P11_7
|
||||
|
||||
/** Host-wake GPIO drive mode */
|
||||
#define CYBSP_WIFI_HOST_WAKE_GPIO_DM CYHAL_GPIO_DRIVE_ANALOG
|
||||
/** Host-wake IRQ event */
|
||||
#define CYBSP_WIFI_HOST_WAKE_IRQ_EVENT CYHAL_GPIO_IRQ_RISE
|
||||
|
||||
/** \} group_bsp_pins */
|
||||
|
||||
/**
|
||||
* \addtogroup group_bsp_enums Enumerated Types
|
||||
* \addtogroup group_bsp_pins_led LED Pins
|
||||
* \{
|
||||
*/
|
||||
|
||||
/** Enum defining the different states for the LED. */
|
||||
typedef enum
|
||||
{
|
||||
CYBSP_LED_STATE_ON = 0,
|
||||
CYBSP_LED_STATE_OFF = 1,
|
||||
} cybsp_led_state_t;
|
||||
/** LED 8; User LED1 */
|
||||
#define CYBSP_LED8 (P1_5)
|
||||
/** LED 9; User LED2 */
|
||||
#define CYBSP_LED9 (P13_7)
|
||||
/** LED 5: RGB LED - Red; User LED3 */
|
||||
#define CYBSP_LED_RGB_RED (P0_3)
|
||||
/** LED 5: RGB LED - Green; User LED4 */
|
||||
#define CYBSP_LED_RGB_GREEN (P1_1)
|
||||
/** LED 5: RGB LED - Blue; User LED5 */
|
||||
#define CYBSP_LED_RGB_BLUE (P11_1)
|
||||
|
||||
/** Enum defining the different states for a button. */
|
||||
typedef enum
|
||||
{
|
||||
CYBSP_BTN_PRESSED = 0,
|
||||
CYBSP_BTN_OFF = 1,
|
||||
} cybsp_btn_state_t;
|
||||
/** LED 8; User LED1 */
|
||||
#define CYBSP_USER_LED1 (CYBSP_LED8)
|
||||
/** LED 9; User LED2 */
|
||||
#define CYBSP_USER_LED2 (CYBSP_LED9)
|
||||
/** LED 5: RGB LED - Red; User LED3 */
|
||||
#define CYBSP_USER_LED3 (CYBSP_LED_RGB_RED)
|
||||
/** LED 5: RGB LED - Green; User LED4 */
|
||||
#define CYBSP_USER_LED4 (CYBSP_LED_RGB_GREEN)
|
||||
/** LED 5: RGB LED - Blue; User LED5 */
|
||||
#define CYBSP_USER_LED5 (CYBSP_LED_RGB_BLUE)
|
||||
/** LED 8; User LED1 */
|
||||
#define CYBSP_USER_LED (CYBSP_USER_LED1)
|
||||
|
||||
/** Enum defining the different LED pins on the board. */
|
||||
typedef enum
|
||||
{
|
||||
CYBSP_LED9 = P13_7,
|
||||
CYBSP_LED8 = P1_5,
|
||||
CYBSP_LED_RGB_RED = P0_3,
|
||||
CYBSP_LED_RGB_GREEN = P1_1,
|
||||
CYBSP_LED_RGB_BLUE = P11_1,
|
||||
/** \} group_bsp_pins_led */
|
||||
|
||||
/* Corresponds to: ioss[0].port[1].pin[5] */
|
||||
CYBSP_USER_LED1 = CYBSP_LED8,
|
||||
/* Corresponds to: ioss[0].port[13].pin[7] */
|
||||
CYBSP_USER_LED2 = CYBSP_LED9,
|
||||
/* Corresponds to: ioss[0].port[0].pin[3] */
|
||||
CYBSP_USER_LED3 = CYBSP_LED_RGB_RED,
|
||||
/* Corresponds to: ioss[0].port[1].pin[1] */
|
||||
CYBSP_USER_LED4 = CYBSP_LED_RGB_GREEN,
|
||||
/* Corresponds to: ioss[0].port[11].pin[1] */
|
||||
CYBSP_USER_LED5 = CYBSP_LED_RGB_BLUE,
|
||||
CYBSP_USER_LED = CYBSP_USER_LED1,
|
||||
} cybsp_led_t;
|
||||
|
||||
/** Enum defining the different button pins on the board. */
|
||||
typedef enum
|
||||
{
|
||||
CYBSP_SW2 = P0_4,
|
||||
/**
|
||||
* \addtogroup group_bsp_pins_btn Button Pins
|
||||
* \{
|
||||
*/
|
||||
|
||||
/* Corresponds to: ioss[0].port[0].pin[4] */
|
||||
CYBSP_USER_BTN1 = CYBSP_SW2,
|
||||
CYBSP_USER_BTN = CYBSP_USER_BTN1,
|
||||
} cybsp_btn_t;
|
||||
/** Switch 2; User Button 1 */
|
||||
#define CYBSP_SW2 (P0_4)
|
||||
|
||||
/** \} group_bsp_enums */
|
||||
/** Switch 2; User Button 1 */
|
||||
#define CYBSP_USER_BTN1 (CYBSP_SW2)
|
||||
/** Switch 2; User Button 1 */
|
||||
#define CYBSP_USER_BTN (CYBSP_USER_BTN1)
|
||||
|
||||
/** \} group_bsp_pins_btn */
|
||||
|
||||
|
||||
/**
|
||||
* \addtogroup group_bsp_pins_comm Communication Pins
|
||||
* \{
|
||||
*/
|
||||
|
||||
/** Pin: WIFI SDIO D0 */
|
||||
#define CYBSP_WIFI_SDIO_D0 (P2_0)
|
||||
/** Pin: WIFI SDIO D1 */
|
||||
#define CYBSP_WIFI_SDIO_D1 (P2_1)
|
||||
/** Pin: WIFI SDIO D2 */
|
||||
#define CYBSP_WIFI_SDIO_D2 (P2_2)
|
||||
/** Pin: WIFI SDIO D3 */
|
||||
#define CYBSP_WIFI_SDIO_D3 (P2_3)
|
||||
/** Pin: WIFI SDIO CMD */
|
||||
#define CYBSP_WIFI_SDIO_CMD (P2_4)
|
||||
/** Pin: WIFI SDIO CLK */
|
||||
#define CYBSP_WIFI_SDIO_CLK (P2_5)
|
||||
/** Pin: WIFI ON */
|
||||
#define CYBSP_WIFI_WL_REG_ON (P2_6)
|
||||
/** Pin: WIFI Host Wakeup */
|
||||
#define CYBSP_WIFI_HOST_WAKE (P2_7)
|
||||
|
||||
/** Pin: BT UART RX */
|
||||
#define CYBSP_BT_UART_RX (P3_0)
|
||||
/** Pin: BT UART TX */
|
||||
#define CYBSP_BT_UART_TX (P3_1)
|
||||
/** Pin: BT UART RTS */
|
||||
#define CYBSP_BT_UART_RTS (P3_2)
|
||||
/** Pin: BT UART CTS */
|
||||
#define CYBSP_BT_UART_CTS (P3_3)
|
||||
|
||||
/** Pin: BT Power */
|
||||
#define CYBSP_BT_POWER (P3_4)
|
||||
/** Pin: BT Host Wakeup */
|
||||
#define CYBSP_BT_HOST_WAKE (P3_5)
|
||||
/** Pin: BT Device Wakeup */
|
||||
#define CYBSP_BT_DEVICE_WAKE (P4_0)
|
||||
|
||||
/** Pin: UART RX */
|
||||
#define CYBSP_DEBUG_UART_RX (P5_0)
|
||||
/** Pin: UART TX */
|
||||
#define CYBSP_DEBUG_UART_TX (P5_1)
|
||||
|
||||
/** Pin: I2C SCL */
|
||||
#define CYBSP_I2C_SCL (P6_0)
|
||||
/** Pin: I2C SDA */
|
||||
#define CYBSP_I2C_SDA (P6_1)
|
||||
|
||||
/** Pin: SWO */
|
||||
#define CYBSP_SWO (P6_4)
|
||||
/** Pin: SWDIO */
|
||||
#define CYBSP_SWDIO (P6_6)
|
||||
/** Pin: SWDCK */
|
||||
#define CYBSP_SWDCK (P6_7)
|
||||
|
||||
/** Pin: QUAD SPI SS */
|
||||
#define CYBSP_QSPI_SS (P11_2)
|
||||
/** Pin: QUAD SPI D3 */
|
||||
#define CYBSP_QSPI_D3 (P11_3)
|
||||
/** Pin: QUAD SPI D2 */
|
||||
#define CYBSP_QSPI_D2 (P11_4)
|
||||
/** Pin: QUAD SPI D1 */
|
||||
#define CYBSP_QSPI_D1 (P11_5)
|
||||
/** Pin: QUAD SPI D0 */
|
||||
#define CYBSP_QSPI_D0 (P11_6)
|
||||
/** Pin: QUAD SPI SCK */
|
||||
#define CYBSP_QSPI_SCK (P11_7)
|
||||
|
||||
/** Host-wake GPIO drive mode */
|
||||
#define CYBSP_WIFI_HOST_WAKE_GPIO_DM (CYHAL_GPIO_DRIVE_ANALOG)
|
||||
/** Host-wake IRQ event */
|
||||
#define CYBSP_WIFI_HOST_WAKE_IRQ_EVENT (CYHAL_GPIO_IRQ_RISE)
|
||||
|
||||
/** \} group_bsp_pins_comm */
|
||||
|
||||
|
||||
/**
|
||||
* \addtogroup group_bsp_pins_arduino Arduino Header Pins
|
||||
* \{
|
||||
*/
|
||||
|
||||
/** Arduino A0 */
|
||||
#define CYBSP_A0 P10_0
|
||||
/** Arduino A1 */
|
||||
#define CYBSP_A1 P10_1
|
||||
/** Arduino A2 */
|
||||
#define CYBSP_A2 P10_2
|
||||
/** Arduino A3 */
|
||||
#define CYBSP_A3 P10_3
|
||||
/** Arduino A4 */
|
||||
#define CYBSP_A4 P10_4
|
||||
/** Arduino A5 */
|
||||
#define CYBSP_A5 P10_5
|
||||
/** Arduino D0 */
|
||||
#define CYBSP_D0 (P5_0)
|
||||
/** Arduino D1 */
|
||||
#define CYBSP_D1 (P5_1)
|
||||
/** Arduino D2 */
|
||||
#define CYBSP_D2 (P5_2)
|
||||
/** Arduino D3 */
|
||||
#define CYBSP_D3 (P5_3)
|
||||
/** Arduino D4 */
|
||||
#define CYBSP_D4 (P5_4)
|
||||
/** Arduino D5 */
|
||||
#define CYBSP_D5 (P5_5)
|
||||
/** Arduino D6 */
|
||||
#define CYBSP_D6 (P5_6)
|
||||
/** Arduino D7 */
|
||||
#define CYBSP_D7 (P0_2)
|
||||
/** Arduino D8 */
|
||||
#define CYBSP_D8 (P13_0)
|
||||
/** Arduino D9 */
|
||||
#define CYBSP_D9 (P13_1)
|
||||
/** Arduino D10 */
|
||||
#define CYBSP_D10 (P12_3)
|
||||
/** Arduino D11 */
|
||||
#define CYBSP_D11 (P12_0)
|
||||
/** Arduino D12 */
|
||||
#define CYBSP_D12 (P12_1)
|
||||
/** Arduino D13 */
|
||||
#define CYBSP_D13 (P12_2)
|
||||
/** Arduino D14 */
|
||||
#define CYBSP_D14 (P6_1)
|
||||
/** Arduino D15 */
|
||||
#define CYBSP_D15 (P6_0)
|
||||
|
||||
/** \} group_bsp_pins_arduino */
|
||||
|
||||
/** \} group_bsp_pins */
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/***************************************************************************//**
|
||||
* \file TARGET_CY8CPROTO_062_4343W/cybsp.c
|
||||
* \file cybsp.c
|
||||
*
|
||||
* Description:
|
||||
* Provides APIs for interacting with the hardware contained on the Cypress
|
||||
* CY8CPROTO-062-4343W prototyping kit.
|
||||
* Provides initialization code for starting up the hardware contained on the
|
||||
* Cypress board.
|
||||
*
|
||||
********************************************************************************
|
||||
* \copyright
|
||||
|
@ -32,6 +32,15 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* The sysclk deep sleep callback is recommended to be the last callback that
|
||||
* is executed before entry into deep sleep mode and the first one upon
|
||||
* exit the deep sleep mode.
|
||||
* Doing so minimizes the time spent on low power mode entry and exit.
|
||||
*/
|
||||
#ifndef CYBSP_SYSCLK_PM_CALLBACK_ORDER
|
||||
#define CYBSP_SYSCLK_PM_CALLBACK_ORDER (255u)
|
||||
#endif
|
||||
|
||||
#if defined(CYBSP_WIFI_CAPABLE)
|
||||
static cyhal_sdio_t sdio_obj;
|
||||
|
||||
|
@ -41,6 +50,29 @@ cyhal_sdio_t* cybsp_get_wifi_sdio_obj(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Registers a power management callback that prepares the clock system
|
||||
* for entering deep sleep mode and restore the clocks upon wakeup from deep sleep.
|
||||
* NOTE: This is called automatically as part of \ref cybsp_init
|
||||
*/
|
||||
static cy_rslt_t cybsp_register_sysclk_pm_callback(void)
|
||||
{
|
||||
cy_rslt_t result = CY_RSLT_SUCCESS;
|
||||
static cy_stc_syspm_callback_params_t cybsp_sysclk_pm_callback_param = {NULL, NULL};
|
||||
static cy_stc_syspm_callback_t cybsp_sysclk_pm_callback = {
|
||||
.callback = &Cy_SysClk_DeepSleepCallback,
|
||||
.type = CY_SYSPM_DEEPSLEEP,
|
||||
.callbackParams = &cybsp_sysclk_pm_callback_param,
|
||||
.order = CYBSP_SYSCLK_PM_CALLBACK_ORDER
|
||||
};
|
||||
|
||||
if (!Cy_SysPm_RegisterCallback(&cybsp_sysclk_pm_callback))
|
||||
{
|
||||
result = CYBSP_RSLT_ERR_SYSCLK_PM_CALLBACK;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
cy_rslt_t cybsp_init(void)
|
||||
{
|
||||
/* Setup hardware manager to track resource usage then initialize all system (clock/power) board configuration */
|
||||
|
@ -52,27 +84,6 @@ cy_rslt_t cybsp_init(void)
|
|||
result = cybsp_register_sysclk_pm_callback();
|
||||
}
|
||||
|
||||
#ifndef __MBED__
|
||||
if (CY_RSLT_SUCCESS == result)
|
||||
{
|
||||
/* Initialize User LEDs */
|
||||
/* Reserves: CYBSP_USER_LED1 */
|
||||
result |= cybsp_led_init(CYBSP_USER_LED1);
|
||||
/* Initialize User Buttons */
|
||||
/* Reserves: CYBSP_USER_BTN1 */
|
||||
result |= cybsp_btn_init(CYBSP_USER_BTN1);
|
||||
CY_ASSERT(CY_RSLT_SUCCESS == result);
|
||||
|
||||
/* Initialize retargetting stdio to 'DEBUG_UART' peripheral */
|
||||
if (CY_RSLT_SUCCESS == result)
|
||||
{
|
||||
/* Reserves: CYBSP_DEBUG_UART_RX, CYBSP_DEBUG_UART_TX, corresponding SCB instance
|
||||
* and one of available clock dividers */
|
||||
result = cybsp_retarget_init();
|
||||
}
|
||||
}
|
||||
#endif /* __MBED__ */
|
||||
|
||||
#if defined(CYBSP_WIFI_CAPABLE)
|
||||
/* Initialize SDIO interface. This must be done before other HAL API calls as some SDIO implementations require
|
||||
* specific peripheral instances.
|
||||
|
@ -96,8 +107,9 @@ cy_rslt_t cybsp_init(void)
|
|||
#endif /* defined(CYBSP_WIFI_CAPABLE) */
|
||||
|
||||
/* CYHAL_HWMGR_RSLT_ERR_INUSE error code could be returned if any needed for BSP resource was reserved by
|
||||
* user previously. Please review the Device Configurator (design.modus) and the BSP reservation list
|
||||
* (cyreservedresources.list) to make sure no resources are reserved by both. */
|
||||
* user previously. Please review the Device Configurator (design.modus) and the BSP reservation list
|
||||
* (cyreservedresources.list) to make sure no resources are reserved by both.
|
||||
*/
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
/***************************************************************************//**
|
||||
* \file CY8CPROTO-062-4343W/cybsp.h
|
||||
* \file cybsp.h
|
||||
*
|
||||
* Description:
|
||||
* Provides APIs for interacting with the hardware contained on the Cypress
|
||||
* CY8CPROTO-062-4343W prototyping kit.
|
||||
* \brief
|
||||
* Basic API for setting up boards containing a Cypress MCU.
|
||||
*
|
||||
********************************************************************************
|
||||
* \copyright
|
||||
|
@ -25,25 +24,39 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "cy_result.h"
|
||||
#include "cybsp_types.h"
|
||||
#include "cybsp_core.h"
|
||||
#if defined(CYBSP_WIFI_CAPABLE)
|
||||
#include "cyhal_sdio.h"
|
||||
#endif
|
||||
#ifndef __MBED__
|
||||
#include "cybsp_retarget.h"
|
||||
#include "cybsp_serial_flash.h"
|
||||
#endif /* __MBED__ */
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \addtogroup group_bsp_macros Macros
|
||||
* \{
|
||||
*/
|
||||
|
||||
/** Failed to configure sysclk power management callback */
|
||||
#define CYBSP_RSLT_ERR_SYSCLK_PM_CALLBACK (CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_ABSTRACTION_BSP, 0))
|
||||
|
||||
/** \} group_bsp_macros */
|
||||
|
||||
/**
|
||||
* \addtogroup group_bsp_functions Functions
|
||||
* \{
|
||||
*/
|
||||
|
||||
/**
|
||||
* \brief Initialize all hardware on the board
|
||||
* \returns CY_RSLT_SUCCESS if the board is sucessfully initialized, if there is
|
||||
* a problem initializing any hardware it returns an error code specific
|
||||
* to the hardware module that had a problem.
|
||||
*/
|
||||
cy_rslt_t cybsp_init(void);
|
||||
|
||||
#if defined(CYBSP_WIFI_CAPABLE)
|
||||
/**
|
||||
* \brief Get the initialized sdio object used for communicating with the WiFi Chip.
|
||||
|
|
|
@ -25,124 +25,144 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "cyhal.h"
|
||||
#include "cyhal_pin_package.h"
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* \addtogroup group_bsp_pin_state Pin States
|
||||
* \{
|
||||
*/
|
||||
|
||||
/** Pin state for the LED on. */
|
||||
#define CYBSP_LED_STATE_ON (0U)
|
||||
/** Pin state for the LED off. */
|
||||
#define CYBSP_LED_STATE_OFF (1U)
|
||||
|
||||
/** Pin state for when a button is pressed. */
|
||||
#define CYBSP_BTN_PRESSED (0U)
|
||||
/** Pin state for when a button is released. */
|
||||
#define CYBSP_BTN_OFF (1U)
|
||||
|
||||
/** \} group_bsp_pin_state */
|
||||
|
||||
|
||||
/**
|
||||
* \addtogroup group_bsp_pins Pin Mappings
|
||||
* \{
|
||||
*/
|
||||
|
||||
/** Pin: WIFI SDIO D0 */
|
||||
/* Corresponds to: ioss[0].port[2].pin[0], sdhc[0] */
|
||||
#define CYBSP_WIFI_SDIO_D0 P2_0
|
||||
/** Pin: WIFI SDIO D1 */
|
||||
/* Corresponds to: ioss[0].port[2].pin[1], sdhc[0] */
|
||||
#define CYBSP_WIFI_SDIO_D1 P2_1
|
||||
/** Pin: WIFI SDIO D2 */
|
||||
/* Corresponds to: ioss[0].port[2].pin[2], sdhc[0] */
|
||||
#define CYBSP_WIFI_SDIO_D2 P2_2
|
||||
/** Pin: WIFI SDIO D3 */
|
||||
/* Corresponds to: ioss[0].port[2].pin[3], sdhc[0] */
|
||||
#define CYBSP_WIFI_SDIO_D3 P2_3
|
||||
/** Pin: WIFI SDIO CMD */
|
||||
/* Corresponds to: ioss[0].port[2].pin[4], sdhc[0] */
|
||||
#define CYBSP_WIFI_SDIO_CMD P2_4
|
||||
/** Pin: WIFI SDIO CLK */
|
||||
/* Corresponds to: ioss[0].port[2].pin[5], sdhc[0] */
|
||||
#define CYBSP_WIFI_SDIO_CLK P2_5
|
||||
/** Pin: WIFI ON */
|
||||
/* Corresponds to: ioss[0].port[2].pin[6], sdhc[0] */
|
||||
#define CYBSP_WIFI_WL_REG_ON P2_6
|
||||
/** Pin: WIFI Host Wakeup */
|
||||
#define CYBSP_WIFI_HOST_WAKE P0_4
|
||||
|
||||
/** Pin: BT UART RX */
|
||||
#define CYBSP_BT_UART_RX P3_0
|
||||
/** Pin: BT UART TX */
|
||||
#define CYBSP_BT_UART_TX P3_1
|
||||
/** Pin: BT UART RTS */
|
||||
#define CYBSP_BT_UART_RTS P3_2
|
||||
/** Pin: BT UART CTS */
|
||||
#define CYBSP_BT_UART_CTS P3_3
|
||||
|
||||
/** Pin: BT Power */
|
||||
#define CYBSP_BT_POWER P3_4
|
||||
/** Pin: BT Host Wakeup */
|
||||
#define CYBSP_BT_HOST_WAKE P4_0
|
||||
/** Pin: BT Device Wakeup */
|
||||
#define CYBSP_BT_DEVICE_WAKE P3_5
|
||||
|
||||
/** Pin: UART RX */
|
||||
/* Corresponds to: ioss[0].port[5].pin[0], scb[5] */
|
||||
#define CYBSP_DEBUG_UART_RX P5_0
|
||||
/** Pin: UART TX */
|
||||
/* Corresponds to: ioss[0].port[5].pin[1], scb[5] */
|
||||
#define CYBSP_DEBUG_UART_TX P5_1
|
||||
|
||||
/** Pin: QUAD SPI SS */
|
||||
#define CYBSP_QSPI_SS P11_2
|
||||
/** Pin: QUAD SPI D3 */
|
||||
#define CYBSP_QSPI_D3 P11_3
|
||||
/** Pin: QUAD SPI D2 */
|
||||
#define CYBSP_QSPI_D2 P11_4
|
||||
/** Pin: QUAD SPI D1 */
|
||||
#define CYBSP_QSPI_D1 P11_5
|
||||
/** Pin: QUAD SPI D0 */
|
||||
#define CYBSP_QSPI_D0 P11_6
|
||||
/** Pin: QUAD SPI SCK */
|
||||
#define CYBSP_QSPI_SCK P11_7
|
||||
|
||||
/** Host-wake GPIO drive mode */
|
||||
#define CYBSP_WIFI_HOST_WAKE_GPIO_DM CYHAL_GPIO_DRIVE_ANALOG
|
||||
/** Host-wake IRQ event */
|
||||
#define CYBSP_WIFI_HOST_WAKE_IRQ_EVENT CYHAL_GPIO_IRQ_RISE
|
||||
|
||||
/** \} group_bsp_pins */
|
||||
|
||||
/**
|
||||
* \addtogroup group_bsp_enums Enumerated Types
|
||||
* \addtogroup group_bsp_pins_led LED Pins
|
||||
* \{
|
||||
*/
|
||||
|
||||
/** Enum defining the different states for the LED. */
|
||||
typedef enum
|
||||
{
|
||||
CYBSP_LED_STATE_ON = 0,
|
||||
CYBSP_LED_STATE_OFF = 1,
|
||||
} cybsp_led_state_t;
|
||||
/** LED 4; User LED1 (red) */
|
||||
#define CYBSP_LED4 (P13_7)
|
||||
|
||||
/** Enum defining the different states for a button. */
|
||||
typedef enum
|
||||
{
|
||||
CYBSP_BTN_PRESSED = 0,
|
||||
CYBSP_BTN_OFF = 1,
|
||||
} cybsp_btn_state_t;
|
||||
/** LED 4; User LED1 (red) */
|
||||
#define CYBSP_USER_LED1 (CYBSP_LED4)
|
||||
/** LED 4; User LED1 (red) */
|
||||
#define CYBSP_USER_LED (CYBSP_USER_LED1)
|
||||
|
||||
/** Enum defining the different LED pins on the board. */
|
||||
typedef enum
|
||||
{
|
||||
CYBSP_LED_RED = P13_7,
|
||||
/** \} group_bsp_pins_led */
|
||||
|
||||
/* Corresponds to: ioss[0].port[13].pin[7] */
|
||||
CYBSP_USER_LED1 = CYBSP_LED_RED,
|
||||
CYBSP_USER_LED = CYBSP_USER_LED1,
|
||||
} cybsp_led_t;
|
||||
|
||||
/** Enum defining the different button pins on the board. */
|
||||
typedef enum
|
||||
{
|
||||
CYBSP_SW2 = P0_4,
|
||||
|
||||
/* Corresponds to: ioss[0].port[0].pin[4] */
|
||||
CYBSP_USER_BTN1 = CYBSP_SW2,
|
||||
CYBSP_USER_BTN = CYBSP_USER_BTN1,
|
||||
} cybsp_btn_t;
|
||||
/**
|
||||
* \addtogroup group_bsp_pins_btn Button Pins
|
||||
* \{
|
||||
*/
|
||||
|
||||
/** \} group_bsp_enums */
|
||||
/** Switch 2; User Button 1 */
|
||||
#define CYBSP_SW2 (P0_4)
|
||||
|
||||
/** Switch 2; User Button 1 */
|
||||
#define CYBSP_USER_BTN1 (CYBSP_SW2)
|
||||
/** Switch 2; User Button 1 */
|
||||
#define CYBSP_USER_BTN (CYBSP_USER_BTN1)
|
||||
|
||||
/** \} group_bsp_pins_btn */
|
||||
|
||||
|
||||
/**
|
||||
* \addtogroup group_bsp_pins_comm Communication Pins
|
||||
* \{
|
||||
*/
|
||||
|
||||
/** Pin: WIFI SDIO D0 */
|
||||
#define CYBSP_WIFI_SDIO_D0 (P2_0)
|
||||
/** Pin: WIFI SDIO D1 */
|
||||
#define CYBSP_WIFI_SDIO_D1 (P2_1)
|
||||
/** Pin: WIFI SDIO D2 */
|
||||
#define CYBSP_WIFI_SDIO_D2 (P2_2)
|
||||
/** Pin: WIFI SDIO D3 */
|
||||
#define CYBSP_WIFI_SDIO_D3 (P2_3)
|
||||
/** Pin: WIFI SDIO CMD */
|
||||
#define CYBSP_WIFI_SDIO_CMD (P2_4)
|
||||
/** Pin: WIFI SDIO CLK */
|
||||
#define CYBSP_WIFI_SDIO_CLK (P2_5)
|
||||
/** Pin: WIFI ON */
|
||||
#define CYBSP_WIFI_WL_REG_ON (P2_6)
|
||||
/** Pin: WIFI Host Wakeup */
|
||||
#define CYBSP_WIFI_HOST_WAKE (P0_4)
|
||||
|
||||
/** Pin: BT UART RX */
|
||||
#define CYBSP_BT_UART_RX (P3_0)
|
||||
/** Pin: BT UART TX */
|
||||
#define CYBSP_BT_UART_TX (P3_1)
|
||||
/** Pin: BT UART RTS */
|
||||
#define CYBSP_BT_UART_RTS (P3_2)
|
||||
/** Pin: BT UART CTS */
|
||||
#define CYBSP_BT_UART_CTS (P3_3)
|
||||
|
||||
/** Pin: BT Power */
|
||||
#define CYBSP_BT_POWER (P3_4)
|
||||
/** Pin: BT Host Wakeup */
|
||||
#define CYBSP_BT_HOST_WAKE (P4_0)
|
||||
/** Pin: BT Device Wakeup */
|
||||
#define CYBSP_BT_DEVICE_WAKE (P3_5)
|
||||
|
||||
/** Pin: UART RX */
|
||||
#define CYBSP_DEBUG_UART_RX (P5_0)
|
||||
/** Pin: UART TX */
|
||||
#define CYBSP_DEBUG_UART_TX (P5_1)
|
||||
|
||||
/** Pin: I2C SCL */
|
||||
#define CYBSP_I2C_SCL (P6_0)
|
||||
/** Pin: I2C SDA */
|
||||
#define CYBSP_I2C_SDA (P6_1)
|
||||
|
||||
/** Pin: SWO */
|
||||
#define CYBSP_SWO (P6_4)
|
||||
/** Pin: SWDIO */
|
||||
#define CYBSP_SWDIO (P6_6)
|
||||
/** Pin: SWDCK */
|
||||
#define CYBSP_SWDCK (P6_7)
|
||||
|
||||
/** Pin: QUAD SPI SS */
|
||||
#define CYBSP_QSPI_SS (P11_2)
|
||||
/** Pin: QUAD SPI D3 */
|
||||
#define CYBSP_QSPI_D3 (P11_3)
|
||||
/** Pin: QUAD SPI D2 */
|
||||
#define CYBSP_QSPI_D2 (P11_4)
|
||||
/** Pin: QUAD SPI D1 */
|
||||
#define CYBSP_QSPI_D1 (P11_5)
|
||||
/** Pin: QUAD SPI D0 */
|
||||
#define CYBSP_QSPI_D0 (P11_6)
|
||||
/** Pin: QUAD SPI SCK */
|
||||
#define CYBSP_QSPI_SCK (P11_7)
|
||||
|
||||
/** Host-wake GPIO drive mode */
|
||||
#define CYBSP_WIFI_HOST_WAKE_GPIO_DM (CYHAL_GPIO_DRIVE_ANALOG)
|
||||
/** Host-wake IRQ event */
|
||||
#define CYBSP_WIFI_HOST_WAKE_IRQ_EVENT (CYHAL_GPIO_IRQ_RISE)
|
||||
|
||||
/** \} group_bsp_pins_comm */
|
||||
|
||||
/** \} group_bsp_pins */
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/***************************************************************************//**
|
||||
* \file CY8CPROTO-064-SB/cybsp.c
|
||||
* \file cybsp.c
|
||||
*
|
||||
* Description:
|
||||
* Provides APIs for interacting with the hardware contained on the Cypress
|
||||
* CY8CPROTO-064-SB prototyping kit.
|
||||
* Provides initialization code for starting up the hardware contained on the
|
||||
* Cypress board.
|
||||
*
|
||||
********************************************************************************
|
||||
* \copyright
|
||||
|
@ -32,6 +32,15 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* The sysclk deep sleep callback is recommended to be the last callback that
|
||||
* is executed before entry into deep sleep mode and the first one upon
|
||||
* exit the deep sleep mode.
|
||||
* Doing so minimizes the time spent on low power mode entry and exit.
|
||||
*/
|
||||
#ifndef CYBSP_SYSCLK_PM_CALLBACK_ORDER
|
||||
#define CYBSP_SYSCLK_PM_CALLBACK_ORDER (255u)
|
||||
#endif
|
||||
|
||||
#if defined(CYBSP_WIFI_CAPABLE)
|
||||
static cyhal_sdio_t sdio_obj;
|
||||
|
||||
|
@ -41,27 +50,38 @@ cyhal_sdio_t* cybsp_get_wifi_sdio_obj(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Registers a power management callback that prepares the clock system
|
||||
* for entering deep sleep mode and restore the clocks upon wakeup from deep sleep.
|
||||
* NOTE: This is called automatically as part of \ref cybsp_init
|
||||
*/
|
||||
static cy_rslt_t cybsp_register_sysclk_pm_callback(void)
|
||||
{
|
||||
cy_rslt_t result = CY_RSLT_SUCCESS;
|
||||
static cy_stc_syspm_callback_params_t cybsp_sysclk_pm_callback_param = {NULL, NULL};
|
||||
static cy_stc_syspm_callback_t cybsp_sysclk_pm_callback = {
|
||||
.callback = &Cy_SysClk_DeepSleepCallback,
|
||||
.type = CY_SYSPM_DEEPSLEEP,
|
||||
.callbackParams = &cybsp_sysclk_pm_callback_param,
|
||||
.order = CYBSP_SYSCLK_PM_CALLBACK_ORDER
|
||||
};
|
||||
|
||||
if (!Cy_SysPm_RegisterCallback(&cybsp_sysclk_pm_callback))
|
||||
{
|
||||
result = CYBSP_RSLT_ERR_SYSCLK_PM_CALLBACK;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
cy_rslt_t cybsp_init(void)
|
||||
{
|
||||
/* Setup hardware manager to track resource usage then initialize all system (clock/power) board configuration */
|
||||
cy_rslt_t result = cyhal_hwmgr_init();
|
||||
init_cycfg_system();
|
||||
result = cybsp_register_sysclk_pm_callback();
|
||||
|
||||
#ifndef __MBED__
|
||||
if (CY_RSLT_SUCCESS == result)
|
||||
{
|
||||
/* Initialize User LEDs */
|
||||
result |= cybsp_led_init(CYBSP_USER_LED1);
|
||||
result |= cybsp_led_init(CYBSP_USER_LED2);
|
||||
/* Initialize User Buttons */
|
||||
result |= cybsp_btn_init(CYBSP_USER_BTN1);
|
||||
|
||||
/* Initialize retargetting stdio to 'DEBUG_UART' peripheral */
|
||||
if (CY_RSLT_SUCCESS == result)
|
||||
{
|
||||
result = cybsp_retarget_init();
|
||||
}
|
||||
result = cybsp_register_sysclk_pm_callback();
|
||||
}
|
||||
|
||||
#if defined(CYBSP_WIFI_CAPABLE)
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
/***************************************************************************//**
|
||||
* \file CY8CPROTO-064-SB/cybsp.h
|
||||
* \file cybsp.h
|
||||
*
|
||||
* Description:
|
||||
* Provides APIs for interacting with the hardware contained on the Cypress
|
||||
* CY8CPROTO-064-SB prototyping kit.
|
||||
* \brief
|
||||
* Basic API for setting up boards containing a Cypress MCU.
|
||||
*
|
||||
********************************************************************************
|
||||
* \copyright
|
||||
|
@ -25,11 +24,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "cy_result.h"
|
||||
#include "cybsp_types.h"
|
||||
#include "cybsp_core.h"
|
||||
#ifndef __MBED__
|
||||
#include "cybsp_retarget.h"
|
||||
#endif /* __MBED__ */
|
||||
#if defined(CYBSP_WIFI_CAPABLE)
|
||||
#include "cyhal_sdio.h"
|
||||
#endif
|
||||
|
@ -37,11 +33,30 @@
|
|||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \addtogroup group_bsp_macros Macros
|
||||
* \{
|
||||
*/
|
||||
|
||||
/** Failed to configure sysclk power management callback */
|
||||
#define CYBSP_RSLT_ERR_SYSCLK_PM_CALLBACK (CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_ABSTRACTION_BSP, 0))
|
||||
|
||||
/** \} group_bsp_macros */
|
||||
|
||||
/**
|
||||
* \addtogroup group_bsp_functions Functions
|
||||
* \{
|
||||
*/
|
||||
|
||||
/**
|
||||
* \brief Initialize all hardware on the board
|
||||
* \returns CY_RSLT_SUCCESS if the board is sucessfully initialized, if there is
|
||||
* a problem initializing any hardware it returns an error code specific
|
||||
* to the hardware module that had a problem.
|
||||
*/
|
||||
cy_rslt_t cybsp_init(void);
|
||||
|
||||
#if defined(CYBSP_WIFI_CAPABLE)
|
||||
/**
|
||||
* \brief Get the initialized sdio object used for communicating with the WiFi Chip.
|
||||
|
|
|
@ -25,122 +25,115 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "cyhal.h"
|
||||
#include "cyhal_pin_package.h"
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* \addtogroup group_bsp_pin_state Pin States
|
||||
* \{
|
||||
*/
|
||||
|
||||
/** Pin state for the LED on. */
|
||||
#define CYBSP_LED_STATE_ON (0U)
|
||||
/** Pin state for the LED off. */
|
||||
#define CYBSP_LED_STATE_OFF (1U)
|
||||
|
||||
/** Pin state for when a button is pressed. */
|
||||
#define CYBSP_BTN_PRESSED (0U)
|
||||
/** Pin state for when a button is released. */
|
||||
#define CYBSP_BTN_OFF (1U)
|
||||
|
||||
/** \} group_bsp_pin_state */
|
||||
|
||||
|
||||
/**
|
||||
* \addtogroup group_bsp_pins Pin Mappings
|
||||
* \{
|
||||
*/
|
||||
|
||||
/* Board components mapping */
|
||||
/** Pin: LED3 in the CY8CPROTO-064-SB board */
|
||||
#define CYBSP_LED3 P13_7
|
||||
/** Pin: LED4 in the CY8CPROTO-064-SB board */
|
||||
#define CYBSP_LED4 P1_5
|
||||
/** Pin: SW2 in the CY8CPROTO-064-SB board */
|
||||
#define CYBSP_SW2 P0_4
|
||||
|
||||
/* Board peripheral count */
|
||||
/** Macro: Number of LEDs on CY8CPROTO-064-SB board */
|
||||
#define CYBSP_LED_COUNT 2
|
||||
/** Macro: Number of buttons on CY8CPROTO-064-SB board */
|
||||
#define CYBSP_BTN_COUNT 1
|
||||
|
||||
/* Generic signal names */
|
||||
/** Pin: WCO input */
|
||||
#define CYBSP_WCO_IN P0_0
|
||||
/** Pin: WCO output */
|
||||
#define CYBSP_WCO_OUT P0_1
|
||||
|
||||
/** Pin: ECO input */
|
||||
#define CYBSP_ECO_IN P12_6
|
||||
/** Pin: ECO output */
|
||||
#define CYBSP_ECO_OUT P12_7
|
||||
|
||||
/** Pin: UART RX */
|
||||
#define CYBSP_UART_RX P5_0
|
||||
/** Pin: UART TX */
|
||||
#define CYBSP_UART_TX P5_1
|
||||
|
||||
/** Pin: UART RX */
|
||||
#define CYBSP_DEBUG_UART_RX P5_0
|
||||
/** Pin: UART TX */
|
||||
#define CYBSP_DEBUG_UART_TX P5_1
|
||||
|
||||
/** Pin: I2C SCL */
|
||||
#define CYBSP_I2C_SCL P6_0
|
||||
/** Pin: I2C SDA */
|
||||
#define CYBSP_I2C_SDA P6_1
|
||||
|
||||
/** Pin: SWDIO */
|
||||
#define CYBSP_SWDIO P6_6
|
||||
/** Pin: SWDCK */
|
||||
#define CYBSP_SWDCK P6_7
|
||||
/** Pin: SWO */
|
||||
#define CYBSP_SWO P6_4
|
||||
|
||||
/** Pin: QUAD SPI SS */
|
||||
#define CYBSP_QSPI_SS P11_2
|
||||
/** Pin: QUAD SPI D3 */
|
||||
#define CYBSP_QSPI_D3 P11_3
|
||||
/** Pin: QUAD SPI D2 */
|
||||
#define CYBSP_QSPI_D2 P11_4
|
||||
/** Pin: QUAD SPI D1 */
|
||||
#define CYBSP_QSPI_D1 P11_5
|
||||
/** Pin: QUAD SPI D0 */
|
||||
#define CYBSP_QSPI_D0 P11_6
|
||||
/** Pin: QUAD SPI SCK */
|
||||
#define CYBSP_QSPI_SCK P11_7
|
||||
|
||||
/** Pin: USB Device D+ */
|
||||
#define CYBSP_USB_DP P14_0
|
||||
/** Pin: USB Device D- */
|
||||
#define CYBSP_USB_DM P14_1
|
||||
|
||||
/** \} group_bsp_pins */
|
||||
|
||||
/**
|
||||
* \addtogroup group_bsp_enums Enumerated Types
|
||||
* \addtogroup group_bsp_pins_led LED Pins
|
||||
* \{
|
||||
*/
|
||||
|
||||
/** Enum defining the different states for the LED. */
|
||||
typedef enum
|
||||
{
|
||||
CYBSP_LED_STATE_ON = 0,
|
||||
CYBSP_LED_STATE_OFF = 1,
|
||||
} cybsp_led_state_t;
|
||||
/** LED 3; User LED1 */
|
||||
#define CYBSP_LED3 (P13_7)
|
||||
/** LED 4; User LED2 */
|
||||
#define CYBSP_LED4 (P1_5)
|
||||
|
||||
/** Enum defining the different states for a button. */
|
||||
typedef enum
|
||||
{
|
||||
CYBSP_BTN_PRESSED = 0,
|
||||
CYBSP_BTN_OFF = 1,
|
||||
} cybsp_btn_state_t;
|
||||
/** LED 3; User LED1 */
|
||||
#define CYBSP_USER_LED1 (CYBSP_LED3)
|
||||
/** LED 4; User LED2 */
|
||||
#define CYBSP_USER_LED2 (CYBSP_LED4)
|
||||
/** LED 3; User LED1 */
|
||||
#define CYBSP_USER_LED (CYBSP_USER_LED1)
|
||||
|
||||
/** Enum defining the different LED pins on the board. */
|
||||
typedef enum
|
||||
{
|
||||
CYBSP_LED_RED = CYBSP_LED3,
|
||||
CYBSP_LED_GREEN = CYBSP_LED4,
|
||||
/** \} group_bsp_pins_led */
|
||||
|
||||
CYBSP_USER_LED = CYBSP_LED_RED,
|
||||
CYBSP_USER_LED1 = CYBSP_LED_RED,
|
||||
CYBSP_USER_LED2 = CYBSP_LED_GREEN,
|
||||
} cybsp_led_t;
|
||||
/**
|
||||
* \addtogroup group_bsp_pins_btn Button Pins
|
||||
* \{
|
||||
*/
|
||||
|
||||
/** Enum defining the different button pins on the board. */
|
||||
typedef enum
|
||||
{
|
||||
CYBSP_USER_BTN = CYBSP_SW2,
|
||||
CYBSP_USER_BTN1 = CYBSP_SW2,
|
||||
} cybsp_btn_t;
|
||||
/** Switch 2; User Button 1 */
|
||||
#define CYBSP_SW2 (P0_4)
|
||||
|
||||
/** Switch 2; User Button 1 */
|
||||
#define CYBSP_USER_BTN1 (CYBSP_SW2)
|
||||
/** Switch 2; User Button 1 */
|
||||
#define CYBSP_USER_BTN (CYBSP_USER_BTN1)
|
||||
|
||||
/** \} group_bsp_pins_btn */
|
||||
|
||||
|
||||
/**
|
||||
* \addtogroup group_bsp_pins_comm Communication Pins
|
||||
* \{
|
||||
*/
|
||||
|
||||
/** Pin: UART RX */
|
||||
#define CYBSP_UART_RX (P5_0)
|
||||
/** Pin: UART TX */
|
||||
#define CYBSP_UART_TX (P5_1)
|
||||
|
||||
/** Pin: UART RX */
|
||||
#define CYBSP_DEBUG_UART_RX (P5_0)
|
||||
/** Pin: UART TX */
|
||||
#define CYBSP_DEBUG_UART_TX (P5_1)
|
||||
|
||||
/** Pin: I2C SCL */
|
||||
#define CYBSP_I2C_SCL (P6_0)
|
||||
/** Pin: I2C SDA */
|
||||
#define CYBSP_I2C_SDA (P6_1)
|
||||
|
||||
/** Pin: SWDIO */
|
||||
#define CYBSP_SWDIO (P6_6)
|
||||
/** Pin: SWDCK */
|
||||
#define CYBSP_SWDCK (P6_7)
|
||||
/** Pin: SWO */
|
||||
#define CYBSP_SWO (P6_4)
|
||||
|
||||
/** Pin: QUAD SPI SS */
|
||||
#define CYBSP_QSPI_SS (P11_2)
|
||||
/** Pin: QUAD SPI D3 */
|
||||
#define CYBSP_QSPI_D3 (P11_3)
|
||||
/** Pin: QUAD SPI D2 */
|
||||
#define CYBSP_QSPI_D2 (P11_4)
|
||||
/** Pin: QUAD SPI D1 */
|
||||
#define CYBSP_QSPI_D1 (P11_5)
|
||||
/** Pin: QUAD SPI D0 */
|
||||
#define CYBSP_QSPI_D0 (P11_6)
|
||||
/** Pin: QUAD SPI SCK */
|
||||
#define CYBSP_QSPI_SCK (P11_7)
|
||||
|
||||
/** \} group_bsp_pins_comm */
|
||||
|
||||
/** \} group_bsp_pins */
|
||||
|
||||
/** \} group_bsp_enums */
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/***************************************************************************//**
|
||||
* \file CYW943012P6EVB-01/cybsp.c
|
||||
* \file cybsp.c
|
||||
*
|
||||
* Description:
|
||||
* Provides APIs for interacting with the hardware contained on the Cypress
|
||||
* CYW943012P6EVB-01 kit.
|
||||
* Provides initialization code for starting up the hardware contained on the
|
||||
* Cypress board.
|
||||
*
|
||||
********************************************************************************
|
||||
* \copyright
|
||||
|
@ -32,6 +32,15 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* The sysclk deep sleep callback is recommended to be the last callback that
|
||||
* is executed before entry into deep sleep mode and the first one upon
|
||||
* exit the deep sleep mode.
|
||||
* Doing so minimizes the time spent on low power mode entry and exit.
|
||||
*/
|
||||
#ifndef CYBSP_SYSCLK_PM_CALLBACK_ORDER
|
||||
#define CYBSP_SYSCLK_PM_CALLBACK_ORDER (255u)
|
||||
#endif
|
||||
|
||||
#if defined(CYBSP_WIFI_CAPABLE)
|
||||
static cyhal_sdio_t sdio_obj;
|
||||
|
||||
|
@ -41,6 +50,29 @@ cyhal_sdio_t* cybsp_get_wifi_sdio_obj(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Registers a power management callback that prepares the clock system
|
||||
* for entering deep sleep mode and restore the clocks upon wakeup from deep sleep.
|
||||
* NOTE: This is called automatically as part of \ref cybsp_init
|
||||
*/
|
||||
static cy_rslt_t cybsp_register_sysclk_pm_callback(void)
|
||||
{
|
||||
cy_rslt_t result = CY_RSLT_SUCCESS;
|
||||
static cy_stc_syspm_callback_params_t cybsp_sysclk_pm_callback_param = {NULL, NULL};
|
||||
static cy_stc_syspm_callback_t cybsp_sysclk_pm_callback = {
|
||||
.callback = &Cy_SysClk_DeepSleepCallback,
|
||||
.type = CY_SYSPM_DEEPSLEEP,
|
||||
.callbackParams = &cybsp_sysclk_pm_callback_param,
|
||||
.order = CYBSP_SYSCLK_PM_CALLBACK_ORDER
|
||||
};
|
||||
|
||||
if (!Cy_SysPm_RegisterCallback(&cybsp_sysclk_pm_callback))
|
||||
{
|
||||
result = CYBSP_RSLT_ERR_SYSCLK_PM_CALLBACK;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
cy_rslt_t cybsp_init(void)
|
||||
{
|
||||
/* Setup hardware manager to track resource usage then initialize all system (clock/power) board configuration */
|
||||
|
@ -52,32 +84,6 @@ cy_rslt_t cybsp_init(void)
|
|||
result = cybsp_register_sysclk_pm_callback();
|
||||
}
|
||||
|
||||
#ifndef __MBED__
|
||||
if (CY_RSLT_SUCCESS == result)
|
||||
{
|
||||
/* Initialize User LEDs */
|
||||
/* Reserves: CYBSP_USER_LED1 */
|
||||
result |= cybsp_led_init(CYBSP_USER_LED1);
|
||||
/* Reserves: CYBSP_USER_LED2 */
|
||||
result |= cybsp_led_init(CYBSP_USER_LED2);
|
||||
/* Reserves: CYBSP_USER_LED3 */
|
||||
result |= cybsp_led_init(CYBSP_USER_LED3);
|
||||
/* Initialize User Buttons */
|
||||
/* Reserves: CYBSP_USER_BTN1 */
|
||||
result |= cybsp_btn_init(CYBSP_USER_BTN1);
|
||||
|
||||
CY_ASSERT(CY_RSLT_SUCCESS == result);
|
||||
|
||||
/* Initialize retargetting stdio to 'DEBUG_UART' peripheral */
|
||||
if (CY_RSLT_SUCCESS == result)
|
||||
{
|
||||
/* Reserves: CYBSP_DEBUG_UART_RX, CYBSP_DEBUG_UART_TX, corresponding SCB instance
|
||||
* and one of available clock dividers */
|
||||
result = cybsp_retarget_init();
|
||||
}
|
||||
}
|
||||
#endif /* __MBED__ */
|
||||
|
||||
#if defined(CYBSP_WIFI_CAPABLE)
|
||||
/* Initialize SDIO interface. This must be done before other HAL API calls as some SDIO implementations require
|
||||
* specific peripheral instances.
|
||||
|
@ -101,8 +107,9 @@ cy_rslt_t cybsp_init(void)
|
|||
#endif /* defined(CYBSP_WIFI_CAPABLE) */
|
||||
|
||||
/* CYHAL_HWMGR_RSLT_ERR_INUSE error code could be returned if any needed for BSP resource was reserved by
|
||||
* user previously. Please review the Device Configurator (design.modus) and the BSP reservation list
|
||||
* (cyreservedresources.list) to make sure no resources are reserved by both. */
|
||||
* user previously. Please review the Device Configurator (design.modus) and the BSP reservation list
|
||||
* (cyreservedresources.list) to make sure no resources are reserved by both.
|
||||
*/
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
/***************************************************************************//**
|
||||
* \file CYW943012P6EVB-01/cybsp.h
|
||||
* \file cybsp.h
|
||||
*
|
||||
* Description:
|
||||
* Provides APIs for interacting with the hardware contained on the Cypress
|
||||
* CYW943012P6EVB-01 kit.
|
||||
* \brief
|
||||
* Basic API for setting up boards containing a Cypress MCU.
|
||||
*
|
||||
********************************************************************************
|
||||
* \copyright
|
||||
|
@ -25,25 +24,39 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "cy_result.h"
|
||||
#include "cybsp_types.h"
|
||||
#include "cybsp_core.h"
|
||||
#if defined(CYBSP_WIFI_CAPABLE)
|
||||
#include "cyhal_sdio.h"
|
||||
#endif
|
||||
#ifndef __MBED__
|
||||
#include "cybsp_retarget.h"
|
||||
#include "cybsp_rgb_led.h"
|
||||
#endif /* __MBED__ */
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \addtogroup group_bsp_macros Macros
|
||||
* \{
|
||||
*/
|
||||
|
||||
/** Failed to configure sysclk power management callback */
|
||||
#define CYBSP_RSLT_ERR_SYSCLK_PM_CALLBACK (CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_ABSTRACTION_BSP, 0))
|
||||
|
||||
/** \} group_bsp_macros */
|
||||
|
||||
/**
|
||||
* \addtogroup group_bsp_functions Functions
|
||||
* \{
|
||||
*/
|
||||
|
||||
/**
|
||||
* \brief Initialize all hardware on the board
|
||||
* \returns CY_RSLT_SUCCESS if the board is sucessfully initialized, if there is
|
||||
* a problem initializing any hardware it returns an error code specific
|
||||
* to the hardware module that had a problem.
|
||||
*/
|
||||
cy_rslt_t cybsp_init(void);
|
||||
|
||||
#if defined(CYBSP_WIFI_CAPABLE)
|
||||
/**
|
||||
* \brief Get the initialized sdio object used for communicating with the WiFi Chip.
|
||||
|
|
|
@ -25,286 +25,204 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "cyhal.h"
|
||||
#include "cyhal_pin_package.h"
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* \addtogroup group_bsp_pin_state Pin States
|
||||
* \{
|
||||
*/
|
||||
|
||||
/** Pin state for the LED on. */
|
||||
#define CYBSP_LED_STATE_ON (0U)
|
||||
/** Pin state for the LED off. */
|
||||
#define CYBSP_LED_STATE_OFF (1U)
|
||||
|
||||
/** Pin state for when a button is pressed. */
|
||||
#define CYBSP_BTN_PRESSED (0U)
|
||||
/** Pin state for when a button is released. */
|
||||
#define CYBSP_BTN_OFF (1U)
|
||||
|
||||
/** \} group_bsp_pin_state */
|
||||
|
||||
|
||||
/**
|
||||
* \addtogroup group_bsp_pins Pin Mappings
|
||||
* \{
|
||||
*/
|
||||
|
||||
// Arduino connector namings
|
||||
/** Arduino A0 */
|
||||
#define CYBSP_A0 P10_0
|
||||
/** Arduino A1 */
|
||||
#define CYBSP_A1 P10_1
|
||||
/** Arduino A2 */
|
||||
#define CYBSP_A2 P6_4
|
||||
/** Arduino A3 */
|
||||
#define CYBSP_A3 P6_5
|
||||
/** Arduino A4 */
|
||||
#define CYBSP_A4 P10_4
|
||||
/** Arduino A5 */
|
||||
#define CYBSP_A5 P10_5
|
||||
/** Arduino D0 */
|
||||
#define CYBSP_D0 P5_0
|
||||
/** Arduino D1 */
|
||||
#define CYBSP_D1 P5_1
|
||||
/** Arduino D2 */
|
||||
#define CYBSP_D2 P5_2
|
||||
/** Arduino D3 */
|
||||
#define CYBSP_D3 P5_3
|
||||
/** Arduino D4 */
|
||||
#define CYBSP_D4 P5_4
|
||||
/** Arduino D5 */
|
||||
#define CYBSP_D5 P5_5
|
||||
/** Arduino D6 */
|
||||
#define CYBSP_D6 P5_6
|
||||
/** Arduino D7 */
|
||||
#define CYBSP_D7 P5_7
|
||||
/** Arduino D8 */
|
||||
#define CYBSP_D8 NC
|
||||
/** Arduino D9 */
|
||||
#define CYBSP_D9 NC
|
||||
/** Arduino D10 */
|
||||
#define CYBSP_D10 P0_5
|
||||
/** Arduino D11 */
|
||||
#define CYBSP_D11 P0_2
|
||||
/** Arduino D12 */
|
||||
#define CYBSP_D12 P0_3
|
||||
/** Arduino D13 */
|
||||
#define CYBSP_D13 P0_4
|
||||
/** Arduino D14 */
|
||||
#define CYBSP_D14 P1_0
|
||||
/** Arduino D15 */
|
||||
#define CYBSP_D15 P1_1
|
||||
|
||||
// Generic signal names
|
||||
/** Pin: CYBSP_WCO_IN */
|
||||
#define CYBSP_WCO_IN P0_0
|
||||
/** Pin: CYBSP_WCO_OUT */
|
||||
#define CYBSP_WCO_OUT P0_1
|
||||
|
||||
/** Pin: CYBSP_CSD_TX */
|
||||
#define CYBSP_CSD_TX P1_0
|
||||
/** Pin: CYBSP_WL_SECI_IN */
|
||||
#define CYBSP_WL_SECI_IN P1_2
|
||||
/** Pin: CYBSP_WL_FRAM_SYNC */
|
||||
#define CYBSP_WL_FRAM_SYNC P1_3
|
||||
/** Pin: CYBSP_WL_PRIORITY */
|
||||
#define CYBSP_WL_PRIORITY P1_4
|
||||
/** Pin: CYBSP_WL_SECI_OUT */
|
||||
#define CYBSP_WL_SECI_OUT P1_5
|
||||
|
||||
/** Pin: CYBSP_WIFI_SDIO_D0 */
|
||||
/* Corresponds to: ioss[0].port[2].pin[0], udb[0] */
|
||||
#define CYBSP_WIFI_SDIO_D0 P2_0
|
||||
/** Pin: CYBSP_WIFI_SDIO_D1 */
|
||||
/* Corresponds to: ioss[0].port[2].pin[1], udb[0] */
|
||||
#define CYBSP_WIFI_SDIO_D1 P2_1
|
||||
/** Pin: CYBSP_WIFI_SDIO_D2 */
|
||||
/* Corresponds to: ioss[0].port[2].pin[2], udb[0] */
|
||||
#define CYBSP_WIFI_SDIO_D2 P2_2
|
||||
/** Pin: CYBSP_WIFI_SDIO_D3 */
|
||||
/* Corresponds to: ioss[0].port[2].pin[3], udb[0] */
|
||||
#define CYBSP_WIFI_SDIO_D3 P2_3
|
||||
/** Pin: CYBSP_WIFI_SDIO_CMD */
|
||||
/* Corresponds to: ioss[0].port[2].pin[4], udb[0] */
|
||||
#define CYBSP_WIFI_SDIO_CMD P2_4
|
||||
/** Pin: CYBSP_WIFI_SDIO_CLK */
|
||||
/* Corresponds to: ioss[0].port[2].pin[5], udb[0] */
|
||||
#define CYBSP_WIFI_SDIO_CLK P2_5
|
||||
/** Pin: CYBSP_WIFI_WL_REG_ON */
|
||||
/* Corresponds to: ioss[0].port[2].pin[6], udb[0] */
|
||||
#define CYBSP_WIFI_WL_REG_ON P2_6
|
||||
/** Pin: CYBSP_WIFI_HOST_WAKE */
|
||||
#define CYBSP_WIFI_HOST_WAKE P2_7
|
||||
/** Host-wake GPIO drive mode */
|
||||
#define CYBSP_WIFI_HOST_WAKE_GPIO_DM CYHAL_GPIO_DRIVE_ANALOG
|
||||
/** Host-wake IRQ event */
|
||||
#define CYBSP_WIFI_HOST_WAKE_IRQ_EVENT CYHAL_GPIO_IRQ_RISE
|
||||
|
||||
/** Pin: CYBSP_BT_UART_RX */
|
||||
#define CYBSP_BT_UART_RX P3_0
|
||||
/** Pin: CYBSP_BT_UART_TX */
|
||||
#define CYBSP_BT_UART_TX P3_1
|
||||
/** Pin: CYBSP_BT_UART_RTS */
|
||||
#define CYBSP_BT_UART_RTS P3_2
|
||||
/** Pin: CYBSP_BT_UART_CTS */
|
||||
#define CYBSP_BT_UART_CTS P3_3
|
||||
|
||||
/** Pin: BT Power */
|
||||
#define CYBSP_BT_POWER P3_4
|
||||
/** Pin: CYBSP_BT_HOST_WAKE */
|
||||
#define CYBSP_BT_HOST_WAKE P3_5
|
||||
/** Pin: CYBSP_BT_DEVICE_WAKE */
|
||||
#define CYBSP_BT_DEVICE_WAKE P4_0
|
||||
/** Pin: CYBSP_BT_RST */
|
||||
#define CYBSP_BT_RST P4_1
|
||||
|
||||
/** Pin: UART RX */
|
||||
/* Corresponds to: ioss[0].port[13].pin[0], scb[6] */
|
||||
#define CYBSP_DEBUG_UART_RX P13_0
|
||||
/** Pin: UART TX */
|
||||
/* Corresponds to: ioss[0].port[13].pin[1], scb[6] */
|
||||
#define CYBSP_DEBUG_UART_TX P13_1
|
||||
|
||||
/** Pin: CYBSP_I2C_SCL */
|
||||
#define CYBSP_I2C_SCL P6_0
|
||||
/** Pin: CYBSP_I2C_SDA */
|
||||
#define CYBSP_I2C_SDA P6_1
|
||||
/** Pin: CYBSP_TDO_SWO */
|
||||
#define CYBSP_TDO_SWO P6_4
|
||||
/** Pin: CYBSP_TMS_SWDIO */
|
||||
#define CYBSP_TMS_SWDIO P6_6
|
||||
/** Pin: CYBSP_SWCLK */
|
||||
#define CYBSP_SWCLK P6_7
|
||||
|
||||
/** Pin: CYBSP_TRACECLK */
|
||||
#define CYBSP_TRACECLK P7_0
|
||||
/** Pin: CYBSP_CINTA */
|
||||
#define CYBSP_CINTA P7_1
|
||||
/** Pin: CYBSP_CINTB */
|
||||
#define CYBSP_CINTB P7_2
|
||||
/** Pin: CYBSP_CMOD */
|
||||
#define CYBSP_CMOD P7_7
|
||||
|
||||
/** Pin: CYBSP_CSD_BTN0 */
|
||||
#define CYBSP_CSD_BTN0 P8_1
|
||||
/** Pin: CYBSP_CSD_BTN1 */
|
||||
#define CYBSP_CSD_BTN1 P8_2
|
||||
/** Pin: CYBSP_CSD_SLD0 */
|
||||
#define CYBSP_CSD_SLD0 P8_3
|
||||
/** Pin: CYBSP_CSD_SLD1 */
|
||||
#define CYBSP_CSD_SLD1 P8_4
|
||||
/** Pin: CYBSP_CSD_SLD2 */
|
||||
#define CYBSP_CSD_SLD2 P8_5
|
||||
/** Pin: CYBSP_CSD_SLD3 */
|
||||
#define CYBSP_CSD_SLD3 P8_6
|
||||
/** Pin: CYBSP_CSD_SLD4 */
|
||||
#define CYBSP_CSD_SLD4 P8_7
|
||||
|
||||
/** Pin: CYBSP_TRACEDATA3 */
|
||||
#define CYBSP_TRACEDATA3 P9_0
|
||||
/** Pin: CYBSP_TRACEDATA2 */
|
||||
#define CYBSP_TRACEDATA2 P9_1
|
||||
/** Pin: CYBSP_TRACEDATA1 */
|
||||
#define CYBSP_TRACEDATA1 P9_2
|
||||
/** Pin: CYBSP_TRACEDATA0 */
|
||||
#define CYBSP_TRACEDATA0 P9_3
|
||||
|
||||
/** Pin: CYBSP_ROW6_SPI_MOSI */
|
||||
#define CYBSP_ROW6_SPI_MOSI P10_0
|
||||
/** Pin: CYBSP_COL8_SPI_MISO */
|
||||
#define CYBSP_COL8_SPI_MISO P10_1
|
||||
/** Pin: CYBSP_ROW7_SPI_CLK */
|
||||
#define CYBSP_ROW7_SPI_CLK P10_2
|
||||
/** Pin: CYBSP_COL7_SPI_CS */
|
||||
#define CYBSP_COL7_SPI_CS P10_3
|
||||
/** Pin: CYBSP_BAT_MON */
|
||||
#define CYBSP_BAT_MON P10_4
|
||||
/** Pin: CYBSP_WL_WAKE */
|
||||
#define CYBSP_WL_WAKE P10_7
|
||||
|
||||
/** Pin: CYBSP_UART_RX */
|
||||
#define CYBSP_UART_RX P11_0
|
||||
/** Pin: CYBSP_UART_TX */
|
||||
#define CYBSP_UART_TX P11_1
|
||||
/** Pin: CYBSP_QSPI_SS */
|
||||
#define CYBSP_QSPI_SS P11_2
|
||||
/** Pin: CYBSP_QSPI_D3 */
|
||||
#define CYBSP_QSPI_D3 P11_3
|
||||
/** Pin: CYBSP_QSPI_D2 */
|
||||
#define CYBSP_QSPI_D2 P11_4
|
||||
/** Pin: CYBSP_QSPI_D1 */
|
||||
#define CYBSP_QSPI_D1 P11_5
|
||||
/** Pin: CYBSP_QSPI_D0 */
|
||||
#define CYBSP_QSPI_D0 P11_6
|
||||
/** Pin: CYBSP_QSPI_SCK */
|
||||
#define CYBSP_QSPI_SCK P11_7
|
||||
|
||||
/** Pin: CYBSP_BT_GPIO4 */
|
||||
#define CYBSP_BT_GPIO4 P12_0
|
||||
/** Pin: CYBSP_BT_GPIO5 */
|
||||
#define CYBSP_BT_GPIO5 P12_1
|
||||
/** Pin: CYBSP_BT_GPIO2 */
|
||||
#define CYBSP_BT_GPIO2 P12_2
|
||||
/** Pin: CYBSP_BT_GPIO3 */
|
||||
#define CYBSP_BT_GPIO3 P12_3
|
||||
/** Pin: CYBSP_ECO_IN */
|
||||
#define CYBSP_ECO_IN P12_6
|
||||
/** Pin: CYBSP_ECO_OUT */
|
||||
#define CYBSP_ECO_OUT P12_7
|
||||
|
||||
/** Pin: CYBSP_P6_UART_RX */
|
||||
/* Corresponds to: ioss[0].port[13].pin[0], scb[6] */
|
||||
#define CYBSP_P6_UART_RX P13_0
|
||||
/** Pin: CYBSP_P6_UART_TX */
|
||||
/* Corresponds to: ioss[0].port[13].pin[1], scb[6] */
|
||||
#define CYBSP_P6_UART_TX P13_1
|
||||
/** Pin: CYBSP_USB_DEV_VBUS_DET */
|
||||
#define CYBSP_USB_DEV_VBUS_DET P13_4
|
||||
/** Pin: CYBSP_USB_HOST_EN */
|
||||
#define CYBSP_USB_HOST_EN P13_5
|
||||
/** Pin: CYBSP_USB_INT_L */
|
||||
#define CYBSP_USB_INT_L P13_7
|
||||
|
||||
/** Pin: CYBSP_USB_DP */
|
||||
#define CYBSP_USB_DP P14_0
|
||||
/** Pin: CYBSP_USB_DM */
|
||||
#define CYBSP_USB_DM P14_1
|
||||
|
||||
/** \} group_bsp_pins */
|
||||
|
||||
/**
|
||||
* \addtogroup group_bsp_enums Enumerated Types
|
||||
* \addtogroup group_bsp_pins_led LED Pins
|
||||
* \{
|
||||
*/
|
||||
|
||||
/** Enum defining the different states for the LED. */
|
||||
typedef enum
|
||||
{
|
||||
CYBSP_LED_STATE_ON = 0,
|
||||
CYBSP_LED_STATE_OFF = 1,
|
||||
} cybsp_led_state_t;
|
||||
/** LED 5: RGB LED - Red; User LED1 */
|
||||
#define CYBSP_LED_RGB_RED (P0_3)
|
||||
/** LED 5: RGB LED - Green; User LED2 */
|
||||
#define CYBSP_LED_RGB_GREEN (P1_1)
|
||||
/** LED 5: RGB LED - Blue; User LED3 */
|
||||
#define CYBSP_LED_RGB_BLUE (P10_6)
|
||||
|
||||
/** Enum defining the different states for a button. */
|
||||
typedef enum
|
||||
{
|
||||
CYBSP_BTN_PRESSED = 0,
|
||||
CYBSP_BTN_OFF = 1,
|
||||
} cybsp_btn_state_t;
|
||||
/** LED 5: RGB LED - Red; User LED1 */
|
||||
#define CYBSP_USER_LED1 (CYBSP_LED_RGB_RED)
|
||||
/** LED 5: RGB LED - Green; User LED2 */
|
||||
#define CYBSP_USER_LED2 (CYBSP_LED_RGB_GREEN)
|
||||
/** LED 5: RGB LED - Blue; User LED3 */
|
||||
#define CYBSP_USER_LED3 (CYBSP_LED_RGB_BLUE)
|
||||
/** LED 8; User LED1 */
|
||||
#define CYBSP_USER_LED (CYBSP_USER_LED1)
|
||||
|
||||
/** Enum defining the different LED pins on the board. */
|
||||
typedef enum
|
||||
{
|
||||
CYBSP_LED_RGB_RED = P0_3,
|
||||
CYBSP_LED_RGB_GREEN = P1_1,
|
||||
CYBSP_LED_RGB_BLUE = P10_6,
|
||||
/** \} group_bsp_pins_led */
|
||||
|
||||
/* Corresponds to: ioss[0].port[0].pin[3] */
|
||||
CYBSP_USER_LED1 = CYBSP_LED_RGB_RED,
|
||||
/* Corresponds to: ioss[0].port[1].pin[1] */
|
||||
CYBSP_USER_LED2 = CYBSP_LED_RGB_GREEN,
|
||||
/* Corresponds to: ioss[0].port[10].pin[6] */
|
||||
CYBSP_USER_LED3 = CYBSP_LED_RGB_BLUE,
|
||||
CYBSP_USER_LED = CYBSP_USER_LED1,
|
||||
} cybsp_led_t;
|
||||
/**
|
||||
* \addtogroup group_bsp_pins_btn Button Pins
|
||||
* \{
|
||||
*/
|
||||
|
||||
/** Enum defining the different button pins on the board. */
|
||||
typedef enum
|
||||
{
|
||||
CYBSP_SW6 = P0_4,
|
||||
/** Switch 6; User Button 1 */
|
||||
#define CYBSP_SW6 (P0_4)
|
||||
|
||||
/* Corresponds to: ioss[0].port[0].pin[4] */
|
||||
CYBSP_USER_BTN1 = CYBSP_SW6,
|
||||
CYBSP_USER_BTN = CYBSP_USER_BTN1,
|
||||
} cybsp_btn_t;
|
||||
/** Switch 6; User Button 1 */
|
||||
#define CYBSP_USER_BTN1 (CYBSP_SW6)
|
||||
/** Switch 6; User Button 1 */
|
||||
#define CYBSP_USER_BTN (CYBSP_USER_BTN1)
|
||||
|
||||
/** \} group_bsp_enums */
|
||||
/** \} group_bsp_pins_btn */
|
||||
|
||||
|
||||
/**
|
||||
* \addtogroup group_bsp_pins_comm Communication Pins
|
||||
* \{
|
||||
*/
|
||||
|
||||
/** Pin: WIFI SDIO D0 */
|
||||
#define CYBSP_WIFI_SDIO_D0 (P2_0)
|
||||
/** Pin: WIFI SDIO D1 */
|
||||
#define CYBSP_WIFI_SDIO_D1 (P2_1)
|
||||
/** Pin: WIFI SDIO D2 */
|
||||
#define CYBSP_WIFI_SDIO_D2 (P2_2)
|
||||
/** Pin: WIFI SDIO D3 */
|
||||
#define CYBSP_WIFI_SDIO_D3 (P2_3)
|
||||
/** Pin: WIFI SDIO CMD */
|
||||
#define CYBSP_WIFI_SDIO_CMD (P2_4)
|
||||
/** Pin: WIFI SDIO CLK */
|
||||
#define CYBSP_WIFI_SDIO_CLK (P2_5)
|
||||
/** Pin: WIFI ON */
|
||||
#define CYBSP_WIFI_WL_REG_ON (P2_6)
|
||||
/** Pin: WIFI Host Wakeup */
|
||||
#define CYBSP_WIFI_HOST_WAKE (P2_7)
|
||||
|
||||
/** Pin: BT UART RX */
|
||||
#define CYBSP_BT_UART_RX (P3_0)
|
||||
/** Pin: BT UART TX */
|
||||
#define CYBSP_BT_UART_TX (P3_1)
|
||||
/** Pin: BT UART RTS */
|
||||
#define CYBSP_BT_UART_RTS (P3_2)
|
||||
/** Pin: BT UART CTS */
|
||||
#define CYBSP_BT_UART_CTS (P3_3)
|
||||
|
||||
/** Pin: BT Power */
|
||||
#define CYBSP_BT_POWER (P3_4)
|
||||
/** Pin: BT Host Wakeup */
|
||||
#define CYBSP_BT_HOST_WAKE (P3_5)
|
||||
/** Pin: BT Device Wakeup */
|
||||
#define CYBSP_BT_DEVICE_WAKE (P4_0)
|
||||
|
||||
/** Pin: UART RX */
|
||||
#define CYBSP_DEBUG_UART_RX (P13_0)
|
||||
/** Pin: UART TX */
|
||||
#define CYBSP_DEBUG_UART_TX (P13_1)
|
||||
|
||||
/** Pin: I2C SCL */
|
||||
#define CYBSP_I2C_SCL (P6_0)
|
||||
/** Pin: I2C SDA */
|
||||
#define CYBSP_I2C_SDA (P6_1)
|
||||
|
||||
/** Pin: SWO */
|
||||
#define CYBSP_SWO (P6_4)
|
||||
/** Pin: SWDIO */
|
||||
#define CYBSP_SWDIO (P6_6)
|
||||
/** Pin: SWDCK */
|
||||
#define CYBSP_SWDCK (P6_7)
|
||||
|
||||
/** Pin: QUAD SPI SS */
|
||||
#define CYBSP_QSPI_SS (P11_2)
|
||||
/** Pin: QUAD SPI D3 */
|
||||
#define CYBSP_QSPI_D3 (P11_3)
|
||||
/** Pin: QUAD SPI D2 */
|
||||
#define CYBSP_QSPI_D2 (P11_4)
|
||||
/** Pin: QUAD SPI D1 */
|
||||
#define CYBSP_QSPI_D1 (P11_5)
|
||||
/** Pin: QUAD SPI D0 */
|
||||
#define CYBSP_QSPI_D0 (P11_6)
|
||||
/** Pin: QUAD SPI SCK */
|
||||
#define CYBSP_QSPI_SCK (P11_7)
|
||||
|
||||
/** Host-wake GPIO drive mode */
|
||||
#define CYBSP_WIFI_HOST_WAKE_GPIO_DM (CYHAL_GPIO_DRIVE_ANALOG)
|
||||
/** Host-wake IRQ event */
|
||||
#define CYBSP_WIFI_HOST_WAKE_IRQ_EVENT (CYHAL_GPIO_IRQ_RISE)
|
||||
|
||||
/** \} group_bsp_pins_comm */
|
||||
|
||||
|
||||
/**
|
||||
* \addtogroup group_bsp_pins_arduino Arduino Header Pins
|
||||
* \{
|
||||
*/
|
||||
|
||||
/** Arduino A0 */
|
||||
#define CYBSP_A0 P10_0
|
||||
/** Arduino A1 */
|
||||
#define CYBSP_A1 P10_1
|
||||
/** Arduino A2 */
|
||||
#define CYBSP_A2 P6_4
|
||||
/** Arduino A3 */
|
||||
#define CYBSP_A3 P6_5
|
||||
/** Arduino A4 */
|
||||
#define CYBSP_A4 P10_4
|
||||
/** Arduino A5 */
|
||||
#define CYBSP_A5 P10_5
|
||||
/** Arduino D0 */
|
||||
#define CYBSP_D0 (P5_0)
|
||||
/** Arduino D1 */
|
||||
#define CYBSP_D1 (P5_1)
|
||||
/** Arduino D2 */
|
||||
#define CYBSP_D2 (P5_2)
|
||||
/** Arduino D3 */
|
||||
#define CYBSP_D3 (P5_3)
|
||||
/** Arduino D4 */
|
||||
#define CYBSP_D4 (P5_4)
|
||||
/** Arduino D5 */
|
||||
#define CYBSP_D5 (P5_5)
|
||||
/** Arduino D6 */
|
||||
#define CYBSP_D6 (P5_6)
|
||||
/** Arduino D7 */
|
||||
#define CYBSP_D7 (P5_7)
|
||||
/** Arduino D8 */
|
||||
#define CYBSP_D8 (NC)
|
||||
/** Arduino D9 */
|
||||
#define CYBSP_D9 (NC)
|
||||
/** Arduino D10 */
|
||||
#define CYBSP_D10 (P0_5)
|
||||
/** Arduino D11 */
|
||||
#define CYBSP_D11 (P0_2)
|
||||
/** Arduino D12 */
|
||||
#define CYBSP_D12 (P0_3)
|
||||
/** Arduino D13 */
|
||||
#define CYBSP_D13 (P0_4)
|
||||
/** Arduino D14 */
|
||||
#define CYBSP_D14 (P1_0)
|
||||
/** Arduino D15 */
|
||||
#define CYBSP_D15 (P1_1)
|
||||
|
||||
/** \} group_bsp_pins_arduino */
|
||||
|
||||
/** \} group_bsp_pins */
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
|
|
|
@ -1,92 +0,0 @@
|
|||
/***************************************************************************//**
|
||||
* \file cybsp_core.c
|
||||
*
|
||||
* \brief
|
||||
* Provides utility functions that are used by board support packages.
|
||||
*
|
||||
********************************************************************************
|
||||
* \copyright
|
||||
* Copyright 2018-2019 Cypress Semiconductor Corporation
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*******************************************************************************/
|
||||
|
||||
#include "cybsp_core.h"
|
||||
#include "cyhal.h"
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
cy_rslt_t cybsp_led_init(cybsp_led_t which)
|
||||
{
|
||||
return cyhal_gpio_init((cyhal_gpio_t)which, CYHAL_GPIO_DIR_OUTPUT, CYHAL_GPIO_DRIVE_STRONG, CYBSP_LED_STATE_OFF);
|
||||
}
|
||||
|
||||
void cybsp_led_set_state(cybsp_led_t which, bool on)
|
||||
{
|
||||
cyhal_gpio_write((cyhal_gpio_t)which, on);
|
||||
}
|
||||
|
||||
void cybsp_led_toggle(cybsp_led_t which)
|
||||
{
|
||||
cyhal_gpio_toggle((cyhal_gpio_t)which);
|
||||
}
|
||||
|
||||
cy_rslt_t cybsp_btn_init(cybsp_btn_t which)
|
||||
{
|
||||
return cyhal_gpio_init((cyhal_gpio_t)which, CYHAL_GPIO_DIR_INPUT, CYHAL_GPIO_DRIVE_PULLUP, CYBSP_BTN_OFF);
|
||||
}
|
||||
|
||||
bool cybsp_btn_get_state(cybsp_btn_t which)
|
||||
{
|
||||
return cyhal_gpio_read((cyhal_gpio_t)which);
|
||||
}
|
||||
|
||||
void cybsp_btn_set_interrupt(cybsp_btn_t which, cyhal_gpio_event_t type, cyhal_gpio_event_callback_t callback, void *callback_arg)
|
||||
{
|
||||
cyhal_gpio_register_callback((cyhal_gpio_t)which, callback, callback_arg);
|
||||
cyhal_gpio_enable_event((cyhal_gpio_t)which, type, 7, 1);
|
||||
}
|
||||
|
||||
/* The sysclk deep sleep callback is recommended to be the last callback that
|
||||
* is executed before entry into deep sleep mode and the first one upon
|
||||
* exit the deep sleep mode.
|
||||
* Doing so minimizes the time spent on low power mode entry and exit.
|
||||
*/
|
||||
#ifndef CYBSP_SYSCLK_PM_CALLBACK_ORDER
|
||||
#define CYBSP_SYSCLK_PM_CALLBACK_ORDER (255u)
|
||||
#endif
|
||||
|
||||
cy_rslt_t cybsp_register_sysclk_pm_callback(void)
|
||||
{
|
||||
cy_rslt_t result = CY_RSLT_SUCCESS;
|
||||
static cy_stc_syspm_callback_params_t cybsp_sysclk_pm_callback_param = {NULL, NULL};
|
||||
static cy_stc_syspm_callback_t cybsp_sysclk_pm_callback = {
|
||||
.callback = &Cy_SysClk_DeepSleepCallback,
|
||||
.type = CY_SYSPM_DEEPSLEEP,
|
||||
.callbackParams = &cybsp_sysclk_pm_callback_param,
|
||||
.order = CYBSP_SYSCLK_PM_CALLBACK_ORDER
|
||||
};
|
||||
|
||||
if (!Cy_SysPm_RegisterCallback(&cybsp_sysclk_pm_callback))
|
||||
{
|
||||
result = CYBSP_RSLT_ERR_SYSCLK_PM_CALLBACK;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
|
@ -1,150 +0,0 @@
|
|||
/***************************************************************************//**
|
||||
* \file cybsp_core.h
|
||||
*
|
||||
* \brief
|
||||
* Basic abstraction layer for dealing with boards containing a Cypress MCU. This
|
||||
* API provides convenience methods for initializing and manipulating different
|
||||
* hardware found on the board.
|
||||
*
|
||||
********************************************************************************
|
||||
* \copyright
|
||||
* Copyright 2018-2019 Cypress Semiconductor Corporation
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*******************************************************************************/
|
||||
|
||||
/**
|
||||
* \addtogroup group_bsp_core Core
|
||||
* \{
|
||||
* Basic abstraction layer for dealing with boards containing a Cypress MCU. This
|
||||
* API provides convenience methods for initializing and manipulating different
|
||||
* hardware found on the board.
|
||||
*
|
||||
* \defgroup group_bsp_core_macros Macros
|
||||
* \defgroup group_bsp_core_functions Functions
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "cy_result.h"
|
||||
#include "cyhal_gpio.h"
|
||||
#include "cybsp_types.h"
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \addtogroup group_bsp_core_macros
|
||||
* \{
|
||||
*/
|
||||
|
||||
/** Failed to configure sysclk power management callback */
|
||||
#define CYBSP_RSLT_ERR_SYSCLK_PM_CALLBACK (CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_ABSTRACTION_BSP, 0))
|
||||
|
||||
/** \} group_bsp_core_macros */
|
||||
|
||||
/**
|
||||
* \addtogroup group_bsp_core_functions
|
||||
* \{
|
||||
*/
|
||||
|
||||
/**
|
||||
* \brief Initialize all hardware on the board
|
||||
* \returns CY_RSLT_SUCCESS if the board is sucessfully initialized, if there is
|
||||
* a problem initializing any hardware it returns an error code specific
|
||||
* to the hardware module that had a problem.
|
||||
*/
|
||||
cy_rslt_t cybsp_init(void);
|
||||
|
||||
/**
|
||||
* \brief Init and allocate the specified LED, setting the GPIO drive mode as necessary
|
||||
* \param which The specific LED number to enable, see BSP header file for available LEDs
|
||||
* \returns CY_RSLT_SUCCESS if the LED was enabled successfully
|
||||
*/
|
||||
cy_rslt_t cybsp_led_init(cybsp_led_t which);
|
||||
|
||||
/**
|
||||
* \brief Toggle the specified LED
|
||||
* \param which The specific LED number to enable, see BSP header file for available LEDs
|
||||
*/
|
||||
void cybsp_led_toggle(cybsp_led_t which);
|
||||
|
||||
/**
|
||||
* \brief Sets the state of the LED.
|
||||
* \param which The specific LED number to set state, see BSP header file for available LEDs
|
||||
* \param on Whether the LED should be turned on (true) or off (false)
|
||||
*/
|
||||
void cybsp_led_set_state(cybsp_led_t which, bool on);
|
||||
|
||||
/**
|
||||
* \brief Turns the LED on.
|
||||
* \param which The specific LED number to set state, see BSP header file for available LEDs
|
||||
* \returns CY_RSLT_SUCCESS if the LED was turned on
|
||||
*/
|
||||
static inline void cybsp_led_on(cybsp_led_t which)
|
||||
{
|
||||
cybsp_led_set_state(which, CYBSP_LED_STATE_ON);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Turns the LED off.
|
||||
* \param which The specific LED number to set state, see BSP header file for available LEDs
|
||||
* \returns CY_RSLT_SUCCESS if the LED was turned off
|
||||
*/
|
||||
static inline void cybsp_led_off(cybsp_led_t which)
|
||||
{
|
||||
cybsp_led_set_state(which, CYBSP_LED_STATE_OFF);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Init and allocate the specified button, setting the GPIO drive mode as necessary
|
||||
* \param which The specific button number to enable, see BSP header file for available buttones
|
||||
* \returns CY_RSLT_SUCCESS if the button was enabled successfully
|
||||
*/
|
||||
cy_rslt_t cybsp_btn_init(cybsp_btn_t which);
|
||||
|
||||
/**
|
||||
* \brief Sets the state of the button.
|
||||
* \param which The specific button number to get state from, see BSP header file for available buttones
|
||||
* \returns State of the button
|
||||
*/
|
||||
bool cybsp_btn_get_state(cybsp_btn_t which);
|
||||
|
||||
/**
|
||||
* \brief Sets the interrupt to trigger when the button state is changed.
|
||||
* \param which The specific button number to get state from, see BSP header file for available buttones
|
||||
* \param type The type sets level vs edge and active high vs active low
|
||||
* \param callback The function pointer to call when the button state changes. NULL to unregister.
|
||||
* \param callback_arg The optional argument to provide when the callback is executed. This can be NULL.
|
||||
*/
|
||||
void cybsp_btn_set_interrupt(cybsp_btn_t which, cyhal_gpio_event_t type, cyhal_gpio_event_callback_t callback, void *callback_arg);
|
||||
|
||||
/**
|
||||
* \brief Registers a power management callback that prepares the clock system
|
||||
* for entering deep sleep mode and restore the clocks upon wakeup from deep sleep.
|
||||
* NOTE: This is called automatically as part of \ref cybsp_init
|
||||
* \returns CY_RSLT_SUCCESS if the callback is sucessfully registered, if there is
|
||||
* a problem registering the callback it returns CYBSP_RSLT_ERR_SYSCLK_PM_CALLBACK.
|
||||
*/
|
||||
cy_rslt_t cybsp_register_sysclk_pm_callback(void);
|
||||
|
||||
/** \} group_bsp_core_functions */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/** \} group_bsp_core */
|
Loading…
Reference in New Issue