[dartuino][bootloader] Create a project for the bootloader.
This commit is contained in:
@@ -5,4 +5,7 @@ MODULE := $(LOCAL_DIR)
|
||||
MODULE_SRCS += \
|
||||
$(LOCAL_DIR)/spifstest.c
|
||||
|
||||
MODULE_DEPS += \
|
||||
lib/libm \
|
||||
|
||||
include make/module.mk
|
||||
|
||||
9
project/dartuinoP0-bootloader.mk
Normal file
9
project/dartuinoP0-bootloader.mk
Normal file
@@ -0,0 +1,9 @@
|
||||
include project/target/dartuinoP0.mk
|
||||
|
||||
# Keep the FS for loading recovery images.
|
||||
include project/virtual/fs.mk
|
||||
|
||||
MODULES += \
|
||||
app/shell \
|
||||
lib/version \
|
||||
lib/buildsig \
|
||||
@@ -5,3 +5,46 @@ include project/virtual/minip.mk
|
||||
# Console serial port is on pins PA9(TX) and PB7(RX)
|
||||
|
||||
include project/virtual/fs.mk
|
||||
|
||||
DISPLAY_PANEL_TYPE ?= LS013B7DH06
|
||||
|
||||
MODULE_DEPS += \
|
||||
app/accelerometer \
|
||||
|
||||
MODULE_SRCS += \
|
||||
$(LOCAL_DIR)/sensor_bus.c \
|
||||
|
||||
GLOBAL_DEFINES += \
|
||||
ENABLE_SENSORBUS=1
|
||||
|
||||
|
||||
ifneq ($(DISPLAY_PANEL_TYPE),)
|
||||
|
||||
MODULE_SRCS += \
|
||||
$(LOCAL_DIR)/memory_lcd.c
|
||||
|
||||
GLOBAL_DEFINES += \
|
||||
ENABLE_LCD=1
|
||||
|
||||
endif
|
||||
|
||||
ifeq ($(DISPLAY_PANEL_TYPE),LS013B7DH06)
|
||||
|
||||
GLOBAL_DEFINES += \
|
||||
LCD_LS013B7DH06=1
|
||||
MODULE_SRCS += \
|
||||
$(LOCAL_DIR)/display/LS013B7DH06.c
|
||||
|
||||
else ifeq ($(DISPLAY_PANEL_TYPE),LS027B7DH01)
|
||||
|
||||
GLOBAL_DEFINES += \
|
||||
LCD_LS027B7DH01=1
|
||||
MODULE_SRCS += \
|
||||
$(LOCAL_DIR)/display/memory_lcd_mono.c
|
||||
|
||||
else ifeq ($(DISPLAY_PANEL_TYPE),LS013B7DH03)
|
||||
GLOBAL_DEFINES += \
|
||||
LCD_LS013B7DH03=1
|
||||
MODULE_SRCS += \
|
||||
$(LOCAL_DIR)/display/memory_lcd_mono.c
|
||||
endif
|
||||
@@ -38,10 +38,16 @@
|
||||
#include <target/bmi055.h>
|
||||
#include <target/debugconfig.h>
|
||||
#include <target/gpioconfig.h>
|
||||
#include <target/memory_lcd.h>
|
||||
#include <target/sensor_bus.h>
|
||||
#include <reg.h>
|
||||
|
||||
#if ENABLE_LCD
|
||||
#include <target/memory_lcd.h>
|
||||
#endif
|
||||
|
||||
#if ENABLE_SENSORBUS
|
||||
#include <target/sensor_bus.h>
|
||||
#endif
|
||||
|
||||
#if WITH_LIB_MINIP
|
||||
#include <lib/minip.h>
|
||||
#endif
|
||||
@@ -90,16 +96,6 @@ void target_early_init(void)
|
||||
gpio_init.Pin = GPIO_TO_PIN_MASK(GPIO_LED114) | GPIO_TO_PIN_MASK(GPIO_LED115);
|
||||
HAL_GPIO_Init(GPIOJ, &gpio_init);
|
||||
|
||||
// Initialize to a pattern just so we know we have something
|
||||
gpio_set(GPIO_LED108, GPIO_LED_ON);
|
||||
gpio_set(GPIO_LED109, GPIO_LED_ON);
|
||||
gpio_set(GPIO_LED110, GPIO_LED_ON);
|
||||
gpio_set(GPIO_LED111, GPIO_LED_ON);
|
||||
gpio_set(GPIO_LED112, GPIO_LED_ON);
|
||||
gpio_set(GPIO_LED113, GPIO_LED_ON);
|
||||
gpio_set(GPIO_LED114, GPIO_LED_ON);
|
||||
gpio_set(GPIO_LED115, GPIO_LED_ON);
|
||||
|
||||
// Initialize the switches GPIOs for interrupt on raising edge. In order
|
||||
// to use stm32_EXTI15_10_IRQ() handler needs to be provided and EXTI15_10_IRQn
|
||||
// needs to be enabled.
|
||||
@@ -112,8 +108,10 @@ void target_early_init(void)
|
||||
GPIO_TO_PIN_MASK(GPIO_SW102) | GPIO_TO_PIN_MASK(GPIO_SW103);
|
||||
HAL_GPIO_Init(GPIOJ, &gpio_init);
|
||||
|
||||
#if ENABLE_SENSORBUS
|
||||
// Initialize Sensor bus (accelerometer / gyroscope / nrf51 spi bus
|
||||
sensor_bus_init_early();
|
||||
#endif
|
||||
|
||||
// now that the uart gpios are configured, enable the debug uart.
|
||||
stm32_debug_early_init();
|
||||
@@ -132,7 +130,9 @@ void target_init(void)
|
||||
|
||||
qspi_flash_init(N25Q128A_FLASH_SIZE);
|
||||
|
||||
#if ENABLE_LCD
|
||||
memory_lcd_init();
|
||||
#endif
|
||||
|
||||
#if WITH_LIB_MINIP
|
||||
uint8_t mac_addr[6];
|
||||
@@ -164,7 +164,9 @@ void target_init(void)
|
||||
// start usb
|
||||
target_usb_setup();
|
||||
|
||||
#if ENABLE_SENSORBUS
|
||||
sensor_bus_init();
|
||||
#endif
|
||||
}
|
||||
|
||||
void HAL_SPI_MspInit(SPI_HandleTypeDef *hspi)
|
||||
@@ -203,7 +205,6 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef *hspi)
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_12;
|
||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||
|
||||
|
||||
/*##-3- Configure the NVIC for SPI #########################################*/
|
||||
/* NVIC for SPI */
|
||||
HAL_NVIC_EnableIRQ(SPI2_IRQn);
|
||||
|
||||
@@ -9,8 +9,6 @@ PLATFORM := stm32f7xx
|
||||
SDRAM_SIZE := 0x00800000
|
||||
SDRAM_BASE := 0xc0000000
|
||||
|
||||
DISPLAY_PANEL_TYPE ?= LS013B7DH06
|
||||
|
||||
GLOBAL_DEFINES += \
|
||||
ENABLE_UART3=1 \
|
||||
ENABLE_SDRAM=1 \
|
||||
@@ -25,43 +23,15 @@ GLOBAL_DEFINES += \
|
||||
\
|
||||
TARGET_HAS_DEBUG_LED=1
|
||||
|
||||
MODULE_DEPS += \
|
||||
app/accelerometer \
|
||||
|
||||
GLOBAL_INCLUDES += $(LOCAL_DIR)/include
|
||||
|
||||
MODULE_SRCS += \
|
||||
$(LOCAL_DIR)/init.c \
|
||||
$(LOCAL_DIR)/sensor_bus.c \
|
||||
$(LOCAL_DIR)/usb.c \
|
||||
|
||||
ifneq ($(DISPLAY_PANEL_TYPE),)
|
||||
|
||||
MODULE_SRCS += \
|
||||
$(LOCAL_DIR)/memory_lcd.c
|
||||
|
||||
endif
|
||||
|
||||
ifeq ($(DISPLAY_PANEL_TYPE),LS013B7DH06)
|
||||
|
||||
GLOBAL_DEFINES += \
|
||||
LCD_LS013B7DH06=1
|
||||
MODULE_SRCS += \
|
||||
$(LOCAL_DIR)/display/LS013B7DH06.c
|
||||
|
||||
else ifeq ($(DISPLAY_PANEL_TYPE),LS027B7DH01)
|
||||
|
||||
GLOBAL_DEFINES += \
|
||||
LCD_LS027B7DH01=1
|
||||
MODULE_SRCS += \
|
||||
$(LOCAL_DIR)/display/memory_lcd_mono.c
|
||||
|
||||
else ifeq ($(DISPLAY_PANEL_TYPE),LS013B7DH03)
|
||||
GLOBAL_DEFINES += \
|
||||
LCD_LS013B7DH03=1
|
||||
MODULE_SRCS += \
|
||||
$(LOCAL_DIR)/display/memory_lcd_mono.c
|
||||
endif
|
||||
MODULE_DEPS += \
|
||||
dev/usb
|
||||
|
||||
include make/module.mk
|
||||
|
||||
|
||||
@@ -80,34 +80,6 @@ static const uint8_t cfg_descr[] = {
|
||||
|
||||
static const uchar langid[] = { 0x04, 0x03, 0x09, 0x04 };
|
||||
|
||||
static const uint8_t if_descriptor_lowspeed[] = {
|
||||
0x09, /* length */
|
||||
INTERFACE, /* type */
|
||||
0x01, /* interface num */
|
||||
0x00, /* alternates */
|
||||
0x02, /* endpoint count */
|
||||
0xff, /* interface class */
|
||||
0xff, /* interface subclass */
|
||||
0x00, /* interface protocol */
|
||||
0x00, /* string index */
|
||||
|
||||
/* endpoint 1 IN */
|
||||
0x07, /* length */
|
||||
ENDPOINT, /* type */
|
||||
0x81, /* address: 1 IN */
|
||||
0x02, /* type: bulk */
|
||||
W(64), /* max packet size: 64 */
|
||||
00, /* interval */
|
||||
|
||||
/* endpoint 1 OUT */
|
||||
0x07, /* length */
|
||||
ENDPOINT, /* type */
|
||||
0x01, /* address: 1 OUT */
|
||||
0x02, /* type: bulk */
|
||||
W(64), /* max packet size: 64 */
|
||||
00, /* interval */
|
||||
};
|
||||
|
||||
usb_config config = {
|
||||
.lowspeed = {
|
||||
.device = USB_DESC_STATIC(dev_descr),
|
||||
@@ -123,97 +95,13 @@ usb_config config = {
|
||||
.langid = USB_DESC_STATIC(langid),
|
||||
};
|
||||
|
||||
static status_t ep_cb_rx(ep_t endpoint, usbc_transfer_t *t);
|
||||
static status_t ep_cb_tx(ep_t endpoint, usbc_transfer_t *t);
|
||||
|
||||
static void queue_rx(void)
|
||||
{
|
||||
static usbc_transfer_t transfer;
|
||||
static uint8_t buf[512];
|
||||
|
||||
transfer.callback = &ep_cb_rx;
|
||||
transfer.result = 0;
|
||||
transfer.buf = &buf;
|
||||
transfer.buflen = sizeof(buf);
|
||||
transfer.bufpos = 0;
|
||||
transfer.extra = 0;
|
||||
|
||||
usbc_queue_rx(1, &transfer);
|
||||
}
|
||||
|
||||
static void queue_tx(void)
|
||||
{
|
||||
static usbc_transfer_t transfer;
|
||||
static uint8_t buf[512];
|
||||
|
||||
for (uint i = 0; i < sizeof(buf); i++) {
|
||||
buf[i] = ~i;
|
||||
}
|
||||
|
||||
transfer.callback = &ep_cb_tx;
|
||||
transfer.result = 0;
|
||||
transfer.buf = &buf;
|
||||
transfer.buflen = sizeof(buf);
|
||||
transfer.bufpos = 0;
|
||||
transfer.extra = 0;
|
||||
|
||||
usbc_queue_tx(1, &transfer);
|
||||
}
|
||||
|
||||
static status_t ep_cb_rx(ep_t endpoint, usbc_transfer_t *t)
|
||||
{
|
||||
#if LOCAL_TRACE
|
||||
LTRACEF("ep %u transfer %p\n", endpoint, t);
|
||||
usbc_dump_transfer(t);
|
||||
|
||||
if (t->result >= 0) {
|
||||
hexdump8(t->buf, t->bufpos);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (t->result >= 0)
|
||||
queue_rx();
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
static status_t ep_cb_tx(ep_t endpoint, usbc_transfer_t *t)
|
||||
{
|
||||
#if LOCAL_TRACE
|
||||
LTRACEF("ep %u transfer %p\n", endpoint, t);
|
||||
usbc_dump_transfer(t);
|
||||
#endif
|
||||
|
||||
if (t->result >= 0)
|
||||
queue_tx();
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
static status_t usb_cb(void *cookie, usb_callback_op_t op, const union usb_callback_args *args)
|
||||
{
|
||||
LTRACEF("cookie %p, op %u, args %p\n", cookie, op, args);
|
||||
|
||||
if (op == USB_CB_ONLINE) {
|
||||
usbc_setup_endpoint(1, USB_IN, 0x40);
|
||||
usbc_setup_endpoint(1, USB_OUT, 0x40);
|
||||
|
||||
queue_rx();
|
||||
queue_tx();
|
||||
}
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
void target_usb_setup(void)
|
||||
{
|
||||
usb_setup(&config);
|
||||
printf("appending interfaces\n");
|
||||
usb_append_interface_lowspeed(if_descriptor_lowspeed, sizeof(if_descriptor_lowspeed));
|
||||
usb_append_interface_highspeed(if_descriptor_lowspeed, sizeof(if_descriptor_lowspeed));
|
||||
|
||||
usb_add_string("LK", 1);
|
||||
usb_add_string("LK Industries", 2);
|
||||
|
||||
usb_register_callback(&usb_cb, NULL);
|
||||
usb_start();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user