Compare commits
7 commits
master
...
fix-sam-e5
| Author | SHA1 | Date | |
|---|---|---|---|
| cdb7fb1f0e | |||
|
|
85dcfde89f | ||
|
|
fb3ca87d70 | ||
|
|
e585be56f1 | ||
|
|
70382927d2 | ||
|
|
a29db5a9a4 | ||
|
|
07f012ea35 |
4 changed files with 47 additions and 6 deletions
|
|
@ -145,7 +145,7 @@ The default board is `zero`. You can build a different one using:
|
|||
make BOARD=metro_m0
|
||||
```
|
||||
|
||||
If you're working on different board, it's best to create `Makefile.local`
|
||||
If you're working on different board, it's best to create `Makefile.user`
|
||||
with say `BOARD=metro` to change the default.
|
||||
The names `zero` and `metro` refer to subdirectories of `boards/`.
|
||||
|
||||
|
|
|
|||
2
boards/same54_xplained/board.mk
Normal file
2
boards/same54_xplained/board.mk
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
CHIP_FAMILY = samd51
|
||||
CHIP_VARIANT = SAME54P20A
|
||||
29
boards/same54_xplained/board_config.h
Normal file
29
boards/same54_xplained/board_config.h
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
#ifndef BOARD_CONFIG_H
|
||||
#define BOARD_CONFIG_H
|
||||
|
||||
#define VENDOR_NAME "Microchip"
|
||||
#define PRODUCT_NAME "SAME54 Xplained"
|
||||
#define VOLUME_LABEL "E54XBOOT"
|
||||
#define INDEX_URL "https://www.microchip.com/developmenttools/ProductDetails/atsame54-xpro"
|
||||
#define BOARD_ID "SAME54P20A-Xplained-v0"
|
||||
|
||||
#define USB_VID 0x239A
|
||||
#define USB_PID 0x00B5
|
||||
|
||||
#define LED_PIN PIN_PC18
|
||||
|
||||
#define BOARD_NEOPIXEL_PIN PIN_PC24
|
||||
#define BOARD_NEOPIXEL_COUNT 0
|
||||
|
||||
#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_PAD1_TX_PAD0
|
||||
#define BOOT_USART_PAD3 PINMUX_UNUSED
|
||||
#define BOOT_USART_PAD2 PINMUX_UNUSED
|
||||
#define BOOT_USART_PAD1 PINMUX_PB25C_SERCOM0_PAD1
|
||||
#define BOOT_USART_PAD0 PINMUX_PB24C_SERCOM0_PAD0
|
||||
#define BOOT_GCLK_ID_CORE SERCOM0_GCLK_ID_CORE
|
||||
#define BOOT_GCLK_ID_SLOW SERCOM0_GCLK_ID_SLOW
|
||||
|
||||
#endif
|
||||
|
|
@ -115,6 +115,8 @@ void usart_open() {
|
|||
clkctrl.bit.WRTLOCK = false;
|
||||
clkctrl.bit.GEN = GCLK_CLKCTRL_GEN_GCLK0_Val;
|
||||
GCLK->CLKCTRL.reg = (clkctrl.reg | temp);
|
||||
/* Baud rate 115200 - clock 8MHz -> BAUD value-50436 */
|
||||
uart_basic_init(BOOT_USART_MODULE, 50436, BOOT_USART_PAD_SETTINGS);
|
||||
#endif
|
||||
|
||||
#ifdef SAMD51
|
||||
|
|
@ -122,10 +124,11 @@ void usart_open() {
|
|||
GCLK->PCHCTRL[BOOT_GCLK_ID_SLOW].reg = GCLK_PCHCTRL_GEN_GCLK3_Val | (1 << GCLK_PCHCTRL_CHEN_Pos);
|
||||
|
||||
MCLK->BOOT_USART_MASK.reg |= BOOT_USART_BUS_CLOCK_INDEX ;
|
||||
/* Baud rate 115200 - clock 48MHz -> BAUD value-63018 */
|
||||
uart_basic_init(BOOT_USART_MODULE, 63018, BOOT_USART_PAD_SETTINGS);
|
||||
#endif
|
||||
|
||||
/* Baud rate 115200 - clock 8MHz -> BAUD value-50436 */
|
||||
uart_basic_init(BOOT_USART_MODULE, 50436, BOOT_USART_PAD_SETTINGS);
|
||||
|
||||
|
||||
// Initialize flag
|
||||
b_sharp_received = false;
|
||||
|
|
@ -158,9 +161,6 @@ int usart_putc(int value) {
|
|||
|
||||
int usart_getc(void) {
|
||||
uint16_t retval;
|
||||
// Wait until input buffer is filled
|
||||
while (!(usart_is_rx_ready()))
|
||||
;
|
||||
retval = (uint16_t)uart_read_byte(BOOT_USART_MODULE);
|
||||
// usart_read_wait(&usart_sam_ba, &retval);
|
||||
return (int)retval;
|
||||
|
|
@ -423,6 +423,13 @@ uint32_t usart_getdata_xmd(void *data, uint32_t length) {
|
|||
uint32_t b_run, nbr_of_timeout = 100;
|
||||
uint8_t sno = 0x01;
|
||||
uint32_t data_transfered = 0;
|
||||
uint16_t crc = 0;
|
||||
|
||||
for (int i =0; i < 128; i++)
|
||||
{
|
||||
crc = add_crc(i, crc); // warm up crc function very slow on first run
|
||||
}
|
||||
|
||||
|
||||
// Copied from legacy source code ... might need some tweaking
|
||||
uint32_t loops_per_second =
|
||||
|
|
@ -444,7 +451,10 @@ uint32_t usart_getdata_xmd(void *data, uint32_t length) {
|
|||
usart_putc('C');
|
||||
timeout = loops_per_second;
|
||||
while (!(usart_is_rx_ready()) && timeout)
|
||||
{
|
||||
timeout--;
|
||||
__asm__ volatile(""); // How to prevent GCC from optimizing out a busy wait loop
|
||||
}
|
||||
if (timeout)
|
||||
break;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue