git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6330 35acf78f-673a-0410-8e92-d51de3d6d3f4

This commit is contained in:
gdisirio 2013-09-29 10:39:31 +00:00
parent 67177198e9
commit 2c928f2833
18 changed files with 70 additions and 65 deletions

View File

@ -27,7 +27,7 @@
<link> <link>
<name>board</name> <name>board</name>
<type>2</type> <type>2</type>
<locationURI>CHIBIOS/boards/ST_STM32373C_EVAL</locationURI> <locationURI>CHIBIOS/os/hal/boards/ST_STM32373C_EVAL</locationURI>
</link> </link>
<link> <link>
<name>os</name> <name>os</name>

View File

@ -152,7 +152,7 @@
#define STM32_PWM_USE_TIM2 FALSE #define STM32_PWM_USE_TIM2 FALSE
#define STM32_PWM_USE_TIM3 FALSE #define STM32_PWM_USE_TIM3 FALSE
#define STM32_PWM_USE_TIM4 FALSE #define STM32_PWM_USE_TIM4 FALSE
#define STM32_PWM_USE_TIM5 FALSE #define STM32_PWM_USE_TIM5 TRUE
#define STM32_PWM_TIM2_IRQ_PRIORITY 7 #define STM32_PWM_TIM2_IRQ_PRIORITY 7
#define STM32_PWM_TIM3_IRQ_PRIORITY 7 #define STM32_PWM_TIM3_IRQ_PRIORITY 7
#define STM32_PWM_TIM4_IRQ_PRIORITY 7 #define STM32_PWM_TIM4_IRQ_PRIORITY 7

View File

@ -27,7 +27,7 @@
<link> <link>
<name>board</name> <name>board</name>
<type>2</type> <type>2</type>
<locationURI>CHIBIOS/boards/ST_STM32373C_EVAL</locationURI> <locationURI>CHIBIOS/os/hal/boards/ST_STM32373C_EVAL</locationURI>
</link> </link>
<link> <link>
<name>os</name> <name>os</name>

View File

@ -102,10 +102,11 @@ static const ADCConversionGroup adcgrpcfg2 = {
/* /*
* Red LEDs blinker thread, times are in milliseconds. * Red LEDs blinker thread, times are in milliseconds.
*/ */
static WORKING_AREA(waThread1, 128); static THD_WORKING_AREA(waThread1, 128);
static msg_t Thread1(void *arg) { static THD_FUNCTION(Thread1, arg) {
(void)arg; (void)arg;
chRegSetThreadName("blinker"); chRegSetThreadName("blinker");
while (TRUE) { while (TRUE) {
palClearPad(GPIOC, GPIOC_LED1); palClearPad(GPIOC, GPIOC_LED1);

View File

@ -63,9 +63,9 @@
* ADC driver system settings. * ADC driver system settings.
*/ */
#define STM32_ADC_USE_ADC1 TRUE #define STM32_ADC_USE_ADC1 TRUE
#define STM32_ADC_USE_SDADC1 FALSE #define STM32_ADC_USE_SDADC1 TRUE
#define STM32_ADC_USE_SDADC2 FALSE #define STM32_ADC_USE_SDADC2 TRUE
#define STM32_ADC_USE_SDADC3 FALSE #define STM32_ADC_USE_SDADC3 TRUE
#define STM32_ADC_ADC1_DMA_PRIORITY 2 #define STM32_ADC_ADC1_DMA_PRIORITY 2
#define STM32_ADC_SDADC1_DMA_PRIORITY 2 #define STM32_ADC_SDADC1_DMA_PRIORITY 2
#define STM32_ADC_SDADC2_DMA_PRIORITY 2 #define STM32_ADC_SDADC2_DMA_PRIORITY 2
@ -81,7 +81,7 @@
/* /*
* CAN driver system settings. * CAN driver system settings.
*/ */
#define STM32_CAN_USE_CAN1 TRUE #define STM32_CAN_USE_CAN1 FALSE
#define STM32_CAN_CAN1_IRQ_PRIORITY 11 #define STM32_CAN_CAN1_IRQ_PRIORITY 11
/* /*

View File

@ -27,7 +27,7 @@
<link> <link>
<name>board</name> <name>board</name>
<type>2</type> <type>2</type>
<locationURI>CHIBIOS/boards/ST_STM32373C_EVAL</locationURI> <locationURI>CHIBIOS/os/hal/boards/ST_STM32373C_EVAL</locationURI>
</link> </link>
<link> <link>
<name>os</name> <name>os</name>

View File

@ -41,7 +41,7 @@
* @brief Enables the ADC subsystem. * @brief Enables the ADC subsystem.
*/ */
#if !defined(HAL_USE_ADC) || defined(__DOXYGEN__) #if !defined(HAL_USE_ADC) || defined(__DOXYGEN__)
#define HAL_USE_ADC TRUE #define HAL_USE_ADC FALSE
#endif #endif
/** /**
@ -132,7 +132,7 @@
* @brief Enables the SPI subsystem. * @brief Enables the SPI subsystem.
*/ */
#if !defined(HAL_USE_SPI) || defined(__DOXYGEN__) #if !defined(HAL_USE_SPI) || defined(__DOXYGEN__)
#define HAL_USE_SPI FALSE #define HAL_USE_SPI TRUE
#endif #endif
/** /**

View File

@ -48,10 +48,11 @@ static uint8_t rxbuf[512];
/* /*
* SPI bus contender 1. * SPI bus contender 1.
*/ */
static WORKING_AREA(spi_thread_1_wa, 256); static THD_WORKING_AREA(spi_thread_1_wa, 256);
static msg_t spi_thread_1(void *p) { static THD_FUNCTION(spi_thread_1, p) {
(void)p; (void)p;
chRegSetThreadName("SPI thread 1"); chRegSetThreadName("SPI thread 1");
while (TRUE) { while (TRUE) {
spiAcquireBus(&SPID2); /* Acquire ownership of the bus. */ spiAcquireBus(&SPID2); /* Acquire ownership of the bus. */
@ -69,10 +70,11 @@ static msg_t spi_thread_1(void *p) {
/* /*
* SPI bus contender 2. * SPI bus contender 2.
*/ */
static WORKING_AREA(spi_thread_2_wa, 256); static THD_WORKING_AREA(spi_thread_2_wa, 256);
static msg_t spi_thread_2(void *p) { static THD_FUNCTION(spi_thread_2, p) {
(void)p; (void)p;
chRegSetThreadName("SPI thread 2"); chRegSetThreadName("SPI thread 2");
while (TRUE) { while (TRUE) {
spiAcquireBus(&SPID2); /* Acquire ownership of the bus. */ spiAcquireBus(&SPID2); /* Acquire ownership of the bus. */
@ -91,10 +93,11 @@ static msg_t spi_thread_2(void *p) {
* This is a periodic thread that does absolutely nothing except flashing * This is a periodic thread that does absolutely nothing except flashing
* a LED. * a LED.
*/ */
static WORKING_AREA(blinker_wa, 128); static THD_WORKING_AREA(blinker_wa, 128);
static msg_t blinker(void *arg) { static THD_FUNCTION(blinker, arg) {
(void)arg; (void)arg;
chRegSetThreadName("blinker"); chRegSetThreadName("blinker");
while (TRUE) { while (TRUE) {
palSetPad(GPIOC, GPIOC_LED1); palSetPad(GPIOC, GPIOC_LED1);

View File

@ -62,7 +62,7 @@
/* /*
* ADC driver system settings. * ADC driver system settings.
*/ */
#define STM32_ADC_USE_ADC1 TRUE #define STM32_ADC_USE_ADC1 FALSE
#define STM32_ADC_USE_SDADC1 FALSE #define STM32_ADC_USE_SDADC1 FALSE
#define STM32_ADC_USE_SDADC2 FALSE #define STM32_ADC_USE_SDADC2 FALSE
#define STM32_ADC_USE_SDADC3 FALSE #define STM32_ADC_USE_SDADC3 FALSE
@ -81,7 +81,7 @@
/* /*
* CAN driver system settings. * CAN driver system settings.
*/ */
#define STM32_CAN_USE_CAN1 TRUE #define STM32_CAN_USE_CAN1 FALSE
#define STM32_CAN_CAN1_IRQ_PRIORITY 11 #define STM32_CAN_CAN1_IRQ_PRIORITY 11
/* /*
@ -175,9 +175,9 @@
/* /*
* SPI driver system settings. * SPI driver system settings.
*/ */
#define STM32_SPI_USE_SPI1 FALSE #define STM32_SPI_USE_SPI1 TRUE
#define STM32_SPI_USE_SPI2 FALSE #define STM32_SPI_USE_SPI2 TRUE
#define STM32_SPI_USE_SPI3 FALSE #define STM32_SPI_USE_SPI3 TRUE
#define STM32_SPI_SPI1_DMA_PRIORITY 1 #define STM32_SPI_SPI1_DMA_PRIORITY 1
#define STM32_SPI_SPI2_DMA_PRIORITY 1 #define STM32_SPI_SPI2_DMA_PRIORITY 1
#define STM32_SPI_SPI3_DMA_PRIORITY 1 #define STM32_SPI_SPI3_DMA_PRIORITY 1

View File

@ -27,7 +27,7 @@
<link> <link>
<name>board</name> <name>board</name>
<type>2</type> <type>2</type>
<locationURI>CHIBIOS/boards/ST_STM32373C_EVAL</locationURI> <locationURI>CHIBIOS/os/hal/boards/ST_STM32373C_EVAL</locationURI>
</link> </link>
<link> <link>
<name>os</name> <name>os</name>

View File

@ -41,7 +41,7 @@
* @brief Enables the ADC subsystem. * @brief Enables the ADC subsystem.
*/ */
#if !defined(HAL_USE_ADC) || defined(__DOXYGEN__) #if !defined(HAL_USE_ADC) || defined(__DOXYGEN__)
#define HAL_USE_ADC TRUE #define HAL_USE_ADC FALSE
#endif #endif
/** /**
@ -139,7 +139,7 @@
* @brief Enables the UART subsystem. * @brief Enables the UART subsystem.
*/ */
#if !defined(HAL_USE_UART) || defined(__DOXYGEN__) #if !defined(HAL_USE_UART) || defined(__DOXYGEN__)
#define HAL_USE_UART FALSE #define HAL_USE_UART TRUE
#endif #endif
/** /**

View File

@ -17,15 +17,15 @@
#include "ch.h" #include "ch.h"
#include "hal.h" #include "hal.h"
static VirtualTimer vt1, vt2; static virtual_timer_t vt1, vt2;
static void restart(void *p) { static void restart(void *p) {
(void)p; (void)p;
chSysLockFromIsr(); chSysLockFromISR();
uartStartSendI(&UARTD2, 14, "Hello World!\r\n"); uartStartSendI(&UARTD2, 14, "Hello World!\r\n");
chSysUnlockFromIsr(); chSysUnlockFromISR();
} }
static void ledoff(void *p) { static void ledoff(void *p) {
@ -51,11 +51,10 @@ static void txend2(UARTDriver *uartp) {
(void)uartp; (void)uartp;
palSetPad(GPIOC, GPIOC_LED1); palSetPad(GPIOC, GPIOC_LED1);
chSysLockFromIsr(); chSysLockFromISR();
if (chVTIsArmedI(&vt1)) chVTResetI(&vt1);
chVTResetI(&vt1); chVTDoSetI(&vt1, MS2ST(5000), restart, NULL);
chVTSetI(&vt1, MS2ST(5000), restart, NULL); chSysUnlockFromISR();
chSysUnlockFromIsr();
} }
/* /*
@ -78,11 +77,10 @@ static void rxchar(UARTDriver *uartp, uint16_t c) {
(void)c; (void)c;
/* Flashing the LED each time a character is received.*/ /* Flashing the LED each time a character is received.*/
palClearPad(GPIOC, GPIOC_LED1); palClearPad(GPIOC, GPIOC_LED1);
chSysLockFromIsr(); chSysLockFromISR();
if (chVTIsArmedI(&vt2)) chVTResetI(&vt2);
chVTResetI(&vt2); chVTDoSetI(&vt2, MS2ST(200), ledoff, NULL);
chVTSetI(&vt2, MS2ST(200), ledoff, NULL); chSysUnlockFromISR();
chSysUnlockFromIsr();
} }
/* /*

View File

@ -62,7 +62,7 @@
/* /*
* ADC driver system settings. * ADC driver system settings.
*/ */
#define STM32_ADC_USE_ADC1 TRUE #define STM32_ADC_USE_ADC1 FALSE
#define STM32_ADC_USE_SDADC1 FALSE #define STM32_ADC_USE_SDADC1 FALSE
#define STM32_ADC_USE_SDADC2 FALSE #define STM32_ADC_USE_SDADC2 FALSE
#define STM32_ADC_USE_SDADC3 FALSE #define STM32_ADC_USE_SDADC3 FALSE
@ -81,7 +81,7 @@
/* /*
* CAN driver system settings. * CAN driver system settings.
*/ */
#define STM32_CAN_USE_CAN1 TRUE #define STM32_CAN_USE_CAN1 FALSE
#define STM32_CAN_CAN1_IRQ_PRIORITY 11 #define STM32_CAN_CAN1_IRQ_PRIORITY 11
/* /*
@ -195,9 +195,9 @@
/* /*
* UART driver system settings. * UART driver system settings.
*/ */
#define STM32_UART_USE_USART1 FALSE #define STM32_UART_USE_USART1 TRUE
#define STM32_UART_USE_USART2 FALSE #define STM32_UART_USE_USART2 TRUE
#define STM32_UART_USE_USART3 FALSE #define STM32_UART_USE_USART3 TRUE
#define STM32_UART_USART1_IRQ_PRIORITY 12 #define STM32_UART_USART1_IRQ_PRIORITY 12
#define STM32_UART_USART2_IRQ_PRIORITY 12 #define STM32_UART_USART2_IRQ_PRIORITY 12
#define STM32_UART_USART3_IRQ_PRIORITY 12 #define STM32_UART_USART3_IRQ_PRIORITY 12

View File

@ -27,7 +27,7 @@
<link> <link>
<name>board</name> <name>board</name>
<type>2</type> <type>2</type>
<locationURI>CHIBIOS/boards/ST_STM32373C_EVAL</locationURI> <locationURI>CHIBIOS/os/hal/boards/ST_STM32373C_EVAL</locationURI>
</link> </link>
<link> <link>
<name>os</name> <name>os</name>

View File

@ -96,6 +96,8 @@ CSRC = $(PORTSRC) \
$(OSALSRC) \ $(OSALSRC) \
$(PLATFORMSRC) \ $(PLATFORMSRC) \
$(BOARDSRC) \ $(BOARDSRC) \
$(CHIBIOS)/os/various/chprintf.c \
$(CHIBIOS)/os/various/shell.c \
main.c main.c
# C++ sources that can be compiled in ARM or THUMB mode depending on the global # C++ sources that can be compiled in ARM or THUMB mode depending on the global

View File

@ -41,7 +41,7 @@
* @brief Enables the ADC subsystem. * @brief Enables the ADC subsystem.
*/ */
#if !defined(HAL_USE_ADC) || defined(__DOXYGEN__) #if !defined(HAL_USE_ADC) || defined(__DOXYGEN__)
#define HAL_USE_ADC TRUE #define HAL_USE_ADC FALSE
#endif #endif
/** /**
@ -125,7 +125,7 @@
* @brief Enables the SERIAL over USB subsystem. * @brief Enables the SERIAL over USB subsystem.
*/ */
#if !defined(HAL_USE_SERIAL_USB) || defined(__DOXYGEN__) #if !defined(HAL_USE_SERIAL_USB) || defined(__DOXYGEN__)
#define HAL_USE_SERIAL_USB FALSE #define HAL_USE_SERIAL_USB TRUE
#endif #endif
/** /**
@ -146,7 +146,7 @@
* @brief Enables the USB subsystem. * @brief Enables the USB subsystem.
*/ */
#if !defined(HAL_USE_USB) || defined(__DOXYGEN__) #if !defined(HAL_USE_USB) || defined(__DOXYGEN__)
#define HAL_USE_USB FALSE #define HAL_USE_USB TRUE
#endif #endif
/*===========================================================================*/ /*===========================================================================*/

View File

@ -291,7 +291,7 @@ static void usb_event(USBDriver *usbp, usbevent_t event) {
case USB_EVENT_ADDRESS: case USB_EVENT_ADDRESS:
return; return;
case USB_EVENT_CONFIGURED: case USB_EVENT_CONFIGURED:
chSysLockFromIsr(); chSysLockFromISR();
/* Enables the endpoints specified into the configuration. /* Enables the endpoints specified into the configuration.
Note, this callback is invoked from an ISR so I-Class functions Note, this callback is invoked from an ISR so I-Class functions
@ -302,7 +302,7 @@ static void usb_event(USBDriver *usbp, usbevent_t event) {
/* Resetting the state of the CDC subsystem.*/ /* Resetting the state of the CDC subsystem.*/
sduConfigureHookI(&SDU1); sduConfigureHookI(&SDU1);
chSysUnlockFromIsr(); chSysUnlockFromISR();
return; return;
case USB_EVENT_SUSPEND: case USB_EVENT_SUSPEND:
return; return;
@ -338,8 +338,8 @@ static const SerialUSBConfig serusbcfg = {
/* Command line related. */ /* Command line related. */
/*===========================================================================*/ /*===========================================================================*/
#define SHELL_WA_SIZE THD_WA_SIZE(2048) #define SHELL_WA_SIZE THD_WORKING_AREA_SIZE(2048)
#define TEST_WA_SIZE THD_WA_SIZE(256) #define TEST_WA_SIZE THD_WORKING_AREA_SIZE(256)
static void cmd_mem(BaseSequentialStream *chp, int argc, char *argv[]) { static void cmd_mem(BaseSequentialStream *chp, int argc, char *argv[]) {
size_t n, size; size_t n, size;
@ -356,8 +356,8 @@ static void cmd_mem(BaseSequentialStream *chp, int argc, char *argv[]) {
} }
static void cmd_threads(BaseSequentialStream *chp, int argc, char *argv[]) { static void cmd_threads(BaseSequentialStream *chp, int argc, char *argv[]) {
static const char *states[] = {THD_STATE_NAMES}; static const char *states[] = {CH_STATE_NAMES};
Thread *tp; thread_t *tp;
(void)argv; (void)argv;
if (argc > 0) { if (argc > 0) {
@ -367,23 +367,23 @@ static void cmd_threads(BaseSequentialStream *chp, int argc, char *argv[]) {
chprintf(chp, " addr stack prio refs state time\r\n"); chprintf(chp, " addr stack prio refs state time\r\n");
tp = chRegFirstThread(); tp = chRegFirstThread();
do { do {
chprintf(chp, "%.8lx %.8lx %4lu %4lu %9s %lu\r\n", chprintf(chp, "%.8lx %.8lx %4lu %4lu %9s\r\n",
(uint32_t)tp, (uint32_t)tp->p_ctx.r13, (uint32_t)tp, (uint32_t)tp->p_ctx.r13,
(uint32_t)tp->p_prio, (uint32_t)(tp->p_refs - 1), (uint32_t)tp->p_prio, (uint32_t)(tp->p_refs - 1),
states[tp->p_state], (uint32_t)tp->p_time); states[tp->p_state]);
tp = chRegNextThread(tp); tp = chRegNextThread(tp);
} while (tp != NULL); } while (tp != NULL);
} }
static void cmd_test(BaseSequentialStream *chp, int argc, char *argv[]) { static void cmd_test(BaseSequentialStream *chp, int argc, char *argv[]) {
Thread *tp; thread_t *tp;
(void)argv; (void)argv;
if (argc > 0) { if (argc > 0) {
chprintf(chp, "Usage: test\r\n"); chprintf(chp, "Usage: test\r\n");
return; return;
} }
tp = chThdCreateFromHeap(NULL, TEST_WA_SIZE, chThdGetPriority(), tp = chThdCreateFromHeap(NULL, TEST_WA_SIZE, chThdGetPriorityX(),
TestThread, chp); TestThread, chp);
if (tp == NULL) { if (tp == NULL) {
chprintf(chp, "out of memory\r\n"); chprintf(chp, "out of memory\r\n");
@ -443,10 +443,11 @@ static const ShellConfig shell_cfg1 = {
/* /*
* Red LED blinker thread, times are in milliseconds. * Red LED blinker thread, times are in milliseconds.
*/ */
static WORKING_AREA(waThread1, 128); static THD_WORKING_AREA(waThread1, 128);
static msg_t Thread1(void *arg) { static THD_FUNCTION(Thread1, arg) {
(void)arg; (void)arg;
chRegSetThreadName("blinker"); chRegSetThreadName("blinker");
while (TRUE) { while (TRUE) {
systime_t time = serusbcfg.usbp->state == USB_ACTIVE ? 250 : 500; systime_t time = serusbcfg.usbp->state == USB_ACTIVE ? 250 : 500;
@ -461,7 +462,7 @@ static msg_t Thread1(void *arg) {
* Application entry point. * Application entry point.
*/ */
int main(void) { int main(void) {
Thread *shelltp = NULL; thread_t *shelltp = NULL;
/* /*
* System initializations. * System initializations.
@ -506,7 +507,7 @@ int main(void) {
while (TRUE) { while (TRUE) {
if (!shelltp && (SDU1.config->usbp->state == USB_ACTIVE)) if (!shelltp && (SDU1.config->usbp->state == USB_ACTIVE))
shelltp = shellCreate(&shell_cfg1, SHELL_WA_SIZE, NORMALPRIO); shelltp = shellCreate(&shell_cfg1, SHELL_WA_SIZE, NORMALPRIO);
else if (chThdTerminated(shelltp)) { else if (chThdTerminatedX(shelltp)) {
chThdRelease(shelltp); /* Recovers memory of the previous shell. */ chThdRelease(shelltp); /* Recovers memory of the previous shell. */
shelltp = NULL; /* Triggers spawning of a new shell. */ shelltp = NULL; /* Triggers spawning of a new shell. */
} }

View File

@ -62,7 +62,7 @@
/* /*
* ADC driver system settings. * ADC driver system settings.
*/ */
#define STM32_ADC_USE_ADC1 TRUE #define STM32_ADC_USE_ADC1 FALSE
#define STM32_ADC_USE_SDADC1 FALSE #define STM32_ADC_USE_SDADC1 FALSE
#define STM32_ADC_USE_SDADC2 FALSE #define STM32_ADC_USE_SDADC2 FALSE
#define STM32_ADC_USE_SDADC3 FALSE #define STM32_ADC_USE_SDADC3 FALSE
@ -81,7 +81,7 @@
/* /*
* CAN driver system settings. * CAN driver system settings.
*/ */
#define STM32_CAN_USE_CAN1 TRUE #define STM32_CAN_USE_CAN1 FALSE
#define STM32_CAN_CAN1_IRQ_PRIORITY 11 #define STM32_CAN_CAN1_IRQ_PRIORITY 11
/* /*
@ -209,7 +209,7 @@
/* /*
* USB driver system settings. * USB driver system settings.
*/ */
#define STM32_USB_USE_USB1 FALSE #define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE #define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
#define STM32_USB_USB1_HP_IRQ_PRIORITY 13 #define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14 #define STM32_USB_USB1_LP_IRQ_PRIORITY 14