CY8CKIT-062-WIFI-BT BSP
ModusToolboxTM BSP User Guide

Introduction

A Board Support Package (BSP) provides a standard interface to a board's features and capabilities. The API is consistent across Cypress kits. Other software (such as middleware or the user's application) can use the BSP to configure and control the hardware. BSPs have the following characteristics:

  • BSPs initialize device resources, such as clocks and power supplies to set up the device to run firmware.
  • BSPs contain linker scripts and startup code so you can customize them for your board.
  • BSPs contain the hardware configuration (structures and macros) for both device peripherals and board peripherals.
  • BSPs provide abstraction to the board by providing common aliases or names to refer to the board peripherals, such as buttons and LEDs.
  • BSPs include the libraries for the default capabilities on the board. For example, the BSP for a kit with CapSense capabilities includes the CapSense library.

Definition of Terms

  • Board Peripheral: On-board peripherals such as QSPI flash, Thermistor, LEDs, Buttons, etc.
  • COMPONENTS: This is a make variable that allows bringing external libraries into the ModusToolbox build system. For example, to include a NEW_FEATURE component, add the following line to the .mk file, and place the source files inside a folder COMPONENT_NEW_FEATURE.
    COMPONENTS+=NEW_FEATURE
    You can add multiple components using a space as a separator. See Running ModusToolbox from the Command Line for details.
  • Device: The MCU or the Wi-Fi/BT chip on the board.
  • Device Configurator: The GUI-based tool available in ModusToolbox to simplify configuring device resources and peripherals. You can access this tool under: < INSTALL DIRECTORY >/ModusToolbox/tools_x.y/device-configurator
  • Device Peripheral: On-chip peripherals such as UART, I2C, CSD, etc.
  • Device Resource: On-chip resources such as clocks and power supply system.
  • ModusToolbox: A collection of software libraries, tools, an IDE, and a make-based build infrastructure for application development with Cypress devices.
  • ModusToolbox IDE: An Eclipse-based IDE for application development with Cypress devices.

Quick Start with BSPs

This section provides a high-level view for using BSPs. You should be familiar with creating an application using both the ModusToolbox 2.0 IDE and command-line environments. To use a BSP for a Cypress kit you need to perform the following steps:

  1. Get a BSP using one of the following methods:
    • Create an application using the ModusToolbox 2.0 IDE New Application wizard. The wizard fetches the BSP for the kit that you selected, and places it in the libs directory.
    • Create an application with the stand-alone Project Creation tool included with the ModusToolbox software installer (< ModusToolbox install>/tools_2.0/project-creator). The tool fetches the BSP for the kit that you selected, and places it in the libs directory.
    • Use the Library Manager tool to fetch the required BSP. This tool is located in < ModusToolbox install >/tools_2.0/library-manager. You can also launch it from within the ModusToolbox IDE.
    • Clone the Cypress BSP GitHub repository using the git clone command. For example: git clone [https://github.com/cypresssemiconductorco/TARGET_CY8CPROTO-062-4343W/#latest-v1.X]
      A BSP includes other libraries. To fetch all the libraries, use the make getlibs command from a command shell in the top directory of the application.
  2. Add #include "cybsp.h" to your main.c file.
  3. Add cybsp_init () at the start of main().
  4. Refer to the API documentation available inside that BSP docs directory to learn more.

Contents of a BSP

This section presents a quick overview of the key resources that are part of a BSP. The contents may vary for different environments. The following shows a typical BSP in a PSoC 6 development scenario.

bsp_contents.png
Makefile (*. mk )

Defines the DEVICE and other BSP-specific make variables such as COMPONENTS.

cybsp.c /.h & cybsp_types.h

These files contain the API interface to the board's resources.

You need to include only cybsp.h in your application to use all the features of a BSP. Call cybsp_init () from cybsp. to initialize the board.

The cybsp_types.h file contains the aliases (macro definitions) for all the board resources.

linker

Linker scripts for all supported toolchains: GCC ARM, IAR, and ARM.

startup

Contains the startup code with the reset handler for the target device, written in assembly language for all supported toolchains: GCC ARM, IAR, and ARM.

COMPONENT_BSP_DESIGN_MODUS

This folder contains the configuration files (such as design.modus) for use with various BSP configurator tools, including Device Configurator, QSPI Configurator, and CapSense Configurator. At the start of a build, the build system invokes these tools to generate the source files in the GeneratedSource directory. See Overriding the design.modus Provided by BSP to learn how the application can override this component.

libs

This folder contains the .lib files that specify the required libraries for the underlying device family. You can use the make getlibs command to fetch these libraries. The IDE's New Application wizard, or the stand-alone Project Creator tool, invoke make getlibs automatically.

docs

The docs directory contains the HTML based documentation. The README.md file serves as the GitHub repository documentation.

BSP Organization in Different Environments

BSPs are packaged or organized differently depending on different IoT environment's rules.

Mbed OS

In Mbed OS, BSPs are referred to as targets. All Cypress targets are located in the mbed-os/targets/TARGET_CYPRESS/TARGET_PSOC6 directory along with other libraries such as WHD, PDL driver, HAL, etc.

bsp_mbed-os.png

A BSP or target is placed inside the TARGET_(board-name) directory. For example, the directory TARGET_CY8CKIT_062_WIFI_BT packages the BSP for the CY8CKIT-062-WIFI-BT kit. Explaining the complete file structure is outside the scope of this document. See Cypress Firmware Deliverables in Mbed OS KBA228252 to learn more.

Amazon FreeRTOS

In Amazon FreeRTOS, the BSP is spread out in the /vendors/cypress directory.

bsp_afr.png

Board Initialization

The cycfg.c file generated by the Device Configurator contains a routine init_cycfg_all(). This function calls several other routines that initialize the device with the configuration defined through the Device Configurator.

The cybsp_init() function in the cybsp.c file does not call init_cycfg_all(). It calls the init_cycfg_system() function to initialize the device resources such as clocks and power supplies. You can call the other routines (for example, init_cycfg_routing()) in main() if required.

Note that you need to call init_cycfg_routing() when you use analog resources such as CapSense and SAR ADC. See the corresponding code examples at the Cypress GitHub webpage for details.

Overriding the BSP design.modus File

The BSP sets up a default board configuration in the design.modus file.

When you create an application that uses a BSP, the design.modus file is copied from the original BSP repository and put into your application. You can open the local copy of the file with the Device Configurator and modify the configuration. However, if you recreate the application, you get a new copy of the original design.modus file and your changes are lost.

Rather than make local changes, if necessary, you can override the BSP_DESIGN_MODUS component with a different configuration. Cypress code examples often override this component to use a different configuration than the one provided by a BSP. To do this, follow these steps:

  1. Add the following line to the Makefile in the application directory.
    DISABLE_COMPONENTS+=BSP_DESIGN_MODUS
  2. Create a directory for each target that you want to support at the top-level directory in your application. The directory name must be TARGET_(board_name). For example, TARGET_CY8CPROTO-062-4343W.
    Remember that the build system automatically includes all the source files inside a directory that begins with TARGET_ followed by the target name for compilation when that target is specified in the application make file. The file structure appears as follows. Here, the BSP_DESIGN_MODUS component is overridden for the targets CY8CPROTO-062-4343W and CY8CKIT-062-WIFI-BT.

    bsp_override1.png
  3. Copy the design.modus file and other configuration files inside this new directory and customize as required. When you save the changes in the design.modus file, the source files are generated and placed under the GeneratedSource directory. The file structure appears as follows.

    bsp_override2.png

Creating a BSP for Your Board

Cypress provides BSPs for its boards. When you design your own board, it is likely to have a different MCU, board peripherals, and other hardware features. You can create a custom BSP for your board to simplify interacting with your board's features.

  1. In a project space, make a copy of the closest-matching BSP. This is the easiest way to create a new BSP. This can be done in an existing project space or by creating a new one for the closest matching target.
  2. Rename the BSP directory to match your board. The name must begin with TARGET_ followed by the name that you want to call your board with. For example, TARGET_MYBOARDNAME.
  3. Rename the .mk file to match the board name. For example, MYBOARDNAME.mk.
  4. Update the DEVICE variable in the .mk file with the correct part number of the device/MCU if it is different than the BSP that you started from.
  5. Update the linker script and startup code if required. Any file specific to a toolchain (for example, linker script) must be placed inside the directory that begins with TOOLCHAIN_ followed by the toolchain name. For example, TOOLCHAIN_GCC_ARM. As a starting point, use the linker script and startup code from a BSP with the same DEVICE.
  6. If you changed DEVICE:

    a. In your BSP’s COMPONENT_BSP_DESIGN_MODUS directory, delete the entire GeneratedSource directory.

    b. Using the command line in your project space, run make build TARGET=MYBOARDNAME. The build system will automatically update the DEVICE in the design.modus file, build the generated source, and attempt to build the project for the new target.

    c. The BSP used as your starting point may have source that is not needed by your custom BSP. In particular if you encounter issues with SDIO_HOST or SDIO_HOST_cfg source files, delete these.

  7. Define or update the alias for pins in the cybsp_types.h file.
  8. Customize the design.modus file and other configuration files with new settings for clocks, power supplies, and peripherals as required.
  9. Update the cybsp_init() function in the cybsp.c file to correctly initialize your board.
  10. Update the comment blocks in the cybsp.h file with any custom configuration used by your board and update the content of README.md file to match your board.