Custom Board Support Package (BSP) Tutorial: Step 3

Step 3.1: Create a Board Support Package (BSP) Folder

1

Make a copy of any folder in the<harmony installation path/bsp directory and rename the folder as "pic32mz_ef_custom".

2

You should have a folder structure similar to the one shown below:

bsp_folder_structure.png

3

For your new BSP you need to modify the content of the files shown in the previous step.

Step 3.2: Modify the Files in the BSP Folder

The script in the.hconfig files is sensitive to whitespace. Ensure that there are no extra spaces or tabs in the script you add or modify.

1

Modify thebsp/pic32mz_ef_custom/config/pic32mz_ef_custom.help file as shown below.

HelpforPIC32MZ_EF_CUSTOM

2

Modify thebsp/pic32mz_ef_custom/config/pic32mz_ef_custom.mhc file as shown below.

# DefaultBSPconfiguration#     Harmonyversion:2.0#CONFIG_USE_BSP=yCONFIG_BSP_PIC32MZ_EF_CUSTOM=y

3

Modify thebsp/pic32mz_ef_custom/config/pic32mz_ef_custom.name file as shown below.

DefaultConfigurationforPIC32MZ(EF)CustomDevelopmentBoard.

4

Replace the contents of thebsp/pic32mz_ef_custom/templates/bsp.c.ftl file, with the script below.

<#include"/bsp/templates/bsp_freemarker_functions.ftl">/*******************************************************************************  Board Support Package Implementation   Company:    Microchip Technology Inc.   File Name:    bsp.c   Summary:    Board Support Package implementation for PIC32MZ EF Curiosity Development    Board.   Description:    This file contains routines that implement the board support package for    PIC32MZ EF Curiosity Development Board.*******************************************************************************/// DOM-IGNORE-BEGIN/*******************************************************************************Copyright (c) 2016 released Microchip Technology Inc.  All rights reserved. Microchip licenses to you the right to use, modify, copy and distributeSoftware only when embedded on a Microchip microcontroller or digital signalcontroller that is integrated into your product or third party product(pursuant to the sublicense terms in the accompanying license agreement). You should refer to the license agreement accompanying this Software foradditional information regarding your rights and obligations. SOFTWARE AND DOCUMENTATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND,EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OFMERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDERCONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OROTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSESINCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE ORCONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OFSUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.*******************************************************************************/// DOM-IGNORE-END// *****************************************************************************// *****************************************************************************// Section: Included Files// *****************************************************************************// *****************************************************************************#include"bsp.h" <#if(Switch_Name_List?size >0)><#include"/bsp/templates/bsp_switches.c.ftl"></#if><#if(LED_Name_List?size >0)><#include"/bsp/templates/bsp_leds.c.ftl"></#if><#if(VBUS_PortPin_List?size >0)><#include"/bsp/templates/bsp_vbus.c.ftl"></#if>// *****************************************************************************// *****************************************************************************// *****************************************************************************// Section: Interface Routines// *****************************************************************************// *****************************************************************************// *****************************************************************************/* Function:    void BSP_Initialize(void)   Summary:    Performs the necessary actions to initialize a board   Description:    This function initializes the LED, Switch and other ports on the board.    This function must be called by the user before using any APIs present in    this BSP.   Remarks:    Refer to bsp.h for usage information.*/voidBSP_Initialize(void){<#if(VBUS_PortPin_List?size >0)>/* Setup the USB VBUS Switch Control Pin */BSP_USBVBUSSwitchStateSet(BSP_USB_VBUS_SWITCH_STATE_DISABLE);</#if> <#if(LED_Name_List?size >0)>/* Switch off LEDs */<#listLED_Name_Listasled>BSP_LEDOff(${led});</#list></#if>}/******************************************************************************* End of File*/

5

Replace the contents of thebsp/pic32mz_ef_custom/templates/bsp.h.ftl file, with the script below.

<#include"/bsp/templates/bsp_freemarker_functions.ftl">/*******************************************************************************  Board Support Package Header File.   Company:          Microchip Technology Inc.   File Name:        bsp.h   Summary:          Board Support Package Header File for PIC32MZ EF Curiosity Development Board.   Description:    This file contains constants, macros, type definitions and function    declarations required by the PIC32MZ EF Curiosity Development Board.*******************************************************************************/// DOM-IGNORE-BEGIN/*******************************************************************************Copyright (c) 2016 released Microchip Technology Inc.  All rights reserved. Microchip licenses to you the right to use, modify, copy and distributeSoftware only when embedded on a Microchip microcontroller or digital signalcontroller that is integrated into your product or third party product(pursuant to the sublicense terms in the accompanying license agreement). You should refer to the license agreement accompanying this Software foradditional information regarding your rights and obligations. SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OFMERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDERCONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OROTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSESINCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE ORCONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OFSUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.*******************************************************************************/// DOM-IGNORE-END#ifndef_BSP_H#define_BSP_H// *****************************************************************************// *****************************************************************************// Section: Included Files// *****************************************************************************// *****************************************************************************#include<xc.h>#include<stdio.h>#include<stdlib.h>#include<stdint.h>#include<stdbool.h>#include"peripheral/ports/plib_ports.h" <#if(Switch_Name_List?size >0)><#include"/bsp/templates/bsp_switches.h.ftl"></#if><#if(LED_Name_List?size >0)><#include"/bsp/templates/bsp_leds.h.ftl"></#if><#if(VBUS_PortPin_List?size >0)><#include"/bsp/templates/bsp_vbus.h.ftl"></#if>// *****************************************************************************// *****************************************************************************// Section: Constants and Type Definitions.// *****************************************************************************// *****************************************************************************// *****************************************************************************// *****************************************************************************// Section: Interface Routines// *****************************************************************************// *****************************************************************************// *****************************************************************************/* Function:     void BSP_Initialize(void)   Summary:    Performs the necessary actions to initialize a board   Description:    This function initializes the LED and Switch ports on the board.  This    function must be called by the user before using any APIs present on this    BSP.     Precondition:    None.   Parameters:    None   Returns:    None.   Example:    <code>    //Initialize the BSP    BSP_Initialize();    </code>   Remarks:    None                                                                   */voidBSP_Initialize(void);#endif// _BSP_H/******************************************************************************* End of File*/



Next Step >