nRF51 SDK
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
main.c

Bootloader project main file. More...

Macros

#define BOOTLOADER_BUTTON_PIN   BUTTON7
 
#define APP_GPIOTE_MAX_USERS   2
 
#define APP_TIMER_PRESCALER   0
 
#define APP_TIMER_MAX_TIMERS   3
 
#define APP_TIMER_OP_QUEUE_SIZE   4
 
#define BUTTON_DETECTION_DELAY   APP_TIMER_TICKS(50, APP_TIMER_PRESCALER)
 

Functions

void app_error_handler (uint32_t error_code, uint32_t line_num, const uint8_t *p_file_name)
 Function for error handling, which is called when an error has occurred. More...
 
void assert_nrf_callback (uint16_t line_num, const uint8_t *p_file_name)
 Callback function for asserts in the SoftDevice. More...
 
static void leds_init (void)
 Function for initialization of LEDs. More...
 
static void leds_off (void)
 Function for clearing the LEDs. More...
 
static void gpiote_init (void)
 Function for initializing the GPIOTE handler module.
 
static void timers_init (void)
 Function for the Timer initialization. More...
 
static void buttons_init (void)
 Function for initializing the button module.
 
int main (void)
 Function for application main entry.
 

Detailed Description

  1. Receive start data package.
  2. Based on start packet, prepare NVM area to store received data.
  3. Receive data packet.
  4. Validate data packet.
  5. Write Data packet to NVM.
  6. If not finished - Wait for next packet.
  7. Receive stop data packet.
  8. Activate Image, boot application.

Macro Definition Documentation

#define BOOTLOADER_BUTTON_PIN   BUTTON7

Button used to enter SW update mode.

#define APP_GPIOTE_MAX_USERS   2

Number of GPIOTE users in total. Used by button module and dfu_transport_serial module (flow control).

#define APP_TIMER_PRESCALER   0

Value of the RTC1 PRESCALER register.

#define APP_TIMER_MAX_TIMERS   3

Maximum number of simultaneously created timers.

#define APP_TIMER_OP_QUEUE_SIZE   4

Size of timer operation queues.

#define BUTTON_DETECTION_DELAY   APP_TIMER_TICKS(50, APP_TIMER_PRESCALER)

Delay from a GPIOTE event until a button is reported as pushed (in number of timer ticks).

Function Documentation

void app_error_handler ( uint32_t  error_code,
uint32_t  line_num,
const uint8_t *  p_file_name 
)
Warning
This handler is an example only and does not fit a final product. You need to analyze how your product is supposed to react in case of error.
Parameters
[in]error_codeError code supplied to the handler.
[in]line_numLine number where the handler is called.
[in]p_file_namePointer to the file name.
void assert_nrf_callback ( uint16_t  line_num,
const uint8_t *  p_file_name 
)

This function will be called in case of an assert in the SoftDevice.

Warning
This handler is an example only and does not fit a final product. You need to analyze how your product is supposed to react in case of Assert.
On assert from the SoftDevice, the system can only recover on reset.
Parameters
[in]line_numLine number of the failing ASSERT call.
[in]file_nameFile name of the failing ASSERT call.
static void leds_init ( void  )
static

Initializes all LEDs used by the application.

static void leds_off ( void  )
static

Clears all LEDs used by the application.

static void timers_init ( void  )
static

Initializes the timer module.