From 2b9c2a3ad54fbc613896609c3c412490b2ef54ed Mon Sep 17 00:00:00 2001 From: edolomb Date: Mon, 12 Feb 2018 16:20:40 +0000 Subject: SAMA5D2-SERIAL now runs in DDR using FLEXCOM0 as serial git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@11487 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- testhal/ATSAMA5D2/SERIAL/Makefile | 4 +- .../SERIAL/debug/SAMA5D2-SERIAL (DDRAM).launch | 58 ++++++++++++++++++++++ .../debug/SAMA5D2-SERIAL (Load and Run).launch | 2 +- .../SERIAL/debug/SAMA5D2-SERIAL (bootstrap).launch | 11 ++-- testhal/ATSAMA5D2/SERIAL/main.c | 17 ++++--- testhal/ATSAMA5D2/SERIAL/mcuconf.h | 54 ++++++++++---------- testhal/ATSAMA5D2/SERIAL/readme.txt | 3 +- 7 files changed, 107 insertions(+), 42 deletions(-) create mode 100644 testhal/ATSAMA5D2/SERIAL/debug/SAMA5D2-SERIAL (DDRAM).launch diff --git a/testhal/ATSAMA5D2/SERIAL/Makefile b/testhal/ATSAMA5D2/SERIAL/Makefile index 4d7aa8cab..8314f5786 100755 --- a/testhal/ATSAMA5D2/SERIAL/Makefile +++ b/testhal/ATSAMA5D2/SERIAL/Makefile @@ -127,7 +127,9 @@ include $(CHIBIOS)/os/common/ports/ARMCAx-TZ/compilers/GCC/mk/port_generic.mk #include $(CHIBIOS)/test/oslib/oslib_test.mk # Define linker script file here -LDSCRIPT= $(STARTUPLD)/SAMA5D2.ld +#LDSCRIPT= $(STARTUPLD)/SAMA5D2.ld +# Only if SAMA_NO_INIT is TRUE +LDSCRIPT= $(STARTUPLD)/SAMA5D2ddr.ld # C sources that can be compiled in ARM or THUMB mode depending on the global # setting. diff --git a/testhal/ATSAMA5D2/SERIAL/debug/SAMA5D2-SERIAL (DDRAM).launch b/testhal/ATSAMA5D2/SERIAL/debug/SAMA5D2-SERIAL (DDRAM).launch new file mode 100644 index 000000000..65424113b --- /dev/null +++ b/testhal/ATSAMA5D2/SERIAL/debug/SAMA5D2-SERIAL (DDRAM).launch @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/testhal/ATSAMA5D2/SERIAL/debug/SAMA5D2-SERIAL (Load and Run).launch b/testhal/ATSAMA5D2/SERIAL/debug/SAMA5D2-SERIAL (Load and Run).launch index d91981d3d..335e6494a 100644 --- a/testhal/ATSAMA5D2/SERIAL/debug/SAMA5D2-SERIAL (Load and Run).launch +++ b/testhal/ATSAMA5D2/SERIAL/debug/SAMA5D2-SERIAL (Load and Run).launch @@ -1,6 +1,6 @@ - + diff --git a/testhal/ATSAMA5D2/SERIAL/debug/SAMA5D2-SERIAL (bootstrap).launch b/testhal/ATSAMA5D2/SERIAL/debug/SAMA5D2-SERIAL (bootstrap).launch index 8617fc36f..10c372d8d 100644 --- a/testhal/ATSAMA5D2/SERIAL/debug/SAMA5D2-SERIAL (bootstrap).launch +++ b/testhal/ATSAMA5D2/SERIAL/debug/SAMA5D2-SERIAL (bootstrap).launch @@ -1,12 +1,12 @@ - + - + @@ -34,7 +34,7 @@ - + @@ -47,9 +47,12 @@ + + + - + diff --git a/testhal/ATSAMA5D2/SERIAL/main.c b/testhal/ATSAMA5D2/SERIAL/main.c index cd1a382f7..e72c1f43e 100755 --- a/testhal/ATSAMA5D2/SERIAL/main.c +++ b/testhal/ATSAMA5D2/SERIAL/main.c @@ -74,7 +74,7 @@ static THD_FUNCTION(Thread1, arg) { static const SerialConfig sdcfg = { 115200, 0, - UART_MR_PAR_NO + US_MR_CHRL_8_BIT | US_MR_PAR_NO }; /* @@ -95,11 +95,12 @@ int main(void) { /* * Activates the serial driver 1 using the driver default configuration. */ - sdStart(&SD1, &sdcfg); + sdStart(&FSD0, &sdcfg); + + /* Redirecting FLEX0 RX on PB29 and FLEX0 TX on PB28. */ + palSetGroupMode(PIOB, PAL_PORT_BIT(28) | PAL_PORT_BIT(29), 0U, + PAL_SAMA_FUNC_PERIPH_C | PAL_MODE_SECURE); - /* Redirecting UART1 RX on PD2 and UART1 TX on PD3. */ - palSetGroupMode(PIOD, PAL_PORT_BIT(2) | PAL_PORT_BIT(3), 0U, - PAL_SAMA_FUNC_PERIPH_A | PAL_MODE_SECURE); /* * Creates the blinker thread. */ @@ -109,9 +110,9 @@ int main(void) { * Normal main() thread activity. */ while (true) { - getInputString((BaseSequentialStream *)&SD1, lineBuffer, BUFFER_SIZE); - chprintf((BaseSequentialStream *)&SD1, lineBuffer); - chprintf((BaseSequentialStream *)&SD1, "\n\r"); + getInputString((BaseSequentialStream *)&FSD0, lineBuffer, BUFFER_SIZE); + chprintf((BaseSequentialStream *)&FSD0, lineBuffer); + chprintf((BaseSequentialStream *)&FSD0, "\n\r"); chThdSleepMilliseconds(500); } } diff --git a/testhal/ATSAMA5D2/SERIAL/mcuconf.h b/testhal/ATSAMA5D2/SERIAL/mcuconf.h index f084e22cd..4024280c4 100644 --- a/testhal/ATSAMA5D2/SERIAL/mcuconf.h +++ b/testhal/ATSAMA5D2/SERIAL/mcuconf.h @@ -23,7 +23,7 @@ * HAL driver system settings. */ #define SAMA_HAL_IS_SECURE TRUE -#define SAMA_NO_INIT FALSE +#define SAMA_NO_INIT TRUE #define SAMA_MOSCRC_ENABLED FALSE #define SAMA_MOSCXT_ENABLED TRUE #define SAMA_MOSC_SEL SAMA_MOSC_MOSCXT @@ -36,44 +36,24 @@ #define SAMA_H64MX_H32MX_RATIO 2 /* - * SPI driver system settings. + * SDMMC driver system settings. */ -#define SAMA_SPI_USE_SPI0 FALSE -#define SAMA_SPI_USE_SPI1 FALSE -#define SAMA_SPI_USE_FLEXCOM0 FALSE -#define SAMA_SPI_USE_FLEXCOM1 FALSE -#define SAMA_SPI_USE_FLEXCOM2 FALSE -#define SAMA_SPI_USE_FLEXCOM3 FALSE -#define SAMA_SPI_USE_FLEXCOM4 FALSE -#define SAMA_SPI_SPI0_DMA_IRQ_PRIORITY 4 -#define SAMA_SPI_SPI1_DMA_IRQ_PRIORITY 4 -#define SAMA_SPI_FLEXCOM0_DMA_IRQ_PRIORITY 4 -#define SAMA_SPI_FLEXCOM1_DMA_IRQ_PRIORITY 4 -#define SAMA_SPI_FLEXCOM2_DMA_IRQ_PRIORITY 4 -#define SAMA_SPI_FLEXCOM3_DMA_IRQ_PRIORITY 4 -#define SAMA_SPI_FLEXCOM4_DMA_IRQ_PRIORITY 4 -#define SAMA_SPI_DMA_ERROR_HOOK(spip) osalSysHalt("DMA failure") -#define SPI_SELECT_MODE SPI_SELECT_MODE_NONE +#define HAL_USE_SDMMC FALSE /* * SECUMOD driver system settings. */ #define HAL_USE_SECUMOD FALSE -/* - * SDMMC driver system settings. - */ -#define HAL_USE_SDMMC FALSE - /* * SERIAL driver system settings. */ #define SAMA_SERIAL_USE_UART0 FALSE -#define SAMA_SERIAL_USE_UART1 TRUE +#define SAMA_SERIAL_USE_UART1 FALSE #define SAMA_SERIAL_USE_UART2 FALSE #define SAMA_SERIAL_USE_UART3 FALSE #define SAMA_SERIAL_USE_UART4 FALSE -#define SAMA_SERIAL_USE_FLEXCOM0 FALSE +#define SAMA_SERIAL_USE_FLEXCOM0 TRUE #define SAMA_SERIAL_USE_FLEXCOM1 FALSE #define SAMA_SERIAL_USE_FLEXCOM2 FALSE #define SAMA_SERIAL_USE_FLEXCOM3 FALSE @@ -89,12 +69,32 @@ #define SAMA_SERIAL_FLEXCOM3_IRQ_PRIORITY 4 #define SAMA_SERIAL_FLEXCOM4_IRQ_PRIORITY 4 +/* + * SPI driver system settings. + */ +#define SAMA_SPI_USE_SPI0 FALSE +#define SAMA_SPI_USE_SPI1 FALSE +#define SAMA_SPI_USE_FLEXCOM0 FALSE +#define SAMA_SPI_USE_FLEXCOM1 FALSE +#define SAMA_SPI_USE_FLEXCOM2 FALSE +#define SAMA_SPI_USE_FLEXCOM3 FALSE +#define SAMA_SPI_USE_FLEXCOM4 FALSE +#define SAMA_SPI_SPI0_DMA_IRQ_PRIORITY 4 +#define SAMA_SPI_SPI1_DMA_IRQ_PRIORITY 4 +#define SAMA_SPI_FLEXCOM0_DMA_IRQ_PRIORITY 4 +#define SAMA_SPI_FLEXCOM1_DMA_IRQ_PRIORITY 4 +#define SAMA_SPI_FLEXCOM2_DMA_IRQ_PRIORITY 4 +#define SAMA_SPI_FLEXCOM3_DMA_IRQ_PRIORITY 4 +#define SAMA_SPI_FLEXCOM4_DMA_IRQ_PRIORITY 4 +#define SAMA_SPI_DMA_ERROR_HOOK(spip) osalSysHalt("DMA failure") +#define SPI_SELECT_MODE SPI_SELECT_MODE_NONE + /* * ST driver settings. */ -#define SAMA_ST_USE_PIT TRUE +#define SAMA_ST_USE_PIT FALSE #define SAMA_ST_USE_TC0 FALSE -#define SAMA_ST_USE_TC1 FALSE +#define SAMA_ST_USE_TC1 TRUE /* * TC driver system settings. diff --git a/testhal/ATSAMA5D2/SERIAL/readme.txt b/testhal/ATSAMA5D2/SERIAL/readme.txt index 3d3eb3206..2653debc7 100755 --- a/testhal/ATSAMA5D2/SERIAL/readme.txt +++ b/testhal/ATSAMA5D2/SERIAL/readme.txt @@ -7,7 +7,8 @@ The demo targets a generic ARM Cortex-A5 device without HAL support. ** The Demo ** -Simple echo from terminal + +Simple echo from terminal using FLEXCOM0 as serial ** Build Procedure ** -- cgit v1.2.3