diff --git a/flight/Bootloaders/OSD/Makefile b/flight/Bootloaders/OSD/Makefile index b058a4c2c..00db70a45 100644 --- a/flight/Bootloaders/OSD/Makefile +++ b/flight/Bootloaders/OSD/Makefile @@ -46,11 +46,9 @@ else REMOVE_CMD = rm endif -FLASH_TOOL = OPENOCD - # Paths -REVO_BL = ./ -REVO_BLINC = $(REVO_BL)/inc +OSD_BL = $(WHEREAMI) +OSD_BLINC = $(OSD_BL)/inc PIOS = ../../PiOS PIOSINC = $(PIOS)/inc FLIGHTLIB = ../../Libraries @@ -64,16 +62,8 @@ STMLIBDIR = $(APPLIBDIR) STMSPDDIR = $(STMLIBDIR)/STM32F4xx_StdPeriph_Driver STMSPDSRCDIR = $(STMSPDDIR)/src STMSPDINCDIR = $(STMSPDDIR)/inc -OPDIR = ../OpenPilot -OPUAVOBJ = ../UAVObjects -OPUAVOBJINC = $(OPUAVOBJ)/inc -OPSYSINC = $(OPDIR)/System/inc -BOOT = ../Bootloaders/Revolution -BOOTINC = $(BOOT)/inc HWDEFSINC = ../../board_hw_defs/$(BOARD_NAME) -OPUAVSYNTHDIR = $(OUTDIR)/../uavobject-synthetics/flight - # List C source files here. (C dependencies are automatically generated.) # use file-extension c for "c-only"-files @@ -81,16 +71,12 @@ OPUAVSYNTHDIR = $(OUTDIR)/../uavobject-synthetics/flight SRC += main.c SRC += pios_board.c SRC += pios_usb_board_data.c -SRC += bl_fsm.c +SRC += op_dfu.c ## PIOS Hardware (STM32F4xx) include $(PIOS)/STM32F4xx/library.mk -## Library files -SRC += $(FLIGHTLIB)/fifo_buffer.c - # PIOS Hardware (Common) -#SRC += $(PIOSCOMMON)/pios_com.c SRC += $(PIOSCOMMON)/pios_board_info.c SRC += $(PIOSCOMMON)/pios_com_msg.c SRC += $(PIOSCOMMON)/printf-stdarg.c @@ -120,8 +106,7 @@ EXTRAINCDIRS += $(PIOSCOMMON) EXTRAINCDIRS += $(PIOSBOARDS) EXTRAINCDIRS += $(STMSPDINCDIR) EXTRAINCDIRS += $(CMSISDIR) -EXTRAINCDIRS += $(REVO_BLINC) -EXTRAINCDIRS += $(BOOTINC) +EXTRAINCDIRS += $(OSD_BLINC) EXTRAINCDIRS += $(HWDEFSINC) # List any extra directories to look for library files here. @@ -163,7 +148,9 @@ DEBUGF = dwarf-2 # Place project-specific -D (define) and/or # -U options for C here. -CDEFS = -DSTM32F10X_$(MODEL) +CDEFS = -DSTM32F4XX +CDEFS += -DSYSCLK_FREQ=$(SYSCLK_FREQ) +CDEFS += -DHSE_VALUE=$(OSCILLATOR_FREQ) CDEFS += -DUSE_STDPERIPH_DRIVER CDEFS += -DUSE_$(BOARD) @@ -328,7 +315,7 @@ $(OUTDIR)/$(TARGET).bin.o: $(OUTDIR)/$(TARGET).bin $(eval $(call OPFW_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(BOARD_TYPE),$(BOARD_REVISION))) # Add jtag targets (program and wipe) -$(eval $(call JTAG_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(BL_BANK_BASE),$(BL_BANK_SIZE),$(OPENOCD_CONFIG))) +$(eval $(call JTAG_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(BL_BANK_BASE),$(BL_BANK_SIZE),$(OPENOCD_JTAG_CONFIG),$(OPENOCD_CONFIG))) .PHONY: elf lss sym hex bin bino elf: $(OUTDIR)/$(TARGET).elf diff --git a/flight/Bootloaders/OSD/bl_fsm.c b/flight/Bootloaders/OSD/bl_fsm.c deleted file mode 100644 index 10e26a46e..000000000 --- a/flight/Bootloaders/OSD/bl_fsm.c +++ /dev/null @@ -1,591 +0,0 @@ -#include /* uint*_t */ -#include /* NULL */ - -#include "bl_fsm.h" - -#include "pios_opahrs_proto.h" - -#include "pios.h" - -struct lfsm_context { - enum lfsm_state curr_state; - enum opahrs_msg_link_state link_state; - enum opahrs_msg_type user_payload_type; - uint32_t user_payload_len; - - uint32_t errors; - - uint8_t * rx; - uint8_t * tx; - - uint8_t * link_rx; - uint8_t * link_tx; - - uint8_t * user_rx; - uint8_t * user_tx; - - struct lfsm_link_stats stats; -}; - -static struct lfsm_context context = { 0 }; - -static void lfsm_update_link_tx(struct lfsm_context * context); -static void lfsm_init_rx(struct lfsm_context * context); - -static uint32_t PIOS_SPI_OP; -void lfsm_attach(uint32_t spi_id) { - PIOS_SPI_OP = spi_id; -} - -/* - * - * Link Finite State Machine - * - */ - -struct lfsm_transition { - void (*entry_fn)(struct lfsm_context * context); - enum lfsm_state next_state[LFSM_EVENT_NUM_EVENTS]; -}; - -static void go_faulted(struct lfsm_context * context); -static void go_stopped(struct lfsm_context * context); -static void go_stopping(struct lfsm_context * context); -static void go_inactive(struct lfsm_context * context); -static void go_user_busy(struct lfsm_context * context); -static void go_user_busy_rx_pending(struct lfsm_context * context); -static void go_user_busy_tx_pending(struct lfsm_context * context); -static void go_user_busy_rxtx_pending(struct lfsm_context * context); -static void go_user_rx_pending(struct lfsm_context * context); -static void go_user_tx_pending(struct lfsm_context * context); -static void go_user_rxtx_pending(struct lfsm_context * context); -static void go_user_rx_active(struct lfsm_context * context); -static void go_user_tx_active(struct lfsm_context * context); -static void go_user_rxtx_active(struct lfsm_context * context); - -const static struct lfsm_transition lfsm_transitions[LFSM_STATE_NUM_STATES] = { - [LFSM_STATE_FAULTED] = { - .entry_fn = go_faulted, - }, [LFSM_STATE_STOPPED] = { - .entry_fn = go_stopped, - .next_state = { - [LFSM_EVENT_INIT_LINK] = LFSM_STATE_INACTIVE, - [LFSM_EVENT_RX_UNKNOWN] = LFSM_STATE_STOPPED, - }, - }, [LFSM_STATE_STOPPING] = { - .entry_fn = go_stopping, - .next_state = { - [LFSM_EVENT_RX_LINK] = LFSM_STATE_STOPPED, - [LFSM_EVENT_RX_USER] = LFSM_STATE_STOPPED, - [LFSM_EVENT_RX_UNKNOWN] = LFSM_STATE_STOPPED, - }, - }, [LFSM_STATE_INACTIVE] = { - .entry_fn = go_inactive, - .next_state = { - [LFSM_EVENT_STOP] = LFSM_STATE_STOPPING, - [LFSM_EVENT_USER_SET_RX] = LFSM_STATE_USER_BUSY_RX_PENDING, - [LFSM_EVENT_USER_SET_TX] = LFSM_STATE_USER_BUSY_TX_PENDING, - [LFSM_EVENT_RX_LINK] = LFSM_STATE_INACTIVE, - [LFSM_EVENT_RX_USER] = LFSM_STATE_INACTIVE, - [LFSM_EVENT_RX_UNKNOWN] = LFSM_STATE_INACTIVE, - }, - }, [LFSM_STATE_USER_BUSY] = { - .entry_fn = go_user_busy, - .next_state = { - [LFSM_EVENT_STOP] = LFSM_STATE_STOPPING, - [LFSM_EVENT_USER_SET_RX] = LFSM_STATE_USER_BUSY_RX_PENDING, - [LFSM_EVENT_USER_SET_TX] = LFSM_STATE_USER_BUSY_TX_PENDING, - [LFSM_EVENT_USER_DONE] = LFSM_STATE_INACTIVE, - [LFSM_EVENT_RX_LINK] = LFSM_STATE_USER_BUSY, - [LFSM_EVENT_RX_USER] = LFSM_STATE_USER_BUSY, - [LFSM_EVENT_RX_UNKNOWN] = LFSM_STATE_USER_BUSY, - }, - }, [LFSM_STATE_USER_BUSY_RX_PENDING] = { - .entry_fn = go_user_busy_rx_pending, - .next_state = { - [LFSM_EVENT_USER_SET_TX] = LFSM_STATE_USER_BUSY_RXTX_PENDING, - [LFSM_EVENT_USER_DONE] = LFSM_STATE_USER_RX_PENDING, - [LFSM_EVENT_RX_LINK] = LFSM_STATE_USER_BUSY_RX_PENDING, - [LFSM_EVENT_RX_USER] = LFSM_STATE_USER_BUSY_RX_PENDING, - [LFSM_EVENT_RX_UNKNOWN] = LFSM_STATE_USER_BUSY_RX_PENDING, - }, - }, [LFSM_STATE_USER_BUSY_TX_PENDING] = { - .entry_fn = go_user_busy_tx_pending, - .next_state = { - [LFSM_EVENT_USER_SET_RX] = LFSM_STATE_USER_BUSY_RXTX_PENDING, - [LFSM_EVENT_USER_DONE] = LFSM_STATE_USER_TX_PENDING, - [LFSM_EVENT_RX_LINK] = LFSM_STATE_USER_BUSY_TX_PENDING, - [LFSM_EVENT_RX_USER] = LFSM_STATE_USER_BUSY_TX_PENDING, - [LFSM_EVENT_RX_UNKNOWN] = LFSM_STATE_USER_BUSY_TX_PENDING, - }, - }, [LFSM_STATE_USER_BUSY_RXTX_PENDING] = { - .entry_fn = go_user_busy_rxtx_pending, - .next_state = { - [LFSM_EVENT_USER_DONE] = LFSM_STATE_USER_RXTX_PENDING, - [LFSM_EVENT_RX_LINK] = LFSM_STATE_USER_BUSY_RXTX_PENDING, - [LFSM_EVENT_RX_USER] = LFSM_STATE_USER_BUSY_RXTX_PENDING, - [LFSM_EVENT_RX_UNKNOWN] = LFSM_STATE_USER_BUSY_RXTX_PENDING, - }, - }, [LFSM_STATE_USER_RX_PENDING] = { - .entry_fn = go_user_rx_pending, - .next_state = { - [LFSM_EVENT_RX_LINK] = LFSM_STATE_USER_RX_ACTIVE, - [LFSM_EVENT_RX_USER] = LFSM_STATE_USER_RX_ACTIVE, - [LFSM_EVENT_RX_UNKNOWN] = LFSM_STATE_USER_RX_ACTIVE, - }, - }, [LFSM_STATE_USER_TX_PENDING] = { - .entry_fn = go_user_tx_pending, - .next_state = { - [LFSM_EVENT_RX_LINK] = LFSM_STATE_USER_TX_ACTIVE, - [LFSM_EVENT_RX_USER] = LFSM_STATE_USER_TX_ACTIVE, - [LFSM_EVENT_RX_UNKNOWN] = LFSM_STATE_USER_TX_ACTIVE, - }, - }, [LFSM_STATE_USER_RXTX_PENDING] = { - .entry_fn = go_user_rxtx_pending, - .next_state = { - [LFSM_EVENT_RX_LINK] = LFSM_STATE_USER_RXTX_ACTIVE, - [LFSM_EVENT_RX_USER] = LFSM_STATE_USER_RXTX_ACTIVE, - [LFSM_EVENT_RX_UNKNOWN] = LFSM_STATE_USER_RXTX_ACTIVE, - }, - }, [LFSM_STATE_USER_RX_ACTIVE] = { - .entry_fn = go_user_rx_active, - .next_state = { - [LFSM_EVENT_RX_LINK] = LFSM_STATE_USER_RX_ACTIVE, - [LFSM_EVENT_RX_USER] = LFSM_STATE_USER_BUSY, - [LFSM_EVENT_RX_UNKNOWN] = LFSM_STATE_USER_RX_ACTIVE, - }, - }, [LFSM_STATE_USER_TX_ACTIVE] = { - .entry_fn = go_user_tx_active, - .next_state = { - [LFSM_EVENT_RX_LINK] = LFSM_STATE_INACTIVE, - [LFSM_EVENT_RX_USER] = LFSM_STATE_INACTIVE, - [LFSM_EVENT_RX_UNKNOWN] = LFSM_STATE_INACTIVE, - }, - }, [LFSM_STATE_USER_RXTX_ACTIVE] = { - .entry_fn = go_user_rxtx_active, - .next_state = { - [LFSM_EVENT_RX_LINK] = LFSM_STATE_USER_RX_ACTIVE, - [LFSM_EVENT_RX_USER] = LFSM_STATE_USER_BUSY, - [LFSM_EVENT_RX_UNKNOWN] = LFSM_STATE_USER_RX_ACTIVE, - }, - }, }; - -/* - * FSM State Entry Functions - */ - -static void go_faulted(struct lfsm_context * context) { - PIOS_DEBUG_Assert(0); -} - -static void go_stopped(struct lfsm_context * context) { -#if 0 - PIOS_SPI_Stop(PIOS_SPI_OP); -#endif -} - -static void go_stopping(struct lfsm_context * context) { - context->link_tx = NULL; - context->tx = NULL; -} - -static void go_inactive(struct lfsm_context * context) { - context->link_state = OPAHRS_MSG_LINK_STATE_INACTIVE; - lfsm_update_link_tx(context); - - context->user_rx = NULL; - context->user_tx = NULL; - - context->rx = context->link_rx; - context->tx = context->link_tx; - - lfsm_init_rx(context); - PIOS_SPI_TransferBlock(PIOS_SPI_OP, context->tx, context->rx, - context->user_payload_len, lfsm_irq_callback); -} - -static void go_user_busy(struct lfsm_context * context) { - /* Sanity checks */ - PIOS_DEBUG_Assert(context->user_rx); - - context->user_rx = NULL; - context->user_tx = NULL; - - context->link_state = OPAHRS_MSG_LINK_STATE_BUSY; - lfsm_update_link_tx(context); - - context->rx = context->link_rx; - context->tx = context->link_tx; - - lfsm_init_rx(context); - PIOS_SPI_TransferBlock(PIOS_SPI_OP, context->tx, context->rx, - context->user_payload_len, lfsm_irq_callback); -} - -static void go_user_busy_rx_pending(struct lfsm_context * context) { - /* Sanity checks */ - PIOS_DEBUG_Assert(context->user_rx); - - context->link_state = OPAHRS_MSG_LINK_STATE_BUSY; - lfsm_update_link_tx(context); - - context->rx = context->link_rx; - context->tx = context->link_tx; - - lfsm_init_rx(context); - PIOS_SPI_TransferBlock(PIOS_SPI_OP, context->tx, context->rx, - context->user_payload_len, lfsm_irq_callback); -} - -static void go_user_busy_tx_pending(struct lfsm_context * context) { - /* Sanity checks */ - PIOS_DEBUG_Assert(context->user_tx); - - context->link_state = OPAHRS_MSG_LINK_STATE_BUSY; - lfsm_update_link_tx(context); - - context->rx = context->link_rx; - context->tx = context->link_tx; - - lfsm_init_rx(context); - PIOS_SPI_TransferBlock(PIOS_SPI_OP, context->tx, context->rx, - context->user_payload_len, lfsm_irq_callback); -} - -static void go_user_busy_rxtx_pending(struct lfsm_context * context) { - /* Sanity checks */ - PIOS_DEBUG_Assert(context->user_rx); PIOS_DEBUG_Assert(context->user_tx); - - context->link_state = OPAHRS_MSG_LINK_STATE_BUSY; - lfsm_update_link_tx(context); - - context->rx = context->link_rx; - context->tx = context->link_tx; - - lfsm_init_rx(context); - PIOS_SPI_TransferBlock(PIOS_SPI_OP, context->tx, context->rx, - context->user_payload_len, lfsm_irq_callback); -} - -static void go_user_rx_pending(struct lfsm_context * context) { - /* Sanity checks */ - PIOS_DEBUG_Assert(context->user_rx); - - context->link_state = OPAHRS_MSG_LINK_STATE_BUSY; - lfsm_update_link_tx(context); - - context->rx = context->link_rx; - context->tx = context->link_tx; - - lfsm_init_rx(context); - PIOS_SPI_TransferBlock(PIOS_SPI_OP, context->tx, context->rx, - context->user_payload_len, lfsm_irq_callback); -} - -static void go_user_tx_pending(struct lfsm_context * context) { - /* Sanity checks */ - PIOS_DEBUG_Assert(context->user_tx); - - context->link_state = OPAHRS_MSG_LINK_STATE_BUSY; - lfsm_update_link_tx(context); - - context->rx = context->link_rx; - context->tx = context->link_tx; - - lfsm_init_rx(context); - PIOS_SPI_TransferBlock(PIOS_SPI_OP, context->tx, context->rx, - context->user_payload_len, lfsm_irq_callback); -} - -static void go_user_rxtx_pending(struct lfsm_context * context) { - /* Sanity checks */ - PIOS_DEBUG_Assert(context->user_rx); PIOS_DEBUG_Assert(context->user_tx); - - context->link_state = OPAHRS_MSG_LINK_STATE_BUSY; - lfsm_update_link_tx(context); - - context->rx = context->link_rx; - context->tx = context->link_tx; - - lfsm_init_rx(context); - PIOS_SPI_TransferBlock(PIOS_SPI_OP, context->tx, context->rx, - context->user_payload_len, lfsm_irq_callback); -} - -static void go_user_rx_active(struct lfsm_context * context) { - /* Sanity checks */ - PIOS_DEBUG_Assert(context->user_rx); - - context->rx = context->user_rx; - context->tx = context->link_tx; - context->link_state = OPAHRS_MSG_LINK_STATE_READY; - - lfsm_update_link_tx(context); - lfsm_init_rx(context); - PIOS_SPI_TransferBlock(PIOS_SPI_OP, context->tx, context->rx, - context->user_payload_len, lfsm_irq_callback); -} - -static void go_user_tx_active(struct lfsm_context * context) { - /* Sanity checks */ - PIOS_DEBUG_Assert(context->user_tx); - - context->link_state = OPAHRS_MSG_LINK_STATE_BUSY; - context->rx = context->link_rx; - context->tx = context->user_tx; - - lfsm_init_rx(context); - PIOS_SPI_TransferBlock(PIOS_SPI_OP, context->tx, context->rx, - context->user_payload_len, lfsm_irq_callback); -} - -static void go_user_rxtx_active(struct lfsm_context * context) { - /* Sanity checks */ - PIOS_DEBUG_Assert(context->user_rx); PIOS_DEBUG_Assert(context->user_tx); - - context->link_state = OPAHRS_MSG_LINK_STATE_READY; - context->rx = context->user_rx; - context->tx = context->user_tx; - - lfsm_init_rx(context); - PIOS_SPI_TransferBlock(PIOS_SPI_OP, context->tx, context->rx, - context->user_payload_len, lfsm_irq_callback); -} - -/* - * - * Misc Helper Functions - * - */ - -static void lfsm_update_link_tx_v0(struct opahrs_msg_v0 * msg, - enum opahrs_msg_link_state state, uint16_t errors) { - opahrs_msg_v0_init_link_tx(msg, OPAHRS_MSG_LINK_TAG_NOP); - - msg->payload.link.state = state; - msg->payload.link.errors = errors; -} - -static void lfsm_update_link_tx_v1(struct opahrs_msg_v1 * msg, - enum opahrs_msg_link_state state, uint16_t errors) { - opahrs_msg_v1_init_link_tx(msg, OPAHRS_MSG_LINK_TAG_NOP); - - msg->payload.link.state = state; - msg->payload.link.errors = errors; -} - -static void lfsm_update_link_tx(struct lfsm_context * context) { - PIOS_DEBUG_Assert(context->link_tx); - - switch (context->user_payload_type) { - case OPAHRS_MSG_TYPE_USER_V0: - lfsm_update_link_tx_v0((struct opahrs_msg_v0 *) context->link_tx, - context->link_state, context->errors); - break; - case OPAHRS_MSG_TYPE_USER_V1: - lfsm_update_link_tx_v1((struct opahrs_msg_v1 *) context->link_tx, - context->link_state, context->errors); - break; - case OPAHRS_MSG_TYPE_LINK: - PIOS_DEBUG_Assert(0); - } -} - -static void lfsm_init_rx(struct lfsm_context * context) { - PIOS_DEBUG_Assert(context->rx); - - switch (context->user_payload_type) { - case OPAHRS_MSG_TYPE_USER_V0: - opahrs_msg_v0_init_rx((struct opahrs_msg_v0 *) context->rx); - break; - case OPAHRS_MSG_TYPE_USER_V1: - opahrs_msg_v1_init_rx((struct opahrs_msg_v1 *) context->rx); - break; - case OPAHRS_MSG_TYPE_LINK: - PIOS_DEBUG_Assert(0); - } -} - -/* - * - * External API - * - */ - -void lfsm_inject_event(enum lfsm_event event) { - PIOS_IRQ_Disable(); - - /* - * Move to the next state - * - * This is done prior to calling the new state's entry function to - * guarantee that the entry function never depends on the previous - * state. This way, it cannot ever know what the previous state was. - */ - context.curr_state = lfsm_transitions[context.curr_state].next_state[event]; - - /* Call the entry function (if any) for the next state. */ - if (lfsm_transitions[context.curr_state].entry_fn) { - lfsm_transitions[context.curr_state].entry_fn(&context); - } - PIOS_IRQ_Enable(); -} - -void lfsm_init(void) { - context.curr_state = LFSM_STATE_STOPPED; - go_stopped(&context); -} - -void lfsm_set_link_proto_v0(struct opahrs_msg_v0 * link_tx, - struct opahrs_msg_v0 * link_rx) { - PIOS_DEBUG_Assert(link_tx); - - context.link_tx = (uint8_t *) link_tx; - context.link_rx = (uint8_t *) link_rx; - context.user_payload_type = OPAHRS_MSG_TYPE_USER_V0; - context.user_payload_len = sizeof(*link_tx); - - lfsm_update_link_tx_v0(link_tx, context.link_state, context.errors); - - lfsm_inject_event(LFSM_EVENT_INIT_LINK); -} - -void lfsm_set_link_proto_v1(struct opahrs_msg_v1 * link_tx, - struct opahrs_msg_v1 * link_rx) { - PIOS_DEBUG_Assert(link_tx); - - context.link_tx = (uint8_t *) link_tx; - context.link_rx = (uint8_t *) link_rx; - context.user_payload_type = OPAHRS_MSG_TYPE_USER_V1; - context.user_payload_len = sizeof(*link_tx); - - lfsm_update_link_tx_v1(link_tx, context.link_state, context.errors); - - lfsm_inject_event(LFSM_EVENT_INIT_LINK); -} - -void lfsm_user_set_tx_v0(struct opahrs_msg_v0 * user_tx) { - PIOS_DEBUG_Assert(user_tx); - - PIOS_DEBUG_Assert(context.user_payload_type == OPAHRS_MSG_TYPE_USER_V0); - context.user_tx = (uint8_t *) user_tx; - - lfsm_inject_event(LFSM_EVENT_USER_SET_TX); -} - -void lfsm_user_set_rx_v0(struct opahrs_msg_v0 * user_rx) { - PIOS_DEBUG_Assert(user_rx); PIOS_DEBUG_Assert(context.user_payload_type == OPAHRS_MSG_TYPE_USER_V0); - - context.user_rx = (uint8_t *) user_rx; - - lfsm_inject_event(LFSM_EVENT_USER_SET_RX); -} - -void lfsm_user_set_tx_v1(struct opahrs_msg_v1 * user_tx) { - PIOS_DEBUG_Assert(user_tx); PIOS_DEBUG_Assert(context.user_payload_type == OPAHRS_MSG_TYPE_USER_V1); - - context.user_tx = (uint8_t *) user_tx; - - lfsm_inject_event(LFSM_EVENT_USER_SET_TX); -} - -void lfsm_user_set_rx_v1(struct opahrs_msg_v1 * user_rx) { - PIOS_DEBUG_Assert(user_rx); PIOS_DEBUG_Assert(context.user_payload_type == OPAHRS_MSG_TYPE_USER_V1); - - context.user_rx = (uint8_t *) user_rx; - - lfsm_inject_event(LFSM_EVENT_USER_SET_RX); -} - -void lfsm_user_done(void) { - lfsm_inject_event(LFSM_EVENT_USER_DONE); -} - -void lfsm_stop(void) { - lfsm_inject_event(LFSM_EVENT_STOP); -} - -void lfsm_get_link_stats(struct lfsm_link_stats * stats) { - PIOS_DEBUG_Assert(stats); - - *stats = context.stats; -} - -enum lfsm_state lfsm_get_state(void) { - return context.curr_state; -} - -/* - * - * ISR Callback - * - */ - -void lfsm_irq_callback(uint8_t crc_ok, uint8_t crc_val) { - if (!crc_ok) { - context.stats.rx_badcrc++; - lfsm_inject_event(LFSM_EVENT_RX_UNKNOWN); - return; - } - - if (!context.rx) { - /* No way to know what we just received, assume invalid */ - lfsm_inject_event(LFSM_EVENT_RX_UNKNOWN); - return; - } - - /* Recover the head and tail pointers from the message */ - struct opahrs_msg_link_head * head = 0; - struct opahrs_msg_link_tail * tail = 0; - - switch (context.user_payload_type) { - case OPAHRS_MSG_TYPE_USER_V0: - head = &((struct opahrs_msg_v0 *) context.rx)->head; - tail = &((struct opahrs_msg_v0 *) context.rx)->tail; - break; - case OPAHRS_MSG_TYPE_USER_V1: - head = &((struct opahrs_msg_v1 *) context.rx)->head; - tail = &((struct opahrs_msg_v1 *) context.rx)->tail; - break; - case OPAHRS_MSG_TYPE_LINK: - /* Should never be rx'ing before the link protocol version is known */ - PIOS_DEBUG_Assert(0); - break; - } - - /* Check for bad magic */ - if ((head->magic != OPAHRS_MSG_MAGIC_HEAD) || (tail->magic - != OPAHRS_MSG_MAGIC_TAIL)) { - if (head->magic != OPAHRS_MSG_MAGIC_HEAD) { - context.stats.rx_badmagic_head++; - } - if (tail->magic != OPAHRS_MSG_MAGIC_TAIL) { - context.stats.rx_badmagic_tail++; - } - lfsm_inject_event(LFSM_EVENT_RX_UNKNOWN); - return; - } - - /* Good magic, find out what type of payload we've got */ - switch (head->type) { - case OPAHRS_MSG_TYPE_LINK: - context.stats.rx_link++; - lfsm_inject_event(LFSM_EVENT_RX_LINK); - break; - case OPAHRS_MSG_TYPE_USER_V0: - case OPAHRS_MSG_TYPE_USER_V1: - if (head->type == context.user_payload_type) { - context.stats.rx_user++; - lfsm_inject_event(LFSM_EVENT_RX_USER); - } else { - /* Mismatched user payload type */ - context.stats.rx_badver++; - lfsm_inject_event(LFSM_EVENT_RX_UNKNOWN); - } - break; - default: - /* Unidentifiable payload type */ - context.stats.rx_badtype++; - lfsm_inject_event(LFSM_EVENT_RX_UNKNOWN); - } -} diff --git a/flight/Bootloaders/OSD/inc/bl_fsm.h b/flight/Bootloaders/OSD/inc/bl_fsm.h deleted file mode 100644 index 7c443edb7..000000000 --- a/flight/Bootloaders/OSD/inc/bl_fsm.h +++ /dev/null @@ -1,97 +0,0 @@ -/** - ****************************************************************************** - * - * @file ahrs_fsm.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief - * @see The GNU Public License (GPL) Version 3 - * - *****************************************************************************/ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef BL_FSM_H -#define BL_FSM_H - -#include "pios_opahrs_proto.h" - -enum lfsm_state { - LFSM_STATE_FAULTED = 0, /* Must be zero so undefined transitions land here */ - LFSM_STATE_STOPPED, - LFSM_STATE_STOPPING, - LFSM_STATE_INACTIVE, - LFSM_STATE_USER_BUSY, - LFSM_STATE_USER_BUSY_RX_PENDING, - LFSM_STATE_USER_BUSY_TX_PENDING, - LFSM_STATE_USER_BUSY_RXTX_PENDING, - LFSM_STATE_USER_RX_PENDING, - LFSM_STATE_USER_TX_PENDING, - LFSM_STATE_USER_RXTX_PENDING, - LFSM_STATE_USER_RX_ACTIVE, - LFSM_STATE_USER_TX_ACTIVE, - LFSM_STATE_USER_RXTX_ACTIVE, - - LFSM_STATE_NUM_STATES -/* Must be last */ -}; - -enum lfsm_event { - LFSM_EVENT_INIT_LINK, - LFSM_EVENT_STOP, - LFSM_EVENT_USER_SET_RX, - LFSM_EVENT_USER_SET_TX, - LFSM_EVENT_USER_DONE, - LFSM_EVENT_RX_LINK, - LFSM_EVENT_RX_USER, - LFSM_EVENT_RX_UNKNOWN, - - LFSM_EVENT_NUM_EVENTS -/* Must be last */ -}; - -struct lfsm_link_stats { - uint32_t rx_badcrc; - uint32_t rx_badmagic_head; - uint32_t rx_badmagic_tail; - uint32_t rx_link; - uint32_t rx_user; - uint32_t tx_user; - uint32_t rx_badtype; - uint32_t rx_badver; -}; - -extern void lfsm_attach(uint32_t spi_id); -extern void lfsm_init(void); -extern void lfsm_inject_event(enum lfsm_event event); - -extern void lfsm_irq_callback(uint8_t crc_ok, uint8_t crc_val); - -extern void lfsm_get_link_stats(struct lfsm_link_stats * stats); -extern enum lfsm_state lfsm_get_state(void); - -extern void lfsm_set_link_proto_v0(struct opahrs_msg_v0 * link_tx, - struct opahrs_msg_v0 * link_rx); -extern void lfsm_user_set_rx_v0(struct opahrs_msg_v0 * user_rx); -extern void lfsm_user_set_tx_v0(struct opahrs_msg_v0 * user_tx); - -extern void lfsm_set_link_proto_v1(struct opahrs_msg_v1 * link_tx, - struct opahrs_msg_v1 * link_rx); -extern void lfsm_user_set_rx_v1(struct opahrs_msg_v1 * user_rx); -extern void lfsm_user_set_tx_v1(struct opahrs_msg_v1 * user_tx); - -extern void lfsm_user_done(void); - -#endif /* BL_FSM_H */ diff --git a/flight/Bootloaders/OSD/inc/common.h b/flight/Bootloaders/OSD/inc/common.h new file mode 100644 index 000000000..9ecff4079 --- /dev/null +++ b/flight/Bootloaders/OSD/inc/common.h @@ -0,0 +1,115 @@ +/** + ****************************************************************************** + * @addtogroup CopterControlBL CopterControl BootLoader + * @brief These files contain the code to the CopterControl Bootloader. + * + * @{ + * @file common.c + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief This file contains various common defines for the BootLoader + * @see The GNU Public License (GPL) Version 3 + * + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef COMMON_H_ +#define COMMON_H_ + +//#include "board.h" + +typedef enum { + start, keepgoing, +} DownloadAction; + +/**************************************************/ +/* OP_DFU states */ +/**************************************************/ + +typedef enum { + DFUidle, //0 + uploading, //1 + wrong_packet_received, //2 + too_many_packets, //3 + too_few_packets, //4 + Last_operation_Success, //5 + downloading, //6 + BLidle, //7 + Last_operation_failed, //8 + uploadingStarting, //9 + outsideDevCapabilities, //10 + CRC_Fail,//11 + failed_jump, +//12 +} DFUStates; +/**************************************************/ +/* OP_DFU commands */ +/**************************************************/ +typedef enum { + Reserved, //0 + Req_Capabilities, //1 + Rep_Capabilities, //2 + EnterDFU, //3 + JumpFW, //4 + Reset, //5 + Abort_Operation, //6 + Upload, //7 + Op_END, //8 + Download_Req, //9 + Download, //10 + Status_Request, //11 + Status_Rep +//12 +} DFUCommands; + +typedef enum { + High_Density, Medium_Density +} DeviceType; +/**************************************************/ +/* OP_DFU transfer types */ +/**************************************************/ +typedef enum { + FW, //0 + Descript +//2 +} DFUTransfer; +/**************************************************/ +/* OP_DFU transfer port */ +/**************************************************/ +typedef enum { + Usb, //0 + Serial +//2 +} DFUPort; +/**************************************************/ +/* OP_DFU programable programable HW types */ +/**************************************************/ +typedef enum { + Self_flash, //0 + Remote_flash_via_spi +//1 +} DFUProgType; +/**************************************************/ +/* OP_DFU programable sources */ +/**************************************************/ +#define USB 0 +#define SPI 1 + +#define DownloadDelay 100000 + +#define MAX_DEL_RETRYS 3 +#define MAX_WRI_RETRYS 3 + +#endif /* COMMON_H_ */ diff --git a/flight/Bootloaders/OSD/inc/op_dfu.h b/flight/Bootloaders/OSD/inc/op_dfu.h new file mode 100644 index 000000000..e031c3364 --- /dev/null +++ b/flight/Bootloaders/OSD/inc/op_dfu.h @@ -0,0 +1,60 @@ +/** + ****************************************************************************** + * + * @file op_dfu.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief + * @see The GNU Public License (GPL) Version 3 + * + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __OP_DFU_H +#define __OP_DFU_H +#include "common.h" +/* Includes ------------------------------------------------------------------*/ +/* Exported types ------------------------------------------------------------*/ +typedef struct { + uint8_t programmingType; + uint8_t readWriteFlags; + uint32_t startOfUserCode; + uint32_t sizeOfCode; + uint8_t sizeOfDescription; + uint8_t BL_Version; + uint16_t devID; + DeviceType devType; + uint32_t FW_Crc; +} Device; + +/* Exported constants --------------------------------------------------------*/ +/* Exported macro ------------------------------------------------------------*/ +/* Exported define -----------------------------------------------------------*/ +#define COMMAND 0 +#define COUNT 1 +#define DATA 5 + +/* Exported functions ------------------------------------------------------- */ +void processComand(uint8_t *Receive_Buffer); +uint32_t baseOfAdressType(uint8_t type); +uint8_t isBiggerThanAvailable(uint8_t type, uint32_t size); +void OPDfuIni(uint8_t discover); +void DataDownload(DownloadAction); +bool flash_read(uint8_t * buffer, uint32_t adr, DFUProgType type); +#endif /* __OP_DFU_H */ + +/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/ diff --git a/flight/Bootloaders/OSD/inc/osd_bl.h b/flight/Bootloaders/OSD/inc/osd_bl.h deleted file mode 100644 index d96ba3bf6..000000000 --- a/flight/Bootloaders/OSD/inc/osd_bl.h +++ /dev/null @@ -1,53 +0,0 @@ -/** - ****************************************************************************** - * - * @file ahrs_bl.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief Main AHRS_BL header. - * @see The GNU Public License (GPL) Version 3 - * - *****************************************************************************/ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#ifndef INS_BL_H -#define INS_BL_H - - -/* PIOS Includes */ -#include - -/** Start programming -returns: true if FLASH erased and ready to program -*/ -bool StartProgramming(void); - -/** Write a block to FLASH -buffer contains the data to be written -returns: true if FLASH programmed correctly -*/ -bool WriteData(uint32_t offset, uint8_t *buffer, uint32_t size); - -/** Read a block from FLASH -returns: true if FLASH read correctly. -Buffer is set to the read data -*/ -bool ReadData(uint32_t offset, uint8_t *buffer, uint32_t size); - - - -#endif /* AHRS_BL_H */ diff --git a/flight/Bootloaders/OSD/inc/pios_config.h b/flight/Bootloaders/OSD/inc/pios_config.h index 469ea9035..dc71a1556 100644 --- a/flight/Bootloaders/OSD/inc/pios_config.h +++ b/flight/Bootloaders/OSD/inc/pios_config.h @@ -37,7 +37,7 @@ #define PIOS_INCLUDE_USB #define PIOS_INCLUDE_USB_HID #define PIOS_INCLUDE_COM_MSG -//#define PIOS_INCLUDE_BL_HELPER -//#define PIOS_INCLUDE_BL_HELPER_WRITE_SUPPORT +#define PIOS_INCLUDE_BL_HELPER +#define PIOS_INCLUDE_BL_HELPER_WRITE_SUPPORT #endif /* PIOS_CONFIG_H */ diff --git a/flight/Bootloaders/OSD/main.c b/flight/Bootloaders/OSD/main.c index 6e0c0e18d..90e946b56 100644 --- a/flight/Bootloaders/OSD/main.c +++ b/flight/Bootloaders/OSD/main.c @@ -1,17 +1,12 @@ /** ****************************************************************************** - * @addtogroup AHRS BOOTLOADER - * @brief The AHRS Modules perform - * - * @{ - * @addtogroup AHRS_BOOTLOADER_Main - * @brief Main function which does the hardware dependent stuff - * @{ - * + * @addtogroup RevolutionBL Revolution BootLoader + * @brief These files contain the code to the Revolution Bootloader. * + * @{ * @file main.c * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief + * @brief This is the file with the main function of the Revolution BootLoader * @see The GNU Public License (GPL) Version 3 * *****************************************************************************/ @@ -30,41 +25,146 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -/* OpenPilot Includes */ -#include "osd_bl.h" +/* Bootloader Includes */ +#include #include -#include "bl_fsm.h" /* lfsm_state */ -//#include "stm32f2xx_flash.h" - +#include +#include "op_dfu.h" +#include "pios_iap.h" +#include "fifo_buffer.h" +#include "pios_com_msg.h" +#include "pios_usbhook.h" /* PIOS_USBHOOK_* */ +/* Prototype of PIOS_Board_Init() function */ extern void PIOS_Board_Init(void); +extern void FLASH_Download(); +#define BSL_HOLD_STATE ((PIOS_USB_DETECT_GPIO_PORT->IDR & PIOS_USB_DETECT_GPIO_PIN) ? 0 : 1) -#define NSS_HOLD_STATE ((GPIOB->IDR & GPIO_Pin_12) ? 0 : 1) -enum bootloader_status boot_status; /* Private typedef -----------------------------------------------------------*/ -typedef void -(*pFunction)(void); +typedef void (*pFunction)(void); +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ pFunction Jump_To_Application; uint32_t JumpAddress; -/* Function Prototypes */ -//void -//process_spi_request(void); -void -jump_to_app(); -uint32_t Fw_crc; -/** - * @brief Bootloader Main function - */ + +/// LEDs PWM +uint32_t period1 = 5000; // 5 mS +uint32_t sweep_steps1 = 100; // * 5 mS -> 500 mS +uint32_t period2 = 5000; // 5 mS +uint32_t sweep_steps2 = 100; // * 5 mS -> 500 mS + + +//////////////////////////////////////// +uint8_t tempcount = 0; + +/* Extern variables ----------------------------------------------------------*/ +DFUStates DeviceState; +int16_t status = 0; +bool JumpToApp = false; +bool GO_dfu = false; +bool USB_connected = false; +bool User_DFU_request = false; +static uint8_t mReceive_Buffer[63]; +/* Private function prototypes -----------------------------------------------*/ +uint32_t LedPWM(uint32_t pwm_period, uint32_t pwm_sweep_steps, uint32_t count); +uint8_t processRX(); +void jump_to_app(); + int main() { - /* Brings up System using CMSIS functions, enables the LEDs. */ PIOS_SYS_Init(); PIOS_Board_Init(); + PIOS_IAP_Init(); - jump_to_app(); - return 0; + USB_connected = PIOS_USB_CheckAvailable(0); + + if (PIOS_IAP_CheckRequest() == true) { + PIOS_DELAY_WaitmS(1000); + User_DFU_request = true; + PIOS_IAP_ClearRequest(); + } + + GO_dfu = (USB_connected == true) || (User_DFU_request == true); + + if (GO_dfu == true) { + PIOS_Board_Init(); + if (User_DFU_request == true) + DeviceState = DFUidle; + else + DeviceState = BLidle; + } else + JumpToApp = true; + + uint32_t stopwatch = 0; + uint32_t prev_ticks = PIOS_DELAY_GetuS(); + while (true) { + /* Update the stopwatch */ + uint32_t elapsed_ticks = PIOS_DELAY_GetuSSince(prev_ticks); + prev_ticks += elapsed_ticks; + stopwatch += elapsed_ticks; + + if (JumpToApp == true) + jump_to_app(); + + switch (DeviceState) { + case Last_operation_Success: + case uploadingStarting: + case DFUidle: + period1 = 5000; + sweep_steps1 = 100; + PIOS_LED_Off(PIOS_LED_HEARTBEAT); + period2 = 0; + break; + case uploading: + period1 = 5000; + sweep_steps1 = 100; + period2 = 2500; + sweep_steps2 = 50; + break; + case downloading: + period1 = 2500; + sweep_steps1 = 50; + PIOS_LED_Off(PIOS_LED_HEARTBEAT); + period2 = 0; + break; + case BLidle: + period1 = 0; + PIOS_LED_On(PIOS_LED_HEARTBEAT); + period2 = 0; + break; + default://error + period1 = 5000; + sweep_steps1 = 100; + period2 = 5000; + sweep_steps2 = 100; + } + + if (period1 != 0) { + if (LedPWM(period1, sweep_steps1, stopwatch)) + PIOS_LED_On(PIOS_LED_HEARTBEAT); + else + PIOS_LED_Off(PIOS_LED_HEARTBEAT); + } else + PIOS_LED_On(PIOS_LED_HEARTBEAT); + + if (period2 != 0) { + if (LedPWM(period2, sweep_steps2, stopwatch)) + PIOS_LED_On(PIOS_LED_HEARTBEAT); + else + PIOS_LED_Off(PIOS_LED_HEARTBEAT); + } else + PIOS_LED_Off(PIOS_LED_HEARTBEAT); + + if (stopwatch > 50 * 1000 * 1000) + stopwatch = 0; + if ((stopwatch > 6 * 1000 * 1000) && (DeviceState + == BLidle)) + JumpToApp = true; + + processRX(); + DataDownload(start); + } } - void jump_to_app() { const struct pios_board_info * bdinfo = &pios_board_info_blob; @@ -75,8 +175,8 @@ void jump_to_app() { RCC_APB1PeriphResetCmd(0xffffffff, ENABLE); RCC_APB2PeriphResetCmd(0xffffffff, DISABLE); RCC_APB1PeriphResetCmd(0xffffffff, DISABLE); - //_SetCNTR(0); // clear interrupt mask - //_SetISTR(0); // clear all requests + + PIOS_USBHOOK_Deactivate(); JumpAddress = *(__IO uint32_t*) (bdinfo->fw_base + 4); Jump_To_Application = (pFunction) JumpAddress; @@ -84,7 +184,25 @@ void jump_to_app() { __set_MSP(*(__IO uint32_t*) bdinfo->fw_base); Jump_To_Application(); } else { - boot_status = jump_failed; + DeviceState = failed_jump; return; } } +uint32_t LedPWM(uint32_t pwm_period, uint32_t pwm_sweep_steps, uint32_t count) { + uint32_t curr_step = (count / pwm_period) % pwm_sweep_steps; /* 0 - pwm_sweep_steps */ + uint32_t pwm_duty = pwm_period * curr_step / pwm_sweep_steps; /* fraction of pwm_period */ + + uint32_t curr_sweep = (count / (pwm_period * pwm_sweep_steps)); /* ticks once per full sweep */ + if (curr_sweep & 1) { + pwm_duty = pwm_period - pwm_duty; /* reverse direction in odd sweeps */ + } + return ((count % pwm_period) > pwm_duty) ? 1 : 0; +} + +uint8_t processRX() { + if (PIOS_COM_MSG_Receive(PIOS_COM_TELEM_USB, mReceive_Buffer, sizeof(mReceive_Buffer))) { + processComand(mReceive_Buffer); + } + return true; +} + diff --git a/flight/Bootloaders/OSD/op_dfu.c b/flight/Bootloaders/OSD/op_dfu.c new file mode 100644 index 000000000..3aceedcfb --- /dev/null +++ b/flight/Bootloaders/OSD/op_dfu.c @@ -0,0 +1,468 @@ +/** + ****************************************************************************** + * @addtogroup CopterControlBL CopterControl BootLoader + * @brief These files contain the code to the CopterControl Bootloader. + * + * @{ + * @file op_dfu.c + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief This file contains the DFU commands handling code + * @see The GNU Public License (GPL) Version 3 + * + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* Includes ------------------------------------------------------------------*/ +#include "pios.h" +#include +#include "op_dfu.h" +#include "pios_bl_helper.h" +#include "pios_com_msg.h" +#include +//programmable devices +Device devicesTable[10]; +uint8_t numberOfDevices = 0; + +DFUProgType currentProgrammingDestination; //flash, flash_trough spi +uint8_t currentDeviceCanRead; +uint8_t currentDeviceCanWrite; +Device currentDevice; + +uint8_t Buffer[64]; +uint8_t echoBuffer[64]; +uint8_t SendBuffer[64]; +uint8_t Command = 0; +uint8_t EchoReqFlag = 0; +uint8_t EchoAnsFlag = 0; +uint8_t StartFlag = 0; +uint32_t Aditionals = 0; +uint32_t SizeOfTransfer = 0; +uint32_t Expected_CRC = 0; +uint8_t SizeOfLastPacket = 0; +uint32_t Next_Packet = 0; +uint8_t TransferType; +uint32_t Count = 0; +uint32_t Data; +uint8_t Data0; +uint8_t Data1; +uint8_t Data2; +uint8_t Data3; +uint8_t offset = 0; +uint32_t aux; +//Download vars +uint32_t downSizeOfLastPacket = 0; +uint32_t downPacketTotal = 0; +uint32_t downPacketCurrent = 0; +DFUTransfer downType = 0; +/* Extern variables ----------------------------------------------------------*/ +extern DFUStates DeviceState; +extern uint8_t JumpToApp; +/* Private function prototypes -----------------------------------------------*/ +/* Private functions ---------------------------------------------------------*/ +void sendData(uint8_t * buf, uint16_t size); +uint32_t CalcFirmCRC(void); + +void DataDownload(DownloadAction action) { + if ((DeviceState == downloading)) { + + uint8_t packetSize; + uint32_t offset; + uint32_t partoffset; + SendBuffer[0] = 0x01; + SendBuffer[1] = Download; + SendBuffer[2] = downPacketCurrent >> 24; + SendBuffer[3] = downPacketCurrent >> 16; + SendBuffer[4] = downPacketCurrent >> 8; + SendBuffer[5] = downPacketCurrent; + if (downPacketCurrent == downPacketTotal - 1) { + packetSize = downSizeOfLastPacket; + } else { + packetSize = 14; + } + for (uint8_t x = 0; x < packetSize; ++x) { + partoffset = (downPacketCurrent * 14 * 4) + (x * 4); + offset = baseOfAdressType(downType) + partoffset; + if (!flash_read(SendBuffer + (6 + x * 4), offset, + currentProgrammingDestination)) { + DeviceState = Last_operation_failed; + } + } + downPacketCurrent = downPacketCurrent + 1; + if (downPacketCurrent > downPacketTotal - 1) { + DeviceState = Last_operation_Success; + Aditionals = (uint32_t) Download; + } + sendData(SendBuffer + 1, 63); + } +} +void processComand(uint8_t *xReceive_Buffer) { + + Command = xReceive_Buffer[COMMAND]; +#ifdef DEBUG_SSP + char str[63]= {0}; + sprintf(str,"Received COMMAND:%d|",Command); + PIOS_COM_SendString(PIOS_COM_TELEM_USB,str); +#endif + EchoReqFlag = (Command >> 7); + EchoAnsFlag = (Command >> 6) & 0x01; + StartFlag = (Command >> 5) & 0x01; + Count = xReceive_Buffer[COUNT] << 24; + Count += xReceive_Buffer[COUNT + 1] << 16; + Count += xReceive_Buffer[COUNT + 2] << 8; + Count += xReceive_Buffer[COUNT + 3]; + + Data = xReceive_Buffer[DATA] << 24; + Data += xReceive_Buffer[DATA + 1] << 16; + Data += xReceive_Buffer[DATA + 2] << 8; + Data += xReceive_Buffer[DATA + 3]; + Data0 = xReceive_Buffer[DATA]; + Data1 = xReceive_Buffer[DATA + 1]; + Data2 = xReceive_Buffer[DATA + 2]; + Data3 = xReceive_Buffer[DATA + 3]; + Command = Command & 0b00011111; + + if (EchoReqFlag == 1) { + memcpy(echoBuffer, xReceive_Buffer, 64); + } + switch (Command) { + case EnterDFU: + if (((DeviceState == BLidle) && (Data0 < numberOfDevices)) + || (DeviceState == DFUidle)) { + if (Data0 > 0) + OPDfuIni(true); + DeviceState = DFUidle; + currentProgrammingDestination = devicesTable[Data0].programmingType; + currentDeviceCanRead = devicesTable[Data0].readWriteFlags & 0x01; + currentDeviceCanWrite = devicesTable[Data0].readWriteFlags >> 1 + & 0x01; + currentDevice = devicesTable[Data0]; + uint8_t result = 0; + switch (currentProgrammingDestination) { + case Self_flash: + result = PIOS_BL_HELPER_FLASH_Ini(); + break; + case Remote_flash_via_spi: + result = true; + break; + default: + DeviceState = Last_operation_failed; + Aditionals = (uint16_t) Command; + } + if (result != 1) { + DeviceState = Last_operation_failed; + Aditionals = (uint32_t) Command; + } + } + break; + case Upload: + if ((DeviceState == DFUidle) || (DeviceState == uploading)) { + if ((StartFlag == 1) && (Next_Packet == 0)) { + TransferType = Data0; + SizeOfTransfer = Count; + Next_Packet = 1; + Expected_CRC = Data2 << 24; + Expected_CRC += Data3 << 16; + Expected_CRC += xReceive_Buffer[DATA + 4] << 8; + Expected_CRC += xReceive_Buffer[DATA + 5]; + SizeOfLastPacket = Data1; + + if (isBiggerThanAvailable(TransferType, (SizeOfTransfer - 1) + * 14 * 4 + SizeOfLastPacket * 4) == true) { + DeviceState = outsideDevCapabilities; + Aditionals = (uint32_t) Command; + } else { + uint8_t result = 1; + if (TransferType == FW) { + switch (currentProgrammingDestination) { + case Self_flash: + result = PIOS_BL_HELPER_FLASH_Start(); + break; + case Remote_flash_via_spi: + result = false; + break; + default: + break; + } + } + if (result != 1) { + DeviceState = Last_operation_failed; + Aditionals = (uint32_t) Command; + } else { + + DeviceState = uploading; + } + } + } else if ((StartFlag != 1) && (Next_Packet != 0)) { + if (Count > SizeOfTransfer) { + DeviceState = too_many_packets; + Aditionals = Count; + } else if (Count == Next_Packet - 1) { + uint8_t numberOfWords = 14; + if (Count == SizeOfTransfer - 1)//is this the last packet? + { + numberOfWords = SizeOfLastPacket; + } + uint8_t result = 0; + switch (currentProgrammingDestination) { + case Self_flash: + for (uint8_t x = 0; x < numberOfWords; ++x) { + offset = 4 * x; + Data = xReceive_Buffer[DATA + offset] << 24; + Data += xReceive_Buffer[DATA + 1 + offset] << 16; + Data += xReceive_Buffer[DATA + 2 + offset] << 8; + Data += xReceive_Buffer[DATA + 3 + offset]; + aux = baseOfAdressType(TransferType) + (uint32_t)( + Count * 14 * 4 + x * 4); + result = 0; + for (int retry = 0; retry < MAX_WRI_RETRYS; ++retry) { + if (result == 0) { + result = (FLASH_ProgramWord(aux, Data) + == FLASH_COMPLETE) ? 1 : 0; + } + } + } + break; + case Remote_flash_via_spi: + result = false; // No support for this for the PipX + break; + default: + result = 0; + break; + } + if (result != 1) { + DeviceState = Last_operation_failed; + Aditionals = (uint32_t) Command; + } + + ++Next_Packet; + } else { + DeviceState = wrong_packet_received; + Aditionals = Count; + } + } else { + DeviceState = Last_operation_failed; + Aditionals = (uint32_t) Command; + } + } + break; + case Req_Capabilities: + OPDfuIni(true); + Buffer[0] = 0x01; + Buffer[1] = Rep_Capabilities; + if (Data0 == 0) { + Buffer[2] = 0; + Buffer[3] = 0; + Buffer[4] = 0; + Buffer[5] = 0; + Buffer[6] = 0; + Buffer[7] = numberOfDevices; + uint16_t WRFlags = 0; + for (int x = 0; x < numberOfDevices; ++x) { + WRFlags = ((devicesTable[x].readWriteFlags << (x * 2)) + | WRFlags); + } + Buffer[8] = WRFlags >> 8; + Buffer[9] = WRFlags; + } else { + Buffer[2] = devicesTable[Data0 - 1].sizeOfCode >> 24; + Buffer[3] = devicesTable[Data0 - 1].sizeOfCode >> 16; + Buffer[4] = devicesTable[Data0 - 1].sizeOfCode >> 8; + Buffer[5] = devicesTable[Data0 - 1].sizeOfCode; + Buffer[6] = Data0; + Buffer[7] = devicesTable[Data0 - 1].BL_Version; + Buffer[8] = devicesTable[Data0 - 1].sizeOfDescription; + Buffer[9] = devicesTable[Data0 - 1].devID; + Buffer[10] = devicesTable[Data0 - 1].FW_Crc >> 24; + Buffer[11] = devicesTable[Data0 - 1].FW_Crc >> 16; + Buffer[12] = devicesTable[Data0 - 1].FW_Crc >> 8; + Buffer[13] = devicesTable[Data0 - 1].FW_Crc; + Buffer[14] = devicesTable[Data0 - 1].devID >> 8; + Buffer[15] = devicesTable[Data0 - 1].devID; + } + sendData(Buffer + 1, 63); + break; + case JumpFW: + if (Data == 0x5AFE) { + /* Force board into safe mode */ + PIOS_IAP_WriteBootCount(0xFFFF); + } + FLASH_Lock(); + JumpToApp = 1; + break; + case Reset: + PIOS_SYS_Reset(); + break; + case Abort_Operation: + Next_Packet = 0; + DeviceState = DFUidle; + break; + + case Op_END: + if (DeviceState == uploading) { + if (Next_Packet - 1 == SizeOfTransfer) { + Next_Packet = 0; + if ((TransferType != FW) || (Expected_CRC == CalcFirmCRC())) { + DeviceState = Last_operation_Success; + } else { + DeviceState = CRC_Fail; + } + } + if (Next_Packet - 1 < SizeOfTransfer) { + Next_Packet = 0; + DeviceState = too_few_packets; + } + } + break; + case Download_Req: +#ifdef DEBUG_SSP + sprintf(str,"COMMAND:DOWNLOAD_REQ 1 Status=%d|",DeviceState); + PIOS_COM_SendString(PIOS_COM_TELEM_USB,str); +#endif + if (DeviceState == DFUidle) { +#ifdef DEBUG_SSP + PIOS_COM_SendString(PIOS_COM_TELEM_USB,"COMMAND:DOWNLOAD_REQ 1|"); +#endif + downType = Data0; + downPacketTotal = Count; + downSizeOfLastPacket = Data1; + if (isBiggerThanAvailable(downType, (downPacketTotal - 1) * 14 * 4 + + downSizeOfLastPacket * 4) == 1) { + DeviceState = outsideDevCapabilities; + Aditionals = (uint32_t) Command; + + } else { + downPacketCurrent = 0; + DeviceState = downloading; + } + } else { + DeviceState = Last_operation_failed; + Aditionals = (uint32_t) Command; + } + break; + + case Status_Request: + Buffer[0] = 0x01; + Buffer[1] = Status_Rep; + if (DeviceState == wrong_packet_received) { + Buffer[2] = Aditionals >> 24; + Buffer[3] = Aditionals >> 16; + Buffer[4] = Aditionals >> 8; + Buffer[5] = Aditionals; + } else { + Buffer[2] = 0; + Buffer[3] = ((uint16_t) Aditionals) >> 8; + Buffer[4] = ((uint16_t) Aditionals); + Buffer[5] = 0; + } + Buffer[6] = DeviceState; + Buffer[7] = 0; + Buffer[8] = 0; + Buffer[9] = 0; + sendData(Buffer + 1, 63); + if (DeviceState == Last_operation_Success) { + DeviceState = DFUidle; + } + break; + case Status_Rep: + + break; + + } + if (EchoReqFlag == 1) { + echoBuffer[0] = echoBuffer[0] | (1 << 6); + sendData(echoBuffer, 63); + } + return; +} +void OPDfuIni(uint8_t discover) { + const struct pios_board_info * bdinfo = &pios_board_info_blob; + Device dev; + + dev.programmingType = Self_flash; + dev.readWriteFlags = (BOARD_READABLE | (BOARD_WRITABLE << 1)); + dev.startOfUserCode = bdinfo->fw_base; + dev.sizeOfCode = bdinfo->fw_size; + dev.sizeOfDescription = bdinfo->desc_size; + dev.BL_Version = bdinfo->bl_rev; + dev.FW_Crc = CalcFirmCRC(); + dev.devID = (bdinfo->board_type << 8) | (bdinfo->board_rev); + dev.devType = bdinfo->hw_type; + numberOfDevices = 1; + devicesTable[0] = dev; + if (discover) { + //TODO check other devices trough spi or whatever + } +} +uint32_t baseOfAdressType(DFUTransfer type) { + switch (type) { + case FW: + return currentDevice.startOfUserCode; + break; + case Descript: + return currentDevice.startOfUserCode + currentDevice.sizeOfCode; + break; + default: + + return 0; + } +} +uint8_t isBiggerThanAvailable(DFUTransfer type, uint32_t size) { + switch (type) { + case FW: + return (size > currentDevice.sizeOfCode) ? 1 : 0; + break; + case Descript: + return (size > currentDevice.sizeOfDescription) ? 1 : 0; + break; + default: + return true; + } +} + +uint32_t CalcFirmCRC() { + switch (currentProgrammingDestination) { + case Self_flash: + return PIOS_BL_HELPER_CRC_Memory_Calc(); + break; + case Remote_flash_via_spi: + return 0; + break; + default: + return 0; + break; + } + +} +void sendData(uint8_t * buf, uint16_t size) { + PIOS_COM_MSG_Send(PIOS_COM_TELEM_USB, buf, size); +} + +bool flash_read(uint8_t * buffer, uint32_t adr, DFUProgType type) { + switch (type) { + case Remote_flash_via_spi: + return false; // We should not get this for the PipX + break; + case Self_flash: + for (uint8_t x = 0; x < 4; ++x) { + buffer[x] = *PIOS_BL_HELPER_FLASH_If_Read(adr + x); + } + return true; + break; + default: + return false; + } +} diff --git a/flight/Bootloaders/OSD/pios_board.c b/flight/Bootloaders/OSD/pios_board.c index a89f83103..463c745f6 100644 --- a/flight/Bootloaders/OSD/pios_board.c +++ b/flight/Bootloaders/OSD/pios_board.c @@ -23,6 +23,13 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +/* Pull in the board-specific static HW definitions. + * Including .c files is a bit ugly but this allows all of + * the HW definitions to be const and static to limit their + * scope. + * + * NOTE: THIS IS THE ONLY PLACE THAT SHOULD EVER INCLUDE THIS FILE + */ #include "board_hw_defs.c" #include @@ -39,10 +46,11 @@ void PIOS_Board_Init() { /* Delay system */ PIOS_DELAY_Init(); +#if defined(PIOS_INCLUDE_LED) PIOS_LED_Init(&pios_led_cfg); +#endif /* PIOS_INCLUDE_LED */ - -#if 0 && defined(PIOS_INCLUDE_USB) +#if defined(PIOS_INCLUDE_USB) /* Initialize board specific USB data */ PIOS_USB_BOARD_DATA_Init(); diff --git a/flight/Modules/Osd/osdgen/inc/osdgen.h b/flight/Modules/Osd/osdgen/inc/osdgen.h index 6becace37..e7e98b1ad 100644 --- a/flight/Modules/Osd/osdgen/inc/osdgen.h +++ b/flight/Modules/Osd/osdgen/inc/osdgen.h @@ -10,9 +10,6 @@ #include "openpilot.h" -#include "xconvert.h" -#include "oem6x8.h" - int32_t osdgenInitialize(void); diff --git a/flight/OSD/Makefile b/flight/OSD/Makefile index 9c4e21b2a..6d7fea097 100644 --- a/flight/OSD/Makefile +++ b/flight/OSD/Makefile @@ -49,9 +49,13 @@ endif FLASH_TOOL = OPENOCD # List of modules to include -MODULES = Osd/osdgen GPS COTelemetry Telemetry #FirmwareIAP +MODULES = Osd/osdgen GPS + +MODULES += Osd/osdinput +#MODULES += COTelemetry +MODULES += Telemetry +MODULES += FirmwareIAP -#Osd/osdinput # Paths OPSYSTEM = ./System OPSYSTEMINC = $(OPSYSTEM)/inc @@ -448,7 +452,7 @@ $(OUTDIR)/$(TARGET).bin.o: $(OUTDIR)/$(TARGET).bin $(eval $(call OPFW_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(BOARD_TYPE),$(BOARD_REVISION))) # Add jtag targets (program and wipe) -$(eval $(call JTAG_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(FW_BANK_BASE),$(FW_BANK_SIZE),$(OPENOCD_CONFIG))) +$(eval $(call JTAG_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(FW_BANK_BASE),$(FW_BANK_SIZE),$(OPENOCD_JTAG_CONFIG),$(OPENOCD_CONFIG))) .PHONY: elf lss sym hex bin bino opfw elf: $(OUTDIR)/$(TARGET).elf diff --git a/flight/OSD/System/inc/font8x10.h b/flight/OSD/System/inc/font8x10.h index 731ad3d4f..621cf13af 100644 --- a/flight/OSD/System/inc/font8x10.h +++ b/flight/OSD/System/inc/font8x10.h @@ -9,7 +9,6 @@ #define FONT8X10_H_ static const uint8_t font_frame8x10[] = { - 0x00, 0x00, 0x00, diff --git a/flight/OSD/System/inc/font_outlined6x8.h b/flight/OSD/System/inc/font_outlined6x8.h deleted file mode 100644 index efaa2367a..000000000 --- a/flight/OSD/System/inc/font_outlined6x8.h +++ /dev/null @@ -1,1041 +0,0 @@ -#ifndef OEM6X8_H_ -#define OEM6X8_H_ - -// Credit for this goes to MegaPirateOSD and Syberian! -// Some minor changes made to fit my code better. - -#define CHAR_ARRAY_OFFSET 0 -#define CHAR_ARRAY_LENGTH 1024 -#define CHAR_ARRAY_MAX (CHAR_ARRAY_OFFSET + CHAR_ARRAY_LENGTH) - -#define CHAR_OFFSET CHAR_ARRAY_OFFSET/8 -#define CHAR_MAX CHAR_ARRAY_MAX/8 - -static const uint8_t oem6x8[CHAR_ARRAY_LENGTH] = { // 6x8 DOS character set -________, -________, -________, -________, -________, -________, -________, -________, -__XXX___, -_X___X__, -_XX_XX__, -_X___X__, -_X_X_X__, -_X___X__, -__XXX___, -________, -__XXX___, -_XXXXX__, -_X_X_X__, -_XXXXX__, -_X___X__, -_XXXXX__, -__XXX___, -________, -________, -__X_X___, -_XXXXX__, -_XXXXX__, -_XXXXX__, -__XXX___, -___X____, -________, -________, -___X____, -__XXX___, -_XXXXX__, -_XXXXX__, -__XXX___, -___X____, -________, -___X____, -__XXX___, -__XXX___, -___X____, -_XXXXX__, -_XXXXX__, -___X____, -________, -________, -___X____, -__XXX___, -_XXXXX__, -_XXXXX__, -___X____, -__XXX___, -________, -________, -________, -________, -__XX____, -__XX____, -________, -________, -________, -XXXXXX__, -XXXXXX__, -XXXXXX__, -XX__XX__, -XX__XX__, -XXXXXX__, -XXXXXX__, -XXXXXX__, -________, -________, -_XXXX___, -_X__X___, -_X__X___, -_XXXX___, -________, -________, -XXXXXX__, -XXXXXX__, -X____X__, -X_XX_X__, -X_XX_X__, -X____X__, -XXXXXX__, -XXXXXX__, -________, -___XXX__, -____XX__, -__XX_X__, -_X__X___, -_X__X___, -__XX____, -________, -__XXX___, -_X___X__, -_X___X__, -__XXX___, -___X____, -__XXX___, -___X____, -________, -___X____, -___XX___, -___X_X__, -___X____, -__XX____, -_XXX____, -_XX_____, -________, -____XX__, -__XX_X__, -__X_XX__, -__XX_X__, -__X_XX__, -_XX_XX__, -_XX_____, -________, -________, -_X_X_X__, -__XXX___, -_XX_XX__, -__XXX___, -_X_X_X__, -________, -________, -__X_____, -__XX____, -__XXX___, -__XXXX__, -__XXX___, -__XX____, -__X_____, -________, -____X___, -___XX___, -__XXX___, -_XXXX___, -__XXX___, -___XX___, -____X___, -________, -___X____, -__XXX___, -_XXXXX__, -___X____, -_XXXXX__, -__XXX___, -___X____, -________, -__X_X___, -__X_X___, -__X_X___, -__X_X___, -__X_X___, -________, -__X_X___, -________, -__XXXX__, -_X_X_X__, -_X_X_X__, -__XX_X__, -___X_X__, -___X_X__, -___X_X__, -________, -__XXX___, -_X___X__, -__XX____, -__X_X___, -___XX___, -_X___X__, -__XXX___, -________, -________, -________, -________, -________, -________, -_XXXX___, -_XXXX___, -________, -___X____, -__XXX___, -_XXXXX__, -___X____, -_XXXXX__, -__XXX___, -___X____, -__XXX___, -___X____, -__XXX___, -_XXXXX__, -___X____, -___X____, -___X____, -___X____, -________, -___X____, -___X____, -___X____, -___X____, -_XXXXX__, -__XXX___, -___X____, -________, -________, -___X____, -___XX___, -_XXXXX__, -___XX___, -___X____, -________, -________, -________, -___X____, -__XX____, -_XXXXX__, -__XX____, -___X____, -________, -________, -________, -________, -________, -_X______, -_X______, -_X______, -_XXXXX__, -________, -________, -__X_X___, -__X_X___, -_XXXXX__, -__X_X___, -__X_X___, -________, -________, -___X____, -___X____, -__XXX___, -__XXX___, -_XXXXX__, -_XXXXX__, -________, -________, -_XXXXX__, -_XXXXX__, -__XXX___, -__XXX___, -___X____, -___X____, -________, -________, -________, -________, -________, -________, -________, -________, -________, -________, -___X____, -__XXX___, -__XXX___, -___X____, -___X____, -________, -___X____, -________, -_XX_XX__, -_XX_XX__, -_X__X___, -________, -________, -________, -________, -________, -________, -__X_X___, -_XXXXX__, -__X_X___, -__X_X___, -_XXXXX__, -__X_X___, -________, -__X_____, -__XXX___, -_X______, -__XX____, -____X___, -_XXX____, -___X____, -________, -_XX__X__, -_XX__X__, -____X___, -___X____, -__X_____, -_X__XX__, -_X__XX__, -________, -__X_____, -_X_X____, -_X_X____, -__X_____, -_X_X_X__, -_X__X___, -__XX_X__, -________, -__XX____, -__XX____, -__X_____, -________, -________, -________, -________, -________, -___X____, -__X_____, -__X_____, -__X_____, -__X_____, -__X_____, -___X____, -________, -__X_____, -___X____, -___X____, -___X____, -___X____, -___X____, -__X_____, -________, -________, -__X_X___, -__XXX___, -_XXXXX__, -__XXX___, -__X_X___, -________, -________, -________, -___X____, -___X____, -_XXXXX__, -___X____, -___X____, -________, -________, -________, -________, -________, -________, -________, -__XX____, -__XX____, -__X_____, -________, -________, -________, -_XXXXX__, -________, -________, -________, -________, -________, -________, -________, -________, -________, -__XX____, -__XX____, -________, -________, -_____X__, -____X___, -___X____, -__X_____, -_X______, -________, -________, -__XXX___, -_X___X__, -_X__XX__, -_X_X_X__, -_XX__X__, -_X___X__, -__XXX___, -________, -___X____, -__XX____, -___X____, -___X____, -___X____, -___X____, -__XXX___, -________, -__XXX___, -_X___X__, -_____X__, -___XX___, -__X_____, -_X______, -_XXXXX__, -________, -__XXX___, -_X___X__, -_____X__, -__XXX___, -_____X__, -_X___X__, -__XXX___, -________, -____X___, -___XX___, -__X_X___, -_X__X___, -_XXXXX__, -____X___, -____X___, -________, -_XXXXX__, -_X______, -_X______, -_XXXX___, -_____X__, -_X___X__, -__XXX___, -________, -___XX___, -__X_____, -_X______, -_XXXX___, -_X___X__, -_X___X__, -__XXX___, -________, -_XXXXX__, -_____X__, -____X___, -___X____, -__X_____, -__X_____, -__X_____, -________, -__XXX___, -_X___X__, -_X___X__, -__XXX___, -_X___X__, -_X___X__, -__XXX___, -________, -__XXX___, -_X___X__, -_X___X__, -__XXXX__, -_____X__, -____X___, -__XX____, -________, -________, -________, -__XX____, -__XX____, -________, -__XX____, -__XX____, -________, -________, -________, -__XX____, -__XX____, -________, -__XX____, -__XX____, -__X_____, -____X___, -___X____, -__X_____, -_X______, -__X_____, -___X____, -____X___, -________, -________, -________, -_XXXXX__, -________, -________, -_XXXXX__, -________, -________, -__X_____, -___X____, -____X___, -_____X__, -____X___, -___X____, -__X_____, -________, -__XXX___, -_X___X__, -_____X__, -___XX___, -___X____, -________, -___X____, -________, -__XXX___, -_X___X__, -_X_XXX__, -_X_X_X__, -_X_XXX__, -_X______, -__XXX___, -________, -__XXX___, -_X___X__, -_X___X__, -_X___X__, -_XXXXX__, -_X___X__, -_X___X__, -________, -_XXXX___, -_X___X__, -_X___X__, -_XXXX___, -_X___X__, -_X___X__, -_XXXX___, -________, -__XXX___, -_X___X__, -_X______, -_X______, -_X______, -_X___X__, -__XXX___, -________, -_XXXX___, -_X___X__, -_X___X__, -_X___X__, -_X___X__, -_X___X__, -_XXXX___, -________, -_XXXXX__, -_X______, -_X______, -_XXXX___, -_X______, -_X______, -_XXXXX__, -________, -_XXXXX__, -_X______, -_X______, -_XXXX___, -_X______, -_X______, -_X______, -________, -__XXX___, -_X___X__, -_X______, -_X_XXX__, -_X___X__, -_X___X__, -__XXXX__, -________, -_X___X__, -_X___X__, -_X___X__, -_XXXXX__, -_X___X__, -_X___X__, -_X___X__, -________, -__XXX___, -___X____, -___X____, -___X____, -___X____, -___X____, -__XXX___, -________, -_____X__, -_____X__, -_____X__, -_____X__, -_X___X__, -_X___X__, -__XXX___, -________, -_X___X__, -_X__X___, -_X_X____, -_XX_____, -_X_X____, -_X__X___, -_X___X__, -________, -_X______, -_X______, -_X______, -_X______, -_X______, -_X______, -_XXXXX__, -________, -_X___X__, -_XX_XX__, -_X_X_X__, -_X___X__, -_X___X__, -_X___X__, -_X___X__, -________, -_X___X__, -_XX__X__, -_X_X_X__, -_X__XX__, -_X___X__, -_X___X__, -_X___X__, -________, -__XXX___, -_X___X__, -_X___X__, -_X___X__, -_X___X__, -_X___X__, -__XXX___, -________, -_XXXX___, -_X___X__, -_X___X__, -_XXXX___, -_X______, -_X______, -_X______, -________, -__XXX___, -_X___X__, -_X___X__, -_X___X__, -_X_X_X__, -_X__X___, -__XX_X__, -________, -_XXXX___, -_X___X__, -_X___X__, -_XXXX___, -_X__X___, -_X___X__, -_X___X__, -________, -__XXX___, -_X___X__, -_X______, -__XXX___, -_____X__, -_X___X__, -__XXX___, -________, -_XXXXX__, -___X____, -___X____, -___X____, -___X____, -___X____, -___X____, -________, -_X___X__, -_X___X__, -_X___X__, -_X___X__, -_X___X__, -_X___X__, -__XXX___, -________, -_X___X__, -_X___X__, -_X___X__, -_X___X__, -_X___X__, -__X_X___, -___X____, -________, -_X___X__, -_X___X__, -_X_X_X__, -_X_X_X__, -_X_X_X__, -_X_X_X__, -__X_X___, -________, -_X___X__, -_X___X__, -__X_X___, -___X____, -__X_X___, -_X___X__, -_X___X__, -________, -_X___X__, -_X___X__, -_X___X__, -__X_X___, -___X____, -___X____, -___X____, -________, -_XXXX___, -____X___, -___X____, -__X_____, -_X______, -_X______, -_XXXX___, -________, -__XXX___, -__X_____, -__X_____, -__X_____, -__X_____, -__X_____, -__XXX___, -________, -________, -_X______, -__X_____, -___X____, -____X___, -_____X__, -________, -________, -__XXX___, -____X___, -____X___, -____X___, -____X___, -____X___, -__XXX___, -________, -___X____, -__X_X___, -_X___X__, -________, -________, -________, -________, -________, -________, -________, -________, -________, -________, -________, -________, -XXXXXX__, -__XX____, -__XX____, -___X____, -________, -________, -________, -________, -________, -________, -________, -__XXX___, -_____X__, -__XXXX__, -_X___X__, -__XXXX__, -________, -_X______, -_X______, -_XXXX___, -_X___X__, -_X___X__, -_X___X__, -_XXXX___, -________, -________, -________, -__XXX___, -_X___X__, -_X______, -_X___X__, -__XXX___, -________, -_____X__, -_____X__, -__XXXX__, -_X___X__, -_X___X__, -_X___X__, -__XXXX__, -________, -________, -________, -__XXX___, -_X___X__, -_XXXX___, -_X______, -__XXX___, -________, -___XX___, -__X_____, -__X_____, -_XXXX___, -__X_____, -__X_____, -__X_____, -________, -________, -________, -__XXXX__, -_X___X__, -_X___X__, -__XXXX__, -_____X__, -__XXX___, -_X______, -_X______, -_XXX____, -_X__X___, -_X__X___, -_X__X___, -_X__X___, -________, -___X____, -________, -___X____, -___X____, -___X____, -___X____, -___XX___, -________, -____X___, -________, -___XX___, -____X___, -____X___, -____X___, -_X__X___, -__XX____, -_X______, -_X______, -_X__X___, -_X_X____, -_XX_____, -_X_X____, -_X__X___, -________, -___X____, -___X____, -___X____, -___X____, -___X____, -___X____, -___XX___, -________, -________, -________, -_XX_X___, -_X_X_X__, -_X_X_X__, -_X___X__, -_X___X__, -________, -________, -________, -_XXX____, -_X__X___, -_X__X___, -_X__X___, -_X__X___, -________, -________, -________, -__XXX___, -_X___X__, -_X___X__, -_X___X__, -__XXX___, -________, -________, -________, -_XXXX___, -_X___X__, -_X___X__, -_X___X__, -_XXXX___, -_X______, -________, -________, -__XXXX__, -_X___X__, -_X___X__, -_X___X__, -__XXXX__, -_____X__, -________, -________, -_X_XX___, -__X__X__, -__X_____, -__X_____, -_XXX____, -________, -________, -________, -__XXX___, -_X______, -__XXX___, -_____X__, -__XXX___, -________, -________, -__X_____, -_XXXX___, -__X_____, -__X_____, -__X_X___, -___X____, -________, -________, -________, -_X__X___, -_X__X___, -_X__X___, -_X_XX___, -__X_X___, -________, -________, -________, -_X___X__, -_X___X__, -_X___X__, -__X_X___, -___X____, -________, -________, -________, -_X___X__, -_X___X__, -_X_X_X__, -_XXXXX__, -__X_X___, -________, -________, -________, -_X__X___, -_X__X___, -__XX____, -_X__X___, -_X__X___, -________, -________, -________, -_X__X___, -_X__X___, -_X__X___, -__XXX___, -___X____, -_XX_____, -________, -________, -_XXXX___, -____X___, -__XX____, -_X______, -_XXXX___, -________, -___XX___, -__X_____, -__X_____, -_XX_____, -__X_____, -__X_____, -___XX___, -________, -___X____, -___X____, -___X____, -________, -___X____, -___X____, -___X____, -________, -__XX____, -____X___, -____X___, -____XX__, -____X___, -____X___, -__XX____, -________, -__X_X___, -_X_X____, -________, -________, -________, -________, -________, -________, -___X____, -__XXX___, -_XX_XX__, -_X___X__, -_X___X__, -_XXXXX__, -________, -________ -}; - -#endif //OEM6X8_H_ diff --git a/flight/OSD/System/inc/oem6x8.h b/flight/OSD/System/inc/oem6x8.h deleted file mode 100644 index efaa2367a..000000000 --- a/flight/OSD/System/inc/oem6x8.h +++ /dev/null @@ -1,1041 +0,0 @@ -#ifndef OEM6X8_H_ -#define OEM6X8_H_ - -// Credit for this goes to MegaPirateOSD and Syberian! -// Some minor changes made to fit my code better. - -#define CHAR_ARRAY_OFFSET 0 -#define CHAR_ARRAY_LENGTH 1024 -#define CHAR_ARRAY_MAX (CHAR_ARRAY_OFFSET + CHAR_ARRAY_LENGTH) - -#define CHAR_OFFSET CHAR_ARRAY_OFFSET/8 -#define CHAR_MAX CHAR_ARRAY_MAX/8 - -static const uint8_t oem6x8[CHAR_ARRAY_LENGTH] = { // 6x8 DOS character set -________, -________, -________, -________, -________, -________, -________, -________, -__XXX___, -_X___X__, -_XX_XX__, -_X___X__, -_X_X_X__, -_X___X__, -__XXX___, -________, -__XXX___, -_XXXXX__, -_X_X_X__, -_XXXXX__, -_X___X__, -_XXXXX__, -__XXX___, -________, -________, -__X_X___, -_XXXXX__, -_XXXXX__, -_XXXXX__, -__XXX___, -___X____, -________, -________, -___X____, -__XXX___, -_XXXXX__, -_XXXXX__, -__XXX___, -___X____, -________, -___X____, -__XXX___, -__XXX___, -___X____, -_XXXXX__, -_XXXXX__, -___X____, -________, -________, -___X____, -__XXX___, -_XXXXX__, -_XXXXX__, -___X____, -__XXX___, -________, -________, -________, -________, -__XX____, -__XX____, -________, -________, -________, -XXXXXX__, -XXXXXX__, -XXXXXX__, -XX__XX__, -XX__XX__, -XXXXXX__, -XXXXXX__, -XXXXXX__, -________, -________, -_XXXX___, -_X__X___, -_X__X___, -_XXXX___, -________, -________, -XXXXXX__, -XXXXXX__, -X____X__, -X_XX_X__, -X_XX_X__, -X____X__, -XXXXXX__, -XXXXXX__, -________, -___XXX__, -____XX__, -__XX_X__, -_X__X___, -_X__X___, -__XX____, -________, -__XXX___, -_X___X__, -_X___X__, -__XXX___, -___X____, -__XXX___, -___X____, -________, -___X____, -___XX___, -___X_X__, -___X____, -__XX____, -_XXX____, -_XX_____, -________, -____XX__, -__XX_X__, -__X_XX__, -__XX_X__, -__X_XX__, -_XX_XX__, -_XX_____, -________, -________, -_X_X_X__, -__XXX___, -_XX_XX__, -__XXX___, -_X_X_X__, -________, -________, -__X_____, -__XX____, -__XXX___, -__XXXX__, -__XXX___, -__XX____, -__X_____, -________, -____X___, -___XX___, -__XXX___, -_XXXX___, -__XXX___, -___XX___, -____X___, -________, -___X____, -__XXX___, -_XXXXX__, -___X____, -_XXXXX__, -__XXX___, -___X____, -________, -__X_X___, -__X_X___, -__X_X___, -__X_X___, -__X_X___, -________, -__X_X___, -________, -__XXXX__, -_X_X_X__, -_X_X_X__, -__XX_X__, -___X_X__, -___X_X__, -___X_X__, -________, -__XXX___, -_X___X__, -__XX____, -__X_X___, -___XX___, -_X___X__, -__XXX___, -________, -________, -________, -________, -________, -________, -_XXXX___, -_XXXX___, -________, -___X____, -__XXX___, -_XXXXX__, -___X____, -_XXXXX__, -__XXX___, -___X____, -__XXX___, -___X____, -__XXX___, -_XXXXX__, -___X____, -___X____, -___X____, -___X____, -________, -___X____, -___X____, -___X____, -___X____, -_XXXXX__, -__XXX___, -___X____, -________, -________, -___X____, -___XX___, -_XXXXX__, -___XX___, -___X____, -________, -________, -________, -___X____, -__XX____, -_XXXXX__, -__XX____, -___X____, -________, -________, -________, -________, -________, -_X______, -_X______, -_X______, -_XXXXX__, -________, -________, -__X_X___, -__X_X___, -_XXXXX__, -__X_X___, -__X_X___, -________, -________, -___X____, -___X____, -__XXX___, -__XXX___, -_XXXXX__, -_XXXXX__, -________, -________, -_XXXXX__, -_XXXXX__, -__XXX___, -__XXX___, -___X____, -___X____, -________, -________, -________, -________, -________, -________, -________, -________, -________, -________, -___X____, -__XXX___, -__XXX___, -___X____, -___X____, -________, -___X____, -________, -_XX_XX__, -_XX_XX__, -_X__X___, -________, -________, -________, -________, -________, -________, -__X_X___, -_XXXXX__, -__X_X___, -__X_X___, -_XXXXX__, -__X_X___, -________, -__X_____, -__XXX___, -_X______, -__XX____, -____X___, -_XXX____, -___X____, -________, -_XX__X__, -_XX__X__, -____X___, -___X____, -__X_____, -_X__XX__, -_X__XX__, -________, -__X_____, -_X_X____, -_X_X____, -__X_____, -_X_X_X__, -_X__X___, -__XX_X__, -________, -__XX____, -__XX____, -__X_____, -________, -________, -________, -________, -________, -___X____, -__X_____, -__X_____, -__X_____, -__X_____, -__X_____, -___X____, -________, -__X_____, -___X____, -___X____, -___X____, -___X____, -___X____, -__X_____, -________, -________, -__X_X___, -__XXX___, -_XXXXX__, -__XXX___, -__X_X___, -________, -________, -________, -___X____, -___X____, -_XXXXX__, -___X____, -___X____, -________, -________, -________, -________, -________, -________, -________, -__XX____, -__XX____, -__X_____, -________, -________, -________, -_XXXXX__, -________, -________, -________, -________, -________, -________, -________, -________, -________, -__XX____, -__XX____, -________, -________, -_____X__, -____X___, -___X____, -__X_____, -_X______, -________, -________, -__XXX___, -_X___X__, -_X__XX__, -_X_X_X__, -_XX__X__, -_X___X__, -__XXX___, -________, -___X____, -__XX____, -___X____, -___X____, -___X____, -___X____, -__XXX___, -________, -__XXX___, -_X___X__, -_____X__, -___XX___, -__X_____, -_X______, -_XXXXX__, -________, -__XXX___, -_X___X__, -_____X__, -__XXX___, -_____X__, -_X___X__, -__XXX___, -________, -____X___, -___XX___, -__X_X___, -_X__X___, -_XXXXX__, -____X___, -____X___, -________, -_XXXXX__, -_X______, -_X______, -_XXXX___, -_____X__, -_X___X__, -__XXX___, -________, -___XX___, -__X_____, -_X______, -_XXXX___, -_X___X__, -_X___X__, -__XXX___, -________, -_XXXXX__, -_____X__, -____X___, -___X____, -__X_____, -__X_____, -__X_____, -________, -__XXX___, -_X___X__, -_X___X__, -__XXX___, -_X___X__, -_X___X__, -__XXX___, -________, -__XXX___, -_X___X__, -_X___X__, -__XXXX__, -_____X__, -____X___, -__XX____, -________, -________, -________, -__XX____, -__XX____, -________, -__XX____, -__XX____, -________, -________, -________, -__XX____, -__XX____, -________, -__XX____, -__XX____, -__X_____, -____X___, -___X____, -__X_____, -_X______, -__X_____, -___X____, -____X___, -________, -________, -________, -_XXXXX__, -________, -________, -_XXXXX__, -________, -________, -__X_____, -___X____, -____X___, -_____X__, -____X___, -___X____, -__X_____, -________, -__XXX___, -_X___X__, -_____X__, -___XX___, -___X____, -________, -___X____, -________, -__XXX___, -_X___X__, -_X_XXX__, -_X_X_X__, -_X_XXX__, -_X______, -__XXX___, -________, -__XXX___, -_X___X__, -_X___X__, -_X___X__, -_XXXXX__, -_X___X__, -_X___X__, -________, -_XXXX___, -_X___X__, -_X___X__, -_XXXX___, -_X___X__, -_X___X__, -_XXXX___, -________, -__XXX___, -_X___X__, -_X______, -_X______, -_X______, -_X___X__, -__XXX___, -________, -_XXXX___, -_X___X__, -_X___X__, -_X___X__, -_X___X__, -_X___X__, -_XXXX___, -________, -_XXXXX__, -_X______, -_X______, -_XXXX___, -_X______, -_X______, -_XXXXX__, -________, -_XXXXX__, -_X______, -_X______, -_XXXX___, -_X______, -_X______, -_X______, -________, -__XXX___, -_X___X__, -_X______, -_X_XXX__, -_X___X__, -_X___X__, -__XXXX__, -________, -_X___X__, -_X___X__, -_X___X__, -_XXXXX__, -_X___X__, -_X___X__, -_X___X__, -________, -__XXX___, -___X____, -___X____, -___X____, -___X____, -___X____, -__XXX___, -________, -_____X__, -_____X__, -_____X__, -_____X__, -_X___X__, -_X___X__, -__XXX___, -________, -_X___X__, -_X__X___, -_X_X____, -_XX_____, -_X_X____, -_X__X___, -_X___X__, -________, -_X______, -_X______, -_X______, -_X______, -_X______, -_X______, -_XXXXX__, -________, -_X___X__, -_XX_XX__, -_X_X_X__, -_X___X__, -_X___X__, -_X___X__, -_X___X__, -________, -_X___X__, -_XX__X__, -_X_X_X__, -_X__XX__, -_X___X__, -_X___X__, -_X___X__, -________, -__XXX___, -_X___X__, -_X___X__, -_X___X__, -_X___X__, -_X___X__, -__XXX___, -________, -_XXXX___, -_X___X__, -_X___X__, -_XXXX___, -_X______, -_X______, -_X______, -________, -__XXX___, -_X___X__, -_X___X__, -_X___X__, -_X_X_X__, -_X__X___, -__XX_X__, -________, -_XXXX___, -_X___X__, -_X___X__, -_XXXX___, -_X__X___, -_X___X__, -_X___X__, -________, -__XXX___, -_X___X__, -_X______, -__XXX___, -_____X__, -_X___X__, -__XXX___, -________, -_XXXXX__, -___X____, -___X____, -___X____, -___X____, -___X____, -___X____, -________, -_X___X__, -_X___X__, -_X___X__, -_X___X__, -_X___X__, -_X___X__, -__XXX___, -________, -_X___X__, -_X___X__, -_X___X__, -_X___X__, -_X___X__, -__X_X___, -___X____, -________, -_X___X__, -_X___X__, -_X_X_X__, -_X_X_X__, -_X_X_X__, -_X_X_X__, -__X_X___, -________, -_X___X__, -_X___X__, -__X_X___, -___X____, -__X_X___, -_X___X__, -_X___X__, -________, -_X___X__, -_X___X__, -_X___X__, -__X_X___, -___X____, -___X____, -___X____, -________, -_XXXX___, -____X___, -___X____, -__X_____, -_X______, -_X______, -_XXXX___, -________, -__XXX___, -__X_____, -__X_____, -__X_____, -__X_____, -__X_____, -__XXX___, -________, -________, -_X______, -__X_____, -___X____, -____X___, -_____X__, -________, -________, -__XXX___, -____X___, -____X___, -____X___, -____X___, -____X___, -__XXX___, -________, -___X____, -__X_X___, -_X___X__, -________, -________, -________, -________, -________, -________, -________, -________, -________, -________, -________, -________, -XXXXXX__, -__XX____, -__XX____, -___X____, -________, -________, -________, -________, -________, -________, -________, -__XXX___, -_____X__, -__XXXX__, -_X___X__, -__XXXX__, -________, -_X______, -_X______, -_XXXX___, -_X___X__, -_X___X__, -_X___X__, -_XXXX___, -________, -________, -________, -__XXX___, -_X___X__, -_X______, -_X___X__, -__XXX___, -________, -_____X__, -_____X__, -__XXXX__, -_X___X__, -_X___X__, -_X___X__, -__XXXX__, -________, -________, -________, -__XXX___, -_X___X__, -_XXXX___, -_X______, -__XXX___, -________, -___XX___, -__X_____, -__X_____, -_XXXX___, -__X_____, -__X_____, -__X_____, -________, -________, -________, -__XXXX__, -_X___X__, -_X___X__, -__XXXX__, -_____X__, -__XXX___, -_X______, -_X______, -_XXX____, -_X__X___, -_X__X___, -_X__X___, -_X__X___, -________, -___X____, -________, -___X____, -___X____, -___X____, -___X____, -___XX___, -________, -____X___, -________, -___XX___, -____X___, -____X___, -____X___, -_X__X___, -__XX____, -_X______, -_X______, -_X__X___, -_X_X____, -_XX_____, -_X_X____, -_X__X___, -________, -___X____, -___X____, -___X____, -___X____, -___X____, -___X____, -___XX___, -________, -________, -________, -_XX_X___, -_X_X_X__, -_X_X_X__, -_X___X__, -_X___X__, -________, -________, -________, -_XXX____, -_X__X___, -_X__X___, -_X__X___, -_X__X___, -________, -________, -________, -__XXX___, -_X___X__, -_X___X__, -_X___X__, -__XXX___, -________, -________, -________, -_XXXX___, -_X___X__, -_X___X__, -_X___X__, -_XXXX___, -_X______, -________, -________, -__XXXX__, -_X___X__, -_X___X__, -_X___X__, -__XXXX__, -_____X__, -________, -________, -_X_XX___, -__X__X__, -__X_____, -__X_____, -_XXX____, -________, -________, -________, -__XXX___, -_X______, -__XXX___, -_____X__, -__XXX___, -________, -________, -__X_____, -_XXXX___, -__X_____, -__X_____, -__X_X___, -___X____, -________, -________, -________, -_X__X___, -_X__X___, -_X__X___, -_X_XX___, -__X_X___, -________, -________, -________, -_X___X__, -_X___X__, -_X___X__, -__X_X___, -___X____, -________, -________, -________, -_X___X__, -_X___X__, -_X_X_X__, -_XXXXX__, -__X_X___, -________, -________, -________, -_X__X___, -_X__X___, -__XX____, -_X__X___, -_X__X___, -________, -________, -________, -_X__X___, -_X__X___, -_X__X___, -__XXX___, -___X____, -_XX_____, -________, -________, -_XXXX___, -____X___, -__XX____, -_X______, -_XXXX___, -________, -___XX___, -__X_____, -__X_____, -_XX_____, -__X_____, -__X_____, -___XX___, -________, -___X____, -___X____, -___X____, -________, -___X____, -___X____, -___X____, -________, -__XX____, -____X___, -____X___, -____XX__, -____X___, -____X___, -__XX____, -________, -__X_X___, -_X_X____, -________, -________, -________, -________, -________, -________, -___X____, -__XXX___, -_XX_XX__, -_X___X__, -_X___X__, -_XXXXX__, -________, -________ -}; - -#endif //OEM6X8_H_ diff --git a/flight/OSD/System/inc/oposd.h b/flight/OSD/System/inc/oposd.h deleted file mode 100644 index b1efc1fce..000000000 --- a/flight/OSD/System/inc/oposd.h +++ /dev/null @@ -1,74 +0,0 @@ -/** - ****************************************************************************** - * - * @file main.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief Main modem header. - * @see The GNU Public License (GPL) Version 3 - * - *****************************************************************************/ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#ifndef __MAIN_H__ -#define __MAIN_H__ - -#include - -// ***************************************************************************** - -// firmware version -#define VERSION_MAJOR 0 // 0 to 255 -#define VERSION_MINOR 9 // 0 to 255 - -// macro's for reading internal flash memory -#define mem8(addr) (*((volatile uint8_t *)(addr))) -#define mem16(addr) (*((volatile uint16_t *)(addr))) -#define mem32(addr) (*((volatile uint32_t *)(addr))) - -enum { - FREQBAND_UNKNOWN = 0, - FREQBAND_434MHz, - FREQBAND_868MHz, - FREQBAND_915MHz -}; - -enum { - MODE_NORMAL = 0, // normal 2-way packet mode - MODE_STREAM_TX, // 1-way continuous tx packet mode - MODE_STREAM_RX, // 1-way continuous rx packet mode - MODE_PPM_TX, // PPM tx mode - MODE_PPM_RX, // PPM rx mode - MODE_SCAN_SPECTRUM, // scan the receiver over the whole band - MODE_TX_BLANK_CARRIER_TEST, // blank carrier Tx mode (for calibrating the carrier frequency say) - MODE_TX_SPECTRUM_TEST // pseudo random Tx data mode (for checking the Tx carrier spectrum) -}; - -// ***************************************************************************** - -extern volatile uint32_t random32; - -extern bool booting; - -extern uint32_t flash_size; - -extern char serial_number_str[25]; -extern uint32_t serial_number_crc32; - -// ***************************************************************************** - -#endif diff --git a/flight/OSD/System/inc/pios_board_posix.h b/flight/OSD/System/inc/pios_board_posix.h deleted file mode 100644 index 741f36ba7..000000000 --- a/flight/OSD/System/inc/pios_board_posix.h +++ /dev/null @@ -1,84 +0,0 @@ -/** - ****************************************************************************** - * - * @file pios_board.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief Defines board hardware for the OpenPilot Version 1.1 hardware. - * @see The GNU Public License (GPL) Version 3 - * - *****************************************************************************/ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#ifndef PIOS_BOARD_H -#define PIOS_BOARD_H - - - - -//------------------------ -// PIOS_LED -//------------------------ -//#define PIOS_LED_LED1_GPIO_PORT GPIOC -//#define PIOS_LED_LED1_GPIO_PIN GPIO_Pin_12 -//#define PIOS_LED_LED1_GPIO_CLK RCC_APB2Periph_GPIOC -//#define PIOS_LED_LED2_GPIO_PORT GPIOC -//#define PIOS_LED_LED2_GPIO_PIN GPIO_Pin_13 -//#define PIOS_LED_LED2_GPIO_CLK RCC_APB2Periph_GPIOC -#define PIOS_LED_NUM 2 -//#define PIOS_LED_PORTS { PIOS_LED_LED1_GPIO_PORT, PIOS_LED_LED2_GPIO_PORT } -//#define PIOS_LED_PINS { PIOS_LED_LED1_GPIO_PIN, PIOS_LED_LED2_GPIO_PIN } -//#define PIOS_LED_CLKS { PIOS_LED_LED1_GPIO_CLK, PIOS_LED_LED2_GPIO_CLK } - - -//------------------------- -// COM -// -// See also pios_board_posix.c -//------------------------- -//#define PIOS_USART_TX_BUFFER_SIZE 256 -#define PIOS_COM_BUFFER_SIZE 1024 -#define PIOS_UDP_RX_BUFFER_SIZE PIOS_COM_BUFFER_SIZE - -#define PIOS_COM_TELEM_RF 0 -#define PIOS_COM_GPS 1 -#define PIOS_COM_TELEM_USB 2 - -#ifdef PIOS_ENABLE_AUX_UART -#define PIOS_COM_AUX 3 -#define PIOS_COM_DEBUG PIOS_COM_AUX -#endif - -/** - * glue macros for file IO - * STM32 uses DOSFS for file IO - */ -#define PIOS_FOPEN_READ(filename,file) (file=fopen((char*)filename,"r"))==NULL - -#define PIOS_FOPEN_WRITE(filename,file) (file=fopen((char*)filename,"w"))==NULL - -#define PIOS_FREAD(file,bufferadr,length,resultadr) (*resultadr=fread((uint8_t*)bufferadr,1,length,*file)) != length - -#define PIOS_FWRITE(file,bufferadr,length,resultadr) *resultadr=fwrite((uint8_t*)bufferadr,1,length,*file) - - - -#define PIOS_FCLOSE(file) fclose(file) - -#define PIOS_FUNLINK(file) unlink((char*)filename) - -#endif /* PIOS_BOARD_H */ diff --git a/flight/OSD/System/inc/pios_config.h b/flight/OSD/System/inc/pios_config.h index cbf5e5df5..8a7af6520 100644 --- a/flight/OSD/System/inc/pios_config.h +++ b/flight/OSD/System/inc/pios_config.h @@ -28,32 +28,48 @@ #ifndef PIOS_CONFIG_H #define PIOS_CONFIG_H -/* Enable/Disable PiOS Modules */ -#define PIOS_INCLUDE_ADC -#define PIOS_INCLUDE_DELAY -#define PIOS_INCLUDE_IRQ -#define PIOS_INCLUDE_LED -#define PIOS_INCLUDE_IAP -//#define PIOS_INCLUDE_SPI -#define PIOS_INCLUDE_SYS -#define PIOS_INCLUDE_USART -#define PIOS_INCLUDE_COM +/* Major features */ #define PIOS_INCLUDE_FREERTOS #define PIOS_INCLUDE_BL_HELPER +/* Enable/Disable PiOS Modules */ +#define PIOS_INCLUDE_ADC +#define PIOS_INCLUDE_DELAY +//#define PIOS_INCLUDE_I2C +#define PIOS_INCLUDE_IRQ +#define PIOS_INCLUDE_LED +#define PIOS_INCLUDE_IAP +//#define PIOS_INCLUDE_SERVO +//#define PIOS_INCLUDE_SPI +#define PIOS_INCLUDE_SYS +#define PIOS_INCLUDE_USART //#define PIOS_INCLUDE_GPIO -#define PIOS_INCLUDE_EXTI #define PIOS_INCLUDE_USB #define PIOS_INCLUDE_USB_HID +#define PIOS_INCLUDE_EXTI #define PIOS_INCLUDE_RTC +#define PIOS_INCLUDE_WDG #define PIOS_INCLUDE_VIDEO -//#define PIOS_INCLUDE_WDG /* Com systems to include */ #define PIOS_INCLUDE_COM #define PIOS_INCLUDE_COM_TELEM +//#define PIOS_INCLUDE_COM_AUX #define PIOS_INCLUDE_GPS +//#define PIOS_OVERO_SPI +/* Supported receiver interfaces */ +//#define PIOS_INCLUDE_RCVR +//#define PIOS_INCLUDE_DSM +//#define PIOS_INCLUDE_SBUS +//#define PIOS_INCLUDE_PPM +//#define PIOS_INCLUDE_PWM +//#define PIOS_INCLUDE_GCSRCVR + +//#define PIOS_INCLUDE_SETTINGS +//#define PIOS_INCLUDE_FLASH +/* A really shitty setting saving implementation */ +//#define PIOS_INCLUDE_FLASH_SECTOR_SETTINGS #define PIOS_INCLUDE_INITCALL /* Include init call structures */ #define PIOS_TELEM_PRIORITY_QUEUE /* Enable a priority queue in telemetry */ diff --git a/flight/OSD/System/inc/pios_config_posix.h b/flight/OSD/System/inc/pios_config_posix.h deleted file mode 100644 index ddf7ee5d4..000000000 --- a/flight/OSD/System/inc/pios_config_posix.h +++ /dev/null @@ -1,54 +0,0 @@ -/** - ****************************************************************************** - * - * @file pios_config.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief PiOS configuration header. - * Central compile time config for the project. - * @see The GNU Public License (GPL) Version 3 - * - *****************************************************************************/ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#ifndef PIOS_CONFIG_POSIX_H -#define PIOS_CONFIG_POSIX_H - - -/* Enable/Disable PiOS Modules */ -#define PIOS_INCLUDE_SYS -#define PIOS_INCLUDE_DELAY -#define PIOS_INCLUDE_LED -#define PIOS_INCLUDE_SDCARD -#define PIOS_INCLUDE_FREERTOS -#define PIOS_INCLUDE_COM -#define PIOS_INCLUDE_UDP -#define PIOS_INCLUDE_SERVO - - -/* Defaults for Logging */ -#define LOG_FILENAME "PIOS.LOG" -#define STARTUP_LOG_ENABLED 1 - -/* COM Module */ -#define GPS_BAUDRATE 19200 -#define TELEM_BAUDRATE 19200 -#define AUXUART_ENABLED 0 -#define AUXUART_BAUDRATE 19200 - - -#endif /* PIOS_CONFIG_POSIX_H */ diff --git a/flight/OSD/System/inc/pios_usb_hid_desc.h b/flight/OSD/System/inc/pios_usb_hid_desc.h deleted file mode 100644 index 4810c1274..000000000 --- a/flight/OSD/System/inc/pios_usb_hid_desc.h +++ /dev/null @@ -1,56 +0,0 @@ -/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** -* File Name : usb_desc.h -* Author : MCD Application Team -* Version : V3.2.1 -* Date : 07/05/2010 -* Description : Descriptor Header for Custom HID Demo -******************************************************************************** -* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS -* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. -* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, -* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE -* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING -* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. -*******************************************************************************/ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __USB_DESC_H -#define __USB_DESC_H - -/* Includes ------------------------------------------------------------------*/ -/* Exported types ------------------------------------------------------------*/ -/* Exported constants --------------------------------------------------------*/ -/* Exported macro ------------------------------------------------------------*/ -/* Exported define -----------------------------------------------------------*/ -#define USB_DEVICE_DESCRIPTOR_TYPE 0x01 -#define USB_CONFIGURATION_DESCRIPTOR_TYPE 0x02 -#define USB_STRING_DESCRIPTOR_TYPE 0x03 -#define USB_INTERFACE_DESCRIPTOR_TYPE 0x04 -#define USB_ENDPOINT_DESCRIPTOR_TYPE 0x05 - -#define HID_DESCRIPTOR_TYPE 0x21 -#define PIOS_HID_SIZ_HID_DESC 0x09 -#define PIOS_HID_OFF_HID_DESC 0x12 - -#define PIOS_HID_SIZ_DEVICE_DESC 18 -#define PIOS_HID_SIZ_CONFIG_DESC 41 -#define PIOS_HID_SIZ_REPORT_DESC 36 -#define PIOS_HID_SIZ_STRING_LANGID 4 -#define PIOS_HID_SIZ_STRING_VENDOR 28 -#define PIOS_HID_SIZ_STRING_PRODUCT 20 -#define PIOS_HID_SIZ_STRING_SERIAL 52 /* 96 bits, 12 bytes, 24 characters, 48 in unicode */ - -#define STANDARD_ENDPOINT_DESC_SIZE 0x09 - -/* Exported functions ------------------------------------------------------- */ -extern const uint8_t PIOS_HID_DeviceDescriptor[PIOS_HID_SIZ_DEVICE_DESC]; -extern const uint8_t PIOS_HID_ConfigDescriptor[PIOS_HID_SIZ_CONFIG_DESC]; -extern const uint8_t PIOS_HID_ReportDescriptor[PIOS_HID_SIZ_REPORT_DESC]; -extern const uint8_t PIOS_HID_StringLangID[PIOS_HID_SIZ_STRING_LANGID]; -extern const uint8_t PIOS_HID_StringVendor[PIOS_HID_SIZ_STRING_VENDOR]; -extern const uint8_t PIOS_HID_StringProduct[PIOS_HID_SIZ_STRING_PRODUCT]; -extern uint8_t PIOS_HID_StringSerial[PIOS_HID_SIZ_STRING_SERIAL]; - -#endif /* __USB_DESC_H */ - -/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/ diff --git a/flight/OSD/System/inc/pios_usssb.h b/flight/OSD/System/inc/pios_usssb.h deleted file mode 100644 index bab436469..000000000 --- a/flight/OSD/System/inc/pios_usssb.h +++ /dev/null @@ -1,79 +0,0 @@ -/** - ****************************************************************************** - * @addtogroup PIOS PIOS Core hardware abstraction layer - * @{ - * @addtogroup PIOS_USB USB Functions - * @brief PIOS USB interface code - * @{ - * - * @file pios_usb.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * Parts by Thorsten Klose (tk@midibox.org) - * @brief USB functions header. - * @see The GNU Public License (GPL) Version 3 - * - *****************************************************************************/ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef PIOS_USB_H -#define PIOS_USB_H - -/* Local defines */ -/* Following settings allow to customise the USB device descriptor */ -#ifndef PIOS_USB_VENDOR_ID -#define PIOS_USB_VENDOR_ID 0x20A0 -#endif - - -#ifndef PIOS_USB_PRODUCT_ID -#define PIOS_USB_PRODUCT_ID 0x415C // PipXtreme PID -#endif - -#ifndef PIOS_USB_VERSION_ID -#define PIOS_USB_VERSION_ID 0x0302 // PipXtreme, board revision 1, Running state (02) -#endif - -/* Internal defines which are used by PIOS USB HID (don't touch) */ -#define PIOS_USB_EP_NUM 2 - -/* Buffer table base address */ -#define PIOS_USB_BTABLE_ADDRESS 0x000 - -/* EP0 rx/tx buffer base address */ -#define PIOS_USB_ENDP0_RXADDR 0x040 -#define PIOS_USB_ENDP0_TXADDR 0x080 - -/* EP1 Rx/Tx buffer base address for HID driver */ -#define PIOS_USB_ENDP1_TXADDR 0x0C0 -#define PIOS_USB_ENDP1_RXADDR 0x100 - - -/* Global Variables */ -extern void (*pEpInt_IN[7])(void); -extern void (*pEpInt_OUT[7])(void); - -/* Public Functions */ -extern int32_t PIOS_USB_Init(uint32_t mode); -extern int32_t PIOS_USB_IsInitialized(void); -extern int32_t PIOS_USB_CableConnected(void); - -#endif /* PIOS_USB_H */ - -/** - * @} - * @} - */ diff --git a/flight/OSD/System/inc/usb_conf.h b/flight/OSD/System/inc/usb_conf.h deleted file mode 100644 index 913060c7f..000000000 --- a/flight/OSD/System/inc/usb_conf.h +++ /dev/null @@ -1,186 +0,0 @@ -/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** -* File Name : usb_conf.h -* Author : MCD Application Team -* Version : V3.2.1 -* Date : 07/05/2010 -* Description : Custom HID demo configuration file -******************************************************************************** -* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS -* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. -* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, -* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE -* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING -* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. -*******************************************************************************/ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __USB_CONF_H -#define __USB_CONF_H - -/* Includes ------------------------------------------------------------------*/ -/* Exported types ------------------------------------------------------------*/ -/* Exported constants --------------------------------------------------------*/ -/* Exported macro ------------------------------------------------------------*/ -/* Exported functions ------------------------------------------------------- */ -/* External variables --------------------------------------------------------*/ -/*-------------------------------------------------------------*/ -/* EP_NUM */ -/* defines how many endpoints are used by the device */ -/*-------------------------------------------------------------*/ -#define EP_NUM (2) - -#ifndef STM32F10X_CL -/*-------------------------------------------------------------*/ -/* -------------- Buffer Description Table -----------------*/ -/*-------------------------------------------------------------*/ -/* buffer table base address */ -/* buffer table base address */ -#define BTABLE_ADDRESS (0x00) - -/* EP0 */ -/* rx/tx buffer base address */ -#define ENDP0_RXADDR (0x18) -#define ENDP0_TXADDR (0x58) - -/* EP1 */ -/* tx buffer base address */ -#define ENDP1_TXADDR (0x100) -#define ENDP1_RXADDR (0x124) - -/*-------------------------------------------------------------*/ -/* ------------------- ISTR events -------------------------*/ -/*-------------------------------------------------------------*/ -/* IMR_MSK */ -/* mask defining which events has to be handled */ -/* by the device application software */ -#define IMR_MSK (CNTR_CTRM | CNTR_WKUPM | CNTR_SUSPM | CNTR_ERRM | CNTR_SOFM \ - | CNTR_ESOFM | CNTR_RESETM ) -#endif /* STM32F10X_CL */ - -#ifdef STM32F10X_CL - -/******************************************************************************* -* FIFO Size Configuration -* -* (i) Dedicated data FIFO SPRAM of 1.25 Kbytes = 1280 bytes = 320 32-bits words -* available for the endpoints IN and OUT. -* Device mode features: -* -1 bidirectional CTRL EP 0 -* -3 IN EPs to support any kind of Bulk, Interrupt or Isochronous transfer -* -3 OUT EPs to support any kind of Bulk, Interrupt or Isochronous transfer -* -* ii) Receive data FIFO size = RAM for setup packets + -* OUT endpoint control information + -* data OUT packets + miscellaneous -* Space = ONE 32-bits words -* --> RAM for setup packets = 4 * n + 6 space -* (n is the nbr of CTRL EPs the device core supports) -* --> OUT EP CTRL info = 1 space -* (one space for status information written to the FIFO along with each -* received packet) -* --> data OUT packets = (Largest Packet Size / 4) + 1 spaces -* (MINIMUM to receive packets) -* --> OR data OUT packets = at least 2*(Largest Packet Size / 4) + 1 spaces -* (if high-bandwidth EP is enabled or multiple isochronous EPs) -* --> miscellaneous = 1 space per OUT EP -* (one space for transfer complete status information also pushed to the -* FIFO with each endpoint's last packet) -* -* (iii)MINIMUM RAM space required for each IN EP Tx FIFO = MAX packet size for -* that particular IN EP. More space allocated in the IN EP Tx FIFO results -* in a better performance on the USB and can hide latencies on the AHB. -* -* (iv) TXn min size = 16 words. (n : Transmit FIFO index) -* (v) When a TxFIFO is not used, the Configuration should be as follows: -* case 1 : n > m and Txn is not used (n,m : Transmit FIFO indexes) -* --> Txm can use the space allocated for Txn. -* case2 : n < m and Txn is not used (n,m : Transmit FIFO indexes) -* --> Txn should be configured with the minimum space of 16 words -* (vi) The FIFO is used optimally when used TxFIFOs are allocated in the top -* of the FIFO.Ex: use EP1 and EP2 as IN instead of EP1 and EP3 as IN ones. -*******************************************************************************/ - -#define RX_FIFO_SIZE 128 -#define TX0_FIFO_SIZE 64 -#define TX1_FIFO_SIZE 64 -#define TX2_FIFO_SIZE 16 -#define TX3_FIFO_SIZE 16 - -/* OTGD-FS-DEVICE IP interrupts Enable definitions */ -/* Uncomment the define to enable the selected interrupt */ -//#define INTR_MODEMISMATCH -#define INTR_SOFINTR -#define INTR_RXSTSQLVL /* Mandatory */ -//#define INTR_NPTXFEMPTY -//#define INTR_GINNAKEFF -//#define INTR_GOUTNAKEFF -//#define INTR_ERLYSUSPEND -#define INTR_USBSUSPEND /* Mandatory */ -#define INTR_USBRESET /* Mandatory */ -#define INTR_ENUMDONE /* Mandatory */ -//#define INTR_ISOOUTDROP -//#define INTR_EOPFRAME -//#define INTR_EPMISMATCH -#define INTR_INEPINTR /* Mandatory */ -#define INTR_OUTEPINTR /* Mandatory */ -//#define INTR_INCOMPLISOIN -//#define INTR_INCOMPLISOOUT -#define INTR_WKUPINTR /* Mandatory */ - -/* OTGD-FS-DEVICE IP interrupts subroutines */ -/* Comment the define to enable the selected interrupt subroutine and replace it - by user code */ -#define INTR_MODEMISMATCH_Callback NOP_Process -#define INTR_SOFINTR_Callback NOP_Process -#define INTR_RXSTSQLVL_Callback NOP_Process -#define INTR_NPTXFEMPTY_Callback NOP_Process -#define INTR_NPTXFEMPTY_Callback NOP_Process -#define INTR_GINNAKEFF_Callback NOP_Process -#define INTR_GOUTNAKEFF_Callback NOP_Process -#define INTR_ERLYSUSPEND_Callback NOP_Process -#define INTR_USBSUSPEND_Callback NOP_Process -#define INTR_USBRESET_Callback NOP_Process -#define INTR_ENUMDONE_Callback NOP_Process -#define INTR_ISOOUTDROP_Callback NOP_Process -#define INTR_EOPFRAME_Callback NOP_Process -#define INTR_EPMISMATCH_Callback NOP_Process -#define INTR_INEPINTR_Callback NOP_Process -#define INTR_OUTEPINTR_Callback NOP_Process -#define INTR_INCOMPLISOIN_Callback NOP_Process -#define INTR_INCOMPLISOOUT_Callback NOP_Process -#define INTR_WKUPINTR_Callback NOP_Process - -/* Isochronous data update */ -#define INTR_RXSTSQLVL_ISODU_Callback NOP_Process - -/* Isochronous transfer parameters */ -/* Size of a single Isochronous buffer (size of a single transfer) */ -#define ISOC_BUFFER_SZE 1 -/* Number of sub-buffers (number of single buffers/transfers), should be even */ -#define NUM_SUB_BUFFERS 2 - -#endif /* STM32F10X_CL */ - - -/* CTR service routines */ -/* associated to defined endpoints */ -#define EP1_IN_Callback NOP_Process -#define EP2_IN_Callback NOP_Process -#define EP3_IN_Callback NOP_Process -#define EP4_IN_Callback NOP_Process -#define EP5_IN_Callback NOP_Process -#define EP6_IN_Callback NOP_Process -#define EP7_IN_Callback NOP_Process - -//#define EP1_OUT_Callback NOP_Process -#define EP2_OUT_Callback NOP_Process -#define EP3_OUT_Callback NOP_Process -#define EP4_OUT_Callback NOP_Process -#define EP5_OUT_Callback NOP_Process -#define EP6_OUT_Callback NOP_Process -#define EP7_OUT_Callback NOP_Process - -#endif /*__USB_CONF_H*/ - -/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/ - diff --git a/flight/OSD/System/inc/watchdog.h b/flight/OSD/System/inc/watchdog.h deleted file mode 100644 index ba3fba199..000000000 --- a/flight/OSD/System/inc/watchdog.h +++ /dev/null @@ -1,32 +0,0 @@ -/** - ****************************************************************************** - * - * @file watchdog.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief RF Module hardware layer - * @see The GNU Public License (GPL) Version 3 - * - *****************************************************************************/ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef _WATCHDOG_H_ -#define _WATCHDOG_H_ - -uint16_t watchdog_Init(uint16_t delayMs); -void watchdog_Clear(void); - -#endif diff --git a/flight/OSD/System/inc/xconvert.h b/flight/OSD/System/inc/xconvert.h deleted file mode 100644 index be0f5aace..000000000 --- a/flight/OSD/System/inc/xconvert.h +++ /dev/null @@ -1,264 +0,0 @@ -#ifndef XCONVERT_H_ -#define XCONVERT_H_ - -// Credit for this goes to MegaPirateOSD and Syberian! -// Some minor changes made to fit my code better. - -#define ________ 0 -#define _______X 1 -#define ______X_ 2 -#define ______XX 3 -#define _____X__ 4 -#define _____X_X 5 -#define _____XX_ 6 -#define _____XXX 7 -#define ____X___ 8 -#define ____X__X 9 -#define ____X_X_ 10 -#define ____X_XX 11 -#define ____XX__ 12 -#define ____XX_X 13 -#define ____XXX_ 14 -#define ____XXXX 15 -#define ___X____ 16 -#define ___X___X 17 -#define ___X__X_ 18 -#define ___X__XX 19 -#define ___X_X__ 20 -#define ___X_X_X 21 -#define ___X_XX_ 22 -#define ___X_XXX 23 -#define ___XX___ 24 -#define ___XX__X 25 -#define ___XX_X_ 26 -#define ___XX_XX 27 -#define ___XXX__ 28 -#define ___XXX_X 29 -#define ___XXXX_ 30 -#define ___XXXXX 31 -#define __X_____ 32 -#define __X____X 33 -#define __X___X_ 34 -#define __X___XX 35 -#define __X__X__ 36 -#define __X__X_X 37 -#define __X__XX_ 38 -#define __X__XXX 39 -#define __X_X___ 40 -#define __X_X__X 41 -#define __X_X_X_ 42 -#define __X_X_XX 43 -#define __X_XX__ 44 -#define __X_XX_X 45 -#define __X_XXX_ 46 -#define __X_XXXX 47 -#define __XX____ 48 -#define __XX___X 49 -#define __XX__X_ 50 -#define __XX__XX 51 -#define __XX_X__ 52 -#define __XX_X_X 53 -#define __XX_XX_ 54 -#define __XX_XXX 55 -#define __XXX___ 56 -#define __XXX__X 57 -#define __XXX_X_ 58 -#define __XXX_XX 59 -#define __XXXX__ 60 -#define __XXXX_X 61 -#define __XXXXX_ 62 -#define __XXXXXX 63 -#define _X______ 64 -#define _X_____X 65 -#define _X____X_ 66 -#define _X____XX 67 -#define _X___X__ 68 -#define _X___X_X 69 -#define _X___XX_ 70 -#define _X___XXX 71 -#define _X__X___ 72 -#define _X__X__X 73 -#define _X__X_X_ 74 -#define _X__X_XX 75 -#define _X__XX__ 76 -#define _X__XX_X 77 -#define _X__XXX_ 78 -#define _X__XXXX 79 -#define _X_X____ 80 -#define _X_X___X 81 -#define _X_X__X_ 82 -#define _X_X__XX 83 -#define _X_X_X__ 84 -#define _X_X_X_X 85 -#define _X_X_XX_ 86 -#define _X_X_XXX 87 -#define _X_XX___ 88 -#define _X_XX__X 89 -#define _X_XX_X_ 90 -#define _X_XX_XX 91 -#define _X_XXX__ 92 -#define _X_XXX_X 93 -#define _X_XXXX_ 94 -#define _X_XXXXX 95 -#define _XX_____ 96 -#define _XX____X 97 -#define _XX___X_ 98 -#define _XX___XX 99 -#define _XX__X__ 100 -#define _XX__X_X 101 -#define _XX__XX_ 102 -#define _XX__XXX 103 -#define _XX_X___ 104 -#define _XX_X__X 105 -#define _XX_X_X_ 106 -#define _XX_X_XX 107 -#define _XX_XX__ 108 -#define _XX_XX_X 109 -#define _XX_XXX_ 110 -#define _XX_XXXX 111 -#define _XXX____ 112 -#define _XXX___X 113 -#define _XXX__X_ 114 -#define _XXX__XX 115 -#define _XXX_X__ 116 -#define _XXX_X_X 117 -#define _XXX_XX_ 118 -#define _XXX_XXX 119 -#define _XXXX___ 120 -#define _XXXX__X 121 -#define _XXXX_X_ 122 -#define _XXXX_XX 123 -#define _XXXXX__ 124 -#define _XXXXX_X 125 -#define _XXXXXX_ 126 -#define _XXXXXXX 127 -#define X_______ 128 -#define X______X 129 -#define X_____X_ 130 -#define X_____XX 131 -#define X____X__ 132 -#define X____X_X 133 -#define X____XX_ 134 -#define X____XXX 135 -#define X___X___ 136 -#define X___X__X 137 -#define X___X_X_ 138 -#define X___X_XX 139 -#define X___XX__ 140 -#define X___XX_X 141 -#define X___XXX_ 142 -#define X___XXXX 143 -#define X__X____ 144 -#define X__X___X 145 -#define X__X__X_ 146 -#define X__X__XX 147 -#define X__X_X__ 148 -#define X__X_X_X 149 -#define X__X_XX_ 150 -#define X__X_XXX 151 -#define X__XX___ 152 -#define X__XX__X 153 -#define X__XX_X_ 154 -#define X__XX_XX 155 -#define X__XXX__ 156 -#define X__XXX_X 157 -#define X__XXXX_ 158 -#define X__XXXXX 159 -#define X_X_____ 160 -#define X_X____X 161 -#define X_X___X_ 162 -#define X_X___XX 163 -#define X_X__X__ 164 -#define X_X__X_X 165 -#define X_X__XX_ 166 -#define X_X__XXX 167 -#define X_X_X___ 168 -#define X_X_X__X 169 -#define X_X_X_X_ 170 -#define X_X_X_XX 171 -#define X_X_XX__ 172 -#define X_X_XX_X 173 -#define X_X_XXX_ 174 -#define X_X_XXXX 175 -#define X_XX____ 176 -#define X_XX___X 177 -#define X_XX__X_ 178 -#define X_XX__XX 179 -#define X_XX_X__ 180 -#define X_XX_X_X 181 -#define X_XX_XX_ 182 -#define X_XX_XXX 183 -#define X_XXX___ 184 -#define X_XXX__X 185 -#define X_XXX_X_ 186 -#define X_XXX_XX 187 -#define X_XXXX__ 188 -#define X_XXXX_X 189 -#define X_XXXXX_ 190 -#define X_XXXXXX 191 -#define XX______ 192 -#define XX_____X 193 -#define XX____X_ 194 -#define XX____XX 195 -#define XX___X__ 196 -#define XX___X_X 197 -#define XX___XX_ 198 -#define XX___XXX 199 -#define XX__X___ 200 -#define XX__X__X 201 -#define XX__X_X_ 202 -#define XX__X_XX 203 -#define XX__XX__ 204 -#define XX__XX_X 205 -#define XX__XXX_ 206 -#define XX__XXXX 207 -#define XX_X____ 208 -#define XX_X___X 209 -#define XX_X__X_ 210 -#define XX_X__XX 211 -#define XX_X_X__ 212 -#define XX_X_X_X 213 -#define XX_X_XX_ 214 -#define XX_X_XXX 215 -#define XX_XX___ 216 -#define XX_XX__X 217 -#define XX_XX_X_ 218 -#define XX_XX_XX 219 -#define XX_XXX__ 220 -#define XX_XXX_X 221 -#define XX_XXXX_ 222 -#define XX_XXXXX 223 -#define XXX_____ 224 -#define XXX____X 225 -#define XXX___X_ 226 -#define XXX___XX 227 -#define XXX__X__ 228 -#define XXX__X_X 229 -#define XXX__XX_ 230 -#define XXX__XXX 231 -#define XXX_X___ 232 -#define XXX_X__X 233 -#define XXX_X_X_ 234 -#define XXX_X_XX 235 -#define XXX_XX__ 236 -#define XXX_XX_X 237 -#define XXX_XXX_ 238 -#define XXX_XXXX 239 -#define XXXX____ 240 -#define XXXX___X 241 -#define XXXX__X_ 242 -#define XXXX__XX 243 -#define XXXX_X__ 244 -#define XXXX_X_X 245 -#define XXXX_XX_ 246 -#define XXXX_XXX 247 -#define XXXXX___ 248 -#define XXXXX__X 249 -#define XXXXX_X_ 250 -#define XXXXX_XX 251 -#define XXXXXX__ 252 -#define XXXXXX_X 253 -#define XXXXXXX_ 254 -#define XXXXXXXX 255 - -#endif //XCONVERT_H_ \ No newline at end of file diff --git a/flight/OSD/System/osd.c b/flight/OSD/System/osd.c index d68943ec8..6d536925b 100644 --- a/flight/OSD/System/osd.c +++ b/flight/OSD/System/osd.c @@ -34,8 +34,7 @@ #include -#include "oposd.h" -#include "watchdog.h" +#include "openpilot.h" #include "systemmod.h" /* Task Priorities */ diff --git a/flight/OSD/System/pios_board.c b/flight/OSD/System/pios_board.c index ba8e9d3e0..da0192055 100644 --- a/flight/OSD/System/pios_board.c +++ b/flight/OSD/System/pios_board.c @@ -51,318 +51,6 @@ uint8_t RxBuffer3[TxBufferSize3]; -#if defined(PIOS_INCLUDE_VIDEO) - -#include -static const struct pios_exti_cfg pios_exti_hsync_cfg __exti_config = { - .vector = PIOS_Hsync_ISR, - .line = EXTI_Line0, - .pin = { - .gpio = GPIOD, - .init = { - .GPIO_Pin = GPIO_Pin_0, - .GPIO_Speed = GPIO_Speed_100MHz, - .GPIO_Mode = GPIO_Mode_IN, - .GPIO_OType = GPIO_OType_OD, - .GPIO_PuPd = GPIO_PuPd_NOPULL, - }, - }, - .irq = { - .init = { - .NVIC_IRQChannel = EXTI0_IRQn, - .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGHEST, - .NVIC_IRQChannelSubPriority = 0, - .NVIC_IRQChannelCmd = ENABLE, - }, - }, - .exti = { - .init = { - .EXTI_Line = EXTI_Line0, // matches above GPIO pin - .EXTI_Mode = EXTI_Mode_Interrupt, - .EXTI_Trigger = EXTI_Trigger_Rising_Falling, - .EXTI_LineCmd = ENABLE, - }, - }, -}; -static const struct pios_exti_cfg pios_exti_vsync_cfg __exti_config = { - .vector = PIOS_Vsync_ISR, - .line = EXTI_Line11, - .pin = { - .gpio = GPIOC, - .init = { - .GPIO_Pin = GPIO_Pin_11, - .GPIO_Speed = GPIO_Speed_100MHz, - .GPIO_Mode = GPIO_Mode_IN, - .GPIO_OType = GPIO_OType_OD, - .GPIO_PuPd = GPIO_PuPd_NOPULL, - }, - }, - .irq = { - .init = { - .NVIC_IRQChannel = EXTI15_10_IRQn, - .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH, - .NVIC_IRQChannelSubPriority = 0, - .NVIC_IRQChannelCmd = ENABLE, - }, - }, - .exti = { - .init = { - .EXTI_Line = EXTI_Line11, // matches above GPIO pin - .EXTI_Mode = EXTI_Mode_Interrupt, - .EXTI_Trigger = EXTI_Trigger_Falling, - .EXTI_LineCmd = ENABLE, - }, - }, -}; - - -static const struct pios_video_cfg pios_video_cfg = { - .mask = { - .regs = SPI3, - .remap = GPIO_AF_SPI3, - .init = { - .SPI_Mode = SPI_Mode_Master, - .SPI_Direction = SPI_Direction_1Line_Tx, - .SPI_DataSize = SPI_DataSize_16b, - .SPI_NSS = SPI_NSS_Soft, - .SPI_FirstBit = SPI_FirstBit_MSB, - .SPI_CRCPolynomial = 7, - .SPI_CPOL = SPI_CPOL_Low, - .SPI_CPHA = SPI_CPHA_2Edge, - .SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_4, - }, - .use_crc = false, - .dma = { - .irq = { - // Note this is the stream ID that triggers interrupts (in this case RX) - .flags = (DMA_IT_TCIF7), - .init = { - .NVIC_IRQChannel = DMA1_Stream7_IRQn, - .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH, - .NVIC_IRQChannelSubPriority = 0, - .NVIC_IRQChannelCmd = ENABLE, - }, - }, - - .rx = { - //not used - .channel = DMA1_Stream4, - .init = { - .DMA_Channel = DMA_Channel_0, - .DMA_PeripheralBaseAddr = (uint32_t) & (SPI3->DR), - .DMA_DIR = DMA_DIR_PeripheralToMemory, - .DMA_PeripheralInc = DMA_PeripheralInc_Disable, - .DMA_MemoryInc = DMA_MemoryInc_Enable, - .DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord, - .DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord, - .DMA_Mode = DMA_Mode_Normal, - .DMA_Priority = DMA_Priority_Medium, - //TODO: Enable FIFO - .DMA_FIFOMode = DMA_FIFOMode_Disable, - .DMA_FIFOThreshold = DMA_FIFOThreshold_Full, - .DMA_MemoryBurst = DMA_MemoryBurst_Single, - .DMA_PeripheralBurst = DMA_PeripheralBurst_Single, - }, - }, - .tx = { - .channel = DMA1_Stream7, - .init = { - .DMA_Channel = DMA_Channel_0, - .DMA_PeripheralBaseAddr = (uint32_t) & (SPI3->DR), - .DMA_DIR = DMA_DIR_MemoryToPeripheral, - .DMA_BufferSize = BUFFER_LINE_LENGTH, - .DMA_PeripheralInc = DMA_PeripheralInc_Disable, - .DMA_MemoryInc = DMA_MemoryInc_Enable, - .DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord, - .DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord, - .DMA_Mode = DMA_Mode_Normal, - .DMA_Priority = DMA_Priority_High, - .DMA_FIFOMode = DMA_FIFOMode_Disable, - .DMA_FIFOThreshold = DMA_FIFOThreshold_Full, - .DMA_MemoryBurst = DMA_MemoryBurst_Single, - .DMA_PeripheralBurst = DMA_PeripheralBurst_Single, - }, - }, - }, - .sclk = { - .gpio = GPIOC, - .init = { - .GPIO_Pin = GPIO_Pin_10, - .GPIO_Speed = GPIO_Speed_100MHz, - .GPIO_Mode = GPIO_Mode_AF, - .GPIO_OType = GPIO_OType_PP, - .GPIO_PuPd = GPIO_PuPd_NOPULL - }, - }, - .miso = { - .gpio = GPIOC, - .init = { - .GPIO_Pin = GPIO_Pin_11, - .GPIO_Speed = GPIO_Speed_50MHz, - .GPIO_Mode = GPIO_Mode_AF, - .GPIO_OType = GPIO_OType_PP, - .GPIO_PuPd = GPIO_PuPd_NOPULL - }, - }, - .mosi = { - .gpio = GPIOC, - .init = { - .GPIO_Pin = GPIO_Pin_12, - .GPIO_Speed = GPIO_Speed_50MHz, - .GPIO_Mode = GPIO_Mode_AF, - .GPIO_OType = GPIO_OType_PP, - .GPIO_PuPd = GPIO_PuPd_NOPULL - }, - }, - .slave_count = 1, - }, - .level = { - .regs = SPI1, - .remap = GPIO_AF_SPI1, - .init = { - .SPI_Mode = SPI_Mode_Slave, - .SPI_Direction = SPI_Direction_1Line_Tx, - .SPI_DataSize = SPI_DataSize_16b, - .SPI_NSS = SPI_NSS_Soft, - .SPI_FirstBit = SPI_FirstBit_MSB, - .SPI_CRCPolynomial = 7, - .SPI_CPOL = SPI_CPOL_Low, - .SPI_CPHA = SPI_CPHA_2Edge, - .SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_2, - }, - .use_crc = false, - .dma = { - .irq = { - .flags = (DMA_IT_TCIF5), - .init = { - .NVIC_IRQChannel = DMA2_Stream5_IRQn, - .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH, - .NVIC_IRQChannelSubPriority = 0, - .NVIC_IRQChannelCmd = ENABLE, - }, - }, - - .rx = { - //not used - .channel = DMA2_Stream0, - .init = { - .DMA_Channel = DMA_Channel_3, - .DMA_PeripheralBaseAddr = (uint32_t)&(SPI1->DR), - .DMA_DIR = DMA_DIR_PeripheralToMemory, - .DMA_PeripheralInc = DMA_PeripheralInc_Disable, - .DMA_MemoryInc = DMA_MemoryInc_Enable, - .DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte, - .DMA_MemoryDataSize = DMA_MemoryDataSize_Byte, - .DMA_Mode = DMA_Mode_Normal, - .DMA_Priority = DMA_Priority_Medium, - .DMA_FIFOMode = DMA_FIFOMode_Disable, - /* .DMA_FIFOThreshold */ - .DMA_MemoryBurst = DMA_MemoryBurst_Single, - .DMA_PeripheralBurst = DMA_PeripheralBurst_Single, - }, - }, - .tx = { - .channel = DMA2_Stream5, - .init = { - .DMA_Channel = DMA_Channel_3, - .DMA_PeripheralBaseAddr = (uint32_t)&(SPI1->DR), - .DMA_DIR = DMA_DIR_MemoryToPeripheral, - .DMA_BufferSize = BUFFER_LINE_LENGTH, - .DMA_PeripheralInc = DMA_PeripheralInc_Disable, - .DMA_MemoryInc = DMA_MemoryInc_Enable, - .DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord, - .DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord, - .DMA_Mode = DMA_Mode_Normal, - .DMA_Priority = DMA_Priority_High, - .DMA_FIFOMode = DMA_FIFOMode_Disable, - .DMA_FIFOThreshold = DMA_FIFOThreshold_Full, - .DMA_MemoryBurst = DMA_MemoryBurst_Single, - .DMA_PeripheralBurst = DMA_PeripheralBurst_Single, - }, - }, - }, - .sclk = { - .gpio = GPIOB, - .init = { - .GPIO_Pin = GPIO_Pin_3, - .GPIO_Speed = GPIO_Speed_100MHz, - .GPIO_Mode = GPIO_Mode_AF, - .GPIO_OType = GPIO_OType_PP, - .GPIO_PuPd = GPIO_PuPd_UP - }, - }, - .miso = { - .gpio = GPIOB, - .init = { - .GPIO_Pin = GPIO_Pin_4, - .GPIO_Speed = GPIO_Speed_50MHz, - .GPIO_Mode = GPIO_Mode_AF, - .GPIO_OType = GPIO_OType_PP, - .GPIO_PuPd = GPIO_PuPd_UP - }, - }, - .mosi = { - .gpio = GPIOB, - .init = { - .GPIO_Pin = GPIO_Pin_5, - .GPIO_Speed = GPIO_Speed_50MHz, - .GPIO_Mode = GPIO_Mode_AF, - .GPIO_OType = GPIO_OType_PP, - .GPIO_PuPd = GPIO_PuPd_UP - }, - }, - .slave_count = 1, - - }, - ///////////////// - - .hsync = &pios_exti_hsync_cfg, - .vsync = &pios_exti_vsync_cfg, -}; - - - - -void PIOS_VIDEO_DMA_Handler(void); -void DMA1_Stream7_IRQHandler(void) __attribute__ ((alias("PIOS_VIDEO_DMA_Handler"))); -void DMA2_Stream5_IRQHandler(void) __attribute__ ((alias("PIOS_VIDEO_DMA_Handler"))); - -/** - * @brief Interrupt for half and full buffer transfer - * - * This interrupt handler swaps between the two halfs of the double buffer to make - * sure the ahrs uses the most recent data. Only swaps data when AHRS is idle, but - * really this is a pretense of a sanity check since the DMA engine is consantly - * running in the background. Keep an eye on the ekf_too_slow variable to make sure - * it's keeping up. - */ -void PIOS_VIDEO_DMA_Handler(void) -{ - if (DMA_GetFlagStatus(DMA1_Stream7,DMA_FLAG_TCIF7)) { // whole double buffer filled - DMA_ClearFlag(DMA1_Stream5,DMA_FLAG_TCIF7); - //PIOS_LED_Toggle(LED2); - } - else if (DMA_GetFlagStatus(DMA1_Stream7,DMA_FLAG_HTIF7)) { - DMA_ClearFlag(DMA1_Stream5,DMA_FLAG_HTIF7); - } - else { - - } - - if (DMA_GetFlagStatus(DMA2_Stream5,DMA_FLAG_TCIF5)) { // whole double buffer filled - DMA_ClearFlag(DMA2_Stream5,DMA_FLAG_TCIF5); - //PIOS_LED_Toggle(LED3); - } - else if (DMA_GetFlagStatus(DMA2_Stream5,DMA_FLAG_HTIF5)) { - DMA_ClearFlag(DMA2_Stream5,DMA_FLAG_HTIF5); - } - else { - - } - -} - -#endif #if defined(PIOS_INCLUDE_ADC) /* @@ -683,7 +371,17 @@ void PIOS_Board_Init(void) { /* Initialize the task monitor library */ TaskMonitorInitialize(); - + /* IAP System Setup */ + PIOS_IAP_Init(); + uint16_t boot_count = PIOS_IAP_ReadBootCount(); + if (boot_count < 3) { + PIOS_IAP_WriteBootCount(++boot_count); + AlarmsClear(SYSTEMALARMS_ALARM_BOOTFAULT); + } else { + /* Too many failed boot attempts, force hwsettings to defaults */ + HwSettingsSetDefaults(HwSettingsHandle(), 0); + AlarmsSet(SYSTEMALARMS_ALARM_BOOTFAULT, SYSTEMALARMS_ALARM_CRITICAL); + } #if defined(PIOS_INCLUDE_RTC) /* Initialize the real-time clock and its associated tick */ @@ -693,9 +391,6 @@ void PIOS_Board_Init(void) { } #endif -#if 0 - - #if defined(PIOS_INCLUDE_USB) /* Initialize board specific USB data */ PIOS_USB_BOARD_DATA_Init(); @@ -825,7 +520,6 @@ void PIOS_Board_Init(void) { PIOS_USBHOOK_Activate(); } #endif /* PIOS_INCLUDE_USB */ -#endif #if defined(PIOS_INCLUDE_COM) #if defined(PIOS_INCLUDE_GPS) diff --git a/flight/OSD/System/pios_usb_board_data.c b/flight/OSD/System/pios_usb_board_data.c index 823496c29..2af604ca4 100644 --- a/flight/OSD/System/pios_usb_board_data.c +++ b/flight/OSD/System/pios_usb_board_data.c @@ -32,19 +32,12 @@ #include "pios_sys.h" /* PIOS_SYS_SerialNumberGet */ #include "pios_usbhook.h" /* PIOS_USBHOOK_* */ -static const uint8_t usb_product_id[22] = { +static const uint8_t usb_product_id[8] = { sizeof(usb_product_id), USB_DESC_TYPE_STRING, - 'R', 0, - 'e', 0, - 'v', 0, - 'o', 0, - 'l', 0, - 'u', 0, - 't', 0, - 'i', 0, - 'o', 0, - 'n', 0, + 'O', 0, + 'S', 0, + 'D', 0, }; static uint8_t usb_serial_number[52] = { diff --git a/flight/OSD/System/pios_usb_hid_desc.c b/flight/OSD/System/pios_usb_hid_desc.c deleted file mode 100644 index 157e85831..000000000 --- a/flight/OSD/System/pios_usb_hid_desc.c +++ /dev/null @@ -1,220 +0,0 @@ -/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** -* File Name : usb_desc.c -* Author : MCD Application Team -* Version : V3.2.1 -* Date : 07/05/2010 -* Description : Descriptors for Custom HID Demo -******************************************************************************** -* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS -* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. -* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, -* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE -* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING -* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. -*******************************************************************************/ - -#include "usb_lib.h" -#include "pios_usb.h" -#include "pios_usb_hid.h" -#include "pios_usb_hid_desc.h" - -// ************************************************* -// USB Standard Device Descriptor - -const uint8_t PIOS_HID_DeviceDescriptor[PIOS_HID_SIZ_DEVICE_DESC] = - { - 0x12, // bLength - USB_DEVICE_DESCRIPTOR_TYPE, // bDescriptorType - 0x00, // bcdUSB - 0x02, - 0x00, // bDeviceClass - 0x00, // bDeviceSubClass - 0x00, // bDeviceProtocol - 0x40, // bMaxPacketSize40 - (uint8_t)((PIOS_USB_VENDOR_ID) & 0xff), // idVendor - (uint8_t)((PIOS_USB_VENDOR_ID) >> 8), - (uint8_t)((PIOS_USB_PRODUCT_ID) & 0xff), // idProduct - (uint8_t)((PIOS_USB_PRODUCT_ID) >> 8), - (uint8_t)((PIOS_USB_VERSION_ID) & 0xff), // bcdDevice - (uint8_t)((PIOS_USB_VERSION_ID) >> 8), - 0x01, // Index of string descriptor describing manufacturer - 0x02, // Index of string descriptor describing product - 0x03, // Index of string descriptor describing the device serial number - 0x01 // bNumConfigurations - }; - -// ************************************************* -// USB Configuration Descriptor -// All Descriptors (Configuration, Interface, Endpoint, Class, Vendor - -const uint8_t PIOS_HID_ConfigDescriptor[PIOS_HID_SIZ_CONFIG_DESC] = - { - 0x09, // bLength: Configuation Descriptor size - USB_CONFIGURATION_DESCRIPTOR_TYPE, // bDescriptorType: Configuration - PIOS_HID_SIZ_CONFIG_DESC, - // wTotalLength: Bytes returned - 0x00, - 0x01, // bNumInterfaces: 1 interface - 0x01, // bConfigurationValue: Configuration value - 0x00, // iConfiguration: Index of string descriptor describing the configuration - 0xC0, // bmAttributes: Bus powered - 0x7D, // MaxPower 250 mA - needed to power the RF transmitter - - // ************** Descriptor of Custom HID interface **************** - // 09 - 0x09, // bLength: Interface Descriptor size - USB_INTERFACE_DESCRIPTOR_TYPE, // bDescriptorType: Interface descriptor type - 0x00, // bInterfaceNumber: Number of Interface - 0x00, // bAlternateSetting: Alternate setting - 0x02, // bNumEndpoints - 0x03, // bInterfaceClass: HID - 0x00, // bInterfaceSubClass : 1=BOOT, 0=no boot - 0x00, // nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse - 0, // iInterface: Index of string descriptor - - // ******************** Descriptor of Custom HID HID ******************** - // 18 - 0x09, // bLength: HID Descriptor size - HID_DESCRIPTOR_TYPE, // bDescriptorType: HID - 0x10, // bcdHID: HID Class Spec release number - 0x01, - 0x00, // bCountryCode: Hardware target country - 0x01, // bNumDescriptors: Number of HID class descriptors to follow - 0x22, // bDescriptorType - PIOS_HID_SIZ_REPORT_DESC, // wItemLength: Total length of Report descriptor - 0x00, - - // ******************** Descriptor of Custom HID endpoints ****************** - // 27 - 0x07, // bLength: Endpoint Descriptor size - USB_ENDPOINT_DESCRIPTOR_TYPE, // bDescriptorType: - - 0x81, // bEndpointAddress: Endpoint Address (IN) - 0x03, // bmAttributes: Interrupt endpoint - 0x40, // wMaxPacketSize: 2 Bytes max - 0x00, - 0x04, // bInterval: Polling Interval in ms - // 34 - - 0x07, // bLength: Endpoint Descriptor size - USB_ENDPOINT_DESCRIPTOR_TYPE, // bDescriptorType: - // Endpoint descriptor type - 0x01, // bEndpointAddress: - // Endpoint Address (OUT) - 0x03, // bmAttributes: Interrupt endpoint - 0x40, // wMaxPacketSize: 2 Bytes max - 0x00, - 0x04, // bInterval: Polling Interval in ms - // 41 - }; - -// ************************************************* - - const uint8_t PIOS_HID_ReportDescriptor[PIOS_HID_SIZ_REPORT_DESC] = - { - 0x06, 0x9c, 0xff, // USAGE_PAGE (Vendor Page: 0xFF00) - 0x09, 0x01, // USAGE (Demo Kit) - 0xa1, 0x01, // COLLECTION (Application) - // 6 - - // Data 1 - 0x85, 0x01, // REPORT_ID (1) - 0x09, 0x02, // USAGE (LED 1) - 0x15, 0x00, // LOGICAL_MINIMUM (0) - 0x25, 0xff, // LOGICAL_MAXIMUM (255) - 0x75, 0x08, // REPORT_SIZE (8) - 0x95, PIOS_USB_HID_DATA_LENGTH+1, // REPORT_COUNT (1) - 0x81, 0x83, // INPUT (Const,Var,Array) - // 20 - - // Data 1 - 0x85, 0x02, // REPORT_ID (2) - 0x09, 0x03, // USAGE (LED 1) - 0x15, 0x00, // LOGICAL_MINIMUM (0) - 0x25, 0xff, // LOGICAL_MAXIMUM (255) - 0x75, 0x08, // REPORT_SIZE (8) - 0x95, PIOS_USB_HID_DATA_LENGTH+1, // REPORT_COUNT (1) - 0x91, 0x82, // OUTPUT (Data,Var,Abs,Vol) - // 34 - - 0xc0 // END_COLLECTION - }; - -// ************************************************* -// USB String Descriptors (optional) - -const uint8_t PIOS_HID_StringLangID[PIOS_HID_SIZ_STRING_LANGID] = - { - PIOS_HID_SIZ_STRING_LANGID, - USB_STRING_DESCRIPTOR_TYPE, - 0x09, 0x08 // LangID = 0x0809: UK. English -// 0x09, 0x04 // LangID = 0x0409: U.S. English - }; - -const uint8_t PIOS_HID_StringVendor[PIOS_HID_SIZ_STRING_VENDOR] = - { - PIOS_HID_SIZ_STRING_VENDOR, // Size of Vendor string - USB_STRING_DESCRIPTOR_TYPE, // bDescriptorType - // Manufacturer: "STMicroelectronics" - 'o', 0, - 'p', 0, - 'e', 0, - 'n', 0, - 'p', 0, - 'i', 0, - 'l', 0, - 'o', 0, - 't', 0, - '.', 0, - 'o', 0, - 'r', 0, - 'g', 0 - }; - -const uint8_t PIOS_HID_StringProduct[PIOS_HID_SIZ_STRING_PRODUCT] = - { - PIOS_HID_SIZ_STRING_PRODUCT, // bLength - USB_STRING_DESCRIPTOR_TYPE, // bDescriptorType - 'P', 0, - 'i', 0, - 'p', 0, - 'X', 0, - 't', 0, - 'r', 0, - 'e', 0, - 'm', 0, - 'e', 0 - }; - -uint8_t PIOS_HID_StringSerial[PIOS_HID_SIZ_STRING_SERIAL] = - { - PIOS_HID_SIZ_STRING_SERIAL, // bLength - USB_STRING_DESCRIPTOR_TYPE, // bDescriptorType - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0 - }; - -// ************************************************* diff --git a/flight/OSD/System/watchdog.c b/flight/OSD/System/watchdog.c deleted file mode 100644 index 044e3d3f3..000000000 --- a/flight/OSD/System/watchdog.c +++ /dev/null @@ -1,71 +0,0 @@ -/** - ****************************************************************************** - * - * @file watchdog.c - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief Modem packet handling routines - * @see The GNU Public License (GPL) Version 3 - * - *****************************************************************************/ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "pios.h" -#include "stm32f10x_iwdg.h" -#include "stm32f10x_dbgmcu.h" - -/** - * @brief Initialize the watchdog timer for a specified timeout - * - * It is important to note that this function returns the achieved timeout - * for this hardware. For hardware indendence this should be checked when - * scheduling updates. Other hardware dependent details may need to be - * considered such as a window time which sets a minimum update time, - * and this function should return a recommended delay for clearing. - * - * For the STM32 nominal clock rate is 32 khz, but for the maximum clock rate of - * 60 khz and a prescalar of 4 yields a clock rate of 15 khz. The delay that is - * set in the watchdog assumes the nominal clock rate, but the delay for FreeRTOS - * to use is 75% of the minimal delay. - * - * @param[in] delayMs The delay period in ms - * @returns Maximum recommended delay between updates - */ -uint16_t watchdog_Init(uint16_t delayMs) -{ - uint16_t delay = ((uint32_t)delayMs * 60) / 16; - if (delay > 0x0fff) - delay = 0x0fff; - - DBGMCU_Config(DBGMCU_IWDG_STOP, ENABLE); // make the watchdog stop counting in debug mode - IWDG_WriteAccessCmd(IWDG_WriteAccess_Enable); - IWDG_SetPrescaler(IWDG_Prescaler_16); - IWDG_SetReload(delay); - IWDG_ReloadCounter(); - IWDG_Enable(); - - return ((((uint32_t)delay * 16) / 60) * .75f); -} - -/** - * @brief Clear the watchdog timer - * - * This function must be called at the appropriate delay to prevent a reset event occuring - */ -void watchdog_Clear(void) -{ - IWDG_ReloadCounter(); -} diff --git a/flight/PiOS/Boards/STM32F4xx_OSD.h b/flight/PiOS/Boards/STM32F4xx_OSD.h index 98cba603b..ca426c543 100644 --- a/flight/PiOS/Boards/STM32F4xx_OSD.h +++ b/flight/PiOS/Boards/STM32F4xx_OSD.h @@ -26,6 +26,9 @@ #ifndef PIOS_BOARD_H #define PIOS_BOARD_H + +#include + // ***************************************************************** // Timers and Channels Used @@ -55,6 +58,13 @@ TIM4 | STOPWATCH | /* Channel 11 - */ /* Channel 12 - */ +//------------------------ +// BOOTLOADER_SETTINGS +//------------------------ +#define BOARD_READABLE true +#define BOARD_WRITABLE true +#define MAX_DEL_RETRYS 3 + //------------------------- // System Settings // @@ -90,13 +100,6 @@ TIM4 | STOPWATCH | #define PIOS_PERIPHERAL_APB2_CLOCK PIOS_SYSCLK -//------------------------ -// BOOTLOADER_SETTINGS -//------------------------ -#define BOARD_READABLE TRUE -#define BOARD_WRITABLE TRUE -#define MAX_DEL_RETRYS 3 - //------------------------ // TELEMETRY //------------------------ diff --git a/flight/PiOS/STM32F4xx/link_STM32F4xx_OP_memory.ld b/flight/PiOS/STM32F4xx/link_STM32F4xx_OP_memory.ld index eb5927ce4..d6082e917 100644 --- a/flight/PiOS/STM32F4xx/link_STM32F4xx_OP_memory.ld +++ b/flight/PiOS/STM32F4xx/link_STM32F4xx_OP_memory.ld @@ -1,7 +1,7 @@ MEMORY { BD_INFO (r) : ORIGIN = 0x08008000 - 0x80, LENGTH = 0x000080 - FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 0x100000 - 0x008000 + FLASH (rx) : ORIGIN = 0x08008000, LENGTH = 0x100000 - 0x008000 SRAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x020000 CCSRAM (rw) : ORIGIN = 0x10000000, LENGTH = 0x010000 } diff --git a/flight/board_hw_defs/osd/board_hw_defs.c b/flight/board_hw_defs/osd/board_hw_defs.c index 74312711c..378f32648 100644 --- a/flight/board_hw_defs/osd/board_hw_defs.c +++ b/flight/board_hw_defs/osd/board_hw_defs.c @@ -312,9 +312,9 @@ static const struct pios_usb_cfg pios_usb_main_cfg = { }, }, .vsense = { - .gpio = GPIOD, + .gpio = GPIOA, .init = { - .GPIO_Pin = GPIO_Pin_11, + .GPIO_Pin = GPIO_Pin_9, .GPIO_Speed = GPIO_Speed_25MHz, .GPIO_Mode = GPIO_Mode_IN, .GPIO_OType = GPIO_OType_OD, @@ -357,3 +357,317 @@ const struct pios_usb_cdc_cfg pios_usb_cdc_cfg = { .data_tx_ep = 3, }; #endif /* PIOS_INCLUDE_USB_CDC */ + +#if defined(PIOS_INCLUDE_VIDEO) + +#include +static const struct pios_exti_cfg pios_exti_hsync_cfg __exti_config = { + .vector = PIOS_Hsync_ISR, + .line = EXTI_Line0, + .pin = { + .gpio = GPIOD, + .init = { + .GPIO_Pin = GPIO_Pin_0, + .GPIO_Speed = GPIO_Speed_100MHz, + .GPIO_Mode = GPIO_Mode_IN, + .GPIO_OType = GPIO_OType_OD, + .GPIO_PuPd = GPIO_PuPd_NOPULL, + }, + }, + .irq = { + .init = { + .NVIC_IRQChannel = EXTI0_IRQn, + .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGHEST, + .NVIC_IRQChannelSubPriority = 0, + .NVIC_IRQChannelCmd = ENABLE, + }, + }, + .exti = { + .init = { + .EXTI_Line = EXTI_Line0, // matches above GPIO pin + .EXTI_Mode = EXTI_Mode_Interrupt, + .EXTI_Trigger = EXTI_Trigger_Rising_Falling, + .EXTI_LineCmd = ENABLE, + }, + }, +}; +static const struct pios_exti_cfg pios_exti_vsync_cfg __exti_config = { + .vector = PIOS_Vsync_ISR, + .line = EXTI_Line11, + .pin = { + .gpio = GPIOC, + .init = { + .GPIO_Pin = GPIO_Pin_11, + .GPIO_Speed = GPIO_Speed_100MHz, + .GPIO_Mode = GPIO_Mode_IN, + .GPIO_OType = GPIO_OType_OD, + .GPIO_PuPd = GPIO_PuPd_NOPULL, + }, + }, + .irq = { + .init = { + .NVIC_IRQChannel = EXTI15_10_IRQn, + .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH, + .NVIC_IRQChannelSubPriority = 0, + .NVIC_IRQChannelCmd = ENABLE, + }, + }, + .exti = { + .init = { + .EXTI_Line = EXTI_Line11, // matches above GPIO pin + .EXTI_Mode = EXTI_Mode_Interrupt, + .EXTI_Trigger = EXTI_Trigger_Falling, + .EXTI_LineCmd = ENABLE, + }, + }, +}; + + +static const struct pios_video_cfg pios_video_cfg = { + .mask = { + .regs = SPI3, + .remap = GPIO_AF_SPI3, + .init = { + .SPI_Mode = SPI_Mode_Master, + .SPI_Direction = SPI_Direction_1Line_Tx, + .SPI_DataSize = SPI_DataSize_16b, + .SPI_NSS = SPI_NSS_Soft, + .SPI_FirstBit = SPI_FirstBit_MSB, + .SPI_CRCPolynomial = 7, + .SPI_CPOL = SPI_CPOL_Low, + .SPI_CPHA = SPI_CPHA_2Edge, + .SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_4, + }, + .use_crc = false, + .dma = { + .irq = { + // Note this is the stream ID that triggers interrupts (in this case RX) + .flags = (DMA_IT_TCIF7), + .init = { + .NVIC_IRQChannel = DMA1_Stream7_IRQn, + .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH, + .NVIC_IRQChannelSubPriority = 0, + .NVIC_IRQChannelCmd = ENABLE, + }, + }, + + .rx = { + //not used + .channel = DMA1_Stream4, + .init = { + .DMA_Channel = DMA_Channel_0, + .DMA_PeripheralBaseAddr = (uint32_t) & (SPI3->DR), + .DMA_DIR = DMA_DIR_PeripheralToMemory, + .DMA_PeripheralInc = DMA_PeripheralInc_Disable, + .DMA_MemoryInc = DMA_MemoryInc_Enable, + .DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord, + .DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord, + .DMA_Mode = DMA_Mode_Normal, + .DMA_Priority = DMA_Priority_Medium, + //TODO: Enable FIFO + .DMA_FIFOMode = DMA_FIFOMode_Disable, + .DMA_FIFOThreshold = DMA_FIFOThreshold_Full, + .DMA_MemoryBurst = DMA_MemoryBurst_Single, + .DMA_PeripheralBurst = DMA_PeripheralBurst_Single, + }, + }, + .tx = { + .channel = DMA1_Stream7, + .init = { + .DMA_Channel = DMA_Channel_0, + .DMA_PeripheralBaseAddr = (uint32_t) & (SPI3->DR), + .DMA_DIR = DMA_DIR_MemoryToPeripheral, + .DMA_BufferSize = BUFFER_LINE_LENGTH, + .DMA_PeripheralInc = DMA_PeripheralInc_Disable, + .DMA_MemoryInc = DMA_MemoryInc_Enable, + .DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord, + .DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord, + .DMA_Mode = DMA_Mode_Normal, + .DMA_Priority = DMA_Priority_High, + .DMA_FIFOMode = DMA_FIFOMode_Disable, + .DMA_FIFOThreshold = DMA_FIFOThreshold_Full, + .DMA_MemoryBurst = DMA_MemoryBurst_Single, + .DMA_PeripheralBurst = DMA_PeripheralBurst_Single, + }, + }, + }, + .sclk = { + .gpio = GPIOC, + .init = { + .GPIO_Pin = GPIO_Pin_10, + .GPIO_Speed = GPIO_Speed_100MHz, + .GPIO_Mode = GPIO_Mode_AF, + .GPIO_OType = GPIO_OType_PP, + .GPIO_PuPd = GPIO_PuPd_NOPULL + }, + }, + .miso = { + .gpio = GPIOC, + .init = { + .GPIO_Pin = GPIO_Pin_11, + .GPIO_Speed = GPIO_Speed_50MHz, + .GPIO_Mode = GPIO_Mode_AF, + .GPIO_OType = GPIO_OType_PP, + .GPIO_PuPd = GPIO_PuPd_NOPULL + }, + }, + .mosi = { + .gpio = GPIOC, + .init = { + .GPIO_Pin = GPIO_Pin_12, + .GPIO_Speed = GPIO_Speed_50MHz, + .GPIO_Mode = GPIO_Mode_AF, + .GPIO_OType = GPIO_OType_PP, + .GPIO_PuPd = GPIO_PuPd_NOPULL + }, + }, + .slave_count = 1, + }, + .level = { + .regs = SPI1, + .remap = GPIO_AF_SPI1, + .init = { + .SPI_Mode = SPI_Mode_Slave, + .SPI_Direction = SPI_Direction_1Line_Tx, + .SPI_DataSize = SPI_DataSize_16b, + .SPI_NSS = SPI_NSS_Soft, + .SPI_FirstBit = SPI_FirstBit_MSB, + .SPI_CRCPolynomial = 7, + .SPI_CPOL = SPI_CPOL_Low, + .SPI_CPHA = SPI_CPHA_2Edge, + .SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_2, + }, + .use_crc = false, + .dma = { + .irq = { + .flags = (DMA_IT_TCIF5), + .init = { + .NVIC_IRQChannel = DMA2_Stream5_IRQn, + .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH, + .NVIC_IRQChannelSubPriority = 0, + .NVIC_IRQChannelCmd = ENABLE, + }, + }, + + .rx = { + //not used + .channel = DMA2_Stream0, + .init = { + .DMA_Channel = DMA_Channel_3, + .DMA_PeripheralBaseAddr = (uint32_t)&(SPI1->DR), + .DMA_DIR = DMA_DIR_PeripheralToMemory, + .DMA_PeripheralInc = DMA_PeripheralInc_Disable, + .DMA_MemoryInc = DMA_MemoryInc_Enable, + .DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte, + .DMA_MemoryDataSize = DMA_MemoryDataSize_Byte, + .DMA_Mode = DMA_Mode_Normal, + .DMA_Priority = DMA_Priority_Medium, + .DMA_FIFOMode = DMA_FIFOMode_Disable, + /* .DMA_FIFOThreshold */ + .DMA_MemoryBurst = DMA_MemoryBurst_Single, + .DMA_PeripheralBurst = DMA_PeripheralBurst_Single, + }, + }, + .tx = { + .channel = DMA2_Stream5, + .init = { + .DMA_Channel = DMA_Channel_3, + .DMA_PeripheralBaseAddr = (uint32_t)&(SPI1->DR), + .DMA_DIR = DMA_DIR_MemoryToPeripheral, + .DMA_BufferSize = BUFFER_LINE_LENGTH, + .DMA_PeripheralInc = DMA_PeripheralInc_Disable, + .DMA_MemoryInc = DMA_MemoryInc_Enable, + .DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord, + .DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord, + .DMA_Mode = DMA_Mode_Normal, + .DMA_Priority = DMA_Priority_High, + .DMA_FIFOMode = DMA_FIFOMode_Disable, + .DMA_FIFOThreshold = DMA_FIFOThreshold_Full, + .DMA_MemoryBurst = DMA_MemoryBurst_Single, + .DMA_PeripheralBurst = DMA_PeripheralBurst_Single, + }, + }, + }, + .sclk = { + .gpio = GPIOB, + .init = { + .GPIO_Pin = GPIO_Pin_3, + .GPIO_Speed = GPIO_Speed_100MHz, + .GPIO_Mode = GPIO_Mode_AF, + .GPIO_OType = GPIO_OType_PP, + .GPIO_PuPd = GPIO_PuPd_UP + }, + }, + .miso = { + .gpio = GPIOB, + .init = { + .GPIO_Pin = GPIO_Pin_4, + .GPIO_Speed = GPIO_Speed_50MHz, + .GPIO_Mode = GPIO_Mode_AF, + .GPIO_OType = GPIO_OType_PP, + .GPIO_PuPd = GPIO_PuPd_UP + }, + }, + .mosi = { + .gpio = GPIOB, + .init = { + .GPIO_Pin = GPIO_Pin_5, + .GPIO_Speed = GPIO_Speed_50MHz, + .GPIO_Mode = GPIO_Mode_AF, + .GPIO_OType = GPIO_OType_PP, + .GPIO_PuPd = GPIO_PuPd_UP + }, + }, + .slave_count = 1, + + }, + ///////////////// + + .hsync = &pios_exti_hsync_cfg, + .vsync = &pios_exti_vsync_cfg, +}; + + + + +void PIOS_VIDEO_DMA_Handler(void); +void DMA1_Stream7_IRQHandler(void) __attribute__ ((alias("PIOS_VIDEO_DMA_Handler"))); +void DMA2_Stream5_IRQHandler(void) __attribute__ ((alias("PIOS_VIDEO_DMA_Handler"))); + +/** + * @brief Interrupt for half and full buffer transfer + * + * This interrupt handler swaps between the two halfs of the double buffer to make + * sure the ahrs uses the most recent data. Only swaps data when AHRS is idle, but + * really this is a pretense of a sanity check since the DMA engine is consantly + * running in the background. Keep an eye on the ekf_too_slow variable to make sure + * it's keeping up. + */ +void PIOS_VIDEO_DMA_Handler(void) +{ + if (DMA_GetFlagStatus(DMA1_Stream7,DMA_FLAG_TCIF7)) { // whole double buffer filled + DMA_ClearFlag(DMA1_Stream5,DMA_FLAG_TCIF7); + //PIOS_LED_Toggle(LED2); + } + else if (DMA_GetFlagStatus(DMA1_Stream7,DMA_FLAG_HTIF7)) { + DMA_ClearFlag(DMA1_Stream5,DMA_FLAG_HTIF7); + } + else { + + } + + if (DMA_GetFlagStatus(DMA2_Stream5,DMA_FLAG_TCIF5)) { // whole double buffer filled + DMA_ClearFlag(DMA2_Stream5,DMA_FLAG_TCIF5); + //PIOS_LED_Toggle(LED3); + } + else if (DMA_GetFlagStatus(DMA2_Stream5,DMA_FLAG_HTIF5)) { + DMA_ClearFlag(DMA2_Stream5,DMA_FLAG_HTIF5); + } + else { + + } + +} + +#endif + diff --git a/make/boards/osd/board-info.mk b/make/boards/osd/board-info.mk index f0104609f..efe04bcbd 100644 --- a/make/boards/osd/board-info.mk +++ b/make/boards/osd/board-info.mk @@ -9,12 +9,14 @@ BOARD := STM32F4xx_OSD MODEL := HD MODEL_SUFFIX := -OPENOCD_CONFIG := stm32f4xx.cfg +OPENOCD_JTAG_CONFIG := stlink-v2.cfg +OPENOCD_CONFIG := stm32f4xx.stlink.cfg +#OPENOCD_CONFIG := stm32f4xx.cfg # Note: These must match the values in link_$(BOARD)_memory.ld BL_BANK_BASE := 0x08000000 # Start of bootloader flash -BL_BANK_SIZE := 0x00000000 # Should include BD_INFO region -FW_BANK_BASE := 0x08000000 # Start of firmware flash +BL_BANK_SIZE := 0x00008000 # Should include BD_INFO region +FW_BANK_BASE := 0x08008000 # Start of firmware flash FW_BANK_SIZE := 0x000F8000 # Should include FW_DESC_SIZE FW_DESC_SIZE := 0x00000064