diff --git a/.gitignore b/.gitignore index 850758cf1e..75da3674af 100644 --- a/.gitignore +++ b/.gitignore @@ -60,3 +60,6 @@ debug.log # Ignore OS X Desktop Services Store files .DS_Store + +# Orig diff files +*.orig diff --git a/libraries/USBDevice/USBAudio/USBAudio.h b/libraries/USBDevice/USBAudio/USBAudio.h index a1057ebfa2..6b6b4bcc45 100644 --- a/libraries/USBDevice/USBAudio/USBAudio.h +++ b/libraries/USBDevice/USBAudio/USBAudio.h @@ -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; }; diff --git a/libraries/USBDevice/USBDevice/USBDescriptor.h b/libraries/USBDevice/USBDevice/USBDescriptor.h index 0793e9cac9..9d4ce849f0 100644 --- a/libraries/USBDevice/USBDevice/USBDescriptor.h +++ b/libraries/USBDevice/USBDevice/USBDescriptor.h @@ -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) diff --git a/libraries/USBDevice/USBDevice/USBDevice.cpp b/libraries/USBDevice/USBDevice/USBDevice.cpp index ffe0b448b1..53659164a7 100644 --- a/libraries/USBDevice/USBDevice/USBDevice.cpp +++ b/libraries/USBDevice/USBDevice/USBDevice.cpp @@ -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); } diff --git a/libraries/USBDevice/USBDevice/USBDevice.h b/libraries/USBDevice/USBDevice/USBDevice.h index 2035aaec38..a25ca1adfe 100644 --- a/libraries/USBDevice/USBDevice/USBDevice.h +++ b/libraries/USBDevice/USBDevice/USBDevice.h @@ -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; }; diff --git a/libraries/USBDevice/USBDevice/USBEndpoints_KL25Z.h b/libraries/USBDevice/USBDevice/USBEndpoints_KL25Z.h index 957e02d834..5cb3f7b395 100644 --- a/libraries/USBDevice/USBDevice/USBEndpoints_KL25Z.h +++ b/libraries/USBDevice/USBDevice/USBEndpoints_KL25Z.h @@ -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 */ diff --git a/libraries/USBDevice/USBDevice/USBHAL.h b/libraries/USBDevice/USBDevice/USBHAL.h index 29516e6e40..eafa008409 100644 --- a/libraries/USBDevice/USBDevice/USBHAL.h +++ b/libraries/USBDevice/USBDevice/USBHAL.h @@ -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 diff --git a/libraries/USBDevice/USBDevice/USBHAL_LPC11U.cpp b/libraries/USBDevice/USBDevice/USBHAL_LPC11U.cpp index 90a8fca6d9..a35c09ccaf 100644 --- a/libraries/USBDevice/USBDevice/USBHAL_LPC11U.cpp +++ b/libraries/USBDevice/USBDevice/USBHAL_LPC11U.cpp @@ -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); diff --git a/libraries/USBDevice/USBDevice/USBHAL_LPC17.cpp b/libraries/USBDevice/USBDevice/USBHAL_LPC17.cpp index 2786fccafe..8bffe10ace 100644 --- a/libraries/USBDevice/USBDevice/USBHAL_LPC17.cpp +++ b/libraries/USBDevice/USBDevice/USBHAL_LPC17.cpp @@ -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); diff --git a/libraries/USBDevice/USBDevice/USBHAL_LPC40.cpp b/libraries/USBDevice/USBDevice/USBHAL_LPC40.cpp index f2643afa37..108f402e9c 100644 --- a/libraries/USBDevice/USBDevice/USBHAL_LPC40.cpp +++ b/libraries/USBDevice/USBDevice/USBHAL_LPC40.cpp @@ -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); diff --git a/libraries/USBDevice/USBDevice/USBHAL_STM32F4.cpp b/libraries/USBDevice/USBDevice/USBHAL_STM32F4.cpp index af1c3c3107..5826b39f24 100644 --- a/libraries/USBDevice/USBDevice/USBHAL_STM32F4.cpp +++ b/libraries/USBDevice/USBDevice/USBHAL_STM32F4.cpp @@ -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) { diff --git a/libraries/USBDevice/USBDevice/USBRegs_STM32.h b/libraries/USBDevice/USBDevice/USBRegs_STM32.h index 303338cc92..3e11a49c15 100644 --- a/libraries/USBDevice/USBDevice/USBRegs_STM32.h +++ b/libraries/USBDevice/USBDevice/USBRegs_STM32.h @@ -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]; diff --git a/libraries/USBDevice/USBHID/USBHID.cpp b/libraries/USBDevice/USBHID/USBHID.cpp index 0014a5db7c..571421d823 100644 --- a/libraries/USBDevice/USBHID/USBHID.cpp +++ b/libraries/USBDevice/USBHID/USBHID.cpp @@ -121,7 +121,7 @@ bool USBHID::USBCallback_request() { success = true; } break; - + default: break; } diff --git a/libraries/USBDevice/USBHID/USBHID.h b/libraries/USBDevice/USBHID/USBHID.h index 16e20073b4..faa75cb94a 100644 --- a/libraries/USBDevice/USBHID/USBHID.h +++ b/libraries/USBDevice/USBHID/USBHID.h @@ -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 * diff --git a/libraries/USBDevice/USBHID/USBKeyboard.cpp b/libraries/USBDevice/USBHID/USBKeyboard.cpp index b82b69b43e..81857095bc 100644 --- a/libraries/USBDevice/USBHID/USBKeyboard.cpp +++ b/libraries/USBDevice/USBHID/USBKeyboard.cpp @@ -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; diff --git a/libraries/USBDevice/USBHID/USBKeyboard.h b/libraries/USBDevice/USBHID/USBKeyboard.h index 92bcbe3c57..c9e08b16bc 100644 --- a/libraries/USBDevice/USBHID/USBKeyboard.h +++ b/libraries/USBDevice/USBHID/USBKeyboard.h @@ -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 */ diff --git a/libraries/USBDevice/USBHID/USBMouse.h b/libraries/USBDevice/USBHID/USBMouse.h index 4b0b735af3..7aa4263343 100644 --- a/libraries/USBDevice/USBHID/USBMouse.h +++ b/libraries/USBDevice/USBHID/USBMouse.h @@ -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; diff --git a/libraries/USBDevice/USBHID/USBMouseKeyboard.cpp b/libraries/USBDevice/USBHID/USBMouseKeyboard.cpp index b6cb28769c..848d81a686 100644 --- a/libraries/USBDevice/USBHID/USBMouseKeyboard.cpp +++ b/libraries/USBDevice/USBHID/USBMouseKeyboard.cpp @@ -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; diff --git a/libraries/USBDevice/USBHID/USBMouseKeyboard.h b/libraries/USBDevice/USBHID/USBMouseKeyboard.h index ae729d9abf..7eaa355e37 100644 --- a/libraries/USBDevice/USBHID/USBMouseKeyboard.h +++ b/libraries/USBDevice/USBHID/USBMouseKeyboard.h @@ -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;} }; diff --git a/libraries/USBDevice/USBMIDI/MIDIMessage.h b/libraries/USBDevice/USBMIDI/MIDIMessage.h index cef7669457..90f695039a 100644 --- a/libraries/USBDevice/USBMIDI/MIDIMessage.h +++ b/libraries/USBDevice/USBMIDI/MIDIMessage.h @@ -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]; }; diff --git a/libraries/USBDevice/USBMIDI/USBMIDI.h b/libraries/USBDevice/USBMIDI/USBMIDI.h index 89f35abab0..fdf5d6d6bb 100644 --- a/libraries/USBDevice/USBMIDI/USBMIDI.h +++ b/libraries/USBDevice/USBMIDI/USBMIDI.h @@ -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 * diff --git a/libraries/USBDevice/USBMSD/USBMSD.h b/libraries/USBDevice/USBMSD/USBMSD.h index 359ca7052f..b362f5618b 100644 --- a/libraries/USBDevice/USBMSD/USBMSD.h +++ b/libraries/USBDevice/USBMSD/USBMSD.h @@ -79,7 +79,7 @@ public: * Disconnect the USB MSD device. */ void disconnect(); - + /** * Destructor */ diff --git a/libraries/USBDevice/USBSerial/USBCDC.cpp b/libraries/USBDevice/USBSerial/USBCDC.cpp index 2b9027eb7e..12f84751fb 100644 --- a/libraries/USBDevice/USBSerial/USBCDC.cpp +++ b/libraries/USBDevice/USBSerial/USBCDC.cpp @@ -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 diff --git a/libraries/USBDevice/USBSerial/USBCDC.h b/libraries/USBDevice/USBSerial/USBCDC.h index 7185ae611f..33c6b0a024 100644 --- a/libraries/USBDevice/USBSerial/USBCDC.h +++ b/libraries/USBDevice/USBSerial/USBCDC.h @@ -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); diff --git a/libraries/USBDevice/USBSerial/USBSerial.h b/libraries/USBDevice/USBSerial/USBSerial.h index 887e75c7bd..d5e2ec71d1 100644 --- a/libraries/USBDevice/USBSerial/USBSerial.h +++ b/libraries/USBDevice/USBSerial/USBSerial.h @@ -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 diff --git a/libraries/USBHost/USBHost/USBDeviceConnected.cpp b/libraries/USBHost/USBHost/USBDeviceConnected.cpp index dc08c84f4c..8314b3ef40 100644 --- a/libraries/USBHost/USBHost/USBDeviceConnected.cpp +++ b/libraries/USBHost/USBHost/USBDeviceConnected.cpp @@ -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; } diff --git a/libraries/USBHost/USBHost/USBDeviceConnected.h b/libraries/USBHost/USBHost/USBDeviceConnected.h index 6bc707ca7c..22a4c1d3e9 100644 --- a/libraries/USBHost/USBHost/USBDeviceConnected.h +++ b/libraries/USBHost/USBHost/USBDeviceConnected.h @@ -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; diff --git a/libraries/USBHost/USBHost/USBEndpoint.cpp b/libraries/USBHost/USBHost/USBEndpoint.cpp index 888e1802f0..fc372232f3 100644 --- a/libraries/USBHost/USBHost/USBEndpoint.cpp +++ b/libraries/USBHost/USBHost/USBEndpoint.cpp @@ -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; diff --git a/libraries/USBHost/USBHost/USBEndpoint.h b/libraries/USBHost/USBHost/USBEndpoint.h index 44a455678c..2ec90d729f 100644 --- a/libraries/USBHost/USBHost/USBEndpoint.h +++ b/libraries/USBHost/USBHost/USBEndpoint.h @@ -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 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; }; diff --git a/libraries/USBHost/USBHost/USBHALHost.cpp b/libraries/USBHost/USBHost/USBHALHost.cpp index a943218662..2d67798d04 100644 --- a/libraries/USBHost/USBHost/USBHALHost.cpp +++ b/libraries/USBHost/USBHost/USBHALHost.cpp @@ -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; diff --git a/libraries/USBHost/USBHost/USBHALHost.h b/libraries/USBHost/USBHost/USBHALHost.h index 0095a8a869..e32969de36 100644 --- a/libraries/USBHost/USBHost/USBHALHost.h +++ b/libraries/USBHost/USBHost/USBHALHost.h @@ -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]; }; diff --git a/libraries/USBHost/USBHost/USBHost.cpp b/libraries/USBHost/USBHost/USBHost.cpp index 9da1e8edfa..d05486db91 100644 --- a/libraries/USBHost/USBHost/USBHost.cpp +++ b/libraries/USBHost/USBHost/USBHost.cpp @@ -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; } diff --git a/libraries/USBHost/USBHost/USBHost.h b/libraries/USBHost/USBHost/USBHost.h index c8da421f23..802ae99313 100644 --- a/libraries/USBHost/USBHost/USBHost.h +++ b/libraries/USBHost/USBHost/USBHost.h @@ -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 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) ; diff --git a/libraries/USBHost/USBHost/USBHostConf.h b/libraries/USBHost/USBHost/USBHostConf.h index d5515edc3b..9b97752f0c 100644 --- a/libraries/USBHost/USBHost/USBHostConf.h +++ b/libraries/USBHost/USBHost/USBHostConf.h @@ -56,7 +56,7 @@ /* * Enable USB3Gmodule */ -#define USBHOST_3GMODULE 1 +#define USBHOST_3GMODULE 1 /* * Maximum number of interfaces of a usb device diff --git a/libraries/USBHost/USBHost/USBHostTypes.h b/libraries/USBHost/USBHost/USBHostTypes.h index e03c6e4239..c4462aa052 100644 --- a/libraries/USBHost/USBHost/USBHostTypes.h +++ b/libraries/USBHost/USBHost/USBHostTypes.h @@ -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 diff --git a/libraries/USBHost/USBHost3GModule/WANDongle.cpp b/libraries/USBHost/USBHost3GModule/WANDongle.cpp index c7896f6e62..49cafb7cc3 100644 --- a/libraries/USBHost/USBHost3GModule/WANDongle.cpp +++ b/libraries/USBHost/USBHost3GModule/WANDongle.cpp @@ -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"); diff --git a/libraries/USBHost/USBHost3GModule/WANDongle.h b/libraries/USBHost/USBHost3GModule/WANDongle.h index ab12bdc6e4..960b8bcfbe 100644 --- a/libraries/USBHost/USBHost3GModule/WANDongle.h +++ b/libraries/USBHost/USBHost3GModule/WANDongle.h @@ -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]; }; diff --git a/libraries/USBHost/USBHost3GModule/WANDongleInitializer.h b/libraries/USBHost/USBHost3GModule/WANDongleInitializer.h index a78d69bdbd..2f0a4a37c7 100644 --- a/libraries/USBHost/USBHost3GModule/WANDongleInitializer.h +++ b/libraries/USBHost/USBHost3GModule/WANDongleInitializer.h @@ -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]; } diff --git a/libraries/USBHost/USBHost3GModule/WANDongleSerialPort.cpp b/libraries/USBHost/USBHost3GModule/WANDongleSerialPort.cpp index 4cb43379e4..96343f15cc 100644 --- a/libraries/USBHost/USBHost3GModule/WANDongleSerialPort.cpp +++ b/libraries/USBHost/USBHost3GModule/WANDongleSerialPort.cpp @@ -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"); diff --git a/libraries/USBHost/USBHost3GModule/WANDongleSerialPort.h b/libraries/USBHost/USBHost3GModule/WANDongleSerialPort.h index 9da1717078..7c79d17341 100644 --- a/libraries/USBHost/USBHost3GModule/WANDongleSerialPort.h +++ b/libraries/USBHost/USBHost3GModule/WANDongleSerialPort.h @@ -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(); diff --git a/libraries/USBHost/USBHostHID/USBHostKeyboard.cpp b/libraries/USBHost/USBHostHID/USBHostKeyboard.cpp index 4c7fef0a8e..dbb2cda53e 100644 --- a/libraries/USBHost/USBHostHID/USBHostKeyboard.cpp +++ b/libraries/USBHost/USBHostHID/USBHostKeyboard.cpp @@ -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; } diff --git a/libraries/USBHost/USBHostHID/USBHostKeyboard.h b/libraries/USBHost/USBHostHID/USBHostKeyboard.h index 64af41efaa..93730061c5 100644 --- a/libraries/USBHost/USBHostHID/USBHostKeyboard.h +++ b/libraries/USBHost/USBHostHID/USBHostKeyboard.h @@ -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(); }; diff --git a/libraries/USBHost/USBHostHID/USBHostMouse.cpp b/libraries/USBHost/USBHostHID/USBHostMouse.cpp index 6c596d08b0..493f12dc6c 100644 --- a/libraries/USBHost/USBHostHID/USBHostMouse.cpp +++ b/libraries/USBHost/USBHostHID/USBHostMouse.cpp @@ -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); } diff --git a/libraries/USBHost/USBHostHID/USBHostMouse.h b/libraries/USBHost/USBHostHID/USBHostMouse.h index 1e97c8e492..03e0994482 100644 --- a/libraries/USBHost/USBHostHID/USBHostMouse.h +++ b/libraries/USBHost/USBHostHID/USBHostMouse.h @@ -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; diff --git a/libraries/USBHost/USBHostHub/USBHostHub.cpp b/libraries/USBHost/USBHostHub/USBHostHub.cpp index e008c9a496..7a9660bdb1 100644 --- a/libraries/USBHost/USBHostHub/USBHostHub.cpp +++ b/libraries/USBHost/USBHostHub/USBHostHub.cpp @@ -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); diff --git a/libraries/USBHost/USBHostHub/USBHostHub.h b/libraries/USBHost/USBHostHub/USBHostHub.h index 17fb4ce3bf..e199c369e7 100644 --- a/libraries/USBHost/USBHostHub/USBHostHub.h +++ b/libraries/USBHost/USBHostHub/USBHostHub.h @@ -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(); diff --git a/libraries/USBHost/USBHostMSD/USBHostMSD.cpp b/libraries/USBHost/USBHostMSD/USBHostMSD.cpp index a91f5fc982..c8406494c6 100644 --- a/libraries/USBHost/USBHostMSD/USBHostMSD.cpp +++ b/libraries/USBHost/USBHostMSD/USBHostMSD.cpp @@ -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(); diff --git a/libraries/USBHost/USBHostMSD/USBHostMSD.h b/libraries/USBHost/USBHostMSD/USBHostMSD.h index 118873996d..b90cd2fe19 100644 --- a/libraries/USBHost/USBHostMSD/USBHostMSD.h +++ b/libraries/USBHost/USBHostMSD/USBHostMSD.h @@ -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(); }; diff --git a/libraries/USBHost/USBHostSerial/MtxCircBuffer.h b/libraries/USBHost/USBHostSerial/MtxCircBuffer.h index 89b0a224f0..ff79affad6 100644 --- a/libraries/USBHost/USBHostSerial/MtxCircBuffer.h +++ b/libraries/USBHost/USBHostSerial/MtxCircBuffer.h @@ -24,7 +24,7 @@ template class MtxCircBuffer { public: - + MtxCircBuffer() { write = 0; read = 0; @@ -43,7 +43,7 @@ public: mtx.unlock(); return r; } - + void flush() { write = 0; read = 0; diff --git a/libraries/USBHost/USBHostSerial/USBHostSerial.cpp b/libraries/USBHost/USBHostSerial/USBHostSerial.cpp index 2124c3aa60..2d3b1736db 100644 --- a/libraries/USBHost/USBHostSerial/USBHostSerial.cpp +++ b/libraries/USBHost/USBHostSerial/USBHostSerial.cpp @@ -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(); diff --git a/libraries/USBHost/USBHostSerial/USBHostSerial.h b/libraries/USBHost/USBHostSerial/USBHostSerial.h index 53466da249..94fc8ad7c5 100644 --- a/libraries/USBHost/USBHostSerial/USBHostSerial.h +++ b/libraries/USBHost/USBHostSerial/USBHostSerial.h @@ -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; }; diff --git a/libraries/fs/fat/ChaN/diskio.cpp b/libraries/fs/fat/ChaN/diskio.cpp index 0ecf295ff8..5bffcd6d89 100644 --- a/libraries/fs/fat/ChaN/diskio.cpp +++ b/libraries/fs/fat/ChaN/diskio.cpp @@ -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(); diff --git a/libraries/fs/fat/FATFileHandle.cpp b/libraries/fs/fat/FATFileHandle.cpp index 768d585ba7..8c2bf881e4 100644 --- a/libraries/fs/fat/FATFileHandle.cpp +++ b/libraries/fs/fat/FATFileHandle.cpp @@ -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; diff --git a/libraries/fs/fat/FATFileSystem.cpp b/libraries/fs/fat/FATFileSystem.cpp index 6e48681987..ee7172c0a8 100644 --- a/libraries/fs/fat/FATFileSystem.cpp +++ b/libraries/fs/fat/FATFileSystem.cpp @@ -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; } diff --git a/libraries/fs/sd/SDFileSystem.cpp b/libraries/fs/sd/SDFileSystem.cpp index 54208b66d0..2e7513b13d 100644 --- a/libraries/fs/sd/SDFileSystem.cpp +++ b/libraries/fs/sd/SDFileSystem.cpp @@ -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; diff --git a/libraries/fs/sd/SDFileSystem.h b/libraries/fs/sd/SDFileSystem.h index 85185546c0..bd74ebf94e 100644 --- a/libraries/fs/sd/SDFileSystem.h +++ b/libraries/fs/sd/SDFileSystem.h @@ -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(); diff --git a/libraries/mbed/api/InterruptManager.h b/libraries/mbed/api/InterruptManager.h index 6f3fa49c5d..4959a64699 100644 --- a/libraries/mbed/api/InterruptManager.h +++ b/libraries/mbed/api/InterruptManager.h @@ -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 diff --git a/libraries/mbed/common/InterruptManager.cpp b/libraries/mbed/common/InterruptManager.cpp index 7bf41d15b5..6fe31f6531 100644 --- a/libraries/mbed/common/InterruptManager.cpp +++ b/libraries/mbed/common/InterruptManager.cpp @@ -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)) diff --git a/libraries/mbed/common/board.c b/libraries/mbed/common/board.c index ab24b09ec0..a9e749b811 100644 --- a/libraries/mbed/common/board.c +++ b/libraries/mbed/common/board.c @@ -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); } } diff --git a/libraries/mbed/common/gpio.c b/libraries/mbed/common/gpio.c index b9dc4b9f9c..3839e8bb2d 100644 --- a/libraries/mbed/common/gpio.c +++ b/libraries/mbed/common/gpio.c @@ -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); diff --git a/libraries/mbed/common/mbed_interface.c b/libraries/mbed/common/mbed_interface.c index 01c734c661..0055843e55 100644 --- a/libraries/mbed/common/mbed_interface.c +++ b/libraries/mbed/common/mbed_interface.c @@ -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; diff --git a/libraries/mbed/common/pinmap_common.c b/libraries/mbed/common/pinmap_common.c index eef617fd45..10b981e784 100644 --- a/libraries/mbed/common/pinmap_common.c +++ b/libraries/mbed/common/pinmap_common.c @@ -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; } diff --git a/libraries/mbed/common/retarget.cpp b/libraries/mbed/common/retarget.cpp index 35a815916c..168d319a97 100644 --- a/libraries/mbed/common/retarget.cpp +++ b/libraries/mbed/common/retarget.cpp @@ -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; } diff --git a/libraries/mbed/common/rtc_time.c b/libraries/mbed/common/rtc_time.c index d0114e2f51..0405e9adc3 100644 --- a/libraries/mbed/common/rtc_time.c +++ b/libraries/mbed/common/rtc_time.c @@ -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 diff --git a/libraries/mbed/common/us_ticker_api.c b/libraries/mbed/common/us_ticker_api.c index 5b5d780636..434f705938 100644 --- a/libraries/mbed/common/us_ticker_api.c +++ b/libraries/mbed/common/us_ticker_api.c @@ -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(); } diff --git a/libraries/rtos/rtos/Mail.h b/libraries/rtos/rtos/Mail.h index d3e599fc8b..6ee3c29205 100644 --- a/libraries/rtos/rtos/Mail.h +++ b/libraries/rtos/rtos/Mail.h @@ -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) { diff --git a/libraries/rtos/rtos/MemoryPool.h b/libraries/rtos/rtos/MemoryPool.h index db2829b502..d1b812611c 100644 --- a/libraries/rtos/rtos/MemoryPool.h +++ b/libraries/rtos/rtos/MemoryPool.h @@ -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); diff --git a/libraries/rtos/rtos/Mutex.h b/libraries/rtos/rtos/Mutex.h index a897836af1..2a8a7fe4be 100644 --- a/libraries/rtos/rtos/Mutex.h +++ b/libraries/rtos/rtos/Mutex.h @@ -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: diff --git a/libraries/rtos/rtos/Queue.h b/libraries/rtos/rtos/Queue.h index 6cf1222d3c..f4b316a9b2 100644 --- a/libraries/rtos/rtos/Queue.h +++ b/libraries/rtos/rtos/Queue.h @@ -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. diff --git a/libraries/rtos/rtos/RtosTimer.cpp b/libraries/rtos/rtos/RtosTimer.cpp index b68a94428b..2138d3311a 100644 --- a/libraries/rtos/rtos/RtosTimer.cpp +++ b/libraries/rtos/rtos/RtosTimer.cpp @@ -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 diff --git a/libraries/rtos/rtos/RtosTimer.h b/libraries/rtos/rtos/RtosTimer.h index 927cdaec58..9e7004c84d 100644 --- a/libraries/rtos/rtos/RtosTimer.h +++ b/libraries/rtos/rtos/RtosTimer.h @@ -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: diff --git a/libraries/rtos/rtos/Semaphore.h b/libraries/rtos/rtos/Semaphore.h index 253f0a3251..b4d294256a 100644 --- a/libraries/rtos/rtos/Semaphore.h +++ b/libraries/rtos/rtos/Semaphore.h @@ -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: diff --git a/libraries/rtos/rtos/Thread.h b/libraries/rtos/rtos/Thread.h index 0d9007530e..a8911e966b 100644 --- a/libraries/rtos/rtos/Thread.h +++ b/libraries/rtos/rtos/Thread.h @@ -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: diff --git a/libraries/rtos/rtx/HAL_CM.c b/libraries/rtos/rtx/HAL_CM.c index a5a2a9cff2..efbe04c68f 100644 --- a/libraries/rtos/rtx/HAL_CM.c +++ b/libraries/rtos/rtx/HAL_CM.c @@ -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; diff --git a/libraries/rtos/rtx/RTX_CM_lib.h b/libraries/rtos/rtx/RTX_CM_lib.h index 5524f94ffa..f9c9904c49 100644 --- a/libraries/rtos/rtx/RTX_CM_lib.h +++ b/libraries/rtos/rtx/RTX_CM_lib.h @@ -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(); } diff --git a/libraries/rtos/rtx/RTX_Conf.h b/libraries/rtos/rtx/RTX_Conf.h index 9da2dfe3c6..0b0d4613cd 100644 --- a/libraries/rtos/rtx/RTX_Conf.h +++ b/libraries/rtos/rtx/RTX_Conf.h @@ -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. *---------------------------------------------------------------------------*/ diff --git a/libraries/rtos/rtx/RTX_Conf_CM.c b/libraries/rtos/rtx/RTX_Conf_CM.c index 0c5f753ad0..d9da204c5c 100644 --- a/libraries/rtos/rtx/RTX_Conf_CM.c +++ b/libraries/rtos/rtx/RTX_Conf_CM.c @@ -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 -// Processor mode for thread execution -// <0=> Unprivileged mode +// Processor mode for thread execution +// <0=> Unprivileged mode // <1=> Privileged mode // 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. diff --git a/libraries/rtos/rtx/TARGET_M0/TOOLCHAIN_ARM/HAL_CM0.c b/libraries/rtos/rtx/TARGET_M0/TOOLCHAIN_ARM/HAL_CM0.c index 783e908b63..492e94a197 100644 --- a/libraries/rtos/rtx/TARGET_M0/TOOLCHAIN_ARM/HAL_CM0.c +++ b/libraries/rtos/rtx/TARGET_M0/TOOLCHAIN_ARM/HAL_CM0.c @@ -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} diff --git a/libraries/rtos/rtx/TARGET_M0P/TOOLCHAIN_ARM/HAL_CM0.c b/libraries/rtos/rtx/TARGET_M0P/TOOLCHAIN_ARM/HAL_CM0.c index 783e908b63..492e94a197 100644 --- a/libraries/rtos/rtx/TARGET_M0P/TOOLCHAIN_ARM/HAL_CM0.c +++ b/libraries/rtos/rtx/TARGET_M0P/TOOLCHAIN_ARM/HAL_CM0.c @@ -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} diff --git a/libraries/rtos/rtx/TARGET_M3/TOOLCHAIN_ARM/HAL_CM3.c b/libraries/rtos/rtx/TARGET_M3/TOOLCHAIN_ARM/HAL_CM3.c index 93764ba063..feb1457913 100644 --- a/libraries/rtos/rtx/TARGET_M3/TOOLCHAIN_ARM/HAL_CM3.c +++ b/libraries/rtos/rtx/TARGET_M3/TOOLCHAIN_ARM/HAL_CM3.c @@ -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 diff --git a/libraries/rtos/rtx/TARGET_M4/TOOLCHAIN_ARM/HAL_CM4.c b/libraries/rtos/rtx/TARGET_M4/TOOLCHAIN_ARM/HAL_CM4.c index 9c388c173a..32327d83d0 100644 --- a/libraries/rtos/rtx/TARGET_M4/TOOLCHAIN_ARM/HAL_CM4.c +++ b/libraries/rtos/rtx/TARGET_M4/TOOLCHAIN_ARM/HAL_CM4.c @@ -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 diff --git a/libraries/rtos/rtx/cmsis_os.h b/libraries/rtos/rtx/cmsis_os.h index 7890789506..f19a7239b8 100644 --- a/libraries/rtos/rtx/cmsis_os.h +++ b/libraries/rtos/rtx/cmsis_os.h @@ -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 CAN BE CHANGED can be adapted towards the needs of the actual CMSIS-RTOS implementation. + +Definitions that are marked with CAN BE CHANGED 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 MUST REMAIN UNCHANGED 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 \#define osObjectsExternal is +This header file defines all objects when included in a C/C++ source file. When \#define osObjectsExternal 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 diff --git a/libraries/rtos/rtx/os_tcb.h b/libraries/rtos/rtx/os_tcb.h index 00b38beb46..9e18b285eb 100644 --- a/libraries/rtos/rtx/os_tcb.h +++ b/libraries/rtos/rtx/os_tcb.h @@ -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; diff --git a/libraries/rtos/rtx/rt_CMSIS.c b/libraries/rtos/rtx/rt_CMSIS.c index 4524e9df51..246f275280 100644 --- a/libraries/rtos/rtx/rt_CMSIS.c +++ b/libraries/rtos/rtx/rt_CMSIS.c @@ -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 diff --git a/libraries/rtos/rtx/rt_Event.c b/libraries/rtos/rtx/rt_Event.c index d4322c6a25..acd8ccc205 100644 --- a/libraries/rtos/rtx/rt_Event.c +++ b/libraries/rtos/rtx/rt_Event.c @@ -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 diff --git a/libraries/rtos/rtx/rt_Event.h b/libraries/rtos/rtx/rt_Event.h index 7081f370c3..8b92f3c4c4 100644 --- a/libraries/rtos/rtx/rt_Event.h +++ b/libraries/rtos/rtx/rt_Event.h @@ -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. *---------------------------------------------------------------------------*/ diff --git a/libraries/rtos/rtx/rt_HAL_CM.h b/libraries/rtos/rtx/rt_HAL_CM.h index 1c664fc1c7..2ab4b36cc7 100644 --- a/libraries/rtos/rtx/rt_HAL_CM.h +++ b/libraries/rtos/rtx/rt_HAL_CM.h @@ -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 diff --git a/libraries/rtos/rtx/rt_List.c b/libraries/rtos/rtx/rt_List.c index ab984f8750..2134d14b38 100644 --- a/libraries/rtos/rtx/rt_List.c +++ b/libraries/rtos/rtx/rt_List.c @@ -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. *---------------------------------------------------------------------------*/ diff --git a/libraries/rtos/rtx/rt_List.h b/libraries/rtos/rtx/rt_List.h index c9cfe295ad..cb3008e713 100644 --- a/libraries/rtos/rtx/rt_List.h +++ b/libraries/rtos/rtx/rt_List.h @@ -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. *---------------------------------------------------------------------------*/ diff --git a/libraries/rtos/rtx/rt_Mailbox.c b/libraries/rtos/rtx/rt_Mailbox.c index 4357d6a02d..ef28b7639c 100644 --- a/libraries/rtos/rtx/rt_Mailbox.c +++ b/libraries/rtos/rtx/rt_Mailbox.c @@ -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); diff --git a/libraries/rtos/rtx/rt_Mailbox.h b/libraries/rtos/rtx/rt_Mailbox.h index 06a20c0fca..0c8e2f39b2 100644 --- a/libraries/rtos/rtx/rt_Mailbox.h +++ b/libraries/rtos/rtx/rt_Mailbox.h @@ -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. *---------------------------------------------------------------------------*/ diff --git a/libraries/rtos/rtx/rt_MemBox.c b/libraries/rtos/rtx/rt_MemBox.c index 3e20fa7a66..5b96ae0e65 100644 --- a/libraries/rtos/rtx/rt_MemBox.c +++ b/libraries/rtos/rtx/rt_MemBox.c @@ -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; } diff --git a/libraries/rtos/rtx/rt_MemBox.h b/libraries/rtos/rtx/rt_MemBox.h index 52f150f138..c10a1cbe70 100644 --- a/libraries/rtos/rtx/rt_MemBox.h +++ b/libraries/rtos/rtx/rt_MemBox.h @@ -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. *---------------------------------------------------------------------------*/ diff --git a/libraries/rtos/rtx/rt_Mutex.c b/libraries/rtos/rtx/rt_Mutex.c index c8d1c42083..c7a996bb50 100644 --- a/libraries/rtos/rtx/rt_Mutex.c +++ b/libraries/rtos/rtx/rt_Mutex.c @@ -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. */ diff --git a/libraries/rtos/rtx/rt_Mutex.h b/libraries/rtos/rtx/rt_Mutex.h index 4f6b0de8a0..bf15c4d56c 100644 --- a/libraries/rtos/rtx/rt_Mutex.h +++ b/libraries/rtos/rtx/rt_Mutex.h @@ -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. *---------------------------------------------------------------------------*/ diff --git a/libraries/rtos/rtx/rt_Robin.c b/libraries/rtos/rtx/rt_Robin.c index 05f5a307f7..d693dc6524 100644 --- a/libraries/rtos/rtx/rt_Robin.c +++ b/libraries/rtos/rtx/rt_Robin.c @@ -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. *---------------------------------------------------------------------------*/ diff --git a/libraries/rtos/rtx/rt_Robin.h b/libraries/rtos/rtx/rt_Robin.h index eb665ad6ef..3ccbffcffd 100644 --- a/libraries/rtos/rtx/rt_Robin.h +++ b/libraries/rtos/rtx/rt_Robin.h @@ -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. *---------------------------------------------------------------------------*/ diff --git a/libraries/rtos/rtx/rt_Semaphore.c b/libraries/rtos/rtx/rt_Semaphore.c index 7cee8cdb3c..93ff2bf083 100644 --- a/libraries/rtos/rtx/rt_Semaphore.c +++ b/libraries/rtos/rtx/rt_Semaphore.c @@ -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. *---------------------------------------------------------------------------*/ diff --git a/libraries/rtos/rtx/rt_Semaphore.h b/libraries/rtos/rtx/rt_Semaphore.h index 5b04480282..ec4548000b 100644 --- a/libraries/rtos/rtx/rt_Semaphore.h +++ b/libraries/rtos/rtx/rt_Semaphore.h @@ -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. *---------------------------------------------------------------------------*/ diff --git a/libraries/rtos/rtx/rt_System.c b/libraries/rtos/rtx/rt_System.c index 3eef20f540..f48b67bc2b 100644 --- a/libraries/rtos/rtx/rt_System.c +++ b/libraries/rtos/rtx/rt_System.c @@ -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); diff --git a/libraries/rtos/rtx/rt_System.h b/libraries/rtos/rtx/rt_System.h index aff9aa662d..91db6487e0 100644 --- a/libraries/rtos/rtx/rt_System.h +++ b/libraries/rtos/rtx/rt_System.h @@ -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. *---------------------------------------------------------------------------*/ diff --git a/libraries/rtos/rtx/rt_Task.c b/libraries/rtos/rtx/rt_Task.c index f5504e2db8..518f78fefb 100644 --- a/libraries/rtos/rtx/rt_Task.c +++ b/libraries/rtos/rtx/rt_Task.c @@ -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. *---------------------------------------------------------------------------*/ @@ -232,7 +232,7 @@ OS_RESULT rt_tsk_delete (OS_TID task_id) { os_tsk.run->tsk_stack = rt_get_PSP (); rt_stk_check (); os_active_TCB[os_tsk.run->task_id-1] = NULL; - + os_tsk.run->stack = NULL; DBG_TASK_NOTIFY(os_tsk.run, __FALSE); os_tsk.run = NULL; @@ -249,7 +249,7 @@ OS_RESULT rt_tsk_delete (OS_TID task_id) { rt_rmv_list (task_context); rt_rmv_dly (task_context); os_active_TCB[task_id-1] = NULL; - + task_context->stack = NULL; DBG_TASK_NOTIFY(task_context, __FALSE); } @@ -273,7 +273,7 @@ void rt_sys_init (FUNCP first_task, U32 prio_stksz, void *stk) { for (i = 0; i < os_maxtaskrun; i++) { os_active_TCB[i] = NULL; } - + /* Set up TCB of idle demon */ os_idle_TCB.task_id = 255; os_idle_TCB.priv_stack = idle_task_stack_size; diff --git a/libraries/rtos/rtx/rt_Task.h b/libraries/rtos/rtx/rt_Task.h index edf3830387..9d3727b5a6 100644 --- a/libraries/rtos/rtx/rt_Task.h +++ b/libraries/rtos/rtx/rt_Task.h @@ -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. *---------------------------------------------------------------------------*/ diff --git a/libraries/rtos/rtx/rt_Time.c b/libraries/rtos/rtx/rt_Time.c index e44e36e3a7..b02ccebbad 100644 --- a/libraries/rtos/rtx/rt_Time.c +++ b/libraries/rtos/rtx/rt_Time.c @@ -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. *---------------------------------------------------------------------------*/ diff --git a/libraries/rtos/rtx/rt_Time.h b/libraries/rtos/rtx/rt_Time.h index e6bae1a6e2..27706373d5 100644 --- a/libraries/rtos/rtx/rt_Time.h +++ b/libraries/rtos/rtx/rt_Time.h @@ -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. *---------------------------------------------------------------------------*/ diff --git a/libraries/rtos/rtx/rt_TypeDef.h b/libraries/rtos/rtx/rt_TypeDef.h index faa56f7f05..2adbe88cd8 100644 --- a/libraries/rtos/rtx/rt_TypeDef.h +++ b/libraries/rtos/rtx/rt_TypeDef.h @@ -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. *---------------------------------------------------------------------------*/ diff --git a/libraries/tests/KL25Z/lptmr/main.cpp b/libraries/tests/KL25Z/lptmr/main.cpp index e7e1d84950..170fc46987 100644 --- a/libraries/tests/KL25Z/lptmr/main.cpp +++ b/libraries/tests/KL25Z/lptmr/main.cpp @@ -7,40 +7,40 @@ DigitalOut led(LED_BLUE); extern "C" void lptmr_isr(void) { // write 1 to TCF to clear the LPT timer compare flag LPTMR0->CSR |= LPTMR_CSR_TCF_MASK; - + ticks++; } int main() { /* Clock the timer */ SIM->SCGC5 |= SIM_SCGC5_LPTMR_MASK; - + /* Reset */ LPTMR0->CSR = 0; - + /* Compare value */ LPTMR0->CMR = 1000; - + /* Enable interrupt */ LPTMR0->CSR |= LPTMR_CSR_TIE_MASK; - + /* Set interrupt handler */ NVIC_SetVector(LPTimer_IRQn, (uint32_t)lptmr_isr); NVIC_EnableIRQ(LPTimer_IRQn); - + /* select LPO for RTC and LPTMR */ LPTMR0->PSR = LPTMR_PSR_PCS(3); // ERCLK32K -> 8MHz LPTMR0->PSR |= LPTMR_PSR_PRESCALE(2); // divide by 8 - + /* Start the timer */ LPTMR0->CSR |= LPTMR_CSR_TEN_MASK; - + led = 0; while (true) { wait(1); led = 1; printf("%d\n", ticks); - + wait(1); led = 0; printf("%d\n", ticks); diff --git a/libraries/tests/KL25Z/pit/main.cpp b/libraries/tests/KL25Z/pit/main.cpp index e4bbc7f639..3b13af2730 100644 --- a/libraries/tests/KL25Z/pit/main.cpp +++ b/libraries/tests/KL25Z/pit/main.cpp @@ -9,7 +9,7 @@ void SysTick_Handler(void) { void Delay(uint32_t dlyTicks) { uint32_t curTicks; - + curTicks = msTicks; while ((msTicks - curTicks) < dlyTicks); } @@ -17,32 +17,32 @@ void Delay(uint32_t dlyTicks) { int main() { SysTick_Config(SystemCoreClock / 1000); - + SIM->SCGC6 |= SIM_SCGC6_PIT_MASK; // Clock PIT PIT->MCR = 0; // Enable PIT - + // Timer 1 PIT->CHANNEL[1].LDVAL = 0xFFFFFFFF; PIT->CHANNEL[1].TCTRL = 0x0; // Disable Interrupts PIT->CHANNEL[1].TCTRL |= PIT_TCTRL_CHN_MASK; // Chain to timer 0 PIT->CHANNEL[1].TCTRL |= PIT_TCTRL_TEN_MASK; // Start timer 1 - + // Timer 2 PIT->CHANNEL[0].LDVAL = 0xFFFFFFFF; PIT->CHANNEL[0].TCTRL = PIT_TCTRL_TEN_MASK; // Start timer 0, disable interrupts - + DigitalOut led(LED_BLUE); while (true) { Delay(1000); led = !led; - + uint64_t ticks = (uint64_t)PIT->LTMR64H << 32; ticks |= (uint64_t)PIT->LTMR64L; printf("ticks: 0x%x%x\n", (uint32_t)(ticks>>32), (uint32_t)(ticks & 0xFFFFFFFF)); - + ticks = (~ticks) / 24; uint32_t us = (uint32_t)(0xFFFFFFFF & ticks); - + printf("us : 0x%x\n", us); } } diff --git a/libraries/tests/KL25Z/rtc/main.cpp b/libraries/tests/KL25Z/rtc/main.cpp index 393f5b42c5..31d7e64d26 100644 --- a/libraries/tests/KL25Z/rtc/main.cpp +++ b/libraries/tests/KL25Z/rtc/main.cpp @@ -23,21 +23,21 @@ void rtc_init(void) { // enable the clock to SRTC module register space SIM->SCGC6 |= SIM_SCGC6_RTC_MASK; SIM->SOPT1 = (SIM->SOPT1 & ~SIM_SOPT1_OSC32KSEL_MASK) | SIM_SOPT1_OSC32KSEL(0); - + // disable interrupts NVIC_DisableIRQ(RTC_Seconds_IRQn); NVIC_DisableIRQ(RTC_IRQn); - + // Reset - RTC->CR = RTC_CR_SWR_MASK; + RTC->CR = RTC_CR_SWR_MASK; RTC->CR &= ~RTC_CR_SWR_MASK; - + // Allow write RTC->CR = RTC_CR_UM_MASK | RTC_CR_SUP_MASK; - + NVIC_EnableIRQ(RTC_Seconds_IRQn); NVIC_EnableIRQ(RTC_Seconds_IRQn); - + printf("LR: 0x%x\n", RTC->LR); printf("CR: 0x%x\n", RTC->CR); wait(1); @@ -45,25 +45,25 @@ void rtc_init(void) { RTC->TSR = 0; } RTC->TCR = 0; - + // After setting this bit, wait the oscillator startup time before enabling // the time counter to allow the clock time to stabilize RTC->CR |= RTC_CR_OSCE_MASK; for (volatile int i=0; i<0x600000; i++); - + //enable seconds interrupts RTC->IER |= RTC_IER_TSIE_MASK; - + // enable time counter RTC->SR |= RTC_SR_TCE_MASK; - - + + } int main() { error_led = 1; rtc_init(); - + while (true) { wait(1); status_led = !status_led; diff --git a/libraries/tests/benchmarks/all/main.cpp b/libraries/tests/benchmarks/all/main.cpp index 4752c5e6cc..a3794f1005 100644 --- a/libraries/tests/benchmarks/all/main.cpp +++ b/libraries/tests/benchmarks/all/main.cpp @@ -11,7 +11,7 @@ volatile float w, x, y, z; int main() { while(1) { z = x * y / w; - printf("Hello World %d %f\n", out.read(), z); + printf("Hello World %d %f\n", out.read(), z); if(in > 0.5) { out = !out; } diff --git a/libraries/tests/dsp/cmsis/fir_f32/data.cpp b/libraries/tests/dsp/cmsis/fir_f32/data.cpp index e2e9ad658b..d946b36bc1 100644 --- a/libraries/tests/dsp/cmsis/fir_f32/data.cpp +++ b/libraries/tests/dsp/cmsis/fir_f32/data.cpp @@ -6,89 +6,89 @@ float32_t testInput_f32_1kHz_15kHz[320] = { -+0.0000000000f, +0.5924659585f, -0.0947343455f, +0.1913417162f, +1.0000000000f, +0.4174197128f, +0.3535533906f, +1.2552931065f, -+0.8660254038f, +0.4619397663f, +1.3194792169f, +1.1827865776f, +0.5000000000f, +1.1827865776f, +1.3194792169f, +0.4619397663f, -+0.8660254038f, +1.2552931065f, +0.3535533906f, +0.4174197128f, +1.0000000000f, +0.1913417162f, -0.0947343455f, +0.5924659585f, --0.0000000000f, -0.5924659585f, +0.0947343455f, -0.1913417162f, -1.0000000000f, -0.4174197128f, -0.3535533906f, -1.2552931065f, --0.8660254038f, -0.4619397663f, -1.3194792169f, -1.1827865776f, -0.5000000000f, -1.1827865776f, -1.3194792169f, -0.4619397663f, --0.8660254038f, -1.2552931065f, -0.3535533906f, -0.4174197128f, -1.0000000000f, -0.1913417162f, +0.0947343455f, -0.5924659585f, -+0.0000000000f, +0.5924659585f, -0.0947343455f, +0.1913417162f, +1.0000000000f, +0.4174197128f, +0.3535533906f, +1.2552931065f, -+0.8660254038f, +0.4619397663f, +1.3194792169f, +1.1827865776f, +0.5000000000f, +1.1827865776f, +1.3194792169f, +0.4619397663f, -+0.8660254038f, +1.2552931065f, +0.3535533906f, +0.4174197128f, +1.0000000000f, +0.1913417162f, -0.0947343455f, +0.5924659585f, -+0.0000000000f, -0.5924659585f, +0.0947343455f, -0.1913417162f, -1.0000000000f, -0.4174197128f, -0.3535533906f, -1.2552931065f, --0.8660254038f, -0.4619397663f, -1.3194792169f, -1.1827865776f, -0.5000000000f, -1.1827865776f, -1.3194792169f, -0.4619397663f, --0.8660254038f, -1.2552931065f, -0.3535533906f, -0.4174197128f, -1.0000000000f, -0.1913417162f, +0.0947343455f, -0.5924659585f, -+0.0000000000f, +0.5924659585f, -0.0947343455f, +0.1913417162f, +1.0000000000f, +0.4174197128f, +0.3535533906f, +1.2552931065f, -+0.8660254038f, +0.4619397663f, +1.3194792169f, +1.1827865776f, +0.5000000000f, +1.1827865776f, +1.3194792169f, +0.4619397663f, -+0.8660254038f, +1.2552931065f, +0.3535533906f, +0.4174197128f, +1.0000000000f, +0.1913417162f, -0.0947343455f, +0.5924659585f, -+0.0000000000f, -0.5924659585f, +0.0947343455f, -0.1913417162f, -1.0000000000f, -0.4174197128f, -0.3535533906f, -1.2552931065f, --0.8660254038f, -0.4619397663f, -1.3194792169f, -1.1827865776f, -0.5000000000f, -1.1827865776f, -1.3194792169f, -0.4619397663f, --0.8660254038f, -1.2552931065f, -0.3535533906f, -0.4174197128f, -1.0000000000f, -0.1913417162f, +0.0947343455f, -0.5924659585f, --0.0000000000f, +0.5924659585f, -0.0947343455f, +0.1913417162f, +1.0000000000f, +0.4174197128f, +0.3535533906f, +1.2552931065f, -+0.8660254038f, +0.4619397663f, +1.3194792169f, +1.1827865776f, +0.5000000000f, +1.1827865776f, +1.3194792169f, +0.4619397663f, -+0.8660254038f, +1.2552931065f, +0.3535533906f, +0.4174197128f, +1.0000000000f, +0.1913417162f, -0.0947343455f, +0.5924659585f, --0.0000000000f, -0.5924659585f, +0.0947343455f, -0.1913417162f, -1.0000000000f, -0.4174197128f, -0.3535533906f, -1.2552931065f, --0.8660254038f, -0.4619397663f, -1.3194792169f, -1.1827865776f, -0.5000000000f, -1.1827865776f, -1.3194792169f, -0.4619397663f, --0.8660254038f, -1.2552931065f, -0.3535533906f, -0.4174197128f, -1.0000000000f, -0.1913417162f, +0.0947343455f, -0.5924659585f, -+0.0000000000f, +0.5924659585f, -0.0947343455f, +0.1913417162f, +1.0000000000f, +0.4174197128f, +0.3535533906f, +1.2552931065f, -+0.8660254038f, +0.4619397663f, +1.3194792169f, +1.1827865776f, +0.5000000000f, +1.1827865776f, +1.3194792169f, +0.4619397663f, -+0.8660254038f, +1.2552931065f, +0.3535533906f, +0.4174197128f, +1.0000000000f, +0.1913417162f, -0.0947343455f, +0.5924659585f, -+0.0000000000f, -0.5924659585f, +0.0947343455f, -0.1913417162f, -1.0000000000f, -0.4174197128f, -0.3535533906f, -1.2552931065f, --0.8660254038f, -0.4619397663f, -1.3194792169f, -1.1827865776f, -0.5000000000f, -1.1827865776f, -1.3194792169f, -0.4619397663f, --0.8660254038f, -1.2552931065f, -0.3535533906f, -0.4174197128f, -1.0000000000f, -0.1913417162f, +0.0947343455f, -0.5924659585f, --0.0000000000f, +0.5924659585f, -0.0947343455f, +0.1913417162f, +1.0000000000f, +0.4174197128f, +0.3535533906f, +1.2552931065f, -+0.8660254038f, +0.4619397663f, +1.3194792169f, +1.1827865776f, +0.5000000000f, +1.1827865776f, +1.3194792169f, +0.4619397663f, -+0.8660254038f, +1.2552931065f, +0.3535533906f, +0.4174197128f, +1.0000000000f, +0.1913417162f, -0.0947343455f, +0.5924659585f, -+0.0000000000f, -0.5924659585f, +0.0947343455f, -0.1913417162f, -1.0000000000f, -0.4174197128f, -0.3535533906f, -1.2552931065f, --0.8660254038f, -0.4619397663f, -1.3194792169f, -1.1827865776f, -0.5000000000f, -1.1827865776f, -1.3194792169f, -0.4619397663f, --0.8660254038f, -1.2552931065f, -0.3535533906f, -0.4174197128f, -1.0000000000f, -0.1913417162f, +0.0947343455f, -0.5924659585f, --0.0000000000f, +0.5924659585f, -0.0947343455f, +0.1913417162f, +1.0000000000f, +0.4174197128f, +0.3535533906f, +1.2552931065f, -+0.8660254038f, +0.4619397663f, +1.3194792169f, +1.1827865776f, +0.5000000000f, +1.1827865776f, +1.3194792169f, +0.4619397663f, -+0.8660254038f, +1.2552931065f, +0.3535533906f, +0.4174197128f, +1.0000000000f, +0.1913417162f, -0.0947343455f, +0.5924659585f, -+0.0000000000f, -0.5924659585f, +0.0947343455f, -0.1913417162f, -1.0000000000f, -0.4174197128f, -0.3535533906f, -1.2552931065f, ++0.0000000000f, +0.5924659585f, -0.0947343455f, +0.1913417162f, +1.0000000000f, +0.4174197128f, +0.3535533906f, +1.2552931065f, ++0.8660254038f, +0.4619397663f, +1.3194792169f, +1.1827865776f, +0.5000000000f, +1.1827865776f, +1.3194792169f, +0.4619397663f, ++0.8660254038f, +1.2552931065f, +0.3535533906f, +0.4174197128f, +1.0000000000f, +0.1913417162f, -0.0947343455f, +0.5924659585f, +-0.0000000000f, -0.5924659585f, +0.0947343455f, -0.1913417162f, -1.0000000000f, -0.4174197128f, -0.3535533906f, -1.2552931065f, +-0.8660254038f, -0.4619397663f, -1.3194792169f, -1.1827865776f, -0.5000000000f, -1.1827865776f, -1.3194792169f, -0.4619397663f, +-0.8660254038f, -1.2552931065f, -0.3535533906f, -0.4174197128f, -1.0000000000f, -0.1913417162f, +0.0947343455f, -0.5924659585f, ++0.0000000000f, +0.5924659585f, -0.0947343455f, +0.1913417162f, +1.0000000000f, +0.4174197128f, +0.3535533906f, +1.2552931065f, ++0.8660254038f, +0.4619397663f, +1.3194792169f, +1.1827865776f, +0.5000000000f, +1.1827865776f, +1.3194792169f, +0.4619397663f, ++0.8660254038f, +1.2552931065f, +0.3535533906f, +0.4174197128f, +1.0000000000f, +0.1913417162f, -0.0947343455f, +0.5924659585f, ++0.0000000000f, -0.5924659585f, +0.0947343455f, -0.1913417162f, -1.0000000000f, -0.4174197128f, -0.3535533906f, -1.2552931065f, +-0.8660254038f, -0.4619397663f, -1.3194792169f, -1.1827865776f, -0.5000000000f, -1.1827865776f, -1.3194792169f, -0.4619397663f, +-0.8660254038f, -1.2552931065f, -0.3535533906f, -0.4174197128f, -1.0000000000f, -0.1913417162f, +0.0947343455f, -0.5924659585f, ++0.0000000000f, +0.5924659585f, -0.0947343455f, +0.1913417162f, +1.0000000000f, +0.4174197128f, +0.3535533906f, +1.2552931065f, ++0.8660254038f, +0.4619397663f, +1.3194792169f, +1.1827865776f, +0.5000000000f, +1.1827865776f, +1.3194792169f, +0.4619397663f, ++0.8660254038f, +1.2552931065f, +0.3535533906f, +0.4174197128f, +1.0000000000f, +0.1913417162f, -0.0947343455f, +0.5924659585f, ++0.0000000000f, -0.5924659585f, +0.0947343455f, -0.1913417162f, -1.0000000000f, -0.4174197128f, -0.3535533906f, -1.2552931065f, +-0.8660254038f, -0.4619397663f, -1.3194792169f, -1.1827865776f, -0.5000000000f, -1.1827865776f, -1.3194792169f, -0.4619397663f, +-0.8660254038f, -1.2552931065f, -0.3535533906f, -0.4174197128f, -1.0000000000f, -0.1913417162f, +0.0947343455f, -0.5924659585f, +-0.0000000000f, +0.5924659585f, -0.0947343455f, +0.1913417162f, +1.0000000000f, +0.4174197128f, +0.3535533906f, +1.2552931065f, ++0.8660254038f, +0.4619397663f, +1.3194792169f, +1.1827865776f, +0.5000000000f, +1.1827865776f, +1.3194792169f, +0.4619397663f, ++0.8660254038f, +1.2552931065f, +0.3535533906f, +0.4174197128f, +1.0000000000f, +0.1913417162f, -0.0947343455f, +0.5924659585f, +-0.0000000000f, -0.5924659585f, +0.0947343455f, -0.1913417162f, -1.0000000000f, -0.4174197128f, -0.3535533906f, -1.2552931065f, +-0.8660254038f, -0.4619397663f, -1.3194792169f, -1.1827865776f, -0.5000000000f, -1.1827865776f, -1.3194792169f, -0.4619397663f, +-0.8660254038f, -1.2552931065f, -0.3535533906f, -0.4174197128f, -1.0000000000f, -0.1913417162f, +0.0947343455f, -0.5924659585f, ++0.0000000000f, +0.5924659585f, -0.0947343455f, +0.1913417162f, +1.0000000000f, +0.4174197128f, +0.3535533906f, +1.2552931065f, ++0.8660254038f, +0.4619397663f, +1.3194792169f, +1.1827865776f, +0.5000000000f, +1.1827865776f, +1.3194792169f, +0.4619397663f, ++0.8660254038f, +1.2552931065f, +0.3535533906f, +0.4174197128f, +1.0000000000f, +0.1913417162f, -0.0947343455f, +0.5924659585f, ++0.0000000000f, -0.5924659585f, +0.0947343455f, -0.1913417162f, -1.0000000000f, -0.4174197128f, -0.3535533906f, -1.2552931065f, +-0.8660254038f, -0.4619397663f, -1.3194792169f, -1.1827865776f, -0.5000000000f, -1.1827865776f, -1.3194792169f, -0.4619397663f, +-0.8660254038f, -1.2552931065f, -0.3535533906f, -0.4174197128f, -1.0000000000f, -0.1913417162f, +0.0947343455f, -0.5924659585f, +-0.0000000000f, +0.5924659585f, -0.0947343455f, +0.1913417162f, +1.0000000000f, +0.4174197128f, +0.3535533906f, +1.2552931065f, ++0.8660254038f, +0.4619397663f, +1.3194792169f, +1.1827865776f, +0.5000000000f, +1.1827865776f, +1.3194792169f, +0.4619397663f, ++0.8660254038f, +1.2552931065f, +0.3535533906f, +0.4174197128f, +1.0000000000f, +0.1913417162f, -0.0947343455f, +0.5924659585f, ++0.0000000000f, -0.5924659585f, +0.0947343455f, -0.1913417162f, -1.0000000000f, -0.4174197128f, -0.3535533906f, -1.2552931065f, +-0.8660254038f, -0.4619397663f, -1.3194792169f, -1.1827865776f, -0.5000000000f, -1.1827865776f, -1.3194792169f, -0.4619397663f, +-0.8660254038f, -1.2552931065f, -0.3535533906f, -0.4174197128f, -1.0000000000f, -0.1913417162f, +0.0947343455f, -0.5924659585f, +-0.0000000000f, +0.5924659585f, -0.0947343455f, +0.1913417162f, +1.0000000000f, +0.4174197128f, +0.3535533906f, +1.2552931065f, ++0.8660254038f, +0.4619397663f, +1.3194792169f, +1.1827865776f, +0.5000000000f, +1.1827865776f, +1.3194792169f, +0.4619397663f, ++0.8660254038f, +1.2552931065f, +0.3535533906f, +0.4174197128f, +1.0000000000f, +0.1913417162f, -0.0947343455f, +0.5924659585f, ++0.0000000000f, -0.5924659585f, +0.0947343455f, -0.1913417162f, -1.0000000000f, -0.4174197128f, -0.3535533906f, -1.2552931065f, }; -float32_t refOutput[320] = +float32_t refOutput[320] = { -+0.0000000000f, -0.0010797829f, -0.0007681386f, -0.0001982932f, +0.0000644313f, +0.0020854271f, +0.0036891871f, +0.0015855941f, --0.0026280805f, -0.0075907658f, -0.0119390538f, -0.0086665968f, +0.0088981202f, +0.0430539279f, +0.0974468742f, +0.1740405600f, -+0.2681416601f, +0.3747720089f, +0.4893362230f, +0.6024154672f, +0.7058740791f, +0.7968348987f, +0.8715901940f, +0.9277881093f, -+0.9682182661f, +0.9934674267f, +1.0012052245f, +0.9925859371f, +0.9681538347f, +0.9257026822f, +0.8679010068f, +0.7952493046f, -+0.7085021596f, +0.6100062330f, +0.5012752767f, +0.3834386057f, +0.2592435399f, +0.1309866321f, -0.0000000000f, -0.1309866321f, --0.2592435399f, -0.3834386057f, -0.5012752767f, -0.6100062330f, -0.7085021596f, -0.7952493046f, -0.8679010068f, -0.9257026822f, --0.9681538347f, -0.9936657199f, -1.0019733630f, -0.9936657199f, -0.9681538347f, -0.9257026822f, -0.8679010068f, -0.7952493046f, --0.7085021596f, -0.6100062330f, -0.5012752767f, -0.3834386057f, -0.2592435399f, -0.1309866321f, +0.0000000000f, +0.1309866321f, -+0.2592435399f, +0.3834386057f, +0.5012752767f, +0.6100062330f, +0.7085021596f, +0.7952493046f, +0.8679010068f, +0.9257026822f, -+0.9681538347f, +0.9936657199f, +1.0019733630f, +0.9936657199f, +0.9681538347f, +0.9257026822f, +0.8679010068f, +0.7952493046f, -+0.7085021596f, +0.6100062330f, +0.5012752767f, +0.3834386057f, +0.2592435399f, +0.1309866321f, -0.0000000000f, -0.1309866321f, --0.2592435399f, -0.3834386057f, -0.5012752767f, -0.6100062330f, -0.7085021596f, -0.7952493046f, -0.8679010068f, -0.9257026822f, --0.9681538347f, -0.9936657199f, -1.0019733630f, -0.9936657199f, -0.9681538347f, -0.9257026822f, -0.8679010068f, -0.7952493046f, --0.7085021596f, -0.6100062330f, -0.5012752767f, -0.3834386057f, -0.2592435399f, -0.1309866321f, +0.0000000000f, +0.1309866321f, -+0.2592435399f, +0.3834386057f, +0.5012752767f, +0.6100062330f, +0.7085021596f, +0.7952493046f, +0.8679010068f, +0.9257026822f, -+0.9681538347f, +0.9936657199f, +1.0019733630f, +0.9936657199f, +0.9681538347f, +0.9257026822f, +0.8679010068f, +0.7952493046f, -+0.7085021596f, +0.6100062330f, +0.5012752767f, +0.3834386057f, +0.2592435399f, +0.1309866321f, -0.0000000000f, -0.1309866321f, --0.2592435399f, -0.3834386057f, -0.5012752767f, -0.6100062330f, -0.7085021596f, -0.7952493046f, -0.8679010068f, -0.9257026822f, --0.9681538347f, -0.9936657199f, -1.0019733630f, -0.9936657199f, -0.9681538347f, -0.9257026822f, -0.8679010068f, -0.7952493046f, --0.7085021596f, -0.6100062330f, -0.5012752767f, -0.3834386057f, -0.2592435399f, -0.1309866321f, +0.0000000000f, +0.1309866321f, -+0.2592435399f, +0.3834386057f, +0.5012752767f, +0.6100062330f, +0.7085021596f, +0.7952493046f, +0.8679010068f, +0.9257026822f, -+0.9681538347f, +0.9936657199f, +1.0019733630f, +0.9936657199f, +0.9681538347f, +0.9257026822f, +0.8679010068f, +0.7952493046f, -+0.7085021596f, +0.6100062330f, +0.5012752767f, +0.3834386057f, +0.2592435399f, +0.1309866321f, +0.0000000000f, -0.1309866321f, --0.2592435399f, -0.3834386057f, -0.5012752767f, -0.6100062330f, -0.7085021596f, -0.7952493046f, -0.8679010068f, -0.9257026822f, --0.9681538347f, -0.9936657199f, -1.0019733630f, -0.9936657199f, -0.9681538347f, -0.9257026822f, -0.8679010068f, -0.7952493046f, --0.7085021596f, -0.6100062330f, -0.5012752767f, -0.3834386057f, -0.2592435399f, -0.1309866321f, +0.0000000000f, +0.1309866321f, -+0.2592435399f, +0.3834386057f, +0.5012752767f, +0.6100062330f, +0.7085021596f, +0.7952493046f, +0.8679010068f, +0.9257026822f, -+0.9681538347f, +0.9936657199f, +1.0019733630f, +0.9936657199f, +0.9681538347f, +0.9257026822f, +0.8679010068f, +0.7952493046f, -+0.7085021596f, +0.6100062330f, +0.5012752767f, +0.3834386057f, +0.2592435399f, +0.1309866321f, +0.0000000000f, -0.1309866321f, --0.2592435399f, -0.3834386057f, -0.5012752767f, -0.6100062330f, -0.7085021596f, -0.7952493046f, -0.8679010068f, -0.9257026822f, --0.9681538347f, -0.9936657199f, -1.0019733630f, -0.9936657199f, -0.9681538347f, -0.9257026822f, -0.8679010068f, -0.7952493046f, --0.7085021596f, -0.6100062330f, -0.5012752767f, -0.3834386057f, -0.2592435399f, -0.1309866321f, -0.0000000000f, +0.1309866321f, -+0.2592435399f, +0.3834386057f, +0.5012752767f, +0.6100062330f, +0.7085021596f, +0.7952493046f, +0.8679010068f, +0.9257026822f, -+0.9681538347f, +0.9936657199f, +1.0019733630f, +0.9936657199f, +0.9681538347f, +0.9257026822f, +0.8679010068f, +0.7952493046f, -+0.7085021596f, +0.6100062330f, +0.5012752767f, +0.3834386057f, +0.2592435399f, +0.1309866321f, +0.0000000000f, -0.1309866321f, --0.2592435399f, -0.3834386057f, -0.5012752767f, -0.6100062330f, -0.7085021596f, -0.7952493046f, -0.8679010068f, -0.9257026822f, --0.9681538347f, -0.9936657199f, -1.0019733630f, -0.9936657199f, -0.9681538347f, -0.9257026822f, -0.8679010068f, -0.7952493046f, --0.7085021596f, -0.6100062330f, -0.5012752767f, -0.3834386057f, -0.2592435399f, -0.1309866321f, +0.0000000000f, +0.1309866321f, -+0.2592435399f, +0.3834386057f, +0.5012752767f, +0.6100062330f, +0.7085021596f, +0.7952493046f, +0.8679010068f, +0.9257026822f, -+0.9681538347f, +0.9936657199f, +1.0019733630f, +0.9936657199f, +0.9681538347f, +0.9257026822f, +0.8679010068f, +0.7952493046f ++0.0000000000f, -0.0010797829f, -0.0007681386f, -0.0001982932f, +0.0000644313f, +0.0020854271f, +0.0036891871f, +0.0015855941f, +-0.0026280805f, -0.0075907658f, -0.0119390538f, -0.0086665968f, +0.0088981202f, +0.0430539279f, +0.0974468742f, +0.1740405600f, ++0.2681416601f, +0.3747720089f, +0.4893362230f, +0.6024154672f, +0.7058740791f, +0.7968348987f, +0.8715901940f, +0.9277881093f, ++0.9682182661f, +0.9934674267f, +1.0012052245f, +0.9925859371f, +0.9681538347f, +0.9257026822f, +0.8679010068f, +0.7952493046f, ++0.7085021596f, +0.6100062330f, +0.5012752767f, +0.3834386057f, +0.2592435399f, +0.1309866321f, -0.0000000000f, -0.1309866321f, +-0.2592435399f, -0.3834386057f, -0.5012752767f, -0.6100062330f, -0.7085021596f, -0.7952493046f, -0.8679010068f, -0.9257026822f, +-0.9681538347f, -0.9936657199f, -1.0019733630f, -0.9936657199f, -0.9681538347f, -0.9257026822f, -0.8679010068f, -0.7952493046f, +-0.7085021596f, -0.6100062330f, -0.5012752767f, -0.3834386057f, -0.2592435399f, -0.1309866321f, +0.0000000000f, +0.1309866321f, ++0.2592435399f, +0.3834386057f, +0.5012752767f, +0.6100062330f, +0.7085021596f, +0.7952493046f, +0.8679010068f, +0.9257026822f, ++0.9681538347f, +0.9936657199f, +1.0019733630f, +0.9936657199f, +0.9681538347f, +0.9257026822f, +0.8679010068f, +0.7952493046f, ++0.7085021596f, +0.6100062330f, +0.5012752767f, +0.3834386057f, +0.2592435399f, +0.1309866321f, -0.0000000000f, -0.1309866321f, +-0.2592435399f, -0.3834386057f, -0.5012752767f, -0.6100062330f, -0.7085021596f, -0.7952493046f, -0.8679010068f, -0.9257026822f, +-0.9681538347f, -0.9936657199f, -1.0019733630f, -0.9936657199f, -0.9681538347f, -0.9257026822f, -0.8679010068f, -0.7952493046f, +-0.7085021596f, -0.6100062330f, -0.5012752767f, -0.3834386057f, -0.2592435399f, -0.1309866321f, +0.0000000000f, +0.1309866321f, ++0.2592435399f, +0.3834386057f, +0.5012752767f, +0.6100062330f, +0.7085021596f, +0.7952493046f, +0.8679010068f, +0.9257026822f, ++0.9681538347f, +0.9936657199f, +1.0019733630f, +0.9936657199f, +0.9681538347f, +0.9257026822f, +0.8679010068f, +0.7952493046f, ++0.7085021596f, +0.6100062330f, +0.5012752767f, +0.3834386057f, +0.2592435399f, +0.1309866321f, -0.0000000000f, -0.1309866321f, +-0.2592435399f, -0.3834386057f, -0.5012752767f, -0.6100062330f, -0.7085021596f, -0.7952493046f, -0.8679010068f, -0.9257026822f, +-0.9681538347f, -0.9936657199f, -1.0019733630f, -0.9936657199f, -0.9681538347f, -0.9257026822f, -0.8679010068f, -0.7952493046f, +-0.7085021596f, -0.6100062330f, -0.5012752767f, -0.3834386057f, -0.2592435399f, -0.1309866321f, +0.0000000000f, +0.1309866321f, ++0.2592435399f, +0.3834386057f, +0.5012752767f, +0.6100062330f, +0.7085021596f, +0.7952493046f, +0.8679010068f, +0.9257026822f, ++0.9681538347f, +0.9936657199f, +1.0019733630f, +0.9936657199f, +0.9681538347f, +0.9257026822f, +0.8679010068f, +0.7952493046f, ++0.7085021596f, +0.6100062330f, +0.5012752767f, +0.3834386057f, +0.2592435399f, +0.1309866321f, +0.0000000000f, -0.1309866321f, +-0.2592435399f, -0.3834386057f, -0.5012752767f, -0.6100062330f, -0.7085021596f, -0.7952493046f, -0.8679010068f, -0.9257026822f, +-0.9681538347f, -0.9936657199f, -1.0019733630f, -0.9936657199f, -0.9681538347f, -0.9257026822f, -0.8679010068f, -0.7952493046f, +-0.7085021596f, -0.6100062330f, -0.5012752767f, -0.3834386057f, -0.2592435399f, -0.1309866321f, +0.0000000000f, +0.1309866321f, ++0.2592435399f, +0.3834386057f, +0.5012752767f, +0.6100062330f, +0.7085021596f, +0.7952493046f, +0.8679010068f, +0.9257026822f, ++0.9681538347f, +0.9936657199f, +1.0019733630f, +0.9936657199f, +0.9681538347f, +0.9257026822f, +0.8679010068f, +0.7952493046f, ++0.7085021596f, +0.6100062330f, +0.5012752767f, +0.3834386057f, +0.2592435399f, +0.1309866321f, +0.0000000000f, -0.1309866321f, +-0.2592435399f, -0.3834386057f, -0.5012752767f, -0.6100062330f, -0.7085021596f, -0.7952493046f, -0.8679010068f, -0.9257026822f, +-0.9681538347f, -0.9936657199f, -1.0019733630f, -0.9936657199f, -0.9681538347f, -0.9257026822f, -0.8679010068f, -0.7952493046f, +-0.7085021596f, -0.6100062330f, -0.5012752767f, -0.3834386057f, -0.2592435399f, -0.1309866321f, -0.0000000000f, +0.1309866321f, ++0.2592435399f, +0.3834386057f, +0.5012752767f, +0.6100062330f, +0.7085021596f, +0.7952493046f, +0.8679010068f, +0.9257026822f, ++0.9681538347f, +0.9936657199f, +1.0019733630f, +0.9936657199f, +0.9681538347f, +0.9257026822f, +0.8679010068f, +0.7952493046f, ++0.7085021596f, +0.6100062330f, +0.5012752767f, +0.3834386057f, +0.2592435399f, +0.1309866321f, +0.0000000000f, -0.1309866321f, +-0.2592435399f, -0.3834386057f, -0.5012752767f, -0.6100062330f, -0.7085021596f, -0.7952493046f, -0.8679010068f, -0.9257026822f, +-0.9681538347f, -0.9936657199f, -1.0019733630f, -0.9936657199f, -0.9681538347f, -0.9257026822f, -0.8679010068f, -0.7952493046f, +-0.7085021596f, -0.6100062330f, -0.5012752767f, -0.3834386057f, -0.2592435399f, -0.1309866321f, +0.0000000000f, +0.1309866321f, ++0.2592435399f, +0.3834386057f, +0.5012752767f, +0.6100062330f, +0.7085021596f, +0.7952493046f, +0.8679010068f, +0.9257026822f, ++0.9681538347f, +0.9936657199f, +1.0019733630f, +0.9936657199f, +0.9681538347f, +0.9257026822f, +0.8679010068f, +0.7952493046f }; diff --git a/libraries/tests/dsp/cmsis/fir_f32/main.cpp b/libraries/tests/dsp/cmsis/fir_f32/main.cpp index 092a25de28..f6bdb4b7ce 100644 --- a/libraries/tests/dsp/cmsis/fir_f32/main.cpp +++ b/libraries/tests/dsp/cmsis/fir_f32/main.cpp @@ -1,5 +1,5 @@ -#include "arm_math.h" -#include "math_helper.h" +#include "arm_math.h" +#include "math_helper.h" #include #define BLOCK_SIZE 32 @@ -14,19 +14,19 @@ * The input signal and reference output (computed with MATLAB) * are defined externally in arm_fir_lpf_data.c. * ------------------------------------------------------------------- */ -extern float32_t testInput_f32_1kHz_15kHz[TEST_LENGTH_SAMPLES]; -extern float32_t refOutput[TEST_LENGTH_SAMPLES]; +extern float32_t testInput_f32_1kHz_15kHz[TEST_LENGTH_SAMPLES]; +extern float32_t refOutput[TEST_LENGTH_SAMPLES]; -/* ------------------------------------------------------------------- +/* ------------------------------------------------------------------- * Declare State buffer of size (numTaps + blockSize - 1) * ------------------------------------------------------------------- */ -static float32_t firStateF32[BLOCK_SIZE + NUM_TAPS - 1]; +static float32_t firStateF32[BLOCK_SIZE + NUM_TAPS - 1]; -/* ---------------------------------------------------------------------- - * FIR Coefficients buffer generated using fir1() MATLAB function. +/* ---------------------------------------------------------------------- + * FIR Coefficients buffer generated using fir1() MATLAB function. * fir1(28, 6/24) - * ------------------------------------------------------------------- */ -const float32_t firCoeffs32[NUM_TAPS] = { + * ------------------------------------------------------------------- */ +const float32_t firCoeffs32[NUM_TAPS] = { -0.0018225230f, -0.0015879294f, +0.0000000000f, +0.0036977508f, +0.0080754303f, +0.0085302217f, -0.0000000000f, -0.0173976984f, -0.0341458607f, -0.0333591565f, +0.0000000000f, +0.0676308395f, +0.1522061835f, +0.2229246956f, +0.2504960933f, @@ -35,23 +35,23 @@ const float32_t firCoeffs32[NUM_TAPS] = { +0.0036977508f, +0.0000000000f, -0.0015879294f, -0.0018225230f }; -/* ---------------------------------------------------------------------- - * FIR LPF Example +/* ---------------------------------------------------------------------- + * FIR LPF Example * ------------------------------------------------------------------- */ -int main(void) { +int main(void) { /* Call FIR init function to initialize the instance structure. */ arm_fir_instance_f32 S; - arm_fir_init_f32(&S, NUM_TAPS, (float32_t *)&firCoeffs32[0], &firStateF32[0], BLOCK_SIZE); - - /* ---------------------------------------------------------------------- - * Call the FIR process function for every blockSize samples - * ------------------------------------------------------------------- */ + arm_fir_init_f32(&S, NUM_TAPS, (float32_t *)&firCoeffs32[0], &firStateF32[0], BLOCK_SIZE); + + /* ---------------------------------------------------------------------- + * Call the FIR process function for every blockSize samples + * ------------------------------------------------------------------- */ for (uint32_t i=0; i < NUM_BLOCKS; i++) { float32_t* signal = testInput_f32_1kHz_15kHz + (i * BLOCK_SIZE); arm_fir_f32(&S, signal, signal, BLOCK_SIZE); - } - - /* ---------------------------------------------------------------------- + } + + /* ---------------------------------------------------------------------- * Compare the generated output against the reference output computed * in MATLAB. * ------------------------------------------------------------------- */ @@ -62,4 +62,4 @@ int main(void) { } else { printf("Success\n\r"); } -} +} diff --git a/libraries/tests/dsp/mbed/fir_f32/main.cpp b/libraries/tests/dsp/mbed/fir_f32/main.cpp index c7c9e4c0cd..d5e98d58ee 100644 --- a/libraries/tests/dsp/mbed/fir_f32/main.cpp +++ b/libraries/tests/dsp/mbed/fir_f32/main.cpp @@ -14,7 +14,7 @@ float32_t output[TEST_LENGTH_SAMPLES]; /* FIR Coefficients buffer generated using fir1() MATLAB function: fir1(28, 6/24) */ #define NUM_TAPS 29 -const float32_t firCoeffs32[NUM_TAPS] = { +const float32_t firCoeffs32[NUM_TAPS] = { -0.0018225230f, -0.0015879294f, +0.0000000000f, +0.0036977508f, +0.0080754303f, +0.0085302217f, -0.0000000000f, -0.0173976984f, -0.0341458607f, -0.0333591565f, +0.0000000000f, +0.0676308395f, +0.1522061835f, +0.2229246956f, +0.2504960933f, @@ -29,7 +29,7 @@ int main() { Sine_f32 sine_1KHz( 1000, SAMPLE_RATE, 1.0); Sine_f32 sine_15KHz(15000, SAMPLE_RATE, 0.5); FIR_f32 fir(firCoeffs32); - + float32_t buffer_a[BLOCK_SIZE]; float32_t buffer_b[BLOCK_SIZE]; for (float32_t *sgn=output; sgn<(output+TEST_LENGTH_SAMPLES); sgn += BLOCK_SIZE) { @@ -37,12 +37,12 @@ int main() { sine_15KHz.process(buffer_a, buffer_b); // Add a 15KHz sine wave fir.process(buffer_b, sgn); // FIR low pass filter: 6KHz cutoff } - + sine_1KHz.reset(); for (float32_t *sgn=expected_output; sgn<(expected_output+TEST_LENGTH_SAMPLES); sgn += BLOCK_SIZE) { sine_1KHz.generate(sgn); // Generate a 1KHz sine wave } - + float snr = arm_snr_f32(&expected_output[DELAY-1], &output[WARMUP-1], TEST_LENGTH_SAMPLES-WARMUP); printf("snr: %f\n\r", snr); if (snr < SNR_THRESHOLD_F32) { diff --git a/libraries/tests/export/mcb1700/main.cpp b/libraries/tests/export/mcb1700/main.cpp index 395eac0f48..bc1d2c6748 100644 --- a/libraries/tests/export/mcb1700/main.cpp +++ b/libraries/tests/export/mcb1700/main.cpp @@ -7,7 +7,7 @@ int main() { while (true) { float value = 8.0 * in.read(); printf("analog in: %f\n\r", value); - + int led_mask = 0; if (value > 0.5) led_mask |= 1 << 0; if (value > 1.5) led_mask |= 1 << 1; @@ -18,7 +18,7 @@ int main() { if (value > 6.5) led_mask |= 1 << 6; if (value > 7.5) led_mask |= 1 << 7; leds = led_mask; - + wait(1); } } diff --git a/libraries/tests/libs/SPIHalfDuplex/SPIHalfDuplex.h b/libraries/tests/libs/SPIHalfDuplex/SPIHalfDuplex.h index ff5555e19f..14633b8555 100644 --- a/libraries/tests/libs/SPIHalfDuplex/SPIHalfDuplex.h +++ b/libraries/tests/libs/SPIHalfDuplex/SPIHalfDuplex.h @@ -30,7 +30,7 @@ namespace mbed { * // Send a byte to a SPI half-duplex slave, and record the response * * #include "mbed.h" - * + * * SPIHalfDuplex device(p5, p6, p7) // mosi, miso, sclk * * int main() { @@ -42,7 +42,7 @@ namespace mbed { class SPIHalfDuplex : public SPI { public: - + /** Create a SPI half-duplex master connected to the specified pins * * Pin Options: @@ -65,7 +65,7 @@ public: * Response from the SPI slave */ virtual int write(int value); - + /** Set the number of databits expected from the slave, from 4-16 * * @param sbits Number of expected bits in the slave response diff --git a/libraries/tests/libs/SerialHalfDuplex/SerialHalfDuplex.cpp b/libraries/tests/libs/SerialHalfDuplex/SerialHalfDuplex.cpp index f6e54a99d6..7594e40473 100644 --- a/libraries/tests/libs/SerialHalfDuplex/SerialHalfDuplex.cpp +++ b/libraries/tests/libs/SerialHalfDuplex/SerialHalfDuplex.cpp @@ -12,7 +12,7 @@ namespace mbed { SerialHalfDuplex::SerialHalfDuplex(PinName tx, PinName rx) : Serial(tx, rx) { - + gpio_init(&gpio, tx, PIN_INPUT); gpio_mode(&gpio, PullNone); // no pull } @@ -27,19 +27,19 @@ SerialHalfDuplex::SerialHalfDuplex(PinName tx, PinName rx) // 6. Re-enable interrupts int SerialHalfDuplex::_putc(int c) { int retc; - + // TODO: We should not disable all interrupts __disable_irq(); - + serial_pinout_tx(gpio.pin); - + Serial::_putc(c); retc = Serial::getc(); // reading also clears any interrupt - + pin_function(gpio.pin, 0); - + __enable_irq(); - + return retc; } diff --git a/libraries/tests/libs/SerialHalfDuplex/SerialHalfDuplex.h b/libraries/tests/libs/SerialHalfDuplex/SerialHalfDuplex.h index 744e261b2f..0ba13d38e5 100644 --- a/libraries/tests/libs/SerialHalfDuplex/SerialHalfDuplex.h +++ b/libraries/tests/libs/SerialHalfDuplex/SerialHalfDuplex.h @@ -13,13 +13,13 @@ namespace mbed { -/** A serial port (UART) for communication with other devices using +/** A serial port (UART) for communication with other devices using * Half-Duplex, allowing transmit and receive on a single - * shared transmit and receive line. Only one end should be transmitting + * shared transmit and receive line. Only one end should be transmitting * at a time. - * - * Both the tx and rx pin should be defined, and wired together. - * This is in addition to them being wired to the other serial + * + * Both the tx and rx pin should be defined, and wired together. + * This is in addition to them being wired to the other serial * device to allow both read and write functions to operate. * * For Simplex and Full-Duplex Serial communication, see Serial() @@ -27,9 +27,9 @@ namespace mbed { * Example: * @code * // Send a byte to a second HalfDuplex device, and read the response - * + * * #include "mbed.h" - * + * * // p9 and p10 should be wired together to form "a" * // p28 and p27 should be wired together to form "b" * // p9/p10 should be wired to p28/p27 as the Half Duplex connection @@ -40,7 +40,7 @@ namespace mbed { * void b_rx() { // second device response * b.putc(b.getc() + 4); * } - * + * * int main() { * b.attach(&b_rx); * for (int c = 'A'; c < 'Z'; c++) { diff --git a/libraries/tests/mbed/analog_in/main.cpp b/libraries/tests/mbed/analog_in/main.cpp index 4be49f849a..157885df36 100644 --- a/libraries/tests/mbed/analog_in/main.cpp +++ b/libraries/tests/mbed/analog_in/main.cpp @@ -6,12 +6,12 @@ * Connect 'control' to pin 21 of an mbed LPC1768 * Connect 'analogInput' to pin 18 of an mbed LPC1768 * Connect 'TX/RX' to pins 27 and 28 of an mbed LPC1768 - * - * Upload: + * + * Upload: */ #include "test_env.h" -#define ERROR_TOLERANCE 0.05 +#define ERROR_TOLERANCE 0.05 #if defined(TARGET_LPC1114) diff --git a/libraries/tests/mbed/can/main.cpp b/libraries/tests/mbed/can/main.cpp index 4a51923f8b..f6fd7d15d4 100644 --- a/libraries/tests/mbed/can/main.cpp +++ b/libraries/tests/mbed/can/main.cpp @@ -10,14 +10,14 @@ CAN can2(p34, p33); CAN can2(p30, p29); #endif char counter = 0; - -void printmsg(char *title, CANMessage *msg) { + +void printmsg(char *title, CANMessage *msg) { printf("%s [%03X]", title, msg->id); for(char i = 0; i < msg->len; i++) { printf(" %02X", msg->data[i]); } printf("\n"); -} +} void send() { printf("send()\n"); @@ -25,7 +25,7 @@ void send() { if(can1.write(msg)) { printmsg("Tx message:", &msg); counter++; - } + } led1 = !led1; } diff --git a/libraries/tests/mbed/can_interrupt/main.cpp b/libraries/tests/mbed/can_interrupt/main.cpp index 979e7ac3d9..468ee4e0d2 100644 --- a/libraries/tests/mbed/can_interrupt/main.cpp +++ b/libraries/tests/mbed/can_interrupt/main.cpp @@ -10,14 +10,14 @@ CAN can2(p34, p33); CAN can2(p30, p29); #endif char counter = 0; - -void printmsg(char *title, CANMessage *msg) { + +void printmsg(char *title, CANMessage *msg) { printf("%s [%03X]", title, msg->id); for(char i = 0; i < msg->len; i++) { printf(" %02X", msg->data[i]); } printf("\n"); -} +} void send() { printf("send()\n"); @@ -25,7 +25,7 @@ void send() { if(can1.write(msg)) { printmsg("Tx message:", &msg); counter++; - } + } led1 = !led1; } @@ -37,7 +37,7 @@ void read() { led2 = !led2; } } - + int main() { printf("main()\n"); ticker.attach(&send, 1); diff --git a/libraries/tests/mbed/dir/main.cpp b/libraries/tests/mbed/dir/main.cpp index dc642cd640..feb3241057 100644 --- a/libraries/tests/mbed/dir/main.cpp +++ b/libraries/tests/mbed/dir/main.cpp @@ -14,7 +14,7 @@ void notify_completion(bool success) { } else { printf("{failure}\n"); } - + printf("{end}\n"); led_blink(success ? LED1 : LED4); } @@ -28,7 +28,7 @@ FILE* test_open(char* path, const char* mode) { printf("Error opening file\n"); notify_completion(false); } - + return f; } @@ -50,12 +50,12 @@ void test_close(FILE* f) { int main() { LocalFileSystem local("local"); - + FILE *f; char* str = TEST_STRING; char* buffer = (char*) malloc(sizeof(unsigned char)*strlen(TEST_STRING)); int str_len = strlen(TEST_STRING); - + printf("Write files\n"); char filename[32]; for (int i=0; i<10; i++) { @@ -65,7 +65,7 @@ int main() { test_write(f, str); test_close(f); } - + printf("List files:\n"); DIR *d = opendir("/local"); struct dirent *p; @@ -73,6 +73,6 @@ int main() { printf("%s\n", p->d_name); } closedir(d); - + notify_completion(true); } diff --git a/libraries/tests/mbed/echo_flow_control/main.cpp b/libraries/tests/mbed/echo_flow_control/main.cpp index d0b6c1b20b..327bca62d4 100644 --- a/libraries/tests/mbed/echo_flow_control/main.cpp +++ b/libraries/tests/mbed/echo_flow_control/main.cpp @@ -24,9 +24,9 @@ int main() { char buf[256]; pc.set_flow_control(Serial::RTSCTS, FLOW_CONTROL_RTS, FLOW_CONTROL_CTS); -#ifdef RTS_CHECK_PIN +#ifdef RTS_CHECK_PIN in.fall(checker); -#endif +#endif while (1) { pc.gets(buf, 256); pc.printf("%s", buf); diff --git a/libraries/tests/mbed/env/test_env.cpp b/libraries/tests/mbed/env/test_env.cpp index 1c86c03625..28a29f5353 100644 --- a/libraries/tests/mbed/env/test_env.cpp +++ b/libraries/tests/mbed/env/test_env.cpp @@ -17,7 +17,7 @@ void notify_completion(bool success) { } else { printf("{{failure}}" NL ); } - + printf("{{end}}" NL); #ifdef LED4 led_blink(success ? LED1 : LED4); diff --git a/libraries/tests/mbed/freopen/TextDisplay.cpp b/libraries/tests/mbed/freopen/TextDisplay.cpp index 4076addae6..0eb30f56cd 100644 --- a/libraries/tests/mbed/freopen/TextDisplay.cpp +++ b/libraries/tests/mbed/freopen/TextDisplay.cpp @@ -2,14 +2,14 @@ * Copyright (c) 2007-2009 sford * Released under the MIT License: http://mbed.org/license/mit */ - + #include "TextDisplay.h" TextDisplay::TextDisplay(const char *name) : Stream(name) { _row = 0; _column = 0; } - + int TextDisplay::_putc(int value) { if(value == '\n') { _column = 0; @@ -47,7 +47,7 @@ void TextDisplay::locate(int column, int row) { int TextDisplay::_getc() { return -1; } - + void TextDisplay::foreground(int colour) { _foreground = colour; } diff --git a/libraries/tests/mbed/freopen/TextDisplay.h b/libraries/tests/mbed/freopen/TextDisplay.h index a9d6de3cf2..51694ab1be 100644 --- a/libraries/tests/mbed/freopen/TextDisplay.h +++ b/libraries/tests/mbed/freopen/TextDisplay.h @@ -9,7 +9,7 @@ * Everything else (locate, printf, putc, cls) will come for free * * The model is the display will wrap at the right and bottom, so you can - * keep writing and will always get valid characters. The location is + * keep writing and will always get valid characters. The location is * maintained internally to the class to make this easy */ @@ -26,7 +26,7 @@ public: virtual void character(int column, int row, int c) = 0; virtual int rows() = 0; virtual int columns() = 0; - + // functions that come for free, but can be overwritten virtual void cls(); virtual void locate(int column, int row); @@ -34,7 +34,7 @@ public: virtual void background(int colour); // putc (from Stream) // printf (from Stream) - + protected: virtual int _putc(int value); diff --git a/libraries/tests/mbed/freopen/TextLCD.cpp b/libraries/tests/mbed/freopen/TextLCD.cpp index 00e386a5cc..8e70c3c299 100644 --- a/libraries/tests/mbed/freopen/TextLCD.cpp +++ b/libraries/tests/mbed/freopen/TextLCD.cpp @@ -2,7 +2,7 @@ * Copyright (c) 2007-2009 sford * Released under the MIT License: http://mbed.org/license/mit */ - + #include "TextLCD.h" #include "mbed.h" @@ -15,7 +15,7 @@ * After attaching the supply voltage/after a reset, the display needs to be brought in to a defined state * * - wait approximately 15 ms so the display is ready to execute commands - * - Execute the command 0x30 ("Display Settings") three times (wait 1,64ms after each command, the busy flag cannot be queried now). + * - Execute the command 0x30 ("Display Settings") three times (wait 1,64ms after each command, the busy flag cannot be queried now). * - The display is in 8 bit mode, so if you have only connected 4 data pins you should only transmit the higher nibble of each command. * - If you want to use the 4 bit mode, now you can execute the command to switch over to this mode now. * - Execute the "clear display" command @@ -23,19 +23,19 @@ * Timing * ====== * - * Nearly all commands transmitted to the display need 40us for execution. - * Exceptions are the commands "Clear Display and Reset" and "Set Cursor to Start Position" - * These commands need 1.64ms for execution. These timings are valid for all displays working with an - * internal clock of 250kHz. But I do not know any displays that use other frequencies. Any time you + * Nearly all commands transmitted to the display need 40us for execution. + * Exceptions are the commands "Clear Display and Reset" and "Set Cursor to Start Position" + * These commands need 1.64ms for execution. These timings are valid for all displays working with an + * internal clock of 250kHz. But I do not know any displays that use other frequencies. Any time you * can use the busy flag to test if the display is ready to accept the next command. - * + * * _e is kept high apart from calling clock * _rw is kept 0 (write) apart from actions that uyse it differently * _rs is set by the data/command writes */ -TextLCD::TextLCD(PinName rs, PinName rw, PinName e, PinName d0, PinName d1, - PinName d2, PinName d3, const char *name) : TextDisplay(name), _rw(rw), _rs(rs), +TextLCD::TextLCD(PinName rs, PinName rw, PinName e, PinName d0, PinName d1, + PinName d2, PinName d3, const char *name) : TextDisplay(name), _rw(rw), _rs(rs), _e(e), _d(d0, d1, d2, d3) { _rw = 0; @@ -45,46 +45,46 @@ TextLCD::TextLCD(PinName rs, PinName rw, PinName e, PinName d0, PinName d1, // Should theoretically wait 15ms, but most things will be powered up pre-reset // so i'll disable that for the minute. If implemented, could wait 15ms post reset // instead - // wait(0.015); - + // wait(0.015); + // send "Display Settings" 3 times (Only top nibble of 0x30 as we've got 4-bit bus) for(int i=0; i<3; i++) { writeByte(0x3); wait(0.00164); // this command takes 1.64ms, so wait for it } writeByte(0x2); // 4-bit mode - - writeCommand(0x28); // Function set 001 BW N F - - + + writeCommand(0x28); // Function set 001 BW N F - - writeCommand(0x0C); - writeCommand(0x6); // Cursor Direction and Display Shift : 0000 01 CD S (CD 0-left, 1-right S(hift) 0-no, 1-yes + writeCommand(0x6); // Cursor Direction and Display Shift : 0000 01 CD S (CD 0-left, 1-right S(hift) 0-no, 1-yes cls(); } void TextLCD::character(int column, int row, int c) { int address = 0x80 + (row * 40) + column; // memory starts at 0x80, and is 40 chars long per row - writeCommand(address); - writeData(c); + writeCommand(address); + writeData(c); } int TextLCD::columns() { return 16; } -int TextLCD::rows() { - return 2; +int TextLCD::rows() { + return 2; } void TextLCD::writeByte(int value) { _d = value >> 4; wait(0.000040f); // most instructions take 40us _e = 0; - wait(0.000040f); - _e = 1; + wait(0.000040f); + _e = 1; _d = value >> 0; wait(0.000040f); _e = 0; wait(0.000040f); // most instructions take 40us - _e = 1; + _e = 1; } void TextLCD::writeCommand(int command) { diff --git a/libraries/tests/mbed/freopen/TextLCD.h b/libraries/tests/mbed/freopen/TextLCD.h index 22f986f6eb..9a29792183 100644 --- a/libraries/tests/mbed/freopen/TextLCD.h +++ b/libraries/tests/mbed/freopen/TextLCD.h @@ -12,11 +12,11 @@ public: TextLCD(PinName rs, PinName rw, PinName e, PinName d0, PinName d1, PinName d2, PinName d3, const char *name = NULL); virtual void character(int column, int row, int c); - virtual int rows(); - virtual int columns(); + virtual int rows(); + virtual int columns(); // locate, cls, putc, printf come from derived class - + protected: void writeByte(int value); diff --git a/libraries/tests/mbed/freopen/main.cpp b/libraries/tests/mbed/freopen/main.cpp index 795fad6f23..145a684a7e 100644 --- a/libraries/tests/mbed/freopen/main.cpp +++ b/libraries/tests/mbed/freopen/main.cpp @@ -3,25 +3,25 @@ int main() { printf("printf to stdout\n"); - + // printf to specific peripherals Serial pc(USBTX, USBRX); pc.printf("Serial(USBTX, USBRX).printf\n"); - + TextLCD lcd(p14, p15, p16, p17, p18, p19, p20, "lcd"); // rs, rw, e, d0-d3, name lcd.printf("TextLCD.printf\n"); - + // change stdout to file LocalFileSystem local("local"); freopen("/local/output.txt", "w", stdout); printf("printf redirected to LocalFileSystem\n"); fclose(stdout); - + // change stdout to LCD freopen("/lcd", "w", stdout); printf("printf redirected to TextLCD\n"); fclose(stdout); - + DigitalOut led(LED1); while (true) { led = !led; diff --git a/libraries/tests/mbed/fs/main.cpp b/libraries/tests/mbed/fs/main.cpp index 3948f60b6c..2dc525cd08 100644 --- a/libraries/tests/mbed/fs/main.cpp +++ b/libraries/tests/mbed/fs/main.cpp @@ -1,9 +1,9 @@ #include "mbed.h" #include "rtos.h" #include "SDFileSystem.h" - + #define FILE_LOC "/sd/test.txt" - + Serial pc(USBTX, USBRX); Serial gps(p28, p27); Serial test(p9,p10); @@ -12,7 +12,7 @@ SDFileSystem sd(p11, p12, p13, p14, "sd"); DigitalOut myled(LED1); DigitalOut sdled(LED2); - + void sd_thread(void const *argument) { while (true) { sdled = !sdled; diff --git a/libraries/tests/mbed/heap_and_stack/main.cpp b/libraries/tests/mbed/heap_and_stack/main.cpp index 4bd61dbf1c..a127efedb4 100644 --- a/libraries/tests/mbed/heap_and_stack/main.cpp +++ b/libraries/tests/mbed/heap_and_stack/main.cpp @@ -9,10 +9,10 @@ static unsigned int iterations = 0; void report_iterations(void) { unsigned int tot = (0x100 * iterations)*2; printf("\nAllocated (%d)Kb in (%u) iterations\n", tot/1024, iterations); -#if !defined(TOOLCHAIN_GCC_CR) +#if !defined(TOOLCHAIN_GCC_CR) // EA: This causes a crash when compiling with GCC_CR??? printf("%.2f\n", ((float)(tot)/(float)(initial_stack_p - initial_heap_p))*100.); -#endif +#endif #ifdef TOOLCHAIN_ARM #ifndef __MICROLIB __heapvalid((__heapprt) fprintf, stdout, 1); @@ -23,12 +23,12 @@ void report_iterations(void) { void stack_test(char *latest_heap_pointer) { char stack_line[256]; iterations++; - + sprintf(stack_line, "\nstack pointer: %p", &stack_line[255]); puts(stack_line); - + char *heap_pointer = (char*)malloc(0x100); - + if (heap_pointer == NULL) { int diff = (&stack_line[255] - latest_heap_pointer); if (diff > 0x200) { @@ -45,7 +45,7 @@ void stack_test(char *latest_heap_pointer) { sprintf(line, "heap pointer: %p", heap_pointer); puts(line); } - + if ((&stack_line[255]) > heap_pointer) { stack_test(heap_pointer); } else { @@ -58,19 +58,19 @@ void stack_test(char *latest_heap_pointer) { int main (void) { char c; initial_stack_p = &c; - + initial_heap_p = (char*)malloc(1); if (initial_heap_p == NULL) { printf("Unable to malloc a single byte\n"); notify_completion(false); } - + printf("Initial stack/heap geometry:\n"); printf(" stack pointer:V %p\n", initial_stack_p); printf(" heap pointer :^ %p\n", initial_heap_p); - + initial_heap_p++; stack_test(initial_heap_p); - + notify_completion(true); } diff --git a/libraries/tests/mbed/i2c_master_slave/main.cpp b/libraries/tests/mbed/i2c_master_slave/main.cpp index 7f7d00f6b7..f94b59f3db 100644 --- a/libraries/tests/mbed/i2c_master_slave/main.cpp +++ b/libraries/tests/mbed/i2c_master_slave/main.cpp @@ -8,7 +8,7 @@ // ******************************************************** // This tests data transfer between two I2C interfaces on // the same chip, one configured as master, the other as -// slave. Works on the LPC1768 mbed. +// slave. Works on the LPC1768 mbed. // // Wiring: // p28 <-> p9 @@ -35,7 +35,7 @@ int main() { notify_completion(false); return 1; - } + } slave.read(&received, 1); if(sent != received) { diff --git a/libraries/tests/mbed/i2c_slave/main.cpp b/libraries/tests/mbed/i2c_slave/main.cpp index 66831d0bc4..1b24b3cd4b 100644 --- a/libraries/tests/mbed/i2c_slave/main.cpp +++ b/libraries/tests/mbed/i2c_slave/main.cpp @@ -22,13 +22,13 @@ I2CSlave slave(p28, p27); switch (i) { case I2CSlave::ReadAddressed: slave.write(buf, SIZE); - for(int i = 0; i < SIZE; i++){ + for(int i = 0; i < SIZE; i++){ } break; case I2CSlave::WriteAddressed: slave.read(buf, SIZE); for(int i = 0; i < SIZE; i++){ - buf[i]++; + buf[i]++; } break; } diff --git a/libraries/tests/mbed/interruptin_2/main.cpp b/libraries/tests/mbed/interruptin_2/main.cpp index 7768f77b0b..0f12f6e976 100644 --- a/libraries/tests/mbed/interruptin_2/main.cpp +++ b/libraries/tests/mbed/interruptin_2/main.cpp @@ -28,7 +28,7 @@ InterruptIn button9(p15); DigitalOut led(LED1); DigitalOut flash(LED2); -#else +#else InterruptIn button(p30); InterruptIn button1(p29); InterruptIn button2(p28); @@ -42,11 +42,11 @@ InterruptIn button9(p21); DigitalOut led(LED1); DigitalOut flash(LED4); #endif - + void flip() { led = !led; } - + int main() { flash = 0; led = 0; diff --git a/libraries/tests/mbed/modserial/main.cpp b/libraries/tests/mbed/modserial/main.cpp index a16abcf811..7db8c6876d 100644 --- a/libraries/tests/mbed/modserial/main.cpp +++ b/libraries/tests/mbed/modserial/main.cpp @@ -48,35 +48,35 @@ void rxCallback(MODSERIAL_IRQ_INFO *q) { int main() { int c = 'A'; - + // Ensure the baud rate for the PC "USB" serial is much // higher than "uart" baud rate below. (default: 9600) // pc.baud(9600); - + // Use a deliberatly slow baud to fill up the TX buffer uart.baud(1200); - + uart.attach(&txCallback, MODSERIAL::ModTxIrq); uart.attach(&rxCallback, MODSERIAL::ModRxIrq); uart.attach(&txEmpty, MODSERIAL::ModTxEmpty); - + // Loop sending characters. We send 512 // which is twice the default TX/RX buffer size. - + led1 = 1; // Show start of sending with LED1. - + for (int loop = 0; loop < 512; loop++) { - uart.printf("%c", c); + uart.printf("%c", c); c++; if (c > 'Z') c = 'A'; } - + led1 = 0; // Show the end of sending by switching off LED1. - + // End program. Flash LED4. Notice how LED 2 and 3 continue - // to flash for a short period while the interrupt system + // to flash for a short period while the interrupt system // continues to send the characters left in the TX buffer. - + while(1) { led4 = !led4; wait(0.25); @@ -97,7 +97,7 @@ int main() { * * Of interest is that last "R" character after the system has said "Done." * This comes from the fact that the TxEmpty callback is made when the TX buffer - * becomes empty. MODSERIAL makes use of the fact that the Uarts built into the + * becomes empty. MODSERIAL makes use of the fact that the Uarts built into the * LPC17xx device use a 16 byte FIFO on both RX and TX channels. This means that * when the TxEmpty callback is made, the TX buffer is empty, but that just means * the "last few characters" were written to the TX FIFO. So although the TX @@ -110,6 +110,6 @@ int main() { * In a similar way, when characters are received into the RX FIFO, the entire * FIFO contents is moved to the RX buffer, assuming there is room left in the * RX buffer. If there is not, any remaining characters are left in the RX FIFO - * and will be moved to the RX buffer on the next interrupt or when the running + * and will be moved to the RX buffer on the next interrupt or when the running * program removes a character(s) from the RX buffer with the getc() method. */ diff --git a/libraries/tests/mbed/portinout/main.cpp b/libraries/tests/mbed/portinout/main.cpp index 30985381da..06345d3174 100644 --- a/libraries/tests/mbed/portinout/main.cpp +++ b/libraries/tests/mbed/portinout/main.cpp @@ -81,24 +81,24 @@ PortInOut port2(PORT_2, MASK_2); int main() { bool check = true; - + port1.output(); port2.input(); - + port1 = MASK_1; wait(0.1); if (port2 != MASK_2) check = false; - + port1 = 0; wait(0.1); if (port2 != 0) check = false; - + port1.input(); port2.output(); - + port2 = MASK_2; wait(0.1); if (port1 != MASK_1) check = false; - + port2 = 0; wait(0.1); if (port1 != 0) check = false; - + notify_completion(check); } diff --git a/libraries/tests/mbed/portout/main.cpp b/libraries/tests/mbed/portout/main.cpp index d6e04353cd..b15383bad0 100644 --- a/libraries/tests/mbed/portout/main.cpp +++ b/libraries/tests/mbed/portout/main.cpp @@ -7,7 +7,7 @@ # define LED4 (1 << 23) // P1.23 # elif defined(TARGET_LPC11U24) || defined(TARGET_LPC1114) # define LED1 (1 << 8) // P1.8 -# define LED2 (1 << 9) // P1.9 +# define LED2 (1 << 9) // P1.9 # define LED3 (1 << 10) // P1.10 # define LED4 (1 << 11) // P1.11 # endif diff --git a/libraries/tests/mbed/portout_portin/main.cpp b/libraries/tests/mbed/portout_portin/main.cpp index 43611a5d3e..6a178eebbb 100644 --- a/libraries/tests/mbed/portout_portin/main.cpp +++ b/libraries/tests/mbed/portout_portin/main.cpp @@ -87,7 +87,7 @@ int main() { printf("[Test high] expected (0x%x) received (0x%x)\n", MASK_2, value); notify_completion(false); } - + port_out = 0; wait(0.1); value = port_in.read(); @@ -95,6 +95,6 @@ int main() { printf("[Test low] expected (0x%x) received (0x%x)\n", 0, value); notify_completion(false); } - + notify_completion(true); } diff --git a/libraries/tests/mbed/pwm/main.cpp b/libraries/tests/mbed/pwm/main.cpp index 4d049e6858..fd99c96457 100644 --- a/libraries/tests/mbed/pwm/main.cpp +++ b/libraries/tests/mbed/pwm/main.cpp @@ -13,7 +13,7 @@ CT32B0/MR0 p25 (P1_24) CT32B0/MR1 p26 (P1_25) and USBTX (P0_19) CT32B0/MR2 p10 (P1_26) */ - + float value = 0.75; int main() { @@ -59,7 +59,7 @@ int main() { printf("Initialize PWM on pin 25 with duty cycle: %.2f\n", pwm_p25.read()); #elif defined(TARGET_DISCO_F100RB) - PwmOut pwm_1(PB_3); + PwmOut pwm_1(PB_3); PwmOut pwm_2(PB_4); pwm_1.write(0.75); @@ -68,7 +68,7 @@ int main() { printf("Initialize PWM on pin PB_3 with duty cycle: %.2f\n", pwm_1.read()); printf("Initialize PWM on pin PB_4 with duty cycle: %.2f\n", pwm_2.read()); #elif defined(TARGET_DISCO_F051R8) - PwmOut pwm_1(PA_7); + PwmOut pwm_1(PA_7); PwmOut pwm_2(PC_7); pwm_1.write(0.75); @@ -77,7 +77,7 @@ int main() { printf("Initialize PWM on pin PA_7 with duty cycle: %.2f\n", pwm_1.read()); printf("Initialize PWM on pin PC_7 with duty cycle: %.2f\n", pwm_2.read()); #elif defined(TARGET_DISCO_F303VC) - PwmOut pwm_1(PA_8); + PwmOut pwm_1(PA_8); PwmOut pwm_2(PA_9); pwm_1.write(0.75); diff --git a/libraries/tests/mbed/reset/main.cpp b/libraries/tests/mbed/reset/main.cpp index be2817bfbd..b38218e706 100644 --- a/libraries/tests/mbed/reset/main.cpp +++ b/libraries/tests/mbed/reset/main.cpp @@ -7,7 +7,7 @@ extern "C" void mbed_reset(); int main() { pc.printf("start\n"); wait(1); - + unsigned int counter = 0; while(1) { pc.printf("%u\n",counter++); diff --git a/libraries/tests/mbed/serial_interrupt/main.cpp b/libraries/tests/mbed/serial_interrupt/main.cpp index 2818422395..5174b308bf 100644 --- a/libraries/tests/mbed/serial_interrupt/main.cpp +++ b/libraries/tests/mbed/serial_interrupt/main.cpp @@ -1,5 +1,5 @@ #include "mbed.h" - + DigitalOut led1(LED1); DigitalOut led2(LED2); @@ -13,13 +13,13 @@ Serial computer(SERIAL_TX, SERIAL_RX); void txCallback() { led1 = !led1; } - + // This function is called when a character goes into the RX buffer. void rxCallback() { led2 = !led2; computer.putc(computer.getc()); } - + int main() { printf("start test\n"); computer.attach(&txCallback, Serial::TxIrq); diff --git a/libraries/tests/mbed/serial_interrupt_2/main.cpp b/libraries/tests/mbed/serial_interrupt_2/main.cpp index 00b199ed01..744116045e 100644 --- a/libraries/tests/mbed/serial_interrupt_2/main.cpp +++ b/libraries/tests/mbed/serial_interrupt_2/main.cpp @@ -22,17 +22,17 @@ int main() { // Use a deliberatly slow baud to fill up the TX buffer uart.baud(1200); uart.attach(&rxCallback, Serial::RxIrq); - + printf("Starting test loop:\n"); wait(1); - + int c = 'A'; for (int loop = 0; loop < 512; loop++) { uart.printf("%c", c); c++; if (c > 'Z') c = 'A'; } - + while (true) { led2 = !led2; wait(1); diff --git a/libraries/tests/mbed/sleep/main.cpp b/libraries/tests/mbed/sleep/main.cpp index ee26d4f694..6922b1ea4d 100644 --- a/libraries/tests/mbed/sleep/main.cpp +++ b/libraries/tests/mbed/sleep/main.cpp @@ -12,7 +12,7 @@ void flip() { int main() { wkp.rise(&flip); - + while (true) { // sleep(); deepsleep(); diff --git a/libraries/tests/mbed/spi/main.cpp b/libraries/tests/mbed/spi/main.cpp index 070469ee8d..ce571cf1d9 100644 --- a/libraries/tests/mbed/spi/main.cpp +++ b/libraries/tests/mbed/spi/main.cpp @@ -6,7 +6,7 @@ DigitalOut latchpin(p10); int main() { spi.format(8, 0); spi.frequency(16 * 1000 * 1000); - + latchpin = 0; while (1) { latchpin = 1; diff --git a/libraries/tests/mbed/spi_ADXL345/main.cpp b/libraries/tests/mbed/spi_ADXL345/main.cpp index 3eaa59b701..11055ebfa1 100644 --- a/libraries/tests/mbed/spi_ADXL345/main.cpp +++ b/libraries/tests/mbed/spi_ADXL345/main.cpp @@ -24,32 +24,32 @@ void check_X_Y(int v) { int main() { int readings[3] = {0, 0, 0}; - + printf("Starting ADXL345 test...\n"); printf("Device ID is: 0x%02x\n", accelerometer.getDevId()); - + //Go into standby mode to configure the device. accelerometer.setPowerControl(0x00); - + //Full resolution, +/-16g, 4mg/LSB. accelerometer.setDataFormatControl(0x0B); - + //3.2kHz data rate. accelerometer.setDataRate(ADXL345_3200HZ); - + //Measurement mode. accelerometer.setPowerControl(0x08); - + for (int i=0; i<3; i++) { wait(0.1); - + //13-bit, sign extended values. accelerometer.getOutput(readings); - + // X and Y check_X_Y(readings[0]); check_X_Y(readings[1]); - + // Z int16_t z = (int16_t)readings[2]; if ((z < MIN_Z) || (z > MAX_Z)) { @@ -57,6 +57,6 @@ int main() { notify_completion(false); } } - + notify_completion(true); } diff --git a/libraries/tests/mbed/spi_slave/main.cpp b/libraries/tests/mbed/spi_slave/main.cpp index ebc4a085c4..c9c58feb15 100644 --- a/libraries/tests/mbed/spi_slave/main.cpp +++ b/libraries/tests/mbed/spi_slave/main.cpp @@ -15,7 +15,7 @@ int main() { uint8_t resp = 0; device.reply(resp); // Prime SPI with first reply - + while(1) { if(device.receive()) { resp = device.read(); // Read byte from master and add 1 diff --git a/libraries/tests/mbed/spifi1/main.cpp b/libraries/tests/mbed/spifi1/main.cpp index 7f64f6d23d..97e6469b71 100644 --- a/libraries/tests/mbed/spifi1/main.cpp +++ b/libraries/tests/mbed/spifi1/main.cpp @@ -26,19 +26,19 @@ const unsigned char cube_image_ref[] = { int cube_image_ref_sz = sizeof(cube_image_ref); -/* +/* * The SPIFI_ROM_PTR (0x1FFF1FF8) points to an area where the pointers to * different drivers in ROM are stored. */ typedef struct { - /*const*/ unsigned p_usbd; // USBROMD + /*const*/ unsigned p_usbd; // USBROMD /*const*/ unsigned p_clib; /*const*/ unsigned p_cand; /*const*/ unsigned p_pwrd; // PWRROMD /*const*/ unsigned p_promd; // DIVROMD /*const*/ SPIFI_RTNS *pSPIFID; // SPIFIROMD /*const*/ unsigned p_dev3; - /*const*/ unsigned p_dev4; + /*const*/ unsigned p_dev4; } ROM; #define ROM_DRIVERS_PTR ((ROM *)(*((unsigned int *)SPIFI_ROM_PTR))) @@ -52,7 +52,7 @@ static void initialize_spifi(void) // Failed to allocate memory for ROM data notify_completion(false); } - + // Turn on SPIFI block as it is disabled on reset LPC_SC->PCONP |= 0x00010000; @@ -63,7 +63,7 @@ static void initialize_spifi(void) LPC_IOCON->P0_16 = 5; /* SPIFI_IO3 @ P0.16 */ LPC_IOCON->P0_17 = 5; /* SPIFI_IO1 @ P0.17 */ LPC_IOCON->P0_18 = 5; /* SPIFI_IO0 @ P0.18 */ - + uint32_t spifi_clk_div = (*((volatile uint32_t*)0x400FC1B4)) & 0x1f; uint32_t spifi_clk_mhz = (SystemCoreClock / spifi_clk_div) / 1000000; @@ -80,17 +80,17 @@ static void initialize_spifi(void) int main() { initialize_spifi(); - + // Make sure that cube_image is placed in SPIFI if (!IS_ADDR_IN_SPIFI(cube_image)) { notify_completion(false); } - + // Make sure that cube_image_ref is in IFLASH if (IS_ADDR_IN_SPIFI(cube_image_ref)) { notify_completion(false); } - + // Compare content if (cube_image_sz != cube_image_ref_sz) { notify_completion(false); @@ -102,6 +102,6 @@ int main() { } } } - + notify_completion(true); } diff --git a/libraries/tests/mbed/spifi1/spifi_rom_api.h b/libraries/tests/mbed/spifi1/spifi_rom_api.h index 69b752f196..baacb38209 100644 --- a/libraries/tests/mbed/spifi1/spifi_rom_api.h +++ b/libraries/tests/mbed/spifi1/spifi_rom_api.h @@ -3,9 +3,9 @@ written by CAM start 4/16/10 first testing 5/12/10 OK with first SST & Winbond devices 6/8/10 - OK with Gigadevice, Numonyx, Atmel, + OK with Gigadevice, Numonyx, Atmel, some Macronyx 7/13/10 - consensus with BK, performance optimized 8/24/10 + consensus with BK, performance optimized 8/24/10 this file is largely platform-independent */ #ifndef SPIFI_ROM_API_H @@ -14,7 +14,7 @@ #define SPIFI_MEM_BASE 0x28000000 /* allocated size of the SPIFI memory area on this device */ -#define MEM_AREA_SIZE 0x00001000 +#define MEM_AREA_SIZE 0x00001000 #define SPIFI_ROM_PTR 0x1FFF1FF8 /* define the symbol TESTING in the environment if test output desired */ @@ -61,7 +61,7 @@ typedef struct { } SPIFIopers; -/* bits in options operands (MODE3, RCVCLK, and FULLCLK +/* bits in options operands (MODE3, RCVCLK, and FULLCLK have the same relationship as in the Control register) */ #define S_MODE3 1 #define S_MODE0 0 @@ -87,7 +87,7 @@ typedef struct { /* interface to ROM API */ typedef struct { - int (*spifi_init) (SPIFIobj *obj, unsigned csHigh, unsigned options, + int (*spifi_init) (SPIFIobj *obj, unsigned csHigh, unsigned options, unsigned mhz); int (*spifi_program) (SPIFIobj *obj, char *source, SPIFIopers *opers); int (*spifi_erase) (SPIFIobj *obj, SPIFIopers *opers); @@ -97,19 +97,19 @@ typedef struct { /* mid level functions */ int (*checkAd) (SPIFIobj *obj, SPIFIopers *opers); - int (*setProt) (SPIFIobj *obj, SPIFIopers *opers, char *change, + int (*setProt) (SPIFIobj *obj, SPIFIopers *opers, char *change, char *saveProt); - int (*check_block) (SPIFIobj *obj, char *source, SPIFIopers *opers, + int (*check_block) (SPIFIobj *obj, char *source, SPIFIopers *opers, unsigned check_program); int (*send_erase_cmd) (SPIFIobj *obj, unsigned char op, unsigned addr); unsigned (*ck_erase) (SPIFIobj *obj, unsigned *addr, unsigned length); - int (*prog_block) (SPIFIobj *obj, char *source, SPIFIopers *opers, + int (*prog_block) (SPIFIobj *obj, char *source, SPIFIopers *opers, unsigned *left_in_page); unsigned (*ck_prog) (SPIFIobj *obj, char *source, char *dest, unsigned length); /* low level functions */ void(*setSize) (SPIFIobj *obj, int value); - int (*setDev) (SPIFIobj *obj, unsigned opts, unsigned mem_cmd, + int (*setDev) (SPIFIobj *obj, unsigned opts, unsigned mem_cmd, unsigned prog_cmd); unsigned (*cmd) (uint8_t op, uint8_t addrLen, uint8_t intLen, unsigned short len); unsigned (*readAd) (SPIFIobj *obj, unsigned cmd, unsigned addr); diff --git a/libraries/tests/mbed/spifi2/main.cpp b/libraries/tests/mbed/spifi2/main.cpp index cabfd29851..aac2a00d91 100644 --- a/libraries/tests/mbed/spifi2/main.cpp +++ b/libraries/tests/mbed/spifi2/main.cpp @@ -18,19 +18,19 @@ extern const unsigned char splash_image13[]; extern int splash_image13_sz; extern const unsigned char splash_image14[]; extern int splash_image14_sz; extern const unsigned char splash_image15[]; extern int splash_image15_sz; -/* +/* * The SPIFI_ROM_PTR (0x1FFF1FF8) points to an area where the pointers to * different drivers in ROM are stored. */ typedef struct { - /*const*/ unsigned p_usbd; // USBROMD + /*const*/ unsigned p_usbd; // USBROMD /*const*/ unsigned p_clib; /*const*/ unsigned p_cand; /*const*/ unsigned p_pwrd; // PWRROMD /*const*/ unsigned p_promd; // DIVROMD /*const*/ SPIFI_RTNS *pSPIFID; // SPIFIROMD /*const*/ unsigned p_dev3; - /*const*/ unsigned p_dev4; + /*const*/ unsigned p_dev4; } ROM; #define ROM_DRIVERS_PTR ((ROM *)(*((unsigned int *)SPIFI_ROM_PTR))) @@ -44,7 +44,7 @@ static void initialize_spifi(void) // Failed to allocate memory for ROM data notify_completion(false); } - + // Turn on SPIFI block as it is disabled on reset LPC_SC->PCONP |= 0x00010000; @@ -55,7 +55,7 @@ static void initialize_spifi(void) LPC_IOCON->P0_16 = 5; /* SPIFI_IO3 @ P0.16 */ LPC_IOCON->P0_17 = 5; /* SPIFI_IO1 @ P0.17 */ LPC_IOCON->P0_18 = 5; /* SPIFI_IO0 @ P0.18 */ - + uint32_t spifi_clk_div = (*((volatile uint32_t*)0x400FC1B4)) & 0x1f; uint32_t spifi_clk_mhz = (SystemCoreClock / spifi_clk_div) / 1000000; @@ -74,27 +74,27 @@ int main() { initialize_spifi(); // Make sure that most files are placed in IFLASH - if (IS_ADDR_IN_SPIFI(splash_image1) || - IS_ADDR_IN_SPIFI(splash_image2) || - IS_ADDR_IN_SPIFI(splash_image3) || - IS_ADDR_IN_SPIFI(splash_image4) || - IS_ADDR_IN_SPIFI(splash_image5) || - IS_ADDR_IN_SPIFI(splash_image6) || - IS_ADDR_IN_SPIFI(splash_image7) || - IS_ADDR_IN_SPIFI(splash_image8) || - IS_ADDR_IN_SPIFI(splash_image9) || - IS_ADDR_IN_SPIFI(splash_image10) || - IS_ADDR_IN_SPIFI(splash_image11) || - IS_ADDR_IN_SPIFI(splash_image12) || + if (IS_ADDR_IN_SPIFI(splash_image1) || + IS_ADDR_IN_SPIFI(splash_image2) || + IS_ADDR_IN_SPIFI(splash_image3) || + IS_ADDR_IN_SPIFI(splash_image4) || + IS_ADDR_IN_SPIFI(splash_image5) || + IS_ADDR_IN_SPIFI(splash_image6) || + IS_ADDR_IN_SPIFI(splash_image7) || + IS_ADDR_IN_SPIFI(splash_image8) || + IS_ADDR_IN_SPIFI(splash_image9) || + IS_ADDR_IN_SPIFI(splash_image10) || + IS_ADDR_IN_SPIFI(splash_image11) || + IS_ADDR_IN_SPIFI(splash_image12) || IS_ADDR_IN_SPIFI(splash_image13) || IS_ADDR_IN_SPIFI(splash_image14)) { notify_completion(false); } - + // Make sure that splash_image15 is placed in SPIFI if (!IS_ADDR_IN_SPIFI(splash_image15)) { notify_completion(false); } - + notify_completion(true); } diff --git a/libraries/tests/mbed/spifi2/spifi_rom_api.h b/libraries/tests/mbed/spifi2/spifi_rom_api.h index 69b752f196..baacb38209 100644 --- a/libraries/tests/mbed/spifi2/spifi_rom_api.h +++ b/libraries/tests/mbed/spifi2/spifi_rom_api.h @@ -3,9 +3,9 @@ written by CAM start 4/16/10 first testing 5/12/10 OK with first SST & Winbond devices 6/8/10 - OK with Gigadevice, Numonyx, Atmel, + OK with Gigadevice, Numonyx, Atmel, some Macronyx 7/13/10 - consensus with BK, performance optimized 8/24/10 + consensus with BK, performance optimized 8/24/10 this file is largely platform-independent */ #ifndef SPIFI_ROM_API_H @@ -14,7 +14,7 @@ #define SPIFI_MEM_BASE 0x28000000 /* allocated size of the SPIFI memory area on this device */ -#define MEM_AREA_SIZE 0x00001000 +#define MEM_AREA_SIZE 0x00001000 #define SPIFI_ROM_PTR 0x1FFF1FF8 /* define the symbol TESTING in the environment if test output desired */ @@ -61,7 +61,7 @@ typedef struct { } SPIFIopers; -/* bits in options operands (MODE3, RCVCLK, and FULLCLK +/* bits in options operands (MODE3, RCVCLK, and FULLCLK have the same relationship as in the Control register) */ #define S_MODE3 1 #define S_MODE0 0 @@ -87,7 +87,7 @@ typedef struct { /* interface to ROM API */ typedef struct { - int (*spifi_init) (SPIFIobj *obj, unsigned csHigh, unsigned options, + int (*spifi_init) (SPIFIobj *obj, unsigned csHigh, unsigned options, unsigned mhz); int (*spifi_program) (SPIFIobj *obj, char *source, SPIFIopers *opers); int (*spifi_erase) (SPIFIobj *obj, SPIFIopers *opers); @@ -97,19 +97,19 @@ typedef struct { /* mid level functions */ int (*checkAd) (SPIFIobj *obj, SPIFIopers *opers); - int (*setProt) (SPIFIobj *obj, SPIFIopers *opers, char *change, + int (*setProt) (SPIFIobj *obj, SPIFIopers *opers, char *change, char *saveProt); - int (*check_block) (SPIFIobj *obj, char *source, SPIFIopers *opers, + int (*check_block) (SPIFIobj *obj, char *source, SPIFIopers *opers, unsigned check_program); int (*send_erase_cmd) (SPIFIobj *obj, unsigned char op, unsigned addr); unsigned (*ck_erase) (SPIFIobj *obj, unsigned *addr, unsigned length); - int (*prog_block) (SPIFIobj *obj, char *source, SPIFIopers *opers, + int (*prog_block) (SPIFIobj *obj, char *source, SPIFIopers *opers, unsigned *left_in_page); unsigned (*ck_prog) (SPIFIobj *obj, char *source, char *dest, unsigned length); /* low level functions */ void(*setSize) (SPIFIobj *obj, int value); - int (*setDev) (SPIFIobj *obj, unsigned opts, unsigned mem_cmd, + int (*setDev) (SPIFIobj *obj, unsigned opts, unsigned mem_cmd, unsigned prog_cmd); unsigned (*cmd) (uint8_t op, uint8_t addrLen, uint8_t intLen, unsigned short len); unsigned (*readAd) (SPIFIobj *obj, unsigned cmd, unsigned addr); diff --git a/libraries/tests/mbed/stdio/main.cpp b/libraries/tests/mbed/stdio/main.cpp index ab32d6110e..5ebe100c0a 100644 --- a/libraries/tests/mbed/stdio/main.cpp +++ b/libraries/tests/mbed/stdio/main.cpp @@ -11,14 +11,14 @@ fprintf(stderr, "Test 4: fprintf(stderr, ...) test\r\n"); fscanf(stdin, "%d", &Value); fprintf(stdout, "Test 3: fprintf(stdout, ...) test\r\n"); - + fprintf(stderr, "Test 4: fprintf(stderr, ...) test\r\n"); - + printf("Test 5: fscanf(stdin, ...) test\r\n"); printf(" Type number and press Enter: \n"); fscanf(stdin, "%d", &Value); printf("\n Your value was: %d\r\n", Value); - + printf("Test complete\r\n"); */ diff --git a/libraries/tests/mbed/stdio_benchmark/main.cpp b/libraries/tests/mbed/stdio_benchmark/main.cpp index 748107fb6a..b9179815dc 100644 --- a/libraries/tests/mbed/stdio_benchmark/main.cpp +++ b/libraries/tests/mbed/stdio_benchmark/main.cpp @@ -4,20 +4,20 @@ int main() { printf("\r\n\r\n*** Start of memory write test (2K bytes) ***\r\n"); - + // dummy data char buf[2048]; int index = 0; for (index = 0; index < 2048; index++) { buf[index] = ~index & 0xFF; } - + // Run the timed write test float starttime, duration; Timer t; t.start(); starttime = t.read(); - + #if TEST_STDIO LocalFileSystem local("local"); FILE *fp = fopen("/local/test.dat", "w"); @@ -29,7 +29,7 @@ int main() { lfh.write(buf, sizeof(buf)); lfh.close(); #endif - + duration = t.read() - starttime; printf("Write completed in %.2f seconds. Average throughput = %.0f bytes/second.\r\n", duration, 2048/duration); } diff --git a/libraries/tests/mbed/stl/main.cpp b/libraries/tests/mbed/stl/main.cpp index 37e11e90b2..221f62f566 100644 --- a/libraries/tests/mbed/stl/main.cpp +++ b/libraries/tests/mbed/stl/main.cpp @@ -23,32 +23,32 @@ int main() { queueObject.push("one"); queueObject.push("two"); queueObject.push("three"); - + while (!queueObject.empty()) { string& s = queueObject.front(); printf("%s"NL, s.c_str()); queueObject.pop(); } - + map m; map::iterator it; - + m["a1"] = "50"; m["b2"] = "100"; m["c3"] = "150"; m["d4"] = "200"; - + it = m.find("b2"); if (it == m.end()) { printf("lookup error"NL); } - + m.erase(it); m.erase(m.find("d4")); - + printf("elements in the map:"NL); printf("a1 => %s"NL, m.find("a1")->second.c_str()); printf("c3 => %s"NL, m.find("c3")->second.c_str()); - + notify_completion(true); } diff --git a/libraries/tests/net/cellular/http/common/HTTPClient/HTTPClient.cpp b/libraries/tests/net/cellular/http/common/HTTPClient/HTTPClient.cpp index ed4574ff75..ff367fb30a 100644 --- a/libraries/tests/net/cellular/http/common/HTTPClient/HTTPClient.cpp +++ b/libraries/tests/net/cellular/http/common/HTTPClient/HTTPClient.cpp @@ -21,15 +21,15 @@ #if 0 //Enable debug #include -#define DBG(x, ...) std::printf("[HTTPClient : DBG]"x"\r\n", ##__VA_ARGS__); -#define WARN(x, ...) std::printf("[HTTPClient : WARN]"x"\r\n", ##__VA_ARGS__); -#define ERR(x, ...) std::printf("[HTTPClient : ERR]"x"\r\n", ##__VA_ARGS__); +#define DBG(x, ...) std::printf("[HTTPClient : DBG]"x"\r\n", ##__VA_ARGS__); +#define WARN(x, ...) std::printf("[HTTPClient : WARN]"x"\r\n", ##__VA_ARGS__); +#define ERR(x, ...) std::printf("[HTTPClient : ERR]"x"\r\n", ##__VA_ARGS__); #else //Disable debug -#define DBG(x, ...) +#define DBG(x, ...) #define WARN(x, ...) -#define ERR(x, ...) +#define ERR(x, ...) #endif @@ -114,10 +114,10 @@ int HTTPClient::getHTTPResponseCode() } while(0) HTTPResult HTTPClient::connect(const char* url, HTTP_METH method, IHTTPDataOut* pDataOut, IHTTPDataIn* pDataIn, int timeout) //Execute request -{ +{ m_httpResponseCode = 0; //Invalidate code m_timeout = timeout; - + pDataIn->writeReset(); if( pDataOut ) { @@ -194,14 +194,14 @@ HTTPResult HTTPClient::connect(const char* url, HTTP_METH method, IHTTPDataOut* CHECK_CONN_ERR(ret); } } - + //Close headers DBG("Headers sent"); ret = send("\r\n"); CHECK_CONN_ERR(ret); size_t trfLen; - + //Send data (if available) if( pDataOut != NULL ) { @@ -249,7 +249,7 @@ HTTPResult HTTPClient::connect(const char* url, HTTP_METH method, IHTTPDataOut* } } - + //Receive response DBG("Receiving response"); ret = recv(buf, CHUNK_SIZE - 1, CHUNK_SIZE - 1, &trfLen); //Read n bytes @@ -276,7 +276,7 @@ HTTPResult HTTPClient::connect(const char* url, HTTP_METH method, IHTTPDataOut* if( (m_httpResponseCode < 200) || (m_httpResponseCode >= 300) ) { - //Did not return a 2xx code; TODO fetch headers/(&data?) anyway and implement a mean of writing/reading headers + //Did not return a 2xx code; TODO fetch headers/(&data?) anyway and implement a mean of writing/reading headers WARN("Response code %d", m_httpResponseCode); PRTCL_ERR(); } @@ -484,13 +484,13 @@ HTTPResult HTTPClient::recv(char* buf, size_t minLen, size_t maxLen, size_t* pRe { DBG("Trying to read between %d and %d bytes", minLen, maxLen); size_t readLen = 0; - + if(!m_sock.is_connected()) { WARN("Connection was closed by server"); - return HTTP_CLOSED; //Connection was closed by server + return HTTP_CLOSED; //Connection was closed by server } - + int ret; while(readLen < maxLen) { @@ -506,7 +506,7 @@ HTTPResult HTTPClient::recv(char* buf, size_t minLen, size_t maxLen, size_t* pRe m_sock.set_blocking(false, 0); ret = m_sock.receive(buf + readLen, maxLen - readLen); } - + if( ret > 0) { readLen += ret; @@ -525,10 +525,10 @@ HTTPResult HTTPClient::recv(char* buf, size_t minLen, size_t maxLen, size_t* pRe } else { - break; + break; } } - + if(!m_sock.is_connected()) { break; @@ -547,13 +547,13 @@ HTTPResult HTTPClient::send(char* buf, size_t len) //0 on success, err code on f } DBG("Trying to write %d bytes", len); size_t writtenLen = 0; - + if(!m_sock.is_connected()) { WARN("Connection was closed by server"); - return HTTP_CLOSED; //Connection was closed by server + return HTTP_CLOSED; //Connection was closed by server } - + m_sock.set_blocking(false, m_timeout); int ret = m_sock.send_all(buf, len); if(ret > 0) @@ -570,7 +570,7 @@ HTTPResult HTTPClient::send(char* buf, size_t len) //0 on success, err code on f ERR("Connection error (send returned %d)", ret); return HTTP_CONN; } - + DBG("Written %d bytes", writtenLen); return HTTP_OK; } diff --git a/libraries/tests/net/cellular/http/common/HTTPClient/HTTPClient.h b/libraries/tests/net/cellular/http/common/HTTPClient/HTTPClient.h index 25301c3649..7cb30b0337 100644 --- a/libraries/tests/net/cellular/http/common/HTTPClient/HTTPClient.h +++ b/libraries/tests/net/cellular/http/common/HTTPClient/HTTPClient.h @@ -60,7 +60,7 @@ public: ///Instantiate the HTTP client HTTPClient(); ~HTTPClient(); - + #if 0 //TODO add header handlers /** Provides a basic authentification feature (Base64 encoded username and password) @@ -70,7 +70,7 @@ public: */ void basicAuth(const char* user, const char* password); //Basic Authentification #endif - + //High Level setup functions /** Execute a GET request on the URL Blocks until completion @@ -80,7 +80,7 @@ public: @return 0 on success, HTTP error (<0) on failure */ HTTPResult get(const char* url, IHTTPDataIn* pDataIn, int timeout = HTTP_CLIENT_DEFAULT_TIMEOUT); //Blocking - + /** Execute a GET request on the URL Blocks until completion This is a helper to directly get a piece of text from a HTTP result @@ -101,7 +101,7 @@ public: @return 0 on success, HTTP error (<0) on failure */ HTTPResult post(const char* url, const IHTTPDataOut& dataOut, IHTTPDataIn* pDataIn, int timeout = HTTP_CLIENT_DEFAULT_TIMEOUT); //Blocking - + /** Execute a PUT request on the URL Blocks until completion @param url : url on which to execute the request @@ -111,7 +111,7 @@ public: @return 0 on success, HTTP error (<0) on failure */ HTTPResult put(const char* url, const IHTTPDataOut& dataOut, IHTTPDataIn* pDataIn, int timeout = HTTP_CLIENT_DEFAULT_TIMEOUT); //Blocking - + /** Execute a DELETE request on the URL Blocks until completion @param url : url on which to execute the request @@ -120,12 +120,12 @@ public: @return 0 on success, HTTP error (<0) on failure */ HTTPResult del(const char* url, IHTTPDataIn* pDataIn, int timeout = HTTP_CLIENT_DEFAULT_TIMEOUT); //Blocking - + /** Get last request's HTTP response code @return The HTTP response code of the last request */ int getHTTPResponseCode(); - + private: enum HTTP_METH { @@ -143,7 +143,7 @@ private: //Parameters TCPSocketConnection m_sock; - + int m_timeout; const char* m_basicAuthUser; diff --git a/libraries/tests/net/cellular/http/common/HTTPClient/IHTTPData.h b/libraries/tests/net/cellular/http/common/HTTPClient/IHTTPData.h index 6c8f4368f8..24f1337511 100644 --- a/libraries/tests/net/cellular/http/common/HTTPClient/IHTTPData.h +++ b/libraries/tests/net/cellular/http/common/HTTPClient/IHTTPData.h @@ -29,8 +29,8 @@ class IHTTPDataOut { protected: friend class HTTPClient; - - /** Reset stream to its beginning + + /** Reset stream to its beginning * Called by the HTTPClient on each new request */ virtual void readReset() = 0; @@ -41,17 +41,17 @@ protected: * @param pReadLen Pointer to the variable on which the actual copied data length will be stored */ virtual int read(char* buf, size_t len, size_t* pReadLen) = 0; - + /** Get MIME type * @param type Internet media type from Content-Type header */ virtual int getDataType(char* type, size_t maxTypeLen) = 0; //Internet media type for Content-Type header - + /** Determine whether the HTTP client should chunk the data * Used for Transfer-Encoding header */ virtual bool getIsChunked() = 0; - + /** If the data is not chunked, get its size * Used for Content-Length header */ @@ -65,7 +65,7 @@ class IHTTPDataIn protected: friend class HTTPClient; - /** Reset stream to its beginning + /** Reset stream to its beginning * Called by the HTTPClient on each new request */ virtual void writeReset() = 0; @@ -85,7 +85,7 @@ protected: * Recovered from Transfer-Encoding header */ virtual void setIsChunked(bool chunked) = 0; - + /** If the data is not chunked, set its size * From Content-Length header */ diff --git a/libraries/tests/net/cellular/http/common/HTTPClient/data/HTTPText.h b/libraries/tests/net/cellular/http/common/HTTPClient/data/HTTPText.h index f55ff762ae..cb76c6fdac 100644 --- a/libraries/tests/net/cellular/http/common/HTTPClient/data/HTTPText.h +++ b/libraries/tests/net/cellular/http/common/HTTPClient/data/HTTPText.h @@ -42,7 +42,7 @@ public: protected: //IHTTPDataIn virtual void readReset(); - + virtual int read(char* buf, size_t len, size_t* pReadLen); virtual int getDataType(char* type, size_t maxTypeLen); //Internet media type for Content-Type header @@ -53,7 +53,7 @@ protected: //IHTTPDataOut virtual void writeReset(); - + virtual int write(const char* buf, size_t len); virtual void setDataType(const char* type); //Internet media type from Content-Type header diff --git a/libraries/tests/net/cellular/http/common/httptest.cpp b/libraries/tests/net/cellular/http/common/httptest.cpp index 3bbc4673ea..e3db1c826a 100644 --- a/libraries/tests/net/cellular/http/common/httptest.cpp +++ b/libraries/tests/net/cellular/http/common/httptest.cpp @@ -4,9 +4,9 @@ #include "httptest.h" int httptest(CellularModem& modem, const char* apn, const char* username, const char* password) -{ +{ printf("Connecting...\n"); - + HTTPClient http; char str[512]; @@ -18,7 +18,7 @@ int httptest(CellularModem& modem, const char* apn, const char* username, const printf("Could not connect\n"); return false; } - + //GET data printf("Trying to fetch page...\n"); ret = http.get("http://mbed.org/media/uploads/donatien/hello.txt", str, 128); @@ -33,7 +33,7 @@ int httptest(CellularModem& modem, const char* apn, const char* username, const modem.disconnect(); return false; } - + //POST data HTTPMap map; HTTPText text(str, 512); @@ -52,7 +52,7 @@ int httptest(CellularModem& modem, const char* apn, const char* username, const modem.disconnect(); return false; } - + modem.disconnect(); return true; } diff --git a/libraries/tests/net/cellular/sms/common/smstest.cpp b/libraries/tests/net/cellular/sms/common/smstest.cpp index ca55e88543..5a6393590f 100644 --- a/libraries/tests/net/cellular/sms/common/smstest.cpp +++ b/libraries/tests/net/cellular/sms/common/smstest.cpp @@ -1,12 +1,12 @@ #include "CellularModem.h" #include "smstest.h" -void smstest(CellularModem& modem) +void smstest(CellularModem& modem) { modem.power(true); Thread::wait(1000); -#ifdef DESTINATION_NUMBER +#ifdef DESTINATION_NUMBER modem.sendSM(DESINATION_NUMBER, "Hello from mbed:)"); #endif @@ -32,7 +32,7 @@ void smstest(CellularModem& modem) Thread::wait(3000); continue; } - + printf("%s : %s\n", num, msg); } Thread::wait(3000); diff --git a/libraries/tests/net/echo/udp_server/main.cpp b/libraries/tests/net/echo/udp_server/main.cpp index ab53f554e4..6cd51ca372 100644 --- a/libraries/tests/net/echo/udp_server/main.cpp +++ b/libraries/tests/net/echo/udp_server/main.cpp @@ -11,10 +11,10 @@ int main (void) { eth.init(); //Use DHCP eth.connect(); printf("Server IP Address is %s:%d\n", eth.getIPAddress(), ECHO_SERVER_PORT); - + UDPSocket server; server.bind(ECHO_SERVER_PORT); - + Endpoint client; char buffer[BUFFER_SIZE] = {0}; while (true) { diff --git a/libraries/tests/net/helloworld/broadcast_receive/main.cpp b/libraries/tests/net/helloworld/broadcast_receive/main.cpp index c8d266f9e3..9cee345519 100644 --- a/libraries/tests/net/helloworld/broadcast_receive/main.cpp +++ b/libraries/tests/net/helloworld/broadcast_receive/main.cpp @@ -7,11 +7,11 @@ int main() { EthernetInterface eth; eth.init(); //Use DHCP eth.connect(); - + UDPSocket socket; socket.bind(BROADCAST_PORT); socket.set_broadcasting(); - + Endpoint broadcaster; char buffer[256]; while (true) { diff --git a/libraries/tests/net/helloworld/broadcast_send/main.cpp b/libraries/tests/net/helloworld/broadcast_send/main.cpp index 77b5b64d02..4632c63ff0 100644 --- a/libraries/tests/net/helloworld/broadcast_send/main.cpp +++ b/libraries/tests/net/helloworld/broadcast_send/main.cpp @@ -7,16 +7,16 @@ int main() { EthernetInterface eth; eth.init(); //Use DHCP eth.connect(); - + UDPSocket sock; sock.init(); sock.set_broadcasting(); - + Endpoint broadcast; broadcast.set_address("255.255.255.255", BROADCAST_PORT); - + char out_buffer[] = "very important data"; - + while (true) { printf("Broadcasting...\n"); sock.sendTo(broadcast, out_buffer, sizeof(out_buffer)); diff --git a/libraries/tests/net/helloworld/multicast_receive/main.cpp b/libraries/tests/net/helloworld/multicast_receive/main.cpp index eeb1527c63..0398bdd1fd 100644 --- a/libraries/tests/net/helloworld/multicast_receive/main.cpp +++ b/libraries/tests/net/helloworld/multicast_receive/main.cpp @@ -8,20 +8,20 @@ int main() { EthernetInterface eth; eth.init(); //Use DHCP eth.connect(); - + UDPSocket server; server.bind(MCAST_PORT); if (server.join_multicast_group(MCAST_GRP) != 0) { printf("Error joining the multicast group\n"); while (true) {} } - + Endpoint client; char buffer[256]; while (true) { printf("\nWait for packet...\n"); int n = server.receiveFrom(client, buffer, sizeof(buffer)); - + printf("Packet from \"%s\": %s\n", client.get_address(), buffer); } } diff --git a/libraries/tests/net/helloworld/multicast_send/main.cpp b/libraries/tests/net/helloworld/multicast_send/main.cpp index 773ea6105a..df41c6d80a 100644 --- a/libraries/tests/net/helloworld/multicast_send/main.cpp +++ b/libraries/tests/net/helloworld/multicast_send/main.cpp @@ -8,13 +8,13 @@ int main() { EthernetInterface eth; eth.init(); //Use DHCP eth.connect(); - + UDPSocket sock; sock.init(); - + Endpoint multicast_group; multicast_group.set_address(MCAST_GRP, MCAST_PORT); - + char out_buffer[] = "very important data"; while (true) { printf("Multicast to group: %s\n", MCAST_GRP); diff --git a/libraries/tests/net/protocols/HTTPClient_HelloWorld/HTTPClient/HTTPClient.cpp b/libraries/tests/net/protocols/HTTPClient_HelloWorld/HTTPClient/HTTPClient.cpp index 2d13aac113..baef0a36ad 100644 --- a/libraries/tests/net/protocols/HTTPClient_HelloWorld/HTTPClient/HTTPClient.cpp +++ b/libraries/tests/net/protocols/HTTPClient_HelloWorld/HTTPClient/HTTPClient.cpp @@ -21,16 +21,16 @@ #if 1 //Enable debug #include -//#define DBG(x, ...) std::printf("[HTTPClient : DBG]"x"\r\n", ##__VA_ARGS__); -#define DBG(x, ...) -#define WARN(x, ...) std::printf("[HTTPClient : WARN]"x"\r\n", ##__VA_ARGS__); -#define ERR(x, ...) std::printf("[HTTPClient : ERR]"x"\r\n", ##__VA_ARGS__); +//#define DBG(x, ...) std::printf("[HTTPClient : DBG]"x"\r\n", ##__VA_ARGS__); +#define DBG(x, ...) +#define WARN(x, ...) std::printf("[HTTPClient : WARN]"x"\r\n", ##__VA_ARGS__); +#define ERR(x, ...) std::printf("[HTTPClient : ERR]"x"\r\n", ##__VA_ARGS__); #else //Disable debug -#define DBG(x, ...) +#define DBG(x, ...) #define WARN(x, ...) -#define ERR(x, ...) +#define ERR(x, ...) #endif @@ -104,7 +104,7 @@ int HTTPClient::getHTTPResponseCode() } while(0) HTTPResult HTTPClient::connect(const char* url, HTTP_METH method, IHTTPDataOut* pDataOut, IHTTPDataIn* pDataIn, int timeout) //Execute request -{ +{ m_httpResponseCode = 0; //Invalidate code m_timeout = timeout; @@ -178,14 +178,14 @@ HTTPResult HTTPClient::connect(const char* url, HTTP_METH method, IHTTPDataOut* CHECK_CONN_ERR(ret); } } - + //Close headers DBG("Headers sent"); ret = send("\r\n"); CHECK_CONN_ERR(ret); size_t trfLen; - + //Send data (if POST) if( (method == HTTP_POST) && (pDataOut != NULL) ) { @@ -233,7 +233,7 @@ HTTPResult HTTPClient::connect(const char* url, HTTP_METH method, IHTTPDataOut* } } - + //Receive response DBG("Receiving response"); ret = recv(buf, CHUNK_SIZE - 1, CHUNK_SIZE - 1, &trfLen); //Read n bytes @@ -458,13 +458,13 @@ HTTPResult HTTPClient::recv(char* buf, size_t minLen, size_t maxLen, size_t* pRe { DBG("Trying to read between %d and %d bytes", minLen, maxLen); size_t readLen = 0; - + if(!m_sock.is_connected()) { WARN("Connection was closed by server"); - return HTTP_CLOSED; //Connection was closed by server + return HTTP_CLOSED; //Connection was closed by server } - + int ret; while(readLen < maxLen) { @@ -480,7 +480,7 @@ HTTPResult HTTPClient::recv(char* buf, size_t minLen, size_t maxLen, size_t* pRe m_sock.set_blocking(false, 0); ret = m_sock.receive(buf + readLen, maxLen - readLen); } - + if( ret > 0) { readLen += ret; @@ -499,10 +499,10 @@ HTTPResult HTTPClient::recv(char* buf, size_t minLen, size_t maxLen, size_t* pRe } else { - break; + break; } } - + if(!m_sock.is_connected()) { break; @@ -521,13 +521,13 @@ HTTPResult HTTPClient::send(char* buf, size_t len) //0 on success, err code on f } DBG("Trying to write %d bytes", len); size_t writtenLen = 0; - + if(!m_sock.is_connected()) { WARN("Connection was closed by server"); - return HTTP_CLOSED; //Connection was closed by server + return HTTP_CLOSED; //Connection was closed by server } - + m_sock.set_blocking(false, m_timeout); int ret = m_sock.send_all(buf, len); if(ret > 0) @@ -544,7 +544,7 @@ HTTPResult HTTPClient::send(char* buf, size_t len) //0 on success, err code on f ERR("Connection error (send returned %d)", ret); return HTTP_CONN; } - + DBG("Written %d bytes", writtenLen); return HTTP_OK; } diff --git a/libraries/tests/net/protocols/HTTPClient_HelloWorld/HTTPClient/HTTPClient.h b/libraries/tests/net/protocols/HTTPClient_HelloWorld/HTTPClient/HTTPClient.h index 8489d277cd..e9ac860cab 100644 --- a/libraries/tests/net/protocols/HTTPClient_HelloWorld/HTTPClient/HTTPClient.h +++ b/libraries/tests/net/protocols/HTTPClient_HelloWorld/HTTPClient/HTTPClient.h @@ -60,7 +60,7 @@ public: ///Instantiate the HTTP client HTTPClient(); ~HTTPClient(); - + #if 0 //TODO add header handlers /** Provides a basic authentification feature (Base64 encoded username and password) @@ -70,7 +70,7 @@ public: */ void basicAuth(const char* user, const char* password); //Basic Authentification #endif - + //High Level setup functions /** Execute a GET request on the url Blocks until completion @@ -80,7 +80,7 @@ public: @return 0 on success, HTTP error (<0) on failure */ HTTPResult get(const char* url, IHTTPDataIn* pDataIn, int timeout = HTTP_CLIENT_DEFAULT_TIMEOUT); //Blocking - + /** Execute a GET request on the url Blocks until completion This is a helper to directly get a piece of text from a HTTP result @@ -101,12 +101,12 @@ public: @return 0 on success, HTTP error (<0) on failure */ HTTPResult post(const char* url, const IHTTPDataOut& dataOut, IHTTPDataIn* pDataIn, int timeout = HTTP_CLIENT_DEFAULT_TIMEOUT); //Blocking - + /** Get last request's HTTP response code @return The HTTP response code of the last request */ int getHTTPResponseCode(); - + private: enum HTTP_METH { @@ -122,7 +122,7 @@ private: //Parameters TCPSocketConnection m_sock; - + int m_timeout; const char* m_basicAuthUser; diff --git a/libraries/tests/net/protocols/HTTPClient_HelloWorld/HTTPClient/IHTTPData.h b/libraries/tests/net/protocols/HTTPClient_HelloWorld/HTTPClient/IHTTPData.h index df06b06647..2eead464f1 100644 --- a/libraries/tests/net/protocols/HTTPClient_HelloWorld/HTTPClient/IHTTPData.h +++ b/libraries/tests/net/protocols/HTTPClient_HelloWorld/HTTPClient/IHTTPData.h @@ -36,17 +36,17 @@ protected: * @param pReadLen Pointer to the variable on which the actual copied data length will be stored */ virtual int read(char* buf, size_t len, size_t* pReadLen) = 0; - + /** Get MIME type * @param type Internet media type from Content-Type header */ virtual int getDataType(char* type, size_t maxTypeLen) = 0; //Internet media type for Content-Type header - + /** Determine whether the HTTP client should chunk the data * Used for Transfer-Encoding header */ virtual bool getIsChunked() = 0; - + /** If the data is not chunked, get its size * Used for Content-Length header */ @@ -75,7 +75,7 @@ protected: * Recovered from Transfer-Encoding header */ virtual void setIsChunked(bool chunked) = 0; - + /** If the data is not chunked, set its size * From Content-Length header */ diff --git a/libraries/tests/net/protocols/NTPClient_HelloWorld/NTPClient/NTPClient.cpp b/libraries/tests/net/protocols/NTPClient_HelloWorld/NTPClient/NTPClient.cpp index ba4ad1b222..b049d30036 100644 --- a/libraries/tests/net/protocols/NTPClient_HelloWorld/NTPClient/NTPClient.cpp +++ b/libraries/tests/net/protocols/NTPClient_HelloWorld/NTPClient/NTPClient.cpp @@ -22,15 +22,15 @@ //Enable debug #define __DEBUG__ #include -#define DBG(x, ...) std::printf("[NTPClient : DBG]"x"\r\n", ##__VA_ARGS__); -#define WARN(x, ...) std::printf("[NTPClient : WARN]"x"\r\n", ##__VA_ARGS__); -#define ERR(x, ...) std::printf("[NTPClient : ERR]"x"\r\n", ##__VA_ARGS__); +#define DBG(x, ...) std::printf("[NTPClient : DBG]"x"\r\n", ##__VA_ARGS__); +#define WARN(x, ...) std::printf("[NTPClient : WARN]"x"\r\n", ##__VA_ARGS__); +#define ERR(x, ...) std::printf("[NTPClient : ERR]"x"\r\n", ##__VA_ARGS__); #else //Disable debug -#define DBG(x, ...) +#define DBG(x, ...) #define WARN(x, ...) -#define ERR(x, ...) +#define ERR(x, ...) #endif @@ -61,7 +61,7 @@ NTPResult NTPClient::setTime(const char* host, uint16_t port, uint32_t timeout) //Create & bind socket DBG("Binding socket"); m_sock.bind(0); //Bind to a random port - + m_sock.set_blocking(false, timeout); //Set not blocking struct NTPPacket pkt; @@ -88,13 +88,13 @@ NTPResult NTPClient::setTime(const char* host, uint16_t port, uint32_t timeout) pkt.refTm_f = pkt.origTm_f = pkt.rxTm_f = pkt.txTm_f = 0; Endpoint outEndpoint; - + if( outEndpoint.set_address(host, port) < 0) { m_sock.close(); return NTP_DNS; } - + //Set timeout, non-blocking and wait using select int ret = m_sock.sendTo( outEndpoint, (char*)&pkt, sizeof(NTPPacket) ); if (ret < 0 ) diff --git a/libraries/tests/net/protocols/NTPClient_HelloWorld/NTPClient/NTPClient.h b/libraries/tests/net/protocols/NTPClient_HelloWorld/NTPClient/NTPClient.h index d66cb2de04..598bdc31c3 100644 --- a/libraries/tests/net/protocols/NTPClient_HelloWorld/NTPClient/NTPClient.h +++ b/libraries/tests/net/protocols/NTPClient_HelloWorld/NTPClient/NTPClient.h @@ -93,7 +93,7 @@ private: uint32_t txTm_s; uint32_t txTm_f; } __attribute__ ((packed)); - + UDPSocket m_sock; }; diff --git a/libraries/tests/peripherals/ADXL345/ADXL345.cpp b/libraries/tests/peripherals/ADXL345/ADXL345.cpp index bc8f97c46e..6f9c856826 100644 --- a/libraries/tests/peripherals/ADXL345/ADXL345.cpp +++ b/libraries/tests/peripherals/ADXL345/ADXL345.cpp @@ -1,6 +1,6 @@ /** * @author Aaron Berk - * + * * @section LICENSE * * Copyright (c) 2010 ARM Limited @@ -30,22 +30,22 @@ * Datasheet: * * http://www.analog.com/static/imported-files/data_sheets/ADXL345.pdf - */ - + */ + /** * Includes */ #include "ADXL345.h" -ADXL345::ADXL345(PinName mosi, - PinName miso, - PinName sck, +ADXL345::ADXL345(PinName mosi, + PinName miso, + PinName sck, PinName cs) : spi_(mosi, miso, sck), nCS_(cs) { //2MHz, allowing us to use the fastest data rates. spi_.frequency(2000000); spi_.format(8,3); - + nCS_ = 1; wait_us(500); @@ -316,9 +316,9 @@ void ADXL345::setDataRate(int rate) { void ADXL345::getOutput(int* readings){ char buffer[6]; - + multiByteRead(ADXL345_DATAX0_REG, buffer, 6); - + readings[0] = (int)buffer[1] << 8 | (int)buffer[0]; readings[1] = (int)buffer[3] << 8 | (int)buffer[2]; readings[2] = (int)buffer[5] << 8 | (int)buffer[4]; diff --git a/libraries/tests/peripherals/ADXL345/ADXL345.h b/libraries/tests/peripherals/ADXL345/ADXL345.h index c02c975bc2..af17c5f3e7 100644 --- a/libraries/tests/peripherals/ADXL345/ADXL345.h +++ b/libraries/tests/peripherals/ADXL345/ADXL345.h @@ -30,7 +30,7 @@ * Datasheet: * * http://www.analog.com/static/imported-files/data_sheets/ADXL345.pdf - */ + */ #ifndef ADXL345_H #define ADXL345_H @@ -254,7 +254,7 @@ public: * seconds. */ int getTimeInactivity(void); - + /** * Set the time required for inactivity to be declared. * @@ -265,7 +265,7 @@ public: * threshold inactivity. */ void setTimeInactivity(int timeInactivity); - + /** * Get the activity/inactivity control settings. * @@ -284,7 +284,7 @@ public: * @return The contents of the ACT_INACT_CTL register. */ int getActivityInactivityControl(void); - + /** * Set the activity/inactivity control settings. * @@ -303,7 +303,7 @@ public: * @param settings The control byte to write to the ACT_INACT_CTL register. */ void setActivityInactivityControl(int settings); - + /** * Get the threshold for free fall detection. * @@ -311,17 +311,17 @@ public: * with scale factor 62.5mg/LSB. */ int getFreefallThreshold(void); - + /** * Set the threshold for free fall detection. * * @return The threshold value for free-fall detection, as an 8-bit number, - * with scale factor 62.5mg/LSB. A value of 0 may result in + * with scale factor 62.5mg/LSB. A value of 0 may result in * undesirable behavior if the free-fall interrupt is enabled. * Values between 300 mg and 600 mg (0x05 to 0x09) are recommended. */ void setFreefallThreshold(int threshold); - + /** * Get the time required to generate a free fall interrupt. * @@ -330,18 +330,18 @@ public: * milliseconds. */ int getFreefallTime(void); - + /** * Set the time required to generate a free fall interrupt. * * @return The minimum time that the value of all axes must be less than * the freefall threshold to generate a free-fall interrupt, in * milliseconds. A value of 0 may result in undesirable behavior - * if the free-fall interrupt is enabled. Values between 100 ms + * if the free-fall interrupt is enabled. Values between 100 ms * and 350 ms (0x14 to 0x46) are recommended. */ void setFreefallTime(int freefallTime_ms); - + /** * Get the axis tap settings. * @@ -355,9 +355,9 @@ public: * See datasheet for more details. * * @return The contents of the TAP_AXES register. - */ + */ int getTapAxisControl(void); - + /** * Set the axis tap settings. * @@ -373,14 +373,14 @@ public: * @param The control byte to write to the TAP_AXES register. */ void setTapAxisControl(int settings); - + /** * Get the source of a tap. * * @return The contents of the ACT_TAP_STATUS register. */ int getTapSource(void); - + /** * Set the power mode. * @@ -388,14 +388,14 @@ public: * 1 -> Reduced power operation. */ void setPowerMode(char mode); - + /** * Set the data rate. * * @param rate The rate code (see #defines or datasheet). */ void setDataRate(int rate); - + /** * Get the power control settings. * @@ -404,7 +404,7 @@ public: * @return The contents of the POWER_CTL register. */ int getPowerControl(void); - + /** * Set the power control settings. * @@ -413,56 +413,56 @@ public: * @param The control byte to write to the POWER_CTL register. */ void setPowerControl(int settings); - + /** * Get the interrupt enable settings. * * @return The contents of the INT_ENABLE register. */ int getInterruptEnableControl(void); - + /** * Set the interrupt enable settings. * * @param settings The control byte to write to the INT_ENABLE register. */ void setInterruptEnableControl(int settings); - + /** * Get the interrupt mapping settings. * * @return The contents of the INT_MAP register. */ int getInterruptMappingControl(void); - + /** * Set the interrupt mapping settings. * * @param settings The control byte to write to the INT_MAP register. */ void setInterruptMappingControl(int settings); - + /** * Get the interrupt source. * * @return The contents of the INT_SOURCE register. */ int getInterruptSource(void); - + /** * Get the data format settings. * * @return The contents of the DATA_FORMAT register. */ int getDataFormatControl(void); - + /** * Set the data format settings. * * @param settings The control byte to write to the DATA_FORMAT register. */ void setDataFormatControl(int settings); - + /** * Get the output of all three axes. * @@ -470,28 +470,28 @@ public: * x-axis, y-axis and z-axis [in that order]. */ void getOutput(int* readings); - + /** * Get the FIFO control settings. * * @return The contents of the FIFO_CTL register. */ int getFifoControl(void); - + /** * Set the FIFO control settings. * * @param The control byte to write to the FIFO_CTL register. */ void setFifoControl(int settings); - + /** * Get FIFO status. * * @return The contents of the FIFO_STATUS register. */ int getFifoStatus(void); - + private: SPI spi_; diff --git a/libraries/tests/peripherals/AX12/AX12.h b/libraries/tests/peripherals/AX12/AX12.h index e686191a6e..d1b3b42aef 100644 --- a/libraries/tests/peripherals/AX12/AX12.h +++ b/libraries/tests/peripherals/AX12/AX12.h @@ -54,9 +54,9 @@ * @code * #include "mbed.h" * #include "AX12.h" - * + * * int main() { - * + * * AX12 myax12 (p9, p10, 1); * * while (1) { @@ -75,8 +75,8 @@ public: /** Create an AX12 servo object connected to the specified serial port, with the specified ID * * @param pin tx pin - * @param pin rx pin - * @param int ID, the Bus ID of the servo 1-255 + * @param pin rx pin + * @param int ID, the Bus ID of the servo 1-255 */ AX12(PinName tx, PinName rx, int ID, int baud=1000000); @@ -106,7 +106,7 @@ public: * * @param degrees 0-300 * @param flags, defaults to 0 - * flags[0] = blocking, return when goal position reached + * flags[0] = blocking, return when goal position reached * flags[1] = register, activate with a broadcast trigger * */ @@ -127,7 +127,7 @@ public: * @param degrees, 0-300 */ int SetCWLimit(int degrees); - + /** Set the counter-clockwise limit of the servo * * @param degrees, 0-300 @@ -165,7 +165,7 @@ public: /** Read the temperature of the servo * - * @returns float temperature + * @returns float temperature */ float GetTemp(void); diff --git a/libraries/tests/peripherals/SRF08/SRF08.cpp b/libraries/tests/peripherals/SRF08/SRF08.cpp index c66c8ffe6b..8e44a3ee23 100644 --- a/libraries/tests/peripherals/SRF08/SRF08.cpp +++ b/libraries/tests/peripherals/SRF08/SRF08.cpp @@ -26,7 +26,7 @@ THE SOFTWARE. SRF08::SRF08(PinName sda, PinName scl, int addr) : m_i2c(sda, scl), m_addr(addr) { char cmd[2]; - + // Set up SRF08 max range and receiver sensitivity over I2C bus cmd[0] = 0x02; // Range register cmd[1] = 0x1C; // Set max range about 100cm diff --git a/libraries/tests/peripherals/SRF08/SRF08.h b/libraries/tests/peripherals/SRF08/SRF08.h index 5edaa9ac98..a3606338b8 100644 --- a/libraries/tests/peripherals/SRF08/SRF08.h +++ b/libraries/tests/peripherals/SRF08/SRF08.h @@ -1,17 +1,17 @@ /* Copyright (c) 2010 Chris Styles (chris dot styles at mbed dot org) - + Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - + The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -39,18 +39,18 @@ public: SRF08 */ SRF08(PinName sda, PinName scl, int addr); - + /*! Destroys instance. - */ + */ ~SRF08(); - + //!Reads the current temperature. /*! Reads the temperature register of the TMP102 and converts it to a useable value. */ float read(); - + private: I2C m_i2c; int m_addr; diff --git a/libraries/tests/peripherals/TMP102/TMP102.cpp b/libraries/tests/peripherals/TMP102/TMP102.cpp index 8bc074e47d..934c690ed3 100644 --- a/libraries/tests/peripherals/TMP102/TMP102.cpp +++ b/libraries/tests/peripherals/TMP102/TMP102.cpp @@ -9,15 +9,15 @@ TMP102::~TMP102() { } float TMP102::read() { const char tempRegAddr = TEMP_REG_ADDR; - + m_i2c.write(m_addr, &tempRegAddr, 1); - + char reg[2] = {0,0}; m_i2c.read(m_addr, reg, 2); - + unsigned short res = (reg[0] << 4) | (reg[1] >> 4); - + float temp = (float) ((float)res * 0.0625); - + return temp; } diff --git a/libraries/tests/peripherals/TMP102/TMP102.h b/libraries/tests/peripherals/TMP102/TMP102.h index 8925b5ba54..ce7de83849 100644 --- a/libraries/tests/peripherals/TMP102/TMP102.h +++ b/libraries/tests/peripherals/TMP102/TMP102.h @@ -14,23 +14,23 @@ public: /*! Connect module at I2C address addr using I2C port pins sda and scl. TMP102 - \param addr
A0 pin connectionAddress
GND0x90
V+0x92
SDA0x94
SCL0x96
+ \param addr
A0 pin connectionAddress
GND0x90
V+0x92
SDA0x94
SCL0x96
*/ TMP102(PinName sda, PinName scl, int addr); - + /*! Destroys instance. - */ + */ ~TMP102(); - + //!Reads the current temperature. /*! Reads the temperature register of the TMP102 and converts it to a useable value. */ float read(); - + I2C m_i2c; - + private: int m_addr; diff --git a/libraries/tests/rtos/cmsis/basic/main.cpp b/libraries/tests/rtos/cmsis/basic/main.cpp index 65155b5518..d78a49fcf6 100644 --- a/libraries/tests/rtos/cmsis/basic/main.cpp +++ b/libraries/tests/rtos/cmsis/basic/main.cpp @@ -14,7 +14,7 @@ osThreadDef(led2_thread, osPriorityNormal, DEFAULT_STACK_SIZE); int main() { osThreadCreate(osThread(led2_thread), NULL); - + while (true) { led1 = !led1; osDelay(500); diff --git a/libraries/tests/rtos/cmsis/isr/main.cpp b/libraries/tests/rtos/cmsis/isr/main.cpp index 1df5871a2d..52c7da3d8c 100644 --- a/libraries/tests/rtos/cmsis/isr/main.cpp +++ b/libraries/tests/rtos/cmsis/isr/main.cpp @@ -19,10 +19,10 @@ void queue_thread(void const *argument) { int main (void) { Thread thread(queue_thread); - + Ticker ticker; ticker.attach(queue_isr, 1.0); - + while (true) { osEvent evt = queue.get(); if (evt.status != osEventMessage) { diff --git a/libraries/tests/rtos/cmsis/mail/main.cpp b/libraries/tests/rtos/cmsis/mail/main.cpp index 4eac5617f1..545fca34c7 100644 --- a/libraries/tests/rtos/cmsis/mail/main.cpp +++ b/libraries/tests/rtos/cmsis/mail/main.cpp @@ -15,7 +15,7 @@ void send_thread (void const *argument) { while (true) { i++; // fake data update mail_t *mail = (mail_t*)osMailAlloc(mail_box, osWaitForever); - mail->voltage = (i * 0.1) * 33; + mail->voltage = (i * 0.1) * 33; mail->current = (i * 0.1) * 11; mail->counter = i; osMailPut(mail_box, mail); @@ -28,7 +28,7 @@ osThreadDef(send_thread, osPriorityNormal, DEFAULT_STACK_SIZE); int main (void) { mail_box = osMailCreate(osMailQ(mail_box), NULL); osThreadCreate(osThread(send_thread), NULL); - + while (true) { osEvent evt = osMailGet(mail_box, osWaitForever); if (evt.status == osEventMail) { @@ -36,7 +36,7 @@ int main (void) { printf("\nVoltage: %.2f V\n\r" , mail->voltage); printf("Current: %.2f A\n\r" , mail->current); printf("Number of cycles: %u\n\r", mail->counter); - + osMailFree(mail_box, mail); } } diff --git a/libraries/tests/rtos/cmsis/mutex/main.cpp b/libraries/tests/rtos/cmsis/mutex/main.cpp index 3e4d92d655..ccd1a603ca 100644 --- a/libraries/tests/rtos/cmsis/mutex/main.cpp +++ b/libraries/tests/rtos/cmsis/mutex/main.cpp @@ -25,9 +25,9 @@ osThreadDef(t3, osPriorityNormal, DEFAULT_STACK_SIZE); int main() { stdio_mutex = osMutexCreate(osMutex(stdio_mutex)); - + osThreadCreate(osThread(t2), NULL); osThreadCreate(osThread(t3), NULL); - + test_thread((void *)"Th 1"); } diff --git a/libraries/tests/rtos/cmsis/queue/main.cpp b/libraries/tests/rtos/cmsis/queue/main.cpp index badce1a273..1c6eab2f39 100644 --- a/libraries/tests/rtos/cmsis/queue/main.cpp +++ b/libraries/tests/rtos/cmsis/queue/main.cpp @@ -18,7 +18,7 @@ void send_thread (void const *argument) { while (true) { i++; // fake data update message_t *message = (message_t*)osPoolAlloc(mpool); - message->voltage = (i * 0.1) * 33; + message->voltage = (i * 0.1) * 33; message->current = (i * 0.1) * 11; message->counter = i; osMessagePut(queue, (uint32_t)message, osWaitForever); @@ -31,9 +31,9 @@ osThreadDef(send_thread, osPriorityNormal, DEFAULT_STACK_SIZE); int main (void) { mpool = osPoolCreate(osPool(mpool)); queue = osMessageCreate(osMessageQ(queue), NULL); - + osThreadCreate(osThread(send_thread), NULL); - + while (true) { osEvent evt = osMessageGet(queue, osWaitForever); if (evt.status == osEventMessage) { @@ -41,7 +41,7 @@ int main (void) { printf("\nVoltage: %.2f V\n\r" , message->voltage); printf("Current: %.2f A\n\r" , message->current); printf("Number of cycles: %u\n\r", message->counter); - + osPoolFree(mpool, message); } } diff --git a/libraries/tests/rtos/cmsis/semaphore/main.cpp b/libraries/tests/rtos/cmsis/semaphore/main.cpp index 4d8d9b53c3..d4b473c187 100644 --- a/libraries/tests/rtos/cmsis/semaphore/main.cpp +++ b/libraries/tests/rtos/cmsis/semaphore/main.cpp @@ -21,9 +21,9 @@ osThreadDef(t3, osPriorityNormal, DEFAULT_STACK_SIZE); int main (void) { two_slots = osSemaphoreCreate(osSemaphore(two_slots), 2); - + osThreadCreate(osThread(t2), NULL); osThreadCreate(osThread(t3), NULL); - + test_thread((void *)"Th 1"); } diff --git a/libraries/tests/rtos/cmsis/signals/main.cpp b/libraries/tests/rtos/cmsis/signals/main.cpp index 190d21ea82..14ce05dadb 100644 --- a/libraries/tests/rtos/cmsis/signals/main.cpp +++ b/libraries/tests/rtos/cmsis/signals/main.cpp @@ -15,7 +15,7 @@ osThreadDef(led_thread, osPriorityNormal, DEFAULT_STACK_SIZE); int main (void) { osThreadId tid = osThreadCreate(osThread(led_thread), NULL); - + while (true) { osDelay(1000); osSignalSet(tid, 0x1); diff --git a/libraries/tests/rtos/cmsis/timer/main.cpp b/libraries/tests/rtos/cmsis/timer/main.cpp index 53888c122c..a0b093f946 100644 --- a/libraries/tests/rtos/cmsis/timer/main.cpp +++ b/libraries/tests/rtos/cmsis/timer/main.cpp @@ -19,11 +19,11 @@ int main(void) { osTimerId timer_1 = osTimerCreate(osTimer(blink_1), osTimerPeriodic, (void *)1); osTimerId timer_2 = osTimerCreate(osTimer(blink_2), osTimerPeriodic, (void *)2); osTimerId timer_3 = osTimerCreate(osTimer(blink_3), osTimerPeriodic, (void *)3); - + osTimerStart(timer_0, 2000); osTimerStart(timer_1, 1000); osTimerStart(timer_2, 500); osTimerStart(timer_3, 250); - + osDelay(osWaitForever); } diff --git a/libraries/tests/usb/device/basic/main.cpp b/libraries/tests/usb/device/basic/main.cpp index dcf6af52c0..9f786559fc 100644 --- a/libraries/tests/usb/device/basic/main.cpp +++ b/libraries/tests/usb/device/basic/main.cpp @@ -10,17 +10,17 @@ int main(void) { int y_center = (Y_MAX_ABS - Y_MIN_ABS)/2; int16_t x_screen = 0; int16_t y_screen = 0; - + int32_t x_origin = x_center; int32_t y_origin = y_center; int32_t radius = 5000; int32_t angle = 0; - + while (1) { x_screen = x_origin + cos((double)angle*3.14/180.0)*radius; y_screen = y_origin + sin((double)angle*3.14/180.0)*radius; printf("cos: %f, sin: %f\r\n", cos((double)angle*3.14/180.0)*radius, sin((double)angle)*radius); - + mouse.move(x_screen, y_screen); angle += 3; wait(0.01); diff --git a/workspace_tools/build_release.py b/workspace_tools/build_release.py index fedaa46808..c1c48deb52 100644 --- a/workspace_tools/build_release.py +++ b/workspace_tools/build_release.py @@ -38,7 +38,7 @@ OFFICIAL_MBED_LIBRARY_BUILD = ( ('LPC11U35_401', ('ARM', 'uARM','GCC_ARM','GCC_CR')), ('LPC11U35_501', ('ARM', 'uARM','GCC_ARM','GCC_CR')), ('LPC1549', ('uARM',)), - + ('KL05Z', ('ARM', 'uARM', 'GCC_ARM')), ('KL25Z', ('ARM', 'GCC_ARM')), ('KL46Z', ('ARM', 'GCC_ARM')), @@ -81,14 +81,14 @@ if __name__ == '__main__': except Exception, e: failures.append(id) print e - + # Write summary of the builds print "\n\nCompleted in: (%.2f)s" % (time() - start) - + if successes: print "\n\nBuild successes:" print "\n".join([" * %s" % s for s in successes]) - + if failures: print "\n\nBuild failures:" print "\n".join([" * %s" % f for f in failures]) diff --git a/workspace_tools/data/rpc/class.cpp b/workspace_tools/data/rpc/class.cpp index 73f36a2371..f7831980c0 100644 --- a/workspace_tools/data/rpc/class.cpp +++ b/workspace_tools/data/rpc/class.cpp @@ -1,9 +1,9 @@ class Rpc{{name}} : public RPC { public: Rpc{{name}}({{cons_proto}}) : RPC(name), o({{cons_call}}) {} - + {{methods}} - + virtual const struct rpc_method *get_rpc_methods() { static const rpc_method rpc_methods[] = { {{rpc_methods}}, diff --git a/workspace_tools/data/support.py b/workspace_tools/data/support.py index ed65eb0ac0..b47380f4d9 100644 --- a/workspace_tools/data/support.py +++ b/workspace_tools/data/support.py @@ -21,7 +21,7 @@ CORTEX_ARM_SUPPORT = {} for target in TARGETS: DEFAULT_SUPPORT[target.name] = target.supported_toolchains - + if target.core.startswith('Cortex'): CORTEX_ARM_SUPPORT[target.name] = [t for t in target.supported_toolchains if (t=='ARM' or t=='uARM')] diff --git a/workspace_tools/dev/intel_hex_utils.py b/workspace_tools/dev/intel_hex_utils.py index da92d9d116..c60e9c4e74 100644 --- a/workspace_tools/dev/intel_hex_utils.py +++ b/workspace_tools/dev/intel_hex_utils.py @@ -8,13 +8,13 @@ def sections(h): if last_address is None: start, last_address = a, a continue - + if a > last_address + 1: yield (start, last_address) start = a - + last_address = a - + if start: yield (start, last_address) diff --git a/workspace_tools/dev/rpc_classes.py b/workspace_tools/dev/rpc_classes.py index 35d75ffc2d..f082f3b9da 100644 --- a/workspace_tools/dev/rpc_classes.py +++ b/workspace_tools/dev/rpc_classes.py @@ -153,38 +153,38 @@ for c in RPC_CLASSES: "cons_proto": get_args_proto(c_args, ["const char *name=NULL"]), "cons_call": get_args_call(c_args) } - + c_name = "Rpc" + c['name'] - + methods = [] rpc_methods = [] for r, m, a in c['methods']: ret_proto = r if r else "void" args_proto = "void" - + ret_defin = "return " if r else "" args_defin = "" - + if a: args_proto = get_args_proto(a) args_defin = get_args_call(a) - + proto = "%s %s(%s)" % (ret_proto, m, args_proto) defin = "{%so.%s(%s);}" % (ret_defin, m, args_defin) methods.append("%s %s" % (proto, defin)) - + rpc_method_type = [r] if r else [] rpc_method_type.append(c_name) rpc_method_type.extend(a) rpc_methods.append('{"%s", rpc_method_caller<%s, &%s::%s>}' % (m, ', '.join(rpc_method_type), c_name, m)) - + data['methods'] = "\n ".join(methods) data['rpc_methods'] = ",\n ".join(rpc_methods) - + class_decl = class_template.render(data) if 'required' in c: class_decl = "#if DEVICE_%s\n%s\n#endif" % (c['required'], class_decl) - + classes.append(class_decl) write_rpc_classes('\n\n'.join(classes)) diff --git a/workspace_tools/dev/syms.py b/workspace_tools/dev/syms.py index 63d90a2add..2fdbd2dfba 100644 --- a/workspace_tools/dev/syms.py +++ b/workspace_tools/dev/syms.py @@ -28,7 +28,7 @@ OBJ_EXT = ['.o', '.a', '.ar'] def find_sym_in_lib(sym, obj_path): contain_symbol = False - + out = Popen(["nm", "-C", obj_path], stdout=PIPE, stderr=PIPE).communicate()[0] for line in out.splitlines(): tokens = line.split() @@ -41,24 +41,24 @@ def find_sym_in_lib(sym, obj_path): sym_name = tokens[2] else: continue - + if sym_type == "U": # This object is using this symbol, not defining it continue - + if sym_name == sym: contain_symbol = True - + return contain_symbol def find_sym_in_path(sym, dir_path): for root, _, files in walk(dir_path): for file in files: - + _, ext = splitext(file) if ext not in OBJ_EXT: continue - + path = join(root, file) if find_sym_in_lib(sym, path): print path @@ -71,5 +71,5 @@ if __name__ == '__main__': parser.add_argument('-p', '--path', required=True, help='The path where to search') args = parser.parse_args() - + find_sym_in_path(args.sym, args.path) diff --git a/workspace_tools/export/codered.py b/workspace_tools/export/codered.py index 31da0c15b3..93acd2bff2 100644 --- a/workspace_tools/export/codered.py +++ b/workspace_tools/export/codered.py @@ -21,7 +21,7 @@ from os.path import splitext, basename class CodeRed(Exporter): NAME = 'CodeRed' TOOLCHAIN = 'GCC_CR' - + TARGETS = [ 'LPC1768', 'LPC4088', @@ -30,13 +30,13 @@ class CodeRed(Exporter): 'LPC11U35_501', 'UBLOX_C027', ] - + def generate(self): libraries = [] for lib in self.resources.libraries: l, _ = splitext(basename(lib)) libraries.append(l[3:]) - + ctx = { 'name': self.program_name, 'include_paths': self.resources.inc_dirs, diff --git a/workspace_tools/export/codesourcery.py b/workspace_tools/export/codesourcery.py index be278d3ec4..691cce809f 100644 --- a/workspace_tools/export/codesourcery.py +++ b/workspace_tools/export/codesourcery.py @@ -21,18 +21,18 @@ from os.path import splitext, basename class CodeSourcery(Exporter): NAME = 'CodeSourcery' TOOLCHAIN = 'GCC_CS' - + TARGETS = [ 'LPC1768', 'UBLOX_C027', ] - + DOT_IN_RELATIVE_PATH = True - + def generate(self): # "make" wants Unix paths self.resources.win_to_unix() - + to_be_compiled = [] for r_type in ['s_sources', 'c_sources', 'cpp_sources']: r = getattr(self.resources, r_type) @@ -40,12 +40,12 @@ class CodeSourcery(Exporter): for source in r: base, ext = splitext(source) to_be_compiled.append(base + '.o') - + libraries = [] for lib in self.resources.libraries: l, _ = splitext(basename(lib)) libraries.append(l[3:]) - + ctx = { 'name': self.program_name, 'to_be_compiled': to_be_compiled, diff --git a/workspace_tools/export/coide.py b/workspace_tools/export/coide.py index 4415d96400..4d88079e39 100644 --- a/workspace_tools/export/coide.py +++ b/workspace_tools/export/coide.py @@ -21,12 +21,12 @@ from os.path import splitext, basename class CoIDE(Exporter): NAME = 'CoIDE' TOOLCHAIN = 'GCC_ARM' - + TARGETS = [ 'KL25Z', 'KL05Z', ] - + # seems like CoIDE currently supports only one type FILE_TYPES = { 'c_sources':'1', diff --git a/workspace_tools/export/ds5_5.py b/workspace_tools/export/ds5_5.py index b78ca09b15..6f304ebafe 100644 --- a/workspace_tools/export/ds5_5.py +++ b/workspace_tools/export/ds5_5.py @@ -20,18 +20,18 @@ from os.path import basename class DS5_5(Exporter): NAME = 'DS5' - + TARGETS = [ 'LPC1768', 'LPC11U24', 'LPC812', 'UBLOX_C027', ] - + USING_MICROLIB = [ 'LPC812', ] - + FILE_TYPES = { 'c_sources':'1', 'cpp_sources':'8', @@ -40,7 +40,7 @@ class DS5_5(Exporter): def get_toolchain(self): return 'uARM' if (self.target in self.USING_MICROLIB) else 'ARM' - + def generate(self): source_files = [] for r_type, n in DS5_5.FILE_TYPES.iteritems(): @@ -48,7 +48,7 @@ class DS5_5(Exporter): source_files.append({ 'name': basename(file), 'type': n, 'path': file }) - + ctx = { 'name': self.program_name, 'include_paths': self.resources.inc_dirs, @@ -58,7 +58,7 @@ class DS5_5(Exporter): 'symbols': self.toolchain.get_symbols() } target = self.target.lower() - + # Project file self.gen_file('ds5_5_%s.project.tmpl' % target, ctx, '.project') self.gen_file('ds5_5_%s.cproject.tmpl' % target, ctx, '.cproject') diff --git a/workspace_tools/export/exporters.py b/workspace_tools/export/exporters.py index b8fcd85f76..a5114c23fc 100644 --- a/workspace_tools/export/exporters.py +++ b/workspace_tools/export/exporters.py @@ -16,20 +16,20 @@ class OldLibrariesException(Exception): pass class Exporter(): TEMPLATE_DIR = dirname(__file__) DOT_IN_RELATIVE_PATH = False - + def __init__(self, target, inputDir, program_name, build_url_resolver): self.inputDir = inputDir self.target = target self.program_name = program_name self.toolchain = TOOLCHAIN_CLASSES[self.get_toolchain()](TARGET_MAP[target]) self.build_url_resolver = build_url_resolver - + def get_toolchain(self): return self.TOOLCHAIN - + def __scan_and_copy(self, src_path, trg_path): resources = self.toolchain.scan_resources(src_path) - + for r_type in ['headers', 's_sources', 'c_sources', 'cpp_sources', 'objects', 'libraries', 'linker_script', 'lib_builds', 'lib_refs', 'repo_files', 'hex_files']: @@ -40,7 +40,7 @@ class Exporter(): def __scan_all(self, path): resources = [] - + for root, dirs, files in walk(path): for d in copy(dirs): if d == '.' or d == '..': @@ -49,9 +49,9 @@ class Exporter(): for file in files: file_path = join(root, file) resources.append(file_path) - + return resources - + def scan_and_copy_resources(self, prj_path, trg_path): # Copy only the file for the required target and toolchain lib_builds = [] @@ -63,7 +63,7 @@ class Exporter(): for repo_dir in resources.repo_dirs: repo_files = self.__scan_all(repo_dir) self.toolchain.copy_files(repo_files, trg_path, rel_path=join(prj_path, src)) - + # The libraries builds for bld in lib_builds: build_url = open(bld).read().strip() @@ -90,7 +90,7 @@ class Exporter(): template_text = open(template_path).read() template = Template(template_text) target_text = template.render(data) - + target_path = join(self.inputDir, target_file) logging.debug("Generating: %s" % target_path) open(target_path, "w").write(target_text) @@ -99,7 +99,7 @@ class Exporter(): def zip_working_directory_and_clean_up(tempdirectory=None, destination=None, program_name=None, clean=True): uid = str(uuid.uuid4()) zipfilename = '%s.zip'%uid - + logging.debug("Zipping up %s to %s" % (tempdirectory, join(destination, zipfilename))) # make zip def zipdir(basedir, archivename): @@ -112,10 +112,10 @@ def zip_working_directory_and_clean_up(tempdirectory=None, destination=None, pro absfn = join(root, fn) zfn = fakeroot + '/' + absfn[len(basedir)+len(os.sep):] z.write(absfn, zfn) - + zipdir(tempdirectory, join(destination, zipfilename)) - + if clean: shutil.rmtree(tempdirectory) - + return join(destination, zipfilename) diff --git a/workspace_tools/export/gccarm.py b/workspace_tools/export/gccarm.py index fc555a2426..b3c56cd5ca 100644 --- a/workspace_tools/export/gccarm.py +++ b/workspace_tools/export/gccarm.py @@ -21,7 +21,7 @@ from os.path import splitext, basename class GccArm(Exporter): NAME = 'GccArm' TOOLCHAIN = 'GCC_ARM' - + TARGETS = [ 'LPC1768', 'KL05Z', @@ -40,13 +40,13 @@ class GccArm(Exporter): 'DISCO_F303VC', 'UBLOX_C027', ] - + DOT_IN_RELATIVE_PATH = True - + def generate(self): # "make" wants Unix paths self.resources.win_to_unix() - + to_be_compiled = [] for r_type in ['s_sources', 'c_sources', 'cpp_sources']: r = getattr(self.resources, r_type) @@ -54,12 +54,12 @@ class GccArm(Exporter): for source in r: base, ext = splitext(source) to_be_compiled.append(base + '.o') - + libraries = [] for lib in self.resources.libraries: l, _ = splitext(basename(lib)) libraries.append(l[3:]) - + ctx = { 'name': self.program_name, 'to_be_compiled': to_be_compiled, diff --git a/workspace_tools/export/iar.py b/workspace_tools/export/iar.py index 3503153424..637e045be6 100644 --- a/workspace_tools/export/iar.py +++ b/workspace_tools/export/iar.py @@ -20,12 +20,12 @@ from exporters import Exporter class IAREmbeddedWorkbench(Exporter): NAME = 'IAR' TOOLCHAIN = 'IAR' - + TARGETS = [ 'LPC1768', 'UBLOX_C027', ] - + def generate(self): ctx = { 'name': self.program_name, diff --git a/workspace_tools/export/uvision4.py b/workspace_tools/export/uvision4.py index beb75267ec..bd9dd31361 100644 --- a/workspace_tools/export/uvision4.py +++ b/workspace_tools/export/uvision4.py @@ -20,7 +20,7 @@ from os.path import basename class Uvision4(Exporter): NAME = 'uVision4' - + TARGETS = [ 'LPC1768', 'LPC11U24', @@ -76,10 +76,10 @@ class Uvision4(Exporter): # By convention uVision projects do not show header files in the editor: # 'headers':'5', - + def get_toolchain(self): return 'uARM' if (self.target in self.USING_MICROLIB) else 'ARM' - + def get_flags(self): return self.FLAGS diff --git a/workspace_tools/export_test.py b/workspace_tools/export_test.py index d99329b7dd..9271c3c27e 100644 --- a/workspace_tools/export_test.py +++ b/workspace_tools/export_test.py @@ -35,9 +35,9 @@ def setup_test_user_prj(): if exists(USER_PRJ): print 'Test user project already generated...' return - + setup_user_prj(USER_PRJ, join(TEST_DIR, "rtos", "mbed", "basic"), [join(LIB_DIR, "rtos")]) - + # FAKE BUILD URL open(join(USER_SRC, "mbed.bld"), 'w').write("http://mbed.org/users/mbed_official/code/mbed/builds/976df7c37ad5\n") @@ -54,9 +54,9 @@ def test_export(toolchain, target, expected_error=None): base_dir = join(EXPORT_TMP, toolchain, target) temp_dir = join(base_dir, "temp") mkdir(temp_dir) - + zip_path, report = export(USER_PRJ, USR_PRJ_NAME, toolchain, target, base_dir, temp_dir, False, fake_build_url_resolver) - + if report['success']: move(zip_path, join(EXPORT_DIR, "export_%s_%s.zip" % (toolchain, target))) print "[OK]" @@ -74,7 +74,7 @@ def test_export(toolchain, target, expected_error=None): if __name__ == '__main__': setup_test_user_prj() - + for toolchain, target in [ ('uvision', 'LPC1768'), ('uvision', 'LPC11U24'), ('uvision', 'KL25Z'), ('uvision', 'LPC1347'), ('uvision', 'LPC1114'), ('uvision', 'LPC4088'), @@ -92,7 +92,7 @@ if __name__ == '__main__': # Linux path: /home/emimon01/bin/gcc-cs/bin/ # Windows path: "C:/Program Files (x86)/CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_EABI/bin/" ('codesourcery', 'LPC1768'), - + # Linux path: /home/emimon01/bin/gcc-arm/bin/ # Windows path: C:/arm-none-eabi-gcc-4_7/bin/ ('gcc_arm', 'LPC1768'), @@ -106,16 +106,16 @@ if __name__ == '__main__': ('gcc_arm', 'DISCO_F407VG'), ('gcc_arm', 'DISCO_F303VC'), - + ('ds5_5', 'LPC1768'), ('ds5_5', 'LPC11U24'), - + ('iar', 'LPC1768'), - + (None, None) ]: print '\n=== Exporting to "%s::%s" ===' % (toolchain, target) test_export(toolchain, target) - + print "\n=== Test error messages ===" test_export('lpcxpresso', 'LPC11U24', expected_error='lpcxpresso') diff --git a/workspace_tools/host_tests/echo.py b/workspace_tools/host_tests/echo.py index dd09701ac8..f5f8300ba6 100644 --- a/workspace_tools/host_tests/echo.py +++ b/workspace_tools/host_tests/echo.py @@ -22,7 +22,7 @@ class EchoTest(Test): Test.__init__(self) self.mbed.init_serial(115200) self.mbed.reset() - + def test(self): self.mbed.flush() self.notify("Starting the ECHO test") @@ -32,14 +32,14 @@ class EchoTest(Test): self.mbed.serial.write(TEST + "\n") l = self.mbed.serial.readline().strip() if not l: continue - + if l != TEST: check = False self.notify('"%s" != "%s"' % (l, TEST)) else: if (i % 10) == 0: self.notify('.') - + return check diff --git a/workspace_tools/host_tests/echo_flow_control.py b/workspace_tools/host_tests/echo_flow_control.py index b354d0b04c..7ea11e9736 100644 --- a/workspace_tools/host_tests/echo_flow_control.py +++ b/workspace_tools/host_tests/echo_flow_control.py @@ -23,7 +23,7 @@ class EchoTest(Test): self.mbed.init_serial() self.mbed.extra_serial.rtscts = True self.mbed.reset() - + def test(self): self.mbed.flush() self.notify("Starting the ECHO test") @@ -33,14 +33,14 @@ class EchoTest(Test): self.mbed.extra_serial.write(TEST + "\n") l = self.mbed.extra_serial.readline().strip() if not l: continue - + if l != TEST: check = False self.notify('"%s" != "%s"' % (l, TEST)) else: if (i % 10) == 0: self.notify('.') - + return check diff --git a/workspace_tools/host_tests/example/UDPEchoServer.py b/workspace_tools/host_tests/example/UDPEchoServer.py index 8dd511d570..38503489ee 100644 --- a/workspace_tools/host_tests/example/UDPEchoServer.py +++ b/workspace_tools/host_tests/example/UDPEchoServer.py @@ -15,7 +15,7 @@ See the License for the specific language governing permissions and limitations under the License. """ import socket - + ECHO_PORT = 7 sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) diff --git a/workspace_tools/host_tests/mbedrpc.py b/workspace_tools/host_tests/mbedrpc.py index 5789270921..3fbc2e6f0d 100644 --- a/workspace_tools/host_tests/mbedrpc.py +++ b/workspace_tools/host_tests/mbedrpc.py @@ -66,7 +66,7 @@ p30 = pin("p30") class mbed: def __init__(self): print("This will work as a demo but no transport mechanism has been selected") - + def rpc(self, name, method, args): print("Superclass method not overridden") @@ -84,18 +84,18 @@ class SerialRPC(mbed): print "Reset mbed" self.ser.sendBreak() time.sleep(2) - + def rpc(self, name, method, args): request = "/" + name + "/" + method + " " + " ".join(args) if self.debug: print "[RPC::TX] %s" % request self.ser.write(request + "\n") - + while True: response = self.ser.readline().strip() if self.debug: print "[RPC::RX] %s" % response - + # Ignore comments if not response.startswith('#'): break return response @@ -104,7 +104,7 @@ class SerialRPC(mbed): class HTTPRPC(mbed): def __init__(self, ip): self.host = "http://" + ip - + def rpc(self, name, method, args): response = urllib2.urlopen(self.host + "/rpc/" + name + "/" + method + "," + ",".join(args)) return response.read().strip() @@ -119,13 +119,13 @@ class DigitalOut(): self.name = mpin elif isinstance(mpin, pin): self.name = self.mbed.rpc("DigitalOut", "new", [mpin.name]) - + def __del__(self): r = self.mbed.rpc(self.name, "delete", []) - + def write(self, value): r = self.mbed.rpc(self.name, "write", [str(value)]) - + def read(self): r = self.mbed.rpc(self.name, "read", []) return int(r) @@ -138,14 +138,14 @@ class AnalogIn(): self.name = mpin elif isinstance(mpin, pin): self.name = self.mbed.rpc("AnalogIn", "new", [mpin.name]) - + def __del__(self): r = self.mbed.rpc(self.name, "delete", []) - + def read(self): r = self.mbed.rpc(self.name, "read", []) return float(r) - + def read_u16(self): r = self.mbed.rpc(self.name, "read_u16", []) return int(r) @@ -158,16 +158,16 @@ class AnalogOut(): self.name = mpin elif isinstance(mpin, pin): self.name = self.mbed.rpc("AnalogOut", "new", [mpin.name]) - + def __del__(self): r = self.mbed.rpc(self.name, "delete", []) - + def write(self, value): r = self.mbed.rpc(self.name, "write", [str(value)]) - + def write_u16(self, value): r = self.mbed.rpc(self.name, "write_u16", [str(value)]) - + def read(self): r = self.mbed.rpc(self.name, "read", []) return float(r) @@ -180,10 +180,10 @@ class DigitalIn(): self.name = mpin elif isinstance(mpin, pin): self.name = self.mbed.rpc("DigitalIn", "new", [mpin.name]) - + def __del__(self): r = self.mbed.rpc(self.name, "delete", []) - + def read(self): r = self.mbed.rpc(self.name, "read", []) return int(r) @@ -196,29 +196,29 @@ class PwmOut(): self.name = mpin elif isinstance(mpin, pin): self.name = self.mbed.rpc("PwmOut", "new", [mpin.name]) - + def __del__(self): r = self.mbed.rpc(self.name, "delete", []) - + def write(self, value): r = self.mbed.rpc(self.name, "write", [str(value)]) - + def read(self): r = self.mbed.rpc(self.name, "read", []) return float(r) - + def period(self, value): r = self.mbed.rpc(self.name, "period", [str(value)]) - + def period_ms(self, value): r = self.mbed.rpc(self.name, "period_ms", [str(value)]) - + def period_us(self, value): r = self.mbed.rpc(self.name, "period_us", [str(value)]) - + def puslewidth(self, value): r = self.mbed.rpc(self.name, "pulsewidth", [str(value)]) - + def puslewidth_ms(self, value): r = self.mbed.rpc(self.name, "pulsewidth_ms", [str(value)]) @@ -233,16 +233,16 @@ class Serial(): self.name = mpin elif isinstance(mpin, pin): self.name = self.mbed.rpc("Serial", "new", [tx.name, rx.name]) - + def __del__(self): r = self.mbed.rpc(self.name, "delete", []) - + def putc(self, value): r = self.mbed.rpc(self.name, "putc", [str(value)]) - + def puts(self, value): r = self.mbed.rpc(self.name, "puts", [ "\"" + str(value) + "\""]) - + def getc(self): r = self.mbed.rpc(self.name, "getc", []) return int(r) @@ -253,14 +253,14 @@ class RPCFunction(): self.mbed = this_mbed if isinstance(name, str): self.name = name - + def __del__(self): r = self.mbed.rpc(self.name, "delete", []) - + def read(self): r = self.mbed.rpc(self.name, "read", []) return int(r) - + def run(self, input): r = self.mbed.rpc(self.name, "run", [input]) return r @@ -271,13 +271,13 @@ class RPCVariable(): self.mbed = this_mbed if isinstance(name, str): self.name = name - + def __del__(self): r = self.mbed.rpc(self.name, "delete", []) - + def write(self, value): self.mbed.rpc(self.name, "write", [str(value)]) - + def read(self): r = self.mbed.rpc(self.name, "read", []) return r diff --git a/workspace_tools/host_tests/rpc.py b/workspace_tools/host_tests/rpc.py index 3e5c147638..84b85d2cc6 100644 --- a/workspace_tools/host_tests/rpc.py +++ b/workspace_tools/host_tests/rpc.py @@ -22,26 +22,26 @@ class RpcTest(Test): def test(self): self.notify("RPC Test") s = SerialRPC(self.mbed.port, debug=True) - + self.notify("Init remote objects") - + p_out = pin("p10") p_in = pin("p11") - + if hasattr(self.mbed.options, 'micro'): if self.mbed.options.micro == 'M0+': print "Freedom Board: PTA12 <-> PTC4" p_out = pin("PTA12") p_in = pin("PTC4") - + self.output = DigitalOut(s, p_out); self.input = DigitalIn(s, p_in); - + self.check = True self.write_read_test(1) self.write_read_test(0) return self.check - + def write_read_test(self, v): self.notify("Check %d" % v) self.output.write(v) diff --git a/workspace_tools/host_tests/tcpecho_client.py b/workspace_tools/host_tests/tcpecho_client.py index cff88e9606..303f002ab8 100644 --- a/workspace_tools/host_tests/tcpecho_client.py +++ b/workspace_tools/host_tests/tcpecho_client.py @@ -30,17 +30,17 @@ UPDATE_STEP = (N_PACKETS/10) class TCP_EchoClient: def __init__(self, host): - self.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + self.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.s.connect((host, ECHO_PORT)) self.packet = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(LEN_PACKET)) - + def __packet(self): # Comment out the checks when measuring the throughput # self.packet = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(LEN_PACKET)) self.s.send(self.packet) data = self.s.recv(LEN_PACKET) # assert self.packet == data, "packet error:\n%s\n%s\n" % (self.packet, data) - + def test(self): start = time() for i in range(N_PACKETS): @@ -48,9 +48,9 @@ class TCP_EchoClient: self.__packet() t = time() - start print 'Throughput: (%.2f)Mbits/s' % ((TOT_BITS / t)/MEGA) - + def __del__(self): - self.s.close() + self.s.close() while True: e = TCP_EchoClient(SERVER_ADDRESS) diff --git a/workspace_tools/host_tests/tcpecho_server.py b/workspace_tools/host_tests/tcpecho_server.py index c85aab96ef..4a68bd9ee7 100644 --- a/workspace_tools/host_tests/tcpecho_server.py +++ b/workspace_tools/host_tests/tcpecho_server.py @@ -31,7 +31,7 @@ class TCP_EchoHandler(BaseRequestHandler): while True: data = self.request.recv(1024) if not data: break - + bytes += len(data) for n in map(ord, data): if n != index: @@ -39,7 +39,7 @@ class TCP_EchoHandler(BaseRequestHandler): index += 1 if index > MAX_INDEX: index = 0 - + self.request.sendall(data) t = time() - start b = float(bytes * 8) * 2 diff --git a/workspace_tools/host_tests/udpecho_client.py b/workspace_tools/host_tests/udpecho_client.py index 753496cd5b..1ff833f175 100644 --- a/workspace_tools/host_tests/udpecho_client.py +++ b/workspace_tools/host_tests/udpecho_client.py @@ -30,18 +30,18 @@ UPDATE_STEP = (N_PACKETS/10) class UDP_EchoClient: s = socket(AF_INET, SOCK_DGRAM) - + def __init__(self, host): self.host = host self.packet = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(LEN_PACKET)) - + def __packet(self): # Comment out the checks when measuring the throughput # packet = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(LEN_PACKET)) UDP_EchoClient.s.sendto(packet, (self.host, ECHO_PORT)) data = UDP_EchoClient.s.recv(LEN_PACKET) # assert packet == data, "packet error:\n%s\n%s\n" % (packet, data) - + def test(self): start = time() for i in range(N_PACKETS): diff --git a/workspace_tools/libraries.py b/workspace_tools/libraries.py index 95040f7573..3af8e42243 100644 --- a/workspace_tools/libraries.py +++ b/workspace_tools/libraries.py @@ -32,7 +32,7 @@ LIBRARIES = [ "build_dir": RTOS_LIBRARIES, "dependencies": [MBED_LIBRARIES, MBED_RTX], }, - + # USB Device libraries { "id": "usb", @@ -40,7 +40,7 @@ LIBRARIES = [ "build_dir": USB_LIBRARIES, "dependencies": [MBED_LIBRARIES], }, - + # USB Host libraries { "id": "usb_host", @@ -48,7 +48,7 @@ LIBRARIES = [ "build_dir": USB_HOST_LIBRARIES, "dependencies": [MBED_LIBRARIES, FAT_FS, MBED_RTX, RTOS_ABSTRACTION], }, - + # DSP libraries { "id": "cmsis_dsp", @@ -62,7 +62,7 @@ LIBRARIES = [ "build_dir": DSP_LIBRARIES, "dependencies": [MBED_LIBRARIES, DSP_CMSIS], }, - + # Network libraries { "id": "eth", @@ -70,7 +70,7 @@ LIBRARIES = [ "build_dir": ETH_LIBRARY, "dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES] }, - + { "id": "ublox", "source_dir": [UBLOX_SOURCES, CELLULAR_SOURCES, CELLULAR_USB_SOURCES, LWIP_SOURCES], @@ -92,7 +92,7 @@ class Library: def __init__(self, lib_id): self.__dict__.update(Library.DEFAULTS) self.__dict__.update(LIBRARY_MAP[lib_id]) - + def is_supported(self, target, toolchain): if not hasattr(self, 'supported'): return True diff --git a/workspace_tools/options.py b/workspace_tools/options.py index 8ba8aff9d6..bbd26f4dd3 100644 --- a/workspace_tools/options.py +++ b/workspace_tools/options.py @@ -22,19 +22,19 @@ from workspace_tools.targets import TARGET_NAMES def get_default_options_parser(): parser = OptionParser() - + parser.add_option("-m", "--mcu", help="build for the given MCU (%s)" % ', '.join(TARGET_NAMES), metavar="MCU") - + parser.add_option("-t", "--tool", help="build using the given TOOLCHAIN (%s)" % ', '.join(TOOLCHAINS), metavar="TOOLCHAIN") - + parser.add_option("-c", "--clean", action="store_true", default=False, help="clean the build directory") - + parser.add_option("-o", "--options", action="append", help='Add a build option ("save-asm": save the asm generated by the compiler, "debug-info": generate debugging information, "analyze": run static code analyzer")') - + return parser diff --git a/workspace_tools/patch.py b/workspace_tools/patch.py index e87b4ef05c..6fda63f3c3 100644 --- a/workspace_tools/patch.py +++ b/workspace_tools/patch.py @@ -31,7 +31,7 @@ def patch(bin_path): with open(bin_path, 'r+b') as bin: # Read entries 0 through 6 (Little Endian 32bits words) vector = [unpack(' (len(TESTS)-1)): message = "[ERROR] You have to specify one of the following tests:\n" message += '\n'.join(map(str, sorted(TEST_MAP.values()))) args_error(parser, message) test = Test(options.program) - + if not options.build: # Substitute the library builds with the sources # TODO: Substitute also the other library build paths if MBED_LIBRARIES in test.dependencies: test.dependencies.remove(MBED_LIBRARIES) test.dependencies.append(MBED_BASE) - + # Build the projectwith the same directory structure of the mbed online IDE project_dir = join(EXPORT_WORKSPACE, test.id) setup_user_prj(project_dir, test.source_dir, test.dependencies) - - # Export to selected toolchain + + # Export to selected toolchain tmp_path, report = export(project_dir, test.id, ide, mcu, EXPORT_WORKSPACE, EXPORT_TMP) if report['success']: zip_path = join(EXPORT_DIR, "%s_%s_%s.zip" % (test.id, ide, mcu)) diff --git a/workspace_tools/size.py b/workspace_tools/size.py index 8ba897d43f..233cb96153 100644 --- a/workspace_tools/size.py +++ b/workspace_tools/size.py @@ -61,13 +61,13 @@ def benchmarks(): # CSV Data csv_data = csv.writer(open(BENCHMARK_DATA_PATH, 'wb')) csv_data.writerow(['Toolchain', "Target", "Benchmark", "code", "data", "bss", "flash"]) - + # Build for toolchain in ['ARM', 'uARM', 'GCC_CR', 'GCC_CS', 'GCC_ARM']: for mcu in ["LPC1768", "LPC11U24"]: # Build Libraries build_mbed_libs(mcu, toolchain) - + # Build benchmarks build_dir = join(BUILD_DIR, "benchmarks", mcu, toolchain) for test_id, title in BENCHMARKS: @@ -90,23 +90,23 @@ def compare(t1, t2, target): benchmarks() else: print "Loading: %s" % BENCHMARK_DATA_PATH - + data = csv.reader(open(BENCHMARK_DATA_PATH, 'rb')) - + benchmarks_data = defaultdict(dict) for (toolchain, mcu, name, code, data, bss, flash) in data: if target == mcu: for t in [t1, t2]: if toolchain == t: benchmarks_data[name][t] = map(int, (code, data, bss, flash)) - + print "%s vs %s for %s" % (t1, t2, target) for name, data in benchmarks_data.iteritems(): try: # Check Size code_a, data_a, bss_a, flash_a = data[t1] code_u, data_u, bss_u, flash_u = data[t2] - + print "\n=== %s ===" % name print_diff("code", code_a , code_u) print_diff("data", data_a , data_u) diff --git a/workspace_tools/synch.py b/workspace_tools/synch.py index a515263d93..cfc17212d9 100644 --- a/workspace_tools/synch.py +++ b/workspace_tools/synch.py @@ -46,19 +46,19 @@ commit_msg = '' # Code that does have a mirror in the mbed SDK # Tuple data: (repo_name, list_of_code_dirs, [team]) # team is optional - if not specified, the code is published under mbed_official -OFFICIAL_CODE = ( +OFFICIAL_CODE = ( ("mbed-src" , "mbed"), ("mbed-rtos", "rtos"), ("mbed-dsp" , "dsp"), ("mbed-rpc" , "rpc"), - + ("lwip" , "net/lwip/lwip"), ("lwip-sys", "net/lwip/lwip-sys"), ("Socket" , "net/lwip/Socket"), - + ("lwip-eth" , "net/eth/lwip-eth"), ("EthernetInterface", "net/eth/EthernetInterface"), - + ("USBDevice", "USBDevice"), ("USBHost" , "USBHost"), @@ -75,7 +75,7 @@ OFFICIAL_CODE = ( CODE_WITH_DEPENDENCIES = ( # Libraries "EthernetInterface", - + # RTOS Examples "rtos_basic", "rtos_isr", @@ -85,7 +85,7 @@ CODE_WITH_DEPENDENCIES = ( "rtos_semaphore", "rtos_signals", "rtos_timer", - + # Net Examples "TCPEchoClient", "TCPEchoServer", @@ -95,7 +95,7 @@ CODE_WITH_DEPENDENCIES = ( "UDPEchoServer", "BroadcastReceive", "BroadcastSend", - + # mbed sources "mbed-src-program", ) @@ -123,7 +123,7 @@ class MbedRepository: def run_and_print(command, cwd): stdout, _, _ = run_cmd(command, wd=cwd, redirect=True) print(stdout) - + def __init__(self, name, team = None): self.name = name self.path = join(MBED_ORG_PATH, name) @@ -135,14 +135,14 @@ class MbedRepository: # Checkout code if not exists(MBED_ORG_PATH): makedirs(MBED_ORG_PATH) - + self.run_and_print(['hg', 'clone', self.url % name], cwd=MBED_ORG_PATH) - + else: # Update self.run_and_print(['hg', 'pull'], cwd=self.path) self.run_and_print(['hg', 'update'], cwd=self.path) - + def publish(self): # The maintainer has to evaluate the changes first and explicitly accept them self.run_and_print(['hg', 'addremove'], cwd=self.path) @@ -205,7 +205,7 @@ def get_line_endings(f): return 'cr' # Copy file to destination, but preserve destination line endings if possible -# This prevents very annoying issues with huge diffs that appear because of +# This prevents very annoying issues with huge diffs that appear because of # differences in line endings def copy_with_line_endings(sdk_file, repo_file): if not isfile(repo_file): @@ -237,11 +237,11 @@ def visit_files(path, visit): if ignore_path(full, IGNORE_DIRS): print "Skipping '%s'" % full dirs.remove(d) - + for file in files: if ignore_path(file, IGNORE_FILES): continue - + visit(join(root, file)) @@ -250,15 +250,15 @@ def update_repo(repo_name, sdk_paths, team_name): # copy files from mbed SDK to mbed_official repository def visit_mbed_sdk(sdk_file): repo_file = join(repo.path, relpath(sdk_file, sdk_path)) - + repo_dir = dirname(repo_file) if not exists(repo_dir): makedirs(repo_dir) - + copy_with_line_endings(sdk_file, repo_file) for sdk_path in sdk_paths: visit_files(sdk_path, visit_mbed_sdk) - + # remove repository files that do not exist in the mbed SDK def visit_repo(repo_file): for sdk_path in sdk_paths: @@ -269,7 +269,7 @@ def update_repo(repo_name, sdk_paths, team_name): remove(repo_file) print "remove: %s" % repo_file visit_files(repo.path, visit_repo) - + if repo.publish(): changed.append(repo_name) @@ -294,7 +294,7 @@ def update_dependencies(repositories): for repo_name in repositories: print '\n=== Updating "%s" ===' % repo_name repo = MbedRepository(repo_name) - + # point to the latest libraries def visit_repo(repo_file): with open(repo_file, "r") as f: @@ -302,7 +302,7 @@ def update_dependencies(repositories): with open(repo_file, "w") as f: f.write(url[:(url.rindex('/')+1)]) visit_files(repo.path, visit_repo, None, MBED_REPO_EXT) - + if repo.publish(): changed.append(repo_name) @@ -317,13 +317,13 @@ def do_sync(options): quiet = options.quiet commit_msg = options.msg chnaged = [] - + if options.code: update_code(OFFICIAL_CODE) - + if options.dependencies: update_dependencies(CODE_WITH_DEPENDENCIES) - + if options.mbed: update_mbed() @@ -337,19 +337,19 @@ def do_sync(options): if __name__ == '__main__': parser = OptionParser() - + parser.add_option("-c", "--code", action="store_true", default=False, help="Update the mbed_official code") - + parser.add_option("-d", "--dependencies", action="store_true", default=False, help="Update the mbed_official code dependencies") - + parser.add_option("-m", "--mbed", action="store_true", default=False, help="Release a build of the mbed library") - + parser.add_option("-n", "--nopush", action="store_true", default=False, help="Commit the changes locally only, don't push them") @@ -361,12 +361,12 @@ if __name__ == '__main__': parser.add_option("-r", "--repository", action="store", type="string", default='', dest='repo', help="Synchronize only the given repository") - + parser.add_option("-q", "--quiet", action="store_true", default=False, help="Don't ask for confirmation before commiting or pushing") - + (options, args) = parser.parse_args() - + do_sync(options) diff --git a/workspace_tools/targets.py b/workspace_tools/targets.py index 096e0fe598..3d598e3811 100644 --- a/workspace_tools/targets.py +++ b/workspace_tools/targets.py @@ -32,13 +32,13 @@ class Target: def __init__(self): # ARM Core self.core = None - + # Is the disk provided by the interface chip of this board virtual? self.is_disk_virtual = False - + # list of toolchains that are supported by the mbed SDK for this target self.supported_toolchains = None - + # list of extra specific labels self.extra_labels = [] @@ -46,13 +46,13 @@ class Target: self.macros = [] self.name = self.__class__.__name__ - + def program_cycle_s(self): return 4 if self.is_disk_virtual else 1.5 - + def get_labels(self): return [self.name, CORE_LABELS[self.core]] + self.extra_labels - + def init_hooks(self, hook, toolchain_name): pass @@ -60,22 +60,22 @@ class Target: class LPC2368(Target): def __init__(self): Target.__init__(self) - + self.core = "ARM7TDMI-S" - + self.extra_labels = ['NXP', 'LPC23XX'] - + self.supported_toolchains = ["ARM","GCC_ARM","GCC_CR"] class LPC1768(Target): def __init__(self): Target.__init__(self) - + self.core = "Cortex-M3" - + self.extra_labels = ['NXP', 'LPC176X', 'MBED_LPC1768'] - + self.supported_toolchains = ["ARM", "uARM", "GCC_ARM", "GCC_CS", "GCC_CR", "IAR"] @@ -84,22 +84,22 @@ class LPC11U24(Target): def __init__(self): Target.__init__(self) - + self.core = "Cortex-M0" - + self.extra_labels = ['NXP', 'LPC11UXX', 'LPC11U24_401'] - + self.supported_toolchains = ["ARM", "uARM", "GCC_ARM"] class LPC11U24_301(Target): def __init__(self): Target.__init__(self) - + self.core = "Cortex-M0" - + self.extra_labels = ['NXP', 'LPC11UXX'] - + self.supported_toolchains = ["ARM", "uARM", "GCC_ARM"] @@ -108,58 +108,58 @@ class KL05Z(Target): def __init__(self): Target.__init__(self) - + self.core = "Cortex-M0+" - + self.extra_labels = ['Freescale', 'KLXX'] - + self.supported_toolchains = ["ARM", "uARM", "GCC_ARM"] - + self.supported_form_factors = ["ARDUINO"] - + self.is_disk_virtual = True class KL25Z(Target): def __init__(self): Target.__init__(self) - + self.core = "Cortex-M0+" - + self.extra_labels = ['Freescale', 'KLXX'] - + self.supported_toolchains = ["ARM", "GCC_CW_EWL", "GCC_CW_NEWLIB", "GCC_ARM"] - + self.supported_form_factors = ["ARDUINO"] - + self.is_disk_virtual = True class KL46Z(Target): def __init__(self): Target.__init__(self) - + self.core = "Cortex-M0+" - + self.extra_labels = ['Freescale', 'KLXX'] - + self.supported_toolchains = ["GCC_ARM", "ARM"] - + self.supported_form_factors = ["ARDUINO"] - + self.is_disk_virtual = True class K20D5M(Target): def __init__(self): Target.__init__(self) - + self.core = "Cortex-M4" - + self.extra_labels = ['Freescale'] - + self.supported_toolchains = ["GCC_ARM", "ARM"] - + self.is_disk_virtual = True @@ -174,7 +174,7 @@ class K64F(Target): self.macros = ["CPU_MK64FN1M0VMD12", "FSL_RTOS_MBED"] self.supported_toolchains = ["ARM"] - + self.supported_form_factors = ["ARDUINO"] self.is_disk_virtual = True @@ -185,15 +185,15 @@ class LPC812(Target): def __init__(self): Target.__init__(self) - + self.core = "Cortex-M0+" - + self.extra_labels = ['NXP', 'LPC81X'] - + self.supported_toolchains = ["uARM"] - + self.supported_form_factors = ["ARDUINO"] - + self.is_disk_virtual = True @@ -202,32 +202,32 @@ class LPC810(Target): def __init__(self): Target.__init__(self) - + self.core = "Cortex-M0+" - + self.extra_labels = ['NXP', 'LPC81X'] - + self.supported_toolchains = ["uARM"] - + self.is_disk_virtual = True class LPC4088(Target): def __init__(self): Target.__init__(self) - + self.core = "Cortex-M4F" - + self.extra_labels = ['NXP', 'LPC408X'] - + self.supported_toolchains = ["ARM", "GCC_CR", "GCC_ARM"] - + self.is_disk_virtual = True - + def init_hooks(self, hook, toolchain_name): if toolchain_name in ['ARM_STD', 'ARM_MICRO']: hook.hook_add_binary("post", self.binary_hook) - + @staticmethod def binary_hook(t_self, resources, elf, binf): if not os.path.isdir(binf): @@ -260,44 +260,44 @@ class LPC4088(Target): class LPC4330_M4(Target): def __init__(self): Target.__init__(self) - + self.core = "Cortex-M4F" - + self.extra_labels = ['NXP', 'LPC43XX'] - + self.supported_toolchains = ["ARM", "GCC_CR", "IAR", "GCC_ARM"] class LPC4330_M0(Target): def __init__(self): Target.__init__(self) - + self.core = "Cortex-M0" - + self.extra_labels = ['NXP', 'LPC43XX'] - + self.supported_toolchains = ["ARM", "GCC_CR", "IAR"] class LPC1800(Target): def __init__(self): Target.__init__(self) - + self.core = "Cortex-M3" - + self.extra_labels = ['NXP', 'LPC43XX'] - + self.supported_toolchains = ["ARM", "GCC_CR", "IAR"] class STM32F407(Target): def __init__(self): Target.__init__(self) - + self.core = "Cortex-M4F" - + self.extra_labels = ['STM', 'STM32F4XX'] - + self.supported_toolchains = ["ARM", "GCC_ARM"] @@ -307,13 +307,13 @@ class NUCLEO_F030R8(Target): def __init__(self): Target.__init__(self) - + self.core = "Cortex-M0" - + self.extra_labels = ['STM', 'STM32F0', 'STM32F030R8'] - + self.supported_toolchains = ["ARM", "uARM"] - + self.supported_form_factors = ["ARDUINO", "MORPHO"] @@ -323,13 +323,13 @@ class NUCLEO_F072RB(Target): def __init__(self): Target.__init__(self) - + self.core = "Cortex-M0" - + self.extra_labels = ['STM', 'STM32F0', 'STM32F072RB'] - + self.supported_toolchains = ["ARM", "uARM"] - + self.supported_form_factors = ["ARDUINO", "MORPHO"] @@ -339,13 +339,13 @@ class NUCLEO_F103RB(Target): def __init__(self): Target.__init__(self) - + self.core = "Cortex-M3" - + self.extra_labels = ['STM', 'STM32F1', 'STM32F103RB'] - + self.supported_toolchains = ["ARM", "uARM", "GCC_ARM"] - + self.supported_form_factors = ["ARDUINO", "MORPHO"] @@ -355,13 +355,13 @@ class NUCLEO_F302R8(Target): def __init__(self): Target.__init__(self) - + self.core = "Cortex-M4F" - + self.extra_labels = ['STM', 'STM32F3', 'STM32F302R8'] - + self.supported_toolchains = ["ARM", "uARM"] - + self.supported_form_factors = ["ARDUINO", "MORPHO"] @@ -371,13 +371,13 @@ class NUCLEO_F401RE(Target): def __init__(self): Target.__init__(self) - + self.core = "Cortex-M4F" - + self.extra_labels = ['STM', 'STM32F4', 'STM32F401RE'] - + self.supported_toolchains = ["ARM", "uARM", "GCC_ARM"] - + self.supported_form_factors = ["ARDUINO", "MORPHO"] @@ -387,13 +387,13 @@ class NUCLEO_L053R8(Target): def __init__(self): Target.__init__(self) - + self.core = "Cortex-M0+" - + self.extra_labels = ['STM', 'STM32L0', 'STM32L053R8'] - + self.supported_toolchains = ["ARM", "uARM"] - + self.supported_form_factors = ["ARDUINO", "MORPHO"] @@ -403,13 +403,13 @@ class NUCLEO_L152RE(Target): def __init__(self): Target.__init__(self) - + self.core = "Cortex-M3" - + self.extra_labels = ['STM', 'STM32L1', 'STM32L152RE'] - + self.supported_toolchains = ["ARM", "uARM"] - + self.supported_form_factors = ["ARDUINO", "MORPHO"] @@ -419,23 +419,23 @@ class STM32F3XX(Target): def __init__(self): Target.__init__(self) - - self.core = "Cortex-M4" - - self.extra_labels = ['STM', 'STM32F3XX'] - - self.supported_toolchains = ["ARM", "uARM", "GCC_ARM"] - - + self.core = "Cortex-M4" + + self.extra_labels = ['STM', 'STM32F3XX'] + + self.supported_toolchains = ["ARM", "uARM", "GCC_ARM"] + + + class LPC1347(Target): def __init__(self): Target.__init__(self) - + self.core = "Cortex-M3" - + self.extra_labels = ['NXP', 'LPC13XX'] - + self.supported_toolchains = ["ARM", "GCC_ARM"] @@ -444,22 +444,22 @@ class LPC1114(Target): def __init__(self): Target.__init__(self) - + self.core = "Cortex-M0" - + self.extra_labels = ['NXP', 'LPC11XX_11CXX', 'LPC11XX'] - + self.supported_toolchains = ["ARM", "uARM", "GCC_ARM","GCC_CR"] class LPC11C24(Target): def __init__(self): Target.__init__(self) - + self.core = "Cortex-M0" - + self.extra_labels = ['NXP', 'LPC11XX_11CXX', 'LPC11CXX'] - + self.supported_toolchains = ["ARM", "uARM", "GCC_ARM"] @@ -468,11 +468,11 @@ class LPC11U35_401(Target): def __init__(self): Target.__init__(self) - + self.core = "Cortex-M0" - + self.extra_labels = ['NXP', 'LPC11UXX'] - + self.supported_toolchains = ["ARM", "uARM", "GCC_ARM","GCC_CR"] @@ -481,50 +481,50 @@ class LPC11U35_501(Target): def __init__(self): Target.__init__(self) - + self.core = "Cortex-M0" - + self.extra_labels = ['NXP', 'LPC11UXX'] - + self.supported_toolchains = ["ARM", "uARM","GCC_ARM","GCC_CR"] class UBLOX_C027(Target): def __init__(self): Target.__init__(self) - + self.core = "Cortex-M3" - + self.extra_labels = ['NXP', 'LPC176X'] - + self.supported_toolchains = ["ARM", "uARM", "GCC_ARM", "GCC_CS", "GCC_CR", "IAR"] self.macros = ['TARGET_LPC1768'] - + self.supported_form_factors = ["ARDUINO"] class NRF51822(Target): EXPECTED_SOFTDEVICE = 's110_nrf51822_6.0.0_softdevice.hex' OUTPUT_EXT = '.hex' - + APPCODE_OFFSET = 0x14000 - + def __init__(self): Target.__init__(self) - + self.core = "Cortex-M0" - + self.extra_labels = ["NORDIC"] - + self.supported_toolchains = ["ARM"] - + self.is_disk_virtual = True - + def init_hooks(self, hook, toolchain_name): if toolchain_name in ['ARM_STD', 'ARM_MICRO']: hook.hook_add_binary("post", self.binary_hook) - + @staticmethod def binary_hook(t_self, resources, elf, binf): for hexf in resources.hex_files: @@ -533,46 +533,46 @@ class NRF51822(Target): else: t_self.debug("Hex file not found. Aborting.") return - + # Merge user code with softdevice from intelhex import IntelHex binh = IntelHex() binh.loadbin(binf, offset = NRF51822.APPCODE_OFFSET) - + sdh = IntelHex(hexf) sdh.merge(binh) - + with open(binf.replace(".bin", ".hex"), "w") as f: sdh.tofile(f, format = 'hex') class LPC1549(Target): ONLINE_TOOLCHAIN = "uARM" - + def __init__(self): Target.__init__(self) - + self.core = "Cortex-M3" - + self.extra_labels = ['NXP', 'LPC15XX'] - + self.supported_toolchains = ["uARM"] - + self.supported_form_factors = ["ARDUINO"] class LPC11U68(Target): ONLINE_TOOLCHAIN = "uARM" - + def __init__(self): Target.__init__(self) - + self.core = "Cortex-M0+" - + self.extra_labels = ['NXP', 'LPC11U6X'] - + self.supported_toolchains = ["uARM"] - + self.supported_form_factors = ["ARDUINO"] @@ -582,39 +582,39 @@ class DISCO_F100RB(Target): def __init__(self): Target.__init__(self) - + self.core = "Cortex-M3" - + self.extra_labels = ['STM', 'STM32F1', 'STM32F100RB'] - + self.supported_toolchains = ["GCC_ARM"] - + class DISCO_F051R8(Target): ONLINE_TOOLCHAIN = "uARM" OUTPUT_NAMING = "8.3" def __init__(self): Target.__init__(self) - + self.core = "Cortex-M0" - + self.extra_labels = ['STM', 'STM32F0', 'STM32F051','STM32F051R8'] - + self.supported_toolchains = ["GCC_ARM"] - + class DISCO_F407VG(Target): ONLINE_TOOLCHAIN = "uARM" OUTPUT_NAMING = "8.3" def __init__(self): Target.__init__(self) - + self.core = "Cortex-M4F" - + self.extra_labels = ['STM', 'STM32F4', 'STM32F407','STM32F407VG'] - + self.supported_toolchains = ["GCC_ARM"] @@ -624,13 +624,13 @@ class DISCO_F303VC(Target): def __init__(self): Target.__init__(self) - + self.core = "Cortex-M4F" - + self.extra_labels = ['STM', 'STM32F3', 'STM32F303','STM32F303VC'] - + self.supported_toolchains = ["GCC_ARM"] - + class XADOW_M0(LPC11U35_501): def __init__(self): LPC11U35_501.__init__(self) diff --git a/workspace_tools/toolchains/arm.py b/workspace_tools/toolchains/arm.py index 34185c6c1a..0b0f076a02 100644 --- a/workspace_tools/toolchains/arm.py +++ b/workspace_tools/toolchains/arm.py @@ -25,28 +25,28 @@ from workspace_tools.settings import GOANNA_PATH class ARM(mbedToolchain): LINKER_EXT = '.sct' LIBRARY_EXT = '.ar' - + STD_LIB_NAME = "%s.ar" DIAGNOSTIC_PATTERN = re.compile('"(?P[^"]+)", line (?P\d+): (?PWarning|Error): (?P.+)') DEP_PATTERN = re.compile('\S+:\s(?P.+)\n') - + def __init__(self, target, options=None, notify=None, macros=None): mbedToolchain.__init__(self, target, options, notify, macros) - + if target.core == "Cortex-M0+": cpu = "Cortex-M0" elif target.core == "Cortex-M4F": cpu = "Cortex-M4.fp" else: cpu = target.core - + main_cc = join(ARM_BIN, "armcc") common = ["-c", "--cpu=%s" % cpu, "--gnu", "-Otime", "--split_sections", "--apcs=interwork", "--brief_diagnostics", "--restrict" ] - + if "save-asm" in self.options: common.extend(["--asm", "--interleave"]) @@ -55,12 +55,12 @@ class ARM(mbedToolchain): common.append("-O0") else: common.append("-O3") - + common_c = [ "--md", "--no_depend_system_headers", '-I%s' % ARM_INC ] - + self.asm = [main_cc] + common + ['-I%s' % ARM_INC] if not "analyze" in self.options: self.cc = [main_cc] + common + common_c + ["--c99"] @@ -68,24 +68,24 @@ class ARM(mbedToolchain): else: self.cc = [join(GOANNA_PATH, "goannacc"), "--with-cc=" + main_cc.replace('\\', '/'), "--dialect=armcc", '--output-format="%s"' % self.GOANNA_FORMAT] + common + common_c + ["--c99"] self.cppc= [join(GOANNA_PATH, "goannac++"), "--with-cxx=" + main_cc.replace('\\', '/'), "--dialect=armcc", '--output-format="%s"' % self.GOANNA_FORMAT] + common + common_c + ["--cpp", "--no_rtti"] - + self.ld = [join(ARM_BIN, "armlink")] self.sys_libs = [] - + self.ar = join(ARM_BIN, "armar") self.elf2bin = join(ARM_BIN, "fromelf") - + def remove_option(self, option): for tool in [self.asm, self.cc, self.cppc]: if option in tool: tool.remove(option) - + def assemble(self, source, object, includes): # Preprocess first, then assemble tempfile = object + '.E.s' self.default_cmd(self.asm + ['-D%s' % s for s in self.get_symbols() + self.macros] + ["-I%s" % i for i in includes] + ["-E", "-o", tempfile, source]) self.default_cmd(self.hook.get_cmdline_assembler(self.asm + ["-o", object, tempfile])) - + def parse_dependencies(self, dep_path): dependencies = [] for line in open(dep_path).readlines(): @@ -93,7 +93,7 @@ class ARM(mbedToolchain): if match is not None: dependencies.append(match.group('file')) return dependencies - + def parse_output(self, output): for line in output.splitlines(): match = ARM.DIAGNOSTIC_PATTERN.match(line) @@ -117,7 +117,7 @@ class ARM(mbedToolchain): def archive(self, objects, lib_path): self.default_cmd([self.ar, '-r', lib_path] + objects) - + def link(self, output, objects, libraries, lib_dirs, mem_map): if len(lib_dirs): args = ["-o", output, "--userlibpath", ",".join(lib_dirs), "--info=totals", "--list=.link_totals.txt"] @@ -131,14 +131,14 @@ class ARM(mbedToolchain): args = self.target.link_cmdline_hook(self.__class__.__name__, args) self.default_cmd(self.ld + args + objects + libraries + self.sys_libs) - + @hook_tool def binary(self, resources, elf, bin): args = [self.elf2bin, '--bin', '-o', bin, elf] - + if hasattr(self.target, "binary_cmdline_hook"): args = self.target.binary_cmdline_hook(self.__class__.__name__, args) - + self.default_cmd(args) class ARM_STD(ARM): @@ -149,29 +149,29 @@ class ARM_STD(ARM): class ARM_MICRO(ARM): PATCHED_LIBRARY = False - + def __init__(self, target, options=None, notify=None, macros=None): ARM.__init__(self, target, options, notify, macros) - + # Compiler self.asm += ["-D__MICROLIB"] self.cc += ["--library_type=microlib", "-D__MICROLIB"] self.cppc += ["--library_type=microlib", "-D__MICROLIB"] - + # Linker self.ld.append("--library_type=microlib") - + # We had to patch microlib to add C++ support # In later releases this patch should have entered mainline if ARM_MICRO.PATCHED_LIBRARY: self.ld.append("--noscanlib") - + # System Libraries self.sys_libs.extend([join(MY_ARM_CLIB, lib+".l") for lib in ["mc_p", "mf_p", "m_ps"]]) - + if target.core == "Cortex-M3": self.sys_libs.extend([join(ARM_CPPLIB, lib+".l") for lib in ["cpp_ws", "cpprt_w"]]) - + elif target.core in ["Cortex-M0", "Cortex-M0+"]: self.sys_libs.extend([join(ARM_CPPLIB, lib+".l") for lib in ["cpp_ps", "cpprt_p"]]) else: diff --git a/workspace_tools/toolchains/gcc.py b/workspace_tools/toolchains/gcc.py index e8a13f7ab1..a14f1a1503 100644 --- a/workspace_tools/toolchains/gcc.py +++ b/workspace_tools/toolchains/gcc.py @@ -24,29 +24,29 @@ from workspace_tools.settings import GOANNA_PATH class GCC(mbedToolchain): LINKER_EXT = '.ld' LIBRARY_EXT = '.a' - + STD_LIB_NAME = "lib%s.a" CIRCULAR_DEPENDENCIES = True DIAGNOSTIC_PATTERN = re.compile('((?P\d+):)(\d+:)? (?Pwarning|error): (?P.+)') - + def __init__(self, target, options=None, notify=None, macros=None, tool_path=""): mbedToolchain.__init__(self, target, options, notify, macros) - + if target.core == "Cortex-M0+": cpu = "cortex-m0" elif target.core == "Cortex-M4F": cpu = "cortex-m4" else: cpu = target.core.lower() - + self.cpu = ["-mcpu=%s" % cpu] if target.core.startswith("Cortex"): self.cpu.append("-mthumb") - + if target.core == "Cortex-M4F": self.cpu.append("-mfpu=fpv4-sp-d16") self.cpu.append("-mfloat-abi=softfp") - + # Note: We are using "-O2" instead of "-Os" to avoid this known GCC bug: # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46762 common_flags = ["-c", "-Wall", "-Wextra", @@ -55,7 +55,7 @@ class GCC(mbedToolchain): "-ffunction-sections", "-fdata-sections", "-MMD", "-fno-delete-null-pointer-checks", ] + self.cpu - + if "save-asm" in self.options: common_flags.append("-save-temps") @@ -74,16 +74,16 @@ class GCC(mbedToolchain): else: self.cc = [join(GOANNA_PATH, "goannacc"), "--with-cc=" + main_cc.replace('\\', '/'), "-std=gnu99", "--dialect=gnu", '--output-format="%s"' % self.GOANNA_FORMAT] + common_flags self.cppc= [join(GOANNA_PATH, "goannac++"), "--with-cxx=" + main_cppc.replace('\\', '/'), "-std=gnu++98", "--dialect=gnu", '--output-format="%s"' % self.GOANNA_FORMAT] + common_flags - + self.ld = [join(tool_path, "arm-none-eabi-gcc"), "-Wl,--gc-sections", "-Wl,--wrap,main"] + self.cpu self.sys_libs = ["stdc++", "supc++", "m", "c", "gcc"] - + self.ar = join(tool_path, "arm-none-eabi-ar") self.elf2bin = join(tool_path, "arm-none-eabi-objcopy") - + def assemble(self, source, object, includes): self.default_cmd(self.hook.get_cmdline_assembler(self.asm + ['-D%s' % s for s in self.get_symbols() + self.macros] + ["-I%s" % i for i in includes] + ["-o", object, source])) - + def parse_dependencies(self, dep_path): dependencies = [] for line in open(dep_path).readlines()[1:]: @@ -102,7 +102,7 @@ class GCC(mbedToolchain): else: dependencies = dependencies + [f.replace('\a', ' ') for f in file.split(" ")] return dependencies - + def parse_output(self, output): # The warning/error notification is multiline WHERE, WHAT = 0, 1 @@ -119,50 +119,50 @@ class GCC(mbedToolchain): toolchain_name=self.name ) continue - + # Each line should start with the file information: "filepath: ..." # i should point past the file path ^ # avoid the first column in Windows (C:\) i = line.find(':', 2) if i == -1: continue - + if state == WHERE: file = line[:i] message = line[i+1:].strip() + ' ' state = WHAT - + elif state == WHAT: match = GCC.DIAGNOSTIC_PATTERN.match(line[i+1:]) if match is None: state = WHERE continue - + self.cc_info( match.group('severity'), file, match.group('line'), message + match.group('message') ) - + def archive(self, objects, lib_path): self.default_cmd([self.ar, "rcs", lib_path] + objects) - + def link(self, output, objects, libraries, lib_dirs, mem_map): libs = [] for l in libraries: name, _ = splitext(basename(l)) libs.append("-l%s" % name[3:]) libs.extend(["-l%s" % l for l in self.sys_libs]) - + # NOTE: There is a circular dependency between the mbed library and the clib # We could define a set of week symbols to satisfy the clib dependencies in "sys.o", # but if an application uses only clib symbols and not mbed symbols, then the final # image is not correctly retargeted if self.CIRCULAR_DEPENDENCIES: libs.extend(libs) - + self.default_cmd(self.hook.get_cmdline_linker(self.ld + ["-T%s" % mem_map, "-o", output] + objects + ["-L%s" % L for L in lib_dirs] + libs)) - + def binary(self, resources, elf, bin): self.default_cmd(self.hook.get_cmdline_binary([self.elf2bin, "-O", "binary", elf, bin])) @@ -170,25 +170,25 @@ class GCC(mbedToolchain): class GCC_ARM(GCC): def __init__(self, target, options=None, notify=None, macros=None): GCC.__init__(self, target, options, notify, macros, GCC_ARM_PATH) - + # Use latest gcc nanolib self.ld.append("--specs=nano.specs") if target.name in ["LPC1768", "LPC4088", "LPC4330", "UBLOX_C027"]: self.ld.extend(["-u", "_printf_float", "-u", "_scanf_float"]) - + self.sys_libs.append("nosys") class GCC_CR(GCC): def __init__(self, target, options=None, notify=None, macros=None): GCC.__init__(self, target, options, notify, macros, GCC_CR_PATH) - + additional_compiler_flags = [ "-D__NEWLIB__", "-D__CODE_RED", "-D__USE_CMSIS", "-DCPP_USE_HEAP", ] self.cc += additional_compiler_flags self.cppc += additional_compiler_flags - + self.ld += ["-nostdlib"] @@ -201,7 +201,7 @@ class GCC_CW(GCC): ARCH_LIB = { "Cortex-M0+": "armv6-m", } - + def __init__(self, target, options=None, notify=None, macros=None): GCC.__init__(self, target, options, notify, macros, CW_GCC_PATH) @@ -209,7 +209,7 @@ class GCC_CW(GCC): class GCC_CW_EWL(GCC_CW): def __init__(self, target, options=None, notify=None, macros=None): GCC_CW.__init__(self, target, options, notify, macros) - + # Compiler common = [ '-mfloat-abi=soft', @@ -222,7 +222,7 @@ class GCC_CW_EWL(GCC_CW): '-nostdinc++', '-I%s' % join(CW_EWL_PATH, "EWL_C++", "include"), '-include', join(CW_EWL_PATH, "EWL_C++", "include", 'lib_ewl_c++.prefix') ] - + # Linker self.sys_libs = [] self.CIRCULAR_DEPENDENCIES = False diff --git a/workspace_tools/toolchains/iar.py b/workspace_tools/toolchains/iar.py index 107aa81292..eb47bd4cec 100644 --- a/workspace_tools/toolchains/iar.py +++ b/workspace_tools/toolchains/iar.py @@ -26,12 +26,12 @@ class IAR(mbedToolchain): LIBRARY_EXT = '.a' LINKER_EXT = '.icf' STD_LIB_NAME = "%s.a" - + DIAGNOSTIC_PATTERN = re.compile('"(?P[^"]+)",(?P[\d]+)\s+(?PWarning|Error)(?P.+)') - + def __init__(self, target, options=None, notify=None, macros=None): mbedToolchain.__init__(self, target, options, notify, macros) - + c_flags = [ "--cpu=%s" % target.core, "--thumb", "--dlib_config", join(IAR_PATH, "inc", "c", "DLib_Config_Full.h"), @@ -49,7 +49,7 @@ class IAR(mbedToolchain): c_flags.append("-On") else: c_flags.append("-Oh") - + IAR_BIN = join(IAR_PATH, "bin") main_cc = join(IAR_BIN, "iccarm") self.asm = [join(IAR_BIN, "iasmarm")] + ["--cpu", target.core] @@ -62,7 +62,7 @@ class IAR(mbedToolchain): self.ld = join(IAR_BIN, "ilinkarm") self.ar = join(IAR_BIN, "iarchive") self.elf2bin = join(IAR_BIN, "ielftool") - + def parse_output(self, output): for line in output.splitlines(): match = IAR.DIAGNOSTIC_PATTERN.match(line) @@ -83,28 +83,28 @@ class IAR(mbedToolchain): match.group('line'), match.group('message') ) - + def get_dep_opt(self, dep_path): return ["--dependencies", dep_path] - + def cc_extra(self, base): return ["-l", base + '.s'] - + def parse_dependencies(self, dep_path): return [path.strip() for path in open(dep_path).readlines() if (path and not path.isspace())] - + def assemble(self, source, object, includes): self.default_cmd(self.hook.get_cmdline_assembler(self.asm + ['-D%s' % s for s in self.get_symbols() + self.macros] + ["-I%s" % i for i in includes] + ["-o", object, source])) - + def archive(self, objects, lib_path): if exists(lib_path): remove(lib_path) self.default_cmd([self.ar, lib_path] + objects) - + def link(self, output, objects, libraries, lib_dirs, mem_map): args = [self.ld, "-o", output, "--config", mem_map] self.default_cmd(self.hook.get_cmdline_linker(args + objects + libraries)) - + def binary(self, resources, elf, bin): self.default_cmd(self.hook.get_cmdline_binary([self.elf2bin, '--bin', elf, bin])) diff --git a/workspace_tools/utils.py b/workspace_tools/utils.py index 3995f0c918..b51ba337c2 100644 --- a/workspace_tools/utils.py +++ b/workspace_tools/utils.py @@ -24,9 +24,9 @@ from shutil import copyfile def cmd(l, check=True, verbose=False, shell=False, cwd=None): text = l if shell else ' '.join(l) if verbose: print text - + rc = call(l, shell=shell, cwd=cwd) - + if check and rc != 0: raise Exception('ERROR %d: "%s"' % (rc, text)) @@ -34,7 +34,7 @@ def cmd(l, check=True, verbose=False, shell=False, cwd=None): def run_cmd(command, wd=None, redirect=False): p = Popen(command, stdout=PIPE, stderr=STDOUT if redirect else PIPE, cwd=wd) stdout, stderr = p.communicate() - + return stdout, stderr, p.returncode @@ -57,7 +57,7 @@ def copy_file(src, dst): def delete_dir_files(dir): if not exists(dir): return - + for f in listdir(dir): file = join(dir, f) if not isdir(file):