dRonin  adbada4
dRonin firmware
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
main.c File Reference
#include <pios.h>
#include <pios_board_info.h>
#include <stdbool.h>
#include "pios_iap.h"
#include "pios_com_msg.h"
#include "pios_usbhook.h"
#include "pios_bl_helper.h"
#include "led_pwm.h"
#include "bl_messages.h"
#include "bl_xfer.h"

Go to the source code of this file.

Data Structures

struct  bl_fsm_context
 
struct  bl_transition
 

Macros

#define MSEC_TO_USEC(ms)   ((ms) * 1000)
 
#define SEC_TO_MSEC(s)   ((s) * 1000)
 
#define SEC_TO_USEC(s)   ((s) * 1000 * 1000)
 
#define BL_DETECT_BREAK_TO_BL_TIMER_WITH_VSENSE   MSEC_TO_USEC(2)
 
#define BL_DETECT_BREAK_TO_BL_TIMER_NO_VSENSE   MSEC_TO_USEC(500)
 
#define BL_WAIT_FOR_DFU_TIMER   SEC_TO_USEC(6)
 
#define BL_RECOVER_FROM_FAULT_TIMER   SEC_TO_USEC(10)
 

Enumerations

enum  bl_states {
  BL_STATE_FSM_FAULT = 0, BL_STATE_INIT, BL_STATE_DETECT_BREAK_TO_BL, BL_STATE_WAIT_FOR_DFU,
  BL_STATE_JUMPING_TO_APP, BL_STATE_JUMP_FAILED, BL_STATE_DFU_OPERATION_FAILED, BL_STATE_DFU_OPERATION_OK,
  BL_STATE_DFU_IDLE, BL_STATE_DFU_READ_IN_PROGRESS, BL_STATE_DFU_WRITE_IN_PROGRESS, BL_STATE_NUM_STATES
}
 
enum  legacy_dfu_states {
  DFU_IDLE = 0, DFU_WRITING, DFU_WRONG_PACKET_RX, DFU_TOO_MANY_PACKETS,
  DFU_TOO_FEW_PACKETS, DFU_LAST_OP_SUCCESS, DFU_READING, DFU_BL_IDLE,
  DFU_LAST_OP_FAILED, DFU_WRITE_START, DFU_OUTSIDE_DEV_CAP, DFU_CRC_FAIL,
  DFU_FAILED_JUMP
}
 
enum  bl_events {
  BL_EVENT_ENTER_DFU, BL_EVENT_USB_CONNECTED, BL_EVENT_USB_DISCONNECTED, BL_EVENT_JUMP_TO_APP,
  BL_EVENT_TIMER_EXPIRY, BL_EVENT_READ_START, BL_EVENT_WRITE_START, BL_EVENT_ABORT_OPERATION,
  BL_EVENT_TRANSFER_DONE, BL_EVENT_TRANSFER_ERROR, BL_EVENT_AUTO, BL_EVENT_FORCE_BOOT,
  BL_EVENT_NUM_EVENTS
}
 

Functions

void PIOS_Board_Init (void)
 
static void go_fsm_fault (struct bl_fsm_context *context)
 
static void go_detect_break_to_bl (struct bl_fsm_context *context)
 
static void go_wait_for_dfu (struct bl_fsm_context *context)
 
static void go_jumping_to_app (struct bl_fsm_context *context)
 
static void go_dfu_idle (struct bl_fsm_context *context)
 
static void go_read_in_progress (struct bl_fsm_context *context)
 
static void go_write_in_progress (struct bl_fsm_context *context)
 
static void go_dfu_operation_ok (struct bl_fsm_context *context)
 
static void go_dfu_operation_failed (struct bl_fsm_context *context)
 
static enum bl_states bl_fsm_get_state (struct bl_fsm_context *context)
 
static void bl_fsm_timer_start (struct bl_fsm_context *context, uint32_t timer_duration_us)
 
static void bl_fsm_timer_cancel (struct bl_fsm_context *context)
 
static void bl_fsm_timer_add_ticks (struct bl_fsm_context *context, uint32_t elapsed_us)
 
static bool bl_fsm_timer_expired_p (struct bl_fsm_context *context)
 
static void bl_fsm_process_auto (struct bl_fsm_context *context)
 
static void bl_fsm_inject_event (struct bl_fsm_context *context, enum bl_events event)
 
static void bl_fsm_init (struct bl_fsm_context *context)
 
static void process_packet_rx (struct bl_fsm_context *context, const struct bl_messages *msg)
 
int main (void)
 
static bool bl_select_dfu_device (struct bl_fsm_context *context, uint8_t device_number)
 
static bool bl_send_status (struct bl_fsm_context *context)
 
static bool bl_send_capabilities (struct bl_fsm_context *context, uint8_t device_number)
 

Variables

static const uint8_t fsm_to_dfu_state_map []
 
bool have_vsense
 
static const struct bl_transition bl_transitions [BL_STATE_NUM_STATES]
 

Detailed Description

Author
Tau Labs, http://taulabs.org, Copyright (C) 2014

Definition in file main.c.