Skip to content

Commit

Permalink
Merge pull request #39 from adafruit/master
Browse files Browse the repository at this point in the history
shumatech stack corruption fix; metro m4 updates; CPX neopixel glitch fix
  • Loading branch information
mmoskal authored Mar 21, 2018
2 parents 1f706a1 + 509d60d commit 7e6819e
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -182,4 +182,4 @@ all-boards:
drop: all-boards drop-pkg

$(SUBMODULES):
git submodule update --init --recursive
git submodule update --init --recursive
18 changes: 9 additions & 9 deletions boards/metro_m4/board_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@
#define USB_VID 0x239A
#define USB_PID 0x0021

#define LED_PIN PIN_PA21
#define LED_PIN PIN_PA16
#define LED_TX_PIN PIN_PA27
#define LED_RX_PIN PIN_PB06

#define BOARD_NEOPIXEL_PIN PIN_PB17
#define BOARD_NEOPIXEL_PIN PIN_PB22
#define BOARD_NEOPIXEL_COUNT 1

#define BOOT_USART_MODULE SERCOM0
#define BOOT_USART_MODULE SERCOM3
#define BOOT_USART_MASK APBAMASK
#define BOOT_USART_BUS_CLOCK_INDEX MCLK_APBAMASK_SERCOM0
#define BOOT_USART_PAD_SETTINGS UART_RX_PAD3_TX_PAD2
#define BOOT_USART_BUS_CLOCK_INDEX MCLK_APBBMASK_SERCOM3
#define BOOT_USART_PAD_SETTINGS UART_RX_PAD1_TX_PAD0
#define BOOT_USART_PAD3 PINMUX_UNUSED
#define BOOT_USART_PAD2 PINMUX_UNUSED
#define BOOT_USART_PAD1 PINMUX_PA10C_SERCOM0_PAD2
#define BOOT_USART_PAD0 PINMUX_PA11C_SERCOM0_PAD3
#define BOOT_GCLK_ID_CORE SERCOM0_GCLK_ID_CORE
#define BOOT_GCLK_ID_SLOW SERCOM0_GCLK_ID_SLOW
#define BOOT_USART_PAD1 PINMUX_PA22C_SERCOM3_PAD0
#define BOOT_USART_PAD0 PINMUX_PA23C_SERCOM3_PAD1
#define BOOT_GCLK_ID_CORE SERCOM3_GCLK_ID_CORE
#define BOOT_GCLK_ID_SLOW SERCOM3_GCLK_ID_SLOW

#endif
2 changes: 2 additions & 0 deletions boards/metro_m4_revb/board.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CHIP_FAMILY = samd51
CHIP_VARIANT = SAMD51J19A
31 changes: 31 additions & 0 deletions boards/metro_m4_revb/board_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#ifndef BOARD_CONFIG_H
#define BOARD_CONFIG_H

#define VENDOR_NAME "Adafruit Industries"
#define PRODUCT_NAME "Metro M4 Rev B"
#define VOLUME_LABEL "METROM4BOOT"
#define INDEX_URL "http://adafru.it/3505"
#define BOARD_ID "SAMD51J19A-Metro-v0"

#define USB_VID 0x239A
#define USB_PID 0x0021

#define LED_PIN PIN_PA21
#define LED_TX_PIN PIN_PA27
#define LED_RX_PIN PIN_PB06

#define BOARD_NEOPIXEL_PIN PIN_PB17
#define BOARD_NEOPIXEL_COUNT 1

#define BOOT_USART_MODULE SERCOM0
#define BOOT_USART_MASK APBAMASK
#define BOOT_USART_BUS_CLOCK_INDEX MCLK_APBAMASK_SERCOM0
#define BOOT_USART_PAD_SETTINGS UART_RX_PAD3_TX_PAD2
#define BOOT_USART_PAD3 PINMUX_UNUSED
#define BOOT_USART_PAD2 PINMUX_UNUSED
#define BOOT_USART_PAD1 PINMUX_PA10C_SERCOM0_PAD2
#define BOOT_USART_PAD0 PINMUX_PA11C_SERCOM0_PAD3
#define BOOT_GCLK_ID_CORE SERCOM0_GCLK_ID_CORE
#define BOOT_GCLK_ID_SLOW SERCOM0_GCLK_ID_SLOW

#endif
13 changes: 5 additions & 8 deletions src/sam_ba_monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,7 @@ volatile uint32_t sp;
void call_applet(uint32_t address) {
uint32_t app_start_address;

__disable_irq();
__DMB();

/* Save current Stack Pointer */
sp = __get_MSP();

/* Rebase the Stack Pointer */
Expand All @@ -106,7 +104,10 @@ void call_applet(uint32_t address) {
app_start_address = *(uint32_t *)(address + 4);

/* Jump to application Reset Handler in the application */
asm("bx %0" ::"r"(app_start_address));
asm("blx %0" ::"r"(app_start_address):"r0","r1","r2","r3","lr");

/* Rebase the Stack Pointer */
__set_MSP(sp);
}

uint32_t current_number;
Expand Down Expand Up @@ -193,10 +194,6 @@ void sam_ba_monitor_run(void) {
sam_ba_putdata_term((uint8_t *)&current_number, 4);
} else if (command == 'G') {
call_applet(current_number);
/* Rebase the Stack Pointer */
__set_MSP(sp);
__DMB();
__enable_irq();
if (b_sam_ba_interface_usart) {
cdc_write_buf("\x06", 1);
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,10 @@ void led_init() {
// using APA102, set pins to outputs
PINOP(BOARD_RGBLED_CLOCK_PIN, DIRSET);
PINOP(BOARD_RGBLED_DATA_PIN, DIRSET);
#endif

// This won't work for neopixel, because we're running at 1MHz or thereabouts...
RGBLED_set_color(COLOR_LEAVE);
#endif
}

#if defined(BOARD_RGBLED_CLOCK_PIN)
Expand Down

0 comments on commit 7e6819e

Please sign in to comment.