git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1495 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
15e6fecf11
commit
bedb87c1e7
|
@ -96,7 +96,7 @@ static void termination_handler(eventid_t id) {
|
|||
chThdSleepMilliseconds(10);
|
||||
cputs("Init: shell on SD1 terminated");
|
||||
chSysLock();
|
||||
chOQResetI(&SD1.d2.oqueue);
|
||||
chOQResetI(&SD1.sd.oqueue);
|
||||
chSysUnlock();
|
||||
}
|
||||
if (shelltp2 && chThdTerminated(shelltp2)) {
|
||||
|
@ -105,7 +105,7 @@ static void termination_handler(eventid_t id) {
|
|||
chThdSleepMilliseconds(10);
|
||||
cputs("Init: shell on SD2 terminated");
|
||||
chSysLock();
|
||||
chOQResetI(&SD2.d2.oqueue);
|
||||
chOQResetI(&SD2.sd.oqueue);
|
||||
chSysUnlock();
|
||||
}
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ static void sd1_handler(eventid_t id) {
|
|||
if (flags & SD_DISCONNECTED) {
|
||||
cputs("Init: disconnection on SD1");
|
||||
chSysLock();
|
||||
chIQResetI(&SD1.d2.iqueue);
|
||||
chIQResetI(&SD1.sd.iqueue);
|
||||
chSysUnlock();
|
||||
}
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ static void sd2_handler(eventid_t id) {
|
|||
if (flags & SD_DISCONNECTED) {
|
||||
cputs("Init: disconnection on SD2");
|
||||
chSysLock();
|
||||
chIQResetI(&SD2.d2.iqueue);
|
||||
chIQResetI(&SD2.sd.iqueue);
|
||||
chSysUnlock();
|
||||
}
|
||||
}
|
||||
|
@ -202,10 +202,10 @@ int main(void) {
|
|||
cputs("Shell service started on SD1, SD2");
|
||||
cputs(" - Listening for connections on SD1");
|
||||
(void) sdGetAndClearFlags(&SD1);
|
||||
chEvtRegister(&SD1.d2.sevent, &sd1fel, 1);
|
||||
chEvtRegister(&SD1.sd.sevent, &sd1fel, 1);
|
||||
cputs(" - Listening for connections on SD2");
|
||||
(void) sdGetAndClearFlags(&SD2);
|
||||
chEvtRegister(&SD2.d2.sevent, &sd2fel, 2);
|
||||
chEvtRegister(&SD2.sd.sevent, &sd2fel, 2);
|
||||
|
||||
/*
|
||||
* Events servicing loop.
|
||||
|
@ -216,7 +216,7 @@ int main(void) {
|
|||
/*
|
||||
* Clean simulator exit.
|
||||
*/
|
||||
chEvtUnregister(&SD1.d2.sevent, &sd1fel);
|
||||
chEvtUnregister(&SD2.d2.sevent, &sd2fel);
|
||||
chEvtUnregister(&SD1.sd.sevent, &sd1fel);
|
||||
chEvtUnregister(&SD2.sd.sevent, &sd2fel);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
* settings file. This file can be used to include platform specific
|
||||
* header files or to override the low level drivers settings.
|
||||
*/
|
||||
#include "mcuconf.h"
|
||||
/*#include "mcuconf.h"*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* PAL driver related settings. */
|
||||
|
|
|
@ -94,7 +94,7 @@ static void termination_handler(eventid_t id) {
|
|||
chThdSleepMilliseconds(10);
|
||||
cputs("Init: shell on SD1 terminated");
|
||||
chSysLock();
|
||||
chOQResetI(&SD1.d2.oqueue);
|
||||
chOQResetI(&SD1.sd.oqueue);
|
||||
chSysUnlock();
|
||||
}
|
||||
if (shelltp2 && chThdTerminated(shelltp2)) {
|
||||
|
@ -103,7 +103,7 @@ static void termination_handler(eventid_t id) {
|
|||
chThdSleepMilliseconds(10);
|
||||
cputs("Init: shell on SD2 terminated");
|
||||
chSysLock();
|
||||
chOQResetI(&SD2.d2.oqueue);
|
||||
chOQResetI(&SD2.sd.oqueue);
|
||||
chSysUnlock();
|
||||
}
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ static void sd1_handler(eventid_t id) {
|
|||
if (flags & SD_DISCONNECTED) {
|
||||
cputs("Init: disconnection on SD1");
|
||||
chSysLock();
|
||||
chIQResetI(&SD1.d2.iqueue);
|
||||
chIQResetI(&SD1.sd.iqueue);
|
||||
chSysUnlock();
|
||||
}
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ static void sd2_handler(eventid_t id) {
|
|||
if (flags & SD_DISCONNECTED) {
|
||||
cputs("Init: disconnection on SD2");
|
||||
chSysLock();
|
||||
chIQResetI(&SD2.d2.iqueue);
|
||||
chIQResetI(&SD2.sd.iqueue);
|
||||
chSysUnlock();
|
||||
}
|
||||
}
|
||||
|
@ -198,10 +198,10 @@ int main(void) {
|
|||
cputs("Shell service started on SD1, SD2");
|
||||
cputs(" - Listening for connections on SD1");
|
||||
(void) sdGetAndClearFlags(&SD1);
|
||||
chEvtRegister(&SD1.d2.sevent, &sd1fel, 1);
|
||||
chEvtRegister(&SD1.sd.sevent, &sd1fel, 1);
|
||||
cputs(" - Listening for connections on SD2");
|
||||
(void) sdGetAndClearFlags(&SD2);
|
||||
chEvtRegister(&SD2.d2.sevent, &sd2fel, 2);
|
||||
chEvtRegister(&SD2.sd.sevent, &sd2fel, 2);
|
||||
|
||||
/*
|
||||
* Events servicing loop.
|
||||
|
@ -212,7 +212,7 @@ int main(void) {
|
|||
/*
|
||||
* Clean simulator exit.
|
||||
*/
|
||||
chEvtUnregister(&SD1.d2.sevent, &sd1fel);
|
||||
chEvtUnregister(&SD2.d2.sevent, &sd2fel);
|
||||
chEvtUnregister(&SD1.sd.sevent, &sd1fel);
|
||||
chEvtUnregister(&SD2.sd.sevent, &sd2fel);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ Settings: MCLK=XT2CLK 8MHz
|
|||
|
||||
*** ChibiOS/RT test suite
|
||||
***
|
||||
*** Kernel: 1.3.5unstable
|
||||
*** Kernel: 1.3.7unstable
|
||||
*** Architecture: MSP430
|
||||
*** GCC Version: 3.2.3
|
||||
|
||||
|
@ -89,27 +89,27 @@ Settings: MCLK=XT2CLK 8MHz
|
|||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 11.1 (Benchmark, messages #1)
|
||||
--- Score : 20960 msgs/S, 41920 ctxswc/S
|
||||
--- Score : 20944 msgs/S, 41888 ctxswc/S
|
||||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 11.2 (Benchmark, messages #2)
|
||||
--- Score : 17361 msgs/S, 34722 ctxswc/S
|
||||
--- Score : 17347 msgs/S, 34694 ctxswc/S
|
||||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 11.3 (Benchmark, messages #3)
|
||||
--- Score : 17361 msgs/S, 34722 ctxswc/S
|
||||
--- Score : 17347 msgs/S, 34694 ctxswc/S
|
||||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 11.4 (Benchmark, context switch)
|
||||
--- Score : 64272 ctxswc/S
|
||||
--- Score : 64224 ctxswc/S
|
||||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 11.5 (Benchmark, threads, full cycle)
|
||||
--- Score : 14284 threads/S
|
||||
--- Score : 14272 threads/S
|
||||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 11.6 (Benchmark, threads, create only)
|
||||
--- Score : 18397 threads/S
|
||||
--- Score : 18383 threads/S
|
||||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 11.7 (Benchmark, mass reschedulation, 5 threads)
|
||||
|
@ -117,23 +117,23 @@ Settings: MCLK=XT2CLK 8MHz
|
|||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 11.8 (Benchmark, round robin context switching)
|
||||
--- Score : 46344 reschedulations/S, 46344 ctxswc/S
|
||||
--- Score : 46308 reschedulations/S, 46308 ctxswc/S
|
||||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 11.9 (Benchmark, I/O Queues throughput)
|
||||
--- Score : 54360 bytes/S
|
||||
--- Score : 54320 bytes/S
|
||||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 11.10 (Benchmark, virtual timers set/reset)
|
||||
--- Score : 60944 timers/S
|
||||
--- Score : 60896 timers/S
|
||||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 11.11 (Benchmark, semaphores wait/signal)
|
||||
--- Score : 150640 wait+signal/S
|
||||
--- Score : 150520 wait+signal/S
|
||||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 11.12 (Benchmark, mutexes lock/unlock)
|
||||
--- Score : 84048 lock+unlock/S
|
||||
--- Score : 83980 lock+unlock/S
|
||||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 11.13 (Benchmark, RAM footprint)
|
||||
|
|
|
@ -36,23 +36,23 @@
|
|||
/**
|
||||
* @brief Errors rate warning.
|
||||
*/
|
||||
#define CAN_LIMIT_WARNING 1
|
||||
#define CAN_LIMIT_WARNING 1
|
||||
/**
|
||||
* @brief Errors rate error.
|
||||
*/
|
||||
#define CAN_LIMIT_ERROR 2
|
||||
#define CAN_LIMIT_ERROR 2
|
||||
/**
|
||||
* @brief Bus off condition reached.
|
||||
*/
|
||||
#define CAN_BUS_OFF_ERROR 4
|
||||
#define CAN_BUS_OFF_ERROR 4
|
||||
/**
|
||||
* @brief Framing error of some kind on the CAN bus.
|
||||
*/
|
||||
#define CAN_FRAMING_ERROR 8
|
||||
#define CAN_FRAMING_ERROR 8
|
||||
/**
|
||||
* @brief Overflow in receive queue.
|
||||
*/
|
||||
#define CAN_OVERFLOW_ERROR 16
|
||||
#define CAN_OVERFLOW_ERROR 16
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver pre-compile time settings. */
|
||||
|
@ -60,23 +60,15 @@
|
|||
|
||||
/**
|
||||
* @brief Sleep mode related APIs inclusion switch.
|
||||
* @note This switch is enforced to @p FALSE if the driver implementation
|
||||
* does not support the sleep mode.
|
||||
*/
|
||||
#if CAN_SUPPORTS_SLEEP || defined(__DOXYGEN__)
|
||||
#if !defined(CAN_USE_SLEEP_MODE) || defined(__DOXYGEN__)
|
||||
#define CAN_USE_SLEEP_MODE TRUE
|
||||
#endif
|
||||
#else /* !CAN_SUPPORTS_SLEEP */
|
||||
#define CAN_USE_SLEEP_MODE FALSE
|
||||
#endif /* !CAN_SUPPORTS_SLEEP */
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Derived constants and error checks. */
|
||||
/*===========================================================================*/
|
||||
|
||||
#if !CH_USE_SEMAPHORES || !CH_USE_EVENTS
|
||||
#error "the ADC driver requires CH_USE_SEMAPHORES and CH_USE_EVENTS"
|
||||
#error "CAN driver requires CH_USE_SEMAPHORES and CH_USE_EVENTS"
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
|
|
|
@ -93,6 +93,10 @@
|
|||
/* Derived constants and error checks. */
|
||||
/*===========================================================================*/
|
||||
|
||||
#if CAN_USE_SLEEP_MODE && !CAN_SUPPORTS_SLEEP
|
||||
#error "CAN sleep mode not supported in this architecture"
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver data structures and types. */
|
||||
/*===========================================================================*/
|
||||
|
|
|
@ -90,6 +90,7 @@ static void stop_channels(PWMDriver *pwmp) {
|
|||
pwmp->pd_tim->CCMR2 = 0; /* Channels 3 and 4 frozen. */
|
||||
}
|
||||
|
||||
#if USE_STM32_PWM2 || USE_STM32_PWM3 || USE_STM32_PWM4 || defined(__DOXYGEN__)
|
||||
/**
|
||||
* @brief Common TIM2...TIM4 IRQ handler.
|
||||
* @note It is assumed that the various sources are only activated if the
|
||||
|
@ -113,6 +114,7 @@ static void serve_interrupt(PWMDriver *pwmp) {
|
|||
if ((sr & TIM_SR_UIF) != 0)
|
||||
pwmp->pd_config->pc_callback();
|
||||
}
|
||||
#endif /* USE_STM32_PWM2 || USE_STM32_PWM3 || USE_STM32_PWM4 */
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver interrupt handlers. */
|
||||
|
|
|
@ -47,7 +47,7 @@ SerialDriver SD2;
|
|||
/*===========================================================================*/
|
||||
|
||||
/** @brief Driver default configuration.*/
|
||||
static const SerialDriverConfig default_config = {
|
||||
static const SerialConfig default_config = {
|
||||
};
|
||||
|
||||
static u_long nb = 1;
|
||||
|
@ -61,18 +61,18 @@ static void init(SerialDriver *sdp, uint16_t port) {
|
|||
struct protoent *prtp;
|
||||
|
||||
if ((prtp = getprotobyname("tcp")) == NULL) {
|
||||
printf("%s: Error mapping protocol name to protocol number\n", sdp->d2.com_name);
|
||||
printf("%s: Error mapping protocol name to protocol number\n", sdp->sd.com_name);
|
||||
goto abort;
|
||||
}
|
||||
|
||||
sdp->d2.com_listen = socket(PF_INET, SOCK_STREAM, prtp->p_proto);
|
||||
if (sdp->d2.com_listen == INVALID_SOCKET) {
|
||||
printf("%s: Error creating simulator socket\n", sdp->d2.com_name);
|
||||
sdp->sd.com_listen = socket(PF_INET, SOCK_STREAM, prtp->p_proto);
|
||||
if (sdp->sd.com_listen == INVALID_SOCKET) {
|
||||
printf("%s: Error creating simulator socket\n", sdp->sd.com_name);
|
||||
goto abort;
|
||||
}
|
||||
|
||||
if (ioctlsocket(sdp->d2.com_listen, FIONBIO, &nb) != 0) {
|
||||
printf("%s: Unable to setup non blocking mode on socket\n", sdp->d2.com_name);
|
||||
if (ioctlsocket(sdp->sd.com_listen, FIONBIO, &nb) != 0) {
|
||||
printf("%s: Unable to setup non blocking mode on socket\n", sdp->sd.com_name);
|
||||
goto abort;
|
||||
}
|
||||
|
||||
|
@ -80,36 +80,36 @@ static void init(SerialDriver *sdp, uint16_t port) {
|
|||
sad.sin_family = AF_INET;
|
||||
sad.sin_addr.s_addr = INADDR_ANY;
|
||||
sad.sin_port = htons(port);
|
||||
if (bind(sdp->d2.com_listen, (struct sockaddr *)&sad, sizeof(sad))) {
|
||||
printf("%s: Error binding socket\n", sdp->d2.com_name);
|
||||
if (bind(sdp->sd.com_listen, (struct sockaddr *)&sad, sizeof(sad))) {
|
||||
printf("%s: Error binding socket\n", sdp->sd.com_name);
|
||||
goto abort;
|
||||
}
|
||||
|
||||
if (listen(sdp->d2.com_listen, 1) != 0) {
|
||||
printf("%s: Error listening socket\n", sdp->d2.com_name);
|
||||
if (listen(sdp->sd.com_listen, 1) != 0) {
|
||||
printf("%s: Error listening socket\n", sdp->sd.com_name);
|
||||
goto abort;
|
||||
}
|
||||
printf("Full Duplex Channel %s listening on port %d\n", sdp->d2.com_name, port);
|
||||
printf("Full Duplex Channel %s listening on port %d\n", sdp->sd.com_name, port);
|
||||
return;
|
||||
|
||||
abort:
|
||||
if (sdp->d2.com_listen != INVALID_SOCKET)
|
||||
closesocket(sdp->d2.com_listen);
|
||||
if (sdp->sd.com_listen != INVALID_SOCKET)
|
||||
closesocket(sdp->sd.com_listen);
|
||||
WSACleanup();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static bool_t connint(SerialDriver *sdp) {
|
||||
|
||||
if (sdp->d2.com_data == INVALID_SOCKET) {
|
||||
if (sdp->sd.com_data == INVALID_SOCKET) {
|
||||
struct sockaddr addr;
|
||||
int addrlen = sizeof(addr);
|
||||
|
||||
if ((sdp->d2.com_data = accept(sdp->d2.com_listen, &addr, &addrlen)) == INVALID_SOCKET)
|
||||
if ((sdp->sd.com_data = accept(sdp->sd.com_listen, &addr, &addrlen)) == INVALID_SOCKET)
|
||||
return FALSE;
|
||||
|
||||
if (ioctlsocket(sdp->d2.com_data, FIONBIO, &nb) != 0) {
|
||||
printf("%s: Unable to setup non blocking mode on data socket\n", sdp->d2.com_name);
|
||||
if (ioctlsocket(sdp->sd.com_data, FIONBIO, &nb) != 0) {
|
||||
printf("%s: Unable to setup non blocking mode on data socket\n", sdp->sd.com_name);
|
||||
goto abort;
|
||||
}
|
||||
sdAddFlagsI(sdp, SD_CONNECTED);
|
||||
|
@ -117,35 +117,35 @@ static bool_t connint(SerialDriver *sdp) {
|
|||
}
|
||||
return FALSE;
|
||||
abort:
|
||||
if (sdp->d2.com_listen != INVALID_SOCKET)
|
||||
closesocket(sdp->d2.com_listen);
|
||||
if (sdp->d2.com_data != INVALID_SOCKET)
|
||||
closesocket(sdp->d2.com_data);
|
||||
if (sdp->sd.com_listen != INVALID_SOCKET)
|
||||
closesocket(sdp->sd.com_listen);
|
||||
if (sdp->sd.com_data != INVALID_SOCKET)
|
||||
closesocket(sdp->sd.com_data);
|
||||
WSACleanup();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static bool_t inint(SerialDriver *sdp) {
|
||||
|
||||
if (sdp->d2.com_data != INVALID_SOCKET) {
|
||||
if (sdp->sd.com_data != INVALID_SOCKET) {
|
||||
int i;
|
||||
uint8_t data[32];
|
||||
|
||||
/*
|
||||
* Input.
|
||||
*/
|
||||
int n = recv(sdp->d2.com_data, data, sizeof(data), 0);
|
||||
int n = recv(sdp->sd.com_data, data, sizeof(data), 0);
|
||||
switch (n) {
|
||||
case 0:
|
||||
closesocket(sdp->d2.com_data);
|
||||
sdp->d2.com_data = INVALID_SOCKET;
|
||||
closesocket(sdp->sd.com_data);
|
||||
sdp->sd.com_data = INVALID_SOCKET;
|
||||
sdAddFlagsI(sdp, SD_DISCONNECTED);
|
||||
return FALSE;
|
||||
case SOCKET_ERROR:
|
||||
if (WSAGetLastError() == WSAEWOULDBLOCK)
|
||||
return FALSE;
|
||||
closesocket(sdp->d2.com_data);
|
||||
sdp->d2.com_data = INVALID_SOCKET;
|
||||
closesocket(sdp->sd.com_data);
|
||||
sdp->sd.com_data = INVALID_SOCKET;
|
||||
return FALSE;
|
||||
}
|
||||
for (i = 0; i < n; i++)
|
||||
|
@ -157,7 +157,7 @@ static bool_t inint(SerialDriver *sdp) {
|
|||
|
||||
static bool_t outint(SerialDriver *sdp) {
|
||||
|
||||
if (sdp->d2.com_data != INVALID_SOCKET) {
|
||||
if (sdp->sd.com_data != INVALID_SOCKET) {
|
||||
int n;
|
||||
uint8_t data[1];
|
||||
|
||||
|
@ -168,18 +168,18 @@ static bool_t outint(SerialDriver *sdp) {
|
|||
if (n < 0)
|
||||
return FALSE;
|
||||
data[0] = (uint8_t)n;
|
||||
n = send(sdp->d2.com_data, data, sizeof(data), 0);
|
||||
n = send(sdp->sd.com_data, data, sizeof(data), 0);
|
||||
switch (n) {
|
||||
case 0:
|
||||
closesocket(sdp->d2.com_data);
|
||||
sdp->d2.com_data = INVALID_SOCKET;
|
||||
closesocket(sdp->sd.com_data);
|
||||
sdp->sd.com_data = INVALID_SOCKET;
|
||||
sdAddFlagsI(sdp, SD_DISCONNECTED);
|
||||
return FALSE;
|
||||
case SOCKET_ERROR:
|
||||
if (WSAGetLastError() == WSAEWOULDBLOCK)
|
||||
return FALSE;
|
||||
closesocket(sdp->d2.com_data);
|
||||
sdp->d2.com_data = INVALID_SOCKET;
|
||||
closesocket(sdp->sd.com_data);
|
||||
sdp->sd.com_data = INVALID_SOCKET;
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
|
@ -202,16 +202,16 @@ void sd_lld_init(void) {
|
|||
|
||||
#if USE_WIN32_SERIAL1
|
||||
sdObjectInit(&SD1, NULL, NULL);
|
||||
SD1.d2.com_listen = INVALID_SOCKET;
|
||||
SD1.d2.com_data = INVALID_SOCKET;
|
||||
SD1.d2.com_name = "SD1";
|
||||
SD1.sd.com_listen = INVALID_SOCKET;
|
||||
SD1.sd.com_data = INVALID_SOCKET;
|
||||
SD1.sd.com_name = "SD1";
|
||||
#endif
|
||||
|
||||
#if USE_WIN32_SERIAL1
|
||||
sdObjectInit(&SD2, NULL, NULL);
|
||||
SD2.d2.com_listen = INVALID_SOCKET;
|
||||
SD2.d2.com_data = INVALID_SOCKET;
|
||||
SD2.d2.com_name = "SD2";
|
||||
SD2.sd.com_listen = INVALID_SOCKET;
|
||||
SD2.sd.com_data = INVALID_SOCKET;
|
||||
SD2.sd.com_name = "SD2";
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -219,14 +219,11 @@ void sd_lld_init(void) {
|
|||
* @brief Low level serial driver configuration and (re)start.
|
||||
*
|
||||
* @param[in] sdp pointer to a @p SerialDriver object
|
||||
* @param[in] config the architecture-dependent serial driver configuration.
|
||||
* If this parameter is set to @p NULL then a default
|
||||
* configuration is used.
|
||||
*/
|
||||
void sd_lld_start(SerialDriver *sdp, const SerialDriverConfig *config) {
|
||||
void sd_lld_start(SerialDriver *sdp) {
|
||||
|
||||
if (config == NULL)
|
||||
config = &default_config;
|
||||
if (sdp->sd.config == NULL)
|
||||
sdp->sd.config = &default_config;
|
||||
|
||||
#if USE_WIN32_SERIAL1
|
||||
if (sdp == &SD1)
|
||||
|
|
|
@ -87,51 +87,6 @@
|
|||
*/
|
||||
typedef uint32_t sdflags_t;
|
||||
|
||||
/**
|
||||
* @brief @p SerialDriver specific data.
|
||||
*/
|
||||
struct _serial_driver_data {
|
||||
/**
|
||||
* Input queue, incoming data can be read from this input queue by
|
||||
* using the queues APIs.
|
||||
*/
|
||||
InputQueue iqueue;
|
||||
/**
|
||||
* Output queue, outgoing data can be written to this output queue by
|
||||
* using the queues APIs.
|
||||
*/
|
||||
OutputQueue oqueue;
|
||||
/**
|
||||
* Status Change @p EventSource. This event is generated when one or more
|
||||
* condition flags change.
|
||||
*/
|
||||
EventSource sevent;
|
||||
/**
|
||||
* I/O driver status flags.
|
||||
*/
|
||||
sdflags_t flags;
|
||||
/**
|
||||
* Input circular buffer.
|
||||
*/
|
||||
uint8_t ib[SERIAL_BUFFERS_SIZE];
|
||||
/**
|
||||
* Output circular buffer.
|
||||
*/
|
||||
uint8_t ob[SERIAL_BUFFERS_SIZE];
|
||||
/**
|
||||
* Listen socket for simulated serial port.
|
||||
*/
|
||||
SOCKET com_listen;
|
||||
/**
|
||||
* Data socket for simulated serial port.
|
||||
*/
|
||||
SOCKET com_data;
|
||||
/**
|
||||
* Port readable name.
|
||||
*/
|
||||
const char *com_name;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Generic Serial Driver configuration structure.
|
||||
* @details An instance of this structure must be passed to @p sdStart()
|
||||
|
@ -142,7 +97,61 @@ struct _serial_driver_data {
|
|||
* initializers.
|
||||
*/
|
||||
typedef struct {
|
||||
} SerialDriverConfig;
|
||||
} SerialConfig;
|
||||
|
||||
/**
|
||||
* @brief @p SerialDriver specific data.
|
||||
*/
|
||||
struct _serial_driver_data {
|
||||
/**
|
||||
* @brief Driver state.
|
||||
*/
|
||||
sdstate_t state;
|
||||
/**
|
||||
* @brief Current configuration data.
|
||||
*/
|
||||
const SerialConfig *config;
|
||||
/**
|
||||
* @brief Input queue, incoming data can be read from this input queue by
|
||||
* using the queues APIs.
|
||||
*/
|
||||
InputQueue iqueue;
|
||||
/**
|
||||
* @brief Output queue, outgoing data can be written to this output queue by
|
||||
* using the queues APIs.
|
||||
*/
|
||||
OutputQueue oqueue;
|
||||
/**
|
||||
* @brief Status Change @p EventSource. This event is generated when one or
|
||||
* more condition flags change.
|
||||
*/
|
||||
EventSource sevent;
|
||||
/**
|
||||
* @brief I/O driver status flags.
|
||||
*/
|
||||
sdflags_t flags;
|
||||
/**
|
||||
* @brief Input circular buffer.
|
||||
*/
|
||||
uint8_t ib[SERIAL_BUFFERS_SIZE];
|
||||
/**
|
||||
* @brief Output circular buffer.
|
||||
*/
|
||||
uint8_t ob[SERIAL_BUFFERS_SIZE];
|
||||
/* End of the mandatory fields.*/
|
||||
/**
|
||||
* Listen socket for simulated serial port.
|
||||
*/
|
||||
SOCKET com_listen;
|
||||
/**
|
||||
* Data socket for simulated serial port.
|
||||
*/
|
||||
SOCKET com_data;
|
||||
/**
|
||||
* Port readable name.
|
||||
*/
|
||||
const char *com_name;
|
||||
};
|
||||
|
||||
/*===========================================================================*/
|
||||
/* External declarations. */
|
||||
|
@ -160,7 +169,7 @@ extern SerialDriver SD2;
|
|||
extern "C" {
|
||||
#endif
|
||||
void sd_lld_init(void);
|
||||
void sd_lld_start(SerialDriver *sdp, const SerialDriverConfig *config);
|
||||
void sd_lld_start(SerialDriver *sdp);
|
||||
void sd_lld_stop(SerialDriver *sdp);
|
||||
bool_t sd_lld_interrupt_pending(void);
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -60,8 +60,8 @@
|
|||
/* Derived constants and error checks. */
|
||||
/*===========================================================================*/
|
||||
|
||||
#if !CH_USE_SEMAPHORES || !CH_USE_EVENTS
|
||||
#error "the ADC driver requires CH_USE_SEMAPHORES and CH_USE_EVENTS"
|
||||
#if CAN_USE_SLEEP_MODE && !CAN_SUPPORTS_SLEEP
|
||||
#error "CAN sleep mode not supported in this architecture"
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
/*===========================================================================*/
|
||||
|
||||
/** @brief Driver default configuration.*/
|
||||
static const SerialDriverConfig default_config = {
|
||||
static const SerialConfig default_config = {
|
||||
};
|
||||
|
||||
/*===========================================================================*/
|
||||
|
@ -64,14 +64,11 @@ void sd_lld_init(void) {
|
|||
* @brief Low level serial driver configuration and (re)start.
|
||||
*
|
||||
* @param[in] sdp pointer to a @p SerialDriver object
|
||||
* @param[in] config the architecture-dependent serial driver configuration.
|
||||
* If this parameter is set to @p NULL then a default
|
||||
* configuration is used.
|
||||
*/
|
||||
void sd_lld_start(SerialDriver *sdp, const SerialDriverConfig *config) {
|
||||
void sd_lld_start(SerialDriver *sdp) {
|
||||
|
||||
if (config == NULL)
|
||||
config = &default_config;
|
||||
if (sdp->sd.config == NULL)
|
||||
sdp->sd.config = &default_config;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -50,39 +50,6 @@
|
|||
*/
|
||||
typedef uint8_t sdflags_t;
|
||||
|
||||
/**
|
||||
* @brief @p SerialDriver specific data.
|
||||
*/
|
||||
struct _serial_driver_data {
|
||||
/**
|
||||
* Input queue, incoming data can be read from this input queue by
|
||||
* using the queues APIs.
|
||||
*/
|
||||
InputQueue iqueue;
|
||||
/**
|
||||
* Output queue, outgoing data can be written to this output queue by
|
||||
* using the queues APIs.
|
||||
*/
|
||||
OutputQueue oqueue;
|
||||
/**
|
||||
* Status Change @p EventSource. This event is generated when one or more
|
||||
* condition flags change.
|
||||
*/
|
||||
EventSource sevent;
|
||||
/**
|
||||
* I/O driver status flags.
|
||||
*/
|
||||
sdflags_t flags;
|
||||
/**
|
||||
* Input circular buffer.
|
||||
*/
|
||||
uint8_t ib[SERIAL_BUFFERS_SIZE];
|
||||
/**
|
||||
* Output circular buffer.
|
||||
*/
|
||||
uint8_t ob[SERIAL_BUFFERS_SIZE];
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Generic Serial Driver configuration structure.
|
||||
* @details An instance of this structure must be passed to @p sdStart()
|
||||
|
@ -94,7 +61,49 @@ struct _serial_driver_data {
|
|||
*/
|
||||
typedef struct {
|
||||
|
||||
} SerialDriverConfig;
|
||||
} SerialConfig;
|
||||
|
||||
/**
|
||||
* @brief @p SerialDriver specific data.
|
||||
*/
|
||||
struct _serial_driver_data {
|
||||
/**
|
||||
* @brief Driver state.
|
||||
*/
|
||||
sdstate_t state;
|
||||
/**
|
||||
* @brief Current configuration data.
|
||||
*/
|
||||
const SerialConfig *config;
|
||||
/**
|
||||
* @brief Input queue, incoming data can be read from this input queue by
|
||||
* using the queues APIs.
|
||||
*/
|
||||
InputQueue iqueue;
|
||||
/**
|
||||
* @brief Output queue, outgoing data can be written to this output queue by
|
||||
* using the queues APIs.
|
||||
*/
|
||||
OutputQueue oqueue;
|
||||
/**
|
||||
* @brief Status Change @p EventSource. This event is generated when one or
|
||||
* more condition flags change.
|
||||
*/
|
||||
EventSource sevent;
|
||||
/**
|
||||
* @brief I/O driver status flags.
|
||||
*/
|
||||
sdflags_t flags;
|
||||
/**
|
||||
* @brief Input circular buffer.
|
||||
*/
|
||||
uint8_t ib[SERIAL_BUFFERS_SIZE];
|
||||
/**
|
||||
* @brief Output circular buffer.
|
||||
*/
|
||||
uint8_t ob[SERIAL_BUFFERS_SIZE];
|
||||
/* End of the mandatory fields.*/
|
||||
};
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver macros. */
|
||||
|
@ -108,7 +117,7 @@ typedef struct {
|
|||
extern "C" {
|
||||
#endif
|
||||
void sd_lld_init(void);
|
||||
void sd_lld_start(SerialDriver *sdp, const SerialDriverConfig *config);
|
||||
void sd_lld_start(SerialDriver *sdp);
|
||||
void sd_lld_stop(SerialDriver *sdp);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
* @brief Enables the PAL subsystem.
|
||||
*/
|
||||
#if !defined(CH_HAL_USE_PAL) || defined(__DOXYGEN__)
|
||||
#define CH_HAL_USE_PAL FALSE
|
||||
#define CH_HAL_USE_PAL FALSE
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
|
@ -59,7 +59,7 @@
|
|||
* @brief Enables the ADC subsystem.
|
||||
*/
|
||||
#if !defined(CH_HAL_USE_ADC) || defined(__DOXYGEN__)
|
||||
#define CH_HAL_USE_ADC FALSE
|
||||
#define CH_HAL_USE_ADC FALSE
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
|
@ -70,7 +70,7 @@
|
|||
* @brief Enables the CAN subsystem.
|
||||
*/
|
||||
#if !defined(CH_HAL_USE_CAN) || defined(__DOXYGEN__)
|
||||
#define CH_HAL_USE_CAN FALSE
|
||||
#define CH_HAL_USE_CAN FALSE
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
|
@ -81,7 +81,7 @@
|
|||
* @brief Enables the MAC subsystem.
|
||||
*/
|
||||
#if !defined(CH_HAL_USE_MAC) || defined(__DOXYGEN__)
|
||||
#define CH_HAL_USE_MAC FALSE
|
||||
#define CH_HAL_USE_MAC FALSE
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
|
@ -92,7 +92,7 @@
|
|||
* @brief Enables the PWM subsystem.
|
||||
*/
|
||||
#if !defined(CH_HAL_USE_PWM) || defined(__DOXYGEN__)
|
||||
#define CH_HAL_USE_PWM FALSE
|
||||
#define CH_HAL_USE_PWM FALSE
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
|
@ -103,9 +103,15 @@
|
|||
* @brief Enables the SERIAL subsystem.
|
||||
*/
|
||||
#if !defined(CH_HAL_USE_SERIAL) || defined(__DOXYGEN__)
|
||||
#define CH_HAL_USE_SERIAL FALSE
|
||||
#define CH_HAL_USE_SERIAL FALSE
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Default SERIAL settings overrides (uncomment to override).
|
||||
*/
|
||||
/*#define SERIAL_DEFAULT_BITRATE 38400*/
|
||||
/*#define SERIAL_BUFFERS_SIZE 64*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* SPI driver related settings. */
|
||||
/*===========================================================================*/
|
||||
|
@ -114,13 +120,13 @@
|
|||
* @brief Enables the SPI subsystem.
|
||||
*/
|
||||
#if !defined(CH_HAL_USE_SPI) || defined(__DOXYGEN__)
|
||||
#define CH_HAL_USE_SPI FALSE
|
||||
#define CH_HAL_USE_SPI FALSE
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Default SPI settings overrides (uncomment to override).
|
||||
*/
|
||||
/*#define SPI_USE_MUTUAL_EXCLUSION TRUE*/
|
||||
/*#define SPI_USE_MUTUAL_EXCLUSION TRUE*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* MMC_SPI driver related settings. */
|
||||
|
@ -130,16 +136,16 @@
|
|||
* @brief Enables the MMC_SPI subsystem.
|
||||
*/
|
||||
#if !defined(CH_HAL_USE_MMC_SPI) || defined(__DOXYGEN__)
|
||||
#define CH_HAL_USE_MMC_SPI FALSE
|
||||
#define CH_HAL_USE_MMC_SPI FALSE
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Default MMC_SPI settings overrides (uncomment to override).
|
||||
*/
|
||||
/*#define MMC_SECTOR_SIZE 512*/
|
||||
/*#define MMC_NICE_WAITING TRUE*/
|
||||
/*#define MMC_POLLING_INTERVAL 10*/
|
||||
/*#define MMC_POLLING_DELAY 10*/
|
||||
/*#define MMC_SECTOR_SIZE 512*/
|
||||
/*#define MMC_NICE_WAITING TRUE*/
|
||||
/*#define MMC_POLLING_INTERVAL 10*/
|
||||
/*#define MMC_POLLING_DELAY 10*/
|
||||
|
||||
#endif /* _HALCONF_H_ */
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
* settings file. This file can be used to include platform specific
|
||||
* header files or to override the low level drivers settings.
|
||||
*/
|
||||
/*#include "mcuconf.h"*/
|
||||
#include "mcuconf.h"
|
||||
|
||||
/*===========================================================================*/
|
||||
/* PAL driver related settings. */
|
||||
|
@ -48,7 +48,7 @@
|
|||
* @brief Enables the PAL subsystem.
|
||||
*/
|
||||
#if !defined(CH_HAL_USE_PAL) || defined(__DOXYGEN__)
|
||||
#define CH_HAL_USE_PAL TRUE
|
||||
#define CH_HAL_USE_PAL TRUE
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
|
@ -59,7 +59,7 @@
|
|||
* @brief Enables the ADC subsystem.
|
||||
*/
|
||||
#if !defined(CH_HAL_USE_ADC) || defined(__DOXYGEN__)
|
||||
#define CH_HAL_USE_ADC TRUE
|
||||
#define CH_HAL_USE_ADC TRUE
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
|
@ -70,7 +70,7 @@
|
|||
* @brief Enables the CAN subsystem.
|
||||
*/
|
||||
#if !defined(CH_HAL_USE_CAN) || defined(__DOXYGEN__)
|
||||
#define CH_HAL_USE_CAN TRUE
|
||||
#define CH_HAL_USE_CAN TRUE
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
|
@ -81,7 +81,7 @@
|
|||
* @brief Enables the MAC subsystem.
|
||||
*/
|
||||
#if !defined(CH_HAL_USE_MAC) || defined(__DOXYGEN__)
|
||||
#define CH_HAL_USE_MAC FALSE
|
||||
#define CH_HAL_USE_MAC FALSE
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
|
@ -92,7 +92,7 @@
|
|||
* @brief Enables the PWM subsystem.
|
||||
*/
|
||||
#if !defined(CH_HAL_USE_PWM) || defined(__DOXYGEN__)
|
||||
#define CH_HAL_USE_PWM TRUE
|
||||
#define CH_HAL_USE_PWM TRUE
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
|
@ -103,9 +103,15 @@
|
|||
* @brief Enables the SERIAL subsystem.
|
||||
*/
|
||||
#if !defined(CH_HAL_USE_SERIAL) || defined(__DOXYGEN__)
|
||||
#define CH_HAL_USE_SERIAL TRUE
|
||||
#define CH_HAL_USE_SERIAL TRUE
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Default SERIAL settings overrides (uncomment to override).
|
||||
*/
|
||||
/*#define SERIAL_DEFAULT_BITRATE 38400*/
|
||||
/*#define SERIAL_BUFFERS_SIZE 64*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* SPI driver related settings. */
|
||||
/*===========================================================================*/
|
||||
|
@ -114,13 +120,13 @@
|
|||
* @brief Enables the SPI subsystem.
|
||||
*/
|
||||
#if !defined(CH_HAL_USE_SPI) || defined(__DOXYGEN__)
|
||||
#define CH_HAL_USE_SPI TRUE
|
||||
#define CH_HAL_USE_SPI TRUE
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Default SPI settings overrides (uncomment to override).
|
||||
*/
|
||||
/*#define SPI_USE_MUTUAL_EXCLUSION TRUE*/
|
||||
/*#define SPI_USE_MUTUAL_EXCLUSION TRUE*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* MMC_SPI driver related settings. */
|
||||
|
@ -130,16 +136,16 @@
|
|||
* @brief Enables the MMC_SPI subsystem.
|
||||
*/
|
||||
#if !defined(CH_HAL_USE_MMC_SPI) || defined(__DOXYGEN__)
|
||||
#define CH_HAL_USE_MMC_SPI FALSE
|
||||
#define CH_HAL_USE_MMC_SPI FALSE
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Default MMC_SPI settings overrides (uncomment to override).
|
||||
*/
|
||||
/*#define MMC_SECTOR_SIZE 512*/
|
||||
/*#define MMC_NICE_WAITING TRUE*/
|
||||
/*#define MMC_POLLING_INTERVAL 10*/
|
||||
/*#define MMC_POLLING_DELAY 10*/
|
||||
/*#define MMC_SECTOR_SIZE 512*/
|
||||
/*#define MMC_NICE_WAITING TRUE*/
|
||||
/*#define MMC_POLLING_INTERVAL 10*/
|
||||
/*#define MMC_POLLING_DELAY 10*/
|
||||
|
||||
#endif /* _HALCONF_H_ */
|
||||
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
ChibiOS/RT - Copyright (C) 2006-2007 Giovanni Di Sirio.
|
||||
|
||||
This file is part of ChibiOS/RT.
|
||||
|
||||
ChibiOS/RT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ChibiOS/RT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* STM32 drivers configuration.
|
||||
* The following settings override the default settings present in
|
||||
* the various device driver implementation headers.
|
||||
* Note that the settings for each driver only have effect if the driver
|
||||
* is enabled in halconf.h.
|
||||
*
|
||||
* IRQ priorities:
|
||||
* 0xF0 Lowest, priority level reserved for PENDSV.
|
||||
* 0xE0...0x40 Normal IRQs priority levels (0x80 used by SYSTICK).
|
||||
* 0x30 Used by SVCALL, do not share.
|
||||
* 0x20...0x00 Fast interrupts, can preempt the kernel but cannot use it.
|
||||
*
|
||||
* DMA priorities:
|
||||
* 0...3 Lowest...Highest.
|
||||
*/
|
||||
|
||||
/*
|
||||
* ADC driver system settings.
|
||||
*/
|
||||
#define USE_STM32_ADC1 TRUE
|
||||
#define STM32_ADC1_DMA_PRIORITY 3
|
||||
#define STM32_ADC1_IRQ_PRIORITY 0x50
|
||||
#define STM32_ADC1_DMA_ERROR_HOOK() chSysHalt()
|
||||
|
||||
/*
|
||||
* CAN driver system settings.
|
||||
*/
|
||||
#define USE_STM32_CAN1 TRUE
|
||||
#define STM32_CAN1_IRQ_PRIORITY 0xB0
|
||||
|
||||
/*
|
||||
* PWM driver system settings.
|
||||
*/
|
||||
#define USE_STM32_PWM1 TRUE
|
||||
#define USE_STM32_PWM2 FALSE
|
||||
#define USE_STM32_PWM3 FALSE
|
||||
#define USE_STM32_PWM4 FALSE
|
||||
#define STM32_PWM1_IRQ_PRIORITY 0x70
|
||||
#define STM32_PWM2_IRQ_PRIORITY 0x70
|
||||
#define STM32_PWM3_IRQ_PRIORITY 0x70
|
||||
#define STM32_PWM4_IRQ_PRIORITY 0x70
|
||||
|
||||
/*
|
||||
* SERIAL driver system settings.
|
||||
*/
|
||||
#define USE_STM32_USART1 FALSE
|
||||
#define USE_STM32_USART2 TRUE
|
||||
#define USE_STM32_USART3 FALSE
|
||||
#define STM32_USART1_PRIORITY 0xC0
|
||||
#define STM32_USART2_PRIORITY 0xC0
|
||||
#define STM32_USART3_PRIORITY 0xC0
|
||||
|
||||
/*
|
||||
* SPI driver system settings.
|
||||
*/
|
||||
#define USE_STM32_SPI1 TRUE
|
||||
#define USE_STM32_SPI2 TRUE
|
||||
#define STM32_SPI1_DMA_PRIORITY 2
|
||||
#define STM32_SPI2_DMA_PRIORITY 2
|
||||
#define STM32_SPI1_IRQ_PRIORITY 0xA0
|
||||
#define STM32_SPI2_IRQ_PRIORITY 0xA0
|
||||
#define STM32_SPI1_DMA_ERROR_HOOK() chSysHalt()
|
Loading…
Reference in New Issue