Simulator compiles, to be tested.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@10078 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
e3498cf082
commit
07fc57b2c8
|
@ -156,8 +156,7 @@ UINCDIR =
|
||||||
ULIBDIR =
|
ULIBDIR =
|
||||||
|
|
||||||
# List all user libraries here
|
# List all user libraries here
|
||||||
ULIBS = -lws2_32
|
ULIBS =
|
||||||
|
|
||||||
#
|
#
|
||||||
# End of user defines
|
# End of user defines
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
|
@ -43,7 +43,7 @@ BaseChannel CD1;
|
||||||
/* Driver local functions. */
|
/* Driver local functions. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
static size_t write(void *ip, const uint8_t *bp, size_t n) {
|
static size_t _write(void *ip, const uint8_t *bp, size_t n) {
|
||||||
size_t ret;
|
size_t ret;
|
||||||
|
|
||||||
(void)ip;
|
(void)ip;
|
||||||
|
@ -53,14 +53,14 @@ static size_t write(void *ip, const uint8_t *bp, size_t n) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t read(void *ip, uint8_t *bp, size_t n) {
|
static size_t _read(void *ip, uint8_t *bp, size_t n) {
|
||||||
|
|
||||||
(void)ip;
|
(void)ip;
|
||||||
|
|
||||||
return fread(bp, 1, n, stdin);
|
return fread(bp, 1, n, stdin);
|
||||||
}
|
}
|
||||||
|
|
||||||
static msg_t put(void *ip, uint8_t b) {
|
static msg_t _put(void *ip, uint8_t b) {
|
||||||
|
|
||||||
(void)ip;
|
(void)ip;
|
||||||
|
|
||||||
|
@ -69,14 +69,14 @@ static msg_t put(void *ip, uint8_t b) {
|
||||||
return MSG_OK;
|
return MSG_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static msg_t get(void *ip) {
|
static msg_t _get(void *ip) {
|
||||||
|
|
||||||
(void)ip;
|
(void)ip;
|
||||||
|
|
||||||
return fgetc(stdin);
|
return fgetc(stdin);
|
||||||
}
|
}
|
||||||
|
|
||||||
static msg_t putt(void *ip, uint8_t b, systime_t time) {
|
static msg_t _putt(void *ip, uint8_t b, systime_t time) {
|
||||||
|
|
||||||
(void)ip;
|
(void)ip;
|
||||||
(void)time;
|
(void)time;
|
||||||
|
@ -86,7 +86,7 @@ static msg_t putt(void *ip, uint8_t b, systime_t time) {
|
||||||
return MSG_OK;
|
return MSG_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static msg_t gett(void *ip, systime_t time) {
|
static msg_t _gett(void *ip, systime_t time) {
|
||||||
|
|
||||||
(void)ip;
|
(void)ip;
|
||||||
(void)time;
|
(void)time;
|
||||||
|
@ -94,7 +94,7 @@ static msg_t gett(void *ip, systime_t time) {
|
||||||
return fgetc(stdin);
|
return fgetc(stdin);
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t writet(void *ip, const uint8_t *bp, size_t n, systime_t time) {
|
static size_t _writet(void *ip, const uint8_t *bp, size_t n, systime_t time) {
|
||||||
size_t ret;
|
size_t ret;
|
||||||
|
|
||||||
(void)ip;
|
(void)ip;
|
||||||
|
@ -105,7 +105,7 @@ static size_t writet(void *ip, const uint8_t *bp, size_t n, systime_t time) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t readt(void *ip, uint8_t *bp, size_t n, systime_t time) {
|
static size_t _readt(void *ip, uint8_t *bp, size_t n, systime_t time) {
|
||||||
|
|
||||||
(void)ip;
|
(void)ip;
|
||||||
(void)time;
|
(void)time;
|
||||||
|
@ -114,8 +114,8 @@ static size_t readt(void *ip, uint8_t *bp, size_t n, systime_t time) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct BaseChannelVMT vmt = {
|
static const struct BaseChannelVMT vmt = {
|
||||||
write, read, put, get,
|
_write, _read, _put, _get,
|
||||||
putt, gett, writet, readt
|
_putt, _gett, _writet, _readt
|
||||||
};
|
};
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
|
@ -22,6 +22,10 @@
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
|
||||||
#include "hal.h"
|
#include "hal.h"
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
@ -32,8 +36,8 @@
|
||||||
/* Driver local variables and types. */
|
/* Driver local variables and types. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
static LARGE_INTEGER nextcnt;
|
static struct timeval nextcnt;
|
||||||
static LARGE_INTEGER slice;
|
static struct timeval tick = {0UL, 1000000UL / OSAL_ST_FREQUENCY};
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Driver local functions. */
|
/* Driver local functions. */
|
||||||
|
@ -51,31 +55,21 @@ static LARGE_INTEGER slice;
|
||||||
* @brief Low level HAL driver initialization.
|
* @brief Low level HAL driver initialization.
|
||||||
*/
|
*/
|
||||||
void hal_lld_init(void) {
|
void hal_lld_init(void) {
|
||||||
WSADATA wsaData;
|
|
||||||
|
|
||||||
/* Initialization.*/
|
#if defined(__APPLE__)
|
||||||
if (WSAStartup(2, &wsaData) != 0) {
|
puts("ChibiOS/RT simulator (OS X)\n");
|
||||||
printf("Unable to locate a winsock DLL\n");
|
#else
|
||||||
exit(1);
|
puts("ChibiOS/RT simulator (Linux)\n");
|
||||||
}
|
#endif
|
||||||
|
gettimeofday(&nextcnt, NULL);
|
||||||
printf("ChibiOS/RT simulator (Win32)\n");
|
timeradd(&nextcnt, &tick, &nextcnt);
|
||||||
if (!QueryPerformanceFrequency(&slice)) {
|
|
||||||
printf("QueryPerformanceFrequency() error");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
slice.QuadPart /= CH_CFG_ST_FREQUENCY;
|
|
||||||
QueryPerformanceCounter(&nextcnt);
|
|
||||||
nextcnt.QuadPart += slice.QuadPart;
|
|
||||||
|
|
||||||
fflush(stdout);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Interrupt simulation.
|
* @brief Interrupt simulation.
|
||||||
*/
|
*/
|
||||||
void _sim_check_for_interrupts(void) {
|
void _sim_check_for_interrupts(void) {
|
||||||
LARGE_INTEGER n;
|
struct timeval tv;
|
||||||
|
|
||||||
#if HAL_USE_SERIAL
|
#if HAL_USE_SERIAL
|
||||||
if (sd_lld_interrupt_pending()) {
|
if (sd_lld_interrupt_pending()) {
|
||||||
|
@ -87,10 +81,9 @@ void _sim_check_for_interrupts(void) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Interrupt Timer simulation (10ms interval).*/
|
gettimeofday(&tv, NULL);
|
||||||
QueryPerformanceCounter(&n);
|
if (timercmp(&tv, &nextcnt, >=)) {
|
||||||
if (n.QuadPart > nextcnt.QuadPart) {
|
timeradd(&nextcnt, &tick, &nextcnt);
|
||||||
nextcnt.QuadPart += slice.QuadPart;
|
|
||||||
|
|
||||||
CH_IRQ_PROLOGUE();
|
CH_IRQ_PROLOGUE();
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,15 @@
|
||||||
#ifndef HAL_LLD_H
|
#ifndef HAL_LLD_H
|
||||||
#define HAL_LLD_H
|
#define HAL_LLD_H
|
||||||
|
|
||||||
|
#if defined(WIN32)
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#else
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <netdb.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#endif
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
@ -35,7 +43,11 @@
|
||||||
/**
|
/**
|
||||||
* @brief Platform name.
|
* @brief Platform name.
|
||||||
*/
|
*/
|
||||||
|
#if defined(WIN32)
|
||||||
#define PLATFORM_NAME "Win32 Simulator"
|
#define PLATFORM_NAME "Win32 Simulator"
|
||||||
|
#else
|
||||||
|
#define PLATFORM_NAME "Posix Simulator"
|
||||||
|
#endif
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Driver pre-compile time settings. */
|
/* Driver pre-compile time settings. */
|
||||||
|
|
|
@ -22,6 +22,10 @@
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
#include "hal.h"
|
#include "hal.h"
|
||||||
|
|
||||||
#if HAL_USE_SERIAL || defined(__DOXYGEN__)
|
#if HAL_USE_SERIAL || defined(__DOXYGEN__)
|
||||||
|
@ -31,11 +35,12 @@
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
/** @brief Serial driver 1 identifier.*/
|
/** @brief Serial driver 1 identifier.*/
|
||||||
#if USE_WIN32_SERIAL1 || defined(__DOXYGEN__)
|
#if USE_SIM_SERIAL1 || defined(__DOXYGEN__)
|
||||||
SerialDriver SD1;
|
SerialDriver SD1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** @brief Serial driver 2 identifier.*/
|
/** @brief Serial driver 2 identifier.*/
|
||||||
#if USE_WIN32_SERIAL2 || defined(__DOXYGEN__)
|
#if USE_SIM_SERIAL2 || defined(__DOXYGEN__)
|
||||||
SerialDriver SD2;
|
SerialDriver SD2;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -47,8 +52,6 @@ SerialDriver SD2;
|
||||||
static const SerialConfig default_config = {
|
static const SerialConfig default_config = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static u_long nb = 1;
|
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Driver local functions. */
|
/* Driver local functions. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
@ -56,6 +59,8 @@ static u_long nb = 1;
|
||||||
static void init(SerialDriver *sdp, uint16_t port) {
|
static void init(SerialDriver *sdp, uint16_t port) {
|
||||||
struct sockaddr_in sad;
|
struct sockaddr_in sad;
|
||||||
struct protoent *prtp;
|
struct protoent *prtp;
|
||||||
|
int sockval = 1;
|
||||||
|
socklen_t socklen = sizeof(sockval);
|
||||||
|
|
||||||
if ((prtp = getprotobyname("tcp")) == NULL) {
|
if ((prtp = getprotobyname("tcp")) == NULL) {
|
||||||
printf("%s: Error mapping protocol name to protocol number\n", sdp->com_name);
|
printf("%s: Error mapping protocol name to protocol number\n", sdp->com_name);
|
||||||
|
@ -63,12 +68,21 @@ static void init(SerialDriver *sdp, uint16_t port) {
|
||||||
}
|
}
|
||||||
|
|
||||||
sdp->com_listen = socket(PF_INET, SOCK_STREAM, prtp->p_proto);
|
sdp->com_listen = socket(PF_INET, SOCK_STREAM, prtp->p_proto);
|
||||||
if (sdp->com_listen == INVALID_SOCKET) {
|
if (sdp->com_listen == -1) {
|
||||||
printf("%s: Error creating simulator socket\n", sdp->com_name);
|
printf("%s: Error creating simulator socket\n", sdp->com_name);
|
||||||
goto abort;
|
goto abort;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ioctlsocket(sdp->com_listen, FIONBIO, &nb) != 0) {
|
setsockopt(sdp->com_listen, SOL_SOCKET, SO_REUSEADDR, &sockval, socklen);
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
if (ioctl(sdp->com_listen, FIONBIO, &nb) != 0) {
|
||||||
|
printf("%s: Unable to setup non blocking mode on socket\n", sdp->com_name);
|
||||||
|
goto abort;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
int flags = fcntl(sdp->com_listen, F_GETFL, 0);
|
||||||
|
if (fcntl(sdp->com_listen, F_SETFL, flags | O_NONBLOCK) != 0) {
|
||||||
printf("%s: Unable to setup non blocking mode on socket\n", sdp->com_name);
|
printf("%s: Unable to setup non blocking mode on socket\n", sdp->com_name);
|
||||||
goto abort;
|
goto abort;
|
||||||
}
|
}
|
||||||
|
@ -90,69 +104,75 @@ static void init(SerialDriver *sdp, uint16_t port) {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
abort:
|
abort:
|
||||||
if (sdp->com_listen != INVALID_SOCKET)
|
if (sdp->com_listen != -1)
|
||||||
closesocket(sdp->com_listen);
|
close(sdp->com_listen);
|
||||||
WSACleanup();
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool connint(SerialDriver *sdp) {
|
static bool connint(SerialDriver *sdp) {
|
||||||
|
|
||||||
if (sdp->com_data == INVALID_SOCKET) {
|
if (sdp->com_data == -1) {
|
||||||
struct sockaddr addr;
|
struct sockaddr addr;
|
||||||
int addrlen = sizeof(addr);
|
socklen_t addrlen = sizeof(addr);
|
||||||
|
|
||||||
if ((sdp->com_data = accept(sdp->com_listen, &addr, &addrlen)) == INVALID_SOCKET)
|
if ((sdp->com_data = accept(sdp->com_listen, &addr, &addrlen)) == -1)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (ioctlsocket(sdp->com_data, FIONBIO, &nb) != 0) {
|
#if 0
|
||||||
|
if (ioctl(sdp->com_data, FIONBIO, &nb) != 0) {
|
||||||
printf("%s: Unable to setup non blocking mode on data socket\n", sdp->com_name);
|
printf("%s: Unable to setup non blocking mode on data socket\n", sdp->com_name);
|
||||||
goto abort;
|
goto abort;
|
||||||
}
|
}
|
||||||
chSysLockFromISR();
|
#endif
|
||||||
|
int flags = fcntl(sdp->com_data, F_GETFL, 0);
|
||||||
|
if (fcntl(sdp->com_data, F_SETFL, flags | O_NONBLOCK) != 0) {
|
||||||
|
printf("%s: Unable to setup non blocking mode on data socket\n", sdp->com_name);
|
||||||
|
goto abort;
|
||||||
|
}
|
||||||
|
|
||||||
|
osalSysLockFromISR();
|
||||||
chnAddFlagsI(sdp, CHN_CONNECTED);
|
chnAddFlagsI(sdp, CHN_CONNECTED);
|
||||||
chSysUnlockFromISR();
|
osalSysUnlockFromISR();
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
abort:
|
abort:
|
||||||
if (sdp->com_listen != INVALID_SOCKET)
|
if (sdp->com_listen != -1)
|
||||||
closesocket(sdp->com_listen);
|
close(sdp->com_listen);
|
||||||
if (sdp->com_data != INVALID_SOCKET)
|
if (sdp->com_data != -1)
|
||||||
closesocket(sdp->com_data);
|
close(sdp->com_data);
|
||||||
WSACleanup();
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool inint(SerialDriver *sdp) {
|
static bool inint(SerialDriver *sdp) {
|
||||||
|
|
||||||
if (sdp->com_data != INVALID_SOCKET) {
|
if (sdp->com_data != -1) {
|
||||||
int i;
|
int i;
|
||||||
uint8_t data[32];
|
uint8_t data[32];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Input.
|
* Input.
|
||||||
*/
|
*/
|
||||||
int n = recv(sdp->com_data, (char *)data, sizeof(data), 0);
|
int n = recv(sdp->com_data, data, sizeof(data), 0);
|
||||||
switch (n) {
|
switch (n) {
|
||||||
case 0:
|
case 0:
|
||||||
closesocket(sdp->com_data);
|
close(sdp->com_data);
|
||||||
sdp->com_data = INVALID_SOCKET;
|
sdp->com_data = -1;
|
||||||
chSysLockFromISR();
|
osalSysLockFromISR();
|
||||||
chnAddFlagsI(sdp, CHN_DISCONNECTED);
|
chnAddFlagsI(sdp, CHN_DISCONNECTED);
|
||||||
chSysUnlockFromISR();
|
osalSysUnlockFromISR();
|
||||||
return FALSE;
|
return FALSE;
|
||||||
case SOCKET_ERROR:
|
case -1:
|
||||||
if (WSAGetLastError() == WSAEWOULDBLOCK)
|
if (errno == EWOULDBLOCK)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
closesocket(sdp->com_data);
|
close(sdp->com_data);
|
||||||
sdp->com_data = INVALID_SOCKET;
|
sdp->com_data = -1;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
chSysLockFromISR();
|
osalSysLockFromISR();
|
||||||
sdIncomingDataI(sdp, data[i]);
|
sdIncomingDataI(sdp, data[i]);
|
||||||
chSysUnlockFromISR();
|
osalSysUnlockFromISR();
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -161,33 +181,33 @@ static bool inint(SerialDriver *sdp) {
|
||||||
|
|
||||||
static bool outint(SerialDriver *sdp) {
|
static bool outint(SerialDriver *sdp) {
|
||||||
|
|
||||||
if (sdp->com_data != INVALID_SOCKET) {
|
if (sdp->com_data != -1) {
|
||||||
int n;
|
int n;
|
||||||
uint8_t data[1];
|
uint8_t data[1];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Input.
|
* Input.
|
||||||
*/
|
*/
|
||||||
chSysLockFromISR();
|
osalSysLockFromISR();
|
||||||
n = sdRequestDataI(sdp);
|
n = sdRequestDataI(sdp);
|
||||||
chSysUnlockFromISR();
|
osalSysUnlockFromISR();
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
data[0] = (uint8_t)n;
|
data[0] = (uint8_t)n;
|
||||||
n = send(sdp->com_data, (char *)data, sizeof(data), 0);
|
n = send(sdp->com_data, data, sizeof(data), 0);
|
||||||
switch (n) {
|
switch (n) {
|
||||||
case 0:
|
case 0:
|
||||||
closesocket(sdp->com_data);
|
close(sdp->com_data);
|
||||||
sdp->com_data = INVALID_SOCKET;
|
sdp->com_data = -1;
|
||||||
chSysLockFromISR();
|
osalSysLockFromISR();
|
||||||
chnAddFlagsI(sdp, CHN_DISCONNECTED);
|
chnAddFlagsI(sdp, CHN_DISCONNECTED);
|
||||||
chSysUnlockFromISR();
|
osalSysUnlockFromISR();
|
||||||
return FALSE;
|
return FALSE;
|
||||||
case SOCKET_ERROR:
|
case -1:
|
||||||
if (WSAGetLastError() == WSAEWOULDBLOCK)
|
if (errno == EWOULDBLOCK)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
closesocket(sdp->com_data);
|
close(sdp->com_data);
|
||||||
sdp->com_data = INVALID_SOCKET;
|
sdp->com_data = -1;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -208,17 +228,17 @@ static bool outint(SerialDriver *sdp) {
|
||||||
*/
|
*/
|
||||||
void sd_lld_init(void) {
|
void sd_lld_init(void) {
|
||||||
|
|
||||||
#if USE_WIN32_SERIAL1
|
#if USE_SIM_SERIAL1
|
||||||
sdObjectInit(&SD1, NULL, NULL);
|
sdObjectInit(&SD1, NULL, NULL);
|
||||||
SD1.com_listen = INVALID_SOCKET;
|
SD1.com_listen = -1;
|
||||||
SD1.com_data = INVALID_SOCKET;
|
SD1.com_data = -1;
|
||||||
SD1.com_name = "SD1";
|
SD1.com_name = "SD1";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if USE_WIN32_SERIAL2
|
#if USE_SIM_SERIAL2
|
||||||
sdObjectInit(&SD2, NULL, NULL);
|
sdObjectInit(&SD2, NULL, NULL);
|
||||||
SD2.com_listen = INVALID_SOCKET;
|
SD2.com_listen = -1;
|
||||||
SD2.com_data = INVALID_SOCKET;
|
SD2.com_data = -1;
|
||||||
SD2.com_name = "SD2";
|
SD2.com_name = "SD2";
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -236,14 +256,14 @@ void sd_lld_start(SerialDriver *sdp, const SerialConfig *config) {
|
||||||
if (config == NULL)
|
if (config == NULL)
|
||||||
config = &default_config;
|
config = &default_config;
|
||||||
|
|
||||||
#if USE_WIN32_SERIAL1
|
#if USE_SIM_SERIAL1
|
||||||
if (sdp == &SD1)
|
if (sdp == &SD1)
|
||||||
init(&SD1, SD1_PORT);
|
init(&SD1, SIM_SD1_PORT);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if USE_WIN32_SERIAL2
|
#if USE_SIM_SERIAL2
|
||||||
if (sdp == &SD2)
|
if (sdp == &SD2)
|
||||||
init(&SD2, SD2_PORT);
|
init(&SD2, SIM_SD2_PORT);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,19 +280,15 @@ void sd_lld_stop(SerialDriver *sdp) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool sd_lld_interrupt_pending(void) {
|
bool sd_lld_interrupt_pending(void) {
|
||||||
bool b = false;
|
bool b;
|
||||||
|
|
||||||
CH_IRQ_PROLOGUE();
|
OSAL_IRQ_PROLOGUE();
|
||||||
|
|
||||||
#if USE_WIN32_SERIAL1
|
b = connint(&SD1) || connint(&SD2) ||
|
||||||
b |= connint(&SD1) || inint(&SD1) || outint(&SD1);
|
inint(&SD1) || inint(&SD2) ||
|
||||||
#endif
|
outint(&SD1) || outint(&SD2);
|
||||||
|
|
||||||
#if USE_WIN32_SERIAL2
|
OSAL_IRQ_EPILOGUE();
|
||||||
b |= connint(&SD2) || inint(&SD2) || outint(&SD2);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
CH_IRQ_EPILOGUE();
|
|
||||||
|
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,8 +45,8 @@
|
||||||
* @details If set to @p TRUE the support for SD1 is included.
|
* @details If set to @p TRUE the support for SD1 is included.
|
||||||
* @note The default is @p TRUE.
|
* @note The default is @p TRUE.
|
||||||
*/
|
*/
|
||||||
#if !defined(USE_WIN32_SERIAL1) || defined(__DOXYGEN__)
|
#if !defined(USE_SIM_SERIAL1) || defined(__DOXYGEN__)
|
||||||
#define USE_WIN32_SERIAL1 TRUE
|
#define USE_SIM_SERIAL1 TRUE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -54,22 +54,22 @@
|
||||||
* @details If set to @p TRUE the support for SD2 is included.
|
* @details If set to @p TRUE the support for SD2 is included.
|
||||||
* @note The default is @p TRUE.
|
* @note The default is @p TRUE.
|
||||||
*/
|
*/
|
||||||
#if !defined(USE_WIN32_SERIAL2) || defined(__DOXYGEN__)
|
#if !defined(USE_SIM_SERIAL2) || defined(__DOXYGEN__)
|
||||||
#define USE_WIN32_SERIAL2 TRUE
|
#define USE_SIM_SERIAL2 TRUE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Listen port for SD1.
|
* @brief Listen port for SD1.
|
||||||
*/
|
*/
|
||||||
#if !defined(SD1_PORT) || defined(__DOXYGEN__)
|
#if !defined(SD1_PORT) || defined(__DOXYGEN__)
|
||||||
#define SD1_PORT 29001
|
#define SIM_SD1_PORT 29001
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Listen port for SD2.
|
* @brief Listen port for SD2.
|
||||||
*/
|
*/
|
||||||
#if !defined(SD2_PORT) || defined(__DOXYGEN__)
|
#if !defined(SD2_PORT) || defined(__DOXYGEN__)
|
||||||
#define SD2_PORT 29002
|
#define SIM_SD2_PORT 29002
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
@ -108,9 +108,9 @@ typedef struct {
|
||||||
uint8_t ob[SERIAL_BUFFERS_SIZE]; \
|
uint8_t ob[SERIAL_BUFFERS_SIZE]; \
|
||||||
/* End of the mandatory fields.*/ \
|
/* End of the mandatory fields.*/ \
|
||||||
/* Listen socket for simulated serial port.*/ \
|
/* Listen socket for simulated serial port.*/ \
|
||||||
SOCKET com_listen; \
|
int com_listen; \
|
||||||
/* Data socket for simulated serial port.*/ \
|
/* Data socket for simulated serial port.*/ \
|
||||||
SOCKET com_data; \
|
int com_data; \
|
||||||
/* Port readable name.*/ \
|
/* Port readable name.*/ \
|
||||||
const char *com_name;
|
const char *com_name;
|
||||||
|
|
||||||
|
@ -118,10 +118,10 @@ typedef struct {
|
||||||
/* External declarations. */
|
/* External declarations. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
#if USE_WIN32_SERIAL1 && !defined(__DOXYGEN__)
|
#if USE_SIM_SERIAL1 && !defined(__DOXYGEN__)
|
||||||
extern SerialDriver SD1;
|
extern SerialDriver SD1;
|
||||||
#endif
|
#endif
|
||||||
#if USE_WIN32_SERIAL2 && !defined(__DOXYGEN__)
|
#if USE_SIM_SERIAL2 && !defined(__DOXYGEN__)
|
||||||
extern SerialDriver SD2;
|
extern SerialDriver SD2;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue