PRELIMIN ARY
CYW920706WCDEVAL Hardware User Guide Doc. No.: 002-16535 Rev. **
36
10 Interface Programming Information and Examples
Note:
All code and code references in this section pertain to WICED Studio. Source C files may be found under the
appropriate application folder in the Project Explorer window under 20706-A2_Bluetooth\apps, and header H files which
contain definitions for the #define’s used in the example code may be found under 20706-A2_Bluetooth\include. See [
detailed information on using WICED Studio to build and run the sample applications mentioned in the subsections below,
including viewing application trace message output generated from WICED_BT_TRACE().statements shown in the example
code.
Consider the following information after physically assigning GPIO_Pxx to digital I/O pins:
When CYW20706 is in the Low Power or Deep Sleep modes, no data can be received from any of its interfaces (SPI,
PUART, etc.). To wake CYW20706, use a GPIO_Pxx configured as an interrupt. Refer to
wiced_hal_gpio.h
and
gpiodriver.h
for the pertinent API functions and constants. See
Appendix A “Power-Save Options
” for more information
about the sleep modes and power-save options.
To access GPIO driver services invoke the
wiced_hal_gpio_init
function during application initialization. This is
independent of other functions and must be called before any other GPIO functions.
For a sample application that pertains to GPIO API function usage refer to the
hal_gpio_app.c
file in WICED Studio.
For information on the API functions that support SPI1 configuration, control, and data exchange, refer to
wiced_hal_pspi.h
. To generate chip-select (CS) signals to attached slaves, refer to
wiced_hal_gpio.h
.
For information on the API functions that pertain to PUART access, refer to
wiced_hal_puart.h
.
The remaining paragraphs in this section provide the following programming examples:
SPI1 Master Programming Example
SPI1 Slave Programming Example
10.1 GPIO Programming Example
The example in this section demonstrates some aspects of GPIO programming, including GPIO driver initialization, configuring
GPIOs for input and output, and registering interrupt handlers. Refer to
wiced_hal_gpio.h
for the complete set of API functions
that support GPIO programming. See the
hal_gpio_app
sample application in WICED Studio under
20706-
A2_Bluetooth\apps\snip\hal_gpio
for a complete working program using these APIs.
To initialize the GPIO driver, invoke the
wiced_hal_gpio_init
function. The GPIO driver should be one of the first to be
initialized.
The following example code is similar to the code found in
hal_gpio_app.c
.
APPLICATION_START( )
{
wiced_set_debug_uart( WICED_ROUTE_DEBUG_TO_PUART);
wiced_hal_puart_select_uart_pads( WICED_PUART_RXD, WICED_PUART_TXD, 0, 0);
WICED_BT_TRACE( "GPIO application start\n\r" );
wiced_bt_stack_init( sample_gpio_app_management_cback,NULL,NULL);
}
wiced_result_t sample_gpio_app_management_cback( wiced_bt_management_evt_t event,
wiced_bt_management_evt_data_t *p_event_data)
{
wiced_result_t result = WICED_SUCCESS;