Microchip® Advanced Software Framework

main.c File Reference

SAM SAM-BA Bootloader.

Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries.

#include "asf.h"
#include <stdio.h>
#include <stdlib.h>
#include <io.h>
#include <string.h>
#include "conf_board.h"
#include "conf_clocks.h"
#include "conf_bootloader.h"
#include "sam_ba_monitor.h"
#include "usart_sam_ba.h"

Macros

#define DEBUG_PIN_HIGH   do{}while(0)
 
#define DEBUG_PIN_LOW   do{}while(0)
 

Functions

static void check_start_application (void)
 Check the application startup condition. More...
 
int main (void)
 SAM-BA Main loop. More...
 
void main_cdc_disable (uint8_t port)
 Closes the communication port This is called by CDC interface when USB Host disable it. More...
 
bool main_cdc_enable (uint8_t port)
 Opens the communication port This is called by CDC interface when USB Host enable it. More...
 
void main_cdc_rx_notify (uint8_t port)
 Called by CDC interface Callback running when CDC device have received data. More...
 
void main_cdc_set_coding (uint8_t port, usb_cdc_line_coding_t *cfg)
 Configures communication line. More...
 
void main_cdc_set_dtr (uint8_t port, bool b_enable)
 Save new DTR state to change led behavior. The DTR notify that the terminal have open or close the communication port. More...
 
void main_remotewakeup_lpm_disable (void)
 Called by UDC when USB Host request to disable LPM remote wakeup. More...
 
void main_remotewakeup_lpm_enable (void)
 Called by UDC when USB Host request to enable LPM remote wakeup. More...
 
void main_suspend_lpm_action (void)
 Enters the application in low power mode Callback called when USB host sets LPM suspend state. More...
 

Variables

static volatile bool main_b_cdc_enable = false
 

#define DEBUG_PIN_HIGH   do{}while(0)

Referenced by main().

#define DEBUG_PIN_LOW   do{}while(0)

Referenced by main().

static void check_start_application ( void  )
static

Check the application startup condition.

Test reset vector of application +4 Stay in SAM-BA if *(APP_START+0x4) == 0xFFFFFFFF Application erased condition

References APP_START_ADDRESS, BOOT_LOAD_PIN, and GPIO_BOOT_PIN_MASK.

Referenced by main().

void main_cdc_disable ( uint8_t  port)

Closes the communication port This is called by CDC interface when USB Host disable it.

References main_b_cdc_enable.

bool main_cdc_enable ( uint8_t  port)

Opens the communication port This is called by CDC interface when USB Host enable it.

Return values
trueif cdc startup is successfully done

References main_b_cdc_enable.

void main_cdc_rx_notify ( uint8_t  port)

Called by CDC interface Callback running when CDC device have received data.

void main_cdc_set_coding ( uint8_t  port,
usb_cdc_line_coding_t cfg 
)

Configures communication line.

Parameters
cfgline configuration
void main_cdc_set_dtr ( uint8_t  port,
bool  b_enable 
)

Save new DTR state to change led behavior. The DTR notify that the terminal have open or close the communication port.

void main_remotewakeup_lpm_disable ( void  )

Called by UDC when USB Host request to disable LPM remote wakeup.

void main_remotewakeup_lpm_enable ( void  )

Called by UDC when USB Host request to enable LPM remote wakeup.

void main_suspend_lpm_action ( void  )

Enters the application in low power mode Callback called when USB host sets LPM suspend state.

volatile bool main_b_cdc_enable = false
static