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 the bsp/pic32mz_ef_custom/config/pic32mz_ef_custom.help file as shown below.

Help for PIC32MZ_EF_CUSTOM

2

Modify the bsp/pic32mz_ef_custom/config/pic32mz_ef_custom.mhc file as shown below.

# Default BSP configuration
#     Harmony version: 2.0
#
CONFIG_USE_BSP=y
CONFIG_BSP_PIC32MZ_EF_CUSTOM=y

3

Modify the bsp/pic32mz_ef_custom/config/pic32mz_ef_custom.name file as shown below.

Default Configuration for PIC32MZ (EF) Custom Development Board.

4

Replace the contents of the bsp/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 distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller 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 for
additional 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 OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE 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.
*/
 
void BSP_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 */
<#list LED_Name_List as led>
    BSP_LEDOff(${led});
</#list>
</#if>
}
 
/*******************************************************************************
 End of File
*/

5

Replace the contents of the bsp/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 distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller 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 for
additional 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 OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE 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                                                                   
*/
 
void BSP_Initialize(void);
 
#endif // _BSP_H
 
/*******************************************************************************
 End of File
*/



Next Step >

© 2024 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.