Merge branch 'dev_trailing_spaces_removal' of git://github.com/0xc0170/mbed into 0xc0170-dev_trailing_spaces_removal

Conflicts:
	workspace_tools/toolchains/__init__.py
	workspace_tools/toolchains/arm.py
pull/344/head
Bogdan Marinescu 2014-06-03 10:39:31 +01:00
commit bb120221fb
218 changed files with 2093 additions and 2090 deletions

3
.gitignore vendored
View File

@ -60,3 +60,6 @@ debug.log
# Ignore OS X Desktop Services Store files
.DS_Store
# Orig diff files
*.orig

View File

@ -50,7 +50,7 @@
*
* int main() {
* int16_t buf[AUDIO_LENGTH_PACKET/2];
*
*
* while (1) {
* // read an audio packet
* audio.read((uint8_t *)buf);
@ -88,7 +88,7 @@ public:
* @returns volume
*/
float getVolume();
/**
* Read an audio packet. During a frame, only a single reading (you can't write and read an audio packet during the same frame)can be done using this method. Warning: Blocking
*
@ -97,7 +97,7 @@ public:
* @returns true if successfull
*/
bool read(uint8_t * buf);
/**
* Try to read an audio packet. During a frame, only a single reading (you can't write and read an audio packet during the same frame)can be done using this method. Warning: Non Blocking
*
@ -106,7 +106,7 @@ public:
* @returns true if successfull
*/
bool readNB(uint8_t * buf);
/**
* Write an audio packet. During a frame, only a single writing (you can't write and read an audio packet during the same frame)can be done using this method.
*
@ -114,7 +114,7 @@ public:
* @returns true if successful
*/
bool write(uint8_t * buf);
/**
* Write and read an audio packet at the same time (on the same frame)
*
@ -123,7 +123,7 @@ public:
* @returns true if successful
*/
bool readWrite(uint8_t * buf_read, uint8_t * buf_write);
/** attach a handler to update the volume
*
@ -212,12 +212,12 @@ protected:
* Callback called on each Start of Frame event
*/
virtual void SOF(int frameNumber);
/*
* Callback called when a packet is received
*/
virtual bool EP3_OUT_callback();
/*
* Callback called when a packet has been sent
*/
@ -227,13 +227,13 @@ private:
// stream available ?
volatile bool available;
// interrupt OUT has been received
volatile bool interruptOUT;
// interrupt IN has been received
volatile bool interruptIN;
// audio packet has been written
volatile bool writeIN;
@ -248,7 +248,7 @@ private:
// mono, stereo,...
uint8_t channel_nb_in;
uint8_t channel_nb_out;
// channel config: master, left, right
uint8_t channel_config_in;
uint8_t channel_config_out;
@ -270,16 +270,16 @@ private:
// Buffer containing one audio packet (to be read)
volatile uint8_t * buf_stream_in;
// Buffer containing one audio packet (to be written)
volatile uint8_t * buf_stream_out;
// callback to update volume
FunctionPointer updateVol;
// boolean showing that the SOF handler has been called. Useful for readNB.
volatile bool SOF_handler;
volatile float volume;
};

View File

@ -32,7 +32,7 @@
/*string offset*/
#define STRING_OFFSET_LANGID (0)
#define STRING_OFFSET_LANGID (0)
#define STRING_OFFSET_IMANUFACTURER (1)
#define STRING_OFFSET_IPRODUCT (2)
#define STRING_OFFSET_ISERIAL (3)

View File

@ -106,7 +106,7 @@ bool USBDevice::requestGetDescriptor(void)
transfer.ptr = stringImanufacturerDesc();
transfer.direction = DEVICE_TO_HOST;
success = true;
break;
break;
case STRING_OFFSET_IPRODUCT:
#ifdef DEBUG
printf("3\r\n");
@ -115,7 +115,7 @@ bool USBDevice::requestGetDescriptor(void)
transfer.ptr = stringIproductDesc();
transfer.direction = DEVICE_TO_HOST;
success = true;
break;
break;
case STRING_OFFSET_ISERIAL:
#ifdef DEBUG
printf("4\r\n");
@ -124,7 +124,7 @@ bool USBDevice::requestGetDescriptor(void)
transfer.ptr = stringIserialDesc();
transfer.direction = DEVICE_TO_HOST;
success = true;
break;
break;
case STRING_OFFSET_ICONFIGURATION:
#ifdef DEBUG
printf("5\r\n");
@ -133,7 +133,7 @@ bool USBDevice::requestGetDescriptor(void)
transfer.ptr = stringIConfigurationDesc();
transfer.direction = DEVICE_TO_HOST;
success = true;
break;
break;
case STRING_OFFSET_IINTERFACE:
#ifdef DEBUG
printf("6\r\n");
@ -142,7 +142,7 @@ bool USBDevice::requestGetDescriptor(void)
transfer.ptr = stringIinterfaceDesc();
transfer.direction = DEVICE_TO_HOST;
success = true;
break;
break;
}
break;
case INTERFACE_DESCRIPTOR:
@ -357,7 +357,7 @@ bool USBDevice::requestSetInterface(void)
{
success = true;
currentInterface = transfer.setup.wIndex;
currentAlternate = transfer.setup.wValue;
currentAlternate = transfer.setup.wValue;
}
return success;
}
@ -473,12 +473,12 @@ bool USBDevice::requestGetStatus(void)
if (success)
{
/* Send the status */
/* Send the status */
transfer.ptr = (uint8_t *)&status; /* Assumes little endian */
transfer.remaining = sizeof(status);
transfer.direction = DEVICE_TO_HOST;
}
return success;
}
@ -546,7 +546,7 @@ bool USBDevice::controlSetup(void)
transfer.direction = 0;
transfer.zlp = false;
transfer.notify = false;
#ifdef DEBUG
printf("dataTransferDirection: %d\r\nType: %d\r\nRecipient: %d\r\nbRequest: %d\r\nwValue: %d\r\nwIndex: %d\r\nwLength: %d\r\n",transfer.setup.bmRequestType.dataTransferDirection,
transfer.setup.bmRequestType.Type,
@ -593,7 +593,7 @@ bool USBDevice::controlSetup(void)
}
else
{
/* OUT data stage is required */
if (transfer.direction != HOST_TO_DEVICE)
{
@ -707,7 +707,7 @@ void USBDevice::connect(bool blocking)
{
/* Connect device */
USBHAL::connect();
if (blocking) {
/* Block if not configured */
while (!configured());
@ -793,8 +793,8 @@ void USBDevice::suspendStateChanged(unsigned int suspended)
USBDevice::USBDevice(uint16_t vendor_id, uint16_t product_id, uint16_t product_release){
VENDOR_ID = vendor_id;
PRODUCT_ID = product_id;
VENDOR_ID = vendor_id;
PRODUCT_ID = product_id;
PRODUCT_RELEASE = product_release;
/* Set initial device state */
@ -818,12 +818,12 @@ bool USBDevice::write(uint8_t endpoint, uint8_t * buffer, uint32_t size, uint32_
{
return false;
}
if(!configured()) {
return false;
}
/* Send report */
result = endpointWrite(endpoint, buffer, size);
@ -849,7 +849,7 @@ bool USBDevice::writeNB(uint8_t endpoint, uint8_t * buffer, uint32_t size, uint3
{
return false;
}
if(!configured()) {
return false;
}
@ -872,7 +872,7 @@ bool USBDevice::writeNB(uint8_t endpoint, uint8_t * buffer, uint32_t size, uint3
bool USBDevice::readEP(uint8_t endpoint, uint8_t * buffer, uint32_t * size, uint32_t maxSize)
{
EP_STATUS result;
if(!configured()) {
return false;
}
@ -889,13 +889,13 @@ bool USBDevice::readEP(uint8_t endpoint, uint8_t * buffer, uint32_t * size, uint
bool USBDevice::readEP_NB(uint8_t endpoint, uint8_t * buffer, uint32_t * size, uint32_t maxSize)
{
EP_STATUS result;
if(!configured()) {
return false;
}
result = endpointReadResult(endpoint, buffer, size);
return (result == EP_COMPLETED);
}

View File

@ -27,26 +27,26 @@ class USBDevice: public USBHAL
{
public:
USBDevice(uint16_t vendor_id, uint16_t product_id, uint16_t product_release);
/*
* Check if the device is configured
*
* @returns true if configured, false otherwise
*/
bool configured(void);
/*
* Connect a device
*
*
* @param blocking: block if not configured
*/
void connect(bool blocking = true);
/*
* Disconnect a device
*/
void disconnect(void);
/*
* Add an endpoint
*
@ -65,7 +65,7 @@ public:
* @return true if successful
*/
bool readStart(uint8_t endpoint, uint32_t maxSize);
/*
* Read a certain endpoint. Before calling this function, USBUSBDevice_readStart
* must be called.
@ -79,20 +79,20 @@ public:
* @returns true if successful
*/
bool readEP(uint8_t endpoint, uint8_t * buffer, uint32_t * size, uint32_t maxSize);
/*
* Read a certain endpoint.
*
* Warning: non blocking
*
* @param endpoint endpoint which will be read
* @param buffer buffer will be filled with the data received (if data are available)
* @param buffer buffer will be filled with the data received (if data are available)
* @param size the number of bytes read will be stored in *size
* @param maxSize the maximum length that can be read
* @returns true if successful
*/
bool readEP_NB(uint8_t endpoint, uint8_t * buffer, uint32_t * size, uint32_t maxSize);
/*
* Write a certain endpoint.
*
@ -104,8 +104,8 @@ public:
* @param maxSize the maximum length that can be written on this endpoint
*/
bool write(uint8_t endpoint, uint8_t * buffer, uint32_t size, uint32_t maxSize);
/*
* Write a certain endpoint.
*
@ -118,14 +118,14 @@ public:
*/
bool writeNB(uint8_t endpoint, uint8_t * buffer, uint32_t size, uint32_t maxSize);
/*
* Called by USBDevice layer on bus reset. Warning: Called in ISR context
*
* May be used to reset state
*/
virtual void USBCallback_busReset(void) {};
/*
* Called by USBDevice on Endpoint0 request. Warning: Called in ISR context
* This is used to handle extensions to standard requests
@ -133,8 +133,8 @@ public:
*
* @returns true if class handles this request
*/
virtual bool USBCallback_request() { return false; };
virtual bool USBCallback_request() { return false; };
/*
* Called by USBDevice on Endpoint0 request completion
* if the 'notify' flag has been set to true. Warning: Called in ISR context
@ -146,7 +146,7 @@ public:
* @param length length of this buffer
*/
virtual void USBCallback_requestCompleted(uint8_t * buf, uint32_t length) {};
/*
* Called by USBDevice layer. Set configuration of the device.
* For instance, you can add all endpoints that you need on this function.
@ -154,7 +154,7 @@ public:
* @param configuration Number of the configuration
*/
virtual bool USBCallback_setConfiguration(uint8_t configuration) { return false; };
/*
* Called by USBDevice layer. Set interface/alternate of the device.
*
@ -170,63 +170,63 @@ public:
* @returns pointer to the device descriptor
*/
virtual uint8_t * deviceDesc();
/*
* Get configuration descriptor
*
* @returns pointer to the configuration descriptor
*/
virtual uint8_t * configurationDesc(){return NULL;};
/*
* Get string lang id descriptor
*
* @return pointer to the string lang id descriptor
*/
virtual uint8_t * stringLangidDesc();
/*
* Get string manufacturer descriptor
*
* @returns pointer to the string manufacturer descriptor
*/
virtual uint8_t * stringImanufacturerDesc();
/*
* Get string product descriptor
*
* @returns pointer to the string product descriptor
*/
virtual uint8_t * stringIproductDesc();
/*
* Get string serial descriptor
*
* @returns pointer to the string serial descriptor
*/
virtual uint8_t * stringIserialDesc();
/*
* Get string configuration descriptor
*
* @returns pointer to the string configuration descriptor
*/
virtual uint8_t * stringIConfigurationDesc();
/*
* Get string interface descriptor
*
* @returns pointer to the string interface descriptor
*/
virtual uint8_t * stringIinterfaceDesc();
/*
* Get the length of the report descriptor
*
* @returns length of the report descriptor
*/
virtual uint16_t reportDescLength() { return 0; };
protected:
@ -238,7 +238,7 @@ protected:
virtual void suspendStateChanged(unsigned int suspended);
uint8_t * findDescriptor(uint8_t descriptorType);
CONTROL_TRANSFER * getTransferPtr(void);
uint16_t VENDOR_ID;
uint16_t PRODUCT_ID;
uint16_t PRODUCT_RELEASE;
@ -262,7 +262,7 @@ private:
CONTROL_TRANSFER transfer;
USB_DEVICE device;
uint16_t currentInterface;
uint8_t currentAlternate;
};

View File

@ -23,38 +23,38 @@
/* Endpoint No. */
/* ---------------- */
#define EP0OUT (0)
#define EP0IN (1)
#define EP1OUT (2)
#define EP1IN (3)
#define EP2OUT (4)
#define EP2IN (5)
#define EP3OUT (6)
#define EP3IN (7)
#define EP4OUT (8)
#define EP4IN (9)
#define EP5OUT (10)
#define EP5IN (11)
#define EP6OUT (12)
#define EP6IN (13)
#define EP7OUT (14)
#define EP7IN (15)
#define EP8OUT (16)
#define EP8IN (17)
#define EP9OUT (18)
#define EP9IN (19)
#define EP10OUT (20)
#define EP10IN (21)
#define EP11OUT (22)
#define EP11IN (23)
#define EP12OUT (24)
#define EP12IN (25)
#define EP13OUT (26)
#define EP13IN (27)
#define EP14OUT (28)
#define EP14IN (29)
#define EP15OUT (30)
#define EP15IN (31)
#define EP0OUT (0)
#define EP0IN (1)
#define EP1OUT (2)
#define EP1IN (3)
#define EP2OUT (4)
#define EP2IN (5)
#define EP3OUT (6)
#define EP3IN (7)
#define EP4OUT (8)
#define EP4IN (9)
#define EP5OUT (10)
#define EP5IN (11)
#define EP6OUT (12)
#define EP6IN (13)
#define EP7OUT (14)
#define EP7IN (15)
#define EP8OUT (16)
#define EP8IN (17)
#define EP9OUT (18)
#define EP9IN (19)
#define EP10OUT (20)
#define EP10IN (21)
#define EP11OUT (22)
#define EP11IN (23)
#define EP12OUT (24)
#define EP12IN (25)
#define EP13OUT (26)
#define EP13IN (27)
#define EP14OUT (28)
#define EP14IN (29)
#define EP15OUT (30)
#define EP15IN (31)
/* Maximum Packet sizes */

View File

@ -58,7 +58,7 @@ public:
bool realiseEndpoint(uint8_t endpoint, uint32_t maxPacket, uint32_t options);
bool getEndpointStallState(unsigned char endpoint);
uint32_t endpointReadcore(uint8_t endpoint, uint8_t *buffer);
protected:
virtual void busReset(void){};
virtual void EP0setupCallback(void){};
@ -67,7 +67,7 @@ protected:
virtual void connectStateChanged(unsigned int connected){};
virtual void suspendStateChanged(unsigned int suspended){};
virtual void SOF(int frameNumber){};
virtual bool EP1_OUT_callback(){return false;};
virtual bool EP1_IN_callback(){return false;};
virtual bool EP2_OUT_callback(){return false;};
@ -102,7 +102,7 @@ protected:
virtual bool EP15_IN_callback(){return false;};
#endif
#endif
private:
void usbisr(void);
static void _usbisr(void);
@ -116,6 +116,6 @@ private:
bool (USBHAL::*epCallback[32 - 2])(void);
#endif
};
#endif

View File

@ -134,7 +134,7 @@ void USBMemCopy(uint8_t *dst, uint8_t *src, uint32_t size) {
USBHAL::USBHAL(void) {
NVIC_DisableIRQ(USB_IRQ);
// fill in callback array
epCallback[0] = &USBHAL::EP1_OUT_callback;
epCallback[1] = &USBHAL::EP1_IN_callback;
@ -149,7 +149,7 @@ USBHAL::USBHAL(void) {
// USB_VBUS input with pull-down
LPC_IOCON->PIO0_3 = 0x00000009;
#endif
// nUSB_CONNECT output
LPC_IOCON->PIO0_6 = 0x00000001;
@ -287,13 +287,13 @@ EP_STATUS USBHAL::endpointRead(uint8_t endpoint, uint32_t maximumSize) {
bf = 0;
}
}
// if isochronous endpoint, T = 1
if(endpointState[endpoint].options & ISOCHRONOUS)
{
flags |= CMDSTS_T;
}
//Active the endpoint for reading
ep[PHY_TO_LOG(endpoint)].out[bf] = CMDSTS_A | CMDSTS_NBYTES(maximumSize) \
| CMDSTS_ADDRESS_OFFSET((uint32_t)ct->out) | flags;
@ -408,7 +408,7 @@ EP_STATUS USBHAL::endpointWrite(uint8_t endpoint, uint8_t *data, uint32_t size)
EP_STATUS USBHAL::endpointWriteResult(uint8_t endpoint) {
uint32_t bf;
// Validate parameters
if (endpoint > LAST_PHYSICAL_ENDPOINT) {
return EP_INVALID;
@ -680,7 +680,7 @@ void USBHAL::usbisr(void) {
// EP0IN ACK event (IN data sent)
EP0in();
}
for (uint8_t num = 2; num < 5*2; num++) {
if (LPC_USB->INTSTAT & EP(num)) {
LPC_USB->INTSTAT = EP(num);

View File

@ -279,7 +279,7 @@ uint32_t USBHAL::endpointReadcore(uint8_t endpoint, uint8_t *buffer) {
SIEselectEndpoint(endpoint);
SIEclearBuffer();
}
return size;
}
@ -327,7 +327,7 @@ static void endpointWritecore(uint8_t endpoint, uint8_t *buffer, uint32_t size)
USBHAL::USBHAL(void) {
// Disable IRQ
NVIC_DisableIRQ(USB_IRQn);
// fill in callback array
epCallback[0] = &USBHAL::EP1_OUT_callback;
epCallback[1] = &USBHAL::EP1_IN_callback;
@ -466,7 +466,7 @@ EP_STATUS USBHAL::endpointReadResult(uint8_t endpoint, uint8_t * buffer, uint32_
if (!(epComplete & EP(endpoint)))
return EP_PENDING;
}
*bytesRead = endpointReadcore(endpoint, buffer);
epComplete &= ~EP(endpoint);
return EP_COMPLETED;
@ -606,7 +606,7 @@ void USBHAL::usbisr(void) {
LPC_USB->USBDevIntClr = EP_SLOW;
EP0in();
}
for (uint8_t num = 2; num < 16*2; num++) {
if (LPC_USB->USBEpIntSt & EP(num)) {
selectEndpointClearInterrupt(num);

View File

@ -280,7 +280,7 @@ uint32_t USBHAL::endpointReadcore(uint8_t endpoint, uint8_t *buffer) {
SIEselectEndpoint(endpoint);
SIEclearBuffer();
}
return size;
}
@ -328,7 +328,7 @@ static void endpointWritecore(uint8_t endpoint, uint8_t *buffer, uint32_t size)
USBHAL::USBHAL(void) {
// Disable IRQ
NVIC_DisableIRQ(USB_IRQn);
// fill in callback array
epCallback[0] = &USBHAL::EP1_OUT_callback;
epCallback[1] = &USBHAL::EP1_IN_callback;
@ -367,7 +367,7 @@ USBHAL::USBHAL(void) {
// Enable USB clocks
LPC_USB->USBClkCtrl |= DEV_CLK_EN | AHB_CLK_EN | PORT_CLK_EN;
while ((LPC_USB->USBClkSt & (DEV_CLK_EN | AHB_CLK_EN | PORT_CLK_EN)) != (DEV_CLK_ON | AHB_CLK_ON | PORT_CLK_EN));
// Select port USB2
LPC_USB->StCtrl |= 3;
@ -375,13 +375,13 @@ USBHAL::USBHAL(void) {
// Configure pin P0.31 to be USB2
LPC_IOCON->P0_31 &= ~0x07;
LPC_IOCON->P0_31 |= 0x01;
// Disconnect USB device
SIEdisconnect();
// Configure pin P0.14 to be Connect
LPC_IOCON->P0_14 &= ~0x07;
LPC_IOCON->P0_14 |= 0x03;
LPC_IOCON->P0_14 |= 0x03;
// Connect must be low for at least 2.5uS
wait(0.3);
@ -471,7 +471,7 @@ EP_STATUS USBHAL::endpointReadResult(uint8_t endpoint, uint8_t * buffer, uint32_
if (!(epComplete & EP(endpoint)))
return EP_PENDING;
}
*bytesRead = endpointReadcore(endpoint, buffer);
epComplete &= ~EP(endpoint);
return EP_COMPLETED;
@ -611,7 +611,7 @@ void USBHAL::usbisr(void) {
LPC_USB->DevIntClr = EP_SLOW;
EP0in();
}
for (uint8_t num = 2; num < 16*2; num++) {
if (LPC_USB->EpIntSt & EP(num)) {
selectEndpointClearInterrupt(num);

View File

@ -36,7 +36,7 @@ uint32_t USBHAL::endpointReadcore(uint8_t endpoint, uint8_t *buffer) {
return 0;
}
USBHAL::USBHAL(void) {
USBHAL::USBHAL(void) {
NVIC_DisableIRQ(OTG_FS_IRQn);
epCallback[0] = &USBHAL::EP1_OUT_callback;
epCallback[1] = &USBHAL::EP1_IN_callback;
@ -63,7 +63,7 @@ USBHAL::USBHAL(void) {
pin_mode(PA_9, OpenDrain);
RCC->AHB2ENR |= RCC_AHB2ENR_OTGFSEN;
// Enable interrupts
OTG_FS->GREGS.GAHBCFG |= (1 << 0);
@ -116,21 +116,21 @@ bool USBHAL::realiseEndpoint(uint8_t endpoint, uint32_t maxPacket,
uint32_t type;
switch (endpoint) {
case EP0IN:
case EP0IN:
case EP0OUT:
type = 0;
break;
break;
case EPISO_IN:
case EPISO_OUT:
type = 1;
type = 1;
case EPBULK_IN:
case EPBULK_OUT:
type = 2;
break;
type = 2;
break;
case EPINT_IN:
case EPINT_OUT:
type = 3;
break;
type = 3;
break;
}
// Generic in or out EP controls
@ -154,7 +154,7 @@ bool USBHAL::realiseEndpoint(uint8_t endpoint, uint32_t maxPacket,
if (endpoint != EP0IN) {
control |= (1 << 28); // SD0PID
}
control |= (epIndex << 22) | // TxFIFO index
(1 << 27); // SNAK
OTG_FS->INEP_REGS[epIndex].DIEPCTL = control;
@ -166,7 +166,7 @@ bool USBHAL::realiseEndpoint(uint8_t endpoint, uint32_t maxPacket,
// Set the out EP specific control settings
control |= (1 << 26); // CNAK
OTG_FS->OUTEP_REGS[epIndex].DOEPCTL = control;
// Unmask the interrupt
OTG_FS->DREGS.DAINTMSK |= (1 << (epIndex + 16));
}
@ -190,7 +190,7 @@ uint32_t USBHAL::EP0getReadResult(uint8_t *buffer) {
for (uint32_t i = 0; i < length; i += 4) {
buffer32[i >> 2] = OTG_FS->FIFO[0][0];
}
rxFifoCount = 0;
return length;
}
@ -266,7 +266,7 @@ EP_STATUS USBHAL::endpointWriteResult(uint8_t endpoint) {
return EP_COMPLETED;
}
return EP_PENDING;
return EP_PENDING;
}
void USBHAL::stallEndpoint(uint8_t endpoint) {
@ -282,7 +282,7 @@ void USBHAL::stallEndpoint(uint8_t endpoint) {
}
void USBHAL::unstallEndpoint(uint8_t endpoint) {
}
bool USBHAL::getEndpointStallState(uint8_t endpoint) {

View File

@ -16,8 +16,8 @@
*
* http://www.st.com/software_license_agreement_liberty_v2
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* 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.
@ -70,7 +70,7 @@ typedef struct // 800h
}
USB_OTG_DREGS;
typedef struct
typedef struct
{
__IO uint32_t DIEPCTL; /* dev IN Endpoint Control Reg 900h + (ep_num * 20h) + 00h*/
uint32_t Reserved04; /* Reserved 900h + (ep_num * 20h) + 04h*/
@ -83,7 +83,7 @@ typedef struct
}
USB_OTG_INEPREGS;
typedef struct
typedef struct
{
__IO uint32_t DOEPCTL; /* dev OUT Endpoint Control Reg B00h + (ep_num * 20h) + 00h*/
uint32_t Reserved04; /* Reserved B00h + (ep_num * 20h) + 04h*/
@ -117,7 +117,7 @@ typedef struct
}
USB_OTG_HC_REGS;
typedef struct
typedef struct
{
USB_OTG_GREGS GREGS;
uint32_t RESERVED0[188];

View File

@ -121,7 +121,7 @@ bool USBHID::USBCallback_request() {
success = true;
}
break;
default:
break;
}

View File

@ -70,8 +70,8 @@ public:
* @returns true if successful
*/
bool send(HID_REPORT *report);
/**
* Send a Report. warning: non blocking
*
@ -79,7 +79,7 @@ public:
* @returns true if successful
*/
bool sendNB(HID_REPORT *report);
/**
* Read a report: blocking
*
@ -87,7 +87,7 @@ public:
* @returns true if successful
*/
bool read(HID_REPORT * report);
/**
* Read a report: non blocking
*
@ -98,7 +98,7 @@ public:
protected:
uint16_t reportLength;
/*
* Get the Report descriptor
*
@ -119,14 +119,14 @@ protected:
* @returns pointer to the string product descriptor
*/
virtual uint8_t * stringIproductDesc();
/*
* Get string interface descriptor
*
* @returns pointer to the string interface descriptor
*/
virtual uint8_t * stringIinterfaceDesc();
/*
* Get configuration descriptor
*

View File

@ -183,7 +183,7 @@ const KEYMAP keymap[KEYMAP_SIZE] = {
{0x4a, 0}, /* HOME */
{0x4b, 0}, /* PAGE_UP */
{0x4e, 0}, /* PAGE_DOWN */
{0x4f, 0}, /* RIGHT_ARROW */
{0x50, 0}, /* LEFT_ARROW */
{0x51, 0}, /* DOWN_ARROW */
@ -344,7 +344,7 @@ const KEYMAP keymap[KEYMAP_SIZE] = {
{0x4a, 0}, /* HOME */
{0x4b, 0}, /* PAGE_UP */
{0x4e, 0}, /* PAGE_DOWN */
{0x4f, 0}, /* RIGHT_ARROW */
{0x50, 0}, /* LEFT_ARROW */
{0x51, 0}, /* DOWN_ARROW */
@ -424,10 +424,10 @@ bool USBKeyboard::EP1_OUT_callback() {
uint32_t bytesRead = 0;
uint8_t led[65];
USBDevice::readEP(EPINT_OUT, led, &bytesRead, MAX_HID_REPORT_SIZE);
// we take led[1] because led[0] is the report ID
lock_status = led[1] & 0x07;
// We activate the endpoint to be able to recceive data
if (!readStart(EPINT_OUT, MAX_HID_REPORT_SIZE))
return false;

View File

@ -53,7 +53,7 @@ enum FUNCTION_KEY {
KEY_F10, /* F10 key */
KEY_F11, /* F11 key */
KEY_F12, /* F12 key */
KEY_PRINT_SCREEN, /* Print Screen key */
KEY_SCROLL_LOCK, /* Scroll lock */
KEY_CAPS_LOCK, /* caps lock */
@ -62,7 +62,7 @@ enum FUNCTION_KEY {
KEY_HOME, /* Home key */
KEY_PAGE_UP, /* Page Up key */
KEY_PAGE_DOWN, /* Page Down key */
RIGHT_ARROW, /* Right arrow */
LEFT_ARROW, /* Left arrow */
DOWN_ARROW, /* Down arrow */

View File

@ -35,7 +35,7 @@ enum MOUSE_BUTTON
/* X and Y limits */
/* These values do not directly map to screen pixels */
/* Zero may be interpreted as meaning 'no movement' */
#define X_MIN_ABS (1) /*!< Minimum value on x-axis */
#define X_MIN_ABS (1) /*!< Minimum value on x-axis */
#define Y_MIN_ABS (1) /*!< Minimum value on y-axis */
#define X_MAX_ABS (0x7fff) /*!< Maximum value on x-axis */
#define Y_MAX_ABS (0x7fff) /*!< Maximum value on y-axis */
@ -85,7 +85,7 @@ enum MOUSE_TYPE
* uint16_t y_center = (Y_MAX_ABS - Y_MIN_ABS)/2;
* uint16_t x_screen = 0;
* uint16_t y_screen = 0;
*
*
* uint32_t x_origin = x_center;
* uint32_t y_origin = y_center;
* uint32_t radius = 5000;
@ -95,7 +95,7 @@ enum MOUSE_TYPE
* {
* x_screen = x_origin + cos((double)angle*3.14/180.0)*radius;
* y_screen = y_origin + sin((double)angle*3.14/180.0)*radius;
*
*
* mouse.move(x_screen, y_screen);
* angle += 3;
* wait(0.01);
@ -107,7 +107,7 @@ enum MOUSE_TYPE
class USBMouse: public USBHID
{
public:
/**
* Constructor
*
@ -117,14 +117,14 @@ class USBMouse: public USBHID
* @param product_release Your preoduct_release (default: 0x0001)
*
*/
USBMouse(MOUSE_TYPE mouse_type = REL_MOUSE, uint16_t vendor_id = 0x1234, uint16_t product_id = 0x0001, uint16_t product_release = 0x0001):
USBMouse(MOUSE_TYPE mouse_type = REL_MOUSE, uint16_t vendor_id = 0x1234, uint16_t product_id = 0x0001, uint16_t product_release = 0x0001):
USBHID(0, 0, vendor_id, product_id, product_release, false)
{
{
button = 0;
this->mouse_type = mouse_type;
connect();
};
/**
* Write a state of the mouse
*
@ -135,8 +135,8 @@ class USBMouse: public USBHID
* @returns true if there is no error, false otherwise
*/
bool update(int16_t x, int16_t y, uint8_t buttons, int8_t z);
/**
* Move the cursor to (x, y)
*
@ -145,7 +145,7 @@ class USBMouse: public USBHID
* @returns true if there is no error, false otherwise
*/
bool move(int16_t x, int16_t y);
/**
* Press one or several buttons
*
@ -153,7 +153,7 @@ class USBMouse: public USBHID
* @returns true if there is no error, false otherwise
*/
bool press(uint8_t button);
/**
* Release one or several buttons
*
@ -161,22 +161,22 @@ class USBMouse: public USBHID
* @returns true if there is no error, false otherwise
*/
bool release(uint8_t button);
/**
* Double click (MOUSE_LEFT)
*
* @returns true if there is no error, false otherwise
*/
bool doubleClick();
/**
* Click
*
* @param button state of the buttons ( ex: clic(MOUSE_LEFT))
* @returns true if there is no error, false otherwise
*/
bool click(uint8_t button);
bool click(uint8_t button);
/**
* Scrolling
*
@ -184,7 +184,7 @@ class USBMouse: public USBHID
* @returns true if there is no error, false otherwise
*/
bool scroll(int8_t z);
/*
* To define the report descriptor. Warning: this method has to store the length of the report descriptor in reportLength.
*
@ -199,7 +199,7 @@ class USBMouse: public USBHID
* @returns pointer to the configuration descriptor
*/
virtual uint8_t * configurationDesc();
private:
MOUSE_TYPE mouse_type;
uint8_t button;

View File

@ -178,7 +178,7 @@ const KEYMAP keymap[KEYMAP_SIZE] = {
{0x4a, 0}, /* HOME */
{0x4b, 0}, /* PAGE_UP */
{0x4e, 0}, /* PAGE_DOWN */
{0x4f, 0}, /* RIGHT_ARROW */
{0x50, 0}, /* LEFT_ARROW */
{0x51, 0}, /* DOWN_ARROW */
@ -339,7 +339,7 @@ const KEYMAP keymap[KEYMAP_SIZE] = {
{0x4a, 0}, /* HOME */
{0x4b, 0}, /* PAGE_UP */
{0x4e, 0}, /* PAGE_DOWN */
{0x4f, 0}, /* RIGHT_ARROW */
{0x50, 0}, /* LEFT_ARROW */
{0x51, 0}, /* DOWN_ARROW */
@ -552,10 +552,10 @@ bool USBMouseKeyboard::EP1_OUT_callback() {
uint32_t bytesRead = 0;
uint8_t led[65];
USBDevice::readEP(EPINT_OUT, led, &bytesRead, MAX_HID_REPORT_SIZE);
// we take led[1] because led[0] is the report ID
lock_status = led[1] & 0x07;
// We activate the endpoint to be able to recceive data
if (!readStart(EPINT_OUT, MAX_HID_REPORT_SIZE))
return false;
@ -696,7 +696,7 @@ bool USBMouseKeyboard::mediaControl(MEDIA_KEY key) {
report.length = 2;
send(&report);
report.data[0] = REPORT_ID_VOLUME;
report.data[1] = 0;

View File

@ -28,7 +28,7 @@
#include "Stream.h"
#include "USBHID.h"
/**
/**
* USBMouseKeyboard example
* @code
*
@ -70,7 +70,7 @@
class USBMouseKeyboard: public USBHID, public Stream
{
public:
/**
* Constructor
*
@ -81,7 +81,7 @@ class USBMouseKeyboard: public USBHID, public Stream
* @param product_release Your preoduct_release (default: 0x0001)
*
*/
USBMouseKeyboard(MOUSE_TYPE mouse_type = REL_MOUSE, uint16_t vendor_id = 0x0021, uint16_t product_id = 0x0011, uint16_t product_release = 0x0001):
USBMouseKeyboard(MOUSE_TYPE mouse_type = REL_MOUSE, uint16_t vendor_id = 0x0021, uint16_t product_id = 0x0011, uint16_t product_release = 0x0001):
USBHID(0, 0, vendor_id, product_id, product_release, false)
{
lock_status = 0;
@ -89,7 +89,7 @@ class USBMouseKeyboard: public USBHID, public Stream
this->mouse_type = mouse_type;
connect();
};
/**
* Write a state of the mouse
*
@ -100,8 +100,8 @@ class USBMouseKeyboard: public USBHID, public Stream
* @returns true if there is no error, false otherwise
*/
bool update(int16_t x, int16_t y, uint8_t buttons, int8_t z);
/**
* Move the cursor to (x, y)
*
@ -110,7 +110,7 @@ class USBMouseKeyboard: public USBHID, public Stream
* @returns true if there is no error, false otherwise
*/
bool move(int16_t x, int16_t y);
/**
* Press one or several buttons
*
@ -118,7 +118,7 @@ class USBMouseKeyboard: public USBHID, public Stream
* @returns true if there is no error, false otherwise
*/
bool press(uint8_t button);
/**
* Release one or several buttons
*
@ -126,22 +126,22 @@ class USBMouseKeyboard: public USBHID, public Stream
* @returns true if there is no error, false otherwise
*/
bool release(uint8_t button);
/**
* Double click (MOUSE_LEFT)
*
* @returns true if there is no error, false otherwise
*/
bool doubleClick();
/**
* Click
*
* @param button state of the buttons ( ex: clic(MOUSE_LEFT))
* @returns true if there is no error, false otherwise
*/
bool click(uint8_t button);
bool click(uint8_t button);
/**
* Scrolling
*
@ -151,7 +151,7 @@ class USBMouseKeyboard: public USBHID, public Stream
bool scroll(int8_t z);
/**
* To send a character defined by a modifier(CTRL, SHIFT, ALT) and the key
* To send a character defined by a modifier(CTRL, SHIFT, ALT) and the key
*
* @code
* //To send CTRL + s (save)
@ -163,7 +163,7 @@ class USBMouseKeyboard: public USBHID, public Stream
* @returns true if there is no error, false otherwise
*/
bool keyCode(uint8_t key, uint8_t modifier = 0);
/**
* Send a character
*
@ -171,7 +171,7 @@ class USBMouseKeyboard: public USBHID, public Stream
* @returns true if there is no error, false otherwise
*/
virtual int _putc(int c);
/**
* Control media keys
*
@ -179,7 +179,7 @@ class USBMouseKeyboard: public USBHID, public Stream
* @returns true if there is no error, false otherwise
*/
bool mediaControl(MEDIA_KEY key);
/**
* Read status of lock keys. Useful to switch-on/off leds according to key pressed. Only the first three bits of the result is important:
* - First bit: NUM_LOCK
@ -189,30 +189,30 @@ class USBMouseKeyboard: public USBHID, public Stream
* @returns status of lock keys
*/
uint8_t lockStatus();
/*
* To define the report descriptor. Warning: this method has to store the length of the report descriptor in reportLength.
*
* @returns pointer to the report descriptor
*/
virtual uint8_t * reportDesc();
/*
* Called when a data is received on the OUT endpoint. Useful to switch on LED of LOCK keys
*
* @returns if handle by subclass, return true
*/
virtual bool EP1_OUT_callback();
private:
bool mouseWrite(int8_t x, int8_t y, uint8_t buttons, int8_t z);
MOUSE_TYPE mouse_type;
uint8_t button;
bool mouseSend(int8_t x, int8_t y, uint8_t buttons, int8_t z);
uint8_t lock_status;
//dummy otherwise it doesn't compile (we must define all methods of an abstract class)
virtual int _getc() { return -1;}
};

View File

@ -22,7 +22,7 @@
#include "mbed.h"
// MIDI Message Format
//
//
// [ msg(4) | channel(4) ] [ 0 | n(7) ] [ 0 | m(7) ]
//
// MIDI Data Messages (Channel Specific)
@ -43,15 +43,15 @@
class MIDIMessage {
public:
MIDIMessage() {}
MIDIMessage(uint8_t *buf) {
for (int i = 0; i < 4; i++)
data[i] = buf[i];
}
// create messages
/** Create a NoteOff message
/** Create a NoteOff message
* @param key Key ID
* @param velocity Key velocity (0-127, default = 127)
* @param channel Key channel (0-15, default 0)
@ -62,11 +62,11 @@ public:
msg.data[0] = CABLE_NUM | 0x08;
msg.data[1] = 0x80 | (channel & 0x0F);
msg.data[2] = key & 0x7F;
msg.data[3] = velocity & 0x7F;
msg.data[3] = velocity & 0x7F;
return msg;
}
/** Create a NoteOn message
/** Create a NoteOn message
* @param key Key ID
* @param velocity Key velocity (0-127, default = 127)
* @param channel Key channel (0-15, default 0)
@ -77,26 +77,26 @@ public:
msg.data[0] = CABLE_NUM | 0x09;
msg.data[1] = 0x90 | (channel & 0x0F);
msg.data[2] = key & 0x7F;
msg.data[3] = velocity & 0x7F;
msg.data[3] = velocity & 0x7F;
return msg;
}
/** Create a PolyPhonic Aftertouch message
/** Create a PolyPhonic Aftertouch message
* @param key Key ID
* @param pressure Aftertouch pressure (0-127)
* @param channel Key channel (0-15, default 0)
* @returns A MIDIMessage
*/
*/
static MIDIMessage PolyphonicAftertouch(int key, int pressure, int channel = 0) {
MIDIMessage msg;
msg.data[0] = CABLE_NUM | 0x0A;
msg.data[1] = 0xA0 | (channel & 0x0F);
msg.data[2] = key & 0x7F;
msg.data[3] = pressure & 0x7F;
msg.data[3] = pressure & 0x7F;
return msg;
}
/** Create a Control Change message
/** Create a Control Change message
* @param control Controller ID
* @param value Controller value (0-127)
* @param channel Controller channel (0-15, default 0)
@ -107,63 +107,63 @@ public:
msg.data[0] = CABLE_NUM | 0x0B;
msg.data[1] = 0xB0 | (channel & 0x0F);
msg.data[2] = control & 0x7F;
msg.data[3] = value & 0x7F;
msg.data[3] = value & 0x7F;
return msg;
}
/** Create a Program Change message
/** Create a Program Change message
* @param program Program ID
* @param channel Channel (0-15, default 0)
* @returns A MIDIMessage
*/
*/
static MIDIMessage ProgramChange(int program, int channel = 0) {
MIDIMessage msg;
msg.data[0] = CABLE_NUM | 0x0C;
msg.data[1] = 0xC0 | (channel & 0x0F);
msg.data[2] = program & 0x7F;
msg.data[3] = 0x00;
msg.data[3] = 0x00;
return msg;
}
/** Create a Channel Aftertouch message
* @param pressure Pressure
/** Create a Channel Aftertouch message
* @param pressure Pressure
* @param channel Key channel (0-15, default 0)
* @returns A MIDIMessage
*/
*/
static MIDIMessage ChannelAftertouch(int pressure, int channel = 0) {
MIDIMessage msg;
msg.data[0] = CABLE_NUM | 0x0D;
msg.data[1] = 0xD0 | (channel & 0x0F);
msg.data[2] = pressure & 0x7F;
msg.data[3] = 0x00;
msg.data[3] = 0x00;
return msg;
}
/** Create a Pitch Wheel message
/** Create a Pitch Wheel message
* @param pitch Pitch (-8192 - 8191, default = 0)
* @param channel Channel (0-15, default 0)
* @returns A MIDIMessage
*/
*/
static MIDIMessage PitchWheel(int pitch = 0, int channel = 0) {
MIDIMessage msg;
int p = pitch + 8192; // 0 - 16383, 8192 is center
msg.data[0] = CABLE_NUM | 0x0E;
msg.data[1] = 0xE0 | (channel & 0x0F);
msg.data[2] = p & 0x7F;
msg.data[3] = (p >> 7) & 0x7F;
msg.data[3] = (p >> 7) & 0x7F;
return msg;
}
/** Create an All Notes Off message
/** Create an All Notes Off message
* @param channel Channel (0-15, default 0)
* @returns A MIDIMessage
*/
*/
static MIDIMessage AllNotesOff(int channel = 0) {
return ControlChange(123, 0, channel);
}
// decode messages
/** MIDI Message Types */
enum MIDIMessageType {
ErrorType,
@ -176,16 +176,16 @@ public:
PitchWheelType,
AllNotesOffType
};
/** Read the message type
* @returns MIDIMessageType
*/
*/
MIDIMessageType type() {
switch((data[1] >> 4) & 0xF) {
case 0x8: return NoteOffType;
case 0x9: return NoteOnType;
case 0xA: return PolyphonicAftertouchType;
case 0xB:
case 0xB:
if(controller() < 120) { // standard controllers
return ControlChangeType;
} else if(controller() == 123) {
@ -200,51 +200,51 @@ public:
}
}
/** Read the channel number */
/** Read the channel number */
int channel() {
return (data[1] & 0x0F);
}
/** Read the key ID */
/** Read the key ID */
int key() {
return (data[2] & 0x7F);
}
/** Read the velocity */
int velocity() {
return (data[3] & 0x7F);
return (data[2] & 0x7F);
}
/** Read the controller value */
int value() {
return (data[3] & 0x7F);
/** Read the velocity */
int velocity() {
return (data[3] & 0x7F);
}
/** Read the aftertouch pressure */
/** Read the controller value */
int value() {
return (data[3] & 0x7F);
}
/** Read the aftertouch pressure */
int pressure() {
if(type() == PolyphonicAftertouchType) {
return (data[3] & 0x7F);
return (data[3] & 0x7F);
} else {
return (data[2] & 0x7F);
return (data[2] & 0x7F);
}
}
/** Read the controller number */
/** Read the controller number */
int controller() {
return (data[2] & 0x7F);
return (data[2] & 0x7F);
}
/** Read the program number */
/** Read the program number */
int program() {
return (data[2] & 0x7F);
return (data[2] & 0x7F);
}
/** Read the pitch value */
/** Read the pitch value */
int pitch() {
int p = ((data[3] & 0x7F) << 7) | (data[2] & 0x7F);
return p - 8192; // 0 - 16383, 8192 is center
}
uint8_t data[4];
};

View File

@ -29,7 +29,7 @@
#define DEFAULT_CONFIGURATION (1)
/**
/**
* USBMIDI example
*
* @code
@ -38,8 +38,8 @@
*
* USBMIDI midi;
*
* int main() {
* while (1) {
* int main() {
* while (1) {
* for(int i=48; i<83; i++) { // send some messages!
* midi.write(MIDIMessage::NoteOn(i));
* wait(0.25);
@ -61,12 +61,12 @@ public:
* @param product_release Your preoduct_release
*/
USBMIDI(uint16_t vendor_id = 0x0700, uint16_t product_id = 0x0101, uint16_t product_release = 0x0001);
/**
* Send a MIDIMessage
*
* @param m The MIDIMessage to send
*/
*/
void write(MIDIMessage m);
/**
@ -75,8 +75,8 @@ public:
* @param fptr function pointer
*/
void attach(void (*fptr)(MIDIMessage));
protected:
virtual bool EP2_OUT_callback();
virtual bool USBCallback_setConfiguration(uint8_t configuration);
@ -86,14 +86,14 @@ protected:
* @returns pointer to the string product descriptor
*/
virtual uint8_t * stringIproductDesc();
/*
* Get string interface descriptor
*
* @returns pointer to the string interface descriptor
*/
virtual uint8_t * stringIinterfaceDesc();
/*
* Get configuration descriptor
*

View File

@ -79,7 +79,7 @@ public:
* Disconnect the USB MSD device.
*/
void disconnect();
/**
* Destructor
*/

View File

@ -73,15 +73,15 @@ void USBCDC::USBCallback_requestCompleted(uint8_t *buf, uint32_t length) {
if (length != 7) {
return;
}
CONTROL_TRANSFER * transfer = getTransferPtr();
/* Process class-specific requests */
if (transfer->setup.bmRequestType.Type == CLASS_TYPE) {
if (transfer->setup.bRequest == CDC_SET_LINE_CODING) {
if (memcmp(cdc_line_coding, buf, 7)) {
memcpy(cdc_line_coding, buf, 7);
memcpy(cdc_line_coding, buf, 7);
int baud = buf[0] + (buf[1] << 8)
+ (buf[2] << 16) + (buf[3] << 24);
int stop = buf[4];
@ -186,7 +186,7 @@ uint8_t * USBCDC::configurationDesc() {
0, // iConfiguration
0x80, // bmAttributes
50, // bMaxPower
// IAD to associate the two CDC interfaces
0x08, // bLength
0x0b, // bDescriptorType

View File

@ -40,35 +40,35 @@ public:
USBCDC(uint16_t vendor_id, uint16_t product_id, uint16_t product_release, bool connect_blocking);
protected:
/*
* Get device descriptor. Warning: this method has to store the length of the report descriptor in reportLength.
*
* @returns pointer to the device descriptor
*/
virtual uint8_t * deviceDesc();
/*
* Get string product descriptor
*
* @returns pointer to the string product descriptor
*/
virtual uint8_t * stringIproductDesc();
/*
* Get string interface descriptor
*
* @returns pointer to the string interface descriptor
*/
virtual uint8_t * stringIinterfaceDesc();
/*
* Get configuration descriptor
*
* @returns pointer to the configuration descriptor
*/
virtual uint8_t * configurationDesc();
/*
* Send a buffer
*
@ -78,7 +78,7 @@ protected:
* @returns true if successful
*/
bool send(uint8_t * buffer, uint32_t size);
/*
* Read a buffer from a certain endpoint. Warning: blocking
*
@ -89,7 +89,7 @@ protected:
* @returns true if successful
*/
bool readEP(uint8_t * buffer, uint32_t * size);
/*
* Read a buffer from a certain endpoint. Warning: non blocking
*
@ -111,7 +111,7 @@ protected:
* @param stop The number of stop bits (1 or 2)
*/
virtual void lineCodingChanged(int baud, int bits, int parity, int stop) {};
protected:
virtual bool USBCallback_request();
virtual void USBCallback_requestCompleted(uint8_t *buf, uint32_t length);

View File

@ -68,20 +68,20 @@ public:
* @returns true if there is no error, false otherwise
*/
virtual int _putc(int c);
/**
* Read a character: blocking
*
* @returns character read
*/
virtual int _getc();
/**
* Check the number of bytes available.
*
* @returns the number of bytes available
*/
uint8_t available();
uint8_t available();
/** Determine if there is a character available to read
*
@ -90,7 +90,7 @@ public:
* 0 otherwise
*/
int readable() { return available() ? 1 : 0; }
/** Determine if there is space available to write a character
*
* @returns
@ -98,9 +98,9 @@ public:
* 0 otherwise
*/
int writeable() { return 1; } // always return 1, for write operation is blocking
/**
* Write a block of data.
* Write a block of data.
*
* For more efficiency, a block of size 64 (maximum size of a bulk endpoint) has to be written.
*
@ -112,7 +112,7 @@ public:
bool writeBlock(uint8_t * buf, uint16_t size);
/**
* Attach a member function to call when a packet is received.
* Attach a member function to call when a packet is received.
*
* @param tptr pointer to the object to call the member function on
* @param mptr pointer to the member function to be called

View File

@ -50,10 +50,10 @@ void USBDeviceConnected::init() {
INTERFACE * USBDeviceConnected::getInterface(uint8_t index) {
if (index >= MAX_INTF)
return NULL;
if (intf[index].in_use)
return &intf[index];
return NULL;
}

View File

@ -33,7 +33,7 @@ typedef struct {
USBEndpoint * ep[MAX_ENDPOINT_PER_INTERFACE];
FunctionPointer detach;
char name[10];
} INTERFACE;
} INTERFACE;
/**
* USBDeviceConnected class
@ -157,7 +157,7 @@ public:
inline USBHostHub * getHubParent() { return hub_parent; };
inline uint8_t getNbIntf() { return nb_interf; };
inline const char * getName(uint8_t intf_nb) { return intf[intf_nb].name; };
// in case this device is a hub
USBHostHub * hub;

View File

@ -29,7 +29,7 @@ void USBEndpoint::init(HCED * hced_, ENDPOINT_TYPE type_, ENDPOINT_DIRECTION dir
memcpy((HCTD**)td_list, td_list_, sizeof(HCTD*)*2); //TODO: Maybe should add a param for td_list size... at least a define
memset(td_list_[0], 0, sizeof(HCTD));
memset(td_list_[1], 0, sizeof(HCTD));
td_list[0]->ep = this;
td_list[1]->ep = this;
@ -52,7 +52,7 @@ void USBEndpoint::init(HCED * hced_, ENDPOINT_TYPE type_, ENDPOINT_DIRECTION dir
td_current = td_list[0];
td_next = td_list[1];
intf_nb = 0;
state = USB_TYPE_IDLE;

View File

@ -136,9 +136,9 @@ public:
inline bool isSetup() { return setup; }
inline USBEndpoint * nextEndpoint() { return (USBEndpoint*)nextEp; };
inline uint8_t getIntfNb() { return intf_nb; };
USBDeviceConnected * dev;
Queue<uint8_t, 1> ep_queue;
private:
@ -163,7 +163,7 @@ private:
volatile HCTD * td_list[2];
volatile HCTD * td_current;
volatile HCTD * td_next;
uint8_t intf_nb;
};

View File

@ -57,7 +57,7 @@ USBHALHost::USBHALHost() {
void USBHALHost::init() {
NVIC_DisableIRQ(USB_IRQn);
//Cut power
LPC_SC->PCONP &= ~(1UL<<31);
wait_ms(100);
@ -98,7 +98,7 @@ void USBHALHost::init() {
// software reset
LPC_USB->HcCommandStatus = OR_CMD_STATUS_HCR;
// Write Fm Interval and Largest Data Packet Counter
LPC_USB->HcFmInterval = DEFAULT_FMINTERVAL;
LPC_USB->HcPeriodicStart = FI * 90 / 100;
@ -109,7 +109,7 @@ void USBHALHost::init() {
LPC_USB->HcRhStatus = OR_RH_STATUS_LPSC;
LPC_USB->HcHCCA = (uint32_t)(usb_hcca);
// Clear Interrrupt Status
LPC_USB->HcInterruptStatus |= LPC_USB->HcInterruptStatus;
@ -249,9 +249,9 @@ void USBHALHost::freeTD(volatile uint8_t * td) {
void USBHALHost::resetRootHub() {
// Initiate port reset
LPC_USB->HcRhPortStatus1 = OR_RH_PORT_PRS;
while (LPC_USB->HcRhPortStatus1 & OR_RH_PORT_PRS);
// ...and clear port reset signal
LPC_USB->HcRhPortStatus1 = OR_RH_PORT_PRSC;
}
@ -266,11 +266,11 @@ void USBHALHost::_usbisr(void) {
void USBHALHost::UsbIrqhandler() {
if( LPC_USB->HcInterruptStatus & LPC_USB->HcInterruptEnable ) //Is there something to actually process?
{
uint32_t int_status = LPC_USB->HcInterruptStatus & LPC_USB->HcInterruptEnable;
// Root hub status change interrupt
if (int_status & OR_INTR_STATUS_RHSC) {
if (int_status & OR_INTR_STATUS_RHSC) {
if (LPC_USB->HcRhPortStatus1 & OR_RH_PORT_CSC) {
if (LPC_USB->HcRhStatus & OR_RH_STATUS_DRWE) {
// When DRWE is on, Connect Status Change
@ -278,27 +278,27 @@ void USBHALHost::UsbIrqhandler() {
} else {
//Root device connected
if (LPC_USB->HcRhPortStatus1 & OR_RH_PORT_CCS) {
if (LPC_USB->HcRhPortStatus1 & OR_RH_PORT_CCS) {
// wait 150ms to avoid bounce
wait_ms(150);
//Hub 0 (root hub), Port 1 (count starts at 1), Low or High speed
deviceConnected(0, 1, LPC_USB->HcRhPortStatus1 & OR_RH_PORT_LSDA);
}
deviceConnected(0, 1, LPC_USB->HcRhPortStatus1 & OR_RH_PORT_LSDA);
}
//Root device disconnected
else {
else {
if (!(int_status & OR_INTR_STATUS_WDH)) {
usb_hcca->DoneHead = 0;
}
// wait 200ms to avoid bounce
wait_ms(200);
deviceDisconnected(0, 1, NULL, usb_hcca->DoneHead & 0xFFFFFFFE);
if (int_status & OR_INTR_STATUS_WDH) {
usb_hcca->DoneHead = 0;
LPC_USB->HcInterruptStatus = OR_INTR_STATUS_WDH;

View File

@ -33,61 +33,61 @@ protected:
* init variables and memory where will be stored HCCA, ED and TD
*/
USBHALHost();
/**
* Initialize host controller. Enable USB interrupts. This part is not in the constructor because,
* Initialize host controller. Enable USB interrupts. This part is not in the constructor because,
* this function calls a virtual method if a device is already connected
*/
void init();
/**
* reset the root hub
*/
void resetRootHub();
/**
* return the value contained in the control HEAD ED register
*
* @returns address of the control Head ED
*/
uint32_t controlHeadED();
/**
* return the value contained in the bulk HEAD ED register
*
* @returns address of the bulk head ED
*/
uint32_t bulkHeadED();
/**
* return the value of the head interrupt ED contained in the HCCA
*
* @returns address of the head interrupt ED contained in the HCCA
*/
uint32_t interruptHeadED();
/**
* Update the head ED for control transfers
*/
void updateControlHeadED(uint32_t addr);
/**
* Update the head ED for bulk transfers
*/
void updateBulkHeadED(uint32_t addr);
/**
* Update the head ED for interrupt transfers
*/
void updateInterruptHeadED(uint32_t addr);
/**
* Enable List for the specified endpoint type
*
* @param type enable the list of ENDPOINT_TYPE type
*/
void enableList(ENDPOINT_TYPE type);
/**
* Disable List for the specified endpoint type
*
@ -104,7 +104,7 @@ protected:
* @param hub_parent reference to the hub where the device is connected (NULL if the hub parent is the root hub)
*/
virtual void deviceConnected(int hub, int port, bool lowSpeed, USBHostHub * hub_parent = NULL) = 0;
/**
* Virtual method called when a device has been disconnected
*
@ -114,35 +114,35 @@ protected:
* @param addr list of the TDs which have been completed to dequeue freed TDs
*/
virtual void deviceDisconnected(int hub, int port, USBHostHub * hub_parent, volatile uint32_t addr) = 0;
/**
* Virtual method called when a transfer has been completed
*
* @param addr list of the TDs which have been completed
*/
virtual void transferCompleted(volatile uint32_t addr) = 0;
/**
* Find a memory section for a new ED
*
* @returns the address of the new ED
*/
volatile uint8_t * getED();
/**
* Find a memory section for a new TD
*
* @returns the address of the new TD
*/
volatile uint8_t * getTD();
/**
* Release a previous memory section reserved for an ED
*
* @param ed address of the ED
*/
void freeED(volatile uint8_t * ed);
/**
* Release a previous memory section reserved for an TD
*
@ -161,7 +161,7 @@ private:
uint8_t volatile * usb_tdBuf; //4 bytes aligned
static USBHALHost * instHost;
bool volatile edBufAlloc[MAX_ENDPOINT];
bool volatile tdBufAlloc[MAX_TD];
};

View File

@ -47,7 +47,7 @@ USBHost * USBHost::instHost = NULL;
* - call the callback attached to the endpoint where the td is attached
*/
void USBHost::usb_process() {
bool controlListState;
bool bulkListState;
bool interruptListState;
@ -60,29 +60,29 @@ void USBHost::usb_process() {
#if DEBUG_TRANSFER
uint8_t * buf_transfer;
#endif
#if MAX_HUB_NB
uint8_t k;
#endif
while(1) {
osEvent evt = mail_usb_event.get();
if (evt.status == osEventMail) {
message_t * usb_msg = (message_t*)evt.value.p;
switch (usb_msg->event_id) {
// a new device has been connected
case DEVICE_CONNECTED_EVENT:
too_many_hub = false;
buf[4] = 0;
do
{
Lock lock(this);
for (i = 0; i < MAX_DEVICE_CONNECTED; i++) {
if (!deviceInUse[i]) {
USB_DBG_EVENT("new device connected: %p\r\n", &devices[i]);
@ -92,68 +92,68 @@ void USBHost::usb_process() {
break;
}
}
if (i == MAX_DEVICE_CONNECTED) {
USB_ERR("Too many device connected!!\r\n");
continue;
}
if (!controlEndpointAllocated) {
control = newEndpoint(CONTROL_ENDPOINT, OUT, 0x08, 0x00);
addEndpoint(NULL, 0, (USBEndpoint*)control);
controlEndpointAllocated = true;
}
#if MAX_HUB_NB
if (usb_msg->hub_parent)
devices[i].setHubParent((USBHostHub *)(usb_msg->hub_parent));
#endif
for (j = 0; j < timeout_set_addr; j++) {
resetDevice(&devices[i]);
// set size of control endpoint
devices[i].setSizeControlEndpoint(8);
devices[i].activeAddress(false);
// get first 8 bit of device descriptor
// and check if we deal with a hub
USB_DBG("usb_thread read device descriptor on dev: %p\r\n", &devices[i]);
res = getDeviceDescriptor(&devices[i], buf, 8);
if (res != USB_TYPE_OK) {
USB_ERR("usb_thread could not read dev descr");
continue;
}
// set size of control endpoint
devices[i].setSizeControlEndpoint(buf[7]);
// second step: set an address to the device
res = setAddress(&devices[i], devices[i].getAddress());
if (res != USB_TYPE_OK) {
USB_ERR("SET ADDR FAILED");
continue;
}
devices[i].activeAddress(true);
USB_DBG("Address of %p: %d", &devices[i], devices[i].getAddress());
// try to read again the device descriptor to check if the device
// answers to its new address
res = getDeviceDescriptor(&devices[i], buf, 8);
if (res == USB_TYPE_OK) {
break;
}
Thread::wait(100);
}
USB_INFO("New device connected: %p [hub: %d - port: %d]", &devices[i], usb_msg->hub, usb_msg->port);
#if MAX_HUB_NB
if (buf[4] == HUB_CLASS) {
for (k = 0; k < MAX_HUB_NB; k++) {
@ -169,49 +169,49 @@ void USBHost::usb_process() {
break;
}
}
if (k == MAX_HUB_NB) {
USB_ERR("Too many hubs connected!!\r\n");
too_many_hub = true;
}
}
if (usb_msg->hub_parent)
((USBHostHub *)(usb_msg->hub_parent))->deviceConnected(&devices[i]);
#endif
if ((i < MAX_DEVICE_CONNECTED) && !too_many_hub) {
deviceInUse[i] = true;
}
} while(0);
break;
// a device has been disconnected
case DEVICE_DISCONNECTED_EVENT:
do
{
Lock lock(this);
controlListState = disableList(CONTROL_ENDPOINT);
bulkListState = disableList(BULK_ENDPOINT);
interruptListState = disableList(INTERRUPT_ENDPOINT);
idx = findDevice(usb_msg->hub, usb_msg->port, (USBHostHub *)(usb_msg->hub_parent));
if (idx != -1) {
freeDevice((USBDeviceConnected*)&devices[idx]);
}
if (controlListState) enableList(CONTROL_ENDPOINT);
if (bulkListState) enableList(BULK_ENDPOINT);
if (interruptListState) enableList(INTERRUPT_ENDPOINT);
} while(0);
break;
// a td has been processed
// call callback on the ed associated to the td
// we are not in ISR -> users can use printf in their callback method
@ -241,7 +241,7 @@ void USBHost::usb_process() {
}
break;
}
mail_usb_event.free(usb_msg);
}
}
@ -272,7 +272,7 @@ USBHost::USBHost() : usbThread(USBHost::usb_process_static, (void *)this, osPrio
for (uint8_t j = 0; j < MAX_INTF; j++)
deviceAttachedDriver[i][j] = false;
}
#if MAX_HUB_NB
for (uint8_t i = 0; i < MAX_HUB_NB; i++) {
hubs[i].setHost(this);
@ -313,7 +313,7 @@ void USBHost::transferCompleted(volatile uint32_t addr)
tdList = (volatile HCTD*)td->nextTD; //Dequeue element now as it could be modified below
if (td->ep != NULL) {
USBEndpoint * ep = (USBEndpoint *)(td->ep);
if (((HCTD *)td)->control >> 28) {
state = ((HCTD *)td)->control >> 28;
} else {
@ -321,9 +321,9 @@ void USBHost::transferCompleted(volatile uint32_t addr)
ep->setLengthTransferred((uint32_t)td->currBufPtr - (uint32_t)ep->getBufStart());
state = 16 /*USB_TYPE_IDLE*/;
}
ep->unqueueTransfer(td);
if (ep->getType() != CONTROL_ENDPOINT) {
// callback on the processed td will be called from the usb_thread (not in ISR)
message_t * usb_msg = mail_usb_event.alloc();
@ -360,7 +360,7 @@ USBHost * USBHost::getHostInst()
if (deviceInited[idx])
return;
}
message_t * usb_msg = mail_usb_event.alloc();
usb_msg->event_id = DEVICE_CONNECTED_EVENT;
usb_msg->hub = hub;
@ -384,7 +384,7 @@ USBHost * USBHost::getHostInst()
} else {
return;
}
message_t * usb_msg = mail_usb_event.alloc();
usb_msg->event_id = DEVICE_DISCONNECTED_EVENT;
usb_msg->hub = hub;
@ -397,7 +397,7 @@ void USBHost::freeDevice(USBDeviceConnected * dev)
{
USBEndpoint * ep = NULL;
HCED * ed = NULL;
#if MAX_HUB_NB
if (dev->getClass() == HUB_CLASS) {
if (dev->hub == NULL) {
@ -412,13 +412,13 @@ void USBHost::freeDevice(USBDeviceConnected * dev)
}
}
}
// notify hub parent that this device has been disconnected
if (dev->getHubParent())
dev->getHubParent()->deviceDisconnected(dev);
#endif
int idx = findDevice(dev);
if (idx != -1) {
deviceInUse[idx] = false;
@ -481,7 +481,7 @@ void USBHost::unqueueEndpoint(USBEndpoint * ep)
updateInterruptHeadED(0);
headInterruptEndpoint = current->nextEndpoint();
}
// modify tail
switch (current->getType()) {
case BULK_ENDPOINT:
@ -553,7 +553,7 @@ USB_TYPE USBHost::resetDevice(USBDeviceConnected * dev)
deviceReset[index] = true;
return USB_TYPE_OK;
}
return USB_TYPE_ERROR;
}
@ -577,7 +577,7 @@ bool USBHost::addEndpoint(USBDeviceConnected * dev, uint8_t intf_nb, USBEndpoint
if ((dev != NULL) && dev->getSpeed()) {
ep->setSpeed(dev->getSpeed());
}
ep->setIntfNb(intf_nb);
// queue the new USBEndpoint on the ED list
@ -626,7 +626,7 @@ bool USBHost::addEndpoint(USBDeviceConnected * dev, uint8_t intf_nb, USBEndpoint
default:
return false;
}
ep->dev = dev;
dev->addEndpoint(intf_nb, ep);
@ -733,7 +733,7 @@ USB_TYPE USBHost::addTransfer(USBEndpoint * ed, uint8_t * buf, uint32_t len)
ed->queueTransfer();
printList(type);
enableList(type);
td_mutex.unlock();
return USB_TYPE_PROCESSING;
@ -750,7 +750,7 @@ USB_TYPE USBHost::getDeviceDescriptor(USBDeviceConnected * dev, uint8_t * buf, u
0, buf, MIN(DEVICE_DESCRIPTOR_LENGTH, max_len_buf));
if (len_dev_descr)
*len_dev_descr = MIN(DEVICE_DESCRIPTOR_LENGTH, max_len_buf);
return t;
}
@ -772,10 +772,10 @@ USB_TYPE USBHost::getConfigurationDescriptor(USBDeviceConnected * dev, uint8_t *
}
total_conf_descr_length = buf[2] | (buf[3] << 8);
total_conf_descr_length = MIN(max_len_buf, total_conf_descr_length);
if (len_conf_descr)
*len_conf_descr = total_conf_descr_length;
USB_DBG("TOTAL_LENGTH: %d \t NUM_INTERF: %d", total_conf_descr_length, buf[4]);
return controlRead( dev,
@ -792,7 +792,7 @@ USB_TYPE USBHost::setAddress(USBDeviceConnected * dev, uint8_t address) {
SET_ADDRESS,
address,
0, NULL, 0);
}
USB_TYPE USBHost::setConfiguration(USBDeviceConnected * dev, uint8_t conf)
@ -821,18 +821,18 @@ USB_TYPE USBHost::enumerate(USBDeviceConnected * dev, IUSBEnumerator* pEnumerato
{
uint16_t total_conf_descr_length = 0;
USB_TYPE res;
do
{
Lock lock(this);
// don't enumerate a device which all interfaces are registered to a specific driver
int index = findDevice(dev);
if (index == -1) {
return USB_TYPE_ERROR;
}
uint8_t nb_intf_attached = numberDriverAttached(dev);
USB_DBG("dev: %p nb_intf: %d", dev, dev->getNbIntf());
USB_DBG("dev: %p nb_intf_attached: %d", dev, nb_intf_attached);
@ -840,9 +840,9 @@ USB_TYPE USBHost::enumerate(USBDeviceConnected * dev, IUSBEnumerator* pEnumerato
USB_DBG("Don't enumerate dev: %p because all intf are registered with a driver", dev);
return USB_TYPE_OK;
}
USB_DBG("Enumerate dev: %p", dev);
// third step: get the whole device descriptor to see vid, pid
res = getDeviceDescriptor(dev, data, DEVICE_DESCRIPTOR_LENGTH);
@ -850,7 +850,7 @@ USB_TYPE USBHost::enumerate(USBDeviceConnected * dev, IUSBEnumerator* pEnumerato
USB_DBG("GET DEV DESCR FAILED");
return res;
}
dev->setClass(data[4]);
dev->setSubClass(data[5]);
dev->setProtocol(data[6]);
@ -877,7 +877,7 @@ USB_TYPE USBHost::enumerate(USBDeviceConnected * dev, IUSBEnumerator* pEnumerato
// only set configuration if not enumerated before
if (!dev->isEnumerated()) {
USB_DBG("Set configuration 1 on dev: %p", dev);
// sixth step: set configuration (only 1 supported)
res = setConfiguration(dev, 1);
@ -887,12 +887,12 @@ USB_TYPE USBHost::enumerate(USBDeviceConnected * dev, IUSBEnumerator* pEnumerato
return res;
}
}
dev->setEnumerated();
// Now the device is enumerated!
USB_DBG("dev %p is enumerated\r\n", dev);
} while(0);
// Some devices may require this delay
@ -991,17 +991,17 @@ USB_TYPE USBHost::interruptRead(USBDeviceConnected * dev, USBEndpoint * ep, uint
}
USB_TYPE USBHost::generalTransfer(USBDeviceConnected * dev, USBEndpoint * ep, uint8_t * buf, uint32_t len, bool blocking, ENDPOINT_TYPE type, bool write) {
#if DEBUG_TRANSFER
const char * type_str = (type == BULK_ENDPOINT) ? "BULK" : ((type == INTERRUPT_ENDPOINT) ? "INTERRUPT" : "ISOCHRONOUS");
USB_DBG_TRANSFER("----- %s %s [dev: %p - %s - hub: %d - port: %d - addr: %d - ep: %02X]------", type_str, (write) ? "WRITE" : "READ", dev, dev->getName(ep->getIntfNb()), dev->getHub(), dev->getPort(), dev->getAddress(), ep->getAddress());
#endif
Lock lock(this);
USB_TYPE res;
ENDPOINT_DIRECTION dir = (write) ? OUT : IN;
if (dev == NULL) {
USB_ERR("dev NULL");
return USB_TYPE_ERROR;
@ -1026,7 +1026,7 @@ USB_TYPE USBHost::generalTransfer(USBDeviceConnected * dev, USBEndpoint * ep, ui
USB_ERR("[ep: %p - dev: %p] USBEndpoint addr and device addr don't match", ep, ep->dev);
return USB_TYPE_ERROR;
}
#if DEBUG_TRANSFER
if (write) {
USB_DBG_TRANSFER("%s WRITE buffer", type_str);
@ -1038,19 +1038,19 @@ USB_TYPE USBHost::generalTransfer(USBDeviceConnected * dev, USBEndpoint * ep, ui
addTransfer(ep, buf, len);
if (blocking) {
ep->ep_queue.get();
res = ep->getState();
USB_DBG_TRANSFER("%s TRANSFER res: %s on ep: %p\r\n", type_str, ep->getStateString(), ep);
if (res != USB_TYPE_IDLE) {
return res;
}
return USB_TYPE_OK;
}
return USB_TYPE_PROCESSING;
}

View File

@ -35,7 +35,7 @@ public:
* Static method to create or retrieve the single USBHost instance
*/
static USBHost * getHostInst();
/**
* Control read: setup stage, data stage and status stage
*
@ -186,19 +186,19 @@ public:
dev->onDisconnect(intf, fn);
}
}
/**
* Instantiate to protect USB thread from accessing shared objects (USBConnectedDevices and Interfaces)
*/
class Lock
{
public:
Lock(USBHost* pHost);
~Lock();
Lock(USBHost* pHost);
~Lock();
private:
USBHost* m_pHost;
};
friend class USBHostHub;
protected:
@ -257,7 +257,7 @@ private:
bool deviceAttachedDriver[MAX_DEVICE_CONNECTED][MAX_INTF];
bool deviceReset[MAX_DEVICE_CONNECTED];
bool deviceInited[MAX_DEVICE_CONNECTED];
#if MAX_HUB_NB
USBHostHub hubs[MAX_HUB_NB];
bool hub_in_use[MAX_HUB_NB];
@ -265,7 +265,7 @@ private:
// to store a setup packet
uint8_t setupPacket[8];
typedef struct {
uint8_t event_id;
void * td_addr;
@ -275,17 +275,17 @@ private:
uint8_t td_state;
void * hub_parent;
} message_t;
Thread usbThread;
void usb_process();
static void usb_process_static(void const * arg);
Mail<message_t, 10> mail_usb_event;
Mutex usb_mutex;
Mutex td_mutex;
// buffer for conf descriptor
uint8_t data[415];
/**
* Add a transfer on the TD linked list associated to an ED
*
@ -296,7 +296,7 @@ private:
* @return status of the transfer
*/
USB_TYPE addTransfer(USBEndpoint * ed, uint8_t * buf, uint32_t len) ;
/**
* Link the USBEndpoint to the linked list and attach an USBEndpoint this USBEndpoint to a device
*
@ -318,7 +318,7 @@ private:
* @returns pointer on the USBEndpoint created
*/
USBEndpoint * newEndpoint(ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir, uint32_t size, uint8_t addr) ;
/**
* Request the device descriptor
*
@ -338,7 +338,7 @@ private:
* @param len_conf_descr pointer to store the length of the packet transferred
*/
USB_TYPE getConfigurationDescriptor(USBDeviceConnected * dev, uint8_t * buf, uint16_t max_len_buf, uint16_t * len_conf_descr = NULL);
/**
* Set the address of a specific device
*
@ -354,7 +354,7 @@ private:
* @param conf configuration number to activate (usually 1)
*/
USB_TYPE setConfiguration(USBDeviceConnected * dev, uint8_t conf);
/**
* Free a specific device
*
@ -378,7 +378,7 @@ private:
bool blocking,
ENDPOINT_TYPE type,
bool write) ;
void fillControlBuf(uint8_t requestType, uint8_t request, uint16_t value, uint16_t index, int len) ;
void parseConfDescr(USBDeviceConnected * dev, uint8_t * conf_descr, uint32_t len, IUSBEnumerator* pEnumerator) ;
int findDevice(USBDeviceConnected * dev) ;

View File

@ -56,7 +56,7 @@
/*
* Enable USB3Gmodule
*/
#define USBHOST_3GMODULE 1
#define USBHOST_3GMODULE 1
/*
* Maximum number of interfaces of a usb device

View File

@ -67,28 +67,28 @@ enum ENDPOINT_TYPE {
#define HUB_CLASS 0x09
#define SERIAL_CLASS 0x0A
// ------------------ HcControl Register ---------------------
// ------------------ HcControl Register ---------------------
#define OR_CONTROL_PLE 0x00000004
#define OR_CONTROL_CLE 0x00000010
#define OR_CONTROL_BLE 0x00000020
#define OR_CONTROL_HCFS 0x000000C0
#define OR_CONTROL_HC_OPER 0x00000080
// ----------------- HcCommandStatus Register -----------------
// ----------------- HcCommandStatus Register -----------------
#define OR_CMD_STATUS_HCR 0x00000001
#define OR_CMD_STATUS_CLF 0x00000002
#define OR_CMD_STATUS_BLF 0x00000004
// --------------- HcInterruptStatus Register -----------------
// --------------- HcInterruptStatus Register -----------------
#define OR_INTR_STATUS_WDH 0x00000002
#define OR_INTR_STATUS_RHSC 0x00000040
#define OR_INTR_STATUS_UE 0x00000010
// --------------- HcInterruptEnable Register -----------------
// --------------- HcInterruptEnable Register -----------------
#define OR_INTR_ENABLE_WDH 0x00000002
#define OR_INTR_ENABLE_RHSC 0x00000040
#define OR_INTR_ENABLE_MIE 0x80000000
// ---------------- HcRhDescriptorA Register ------------------
// ---------------- HcRhDescriptorA Register ------------------
#define OR_RH_STATUS_LPSC 0x00010000
#define OR_RH_STATUS_DRWE 0x00008000
// -------------- HcRhPortStatus[1:NDP] Register --------------
// -------------- HcRhPortStatus[1:NDP] Register --------------
#define OR_RH_PORT_CCS 0x00000001
#define OR_RH_PORT_PRS 0x00000010
#define OR_RH_PORT_CSC 0x00010000
@ -100,14 +100,14 @@ enum ENDPOINT_TYPE {
#define ED_SKIP (uint32_t) (0x00001000) // Skip this ep in queue
#define TD_ROUNDING (uint32_t) (0x00040000) // Buffer Rounding
#define TD_SETUP (uint32_t)(0) // Direction of Setup Packet
#define TD_IN (uint32_t)(0x00100000) // Direction In
#define TD_OUT (uint32_t)(0x00080000) // Direction Out
#define TD_DELAY_INT(x) (uint32_t)((x) << 21) // Delay Interrupt
#define TD_TOGGLE_0 (uint32_t)(0x02000000) // Toggle 0
#define TD_TOGGLE_1 (uint32_t)(0x03000000) // Toggle 1
#define TD_CC (uint32_t)(0xF0000000) // Completion Code
#define TD_ROUNDING (uint32_t) (0x00040000) // Buffer Rounding
#define TD_SETUP (uint32_t)(0) // Direction of Setup Packet
#define TD_IN (uint32_t)(0x00100000) // Direction In
#define TD_OUT (uint32_t)(0x00080000) // Direction Out
#define TD_DELAY_INT(x) (uint32_t)((x) << 21) // Delay Interrupt
#define TD_TOGGLE_0 (uint32_t)(0x02000000) // Toggle 0
#define TD_TOGGLE_1 (uint32_t)(0x03000000) // Toggle 1
#define TD_CC (uint32_t)(0xF0000000) // Completion Code
#define DEVICE_DESCRIPTOR (1)
#define CONFIGURATION_DESCRIPTOR (2)
@ -115,7 +115,7 @@ enum ENDPOINT_TYPE {
#define ENDPOINT_DESCRIPTOR (5)
#define HID_DESCRIPTOR (33)
// ----------- Control RequestType Fields -----------
// ----------- Control RequestType Fields -----------
#define USB_DEVICE_TO_HOST 0x80
#define USB_HOST_TO_DEVICE 0x00
#define USB_REQUEST_TYPE_CLASS 0x20
@ -124,14 +124,14 @@ enum ENDPOINT_TYPE {
#define USB_RECIPIENT_INTERFACE 0x01
#define USB_RECIPIENT_ENDPOINT 0x02
// -------------- USB Standard Requests --------------
// -------------- USB Standard Requests --------------
#define SET_ADDRESS 0x05
#define GET_DESCRIPTOR 0x06
#define SET_CONFIGURATION 0x09
#define SET_INTERFACE 0x0b
#define CLEAR_FEATURE 0x01
// -------------- USB Descriptor Length --------------
// -------------- USB Descriptor Length --------------
#define DEVICE_DESCRIPTOR_LENGTH 0x12
#define CONFIGURATION_DESCRIPTOR_LENGTH 0x09
@ -145,7 +145,7 @@ typedef struct HCTD {
uint32_t dummy[3]; // padding
} PACKED HCTD;
// ----------- HostController EndPoint Descriptor -------------
// ----------- HostController EndPoint Descriptor -------------
typedef struct hcEd {
__IO uint32_t control; // Endpoint descriptor control
__IO HCTD * tailTD; // Physical address of tail in Transfer descriptor list
@ -154,73 +154,73 @@ typedef struct hcEd {
} PACKED HCED;
// ----------- Host Controller Communication Area ------------
// ----------- Host Controller Communication Area ------------
typedef struct hcca {
__IO uint32_t IntTable[32]; // Interrupt Table
__IO uint32_t FrameNumber; // Frame Number
__IO uint32_t DoneHead; // Done Head
volatile uint8_t Reserved[116]; // Reserved for future use
volatile uint8_t Unknown[4]; // Unused
volatile uint8_t Reserved[116]; // Reserved for future use
volatile uint8_t Unknown[4]; // Unused
} PACKED HCCA;
typedef struct {
uint8_t bLength;
uint8_t bDescriptorType;
uint16_t bcdUSB;
uint8_t bDeviceClass;
uint8_t bDeviceSubClass;
uint8_t bDeviceProtocol;
uint8_t bMaxPacketSize;
uint16_t idVendor;
uint16_t idProduct;
uint16_t bcdDevice;
uint8_t iManufacturer;
uint8_t iProduct;
uint8_t iSerialNumber;
uint8_t bNumConfigurations;
uint8_t bLength;
uint8_t bDescriptorType;
uint16_t bcdUSB;
uint8_t bDeviceClass;
uint8_t bDeviceSubClass;
uint8_t bDeviceProtocol;
uint8_t bMaxPacketSize;
uint16_t idVendor;
uint16_t idProduct;
uint16_t bcdDevice;
uint8_t iManufacturer;
uint8_t iProduct;
uint8_t iSerialNumber;
uint8_t bNumConfigurations;
} PACKED DeviceDescriptor;
typedef struct {
uint8_t bLength;
uint8_t bDescriptorType;
uint16_t wTotalLength;
uint8_t bNumInterfaces;
uint8_t bConfigurationValue;
uint8_t iConfiguration;
uint8_t bmAttributes;
uint8_t bMaxPower;
} PACKED ConfigurationDescriptor;
uint8_t bLength;
uint8_t bDescriptorType;
uint16_t wTotalLength;
uint8_t bNumInterfaces;
uint8_t bConfigurationValue;
uint8_t iConfiguration;
uint8_t bmAttributes;
uint8_t bMaxPower;
} PACKED ConfigurationDescriptor;
typedef struct {
uint8_t bLength;
uint8_t bDescriptorType;
uint8_t bInterfaceNumber;
uint8_t bAlternateSetting;
uint8_t bNumEndpoints;
uint8_t bInterfaceClass;
uint8_t bLength;
uint8_t bDescriptorType;
uint8_t bInterfaceNumber;
uint8_t bAlternateSetting;
uint8_t bNumEndpoints;
uint8_t bInterfaceClass;
uint8_t bInterfaceSubClass;
uint8_t bInterfaceProtocol;
uint8_t iInterface;
} InterfaceDescriptor;
uint8_t iInterface;
} InterfaceDescriptor;
typedef struct {
uint8_t bLength;
uint8_t bDescriptorType;
uint8_t bEndpointAddress;
uint8_t bmAttributes;
uint16_t wMaxPacketSize;
uint8_t bInterval;
uint8_t bLength;
uint8_t bDescriptorType;
uint8_t bEndpointAddress;
uint8_t bmAttributes;
uint16_t wMaxPacketSize;
uint8_t bInterval;
} EndpointDescriptor;
typedef struct {
uint8_t bDescLength;
uint8_t bDescriptorType;
uint8_t bNbrPorts;
uint8_t bDescLength;
uint8_t bDescriptorType;
uint8_t bNbrPorts;
uint16_t wHubCharacteristics;
uint8_t bPwrOn2PwrGood;
uint8_t bHubContrCurrent;
uint8_t DeviceRemovable;
uint8_t PortPweCtrlMak;
} HubDescriptor;
uint8_t bPwrOn2PwrGood;
uint8_t bHubContrCurrent;
uint8_t DeviceRemovable;
uint8_t PortPweCtrlMak;
} HubDescriptor;
#endif

View File

@ -45,12 +45,12 @@ bool WANDongle::tryConnect()
USB_DBG("Trying to connect device");
if (dev_connected) {
USB_DBG("Device is already connected!");
USB_DBG("Device is already connected!");
return true;
}
m_pInitializer = NULL;
//Protect from concurrent access from USB thread
USBHost::Lock lock(host);
@ -59,16 +59,16 @@ bool WANDongle::tryConnect()
if ((dev = host->getDevice(i)) != NULL)
{
m_pInitializer = NULL; //Will be set in setVidPid callback
USB_DBG("Enumerate");
int ret = host->enumerate(dev, this);
if(ret)
{
return false;
}
USB_DBG("Device has VID:%04x PID:%04x", dev->getVid(), dev->getPid());
if(m_pInitializer) //If an initializer has been found
{
USB_DBG("m_pInitializer=%p", m_pInitializer);
@ -90,18 +90,18 @@ bool WANDongle::tryConnect()
USB_DBG("Ep %p", m_pInitializer->getEp(dev, j, true));
m_serial[j].connect( dev, m_pInitializer->getEp(dev, j, false), m_pInitializer->getEp(dev, j, true) );
}
USB_DBG("Device connected");
dev_connected = true;
return true;
}
else if ((dev->getVid() == m_pInitializer->getMSDVid()) && (dev->getPid() == m_pInitializer->getMSDPid()))
{
USB_DBG("Vodafone K3370 dongle detected in MSD mode");
//Try to switch
//Try to switch
if( m_pInitializer->switchMode(dev) )
{
USB_DBG("Switched OK");

View File

@ -58,47 +58,47 @@ public:
* @return true if a serial device is connected
*/
bool connected();
/*
* Try to connect device
*
* * @return true if connection was successful
*/
bool tryConnect();
/*
* Disconnect device
*
* * @return true if disconnection was successful
*/
bool disconnect();
int getDongleType();
IUSBHostSerial& getSerial(int index);
int getSerialCount();
bool addInitializer(WANDongleInitializer* pInitializer);
//From IUSBEnumerator
virtual void setVidPid(uint16_t vid, uint16_t pid);
virtual bool parseInterface(uint8_t intf_nb, uint8_t intf_class, uint8_t intf_subclass, uint8_t intf_protocol); //Must return true if the interface should be parsed
virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir); //Must return true if the endpoint will be used
protected:
USBHost * host;
USBDeviceConnected * dev;
bool dev_connected;
WANDongleInitializer* m_pInitializer;
void init();
WANDongleSerialPort m_serial[WANDONGLE_MAX_SERIAL_PORTS];
int m_serialCount;
int m_totalInitializers;
WANDongleInitializer* m_Initializers[WANDONGLE_MAX_INITIALIZERS];
};

View File

@ -40,29 +40,29 @@ protected:
WANDongleInitializer(USBHost* pHost) { m_pHost = pHost; }
USBHost* m_pHost;
uint8_t m_serialIntfMap[WANDONGLE_MAX_SERIAL_PORTS];
public:
virtual ~WANDongleInitializer() {}
virtual uint16_t getMSDVid() = 0;
virtual uint16_t getMSDPid() = 0;
virtual uint16_t getSerialVid() = 0;
virtual uint16_t getSerialPid() = 0;
virtual bool switchMode(USBDeviceConnected* pDev) = 0;
virtual USBEndpoint* getEp(USBDeviceConnected* pDev, int serialPortNumber, bool tx) {
return pDev->getEndpoint(m_serialIntfMap[serialPortNumber], BULK_ENDPOINT, tx ? OUT : IN, 0);
}
virtual int getSerialPortCount() = 0;
virtual void setVidPid(uint16_t vid, uint16_t pid) = 0;
virtual bool parseInterface(uint8_t intf_nb, uint8_t intf_class, uint8_t intf_subclass, uint8_t intf_protocol) = 0; //Must return true if the interface should be parsed
virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir) = 0; //Must return true if the endpoint will be used
virtual int getType() = 0;
virtual uint8_t getSerialIntf(int index) { return m_serialIntfMap[index]; }

View File

@ -58,7 +58,7 @@ void WANDongleSerialPort::reset()
buf_in_read_pos = 0;
lock_rx = false;
cb_rx_pending = false;
tx_mtx.unlock();
rx_mtx.unlock();
}
@ -73,7 +73,7 @@ int WANDongleSerialPort::readPacket()
rx_mtx.unlock();
return -1;
}
if( bulk_in == NULL )
{
USB_WARN("Port is disconnected");
@ -105,7 +105,7 @@ int WANDongleSerialPort::writePacket()
tx_mtx.unlock();
return -1;
}
if( bulk_out == NULL )
{
USB_WARN("Port is disconnected");

View File

@ -42,11 +42,11 @@ public:
*
*/
WANDongleSerialPort();
void init( USBHost* pHost );
void connect( USBDeviceConnected* pDev, USBEndpoint* pInEp, USBEndpoint* pOutEp );
void disconnect( );
/*
@ -89,13 +89,13 @@ public:
* @param pListener instance of the listener deriving from the IUSBHostSerialListener
*/
virtual void attach(IUSBHostSerialListener* pListener);
/**
* Enable or disable readable/writeable callbacks
*/
virtual void setupIrq(bool en, IrqType irq = RxIrq);
protected:
USBEndpoint * bulk_in;
USBEndpoint * bulk_out;
@ -117,11 +117,11 @@ protected:
volatile bool cb_rx_en;
volatile bool cb_rx_pending;
Mutex rx_mtx;
IUSBHostSerialListener* listener;
void reset();
void rxHandler();
void txHandler();

View File

@ -18,7 +18,7 @@
#if USBHOST_KEYBOARD
static uint8_t keymap[4][0x39] = {
static uint8_t keymap[4][0x39] = {
{ 0, 0, 0, 0, 'a', 'b' /*0x05*/,
'c', 'd', 'e', 'f', 'g' /*0x0a*/,
'h', 'i', 'j', 'k', 'l'/*0x0f*/,
@ -100,30 +100,30 @@ bool USBHostKeyboard::connected() {
bool USBHostKeyboard::connect() {
if (dev_connected) {
return true;
}
for (uint8_t i = 0; i < MAX_DEVICE_CONNECTED; i++) {
if ((dev = host->getDevice(i)) != NULL) {
if (host->enumerate(dev, this))
break;
if (keyboard_device_found) {
int_in = dev->getEndpoint(keyboard_intf, INTERRUPT_ENDPOINT, IN);
if (!int_in)
break;
USB_INFO("New Keyboard device: VID:%04x PID:%04x [dev: %p - intf: %d]", dev->getVid(), dev->getPid(), dev, keyboard_intf);
dev->setName("Keyboard", keyboard_intf);
host->registerDriver(dev, keyboard_intf, this, &USBHostKeyboard::init);
int_in->attach(this, &USBHostKeyboard::rxHandler);
host->interruptRead(dev, int_in, report, int_in->getSize(), false);
dev_connected = true;
return true;
}

View File

@ -23,12 +23,12 @@
#include "USBHost.h"
/**
/**
* A class to communicate a USB keyboard
*/
class USBHostKeyboard : public IUSBEnumerator {
public:
/**
* Constructor
*/
@ -83,7 +83,7 @@ private:
uint8_t report[9];
int keyboard_intf;
bool keyboard_device_found;
bool dev_connected;
void rxHandler();
@ -92,7 +92,7 @@ private:
void (*onKeyCode)(uint8_t key, uint8_t modifier);
int report_id;
void init();
};

View File

@ -35,7 +35,7 @@ void USBHostMouse::init() {
dev_connected = false;
mouse_device_found = false;
mouse_intf = -1;
buttons = 0;
x = 0;
y = 0;
@ -51,26 +51,26 @@ bool USBHostMouse::connect() {
if (dev_connected) {
return true;
}
for (uint8_t i = 0; i < MAX_DEVICE_CONNECTED; i++) {
if ((dev = host->getDevice(i)) != NULL) {
if(host->enumerate(dev, this))
break;
if (mouse_device_found) {
int_in = dev->getEndpoint(mouse_intf, INTERRUPT_ENDPOINT, IN);
if (!int_in)
break;
USB_INFO("New Mouse device: VID:%04x PID:%04x [dev: %p - intf: %d]", dev->getVid(), dev->getPid(), dev, mouse_intf);
dev->setName("Mouse", mouse_intf);
host->registerDriver(dev, mouse_intf, this, &USBHostMouse::init);
int_in->attach(this, &USBHostMouse::rxHandler);
host->interruptRead(dev, int_in, report, int_in->getSize(), false);
dev_connected = true;
return true;
}
@ -82,33 +82,33 @@ bool USBHostMouse::connect() {
void USBHostMouse::rxHandler() {
int len_listen = int_in->getSize();
if (onUpdate) {
(*onUpdate)(report[0] & 0x07, report[1], report[2], report[3]);
}
if (onButtonUpdate && (buttons != (report[0] & 0x07))) {
(*onButtonUpdate)(report[0] & 0x07);
}
if (onXUpdate && (x != report[1])) {
(*onXUpdate)(report[1]);
}
if (onYUpdate && (y != report[2])) {
(*onYUpdate)(report[2]);
}
if (onZUpdate && (z != report[3])) {
(*onZUpdate)(report[3]);
}
// update mouse state
buttons = report[0] & 0x07;
x = report[1];
y = report[2];
z = report[3];
if (dev)
host->interruptRead(dev, int_in, report, len_listen, false);
}

View File

@ -23,7 +23,7 @@
#include "USBHost.h"
/**
/**
* A class to communicate a USB mouse
*/
class USBHostMouse : public IUSBEnumerator {
@ -58,7 +58,7 @@ public:
onUpdate = ptr;
}
}
/**
* Attach a callback called when the button state changes
*
@ -69,7 +69,7 @@ public:
onButtonUpdate = ptr;
}
}
/**
* Attach a callback called when the X axis value changes
*
@ -80,7 +80,7 @@ public:
onXUpdate = ptr;
}
}
/**
* Attach a callback called when the Y axis value changes
*
@ -91,7 +91,7 @@ public:
onYUpdate = ptr;
}
}
/**
* Attach a callback called when the Z axis value changes (scrolling)
*
@ -114,7 +114,7 @@ private:
USBDeviceConnected * dev;
USBEndpoint * int_in;
uint8_t report[4];
bool dev_connected;
bool mouse_device_found;
int mouse_intf;

View File

@ -64,7 +64,7 @@ void USBHostHub::init() {
hub_device_found = false;
nb_port = 0;
hub_characteristics = 0;
for (int i = 0; i < MAX_HUB_PORT; i++) {
device_children[i] = NULL;
}
@ -80,52 +80,52 @@ bool USBHostHub::connected()
}
bool USBHostHub::connect(USBDeviceConnected * dev)
{
{
if (dev_connected) {
return true;
}
if(host->enumerate(dev, this)) {
init();
return false;
}
if (hub_device_found) {
this->dev = dev;
int_in = dev->getEndpoint(hub_intf, INTERRUPT_ENDPOINT, IN);
if (!int_in) {
init();
return false;
}
USB_INFO("New HUB: VID:%04x PID:%04x [dev: %p - intf: %d]", dev->getVid(), dev->getPid(), dev, hub_intf);
dev->setName("Hub", hub_intf);
host->registerDriver(dev, hub_intf, this, &USBHostHub::disconnect);
int_in->attach(this, &USBHostHub::rxHandler);
// get HUB descriptor
host->controlRead( dev,
host->controlRead( dev,
USB_DEVICE_TO_HOST | USB_REQUEST_TYPE_CLASS,
GET_DESCRIPTOR,
0x29 << 8, 0, buf, sizeof(HubDescriptor));
nb_port = buf[2];
hub_characteristics = buf[3];
USB_DBG("Hub has %d port", nb_port);
for (uint8_t j = 1; j <= nb_port; j++) {
setPortFeature(PORT_POWER_FEATURE, j);
}
wait_ms(buf[5]*2);
host->interruptRead(dev, int_in, buf, 1, false);
dev_connected = true;
return true;
}
return false;
}
@ -184,7 +184,7 @@ void USBHostHub::rxHandler() {
for (int port = 1; port <= nb_port; port++) {
status = getPortStatus(port);
USB_DBG("[hub handler hub: %d] status port %d [hub: %p]: 0x%X", dev->getHub(), port, dev, status);
// if connection status has changed
if (status & C_PORT_CONNECTION) {
if (status & PORT_CONNECTION) {
@ -194,18 +194,18 @@ void USBHostHub::rxHandler() {
USB_DBG("[hub handler hub: %d - port: %d] device disconnected", dev->getHub(), port);
host->deviceDisconnected(dev->getHub() + 1, port, this, 0);
}
clearPortFeature(C_PORT_CONNECTION_FEATURE, port);
}
if (status & C_PORT_RESET) {
clearPortFeature(C_PORT_RESET_FEATURE, port);
}
if (status & C_PORT_ENABLE) {
clearPortFeature(C_PORT_ENABLE_FEATURE, port);
}
if ((status & PORT_OVER_CURRENT)) {
USB_ERR("OVER CURRENT DETECTED\r\n");
clearPortFeature(PORT_OVER_CURRENT, port);

View File

@ -28,7 +28,7 @@ class USBHost;
class USBDeviceConnected;
class USBEndpoint;
/**
/**
* A class to use a USB Hub
*/
class USBHostHub : public IUSBEnumerator {
@ -52,7 +52,7 @@ public:
* @return true if connection was successful
*/
bool connect(USBDeviceConnected * dev);
/**
* Automatically called by USBHost when a device
* has been enumerated by usb_thread
@ -60,7 +60,7 @@ public:
* @param dev device connected
*/
void deviceConnected(USBDeviceConnected * dev);
/**
* Automatically called by USBHost when a device
* has been disconnected from this hub
@ -68,21 +68,21 @@ public:
* @param dev device disconnected
*/
void deviceDisconnected(USBDeviceConnected * dev);
/**
* Rest a specific port
*
* @param port port number
*/
void portReset(uint8_t port);
/*
* Called by USBHost to set the instance of USBHost
*
* @param host host instance
*/
void setHost(USBHost * host);
/**
* Called by USBhost when a hub has been disconnected
*/
@ -114,7 +114,7 @@ private:
uint32_t getPortStatus(uint8_t port);
USBDeviceConnected * device_children[MAX_HUB_PORT];
void init();
void disconnect();

View File

@ -65,19 +65,19 @@ bool USBHostMSD::connect()
for (uint8_t i = 0; i < MAX_DEVICE_CONNECTED; i++) {
if ((dev = host->getDevice(i)) != NULL) {
USB_DBG("Trying to connect MSD device\r\n");
if(host->enumerate(dev, this))
break;
if (msd_device_found) {
bulk_in = dev->getEndpoint(msd_intf, BULK_ENDPOINT, IN);
bulk_out = dev->getEndpoint(msd_intf, BULK_ENDPOINT, OUT);
if (!bulk_in || !bulk_out)
continue;
USB_INFO("New MSD device: VID:%04x PID:%04x [dev: %p - intf: %d]", dev->getVid(), dev->getPid(), dev, msd_intf);
dev->setName("MSD", msd_intf);
host->registerDriver(dev, msd_intf, this, &USBHostMSD::init);
@ -219,7 +219,7 @@ int USBHostMSD::SCSITransfer(uint8_t * cmd, uint8_t cmd_len, int flags, uint8_t
if (data) {
USB_DBG("data stage");
if (flags == HOST_TO_DEVICE) {
res = host->bulkWrite(dev, bulk_out, data, transfer_len);
if (checkResult(res, bulk_out))
return -1;
@ -242,7 +242,7 @@ int USBHostMSD::SCSITransfer(uint8_t * cmd, uint8_t cmd_len, int flags, uint8_t
if (csw.Signature != CSW_SIGNATURE) {
return -1;
}
USB_DBG("recv csw: status: %d", csw.Status);
// ModeSense?
@ -250,27 +250,27 @@ int USBHostMSD::SCSITransfer(uint8_t * cmd, uint8_t cmd_len, int flags, uint8_t
USB_DBG("request mode sense");
return SCSIRequestSense();
}
// perform reset recovery
if ((csw.Status == 2) && (cmd[0] != 0x03)) {
// send Bulk-Only Mass Storage Reset request
res = host->controlWrite( dev,
USB_RECIPIENT_INTERFACE | USB_HOST_TO_DEVICE | USB_REQUEST_TYPE_CLASS,
BO_MASS_STORAGE_RESET,
0, msd_intf, NULL, 0);
// unstall both endpoints
res = host->controlWrite( dev,
USB_RECIPIENT_ENDPOINT | USB_HOST_TO_DEVICE | USB_REQUEST_TYPE_STANDARD,
CLEAR_FEATURE,
0, bulk_in->getAddress(), NULL, 0);
res = host->controlWrite( dev,
USB_RECIPIENT_ENDPOINT | USB_HOST_TO_DEVICE | USB_REQUEST_TYPE_STANDARD,
CLEAR_FEATURE,
0, bulk_out->getAddress(), NULL, 0);
}
return csw.Status;
@ -304,20 +304,20 @@ int USBHostMSD::getMaxLun() {
int USBHostMSD::disk_initialize() {
USB_DBG("FILESYSTEM: init");
U16 i, timeout = 10;
getMaxLun();
for (i = 0; i < timeout; i++) {
Thread::wait(100);
if (!testUnitReady())
break;
}
if (i == timeout) {
disk_init = false;
return -1;
}
inquiry(0, 0);
disk_init = 1;
return readCapacity();

View File

@ -24,7 +24,7 @@
#include "USBHost.h"
#include "FATFileSystem.h"
/**
/**
* A class to communicate a USB flash disk
*/
class USBHostMSD : public IUSBEnumerator, public FATFileSystem {
@ -109,7 +109,7 @@ private:
int msd_intf;
bool msd_device_found;
bool disk_init;
void init();
};

View File

@ -24,7 +24,7 @@
template<typename T, int size>
class MtxCircBuffer {
public:
MtxCircBuffer() {
write = 0;
read = 0;
@ -43,7 +43,7 @@ public:
mtx.unlock();
return r;
}
void flush() {
write = 0;
read = 0;

View File

@ -26,7 +26,7 @@
#if (USBHOST_SERIAL <= 1)
USBHostSerial::USBHostSerial()
USBHostSerial::USBHostSerial()
{
host = USBHost::getHostInst();
ports_found = 0;
@ -46,9 +46,9 @@ void USBHostSerial::disconnect(void)
bool USBHostSerial::connect() {
if (dev)
if (dev)
{
for (uint8_t i = 0; i < MAX_DEVICE_CONNECTED; i++)
for (uint8_t i = 0; i < MAX_DEVICE_CONNECTED; i++)
{
USBDeviceConnected* d = host->getDevice(i);
if (dev == d)
@ -56,15 +56,15 @@ bool USBHostSerial::connect() {
}
disconnect();
}
for (uint8_t i = 0; i < MAX_DEVICE_CONNECTED; i++)
for (uint8_t i = 0; i < MAX_DEVICE_CONNECTED; i++)
{
USBDeviceConnected* d = host->getDevice(i);
if (d != NULL) {
USB_DBG("Trying to connect serial device \r\n");
if(host->enumerate(d, this))
break;
USBEndpoint* bulk_in = d->getEndpoint(port_intf, BULK_ENDPOINT, IN);
USBEndpoint* bulk_out = d->getEndpoint(port_intf, BULK_ENDPOINT, OUT);
if (bulk_in && bulk_out)
@ -84,7 +84,7 @@ bool USBHostSerial::connect() {
/*virtual*/ bool USBHostSerial::parseInterface(uint8_t intf_nb, uint8_t intf_class, uint8_t intf_subclass, uint8_t intf_protocol) //Must return true if the interface should be parsed
{
if (!ports_found &&
if (!ports_found &&
CHECK_INTERFACE(intf_class, intf_subclass, intf_protocol)) {
port_intf = intf_nb;
ports_found = true;
@ -96,7 +96,7 @@ bool USBHostSerial::connect() {
/*virtual*/ bool USBHostSerial::useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir) //Must return true if the endpoint will be used
{
if (ports_found && (intf_nb == port_intf)) {
if (type == BULK_ENDPOINT)
if (type == BULK_ENDPOINT)
return true;
}
return false;
@ -106,7 +106,7 @@ bool USBHostSerial::connect() {
//------------------------------------------------------------------------------
USBHostMultiSerial::USBHostMultiSerial()
USBHostMultiSerial::USBHostMultiSerial()
{
host = USBHost::getHostInst();
dev = NULL;
@ -127,7 +127,7 @@ bool USBHostMultiSerial::connected()
void USBHostMultiSerial::disconnect(void)
{
for (int port = 0; port < USBHOST_SERIAL; port ++)
for (int port = 0; port < USBHOST_SERIAL; port ++)
{
if (ports[port])
{
@ -141,9 +141,9 @@ void USBHostMultiSerial::disconnect(void)
bool USBHostMultiSerial::connect() {
if (dev)
if (dev)
{
for (uint8_t i = 0; i < MAX_DEVICE_CONNECTED; i++)
for (uint8_t i = 0; i < MAX_DEVICE_CONNECTED; i++)
{
USBDeviceConnected* d = host->getDevice(i);
if (dev == d)
@ -151,16 +151,16 @@ bool USBHostMultiSerial::connect() {
}
disconnect();
}
for (uint8_t i = 0; i < MAX_DEVICE_CONNECTED; i++)
for (uint8_t i = 0; i < MAX_DEVICE_CONNECTED; i++)
{
USBDeviceConnected* d = host->getDevice(i);
if (d != NULL) {
USB_DBG("Trying to connect serial device \r\n");
if(host->enumerate(d, this))
break;
for (int port = 0; port < ports_found; port ++)
for (int port = 0; port < ports_found; port ++)
{
USBEndpoint* bulk_in = d->getEndpoint(port_intf[port], BULK_ENDPOINT, IN);
USBEndpoint* bulk_out = d->getEndpoint(port_intf[port], BULK_ENDPOINT, OUT);
@ -186,7 +186,7 @@ bool USBHostMultiSerial::connect() {
/*virtual*/ bool USBHostMultiSerial::parseInterface(uint8_t intf_nb, uint8_t intf_class, uint8_t intf_subclass, uint8_t intf_protocol) //Must return true if the interface should be parsed
{
if ((ports_found < USBHOST_SERIAL) &&
if ((ports_found < USBHOST_SERIAL) &&
CHECK_INTERFACE(intf_class, intf_subclass, intf_protocol)) {
port_intf[ports_found++] = intf_nb;
return true;
@ -197,7 +197,7 @@ bool USBHostMultiSerial::connect() {
/*virtual*/ bool USBHostMultiSerial::useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir) //Must return true if the endpoint will be used
{
if ((ports_found > 0) && (intf_nb == port_intf[ports_found-1])) {
if (type == BULK_ENDPOINT)
if (type == BULK_ENDPOINT)
return true;
}
return false;
@ -209,7 +209,7 @@ bool USBHostMultiSerial::connect() {
#define SET_LINE_CODING 0x20
USBHostSerialPort::USBHostSerialPort(): circ_buf()
USBHostSerialPort::USBHostSerialPort(): circ_buf()
{
init();
}
@ -230,7 +230,7 @@ void USBHostSerialPort::init(void)
circ_buf.flush();
}
void USBHostSerialPort::connect(USBHost* _host, USBDeviceConnected * _dev,
void USBHostSerialPort::connect(USBHost* _host, USBDeviceConnected * _dev,
uint8_t _serial_intf, USBEndpoint* _bulk_in, USBEndpoint* _bulk_out)
{
host = _host;
@ -238,7 +238,7 @@ void USBHostSerialPort::connect(USBHost* _host, USBDeviceConnected * _dev,
serial_intf = _serial_intf;
bulk_in = _bulk_in;
bulk_out = _bulk_out;
USB_INFO("New Serial device: VID:%04x PID:%04x [dev: %p - intf: %d]", dev->getVid(), dev->getPid(), dev, serial_intf);
dev->setName("Serial", serial_intf);
host->registerDriver(dev, serial_intf, this, &USBHostSerialPort::init);
@ -289,7 +289,7 @@ void USBHostSerialPort::format(int bits, Parity parity, int stop_bits) {
line_coding.data_bits = bits;
line_coding.parity = parity;
line_coding.stop_bits = (stop_bits == 1) ? 0 : 2;
// set line coding
host->controlWrite( dev,
USB_RECIPIENT_INTERFACE | USB_HOST_TO_DEVICE | USB_REQUEST_TYPE_CLASS,
@ -311,12 +311,12 @@ int USBHostSerialPort::_getc() {
int USBHostSerialPort::writeBuf(const char* b, int s)
{
int c = 0;
if (bulk_out)
if (bulk_out)
{
while (c < s)
{
int i = (s < size_bulk_out) ? s : size_bulk_out;
if (host->bulkWrite(dev, bulk_out, (uint8_t *)(b+c), i) == USB_TYPE_OK)
if (host->bulkWrite(dev, bulk_out, (uint8_t *)(b+c), i) == USB_TYPE_OK)
c += i;
}
}
@ -326,7 +326,7 @@ int USBHostSerialPort::writeBuf(const char* b, int s)
int USBHostSerialPort::readBuf(char* b, int s)
{
int i = 0;
if (bulk_in)
if (bulk_in)
{
for (i = 0; i < s; )
b[i++] = getc();

View File

@ -25,7 +25,7 @@
#include "Stream.h"
#include "MtxCircBuffer.h"
/**
/**
* A class to communicate a USB virtual serial port
*/
class USBHostSerialPort : public Stream {
@ -39,7 +39,7 @@ public:
RxIrq,
TxIrq
};
enum Parity {
None = 0,
Odd,
@ -48,7 +48,7 @@ public:
Space
};
void connect(USBHost* _host, USBDeviceConnected * _dev,
void connect(USBHost* _host, USBDeviceConnected * _dev,
uint8_t _serial_intf, USBEndpoint* _bulk_in, USBEndpoint* _bulk_out);
/**
@ -56,7 +56,7 @@ public:
*
* @returns the number of bytes available
*/
uint8_t available();
uint8_t available();
/**
* Attach a member function to call when a packet is received.
@ -90,13 +90,13 @@ public:
}
}
}
/** Set the baud rate of the serial port
*
* @param baudrate The baudrate of the serial port (default = 9600).
*/
void baud(int baudrate = 9600);
/** Set the transmission format used by the Serial port
*
* @param bits The number of bits in a word (default = 8)
@ -110,7 +110,7 @@ public:
protected:
virtual int _getc();
virtual int _putc(int c);
private:
USBHost * host;
USBDeviceConnected * dev;
@ -132,7 +132,7 @@ private:
uint8_t parity;
uint8_t data_bits;
} PACKED LINE_CODING;
LINE_CODING line_coding;
void rxHandler();
@ -145,18 +145,18 @@ private:
#if (USBHOST_SERIAL <= 1)
class USBHostSerial : public IUSBEnumerator, public USBHostSerialPort
class USBHostSerial : public IUSBEnumerator, public USBHostSerialPort
{
public:
public:
USBHostSerial();
/**
* Try to connect a serial device
*
* @return true if connection was successful
*/
bool connect();
void disconnect();
/**
@ -165,7 +165,7 @@ public:
* @returns true if a serial device is connected
*/
bool connected();
protected:
USBHost* host;
USBDeviceConnected* dev;
@ -176,7 +176,7 @@ protected:
virtual void setVidPid(uint16_t vid, uint16_t pid);
virtual bool parseInterface(uint8_t intf_nb, uint8_t intf_class, uint8_t intf_subclass, uint8_t intf_protocol); //Must return true if the interface should be parsed
virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir); //Must return true if the endpoint will be used
private:
bool dev_connected;
};
@ -184,13 +184,13 @@ private:
#else // (USBHOST_SERIAL > 1)
class USBHostMultiSerial : public IUSBEnumerator {
public:
public:
USBHostMultiSerial();
virtual ~USBHostMultiSerial();
USBHostSerialPort* getPort(int port)
{
return port < USBHOST_SERIAL ? ports[port] : NULL;
USBHostSerialPort* getPort(int port)
{
return port < USBHOST_SERIAL ? ports[port] : NULL;
}
/**
@ -199,7 +199,7 @@ public:
* @return true if connection was successful
*/
bool connect();
void disconnect();
/**
@ -208,7 +208,7 @@ public:
* @returns true if a serial device is connected
*/
bool connected();
protected:
USBHost* host;
USBDeviceConnected* dev;
@ -220,7 +220,7 @@ protected:
virtual void setVidPid(uint16_t vid, uint16_t pid);
virtual bool parseInterface(uint8_t intf_nb, uint8_t intf_class, uint8_t intf_subclass, uint8_t intf_protocol); //Must return true if the interface should be parsed
virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir); //Must return true if the endpoint will be used
private:
bool dev_connected;
};

View File

@ -14,7 +14,7 @@ using namespace mbed;
DSTATUS disk_initialize (
BYTE drv /* Physical drive nmuber (0..) */
)
)
{
debug_if(FFS_DBG, "disk_initialize on drv [%d]\n", drv);
return (DSTATUS)FATFileSystem::_ffs[drv]->disk_initialize();
@ -22,7 +22,7 @@ DSTATUS disk_initialize (
DSTATUS disk_status (
BYTE drv /* Physical drive nmuber (0..) */
)
)
{
debug_if(FFS_DBG, "disk_status on drv [%d]\n", drv);
return (DSTATUS)FATFileSystem::_ffs[drv]->disk_status();

View File

@ -38,13 +38,13 @@ int FATFileHandle::close() {
ssize_t FATFileHandle::write(const void* buffer, size_t length) {
UINT n;
FRESULT res = f_write(&_fh, buffer, length, &n);
if (res) {
if (res) {
debug_if(FFS_DBG, "f_write() failed: %d", res);
return -1;
}
return n;
}
ssize_t FATFileHandle::read(void* buffer, size_t length) {
debug_if(FFS_DBG, "read(%d)\n", length);
UINT n;

View File

@ -69,7 +69,7 @@ FileHandle *FATFileSystem::open(const char* name, int flags) {
debug_if(FFS_DBG, "open(%s) on filesystem [%s], drv [%d]\n", name, _name, _fsid);
char n[64];
sprintf(n, "%d:/%s", _fsid, name);
/* POSIX flags -> FatFS open mode */
BYTE openmode;
if (flags & O_RDWR) {
@ -86,10 +86,10 @@ FileHandle *FATFileSystem::open(const char* name, int flags) {
openmode |= FA_OPEN_ALWAYS;
}
}
FIL fh;
FRESULT res = f_open(&fh, n, openmode);
if (res) {
if (res) {
debug_if(FFS_DBG, "f_open('w') failed: %d\n", res);
return NULL;
}
@ -98,10 +98,10 @@ FileHandle *FATFileSystem::open(const char* name, int flags) {
}
return new FATFileHandle(fh);
}
int FATFileSystem::remove(const char *filename) {
FRESULT res = f_unlink(filename);
if (res) {
if (res) {
debug_if(FFS_DBG, "f_unlink() failed: %d\n", res);
return -1;
}

View File

@ -153,13 +153,13 @@ int SDFileSystem::initialise_card() {
for (int i = 0; i < 16; i++) {
_spi.write(0xFF);
}
// send CMD0, should return with all zeros except IDLE STATE set (bit 0)
if (_cmd(0, 0) != R1_IDLE_STATE) {
debug("No disk, or could not put SD card in to SPI idle state\n");
return SDCARD_FAIL;
}
// send CMD8 to determine whther it is ver 2.x
int r = _cmd8();
if (r == R1_IDLE_STATE) {
@ -181,7 +181,7 @@ int SDFileSystem::initialise_card_v1() {
return SDCARD_V1;
}
}
debug("Timeout waiting for v1.x card\n");
return SDCARD_FAIL;
}
@ -198,7 +198,7 @@ int SDFileSystem::initialise_card_v2() {
return SDCARD_V2;
}
}
debug("Timeout waiting for v2.x card\n");
return SDCARD_FAIL;
}
@ -211,7 +211,7 @@ int SDFileSystem::disk_initialize() {
}
debug_if(SD_DBG, "init card = %d\n", _is_initialized);
_sectors = _sd_sectors();
// Set block length to 512 (CMD16)
if (_cmd(16, 512) != 0) {
debug("Set 512-byte block timed out\n");
@ -232,7 +232,7 @@ int SDFileSystem::disk_write(const uint8_t *buffer, uint64_t block_number) {
if (_cmd(24, block_number * cdv) != 0) {
return 1;
}
// send the data block
_write(buffer, 512);
return 0;
@ -247,7 +247,7 @@ int SDFileSystem::disk_read(uint8_t *buffer, uint64_t block_number) {
if (_cmd(17, block_number * cdv) != 0) {
return 1;
}
// receive the data
_read(buffer, 512);
return 0;
@ -269,7 +269,7 @@ uint64_t SDFileSystem::disk_sectors() { return _sectors; }
// PRIVATE FUNCTIONS
int SDFileSystem::_cmd(int cmd, int arg) {
_cs = 0;
// send a command
_spi.write(0x40 | cmd);
_spi.write(arg >> 24);
@ -277,7 +277,7 @@ int SDFileSystem::_cmd(int cmd, int arg) {
_spi.write(arg >> 8);
_spi.write(arg >> 0);
_spi.write(0x95);
// wait for the repsonse (response[7] == 0)
for (int i = 0; i < SD_COMMAND_TIMEOUT; i++) {
int response = _spi.write(0xFF);
@ -293,7 +293,7 @@ int SDFileSystem::_cmd(int cmd, int arg) {
}
int SDFileSystem::_cmdx(int cmd, int arg) {
_cs = 0;
// send a command
_spi.write(0x40 | cmd);
_spi.write(arg >> 24);
@ -301,7 +301,7 @@ int SDFileSystem::_cmdx(int cmd, int arg) {
_spi.write(arg >> 8);
_spi.write(arg >> 0);
_spi.write(0x95);
// wait for the repsonse (response[7] == 0)
for (int i = 0; i < SD_COMMAND_TIMEOUT; i++) {
int response = _spi.write(0xFF);
@ -318,7 +318,7 @@ int SDFileSystem::_cmdx(int cmd, int arg) {
int SDFileSystem::_cmd58() {
_cs = 0;
int arg = 0;
// send a command
_spi.write(0x40 | 58);
_spi.write(arg >> 24);
@ -326,7 +326,7 @@ int SDFileSystem::_cmd58() {
_spi.write(arg >> 8);
_spi.write(arg >> 0);
_spi.write(0x95);
// wait for the repsonse (response[7] == 0)
for (int i = 0; i < SD_COMMAND_TIMEOUT; i++) {
int response = _spi.write(0xFF);
@ -347,7 +347,7 @@ int SDFileSystem::_cmd58() {
int SDFileSystem::_cmd8() {
_cs = 0;
// send a command
_spi.write(0x40 | 8); // CMD8
_spi.write(0x00); // reserved
@ -355,7 +355,7 @@ int SDFileSystem::_cmd8() {
_spi.write(0x01); // 3.3v
_spi.write(0xAA); // check pattern
_spi.write(0x87); // crc
// wait for the repsonse (response[7] == 0)
for (int i = 0; i < SD_COMMAND_TIMEOUT * 1000; i++) {
char response[5];
@ -376,17 +376,17 @@ int SDFileSystem::_cmd8() {
int SDFileSystem::_read(uint8_t *buffer, uint32_t length) {
_cs = 0;
// read until start byte (0xFF)
while (_spi.write(0xFF) != 0xFE);
// read data
for (uint32_t i = 0; i < length; i++) {
buffer[i] = _spi.write(0xFF);
}
_spi.write(0xFF); // checksum
_spi.write(0xFF);
_cs = 1;
_spi.write(0xFF);
return 0;
@ -394,29 +394,29 @@ int SDFileSystem::_read(uint8_t *buffer, uint32_t length) {
int SDFileSystem::_write(const uint8_t*buffer, uint32_t length) {
_cs = 0;
// indicate start of block
_spi.write(0xFE);
// write the data
for (uint32_t i = 0; i < length; i++) {
_spi.write(buffer[i]);
}
// write the checksum
_spi.write(0xFF);
_spi.write(0xFF);
// check the response token
if ((_spi.write(0xFF) & 0x1F) != 0x05) {
_cs = 1;
_spi.write(0xFF);
return 1;
}
// wait for write to finish
while (_spi.write(0xFF) == 0);
_cs = 1;
_spi.write(0xFF);
return 0;
@ -440,33 +440,33 @@ uint64_t SDFileSystem::_sd_sectors() {
uint32_t block_len, mult, blocknr, capacity;
uint32_t hc_c_size;
uint64_t blocks;
// CMD9, Response R2 (R1 byte + 16-byte block read)
if (_cmdx(9, 0) != 0) {
debug("Didn't get a response from the disk\n");
return 0;
}
uint8_t csd[16];
if (_read(csd, 16) != 0) {
debug("Couldn't read csd response from disk\n");
return 0;
}
// csd_structure : csd[127:126]
// c_size : csd[73:62]
// c_size_mult : csd[49:47]
// read_bl_len : csd[83:80] - the *maximum* read block length
int csd_structure = ext_bits(csd, 127, 126);
switch (csd_structure) {
case 0:
cdv = 512;
c_size = ext_bits(csd, 73, 62);
c_size_mult = ext_bits(csd, 49, 47);
read_bl_len = ext_bits(csd, 83, 80);
block_len = 1 << read_bl_len;
mult = 1 << (c_size_mult + 2);
blocknr = (c_size + 1) * mult;
@ -474,14 +474,14 @@ uint64_t SDFileSystem::_sd_sectors() {
blocks = capacity / 512;
debug_if(SD_DBG, "\n\rSDCard\n\rc_size: %d \n\rcapacity: %ld \n\rsectors: %lld\n\r", c_size, capacity, blocks);
break;
case 1:
cdv = 1;
hc_c_size = ext_bits(csd, 63, 48);
blocks = (hc_c_size+1)*1024;
debug_if(SD_DBG, "\n\rSDHC Card \n\rhc_c_size: %d\n\rcapacity: %lld \n\rsectors: %lld\n\r", hc_c_size, blocks*512, blocks);
break;
default:
debug("CSD struct unsupported\r\n");
return 0;

View File

@ -33,7 +33,7 @@
* #include "SDFileSystem.h"
*
* SDFileSystem sd(p5, p6, p7, p12, "sd"); // mosi, miso, sclk, cs
*
*
* int main() {
* FILE *fp = fopen("/sd/myfile.txt", "w");
* fprintf(fp, "Hello World!\n");
@ -68,7 +68,7 @@ protected:
int initialise_card();
int initialise_card_v1();
int initialise_card_v2();
int _read(uint8_t * buffer, uint32_t length);
int _write(const uint8_t *buffer, uint32_t length);
uint64_t _sd_sectors();

View File

@ -13,19 +13,19 @@ namespace mbed {
* @code
* #include "InterruptManager.h"
* #include "mbed.h"
*
*
* Ticker flipper;
* DigitalOut led1(LED1);
* DigitalOut led2(LED2);
*
*
* void flip(void) {
* led1 = !led1;
* }
*
*
* void handler(void) {
* led2 = !led1;
* }
*
*
* int main() {
* led1 = led2 = 0;
* flipper.attach(&flip, 1.0);
@ -42,7 +42,7 @@ public:
/** Destroy the current instance of the interrupt manager
*/
static void destroy();
/** Add a handler for an interrupt at the end of the handler list
*
* @param function the handler to add

View File

@ -58,7 +58,7 @@ pFunctionPointer_t InterruptManager::add_common(void (*function)(void), IRQn_Typ
bool InterruptManager::remove_handler(pFunctionPointer_t handler, IRQn_Type irq) {
int irq_pos = get_irq_index(irq);
if (NULL == _chains[irq_pos])
return false;
if (!_chains[irq_pos]->remove(handler))

View File

@ -30,7 +30,7 @@ WEAK void mbed_die(void) {
gpio_t led_3; gpio_init_out(&led_3, LED3);
gpio_t led_4; gpio_init_out(&led_4, LED4);
#endif
while (1) {
#if (DEVICE_ERROR_RED == 1)
gpio_write(&led_red, 1);
@ -41,7 +41,7 @@ WEAK void mbed_die(void) {
gpio_write(&led_3, 0);
gpio_write(&led_4, 1);
#endif
wait_ms(150);
#if (DEVICE_ERROR_RED == 1)
@ -53,7 +53,7 @@ WEAK void mbed_die(void) {
gpio_write(&led_3, 1);
gpio_write(&led_4, 0);
#endif
wait_ms(150);
}
}

View File

@ -17,13 +17,13 @@
static inline void _gpio_init_in(gpio_t* gpio, PinName pin, PinMode mode)
{
gpio_init(gpio, pin);
if (pin != NC) {
gpio_init(gpio, pin);
if (pin != NC) {
gpio_dir(gpio, PIN_INPUT);
gpio_mode(gpio, mode);
}
}
static inline void _gpio_init_out(gpio_t* gpio, PinName pin, PinMode mode, int value)
{
gpio_init(gpio, pin);

View File

@ -88,7 +88,7 @@ WEAK void mbed_mac_address(char *mac) {
#if DEVICE_SEMIHOST
char uid[DEVICE_ID_LENGTH + 1];
int i;
// if we have a UID, extract the MAC
if (mbed_interface_uid(uid) == 0) {
char *p = uid;

View File

@ -22,7 +22,7 @@ void pinmap_pinout(PinName pin, const PinMap *map) {
while (map->pin != NC) {
if (map->pin == pin) {
pin_function(pin, map->function);
pin_mode(pin, PullNone);
return;
}

View File

@ -126,7 +126,7 @@ extern "C" FILEHANDLE PREFIX(_open)(const char* name, int openmode) {
// This is the workaround that the microlib author suggested us
static int n = 0;
if (!std::strcmp(name, ":tt")) return n++;
#else
/* Use the posix convention that stdin,out,err are filehandles 0,1,2.
*/
@ -141,7 +141,7 @@ extern "C" FILEHANDLE PREFIX(_open)(const char* name, int openmode) {
return 2;
}
#endif
// find the first empty slot in filehandles
unsigned int fh_i;
for (fh_i = 0; fh_i < sizeof(filehandles)/sizeof(*filehandles); fh_i++) {
@ -466,7 +466,7 @@ extern "C" caddr_t _sbrk(int incr) {
errno = ENOMEM;
return (caddr_t)-1;
}
heap = new_heap;
return (caddr_t) prev_heap;
}

View File

@ -21,7 +21,7 @@
#ifdef __cplusplus
extern "C" {
#endif
#endif
#if defined (__ICCARM__)
time_t __time32(time_t *timer)
#else
@ -60,4 +60,4 @@ clock_t clock() {
#ifdef __cplusplus
}
#endif
#endif

View File

@ -22,13 +22,13 @@ static ticker_event_t *head = NULL;
void us_ticker_set_handler(ticker_event_handler handler) {
us_ticker_init();
event_handler = handler;
}
void us_ticker_irq_handler(void) {
us_ticker_clear_interrupt();
/* Go through all the pending TimerEvents */
while (1) {
if (head == NULL) {
@ -36,7 +36,7 @@ void us_ticker_irq_handler(void) {
us_ticker_disable_interrupt();
return;
}
if ((int)(head->timestamp - us_ticker_read()) <= 0) {
// This event was in the past:
// point to the following one and execute its handler
@ -57,11 +57,11 @@ void us_ticker_irq_handler(void) {
void us_ticker_insert_event(ticker_event_t *obj, unsigned int timestamp, uint32_t id) {
/* disable interrupts for the duration of the function */
__disable_irq();
// initialise our data
obj->timestamp = timestamp;
obj->id = id;
/* Go through the list until we either reach the end, or find
an element this should come before (which is possibly the
head). */
@ -84,13 +84,13 @@ void us_ticker_insert_event(ticker_event_t *obj, unsigned int timestamp, uint32_
}
/* if we're at the end p will be NULL, which is correct */
obj->next = p;
__enable_irq();
}
void us_ticker_remove_event(ticker_event_t *obj) {
__disable_irq();
// remove this object from the list
if (head == obj) {
// first in the list, so just drop me
@ -109,6 +109,6 @@ void us_ticker_remove_event(ticker_event_t *obj) {
p = p->next;
}
}
__enable_irq();
}

View File

@ -42,17 +42,17 @@ public:
#ifdef CMSIS_OS_RTX
memset(_mail_q, 0, sizeof(_mail_q));
_mail_p[0] = _mail_q;
memset(_mail_m, 0, sizeof(_mail_m));
_mail_p[1] = _mail_m;
_mail_def.pool = _mail_p;
_mail_def.queue_sz = queue_sz;
_mail_def.item_sz = sizeof(T);
#endif
_mail_id = osMailCreate(&_mail_def, NULL);
}
/** Allocate a memory block of type T
@param millisec timeout value or 0 in case of no time-out. (default: 0).
@return pointer to memory block that can be filled with mail or NULL in case error.
@ -60,23 +60,23 @@ public:
T* alloc(uint32_t millisec=0) {
return (T*)osMailAlloc(_mail_id, millisec);
}
/** Allocate a memory block of type T and set memory block to zero.
/** Allocate a memory block of type T and set memory block to zero.
@param millisec timeout value or 0 in case of no time-out. (default: 0).
@return pointer to memory block that can be filled with mail or NULL in case error.
*/
T* calloc(uint32_t millisec=0) {
return (T*)osMailCAlloc(_mail_id, millisec);
}
/** Put a mail in the queue.
@param mptr memory block previously allocated with Mail::alloc or Mail::calloc.
@return status code that indicates the execution status of the function.
@return status code that indicates the execution status of the function.
*/
osStatus put(T *mptr) {
return osMailPut(_mail_id, (void*)mptr);
}
/** Get a mail from a queue.
@param millisec timeout value or 0 in case of no time-out. (default: osWaitForever).
@return event that contains mail information or error code.
@ -84,9 +84,9 @@ public:
osEvent get(uint32_t millisec=osWaitForever) {
return osMailGet(_mail_id, millisec);
}
/** Free a memory block from a mail.
@param mptr pointer to the memory block that was obtained with Mail::get.
@param mptr pointer to the memory block that was obtained with Mail::get.
@return status code that indicates the execution status of the function.
*/
osStatus free(T *mptr) {

View File

@ -41,30 +41,30 @@ public:
#ifdef CMSIS_OS_RTX
memset(_pool_m, 0, sizeof(_pool_m));
_pool_def.pool = _pool_m;
_pool_def.pool_sz = pool_sz;
_pool_def.item_sz = sizeof(T);
#endif
_pool_id = osPoolCreate(&_pool_def);
}
/** Allocate a memory block of type T from a memory pool.
@return address of the allocated memory block or NULL in case of no memory available.
*/
T* alloc(void) {
return (T*)osPoolAlloc(_pool_id);
}
/** Allocate a memory block of type T from a memory pool and set memory block to zero.
@return address of the allocated memory block or NULL in case of no memory available.
@return address of the allocated memory block or NULL in case of no memory available.
*/
T* calloc(void) {
return (T*)osPoolCAlloc(_pool_id);
}
/** Return an allocated memory block back to a specific memory pool.
@param address of the allocated memory block that is returned to the memory pool.
@return status code that indicates the execution status of the function.
@return status code that indicates the execution status of the function.
*/
osStatus free(T *block) {
return osPoolFree(_pool_id, (void*)block);

View File

@ -34,23 +34,23 @@ class Mutex {
public:
/** Create and Initialize a Mutex object */
Mutex();
/** Wait until a Mutex becomes available.
@param millisec timeout value or 0 in case of no time-out. (default: osWaitForever)
@return status code that indicates the execution status of the function.
*/
*/
osStatus lock(uint32_t millisec=osWaitForever);
/** Try to lock the mutex, and return immediately
@return true if the mutex was acquired, false otherwise.
*/
bool trylock();
/** Unlock the mutex that has previously been locked by the same thread
@return status code that indicates the execution status of the function.
@return status code that indicates the execution status of the function.
*/
osStatus unlock();
~Mutex();
private:

View File

@ -51,16 +51,16 @@ public:
error("Error initialising the queue object\n");
}
}
/** Put a message in a Queue.
@param data message pointer.
@param millisec timeout value or 0 in case of no time-out. (default: 0)
@return status code that indicates the execution status of the function.
@return status code that indicates the execution status of the function.
*/
osStatus put(T* data, uint32_t millisec=0) {
return osMessagePut(_queue_id, (uint32_t)data, millisec);
}
/** Get a message or Wait for a message from a Queue.
@param millisec timeout value or 0 in case of no time-out. (default: osWaitForever).
@return event information that includes the message and the status code.

View File

@ -31,7 +31,7 @@ namespace rtos {
RtosTimer::RtosTimer(void (*periodic_task)(void const *argument), os_timer_type type, void *argument) {
#ifdef CMSIS_OS_RTX
_timer.ptimer = periodic_task;
memset(_timer_data, 0, sizeof(_timer_data));
_timer.timer = _timer_data;
#endif

View File

@ -32,7 +32,7 @@ namespace rtos {
periodic timers are possible. A timer can be started, restarted, or stopped.
Timers are handled in the thread osTimerThread.
Callback functions run under control of this thread and may use CMSIS-RTOS API calls.
Callback functions run under control of this thread and may use CMSIS-RTOS API calls.
*/
class RtosTimer {
public:
@ -44,18 +44,18 @@ public:
RtosTimer(void (*task)(void const *argument),
os_timer_type type=osTimerPeriodic,
void *argument=NULL);
/** Stop the timer.
@return status code that indicates the execution status of the function.
@return status code that indicates the execution status of the function.
*/
osStatus stop(void);
/** start a timer.
@param millisec time delay value of the timer.
@return status code that indicates the execution status of the function.
@return status code that indicates the execution status of the function.
*/
osStatus start(uint32_t millisec);
~RtosTimer();
private:

View File

@ -30,22 +30,22 @@ namespace rtos {
/** The Semaphore class is used to manage and protect access to a set of shared resources. */
class Semaphore {
public:
/** Create and Initialize a Semaphore object used for managing resources.
/** Create and Initialize a Semaphore object used for managing resources.
@param number of available resources; maximum index value is (count-1).
*/
Semaphore(int32_t count);
/** Wait until a Semaphore resource becomes available.
/** Wait until a Semaphore resource becomes available.
@param millisec timeout value or 0 in case of no time-out. (default: osWaitForever).
@return number of available tokens, or -1 in case of incorrect parameters
*/
int32_t wait(uint32_t millisec=osWaitForever);
/** Release a Semaphore resource that was obtain with Semaphore::wait.
@return status code that indicates the execution status of the function.
@return status code that indicates the execution status of the function.
*/
osStatus release(void);
~Semaphore();
private:

View File

@ -41,29 +41,29 @@ public:
osPriority priority=osPriorityNormal,
uint32_t stack_size=DEFAULT_STACK_SIZE,
unsigned char *stack_pointer=NULL);
/** Terminate execution of a thread and remove it from Active Threads
@return status code that indicates the execution status of the function.
*/
osStatus terminate();
/** Set priority of an active thread
@param priority new priority value for the thread function.
@return status code that indicates the execution status of the function.
*/
osStatus set_priority(osPriority priority);
/** Get priority of an active thread
@return current priority value of the thread function.
*/
osPriority get_priority();
/** Set the specified Signal Flags of an active thread.
@param signals specifies the signal flags of the thread that should be set.
@return previous signal flags of the specified thread or 0x80000000 in case of incorrect parameters.
*/
int32_t signal_set(int32_t signals);
/** State of the Thread */
enum State {
Inactive, /**< Not created or terminated */
@ -77,35 +77,35 @@ public:
WaitingMailbox, /**< Waiting for a mailbox event to occur */
WaitingMutex, /**< Waiting for a mutex event to occur */
};
/** State of this Thread
@return the State of this Thread
*/
State get_state();
/** Wait for one or more Signal Flags to become signaled for the current RUNNING thread.
/** Wait for one or more Signal Flags to become signaled for the current RUNNING thread.
@param signals wait until all specified signal flags set or 0 for any single signal flag.
@param millisec timeout value or 0 in case of no time-out. (default: osWaitForever).
@return event flag information or error code.
*/
static osEvent signal_wait(int32_t signals, uint32_t millisec=osWaitForever);
/** Wait for a specified time period in millisec:
@param millisec time delay value
@return status code that indicates the execution status of the function.
@return status code that indicates the execution status of the function.
*/
static osStatus wait(uint32_t millisec);
/** Pass control to next thread that is in state READY.
@return status code that indicates the execution status of the function.
*/
static osStatus yield();
/** Get the thread id of the current running thread.
@return thread ID for reference by other functions or NULL in case of error.
*/
static osThreadId gettid();
virtual ~Thread();
private:

View File

@ -15,19 +15,19 @@
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* - Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*---------------------------------------------------------------------------*/
@ -58,7 +58,7 @@ void rt_init_stack (P_TCB p_TCB, FUNCP task_body) {
/* Prepare a complete interrupt frame for first task start */
size = p_TCB->priv_stack >> 2;
/* Write to the top of stack. */
stk = &p_TCB->stack[size];
@ -135,7 +135,7 @@ void rt_ret_val2(P_TCB p_TCB, U32 v0, U32 v1) {
#ifdef DBG_MSG
void dbg_init (void) {
if ((DEMCR & DEMCR_TRCENA) &&
if ((DEMCR & DEMCR_TRCENA) &&
(ITM_CONTROL & ITM_ITMENA) &&
(ITM_ENABLE & (1UL << 31))) {
dbg_msg = __TRUE;

View File

@ -152,7 +152,7 @@ osMessageQId osMessageQId_osTimerMessageQ;
static uint32_t nr_mutex;
/*--------------------------- _mutex_initialize -----------------------------*/
int _mutex_initialize (OS_ID *mutex) {
/* Allocate and initialize a system mutex. */
@ -263,7 +263,7 @@ extern unsigned char __end__[];
void set_main_stack(void) {
// That is the bottom of the main stack block: no collision detection
os_thread_def_main.stack_pointer = HEAP_START;
// Leave OS_SCHEDULERSTKSIZE words for the scheduler and interrupts
os_thread_def_main.stacksize = (INITIAL_SP - (unsigned int)HEAP_START) - (OS_SCHEDULERSTKSIZE * 4);
}
@ -282,7 +282,7 @@ void _main_init (void) {
/* The single memory model is checking for stack collision at run time, verifing
that the heap pointer is underneath the stack pointer.
With the RTOS there is not only one stack above the heap, there are multiple
stacks and some of them are underneath the heap pointer.
*/
@ -403,7 +403,7 @@ extern void exit(int arg);
__noreturn __stackless void __cmain(void) {
int a;
if (__low_level_init() != 0) {
__iar_data_init3();
}

View File

@ -15,19 +15,19 @@
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* - Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*---------------------------------------------------------------------------*/

View File

@ -15,19 +15,19 @@
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* - Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*---------------------------------------------------------------------------*/
@ -93,8 +93,8 @@
#define OS_STKCHECK 1
#endif
// <o>Processor mode for thread execution
// <0=> Unprivileged mode
// <o>Processor mode for thread execution
// <0=> Unprivileged mode
// <1=> Privileged mode
// <i> Default: Privileged mode
#ifndef OS_RUNPRIV
@ -211,7 +211,7 @@
// Standard library system mutexes
// ===============================
// Define max. number system mutexes that are used to protect
// Define max. number system mutexes that are used to protect
// the arm standard runtime library. For microlib they are not used.
#ifndef OS_MUTEXCNT
#define OS_MUTEXCNT 12
@ -230,7 +230,7 @@
void os_idle_demon (void) {
/* The idle demon is a system thread, running when no other thread is */
/* ready to run. */
/* Sleep: ideally, we should put the chip to sleep.
Unfortunately, this usually requires disconnecting the interface chip (debugger).
This can be done, but it would break the local file system.

View File

@ -15,19 +15,19 @@
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* - Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*---------------------------------------------------------------------------*/
@ -145,7 +145,7 @@ __asm void SVC_Handler (void) {
LDMIA R0,{R0-R3,R4} ; Read R0-R3,R12 from stack
MOV R12,R4
MOV R4,LR
BLX R12 ; Call SVC Function
BLX R12 ; Call SVC Function
MRS R3,PSP ; Read PSP
STMIA R3!,{R0-R2} ; Store return values
@ -161,14 +161,14 @@ __asm void SVC_Handler (void) {
MRS R0,PSP ; Read PSP
SUBS R0,R0,#32 ; Adjust Start Address
STR R0,[R1,#TCB_TSTACK] ; Update os_tsk.run->tsk_stack
STR R0,[R1,#TCB_TSTACK] ; Update os_tsk.run->tsk_stack
STMIA R0!,{R4-R7} ; Save old context (R4-R7)
MOV R4,R8
MOV R5,R9
MOV R6,R10
MOV R7,R11
STMIA R0!,{R4-R7} ; Save old context (R8-R11)
PUSH {R2,R3}
BL rt_stk_check ; Check for Stack overflow
POP {R2,R3}
@ -243,7 +243,7 @@ Sys_Switch
MOV R6,R10
MOV R7,R11
STMIA R0!,{R4-R7} ; Save old context (R8-R11)
PUSH {R2,R3}
BL rt_stk_check ; Check for Stack overflow
POP {R2,R3}

View File

@ -15,19 +15,19 @@
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* - Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*---------------------------------------------------------------------------*/
@ -145,7 +145,7 @@ __asm void SVC_Handler (void) {
LDMIA R0,{R0-R3,R4} ; Read R0-R3,R12 from stack
MOV R12,R4
MOV R4,LR
BLX R12 ; Call SVC Function
BLX R12 ; Call SVC Function
MRS R3,PSP ; Read PSP
STMIA R3!,{R0-R2} ; Store return values
@ -161,14 +161,14 @@ __asm void SVC_Handler (void) {
MRS R0,PSP ; Read PSP
SUBS R0,R0,#32 ; Adjust Start Address
STR R0,[R1,#TCB_TSTACK] ; Update os_tsk.run->tsk_stack
STR R0,[R1,#TCB_TSTACK] ; Update os_tsk.run->tsk_stack
STMIA R0!,{R4-R7} ; Save old context (R4-R7)
MOV R4,R8
MOV R5,R9
MOV R6,R10
MOV R7,R11
STMIA R0!,{R4-R7} ; Save old context (R8-R11)
PUSH {R2,R3}
BL rt_stk_check ; Check for Stack overflow
POP {R2,R3}
@ -243,7 +243,7 @@ Sys_Switch
MOV R6,R10
MOV R7,R11
STMIA R0!,{R4-R7} ; Save old context (R8-R11)
PUSH {R2,R3}
BL rt_stk_check ; Check for Stack overflow
POP {R2,R3}

View File

@ -15,19 +15,19 @@
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* - Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*---------------------------------------------------------------------------*/
@ -130,7 +130,7 @@ __asm void SVC_Handler (void) {
CBNZ R1,SVC_User
LDM R0,{R0-R3,R12} ; Read R0-R3,R12 from stack
BLX R12 ; Call SVC Function
BLX R12 ; Call SVC Function
MRS R12,PSP ; Read PSP
STM R12,{R0-R2} ; Store return values

View File

@ -15,19 +15,19 @@
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* - Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*---------------------------------------------------------------------------*/
@ -126,7 +126,7 @@ __asm void SVC_Handler (void) {
#ifdef IFX_XMC4XXX
EXPORT SVC_Handler_Veneer
SVC_Handler_Veneer
SVC_Handler_Veneer
#endif
MRS R0,PSP ; Read PSP
@ -136,7 +136,7 @@ SVC_Handler_Veneer
LDM R0,{R0-R3,R12} ; Read R0-R3,R12 from stack
PUSH {R4,LR} ; Save EXC_RETURN
BLX R12 ; Call SVC Function
BLX R12 ; Call SVC Function
POP {R4,LR} ; Restore EXC_RETURN
MRS R12,PSP ; Read PSP
@ -216,7 +216,7 @@ __asm void PendSV_Handler (void) {
#ifdef IFX_XMC4XXX
EXPORT PendSV_Handler_Veneer
PendSV_Handler_Veneer
PendSV_Handler_Veneer
#endif
PUSH {R4,LR} ; Save EXC_RETURN
@ -278,7 +278,7 @@ __asm void SysTick_Handler (void) {
#ifdef IFX_XMC4XXX
EXPORT SysTick_Handler_Veneer
SysTick_Handler_Veneer
SysTick_Handler_Veneer
#endif
PUSH {R4,LR} ; Save EXC_RETURN

View File

@ -1,14 +1,14 @@
/* ----------------------------------------------------------------------
* Copyright (C) 2012 ARM Limited. All rights reserved.
*
/* ----------------------------------------------------------------------
* Copyright (C) 2012 ARM Limited. All rights reserved.
*
* $Date: 5. June 2012
* $Revision: V1.01
*
*
* Project: CMSIS-RTOS API
* Title: cmsis_os.h RTX header file
*
*
* Version 0.02
* Initial Proposal Phase
* Initial Proposal Phase
* Version 0.03
* osKernelStart added, optional feature: main started as thread
* osSemaphores have standard behavior
@ -16,11 +16,11 @@
* osThreadPass is renamed to osThreadYield
* Version 1.01
* Support for C++ interface
* - const attribute removed from the osXxxxDef_t typedef's
* - const attribute removed from the osXxxxDef_t typedef's
* - const attribute added to the osXxxxDef macros
* Added: osTimerDelete, osMutexDelete, osSemaphoreDelete
* Added: osKernelInitialize
* -------------------------------------------------------------------- */
* -------------------------------------------------------------------- */
/**
\page cmsis_os_h Header File Template: cmsis_os.h
@ -41,8 +41,8 @@ The file cmsis_os.h contains:
All definitions are prefixed with \b os to give an unique name space for CMSIS-RTOS functions.
Definitions that are prefixed \b os_ are not used in the application code but local to this header file.
All definitions and functions that belong to a module are grouped and have a common prefix, i.e. \b osThread.
Definitions that are marked with <b>CAN BE CHANGED</b> can be adapted towards the needs of the actual CMSIS-RTOS implementation.
Definitions that are marked with <b>CAN BE CHANGED</b> can be adapted towards the needs of the actual CMSIS-RTOS implementation.
These definitions can be specific to the underlying RTOS kernel.
Definitions that are marked with <b>MUST REMAIN UNCHANGED</b> cannot be altered. Otherwise the CMSIS-RTOS implementation is no longer
@ -58,7 +58,7 @@ The following CMSIS-RTOS functions can be called from threads and interrupt serv
- \ref osMessagePut, \ref osMessageGet
- \ref osMailAlloc, \ref osMailCAlloc, \ref osMailGet, \ref osMailPut, \ref osMailFree
Functions that cannot be called from an ISR are verifying the interrupt status and return in case that they are called
Functions that cannot be called from an ISR are verifying the interrupt status and return in case that they are called
from an ISR context the status code \b osErrorISR. In some implementations this condition might be caught using the HARD FAULT vector.
Some CMSIS-RTOS implementations support CMSIS-RTOS function calls from multiple ISR at the same time.
@ -79,11 +79,11 @@ extern void thread_sample (void const *argument); // function protot
osThreadDef (thread_sample, osPriorityBelowNormal, 1, 100);
// Pool definition
osPoolDef(MyPool, 10, long);
osPoolDef(MyPool, 10, long);
\endcode
This header file defines all objects when included in a C/C++ source file. When <b>\#define osObjectsExternal</b> is
This header file defines all objects when included in a C/C++ source file. When <b>\#define osObjectsExternal</b> is
present before the header file, the objects are defined as external symbols. A single consistent header file can therefore be
used throughout the whole project.
@ -98,7 +98,7 @@ used throughout the whole project.
\endcode
*/
#ifndef _CMSIS_OS_H
#define _CMSIS_OS_H
@ -159,7 +159,7 @@ typedef enum {
osPriorityBelowNormal = -1, ///< priority: below normal
osPriorityNormal = 0, ///< priority: normal (default)
osPriorityAboveNormal = +1, ///< priority: above normal
osPriorityHigh = +2, ///< priority: high
osPriorityHigh = +2, ///< priority: high
osPriorityRealtime = +3, ///< priority: realtime (highest)
osPriorityError = 0x84 ///< system cannot determine priority or thread has illegal priority
} osPriority;
@ -186,23 +186,23 @@ typedef enum {
osErrorValue = 0x86, ///< value of a parameter is out of range.
osErrorOS = 0xFF, ///< unspecified RTOS error: run-time error but no other error message fits.
os_status_reserved = 0x7FFFFFFF ///< prevent from enum down-size compiler optimization.
} osStatus;
} osStatus;
/// Timer type value for the timer definition.
/// \note MUST REMAIN UNCHANGED: \b os_timer_type shall be consistent in every CMSIS-RTOS.
typedef enum {
osTimerOnce = 0, ///< one-shot timer
osTimerPeriodic = 1 ///< repeating timer
} os_timer_type;
osTimerOnce = 0, ///< one-shot timer
osTimerPeriodic = 1 ///< repeating timer
} os_timer_type;
/// Entry point of a thread.
/// \note MUST REMAIN UNCHANGED: \b os_pthread shall be consistent in every CMSIS-RTOS.
typedef void (*os_pthread) (void const *argument);
typedef void (*os_pthread) (void const *argument);
/// Entry point of a timer call back function.
/// \note MUST REMAIN UNCHANGED: \b os_ptimer shall be consistent in every CMSIS-RTOS.
typedef void (*os_ptimer) (void const *argument);
typedef void (*os_ptimer) (void const *argument);
// >>> the following data type definitions may shall adapted towards a specific RTOS
@ -268,7 +268,7 @@ typedef struct os_semaphore_def {
/// \note CAN BE CHANGED: \b os_pool_def is implementation specific in every CMSIS-RTOS.
typedef struct os_pool_def {
uint32_t pool_sz; ///< number of items (elements) in the pool
uint32_t item_sz; ///< size of an item
uint32_t item_sz; ///< size of an item
void *pool; ///< pointer to memory for pool
} osPoolDef_t;
@ -283,23 +283,23 @@ typedef struct os_messageQ_def {
/// \note CAN BE CHANGED: \b os_mailQ_def is implementation specific in every CMSIS-RTOS.
typedef struct os_mailQ_def {
uint32_t queue_sz; ///< number of elements in the queue
uint32_t item_sz; ///< size of an item
uint32_t item_sz; ///< size of an item
void *pool; ///< memory array for mail
} osMailQDef_t;
/// Event structure contains detailed information about an event.
/// \note MUST REMAIN UNCHANGED: \b os_event shall be consistent in every CMSIS-RTOS.
/// Event structure contains detailed information about an event.
/// \note MUST REMAIN UNCHANGED: \b os_event shall be consistent in every CMSIS-RTOS.
/// However the struct may be extended at the end.
typedef struct {
osStatus status; ///< status code: event or error information
union {
uint32_t v; ///< message as 32-bit value
uint32_t v; ///< message as 32-bit value
void *p; ///< message or mail as void pointer
int32_t signals; ///< signal flags
int32_t signals; ///< signal flags
} value; ///< event value
union {
osMailQId mail_id; ///< mail id obtained by \ref osMailCreate
osMessageQId message_id; ///< message id obtained by \ref osMessageCreate
osMailQId mail_id; ///< mail id obtained by \ref osMailCreate
osMessageQId message_id; ///< message id obtained by \ref osMessageCreate
} def; ///< event definition
} osEvent;
@ -308,16 +308,16 @@ typedef struct {
/// Initialize the RTOS Kernel for creating objects.
/// \return status code that indicates the execution status of the function.
/// \note MUST REMAIN UNCHANGED: \b osKernelInitialize shall be consistent in every CMSIS-RTOS.
/// \note MUST REMAIN UNCHANGED: \b osKernelInitialize shall be consistent in every CMSIS-RTOS.
osStatus osKernelInitialize (void);
/// Start the RTOS Kernel.
/// \return status code that indicates the execution status of the function.
/// \note MUST REMAIN UNCHANGED: \b osKernelStart shall be consistent in every CMSIS-RTOS.
/// \note MUST REMAIN UNCHANGED: \b osKernelStart shall be consistent in every CMSIS-RTOS.
osStatus osKernelStart (void);
/// Check if the RTOS kernel is already started.
/// \note MUST REMAIN UNCHANGED: \b osKernelRunning shall be consistent in every CMSIS-RTOS.
/// \note MUST REMAIN UNCHANGED: \b osKernelRunning shall be consistent in every CMSIS-RTOS.
/// \return 0 RTOS is not started, 1 RTOS is started.
int32_t osKernelRunning(void);
@ -328,7 +328,7 @@ int32_t osKernelRunning(void);
/// \param name name of the thread function.
/// \param priority initial priority of the thread function.
/// \param stacksz stack size (in bytes) requirements for the thread function.
/// \note CAN BE CHANGED: The parameters to \b osThreadDef shall be consistent but the
/// \note CAN BE CHANGED: The parameters to \b osThreadDef shall be consistent but the
/// macro body is implementation specific in every CMSIS-RTOS.
#if defined (osObjectsExternal) // object is external
#define osThreadDef(name, priority, stacksz) \
@ -342,7 +342,7 @@ osThreadDef_t os_thread_def_##name = \
/// Access a Thread definition.
/// \param name name of the thread definition object.
/// \note CAN BE CHANGED: The parameter to \b osThread shall be consistent but the
/// \note CAN BE CHANGED: The parameter to \b osThread shall be consistent but the
/// macro body is implementation specific in every CMSIS-RTOS.
#define osThread(name) \
&os_thread_def_##name
@ -370,7 +370,7 @@ osStatus osThreadTerminate (osThreadId thread_id);
/// \note MUST REMAIN UNCHANGED: \b osThreadYield shall be consistent in every CMSIS-RTOS.
osStatus osThreadYield (void);
/// Change priority of an active thread.
/// Change priority of an active thread.
/// \param[in] thread_id thread ID obtained by \ref osThreadCreate or \ref osThreadGetId.
/// \param[in] priority new priority value for the thread function.
/// \return status code that indicates the execution status of the function.
@ -387,7 +387,7 @@ osPriority osThreadGetPriority (osThreadId thread_id);
// ==== Generic Wait Functions ====
/// Wait for Timeout (Time Delay).
/// \param[in] millisec time delay value
/// \param[in] millisec time delay value
/// \return status code that indicates the execution status of the function.
osStatus osDelay (uint32_t millisec);
@ -406,7 +406,7 @@ os_InRegs osEvent osWait (uint32_t millisec);
/// Define a Timer object.
/// \param name name of the timer object.
/// \param function name of the timer call back function.
/// \note CAN BE CHANGED: The parameter to \b osTimerDef shall be consistent but the
/// \note CAN BE CHANGED: The parameter to \b osTimerDef shall be consistent but the
/// macro body is implementation specific in every CMSIS-RTOS.
#if defined (osObjectsExternal) // object is external
#define osTimerDef(name, function) \
@ -420,7 +420,7 @@ osTimerDef_t os_timer_def_##name = \
/// Access a Timer definition.
/// \param name name of the timer object.
/// \note CAN BE CHANGED: The parameter to \b osTimer shall be consistent but the
/// \note CAN BE CHANGED: The parameter to \b osTimer shall be consistent but the
/// macro body is implementation specific in every CMSIS-RTOS.
#define osTimer(name) \
&os_timer_def_##name
@ -487,7 +487,7 @@ os_InRegs osEvent osSignalWait (int32_t signals, uint32_t millisec);
/// Define a Mutex.
/// \param name name of the mutex object.
/// \note CAN BE CHANGED: The parameter to \b osMutexDef shall be consistent but the
/// \note CAN BE CHANGED: The parameter to \b osMutexDef shall be consistent but the
/// macro body is implementation specific in every CMSIS-RTOS.
#if defined (osObjectsExternal) // object is external
#define osMutexDef(name) \
@ -500,7 +500,7 @@ osMutexDef_t os_mutex_def_##name = { (os_mutex_cb_##name) }
/// Access a Mutex definition.
/// \param name name of the mutex object.
/// \note CAN BE CHANGED: The parameter to \b osMutex shall be consistent but the
/// \note CAN BE CHANGED: The parameter to \b osMutex shall be consistent but the
/// macro body is implementation specific in every CMSIS-RTOS.
#define osMutex(name) \
&os_mutex_def_##name
@ -537,7 +537,7 @@ osStatus osMutexDelete (osMutexId mutex_id);
/// Define a Semaphore object.
/// \param name name of the semaphore object.
/// \note CAN BE CHANGED: The parameter to \b osSemaphoreDef shall be consistent but the
/// \note CAN BE CHANGED: The parameter to \b osSemaphoreDef shall be consistent but the
/// macro body is implementation specific in every CMSIS-RTOS.
#if defined (osObjectsExternal) // object is external
#define osSemaphoreDef(name) \
@ -550,7 +550,7 @@ osSemaphoreDef_t os_semaphore_def_##name = { (os_semaphore_cb_##name) }
/// Access a Semaphore definition.
/// \param name name of the semaphore object.
/// \note CAN BE CHANGED: The parameter to \b osSemaphore shall be consistent but the
/// \note CAN BE CHANGED: The parameter to \b osSemaphore shall be consistent but the
/// macro body is implementation specific in every CMSIS-RTOS.
#define osSemaphore(name) \
&os_semaphore_def_##name
@ -583,7 +583,7 @@ osStatus osSemaphoreDelete (osSemaphoreId semaphore_id);
#endif // Semaphore available
// ==== Memory Pool Management Functions ====
#if (defined (osFeature_Pool) && (osFeature_Pool != 0)) // Memory Pool Management available
@ -592,7 +592,7 @@ osStatus osSemaphoreDelete (osSemaphoreId semaphore_id);
/// \param name name of the memory pool.
/// \param no maximum number of blocks (objects) in the memory pool.
/// \param type data type of a single block (object).
/// \note CAN BE CHANGED: The parameter to \b osPoolDef shall be consistent but the
/// \note CAN BE CHANGED: The parameter to \b osPoolDef shall be consistent but the
/// macro body is implementation specific in every CMSIS-RTOS.
#if defined (osObjectsExternal) // object is external
#define osPoolDef(name, no, type) \
@ -606,7 +606,7 @@ osPoolDef_t os_pool_def_##name = \
/// \brief Access a Memory Pool definition.
/// \param name name of the memory pool
/// \note CAN BE CHANGED: The parameter to \b osPool shall be consistent but the
/// \note CAN BE CHANGED: The parameter to \b osPool shall be consistent but the
/// macro body is implementation specific in every CMSIS-RTOS.
#define osPool(name) \
&os_pool_def_##name
@ -647,7 +647,7 @@ osStatus osPoolFree (osPoolId pool_id, void *block);
/// \param name name of the queue.
/// \param queue_sz maximum number of messages in the queue.
/// \param type data type of a single message element (for debugger).
/// \note CAN BE CHANGED: The parameter to \b osMessageQDef shall be consistent but the
/// \note CAN BE CHANGED: The parameter to \b osMessageQDef shall be consistent but the
/// macro body is implementation specific in every CMSIS-RTOS.
#if defined (osObjectsExternal) // object is external
#define osMessageQDef(name, queue_sz, type) \
@ -661,7 +661,7 @@ osMessageQDef_t os_messageQ_def_##name = \
/// \brief Access a Message Queue Definition.
/// \param name name of the queue
/// \note CAN BE CHANGED: The parameter to \b osMessageQ shall be consistent but the
/// \note CAN BE CHANGED: The parameter to \b osMessageQ shall be consistent but the
/// macro body is implementation specific in every CMSIS-RTOS.
#define osMessageQ(name) \
&os_messageQ_def_##name
@ -699,7 +699,7 @@ os_InRegs osEvent osMessageGet (osMessageQId queue_id, uint32_t millisec);
/// \param name name of the queue
/// \param queue_sz maximum number of messages in queue
/// \param type data type of a single message element
/// \note CAN BE CHANGED: The parameter to \b osMailQDef shall be consistent but the
/// \note CAN BE CHANGED: The parameter to \b osMailQDef shall be consistent but the
/// macro body is implementation specific in every CMSIS-RTOS.
#if defined (osObjectsExternal) // object is external
#define osMailQDef(name, queue_sz, type) \
@ -712,10 +712,10 @@ void * os_mailQ_p_##name[2] = { (os_mailQ_q_##name), os_mailQ_m_##name }; \
osMailQDef_t os_mailQ_def_##name = \
{ (queue_sz), sizeof(type), (os_mailQ_p_##name) }
#endif
/// \brief Access a Mail Queue Definition.
/// \param name name of the queue
/// \note CAN BE CHANGED: The parameter to \b osMailQ shall be consistent but the
/// \note CAN BE CHANGED: The parameter to \b osMailQ shall be consistent but the
/// macro body is implementation specific in every CMSIS-RTOS.
#define osMailQ(name) \
&os_mailQ_def_##name
@ -761,7 +761,7 @@ os_InRegs osEvent osMailGet (osMailQId queue_id, uint32_t millisec);
/// \return status code that indicates the execution status of the function.
/// \note MUST REMAIN UNCHANGED: \b osMailFree shall be consistent in every CMSIS-RTOS.
osStatus osMailFree (osMailQId queue_id, void *mail);
#endif // Mail Queues available

View File

@ -36,13 +36,13 @@ typedef struct OS_TCB {
U16 priv_stack; /* Private stack size in bytes */
U32 tsk_stack; /* Current task Stack pointer (R13) */
U32 *stack; /* Pointer to Task Stack memory block */
/* Library dependant part */
#if defined (__CC_ARM) && !defined (__MICROLIB)
/* A memory space for arm standard library. */
U32 std_libspace[96/4];
#endif
/* Task entry point used for uVision debugger */
FUNCP ptask; /* Task entry address */
} *P_TCB;

View File

@ -15,19 +15,19 @@
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* - Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*---------------------------------------------------------------------------*/
@ -131,9 +131,9 @@ static __inline t __##f (t1 a1, t2 a2, t3 a3, t4 a4) { \
return _##f(f,a1,a2,a3,a4); \
}
#define SVC_1_2 SVC_1_1
#define SVC_1_3 SVC_1_1
#define SVC_2_3 SVC_2_1
#define SVC_1_2 SVC_1_1
#define SVC_1_3 SVC_1_1
#define SVC_2_3 SVC_2_1
#elif defined (__GNUC__) /* GNU Compiler */
@ -257,9 +257,9 @@ static inline t __##f (t1 a1, t2 a2, t3 a3, t4 a4) { \
return (t) rv; \
}
#define SVC_1_2 SVC_1_1
#define SVC_1_3 SVC_1_1
#define SVC_2_3 SVC_2_1
#define SVC_1_2 SVC_1_1
#define SVC_1_3 SVC_1_1
#define SVC_2_3 SVC_2_1
#elif defined (__ICCARM__) /* IAR Compiler */
@ -405,7 +405,7 @@ static uint32_t rt_ms2tick (uint32_t millisec) {
tick = ((1000 * millisec) + os_clockrate - 1) / os_clockrate;
if (tick > 0xFFFE) return 0xFFFE;
return tick;
}
@ -517,12 +517,12 @@ osStatus osKernelInitialize (void) {
/// Start the RTOS Kernel
osStatus osKernelStart (void) {
uint32_t stack[8];
if (__get_IPSR() != 0) return osErrorISR; // Not allowed in ISR
switch (__get_CONTROL() & 0x03) {
case 0x00: // Privileged Thread mode & MSP
__set_PSP((uint32_t)(stack + 8)); // Initial PSP
if (os_flags & 1) {
if (os_flags & 1) {
__set_CONTROL(0x02); // Set Privileged Thread mode & PSP
} else {
__set_CONTROL(0x03); // Set Unprivileged Thread mode & PSP
@ -576,20 +576,20 @@ extern void rt_init_context (P_TCB p_TCB, U8 priority, FUNCP task_body);
/// Create a thread and add it to Active Threads and set it to state READY
osThreadId svcThreadCreate (osThreadDef_t *thread_def, void *argument) {
P_TCB ptcb;
if ((thread_def == NULL) ||
(thread_def->pthread == NULL) ||
(thread_def->tpriority < osPriorityIdle) ||
(thread_def->tpriority > osPriorityRealtime) ||
(thread_def->stacksize == 0) ||
(thread_def->stack_pointer == NULL) ) {
sysThreadError(osErrorParameter);
return NULL;
sysThreadError(osErrorParameter);
return NULL;
}
U8 priority = thread_def->tpriority - osPriorityIdle + 1;
P_TCB task_context = &thread_def->tcb;
/* If "size != 0" use a private user provided stack. */
task_context->stack = (U32*)thread_def->stack_pointer;
task_context->priv_stack = thread_def->stacksize;
@ -604,7 +604,7 @@ osThreadId svcThreadCreate (osThreadDef_t *thread_def, void *argument) {
task_context->task_id = tsk;
DBG_TASK_NOTIFY(task_context, __TRUE);
rt_dispatch (task_context);
ptcb = (P_TCB)os_active_TCB[tsk - 1]; // TCB pointer
*((uint32_t *)ptcb->tsk_stack + 13) = (uint32_t)osThreadExit;
@ -625,14 +625,14 @@ osThreadId svcThreadGetId (void) {
osStatus svcThreadTerminate (osThreadId thread_id) {
OS_RESULT res;
P_TCB ptcb;
ptcb = rt_tid2ptcb(thread_id); // Get TCB pointer
if (ptcb == NULL) return osErrorParameter;
res = rt_tsk_delete(ptcb->task_id); // Delete task
if (res == OS_R_NOK) return osErrorResource; // Delete task failed
return osOK;
}
@ -671,7 +671,7 @@ osPriority svcThreadGetPriority (osThreadId thread_id) {
ptcb = rt_tid2ptcb(thread_id); // Get TCB pointer
if (ptcb == NULL) return osPriorityError;
return (osPriority)(ptcb->prio - 1 + osPriorityIdle);
return (osPriority)(ptcb->prio - 1 + osPriorityIdle);
}
@ -720,8 +720,8 @@ osPriority osThreadGetPriority (osThreadId thread_id) {
/// INTERNAL - Not Public
/// Auto Terminate Thread on exit (used implicitly when thread exists)
__NO_RETURN void osThreadExit (void) {
__svcThreadTerminate(__svcThreadGetId());
__NO_RETURN void osThreadExit (void) {
__svcThreadTerminate(__svcThreadGetId());
for (;;); // Should never come here
}
@ -794,7 +794,7 @@ os_InRegs osEvent osWait (uint32_t millisec) {
#define osTimerStopped 1
#define osTimerRunning 2
// Timer structures
// Timer structures
typedef struct os_timer_cb_ { // Timer Control Block
struct os_timer_cb_ *next; // Pointer to next active Timer
@ -802,7 +802,7 @@ typedef struct os_timer_cb_ { // Timer Control Block
uint8_t type; // Timer Type (Periodic/One-shot)
uint16_t reserved; // Reserved
uint16_t tcnt; // Timer Delay Count
uint16_t icnt; // Timer Initial Count
uint16_t icnt; // Timer Initial Count
void *arg; // Timer Function Argument
osTimerDef_t *timer; // Pointer to Timer definition
} os_timer_cb;
@ -933,7 +933,7 @@ osStatus svcTimerStart (osTimerId timer_id, uint32_t millisec) {
default:
return osErrorResource;
}
rt_timer_insert(pt, tcnt);
return osOK;
@ -1054,8 +1054,8 @@ osStatus osTimerDelete (osTimerId timer_id) {
/// INTERNAL - Not Public
/// Get timer callback parameters (used by OS Timer Thread)
os_InRegs osCallback osTimerCall (osTimerId timer_id) {
return __svcTimerCall(timer_id);
os_InRegs osCallback osTimerCall (osTimerId timer_id) {
return __svcTimerCall(timer_id);
}
@ -1183,7 +1183,7 @@ static __INLINE int32_t isrSignalSet (osThreadId thread_id, int32_t signals) {
/// Set the specified Signal Flags of an active thread
int32_t osSignalSet (osThreadId thread_id, int32_t signals) {
if (__get_IPSR() != 0) { // in ISR
return isrSignalSet(thread_id, signals);
return isrSignalSet(thread_id, signals);
} else { // in Thread
return __svcSignalSet(thread_id, signals);
}
@ -1367,7 +1367,7 @@ osSemaphoreId svcSemaphoreCreate (const osSemaphoreDef_t *semaphore_def, int32_t
}
rt_sem_init(sem, count); // Initialize Semaphore
return sem;
}
@ -1398,7 +1398,7 @@ osStatus svcSemaphoreRelease (osSemaphoreId semaphore_id) {
if (((P_SCB)sem)->cb_type != SCB) return osErrorParameter;
if (((P_SCB)sem)->tokens == osFeature_Semaphore) return osErrorResource;
rt_sem_send(sem); // Release Semaphore
return osOK;
@ -1532,7 +1532,7 @@ void *sysPoolAlloc (osPoolId pool_id, uint32_t clr) {
/// Return an allocated memory block back to a specific memory pool
osStatus sysPoolFree (osPoolId pool_id, void *block) {
int32_t res;
if (pool_id == NULL) return osErrorParameter;
res = rt_free_box(pool_id, block);
@ -1601,7 +1601,7 @@ osMessageQId svcMessageCreate (osMessageQDef_t *queue_def, osThreadId thread_id)
sysThreadError(osErrorParameter);
return NULL;
}
if (((P_MCB)queue_def->pool)->cb_type != 0) {
sysThreadError(osErrorParameter);
return NULL;
@ -1645,7 +1645,7 @@ os_InRegs osEvent_type svcMessageGet (osMessageQId queue_id, uint32_t millisec)
}
res = rt_mbx_wait(queue_id, &ret.value.p, rt_ms2tick(millisec));
if (res == OS_R_TMO) {
ret.status = millisec ? osEventTimeout : osOK;
return osEvent_ret_value;
@ -1693,13 +1693,13 @@ static __INLINE os_InRegs osEvent isrMessageGet (osMessageQId queue_id, uint32_t
}
res = isr_mbx_receive(queue_id, &ret.value.p);
if (res != OS_R_MBX) {
ret.status = osOK;
return ret;
}
ret.status = osEventMessage;
ret.status = osEventMessage;
return ret;
}
@ -1812,7 +1812,7 @@ void *sysMailAlloc (osMailQId queue_id, uint32_t millisec, uint32_t isr, uint32_
rt_block(rt_ms2tick(millisec), WAIT_MBX);
}
return mem;
return mem;
}
/// Free a memory block from a mail

View File

@ -15,19 +15,19 @@
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* - Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*---------------------------------------------------------------------------*/
@ -108,7 +108,7 @@ wkup: p_tcb->events &= ~event_flags;
rt_rmv_dly (p_tcb);
p_tcb->state = READY;
#ifdef __CMSIS_RTOS
rt_ret_val2(p_tcb, 0x08/*osEventSignal*/, p_tcb->waits);
rt_ret_val2(p_tcb, 0x08/*osEventSignal*/, p_tcb->waits);
#else
rt_ret_val (p_tcb, OS_R_EVT);
#endif
@ -176,7 +176,7 @@ rdy: p_CB->events &= ~event_flags;
rt_rmv_dly (p_CB);
p_CB->state = READY;
#ifdef __CMSIS_RTOS
rt_ret_val2(p_CB, 0x08/*osEventSignal*/, p_CB->waits);
rt_ret_val2(p_CB, 0x08/*osEventSignal*/, p_CB->waits);
#else
rt_ret_val (p_CB, OS_R_EVT);
#endif

View File

@ -15,19 +15,19 @@
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* - Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*---------------------------------------------------------------------------*/

View File

@ -15,19 +15,19 @@
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* - Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*---------------------------------------------------------------------------*/
@ -86,7 +86,7 @@ __attribute__((always_inline)) static inline U32 __disable_irq(void)
__attribute__(( always_inline)) static inline U8 __clz(U32 value)
{
U8 result;
__asm volatile ("clz %0, %1" : "=r" (result) : "r" (value));
return(result);
}
@ -119,7 +119,7 @@ static inline void __enable_irq(void)
static inline U32 __disable_irq(void)
{
U32 result;
__asm volatile ("mrs %0, primask" : "=r" (result));
__asm volatile ("cpsid i");
return(result & 1);
@ -130,7 +130,7 @@ static inline U32 __disable_irq(void)
static inline U8 __clz(U32 value)
{
U8 result;
__asm volatile ("clz %0, %1" : "=r" (result) : "r" (value));
return(result);
}
@ -214,7 +214,7 @@ __inline static U32 rt_inc_qi (U32 size, U8 *count, U8 *first) {
*count = cnt+1;
c2 = (cnt = *first) + 1;
if (c2 == size) c2 = 0;
*first = c2;
*first = c2;
}
__enable_irq ();
#endif

View File

@ -15,19 +15,19 @@
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* - Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*---------------------------------------------------------------------------*/

View File

@ -15,19 +15,19 @@
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* - Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*---------------------------------------------------------------------------*/

View File

@ -15,19 +15,19 @@
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* - Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*---------------------------------------------------------------------------*/
@ -100,7 +100,7 @@ OS_RESULT rt_mbx_send (OS_ID mailbox, void *p_msg, U16 timeout) {
p_MCB->p_lnk = os_tsk.run;
os_tsk.run->p_lnk = NULL;
os_tsk.run->p_rlnk = (P_TCB)p_MCB;
/* Task is waiting to send a message */
/* Task is waiting to send a message */
p_MCB->state = 2;
}
os_tsk.run->msg = p_msg;
@ -163,7 +163,7 @@ OS_RESULT rt_mbx_wait (OS_ID mailbox, void **message, U16 timeout) {
p_MCB->p_lnk = os_tsk.run;
os_tsk.run->p_lnk = NULL;
os_tsk.run->p_rlnk = (P_TCB)p_MCB;
/* Task is waiting to receive a message */
/* Task is waiting to receive a message */
p_MCB->state = 1;
}
rt_block(timeout, WAIT_MBX);

View File

@ -15,19 +15,19 @@
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* - Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*---------------------------------------------------------------------------*/

View File

@ -15,19 +15,19 @@
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* - Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*---------------------------------------------------------------------------*/
@ -54,7 +54,7 @@ int _init_box (void *box_mem, U32 box_size, U32 blk_size) {
/* Create memory structure. */
if (blk_size & BOX_ALIGN_8) {
/* Memory blocks 8-byte aligned. */
/* Memory blocks 8-byte aligned. */
blk_size = ((blk_size & ~BOX_ALIGN_8) + 7) & ~7;
sizeof_bm = (sizeof (struct OS_BM) + 7) & ~7;
}

View File

@ -15,19 +15,19 @@
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* - Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*---------------------------------------------------------------------------*/

View File

@ -15,19 +15,19 @@
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* - Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*---------------------------------------------------------------------------*/
@ -120,7 +120,7 @@ OS_RESULT rt_mut_release (OS_ID mutex) {
#ifdef __CMSIS_RTOS
rt_ret_val(p_TCB, 0/*osOK*/);
#else
rt_ret_val(p_TCB, OS_R_MUT);
rt_ret_val(p_TCB, OS_R_MUT);
#endif
rt_rmv_dly (p_TCB);
/* A waiting task becomes the owner of this mutex. */

View File

@ -15,19 +15,19 @@
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* - Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*---------------------------------------------------------------------------*/

View File

@ -15,19 +15,19 @@
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* - Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*---------------------------------------------------------------------------*/

View File

@ -15,19 +15,19 @@
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* - Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*---------------------------------------------------------------------------*/

View File

@ -15,19 +15,19 @@
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* - Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*---------------------------------------------------------------------------*/

View File

@ -15,19 +15,19 @@
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* - Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*---------------------------------------------------------------------------*/

View File

@ -15,19 +15,19 @@
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* - Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*---------------------------------------------------------------------------*/
@ -77,9 +77,9 @@ __RL_RTX_VER EQU 0x450
U32 rt_suspend (void) {
/* Suspend OS scheduler */
U32 delta = 0xFFFF;
rt_tsk_lock();
if (os_dly.p_dlnk) {
delta = os_dly.delta_time;
}
@ -88,7 +88,7 @@ U32 rt_suspend (void) {
if (os_tmr.tcnt < delta) delta = os_tmr.tcnt;
}
#endif
return (delta);
}
@ -124,7 +124,7 @@ void rt_resume (U32 sleep_time) {
} else {
os_time += sleep_time;
}
#ifndef __CMSIS_RTOS
/* Check the user timers. */
if (os_tmr.next) {
@ -274,7 +274,7 @@ void rt_systick (void) {
#else
rt_tmr_tick ();
#endif
/* Switch back to highest ready task */
next = rt_get_first (&os_rdy);
rt_switch_req (next);

Some files were not shown because too many files have changed in this diff Show More