Compare commits

...

7 commits

Author SHA1 Message Date
cdb7fb1f0e same54_xplained: Rename (was missing "5") 2020-07-08 13:48:54 -05:00
Dan Halbert
85dcfde89f
Merge pull request #129 from slyalfa/master
3 bugs fixed. Only tested on samd51
2020-07-05 16:22:08 -04:00
slyalfa
fb3ca87d70 3 bugs fixed. Only tested on samd51
1: Fix for baud samd21 vs samd51
2: Added fix for first run where super slow first run of crc would cause
overruns on USART.
3: Prevent GCC from optimizing out a busy wait loop in Xmodem code
2020-07-05 12:42:53 -07:00
Dan Halbert
e585be56f1
Merge pull request #126 from dnbdmr/readme_fix
Small fix to README.md
2020-06-25 09:42:06 -04:00
dnbdmr
70382927d2 Small fix to README.md 2020-06-25 06:15:40 -07:00
Dan Halbert
a29db5a9a4
Merge pull request #125 from jepler/sam-e54-xplained
Add configuration for SAM E54 Xplained
2020-06-18 14:02:59 -04:00
Jeff Epler
07f012ea35 Add configuration for SAM E54 Xplained 2020-06-18 11:56:58 -05:00
4 changed files with 47 additions and 6 deletions

View file

@ -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/`.

View file

@ -0,0 +1,2 @@
CHIP_FAMILY = samd51
CHIP_VARIANT = SAME54P20A

View 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

View file

@ -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;