aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortheshed <theshed@35acf78f-673a-0410-8e92-d51de3d6d3f4>2014-03-02 18:15:18 +0000
committertheshed <theshed@35acf78f-673a-0410-8e92-d51de3d6d3f4>2014-03-02 18:15:18 +0000
commit0d5a32eb1883347244676822cc3089410ca9a227 (patch)
tree858991b5aef669117fdddaf641be9524352b5b25
parent24389bfe09815fd20aede0485ea544f7e76da30b (diff)
downloadChibiOS-0d5a32eb1883347244676822cc3089410ca9a227.tar.gz
ChibiOS-0d5a32eb1883347244676822cc3089410ca9a227.tar.bz2
ChibiOS-0d5a32eb1883347244676822cc3089410ca9a227.zip
Fix more line-endings on LPC17xx and LPC43xx files
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@6746 35acf78f-673a-0410-8e92-d51de3d6d3f4
-rw-r--r--demos/ARMCM3-LPC1769-LPCXPRESSO-LWIP/main.c174
-rw-r--r--demos/ARMCM3-LPC1769-LPCXPRESSO-LWIP/web/web.c242
-rw-r--r--demos/ARMCM3-LPC1769-LPCXPRESSO/main.c144
-rw-r--r--demos/ARMCM4CM0-NONSTANDARD-LPC4330-SBC-RAM-LWIP/main.c176
-rw-r--r--demos/ARMCM4CM0-NONSTANDARD-LPC4330-SBC-RAM-LWIP/web/web.c242
-rw-r--r--demos/ARMCM4CM0-NONSTANDARD-LPC4330-SBC-RAM/main.c142
-rw-r--r--testhal/LPC17xx/CAN/main.c316
-rw-r--r--testhal/LPC17xx/CAN_LOCAL_SELF_TEST/main.c224
-rw-r--r--testhal/LPC17xx/DAC/main.c230
-rw-r--r--testhal/LPC17xx/DMA_MEM/main.c236
-rw-r--r--testhal/LPC17xx/I2C/main.c248
-rw-r--r--testhal/LPC17xx/IRQ_STORM/main.c648
-rw-r--r--testhal/LPC17xx/RTC/main.c560
-rw-r--r--testhal/LPC43xx/DAC/main.c230
-rw-r--r--testhal/LPC43xx/DMA_MEM/main.c240
-rw-r--r--testhal/LPC43xx/IRQ_STORM/main.c648
16 files changed, 2350 insertions, 2350 deletions
diff --git a/demos/ARMCM3-LPC1769-LPCXPRESSO-LWIP/main.c b/demos/ARMCM3-LPC1769-LPCXPRESSO-LWIP/main.c
index 5bb98fb4b..e87b03f5e 100644
--- a/demos/ARMCM3-LPC1769-LPCXPRESSO-LWIP/main.c
+++ b/demos/ARMCM3-LPC1769-LPCXPRESSO-LWIP/main.c
@@ -1,87 +1,87 @@
-/*
- ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-#include "ch.h"
-#include "hal.h"
-#include "test.h"
-
-#include "lwipthread.h"
-
-#include "web/web.h"
-
-/*
- * Green LED blinker thread, times are in milliseconds.
- */
-static WORKING_AREA(waThread1, 128);
-static msg_t Thread1(void *arg) {
-
- (void)arg;
- chRegSetThreadName("blinker");
- while (TRUE) {
- palClearPad(GPIO0, GPIO0_LED2_RED);
- chThdSleepMilliseconds(500);
- palSetPad(GPIO0, GPIO0_LED2_RED);
- chThdSleepMilliseconds(500);
- }
-}
-
-/*
- * Application entry point.
- */
-int main(void) {
-
- /*
- * System initializations.
- * - HAL initialization, this also initializes the configured device drivers
- * and performs the board-specific initializations.
- * - Kernel initialization, the main() function becomes a thread and the
- * RTOS is active.
- */
- halInit();
- chSysInit();
-
- /*
- * Activates the serial driver 6 using the driver default configuration.
- */
- sdStart(&SD1, NULL);
-
- /*
- * Creates the blinker thread.
- */
- chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
-
- /*
- * Creates the LWIP threads (it changes priority internally).
- */
- chThdCreateStatic(wa_lwip_thread, LWIP_THREAD_STACK_SIZE, NORMALPRIO + 1,
- lwip_thread, NULL);
-
- /*
- * Creates the HTTP thread (it changes priority internally).
- */
- chThdCreateStatic(wa_http_server, sizeof(wa_http_server), NORMALPRIO + 1,
- http_server, NULL);
-
- /*
- * Normal main() thread activity, in this demo it does nothing except
- * sleeping in a loop and check the button state.
- */
- while (TRUE) {
- if (palReadPad(GPIO2, GPIO2_PIN12_TO_GND) == 0)
- TestThread(&SD1);
- chThdSleepMilliseconds(500);
- }
-}
+/*
+ ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+#include "ch.h"
+#include "hal.h"
+#include "test.h"
+
+#include "lwipthread.h"
+
+#include "web/web.h"
+
+/*
+ * Green LED blinker thread, times are in milliseconds.
+ */
+static WORKING_AREA(waThread1, 128);
+static msg_t Thread1(void *arg) {
+
+ (void)arg;
+ chRegSetThreadName("blinker");
+ while (TRUE) {
+ palClearPad(GPIO0, GPIO0_LED2_RED);
+ chThdSleepMilliseconds(500);
+ palSetPad(GPIO0, GPIO0_LED2_RED);
+ chThdSleepMilliseconds(500);
+ }
+}
+
+/*
+ * Application entry point.
+ */
+int main(void) {
+
+ /*
+ * System initializations.
+ * - HAL initialization, this also initializes the configured device drivers
+ * and performs the board-specific initializations.
+ * - Kernel initialization, the main() function becomes a thread and the
+ * RTOS is active.
+ */
+ halInit();
+ chSysInit();
+
+ /*
+ * Activates the serial driver 6 using the driver default configuration.
+ */
+ sdStart(&SD1, NULL);
+
+ /*
+ * Creates the blinker thread.
+ */
+ chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
+
+ /*
+ * Creates the LWIP threads (it changes priority internally).
+ */
+ chThdCreateStatic(wa_lwip_thread, LWIP_THREAD_STACK_SIZE, NORMALPRIO + 1,
+ lwip_thread, NULL);
+
+ /*
+ * Creates the HTTP thread (it changes priority internally).
+ */
+ chThdCreateStatic(wa_http_server, sizeof(wa_http_server), NORMALPRIO + 1,
+ http_server, NULL);
+
+ /*
+ * Normal main() thread activity, in this demo it does nothing except
+ * sleeping in a loop and check the button state.
+ */
+ while (TRUE) {
+ if (palReadPad(GPIO2, GPIO2_PIN12_TO_GND) == 0)
+ TestThread(&SD1);
+ chThdSleepMilliseconds(500);
+ }
+}
diff --git a/demos/ARMCM3-LPC1769-LPCXPRESSO-LWIP/web/web.c b/demos/ARMCM3-LPC1769-LPCXPRESSO-LWIP/web/web.c
index ed911b729..c4f16852e 100644
--- a/demos/ARMCM3-LPC1769-LPCXPRESSO-LWIP/web/web.c
+++ b/demos/ARMCM3-LPC1769-LPCXPRESSO-LWIP/web/web.c
@@ -1,121 +1,121 @@
-/*
- ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-/*
- * This file is a modified version of the lwIP web server demo. The original
- * author is unknown because the file didn't contain any license information.
- */
-
-/**
- * @file web.c
- * @brief HTTP server wrapper thread code.
- * @addtogroup WEB_THREAD
- * @{
- */
-
-#include "ch.h"
-
-#include "lwip/opt.h"
-#include "lwip/arch.h"
-#include "lwip/api.h"
-
-#include "web.h"
-
-#if LWIP_NETCONN
-
-static const char http_html_hdr[] = "HTTP/1.1 200 OK\r\nContent-type: text/html\r\n\r\n";
-static const char http_index_html[] = "<html><head><title>Congrats!</title></head><body><h1>Welcome to our lwIP HTTP server!</h1><p>This is a small test page.</body></html>";
-
-static void http_server_serve(struct netconn *conn) {
- struct netbuf *inbuf;
- char *buf;
- u16_t buflen;
- err_t err;
-
- /* Read the data from the port, blocking if nothing yet there.
- We assume the request (the part we care about) is in one netbuf */
- err = netconn_recv(conn, &inbuf);
-
- if (err == ERR_OK) {
- netbuf_data(inbuf, (void **)&buf, &buflen);
-
- /* Is this an HTTP GET command? (only check the first 5 chars, since
- there are other formats for GET, and we're keeping it very simple )*/
- if (buflen>=5 &&
- buf[0]=='G' &&
- buf[1]=='E' &&
- buf[2]=='T' &&
- buf[3]==' ' &&
- buf[4]=='/' ) {
-
- /* Send the HTML header
- * subtract 1 from the size, since we dont send the \0 in the string
- * NETCONN_NOCOPY: our data is const static, so no need to copy it
- */
- netconn_write(conn, http_html_hdr, sizeof(http_html_hdr)-1, NETCONN_NOCOPY);
-
- /* Send our HTML page */
- netconn_write(conn, http_index_html, sizeof(http_index_html)-1, NETCONN_NOCOPY);
- }
- }
- /* Close the connection (server closes in HTTP) */
- netconn_close(conn);
-
- /* Delete the buffer (netconn_recv gives us ownership,
- so we have to make sure to deallocate the buffer) */
- netbuf_delete(inbuf);
-}
-
-/**
- * Stack area for the http thread.
- */
-WORKING_AREA(wa_http_server, WEB_THREAD_STACK_SIZE);
-
-/**
- * HTTP server thread.
- */
-msg_t http_server(void *p) {
- struct netconn *conn, *newconn;
- err_t err;
-
- (void)p;
-
- /* Create a new TCP connection handle */
- conn = netconn_new(NETCONN_TCP);
- LWIP_ERROR("http_server: invalid conn", (conn != NULL), return RDY_RESET;);
-
- /* Bind to port 80 (HTTP) with default IP address */
- netconn_bind(conn, NULL, WEB_THREAD_PORT);
-
- /* Put the connection into LISTEN state */
- netconn_listen(conn);
-
- /* Goes to the final priority after initialization.*/
- chThdSetPriority(WEB_THREAD_PRIORITY);
-
- while(1) {
- err = netconn_accept(conn, &newconn);
- if (err != ERR_OK)
- continue;
- http_server_serve(newconn);
- netconn_delete(newconn);
- }
- return RDY_OK;
-}
-
-#endif /* LWIP_NETCONN */
-
-/** @} */
+/*
+ ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+/*
+ * This file is a modified version of the lwIP web server demo. The original
+ * author is unknown because the file didn't contain any license information.
+ */
+
+/**
+ * @file web.c
+ * @brief HTTP server wrapper thread code.
+ * @addtogroup WEB_THREAD
+ * @{
+ */
+
+#include "ch.h"
+
+#include "lwip/opt.h"
+#include "lwip/arch.h"
+#include "lwip/api.h"
+
+#include "web.h"
+
+#if LWIP_NETCONN
+
+static const char http_html_hdr[] = "HTTP/1.1 200 OK\r\nContent-type: text/html\r\n\r\n";
+static const char http_index_html[] = "<html><head><title>Congrats!</title></head><body><h1>Welcome to our lwIP HTTP server!</h1><p>This is a small test page.</body></html>";
+
+static void http_server_serve(struct netconn *conn) {
+ struct netbuf *inbuf;
+ char *buf;
+ u16_t buflen;
+ err_t err;
+
+ /* Read the data from the port, blocking if nothing yet there.
+ We assume the request (the part we care about) is in one netbuf */
+ err = netconn_recv(conn, &inbuf);
+
+ if (err == ERR_OK) {
+ netbuf_data(inbuf, (void **)&buf, &buflen);
+
+ /* Is this an HTTP GET command? (only check the first 5 chars, since
+ there are other formats for GET, and we're keeping it very simple )*/
+ if (buflen>=5 &&
+ buf[0]=='G' &&
+ buf[1]=='E' &&
+ buf[2]=='T' &&
+ buf[3]==' ' &&
+ buf[4]=='/' ) {
+
+ /* Send the HTML header
+ * subtract 1 from the size, since we dont send the \0 in the string
+ * NETCONN_NOCOPY: our data is const static, so no need to copy it
+ */
+ netconn_write(conn, http_html_hdr, sizeof(http_html_hdr)-1, NETCONN_NOCOPY);
+
+ /* Send our HTML page */
+ netconn_write(conn, http_index_html, sizeof(http_index_html)-1, NETCONN_NOCOPY);
+ }
+ }
+ /* Close the connection (server closes in HTTP) */
+ netconn_close(conn);
+
+ /* Delete the buffer (netconn_recv gives us ownership,
+ so we have to make sure to deallocate the buffer) */
+ netbuf_delete(inbuf);
+}
+
+/**
+ * Stack area for the http thread.
+ */
+WORKING_AREA(wa_http_server, WEB_THREAD_STACK_SIZE);
+
+/**
+ * HTTP server thread.
+ */
+msg_t http_server(void *p) {
+ struct netconn *conn, *newconn;
+ err_t err;
+
+ (void)p;
+
+ /* Create a new TCP connection handle */
+ conn = netconn_new(NETCONN_TCP);
+ LWIP_ERROR("http_server: invalid conn", (conn != NULL), return RDY_RESET;);
+
+ /* Bind to port 80 (HTTP) with default IP address */
+ netconn_bind(conn, NULL, WEB_THREAD_PORT);
+
+ /* Put the connection into LISTEN state */
+ netconn_listen(conn);
+
+ /* Goes to the final priority after initialization.*/
+ chThdSetPriority(WEB_THREAD_PRIORITY);
+
+ while(1) {
+ err = netconn_accept(conn, &newconn);
+ if (err != ERR_OK)
+ continue;
+ http_server_serve(newconn);
+ netconn_delete(newconn);
+ }
+ return RDY_OK;
+}
+
+#endif /* LWIP_NETCONN */
+
+/** @} */
diff --git a/demos/ARMCM3-LPC1769-LPCXPRESSO/main.c b/demos/ARMCM3-LPC1769-LPCXPRESSO/main.c
index ebe90fb5e..24773e969 100644
--- a/demos/ARMCM3-LPC1769-LPCXPRESSO/main.c
+++ b/demos/ARMCM3-LPC1769-LPCXPRESSO/main.c
@@ -1,72 +1,72 @@
-/*
- ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-#include "ch.h"
-#include "hal.h"
-#include "test.h"
-
-/*
- * Red LED blinker thread, times are in milliseconds.
- */
-static WORKING_AREA(waThread1, 128);
-static msg_t Thread1(void *arg) {
-
- (void)arg;
- chRegSetThreadName("blinker1");
- while (TRUE) {
- palTogglePad(GPIO0, GPIO0_LED2_RED);
- chThdSleepMilliseconds(500);
- }
-}
-
-
-/*
- * Application entry point.
- */
-int main(void) {
-
- /*
- * System initializations.
- * - HAL initialization, this also initializes the configured device drivers
- * and performs the board-specific initializations.
- * - Kernel initialization, the main() function becomes a thread and the
- * RTOS is active.
- */
- halInit();
- chSysInit();
-
- /*
- * Activates the SD1 and SPI1 drivers.
- */
- sdStart(&SD1, NULL); /* Default: 38400,8,N,1. */
-
- /*
- * Creates the blinker threads.
- */
- chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
-
-
- /*
- * Normal main() thread activity, in this demo it updates the 7-segments
- * display on the LPCXpresso main board using the SPI driver.
- */
-
- while (TRUE) {
- if (!palReadPad(GPIO2, GPIO2_PIN12_TO_GND))
- TestThread(&SD1);
- }
- chThdSleepMilliseconds(100);
-}
+/*
+ ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+#include "ch.h"
+#include "hal.h"
+#include "test.h"
+
+/*
+ * Red LED blinker thread, times are in milliseconds.
+ */
+static WORKING_AREA(waThread1, 128);
+static msg_t Thread1(void *arg) {
+
+ (void)arg;
+ chRegSetThreadName("blinker1");
+ while (TRUE) {
+ palTogglePad(GPIO0, GPIO0_LED2_RED);
+ chThdSleepMilliseconds(500);
+ }
+}
+
+
+/*
+ * Application entry point.
+ */
+int main(void) {
+
+ /*
+ * System initializations.
+ * - HAL initialization, this also initializes the configured device drivers
+ * and performs the board-specific initializations.
+ * - Kernel initialization, the main() function becomes a thread and the
+ * RTOS is active.
+ */
+ halInit();
+ chSysInit();
+
+ /*
+ * Activates the SD1 and SPI1 drivers.
+ */
+ sdStart(&SD1, NULL); /* Default: 38400,8,N,1. */
+
+ /*
+ * Creates the blinker threads.
+ */
+ chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
+
+
+ /*
+ * Normal main() thread activity, in this demo it updates the 7-segments
+ * display on the LPCXpresso main board using the SPI driver.
+ */
+
+ while (TRUE) {
+ if (!palReadPad(GPIO2, GPIO2_PIN12_TO_GND))
+ TestThread(&SD1);
+ }
+ chThdSleepMilliseconds(100);
+}
diff --git a/demos/ARMCM4CM0-NONSTANDARD-LPC4330-SBC-RAM-LWIP/main.c b/demos/ARMCM4CM0-NONSTANDARD-LPC4330-SBC-RAM-LWIP/main.c
index 20fb3efac..56c76ebe2 100644
--- a/demos/ARMCM4CM0-NONSTANDARD-LPC4330-SBC-RAM-LWIP/main.c
+++ b/demos/ARMCM4CM0-NONSTANDARD-LPC4330-SBC-RAM-LWIP/main.c
@@ -1,88 +1,88 @@
-/*
- ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-#include "ch.h"
-#include "hal.h"
-#include "test.h"
-
-#include "lwipthread.h"
-
-#include "web/web.h"
-
-/*
- * Green LED blinker thread, times are in milliseconds.
- */
-static WORKING_AREA(waThread1, 128);
-static msg_t Thread1(void *arg) {
-
- (void)arg;
- chRegSetThreadName("blinker");
- while (TRUE) {
- palClearPad(GPIO2, GPIO2_LED);
- chThdSleepMilliseconds(500);
- palSetPad(GPIO2, GPIO2_LED);
- chThdSleepMilliseconds(500);
- }
-}
-
-/*
- * Application entry point.
- */
-int main(void) {
-
- /*
- * System initializations.
- * - HAL initialization, this also initializes the configured device drivers
- * and performs the board-specific initializations.
- * - Kernel initialization, the main() function becomes a thread and the
- * RTOS is active.
- */
- halInit();
- chSysInit();
-
- /*
- * Activates the serial driver 6 using the driver default configuration.
- */
- sdStart(&SD4, NULL);
-
- /*
- * Creates the blinker thread.
- */
- chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
-
- /*
- * Creates the LWIP threads (it changes priority internally).
- */
- chThdCreateStatic(wa_lwip_thread, LWIP_THREAD_STACK_SIZE, NORMALPRIO + 1,
- lwip_thread, NULL);
-
- /*
- * Creates the HTTP thread (it changes priority internally).
- */
- chThdCreateStatic(wa_http_server, sizeof(wa_http_server), NORMALPRIO + 1,
- http_server, NULL);
-
- /*
- * Normal main() thread activity, in this demo it does nothing except
- * sleeping in a loop and check the button state.
- */
- while (TRUE) {
- if (!palReadPad(GPIO3, GPIO3_SW_USER1)) {
- TestThread(&SD4);
- }
- chThdSleepMilliseconds(500);
- }
-}
+/*
+ ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+#include "ch.h"
+#include "hal.h"
+#include "test.h"
+
+#include "lwipthread.h"
+
+#include "web/web.h"
+
+/*
+ * Green LED blinker thread, times are in milliseconds.
+ */
+static WORKING_AREA(waThread1, 128);
+static msg_t Thread1(void *arg) {
+
+ (void)arg;
+ chRegSetThreadName("blinker");
+ while (TRUE) {
+ palClearPad(GPIO2, GPIO2_LED);
+ chThdSleepMilliseconds(500);
+ palSetPad(GPIO2, GPIO2_LED);
+ chThdSleepMilliseconds(500);
+ }
+}
+
+/*
+ * Application entry point.
+ */
+int main(void) {
+
+ /*
+ * System initializations.
+ * - HAL initialization, this also initializes the configured device drivers
+ * and performs the board-specific initializations.
+ * - Kernel initialization, the main() function becomes a thread and the
+ * RTOS is active.
+ */
+ halInit();
+ chSysInit();
+
+ /*
+ * Activates the serial driver 6 using the driver default configuration.
+ */
+ sdStart(&SD4, NULL);
+
+ /*
+ * Creates the blinker thread.
+ */
+ chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
+
+ /*
+ * Creates the LWIP threads (it changes priority internally).
+ */
+ chThdCreateStatic(wa_lwip_thread, LWIP_THREAD_STACK_SIZE, NORMALPRIO + 1,
+ lwip_thread, NULL);
+
+ /*
+ * Creates the HTTP thread (it changes priority internally).
+ */
+ chThdCreateStatic(wa_http_server, sizeof(wa_http_server), NORMALPRIO + 1,
+ http_server, NULL);
+
+ /*
+ * Normal main() thread activity, in this demo it does nothing except
+ * sleeping in a loop and check the button state.
+ */
+ while (TRUE) {
+ if (!palReadPad(GPIO3, GPIO3_SW_USER1)) {
+ TestThread(&SD4);
+ }
+ chThdSleepMilliseconds(500);
+ }
+}
diff --git a/demos/ARMCM4CM0-NONSTANDARD-LPC4330-SBC-RAM-LWIP/web/web.c b/demos/ARMCM4CM0-NONSTANDARD-LPC4330-SBC-RAM-LWIP/web/web.c
index ed911b729..c4f16852e 100644
--- a/demos/ARMCM4CM0-NONSTANDARD-LPC4330-SBC-RAM-LWIP/web/web.c
+++ b/demos/ARMCM4CM0-NONSTANDARD-LPC4330-SBC-RAM-LWIP/web/web.c
@@ -1,121 +1,121 @@
-/*
- ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-/*
- * This file is a modified version of the lwIP web server demo. The original
- * author is unknown because the file didn't contain any license information.
- */
-
-/**
- * @file web.c
- * @brief HTTP server wrapper thread code.
- * @addtogroup WEB_THREAD
- * @{
- */
-
-#include "ch.h"
-
-#include "lwip/opt.h"
-#include "lwip/arch.h"
-#include "lwip/api.h"
-
-#include "web.h"
-
-#if LWIP_NETCONN
-
-static const char http_html_hdr[] = "HTTP/1.1 200 OK\r\nContent-type: text/html\r\n\r\n";
-static const char http_index_html[] = "<html><head><title>Congrats!</title></head><body><h1>Welcome to our lwIP HTTP server!</h1><p>This is a small test page.</body></html>";
-
-static void http_server_serve(struct netconn *conn) {
- struct netbuf *inbuf;
- char *buf;
- u16_t buflen;
- err_t err;
-
- /* Read the data from the port, blocking if nothing yet there.
- We assume the request (the part we care about) is in one netbuf */
- err = netconn_recv(conn, &inbuf);
-
- if (err == ERR_OK) {
- netbuf_data(inbuf, (void **)&buf, &buflen);
-
- /* Is this an HTTP GET command? (only check the first 5 chars, since
- there are other formats for GET, and we're keeping it very simple )*/
- if (buflen>=5 &&
- buf[0]=='G' &&
- buf[1]=='E' &&
- buf[2]=='T' &&
- buf[3]==' ' &&
- buf[4]=='/' ) {
-
- /* Send the HTML header
- * subtract 1 from the size, since we dont send the \0 in the string
- * NETCONN_NOCOPY: our data is const static, so no need to copy it
- */
- netconn_write(conn, http_html_hdr, sizeof(http_html_hdr)-1, NETCONN_NOCOPY);
-
- /* Send our HTML page */
- netconn_write(conn, http_index_html, sizeof(http_index_html)-1, NETCONN_NOCOPY);
- }
- }
- /* Close the connection (server closes in HTTP) */
- netconn_close(conn);
-
- /* Delete the buffer (netconn_recv gives us ownership,
- so we have to make sure to deallocate the buffer) */
- netbuf_delete(inbuf);
-}
-
-/**
- * Stack area for the http thread.
- */
-WORKING_AREA(wa_http_server, WEB_THREAD_STACK_SIZE);
-
-/**
- * HTTP server thread.
- */
-msg_t http_server(void *p) {
- struct netconn *conn, *newconn;
- err_t err;
-
- (void)p;
-
- /* Create a new TCP connection handle */
- conn = netconn_new(NETCONN_TCP);
- LWIP_ERROR("http_server: invalid conn", (conn != NULL), return RDY_RESET;);
-
- /* Bind to port 80 (HTTP) with default IP address */
- netconn_bind(conn, NULL, WEB_THREAD_PORT);
-
- /* Put the connection into LISTEN state */
- netconn_listen(conn);
-
- /* Goes to the final priority after initialization.*/
- chThdSetPriority(WEB_THREAD_PRIORITY);
-
- while(1) {
- err = netconn_accept(conn, &newconn);
- if (err != ERR_OK)
- continue;
- http_server_serve(newconn);
- netconn_delete(newconn);
- }
- return RDY_OK;
-}
-
-#endif /* LWIP_NETCONN */
-
-/** @} */
+/*
+ ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+/*
+ * This file is a modified version of the lwIP web server demo. The original
+ * author is unknown because the file didn't contain any license information.
+ */
+
+/**
+ * @file web.c
+ * @brief HTTP server wrapper thread code.
+ * @addtogroup WEB_THREAD
+ * @{
+ */
+
+#include "ch.h"
+
+#include "lwip/opt.h"
+#include "lwip/arch.h"
+#include "lwip/api.h"
+
+#include "web.h"
+
+#if LWIP_NETCONN
+
+static const char http_html_hdr[] = "HTTP/1.1 200 OK\r\nContent-type: text/html\r\n\r\n";
+static const char http_index_html[] = "<html><head><title>Congrats!</title></head><body><h1>Welcome to our lwIP HTTP server!</h1><p>This is a small test page.</body></html>";
+
+static void http_server_serve(struct netconn *conn) {
+ struct netbuf *inbuf;
+ char *buf;
+ u16_t buflen;
+ err_t err;
+
+ /* Read the data from the port, blocking if nothing yet there.
+ We assume the request (the part we care about) is in one netbuf */
+ err = netconn_recv(conn, &inbuf);
+
+ if (err == ERR_OK) {
+ netbuf_data(inbuf, (void **)&buf, &buflen);
+
+ /* Is this an HTTP GET command? (only check the first 5 chars, since
+ there are other formats for GET, and we're keeping it very simple )*/
+ if (buflen>=5 &&
+ buf[0]=='G' &&
+ buf[1]=='E' &&
+ buf[2]=='T' &&
+ buf[3]==' ' &&
+ buf[4]=='/' ) {
+
+ /* Send the HTML header
+ * subtract 1 from the size, since we dont send the \0 in the string
+ * NETCONN_NOCOPY: our data is const static, so no need to copy it
+ */
+ netconn_write(conn, http_html_hdr, sizeof(http_html_hdr)-1, NETCONN_NOCOPY);
+
+ /* Send our HTML page */
+ netconn_write(conn, http_index_html, sizeof(http_index_html)-1, NETCONN_NOCOPY);
+ }
+ }
+ /* Close the connection (server closes in HTTP) */
+ netconn_close(conn);
+
+ /* Delete the buffer (netconn_recv gives us ownership,
+ so we have to make sure to deallocate the buffer) */
+ netbuf_delete(inbuf);
+}
+
+/**
+ * Stack area for the http thread.
+ */
+WORKING_AREA(wa_http_server, WEB_THREAD_STACK_SIZE);
+
+/**
+ * HTTP server thread.
+ */
+msg_t http_server(void *p) {
+ struct netconn *conn, *newconn;
+ err_t err;
+
+ (void)p;
+
+ /* Create a new TCP connection handle */
+ conn = netconn_new(NETCONN_TCP);
+ LWIP_ERROR("http_server: invalid conn", (conn != NULL), return RDY_RESET;);
+
+ /* Bind to port 80 (HTTP) with default IP address */
+ netconn_bind(conn, NULL, WEB_THREAD_PORT);
+
+ /* Put the connection into LISTEN state */
+ netconn_listen(conn);
+
+ /* Goes to the final priority after initialization.*/
+ chThdSetPriority(WEB_THREAD_PRIORITY);
+
+ while(1) {
+ err = netconn_accept(conn, &newconn);
+ if (err != ERR_OK)
+ continue;
+ http_server_serve(newconn);
+ netconn_delete(newconn);
+ }
+ return RDY_OK;
+}
+
+#endif /* LWIP_NETCONN */
+
+/** @} */
diff --git a/demos/ARMCM4CM0-NONSTANDARD-LPC4330-SBC-RAM/main.c b/demos/ARMCM4CM0-NONSTANDARD-LPC4330-SBC-RAM/main.c
index 86033a143..fd34a4555 100644
--- a/demos/ARMCM4CM0-NONSTANDARD-LPC4330-SBC-RAM/main.c
+++ b/demos/ARMCM4CM0-NONSTANDARD-LPC4330-SBC-RAM/main.c
@@ -1,71 +1,71 @@
-/*
- ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-#include "ch.h"
-#include "hal.h"
-#include "test.h"
-
-/*
- * Red LED blinker thread, times are in milliseconds.
- */
-static WORKING_AREA(waThread1, 128);
-static msg_t Thread1(void *arg) {
-
- (void)arg;
- chRegSetThreadName("blinker1");
- while (TRUE) {
- palTogglePad(GPIO2, GPIO2_LED);
- chThdSleepMilliseconds(500);
- }
-}
-
-
-/*
- * Application entry point.
- */
-int main(void) {
-
- /*
- * System initializations.
- * - HAL initialization, this also initializes the configured device drivers
- * and performs the board-specific initializations.
- * - Kernel initialization, the main() function becomes a thread and the
- * RTOS is active.
- */
- halInit();
- chSysInit();
-
- /*
- * Activates the SD1 and SPI1 drivers.
- */
- sdStart(&SD4, NULL); /* Default: 38400,8,N,1. */
-
- /*
- * Creates the blinker threads.
- */
- chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
-
- /*
- * Normal main() thread activity.
- */
-
- while (TRUE) {
- if (!palReadPad(GPIO3, GPIO3_SW_USER1)) {
- TestThread(&SD4);
- }
- chThdSleepMilliseconds(100);
- }
-}
+/*
+ ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+#include "ch.h"
+#include "hal.h"
+#include "test.h"
+
+/*
+ * Red LED blinker thread, times are in milliseconds.
+ */
+static WORKING_AREA(waThread1, 128);
+static msg_t Thread1(void *arg) {
+
+ (void)arg;
+ chRegSetThreadName("blinker1");
+ while (TRUE) {
+ palTogglePad(GPIO2, GPIO2_LED);
+ chThdSleepMilliseconds(500);
+ }
+}
+
+
+/*
+ * Application entry point.
+ */
+int main(void) {
+
+ /*
+ * System initializations.
+ * - HAL initialization, this also initializes the configured device drivers
+ * and performs the board-specific initializations.
+ * - Kernel initialization, the main() function becomes a thread and the
+ * RTOS is active.
+ */
+ halInit();
+ chSysInit();
+
+ /*
+ * Activates the SD1 and SPI1 drivers.
+ */
+ sdStart(&SD4, NULL); /* Default: 38400,8,N,1. */
+
+ /*
+ * Creates the blinker threads.
+ */
+ chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
+
+ /*
+ * Normal main() thread activity.
+ */
+
+ while (TRUE) {
+ if (!palReadPad(GPIO3, GPIO3_SW_USER1)) {
+ TestThread(&SD4);
+ }
+ chThdSleepMilliseconds(100);
+ }
+}
diff --git a/testhal/LPC17xx/CAN/main.c b/testhal/LPC17xx/CAN/main.c
index a382ce501..163fb6616 100644
--- a/testhal/LPC17xx/CAN/main.c
+++ b/testhal/LPC17xx/CAN/main.c
@@ -1,158 +1,158 @@
-/*
- ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-#include "ch.h"
-#include "hal.h"
-
-struct can_instance {
- CANDriver *canp;
- uint32_t led;
-};
-
-static const struct can_instance can1 = {&CAND1, GPIO0_LED2_RED};
-static const struct can_instance can2 = {&CAND2, GPIO0_LED3_EXT}; /* Connect LED to board. */
-
-#if LPC17xx_CAN_USE_FILTER
-static const CANFilterExt cfe_id_table[2] = {
- CANFilterExtEntry(0, 0x0ABCDEF0),
- CANFilterExtEntry(1, 0x01234567)
-
-};
-
-static const CANFilterConfig canfcfg = {
- 0,
- NULL,
- 0,
- NULL,
- 0,
- NULL,
- 0,
- cfe_id_table,
- 2,
- NULL,
- 0
-};
-#endif
-
-/*
- * Operating mode
- */
-static const CANConfig cancfg = {
- 0,
- CANBTR_SJW(0) | CANBTR_TESG2(1) |
- CANBTR_TESG1(8) | CANBTR_BRP(20)
-};
-
-/*
- * Receiver thread.
- */
-static WORKING_AREA(can_rx1_wa, 256);
-static WORKING_AREA(can_rx2_wa, 256);
-static msg_t can_rx(void *p) {
- struct can_instance *cip = p;
- EventListener el;
- CANRxFrame rxmsg;
-
- (void)p;
- chRegSetThreadName("receiver");
- chEvtRegister(&cip->canp->rxfull_event, &el, 0);
- while(!chThdShouldTerminate()) {
- if (chEvtWaitAnyTimeout(ALL_EVENTS, MS2ST(100)) == 0)
- continue;
- while (canReceive(cip->canp, CAN_ANY_MAILBOX,
- &rxmsg, TIME_IMMEDIATE) == RDY_OK) {
- /* Process message.*/
- palTogglePad(GPIO0, cip->led);
- }
- }
- chEvtUnregister(&CAND1.rxfull_event, &el);
- return 0;
-}
-
-/*
- * Transmitter thread.
- */
-static WORKING_AREA(can_tx_wa, 256);
-static msg_t can_tx(void * p) {
- CANTxFrame txmsg_can1;
- CANTxFrame txmsg_can2;
-
- (void)p;
- chRegSetThreadName("transmitter");
- txmsg_can1.IDE = CAN_IDE_EXT;
- txmsg_can1.EID = 0x01234567;
- txmsg_can1.RTR = CAN_RTR_DATA;
- txmsg_can1.DLC = 8;
- txmsg_can1.data32[0] = 0x55AA55AA;
- txmsg_can1.data32[1] = 0x00FF00FF;
-
- txmsg_can2.IDE = CAN_IDE_EXT;
- txmsg_can2.EID = 0x0ABCDEF0;
- txmsg_can2.RTR = CAN_RTR_DATA;
- txmsg_can2.DLC = 8;
- txmsg_can2.data32[0] = 0x66AA66AA;
- txmsg_can2.data32[1] = 0x44FF44FF;
-
- while (!chThdShouldTerminate()) {
- canTransmit(&CAND1, CAN_ANY_MAILBOX, &txmsg_can1, MS2ST(100));
- canTransmit(&CAND2, CAN_ANY_MAILBOX, &txmsg_can2, MS2ST(100));
- chThdSleepMilliseconds(500);
- }
- return 0;
-}
-
-/*
- * Application entry point.
- */
-int main(void) {
-
- /*
- * System initializations.
- * - HAL initialization, this also initializes the configured device drivers
- * and performs the board-specific initializations.
- * - Kernel initialization, the main() function becomes a thread and the
- * RTOS is active.
- */
- halInit();
- chSysInit();
-
- /*
- * Activates the CAN drivers 1 and 2.
- */
- canStart(&CAND1, &cancfg);
- canStart(&CAND2, &cancfg);
-
-#if LPC17xx_CAN_USE_FILTER
- canSetFilter(&canfcfg);
-#endif
- /*
- * Starting the transmitter and receiver threads.
- */
- chThdCreateStatic(can_rx1_wa, sizeof(can_rx1_wa), NORMALPRIO + 7,
- can_rx, (void *)&can1);
- chThdCreateStatic(can_rx2_wa, sizeof(can_rx2_wa), NORMALPRIO + 7,
- can_rx, (void *)&can2);
- chThdCreateStatic(can_tx_wa, sizeof(can_tx_wa), NORMALPRIO + 7,
- can_tx, NULL);
-
- /*
- * Normal main() thread activity, in this demo it does nothing.
- */
- while (TRUE) {
- chThdSleepMilliseconds(500);
- }
- return 0;
-}
+/*
+ ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+#include "ch.h"
+#include "hal.h"
+
+struct can_instance {
+ CANDriver *canp;
+ uint32_t led;
+};
+
+static const struct can_instance can1 = {&CAND1, GPIO0_LED2_RED};
+static const struct can_instance can2 = {&CAND2, GPIO0_LED3_EXT}; /* Connect LED to board. */
+
+#if LPC17xx_CAN_USE_FILTER
+static const CANFilterExt cfe_id_table[2] = {
+ CANFilterExtEntry(0, 0x0ABCDEF0),
+ CANFilterExtEntry(1, 0x01234567)
+
+};
+
+static const CANFilterConfig canfcfg = {
+ 0,
+ NULL,
+ 0,
+ NULL,
+ 0,
+ NULL,
+ 0,
+ cfe_id_table,
+ 2,
+ NULL,
+ 0
+};
+#endif
+
+/*
+ * Operating mode
+ */
+static const CANConfig cancfg = {
+ 0,
+ CANBTR_SJW(0) | CANBTR_TESG2(1) |
+ CANBTR_TESG1(8) | CANBTR_BRP(20)
+};
+
+/*
+ * Receiver thread.
+ */
+static WORKING_AREA(can_rx1_wa, 256);
+static WORKING_AREA(can_rx2_wa, 256);
+static msg_t can_rx(void *p) {
+ struct can_instance *cip = p;
+ EventListener el;
+ CANRxFrame rxmsg;
+
+ (void)p;
+ chRegSetThreadName("receiver");
+ chEvtRegister(&cip->canp->rxfull_event, &el, 0);
+ while(!chThdShouldTerminate()) {
+ if (chEvtWaitAnyTimeout(ALL_EVENTS, MS2ST(100)) == 0)
+ continue;
+ while (canReceive(cip->canp, CAN_ANY_MAILBOX,
+ &rxmsg, TIME_IMMEDIATE) == RDY_OK) {
+ /* Process message.*/
+ palTogglePad(GPIO0, cip->led);
+ }
+ }
+ chEvtUnregister(&CAND1.rxfull_event, &el);
+ return 0;
+}
+
+/*
+ * Transmitter thread.
+ */
+static WORKING_AREA(can_tx_wa, 256);
+static msg_t can_tx(void * p) {
+ CANTxFrame txmsg_can1;
+ CANTxFrame txmsg_can2;
+
+ (void)p;
+ chRegSetThreadName("transmitter");
+ txmsg_can1.IDE = CAN_IDE_EXT;
+ txmsg_can1.EID = 0x01234567;
+ txmsg_can1.RTR = CAN_RTR_DATA;
+ txmsg_can1.DLC = 8;
+ txmsg_can1.data32[0] = 0x55AA55AA;
+ txmsg_can1.data32[1] = 0x00FF00FF;
+
+ txmsg_can2.IDE = CAN_IDE_EXT;
+ txmsg_can2.EID = 0x0ABCDEF0;
+ txmsg_can2.RTR = CAN_RTR_DATA;
+ txmsg_can2.DLC = 8;
+ txmsg_can2.data32[0] = 0x66AA66AA;
+ txmsg_can2.data32[1] = 0x44FF44FF;
+
+ while (!chThdShouldTerminate()) {
+ canTransmit(&CAND1, CAN_ANY_MAILBOX, &txmsg_can1, MS2ST(100));
+ canTransmit(&CAND2, CAN_ANY_MAILBOX, &txmsg_can2, MS2ST(100));
+ chThdSleepMilliseconds(500);
+ }
+ return 0;
+}
+
+/*
+ * Application entry point.
+ */
+int main(void) {
+
+ /*
+ * System initializations.
+ * - HAL initialization, this also initializes the configured device drivers
+ * and performs the board-specific initializations.
+ * - Kernel initialization, the main() function becomes a thread and the
+ * RTOS is active.
+ */
+ halInit();
+ chSysInit();
+
+ /*
+ * Activates the CAN drivers 1 and 2.
+ */
+ canStart(&CAND1, &cancfg);
+ canStart(&CAND2, &cancfg);
+
+#if LPC17xx_CAN_USE_FILTER
+ canSetFilter(&canfcfg);
+#endif
+ /*
+ * Starting the transmitter and receiver threads.
+ */
+ chThdCreateStatic(can_rx1_wa, sizeof(can_rx1_wa), NORMALPRIO + 7,
+ can_rx, (void *)&can1);
+ chThdCreateStatic(can_rx2_wa, sizeof(can_rx2_wa), NORMALPRIO + 7,
+ can_rx, (void *)&can2);
+ chThdCreateStatic(can_tx_wa, sizeof(can_tx_wa), NORMALPRIO + 7,
+ can_tx, NULL);
+
+ /*
+ * Normal main() thread activity, in this demo it does nothing.
+ */
+ while (TRUE) {
+ chThdSleepMilliseconds(500);
+ }
+ return 0;
+}
diff --git a/testhal/LPC17xx/CAN_LOCAL_SELF_TEST/main.c b/testhal/LPC17xx/CAN_LOCAL_SELF_TEST/main.c
index baa15624f..ec6322946 100644
--- a/testhal/LPC17xx/CAN_LOCAL_SELF_TEST/main.c
+++ b/testhal/LPC17xx/CAN_LOCAL_SELF_TEST/main.c
@@ -1,112 +1,112 @@
-/*
- ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-#include "ch.h"
-#include "hal.h"
-
-/*
- * Local self test mode.
- */
-static const CANConfig cancfg = {
- CANMOD_STM,
- CANBTR_SJW(0) | CANBTR_TESG2(1) |
- CANBTR_TESG1(8) | CANBTR_BRP(20)
-};
-
-/*
- * Receiver thread.
- */
-static WORKING_AREA(can_rx1_wa, 256);
-static msg_t can_rx(void *p) {
-
- EventListener el;
- CANRxFrame rxmsg;
-
- (void)p;
- chRegSetThreadName("receiver");
- chEvtRegister(&CAND1.rxfull_event, &el, 0);
- while(!chThdShouldTerminate()) {
- if (chEvtWaitAnyTimeout(ALL_EVENTS, MS2ST(100)) == 0)
- continue;
- while (canReceive(&CAND1, CAN_ANY_MAILBOX,
- &rxmsg, TIME_IMMEDIATE) == RDY_OK) {
- /* Process message.*/
- palTogglePad(GPIO0, GPIO0_LED2_RED);
- }
- }
- chEvtUnregister(&CAND1.rxfull_event, &el);
- return 0;
-}
-
-/*
- * Transmitter thread.
- */
-static WORKING_AREA(can_tx_wa, 256);
-static msg_t can_tx(void * p) {
- CANTxFrame txmsg;
-
- (void)p;
- chRegSetThreadName("transmitter");
- txmsg.IDE = CAN_IDE_EXT;
- txmsg.EID = 0x01234567;
- txmsg.RTR = CAN_RTR_DATA;
- txmsg.DLC = 8;
- txmsg.data32[0] = 0x55AA55AA;
- txmsg.data32[1] = 0x00FF00FF;
-
- while (!chThdShouldTerminate()) {
- canTransmit(&CAND1, CAN_ANY_MAILBOX, &txmsg, MS2ST(100));
- chThdSleepMilliseconds(500);
- }
- return 0;
-}
-
-/*
- * Application entry point.
- */
-int main(void) {
-
- /*
- * System initializations.
- * - HAL initialization, this also initializes the configured device drivers
- * and performs the board-specific initializations.
- * - Kernel initialization, the main() function becomes a thread and the
- * RTOS is active.
- */
- halInit();
- chSysInit();
-
- /*
- * Activates the CAN drivers 1.
- */
- canStart(&CAND1, &cancfg);
-
- /*
- * Starting the transmitter and receiver threads.
- */
- chThdCreateStatic(can_rx1_wa, sizeof(can_rx1_wa), NORMALPRIO + 7,
- can_rx, NULL);
- chThdCreateStatic(can_tx_wa, sizeof(can_tx_wa), NORMALPRIO + 7,
- can_tx, NULL);
-
- /*
- * Normal main() thread activity, in this demo it does nothing.
- */
- while (TRUE) {
- chThdSleepMilliseconds(500);
- }
- return 0;
-}
+/*
+ ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+#include "ch.h"
+#include "hal.h"
+
+/*
+ * Local self test mode.
+ */
+static const CANConfig cancfg = {
+ CANMOD_STM,
+ CANBTR_SJW(0) | CANBTR_TESG2(1) |
+ CANBTR_TESG1(8) | CANBTR_BRP(20)
+};
+
+/*
+ * Receiver thread.
+ */
+static WORKING_AREA(can_rx1_wa, 256);
+static msg_t can_rx(void *p) {
+
+ EventListener el;
+ CANRxFrame rxmsg;
+
+ (void)p;
+ chRegSetThreadName("receiver");
+ chEvtRegister(&CAND1.rxfull_event, &el, 0);
+ while(!chThdShouldTerminate()) {
+ if (chEvtWaitAnyTimeout(ALL_EVENTS, MS2ST(100)) == 0)
+ continue;
+ while (canReceive(&CAND1, CAN_ANY_MAILBOX,
+ &rxmsg, TIME_IMMEDIATE) == RDY_OK) {
+ /* Process message.*/
+ palTogglePad(GPIO0, GPIO0_LED2_RED);
+ }
+ }
+ chEvtUnregister(&CAND1.rxfull_event, &el);
+ return 0;
+}
+
+/*
+ * Transmitter thread.
+ */
+static WORKING_AREA(can_tx_wa, 256);
+static msg_t can_tx(void * p) {
+ CANTxFrame txmsg;
+
+ (void)p;
+ chRegSetThreadName("transmitter");
+ txmsg.IDE = CAN_IDE_EXT;
+ txmsg.EID = 0x01234567;
+ txmsg.RTR = CAN_RTR_DATA;
+ txmsg.DLC = 8;
+ txmsg.data32[0] = 0x55AA55AA;
+ txmsg.data32[1] = 0x00FF00FF;
+
+ while (!chThdShouldTerminate()) {
+ canTransmit(&CAND1, CAN_ANY_MAILBOX, &txmsg, MS2ST(100));
+ chThdSleepMilliseconds(500);
+ }
+ return 0;
+}
+
+/*
+ * Application entry point.
+ */
+int main(void) {
+
+ /*
+ * System initializations.
+ * - HAL initialization, this also initializes the configured device drivers
+ * and performs the board-specific initializations.
+ * - Kernel initialization, the main() function becomes a thread and the
+ * RTOS is active.
+ */
+ halInit();
+ chSysInit();
+
+ /*
+ * Activates the CAN drivers 1.
+ */
+ canStart(&CAND1, &cancfg);
+
+ /*
+ * Starting the transmitter and receiver threads.
+ */
+ chThdCreateStatic(can_rx1_wa, sizeof(can_rx1_wa), NORMALPRIO + 7,
+ can_rx, NULL);
+ chThdCreateStatic(can_tx_wa, sizeof(can_tx_wa), NORMALPRIO + 7,
+ can_tx, NULL);
+
+ /*
+ * Normal main() thread activity, in this demo it does nothing.
+ */
+ while (TRUE) {
+ chThdSleepMilliseconds(500);
+ }
+ return 0;
+}
diff --git a/testhal/LPC17xx/DAC/main.c b/testhal/LPC17xx/DAC/main.c
index 68cf55659..624d52c8f 100644
--- a/testhal/LPC17xx/DAC/main.c
+++ b/testhal/LPC17xx/DAC/main.c
@@ -1,115 +1,115 @@
-/*
- ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-#include "ch.h"
-#include "hal.h"
-
-#define NSAMPLES 255
-
-const uint32_t sine_wave[NSAMPLES] = {
- 512 << 6, 524 << 6, 537 << 6, 549 << 6, 562 << 6, 574 << 6, 587 << 6, 599 << 6, 612 << 6, 624 << 6,
- 636 << 6, 649 << 6, 661 << 6, 673 << 6, 685 << 6, 696 << 6, 708 << 6, 720 << 6, 731 << 6, 743 << 6,
- 754 << 6, 765 << 6, 776 << 6, 786 << 6, 797 << 6, 807 << 6, 818 << 6, 828 << 6, 837 << 6, 847 << 6,
- 856 << 6, 866 << 6, 875 << 6, 883 << 6, 892 << 6, 900 << 6, 908 << 6, 916 << 6, 924 << 6, 931 << 6,
- 938 << 6, 945 << 6, 952 << 6, 958 << 6, 964 << 6, 970 << 6, 975 << 6, 981 << 6, 985 << 6, 990 << 6,
- 994 << 6, 998 << 6, 1002 << 6, 1006 << 6, 1009 << 6, 1012 << 6, 1014 << 6, 1016 << 6, 1018 << 6, 1020 << 6,
-1021 << 6, 1022 << 6, 1023 << 6, 1023 << 6, 1023 << 6, 1023 << 6, 1023 << 6, 1022 << 6, 1021 << 6, 1019 << 6,
-1017 << 6, 1015 << 6, 1013 << 6, 1010 << 6, 1007 << 6, 1004 << 6, 1000 << 6, 996 << 6, 992 << 6, 988 << 6,
- 983 << 6, 978 << 6, 973 << 6, 967 << 6, 961 << 6, 955 << 6, 948 << 6, 942 << 6, 935 << 6, 928 << 6,
- 920 << 6, 912 << 6, 904 << 6, 896 << 6, 888 << 6, 879 << 6, 870 << 6, 861 << 6, 852 << 6, 842 << 6,
- 832 << 6, 823 << 6, 812 << 6, 802 << 6, 792 << 6, 781 << 6, 770 << 6, 759 << 6, 748 << 6, 737 << 6,
- 725 << 6, 714 << 6, 702 << 6, 691 << 6, 679 << 6, 667 << 6, 655 << 6, 642 << 6, 630 << 6, 618 << 6,
- 606 << 6, 593 << 6, 581 << 6, 568 << 6, 556 << 6, 543 << 6, 530 << 6, 518 << 6, 505 << 6, 493 << 6,
- 480 << 6, 467 << 6, 455 << 6, 442 << 6, 430 << 6, 417 << 6, 405 << 6, 393 << 6, 381 << 6, 368 << 6,
- 356 << 6, 344 << 6, 332 << 6, 321 << 6, 309 << 6, 298 << 6, 286 << 6, 275 << 6, 264 << 6, 253 << 6,
- 242 << 6, 231 << 6, 221 << 6, 211 << 6, 200 << 6, 191 << 6, 181 << 6, 171 << 6, 162 << 6, 153 << 6,
- 144 << 6, 135 << 6, 127 << 6, 119 << 6, 111 << 6, 103 << 6, 95 << 6, 88 << 6, 81 << 6, 75 << 6,
- 68 << 6, 62 << 6, 56 << 6, 50 << 6, 45 << 6, 40 << 6, 35 << 6, 31 << 6, 27 << 6, 23 << 6,
- 19 << 6, 16 << 6, 13 << 6, 10 << 6, 8 << 6, 6 << 6, 4 << 6, 2 << 6, 1 << 6, 0 << 6,
- 0 << 6, 0 << 6, 0 << 6, 0 << 6, 1 << 6, 2 << 6, 3 << 6, 5 << 6, 7 << 6, 9 << 6,
- 11 << 6, 14 << 6, 17 << 6, 21 << 6, 25 << 6, 29 << 6, 33 << 6, 38 << 6, 42 << 6, 48 << 6,
- 53 << 6, 59 << 6, 65 << 6, 71 << 6, 78 << 6, 85 << 6, 92 << 6, 99 << 6, 107 << 6, 115 << 6,
- 123 << 6, 131 << 6, 140 << 6, 148 << 6, 157 << 6, 167 << 6, 176 << 6, 186 << 6, 195 << 6, 205 << 6,
- 216 << 6, 226 << 6, 237 << 6, 247 << 6, 258 << 6, 269 << 6, 280 << 6, 292 << 6, 303 << 6, 315 << 6,
- 327 << 6, 338 << 6, 350 << 6, 362 << 6, 374 << 6, 387 << 6, 399 << 6, 411 << 6, 424 << 6, 436 << 6,
- 449 << 6, 461 << 6, 474 << 6, 486 << 6, 499 << 6};
-
-/*
- * Red LEDs blinker thread, times are in milliseconds.
- */
-static WORKING_AREA(waThread1, 128);
-static msg_t Thread1(void *arg) {
-
- (void)arg;
- chRegSetThreadName("blinker");
- while (TRUE) {
- palTogglePad(GPIO0, GPIO0_LED2_RED);
- chThdSleepMilliseconds(500);
- }
-}
-
-/*
- * DAC conversion groups, with callbacks.
- */
-static const DACConversionGroup dacconvgrp1 = {
- 1, /* Channels */
- NULL, /* End of transfer callback */
- NULL, /* Error callback */
- true /*circular mode */
-};
-
-/*
- * DAC config
- */
-static const DACConfig daccfg1 = {
- 1000*NSAMPLES, /* Multiply the buffer size to the desired frequency in Hz */
-};
-
-/*
- * Application entry point.
- */
-int main(void) {
- /*
- * System initializations.
- * - HAL initialization, this also initializes the configured device drivers
- * and performs the board-specific initializations.
- * - Kernel initialization, the main() function becomes a thread and the
- * RTOS is active.
- */
- halInit();
- chSysInit();
-
- /*
- * Creates the blinker thread.
- */
- chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
-
- /*
- * Starting the DAC driver.
- */
- dacStart(&DACD1, &daccfg1);
-
- /*
- * Sending the dac_buffer
- */
- dacStartConversion(&DACD1, &dacconvgrp1, sine_wave, NSAMPLES);
-
- while (TRUE) {
-
- chThdSleepMilliseconds(1000);
-
- }
-}
+/*
+ ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+#include "ch.h"
+#include "hal.h"
+
+#define NSAMPLES 255
+
+const uint32_t sine_wave[NSAMPLES] = {
+ 512 << 6, 524 << 6, 537 << 6, 549 << 6, 562 << 6, 574 << 6, 587 << 6, 599 << 6, 612 << 6, 624 << 6,
+ 636 << 6, 649 << 6, 661 << 6, 673 << 6, 685 << 6, 696 << 6, 708 << 6, 720 << 6, 731 << 6, 743 << 6,
+ 754 << 6, 765 << 6, 776 << 6, 786 << 6, 797 << 6, 807 << 6, 818 << 6, 828 << 6, 837 << 6, 847 << 6,
+ 856 << 6, 866 << 6, 875 << 6, 883 << 6, 892 << 6, 900 << 6, 908 << 6, 916 << 6, 924 << 6, 931 << 6,
+ 938 << 6, 945 << 6, 952 << 6, 958 << 6, 964 << 6, 970 << 6, 975 << 6, 981 << 6, 985 << 6, 990 << 6,
+ 994 << 6, 998 << 6, 1002 << 6, 1006 << 6, 1009 << 6, 1012 << 6, 1014 << 6, 1016 << 6, 1018 << 6, 1020 << 6,
+1021 << 6, 1022 << 6, 1023 << 6, 1023 << 6, 1023 << 6, 1023 << 6, 1023 << 6, 1022 << 6, 1021 << 6, 1019 << 6,
+1017 << 6, 1015 << 6, 1013 << 6, 1010 << 6, 1007 << 6, 1004 << 6, 1000 << 6, 996 << 6, 992 << 6, 988 << 6,
+ 983 << 6, 978 << 6, 973 << 6, 967 << 6, 961 << 6, 955 << 6, 948 << 6, 942 << 6, 935 << 6, 928 << 6,
+ 920 << 6, 912 << 6, 904 << 6, 896 << 6, 888 << 6, 879 << 6, 870 << 6, 861 << 6, 852 << 6, 842 << 6,
+ 832 << 6, 823 << 6, 812 << 6, 802 << 6, 792 << 6, 781 << 6, 770 << 6, 759 << 6, 748 << 6, 737 << 6,
+ 725 << 6, 714 << 6, 702 << 6, 691 << 6, 679 << 6, 667 << 6, 655 << 6, 642 << 6, 630 << 6, 618 << 6,
+ 606 << 6, 593 << 6, 581 << 6, 568 << 6, 556 << 6, 543 << 6, 530 << 6, 518 << 6, 505 << 6, 493 << 6,
+ 480 << 6, 467 << 6, 455 << 6, 442 << 6, 430 << 6, 417 << 6, 405 << 6, 393 << 6, 381 << 6, 368 << 6,
+ 356 << 6, 344 << 6, 332 << 6, 321 << 6, 309 << 6, 298 << 6, 286 << 6, 275 << 6, 264 << 6, 253 << 6,
+ 242 << 6, 231 << 6, 221 << 6, 211 << 6, 200 << 6, 191 << 6, 181 << 6, 171 << 6, 162 << 6, 153 << 6,
+ 144 << 6, 135 << 6, 127 << 6, 119 << 6, 111 << 6, 103 << 6, 95 << 6, 88 << 6, 81 << 6, 75 << 6,
+ 68 << 6, 62 << 6, 56 << 6, 50 << 6, 45 << 6, 40 << 6, 35 << 6, 31 << 6, 27 << 6, 23 << 6,
+ 19 << 6, 16 << 6, 13 << 6, 10 << 6, 8 << 6, 6 << 6, 4 << 6, 2 << 6, 1 << 6, 0 << 6,
+ 0 << 6, 0 << 6, 0 << 6, 0 << 6, 1 << 6, 2 << 6, 3 << 6, 5 << 6, 7 << 6, 9 << 6,
+ 11 << 6, 14 << 6, 17 << 6, 21 << 6, 25 << 6, 29 << 6, 33 << 6, 38 << 6, 42 << 6, 48 << 6,
+ 53 << 6, 59 << 6, 65 << 6, 71 << 6, 78 << 6, 85 << 6, 92 << 6, 99 << 6, 107 << 6, 115 << 6,
+ 123 << 6, 131 << 6, 140 << 6, 148 << 6, 157 << 6, 167 << 6, 176 << 6, 186 << 6, 195 << 6, 205 << 6,
+ 216 << 6, 226 << 6, 237 << 6, 247 << 6, 258 << 6, 269 << 6, 280 << 6, 292 << 6, 303 << 6, 315 << 6,
+ 327 << 6, 338 << 6, 350 << 6, 362 << 6, 374 << 6, 387 << 6, 399 << 6, 411 << 6, 424 << 6, 436 << 6,
+ 449 << 6, 461 << 6, 474 << 6, 486 << 6, 499 << 6};
+
+/*
+ * Red LEDs blinker thread, times are in milliseconds.
+ */
+static WORKING_AREA(waThread1, 128);
+static msg_t Thread1(void *arg) {
+
+ (void)arg;
+ chRegSetThreadName("blinker");
+ while (TRUE) {
+ palTogglePad(GPIO0, GPIO0_LED2_RED);
+ chThdSleepMilliseconds(500);
+ }
+}
+
+/*
+ * DAC conversion groups, with callbacks.
+ */
+static const DACConversionGroup dacconvgrp1 = {
+ 1, /* Channels */
+ NULL, /* End of transfer callback */
+ NULL, /* Error callback */
+ true /*circular mode */
+};
+
+/*
+ * DAC config
+ */
+static const DACConfig daccfg1 = {
+ 1000*NSAMPLES, /* Multiply the buffer size to the desired frequency in Hz */
+};
+
+/*
+ * Application entry point.
+ */
+int main(void) {
+ /*
+ * System initializations.
+ * - HAL initialization, this also initializes the configured device drivers
+ * and performs the board-specific initializations.
+ * - Kernel initialization, the main() function becomes a thread and the
+ * RTOS is active.
+ */
+ halInit();
+ chSysInit();
+
+ /*
+ * Creates the blinker thread.
+ */
+ chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
+
+ /*
+ * Starting the DAC driver.
+ */
+ dacStart(&DACD1, &daccfg1);
+
+ /*
+ * Sending the dac_buffer
+ */
+ dacStartConversion(&DACD1, &dacconvgrp1, sine_wave, NSAMPLES);
+
+ while (TRUE) {
+
+ chThdSleepMilliseconds(1000);
+
+ }
+}
diff --git a/testhal/LPC17xx/DMA_MEM/main.c b/testhal/LPC17xx/DMA_MEM/main.c
index 89e86d522..8c50302da 100644
--- a/testhal/LPC17xx/DMA_MEM/main.c
+++ b/testhal/LPC17xx/DMA_MEM/main.c
@@ -1,118 +1,118 @@
-/*
- ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-#include "ch.h"
-#include "hal.h"
-#include "chprintf.h"
-
-#define MEM_SIZE 50
-
-BaseSequentialStream * chp = (BaseSequentialStream *)&SD1;
-
-uint32_t mem_src[MEM_SIZE];
-uint32_t mem_dst[MEM_SIZE];
-
-static void dma_mem_callback(void * dummy, uint32_t flags) {
- (void)dummy;
- (void)flags;
-}
-
-/*
- * Red LEDs blinker thread, times are in milliseconds.
- */
-static WORKING_AREA(waThread1, 128);
-static msg_t Thread1(void *arg) {
-
- (void)arg;
- chRegSetThreadName("blinker");
- while (TRUE) {
- palTogglePad(GPIO0, GPIO0_LED2_RED);
- chThdSleepMilliseconds(500);
- }
-}
-
-/*
- * Application entry point.
- */
-int main(void) {
- uint32_t i;
- /*
- * System initializations.
- * - HAL initialization, this also initializes the configured device drivers
- * and performs the board-specific initializations.
- * - Kernel initialization, the main() function becomes a thread and the
- * RTOS is active.
- */
- halInit();
- chSysInit();
-
- /*
- * Creates the blinker thread.
- */
- chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
-
- /*
- * Activates the SD driver 1.
- */
- sdStart(&SD1, NULL); /* Default is 38400-8-N-1.*/
-
- chprintf(chp, "Data before dma transfer.\r\n");
- chprintf(chp, "source \t destination\r\n");
- for (i = 0; i < MEM_SIZE; i++) {
- mem_src[i] = i;
- mem_dst[i] = 0;
- chprintf(chp, "%x \t %x\r\n", mem_src[i], mem_dst[i]);
- }
-
- dmaChannelAllocate(DMA_CHANNEL0, &dma_mem_callback, NULL);
- dmaChannelSrcAddr(DMA_CHANNEL0, &mem_src[0]);
- dmaChannelDstAddr(DMA_CHANNEL0, &mem_dst[0]);
- dmaChannelControl(DMA_CHANNEL0, DMA_CTRL_TRANSFER_SIZE(MEM_SIZE) |
- DMA_CTRL_SRC_BSIZE_16 |
- DMA_CTRL_DST_BSIZE_16 |
- DMA_CTRL_SRC_WIDTH_WORD |
- DMA_CTRL_DST_WIDTH_WORD |
- DMA_CTRL_SRC_INC |
- DMA_CTRL_DST_INC |
- DMA_CTRL_INT);
-
- dmaChannelConfig(DMA_CHANNEL0, DMA_CFG_CH_ENABLE |
- DMA_CFG_TTYPE_M2M |
- DMA_CFG_IE |
- DMA_CFG_ITC);
-
- chThdSleepMilliseconds(5000);
- chprintf(chp, "Data after dma transfer.\r\n");
- chprintf(chp, "source \t destination\r\n");
- for (i = 0; i < MEM_SIZE; i++) {
- chprintf(chp, "%x \t %x\r\n", mem_src[i], mem_dst[i]);
- }
-
- for (i = 0; i < MEM_SIZE; i++)
- if (mem_src[i] != mem_dst[i])
- break;
-
- if (i == MEM_SIZE)
- chprintf(chp, "Data transfer ok.\r\n");
- else
- chprintf(chp, "Error.\r\n");
-
- while (TRUE) {
-
- chThdSleepMilliseconds(1000);
-
- }
-}
+/*
+ ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+#include "ch.h"
+#include "hal.h"
+#include "chprintf.h"
+
+#define MEM_SIZE 50
+
+BaseSequentialStream * chp = (BaseSequentialStream *)&SD1;
+
+uint32_t mem_src[MEM_SIZE];
+uint32_t mem_dst[MEM_SIZE];
+
+static void dma_mem_callback(void * dummy, uint32_t flags) {
+ (void)dummy;
+ (void)flags;
+}
+
+/*
+ * Red LEDs blinker thread, times are in milliseconds.
+ */
+static WORKING_AREA(waThread1, 128);
+static msg_t Thread1(void *arg) {
+
+ (void)arg;
+ chRegSetThreadName("blinker");
+ while (TRUE) {
+ palTogglePad(GPIO0, GPIO0_LED2_RED);
+ chThdSleepMilliseconds(500);
+ }
+}
+
+/*
+ * Application entry point.
+ */
+int main(void) {
+ uint32_t i;
+ /*
+ * System initializations.
+ * - HAL initialization, this also initializes the configured device drivers
+ * and performs the board-specific initializations.
+ * - Kernel initialization, the main() function becomes a thread and the
+ * RTOS is active.
+ */
+ halInit();
+ chSysInit();
+
+ /*
+ * Creates the blinker thread.
+ */
+ chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
+
+ /*
+ * Activates the SD driver 1.
+ */
+ sdStart(&SD1, NULL); /* Default is 38400-8-N-1.*/
+
+ chprintf(chp, "Data before dma transfer.\r\n");
+ chprintf(chp, "source \t destination\r\n");
+ for (i = 0; i < MEM_SIZE; i++) {
+ mem_src[i] = i;
+ mem_dst[i] = 0;
+ chprintf(chp, "%x \t %x\r\n", mem_src[i], mem_dst[i]);
+ }
+
+ dmaChannelAllocate(DMA_CHANNEL0, &dma_mem_callback, NULL);
+ dmaChannelSrcAddr(DMA_CHANNEL0, &mem_src[0]);
+ dmaChannelDstAddr(DMA_CHANNEL0, &mem_dst[0]);
+ dmaChannelControl(DMA_CHANNEL0, DMA_CTRL_TRANSFER_SIZE(MEM_SIZE) |
+ DMA_CTRL_SRC_BSIZE_16 |
+ DMA_CTRL_DST_BSIZE_16 |
+ DMA_CTRL_SRC_WIDTH_WORD |
+ DMA_CTRL_DST_WIDTH_WORD |
+ DMA_CTRL_SRC_INC |
+ DMA_CTRL_DST_INC |
+ DMA_CTRL_INT);
+
+ dmaChannelConfig(DMA_CHANNEL0, DMA_CFG_CH_ENABLE |
+ DMA_CFG_TTYPE_M2M |
+ DMA_CFG_IE |
+ DMA_CFG_ITC);
+
+ chThdSleepMilliseconds(5000);
+ chprintf(chp, "Data after dma transfer.\r\n");
+ chprintf(chp, "source \t destination\r\n");
+ for (i = 0; i < MEM_SIZE; i++) {
+ chprintf(chp, "%x \t %x\r\n", mem_src[i], mem_dst[i]);
+ }
+
+ for (i = 0; i < MEM_SIZE; i++)
+ if (mem_src[i] != mem_dst[i])
+ break;
+
+ if (i == MEM_SIZE)
+ chprintf(chp, "Data transfer ok.\r\n");
+ else
+ chprintf(chp, "Error.\r\n");
+
+ while (TRUE) {
+
+ chThdSleepMilliseconds(1000);
+
+ }
+}
diff --git a/testhal/LPC17xx/I2C/main.c b/testhal/LPC17xx/I2C/main.c
index a9bf8fda9..6a9d35268 100644
--- a/testhal/LPC17xx/I2C/main.c
+++ b/testhal/LPC17xx/I2C/main.c
@@ -1,124 +1,124 @@
-/*
- ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-#include <stdlib.h>
-
-#include "ch.h"
-#include "hal.h"
-#include "chprintf.h"
-
-BaseSequentialStream * chp = (BaseSequentialStream *)&SD1;
-
-/* buffers depth */
-#define EEPROM_RX_DEPTH 10
-#define EEPROM_TX_DEPTH 12
-
-#define EEPROM_WR_ADRESS_H 0x00
-#define EEPROM_WR_ADRESS_L 0x00
-
-#define EEPROM_RD_ADRESS_H 0x00
-#define EEPROM_RD_ADRESS_L 0x00
-
-static uint8_t rxbuf[EEPROM_RX_DEPTH];
-static uint8_t txbuf[EEPROM_TX_DEPTH];
-
-static i2cflags_t errors = 0;
-#define EEPROM_24LC64_ADDR 0b1010000
-
-
-/* I2C interface #2 */
-static const I2CConfig i2ccfg2 = {
- I2C_FAST_MODE,
- 400000
-};
-
-/*
- * Application entry point.
- */
-int main(void) {
- msg_t status = RDY_OK;
- systime_t tmo = MS2ST(4);
- uint8_t i;
-
- /*
- * System initializations.
- * - HAL initialization, this also initializes the configured device drivers
- * and performs the board-specific initializations.
- * - Kernel initialization, the main() function becomes a thread and the
- * RTOS is active.
- */
- halInit();
- chSysInit();
-
- /*
- * Starts I2C
- */
- i2cStart(&I2CD2, &i2ccfg2);
-
- /*
- * Prepares the Serial driver 1
- */
- sdStart(&SD1, NULL); /* Default is 38400-8-N-1.*/
-
- txbuf[0] = EEPROM_WR_ADRESS_H; /* register address */
- txbuf[1] = EEPROM_WR_ADRESS_L;
- for (i = 2; i < EEPROM_TX_DEPTH; i++)
- txbuf[i] = i - 2;
-
- i2cAcquireBus(&I2CD2);
- status = i2cMasterTransmitTimeout(&I2CD2, EEPROM_24LC64_ADDR, txbuf, EEPROM_TX_DEPTH, rxbuf, 0, tmo);
- i2cReleaseBus(&I2CD2);
-
- if (status != RDY_OK){
- errors = i2cGetErrors(&I2CD2);
- chprintf(chp, "EEPROM write error code: %d\n\r", errors);
- }
- else {
- chprintf(chp, "\n\rEEPROM write:\t");
- for (i = 2; i < EEPROM_TX_DEPTH; i++) {
- chprintf(chp, "0x%02x ", txbuf[i]);
- }
- }
-
- chThdSleepMilliseconds(5);
-
- /* Read */
- txbuf[0] = EEPROM_RD_ADRESS_H; /* register address */
- txbuf[1] = EEPROM_RD_ADRESS_L;
- i2cAcquireBus(&I2CD2);
- status = i2cMasterTransmitTimeout(&I2CD2, EEPROM_24LC64_ADDR, txbuf, 2, rxbuf, EEPROM_RX_DEPTH, tmo);
- i2cReleaseBus(&I2CD2);
-
- if (status != RDY_OK) {
- errors = i2cGetErrors(&I2CD2);
- chprintf(chp, "EEPROM read error code: %d\n\r", errors);
- }
-
- chprintf(chp, "\n\rEEPROM read:\t ");
- for (i = 0; i < EEPROM_RX_DEPTH; i++) {
- chprintf(chp, "0x%02x ", rxbuf[i]);
- }
- /*
- * Normal main() thread activity, nothing in this test.
- */
- while (TRUE) {
- palTogglePad(GPIO0, GPIO0_LED2_RED);
- chThdSleepMilliseconds(100);
- }
-}
-
-
-
+/*
+ ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+#include <stdlib.h>
+
+#include "ch.h"
+#include "hal.h"
+#include "chprintf.h"
+
+BaseSequentialStream * chp = (BaseSequentialStream *)&SD1;
+
+/* buffers depth */
+#define EEPROM_RX_DEPTH 10
+#define EEPROM_TX_DEPTH 12
+
+#define EEPROM_WR_ADRESS_H 0x00
+#define EEPROM_WR_ADRESS_L 0x00
+
+#define EEPROM_RD_ADRESS_H 0x00
+#define EEPROM_RD_ADRESS_L 0x00
+
+static uint8_t rxbuf[EEPROM_RX_DEPTH];
+static uint8_t txbuf[EEPROM_TX_DEPTH];
+
+static i2cflags_t errors = 0;
+#define EEPROM_24LC64_ADDR 0b1010000
+
+
+/* I2C interface #2 */
+static const I2CConfig i2ccfg2 = {
+ I2C_FAST_MODE,
+ 400000
+};
+
+/*
+ * Application entry point.
+ */
+int main(void) {
+ msg_t status = RDY_OK;
+ systime_t tmo = MS2ST(4);
+ uint8_t i;
+
+ /*
+ * System initializations.
+ * - HAL initialization, this also initializes the configured device drivers
+ * and performs the board-specific initializations.
+ * - Kernel initialization, the main() function becomes a thread and the
+ * RTOS is active.
+ */
+ halInit();
+ chSysInit();
+
+ /*
+ * Starts I2C
+ */
+ i2cStart(&I2CD2, &i2ccfg2);
+
+ /*
+ * Prepares the Serial driver 1
+ */
+ sdStart(&SD1, NULL); /* Default is 38400-8-N-1.*/
+
+ txbuf[0] = EEPROM_WR_ADRESS_H; /* register address */
+ txbuf[1] = EEPROM_WR_ADRESS_L;
+ for (i = 2; i < EEPROM_TX_DEPTH; i++)
+ txbuf[i] = i - 2;
+
+ i2cAcquireBus(&I2CD2);
+ status = i2cMasterTransmitTimeout(&I2CD2, EEPROM_24LC64_ADDR, txbuf, EEPROM_TX_DEPTH, rxbuf, 0, tmo);
+ i2cReleaseBus(&I2CD2);
+
+ if (status != RDY_OK){
+ errors = i2cGetErrors(&I2CD2);
+ chprintf(chp, "EEPROM write error code: %d\n\r", errors);
+ }
+ else {
+ chprintf(chp, "\n\rEEPROM write:\t");
+ for (i = 2; i < EEPROM_TX_DEPTH; i++) {
+ chprintf(chp, "0x%02x ", txbuf[i]);
+ }
+ }
+
+ chThdSleepMilliseconds(5);
+
+ /* Read */
+ txbuf[0] = EEPROM_RD_ADRESS_H; /* register address */
+ txbuf[1] = EEPROM_RD_ADRESS_L;
+ i2cAcquireBus(&I2CD2);
+ status = i2cMasterTransmitTimeout(&I2CD2, EEPROM_24LC64_ADDR, txbuf, 2, rxbuf, EEPROM_RX_DEPTH, tmo);
+ i2cReleaseBus(&I2CD2);
+
+ if (status != RDY_OK) {
+ errors = i2cGetErrors(&I2CD2);
+ chprintf(chp, "EEPROM read error code: %d\n\r", errors);
+ }
+
+ chprintf(chp, "\n\rEEPROM read:\t ");
+ for (i = 0; i < EEPROM_RX_DEPTH; i++) {
+ chprintf(chp, "0x%02x ", rxbuf[i]);
+ }
+ /*
+ * Normal main() thread activity, nothing in this test.
+ */
+ while (TRUE) {
+ palTogglePad(GPIO0, GPIO0_LED2_RED);
+ chThdSleepMilliseconds(100);
+ }
+}
+
+
+
diff --git a/testhal/LPC17xx/IRQ_STORM/main.c b/testhal/LPC17xx/IRQ_STORM/main.c
index b52f01283..833ccde71 100644
--- a/testhal/LPC17xx/IRQ_STORM/main.c
+++ b/testhal/LPC17xx/IRQ_STORM/main.c
@@ -1,324 +1,324 @@
-/*
- ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-#include <stdlib.h>
-
-#include "ch.h"
-#include "hal.h"
-
-/*===========================================================================*/
-/* Configurable settings. */
-/*===========================================================================*/
-
-#ifndef RANDOMIZE
-#define RANDOMIZE FALSE
-#endif
-
-#ifndef ITERATIONS
-#define ITERATIONS 100
-#endif
-
-#ifndef NUM_THREADS
-#define NUM_THREADS 4
-#endif
-
-#ifndef MAILBOX_SIZE
-#define MAILBOX_SIZE 4
-#endif
-
-/*===========================================================================*/
-/* Test related code. */
-/*===========================================================================*/
-
-#define MSG_SEND_LEFT 0
-#define MSG_SEND_RIGHT 1
-
-static bool_t saturated;
-
-/*
- * Mailboxes and buffers.
- */
-static Mailbox mb[NUM_THREADS];
-static msg_t b[NUM_THREADS][MAILBOX_SIZE];
-
-/*
- * Test worker threads.
- */
-static WORKING_AREA(waWorkerThread[NUM_THREADS], 128);
-static msg_t WorkerThread(void *arg) {
- static volatile unsigned x = 0;
- static unsigned cnt = 0;
- unsigned me = (unsigned)arg;
- unsigned target;
- unsigned r;
- msg_t msg;
-
- chRegSetThreadName("worker");
-
- /* Work loop.*/
- while (TRUE) {
- /* Waiting for a message.*/
- chMBFetch(&mb[me], &msg, TIME_INFINITE);
-
-#if RANDOMIZE
- /* Pseudo-random delay.*/
- {
- chSysLock();
- r = rand() & 15;
- chSysUnlock();
- while (r--)
- x++;
- }
-#else
- /* Fixed delay.*/
- {
- r = me >> 4;
- while (r--)
- x++;
- }
-#endif
-
- /* Deciding in which direction to re-send the message.*/
- if (msg == MSG_SEND_LEFT)
- target = me - 1;
- else
- target = me + 1;
-
- if (target < NUM_THREADS) {
- /* If this thread is not at the end of a chain re-sending the message,
- note this check works because the variable target is unsigned.*/
- msg = chMBPost(&mb[target], msg, TIME_IMMEDIATE);
- if (msg != RDY_OK)
- saturated = TRUE;
- }
- else {
- /* Provides a visual feedback about the system.*/
- if (++cnt >= 500) {
- cnt = 0;
- palTogglePad(GPIO0, GPIO0_LED2_RED);
- }
- }
- }
-}
-
-/*
- * GPT1 callback.
- */
-static void gpt1cb(GPTDriver *gptp) {
- msg_t msg;
-
- (void)gptp;
- chSysLockFromIsr();
- msg = chMBPostI(&mb[0], MSG_SEND_RIGHT);
- if (msg != RDY_OK)
- saturated = TRUE;
- chSysUnlockFromIsr();
-}
-
-/*
- * GPT2 callback.
- */
-static void gpt2cb(GPTDriver *gptp) {
- msg_t msg;
-
- (void)gptp;
- chSysLockFromIsr();
- msg = chMBPostI(&mb[NUM_THREADS - 1], MSG_SEND_LEFT);
- if (msg != RDY_OK)
- saturated = TRUE;
- chSysUnlockFromIsr();
-}
-
-/*
- * GPT1 configuration.
- */
-static const GPTConfig gpt1cfg = {
- 1000000, /* 1MHz timer clock.*/
- gpt1cb /* Timer callback.*/
-};
-
-/*
- * GPT2 configuration.
- */
-static const GPTConfig gpt2cfg = {
- 1000000, /* 1MHz timer clock.*/
- gpt2cb /* Timer callback.*/
-};
-
-
-/*===========================================================================*/
-/* Generic demo code. */
-/*===========================================================================*/
-
-static void print(char *p) {
-
- while (*p) {
- chSequentialStreamPut(&SD1, *p++);
- }
-}
-
-static void println(char *p) {
-
- while (*p) {
- chSequentialStreamPut(&SD1, *p++);
- }
- chSequentialStreamWrite(&SD1, (uint8_t *)"\r\n", 2);
-}
-
-static void printn(uint32_t n) {
- char buf[16], *p;
-
- if (!n)
- chSequentialStreamPut(&SD1, '0');
- else {
- p = buf;
- while (n)
- *p++ = (n % 10) + '0', n /= 10;
- while (p > buf)
- chSequentialStreamPut(&SD1, *--p);
- }
-}
-
-/*
- * Application entry point.
- */
-int main(void) {
- unsigned i;
- gptcnt_t interval, threshold, worst;
-
- /*
- * System initializations.
- * - HAL initialization, this also initializes the configured device drivers
- * and performs the board-specific initializations.
- * - Kernel initialization, the main() function becomes a thread and the
- * RTOS is active.
- */
- halInit();
- chSysInit();
-
- /*
- * Prepares the Serial driver 2 and GPT drivers 1 and 2.
- */
- sdStart(&SD1, NULL); /* Default is 38400-8-N-1.*/
- gptStart(&GPTD1, &gpt1cfg);
- gptStart(&GPTD2, &gpt2cfg);
-
- /*
- * Initializes the mailboxes and creates the worker threads.
- */
- for (i = 0; i < NUM_THREADS; i++) {
- chMBInit(&mb[i], b[i], MAILBOX_SIZE);
- chThdCreateStatic(waWorkerThread[i], sizeof waWorkerThread[i],
- NORMALPRIO - 20, WorkerThread, (void *)i);
- }
-
- /*
- * Test procedure.
- */
- println("");
- println("*** ChibiOS/RT IRQ-STORM long duration test");
- println("***");
- print("*** Kernel: ");
- println(CH_KERNEL_VERSION);
-#ifdef CH_COMPILER_NAME
- print("*** Compiler: ");
- println(CH_COMPILER_NAME);
-#endif
- print("*** Architecture: ");
- println(CH_ARCHITECTURE_NAME);
-#ifdef CH_CORE_VARIANT_NAME
- print("*** Core Variant: ");
- println(CH_CORE_VARIANT_NAME);
-#endif
-#ifdef CH_PORT_INFO
- print("*** Port Info: ");
- println(CH_PORT_INFO);
-#endif
-#ifdef PLATFORM_NAME
- print("*** Platform: ");
- println(PLATFORM_NAME);
-#endif
-#ifdef BOARD_NAME
- print("*** Test Board: ");
- println(BOARD_NAME);
-#endif
- println("***");
- print("*** System Clock: ");
- printn(LPC17xx_CCLK);
- println("");
- print("*** Iterations: ");
- printn(ITERATIONS);
- println("");
- print("*** Randomize: ");
- printn(RANDOMIZE);
- println("");
- print("*** Threads: ");
- printn(NUM_THREADS);
- println("");
- print("*** Mailbox size: ");
- printn(MAILBOX_SIZE);
- println("");
-
- println("");
- worst = 0;
- for (i = 1; i <= ITERATIONS; i++){
- print("Iteration ");
- printn(i);
- println("");
- saturated = FALSE;
- threshold = 0;
- for (interval = 2000; interval >= 20; interval -= interval / 10) {
- gptStartContinuous(&GPTD1, interval - 1); /* Slightly out of phase.*/
- gptStartContinuous(&GPTD2, interval + 1); /* Slightly out of phase.*/
- chThdSleepMilliseconds(1000);
- gptStopTimer(&GPTD1);
- gptStopTimer(&GPTD2);
- if (!saturated)
- print(".");
- else {
- print("#");
- if (threshold == 0)
- threshold = interval;
- }
- }
- /* Gives the worker threads a chance to empty the mailboxes before next
- cycle.*/
- chThdSleepMilliseconds(20);
- println("");
- print("Saturated at ");
- printn(threshold);
- println(" uS");
- println("");
- if (threshold > worst)
- worst = threshold;
- }
- gptStopTimer(&GPTD1);
- gptStopTimer(&GPTD2);
-
- print("Worst case at ");
- printn(worst);
- println(" uS");
- println("");
- println("Test Complete");
-
- /*
- * Normal main() thread activity, nothing in this test.
- */
- while (TRUE) {
- chThdSleepMilliseconds(5000);
- }
- return 0;
-}
+/*
+ ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+#include <stdlib.h>
+
+#include "ch.h"
+#include "hal.h"
+
+/*===========================================================================*/
+/* Configurable settings. */
+/*===========================================================================*/
+
+#ifndef RANDOMIZE
+#define RANDOMIZE FALSE
+#endif
+
+#ifndef ITERATIONS
+#define ITERATIONS 100
+#endif
+
+#ifndef NUM_THREADS
+#define NUM_THREADS 4
+#endif
+
+#ifndef MAILBOX_SIZE
+#define MAILBOX_SIZE 4
+#endif
+
+/*===========================================================================*/
+/* Test related code. */
+/*===========================================================================*/
+
+#define MSG_SEND_LEFT 0
+#define MSG_SEND_RIGHT 1
+
+static bool_t saturated;
+
+/*
+ * Mailboxes and buffers.
+ */
+static Mailbox mb[NUM_THREADS];
+static msg_t b[NUM_THREADS][MAILBOX_SIZE];
+
+/*
+ * Test worker threads.
+ */
+static WORKING_AREA(waWorkerThread[NUM_THREADS], 128);
+static msg_t WorkerThread(void *arg) {
+ static volatile unsigned x = 0;
+ static unsigned cnt = 0;
+ unsigned me = (unsigned)arg;
+ unsigned target;
+ unsigned r;
+ msg_t msg;
+
+ chRegSetThreadName("worker");
+
+ /* Work loop.*/
+ while (TRUE) {
+ /* Waiting for a message.*/
+ chMBFetch(&mb[me], &msg, TIME_INFINITE);
+
+#if RANDOMIZE
+ /* Pseudo-random delay.*/
+ {
+ chSysLock();
+ r = rand() & 15;
+ chSysUnlock();
+ while (r--)
+ x++;
+ }
+#else
+ /* Fixed delay.*/
+ {
+ r = me >> 4;
+ while (r--)
+ x++;
+ }
+#endif
+
+ /* Deciding in which direction to re-send the message.*/
+ if (msg == MSG_SEND_LEFT)
+ target = me - 1;
+ else
+ target = me + 1;
+
+ if (target < NUM_THREADS) {
+ /* If this thread is not at the end of a chain re-sending the message,
+ note this check works because the variable target is unsigned.*/
+ msg = chMBPost(&mb[target], msg, TIME_IMMEDIATE);
+ if (msg != RDY_OK)
+ saturated = TRUE;
+ }
+ else {
+ /* Provides a visual feedback about the system.*/
+ if (++cnt >= 500) {
+ cnt = 0;
+ palTogglePad(GPIO0, GPIO0_LED2_RED);
+ }
+ }
+ }
+}
+
+/*
+ * GPT1 callback.
+ */
+static void gpt1cb(GPTDriver *gptp) {
+ msg_t msg;
+
+ (void)gptp;
+ chSysLockFromIsr();
+ msg = chMBPostI(&mb[0], MSG_SEND_RIGHT);
+ if (msg != RDY_OK)
+ saturated = TRUE;
+ chSysUnlockFromIsr();
+}
+
+/*
+ * GPT2 callback.
+ */
+static void gpt2cb(GPTDriver *gptp) {
+ msg_t msg;
+
+ (void)gptp;
+ chSysLockFromIsr();
+ msg = chMBPostI(&mb[NUM_THREADS - 1], MSG_SEND_LEFT);
+ if (msg != RDY_OK)
+ saturated = TRUE;
+ chSysUnlockFromIsr();
+}
+
+/*
+ * GPT1 configuration.
+ */
+static const GPTConfig gpt1cfg = {
+ 1000000, /* 1MHz timer clock.*/
+ gpt1cb /* Timer callback.*/
+};
+
+/*
+ * GPT2 configuration.
+ */
+static const GPTConfig gpt2cfg = {
+ 1000000, /* 1MHz timer clock.*/
+ gpt2cb /* Timer callback.*/
+};
+
+
+/*===========================================================================*/
+/* Generic demo code. */
+/*===========================================================================*/
+
+static void print(char *p) {
+
+ while (*p) {
+ chSequentialStreamPut(&SD1, *p++);
+ }
+}
+
+static void println(char *p) {
+
+ while (*p) {
+ chSequentialStreamPut(&SD1, *p++);
+ }
+ chSequentialStreamWrite(&SD1, (uint8_t *)"\r\n", 2);
+}
+
+static void printn(uint32_t n) {
+ char buf[16], *p;
+
+ if (!n)
+ chSequentialStreamPut(&SD1, '0');
+ else {
+ p = buf;
+ while (n)
+ *p++ = (n % 10) + '0', n /= 10;
+ while (p > buf)
+ chSequentialStreamPut(&SD1, *--p);
+ }
+}
+
+/*
+ * Application entry point.
+ */
+int main(void) {
+ unsigned i;
+ gptcnt_t interval, threshold, worst;
+
+ /*
+ * System initializations.
+ * - HAL initialization, this also initializes the configured device drivers
+ * and performs the board-specific initializations.
+ * - Kernel initialization, the main() function becomes a thread and the
+ * RTOS is active.
+ */
+ halInit();
+ chSysInit();
+
+ /*
+ * Prepares the Serial driver 2 and GPT drivers 1 and 2.
+ */
+ sdStart(&SD1, NULL); /* Default is 38400-8-N-1.*/
+ gptStart(&GPTD1, &gpt1cfg);
+ gptStart(&GPTD2, &gpt2cfg);
+
+ /*
+ * Initializes the mailboxes and creates the worker threads.
+ */
+ for (i = 0; i < NUM_THREADS; i++) {
+ chMBInit(&mb[i], b[i], MAILBOX_SIZE);
+ chThdCreateStatic(waWorkerThread[i], sizeof waWorkerThread[i],
+ NORMALPRIO - 20, WorkerThread, (void *)i);
+ }
+
+ /*
+ * Test procedure.
+ */
+ println("");
+ println("*** ChibiOS/RT IRQ-STORM long duration test");
+ println("***");
+ print("*** Kernel: ");
+ println(CH_KERNEL_VERSION);
+#ifdef CH_COMPILER_NAME
+ print("*** Compiler: ");
+ println(CH_COMPILER_NAME);
+#endif
+ print("*** Architecture: ");
+ println(CH_ARCHITECTURE_NAME);
+#ifdef CH_CORE_VARIANT_NAME
+ print("*** Core Variant: ");
+ println(CH_CORE_VARIANT_NAME);
+#endif
+#ifdef CH_PORT_INFO
+ print("*** Port Info: ");
+ println(CH_PORT_INFO);
+#endif
+#ifdef PLATFORM_NAME
+ print("*** Platform: ");
+ println(PLATFORM_NAME);
+#endif
+#ifdef BOARD_NAME
+ print("*** Test Board: ");
+ println(BOARD_NAME);
+#endif
+ println("***");
+ print("*** System Clock: ");
+ printn(LPC17xx_CCLK);
+ println("");
+ print("*** Iterations: ");
+ printn(ITERATIONS);
+ println("");
+ print("*** Randomize: ");
+ printn(RANDOMIZE);
+ println("");
+ print("*** Threads: ");
+ printn(NUM_THREADS);
+ println("");
+ print("*** Mailbox size: ");
+ printn(MAILBOX_SIZE);
+ println("");
+
+ println("");
+ worst = 0;
+ for (i = 1; i <= ITERATIONS; i++){
+ print("Iteration ");
+ printn(i);
+ println("");
+ saturated = FALSE;
+ threshold = 0;
+ for (interval = 2000; interval >= 20; interval -= interval / 10) {
+ gptStartContinuous(&GPTD1, interval - 1); /* Slightly out of phase.*/
+ gptStartContinuous(&GPTD2, interval + 1); /* Slightly out of phase.*/
+ chThdSleepMilliseconds(1000);
+ gptStopTimer(&GPTD1);
+ gptStopTimer(&GPTD2);
+ if (!saturated)
+ print(".");
+ else {
+ print("#");
+ if (threshold == 0)
+ threshold = interval;
+ }
+ }
+ /* Gives the worker threads a chance to empty the mailboxes before next
+ cycle.*/
+ chThdSleepMilliseconds(20);
+ println("");
+ print("Saturated at ");
+ printn(threshold);
+ println(" uS");
+ println("");
+ if (threshold > worst)
+ worst = threshold;
+ }
+ gptStopTimer(&GPTD1);
+ gptStopTimer(&GPTD2);
+
+ print("Worst case at ");
+ printn(worst);
+ println(" uS");
+ println("");
+ println("Test Complete");
+
+ /*
+ * Normal main() thread activity, nothing in this test.
+ */
+ while (TRUE) {
+ chThdSleepMilliseconds(5000);
+ }
+ return 0;
+}
diff --git a/testhal/LPC17xx/RTC/main.c b/testhal/LPC17xx/RTC/main.c
index 5321d654f..da8d7e18e 100644
--- a/testhal/LPC17xx/RTC/main.c
+++ b/testhal/LPC17xx/RTC/main.c
@@ -1,280 +1,280 @@
-/*
- ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-/*
-This structure is used to hold the values representing a calendar time.
-It contains the following members, with the meanings as shown.
-
-int tm_sec seconds after minute [0-61] (61 allows for 2 leap-seconds)
-int tm_min minutes after hour [0-59]
-int tm_hour hours after midnight [0-23]
-int tm_mday day of the month [1-31]
-int tm_mon month of year [0-11]
-int tm_year current year-1900
-int tm_wday days since Sunday [0-6]
-int tm_yday days since January 1st [0-365]
-int tm_isdst daylight savings indicator (1 = yes, 0 = no, -1 = unknown)
-*/
-
-#include <string.h>
-#include <stdlib.h>
-#include <time.h>
-
-#include "ch.h"
-#include "hal.h"
-
-#include "shell.h"
-#include "chprintf.h"
-#include "chrtclib.h"
-
-static RTCAlarm alarmspec;
-static time_t unix_time;
-
-/* libc stub */
-int _getpid(void) {return 1;}
-/* libc stub */
-void _exit(int i) {(void)i;}
-/* libc stub */
-#include <errno.h>
-#undef errno
-extern int errno;
-int _kill(int pid, int sig) {
- (void)pid;
- (void)sig;
- errno = EINVAL;
- return -1;
-}
-
-
-/* sleep indicator thread */
-static WORKING_AREA(blinkWA, 128);
-static msg_t blink_thd(void *arg){
- (void)arg;
- while (TRUE) {
- chThdSleepMilliseconds(100);
- palTogglePad(GPIO0, GPIO0_LED2_RED);
- }
- return 0;
-}
-
-static void wakeup_cb(RTCDriver *rtcp, rtcevent_t event) {
-
- (void)rtcp;
-
- if (event == RTC_EVENT_ALARM) {
-
- }
-}
-
-/* Wake-up from Deep-sleep mode with rtc alarm (must be set first) */
-/* Before going sleep disconnect debugger !!! User manual page 758 */
-static void func_sleep(void) {
-
- /* Deep sleep-mode configuration */
- LPC_SC->PCON &= ~((1UL << 1) | (1UL << 0)); /* Clear PM0 and PM1 bit for deep sleep mode.*/
- SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk; /* Deep sleep mode */
-
- __WFI();
-
- NVIC_SystemReset();
-}
-
-/* Wake-up from Deep power-down with wake-up pin or rtc alarm (must be set first) */
-/* Before going power down disconnect debugger !!! User manual page 758 */
-static void func_pwrdown(void) {
-
- LPC_SC->PCON |= (1UL << 1) | (1UL << 0); /* Set PM0 and PM1 bit for deep power-down mode.*/
- SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk; /* Deep sleep mode. */
-
- __WFI();
-}
-
-static void cmd_pwrdown(BaseSequentialStream *chp, int argc, char *argv[]){
- (void)argv;
-
- if (argc > 0) {
- chprintf(chp, "Usage: pwrdown\r\n");
- return;
- }
- chprintf(chp, "Going to power down.\r\n");
-
- chThdSleepMilliseconds(200);
-
- func_pwrdown();
-
-}
-
-static void cmd_sleep(BaseSequentialStream *chp, int argc, char *argv[]){
- (void)argv;
- if (argc > 0) {
- chprintf(chp, "Usage: sleep\r\n");
- return;
- }
- chprintf(chp, "Going to sleep.\r\n");
-
- chThdSleepMilliseconds(200);
-
- /* going to anabiosis */
- func_sleep();
-}
-
-/*
- *
- */
-static void cmd_alarm(BaseSequentialStream *chp, int argc, char *argv[]){
- (void)argv;
- struct tm timp;
-
- if (argc < 1) {
- goto ERROR;
- }
-
- if ((argc == 1) && (strcmp(argv[0], "get") == 0)){
- rtcGetAlarm(&RTCD1, 0, &alarmspec);
- timp.tm_sec = alarmspec.alsec;
- timp.tm_min = alarmspec.almin;
- timp.tm_hour = alarmspec.alhour;
- timp.tm_mday = alarmspec.aldom;
- timp.tm_mon = alarmspec.almonth - 1;
- timp.tm_wday = alarmspec.aldow;
- timp.tm_year = alarmspec.alyear - 1900;
- timp.tm_yday = alarmspec.aldoy - 1;
- chprintf(chp, "%D%s",mktime(&timp)," - alarm in seconds\r\n");
- return;
- }
-
- if ((argc == 2) && (strcmp(argv[0], "set") == 0)){
- unix_time = (uint32_t)atol(argv[1]);
- localtime_r(&unix_time, &timp);
- alarmspec.alsec = timp.tm_sec;
- alarmspec.almin = timp.tm_min;
- alarmspec.alhour = timp.tm_hour;
- alarmspec.aldom = timp.tm_mday;
- alarmspec.almonth = timp.tm_mon + 1;
- alarmspec.aldow = timp.tm_wday;
- alarmspec.alyear = timp.tm_year + 1900;
- alarmspec.aldoy = timp.tm_yday + 1;
- rtcSetAlarm(&RTCD1, 0, &alarmspec);
- rtcSetCallback(&RTCD1, wakeup_cb);
- return;
- }
- else{
- goto ERROR;
- }
-
-ERROR:
- chprintf(chp, "Usage: alarm get\r\n");
- chprintf(chp, " alarm set N\r\n");
- chprintf(chp, "where N is alarm time in seconds\r\n");
-}
-
-/*
- *
- */
-static void cmd_date(BaseSequentialStream *chp, int argc, char *argv[]){
- (void)argv;
- struct tm timp;
-
- if (argc == 0) {
- goto ERROR;
- }
-
- if ((argc == 1) && (strcmp(argv[0], "get") == 0)){
- unix_time = rtcGetTimeUnixSec(&RTCD1);
-
- if (unix_time == -1){
- chprintf(chp, "incorrect time in RTC cell\r\n");
- }
- else{
- chprintf(chp, "%D%s",unix_time," - unix time\r\n");
- rtcGetTimeTm(&RTCD1, &timp);
- chprintf(chp, "%s%s",asctime(&timp)," - formatted time string\r\n");
- }
- return;
- }
-
- if ((argc == 2) && (strcmp(argv[0], "set") == 0)){
- unix_time = atol(argv[1]);
- if (unix_time > 0){
- rtcSetTimeUnixSec(&RTCD1, unix_time);
- return;
- }
- else{
- goto ERROR;
- }
- }
- else{
- goto ERROR;
- }
-
-ERROR:
- chprintf(chp, "Usage: date get\r\n");
- chprintf(chp, " date set N\r\n");
- chprintf(chp, "where N is time in seconds sins Unix epoch\r\n");
- chprintf(chp, "you can get current N value from unix console by the command\r\n");
- chprintf(chp, "%s", "date +\%s\r\n");
- return;
-}
-
-static const ShellCommand commands[] = {
- {"alarm", cmd_alarm},
- {"date", cmd_date},
- {"sleep", cmd_sleep},
- {"pwrdown", cmd_pwrdown},
- {NULL, NULL}
-};
-
-static const ShellConfig shell_cfg1 = {
- (BaseSequentialStream *)&SD1,
- commands
-};
-
-BaseSequentialStream * chp1 = (BaseSequentialStream *)&SD1;
-
-/**
- * Main function.
- */
-int main(void){
-
- halInit();
- chSysInit();
- chThdCreateStatic(blinkWA, sizeof(blinkWA), NORMALPRIO, blink_thd, NULL);
-
- sdStart(&SD1, NULL); /* Default is 38400-8-N-1.*/
-
- if (LPC_SC->PCON & (1UL << 11)) {
- chprintf(chp1, "Woke from Deep power-down\r\n");
- LPC_SC->PCON |= (1UL << 11);
- }
-
- if (LPC_SC->PCON & (1UL << 9)) {
- chprintf(chp1, "Woke from Deep-sleep mode\r\n");
- LPC_SC->PCON |= (1UL << 9);
- }
-
- /* Shell initialization.*/
- shellInit();
- static WORKING_AREA(waShell, 1024);
- shellCreateStatic(&shell_cfg1, waShell, sizeof(waShell), NORMALPRIO);
-
- /* wait until user do not want to test wakeup */
- while (TRUE){
- chThdSleepMilliseconds(200);
- }
- return 0;
-}
-
-
+/*
+ ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+/*
+This structure is used to hold the values representing a calendar time.
+It contains the following members, with the meanings as shown.
+
+int tm_sec seconds after minute [0-61] (61 allows for 2 leap-seconds)
+int tm_min minutes after hour [0-59]
+int tm_hour hours after midnight [0-23]
+int tm_mday day of the month [1-31]
+int tm_mon month of year [0-11]
+int tm_year current year-1900
+int tm_wday days since Sunday [0-6]
+int tm_yday days since January 1st [0-365]
+int tm_isdst daylight savings indicator (1 = yes, 0 = no, -1 = unknown)
+*/
+
+#include <string.h>
+#include <stdlib.h>
+#include <time.h>
+
+#include "ch.h"
+#include "hal.h"
+
+#include "shell.h"
+#include "chprintf.h"
+#include "chrtclib.h"
+
+static RTCAlarm alarmspec;
+static time_t unix_time;
+
+/* libc stub */
+int _getpid(void) {return 1;}
+/* libc stub */
+void _exit(int i) {(void)i;}
+/* libc stub */
+#include <errno.h>
+#undef errno
+extern int errno;
+int _kill(int pid, int sig) {
+ (void)pid;
+ (void)sig;
+ errno = EINVAL;
+ return -1;
+}
+
+
+/* sleep indicator thread */
+static WORKING_AREA(blinkWA, 128);
+static msg_t blink_thd(void *arg){
+ (void)arg;
+ while (TRUE) {
+ chThdSleepMilliseconds(100);
+ palTogglePad(GPIO0, GPIO0_LED2_RED);
+ }
+ return 0;
+}
+
+static void wakeup_cb(RTCDriver *rtcp, rtcevent_t event) {
+
+ (void)rtcp;
+
+ if (event == RTC_EVENT_ALARM) {
+
+ }
+}
+
+/* Wake-up from Deep-sleep mode with rtc alarm (must be set first) */
+/* Before going sleep disconnect debugger !!! User manual page 758 */
+static void func_sleep(void) {
+
+ /* Deep sleep-mode configuration */
+ LPC_SC->PCON &= ~((1UL << 1) | (1UL << 0)); /* Clear PM0 and PM1 bit for deep sleep mode.*/
+ SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk; /* Deep sleep mode */
+
+ __WFI();
+
+ NVIC_SystemReset();
+}
+
+/* Wake-up from Deep power-down with wake-up pin or rtc alarm (must be set first) */
+/* Before going power down disconnect debugger !!! User manual page 758 */
+static void func_pwrdown(void) {
+
+ LPC_SC->PCON |= (1UL << 1) | (1UL << 0); /* Set PM0 and PM1 bit for deep power-down mode.*/
+ SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk; /* Deep sleep mode. */
+
+ __WFI();
+}
+
+static void cmd_pwrdown(BaseSequentialStream *chp, int argc, char *argv[]){
+ (void)argv;
+
+ if (argc > 0) {
+ chprintf(chp, "Usage: pwrdown\r\n");
+ return;
+ }
+ chprintf(chp, "Going to power down.\r\n");
+
+ chThdSleepMilliseconds(200);
+
+ func_pwrdown();
+
+}
+
+static void cmd_sleep(BaseSequentialStream *chp, int argc, char *argv[]){
+ (void)argv;
+ if (argc > 0) {
+ chprintf(chp, "Usage: sleep\r\n");
+ return;
+ }
+ chprintf(chp, "Going to sleep.\r\n");
+
+ chThdSleepMilliseconds(200);
+
+ /* going to anabiosis */
+ func_sleep();
+}
+
+/*
+ *
+ */
+static void cmd_alarm(BaseSequentialStream *chp, int argc, char *argv[]){
+ (void)argv;
+ struct tm timp;
+
+ if (argc < 1) {
+ goto ERROR;
+ }
+
+ if ((argc == 1) && (strcmp(argv[0], "get") == 0)){
+ rtcGetAlarm(&RTCD1, 0, &alarmspec);
+ timp.tm_sec = alarmspec.alsec;
+ timp.tm_min = alarmspec.almin;
+ timp.tm_hour = alarmspec.alhour;
+ timp.tm_mday = alarmspec.aldom;
+ timp.tm_mon = alarmspec.almonth - 1;
+ timp.tm_wday = alarmspec.aldow;
+ timp.tm_year = alarmspec.alyear - 1900;
+ timp.tm_yday = alarmspec.aldoy - 1;
+ chprintf(chp, "%D%s",mktime(&timp)," - alarm in seconds\r\n");
+ return;
+ }
+
+ if ((argc == 2) && (strcmp(argv[0], "set") == 0)){
+ unix_time = (uint32_t)atol(argv[1]);
+ localtime_r(&unix_time, &timp);
+ alarmspec.alsec = timp.tm_sec;
+ alarmspec.almin = timp.tm_min;
+ alarmspec.alhour = timp.tm_hour;
+ alarmspec.aldom = timp.tm_mday;
+ alarmspec.almonth = timp.tm_mon + 1;
+ alarmspec.aldow = timp.tm_wday;
+ alarmspec.alyear = timp.tm_year + 1900;
+ alarmspec.aldoy = timp.tm_yday + 1;
+ rtcSetAlarm(&RTCD1, 0, &alarmspec);
+ rtcSetCallback(&RTCD1, wakeup_cb);
+ return;
+ }
+ else{
+ goto ERROR;
+ }
+
+ERROR:
+ chprintf(chp, "Usage: alarm get\r\n");
+ chprintf(chp, " alarm set N\r\n");
+ chprintf(chp, "where N is alarm time in seconds\r\n");
+}
+
+/*
+ *
+ */
+static void cmd_date(BaseSequentialStream *chp, int argc, char *argv[]){
+ (void)argv;
+ struct tm timp;
+
+ if (argc == 0) {
+ goto ERROR;
+ }
+
+ if ((argc == 1) && (strcmp(argv[0], "get") == 0)){
+ unix_time = rtcGetTimeUnixSec(&RTCD1);
+
+ if (unix_time == -1){
+ chprintf(chp, "incorrect time in RTC cell\r\n");
+ }
+ else{
+ chprintf(chp, "%D%s",unix_time," - unix time\r\n");
+ rtcGetTimeTm(&RTCD1, &timp);
+ chprintf(chp, "%s%s",asctime(&timp)," - formatted time string\r\n");
+ }
+ return;
+ }
+
+ if ((argc == 2) && (strcmp(argv[0], "set") == 0)){
+ unix_time = atol(argv[1]);
+ if (unix_time > 0){
+ rtcSetTimeUnixSec(&RTCD1, unix_time);
+ return;
+ }
+ else{
+ goto ERROR;
+ }
+ }
+ else{
+ goto ERROR;
+ }
+
+ERROR:
+ chprintf(chp, "Usage: date get\r\n");
+ chprintf(chp, " date set N\r\n");
+ chprintf(chp, "where N is time in seconds sins Unix epoch\r\n");
+ chprintf(chp, "you can get current N value from unix console by the command\r\n");
+ chprintf(chp, "%s", "date +\%s\r\n");
+ return;
+}
+
+static const ShellCommand commands[] = {
+ {"alarm", cmd_alarm},
+ {"date", cmd_date},
+ {"sleep", cmd_sleep},
+ {"pwrdown", cmd_pwrdown},
+ {NULL, NULL}
+};
+
+static const ShellConfig shell_cfg1 = {
+ (BaseSequentialStream *)&SD1,
+ commands
+};
+
+BaseSequentialStream * chp1 = (BaseSequentialStream *)&SD1;
+
+/**
+ * Main function.
+ */
+int main(void){
+
+ halInit();
+ chSysInit();
+ chThdCreateStatic(blinkWA, sizeof(blinkWA), NORMALPRIO, blink_thd, NULL);
+
+ sdStart(&SD1, NULL); /* Default is 38400-8-N-1.*/
+
+ if (LPC_SC->PCON & (1UL << 11)) {
+ chprintf(chp1, "Woke from Deep power-down\r\n");
+ LPC_SC->PCON |= (1UL << 11);
+ }
+
+ if (LPC_SC->PCON & (1UL << 9)) {
+ chprintf(chp1, "Woke from Deep-sleep mode\r\n");
+ LPC_SC->PCON |= (1UL << 9);
+ }
+
+ /* Shell initialization.*/
+ shellInit();
+ static WORKING_AREA(waShell, 1024);
+ shellCreateStatic(&shell_cfg1, waShell, sizeof(waShell), NORMALPRIO);
+
+ /* wait until user do not want to test wakeup */
+ while (TRUE){
+ chThdSleepMilliseconds(200);
+ }
+ return 0;
+}
+
+
diff --git a/testhal/LPC43xx/DAC/main.c b/testhal/LPC43xx/DAC/main.c
index 898cc9598..3f4b8309a 100644
--- a/testhal/LPC43xx/DAC/main.c
+++ b/testhal/LPC43xx/DAC/main.c
@@ -1,115 +1,115 @@
-/*
- ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-#include "ch.h"
-#include "hal.h"
-
-#define NSAMPLES 255
-
-const uint32_t sine_wave[NSAMPLES] = {
- 512 << 6, 524 << 6, 537 << 6, 549 << 6, 562 << 6, 574 << 6, 587 << 6, 599 << 6, 612 << 6, 624 << 6,
- 636 << 6, 649 << 6, 661 << 6, 673 << 6, 685 << 6, 696 << 6, 708 << 6, 720 << 6, 731 << 6, 743 << 6,
- 754 << 6, 765 << 6, 776 << 6, 786 << 6, 797 << 6, 807 << 6, 818 << 6, 828 << 6, 837 << 6, 847 << 6,
- 856 << 6, 866 << 6, 875 << 6, 883 << 6, 892 << 6, 900 << 6, 908 << 6, 916 << 6, 924 << 6, 931 << 6,
- 938 << 6, 945 << 6, 952 << 6, 958 << 6, 964 << 6, 970 << 6, 975 << 6, 981 << 6, 985 << 6, 990 << 6,
- 994 << 6, 998 << 6, 1002 << 6, 1006 << 6, 1009 << 6, 1012 << 6, 1014 << 6, 1016 << 6, 1018 << 6, 1020 << 6,
-1021 << 6, 1022 << 6, 1023 << 6, 1023 << 6, 1023 << 6, 1023 << 6, 1023 << 6, 1022 << 6, 1021 << 6, 1019 << 6,
-1017 << 6, 1015 << 6, 1013 << 6, 1010 << 6, 1007 << 6, 1004 << 6, 1000 << 6, 996 << 6, 992 << 6, 988 << 6,
- 983 << 6, 978 << 6, 973 << 6, 967 << 6, 961 << 6, 955 << 6, 948 << 6, 942 << 6, 935 << 6, 928 << 6,
- 920 << 6, 912 << 6, 904 << 6, 896 << 6, 888 << 6, 879 << 6, 870 << 6, 861 << 6, 852 << 6, 842 << 6,
- 832 << 6, 823 << 6, 812 << 6, 802 << 6, 792 << 6, 781 << 6, 770 << 6, 759 << 6, 748 << 6, 737 << 6,
- 725 << 6, 714 << 6, 702 << 6, 691 << 6, 679 << 6, 667 << 6, 655 << 6, 642 << 6, 630 << 6, 618 << 6,
- 606 << 6, 593 << 6, 581 << 6, 568 << 6, 556 << 6, 543 << 6, 530 << 6, 518 << 6, 505 << 6, 493 << 6,
- 480 << 6, 467 << 6, 455 << 6, 442 << 6, 430 << 6, 417 << 6, 405 << 6, 393 << 6, 381 << 6, 368 << 6,
- 356 << 6, 344 << 6, 332 << 6, 321 << 6, 309 << 6, 298 << 6, 286 << 6, 275 << 6, 264 << 6, 253 << 6,
- 242 << 6, 231 << 6, 221 << 6, 211 << 6, 200 << 6, 191 << 6, 181 << 6, 171 << 6, 162 << 6, 153 << 6,
- 144 << 6, 135 << 6, 127 << 6, 119 << 6, 111 << 6, 103 << 6, 95 << 6, 88 << 6, 81 << 6, 75 << 6,
- 68 << 6, 62 << 6, 56 << 6, 50 << 6, 45 << 6, 40 << 6, 35 << 6, 31 << 6, 27 << 6, 23 << 6,
- 19 << 6, 16 << 6, 13 << 6, 10 << 6, 8 << 6, 6 << 6, 4 << 6, 2 << 6, 1 << 6, 0 << 6,
- 0 << 6, 0 << 6, 0 << 6, 0 << 6, 1 << 6, 2 << 6, 3 << 6, 5 << 6, 7 << 6, 9 << 6,
- 11 << 6, 14 << 6, 17 << 6, 21 << 6, 25 << 6, 29 << 6, 33 << 6, 38 << 6, 42 << 6, 48 << 6,
- 53 << 6, 59 << 6, 65 << 6, 71 << 6, 78 << 6, 85 << 6, 92 << 6, 99 << 6, 107 << 6, 115 << 6,
- 123 << 6, 131 << 6, 140 << 6, 148 << 6, 157 << 6, 167 << 6, 176 << 6, 186 << 6, 195 << 6, 205 << 6,
- 216 << 6, 226 << 6, 237 << 6, 247 << 6, 258 << 6, 269 << 6, 280 << 6, 292 << 6, 303 << 6, 315 << 6,
- 327 << 6, 338 << 6, 350 << 6, 362 << 6, 374 << 6, 387 << 6, 399 << 6, 411 << 6, 424 << 6, 436 << 6,
- 449 << 6, 461 << 6, 474 << 6, 486 << 6, 499 << 6};
-
-/*
- * Red LEDs blinker thread, times are in milliseconds.
- */
-static WORKING_AREA(waThread1, 128);
-static msg_t Thread1(void *arg) {
-
- (void)arg;
- chRegSetThreadName("blinker");
- while (TRUE) {
- palTogglePad(GPIO2, GPIO2_LED);
- chThdSleepMilliseconds(500);
- }
-}
-
-/*
- * DAC conversion groups, with callbacks.
- */
-static const DACConversionGroup dacconvgrp1 = {
- 1, /* Channels */
- NULL, /* End of transfer callback */
- NULL, /* Error callback */
- true /*circular mode */
-};
-
-/*
- * DAC config
- */
-static const DACConfig daccfg1 = {
- 1000*NSAMPLES, /* Multiply the buffer size to the desired frequency in Hz */
-};
-
-/*
- * Application entry point.
- */
-int main(void) {
- /*
- * System initializations.
- * - HAL initialization, this also initializes the configured device drivers
- * and performs the board-specific initializations.
- * - Kernel initialization, the main() function becomes a thread and the
- * RTOS is active.
- */
- halInit();
- chSysInit();
-
- /*
- * Creates the blinker thread.
- */
- chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
-
- /*
- * Starting the DAC driver.
- */
- dacStart(&DACD1, &daccfg1);
-
- /*
- * Sending the dac_buffer
- */
- dacStartConversion(&DACD1, &dacconvgrp1, sine_wave, NSAMPLES);
-
- while (TRUE) {
-
- chThdSleepMilliseconds(1000);
-
- }
-}
+/*
+ ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+#include "ch.h"
+#include "hal.h"
+
+#define NSAMPLES 255
+
+const uint32_t sine_wave[NSAMPLES] = {
+ 512 << 6, 524 << 6, 537 << 6, 549 << 6, 562 << 6, 574 << 6, 587 << 6, 599 << 6, 612 << 6, 624 << 6,
+ 636 << 6, 649 << 6, 661 << 6, 673 << 6, 685 << 6, 696 << 6, 708 << 6, 720 << 6, 731 << 6, 743 << 6,
+ 754 << 6, 765 << 6, 776 << 6, 786 << 6, 797 << 6, 807 << 6, 818 << 6, 828 << 6, 837 << 6, 847 << 6,
+ 856 << 6, 866 << 6, 875 << 6, 883 << 6, 892 << 6, 900 << 6, 908 << 6, 916 << 6, 924 << 6, 931 << 6,
+ 938 << 6, 945 << 6, 952 << 6, 958 << 6, 964 << 6, 970 << 6, 975 << 6, 981 << 6, 985 << 6, 990 << 6,
+ 994 << 6, 998 << 6, 1002 << 6, 1006 << 6, 1009 << 6, 1012 << 6, 1014 << 6, 1016 << 6, 1018 << 6, 1020 << 6,
+1021 << 6, 1022 << 6, 1023 << 6, 1023 << 6, 1023 << 6, 1023 << 6, 1023 << 6, 1022 << 6, 1021 << 6, 1019 << 6,
+1017 << 6, 1015 << 6, 1013 << 6, 1010 << 6, 1007 << 6, 1004 << 6, 1000 << 6, 996 << 6, 992 << 6, 988 << 6,
+ 983 << 6, 978 << 6, 973 << 6, 967 << 6, 961 << 6, 955 << 6, 948 << 6, 942 << 6, 935 << 6, 928 << 6,
+ 920 << 6, 912 << 6, 904 << 6, 896 << 6, 888 << 6, 879 << 6, 870 << 6, 861 << 6, 852 << 6, 842 << 6,
+ 832 << 6, 823 << 6, 812 << 6, 802 << 6, 792 << 6, 781 << 6, 770 << 6, 759 << 6, 748 << 6, 737 << 6,
+ 725 << 6, 714 << 6, 702 << 6, 691 << 6, 679 << 6, 667 << 6, 655 << 6, 642 << 6, 630 << 6, 618 << 6,
+ 606 << 6, 593 << 6, 581 << 6, 568 << 6, 556 << 6, 543 << 6, 530 << 6, 518 << 6, 505 << 6, 493 << 6,
+ 480 << 6, 467 << 6, 455 << 6, 442 << 6, 430 << 6, 417 << 6, 405 << 6, 393 << 6, 381 << 6, 368 << 6,
+ 356 << 6, 344 << 6, 332 << 6, 321 << 6, 309 << 6, 298 << 6, 286 << 6, 275 << 6, 264 << 6, 253 << 6,
+ 242 << 6, 231 << 6, 221 << 6, 211 << 6, 200 << 6, 191 << 6, 181 << 6, 171 << 6, 162 << 6, 153 << 6,
+ 144 << 6, 135 << 6, 127 << 6, 119 << 6, 111 << 6, 103 << 6, 95 << 6, 88 << 6, 81 << 6, 75 << 6,
+ 68 << 6, 62 << 6, 56 << 6, 50 << 6, 45 << 6, 40 << 6, 35 << 6, 31 << 6, 27 << 6, 23 << 6,
+ 19 << 6, 16 << 6, 13 << 6, 10 << 6, 8 << 6, 6 << 6, 4 << 6, 2 << 6, 1 << 6, 0 << 6,
+ 0 << 6, 0 << 6, 0 << 6, 0 << 6, 1 << 6, 2 << 6, 3 << 6, 5 << 6, 7 << 6, 9 << 6,
+ 11 << 6, 14 << 6, 17 << 6, 21 << 6, 25 << 6, 29 << 6, 33 << 6, 38 << 6, 42 << 6, 48 << 6,
+ 53 << 6, 59 << 6, 65 << 6, 71 << 6, 78 << 6, 85 << 6, 92 << 6, 99 << 6, 107 << 6, 115 << 6,
+ 123 << 6, 131 << 6, 140 << 6, 148 << 6, 157 << 6, 167 << 6, 176 << 6, 186 << 6, 195 << 6, 205 << 6,
+ 216 << 6, 226 << 6, 237 << 6, 247 << 6, 258 << 6, 269 << 6, 280 << 6, 292 << 6, 303 << 6, 315 << 6,
+ 327 << 6, 338 << 6, 350 << 6, 362 << 6, 374 << 6, 387 << 6, 399 << 6, 411 << 6, 424 << 6, 436 << 6,
+ 449 << 6, 461 << 6, 474 << 6, 486 << 6, 499 << 6};
+
+/*
+ * Red LEDs blinker thread, times are in milliseconds.
+ */
+static WORKING_AREA(waThread1, 128);
+static msg_t Thread1(void *arg) {
+
+ (void)arg;
+ chRegSetThreadName("blinker");
+ while (TRUE) {
+ palTogglePad(GPIO2, GPIO2_LED);
+ chThdSleepMilliseconds(500);
+ }
+}
+
+/*
+ * DAC conversion groups, with callbacks.
+ */
+static const DACConversionGroup dacconvgrp1 = {
+ 1, /* Channels */
+ NULL, /* End of transfer callback */
+ NULL, /* Error callback */
+ true /*circular mode */
+};
+
+/*
+ * DAC config
+ */
+static const DACConfig daccfg1 = {
+ 1000*NSAMPLES, /* Multiply the buffer size to the desired frequency in Hz */
+};
+
+/*
+ * Application entry point.
+ */
+int main(void) {
+ /*
+ * System initializations.
+ * - HAL initialization, this also initializes the configured device drivers
+ * and performs the board-specific initializations.
+ * - Kernel initialization, the main() function becomes a thread and the
+ * RTOS is active.
+ */
+ halInit();
+ chSysInit();
+
+ /*
+ * Creates the blinker thread.
+ */
+ chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
+
+ /*
+ * Starting the DAC driver.
+ */
+ dacStart(&DACD1, &daccfg1);
+
+ /*
+ * Sending the dac_buffer
+ */
+ dacStartConversion(&DACD1, &dacconvgrp1, sine_wave, NSAMPLES);
+
+ while (TRUE) {
+
+ chThdSleepMilliseconds(1000);
+
+ }
+}
diff --git a/testhal/LPC43xx/DMA_MEM/main.c b/testhal/LPC43xx/DMA_MEM/main.c
index 925bda48b..39dbb7e2b 100644
--- a/testhal/LPC43xx/DMA_MEM/main.c
+++ b/testhal/LPC43xx/DMA_MEM/main.c
@@ -1,120 +1,120 @@
-/*
- ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-#include "ch.h"
-#include "hal.h"
-#include "chprintf.h"
-
-#define MEM_SIZE 50
-
-BaseSequentialStream * chp = (BaseSequentialStream *)&SD4;
-
-uint32_t mem_src[MEM_SIZE];
-uint32_t mem_dst[MEM_SIZE];
-
-static void dma_mem_callback(void * dummy, uint32_t flags) {
- (void)dummy;
- (void)flags;
-}
-
-/*
- * Red LEDs blinker thread, times are in milliseconds.
- */
-static WORKING_AREA(waThread1, 128);
-static msg_t Thread1(void *arg) {
-
- (void)arg;
- chRegSetThreadName("blinker");
- while (TRUE) {
- palTogglePad(GPIO2, GPIO2_LED);
- chThdSleepMilliseconds(500);
- }
-}
-
-/*
- * Application entry point.
- */
-int main(void) {
- uint32_t i;
- /*
- * System initializations.
- * - HAL initialization, this also initializes the configured device drivers
- * and performs the board-specific initializations.
- * - Kernel initialization, the main() function becomes a thread and the
- * RTOS is active.
- */
- halInit();
- chSysInit();
-
- /*
- * Creates the blinker thread.
- */
- chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
-
- /*
- * Activates the SD driver 1.
- */
- sdStart(&SD4, NULL); /* Default is 38400-8-N-1.*/
-
- chprintf(chp, "Data before dma transfer.\r\n");
- chprintf(chp, "source \t destination\r\n");
- for (i = 0; i < MEM_SIZE; i++) {
- mem_src[i] = i;
- mem_dst[i] = 0;
- chprintf(chp, "%x \t %x\r\n", mem_src[i], mem_dst[i]);
- }
-
- dmaChannelAllocate(DMA_CHANNEL0, &dma_mem_callback, NULL);
- dmaChannelSrcAddr(DMA_CHANNEL0, &mem_src[0]);
- dmaChannelDstAddr(DMA_CHANNEL0, &mem_dst[0]);
- dmaChannelControl(DMA_CHANNEL0, DMA_CTRL_TRANSFER_SIZE(MEM_SIZE) |
- DMA_CTRL_SRC_BSIZE_16 |
- DMA_CTRL_DST_BSIZE_16 |
- DMA_CTRL_SRC_WIDTH_WORD |
- DMA_CTRL_DST_WIDTH_WORD |
- DMA_CTRL_SRC_AHBM0 |
- DMA_CTRL_DST_AHBM0 |
- DMA_CTRL_SRC_INC |
- DMA_CTRL_DST_INC |
- DMA_CTRL_INT);
-
- dmaChannelConfig(DMA_CHANNEL0, DMA_CFG_CH_ENABLE |
- DMA_CFG_FCTRL_M2M |
- DMA_CFG_IE |
- DMA_CFG_ITC);
-
- chThdSleepMilliseconds(5000);
- chprintf(chp, "Data after dma transfer.\r\n");
- chprintf(chp, "source \t destination\r\n");
- for (i = 0; i < MEM_SIZE; i++) {
- chprintf(chp, "%x \t %x\r\n", mem_src[i], mem_dst[i]);
- }
-
- for (i = 0; i < MEM_SIZE; i++)
- if (mem_src[i] != mem_dst[i])
- break;
-
- if (i == MEM_SIZE)
- chprintf(chp, "Data transfer ok.\r\n");
- else
- chprintf(chp, "Error.\r\n");
-
- while (TRUE) {
-
- chThdSleepMilliseconds(1000);
-
- }
-}
+/*
+ ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+#include "ch.h"
+#include "hal.h"
+#include "chprintf.h"
+
+#define MEM_SIZE 50
+
+BaseSequentialStream * chp = (BaseSequentialStream *)&SD4;
+
+uint32_t mem_src[MEM_SIZE];
+uint32_t mem_dst[MEM_SIZE];
+
+static void dma_mem_callback(void * dummy, uint32_t flags) {
+ (void)dummy;
+ (void)flags;
+}
+
+/*
+ * Red LEDs blinker thread, times are in milliseconds.
+ */
+static WORKING_AREA(waThread1, 128);
+static msg_t Thread1(void *arg) {
+
+ (void)arg;
+ chRegSetThreadName("blinker");
+ while (TRUE) {
+ palTogglePad(GPIO2, GPIO2_LED);
+ chThdSleepMilliseconds(500);
+ }
+}
+
+/*
+ * Application entry point.
+ */
+int main(void) {
+ uint32_t i;
+ /*
+ * System initializations.
+ * - HAL initialization, this also initializes the configured device drivers
+ * and performs the board-specific initializations.
+ * - Kernel initialization, the main() function becomes a thread and the
+ * RTOS is active.
+ */
+ halInit();
+ chSysInit();
+
+ /*
+ * Creates the blinker thread.
+ */
+ chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
+
+ /*
+ * Activates the SD driver 1.
+ */
+ sdStart(&SD4, NULL); /* Default is 38400-8-N-1.*/
+
+ chprintf(chp, "Data before dma transfer.\r\n");
+ chprintf(chp, "source \t destination\r\n");
+ for (i = 0; i < MEM_SIZE; i++) {
+ mem_src[i] = i;
+ mem_dst[i] = 0;
+ chprintf(chp, "%x \t %x\r\n", mem_src[i], mem_dst[i]);
+ }
+
+ dmaChannelAllocate(DMA_CHANNEL0, &dma_mem_callback, NULL);
+ dmaChannelSrcAddr(DMA_CHANNEL0, &mem_src[0]);
+ dmaChannelDstAddr(DMA_CHANNEL0, &mem_dst[0]);
+ dmaChannelControl(DMA_CHANNEL0, DMA_CTRL_TRANSFER_SIZE(MEM_SIZE) |
+ DMA_CTRL_SRC_BSIZE_16 |
+ DMA_CTRL_DST_BSIZE_16 |
+ DMA_CTRL_SRC_WIDTH_WORD |
+ DMA_CTRL_DST_WIDTH_WORD |
+ DMA_CTRL_SRC_AHBM0 |
+ DMA_CTRL_DST_AHBM0 |
+ DMA_CTRL_SRC_INC |
+ DMA_CTRL_DST_INC |
+ DMA_CTRL_INT);
+
+ dmaChannelConfig(DMA_CHANNEL0, DMA_CFG_CH_ENABLE |
+ DMA_CFG_FCTRL_M2M |
+ DMA_CFG_IE |
+ DMA_CFG_ITC);
+
+ chThdSleepMilliseconds(5000);
+ chprintf(chp, "Data after dma transfer.\r\n");
+ chprintf(chp, "source \t destination\r\n");
+ for (i = 0; i < MEM_SIZE; i++) {
+ chprintf(chp, "%x \t %x\r\n", mem_src[i], mem_dst[i]);
+ }
+
+ for (i = 0; i < MEM_SIZE; i++)
+ if (mem_src[i] != mem_dst[i])
+ break;
+
+ if (i == MEM_SIZE)
+ chprintf(chp, "Data transfer ok.\r\n");
+ else
+ chprintf(chp, "Error.\r\n");
+
+ while (TRUE) {
+
+ chThdSleepMilliseconds(1000);
+
+ }
+}
diff --git a/testhal/LPC43xx/IRQ_STORM/main.c b/testhal/LPC43xx/IRQ_STORM/main.c
index 0e1ba3a0e..f8662eb28 100644
--- a/testhal/LPC43xx/IRQ_STORM/main.c
+++ b/testhal/LPC43xx/IRQ_STORM/main.c
@@ -1,324 +1,324 @@
-/*
- ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-#include <stdlib.h>
-
-#include "ch.h"
-#include "hal.h"
-
-/*===========================================================================*/
-/* Configurable settings. */
-/*===========================================================================*/
-
-#ifndef RANDOMIZE
-#define RANDOMIZE FALSE
-#endif
-
-#ifndef ITERATIONS
-#define ITERATIONS 100
-#endif
-
-#ifndef NUM_THREADS
-#define NUM_THREADS 4
-#endif
-
-#ifndef MAILBOX_SIZE
-#define MAILBOX_SIZE 4
-#endif
-
-/*===========================================================================*/
-/* Test related code. */
-/*===========================================================================*/
-
-#define MSG_SEND_LEFT 0
-#define MSG_SEND_RIGHT 1
-
-static bool_t saturated;
-
-/*
- * Mailboxes and buffers.
- */
-static Mailbox mb[NUM_THREADS];
-static msg_t b[NUM_THREADS][MAILBOX_SIZE];
-
-/*
- * Test worker threads.
- */
-static WORKING_AREA(waWorkerThread[NUM_THREADS], 128);
-static msg_t WorkerThread(void *arg) {
- static volatile unsigned x = 0;
- static unsigned cnt = 0;
- unsigned me = (unsigned)arg;
- unsigned target;
- unsigned r;
- msg_t msg;
-
- chRegSetThreadName("worker");
-
- /* Work loop.*/
- while (TRUE) {
- /* Waiting for a message.*/
- chMBFetch(&mb[me], &msg, TIME_INFINITE);
-
-#if RANDOMIZE
- /* Pseudo-random delay.*/
- {
- chSysLock();
- r = rand() & 15;
- chSysUnlock();
- while (r--)
- x++;
- }
-#else
- /* Fixed delay.*/
- {
- r = me >> 4;
- while (r--)
- x++;
- }
-#endif
-
- /* Deciding in which direction to re-send the message.*/
- if (msg == MSG_SEND_LEFT)
- target = me - 1;
- else
- target = me + 1;
-
- if (target < NUM_THREADS) {
- /* If this thread is not at the end of a chain re-sending the message,
- note this check works because the variable target is unsigned.*/
- msg = chMBPost(&mb[target], msg, TIME_IMMEDIATE);
- if (msg != RDY_OK)
- saturated = TRUE;
- }
- else {
- /* Provides a visual feedback about the system.*/
- if (++cnt >= 500) {
- cnt = 0;
- palTogglePad(GPIO2, GPIO2_LED);
- }
- }
- }
-}
-
-/*
- * GPT1 callback.
- */
-static void gpt1cb(GPTDriver *gptp) {
- msg_t msg;
-
- (void)gptp;
- chSysLockFromIsr();
- msg = chMBPostI(&mb[0], MSG_SEND_RIGHT);
- if (msg != RDY_OK)
- saturated = TRUE;
- chSysUnlockFromIsr();
-}
-
-/*
- * GPT2 callback.
- */
-static void gpt2cb(GPTDriver *gptp) {
- msg_t msg;
-
- (void)gptp;
- chSysLockFromIsr();
- msg = chMBPostI(&mb[NUM_THREADS - 1], MSG_SEND_LEFT);
- if (msg != RDY_OK)
- saturated = TRUE;
- chSysUnlockFromIsr();
-}
-
-/*
- * GPT1 configuration.
- */
-static const GPTConfig gpt1cfg = {
- 1000000, /* 1MHz timer clock.*/
- gpt1cb /* Timer callback.*/
-};
-
-/*
- * GPT2 configuration.
- */
-static const GPTConfig gpt2cfg = {
- 1000000, /* 1MHz timer clock.*/
- gpt2cb /* Timer callback.*/
-};
-
-
-/*===========================================================================*/
-/* Generic demo code. */
-/*===========================================================================*/
-
-static void print(char *p) {
-
- while (*p) {
- chSequentialStreamPut(&SD4, *p++);
- }
-}
-
-static void println(char *p) {
-
- while (*p) {
- chSequentialStreamPut(&SD4, *p++);
- }
- chSequentialStreamWrite(&SD4, (uint8_t *)"\r\n", 2);
-}
-
-static void printn(uint32_t n) {
- char buf[16], *p;
-
- if (!n)
- chSequentialStreamPut(&SD4, '0');
- else {
- p = buf;
- while (n)
- *p++ = (n % 10) + '0', n /= 10;
- while (p > buf)
- chSequentialStreamPut(&SD4, *--p);
- }
-}
-
-/*
- * Application entry point.
- */
-int main(void) {
- unsigned i;
- gptcnt_t interval, threshold, worst;
-
- /*
- * System initializations.
- * - HAL initialization, this also initializes the configured device drivers
- * and performs the board-specific initializations.
- * - Kernel initialization, the main() function becomes a thread and the
- * RTOS is active.
- */
- halInit();
- chSysInit();
-
- /*
- * Prepares the Serial driver 2 and GPT drivers 1 and 2.
- */
- sdStart(&SD4, NULL); /* Default is 38400-8-N-1.*/
- gptStart(&GPTD1, &gpt1cfg);
- gptStart(&GPTD2, &gpt2cfg);
-
- /*
- * Initializes the mailboxes and creates the worker threads.
- */
- for (i = 0; i < NUM_THREADS; i++) {
- chMBInit(&mb[i], b[i], MAILBOX_SIZE);
- chThdCreateStatic(waWorkerThread[i], sizeof waWorkerThread[i],
- NORMALPRIO - 20, WorkerThread, (void *)i);
- }
-
- /*
- * Test procedure.
- */
- println("");
- println("*** ChibiOS/RT IRQ-STORM long duration test");
- println("***");
- print("*** Kernel: ");
- println(CH_KERNEL_VERSION);
-#ifdef CH_COMPILER_NAME
- print("*** Compiler: ");
- println(CH_COMPILER_NAME);
-#endif
- print("*** Architecture: ");
- println(CH_ARCHITECTURE_NAME);
-#ifdef CH_CORE_VARIANT_NAME
- print("*** Core Variant: ");
- println(CH_CORE_VARIANT_NAME);
-#endif
-#ifdef CH_PORT_INFO
- print("*** Port Info: ");
- println(CH_PORT_INFO);
-#endif
-#ifdef PLATFORM_NAME
- print("*** Platform: ");
- println(PLATFORM_NAME);
-#endif
-#ifdef BOARD_NAME
- print("*** Test Board: ");
- println(BOARD_NAME);
-#endif
- println("***");
- print("*** System Clock: ");
- printn(LPC_BASE_M4_CLK);
- println("");
- print("*** Iterations: ");
- printn(ITERATIONS);
- println("");
- print("*** Randomize: ");
- printn(RANDOMIZE);
- println("");
- print("*** Threads: ");
- printn(NUM_THREADS);
- println("");
- print("*** Mailbox size: ");
- printn(MAILBOX_SIZE);
- println("");
-
- println("");
- worst = 0;
- for (i = 1; i <= ITERATIONS; i++){
- print("Iteration ");
- printn(i);
- println("");
- saturated = FALSE;
- threshold = 0;
- for (interval = 2000; interval >= 20; interval -= interval / 10) {
- gptStartContinuous(&GPTD1, interval - 1); /* Slightly out of phase.*/
- gptStartContinuous(&GPTD2, interval + 1); /* Slightly out of phase.*/
- chThdSleepMilliseconds(1000);
- gptStopTimer(&GPTD1);
- gptStopTimer(&GPTD2);
- if (!saturated)
- print(".");
- else {
- print("#");
- if (threshold == 0)
- threshold = interval;
- }
- }
- /* Gives the worker threads a chance to empty the mailboxes before next
- cycle.*/
- chThdSleepMilliseconds(20);
- println("");
- print("Saturated at ");
- printn(threshold);
- println(" uS");
- println("");
- if (threshold > worst)
- worst = threshold;
- }
- gptStopTimer(&GPTD1);
- gptStopTimer(&GPTD2);
-
- print("Worst case at ");
- printn(worst);
- println(" uS");
- println("");
- println("Test Complete");
-
- /*
- * Normal main() thread activity, nothing in this test.
- */
- while (TRUE) {
- chThdSleepMilliseconds(5000);
- }
- return 0;
-}
+/*
+ ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+#include <stdlib.h>
+
+#include "ch.h"
+#include "hal.h"
+
+/*===========================================================================*/
+/* Configurable settings. */
+/*===========================================================================*/
+
+#ifndef RANDOMIZE
+#define RANDOMIZE FALSE
+#endif
+
+#ifndef ITERATIONS
+#define ITERATIONS 100
+#endif
+
+#ifndef NUM_THREADS
+#define NUM_THREADS 4
+#endif
+
+#ifndef MAILBOX_SIZE
+#define MAILBOX_SIZE 4
+#endif
+
+/*===========================================================================*/
+/* Test related code. */
+/*===========================================================================*/
+
+#define MSG_SEND_LEFT 0
+#define MSG_SEND_RIGHT 1
+
+static bool_t saturated;
+
+/*
+ * Mailboxes and buffers.
+ */
+static Mailbox mb[NUM_THREADS];
+static msg_t b[NUM_THREADS][MAILBOX_SIZE];
+
+/*
+ * Test worker threads.
+ */
+static WORKING_AREA(waWorkerThread[NUM_THREADS], 128);
+static msg_t WorkerThread(void *arg) {
+ static volatile unsigned x = 0;
+ static unsigned cnt = 0;
+ unsigned me = (unsigned)arg;
+ unsigned target;
+ unsigned r;
+ msg_t msg;
+
+ chRegSetThreadName("worker");
+
+ /* Work loop.*/
+ while (TRUE) {
+ /* Waiting for a message.*/
+ chMBFetch(&mb[me], &msg, TIME_INFINITE);
+
+#if RANDOMIZE
+ /* Pseudo-random delay.*/
+ {
+ chSysLock();
+ r = rand() & 15;
+ chSysUnlock();
+ while (r--)
+ x++;
+ }
+#else
+ /* Fixed delay.*/
+ {
+ r = me >> 4;
+ while (r--)
+ x++;
+ }
+#endif
+
+ /* Deciding in which direction to re-send the message.*/
+ if (msg == MSG_SEND_LEFT)
+ target = me - 1;
+ else
+ target = me + 1;
+
+ if (target < NUM_THREADS) {
+ /* If this thread is not at the end of a chain re-sending the message,
+ note this check works because the variable target is unsigned.*/
+ msg = chMBPost(&mb[target], msg, TIME_IMMEDIATE);
+ if (msg != RDY_OK)
+ saturated = TRUE;
+ }
+ else {
+ /* Provides a visual feedback about the system.*/
+ if (++cnt >= 500) {
+ cnt = 0;
+ palTogglePad(GPIO2, GPIO2_LED);
+ }
+ }
+ }
+}
+
+/*
+ * GPT1 callback.
+ */
+static void gpt1cb(GPTDriver *gptp) {
+ msg_t msg;
+
+ (void)gptp;
+ chSysLockFromIsr();
+ msg = chMBPostI(&mb[0], MSG_SEND_RIGHT);
+ if (msg != RDY_OK)
+ saturated = TRUE;
+ chSysUnlockFromIsr();
+}
+
+/*
+ * GPT2 callback.
+ */
+static void gpt2cb(GPTDriver *gptp) {
+ msg_t msg;
+
+ (void)gptp;
+ chSysLockFromIsr();
+ msg = chMBPostI(&mb[NUM_THREADS - 1], MSG_SEND_LEFT);
+ if (msg != RDY_OK)
+ saturated = TRUE;
+ chSysUnlockFromIsr();
+}
+
+/*
+ * GPT1 configuration.
+ */
+static const GPTConfig gpt1cfg = {
+ 1000000, /* 1MHz timer clock.*/
+ gpt1cb /* Timer callback.*/
+};
+
+/*
+ * GPT2 configuration.
+ */
+static const GPTConfig gpt2cfg = {
+ 1000000, /* 1MHz timer clock.*/
+ gpt2cb /* Timer callback.*/
+};
+
+
+/*===========================================================================*/
+/* Generic demo code. */
+/*===========================================================================*/
+
+static void print(char *p) {
+
+ while (*p) {
+ chSequentialStreamPut(&SD4, *p++);
+ }
+}
+
+static void println(char *p) {
+
+ while (*p) {
+ chSequentialStreamPut(&SD4, *p++);
+ }
+ chSequentialStreamWrite(&SD4, (uint8_t *)"\r\n", 2);
+}
+
+static void printn(uint32_t n) {
+ char buf[16], *p;
+
+ if (!n)
+ chSequentialStreamPut(&SD4, '0');
+ else {
+ p = buf;
+ while (n)
+ *p++ = (n % 10) + '0', n /= 10;
+ while (p > buf)
+ chSequentialStreamPut(&SD4, *--p);
+ }
+}
+
+/*
+ * Application entry point.
+ */
+int main(void) {
+ unsigned i;
+ gptcnt_t interval, threshold, worst;
+
+ /*
+ * System initializations.
+ * - HAL initialization, this also initializes the configured device drivers
+ * and performs the board-specific initializations.
+ * - Kernel initialization, the main() function becomes a thread and the
+ * RTOS is active.
+ */
+ halInit();
+ chSysInit();
+
+ /*
+ * Prepares the Serial driver 2 and GPT drivers 1 and 2.
+ */
+ sdStart(&SD4, NULL); /* Default is 38400-8-N-1.*/
+ gptStart(&GPTD1, &gpt1cfg);
+ gptStart(&GPTD2, &gpt2cfg);
+
+ /*
+ * Initializes the mailboxes and creates the worker threads.
+ */
+ for (i = 0; i < NUM_THREADS; i++) {
+ chMBInit(&mb[i], b[i], MAILBOX_SIZE);
+ chThdCreateStatic(waWorkerThread[i], sizeof waWorkerThread[i],
+ NORMALPRIO - 20, WorkerThread, (void *)i);
+ }
+
+ /*
+ * Test procedure.
+ */
+ println("");
+ println("*** ChibiOS/RT IRQ-STORM long duration test");
+ println("***");
+ print("*** Kernel: ");
+ println(CH_KERNEL_VERSION);
+#ifdef CH_COMPILER_NAME
+ print("*** Compiler: ");
+ println(CH_COMPILER_NAME);
+#endif
+ print("*** Architecture: ");
+ println(CH_ARCHITECTURE_NAME);
+#ifdef CH_CORE_VARIANT_NAME
+ print("*** Core Variant: ");
+ println(CH_CORE_VARIANT_NAME);
+#endif
+#ifdef CH_PORT_INFO
+ print("*** Port Info: ");
+ println(CH_PORT_INFO);
+#endif
+#ifdef PLATFORM_NAME
+ print("*** Platform: ");
+ println(PLATFORM_NAME);
+#endif
+#ifdef BOARD_NAME
+ print("*** Test Board: ");
+ println(BOARD_NAME);
+#endif
+ println("***");
+ print("*** System Clock: ");
+ printn(LPC_BASE_M4_CLK);
+ println("");
+ print("*** Iterations: ");
+ printn(ITERATIONS);
+ println("");
+ print("*** Randomize: ");
+ printn(RANDOMIZE);
+ println("");
+ print("*** Threads: ");
+ printn(NUM_THREADS);
+ println("");
+ print("*** Mailbox size: ");
+ printn(MAILBOX_SIZE);
+ println("");
+
+ println("");
+ worst = 0;
+ for (i = 1; i <= ITERATIONS; i++){
+ print("Iteration ");
+ printn(i);
+ println("");
+ saturated = FALSE;
+ threshold = 0;
+ for (interval = 2000; interval >= 20; interval -= interval / 10) {
+ gptStartContinuous(&GPTD1, interval - 1); /* Slightly out of phase.*/
+ gptStartContinuous(&GPTD2, interval + 1); /* Slightly out of phase.*/
+ chThdSleepMilliseconds(1000);
+ gptStopTimer(&GPTD1);
+ gptStopTimer(&GPTD2);
+ if (!saturated)
+ print(".");
+ else {
+ print("#");
+ if (threshold == 0)
+ threshold = interval;
+ }
+ }
+ /* Gives the worker threads a chance to empty the mailboxes before next
+ cycle.*/
+ chThdSleepMilliseconds(20);
+ println("");
+ print("Saturated at ");
+ printn(threshold);
+ println(" uS");
+ println("");
+ if (threshold > worst)
+ worst = threshold;
+ }
+ gptStopTimer(&GPTD1);
+ gptStopTimer(&GPTD2);
+
+ print("Worst case at ");
+ printn(worst);
+ println(" uS");
+ println("");
+ println("Test Complete");
+
+ /*
+ * Normal main() thread activity, nothing in this test.
+ */
+ while (TRUE) {
+ chThdSleepMilliseconds(5000);
+ }
+ return 0;
+}