aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarti Bolivar <mbolivar@leaflabs.com>2011-05-10 16:41:37 -0400
committerMarti Bolivar <mbolivar@leaflabs.com>2011-05-10 16:41:37 -0400
commit9cfd9ba5d6e2933e72dd93b048e62b9e9494fafb (patch)
treec002f6a389e38576fec44777557e62064e342d02
parent19ea6ba4ea3f1ecb9830cf4d3e1366513f4f96e3 (diff)
downloadlibrambutan-9cfd9ba5d6e2933e72dd93b048e62b9e9494fafb.tar.gz
librambutan-9cfd9ba5d6e2933e72dd93b048e62b9e9494fafb.zip
Converting all files to UNIX newlines.
Committing the results of running the following on the libmaple root directory: $ fromdos `grep --exclude-dir='[.]git' -Ilsr $'\r$' .`
-rw-r--r--examples/blinky.cpp64
-rw-r--r--examples/spi_master.cpp154
-rw-r--r--examples/test-fsmc.cpp250
-rw-r--r--libmaple/usb/usb_lib/usb_core.c2026
-rw-r--r--libmaple/usb/usb_lib/usb_core.h502
-rw-r--r--libmaple/usb/usb_lib/usb_def.h176
-rw-r--r--libmaple/usb/usb_lib/usb_init.c128
-rw-r--r--libmaple/usb/usb_lib/usb_init.h114
-rw-r--r--libmaple/usb/usb_lib/usb_int.c384
-rw-r--r--libmaple/usb/usb_lib/usb_int.h82
-rw-r--r--libmaple/usb/usb_lib/usb_lib.h74
-rw-r--r--libmaple/usb/usb_lib/usb_mem.c146
-rw-r--r--libmaple/usb/usb_lib/usb_mem.h80
-rw-r--r--libmaple/usb/usb_lib/usb_regs.c1496
-rw-r--r--libmaple/usb/usb_lib/usb_regs.h1254
-rw-r--r--libmaple/usb/usb_lib/usb_type.h154
-rw-r--r--support/ld/libcs3_stm32_src/Makefile70
-rw-r--r--support/ld/libcs3_stm32_src/start.S54
-rw-r--r--support/ld/libcs3_stm32_src/start_c.c116
-rw-r--r--support/ld/libcs3_stm32_src/stm32_isrs.S470
-rw-r--r--support/ld/libcs3_stm32_src/stm32_vector_table.S180
-rw-r--r--support/ld/maple/flash.ld56
-rw-r--r--support/ld/maple/jtag.ld56
-rw-r--r--support/ld/maple/ram.ld54
-rw-r--r--support/ld/maple_mini/flash.ld54
-rw-r--r--support/ld/maple_mini/jtag.ld56
-rw-r--r--support/ld/maple_mini/ram.ld54
-rw-r--r--support/ld/maple_native/flash.ld44
-rw-r--r--support/ld/maple_native/jtag.ld42
-rw-r--r--support/ld/maple_native/ram.ld42
-rw-r--r--support/ld/names.inc156
-rw-r--r--wirish/bits.h60
-rw-r--r--wirish/main.cxx76
33 files changed, 4362 insertions, 4362 deletions
diff --git a/examples/blinky.cpp b/examples/blinky.cpp
index 91d1a47..dd72514 100644
--- a/examples/blinky.cpp
+++ b/examples/blinky.cpp
@@ -1,32 +1,32 @@
-// Blinks the built-in LED
-
-#include "wirish.h"
-
-void setup() {
- pinMode(BOARD_LED_PIN, OUTPUT);
-}
-
-int toggle = 1;
-
-void loop() {
- // You could just use toggleLED() instead, but this illustrates
- // the use of digitalWrite():
- digitalWrite(BOARD_LED_PIN, toggle);
- toggle ^= 1;
- delay(100);
-}
-
-// Force init to be called *first*, i.e. before static object allocation.
-// Otherwise, statically allocated objects that need libmaple may fail.
-__attribute__((constructor)) void premain() {
- init();
-}
-
-int main(void) {
- setup();
-
- while (true) {
- loop();
- }
- return 0;
-}
+// Blinks the built-in LED
+
+#include "wirish.h"
+
+void setup() {
+ pinMode(BOARD_LED_PIN, OUTPUT);
+}
+
+int toggle = 1;
+
+void loop() {
+ // You could just use toggleLED() instead, but this illustrates
+ // the use of digitalWrite():
+ digitalWrite(BOARD_LED_PIN, toggle);
+ toggle ^= 1;
+ delay(100);
+}
+
+// Force init to be called *first*, i.e. before static object allocation.
+// Otherwise, statically allocated objects that need libmaple may fail.
+__attribute__((constructor)) void premain() {
+ init();
+}
+
+int main(void) {
+ setup();
+
+ while (true) {
+ loop();
+ }
+ return 0;
+}
diff --git a/examples/spi_master.cpp b/examples/spi_master.cpp
index af3e709..100fc53 100644
--- a/examples/spi_master.cpp
+++ b/examples/spi_master.cpp
@@ -1,77 +1,77 @@
-/******************************************************************************
- * The MIT License
- *
- * Copyright (c) 2010 LeafLabs LLC.
- *
- * 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 AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *****************************************************************************/
-
-/**
- * @brief Sample main.cpp file. Sends "Hello world!" out SPI1.
- *
- * SPI1 is set up to be a master transmitter at 4.5MHz, little
- * endianness, and SPI mode 0.
- *
- * Pin 10 is used as slave select.
- */
-
-#include "wirish.h"
-
-#define NSS 10
-
-byte buf[] = "Hello world!";
-
-HardwareSPI spi1(1);
-
-void setup() {
- /* Set up chip select as output */
- pinMode(NSS, OUTPUT);
-
- /* NSS is usually active LOW, so initialize it HIGH */
- digitalWrite(NSS, HIGH);
-
- /* Initialize SPI */
- spi1.begin(SPI_4_5MHZ, LSBFIRST, 0);
-}
-
-void loop() {
- /* Send message */
- digitalWrite(NSS, LOW);
- spi1.write(buf, sizeof buf);
- digitalWrite(NSS, HIGH);
- delay(1000);
-}
-
-// Force init to be called *first*, i.e. before static object allocation.
-// Otherwise, statically allocated objects that need libmaple may fail.
-__attribute__((constructor)) void premain() {
- init();
-}
-
-int main(void) {
- setup();
-
- while (true) {
- loop();
- }
- return 0;
-}
-
+/******************************************************************************
+ * The MIT License
+ *
+ * Copyright (c) 2010 LeafLabs LLC.
+ *
+ * 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 AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *****************************************************************************/
+
+/**
+ * @brief Sample main.cpp file. Sends "Hello world!" out SPI1.
+ *
+ * SPI1 is set up to be a master transmitter at 4.5MHz, little
+ * endianness, and SPI mode 0.
+ *
+ * Pin 10 is used as slave select.
+ */
+
+#include "wirish.h"
+
+#define NSS 10
+
+byte buf[] = "Hello world!";
+
+HardwareSPI spi1(1);
+
+void setup() {
+ /* Set up chip select as output */
+ pinMode(NSS, OUTPUT);
+
+ /* NSS is usually active LOW, so initialize it HIGH */
+ digitalWrite(NSS, HIGH);
+
+ /* Initialize SPI */
+ spi1.begin(SPI_4_5MHZ, LSBFIRST, 0);
+}
+
+void loop() {
+ /* Send message */
+ digitalWrite(NSS, LOW);
+ spi1.write(buf, sizeof buf);
+ digitalWrite(NSS, HIGH);
+ delay(1000);
+}
+
+// Force init to be called *first*, i.e. before static object allocation.
+// Otherwise, statically allocated objects that need libmaple may fail.
+__attribute__((constructor)) void premain() {
+ init();
+}
+
+int main(void) {
+ setup();
+
+ while (true) {
+ loop();
+ }
+ return 0;
+}
+
diff --git a/examples/test-fsmc.cpp b/examples/test-fsmc.cpp
index 7db3bb7..3aa6c6d 100644
--- a/examples/test-fsmc.cpp
+++ b/examples/test-fsmc.cpp
@@ -1,125 +1,125 @@
-#include <stddef.h> // for ptrdiff_t
-
-#include "wirish.h"
-#include "fsmc.h"
-
-#ifndef BOARD_maple_native
-#error "Sorry, this example only works on Maple Native."
-#endif
-
-// Start of FSMC SRAM bank 1
-static uint16 *const sram_start = (uint16*)0x60000000;
-// End of Maple Native SRAM chip address space (512K 16-bit words)
-static uint16 *const sram_end = (uint16*)0x60080000;
-
-void test_single_write(void);
-void test_all_addresses(void);
-
-void setup() {
- pinMode(BOARD_LED_PIN, OUTPUT);
- digitalWrite(BOARD_LED_PIN, HIGH);
-
- Serial1.begin(115200);
- Serial1.println("*** Beginning RAM chip test");
-
- test_single_write();
- test_all_addresses();
-
- Serial1.println("Tests pass, finished.");
-}
-
-void loop() {
-}
-
-void test_single_write() {
- uint16 *ptr = sram_start;
- uint16 tmp;
-
- Serial1.print("Writing 0x1234... ");
- *ptr = 0x1234;
- Serial1.println("Done.");
-
- Serial1.print("Reading... ");
- tmp = *ptr;
- Serial1.print("Done: 0x");
- Serial1.println(tmp, HEX);
-
- if (tmp != 0x1234) {
- Serial1.println("Mismatch; abort.");
- ASSERT(0);
- }
-}
-
-void test_all_addresses() {
- uint32 start, end;
- uint16 count = 0;
- uint16 *ptr;
-
- Serial1.println("Now writing all memory addresses (unrolled loop)");
- // Turn off the USB interrupt, as it interferes most with timing
- // (don't turn off SysTick, or we won't get micros()).
- SerialUSB.end();
- start = micros();
- for (ptr = sram_start; ptr < sram_end;) {
- *ptr++ = count++;
- *ptr++ = count++;
- *ptr++ = count++;
- *ptr++ = count++;
- *ptr++ = count++;
- *ptr++ = count++;
- *ptr++ = count++;
- *ptr++ = count++;
- *ptr++ = count++;
- *ptr++ = count++;
- *ptr++ = count++;
- *ptr++ = count++;
- *ptr++ = count++;
- *ptr++ = count++;
- *ptr++ = count++;
- *ptr++ = count++;
- }
- end = micros();
- SerialUSB.begin();
- Serial1.print("Done. Elapsed time (us): ");
- Serial1.println(end - start);
-
- Serial1.println("Validating writes.");
- for (ptr = sram_start, count = 0; ptr < sram_end; ptr++, count++) {
- uint16 value = *ptr;
- if (value != count) {
- Serial1.print("mismatch: 0x");
- Serial1.print((uint32)ptr);
- Serial1.print(" = 0x");
- Serial1.print(value, HEX);
- Serial1.print(", should be 0x");
- Serial1.print(count, HEX);
- Serial1.println(".");
- ASSERT(0);
- }
- }
- Serial1.println("Done; all writes seem valid.");
-
- ptrdiff_t nwrites = sram_end - sram_start;
- double us_per_write = double(end-start) / double(nwrites);
- Serial1.print("Number of writes = ");
- Serial1.print(nwrites);
- Serial1.print("; avg. time per write = ");
- Serial1.print(us_per_write);
- Serial1.print(" us (");
- Serial1.print(1 / us_per_write);
- Serial1.println(" MHz)");
-}
-
-__attribute__((constructor)) void premain() {
- init();
-}
-
-int main(void) {
- setup();
-
- while (true) {
- loop();
- }
-
- return 0;
-}
+#include <stddef.h> // for ptrdiff_t
+
+#include "wirish.h"
+#include "fsmc.h"
+
+#ifndef BOARD_maple_native
+#error "Sorry, this example only works on Maple Native."
+#endif
+
+// Start of FSMC SRAM bank 1
+static uint16 *const sram_start = (uint16*)0x60000000;
+// End of Maple Native SRAM chip address space (512K 16-bit words)
+static uint16 *const sram_end = (uint16*)0x60080000;
+
+void test_single_write(void);
+void test_all_addresses(void);
+
+void setup() {
+ pinMode(BOARD_LED_PIN, OUTPUT);
+ digitalWrite(BOARD_LED_PIN, HIGH);
+
+ Serial1.begin(115200);
+ Serial1.println("*** Beginning RAM chip test");
+
+ test_single_write();
+ test_all_addresses();
+
+ Serial1.println("Tests pass, finished.");
+}
+
+void loop() {
+}
+
+void test_single_write() {
+ uint16 *ptr = sram_start;
+ uint16 tmp;
+
+ Serial1.print("Writing 0x1234... ");
+ *ptr = 0x1234;
+ Serial1.println("Done.");
+
+ Serial1.print("Reading... ");
+ tmp = *ptr;
+ Serial1.print("Done: 0x");
+ Serial1.println(tmp, HEX);
+
+ if (tmp != 0x1234) {
+ Serial1.println("Mismatch; abort.");
+ ASSERT(0);
+ }
+}
+
+void test_all_addresses() {
+ uint32 start, end;
+ uint16 count = 0;
+ uint16 *ptr;
+
+ Serial1.println("Now writing all memory addresses (unrolled loop)");
+ // Turn off the USB interrupt, as it interferes most with timing
+ // (don't turn off SysTick, or we won't get micros()).
+ SerialUSB.end();
+ start = micros();
+ for (ptr = sram_start; ptr < sram_end;) {
+ *ptr++ = count++;
+ *ptr++ = count++;
+ *ptr++ = count++;
+ *ptr++ = count++;
+ *ptr++ = count++;
+ *ptr++ = count++;
+ *ptr++ = count++;
+ *ptr++ = count++;
+ *ptr++ = count++;
+ *ptr++ = count++;
+ *ptr++ = count++;
+ *ptr++ = count++;
+ *ptr++ = count++;
+ *ptr++ = count++;
+ *ptr++ = count++;
+ *ptr++ = count++;
+ }
+ end = micros();
+ SerialUSB.begin();
+ Serial1.print("Done. Elapsed time (us): ");
+ Serial1.println(end - start);
+
+ Serial1.println("Validating writes.");
+ for (ptr = sram_start, count = 0; ptr < sram_end; ptr++, count++) {
+ uint16 value = *ptr;
+ if (value != count) {
+ Serial1.print("mismatch: 0x");
+ Serial1.print((uint32)ptr);
+ Serial1.print(" = 0x");
+ Serial1.print(value, HEX);
+ Serial1.print(", should be 0x");
+ Serial1.print(count, HEX);
+ Serial1.println(".");
+ ASSERT(0);
+ }
+ }
+ Serial1.println("Done; all writes seem valid.");
+
+ ptrdiff_t nwrites = sram_end - sram_start;
+ double us_per_write = double(end-start) / double(nwrites);
+ Serial1.print("Number of writes = ");
+ Serial1.print(nwrites);
+ Serial1.print("; avg. time per write = ");
+ Serial1.print(us_per_write);
+ Serial1.print(" us (");
+ Serial1.print(1 / us_per_write);
+ Serial1.println(" MHz)");
+}
+
+__attribute__((constructor)) void premain() {
+ init();
+}
+
+int main(void) {
+ setup();
+
+ while (true) {
+ loop();
+ }
+
+ return 0;
+}
diff --git a/libmaple/usb/usb_lib/usb_core.c b/libmaple/usb/usb_lib/usb_core.c
index afe8798..5cf9e87 100644
--- a/libmaple/usb/usb_lib/usb_core.c
+++ b/libmaple/usb/usb_lib/usb_core.c
@@ -1,1013 +1,1013 @@
-/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
-* File Name : usb_core.c
-* Author : MCD Application Team
-* Version : V2.2.1
-* Date : 09/22/2008
-* Description : Standard protocol processing (USB v2.0)
-********************************************************************************
-* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
-* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
-* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
-* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
-* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
-* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
-*******************************************************************************/
-
-/* Includes ------------------------------------------------------------------*/
-#include "usb_lib.h"
-/* Private typedef -----------------------------------------------------------*/
-/* Private define ------------------------------------------------------------*/
-#define ValBit(VAR,Place) (VAR & (1 << Place))
-#define SetBit(VAR,Place) (VAR |= (1 << Place))
-#define ClrBit(VAR,Place) (VAR &= ((1 << Place) ^ 255))
-
-#define Send0LengthData() { _SetEPTxCount(ENDP0, 0); \
- vSetEPTxStatus(EP_TX_VALID); \
- }
-
-#define vSetEPRxStatus(st) (SaveRState = st)
-#define vSetEPTxStatus(st) (SaveTState = st)
-
-#define USB_StatusIn() Send0LengthData()
-#define USB_StatusOut() vSetEPRxStatus(EP_RX_VALID)
-
-#define StatusInfo0 StatusInfo.bw.bb1 /* Reverse bb0 & bb1 */
-#define StatusInfo1 StatusInfo.bw.bb0
-
-/* Private macro -------------------------------------------------------------*/
-/* Private variables ---------------------------------------------------------*/
-u16_u8 StatusInfo;
-USB_Bool Data_Mul_MaxPacketSize = FALSE;
-/* Private function prototypes -----------------------------------------------*/
-static void DataStageOut(void);
-static void DataStageIn(void);
-static void NoData_Setup0(void);
-static void Data_Setup0(void);
-/* Private functions ---------------------------------------------------------*/
-
-/*******************************************************************************
-* Function Name : Standard_GetConfiguration.
-* Description : Return the current configuration variable address.
-* Input : Length - How many bytes are needed.
-* Output : None.
-* Return : Return 1 , if the request is invalid when "Length" is 0.
-* Return "Buffer" if the "Length" is not 0.
-*******************************************************************************/
-u8 *Standard_GetConfiguration(u16 Length)
-{
- if (Length == 0)
- {
- pInformation->Ctrl_Info.Usb_wLength =
- sizeof(pInformation->Current_Configuration);
- return 0;
- }
- pUser_Standard_Requests->User_GetConfiguration();
- return (u8 *)&pInformation->Current_Configuration;
-}
-
-/*******************************************************************************
-* Function Name : Standard_SetConfiguration.
-* Description : This routine is called to set the configuration value
-* Then each class should configure device themself.
-* Input : None.
-* Output : None.
-* Return : Return USB_SUCCESS, if the request is performed.
-* Return USB_UNSUPPORT, if the request is invalid.
-*******************************************************************************/
-RESULT Standard_SetConfiguration(void)
-{
-
- if ((pInformation->USBwValue0 <=
- Device_Table.Total_Configuration) && (pInformation->USBwValue1 == 0)
- && (pInformation->USBwIndex == 0)) /*call Back usb spec 2.0*/
- {
- pInformation->Current_Configuration = pInformation->USBwValue0;
- pUser_Standard_Requests->User_SetConfiguration();
- return USB_SUCCESS;
- }
- else
- {
- return USB_UNSUPPORT;
- }
-}
-
-/*******************************************************************************
-* Function Name : Standard_GetInterface.
-* Description : Return the Alternate Setting of the current interface.
-* Input : Length - How many bytes are needed.
-* Output : None.
-* Return : Return 0, if the request is invalid when "Length" is 0.
-* Return "Buffer" if the "Length" is not 0.
-*******************************************************************************/
-u8 *Standard_GetInterface(u16 Length)
-{
- if (Length == 0)
- {
- pInformation->Ctrl_Info.Usb_wLength =
- sizeof(pInformation->Current_AlternateSetting);
- return 0;
- }
- pUser_Standard_Requests->User_GetInterface();
- return (u8 *)&pInformation->Current_AlternateSetting;
-}
-
-/*******************************************************************************
-* Function Name : Standard_SetInterface.
-* Description : This routine is called to set the interface.
-* Then each class should configure the interface them self.
-* Input : None.
-* Output : None.
-* Return : - Return USB_SUCCESS, if the request is performed.
-* - Return USB_UNSUPPORT, if the request is invalid.
-*******************************************************************************/
-RESULT Standard_SetInterface(void)
-{
- RESULT Re;
- /*Test if the specified Interface and Alternate Setting are supported by
- the application Firmware*/
- Re = (*pProperty->Class_Get_Interface_Setting)(pInformation->USBwIndex0, pInformation->USBwValue0);
-
- if (pInformation->Current_Configuration != 0)
- {
- if ((Re != USB_SUCCESS) || (pInformation->USBwIndex1 != 0)
- || (pInformation->USBwValue1 != 0))
- {
- return USB_UNSUPPORT;
- }
- else if (Re == USB_SUCCESS)
- {
- pUser_Standard_Requests->User_SetInterface();
- pInformation->Current_Interface = pInformation->USBwIndex0;
- pInformation->Current_AlternateSetting = pInformation->USBwValue0;
- return USB_SUCCESS;
- }
-
- }
-
- return USB_UNSUPPORT;
-}
-
-/*******************************************************************************
-* Function Name : Standard_GetStatus.
-* Description : Copy the device request data to "StatusInfo buffer".
-* Input : - Length - How many bytes are needed.
-* Output : None.
-* Return : Return 0, if the request is at end of data block,
-* or is invalid when "Length" is 0.
-*******************************************************************************/
-u8 *Standard_GetStatus(u16 Length)
-{
- if (Length == 0)
- {
- pInformation->Ctrl_Info.Usb_wLength = 2;
- return 0;
- }
-
- StatusInfo.w = 0;
- /* Reset Status Information */
-
- if (Type_Recipient == (STANDARD_REQUEST | DEVICE_RECIPIENT))
- {
- /*Get Device Status */
- u8 Feature = pInformation->Current_Feature;
-
- /* Remote Wakeup enabled */
- if (ValBit(Feature, 5))
- {
- SetBit(StatusInfo0, 1);
- }
-
- /* Bus-powered */
- if (ValBit(Feature, 6))
- {
- ClrBit(StatusInfo0, 0);
- }
- else /* Self-powered */
- {
- SetBit(StatusInfo0, 0);
- }
- }
- /*Interface Status*/
- else if (Type_Recipient == (STANDARD_REQUEST | INTERFACE_RECIPIENT))
- {
- return (u8 *)&StatusInfo;
- }
- /*Get EndPoint Status*/
- else if (Type_Recipient == (STANDARD_REQUEST | ENDPOINT_RECIPIENT))
- {
- u8 Related_Endpoint;
- u8 wIndex0 = pInformation->USBwIndex0;
-
- Related_Endpoint = (wIndex0 & 0x0f);
- if (ValBit(wIndex0, 7))
- {
- /* IN endpoint */
- if (_GetTxStallStatus(Related_Endpoint))
- {
- SetBit(StatusInfo0, 0); /* IN Endpoint stalled */
- }
- }
- else
- {
- /* OUT endpoint */
- if (_GetRxStallStatus(Related_Endpoint))
- {
- SetBit(StatusInfo0, 0); /* OUT Endpoint stalled */
- }
- }
-
- }
- else
- {
- return NULL;
- }
- pUser_Standard_Requests->User_GetStatus();
- return (u8 *)&StatusInfo;
-}
-
-/*******************************************************************************
-* Function Name : Standard_ClearFeature.
-* Description : Clear or disable a specific feature.
-* Input : None.
-* Output : None.
-* Return : - Return USB_SUCCESS, if the request is performed.
-* - Return USB_UNSUPPORT, if the request is invalid.
-*******************************************************************************/
-RESULT Standard_ClearFeature(void)
-{
- u32 Type_Rec = Type_Recipient;
- u32 Status;
-
-
- if (Type_Rec == (STANDARD_REQUEST | DEVICE_RECIPIENT))
- {/*Device Clear Feature*/
- ClrBit(pInformation->Current_Feature, 5);
- return USB_SUCCESS;
- }
- else if (Type_Rec == (STANDARD_REQUEST | ENDPOINT_RECIPIENT))
- {/*EndPoint Clear Feature*/
- DEVICE* pDev;
- u32 Related_Endpoint;
- u32 wIndex0;
- u32 rEP;
-
- if ((pInformation->USBwValue != ENDPOINT_STALL)
- || (pInformation->USBwIndex1 != 0))
- {
- return USB_UNSUPPORT;
- }
-
- pDev = &Device_Table;
- wIndex0 = pInformation->USBwIndex0;
- rEP = wIndex0 & ~0x80;
- Related_Endpoint = ENDP0 + rEP;
-
- if (ValBit(pInformation->USBwIndex0, 7))
- {
- /*Get Status of endpoint & stall the request if the related_ENdpoint
- is Disabled*/
- Status = _GetEPTxStatus(Related_Endpoint);
- }
- else
- {
- Status = _GetEPRxStatus(Related_Endpoint);
- }
-
- if ((rEP >= pDev->Total_Endpoint) || (Status == 0)
- || (pInformation->Current_Configuration == 0))
- {
- return USB_UNSUPPORT;
- }
-
-
- if (wIndex0 & 0x80)
- {
- /* IN endpoint */
- if (_GetTxStallStatus(Related_Endpoint ))
- {
- ClearDTOG_TX(Related_Endpoint);
- SetEPTxStatus(Related_Endpoint, EP_TX_VALID);
- }
- }
- else
- {
- /* OUT endpoint */
- if (_GetRxStallStatus(Related_Endpoint))
- {
- if (Related_Endpoint == ENDP0)
- {
- /* After clear the STALL, enable the default endpoint receiver */
- SetEPRxCount(Related_Endpoint, Device_Property.MaxPacketSize);
- _SetEPRxStatus(Related_Endpoint, EP_RX_VALID);
- }
- else
- {
- ClearDTOG_RX(Related_Endpoint);
- _SetEPRxStatus(Related_Endpoint, EP_RX_VALID);
- }
- }
- }
- pUser_Standard_Requests->User_ClearFeature();
- return USB_SUCCESS;
- }
-
- return USB_UNSUPPORT;
-}
-
-/*******************************************************************************
-* Function Name : Standard_SetEndPointFeature
-* Description : Set or enable a specific feature of EndPoint
-* Input : None.
-* Output : None.
-* Return : - Return USB_SUCCESS, if the request is performed.
-* - Return USB_UNSUPPORT, if the request is invalid.
-*******************************************************************************/
-RESULT Standard_SetEndPointFeature(void)
-{
- u32 wIndex0;
- u32 Related_Endpoint;
- u32 rEP;
- u32 Status;
-
- wIndex0 = pInformation->USBwIndex0;
- rEP = wIndex0 & ~0x80;
- Related_Endpoint = ENDP0 + rEP;
-
- if (ValBit(pInformation->USBwIndex0, 7))
- {
- /* get Status of endpoint & stall the request if the related_ENdpoint
- is Disabled*/
- Status = _GetEPTxStatus(Related_Endpoint);
- }
- else
- {
- Status = _GetEPRxStatus(Related_Endpoint);
- }
-
- if (Related_Endpoint >= Device_Table.Total_Endpoint
- || pInformation->USBwValue != 0 || Status == 0
- || pInformation->Current_Configuration == 0)
- {
- return USB_UNSUPPORT;
- }
- else
- {
- if (wIndex0 & 0x80)
- {
- /* IN endpoint */
- _SetEPTxStatus(Related_Endpoint, EP_TX_STALL);
- }
-
- else
- {
- /* OUT endpoint */
- _SetEPRxStatus(Related_Endpoint, EP_RX_STALL);
- }
- }
- pUser_Standard_Requests->User_SetEndPointFeature();
- return USB_SUCCESS;
-}
-
-/*******************************************************************************
-* Function Name : Standard_SetDeviceFeature.
-* Description : Set or enable a specific feature of Device.
-* Input : None.
-* Output : None.
-* Return : - Return USB_SUCCESS, if the request is performed.
-* - Return USB_UNSUPPORT, if the request is invalid.
-*******************************************************************************/
-RESULT Standard_SetDeviceFeature(void)
-{
- SetBit(pInformation->Current_Feature, 5);
- pUser_Standard_Requests->User_SetDeviceFeature();
- return USB_SUCCESS;
-}
-
-/*******************************************************************************
-* Function Name : Standard_GetDescriptorData.
-* Description : Standard_GetDescriptorData is used for descriptors transfer.
-* : This routine is used for the descriptors resident in Flash
-* or RAM
-* pDesc can be in either Flash or RAM
-* The purpose of this routine is to have a versatile way to
-* response descriptors request. It allows user to generate
-* certain descriptors with software or read descriptors from
-* external storage part by part.
-* Input : - Length - Length of the data in this transfer.
-* - pDesc - A pointer points to descriptor struct.
-* The structure gives the initial address of the descriptor and
-* its original size.
-* Output : None.
-* Return : Address of a part of the descriptor pointed by the Usb_
-* wOffset The buffer pointed by this address contains at least
-* Length bytes.
-*******************************************************************************/
-u8 *Standard_GetDescriptorData(u16 Length, ONE_DESCRIPTOR *pDesc)
-{
- u32 wOffset;
-
- wOffset = pInformation->Ctrl_Info.Usb_wOffset;
- if (Length == 0)
- {
- pInformation->Ctrl_Info.Usb_wLength = pDesc->Descriptor_Size - wOffset;
- return 0;
- }
-
- return pDesc->Descriptor + wOffset;
-}
-
-/*******************************************************************************
-* Function Name : DataStageOut.
-* Description : Data stage of a Control Write Transfer.
-* Input : None.
-* Output : None.
-* Return : None.
-*******************************************************************************/
-void DataStageOut(void)
-{
- ENDPOINT_INFO *pEPinfo = &pInformation->Ctrl_Info;
- u32 save_rLength;
-
- save_rLength = pEPinfo->Usb_rLength;
-
- if (pEPinfo->CopyData && save_rLength)
- {
- u8 *Buffer;
- u32 Length;
-
- Length = pEPinfo->PacketSize;
- if (Length > save_rLength)
- {
- Length = save_rLength;
- }
-
- Buffer = (*pEPinfo->CopyData)(Length);
- pEPinfo->Usb_rLength -= Length;
- pEPinfo->Usb_rOffset += Length;
-
- PMAToUserBufferCopy(Buffer, GetEPRxAddr(ENDP0), Length);
- }
-
- if (pEPinfo->Usb_rLength != 0)
- {
- vSetEPRxStatus(EP_RX_VALID);/* re-enable for next data reception */
- SetEPTxCount(ENDP0, 0);
- vSetEPTxStatus(EP_TX_VALID);/* Expect the host to abort the data OUT stage */
- }
- /* Set the next State*/
- if (pEPinfo->Usb_rLength >= pEPinfo->PacketSize)
- {
- pInformation->ControlState = OUT_DATA;
- }
- else
- {
- if (pEPinfo->Usb_rLength > 0)
- {
- pInformation->ControlState = LAST_OUT_DATA;
- }
- else if (pEPinfo->Usb_rLength == 0)
- {
- pInformation->ControlState = WAIT_STATUS_IN;
- USB_StatusIn();
- }
- }
-}
-
-/*******************************************************************************
-* Function Name : DataStageIn.
-* Description : Data stage of a Control Read Transfer.
-* Input : None.
-* Output : None.
-* Return : None.
-*******************************************************************************/
-void DataStageIn(void)
-{
- ENDPOINT_INFO *pEPinfo = &pInformation->Ctrl_Info;
- u32 save_wLength = pEPinfo->Usb_wLength;
- u32 ControlState = pInformation->ControlState;
-
- u8 *DataBuffer;
- u32 Length;
-
- if ((save_wLength == 0) && (ControlState == LAST_IN_DATA))
- {
- if(Data_Mul_MaxPacketSize == TRUE)
- {
- /* No more data to send and empty packet */
- Send0LengthData();
- ControlState = LAST_IN_DATA;
- Data_Mul_MaxPacketSize = FALSE;
- }
- else
- {
- /* No more data to send so STALL the TX Status*/
- ControlState = WAIT_STATUS_OUT;
- vSetEPTxStatus(EP_TX_STALL);
- }
-
- goto Expect_Status_Out;
- }
-
- Length = pEPinfo->PacketSize;
- ControlState = (save_wLength <= Length) ? LAST_IN_DATA : IN_DATA;
-
- if (Length > save_wLength)
- {
- Length = save_wLength;
- }
-
- DataBuffer = (*pEPinfo->CopyData)(Length);
-
- UserToPMABufferCopy(DataBuffer, GetEPTxAddr(ENDP0), Length);
-
- SetEPTxCount(ENDP0, Length);
-
- pEPinfo->Usb_wLength -= Length;
- pEPinfo->Usb_wOffset += Length;
- vSetEPTxStatus(EP_TX_VALID);
-
- USB_StatusOut();/* Expect the host to abort the data IN stage */
-
-Expect_Status_Out:
- pInformation->ControlState = ControlState;
-}
-
-/*******************************************************************************
-* Function Name : NoData_Setup0.
-* Description : Proceed the processing of setup request without data stage.
-* Input : None.
-* Output : None.
-* Return : None.
-*******************************************************************************/
-void NoData_Setup0(void)
-{
- RESULT Result = USB_UNSUPPORT;
- u32 RequestNo = pInformation->USBbRequest;
- u32 ControlState;
-
- if (Type_Recipient == (STANDARD_REQUEST | DEVICE_RECIPIENT))
- {
- /* Device Request*/
- /* SET_CONFIGURATION*/
- if (RequestNo == SET_CONFIGURATION)
- {
- Result = Standard_SetConfiguration();
- }
-
- /*SET ADDRESS*/
- else if (RequestNo == SET_ADDRESS)
- {
- if ((pInformation->USBwValue0 > 127) || (pInformation->USBwValue1 != 0)
- || (pInformation->USBwIndex != 0)
- || (pInformation->Current_Configuration != 0))
- /* Device Address should be 127 or less*/
- {
- ControlState = STALLED;
- goto exit_NoData_Setup0;
- }
- else
- {
- Result = USB_SUCCESS;
- }
- }
- /*SET FEATURE for Device*/
- else if (RequestNo == SET_FEATURE)
- {
- if ((pInformation->USBwValue0 == DEVICE_REMOTE_WAKEUP)
- && (pInformation->USBwIndex == 0)
- && (ValBit(pInformation->Current_Feature, 5)))
- {
- Result = Standard_SetDeviceFeature();
- }
- else
- {
- Result = USB_UNSUPPORT;
- }
- }
- /*Clear FEATURE for Device */
- else if (RequestNo == CLEAR_FEATURE)
- {
- if (pInformation->USBwValue0 == DEVICE_REMOTE_WAKEUP
- && pInformation->USBwIndex == 0
- && ValBit(pInformation->Current_Feature, 5))
- {
- Result = Standard_ClearFeature();
- }
- else
- {
- Result = USB_UNSUPPORT;
- }
- }
-
- }
-
- /* Interface Request*/
- else if (Type_Recipient == (STANDARD_REQUEST | INTERFACE_RECIPIENT))
- {
- /*SET INTERFACE*/
- if (RequestNo == SET_INTERFACE)
- {
- Result = Standard_SetInterface();
- }
- }
-
- /* EndPoint Request*/
- else if (Type_Recipient == (STANDARD_REQUEST | ENDPOINT_RECIPIENT))
- {
- /*CLEAR FEATURE for EndPoint*/
- if (RequestNo == CLEAR_FEATURE)
- {
- Result = Standard_ClearFeature();
- }
- /* SET FEATURE for EndPoint*/
- else if (RequestNo == SET_FEATURE)
- {
- Result = Standard_SetEndPointFeature();
- }
- }
- else
- {
- Result = USB_UNSUPPORT;
- }
-
-
- if (Result != USB_SUCCESS)
- {
- Result = (*pProperty->Class_NoData_Setup)(RequestNo);
- if (Result == USB_NOT_READY)
- {
- ControlState = PAUSE;
- goto exit_NoData_Setup0;
- }
- }
-
- if (Result != USB_SUCCESS)
- {
- ControlState = STALLED;
- goto exit_NoData_Setup0;
- }
-
- ControlState = WAIT_STATUS_IN;/* After no data stage SETUP */
-
- USB_StatusIn();
-
-exit_NoData_Setup0:
- pInformation->ControlState = ControlState;
- return;
-}
-
-/*******************************************************************************
-* Function Name : Data_Setup0.
-* Description : Proceed the processing of setup request with data stage.
-* Input : None.
-* Output : None.
-* Return : None.
-*******************************************************************************/
-void Data_Setup0(void)
-{
- u8 *(*CopyRoutine)(u16);
- RESULT Result;
- u32 Request_No = pInformation->USBbRequest;
-
- u32 Related_Endpoint, Reserved;
- u32 wOffset, Status;
-
-
-
- CopyRoutine = NULL;
- wOffset = 0;
-
- if (Request_No == GET_DESCRIPTOR)
- {
- if (Type_Recipient == (STANDARD_REQUEST | DEVICE_RECIPIENT))
- {
- u8 wValue1 = pInformation->USBwValue1;
- if (wValue1 == DEVICE_DESCRIPTOR)
- {
- CopyRoutine = pProperty->GetDeviceDescriptor;
- }
- else if (wValue1 == CONFIG_DESCRIPTOR)
- {
- CopyRoutine = pProperty->GetConfigDescriptor;
- }
- else if (wValue1 == STRING_DESCRIPTOR)
- {
- CopyRoutine = pProperty->GetStringDescriptor;
- } /* End of GET_DESCRIPTOR */
- }
- }
-
- /*GET STATUS*/
- else if ((Request_No == GET_STATUS) && (pInformation->USBwValue == 0)
- && (pInformation->USBwLength == 0x0002)
- && (pInformation->USBwIndex1 == 0))
- {
- /* GET STATUS for Device*/
- if ((Type_Recipient == (STANDARD_REQUEST | DEVICE_RECIPIENT))
- && (pInformation->USBwIndex == 0))
- {
- CopyRoutine = Standard_GetStatus;
- }
-
- /* GET STATUS for Interface*/
- else if (Type_Recipient == (STANDARD_REQUEST | INTERFACE_RECIPIENT))
- {
- if (((*pProperty->Class_Get_Interface_Setting)(pInformation->USBwIndex0, 0) == USB_SUCCESS)
- && (pInformation->Current_Configuration != 0))
- {
- CopyRoutine = Standard_GetStatus;
- }
- }
-
- /* GET STATUS for EndPoint*/
- else if (Type_Recipient == (STANDARD_REQUEST | ENDPOINT_RECIPIENT))
- {
- Related_Endpoint = (pInformation->USBwIndex0 & 0x0f);
- Reserved = pInformation->USBwIndex0 & 0x70;
-
- if (ValBit(pInformation->USBwIndex0, 7))
- {
- /*Get Status of endpoint & stall the request if the related_ENdpoint
- is Disabled*/
- Status = _GetEPTxStatus(Related_Endpoint);
- }
- else
- {
- Status = _GetEPRxStatus(Related_Endpoint);
- }
-
- if ((Related_Endpoint < Device_Table.Total_Endpoint) && (Reserved == 0)
- && (Status != 0))
- {
- CopyRoutine = Standard_GetStatus;
- }
- }
-
- }
-
- /*GET CONFIGURATION*/
- else if (Request_No == GET_CONFIGURATION)
- {
- if (Type_Recipient == (STANDARD_REQUEST | DEVICE_RECIPIENT))
- {
- CopyRoutine = Standard_GetConfiguration;
- }
- }
- /*GET INTERFACE*/
- else if (Request_No == GET_INTERFACE)
- {
- if ((Type_Recipient == (STANDARD_REQUEST | INTERFACE_RECIPIENT))
- && (pInformation->Current_Configuration != 0) && (pInformation->USBwValue == 0)
- && (pInformation->USBwIndex1 == 0) && (pInformation->USBwLength == 0x0001)
- && ((*pProperty->Class_Get_Interface_Setting)(pInformation->USBwIndex0, 0) == USB_SUCCESS))
- {
- CopyRoutine = Standard_GetInterface;
- }
-
- }
-
- if (CopyRoutine)
- {
- pInformation->Ctrl_Info.Usb_wOffset = wOffset;
- pInformation->Ctrl_Info.CopyData = CopyRoutine;
- /* sb in the original the cast to word was directly */
- /* now the cast is made step by step */
- (*CopyRoutine)(0);
- Result = USB_SUCCESS;
- }
- else
- {
- Result = (*pProperty->Class_Data_Setup)(pInformation->USBbRequest);
- if (Result == USB_NOT_READY)
- {
- pInformation->ControlState = PAUSE;
- return;
- }
- }
-
- if (pInformation->Ctrl_Info.Usb_wLength == 0xFFFF)
- {
- /* Data is not ready, wait it */
- pInformation->ControlState = PAUSE;
- return;
- }
- if ((Result == USB_UNSUPPORT) || (pInformation->Ctrl_Info.Usb_wLength == 0))
- {
- /* Unsupported request */
- pInformation->ControlState = STALLED;
- return;
- }
-
-
- if (ValBit(pInformation->USBbmRequestType, 7))
- {
- /* Device ==> Host */
- vu32 wLength = pInformation->USBwLength;
-
- /* Restrict the data length to be the one host asks */
- if (pInformation->Ctrl_Info.Usb_wLength > wLength)
- {
- pInformation->Ctrl_Info.Usb_wLength = wLength;
- }
-
- else if (pInformation->Ctrl_Info.Usb_wLength < pInformation->USBwLength)
- {
- if (pInformation->Ctrl_Info.Usb_wLength < pProperty->MaxPacketSize)
- {
- Data_Mul_MaxPacketSize = FALSE;
- }
- else if ((pInformation->Ctrl_Info.Usb_wLength % pProperty->MaxPacketSize) == 0)
- {
- Data_Mul_MaxPacketSize = TRUE;
- }
- }
-
- pInformation->Ctrl_Info.PacketSize = pProperty->MaxPacketSize;
- DataStageIn();
- }
- else
- {
- pInformation->ControlState = OUT_DATA;
- vSetEPRxStatus(EP_RX_VALID); /* enable for next data reception */
- }
-
- return;
-}
-
-/*******************************************************************************
-* Function Name : Setup0_Process
-* Description : Get the device request data and dispatch to individual process.
-* Input : None.
-* Output : None.
-* Return : Post0_Process.
-*******************************************************************************/
-u8 Setup0_Process(void)
-{
-
- union
- {
- u8* b;
- u16* w;
- } pBuf;
-
- pBuf.b = PMAAddr + (u8 *)(_GetEPRxAddr(ENDP0) * 2); /* *2 for 32 bits addr */
-
- if (pInformation->ControlState != PAUSE)
- {
- pInformation->USBbmRequestType = *pBuf.b++; /* bmRequestType */
- pInformation->USBbRequest = *pBuf.b++; /* bRequest */
- pBuf.w++; /* word not accessed because of 32 bits addressing */
- pInformation->USBwValue = ByteSwap(*pBuf.w++); /* wValue */
- pBuf.w++; /* word not accessed because of 32 bits addressing */
- pInformation->USBwIndex = ByteSwap(*pBuf.w++); /* wIndex */
- pBuf.w++; /* word not accessed because of 32 bits addressing */
- pInformation->USBwLength = *pBuf.w; /* wLength */
- }
-
- pInformation->ControlState = SETTING_UP;
- if (pInformation->USBwLength == 0)
- {
- /* Setup with no data stage */
- NoData_Setup0();
- }
- else
- {
- /* Setup with data stage */
- Data_Setup0();
- }
- return Post0_Process();
-}
-
-/*******************************************************************************
-* Function Name : In0_Process
-* Description : Process the IN token on all default endpoint.
-* Input : None.
-* Output : None.
-* Return : Post0_Process.
-*******************************************************************************/
-u8 In0_Process(void)
-{
- u32 ControlState = pInformation->ControlState;
-
- if ((ControlState == IN_DATA) || (ControlState == LAST_IN_DATA))
- {
- DataStageIn();
- /* ControlState may be changed outside the function */
- ControlState = pInformation->ControlState;
- }
-
- else if (ControlState == WAIT_STATUS_IN)
- {
- if ((pInformation->USBbRequest == SET_ADDRESS) &&
- (Type_Recipient == (STANDARD_REQUEST | DEVICE_RECIPIENT)))
- {
- SetDeviceAddress(pInformation->USBwValue0);
- pUser_Standard_Requests->User_SetDeviceAddress();
- }
- (*pProperty->Process_Status_IN)();
- ControlState = STALLED;
- }
-
- else
- {
- ControlState = STALLED;
- }
-
- pInformation->ControlState = ControlState;
-
- return Post0_Process();
-}
-
-/*******************************************************************************
-* Function Name : Out0_Process
-* Description : Process the OUT token on all default endpoint.
-* Input : None.
-* Output : None.
-* Return : Post0_Process.
-*******************************************************************************/
-u8 Out0_Process(void)
-{
- u32 ControlState = pInformation->ControlState;
-
- if ((ControlState == OUT_DATA) || (ControlState == LAST_OUT_DATA))
- {
- DataStageOut();
- ControlState = pInformation->ControlState; /* may be changed outside the function */
- }
-
- else if (ControlState == WAIT_STATUS_OUT)
- {
- (*pProperty->Process_Status_OUT)();
- ControlState = STALLED;
- }
-
- else if ((ControlState == IN_DATA) || (ControlState == LAST_IN_DATA))
- {
- /* host aborts the transfer before finish */
- ControlState = STALLED;
- }
-
- /* Unexpect state, STALL the endpoint */
- else
- {
- ControlState = STALLED;
- }
-
- pInformation->ControlState = ControlState;
-
- return Post0_Process();
-}
-
-/*******************************************************************************
-* Function Name : Post0_Process
-* Description : Stall the Endpoint 0 in case of error.
-* Input : None.
-* Output : None.
-* Return : - 0 if the control State is in PAUSE
-* - 1 if not.
-*******************************************************************************/
-u8 Post0_Process(void)
-{
- SetEPRxCount(ENDP0, Device_Property.MaxPacketSize);
-
- if (pInformation->ControlState == STALLED)
- {
- vSetEPRxStatus(EP_RX_STALL);
- vSetEPTxStatus(EP_TX_STALL);
- }
-
- return (pInformation->ControlState == PAUSE);
-}
-
-/*******************************************************************************
-* Function Name : SetDeviceAddress.
-* Description : Set the device and all the used Endpoints addresses.
-* Input : - Val: device adress.
-* Output : None.
-* Return : None.
-*******************************************************************************/
-void SetDeviceAddress(u8 Val)
-{
- u32 i;
- u32 nEP = Device_Table.Total_Endpoint;
-
- /* set address in every used endpoint */
- for (i = 0; i < nEP; i++)
- {
- _SetEPAddress((u8)i, (u8)i);
- } /* for */
- _SetDADDR(Val | DADDR_EF); /* set device address and enable function */
-}
-
-/*******************************************************************************
-* Function Name : NOP_Process
-* Description : No operation function.
-* Input : None.
-* Output : None.
-* Return : None.
-*******************************************************************************/
-void NOP_Process(void)
-{
-}
-
-/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
+/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
+* File Name : usb_core.c
+* Author : MCD Application Team
+* Version : V2.2.1
+* Date : 09/22/2008
+* Description : Standard protocol processing (USB v2.0)
+********************************************************************************
+* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
+* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
+* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
+* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
+* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+*******************************************************************************/
+
+/* Includes ------------------------------------------------------------------*/
+#include "usb_lib.h"
+/* Private typedef -----------------------------------------------------------*/
+/* Private define ------------------------------------------------------------*/
+#define ValBit(VAR,Place) (VAR & (1 << Place))
+#define SetBit(VAR,Place) (VAR |= (1 << Place))
+#define ClrBit(VAR,Place) (VAR &= ((1 << Place) ^ 255))
+
+#define Send0LengthData() { _SetEPTxCount(ENDP0, 0); \
+ vSetEPTxStatus(EP_TX_VALID); \
+ }
+
+#define vSetEPRxStatus(st) (SaveRState = st)
+#define vSetEPTxStatus(st) (SaveTState = st)
+
+#define USB_StatusIn() Send0LengthData()
+#define USB_StatusOut() vSetEPRxStatus(EP_RX_VALID)
+
+#define StatusInfo0 StatusInfo.bw.bb1 /* Reverse bb0 & bb1 */
+#define StatusInfo1 StatusInfo.bw.bb0
+
+/* Private macro -------------------------------------------------------------*/
+/* Private variables ---------------------------------------------------------*/
+u16_u8 StatusInfo;
+USB_Bool Data_Mul_MaxPacketSize = FALSE;
+/* Private function prototypes -----------------------------------------------*/
+static void DataStageOut(void);
+static void DataStageIn(void);
+static void NoData_Setup0(void);
+static void Data_Setup0(void);
+/* Private functions ---------------------------------------------------------*/
+
+/*******************************************************************************
+* Function Name : Standard_GetConfiguration.
+* Description : Return the current configuration variable address.
+* Input : Length - How many bytes are needed.
+* Output : None.
+* Return : Return 1 , if the request is invalid when "Length" is 0.
+* Return "Buffer" if the "Length" is not 0.
+*******************************************************************************/
+u8 *Standard_GetConfiguration(u16 Length)
+{
+ if (Length == 0)
+ {
+ pInformation->Ctrl_Info.Usb_wLength =
+ sizeof(pInformation->Current_Configuration);
+ return 0;
+ }
+ pUser_Standard_Requests->User_GetConfiguration();
+ return (u8 *)&pInformation->Current_Configuration;
+}
+
+/*******************************************************************************
+* Function Name : Standard_SetConfiguration.
+* Description : This routine is called to set the configuration value
+* Then each class should configure device themself.
+* Input : None.
+* Output : None.
+* Return : Return USB_SUCCESS, if the request is performed.
+* Return USB_UNSUPPORT, if the request is invalid.
+*******************************************************************************/
+RESULT Standard_SetConfiguration(void)
+{
+
+ if ((pInformation->USBwValue0 <=
+ Device_Table.Total_Configuration) && (pInformation->USBwValue1 == 0)
+ && (pInformation->USBwIndex == 0)) /*call Back usb spec 2.0*/
+ {
+ pInformation->Current_Configuration = pInformation->USBwValue0;
+ pUser_Standard_Requests->User_SetConfiguration();
+ return USB_SUCCESS;
+ }
+ else
+ {
+ return USB_UNSUPPORT;
+ }
+}
+
+/*******************************************************************************
+* Function Name : Standard_GetInterface.
+* Description : Return the Alternate Setting of the current interface.
+* Input : Length - How many bytes are needed.
+* Output : None.
+* Return : Return 0, if the request is invalid when "Length" is 0.
+* Return "Buffer" if the "Length" is not 0.
+*******************************************************************************/
+u8 *Standard_GetInterface(u16 Length)
+{
+ if (Length == 0)
+ {
+ pInformation->Ctrl_Info.Usb_wLength =
+ sizeof(pInformation->Current_AlternateSetting);
+ return 0;
+ }
+ pUser_Standard_Requests->User_GetInterface();
+ return (u8 *)&pInformation->Current_AlternateSetting;
+}
+
+/*******************************************************************************
+* Function Name : Standard_SetInterface.
+* Description : This routine is called to set the interface.
+* Then each class should configure the interface them self.
+* Input : None.
+* Output : None.
+* Return : - Return USB_SUCCESS, if the request is performed.
+* - Return USB_UNSUPPORT, if the request is invalid.
+*******************************************************************************/
+RESULT Standard_SetInterface(void)
+{
+ RESULT Re;
+ /*Test if the specified Interface and Alternate Setting are supported by
+ the application Firmware*/
+ Re = (*pProperty->Class_Get_Interface_Setting)(pInformation->USBwIndex0, pInformation->USBwValue0);
+
+ if (pInformation->Current_Configuration != 0)
+ {
+ if ((Re != USB_SUCCESS) || (pInformation->USBwIndex1 != 0)
+ || (pInformation->USBwValue1 != 0))
+ {
+ return USB_UNSUPPORT;
+ }
+ else if (Re == USB_SUCCESS)
+ {
+ pUser_Standard_Requests->User_SetInterface();
+ pInformation->Current_Interface = pInformation->USBwIndex0;
+ pInformation->Current_AlternateSetting = pInformation->USBwValue0;
+ return USB_SUCCESS;
+ }
+
+ }
+
+ return USB_UNSUPPORT;
+}
+
+/*******************************************************************************
+* Function Name : Standard_GetStatus.
+* Description : Copy the device request data to "StatusInfo buffer".
+* Input : - Length - How many bytes are needed.
+* Output : None.
+* Return : Return 0, if the request is at end of data block,
+* or is invalid when "Length" is 0.
+*******************************************************************************/
+u8 *Standard_GetStatus(u16 Length)
+{
+ if (Length == 0)
+ {
+ pInformation->Ctrl_Info.Usb_wLength = 2;
+ return 0;
+ }
+
+ StatusInfo.w = 0;
+ /* Reset Status Information */
+
+ if (Type_Recipient == (STANDARD_REQUEST | DEVICE_RECIPIENT))
+ {
+ /*Get Device Status */
+ u8 Feature = pInformation->Current_Feature;
+
+ /* Remote Wakeup enabled */
+ if (ValBit(Feature, 5))
+ {
+ SetBit(StatusInfo0, 1);
+ }
+
+ /* Bus-powered */
+ if (ValBit(Feature, 6))
+ {
+ ClrBit(StatusInfo0, 0);
+ }
+ else /* Self-powered */
+ {
+ SetBit(StatusInfo0, 0);
+ }
+ }
+ /*Interface Status*/
+ else if (Type_Recipient == (STANDARD_REQUEST | INTERFACE_RECIPIENT))
+ {
+ return (u8 *)&StatusInfo;
+ }
+ /*Get EndPoint Status*/
+ else if (Type_Recipient == (STANDARD_REQUEST | ENDPOINT_RECIPIENT))
+ {
+ u8 Related_Endpoint;
+ u8 wIndex0 = pInformation->USBwIndex0;
+
+ Related_Endpoint = (wIndex0 & 0x0f);
+ if (ValBit(wIndex0, 7))
+ {
+ /* IN endpoint */
+ if (_GetTxStallStatus(Related_Endpoint))
+ {
+ SetBit(StatusInfo0, 0); /* IN Endpoint stalled */
+ }
+ }
+ else
+ {
+ /* OUT endpoint */
+ if (_GetRxStallStatus(Related_Endpoint))
+ {
+ SetBit(StatusInfo0, 0); /* OUT Endpoint stalled */
+ }
+ }
+
+ }
+ else
+ {
+ return NULL;
+ }
+ pUser_Standard_Requests->User_GetStatus();
+ return (u8 *)&StatusInfo;
+}
+
+/*******************************************************************************
+* Function Name : Standard_ClearFeature.
+* Description : Clear or disable a specific feature.
+* Input : None.
+* Output : None.
+* Return : - Return USB_SUCCESS, if the request is performed.
+* - Return USB_UNSUPPORT, if the request is invalid.
+*******************************************************************************/
+RESULT Standard_ClearFeature(void)
+{
+ u32 Type_Rec = Type_Recipient;
+ u32 Status;
+
+
+ if (Type_Rec == (STANDARD_REQUEST | DEVICE_RECIPIENT))
+ {/*Device Clear Feature*/
+ ClrBit(pInformation->Current_Feature, 5);
+ return USB_SUCCESS;
+ }
+ else if (Type_Rec == (STANDARD_REQUEST | ENDPOINT_RECIPIENT))
+ {/*EndPoint Clear Feature*/
+ DEVICE* pDev;
+ u32 Related_Endpoint;
+ u32 wIndex0;
+ u32 rEP;
+
+ if ((pInformation->USBwValue != ENDPOINT_STALL)
+ || (pInformation->USBwIndex1 != 0))
+ {
+ return USB_UNSUPPORT;
+ }
+
+ pDev = &Device_Table;
+ wIndex0 = pInformation->USBwIndex0;
+ rEP = wIndex0 & ~0x80;
+ Related_Endpoint = ENDP0 + rEP;
+
+ if (ValBit(pInformation->USBwIndex0, 7))
+ {
+ /*Get Status of endpoint & stall the request if the related_ENdpoint
+ is Disabled*/
+ Status = _GetEPTxStatus(Related_Endpoint);
+ }
+ else
+ {
+ Status = _GetEPRxStatus(Related_Endpoint);
+ }
+
+ if ((rEP >= pDev->Total_Endpoint) || (Status == 0)
+ || (pInformation->Current_Configuration == 0))
+ {
+ return USB_UNSUPPORT;
+ }
+
+
+ if (wIndex0 & 0x80)
+ {
+ /* IN endpoint */
+ if (_GetTxStallStatus(Related_Endpoint ))
+ {
+ ClearDTOG_TX(Related_Endpoint);
+ SetEPTxStatus(Related_Endpoint, EP_TX_VALID);
+ }
+ }
+ else
+ {
+ /* OUT endpoint */
+ if (_GetRxStallStatus(Related_Endpoint))
+ {
+ if (Related_Endpoint == ENDP0)
+ {
+ /* After clear the STALL, enable the default endpoint receiver */
+ SetEPRxCount(Related_Endpoint, Device_Property.MaxPacketSize);
+ _SetEPRxStatus(Related_Endpoint, EP_RX_VALID);
+ }
+ else
+ {
+ ClearDTOG_RX(Related_Endpoint);
+ _SetEPRxStatus(Related_Endpoint, EP_RX_VALID);
+ }
+ }
+ }
+ pUser_Standard_Requests->User_ClearFeature();
+ return USB_SUCCESS;
+ }
+
+ return USB_UNSUPPORT;
+}
+
+/*******************************************************************************
+* Function Name : Standard_SetEndPointFeature
+* Description : Set or enable a specific feature of EndPoint
+* Input : None.
+* Output : None.
+* Return : - Return USB_SUCCESS, if the request is performed.
+* - Return USB_UNSUPPORT, if the request is invalid.
+*******************************************************************************/
+RESULT Standard_SetEndPointFeature(void)
+{
+ u32 wIndex0;
+ u32 Related_Endpoint;
+ u32 rEP;
+ u32 Status;
+
+ wIndex0 = pInformation->USBwIndex0;
+ rEP = wIndex0 & ~0x80;
+ Related_Endpoint = ENDP0 + rEP;
+
+ if (ValBit(pInformation->USBwIndex0, 7))
+ {
+ /* get Status of endpoint & stall the request if the related_ENdpoint
+ is Disabled*/
+ Status = _GetEPTxStatus(Related_Endpoint);
+ }
+ else
+ {
+ Status = _GetEPRxStatus(Related_Endpoint);
+ }
+
+ if (Related_Endpoint >= Device_Table.Total_Endpoint
+ || pInformation->USBwValue != 0 || Status == 0
+ || pInformation->Current_Configuration == 0)
+ {
+ return USB_UNSUPPORT;
+ }
+ else
+ {
+ if (wIndex0 & 0x80)
+ {
+ /* IN endpoint */
+ _SetEPTxStatus(Related_Endpoint, EP_TX_STALL);
+ }
+
+ else
+ {
+ /* OUT endpoint */
+ _SetEPRxStatus(Related_Endpoint, EP_RX_STALL);
+ }
+ }
+ pUser_Standard_Requests->User_SetEndPointFeature();
+ return USB_SUCCESS;
+}
+
+/*******************************************************************************
+* Function Name : Standard_SetDeviceFeature.
+* Description : Set or enable a specific feature of Device.
+* Input : None.
+* Output : None.
+* Return : - Return USB_SUCCESS, if the request is performed.
+* - Return USB_UNSUPPORT, if the request is invalid.
+*******************************************************************************/
+RESULT Standard_SetDeviceFeature(void)
+{
+ SetBit(pInformation->Current_Feature, 5);
+ pUser_Standard_Requests->User_SetDeviceFeature();
+ return USB_SUCCESS;
+}
+
+/*******************************************************************************
+* Function Name : Standard_GetDescriptorData.
+* Description : Standard_GetDescriptorData is used for descriptors transfer.
+* : This routine is used for the descriptors resident in Flash
+* or RAM
+* pDesc can be in either Flash or RAM
+* The purpose of this routine is to have a versatile way to
+* response descriptors request. It allows user to generate
+* certain descriptors with software or read descriptors from
+* external storage part by part.
+* Input : - Length - Length of the data in this transfer.
+* - pDesc - A pointer points to descriptor struct.
+* The structure gives the initial address of the descriptor and
+* its original size.
+* Output : None.
+* Return : Address of a part of the descriptor pointed by the Usb_
+* wOffset The buffer pointed by this address contains at least
+* Length bytes.
+*******************************************************************************/
+u8 *Standard_GetDescriptorData(u16 Length, ONE_DESCRIPTOR *pDesc)
+{
+ u32 wOffset;
+
+ wOffset = pInformation->Ctrl_Info.Usb_wOffset;
+ if (Length == 0)
+ {
+ pInformation->Ctrl_Info.Usb_wLength = pDesc->Descriptor_Size - wOffset;
+ return 0;
+ }
+
+ return pDesc->Descriptor + wOffset;
+}
+
+/*******************************************************************************
+* Function Name : DataStageOut.
+* Description : Data stage of a Control Write Transfer.
+* Input : None.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+void DataStageOut(void)
+{
+ ENDPOINT_INFO *pEPinfo = &pInformation->Ctrl_Info;
+ u32 save_rLength;
+
+ save_rLength = pEPinfo->Usb_rLength;
+
+ if (pEPinfo->CopyData && save_rLength)
+ {
+ u8 *Buffer;
+ u32 Length;
+
+ Length = pEPinfo->PacketSize;
+ if (Length > save_rLength)
+ {
+ Length = save_rLength;
+ }
+
+ Buffer = (*pEPinfo->CopyData)(Length);
+ pEPinfo->Usb_rLength -= Length;
+ pEPinfo->Usb_rOffset += Length;
+
+ PMAToUserBufferCopy(Buffer, GetEPRxAddr(ENDP0), Length);
+ }
+
+ if (pEPinfo->Usb_rLength != 0)
+ {
+ vSetEPRxStatus(EP_RX_VALID);/* re-enable for next data reception */
+ SetEPTxCount(ENDP0, 0);
+ vSetEPTxStatus(EP_TX_VALID);/* Expect the host to abort the data OUT stage */
+ }
+ /* Set the next State*/
+ if (pEPinfo->Usb_rLength >= pEPinfo->PacketSize)
+ {
+ pInformation->ControlState = OUT_DATA;
+ }
+ else
+ {
+ if (pEPinfo->Usb_rLength > 0)
+ {
+ pInformation->ControlState = LAST_OUT_DATA;
+ }
+ else if (pEPinfo->Usb_rLength == 0)
+ {
+ pInformation->ControlState = WAIT_STATUS_IN;
+ USB_StatusIn();
+ }
+ }
+}
+
+/*******************************************************************************
+* Function Name : DataStageIn.
+* Description : Data stage of a Control Read Transfer.
+* Input : None.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+void DataStageIn(void)
+{
+ ENDPOINT_INFO *pEPinfo = &pInformation->Ctrl_Info;
+ u32 save_wLength = pEPinfo->Usb_wLength;
+ u32 ControlState = pInformation->ControlState;
+
+ u8 *DataBuffer;
+ u32 Length;
+
+ if ((save_wLength == 0) && (ControlState == LAST_IN_DATA))
+ {
+ if(Data_Mul_MaxPacketSize == TRUE)
+ {
+ /* No more data to send and empty packet */
+ Send0LengthData();
+ ControlState = LAST_IN_DATA;
+ Data_Mul_MaxPacketSize = FALSE;
+ }
+ else
+ {
+ /* No more data to send so STALL the TX Status*/
+ ControlState = WAIT_STATUS_OUT;
+ vSetEPTxStatus(EP_TX_STALL);
+ }
+
+ goto Expect_Status_Out;
+ }
+
+ Length = pEPinfo->PacketSize;
+ ControlState = (save_wLength <= Length) ? LAST_IN_DATA : IN_DATA;
+
+ if (Length > save_wLength)
+ {
+ Length = save_wLength;
+ }
+
+ DataBuffer = (*pEPinfo->CopyData)(Length);
+
+ UserToPMABufferCopy(DataBuffer, GetEPTxAddr(ENDP0), Length);
+
+ SetEPTxCount(ENDP0, Length);
+
+ pEPinfo->Usb_wLength -= Length;
+ pEPinfo->Usb_wOffset += Length;
+ vSetEPTxStatus(EP_TX_VALID);
+
+ USB_StatusOut();/* Expect the host to abort the data IN stage */
+
+Expect_Status_Out:
+ pInformation->ControlState = ControlState;
+}
+
+/*******************************************************************************
+* Function Name : NoData_Setup0.
+* Description : Proceed the processing of setup request without data stage.
+* Input : None.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+void NoData_Setup0(void)
+{
+ RESULT Result = USB_UNSUPPORT;
+ u32 RequestNo = pInformation->USBbRequest;
+ u32 ControlState;
+
+ if (Type_Recipient == (STANDARD_REQUEST | DEVICE_RECIPIENT))
+ {
+ /* Device Request*/
+ /* SET_CONFIGURATION*/
+ if (RequestNo == SET_CONFIGURATION)
+ {
+ Result = Standard_SetConfiguration();
+ }
+
+ /*SET ADDRESS*/
+ else if (RequestNo == SET_ADDRESS)
+ {
+ if ((pInformation->USBwValue0 > 127) || (pInformation->USBwValue1 != 0)
+ || (pInformation->USBwIndex != 0)
+ || (pInformation->Current_Configuration != 0))
+ /* Device Address should be 127 or less*/
+ {
+ ControlState = STALLED;
+ goto exit_NoData_Setup0;
+ }
+ else
+ {
+ Result = USB_SUCCESS;
+ }
+ }
+ /*SET FEATURE for Device*/
+ else if (RequestNo == SET_FEATURE)
+ {
+ if ((pInformation->USBwValue0 == DEVICE_REMOTE_WAKEUP)
+ && (pInformation->USBwIndex == 0)
+ && (ValBit(pInformation->Current_Feature, 5)))
+ {
+ Result = Standard_SetDeviceFeature();
+ }
+ else
+ {
+ Result = USB_UNSUPPORT;
+ }
+ }
+ /*Clear FEATURE for Device */
+ else if (RequestNo == CLEAR_FEATURE)
+ {
+ if (pInformation->USBwValue0 == DEVICE_REMOTE_WAKEUP
+ && pInformation->USBwIndex == 0
+ && ValBit(pInformation->Current_Feature, 5))
+ {
+ Result = Standard_ClearFeature();
+ }
+ else
+ {
+ Result = USB_UNSUPPORT;
+ }
+ }
+
+ }
+
+ /* Interface Request*/
+ else if (Type_Recipient == (STANDARD_REQUEST | INTERFACE_RECIPIENT))
+ {
+ /*SET INTERFACE*/
+ if (RequestNo == SET_INTERFACE)
+ {
+ Result = Standard_SetInterface();
+ }
+ }
+
+ /* EndPoint Request*/
+ else if (Type_Recipient == (STANDARD_REQUEST | ENDPOINT_RECIPIENT))
+ {
+ /*CLEAR FEATURE for EndPoint*/
+ if (RequestNo == CLEAR_FEATURE)
+ {
+ Result = Standard_ClearFeature();
+ }
+ /* SET FEATURE for EndPoint*/
+ else if (RequestNo == SET_FEATURE)
+ {
+ Result = Standard_SetEndPointFeature();
+ }
+ }
+ else
+ {
+ Result = USB_UNSUPPORT;
+ }
+
+
+ if (Result != USB_SUCCESS)
+ {
+ Result = (*pProperty->Class_NoData_Setup)(RequestNo);
+ if (Result == USB_NOT_READY)
+ {
+ ControlState = PAUSE;
+ goto exit_NoData_Setup0;
+ }
+ }
+
+ if (Result != USB_SUCCESS)
+ {
+ ControlState = STALLED;
+ goto exit_NoData_Setup0;
+ }
+
+ ControlState = WAIT_STATUS_IN;/* After no data stage SETUP */
+
+ USB_StatusIn();
+
+exit_NoData_Setup0:
+ pInformation->ControlState = ControlState;
+ return;
+}
+
+/*******************************************************************************
+* Function Name : Data_Setup0.
+* Description : Proceed the processing of setup request with data stage.
+* Input : None.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+void Data_Setup0(void)
+{
+ u8 *(*CopyRoutine)(u16);
+ RESULT Result;
+ u32 Request_No = pInformation->USBbRequest;
+
+ u32 Related_Endpoint, Reserved;
+ u32 wOffset, Status;
+
+
+
+ CopyRoutine = NULL;
+ wOffset = 0;
+
+ if (Request_No == GET_DESCRIPTOR)
+ {
+ if (Type_Recipient == (STANDARD_REQUEST | DEVICE_RECIPIENT))
+ {
+ u8 wValue1 = pInformation->USBwValue1;
+ if (wValue1 == DEVICE_DESCRIPTOR)
+ {
+ CopyRoutine = pProperty->GetDeviceDescriptor;
+ }
+ else if (wValue1 == CONFIG_DESCRIPTOR)
+ {
+ CopyRoutine = pProperty->GetConfigDescriptor;
+ }
+ else if (wValue1 == STRING_DESCRIPTOR)
+ {
+ CopyRoutine = pProperty->GetStringDescriptor;
+ } /* End of GET_DESCRIPTOR */
+ }
+ }
+
+ /*GET STATUS*/
+ else if ((Request_No == GET_STATUS) && (pInformation->USBwValue == 0)
+ && (pInformation->USBwLength == 0x0002)
+ && (pInformation->USBwIndex1 == 0))
+ {
+ /* GET STATUS for Device*/
+ if ((Type_Recipient == (STANDARD_REQUEST | DEVICE_RECIPIENT))
+ && (pInformation->USBwIndex == 0))
+ {
+ CopyRoutine = Standard_GetStatus;
+ }
+
+ /* GET STATUS for Interface*/
+ else if (Type_Recipient == (STANDARD_REQUEST | INTERFACE_RECIPIENT))
+ {
+ if (((*pProperty->Class_Get_Interface_Setting)(pInformation->USBwIndex0, 0) == USB_SUCCESS)
+ && (pInformation->Current_Configuration != 0))
+ {
+ CopyRoutine = Standard_GetStatus;
+ }
+ }
+
+ /* GET STATUS for EndPoint*/
+ else if (Type_Recipient == (STANDARD_REQUEST | ENDPOINT_RECIPIENT))
+ {
+ Related_Endpoint = (pInformation->USBwIndex0 & 0x0f);
+ Reserved = pInformation->USBwIndex0 & 0x70;
+
+ if (ValBit(pInformation->USBwIndex0, 7))
+ {
+ /*Get Status of endpoint & stall the request if the related_ENdpoint
+ is Disabled*/
+ Status = _GetEPTxStatus(Related_Endpoint);
+ }
+ else
+ {
+ Status = _GetEPRxStatus(Related_Endpoint);
+ }
+
+ if ((Related_Endpoint < Device_Table.Total_Endpoint) && (Reserved == 0)
+ && (Status != 0))
+ {
+ CopyRoutine = Standard_GetStatus;
+ }
+ }
+
+ }
+
+ /*GET CONFIGURATION*/
+ else if (Request_No == GET_CONFIGURATION)
+ {
+ if (Type_Recipient == (STANDARD_REQUEST | DEVICE_RECIPIENT))
+ {
+ CopyRoutine = Standard_GetConfiguration;
+ }
+ }
+ /*GET INTERFACE*/
+ else if (Request_No == GET_INTERFACE)
+ {
+ if ((Type_Recipient == (STANDARD_REQUEST | INTERFACE_RECIPIENT))
+ && (pInformation->Current_Configuration != 0) && (pInformation->USBwValue == 0)
+ && (pInformation->USBwIndex1 == 0) && (pInformation->USBwLength == 0x0001)
+ && ((*pProperty->Class_Get_Interface_Setting)(pInformation->USBwIndex0, 0) == USB_SUCCESS))
+ {
+ CopyRoutine = Standard_GetInterface;
+ }
+
+ }
+
+ if (CopyRoutine)
+ {
+ pInformation->Ctrl_Info.Usb_wOffset = wOffset;
+ pInformation->Ctrl_Info.CopyData = CopyRoutine;
+ /* sb in the original the cast to word was directly */
+ /* now the cast is made step by step */
+ (*CopyRoutine)(0);
+ Result = USB_SUCCESS;
+ }
+ else
+ {
+ Result = (*pProperty->Class_Data_Setup)(pInformation->USBbRequest);
+ if (Result == USB_NOT_READY)
+ {
+ pInformation->ControlState = PAUSE;
+ return;
+ }
+ }
+
+ if (pInformation->Ctrl_Info.Usb_wLength == 0xFFFF)
+ {
+ /* Data is not ready, wait it */
+ pInformation->ControlState = PAUSE;
+ return;
+ }
+ if ((Result == USB_UNSUPPORT) || (pInformation->Ctrl_Info.Usb_wLength == 0))
+ {
+ /* Unsupported request */
+ pInformation->ControlState = STALLED;
+ return;
+ }
+
+
+ if (ValBit(pInformation->USBbmRequestType, 7))
+ {
+ /* Device ==> Host */
+ vu32 wLength = pInformation->USBwLength;
+
+ /* Restrict the data length to be the one host asks */
+ if (pInformation->Ctrl_Info.Usb_wLength > wLength)
+ {
+ pInformation->Ctrl_Info.Usb_wLength = wLength;
+ }
+
+ else if (pInformation->Ctrl_Info.Usb_wLength < pInformation->USBwLength)
+ {
+ if (pInformation->Ctrl_Info.Usb_wLength < pProperty->MaxPacketSize)
+ {
+ Data_Mul_MaxPacketSize = FALSE;
+ }
+ else if ((pInformation->Ctrl_Info.Usb_wLength % pProperty->MaxPacketSize) == 0)
+ {
+ Data_Mul_MaxPacketSize = TRUE;
+ }
+ }
+
+ pInformation->Ctrl_Info.PacketSize = pProperty->MaxPacketSize;
+ DataStageIn();
+ }
+ else
+ {
+ pInformation->ControlState = OUT_DATA;
+ vSetEPRxStatus(EP_RX_VALID); /* enable for next data reception */
+ }
+
+ return;
+}
+
+/*******************************************************************************
+* Function Name : Setup0_Process
+* Description : Get the device request data and dispatch to individual process.
+* Input : None.
+* Output : None.
+* Return : Post0_Process.
+*******************************************************************************/
+u8 Setup0_Process(void)
+{
+
+ union
+ {
+ u8* b;
+ u16* w;
+ } pBuf;
+
+ pBuf.b = PMAAddr + (u8 *)(_GetEPRxAddr(ENDP0) * 2); /* *2 for 32 bits addr */
+
+ if (pInformation->ControlState != PAUSE)
+ {
+ pInformation->USBbmRequestType = *pBuf.b++; /* bmRequestType */
+ pInformation->USBbRequest = *pBuf.b++; /* bRequest */
+ pBuf.w++; /* word not accessed because of 32 bits addressing */
+ pInformation->USBwValue = ByteSwap(*pBuf.w++); /* wValue */
+ pBuf.w++; /* word not accessed because of 32 bits addressing */
+ pInformation->USBwIndex = ByteSwap(*pBuf.w++); /* wIndex */
+ pBuf.w++; /* word not accessed because of 32 bits addressing */
+ pInformation->USBwLength = *pBuf.w; /* wLength */
+ }
+
+ pInformation->ControlState = SETTING_UP;
+ if (pInformation->USBwLength == 0)
+ {
+ /* Setup with no data stage */
+ NoData_Setup0();
+ }
+ else
+ {
+ /* Setup with data stage */
+ Data_Setup0();
+ }
+ return Post0_Process();
+}
+
+/*******************************************************************************
+* Function Name : In0_Process
+* Description : Process the IN token on all default endpoint.
+* Input : None.
+* Output : None.
+* Return : Post0_Process.
+*******************************************************************************/
+u8 In0_Process(void)
+{
+ u32 ControlState = pInformation->ControlState;
+
+ if ((ControlState == IN_DATA) || (ControlState == LAST_IN_DATA))
+ {
+ DataStageIn();
+ /* ControlState may be changed outside the function */
+ ControlState = pInformation->ControlState;
+ }
+
+ else if (ControlState == WAIT_STATUS_IN)
+ {
+ if ((pInformation->USBbRequest == SET_ADDRESS) &&
+ (Type_Recipient == (STANDARD_REQUEST | DEVICE_RECIPIENT)))
+ {
+ SetDeviceAddress(pInformation->USBwValue0);
+ pUser_Standard_Requests->User_SetDeviceAddress();
+ }
+ (*pProperty->Process_Status_IN)();
+ ControlState = STALLED;
+ }
+
+ else
+ {
+ ControlState = STALLED;
+ }
+
+ pInformation->ControlState = ControlState;
+
+ return Post0_Process();
+}
+
+/*******************************************************************************
+* Function Name : Out0_Process
+* Description : Process the OUT token on all default endpoint.
+* Input : None.
+* Output : None.
+* Return : Post0_Process.
+*******************************************************************************/
+u8 Out0_Process(void)
+{
+ u32 ControlState = pInformation->ControlState;
+
+ if ((ControlState == OUT_DATA) || (ControlState == LAST_OUT_DATA))
+ {
+ DataStageOut();
+ ControlState = pInformation->ControlState; /* may be changed outside the function */
+ }
+
+ else if (ControlState == WAIT_STATUS_OUT)
+ {
+ (*pProperty->Process_Status_OUT)();
+ ControlState = STALLED;
+ }
+
+ else if ((ControlState == IN_DATA) || (ControlState == LAST_IN_DATA))
+ {
+ /* host aborts the transfer before finish */
+ ControlState = STALLED;
+ }
+
+ /* Unexpect state, STALL the endpoint */
+ else
+ {
+ ControlState = STALLED;
+ }
+
+ pInformation->ControlState = ControlState;
+
+ return Post0_Process();
+}
+
+/*******************************************************************************
+* Function Name : Post0_Process
+* Description : Stall the Endpoint 0 in case of error.
+* Input : None.
+* Output : None.
+* Return : - 0 if the control State is in PAUSE
+* - 1 if not.
+*******************************************************************************/
+u8 Post0_Process(void)
+{
+ SetEPRxCount(ENDP0, Device_Property.MaxPacketSize);
+
+ if (pInformation->ControlState == STALLED)
+ {
+ vSetEPRxStatus(EP_RX_STALL);
+ vSetEPTxStatus(EP_TX_STALL);
+ }
+
+ return (pInformation->ControlState == PAUSE);
+}
+
+/*******************************************************************************
+* Function Name : SetDeviceAddress.
+* Description : Set the device and all the used Endpoints addresses.
+* Input : - Val: device adress.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+void SetDeviceAddress(u8 Val)
+{
+ u32 i;
+ u32 nEP = Device_Table.Total_Endpoint;
+
+ /* set address in every used endpoint */
+ for (i = 0; i < nEP; i++)
+ {
+ _SetEPAddress((u8)i, (u8)i);
+ } /* for */
+ _SetDADDR(Val | DADDR_EF); /* set device address and enable function */
+}
+
+/*******************************************************************************
+* Function Name : NOP_Process
+* Description : No operation function.
+* Input : None.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+void NOP_Process(void)
+{
+}
+
+/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
diff --git a/libmaple/usb/usb_lib/usb_core.h b/libmaple/usb/usb_lib/usb_core.h
index d8c099f..fa29a18 100644
--- a/libmaple/usb/usb_lib/usb_core.h
+++ b/libmaple/usb/usb_lib/usb_core.h
@@ -1,251 +1,251 @@
-/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
-* File Name : usb_core.h
-* Author : MCD Application Team
-* Version : V2.2.1
-* Date : 09/22/2008
-* Description : Standard protocol processing functions prototypes
-********************************************************************************
-* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
-* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
-* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
-* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
-* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
-* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
-*******************************************************************************/
-
-/* Define to prevent recursive inclusion -------------------------------------*/
-#ifndef __USB_CORE_H
-#define __USB_CORE_H
-
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
-/* Includes ------------------------------------------------------------------*/
-/* Exported types ------------------------------------------------------------*/
-typedef enum _CONTROL_STATE
-{
- WAIT_SETUP, /* 0 */
- SETTING_UP, /* 1 */
- IN_DATA, /* 2 */
- OUT_DATA, /* 3 */
- LAST_IN_DATA, /* 4 */
- LAST_OUT_DATA, /* 5 */
- WAIT_STATUS_IN, /* 7 */
- WAIT_STATUS_OUT, /* 8 */
- STALLED, /* 9 */
- PAUSE /* 10 */
-} CONTROL_STATE; /* The state machine states of a control pipe */
-
-typedef struct OneDescriptor
-{
- u8 *Descriptor;
- u16 Descriptor_Size;
-}
-ONE_DESCRIPTOR, *PONE_DESCRIPTOR;
-/* All the request process routines return a value of this type
- If the return value is not SUCCESS or NOT_READY,
- the software will STALL the correspond endpoint */
-typedef enum _RESULT
-{
- USB_SUCCESS = 0, /* Process sucessfully */
- USB_ERROR,
- USB_UNSUPPORT,
- USB_NOT_READY /* The process has not been finished, endpoint will be
- NAK to further rquest */
-} RESULT;
-
-
-/*-*-*-*-*-*-*-*-*-*-* Definitions for endpoint level -*-*-*-*-*-*-*-*-*-*-*-*/
-typedef struct _ENDPOINT_INFO
-{
- /* When send data out of the device,
- CopyData() is used to get data buffer 'Length' bytes data
- if Length is 0,
- CopyData() returns the total length of the data
- if the request is not supported, returns 0
- (NEW Feature )
- if CopyData() returns -1, the calling routine should not proceed
- further and will resume the SETUP process by the class device
- if Length is not 0,
- CopyData() returns a pointer to indicate the data location
- Usb_wLength is the data remain to be sent,
- Usb_wOffset is the Offset of original data
- When receive data from the host,
- CopyData() is used to get user data buffer which is capable
- of Length bytes data to copy data from the endpoint buffer.
- if Length is 0,
- CopyData() returns the available data length,
- if Length is not 0,
- CopyData() returns user buffer address
- Usb_rLength is the data remain to be received,
- Usb_rPointer is the Offset of data buffer
- */
- u16 Usb_wLength;
- u16 Usb_wOffset;
- u16 PacketSize;
- u8 *(*CopyData)(u16 Length);
-}ENDPOINT_INFO;
-
-/*-*-*-*-*-*-*-*-*-*-*-* Definitions for device level -*-*-*-*-*-*-*-*-*-*-*-*/
-
-typedef struct _DEVICE
-{
- u8 Total_Endpoint; /* Number of endpoints that are used */
- u8 Total_Configuration;/* Number of configuration available */
-}
-DEVICE;
-
-typedef union
-{
- u16 w;
- struct BW
- {
- u8 bb1;
- u8 bb0;
- }
- bw;
-} u16_u8;
-
-typedef struct _DEVICE_INFO
-{
- u8 USBbmRequestType; /* bmRequestType */
- u8 USBbRequest; /* bRequest */
- u16_u8 USBwValues; /* wValue */
- u16_u8 USBwIndexs; /* wIndex */
- u16_u8 USBwLengths; /* wLength */
-
- u8 ControlState; /* of type CONTROL_STATE */
- u8 Current_Feature;
- u8 Current_Configuration; /* Selected configuration */
- u8 Current_Interface; /* Selected interface of current configuration */
- u8 Current_AlternateSetting;/* Selected Alternate Setting of current
- interface*/
-
- ENDPOINT_INFO Ctrl_Info;
-}DEVICE_INFO;
-
-typedef struct _DEVICE_PROP
-{
- void (*Init)(void); /* Initialize the device */
- void (*Reset)(void); /* Reset routine of this device */
-
- /* Device dependent process after the status stage */
- void (*Process_Status_IN)(void);
- void (*Process_Status_OUT)(void);
-
- /* Procedure of process on setup stage of a class specified request with data stage */
- /* All class specified requests with data stage are processed in Class_Data_Setup
- Class_Data_Setup()
- responses to check all special requests and fills ENDPOINT_INFO
- according to the request
- If IN tokens are expected, then wLength & wOffset will be filled
- with the total transferring bytes and the starting position
- If OUT tokens are expected, then rLength & rOffset will be filled
- with the total expected bytes and the starting position in the buffer
-
- If the request is valid, Class_Data_Setup returns SUCCESS, else UNSUPPORT
-
- CAUTION:
- Since GET_CONFIGURATION & GET_INTERFACE are highly related to
- the individual classes, they will be checked and processed here.
- */
- RESULT (*Class_Data_Setup)(u8 RequestNo);
-
- /* Procedure of process on setup stage of a class specified request without data stage */
- /* All class specified requests without data stage are processed in Class_NoData_Setup
- Class_NoData_Setup
- responses to check all special requests and perform the request
-
- CAUTION:
- Since SET_CONFIGURATION & SET_INTERFACE are highly related to
- the individual classes, they will be checked and processed here.
- */
- RESULT (*Class_NoData_Setup)(u8 RequestNo);
-
- /*Class_Get_Interface_Setting
- This function is used by the file usb_core.c to test if the selected Interface
- and Alternate Setting (u8 Interface, u8 AlternateSetting) are supported by
- the application.
- This function is writing by user. It should return "SUCCESS" if the Interface
- and Alternate Setting are supported by the application or "UNSUPPORT" if they
- are not supported. */
-
- RESULT (*Class_Get_Interface_Setting)(u8 Interface, u8 AlternateSetting);
-
- u8* (*GetDeviceDescriptor)(u16 Length);
- u8* (*GetConfigDescriptor)(u16 Length);
- u8* (*GetStringDescriptor)(u16 Length);
-
- u8* RxEP_buffer;
- u8 MaxPacketSize;
-
-}DEVICE_PROP;
-
-typedef struct _USER_STANDARD_REQUESTS
-{
- void (*User_GetConfiguration)(void); /* Get Configuration */
- void (*User_SetConfiguration)(void); /* Set Configuration */
- void (*User_GetInterface)(void); /* Get Interface */
- void (*User_SetInterface)(void); /* Set Interface */
- void (*User_GetStatus)(void); /* Get Status */
- void (*User_ClearFeature)(void); /* Clear Feature */
- void (*User_SetEndPointFeature)(void); /* Set Endpoint Feature */
- void (*User_SetDeviceFeature)(void); /* Set Device Feature */
- void (*User_SetDeviceAddress)(void); /* Set Device Address */
-}
-USER_STANDARD_REQUESTS;
-
-/* Exported constants --------------------------------------------------------*/
-#define Type_Recipient (pInformation->USBbmRequestType & (REQUEST_TYPE | RECIPIENT))
-
-#define Usb_rLength Usb_wLength
-#define Usb_rOffset Usb_wOffset
-
-#define USBwValue USBwValues.w
-#define USBwValue0 USBwValues.bw.bb0
-#define USBwValue1 USBwValues.bw.bb1
-#define USBwIndex USBwIndexs.w
-#define USBwIndex0 USBwIndexs.bw.bb0
-#define USBwIndex1 USBwIndexs.bw.bb1
-#define USBwLength USBwLengths.w
-#define USBwLength0 USBwLengths.bw.bb0
-#define USBwLength1 USBwLengths.bw.bb1
-
-/* Exported macro ------------------------------------------------------------*/
-/* Exported functions ------------------------------------------------------- */
-u8 Setup0_Process(void);
-u8 Post0_Process(void);
-u8 Out0_Process(void);
-u8 In0_Process(void);
-
-RESULT Standard_SetEndPointFeature(void);
-RESULT Standard_SetDeviceFeature(void);
-
-u8 *Standard_GetConfiguration(u16 Length);
-RESULT Standard_SetConfiguration(void);
-u8 *Standard_GetInterface(u16 Length);
-RESULT Standard_SetInterface(void);
-u8 *Standard_GetDescriptorData(u16 Length, PONE_DESCRIPTOR pDesc);
-
-u8 *Standard_GetStatus(u16 Length);
-RESULT Standard_ClearFeature(void);
-void SetDeviceAddress(u8);
-void NOP_Process(void);
-
-extern DEVICE_PROP Device_Property;
-extern USER_STANDARD_REQUESTS User_Standard_Requests;
-extern DEVICE Device_Table;
-extern DEVICE_INFO Device_Info;
-
-/* cells saving status during interrupt servicing */
-extern u16 SaveRState;
-extern u16 SaveTState;
-
-#if defined(__cplusplus)
-}
-#endif
-
-#endif /* __USB_CORE_H */
-
-/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
+/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
+* File Name : usb_core.h
+* Author : MCD Application Team
+* Version : V2.2.1
+* Date : 09/22/2008
+* Description : Standard protocol processing functions prototypes
+********************************************************************************
+* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
+* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
+* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
+* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
+* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+*******************************************************************************/
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __USB_CORE_H
+#define __USB_CORE_H
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+/* Exported types ------------------------------------------------------------*/
+typedef enum _CONTROL_STATE
+{
+ WAIT_SETUP, /* 0 */
+ SETTING_UP, /* 1 */
+ IN_DATA, /* 2 */
+ OUT_DATA, /* 3 */
+ LAST_IN_DATA, /* 4 */
+ LAST_OUT_DATA, /* 5 */
+ WAIT_STATUS_IN, /* 7 */
+ WAIT_STATUS_OUT, /* 8 */
+ STALLED, /* 9 */
+ PAUSE /* 10 */
+} CONTROL_STATE; /* The state machine states of a control pipe */
+
+typedef struct OneDescriptor
+{
+ u8 *Descriptor;
+ u16 Descriptor_Size;
+}
+ONE_DESCRIPTOR, *PONE_DESCRIPTOR;
+/* All the request process routines return a value of this type
+ If the return value is not SUCCESS or NOT_READY,
+ the software will STALL the correspond endpoint */
+typedef enum _RESULT
+{
+ USB_SUCCESS = 0, /* Process sucessfully */
+ USB_ERROR,
+ USB_UNSUPPORT,
+ USB_NOT_READY /* The process has not been finished, endpoint will be
+ NAK to further rquest */
+} RESULT;
+
+
+/*-*-*-*-*-*-*-*-*-*-* Definitions for endpoint level -*-*-*-*-*-*-*-*-*-*-*-*/
+typedef struct _ENDPOINT_INFO
+{
+ /* When send data out of the device,
+ CopyData() is used to get data buffer 'Length' bytes data
+ if Length is 0,
+ CopyData() returns the total length of the data
+ if the request is not supported, returns 0
+ (NEW Feature )
+ if CopyData() returns -1, the calling routine should not proceed
+ further and will resume the SETUP process by the class device
+ if Length is not 0,
+ CopyData() returns a pointer to indicate the data location
+ Usb_wLength is the data remain to be sent,
+ Usb_wOffset is the Offset of original data
+ When receive data from the host,
+ CopyData() is used to get user data buffer which is capable
+ of Length bytes data to copy data from the endpoint buffer.
+ if Length is 0,
+ CopyData() returns the available data length,
+ if Length is not 0,
+ CopyData() returns user buffer address
+ Usb_rLength is the data remain to be received,
+ Usb_rPointer is the Offset of data buffer
+ */
+ u16 Usb_wLength;
+ u16 Usb_wOffset;
+ u16 PacketSize;
+ u8 *(*CopyData)(u16 Length);
+}ENDPOINT_INFO;
+
+/*-*-*-*-*-*-*-*-*-*-*-* Definitions for device level -*-*-*-*-*-*-*-*-*-*-*-*/
+
+typedef struct _DEVICE
+{
+ u8 Total_Endpoint; /* Number of endpoints that are used */
+ u8 Total_Configuration;/* Number of configuration available */
+}
+DEVICE;
+
+typedef union
+{
+ u16 w;
+ struct BW
+ {
+ u8 bb1;
+ u8 bb0;
+ }
+ bw;
+} u16_u8;
+
+typedef struct _DEVICE_INFO
+{
+ u8 USBbmRequestType; /* bmRequestType */
+ u8 USBbRequest; /* bRequest */
+ u16_u8 USBwValues; /* wValue */
+ u16_u8 USBwIndexs; /* wIndex */
+ u16_u8 USBwLengths; /* wLength */
+
+ u8 ControlState; /* of type CONTROL_STATE */
+ u8 Current_Feature;
+ u8 Current_Configuration; /* Selected configuration */
+ u8 Current_Interface; /* Selected interface of current configuration */
+ u8 Current_AlternateSetting;/* Selected Alternate Setting of current
+ interface*/
+
+ ENDPOINT_INFO Ctrl_Info;
+}DEVICE_INFO;
+
+typedef struct _DEVICE_PROP
+{
+ void (*Init)(void); /* Initialize the device */
+ void (*Reset)(void); /* Reset routine of this device */
+
+ /* Device dependent process after the status stage */
+ void (*Process_Status_IN)(void);
+ void (*Process_Status_OUT)(void);
+
+ /* Procedure of process on setup stage of a class specified request with data stage */
+ /* All class specified requests with data stage are processed in Class_Data_Setup
+ Class_Data_Setup()
+ responses to check all special requests and fills ENDPOINT_INFO
+ according to the request
+ If IN tokens are expected, then wLength & wOffset will be filled
+ with the total transferring bytes and the starting position
+ If OUT tokens are expected, then rLength & rOffset will be filled
+ with the total expected bytes and the starting position in the buffer
+
+ If the request is valid, Class_Data_Setup returns SUCCESS, else UNSUPPORT
+
+ CAUTION:
+ Since GET_CONFIGURATION & GET_INTERFACE are highly related to
+ the individual classes, they will be checked and processed here.
+ */
+ RESULT (*Class_Data_Setup)(u8 RequestNo);
+
+ /* Procedure of process on setup stage of a class specified request without data stage */
+ /* All class specified requests without data stage are processed in Class_NoData_Setup
+ Class_NoData_Setup
+ responses to check all special requests and perform the request
+
+ CAUTION:
+ Since SET_CONFIGURATION & SET_INTERFACE are highly related to
+ the individual classes, they will be checked and processed here.
+ */
+ RESULT (*Class_NoData_Setup)(u8 RequestNo);
+
+ /*Class_Get_Interface_Setting
+ This function is used by the file usb_core.c to test if the selected Interface
+ and Alternate Setting (u8 Interface, u8 AlternateSetting) are supported by
+ the application.
+ This function is writing by user. It should return "SUCCESS" if the Interface
+ and Alternate Setting are supported by the application or "UNSUPPORT" if they
+ are not supported. */
+
+ RESULT (*Class_Get_Interface_Setting)(u8 Interface, u8 AlternateSetting);
+
+ u8* (*GetDeviceDescriptor)(u16 Length);
+ u8* (*GetConfigDescriptor)(u16 Length);
+ u8* (*GetStringDescriptor)(u16 Length);
+
+ u8* RxEP_buffer;
+ u8 MaxPacketSize;
+
+}DEVICE_PROP;
+
+typedef struct _USER_STANDARD_REQUESTS
+{
+ void (*User_GetConfiguration)(void); /* Get Configuration */
+ void (*User_SetConfiguration)(void); /* Set Configuration */
+ void (*User_GetInterface)(void); /* Get Interface */
+ void (*User_SetInterface)(void); /* Set Interface */
+ void (*User_GetStatus)(void); /* Get Status */
+ void (*User_ClearFeature)(void); /* Clear Feature */
+ void (*User_SetEndPointFeature)(void); /* Set Endpoint Feature */
+ void (*User_SetDeviceFeature)(void); /* Set Device Feature */
+ void (*User_SetDeviceAddress)(void); /* Set Device Address */
+}
+USER_STANDARD_REQUESTS;
+
+/* Exported constants --------------------------------------------------------*/
+#define Type_Recipient (pInformation->USBbmRequestType & (REQUEST_TYPE | RECIPIENT))
+
+#define Usb_rLength Usb_wLength
+#define Usb_rOffset Usb_wOffset
+
+#define USBwValue USBwValues.w
+#define USBwValue0 USBwValues.bw.bb0
+#define USBwValue1 USBwValues.bw.bb1
+#define USBwIndex USBwIndexs.w
+#define USBwIndex0 USBwIndexs.bw.bb0
+#define USBwIndex1 USBwIndexs.bw.bb1
+#define USBwLength USBwLengths.w
+#define USBwLength0 USBwLengths.bw.bb0
+#define USBwLength1 USBwLengths.bw.bb1
+
+/* Exported macro ------------------------------------------------------------*/
+/* Exported functions ------------------------------------------------------- */
+u8 Setup0_Process(void);
+u8 Post0_Process(void);
+u8 Out0_Process(void);
+u8 In0_Process(void);
+
+RESULT Standard_SetEndPointFeature(void);
+RESULT Standard_SetDeviceFeature(void);
+
+u8 *Standard_GetConfiguration(u16 Length);
+RESULT Standard_SetConfiguration(void);
+u8 *Standard_GetInterface(u16 Length);
+RESULT Standard_SetInterface(void);
+u8 *Standard_GetDescriptorData(u16 Length, PONE_DESCRIPTOR pDesc);
+
+u8 *Standard_GetStatus(u16 Length);
+RESULT Standard_ClearFeature(void);
+void SetDeviceAddress(u8);
+void NOP_Process(void);
+
+extern DEVICE_PROP Device_Property;
+extern USER_STANDARD_REQUESTS User_Standard_Requests;
+extern DEVICE Device_Table;
+extern DEVICE_INFO Device_Info;
+
+/* cells saving status during interrupt servicing */
+extern u16 SaveRState;
+extern u16 SaveTState;
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif /* __USB_CORE_H */
+
+/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
diff --git a/libmaple/usb/usb_lib/usb_def.h b/libmaple/usb/usb_lib/usb_def.h
index aa6bcba..80aa303 100644
--- a/libmaple/usb/usb_lib/usb_def.h
+++ b/libmaple/usb/usb_lib/usb_def.h
@@ -1,88 +1,88 @@
-/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
-* File Name : usb_def.h
-* Author : MCD Application Team
-* Version : V2.2.1
-* Date : 09/22/2008
-* Description : Definitions related to USB Core
-********************************************************************************
-* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
-* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
-* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
-* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
-* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
-* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
-*******************************************************************************/
-
-/* Define to prevent recursive inclusion -------------------------------------*/
-#ifndef __USB_DEF_H
-#define __USB_DEF_H
-
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
-/* Includes ------------------------------------------------------------------*/
-/* Exported types ------------------------------------------------------------*/
-typedef enum _RECIPIENT_TYPE
-{
- DEVICE_RECIPIENT, /* Recipient device */
- INTERFACE_RECIPIENT, /* Recipient interface */
- ENDPOINT_RECIPIENT, /* Recipient endpoint */
- OTHER_RECIPIENT
-} RECIPIENT_TYPE;
-
-
-typedef enum _STANDARD_REQUESTS
-{
- GET_STATUS = 0,
- CLEAR_FEATURE,
- RESERVED1,
- SET_FEATURE,
- RESERVED2,
- SET_ADDRESS,
- GET_DESCRIPTOR,
- SET_DESCRIPTOR,
- GET_CONFIGURATION,
- SET_CONFIGURATION,
- GET_INTERFACE,
- SET_INTERFACE,
- TOTAL_sREQUEST, /* Total number of Standard request */
- SYNCH_FRAME = 12
-} STANDARD_REQUESTS;
-
-/* Definition of "USBwValue" */
-typedef enum _DESCRIPTOR_TYPE
-{
- DEVICE_DESCRIPTOR = 1,
- CONFIG_DESCRIPTOR,
- STRING_DESCRIPTOR,
- INTERFACE_DESCRIPTOR,
- ENDPOINT_DESCRIPTOR
-} DESCRIPTOR_TYPE;
-
-/* Feature selector of a SET_FEATURE or CLEAR_FEATURE */
-typedef enum _FEATURE_SELECTOR
-{
- ENDPOINT_STALL,
- DEVICE_REMOTE_WAKEUP
-} FEATURE_SELECTOR;
-
-/* Exported constants --------------------------------------------------------*/
-/* Definition of "USBbmRequestType" */
-#define REQUEST_TYPE 0x60 /* Mask to get request type */
-#define STANDARD_REQUEST 0x00 /* Standard request */
-#define CLASS_REQUEST 0x20 /* Class request */
-#define VENDOR_REQUEST 0x40 /* Vendor request */
-
-#define RECIPIENT 0x1F /* Mask to get recipient */
-
-/* Exported macro ------------------------------------------------------------*/
-/* Exported functions ------------------------------------------------------- */
-
-#if defined(__cplusplus)
-}
-#endif
-
-#endif /* __USB_DEF_H */
-
-/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
+/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
+* File Name : usb_def.h
+* Author : MCD Application Team
+* Version : V2.2.1
+* Date : 09/22/2008
+* Description : Definitions related to USB Core
+********************************************************************************
+* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
+* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
+* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
+* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
+* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+*******************************************************************************/
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __USB_DEF_H
+#define __USB_DEF_H
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+/* Exported types ------------------------------------------------------------*/
+typedef enum _RECIPIENT_TYPE
+{
+ DEVICE_RECIPIENT, /* Recipient device */
+ INTERFACE_RECIPIENT, /* Recipient interface */
+ ENDPOINT_RECIPIENT, /* Recipient endpoint */
+ OTHER_RECIPIENT
+} RECIPIENT_TYPE;
+
+
+typedef enum _STANDARD_REQUESTS
+{
+ GET_STATUS = 0,
+ CLEAR_FEATURE,
+ RESERVED1,
+ SET_FEATURE,
+ RESERVED2,
+ SET_ADDRESS,
+ GET_DESCRIPTOR,
+ SET_DESCRIPTOR,
+ GET_CONFIGURATION,
+ SET_CONFIGURATION,
+ GET_INTERFACE,
+ SET_INTERFACE,
+ TOTAL_sREQUEST, /* Total number of Standard request */
+ SYNCH_FRAME = 12
+} STANDARD_REQUESTS;
+
+/* Definition of "USBwValue" */
+typedef enum _DESCRIPTOR_TYPE
+{
+ DEVICE_DESCRIPTOR = 1,
+ CONFIG_DESCRIPTOR,
+ STRING_DESCRIPTOR,
+ INTERFACE_DESCRIPTOR,
+ ENDPOINT_DESCRIPTOR
+} DESCRIPTOR_TYPE;
+
+/* Feature selector of a SET_FEATURE or CLEAR_FEATURE */
+typedef enum _FEATURE_SELECTOR
+{
+ ENDPOINT_STALL,
+ DEVICE_REMOTE_WAKEUP
+} FEATURE_SELECTOR;
+
+/* Exported constants --------------------------------------------------------*/
+/* Definition of "USBbmRequestType" */
+#define REQUEST_TYPE 0x60 /* Mask to get request type */
+#define STANDARD_REQUEST 0x00 /* Standard request */
+#define CLASS_REQUEST 0x20 /* Class request */
+#define VENDOR_REQUEST 0x40 /* Vendor request */
+
+#define RECIPIENT 0x1F /* Mask to get recipient */
+
+/* Exported macro ------------------------------------------------------------*/
+/* Exported functions ------------------------------------------------------- */
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif /* __USB_DEF_H */
+
+/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
diff --git a/libmaple/usb/usb_lib/usb_init.c b/libmaple/usb/usb_lib/usb_init.c
index 5862145..94f3a83 100644
--- a/libmaple/usb/usb_lib/usb_init.c
+++ b/libmaple/usb/usb_lib/usb_init.c
@@ -1,64 +1,64 @@
-/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
-* File Name : usb_init.c
-* Author : MCD Application Team
-* Version : V2.2.1
-* Date : 09/22/2008
-* Description : Initialization routines & global variables
-********************************************************************************
-* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
-* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
-* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
-* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
-* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
-* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
-*******************************************************************************/
-
-/* Includes ------------------------------------------------------------------*/
-#include "usb_lib.h"
-
-/* Private typedef -----------------------------------------------------------*/
-/* Private define ------------------------------------------------------------*/
-/* Private macro -------------------------------------------------------------*/
-/* Private variables ---------------------------------------------------------*/
-/* The number of current endpoint, it will be used to specify an endpoint */
- u8 EPindex;
-/* The number of current device, it is an index to the Device_Table */
-/* u8 Device_no; */
-/* Points to the DEVICE_INFO structure of current device */
-/* The purpose of this register is to speed up the execution */
-DEVICE_INFO *pInformation;
-/* Points to the DEVICE_PROP structure of current device */
-/* The purpose of this register is to speed up the execution */
-DEVICE_PROP *pProperty;
-/* Temporary save the state of Rx & Tx status. */
-/* Whenever the Rx or Tx state is changed, its value is saved */
-/* in this variable first and will be set to the EPRB or EPRA */
-/* at the end of interrupt process */
-u16 SaveState ;
-u16 wInterrupt_Mask;
-DEVICE_INFO Device_Info;
-USER_STANDARD_REQUESTS *pUser_Standard_Requests;
-
-/* Extern variables ----------------------------------------------------------*/
-/* Private function prototypes -----------------------------------------------*/
-/* Private functions ---------------------------------------------------------*/
-
-/*******************************************************************************
-* Function Name : USB_Init
-* Description : USB system initialization
-* Input : None.
-* Output : None.
-* Return : None.
-*******************************************************************************/
-void USB_Init(void)
-{
- pInformation = &Device_Info;
- pInformation->ControlState = 2;
- pProperty = &Device_Property;
- pUser_Standard_Requests = &User_Standard_Requests;
- /* Initialize devices one by one */
-
- pProperty->Init();
-}
-
-/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
+/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
+* File Name : usb_init.c
+* Author : MCD Application Team
+* Version : V2.2.1
+* Date : 09/22/2008
+* Description : Initialization routines & global variables
+********************************************************************************
+* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
+* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
+* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
+* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
+* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+*******************************************************************************/
+
+/* Includes ------------------------------------------------------------------*/
+#include "usb_lib.h"
+
+/* Private typedef -----------------------------------------------------------*/
+/* Private define ------------------------------------------------------------*/
+/* Private macro -------------------------------------------------------------*/
+/* Private variables ---------------------------------------------------------*/
+/* The number of current endpoint, it will be used to specify an endpoint */
+ u8 EPindex;
+/* The number of current device, it is an index to the Device_Table */
+/* u8 Device_no; */
+/* Points to the DEVICE_INFO structure of current device */
+/* The purpose of this register is to speed up the execution */
+DEVICE_INFO *pInformation;
+/* Points to the DEVICE_PROP structure of current device */
+/* The purpose of this register is to speed up the execution */
+DEVICE_PROP *pProperty;
+/* Temporary save the state of Rx & Tx status. */
+/* Whenever the Rx or Tx state is changed, its value is saved */
+/* in this variable first and will be set to the EPRB or EPRA */
+/* at the end of interrupt process */
+u16 SaveState ;
+u16 wInterrupt_Mask;
+DEVICE_INFO Device_Info;
+USER_STANDARD_REQUESTS *pUser_Standard_Requests;
+
+/* Extern variables ----------------------------------------------------------*/
+/* Private function prototypes -----------------------------------------------*/
+/* Private functions ---------------------------------------------------------*/
+
+/*******************************************************************************
+* Function Name : USB_Init
+* Description : USB system initialization
+* Input : None.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+void USB_Init(void)
+{
+ pInformation = &Device_Info;
+ pInformation->ControlState = 2;
+ pProperty = &Device_Property;
+ pUser_Standard_Requests = &User_Standard_Requests;
+ /* Initialize devices one by one */
+
+ pProperty->Init();
+}
+
+/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
diff --git a/libmaple/usb/usb_lib/usb_init.h b/libmaple/usb/usb_lib/usb_init.h
index 1091ce5..80ee2fb 100644
--- a/libmaple/usb/usb_lib/usb_init.h
+++ b/libmaple/usb/usb_lib/usb_init.h
@@ -1,57 +1,57 @@
-/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
-* File Name : usb_init.h
-* Author : MCD Application Team
-* Version : V2.2.1
-* Date : 09/22/2008
-* Description : Initialization routines & global variables
-********************************************************************************
-* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
-* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
-* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
-* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
-* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
-* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
-*******************************************************************************/
-
-/* Define to prevent recursive inclusion -------------------------------------*/
-#ifndef __USB_INIT_H
-#define __USB_INIT_H
-
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
-/* Includes ------------------------------------------------------------------*/
-/* Exported types ------------------------------------------------------------*/
-/* Exported constants --------------------------------------------------------*/
-/* Exported macro ------------------------------------------------------------*/
-/* Exported functions ------------------------------------------------------- */
-void USB_Init(void);
-
-/* External variables --------------------------------------------------------*/
-/* The number of current endpoint, it will be used to specify an endpoint */
-extern u8 EPindex;
-/* The number of current device, it is an index to the Device_Table */
-/*extern u8 Device_no; */
-/* Points to the DEVICE_INFO structure of current device */
-/* The purpose of this register is to speed up the execution */
-extern DEVICE_INFO* pInformation;
-/* Points to the DEVICE_PROP structure of current device */
-/* The purpose of this register is to speed up the execution */
-extern DEVICE_PROP* pProperty;
-/* Temporary save the state of Rx & Tx status. */
-/* Whenever the Rx or Tx state is changed, its value is saved */
-/* in this variable first and will be set to the EPRB or EPRA */
-/* at the end of interrupt process */
-extern USER_STANDARD_REQUESTS *pUser_Standard_Requests;
-
-extern u16 SaveState ;
-extern u16 wInterrupt_Mask;
-
-#if defined(__cplusplus)
-}
-#endif
-
-#endif /* __USB_INIT_H */
-
-/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
+/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
+* File Name : usb_init.h
+* Author : MCD Application Team
+* Version : V2.2.1
+* Date : 09/22/2008
+* Description : Initialization routines & global variables
+********************************************************************************
+* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
+* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
+* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
+* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
+* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+*******************************************************************************/
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __USB_INIT_H
+#define __USB_INIT_H
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+/* Exported types ------------------------------------------------------------*/
+/* Exported constants --------------------------------------------------------*/
+/* Exported macro ------------------------------------------------------------*/
+/* Exported functions ------------------------------------------------------- */
+void USB_Init(void);
+
+/* External variables --------------------------------------------------------*/
+/* The number of current endpoint, it will be used to specify an endpoint */
+extern u8 EPindex;
+/* The number of current device, it is an index to the Device_Table */
+/*extern u8 Device_no; */
+/* Points to the DEVICE_INFO structure of current device */
+/* The purpose of this register is to speed up the execution */
+extern DEVICE_INFO* pInformation;
+/* Points to the DEVICE_PROP structure of current device */
+/* The purpose of this register is to speed up the execution */
+extern DEVICE_PROP* pProperty;
+/* Temporary save the state of Rx & Tx status. */
+/* Whenever the Rx or Tx state is changed, its value is saved */
+/* in this variable first and will be set to the EPRB or EPRA */
+/* at the end of interrupt process */
+extern USER_STANDARD_REQUESTS *pUser_Standard_Requests;
+
+extern u16 SaveState ;
+extern u16 wInterrupt_Mask;
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif /* __USB_INIT_H */
+
+/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
diff --git a/libmaple/usb/usb_lib/usb_int.c b/libmaple/usb/usb_lib/usb_int.c
index f1d82be..61a989b 100644
--- a/libmaple/usb/usb_lib/usb_int.c
+++ b/libmaple/usb/usb_lib/usb_int.c
@@ -1,192 +1,192 @@
-/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
-* File Name : usb_int.c
-* Author : MCD Application Team
-* Version : V2.2.1
-* Date : 09/22/2008
-* Description : Endpoint CTR (Low and High) interrupt's service routines
-********************************************************************************
-* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
-* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
-* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
-* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
-* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
-* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
-*******************************************************************************/
-
-/* Includes ------------------------------------------------------------------*/
-#include "usb_lib.h"
-
-/* Private typedef -----------------------------------------------------------*/
-/* Private define ------------------------------------------------------------*/
-/* Private macro -------------------------------------------------------------*/
-/* Private variables ---------------------------------------------------------*/
-u16 SaveRState;
-u16 SaveTState;
-
-/* Extern variables ----------------------------------------------------------*/
-extern void (*pEpInt_IN[7])(void); /* Handles IN interrupts */
-extern void (*pEpInt_OUT[7])(void); /* Handles OUT interrupts */
-
-/* Private function prototypes -----------------------------------------------*/
-/* Private functions ---------------------------------------------------------*/
-
-/*******************************************************************************
-* Function Name : CTR_LP.
-* Description : Low priority Endpoint Correct Transfer interrupt's service
-* routine.
-* Input : None.
-* Output : None.
-* Return : None.
-*******************************************************************************/
-void CTR_LP(void)
-{
- u32 wEPVal = 0;
- /* stay in loop while pending ints */
- while (((wIstr = _GetISTR()) & ISTR_CTR) != 0)
- {
- _SetISTR((u16)CLR_CTR); /* clear CTR flag */
- /* extract highest priority endpoint number */
- EPindex = (u8)(wIstr & ISTR_EP_ID);
- if (EPindex == 0)
- {
- /* Decode and service control endpoint interrupt */
- /* calling related service routine */
- /* (Setup0_Process, In0_Process, Out0_Process) */
-
- /* save RX & TX status */
- /* and set both to NAK */
- SaveRState = _GetEPRxStatus(ENDP0);
- SaveTState = _GetEPTxStatus(ENDP0);
- _SetEPRxStatus(ENDP0, EP_RX_NAK);
- _SetEPTxStatus(ENDP0, EP_TX_NAK);
-
-
- /* DIR bit = origin of the interrupt */
-
- if ((wIstr & ISTR_DIR) == 0)
- {
- /* DIR = 0 */
-
- /* DIR = 0 => IN int */
- /* DIR = 0 implies that (EP_CTR_TX = 1) always */
-
-
- _ClearEP_CTR_TX(ENDP0);
- In0_Process();
-
- /* before terminate set Tx & Rx status */
- _SetEPRxStatus(ENDP0, SaveRState);
- _SetEPTxStatus(ENDP0, SaveTState);
- return;
- }
- else
- {
- /* DIR = 1 */
-
- /* DIR = 1 & CTR_RX => SETUP or OUT int */
- /* DIR = 1 & (CTR_TX | CTR_RX) => 2 int pending */
-
- wEPVal = _GetENDPOINT(ENDP0);
- if ((wEPVal & EP_CTR_TX) != 0)
- {
- _ClearEP_CTR_TX(ENDP0);
- In0_Process();
- /* before terminate set Tx & Rx status */
- _SetEPRxStatus(ENDP0, SaveRState);
- _SetEPTxStatus(ENDP0, SaveTState);
- return;
- }
- else if ((wEPVal &EP_SETUP) != 0)
- {
- _ClearEP_CTR_RX(ENDP0); /* SETUP bit kept frozen while CTR_RX = 1 */
- Setup0_Process();
- /* before terminate set Tx & Rx status */
- _SetEPRxStatus(ENDP0, SaveRState);
- _SetEPTxStatus(ENDP0, SaveTState);
- return;
- }
-
- else if ((wEPVal & EP_CTR_RX) != 0)
- {
- _ClearEP_CTR_RX(ENDP0);
- Out0_Process();
- /* before terminate set Tx & Rx status */
- _SetEPRxStatus(ENDP0, SaveRState);
- _SetEPTxStatus(ENDP0, SaveTState);
- return;
- }
- }
- }/* if(EPindex == 0) */
- else
- {
- /* Decode and service non control endpoints interrupt */
-
- /* process related endpoint register */
- wEPVal = _GetENDPOINT(EPindex);
- if ((wEPVal & EP_CTR_RX) != 0)
- {
- /* clear int flag */
- _ClearEP_CTR_RX(EPindex);
-
- /* call OUT service function */
- (*pEpInt_OUT[EPindex-1])();
-
- } /* if((wEPVal & EP_CTR_RX) */
-
- if ((wEPVal & EP_CTR_TX) != 0)
- {
- /* clear int flag */
- _ClearEP_CTR_TX(EPindex);
-
- /* call IN service function */
- (*pEpInt_IN[EPindex-1])();
- } /* if((wEPVal & EP_CTR_TX) != 0) */
-
- }/* if(EPindex == 0) else */
-
- }/* while(...) */
-}
-
-/*******************************************************************************
-* Function Name : CTR_HP.
-* Description : High Priority Endpoint Correct Transfer interrupt's service
-* routine.
-* Input : None.
-* Output : None.
-* Return : None.
-*******************************************************************************/
-void CTR_HP(void)
-{
- u32 wEPVal = 0;
-
- while (((wIstr = _GetISTR()) & ISTR_CTR) != 0)
- {
- _SetISTR((u16)CLR_CTR); /* clear CTR flag */
- /* extract highest priority endpoint number */
- EPindex = (u8)(wIstr & ISTR_EP_ID);
- /* process related endpoint register */
- wEPVal = _GetENDPOINT(EPindex);
- if ((wEPVal & EP_CTR_RX) != 0)
- {
- /* clear int flag */
- _ClearEP_CTR_RX(EPindex);
-
- /* call OUT service function */
- (*pEpInt_OUT[EPindex-1])();
-
- } /* if((wEPVal & EP_CTR_RX) */
- else if ((wEPVal & EP_CTR_TX) != 0)
- {
- /* clear int flag */
- _ClearEP_CTR_TX(EPindex);
-
- /* call IN service function */
- (*pEpInt_IN[EPindex-1])();
-
-
- } /* if((wEPVal & EP_CTR_TX) != 0) */
-
- }/* while(...) */
-}
-
-/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
+/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
+* File Name : usb_int.c
+* Author : MCD Application Team
+* Version : V2.2.1
+* Date : 09/22/2008
+* Description : Endpoint CTR (Low and High) interrupt's service routines
+********************************************************************************
+* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
+* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
+* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
+* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
+* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+*******************************************************************************/
+
+/* Includes ------------------------------------------------------------------*/
+#include "usb_lib.h"
+
+/* Private typedef -----------------------------------------------------------*/
+/* Private define ------------------------------------------------------------*/
+/* Private macro -------------------------------------------------------------*/
+/* Private variables ---------------------------------------------------------*/
+u16 SaveRState;
+u16 SaveTState;
+
+/* Extern variables ----------------------------------------------------------*/
+extern void (*pEpInt_IN[7])(void); /* Handles IN interrupts */
+extern void (*pEpInt_OUT[7])(void); /* Handles OUT interrupts */
+
+/* Private function prototypes -----------------------------------------------*/
+/* Private functions ---------------------------------------------------------*/
+
+/*******************************************************************************
+* Function Name : CTR_LP.
+* Description : Low priority Endpoint Correct Transfer interrupt's service
+* routine.
+* Input : None.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+void CTR_LP(void)
+{
+ u32 wEPVal = 0;
+ /* stay in loop while pending ints */
+ while (((wIstr = _GetISTR()) & ISTR_CTR) != 0)
+ {
+ _SetISTR((u16)CLR_CTR); /* clear CTR flag */
+ /* extract highest priority endpoint number */
+ EPindex = (u8)(wIstr & ISTR_EP_ID);
+ if (EPindex == 0)
+ {
+ /* Decode and service control endpoint interrupt */
+ /* calling related service routine */
+ /* (Setup0_Process, In0_Process, Out0_Process) */
+
+ /* save RX & TX status */
+ /* and set both to NAK */
+ SaveRState = _GetEPRxStatus(ENDP0);
+ SaveTState = _GetEPTxStatus(ENDP0);
+ _SetEPRxStatus(ENDP0, EP_RX_NAK);
+ _SetEPTxStatus(ENDP0, EP_TX_NAK);
+
+
+ /* DIR bit = origin of the interrupt */
+
+ if ((wIstr & ISTR_DIR) == 0)
+ {
+ /* DIR = 0 */
+
+ /* DIR = 0 => IN int */
+ /* DIR = 0 implies that (EP_CTR_TX = 1) always */
+
+
+ _ClearEP_CTR_TX(ENDP0);
+ In0_Process();
+
+ /* before terminate set Tx & Rx status */
+ _SetEPRxStatus(ENDP0, SaveRState);
+ _SetEPTxStatus(ENDP0, SaveTState);
+ return;
+ }
+ else
+ {
+ /* DIR = 1 */
+
+ /* DIR = 1 & CTR_RX => SETUP or OUT int */
+ /* DIR = 1 & (CTR_TX | CTR_RX) => 2 int pending */
+
+ wEPVal = _GetENDPOINT(ENDP0);
+ if ((wEPVal & EP_CTR_TX) != 0)
+ {
+ _ClearEP_CTR_TX(ENDP0);
+ In0_Process();
+ /* before terminate set Tx & Rx status */
+ _SetEPRxStatus(ENDP0, SaveRState);
+ _SetEPTxStatus(ENDP0, SaveTState);
+ return;
+ }
+ else if ((wEPVal &EP_SETUP) != 0)
+ {
+ _ClearEP_CTR_RX(ENDP0); /* SETUP bit kept frozen while CTR_RX = 1 */
+ Setup0_Process();
+ /* before terminate set Tx & Rx status */
+ _SetEPRxStatus(ENDP0, SaveRState);
+ _SetEPTxStatus(ENDP0, SaveTState);
+ return;
+ }
+
+ else if ((wEPVal & EP_CTR_RX) != 0)
+ {
+ _ClearEP_CTR_RX(ENDP0);
+ Out0_Process();
+ /* before terminate set Tx & Rx status */
+ _SetEPRxStatus(ENDP0, SaveRState);
+ _SetEPTxStatus(ENDP0, SaveTState);
+ return;
+ }
+ }
+ }/* if(EPindex == 0) */
+ else
+ {
+ /* Decode and service non control endpoints interrupt */
+
+ /* process related endpoint register */
+ wEPVal = _GetENDPOINT(EPindex);
+ if ((wEPVal & EP_CTR_RX) != 0)
+ {
+ /* clear int flag */
+ _ClearEP_CTR_RX(EPindex);
+
+ /* call OUT service function */
+ (*pEpInt_OUT[EPindex-1])();
+
+ } /* if((wEPVal & EP_CTR_RX) */
+
+ if ((wEPVal & EP_CTR_TX) != 0)
+ {
+ /* clear int flag */
+ _ClearEP_CTR_TX(EPindex);
+
+ /* call IN service function */
+ (*pEpInt_IN[EPindex-1])();
+ } /* if((wEPVal & EP_CTR_TX) != 0) */
+
+ }/* if(EPindex == 0) else */
+
+ }/* while(...) */
+}
+
+/*******************************************************************************
+* Function Name : CTR_HP.
+* Description : High Priority Endpoint Correct Transfer interrupt's service
+* routine.
+* Input : None.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+void CTR_HP(void)
+{
+ u32 wEPVal = 0;
+
+ while (((wIstr = _GetISTR()) & ISTR_CTR) != 0)
+ {
+ _SetISTR((u16)CLR_CTR); /* clear CTR flag */
+ /* extract highest priority endpoint number */
+ EPindex = (u8)(wIstr & ISTR_EP_ID);
+ /* process related endpoint register */
+ wEPVal = _GetENDPOINT(EPindex);
+ if ((wEPVal & EP_CTR_RX) != 0)
+ {
+ /* clear int flag */
+ _ClearEP_CTR_RX(EPindex);
+
+ /* call OUT service function */
+ (*pEpInt_OUT[EPindex-1])();
+
+ } /* if((wEPVal & EP_CTR_RX) */
+ else if ((wEPVal & EP_CTR_TX) != 0)
+ {
+ /* clear int flag */
+ _ClearEP_CTR_TX(EPindex);
+
+ /* call IN service function */
+ (*pEpInt_IN[EPindex-1])();
+
+
+ } /* if((wEPVal & EP_CTR_TX) != 0) */
+
+ }/* while(...) */
+}
+
+/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
diff --git a/libmaple/usb/usb_lib/usb_int.h b/libmaple/usb/usb_lib/usb_int.h
index 10a33fb..5c14711 100644
--- a/libmaple/usb/usb_lib/usb_int.h
+++ b/libmaple/usb/usb_lib/usb_int.h
@@ -1,41 +1,41 @@
-/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
-* File Name : usb_int.h
-* Author : MCD Application Team
-* Version : V2.2.1
-* Date : 09/22/2008
-* Description : Endpoint CTR (Low and High) interrupt's service routines
-* prototypes
-********************************************************************************
-* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
-* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
-* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
-* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
-* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
-* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
-*******************************************************************************/
-
-/* Define to prevent recursive inclusion -------------------------------------*/
-#ifndef __USB_INT_H
-#define __USB_INT_H
-
-/* Includes ------------------------------------------------------------------*/
-/* Exported types ------------------------------------------------------------*/
-/* Exported constants --------------------------------------------------------*/
-/* Exported macro ------------------------------------------------------------*/
-/* Exported functions ------------------------------------------------------- */
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
-void CTR_LP(void);
-void CTR_HP(void);
-
-/* External variables --------------------------------------------------------*/
-
-#if defined(__cplusplus)
-}
-#endif
-
-#endif /* __USB_INT_H */
-
-/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
+/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
+* File Name : usb_int.h
+* Author : MCD Application Team
+* Version : V2.2.1
+* Date : 09/22/2008
+* Description : Endpoint CTR (Low and High) interrupt's service routines
+* prototypes
+********************************************************************************
+* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
+* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
+* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
+* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
+* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+*******************************************************************************/
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __USB_INT_H
+#define __USB_INT_H
+
+/* Includes ------------------------------------------------------------------*/
+/* Exported types ------------------------------------------------------------*/
+/* Exported constants --------------------------------------------------------*/
+/* Exported macro ------------------------------------------------------------*/
+/* Exported functions ------------------------------------------------------- */
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+void CTR_LP(void);
+void CTR_HP(void);
+
+/* External variables --------------------------------------------------------*/
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif /* __USB_INT_H */
+
+/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
diff --git a/libmaple/usb/usb_lib/usb_lib.h b/libmaple/usb/usb_lib/usb_lib.h
index 5d14b5a..4437b8d 100644
--- a/libmaple/usb/usb_lib/usb_lib.h
+++ b/libmaple/usb/usb_lib/usb_lib.h
@@ -1,37 +1,37 @@
-/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
-* File Name : usb_lib.h
-* Author : MCD Application Team
-* Version : V2.2.1
-* Date : 09/22/2008
-* Description : USB library include files
-********************************************************************************
-* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
-* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
-* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
-* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
-* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
-* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
-*******************************************************************************/
-
-/* Define to prevent recursive inclusion -------------------------------------*/
-#ifndef __USB_LIB_H
-#define __USB_LIB_H
-
-/* Includes ------------------------------------------------------------------*/
-#include "usb_type.h"
-#include "usb_regs.h"
-#include "usb_def.h"
-#include "usb_core.h"
-#include "usb_init.h"
-#include "usb_mem.h"
-#include "usb_int.h"
-
-/* Exported types ------------------------------------------------------------*/
-/* Exported constants --------------------------------------------------------*/
-/* Exported macro ------------------------------------------------------------*/
-/* Exported functions ------------------------------------------------------- */
-/* External variables --------------------------------------------------------*/
-
-#endif /* __USB_LIB_H */
-
-/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
+/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
+* File Name : usb_lib.h
+* Author : MCD Application Team
+* Version : V2.2.1
+* Date : 09/22/2008
+* Description : USB library include files
+********************************************************************************
+* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
+* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
+* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
+* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
+* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+*******************************************************************************/
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __USB_LIB_H
+#define __USB_LIB_H
+
+/* Includes ------------------------------------------------------------------*/
+#include "usb_type.h"
+#include "usb_regs.h"
+#include "usb_def.h"
+#include "usb_core.h"
+#include "usb_init.h"
+#include "usb_mem.h"
+#include "usb_int.h"
+
+/* Exported types ------------------------------------------------------------*/
+/* Exported constants --------------------------------------------------------*/
+/* Exported macro ------------------------------------------------------------*/
+/* Exported functions ------------------------------------------------------- */
+/* External variables --------------------------------------------------------*/
+
+#endif /* __USB_LIB_H */
+
+/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
diff --git a/libmaple/usb/usb_lib/usb_mem.c b/libmaple/usb/usb_lib/usb_mem.c
index 90ffc62..ad9740a 100644
--- a/libmaple/usb/usb_lib/usb_mem.c
+++ b/libmaple/usb/usb_lib/usb_mem.c
@@ -1,73 +1,73 @@
-/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
-* File Name : usb_mem.c
-* Author : MCD Application Team
-* Version : V2.2.1
-* Date : 09/22/2008
-* Description : Utility functions for memory transfers to/from PMA
-********************************************************************************
-* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
-* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
-* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
-* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
-* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
-* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
-*******************************************************************************/
-
-/* Includes ------------------------------------------------------------------*/
-#include "usb_lib.h"
-
-/* Private typedef -----------------------------------------------------------*/
-/* Private define ------------------------------------------------------------*/
-/* Private macro -------------------------------------------------------------*/
-/* Private variables ---------------------------------------------------------*/
-/* Extern variables ----------------------------------------------------------*/
-/* Private function prototypes -----------------------------------------------*/
-/* Private functions ---------------------------------------------------------*/
-/*******************************************************************************
-* Function Name : UserToPMABufferCopy
-* Description : Copy a buffer from user memory area to packet memory area (PMA)
-* Input : - pbUsrBuf: pointer to user memory area.
-* - wPMABufAddr: address into PMA.
-* - wNBytes: no. of bytes to be copied.
-* Output : None.
-* Return : None .
-*******************************************************************************/
-void UserToPMABufferCopy(const u8 *pbUsrBuf, u16 wPMABufAddr, u16 wNBytes)
-{
- u32 n = (wNBytes + 1) >> 1; /* n = (wNBytes + 1) / 2 */
- u32 i, temp1, temp2;
- u16 *pdwVal;
- pdwVal = (u16 *)(wPMABufAddr * 2 + PMAAddr);
- for (i = n; i != 0; i--)
- {
- temp1 = (u16) * pbUsrBuf;
- pbUsrBuf++;
- temp2 = temp1 | (u16) * pbUsrBuf << 8;
- *pdwVal++ = temp2;
- pdwVal++;
- pbUsrBuf++;
- }
-}
-/*******************************************************************************
-* Function Name : PMAToUserBufferCopy
-* Description : Copy a buffer from user memory area to packet memory area (PMA)
-* Input : - pbUsrBuf = pointer to user memory area.
-* - wPMABufAddr = address into PMA.
-* - wNBytes = no. of bytes to be copied.
-* Output : None.
-* Return : None.
-*******************************************************************************/
-void PMAToUserBufferCopy(u8 *pbUsrBuf, u16 wPMABufAddr, u16 wNBytes)
-{
- u32 n = (wNBytes + 1) >> 1;/* /2*/
- u32 i;
- u32 *pdwVal;
- pdwVal = (u32 *)(wPMABufAddr * 2 + PMAAddr);
- for (i = n; i != 0; i--)
- {
- *(u16*)pbUsrBuf++ = *pdwVal++;
- pbUsrBuf++;
- }
-}
-
-/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
+/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
+* File Name : usb_mem.c
+* Author : MCD Application Team
+* Version : V2.2.1
+* Date : 09/22/2008
+* Description : Utility functions for memory transfers to/from PMA
+********************************************************************************
+* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
+* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
+* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
+* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
+* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+*******************************************************************************/
+
+/* Includes ------------------------------------------------------------------*/
+#include "usb_lib.h"
+
+/* Private typedef -----------------------------------------------------------*/
+/* Private define ------------------------------------------------------------*/
+/* Private macro -------------------------------------------------------------*/
+/* Private variables ---------------------------------------------------------*/
+/* Extern variables ----------------------------------------------------------*/
+/* Private function prototypes -----------------------------------------------*/
+/* Private functions ---------------------------------------------------------*/
+/*******************************************************************************
+* Function Name : UserToPMABufferCopy
+* Description : Copy a buffer from user memory area to packet memory area (PMA)
+* Input : - pbUsrBuf: pointer to user memory area.
+* - wPMABufAddr: address into PMA.
+* - wNBytes: no. of bytes to be copied.
+* Output : None.
+* Return : None .
+*******************************************************************************/
+void UserToPMABufferCopy(const u8 *pbUsrBuf, u16 wPMABufAddr, u16 wNBytes)
+{
+ u32 n = (wNBytes + 1) >> 1; /* n = (wNBytes + 1) / 2 */
+ u32 i, temp1, temp2;
+ u16 *pdwVal;
+ pdwVal = (u16 *)(wPMABufAddr * 2 + PMAAddr);
+ for (i = n; i != 0; i--)
+ {
+ temp1 = (u16) * pbUsrBuf;
+ pbUsrBuf++;
+ temp2 = temp1 | (u16) * pbUsrBuf << 8;
+ *pdwVal++ = temp2;
+ pdwVal++;
+ pbUsrBuf++;
+ }
+}
+/*******************************************************************************
+* Function Name : PMAToUserBufferCopy
+* Description : Copy a buffer from user memory area to packet memory area (PMA)
+* Input : - pbUsrBuf = pointer to user memory area.
+* - wPMABufAddr = address into PMA.
+* - wNBytes = no. of bytes to be copied.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+void PMAToUserBufferCopy(u8 *pbUsrBuf, u16 wPMABufAddr, u16 wNBytes)
+{
+ u32 n = (wNBytes + 1) >> 1;/* /2*/
+ u32 i;
+ u32 *pdwVal;
+ pdwVal = (u32 *)(wPMABufAddr * 2 + PMAAddr);
+ for (i = n; i != 0; i--)
+ {
+ *(u16*)pbUsrBuf++ = *pdwVal++;
+ pbUsrBuf++;
+ }
+}
+
+/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
diff --git a/libmaple/usb/usb_lib/usb_mem.h b/libmaple/usb/usb_lib/usb_mem.h
index 60ff9f1..b0e0474 100644
--- a/libmaple/usb/usb_lib/usb_mem.h
+++ b/libmaple/usb/usb_lib/usb_mem.h
@@ -1,40 +1,40 @@
-/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
-* File Name : usb_mem.h
-* Author : MCD Application Team
-* Version : V2.2.1
-* Date : 09/22/2008
-* Description : Utility prototypes functions for memory/PMA transfers
-********************************************************************************
-* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
-* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
-* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
-* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
-* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
-* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
-*******************************************************************************/
-
-/* Define to prevent recursive inclusion -------------------------------------*/
-#ifndef __USB_MEM_H
-#define __USB_MEM_H
-
-/* Includes ------------------------------------------------------------------*/
-/* Exported types ------------------------------------------------------------*/
-/* Exported constants --------------------------------------------------------*/
-/* Exported macro ------------------------------------------------------------*/
-/* Exported functions ------------------------------------------------------- */
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
-void UserToPMABufferCopy(const u8 *pbUsrBuf, u16 wPMABufAddr, u16 wNBytes);
-void PMAToUserBufferCopy(u8 *pbUsrBuf, u16 wPMABufAddr, u16 wNBytes);
-
-#if defined(__cplusplus)
-}
-#endif
-
-/* External variables --------------------------------------------------------*/
-
-#endif /*__USB_MEM_H*/
-
-/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
+/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
+* File Name : usb_mem.h
+* Author : MCD Application Team
+* Version : V2.2.1
+* Date : 09/22/2008
+* Description : Utility prototypes functions for memory/PMA transfers
+********************************************************************************
+* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
+* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
+* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
+* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
+* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+*******************************************************************************/
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __USB_MEM_H
+#define __USB_MEM_H
+
+/* Includes ------------------------------------------------------------------*/
+/* Exported types ------------------------------------------------------------*/
+/* Exported constants --------------------------------------------------------*/
+/* Exported macro ------------------------------------------------------------*/
+/* Exported functions ------------------------------------------------------- */
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+void UserToPMABufferCopy(const u8 *pbUsrBuf, u16 wPMABufAddr, u16 wNBytes);
+void PMAToUserBufferCopy(u8 *pbUsrBuf, u16 wPMABufAddr, u16 wNBytes);
+
+#if defined(__cplusplus)
+}
+#endif
+
+/* External variables --------------------------------------------------------*/
+
+#endif /*__USB_MEM_H*/
+
+/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
diff --git a/libmaple/usb/usb_lib/usb_regs.c b/libmaple/usb/usb_lib/usb_regs.c
index c28ef5a..c7e0276 100644
--- a/libmaple/usb/usb_lib/usb_regs.c
+++ b/libmaple/usb/usb_lib/usb_regs.c
@@ -1,748 +1,748 @@
-/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
-* File Name : usb_regs.c
-* Author : MCD Application Team
-* Version : V2.2.1
-* Date : 09/22/2008
-* Description : Interface functions to USB cell registers
-********************************************************************************
-* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
-* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
-* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
-* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
-* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
-* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
-*******************************************************************************/
-
-/* Includes ------------------------------------------------------------------*/
-#include "usb_lib.h"
-
-/* Private typedef -----------------------------------------------------------*/
-/* Private define ------------------------------------------------------------*/
-/* Private macro -------------------------------------------------------------*/
-/* Private variables ---------------------------------------------------------*/
-/* Extern variables ----------------------------------------------------------*/
-/* Private function prototypes -----------------------------------------------*/
-/* Private functions ---------------------------------------------------------*/
-
-/*******************************************************************************
-* Function Name : SetCNTR.
-* Description : Set the CNTR register value.
-* Input : wRegValue: new register value.
-* Output : None.
-* Return : None.
-*******************************************************************************/
-void SetCNTR(u16 wRegValue)
-{
- _SetCNTR(wRegValue);
-}
-
-/*******************************************************************************
-* Function Name : GetCNTR.
-* Description : returns the CNTR register value.
-* Input : None.
-* Output : None.
-* Return : CNTR register Value.
-*******************************************************************************/
-u16 GetCNTR(void)
-{
- return(_GetCNTR());
-}
-
-/*******************************************************************************
-* Function Name : SetISTR.
-* Description : Set the ISTR register value.
-* Input : wRegValue: new register value.
-* Output : None.
-* Return : None.
-*******************************************************************************/
-void SetISTR(u16 wRegValue)
-{
- _SetISTR(wRegValue);
-}
-
-/*******************************************************************************
-* Function Name : GetISTR
-* Description : Returns the ISTR register value.
-* Input : None.
-* Output : None.
-* Return : ISTR register Value
-*******************************************************************************/
-u16 GetISTR(void)
-{
- return(_GetISTR());
-}
-
-/*******************************************************************************
-* Function Name : GetFNR
-* Description : Returns the FNR register value.
-* Input : None.
-* Output : None.
-* Return : FNR register Value
-*******************************************************************************/
-u16 GetFNR(void)
-{
- return(_GetFNR());
-}
-
-/*******************************************************************************
-* Function Name : SetDADDR
-* Description : Set the DADDR register value.
-* Input : wRegValue: new register value.
-* Output : None.
-* Return : None.
-*******************************************************************************/
-void SetDADDR(u16 wRegValue)
-{
- _SetDADDR(wRegValue);
-}
-
-/*******************************************************************************
-* Function Name : GetDADDR
-* Description : Returns the DADDR register value.
-* Input : None.
-* Output : None.
-* Return : DADDR register Value
-*******************************************************************************/
-u16 GetDADDR(void)
-{
- return(_GetDADDR());
-}
-
-/*******************************************************************************
-* Function Name : SetBTABLE
-* Description : Set the BTABLE.
-* Input : wRegValue: New register value.
-* Output : None.
-* Return : None.
-*******************************************************************************/
-void SetBTABLE(u16 wRegValue)
-{
- _SetBTABLE(wRegValue);
-}
-
-/*******************************************************************************
-* Function Name : GetBTABLE.
-* Description : Returns the BTABLE register value.
-* Input : None.
-* Output : None.
-* Return : BTABLE address.
-*******************************************************************************/
-u16 GetBTABLE(void)
-{
- return(_GetBTABLE());
-}
-
-/*******************************************************************************
-* Function Name : SetENDPOINT
-* Description : Setthe Endpoint register value.
-* Input : bEpNum: Endpoint Number.
-* wRegValue.
-* Output : None.
-* Return : None.
-*******************************************************************************/
-void SetENDPOINT(u8 bEpNum, u16 wRegValue)
-{
- _SetENDPOINT(bEpNum, wRegValue);
-}
-
-/*******************************************************************************
-* Function Name : GetENDPOINT
-* Description : Return the Endpoint register value.
-* Input : bEpNum: Endpoint Number.
-* Output : None.
-* Return : Endpoint register value.
-*******************************************************************************/
-u16 GetENDPOINT(u8 bEpNum)
-{
- return(_GetENDPOINT(bEpNum));
-}
-
-/*******************************************************************************
-* Function Name : SetEPType
-* Description : sets the type in the endpoint register.
-* Input : bEpNum: Endpoint Number.
-* wType: type definition.
-* Output : None.
-* Return : None.
-*******************************************************************************/
-void SetEPType(u8 bEpNum, u16 wType)
-{
- _SetEPType(bEpNum, wType);
-}
-
-/*******************************************************************************
-* Function Name : GetEPType
-* Description : Returns the endpoint type.
-* Input : bEpNum: Endpoint Number.
-* Output : None.
-* Return : Endpoint Type
-*******************************************************************************/
-u16 GetEPType(u8 bEpNum)
-{
- return(_GetEPType(bEpNum));
-}
-
-/*******************************************************************************
-* Function Name : SetEPTxStatus
-* Description : Set the status of Tx endpoint.
-* Input : bEpNum: Endpoint Number.
-* wState: new state.
-* Output : None.
-* Return : None.
-*******************************************************************************/
-void SetEPTxStatus(u8 bEpNum, u16 wState)
-{
- _SetEPTxStatus(bEpNum, wState);
-}
-
-/*******************************************************************************
-* Function Name : SetEPRxStatus
-* Description : Set the status of Rx endpoint.
-* Input : bEpNum: Endpoint Number.
-* wState: new state.
-* Output : None.
-* Return : None.
-*******************************************************************************/
-void SetEPRxStatus(u8 bEpNum, u16 wState)
-{
- _SetEPRxStatus(bEpNum, wState);
-}
-
-/*******************************************************************************
-* Function Name : SetDouBleBuffEPStall
-* Description : sets the status for Double Buffer Endpoint to STALL
-* Input : bEpNum: Endpoint Number.
-* bDir: Endpoint direction.
-* Output : None.
-* Return : None.
-*******************************************************************************/
-void SetDouBleBuffEPStall(u8 bEpNum, u8 bDir)
-{
- u16 Endpoint_DTOG_Status;
- Endpoint_DTOG_Status = GetENDPOINT(bEpNum);
- if (bDir == EP_DBUF_OUT)
- { /* OUT double buffered endpoint */
- _SetENDPOINT(bEpNum, Endpoint_DTOG_Status & ~EPRX_DTOG1);
- }
- else if (bDir == EP_DBUF_IN)
- { /* IN double buffered endpoint */
- _SetENDPOINT(bEpNum, Endpoint_DTOG_Status & ~EPTX_DTOG1);
- }
-}
-
-/*******************************************************************************
-* Function Name : GetEPTxStatus
-* Description : Returns the endpoint Tx status.
-* Input : bEpNum: Endpoint Number.
-* Output : None.
-* Return : Endpoint TX Status
-*******************************************************************************/
-u16 GetEPTxStatus(u8 bEpNum)
-{
- return(_GetEPTxStatus(bEpNum));
-}
-
-/*******************************************************************************
-* Function Name : GetEPRxStatus
-* Description : Returns the endpoint Rx status.
-* Input : bEpNum: Endpoint Number.
-* Output : None.
-* Return : Endpoint RX Status
-*******************************************************************************/
-u16 GetEPRxStatus(u8 bEpNum)
-{
- return(_GetEPRxStatus(bEpNum));
-}
-
-/*******************************************************************************
-* Function Name : SetEPTxValid
-* Description : Valid the endpoint Tx Status.
-* Input : bEpNum: Endpoint Number.
-* Output : None.
-* Return : None.
-*******************************************************************************/
-void SetEPTxValid(u8 bEpNum)
-{
- _SetEPTxStatus(bEpNum, EP_TX_VALID);
-}
-
-/*******************************************************************************
-* Function Name : SetEPRxValid
-* Description : Valid the endpoint Rx Status.
-* Input : bEpNum: Endpoint Number.
-* Output : None.
-* Return : None.
-*******************************************************************************/
-void SetEPRxValid(u8 bEpNum)
-{
- _SetEPRxStatus(bEpNum, EP_RX_VALID);
-}
-
-/*******************************************************************************
-* Function Name : SetEP_KIND
-* Description : Clear the EP_KIND bit.
-* Input : bEpNum: Endpoint Number.
-* Output : None.
-* Return : None.
-*******************************************************************************/
-void SetEP_KIND(u8 bEpNum)
-{
- _SetEP_KIND(bEpNum);
-}
-
-/*******************************************************************************
-* Function Name : ClearEP_KIND
-* Description : set the EP_KIND bit.
-* Input : bEpNum: Endpoint Number.
-* Output : None.
-* Return : None.
-*******************************************************************************/
-void ClearEP_KIND(u8 bEpNum)
-{
- _ClearEP_KIND(bEpNum);
-}
-/*******************************************************************************
-* Function Name : Clear_Status_Out
-* Description : Clear the Status Out of the related Endpoint
-* Input : bEpNum: Endpoint Number.
-* Output : None.
-* Return : None.
-*******************************************************************************/
-void Clear_Status_Out(u8 bEpNum)
-{
- _ClearEP_KIND(bEpNum);
-}
-/*******************************************************************************
-* Function Name : Set_Status_Out
-* Description : Set the Status Out of the related Endpoint
-* Input : bEpNum: Endpoint Number.
-* Output : None.
-* Return : None.
-*******************************************************************************/
-void Set_Status_Out(u8 bEpNum)
-{
- _SetEP_KIND(bEpNum);
-}
-/*******************************************************************************
-* Function Name : SetEPDoubleBuff
-* Description : Enable the double buffer feature for the endpoint.
-* Input : bEpNum: Endpoint Number.
-* Output : None.
-* Return : None.
-*******************************************************************************/
-void SetEPDoubleBuff(u8 bEpNum)
-{
- _SetEP_KIND(bEpNum);
-}
-/*******************************************************************************
-* Function Name : ClearEPDoubleBuff
-* Description : Disable the double buffer feature for the endpoint.
-* Input : bEpNum: Endpoint Number.
-* Output : None.
-* Return : None.
-*******************************************************************************/
-void ClearEPDoubleBuff(u8 bEpNum)
-{
- _ClearEP_KIND(bEpNum);
-}
-/*******************************************************************************
-* Function Name : GetTxStallStatus
-* Description : Returns the Stall status of the Tx endpoint.
-* Input : bEpNum: Endpoint Number.
-* Output : None.
-* Return : Tx Stall status.
-*******************************************************************************/
-u16 GetTxStallStatus(u8 bEpNum)
-{
- return(_GetTxStallStatus(bEpNum));
-}
-/*******************************************************************************
-* Function Name : GetRxStallStatus
-* Description : Returns the Stall status of the Rx endpoint.
-* Input : bEpNum: Endpoint Number.
-* Output : None.
-* Return : Rx Stall status.
-*******************************************************************************/
-u16 GetRxStallStatus(u8 bEpNum)
-{
- return(_GetRxStallStatus(bEpNum));
-}
-/*******************************************************************************
-* Function Name : ClearEP_CTR_RX
-* Description : Clear the CTR_RX bit.
-* Input : bEpNum: Endpoint Number.
-* Output : None.
-* Return : None.
-*******************************************************************************/
-void ClearEP_CTR_RX(u8 bEpNum)
-{
- _ClearEP_CTR_RX(bEpNum);
-}
-/*******************************************************************************
-* Function Name : ClearEP_CTR_TX
-* Description : Clear the CTR_TX bit.
-* Input : bEpNum: Endpoint Number.
-* Output : None.
-* Return : None.
-*******************************************************************************/
-void ClearEP_CTR_TX(u8 bEpNum)
-{
- _ClearEP_CTR_TX(bEpNum);
-}
-/*******************************************************************************
-* Function Name : ToggleDTOG_RX
-* Description : Toggle the DTOG_RX bit.
-* Input : bEpNum: Endpoint Number.
-* Output : None.
-* Return : None.
-*******************************************************************************/
-void ToggleDTOG_RX(u8 bEpNum)
-{
- _ToggleDTOG_RX(bEpNum);
-}
-/*******************************************************************************
-* Function Name : ToggleDTOG_TX
-* Description : Toggle the DTOG_TX bit.
-* Input : bEpNum: Endpoint Number.
-* Output : None.
-* Return : None.
-*******************************************************************************/
-void ToggleDTOG_TX(u8 bEpNum)
-{
- _ToggleDTOG_TX(bEpNum);
-}
-/*******************************************************************************
-* Function Name : ClearDTOG_RX.
-* Description : Clear the DTOG_RX bit.
-* Input : bEpNum: Endpoint Number.
-* Output : None.
-* Return : None.
-*******************************************************************************/
-void ClearDTOG_RX(u8 bEpNum)
-{
- _ClearDTOG_RX(bEpNum);
-}
-/*******************************************************************************
-* Function Name : ClearDTOG_TX.
-* Description : Clear the DTOG_TX bit.
-* Input : bEpNum: Endpoint Number.
-* Output : None.
-* Return : None.
-*******************************************************************************/
-void ClearDTOG_TX(u8 bEpNum)
-{
- _ClearDTOG_TX(bEpNum);
-}
-/*******************************************************************************
-* Function Name : SetEPAddress
-* Description : Set the endpoint address.
-* Input : bEpNum: Endpoint Number.
-* bAddr: New endpoint address.
-* Output : None.
-* Return : None.
-*******************************************************************************/
-void SetEPAddress(u8 bEpNum, u8 bAddr)
-{
- _SetEPAddress(bEpNum, bAddr);
-}
-/*******************************************************************************
-* Function Name : GetEPAddress
-* Description : Get the endpoint address.
-* Input : bEpNum: Endpoint Number.
-* Output : None.
-* Return : Endpoint address.
-*******************************************************************************/
-u8 GetEPAddress(u8 bEpNum)
-{
- return(_GetEPAddress(bEpNum));
-}
-/*******************************************************************************
-* Function Name : SetEPTxAddr
-* Description : Set the endpoint Tx buffer address.
-* Input : bEpNum: Endpoint Number.
-* wAddr: new address.
-* Output : None.
-* Return : None.
-*******************************************************************************/
-void SetEPTxAddr(u8 bEpNum, u16 wAddr)
-{
- _SetEPTxAddr(bEpNum, wAddr);
-}
-/*******************************************************************************
-* Function Name : SetEPRxAddr
-* Description : Set the endpoint Rx buffer address.
-* Input : bEpNum: Endpoint Number.
-* wAddr: new address.
-* Output : None.
-* Return : None.
-*******************************************************************************/
-void SetEPRxAddr(u8 bEpNum, u16 wAddr)
-{
- _SetEPRxAddr(bEpNum, wAddr);
-}
-/*******************************************************************************
-* Function Name : GetEPTxAddr
-* Description : Returns the endpoint Tx buffer address.
-* Input : bEpNum: Endpoint Number.
-* Output : None.
-* Return : Rx buffer address.
-*******************************************************************************/
-u16 GetEPTxAddr(u8 bEpNum)
-{
- return(_GetEPTxAddr(bEpNum));
-}
-/*******************************************************************************
-* Function Name : GetEPRxAddr.
-* Description : Returns the endpoint Rx buffer address.
-* Input : bEpNum: Endpoint Number.
-* Output : None.
-* Return : Rx buffer address.
-*******************************************************************************/
-u16 GetEPRxAddr(u8 bEpNum)
-{
- return(_GetEPRxAddr(bEpNum));
-}
-/*******************************************************************************
-* Function Name : SetEPTxCount.
-* Description : Set the Tx count.
-* Input : bEpNum: Endpoint Number.
-* wCount: new count value.
-* Output : None.
-* Return : None.
-*******************************************************************************/
-void SetEPTxCount(u8 bEpNum, u16 wCount)
-{
- _SetEPTxCount(bEpNum, wCount);
-}
-/*******************************************************************************
-* Function Name : SetEPCountRxReg.
-* Description : Set the Count Rx Register value.
-* Input : *pdwReg: point to the register.
-* wCount: the new register value.
-* Output : None.
-* Return : None.
-*******************************************************************************/
-void SetEPCountRxReg(u32 *pdwReg, u16 wCount)
-{
- _SetEPCountRxReg(dwReg, wCount);
-}
-/*******************************************************************************
-* Function Name : SetEPRxCount
-* Description : Set the Rx count.
-* Input : bEpNum: Endpoint Number.
-* wCount: the new count value.
-* Output : None.
-* Return : None.
-*******************************************************************************/
-void SetEPRxCount(u8 bEpNum, u16 wCount)
-{
- _SetEPRxCount(bEpNum, wCount);
-}
-/*******************************************************************************
-* Function Name : GetEPTxCount
-* Description : Get the Tx count.
-* Input : bEpNum: Endpoint Number.
-* Output : None
-* Return : Tx count value.
-*******************************************************************************/
-u16 GetEPTxCount(u8 bEpNum)
-{
- return(_GetEPTxCount(bEpNum));
-}
-/*******************************************************************************
-* Function Name : GetEPRxCount
-* Description : Get the Rx count.
-* Input : bEpNum: Endpoint Number.
-* Output : None.
-* Return : Rx count value.
-*******************************************************************************/
-u16 GetEPRxCount(u8 bEpNum)
-{
- return(_GetEPRxCount(bEpNum));
-}
-/*******************************************************************************
-* Function Name : SetEPDblBuffAddr
-* Description : Set the addresses of the buffer 0 and 1.
-* Input : bEpNum: Endpoint Number.
-* wBuf0Addr: new address of buffer 0.
-* wBuf1Addr: new address of buffer 1.
-* Output : None.
-* Return : None.
-*******************************************************************************/
-void SetEPDblBuffAddr(u8 bEpNum, u16 wBuf0Addr, u16 wBuf1Addr)
-{
- _SetEPDblBuffAddr(bEpNum, wBuf0Addr, wBuf1Addr);
-}
-/*******************************************************************************
-* Function Name : SetEPDblBuf0Addr
-* Description : Set the Buffer 1 address.
-* Input : bEpNum: Endpoint Number
-* wBuf0Addr: new address.
-* Output : None.
-* Return : None.
-*******************************************************************************/
-void SetEPDblBuf0Addr(u8 bEpNum, u16 wBuf0Addr)
-{
- _SetEPDblBuf0Addr(bEpNum, wBuf0Addr);
-}
-/*******************************************************************************
-* Function Name : SetEPDblBuf1Addr
-* Description : Set the Buffer 1 address.
-* Input : bEpNum: Endpoint Number
-* wBuf1Addr: new address.
-* Output : None.
-* Return : None.
-*******************************************************************************/
-void SetEPDblBuf1Addr(u8 bEpNum, u16 wBuf1Addr)
-{
- _SetEPDblBuf1Addr(bEpNum, wBuf1Addr);
-}
-/*******************************************************************************
-* Function Name : GetEPDblBuf0Addr
-* Description : Returns the address of the Buffer 0.
-* Input : bEpNum: Endpoint Number.
-* Output : None.
-* Return : None.
-*******************************************************************************/
-u16 GetEPDblBuf0Addr(u8 bEpNum)
-{
- return(_GetEPDblBuf0Addr(bEpNum));
-}
-/*******************************************************************************
-* Function Name : GetEPDblBuf1Addr
-* Description : Returns the address of the Buffer 1.
-* Input : bEpNum: Endpoint Number.
-* Output : None.
-* Return : Address of the Buffer 1.
-*******************************************************************************/
-u16 GetEPDblBuf1Addr(u8 bEpNum)
-{
- return(_GetEPDblBuf1Addr(bEpNum));
-}
-/*******************************************************************************
-* Function Name : SetEPDblBuffCount
-* Description : Set the number of bytes for a double Buffer
-* endpoint.
-* Input : bEpNum,bDir, wCount
-* Output : None.
-* Return : None.
-*******************************************************************************/
-void SetEPDblBuffCount(u8 bEpNum, u8 bDir, u16 wCount)
-{
- _SetEPDblBuffCount(bEpNum, bDir, wCount);
-}
-/*******************************************************************************
-* Function Name : SetEPDblBuf0Count
-* Description : Set the number of bytes in the buffer 0 of a double Buffer
-* endpoint.
-* Input : bEpNum, bDir, wCount
-* Output : None.
-* Return : None.
-*******************************************************************************/
-void SetEPDblBuf0Count(u8 bEpNum, u8 bDir, u16 wCount)
-{
- _SetEPDblBuf0Count(bEpNum, bDir, wCount);
-}
-/*******************************************************************************
-* Function Name : SetEPDblBuf1Count
-* Description : Set the number of bytes in the buffer 0 of a double Buffer
-* endpoint.
-* Input : bEpNum, bDir, wCount
-* Output : None.
-* Return : None.
-*******************************************************************************/
-void SetEPDblBuf1Count(u8 bEpNum, u8 bDir, u16 wCount)
-{
- _SetEPDblBuf1Count(bEpNum, bDir, wCount);
-}
-/*******************************************************************************
-* Function Name : GetEPDblBuf0Count
-* Description : Returns the number of byte received in the buffer 0 of a double
-* Buffer endpoint.
-* Input : bEpNum: Endpoint Number.
-* Output : None.
-* Return : Endpoint Buffer 0 count
-*******************************************************************************/
-u16 GetEPDblBuf0Count(u8 bEpNum)
-{
- return(_GetEPDblBuf0Count(bEpNum));
-}
-/*******************************************************************************
-* Function Name : GetEPDblBuf1Count
-* Description : Returns the number of data received in the buffer 1 of a double
-* Buffer endpoint.
-* Input : bEpNum: Endpoint Number.
-* Output : None.
-* Return : Endpoint Buffer 1 count.
-*******************************************************************************/
-u16 GetEPDblBuf1Count(u8 bEpNum)
-{
- return(_GetEPDblBuf1Count(bEpNum));
-}
-/*******************************************************************************
-* Function Name : GetEPDblBufDir
-* Description : gets direction of the double buffered endpoint
-* Input : bEpNum: Endpoint Number.
-* Output : None.
-* Return : EP_DBUF_OUT, EP_DBUF_IN,
-* EP_DBUF_ERR if the endpoint counter not yet programmed.
-*******************************************************************************/
-EP_DBUF_DIR GetEPDblBufDir(u8 bEpNum)
-{
- if ((u16)(*_pEPRxCount(bEpNum) & 0xFC00) != 0)
- return(EP_DBUF_OUT);
- else if (((u16)(*_pEPTxCount(bEpNum)) & 0x03FF) != 0)
- return(EP_DBUF_IN);
- else
- return(EP_DBUF_ERR);
-}
-/*******************************************************************************
-* Function Name : FreeUserBuffer
-* Description : free buffer used from the application realizing it to the line
- toggles bit SW_BUF in the double buffered endpoint register
-* Input : bEpNum, bDir
-* Output : None.
-* Return : None.
-*******************************************************************************/
-void FreeUserBuffer(u8 bEpNum, u8 bDir)
-{
- if (bDir == EP_DBUF_OUT)
- { /* OUT double buffered endpoint */
- _ToggleDTOG_TX(bEpNum);
- }
- else if (bDir == EP_DBUF_IN)
- { /* IN double buffered endpoint */
- _ToggleDTOG_RX(bEpNum);
- }
-}
-
-/*******************************************************************************
-* Function Name : ToWord
-* Description : merge two byte in a word.
-* Input : bh: byte high, bl: bytes low.
-* Output : None.
-* Return : resulted word.
-*******************************************************************************/
-u16 ToWord(u8 bh, u8 bl)
-{
- u16 wRet;
- wRet = (u16)bl | ((u16)bh << 8);
- return(wRet);
-}
-/*******************************************************************************
-* Function Name : ByteSwap
-* Description : Swap two byte in a word.
-* Input : wSwW: word to Swap.
-* Output : None.
-* Return : resulted word.
-*******************************************************************************/
-u16 ByteSwap(u16 wSwW)
-{
- u8 bTemp;
- u16 wRet;
- bTemp = (u8)(wSwW & 0xff);
- wRet = (wSwW >> 8) | ((u16)bTemp << 8);
- return(wRet);
-}
-
-/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
+/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
+* File Name : usb_regs.c
+* Author : MCD Application Team
+* Version : V2.2.1
+* Date : 09/22/2008
+* Description : Interface functions to USB cell registers
+********************************************************************************
+* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
+* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
+* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
+* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
+* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+*******************************************************************************/
+
+/* Includes ------------------------------------------------------------------*/
+#include "usb_lib.h"
+
+/* Private typedef -----------------------------------------------------------*/
+/* Private define ------------------------------------------------------------*/
+/* Private macro -------------------------------------------------------------*/
+/* Private variables ---------------------------------------------------------*/
+/* Extern variables ----------------------------------------------------------*/
+/* Private function prototypes -----------------------------------------------*/
+/* Private functions ---------------------------------------------------------*/
+
+/*******************************************************************************
+* Function Name : SetCNTR.
+* Description : Set the CNTR register value.
+* Input : wRegValue: new register value.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+void SetCNTR(u16 wRegValue)
+{
+ _SetCNTR(wRegValue);
+}
+
+/*******************************************************************************
+* Function Name : GetCNTR.
+* Description : returns the CNTR register value.
+* Input : None.
+* Output : None.
+* Return : CNTR register Value.
+*******************************************************************************/
+u16 GetCNTR(void)
+{
+ return(_GetCNTR());
+}
+
+/*******************************************************************************
+* Function Name : SetISTR.
+* Description : Set the ISTR register value.
+* Input : wRegValue: new register value.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+void SetISTR(u16 wRegValue)
+{
+ _SetISTR(wRegValue);
+}
+
+/*******************************************************************************
+* Function Name : GetISTR
+* Description : Returns the ISTR register value.
+* Input : None.
+* Output : None.
+* Return : ISTR register Value
+*******************************************************************************/
+u16 GetISTR(void)
+{
+ return(_GetISTR());
+}
+
+/*******************************************************************************
+* Function Name : GetFNR
+* Description : Returns the FNR register value.
+* Input : None.
+* Output : None.
+* Return : FNR register Value
+*******************************************************************************/
+u16 GetFNR(void)
+{
+ return(_GetFNR());
+}
+
+/*******************************************************************************
+* Function Name : SetDADDR
+* Description : Set the DADDR register value.
+* Input : wRegValue: new register value.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+void SetDADDR(u16 wRegValue)
+{
+ _SetDADDR(wRegValue);
+}
+
+/*******************************************************************************
+* Function Name : GetDADDR
+* Description : Returns the DADDR register value.
+* Input : None.
+* Output : None.
+* Return : DADDR register Value
+*******************************************************************************/
+u16 GetDADDR(void)
+{
+ return(_GetDADDR());
+}
+
+/*******************************************************************************
+* Function Name : SetBTABLE
+* Description : Set the BTABLE.
+* Input : wRegValue: New register value.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+void SetBTABLE(u16 wRegValue)
+{
+ _SetBTABLE(wRegValue);
+}
+
+/*******************************************************************************
+* Function Name : GetBTABLE.
+* Description : Returns the BTABLE register value.
+* Input : None.
+* Output : None.
+* Return : BTABLE address.
+*******************************************************************************/
+u16 GetBTABLE(void)
+{
+ return(_GetBTABLE());
+}
+
+/*******************************************************************************
+* Function Name : SetENDPOINT
+* Description : Setthe Endpoint register value.
+* Input : bEpNum: Endpoint Number.
+* wRegValue.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+void SetENDPOINT(u8 bEpNum, u16 wRegValue)
+{
+ _SetENDPOINT(bEpNum, wRegValue);
+}
+
+/*******************************************************************************
+* Function Name : GetENDPOINT
+* Description : Return the Endpoint register value.
+* Input : bEpNum: Endpoint Number.
+* Output : None.
+* Return : Endpoint register value.
+*******************************************************************************/
+u16 GetENDPOINT(u8 bEpNum)
+{
+ return(_GetENDPOINT(bEpNum));
+}
+
+/*******************************************************************************
+* Function Name : SetEPType
+* Description : sets the type in the endpoint register.
+* Input : bEpNum: Endpoint Number.
+* wType: type definition.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+void SetEPType(u8 bEpNum, u16 wType)
+{
+ _SetEPType(bEpNum, wType);
+}
+
+/*******************************************************************************
+* Function Name : GetEPType
+* Description : Returns the endpoint type.
+* Input : bEpNum: Endpoint Number.
+* Output : None.
+* Return : Endpoint Type
+*******************************************************************************/
+u16 GetEPType(u8 bEpNum)
+{
+ return(_GetEPType(bEpNum));
+}
+
+/*******************************************************************************
+* Function Name : SetEPTxStatus
+* Description : Set the status of Tx endpoint.
+* Input : bEpNum: Endpoint Number.
+* wState: new state.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+void SetEPTxStatus(u8 bEpNum, u16 wState)
+{
+ _SetEPTxStatus(bEpNum, wState);
+}
+
+/*******************************************************************************
+* Function Name : SetEPRxStatus
+* Description : Set the status of Rx endpoint.
+* Input : bEpNum: Endpoint Number.
+* wState: new state.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+void SetEPRxStatus(u8 bEpNum, u16 wState)
+{
+ _SetEPRxStatus(bEpNum, wState);
+}
+
+/*******************************************************************************
+* Function Name : SetDouBleBuffEPStall
+* Description : sets the status for Double Buffer Endpoint to STALL
+* Input : bEpNum: Endpoint Number.
+* bDir: Endpoint direction.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+void SetDouBleBuffEPStall(u8 bEpNum, u8 bDir)
+{
+ u16 Endpoint_DTOG_Status;
+ Endpoint_DTOG_Status = GetENDPOINT(bEpNum);
+ if (bDir == EP_DBUF_OUT)
+ { /* OUT double buffered endpoint */
+ _SetENDPOINT(bEpNum, Endpoint_DTOG_Status & ~EPRX_DTOG1);
+ }
+ else if (bDir == EP_DBUF_IN)
+ { /* IN double buffered endpoint */
+ _SetENDPOINT(bEpNum, Endpoint_DTOG_Status & ~EPTX_DTOG1);
+ }
+}
+
+/*******************************************************************************
+* Function Name : GetEPTxStatus
+* Description : Returns the endpoint Tx status.
+* Input : bEpNum: Endpoint Number.
+* Output : None.
+* Return : Endpoint TX Status
+*******************************************************************************/
+u16 GetEPTxStatus(u8 bEpNum)
+{
+ return(_GetEPTxStatus(bEpNum));
+}
+
+/*******************************************************************************
+* Function Name : GetEPRxStatus
+* Description : Returns the endpoint Rx status.
+* Input : bEpNum: Endpoint Number.
+* Output : None.
+* Return : Endpoint RX Status
+*******************************************************************************/
+u16 GetEPRxStatus(u8 bEpNum)
+{
+ return(_GetEPRxStatus(bEpNum));
+}
+
+/*******************************************************************************
+* Function Name : SetEPTxValid
+* Description : Valid the endpoint Tx Status.
+* Input : bEpNum: Endpoint Number.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+void SetEPTxValid(u8 bEpNum)
+{
+ _SetEPTxStatus(bEpNum, EP_TX_VALID);
+}
+
+/*******************************************************************************
+* Function Name : SetEPRxValid
+* Description : Valid the endpoint Rx Status.
+* Input : bEpNum: Endpoint Number.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+void SetEPRxValid(u8 bEpNum)
+{
+ _SetEPRxStatus(bEpNum, EP_RX_VALID);
+}
+
+/*******************************************************************************
+* Function Name : SetEP_KIND
+* Description : Clear the EP_KIND bit.
+* Input : bEpNum: Endpoint Number.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+void SetEP_KIND(u8 bEpNum)
+{
+ _SetEP_KIND(bEpNum);
+}
+
+/*******************************************************************************
+* Function Name : ClearEP_KIND
+* Description : set the EP_KIND bit.
+* Input : bEpNum: Endpoint Number.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+void ClearEP_KIND(u8 bEpNum)
+{
+ _ClearEP_KIND(bEpNum);
+}
+/*******************************************************************************
+* Function Name : Clear_Status_Out
+* Description : Clear the Status Out of the related Endpoint
+* Input : bEpNum: Endpoint Number.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+void Clear_Status_Out(u8 bEpNum)
+{
+ _ClearEP_KIND(bEpNum);
+}
+/*******************************************************************************
+* Function Name : Set_Status_Out
+* Description : Set the Status Out of the related Endpoint
+* Input : bEpNum: Endpoint Number.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+void Set_Status_Out(u8 bEpNum)
+{
+ _SetEP_KIND(bEpNum);
+}
+/*******************************************************************************
+* Function Name : SetEPDoubleBuff
+* Description : Enable the double buffer feature for the endpoint.
+* Input : bEpNum: Endpoint Number.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+void SetEPDoubleBuff(u8 bEpNum)
+{
+ _SetEP_KIND(bEpNum);
+}
+/*******************************************************************************
+* Function Name : ClearEPDoubleBuff
+* Description : Disable the double buffer feature for the endpoint.
+* Input : bEpNum: Endpoint Number.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+void ClearEPDoubleBuff(u8 bEpNum)
+{
+ _ClearEP_KIND(bEpNum);
+}
+/*******************************************************************************
+* Function Name : GetTxStallStatus
+* Description : Returns the Stall status of the Tx endpoint.
+* Input : bEpNum: Endpoint Number.
+* Output : None.
+* Return : Tx Stall status.
+*******************************************************************************/
+u16 GetTxStallStatus(u8 bEpNum)
+{
+ return(_GetTxStallStatus(bEpNum));
+}
+/*******************************************************************************
+* Function Name : GetRxStallStatus
+* Description : Returns the Stall status of the Rx endpoint.
+* Input : bEpNum: Endpoint Number.
+* Output : None.
+* Return : Rx Stall status.
+*******************************************************************************/
+u16 GetRxStallStatus(u8 bEpNum)
+{
+ return(_GetRxStallStatus(bEpNum));
+}
+/*******************************************************************************
+* Function Name : ClearEP_CTR_RX
+* Description : Clear the CTR_RX bit.
+* Input : bEpNum: Endpoint Number.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+void ClearEP_CTR_RX(u8 bEpNum)
+{
+ _ClearEP_CTR_RX(bEpNum);
+}
+/*******************************************************************************
+* Function Name : ClearEP_CTR_TX
+* Description : Clear the CTR_TX bit.
+* Input : bEpNum: Endpoint Number.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+void ClearEP_CTR_TX(u8 bEpNum)
+{
+ _ClearEP_CTR_TX(bEpNum);
+}
+/*******************************************************************************
+* Function Name : ToggleDTOG_RX
+* Description : Toggle the DTOG_RX bit.
+* Input : bEpNum: Endpoint Number.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+void ToggleDTOG_RX(u8 bEpNum)
+{
+ _ToggleDTOG_RX(bEpNum);
+}
+/*******************************************************************************
+* Function Name : ToggleDTOG_TX
+* Description : Toggle the DTOG_TX bit.
+* Input : bEpNum: Endpoint Number.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+void ToggleDTOG_TX(u8 bEpNum)
+{
+ _ToggleDTOG_TX(bEpNum);
+}
+/*******************************************************************************
+* Function Name : ClearDTOG_RX.
+* Description : Clear the DTOG_RX bit.
+* Input : bEpNum: Endpoint Number.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+void ClearDTOG_RX(u8 bEpNum)
+{
+ _ClearDTOG_RX(bEpNum);
+}
+/*******************************************************************************
+* Function Name : ClearDTOG_TX.
+* Description : Clear the DTOG_TX bit.
+* Input : bEpNum: Endpoint Number.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+void ClearDTOG_TX(u8 bEpNum)
+{
+ _ClearDTOG_TX(bEpNum);
+}
+/*******************************************************************************
+* Function Name : SetEPAddress
+* Description : Set the endpoint address.
+* Input : bEpNum: Endpoint Number.
+* bAddr: New endpoint address.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+void SetEPAddress(u8 bEpNum, u8 bAddr)
+{
+ _SetEPAddress(bEpNum, bAddr);
+}
+/*******************************************************************************
+* Function Name : GetEPAddress
+* Description : Get the endpoint address.
+* Input : bEpNum: Endpoint Number.
+* Output : None.
+* Return : Endpoint address.
+*******************************************************************************/
+u8 GetEPAddress(u8 bEpNum)
+{
+ return(_GetEPAddress(bEpNum));
+}
+/*******************************************************************************
+* Function Name : SetEPTxAddr
+* Description : Set the endpoint Tx buffer address.
+* Input : bEpNum: Endpoint Number.
+* wAddr: new address.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+void SetEPTxAddr(u8 bEpNum, u16 wAddr)
+{
+ _SetEPTxAddr(bEpNum, wAddr);
+}
+/*******************************************************************************
+* Function Name : SetEPRxAddr
+* Description : Set the endpoint Rx buffer address.
+* Input : bEpNum: Endpoint Number.
+* wAddr: new address.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+void SetEPRxAddr(u8 bEpNum, u16 wAddr)
+{
+ _SetEPRxAddr(bEpNum, wAddr);
+}
+/*******************************************************************************
+* Function Name : GetEPTxAddr
+* Description : Returns the endpoint Tx buffer address.
+* Input : bEpNum: Endpoint Number.
+* Output : None.
+* Return : Rx buffer address.
+*******************************************************************************/
+u16 GetEPTxAddr(u8 bEpNum)
+{
+ return(_GetEPTxAddr(bEpNum));
+}
+/*******************************************************************************
+* Function Name : GetEPRxAddr.
+* Description : Returns the endpoint Rx buffer address.
+* Input : bEpNum: Endpoint Number.
+* Output : None.
+* Return : Rx buffer address.
+*******************************************************************************/
+u16 GetEPRxAddr(u8 bEpNum)
+{
+ return(_GetEPRxAddr(bEpNum));
+}
+/*******************************************************************************
+* Function Name : SetEPTxCount.
+* Description : Set the Tx count.
+* Input : bEpNum: Endpoint Number.
+* wCount: new count value.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+void SetEPTxCount(u8 bEpNum, u16 wCount)
+{
+ _SetEPTxCount(bEpNum, wCount);
+}
+/*******************************************************************************
+* Function Name : SetEPCountRxReg.
+* Description : Set the Count Rx Register value.
+* Input : *pdwReg: point to the register.
+* wCount: the new register value.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+void SetEPCountRxReg(u32 *pdwReg, u16 wCount)
+{
+ _SetEPCountRxReg(dwReg, wCount);
+}
+/*******************************************************************************
+* Function Name : SetEPRxCount
+* Description : Set the Rx count.
+* Input : bEpNum: Endpoint Number.
+* wCount: the new count value.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+void SetEPRxCount(u8 bEpNum, u16 wCount)
+{
+ _SetEPRxCount(bEpNum, wCount);
+}
+/*******************************************************************************
+* Function Name : GetEPTxCount
+* Description : Get the Tx count.
+* Input : bEpNum: Endpoint Number.
+* Output : None
+* Return : Tx count value.
+*******************************************************************************/
+u16 GetEPTxCount(u8 bEpNum)
+{
+ return(_GetEPTxCount(bEpNum));
+}
+/*******************************************************************************
+* Function Name : GetEPRxCount
+* Description : Get the Rx count.
+* Input : bEpNum: Endpoint Number.
+* Output : None.
+* Return : Rx count value.
+*******************************************************************************/
+u16 GetEPRxCount(u8 bEpNum)
+{
+ return(_GetEPRxCount(bEpNum));
+}
+/*******************************************************************************
+* Function Name : SetEPDblBuffAddr
+* Description : Set the addresses of the buffer 0 and 1.
+* Input : bEpNum: Endpoint Number.
+* wBuf0Addr: new address of buffer 0.
+* wBuf1Addr: new address of buffer 1.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+void SetEPDblBuffAddr(u8 bEpNum, u16 wBuf0Addr, u16 wBuf1Addr)
+{
+ _SetEPDblBuffAddr(bEpNum, wBuf0Addr, wBuf1Addr);
+}
+/*******************************************************************************
+* Function Name : SetEPDblBuf0Addr
+* Description : Set the Buffer 1 address.
+* Input : bEpNum: Endpoint Number
+* wBuf0Addr: new address.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+void SetEPDblBuf0Addr(u8 bEpNum, u16 wBuf0Addr)
+{
+ _SetEPDblBuf0Addr(bEpNum, wBuf0Addr);
+}
+/*******************************************************************************
+* Function Name : SetEPDblBuf1Addr
+* Description : Set the Buffer 1 address.
+* Input : bEpNum: Endpoint Number
+* wBuf1Addr: new address.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+void SetEPDblBuf1Addr(u8 bEpNum, u16 wBuf1Addr)
+{
+ _SetEPDblBuf1Addr(bEpNum, wBuf1Addr);
+}
+/*******************************************************************************
+* Function Name : GetEPDblBuf0Addr
+* Description : Returns the address of the Buffer 0.
+* Input : bEpNum: Endpoint Number.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+u16 GetEPDblBuf0Addr(u8 bEpNum)
+{
+ return(_GetEPDblBuf0Addr(bEpNum));
+}
+/*******************************************************************************
+* Function Name : GetEPDblBuf1Addr
+* Description : Returns the address of the Buffer 1.
+* Input : bEpNum: Endpoint Number.
+* Output : None.
+* Return : Address of the Buffer 1.
+*******************************************************************************/
+u16 GetEPDblBuf1Addr(u8 bEpNum)
+{
+ return(_GetEPDblBuf1Addr(bEpNum));
+}
+/*******************************************************************************
+* Function Name : SetEPDblBuffCount
+* Description : Set the number of bytes for a double Buffer
+* endpoint.
+* Input : bEpNum,bDir, wCount
+* Output : None.
+* Return : None.
+*******************************************************************************/
+void SetEPDblBuffCount(u8 bEpNum, u8 bDir, u16 wCount)
+{
+ _SetEPDblBuffCount(bEpNum, bDir, wCount);
+}
+/*******************************************************************************
+* Function Name : SetEPDblBuf0Count
+* Description : Set the number of bytes in the buffer 0 of a double Buffer
+* endpoint.
+* Input : bEpNum, bDir, wCount
+* Output : None.
+* Return : None.
+*******************************************************************************/
+void SetEPDblBuf0Count(u8 bEpNum, u8 bDir, u16 wCount)
+{
+ _SetEPDblBuf0Count(bEpNum, bDir, wCount);
+}
+/*******************************************************************************
+* Function Name : SetEPDblBuf1Count
+* Description : Set the number of bytes in the buffer 0 of a double Buffer
+* endpoint.
+* Input : bEpNum, bDir, wCount
+* Output : None.
+* Return : None.
+*******************************************************************************/
+void SetEPDblBuf1Count(u8 bEpNum, u8 bDir, u16 wCount)
+{
+ _SetEPDblBuf1Count(bEpNum, bDir, wCount);
+}
+/*******************************************************************************
+* Function Name : GetEPDblBuf0Count
+* Description : Returns the number of byte received in the buffer 0 of a double
+* Buffer endpoint.
+* Input : bEpNum: Endpoint Number.
+* Output : None.
+* Return : Endpoint Buffer 0 count
+*******************************************************************************/
+u16 GetEPDblBuf0Count(u8 bEpNum)
+{
+ return(_GetEPDblBuf0Count(bEpNum));
+}
+/*******************************************************************************
+* Function Name : GetEPDblBuf1Count
+* Description : Returns the number of data received in the buffer 1 of a double
+* Buffer endpoint.
+* Input : bEpNum: Endpoint Number.
+* Output : None.
+* Return : Endpoint Buffer 1 count.
+*******************************************************************************/
+u16 GetEPDblBuf1Count(u8 bEpNum)
+{
+ return(_GetEPDblBuf1Count(bEpNum));
+}
+/*******************************************************************************
+* Function Name : GetEPDblBufDir
+* Description : gets direction of the double buffered endpoint
+* Input : bEpNum: Endpoint Number.
+* Output : None.
+* Return : EP_DBUF_OUT, EP_DBUF_IN,
+* EP_DBUF_ERR if the endpoint counter not yet programmed.
+*******************************************************************************/
+EP_DBUF_DIR GetEPDblBufDir(u8 bEpNum)
+{
+ if ((u16)(*_pEPRxCount(bEpNum) & 0xFC00) != 0)
+ return(EP_DBUF_OUT);
+ else if (((u16)(*_pEPTxCount(bEpNum)) & 0x03FF) != 0)
+ return(EP_DBUF_IN);
+ else
+ return(EP_DBUF_ERR);
+}
+/*******************************************************************************
+* Function Name : FreeUserBuffer
+* Description : free buffer used from the application realizing it to the line
+ toggles bit SW_BUF in the double buffered endpoint register
+* Input : bEpNum, bDir
+* Output : None.
+* Return : None.
+*******************************************************************************/
+void FreeUserBuffer(u8 bEpNum, u8 bDir)
+{
+ if (bDir == EP_DBUF_OUT)
+ { /* OUT double buffered endpoint */
+ _ToggleDTOG_TX(bEpNum);
+ }
+ else if (bDir == EP_DBUF_IN)
+ { /* IN double buffered endpoint */
+ _ToggleDTOG_RX(bEpNum);
+ }
+}
+
+/*******************************************************************************
+* Function Name : ToWord
+* Description : merge two byte in a word.
+* Input : bh: byte high, bl: bytes low.
+* Output : None.
+* Return : resulted word.
+*******************************************************************************/
+u16 ToWord(u8 bh, u8 bl)
+{
+ u16 wRet;
+ wRet = (u16)bl | ((u16)bh << 8);
+ return(wRet);
+}
+/*******************************************************************************
+* Function Name : ByteSwap
+* Description : Swap two byte in a word.
+* Input : wSwW: word to Swap.
+* Output : None.
+* Return : resulted word.
+*******************************************************************************/
+u16 ByteSwap(u16 wSwW)
+{
+ u8 bTemp;
+ u16 wRet;
+ bTemp = (u8)(wSwW & 0xff);
+ wRet = (wSwW >> 8) | ((u16)bTemp << 8);
+ return(wRet);
+}
+
+/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
diff --git a/libmaple/usb/usb_lib/usb_regs.h b/libmaple/usb/usb_lib/usb_regs.h
index 9a4df75..a888f72 100644
--- a/libmaple/usb/usb_lib/usb_regs.h
+++ b/libmaple/usb/usb_lib/usb_regs.h
@@ -1,627 +1,627 @@
-/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
-* File Name : usb_regs.h
-* Author : MCD Application Team
-* Version : V2.2.1
-* Date : 09/22/2008
-* Description : Interface prototype functions to USB cell registers
-********************************************************************************
-* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
-* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
-* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
-* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
-* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
-* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
-*******************************************************************************/
-
-/* Define to prevent recursive inclusion -------------------------------------*/
-#ifndef __USB_REGS_H
-#define __USB_REGS_H
-
-/* Includes ------------------------------------------------------------------*/
-/* Exported types ------------------------------------------------------------*/
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
-typedef enum _EP_DBUF_DIR
-{
- /* double buffered endpoint direction */
- EP_DBUF_ERR,
- EP_DBUF_OUT,
- EP_DBUF_IN
-}EP_DBUF_DIR;
-
-/* endpoint buffer number */
-enum EP_BUF_NUM
-{
- EP_NOBUF,
- EP_BUF0,
- EP_BUF1
-};
-
-/* Exported constants --------------------------------------------------------*/
-#define RegBase (0x40005C00L) /* USB_IP Peripheral Registers base address */
-#define PMAAddr (0x40006000L) /* USB_IP Packet Memory Area base address */
-
-/******************************************************************************/
-/* General registers */
-/******************************************************************************/
-
-/* Control register */
-#define CNTR ((volatile unsigned *)(RegBase + 0x40))
-/* Interrupt status register */
-#define ISTR ((volatile unsigned *)(RegBase + 0x44))
-/* Frame number register */
-#define FNR ((volatile unsigned *)(RegBase + 0x48))
-/* Device address register */
-#define DADDR ((volatile unsigned *)(RegBase + 0x4C))
-/* Buffer Table address register */
-#define BTABLE ((volatile unsigned *)(RegBase + 0x50))
-/******************************************************************************/
-/* Endpoint registers */
-/******************************************************************************/
-#define EP0REG ((volatile unsigned *)(RegBase)) /* endpoint 0 register address */
-
-/* endpoints enumeration */
-#define ENDP0 ((u8)0)
-#define ENDP1 ((u8)1)
-#define ENDP2 ((u8)2)
-#define ENDP3 ((u8)3)
-#define ENDP4 ((u8)4)
-#define ENDP5 ((u8)5)
-#define ENDP6 ((u8)6)
-#define ENDP7 ((u8)7)
-/******************************************************************************/
-/* ISTR interrupt events */
-/******************************************************************************/
-#define ISTR_CTR (0x8000) /* Correct TRansfer (clear-only bit) */
-#define ISTR_DOVR (0x4000) /* DMA OVeR/underrun (clear-only bit) */
-#define ISTR_ERR (0x2000) /* ERRor (clear-only bit) */
-#define ISTR_WKUP (0x1000) /* WaKe UP (clear-only bit) */
-#define ISTR_SUSP (0x0800) /* SUSPend (clear-only bit) */
-#define ISTR_RESET (0x0400) /* RESET (clear-only bit) */
-#define ISTR_SOF (0x0200) /* Start Of Frame (clear-only bit) */
-#define ISTR_ESOF (0x0100) /* Expected Start Of Frame (clear-only bit) */
-
-
-#define ISTR_DIR (0x0010) /* DIRection of transaction (read-only bit) */
-#define ISTR_EP_ID (0x000F) /* EndPoint IDentifier (read-only bit) */
-
-#define CLR_CTR (~ISTR_CTR) /* clear Correct TRansfer bit */
-#define CLR_DOVR (~ISTR_DOVR) /* clear DMA OVeR/underrun bit*/
-#define CLR_ERR (~ISTR_ERR) /* clear ERRor bit */
-#define CLR_WKUP (~ISTR_WKUP) /* clear WaKe UP bit */
-#define CLR_SUSP (~ISTR_SUSP) /* clear SUSPend bit */
-#define CLR_RESET (~ISTR_RESET) /* clear RESET bit */
-#define CLR_SOF (~ISTR_SOF) /* clear Start Of Frame bit */
-#define CLR_ESOF (~ISTR_ESOF) /* clear Expected Start Of Frame bit */
-
-/******************************************************************************/
-/* CNTR control register bits definitions */
-/******************************************************************************/
-#define CNTR_CTRM (0x8000) /* Correct TRansfer Mask */
-#define CNTR_DOVRM (0x4000) /* DMA OVeR/underrun Mask */
-#define CNTR_ERRM (0x2000) /* ERRor Mask */
-#define CNTR_WKUPM (0x1000) /* WaKe UP Mask */
-#define CNTR_SUSPM (0x0800) /* SUSPend Mask */
-#define CNTR_RESETM (0x0400) /* RESET Mask */
-#define CNTR_SOFM (0x0200) /* Start Of Frame Mask */
-#define CNTR_ESOFM (0x0100) /* Expected Start Of Frame Mask */
-
-
-#define CNTR_RESUME (0x0010) /* RESUME request */
-#define CNTR_FSUSP (0x0008) /* Force SUSPend */
-#define CNTR_LPMODE (0x0004) /* Low-power MODE */
-#define CNTR_PDWN (0x0002) /* Power DoWN */
-#define CNTR_FRES (0x0001) /* Force USB RESet */
-
-/******************************************************************************/
-/* FNR Frame Number Register bit definitions */
-/******************************************************************************/
-#define FNR_RXDP (0x8000) /* status of D+ data line */
-#define FNR_RXDM (0x4000) /* status of D- data line */
-#define FNR_LCK (0x2000) /* LoCKed */
-#define FNR_LSOF (0x1800) /* Lost SOF */
-#define FNR_FN (0x07FF) /* Frame Number */
-/******************************************************************************/
-/* DADDR Device ADDRess bit definitions */
-/******************************************************************************/
-#define DADDR_EF (0x80)
-#define DADDR_ADD (0x7F)
-/******************************************************************************/
-/* Endpoint register */
-/******************************************************************************/
-/* bit positions */
-#define EP_CTR_RX (0x8000) /* EndPoint Correct TRansfer RX */
-#define EP_DTOG_RX (0x4000) /* EndPoint Data TOGGLE RX */
-#define EPRX_STAT (0x3000) /* EndPoint RX STATus bit field */
-#define EP_SETUP (0x0800) /* EndPoint SETUP */
-#define EP_T_FIELD (0x0600) /* EndPoint TYPE */
-#define EP_KIND (0x0100) /* EndPoint KIND */
-#define EP_CTR_TX (0x0080) /* EndPoint Correct TRansfer TX */
-#define EP_DTOG_TX (0x0040) /* EndPoint Data TOGGLE TX */
-#define EPTX_STAT (0x0030) /* EndPoint TX STATus bit field */
-#define EPADDR_FIELD (0x000F) /* EndPoint ADDRess FIELD */
-
-/* EndPoint REGister MASK (no toggle fields) */
-#define EPREG_MASK (EP_CTR_RX|EP_SETUP|EP_T_FIELD|EP_KIND|EP_CTR_TX|EPADDR_FIELD)
-
-/* EP_TYPE[1:0] EndPoint TYPE */
-#define EP_TYPE_MASK (0x0600) /* EndPoint TYPE Mask */
-#define EP_BULK (0x0000) /* EndPoint BULK */
-#define EP_CONTROL (0x0200) /* EndPoint CONTROL */
-#define EP_ISOCHRONOUS (0x0400) /* EndPoint ISOCHRONOUS */
-#define EP_INTERRUPT (0x0600) /* EndPoint INTERRUPT */
-#define EP_T_MASK (~EP_T_FIELD & EPREG_MASK)
-
-
-/* EP_KIND EndPoint KIND */
-#define EPKIND_MASK (~EP_KIND & EPREG_MASK)
-
-/* STAT_TX[1:0] STATus for TX transfer */
-#define EP_TX_DIS (0x0000) /* EndPoint TX DISabled */
-#define EP_TX_STALL (0x0010) /* EndPoint TX STALLed */
-#define EP_TX_NAK (0x0020) /* EndPoint TX NAKed */
-#define EP_TX_VALID (0x0030) /* EndPoint TX VALID */
-#define EPTX_DTOG1 (0x0010) /* EndPoint TX Data TOGgle bit1 */
-#define EPTX_DTOG2 (0x0020) /* EndPoint TX Data TOGgle bit2 */
-#define EPTX_DTOGMASK (EPTX_STAT|EPREG_MASK)
-
-/* STAT_RX[1:0] STATus for RX transfer */
-#define EP_RX_DIS (0x0000) /* EndPoint RX DISabled */
-#define EP_RX_STALL (0x1000) /* EndPoint RX STALLed */
-#define EP_RX_NAK (0x2000) /* EndPoint RX NAKed */
-#define EP_RX_VALID (0x3000) /* EndPoint RX VALID */
-#define EPRX_DTOG1 (0x1000) /* EndPoint RX Data TOGgle bit1 */
-#define EPRX_DTOG2 (0x2000) /* EndPoint RX Data TOGgle bit1 */
-#define EPRX_DTOGMASK (EPRX_STAT|EPREG_MASK)
-/* Exported macro ------------------------------------------------------------*/
-/* SetCNTR */
-#define _SetCNTR(wRegValue) (*CNTR = (u16)wRegValue)
-
-/* SetISTR */
-#define _SetISTR(wRegValue) (*ISTR = (u16)wRegValue)
-
-/* SetDADDR */
-#define _SetDADDR(wRegValue) (*DADDR = (u16)wRegValue)
-
-/* SetBTABLE */
-#define _SetBTABLE(wRegValue)(*BTABLE = (u16)(wRegValue & 0xFFF8))
-
-/* GetCNTR */
-#define _GetCNTR() ((u16) *CNTR)
-
-/* GetISTR */
-#define _GetISTR() ((u16) *ISTR)
-
-/* GetFNR */
-#define _GetFNR() ((u16) *FNR)
-
-/* GetDADDR */
-#define _GetDADDR() ((u16) *DADDR)
-
-/* GetBTABLE */
-#define _GetBTABLE() ((u16) *BTABLE)
-
-/* SetENDPOINT */
-#define _SetENDPOINT(bEpNum,wRegValue) (*(EP0REG + bEpNum)= \
- (u16)wRegValue)
-
-/* GetENDPOINT */
-#define _GetENDPOINT(bEpNum) ((u16)(*(EP0REG + bEpNum)))
-
-/*******************************************************************************
-* Macro Name : SetEPType
-* Description : sets the type in the endpoint register(bits EP_TYPE[1:0])
-* Input : bEpNum: Endpoint Number.
-* wType
-* Output : None.
-* Return : None.
-*******************************************************************************/
-#define _SetEPType(bEpNum,wType) (_SetENDPOINT(bEpNum,\
- ((_GetENDPOINT(bEpNum) & EP_T_MASK) | wType)))
-
-/*******************************************************************************
-* Macro Name : GetEPType
-* Description : gets the type in the endpoint register(bits EP_TYPE[1:0])
-* Input : bEpNum: Endpoint Number.
-* Output : None.
-* Return : Endpoint Type
-*******************************************************************************/
-#define _GetEPType(bEpNum) (_GetENDPOINT(bEpNum) & EP_T_FIELD)
-
-/*******************************************************************************
-* Macro Name : SetEPTxStatus
-* Description : sets the status for tx transfer (bits STAT_TX[1:0]).
-* Input : bEpNum: Endpoint Number.
-* wState: new state
-* Output : None.
-* Return : None.
-*******************************************************************************/
-#define _SetEPTxStatus(bEpNum,wState) {\
- register u16 _wRegVal; \
- _wRegVal = _GetENDPOINT(bEpNum) & EPTX_DTOGMASK;\
- /* toggle first bit ? */ \
- if((EPTX_DTOG1 & wState)!= 0) \
- _wRegVal ^= EPTX_DTOG1; \
- /* toggle second bit ? */ \
- if((EPTX_DTOG2 & wState)!= 0) \
- _wRegVal ^= EPTX_DTOG2; \
- _SetENDPOINT(bEpNum, _wRegVal); \
- } /* _SetEPTxStatus */
-
-/*******************************************************************************
-* Macro Name : SetEPRxStatus
-* Description : sets the status for rx transfer (bits STAT_TX[1:0])
-* Input : bEpNum: Endpoint Number.
-* wState: new state.
-* Output : None.
-* Return : None.
-*******************************************************************************/
-#define _SetEPRxStatus(bEpNum,wState) {\
- register u16 _wRegVal; \
- \
- _wRegVal = _GetENDPOINT(bEpNum) & EPRX_DTOGMASK;\
- /* toggle first bit ? */ \
- if((EPRX_DTOG1 & wState)!= 0) \
- _wRegVal ^= EPRX_DTOG1; \
- /* toggle second bit ? */ \
- if((EPRX_DTOG2 & wState)!= 0) \
- _wRegVal ^= EPRX_DTOG2; \
- _SetENDPOINT(bEpNum, _wRegVal); \
- } /* _SetEPRxStatus */
-/*******************************************************************************
-* Macro Name : GetEPTxStatus / GetEPRxStatus
-* Description : gets the status for tx/rx transfer (bits STAT_TX[1:0]
-* /STAT_RX[1:0])
-* Input : bEpNum: Endpoint Number.
-* Output : None.
-* Return : status .
-*******************************************************************************/
-#define _GetEPTxStatus(bEpNum) ((u16)_GetENDPOINT(bEpNum) & EPTX_STAT)
-
-#define _GetEPRxStatus(bEpNum) ((u16)_GetENDPOINT(bEpNum) & EPRX_STAT)
-
-/*******************************************************************************
-* Macro Name : SetEPTxValid / SetEPRxValid
-* Description : sets directly the VALID tx/rx-status into the enpoint register
-* Input : bEpNum: Endpoint Number.
-* Output : None.
-* Return : None.
-*******************************************************************************/
-#define _SetEPTxValid(bEpNum) (_SetEPTxStatus(bEpNum, EP_TX_VALID))
-
-#define _SetEPRxValid(bEpNum) (_SetEPRxStatus(bEpNum, EP_RX_VALID))
-
-/*******************************************************************************
-* Macro Name : GetTxStallStatus / GetRxStallStatus.
-* Description : checks stall condition in an endpoint.
-* Input : bEpNum: Endpoint Number.
-* Output : None.
-* Return : TRUE = endpoint in stall condition.
-*******************************************************************************/
-#define _GetTxStallStatus(bEpNum) (_GetEPTxStatus(bEpNum) \
- == EP_TX_STALL)
-#define _GetRxStallStatus(bEpNum) (_GetEPRxStatus(bEpNum) \
- == EP_RX_STALL)
-
-/*******************************************************************************
-* Macro Name : SetEP_KIND / ClearEP_KIND.
-* Description : set & clear EP_KIND bit.
-* Input : bEpNum: Endpoint Number.
-* Output : None.
-* Return : None.
-*******************************************************************************/
-#define _SetEP_KIND(bEpNum) (_SetENDPOINT(bEpNum, \
- (_GetENDPOINT(bEpNum) | EP_KIND) & EPREG_MASK))
-#define _ClearEP_KIND(bEpNum) (_SetENDPOINT(bEpNum, \
- (_GetENDPOINT(bEpNum) & EPKIND_MASK)))
-
-/*******************************************************************************
-* Macro Name : Set_Status_Out / Clear_Status_Out.
-* Description : Sets/clears directly STATUS_OUT bit in the endpoint register.
-* Input : bEpNum: Endpoint Number.
-* Output : None.
-* Return : None.
-*******************************************************************************/
-#define _Set_Status_Out(bEpNum) _SetEP_KIND(bEpNum)
-#define _Clear_Status_Out(bEpNum) _ClearEP_KIND(bEpNum)
-
-/*******************************************************************************
-* Macro Name : SetEPDoubleBuff / ClearEPDoubleBuff.
-* Description : Sets/clears directly EP_KIND bit in the endpoint register.
-* Input : bEpNum: Endpoint Number.
-* Output : None.
-* Return : None.
-*******************************************************************************/
-#define _SetEPDoubleBuff(bEpNum) _SetEP_KIND(bEpNum)
-#define _ClearEPDoubleBuff(bEpNum) _ClearEP_KIND(bEpNum)
-
-/*******************************************************************************
-* Macro Name : ClearEP_CTR_RX / ClearEP_CTR_TX.
-* Description : Clears bit CTR_RX / CTR_TX in the endpoint register.
-* Input : bEpNum: Endpoint Number.
-* Output : None.
-* Return : None.
-*******************************************************************************/
-#define _ClearEP_CTR_RX(bEpNum) (_SetENDPOINT(bEpNum,\
- _GetENDPOINT(bEpNum) & 0x7FFF & EPREG_MASK))
-#define _ClearEP_CTR_TX(bEpNum) (_SetENDPOINT(bEpNum,\
- _GetENDPOINT(bEpNum) & 0xFF7F & EPREG_MASK))
-
-/*******************************************************************************
-* Macro Name : ToggleDTOG_RX / ToggleDTOG_TX .
-* Description : Toggles DTOG_RX / DTOG_TX bit in the endpoint register.
-* Input : bEpNum: Endpoint Number.
-* Output : None.
-* Return : None.
-*******************************************************************************/
-#define _ToggleDTOG_RX(bEpNum) (_SetENDPOINT(bEpNum, \
- EP_DTOG_RX | _GetENDPOINT(bEpNum) & EPREG_MASK))
-#define _ToggleDTOG_TX(bEpNum) (_SetENDPOINT(bEpNum, \
- EP_DTOG_TX | _GetENDPOINT(bEpNum) & EPREG_MASK))
-
-/*******************************************************************************
-* Macro Name : ClearDTOG_RX / ClearDTOG_TX.
-* Description : Clears DTOG_RX / DTOG_TX bit in the endpoint register.
-* Input : bEpNum: Endpoint Number.
-* Output : None.
-* Return : None.
-*******************************************************************************/
-#define _ClearDTOG_RX(bEpNum) if((_GetENDPOINT(bEpNum) & EP_DTOG_RX) != 0)\
- _ToggleDTOG_RX(bEpNum)
-#define _ClearDTOG_TX(bEpNum) if((_GetENDPOINT(bEpNum) & EP_DTOG_TX) != 0)\
- _ToggleDTOG_TX(bEpNum)
-/*******************************************************************************
-* Macro Name : SetEPAddress.
-* Description : Sets address in an endpoint register.
-* Input : bEpNum: Endpoint Number.
-* bAddr: Address.
-* Output : None.
-* Return : None.
-*******************************************************************************/
-#define _SetEPAddress(bEpNum,bAddr) _SetENDPOINT(bEpNum,\
- _GetENDPOINT(bEpNum) & EPREG_MASK | bAddr)
-
-/*******************************************************************************
-* Macro Name : GetEPAddress.
-* Description : Gets address in an endpoint register.
-* Input : bEpNum: Endpoint Number.
-* Output : None.
-* Return : None.
-*******************************************************************************/
-#define _GetEPAddress(bEpNum) ((u8)(_GetENDPOINT(bEpNum) & EPADDR_FIELD))
-
-#define _pEPTxAddr(bEpNum) ((u32 *)((_GetBTABLE()+bEpNum*8 )*2 + PMAAddr))
-#define _pEPTxCount(bEpNum) ((u32 *)((_GetBTABLE()+bEpNum*8+2)*2 + PMAAddr))
-#define _pEPRxAddr(bEpNum) ((u32 *)((_GetBTABLE()+bEpNum*8+4)*2 + PMAAddr))
-#define _pEPRxCount(bEpNum) ((u32 *)((_GetBTABLE()+bEpNum*8+6)*2 + PMAAddr))
-
-/*******************************************************************************
-* Macro Name : SetEPTxAddr / SetEPRxAddr.
-* Description : sets address of the tx/rx buffer.
-* Input : bEpNum: Endpoint Number.
-* wAddr: address to be set (must be word aligned).
-* Output : None.
-* Return : None.
-*******************************************************************************/
-#define _SetEPTxAddr(bEpNum,wAddr) (*_pEPTxAddr(bEpNum) = ((wAddr >> 1) << 1))
-#define _SetEPRxAddr(bEpNum,wAddr) (*_pEPRxAddr(bEpNum) = ((wAddr >> 1) << 1))
-
-/*******************************************************************************
-* Macro Name : GetEPTxAddr / GetEPRxAddr.
-* Description : Gets address of the tx/rx buffer.
-* Input : bEpNum: Endpoint Number.
-* Output : None.
-* Return : address of the buffer.
-*******************************************************************************/
-#define _GetEPTxAddr(bEpNum) ((u16)*_pEPTxAddr(bEpNum))
-#define _GetEPRxAddr(bEpNum) ((u16)*_pEPRxAddr(bEpNum))
-
-/*******************************************************************************
-* Macro Name : SetEPCountRxReg.
-* Description : Sets counter of rx buffer with no. of blocks.
-* Input : pdwReg: pointer to counter.
-* wCount: Counter.
-* Output : None.
-* Return : None.
-*******************************************************************************/
-#define _BlocksOf32(dwReg,wCount,wNBlocks) {\
- wNBlocks = wCount >> 5;\
- if((wCount & 0x1f) == 0)\
- wNBlocks--;\
- *pdwReg = (u32)((wNBlocks << 10) | 0x8000);\
- }/* _BlocksOf32 */
-
-#define _BlocksOf2(dwReg,wCount,wNBlocks) {\
- wNBlocks = wCount >> 1;\
- if((wCount & 0x1) != 0)\
- wNBlocks++;\
- *pdwReg = (u32)(wNBlocks << 10);\
- }/* _BlocksOf2 */
-
-#define _SetEPCountRxReg(dwReg,wCount) {\
- u16 wNBlocks;\
- if(wCount > 62){_BlocksOf32(dwReg,wCount,wNBlocks);}\
- else {_BlocksOf2(dwReg,wCount,wNBlocks);}\
- }/* _SetEPCountRxReg */
-
-
-
-#define _SetEPRxDblBuf0Count(bEpNum,wCount) {\
- u32 *pdwReg = _pEPTxCount(bEpNum); \
- _SetEPCountRxReg(pdwReg, wCount);\
- }
-/*******************************************************************************
-* Macro Name : SetEPTxCount / SetEPRxCount.
-* Description : sets counter for the tx/rx buffer.
-* Input : bEpNum: endpoint number.
-* wCount: Counter value.
-* Output : None.
-* Return : None.
-*******************************************************************************/
-#define _SetEPTxCount(bEpNum,wCount) (*_pEPTxCount(bEpNum) = wCount)
-#define _SetEPRxCount(bEpNum,wCount) {\
- u32 *pdwReg = _pEPRxCount(bEpNum); \
- _SetEPCountRxReg(pdwReg, wCount);\
- }
-/*******************************************************************************
-* Macro Name : GetEPTxCount / GetEPRxCount.
-* Description : gets counter of the tx buffer.
-* Input : bEpNum: endpoint number.
-* Output : None.
-* Return : Counter value.
-*******************************************************************************/
-#define _GetEPTxCount(bEpNum)((u16)(*_pEPTxCount(bEpNum)) & 0x3ff)
-#define _GetEPRxCount(bEpNum)((u16)(*_pEPRxCount(bEpNum)) & 0x3ff)
-
-/*******************************************************************************
-* Macro Name : SetEPDblBuf0Addr / SetEPDblBuf1Addr.
-* Description : Sets buffer 0/1 address in a double buffer endpoint.
-* Input : bEpNum: endpoint number.
-* : wBuf0Addr: buffer 0 address.
-* Output : None.
-* Return : None.
-*******************************************************************************/
-#define _SetEPDblBuf0Addr(bEpNum,wBuf0Addr) {_SetEPTxAddr(bEpNum, wBuf0Addr);}
-#define _SetEPDblBuf1Addr(bEpNum,wBuf1Addr) {_SetEPRxAddr(bEpNum, wBuf1Addr);}
-
-/*******************************************************************************
-* Macro Name : SetEPDblBuffAddr.
-* Description : Sets addresses in a double buffer endpoint.
-* Input : bEpNum: endpoint number.
-* : wBuf0Addr: buffer 0 address.
-* : wBuf1Addr = buffer 1 address.
-* Output : None.
-* Return : None.
-*******************************************************************************/
-#define _SetEPDblBuffAddr(bEpNum,wBuf0Addr,wBuf1Addr) { \
- _SetEPDblBuf0Addr(bEpNum, wBuf0Addr);\
- _SetEPDblBuf1Addr(bEpNum, wBuf1Addr);\
- } /* _SetEPDblBuffAddr */
-
-/*******************************************************************************
-* Macro Name : GetEPDblBuf0Addr / GetEPDblBuf1Addr.
-* Description : Gets buffer 0/1 address of a double buffer endpoint.
-* Input : bEpNum: endpoint number.
-* Output : None.
-* Return : None.
-*******************************************************************************/
-#define _GetEPDblBuf0Addr(bEpNum) (_GetEPTxAddr(bEpNum))
-#define _GetEPDblBuf1Addr(bEpNum) (_GetEPRxAddr(bEpNum))
-
-/*******************************************************************************
-* Macro Name : SetEPDblBuffCount / SetEPDblBuf0Count / SetEPDblBuf1Count.
-* Description : Gets buffer 0/1 address of a double buffer endpoint.
-* Input : bEpNum: endpoint number.
-* : bDir: endpoint dir EP_DBUF_OUT = OUT
-* EP_DBUF_IN = IN
-* : wCount: Counter value
-* Output : None.
-* Return : None.
-*******************************************************************************/
-#define _SetEPDblBuf0Count(bEpNum, bDir, wCount) { \
- if(bDir == EP_DBUF_OUT)\
- /* OUT endpoint */ \
- {_SetEPRxDblBuf0Count(bEpNum,wCount);} \
- else if(bDir == EP_DBUF_IN)\
- /* IN endpoint */ \
- *_pEPTxCount(bEpNum) = (u32)wCount; \
- } /* SetEPDblBuf0Count*/
-
-#define _SetEPDblBuf1Count(bEpNum, bDir, wCount) { \
- if(bDir == EP_DBUF_OUT)\
- /* OUT endpoint */ \
- {_SetEPRxCount(bEpNum,wCount);}\
- else if(bDir == EP_DBUF_IN)\
- /* IN endpoint */\
- *_pEPRxCount(bEpNum) = (u32)wCount; \
- } /* SetEPDblBuf1Count */
-
-#define _SetEPDblBuffCount(bEpNum, bDir, wCount) {\
- _SetEPDblBuf0Count(bEpNum, bDir, wCount); \
- _SetEPDblBuf1Count(bEpNum, bDir, wCount); \
- } /* _SetEPDblBuffCount */
-
-/*******************************************************************************
-* Macro Name : GetEPDblBuf0Count / GetEPDblBuf1Count.
-* Description : Gets buffer 0/1 rx/tx counter for double buffering.
-* Input : bEpNum: endpoint number.
-* Output : None.
-* Return : None.
-*******************************************************************************/
-#define _GetEPDblBuf0Count(bEpNum) (_GetEPTxCount(bEpNum))
-#define _GetEPDblBuf1Count(bEpNum) (_GetEPRxCount(bEpNum))
-
-
-/* External variables --------------------------------------------------------*/
-extern volatile u16 wIstr; /* ISTR register last read value */
-
-/* Exported functions ------------------------------------------------------- */
-void SetCNTR(u16 /*wRegValue*/);
-void SetISTR(u16 /*wRegValue*/);
-void SetDADDR(u16 /*wRegValue*/);
-void SetBTABLE(u16 /*wRegValue*/);
-u16 GetCNTR(void);
-u16 GetISTR(void);
-u16 GetFNR(void);
-u16 GetDADDR(void);
-u16 GetBTABLE(void);
-void SetENDPOINT(u8 /*bEpNum*/, u16 /*wRegValue*/);
-u16 GetENDPOINT(u8 /*bEpNum*/);
-void SetEPType(u8 /*bEpNum*/, u16 /*wType*/);
-u16 GetEPType(u8 /*bEpNum*/);
-void SetEPTxStatus(u8 /*bEpNum*/, u16 /*wState*/);
-void SetEPRxStatus(u8 /*bEpNum*/, u16 /*wState*/);
-void SetDouBleBuffEPStall(u8 /*bEpNum*/, u8 bDir);
-u16 GetEPTxStatus(u8 /*bEpNum*/);
-u16 GetEPRxStatus(u8 /*bEpNum*/);
-void SetEPTxValid(u8 /*bEpNum*/);
-void SetEPRxValid(u8 /*bEpNum*/);
-u16 GetTxStallStatus(u8 /*bEpNum*/);
-u16 GetRxStallStatus(u8 /*bEpNum*/);
-void SetEP_KIND(u8 /*bEpNum*/);
-void ClearEP_KIND(u8 /*bEpNum*/);
-void Set_Status_Out(u8 /*bEpNum*/);
-void Clear_Status_Out(u8 /*bEpNum*/);
-void SetEPDoubleBuff(u8 /*bEpNum*/);
-void ClearEPDoubleBuff(u8 /*bEpNum*/);
-void ClearEP_CTR_RX(u8 /*bEpNum*/);
-void ClearEP_CTR_TX(u8 /*bEpNum*/);
-void ToggleDTOG_RX(u8 /*bEpNum*/);
-void ToggleDTOG_TX(u8 /*bEpNum*/);
-void ClearDTOG_RX(u8 /*bEpNum*/);
-void ClearDTOG_TX(u8 /*bEpNum*/);
-void SetEPAddress(u8 /*bEpNum*/, u8 /*bAddr*/);
-u8 GetEPAddress(u8 /*bEpNum*/);
-void SetEPTxAddr(u8 /*bEpNum*/, u16 /*wAddr*/);
-void SetEPRxAddr(u8 /*bEpNum*/, u16 /*wAddr*/);
-u16 GetEPTxAddr(u8 /*bEpNum*/);
-u16 GetEPRxAddr(u8 /*bEpNum*/);
-void SetEPCountRxReg(u32 * /*pdwReg*/, u16 /*wCount*/);
-void SetEPTxCount(u8 /*bEpNum*/, u16 /*wCount*/);
-void SetEPRxCount(u8 /*bEpNum*/, u16 /*wCount*/);
-u16 GetEPTxCount(u8 /*bEpNum*/);
-u16 GetEPRxCount(u8 /*bEpNum*/);
-void SetEPDblBuf0Addr(u8 /*bEpNum*/, u16 /*wBuf0Addr*/);
-void SetEPDblBuf1Addr(u8 /*bEpNum*/, u16 /*wBuf1Addr*/);
-void SetEPDblBuffAddr(u8 /*bEpNum*/, u16 /*wBuf0Addr*/, u16 /*wBuf1Addr*/);
-u16 GetEPDblBuf0Addr(u8 /*bEpNum*/);
-u16 GetEPDblBuf1Addr(u8 /*bEpNum*/);
-void SetEPDblBuffCount(u8 /*bEpNum*/, u8 /*bDir*/, u16 /*wCount*/);
-void SetEPDblBuf0Count(u8 /*bEpNum*/, u8 /*bDir*/, u16 /*wCount*/);
-void SetEPDblBuf1Count(u8 /*bEpNum*/, u8 /*bDir*/, u16 /*wCount*/);
-u16 GetEPDblBuf0Count(u8 /*bEpNum*/);
-u16 GetEPDblBuf1Count(u8 /*bEpNum*/);
-EP_DBUF_DIR GetEPDblBufDir(u8 /*bEpNum*/);
-void FreeUserBuffer(u8 bEpNum/*bEpNum*/, u8 bDir);
-u16 ToWord(u8, u8);
-u16 ByteSwap(u16);
-
-#if defined(__cplusplus)
-}
-#endif
-
-#endif /* __USB_REGS_H */
-
-/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
+/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
+* File Name : usb_regs.h
+* Author : MCD Application Team
+* Version : V2.2.1
+* Date : 09/22/2008
+* Description : Interface prototype functions to USB cell registers
+********************************************************************************
+* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
+* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
+* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
+* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
+* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+*******************************************************************************/
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __USB_REGS_H
+#define __USB_REGS_H
+
+/* Includes ------------------------------------------------------------------*/
+/* Exported types ------------------------------------------------------------*/
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+typedef enum _EP_DBUF_DIR
+{
+ /* double buffered endpoint direction */
+ EP_DBUF_ERR,
+ EP_DBUF_OUT,
+ EP_DBUF_IN
+}EP_DBUF_DIR;
+
+/* endpoint buffer number */
+enum EP_BUF_NUM
+{
+ EP_NOBUF,
+ EP_BUF0,
+ EP_BUF1
+};
+
+/* Exported constants --------------------------------------------------------*/
+#define RegBase (0x40005C00L) /* USB_IP Peripheral Registers base address */
+#define PMAAddr (0x40006000L) /* USB_IP Packet Memory Area base address */
+
+/******************************************************************************/
+/* General registers */
+/******************************************************************************/
+
+/* Control register */
+#define CNTR ((volatile unsigned *)(RegBase + 0x40))
+/* Interrupt status register */
+#define ISTR ((volatile unsigned *)(RegBase + 0x44))
+/* Frame number register */
+#define FNR ((volatile unsigned *)(RegBase + 0x48))
+/* Device address register */
+#define DADDR ((volatile unsigned *)(RegBase + 0x4C))
+/* Buffer Table address register */
+#define BTABLE ((volatile unsigned *)(RegBase + 0x50))
+/******************************************************************************/
+/* Endpoint registers */
+/******************************************************************************/
+#define EP0REG ((volatile unsigned *)(RegBase)) /* endpoint 0 register address */
+
+/* endpoints enumeration */
+#define ENDP0 ((u8)0)
+#define ENDP1 ((u8)1)
+#define ENDP2 ((u8)2)
+#define ENDP3 ((u8)3)
+#define ENDP4 ((u8)4)
+#define ENDP5 ((u8)5)
+#define ENDP6 ((u8)6)
+#define ENDP7 ((u8)7)
+/******************************************************************************/
+/* ISTR interrupt events */
+/******************************************************************************/
+#define ISTR_CTR (0x8000) /* Correct TRansfer (clear-only bit) */
+#define ISTR_DOVR (0x4000) /* DMA OVeR/underrun (clear-only bit) */
+#define ISTR_ERR (0x2000) /* ERRor (clear-only bit) */
+#define ISTR_WKUP (0x1000) /* WaKe UP (clear-only bit) */
+#define ISTR_SUSP (0x0800) /* SUSPend (clear-only bit) */
+#define ISTR_RESET (0x0400) /* RESET (clear-only bit) */
+#define ISTR_SOF (0x0200) /* Start Of Frame (clear-only bit) */
+#define ISTR_ESOF (0x0100) /* Expected Start Of Frame (clear-only bit) */
+
+
+#define ISTR_DIR (0x0010) /* DIRection of transaction (read-only bit) */
+#define ISTR_EP_ID (0x000F) /* EndPoint IDentifier (read-only bit) */
+
+#define CLR_CTR (~ISTR_CTR) /* clear Correct TRansfer bit */
+#define CLR_DOVR (~ISTR_DOVR) /* clear DMA OVeR/underrun bit*/
+#define CLR_ERR (~ISTR_ERR) /* clear ERRor bit */
+#define CLR_WKUP (~ISTR_WKUP) /* clear WaKe UP bit */
+#define CLR_SUSP (~ISTR_SUSP) /* clear SUSPend bit */
+#define CLR_RESET (~ISTR_RESET) /* clear RESET bit */
+#define CLR_SOF (~ISTR_SOF) /* clear Start Of Frame bit */
+#define CLR_ESOF (~ISTR_ESOF) /* clear Expected Start Of Frame bit */
+
+/******************************************************************************/
+/* CNTR control register bits definitions */
+/******************************************************************************/
+#define CNTR_CTRM (0x8000) /* Correct TRansfer Mask */
+#define CNTR_DOVRM (0x4000) /* DMA OVeR/underrun Mask */
+#define CNTR_ERRM (0x2000) /* ERRor Mask */
+#define CNTR_WKUPM (0x1000) /* WaKe UP Mask */
+#define CNTR_SUSPM (0x0800) /* SUSPend Mask */
+#define CNTR_RESETM (0x0400) /* RESET Mask */
+#define CNTR_SOFM (0x0200) /* Start Of Frame Mask */
+#define CNTR_ESOFM (0x0100) /* Expected Start Of Frame Mask */
+
+
+#define CNTR_RESUME (0x0010) /* RESUME request */
+#define CNTR_FSUSP (0x0008) /* Force SUSPend */
+#define CNTR_LPMODE (0x0004) /* Low-power MODE */
+#define CNTR_PDWN (0x0002) /* Power DoWN */
+#define CNTR_FRES (0x0001) /* Force USB RESet */
+
+/******************************************************************************/
+/* FNR Frame Number Register bit definitions */
+/******************************************************************************/
+#define FNR_RXDP (0x8000) /* status of D+ data line */
+#define FNR_RXDM (0x4000) /* status of D- data line */
+#define FNR_LCK (0x2000) /* LoCKed */
+#define FNR_LSOF (0x1800) /* Lost SOF */
+#define FNR_FN (0x07FF) /* Frame Number */
+/******************************************************************************/
+/* DADDR Device ADDRess bit definitions */
+/******************************************************************************/
+#define DADDR_EF (0x80)
+#define DADDR_ADD (0x7F)
+/******************************************************************************/
+/* Endpoint register */
+/******************************************************************************/
+/* bit positions */
+#define EP_CTR_RX (0x8000) /* EndPoint Correct TRansfer RX */
+#define EP_DTOG_RX (0x4000) /* EndPoint Data TOGGLE RX */
+#define EPRX_STAT (0x3000) /* EndPoint RX STATus bit field */
+#define EP_SETUP (0x0800) /* EndPoint SETUP */
+#define EP_T_FIELD (0x0600) /* EndPoint TYPE */
+#define EP_KIND (0x0100) /* EndPoint KIND */
+#define EP_CTR_TX (0x0080) /* EndPoint Correct TRansfer TX */
+#define EP_DTOG_TX (0x0040) /* EndPoint Data TOGGLE TX */
+#define EPTX_STAT (0x0030) /* EndPoint TX STATus bit field */
+#define EPADDR_FIELD (0x000F) /* EndPoint ADDRess FIELD */
+
+/* EndPoint REGister MASK (no toggle fields) */
+#define EPREG_MASK (EP_CTR_RX|EP_SETUP|EP_T_FIELD|EP_KIND|EP_CTR_TX|EPADDR_FIELD)
+
+/* EP_TYPE[1:0] EndPoint TYPE */
+#define EP_TYPE_MASK (0x0600) /* EndPoint TYPE Mask */
+#define EP_BULK (0x0000) /* EndPoint BULK */
+#define EP_CONTROL (0x0200) /* EndPoint CONTROL */
+#define EP_ISOCHRONOUS (0x0400) /* EndPoint ISOCHRONOUS */
+#define EP_INTERRUPT (0x0600) /* EndPoint INTERRUPT */
+#define EP_T_MASK (~EP_T_FIELD & EPREG_MASK)
+
+
+/* EP_KIND EndPoint KIND */
+#define EPKIND_MASK (~EP_KIND & EPREG_MASK)
+
+/* STAT_TX[1:0] STATus for TX transfer */
+#define EP_TX_DIS (0x0000) /* EndPoint TX DISabled */
+#define EP_TX_STALL (0x0010) /* EndPoint TX STALLed */
+#define EP_TX_NAK (0x0020) /* EndPoint TX NAKed */
+#define EP_TX_VALID (0x0030) /* EndPoint TX VALID */
+#define EPTX_DTOG1 (0x0010) /* EndPoint TX Data TOGgle bit1 */
+#define EPTX_DTOG2 (0x0020) /* EndPoint TX Data TOGgle bit2 */
+#define EPTX_DTOGMASK (EPTX_STAT|EPREG_MASK)
+
+/* STAT_RX[1:0] STATus for RX transfer */
+#define EP_RX_DIS (0x0000) /* EndPoint RX DISabled */
+#define EP_RX_STALL (0x1000) /* EndPoint RX STALLed */
+#define EP_RX_NAK (0x2000) /* EndPoint RX NAKed */
+#define EP_RX_VALID (0x3000) /* EndPoint RX VALID */
+#define EPRX_DTOG1 (0x1000) /* EndPoint RX Data TOGgle bit1 */
+#define EPRX_DTOG2 (0x2000) /* EndPoint RX Data TOGgle bit1 */
+#define EPRX_DTOGMASK (EPRX_STAT|EPREG_MASK)
+/* Exported macro ------------------------------------------------------------*/
+/* SetCNTR */
+#define _SetCNTR(wRegValue) (*CNTR = (u16)wRegValue)
+
+/* SetISTR */
+#define _SetISTR(wRegValue) (*ISTR = (u16)wRegValue)
+
+/* SetDADDR */
+#define _SetDADDR(wRegValue) (*DADDR = (u16)wRegValue)
+
+/* SetBTABLE */
+#define _SetBTABLE(wRegValue)(*BTABLE = (u16)(wRegValue & 0xFFF8))
+
+/* GetCNTR */
+#define _GetCNTR() ((u16) *CNTR)
+
+/* GetISTR */
+#define _GetISTR() ((u16) *ISTR)
+
+/* GetFNR */
+#define _GetFNR() ((u16) *FNR)
+
+/* GetDADDR */
+#define _GetDADDR() ((u16) *DADDR)
+
+/* GetBTABLE */
+#define _GetBTABLE() ((u16) *BTABLE)
+
+/* SetENDPOINT */
+#define _SetENDPOINT(bEpNum,wRegValue) (*(EP0REG + bEpNum)= \
+ (u16)wRegValue)
+
+/* GetENDPOINT */
+#define _GetENDPOINT(bEpNum) ((u16)(*(EP0REG + bEpNum)))
+
+/*******************************************************************************
+* Macro Name : SetEPType
+* Description : sets the type in the endpoint register(bits EP_TYPE[1:0])
+* Input : bEpNum: Endpoint Number.
+* wType
+* Output : None.
+* Return : None.
+*******************************************************************************/
+#define _SetEPType(bEpNum,wType) (_SetENDPOINT(bEpNum,\
+ ((_GetENDPOINT(bEpNum) & EP_T_MASK) | wType)))
+
+/*******************************************************************************
+* Macro Name : GetEPType
+* Description : gets the type in the endpoint register(bits EP_TYPE[1:0])
+* Input : bEpNum: Endpoint Number.
+* Output : None.
+* Return : Endpoint Type
+*******************************************************************************/
+#define _GetEPType(bEpNum) (_GetENDPOINT(bEpNum) & EP_T_FIELD)
+
+/*******************************************************************************
+* Macro Name : SetEPTxStatus
+* Description : sets the status for tx transfer (bits STAT_TX[1:0]).
+* Input : bEpNum: Endpoint Number.
+* wState: new state
+* Output : None.
+* Return : None.
+*******************************************************************************/
+#define _SetEPTxStatus(bEpNum,wState) {\
+ register u16 _wRegVal; \
+ _wRegVal = _GetENDPOINT(bEpNum) & EPTX_DTOGMASK;\
+ /* toggle first bit ? */ \
+ if((EPTX_DTOG1 & wState)!= 0) \
+ _wRegVal ^= EPTX_DTOG1; \
+ /* toggle second bit ? */ \
+ if((EPTX_DTOG2 & wState)!= 0) \
+ _wRegVal ^= EPTX_DTOG2; \
+ _SetENDPOINT(bEpNum, _wRegVal); \
+ } /* _SetEPTxStatus */
+
+/*******************************************************************************
+* Macro Name : SetEPRxStatus
+* Description : sets the status for rx transfer (bits STAT_TX[1:0])
+* Input : bEpNum: Endpoint Number.
+* wState: new state.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+#define _SetEPRxStatus(bEpNum,wState) {\
+ register u16 _wRegVal; \
+ \
+ _wRegVal = _GetENDPOINT(bEpNum) & EPRX_DTOGMASK;\
+ /* toggle first bit ? */ \
+ if((EPRX_DTOG1 & wState)!= 0) \
+ _wRegVal ^= EPRX_DTOG1; \
+ /* toggle second bit ? */ \
+ if((EPRX_DTOG2 & wState)!= 0) \
+ _wRegVal ^= EPRX_DTOG2; \
+ _SetENDPOINT(bEpNum, _wRegVal); \
+ } /* _SetEPRxStatus */
+/*******************************************************************************
+* Macro Name : GetEPTxStatus / GetEPRxStatus
+* Description : gets the status for tx/rx transfer (bits STAT_TX[1:0]
+* /STAT_RX[1:0])
+* Input : bEpNum: Endpoint Number.
+* Output : None.
+* Return : status .
+*******************************************************************************/
+#define _GetEPTxStatus(bEpNum) ((u16)_GetENDPOINT(bEpNum) & EPTX_STAT)
+
+#define _GetEPRxStatus(bEpNum) ((u16)_GetENDPOINT(bEpNum) & EPRX_STAT)
+
+/*******************************************************************************
+* Macro Name : SetEPTxValid / SetEPRxValid
+* Description : sets directly the VALID tx/rx-status into the enpoint register
+* Input : bEpNum: Endpoint Number.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+#define _SetEPTxValid(bEpNum) (_SetEPTxStatus(bEpNum, EP_TX_VALID))
+
+#define _SetEPRxValid(bEpNum) (_SetEPRxStatus(bEpNum, EP_RX_VALID))
+
+/*******************************************************************************
+* Macro Name : GetTxStallStatus / GetRxStallStatus.
+* Description : checks stall condition in an endpoint.
+* Input : bEpNum: Endpoint Number.
+* Output : None.
+* Return : TRUE = endpoint in stall condition.
+*******************************************************************************/
+#define _GetTxStallStatus(bEpNum) (_GetEPTxStatus(bEpNum) \
+ == EP_TX_STALL)
+#define _GetRxStallStatus(bEpNum) (_GetEPRxStatus(bEpNum) \
+ == EP_RX_STALL)
+
+/*******************************************************************************
+* Macro Name : SetEP_KIND / ClearEP_KIND.
+* Description : set & clear EP_KIND bit.
+* Input : bEpNum: Endpoint Number.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+#define _SetEP_KIND(bEpNum) (_SetENDPOINT(bEpNum, \
+ (_GetENDPOINT(bEpNum) | EP_KIND) & EPREG_MASK))
+#define _ClearEP_KIND(bEpNum) (_SetENDPOINT(bEpNum, \
+ (_GetENDPOINT(bEpNum) & EPKIND_MASK)))
+
+/*******************************************************************************
+* Macro Name : Set_Status_Out / Clear_Status_Out.
+* Description : Sets/clears directly STATUS_OUT bit in the endpoint register.
+* Input : bEpNum: Endpoint Number.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+#define _Set_Status_Out(bEpNum) _SetEP_KIND(bEpNum)
+#define _Clear_Status_Out(bEpNum) _ClearEP_KIND(bEpNum)
+
+/*******************************************************************************
+* Macro Name : SetEPDoubleBuff / ClearEPDoubleBuff.
+* Description : Sets/clears directly EP_KIND bit in the endpoint register.
+* Input : bEpNum: Endpoint Number.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+#define _SetEPDoubleBuff(bEpNum) _SetEP_KIND(bEpNum)
+#define _ClearEPDoubleBuff(bEpNum) _ClearEP_KIND(bEpNum)
+
+/*******************************************************************************
+* Macro Name : ClearEP_CTR_RX / ClearEP_CTR_TX.
+* Description : Clears bit CTR_RX / CTR_TX in the endpoint register.
+* Input : bEpNum: Endpoint Number.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+#define _ClearEP_CTR_RX(bEpNum) (_SetENDPOINT(bEpNum,\
+ _GetENDPOINT(bEpNum) & 0x7FFF & EPREG_MASK))
+#define _ClearEP_CTR_TX(bEpNum) (_SetENDPOINT(bEpNum,\
+ _GetENDPOINT(bEpNum) & 0xFF7F & EPREG_MASK))
+
+/*******************************************************************************
+* Macro Name : ToggleDTOG_RX / ToggleDTOG_TX .
+* Description : Toggles DTOG_RX / DTOG_TX bit in the endpoint register.
+* Input : bEpNum: Endpoint Number.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+#define _ToggleDTOG_RX(bEpNum) (_SetENDPOINT(bEpNum, \
+ EP_DTOG_RX | _GetENDPOINT(bEpNum) & EPREG_MASK))
+#define _ToggleDTOG_TX(bEpNum) (_SetENDPOINT(bEpNum, \
+ EP_DTOG_TX | _GetENDPOINT(bEpNum) & EPREG_MASK))
+
+/*******************************************************************************
+* Macro Name : ClearDTOG_RX / ClearDTOG_TX.
+* Description : Clears DTOG_RX / DTOG_TX bit in the endpoint register.
+* Input : bEpNum: Endpoint Number.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+#define _ClearDTOG_RX(bEpNum) if((_GetENDPOINT(bEpNum) & EP_DTOG_RX) != 0)\
+ _ToggleDTOG_RX(bEpNum)
+#define _ClearDTOG_TX(bEpNum) if((_GetENDPOINT(bEpNum) & EP_DTOG_TX) != 0)\
+ _ToggleDTOG_TX(bEpNum)
+/*******************************************************************************
+* Macro Name : SetEPAddress.
+* Description : Sets address in an endpoint register.
+* Input : bEpNum: Endpoint Number.
+* bAddr: Address.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+#define _SetEPAddress(bEpNum,bAddr) _SetENDPOINT(bEpNum,\
+ _GetENDPOINT(bEpNum) & EPREG_MASK | bAddr)
+
+/*******************************************************************************
+* Macro Name : GetEPAddress.
+* Description : Gets address in an endpoint register.
+* Input : bEpNum: Endpoint Number.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+#define _GetEPAddress(bEpNum) ((u8)(_GetENDPOINT(bEpNum) & EPADDR_FIELD))
+
+#define _pEPTxAddr(bEpNum) ((u32 *)((_GetBTABLE()+bEpNum*8 )*2 + PMAAddr))
+#define _pEPTxCount(bEpNum) ((u32 *)((_GetBTABLE()+bEpNum*8+2)*2 + PMAAddr))
+#define _pEPRxAddr(bEpNum) ((u32 *)((_GetBTABLE()+bEpNum*8+4)*2 + PMAAddr))
+#define _pEPRxCount(bEpNum) ((u32 *)((_GetBTABLE()+bEpNum*8+6)*2 + PMAAddr))
+
+/*******************************************************************************
+* Macro Name : SetEPTxAddr / SetEPRxAddr.
+* Description : sets address of the tx/rx buffer.
+* Input : bEpNum: Endpoint Number.
+* wAddr: address to be set (must be word aligned).
+* Output : None.
+* Return : None.
+*******************************************************************************/
+#define _SetEPTxAddr(bEpNum,wAddr) (*_pEPTxAddr(bEpNum) = ((wAddr >> 1) << 1))
+#define _SetEPRxAddr(bEpNum,wAddr) (*_pEPRxAddr(bEpNum) = ((wAddr >> 1) << 1))
+
+/*******************************************************************************
+* Macro Name : GetEPTxAddr / GetEPRxAddr.
+* Description : Gets address of the tx/rx buffer.
+* Input : bEpNum: Endpoint Number.
+* Output : None.
+* Return : address of the buffer.
+*******************************************************************************/
+#define _GetEPTxAddr(bEpNum) ((u16)*_pEPTxAddr(bEpNum))
+#define _GetEPRxAddr(bEpNum) ((u16)*_pEPRxAddr(bEpNum))
+
+/*******************************************************************************
+* Macro Name : SetEPCountRxReg.
+* Description : Sets counter of rx buffer with no. of blocks.
+* Input : pdwReg: pointer to counter.
+* wCount: Counter.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+#define _BlocksOf32(dwReg,wCount,wNBlocks) {\
+ wNBlocks = wCount >> 5;\
+ if((wCount & 0x1f) == 0)\
+ wNBlocks--;\
+ *pdwReg = (u32)((wNBlocks << 10) | 0x8000);\
+ }/* _BlocksOf32 */
+
+#define _BlocksOf2(dwReg,wCount,wNBlocks) {\
+ wNBlocks = wCount >> 1;\
+ if((wCount & 0x1) != 0)\
+ wNBlocks++;\
+ *pdwReg = (u32)(wNBlocks << 10);\
+ }/* _BlocksOf2 */
+
+#define _SetEPCountRxReg(dwReg,wCount) {\
+ u16 wNBlocks;\
+ if(wCount > 62){_BlocksOf32(dwReg,wCount,wNBlocks);}\
+ else {_BlocksOf2(dwReg,wCount,wNBlocks);}\
+ }/* _SetEPCountRxReg */
+
+
+
+#define _SetEPRxDblBuf0Count(bEpNum,wCount) {\
+ u32 *pdwReg = _pEPTxCount(bEpNum); \
+ _SetEPCountRxReg(pdwReg, wCount);\
+ }
+/*******************************************************************************
+* Macro Name : SetEPTxCount / SetEPRxCount.
+* Description : sets counter for the tx/rx buffer.
+* Input : bEpNum: endpoint number.
+* wCount: Counter value.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+#define _SetEPTxCount(bEpNum,wCount) (*_pEPTxCount(bEpNum) = wCount)
+#define _SetEPRxCount(bEpNum,wCount) {\
+ u32 *pdwReg = _pEPRxCount(bEpNum); \
+ _SetEPCountRxReg(pdwReg, wCount);\
+ }
+/*******************************************************************************
+* Macro Name : GetEPTxCount / GetEPRxCount.
+* Description : gets counter of the tx buffer.
+* Input : bEpNum: endpoint number.
+* Output : None.
+* Return : Counter value.
+*******************************************************************************/
+#define _GetEPTxCount(bEpNum)((u16)(*_pEPTxCount(bEpNum)) & 0x3ff)
+#define _GetEPRxCount(bEpNum)((u16)(*_pEPRxCount(bEpNum)) & 0x3ff)
+
+/*******************************************************************************
+* Macro Name : SetEPDblBuf0Addr / SetEPDblBuf1Addr.
+* Description : Sets buffer 0/1 address in a double buffer endpoint.
+* Input : bEpNum: endpoint number.
+* : wBuf0Addr: buffer 0 address.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+#define _SetEPDblBuf0Addr(bEpNum,wBuf0Addr) {_SetEPTxAddr(bEpNum, wBuf0Addr);}
+#define _SetEPDblBuf1Addr(bEpNum,wBuf1Addr) {_SetEPRxAddr(bEpNum, wBuf1Addr);}
+
+/*******************************************************************************
+* Macro Name : SetEPDblBuffAddr.
+* Description : Sets addresses in a double buffer endpoint.
+* Input : bEpNum: endpoint number.
+* : wBuf0Addr: buffer 0 address.
+* : wBuf1Addr = buffer 1 address.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+#define _SetEPDblBuffAddr(bEpNum,wBuf0Addr,wBuf1Addr) { \
+ _SetEPDblBuf0Addr(bEpNum, wBuf0Addr);\
+ _SetEPDblBuf1Addr(bEpNum, wBuf1Addr);\
+ } /* _SetEPDblBuffAddr */
+
+/*******************************************************************************
+* Macro Name : GetEPDblBuf0Addr / GetEPDblBuf1Addr.
+* Description : Gets buffer 0/1 address of a double buffer endpoint.
+* Input : bEpNum: endpoint number.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+#define _GetEPDblBuf0Addr(bEpNum) (_GetEPTxAddr(bEpNum))
+#define _GetEPDblBuf1Addr(bEpNum) (_GetEPRxAddr(bEpNum))
+
+/*******************************************************************************
+* Macro Name : SetEPDblBuffCount / SetEPDblBuf0Count / SetEPDblBuf1Count.
+* Description : Gets buffer 0/1 address of a double buffer endpoint.
+* Input : bEpNum: endpoint number.
+* : bDir: endpoint dir EP_DBUF_OUT = OUT
+* EP_DBUF_IN = IN
+* : wCount: Counter value
+* Output : None.
+* Return : None.
+*******************************************************************************/
+#define _SetEPDblBuf0Count(bEpNum, bDir, wCount) { \
+ if(bDir == EP_DBUF_OUT)\
+ /* OUT endpoint */ \
+ {_SetEPRxDblBuf0Count(bEpNum,wCount);} \
+ else if(bDir == EP_DBUF_IN)\
+ /* IN endpoint */ \
+ *_pEPTxCount(bEpNum) = (u32)wCount; \
+ } /* SetEPDblBuf0Count*/
+
+#define _SetEPDblBuf1Count(bEpNum, bDir, wCount) { \
+ if(bDir == EP_DBUF_OUT)\
+ /* OUT endpoint */ \
+ {_SetEPRxCount(bEpNum,wCount);}\
+ else if(bDir == EP_DBUF_IN)\
+ /* IN endpoint */\
+ *_pEPRxCount(bEpNum) = (u32)wCount; \
+ } /* SetEPDblBuf1Count */
+
+#define _SetEPDblBuffCount(bEpNum, bDir, wCount) {\
+ _SetEPDblBuf0Count(bEpNum, bDir, wCount); \
+ _SetEPDblBuf1Count(bEpNum, bDir, wCount); \
+ } /* _SetEPDblBuffCount */
+
+/*******************************************************************************
+* Macro Name : GetEPDblBuf0Count / GetEPDblBuf1Count.
+* Description : Gets buffer 0/1 rx/tx counter for double buffering.
+* Input : bEpNum: endpoint number.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+#define _GetEPDblBuf0Count(bEpNum) (_GetEPTxCount(bEpNum))
+#define _GetEPDblBuf1Count(bEpNum) (_GetEPRxCount(bEpNum))
+
+
+/* External variables --------------------------------------------------------*/
+extern volatile u16 wIstr; /* ISTR register last read value */
+
+/* Exported functions ------------------------------------------------------- */
+void SetCNTR(u16 /*wRegValue*/);
+void SetISTR(u16 /*wRegValue*/);
+void SetDADDR(u16 /*wRegValue*/);
+void SetBTABLE(u16 /*wRegValue*/);
+u16 GetCNTR(void);
+u16 GetISTR(void);
+u16 GetFNR(void);
+u16 GetDADDR(void);
+u16 GetBTABLE(void);
+void SetENDPOINT(u8 /*bEpNum*/, u16 /*wRegValue*/);
+u16 GetENDPOINT(u8 /*bEpNum*/);
+void SetEPType(u8 /*bEpNum*/, u16 /*wType*/);
+u16 GetEPType(u8 /*bEpNum*/);
+void SetEPTxStatus(u8 /*bEpNum*/, u16 /*wState*/);
+void SetEPRxStatus(u8 /*bEpNum*/, u16 /*wState*/);
+void SetDouBleBuffEPStall(u8 /*bEpNum*/, u8 bDir);
+u16 GetEPTxStatus(u8 /*bEpNum*/);
+u16 GetEPRxStatus(u8 /*bEpNum*/);
+void SetEPTxValid(u8 /*bEpNum*/);
+void SetEPRxValid(u8 /*bEpNum*/);
+u16 GetTxStallStatus(u8 /*bEpNum*/);
+u16 GetRxStallStatus(u8 /*bEpNum*/);
+void SetEP_KIND(u8 /*bEpNum*/);
+void ClearEP_KIND(u8 /*bEpNum*/);
+void Set_Status_Out(u8 /*bEpNum*/);
+void Clear_Status_Out(u8 /*bEpNum*/);
+void SetEPDoubleBuff(u8 /*bEpNum*/);
+void ClearEPDoubleBuff(u8 /*bEpNum*/);
+void ClearEP_CTR_RX(u8 /*bEpNum*/);
+void ClearEP_CTR_TX(u8 /*bEpNum*/);
+void ToggleDTOG_RX(u8 /*bEpNum*/);
+void ToggleDTOG_TX(u8 /*bEpNum*/);
+void ClearDTOG_RX(u8 /*bEpNum*/);
+void ClearDTOG_TX(u8 /*bEpNum*/);
+void SetEPAddress(u8 /*bEpNum*/, u8 /*bAddr*/);
+u8 GetEPAddress(u8 /*bEpNum*/);
+void SetEPTxAddr(u8 /*bEpNum*/, u16 /*wAddr*/);
+void SetEPRxAddr(u8 /*bEpNum*/, u16 /*wAddr*/);
+u16 GetEPTxAddr(u8 /*bEpNum*/);
+u16 GetEPRxAddr(u8 /*bEpNum*/);
+void SetEPCountRxReg(u32 * /*pdwReg*/, u16 /*wCount*/);
+void SetEPTxCount(u8 /*bEpNum*/, u16 /*wCount*/);
+void SetEPRxCount(u8 /*bEpNum*/, u16 /*wCount*/);
+u16 GetEPTxCount(u8 /*bEpNum*/);
+u16 GetEPRxCount(u8 /*bEpNum*/);
+void SetEPDblBuf0Addr(u8 /*bEpNum*/, u16 /*wBuf0Addr*/);
+void SetEPDblBuf1Addr(u8 /*bEpNum*/, u16 /*wBuf1Addr*/);
+void SetEPDblBuffAddr(u8 /*bEpNum*/, u16 /*wBuf0Addr*/, u16 /*wBuf1Addr*/);
+u16 GetEPDblBuf0Addr(u8 /*bEpNum*/);
+u16 GetEPDblBuf1Addr(u8 /*bEpNum*/);
+void SetEPDblBuffCount(u8 /*bEpNum*/, u8 /*bDir*/, u16 /*wCount*/);
+void SetEPDblBuf0Count(u8 /*bEpNum*/, u8 /*bDir*/, u16 /*wCount*/);
+void SetEPDblBuf1Count(u8 /*bEpNum*/, u8 /*bDir*/, u16 /*wCount*/);
+u16 GetEPDblBuf0Count(u8 /*bEpNum*/);
+u16 GetEPDblBuf1Count(u8 /*bEpNum*/);
+EP_DBUF_DIR GetEPDblBufDir(u8 /*bEpNum*/);
+void FreeUserBuffer(u8 bEpNum/*bEpNum*/, u8 bDir);
+u16 ToWord(u8, u8);
+u16 ByteSwap(u16);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif /* __USB_REGS_H */
+
+/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
diff --git a/libmaple/usb/usb_lib/usb_type.h b/libmaple/usb/usb_lib/usb_type.h
index 1106786..34b3bf5 100644
--- a/libmaple/usb/usb_lib/usb_type.h
+++ b/libmaple/usb/usb_lib/usb_type.h
@@ -1,77 +1,77 @@
-/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
-* File Name : usb_type.h
-* Author : MCD Application Team
-* Version : V2.2.1
-* Date : 09/22/2008
-* Description : Type definitions used by the USB Library
-********************************************************************************
-* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
-* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
-* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
-* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
-* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
-* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
-*******************************************************************************/
-
-/* Define to prevent recursive inclusion -------------------------------------*/
-#ifndef __USB_TYPE_H
-#define __USB_TYPE_H
-
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
-/* Exported types ------------------------------------------------------------*/
-/* Exported constants --------------------------------------------------------*/
-#ifndef NULL
-#define NULL ((void *)0)
-#endif
-
-typedef signed long s32;
-typedef signed short s16;
-typedef signed char s8;
-
-typedef volatile signed long vs32;
-typedef volatile signed short vs16;
-typedef volatile signed char vs8;
-
-typedef unsigned long u32;
-typedef unsigned short u16;
-typedef unsigned char u8;
-
-typedef unsigned long const uc32; /* Read Only */
-typedef unsigned short const uc16; /* Read Only */
-typedef unsigned char const uc8; /* Read Only */
-
-typedef volatile unsigned long vu32;
-typedef volatile unsigned short vu16;
-typedef volatile unsigned char vu8;
-
-typedef volatile unsigned long const vuc32; /* Read Only */
-typedef volatile unsigned short const vuc16; /* Read Only */
-typedef volatile unsigned char const vuc8; /* Read Only */
-
-
-typedef enum
-{
- FALSE = 0, TRUE = !FALSE
-}
-USB_Bool;
-
-typedef enum { RESET = 0, SET = !RESET } FlagStatus, ITStatus;
-
-typedef enum { DISABLE = 0, ENABLE = !DISABLE} FunctionalState;
-
-typedef enum { ERROR = 0, SUCCESS = !ERROR} ErrorStatus;
-
-/* Exported macro ------------------------------------------------------------*/
-/* Exported functions ------------------------------------------------------- */
-/* External variables --------------------------------------------------------*/
-
-#if defined(__cplusplus)
-}
-#endif
-
-#endif /* __USB_TYPE_H */
-
-/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
+/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
+* File Name : usb_type.h
+* Author : MCD Application Team
+* Version : V2.2.1
+* Date : 09/22/2008
+* Description : Type definitions used by the USB Library
+********************************************************************************
+* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
+* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
+* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
+* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
+* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+*******************************************************************************/
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __USB_TYPE_H
+#define __USB_TYPE_H
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+/* Exported types ------------------------------------------------------------*/
+/* Exported constants --------------------------------------------------------*/
+#ifndef NULL
+#define NULL ((void *)0)
+#endif
+
+typedef signed long s32;
+typedef signed short s16;
+typedef signed char s8;
+
+typedef volatile signed long vs32;
+typedef volatile signed short vs16;
+typedef volatile signed char vs8;
+
+typedef unsigned long u32;
+typedef unsigned short u16;
+typedef unsigned char u8;
+
+typedef unsigned long const uc32; /* Read Only */
+typedef unsigned short const uc16; /* Read Only */
+typedef unsigned char const uc8; /* Read Only */
+
+typedef volatile unsigned long vu32;
+typedef volatile unsigned short vu16;
+typedef volatile unsigned char vu8;
+
+typedef volatile unsigned long const vuc32; /* Read Only */
+typedef volatile unsigned short const vuc16; /* Read Only */
+typedef volatile unsigned char const vuc8; /* Read Only */
+
+
+typedef enum
+{
+ FALSE = 0, TRUE = !FALSE
+}
+USB_Bool;
+
+typedef enum { RESET = 0, SET = !RESET } FlagStatus, ITStatus;
+
+typedef enum { DISABLE = 0, ENABLE = !DISABLE} FunctionalState;
+
+typedef enum { ERROR = 0, SUCCESS = !ERROR} ErrorStatus;
+
+/* Exported macro ------------------------------------------------------------*/
+/* Exported functions ------------------------------------------------------- */
+/* External variables --------------------------------------------------------*/
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif /* __USB_TYPE_H */
+
+/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
diff --git a/support/ld/libcs3_stm32_src/Makefile b/support/ld/libcs3_stm32_src/Makefile
index d5275b9..834cdad 100644
--- a/support/ld/libcs3_stm32_src/Makefile
+++ b/support/ld/libcs3_stm32_src/Makefile
@@ -1,35 +1,35 @@
-# setup environment
-
-TARGET_ARCH = -mcpu=cortex-m3 -mthumb
-
-CC = arm-none-eabi-gcc
-CFLAGS =
-
-AS = $(CC) -x assembler-with-cpp -c $(TARGET_ARCH)
-ASFLAGS =
-
-AR = arm-none-eabi-ar
-ARFLAGS = cr
-
-LIB_OBJS = stm32_vector_table.o stm32_isrs.o start.o start_c.o
-
-help:
- @echo "Targets:"
- @echo "\t medium-density: Target medium density chips (e.g. Maple)"
- @echo "\t high-density: Target high density chips (e.g. Maple-native)"
-
-.PHONY: help medium high
-
-medium-density: $(LIB_OBJS)
- $(AR) $(ARFLAGS) libcs3_stm32_med_density.a $(LIB_OBJS)
- rm -f $(LIB_OBJS)
-
-high-density: CFLAGS := -DSTM32_HIGH_DENSITY
-high-density: $(LIB_OBJS)
- $(AR) $(ARFLAGS) libcs3_stm32_high_density.a $(LIB_OBJS)
- rm -f $(LIB_OBJS)
-
-# clean
-.PHONY: clean
-clean:
- -rm -f $(LIB_OBJS) *.a
+# setup environment
+
+TARGET_ARCH = -mcpu=cortex-m3 -mthumb
+
+CC = arm-none-eabi-gcc
+CFLAGS =
+
+AS = $(CC) -x assembler-with-cpp -c $(TARGET_ARCH)
+ASFLAGS =
+
+AR = arm-none-eabi-ar
+ARFLAGS = cr
+
+LIB_OBJS = stm32_vector_table.o stm32_isrs.o start.o start_c.o
+
+help:
+ @echo "Targets:"
+ @echo "\t medium-density: Target medium density chips (e.g. Maple)"
+ @echo "\t high-density: Target high density chips (e.g. Maple-native)"
+
+.PHONY: help medium high
+
+medium-density: $(LIB_OBJS)
+ $(AR) $(ARFLAGS) libcs3_stm32_med_density.a $(LIB_OBJS)
+ rm -f $(LIB_OBJS)
+
+high-density: CFLAGS := -DSTM32_HIGH_DENSITY
+high-density: $(LIB_OBJS)
+ $(AR) $(ARFLAGS) libcs3_stm32_high_density.a $(LIB_OBJS)
+ rm -f $(LIB_OBJS)
+
+# clean
+.PHONY: clean
+clean:
+ -rm -f $(LIB_OBJS) *.a
diff --git a/support/ld/libcs3_stm32_src/start.S b/support/ld/libcs3_stm32_src/start.S
index ae75747..4d1d405 100644
--- a/support/ld/libcs3_stm32_src/start.S
+++ b/support/ld/libcs3_stm32_src/start.S
@@ -1,27 +1,27 @@
-/*
- * The authors hereby grant permission to use, copy, modify, distribute,
- * and license this software and its documentation for any purpose, provided
- * that existing copyright notices are retained in all copies and that this
- * notice is included verbatim in any distributions. No written agreement,
- * license, or royalty fee is required for any of the authorized uses.
- * Modifications to this software may be copyrighted by their authors
- * and need not follow the licensing terms described here, provided that
- * the new terms are clearly indicated on the first page of each file where
- * they apply.
- */
-
- .text
- .code 16
- .thumb_func
-
- .globl _start
- .type _start, %function
-_start:
- .fnstart
- ldr r1,=__cs3_stack
- mov sp,r1
- ldr r1,=__cs3_start_c
- bx r1
- .pool
- .cantunwind
- .fnend
+/*
+ * The authors hereby grant permission to use, copy, modify, distribute,
+ * and license this software and its documentation for any purpose, provided
+ * that existing copyright notices are retained in all copies and that this
+ * notice is included verbatim in any distributions. No written agreement,
+ * license, or royalty fee is required for any of the authorized uses.
+ * Modifications to this software may be copyrighted by their authors
+ * and need not follow the licensing terms described here, provided that
+ * the new terms are clearly indicated on the first page of each file where
+ * they apply.
+ */
+
+ .text
+ .code 16
+ .thumb_func
+
+ .globl _start
+ .type _start, %function
+_start:
+ .fnstart
+ ldr r1,=__cs3_stack
+ mov sp,r1
+ ldr r1,=__cs3_start_c
+ bx r1
+ .pool
+ .cantunwind
+ .fnend
diff --git a/support/ld/libcs3_stm32_src/start_c.c b/support/ld/libcs3_stm32_src/start_c.c
index dff9fa3..2ab0212 100644
--- a/support/ld/libcs3_stm32_src/start_c.c
+++ b/support/ld/libcs3_stm32_src/start_c.c
@@ -1,58 +1,58 @@
-/* CS3 start_c routine.
- *
- * Copyright (c) 2006, 2007 CodeSourcery Inc
- *
- * The authors hereby grant permission to use, copy, modify, distribute,
- * and license this software and its documentation for any purpose, provided
- * that existing copyright notices are retained in all copies and that this
- * notice is included verbatim in any distributions. No written agreement,
- * license, or royalty fee is required for any of the authorized uses.
- * Modifications to this software may be copyrighted by their authors
- * and need not follow the licensing terms described here, provided that
- * the new terms are clearly indicated on the first page of each file where
- * they apply.
- */
-
-#include "cs3.h"
-
-extern void __libc_init_array (void);
-
-extern int main (int, char **, char **);
-
-extern void exit (int) __attribute__ ((noreturn, weak));
-
-void __attribute ((noreturn))
-__cs3_start_c (void)
-{
- unsigned regions = __cs3_region_num;
- const struct __cs3_region *rptr = __cs3_regions;
- int exit_code;
-
- /* Initialize memory */
- for (regions = __cs3_region_num, rptr = __cs3_regions; regions--; rptr++)
- {
- long long *src = (long long *)rptr->init;
- long long *dst = (long long *)rptr->data;
- unsigned limit = rptr->init_size;
- unsigned count;
-
- if (src != dst)
- for (count = 0; count != limit; count += sizeof (long long))
- *dst++ = *src++;
- else
- dst = (long long *)((char *)dst + limit);
- limit = rptr->zero_size;
- for (count = 0; count != limit; count += sizeof (long long))
- *dst++ = 0;
- }
-
- /* Run initializers. */
- __libc_init_array ();
-
- exit_code = main (0, NULL, NULL);
- if (exit)
- exit (exit_code);
- /* If exit is NULL, make sure we don't return. */
- for (;;)
- continue;
-}
+/* CS3 start_c routine.
+ *
+ * Copyright (c) 2006, 2007 CodeSourcery Inc
+ *
+ * The authors hereby grant permission to use, copy, modify, distribute,
+ * and license this software and its documentation for any purpose, provided
+ * that existing copyright notices are retained in all copies and that this
+ * notice is included verbatim in any distributions. No written agreement,
+ * license, or royalty fee is required for any of the authorized uses.
+ * Modifications to this software may be copyrighted by their authors
+ * and need not follow the licensing terms described here, provided that
+ * the new terms are clearly indicated on the first page of each file where
+ * they apply.
+ */
+
+#include "cs3.h"
+
+extern void __libc_init_array (void);
+
+extern int main (int, char **, char **);
+
+extern void exit (int) __attribute__ ((noreturn, weak));
+
+void __attribute ((noreturn))
+__cs3_start_c (void)
+{
+ unsigned regions = __cs3_region_num;
+ const struct __cs3_region *rptr = __cs3_regions;
+ int exit_code;
+
+ /* Initialize memory */
+ for (regions = __cs3_region_num, rptr = __cs3_regions; regions--; rptr++)
+ {
+ long long *src = (long long *)rptr->init;
+ long long *dst = (long long *)rptr->data;
+ unsigned limit = rptr->init_size;
+ unsigned count;
+
+ if (src != dst)
+ for (count = 0; count != limit; count += sizeof (long long))
+ *dst++ = *src++;
+ else
+ dst = (long long *)((char *)dst + limit);
+ limit = rptr->zero_size;
+ for (count = 0; count != limit; count += sizeof (long long))
+ *dst++ = 0;
+ }
+
+ /* Run initializers. */
+ __libc_init_array ();
+
+ exit_code = main (0, NULL, NULL);
+ if (exit)
+ exit (exit_code);
+ /* If exit is NULL, make sure we don't return. */
+ for (;;)
+ continue;
+}
diff --git a/support/ld/libcs3_stm32_src/stm32_isrs.S b/support/ld/libcs3_stm32_src/stm32_isrs.S
index f95468c..be102e7 100644
--- a/support/ld/libcs3_stm32_src/stm32_isrs.S
+++ b/support/ld/libcs3_stm32_src/stm32_isrs.S
@@ -1,235 +1,235 @@
-/* STM32 ISR weak declarations */
-
- .thumb
-
-/* Default handler for all non-overridden interrupts and exceptions */
- .globl __default_handler
- .type __default_handler, %function
-
-__default_handler:
- b .
-
- .weak __exc_nmi
- .globl __exc_nmi
- .set __exc_nmi, __default_handler
- .weak __exc_hardfault
- .globl __exc_hardfault
- .set __exc_hardfault, __default_handler
- .weak __exc_memmanage
- .globl __exc_memmanage
- .set __exc_memmanage, __default_handler
- .weak __exc_busfault
- .globl __exc_busfault
- .set __exc_busfault, __default_handler
- .weak __exc_usagefault
- .globl __exc_usagefault
- .set __exc_usagefault, __default_handler
- .weak __stm32reservedexception7
- .globl __stm32reservedexception7
- .set __stm32reservedexception7, __default_handler
- .weak __stm32reservedexception8
- .globl __stm32reservedexception8
- .set __stm32reservedexception8, __default_handler
- .weak __stm32reservedexception9
- .globl __stm32reservedexception9
- .set __stm32reservedexception9, __default_handler
- .weak __stm32reservedexception10
- .globl __stm32reservedexception10
- .set __stm32reservedexception10, __default_handler
- .weak __exc_svc
- .globl __exc_svc
- .set __exc_svc, __default_handler
- .weak __exc_debug_monitor
- .globl __exc_debug_monitor
- .set __exc_debug_monitor, __default_handler
- .weak __stm32reservedexception13
- .globl __stm32reservedexception13
- .set __stm32reservedexception13, __default_handler
- .weak __exc_pendsv
- .globl __exc_pendsv
- .set __exc_pendsv, __default_handler
- .weak __exc_systick
- .globl __exc_systick
- .set __exc_systick, __default_handler
- .weak __irq_wwdg
- .globl __irq_wwdg
- .set __irq_wwdg, __default_handler
- .weak __irq_pvd
- .globl __irq_pvd
- .set __irq_pvd, __default_handler
- .weak __irq_tamper
- .globl __irq_tamper
- .set __irq_tamper, __default_handler
- .weak __irq_rtc
- .globl __irq_rtc
- .set __irq_rtc, __default_handler
- .weak __irq_flash
- .globl __irq_flash
- .set __irq_flash, __default_handler
- .weak __irq_rcc
- .globl __irq_rcc
- .set __irq_rcc, __default_handler
- .weak __irq_exti0
- .globl __irq_exti0
- .set __irq_exti0, __default_handler
- .weak __irq_exti1
- .globl __irq_exti1
- .set __irq_exti1, __default_handler
- .weak __irq_exti2
- .globl __irq_exti2
- .set __irq_exti2, __default_handler
- .weak __irq_exti3
- .globl __irq_exti3
- .set __irq_exti3, __default_handler
- .weak __irq_exti4
- .globl __irq_exti4
- .set __irq_exti4, __default_handler
- .weak __irq_dma1_channel1
- .globl __irq_dma1_channel1
- .set __irq_dma1_channel1, __default_handler
- .weak __irq_dma1_channel2
- .globl __irq_dma1_channel2
- .set __irq_dma1_channel2, __default_handler
- .weak __irq_dma1_channel3
- .globl __irq_dma1_channel3
- .set __irq_dma1_channel3, __default_handler
- .weak __irq_dma1_channel4
- .globl __irq_dma1_channel4
- .set __irq_dma1_channel4, __default_handler
- .weak __irq_dma1_channel5
- .globl __irq_dma1_channel5
- .set __irq_dma1_channel5, __default_handler
- .weak __irq_dma1_channel6
- .globl __irq_dma1_channel6
- .set __irq_dma1_channel6, __default_handler
- .weak __irq_dma1_channel7
- .globl __irq_dma1_channel7
- .set __irq_dma1_channel7, __default_handler
- .weak __irq_adc
- .globl __irq_adc
- .set __irq_adc, __default_handler
- .weak __irq_usb_hp_can_tx
- .globl __irq_usb_hp_can_tx
- .set __irq_usb_hp_can_tx, __default_handler
- .weak __irq_usb_lp_can_rx0
- .globl __irq_usb_lp_can_rx0
- .set __irq_usb_lp_can_rx0, __default_handler
- .weak __irq_can_rx1
- .globl __irq_can_rx1
- .set __irq_can_rx1, __default_handler
- .weak __irq_can_sce
- .globl __irq_can_sce
- .set __irq_can_sce, __default_handler
- .weak __irq_exti9_5
- .globl __irq_exti9_5
- .set __irq_exti9_5, __default_handler
- .weak __irq_tim1_brk
- .globl __irq_tim1_brk
- .set __irq_tim1_brk, __default_handler
- .weak __irq_tim1_up
- .globl __irq_tim1_up
- .set __irq_tim1_up, __default_handler
- .weak __irq_tim1_trg_com
- .globl __irq_tim1_trg_com
- .set __irq_tim1_trg_com, __default_handler
- .weak __irq_tim1_cc
- .globl __irq_tim1_cc
- .set __irq_tim1_cc, __default_handler
- .weak __irq_tim2
- .globl __irq_tim2
- .set __irq_tim2, __default_handler
- .weak __irq_tim3
- .globl __irq_tim3
- .set __irq_tim3, __default_handler
- .weak __irq_tim4
- .globl __irq_tim4
- .set __irq_tim4, __default_handler
- .weak __irq_i2c1_ev
- .globl __irq_i2c1_ev
- .set __irq_i2c1_ev, __default_handler
- .weak __irq_i2c1_er
- .globl __irq_i2c1_er
- .set __irq_i2c1_er, __default_handler
- .weak __irq_i2c2_ev
- .globl __irq_i2c2_ev
- .set __irq_i2c2_ev, __default_handler
- .weak __irq_i2c2_er
- .globl __irq_i2c2_er
- .set __irq_i2c2_er, __default_handler
- .weak __irq_spi1
- .globl __irq_spi1
- .set __irq_spi1, __default_handler
- .weak __irq_spi2
- .globl __irq_spi2
- .set __irq_spi2, __default_handler
- .weak __irq_usart1
- .globl __irq_usart1
- .set __irq_usart1, __default_handler
- .weak __irq_usart2
- .globl __irq_usart2
- .set __irq_usart2, __default_handler
- .weak __irq_usart3
- .globl __irq_usart3
- .set __irq_usart3, __default_handler
- .weak __irq_exti15_10
- .globl __irq_exti15_10
- .set __irq_exti15_10, __default_handler
- .weak __irq_rtcalarm
- .globl __irq_rtcalarm
- .set __irq_rtcalarm, __default_handler
- .weak __irq_usbwakeup
- .globl __irq_usbwakeup
- .set __irq_usbwakeup, __default_handler
-#if defined (STM32_HIGH_DENSITY)
- .weak __irq_tim8_brk
- .globl __irq_tim8_brk
- .set __irq_tim8_brk, __default_handler
- .weak __irq_tim8_up
- .globl __irq_tim8_up
- .set __irq_tim8_up, __default_handler
- .weak __irq_tim8_trg_com
- .globl __irq_tim8_trg_com
- .set __irq_tim8_trg_com, __default_handler
- .weak __irq_tim8_cc
- .globl __irq_tim8_cc
- .set __irq_tim8_cc, __default_handler
- .weak __irq_adc3
- .globl __irq_adc3
- .set __irq_adc3, __default_handler
- .weak __irq_fsmc
- .globl __irq_fsmc
- .set __irq_fsmc, __default_handler
- .weak __irq_sdio
- .globl __irq_sdio
- .set __irq_sdio, __default_handler
- .weak __irq_tim5
- .globl __irq_tim5
- .set __irq_tim5, __default_handler
- .weak __irq_spi3
- .globl __irq_spi3
- .set __irq_spi3, __default_handler
- .weak __irq_uart4
- .globl __irq_uart4
- .set __irq_uart4, __default_handler
- .weak __irq_uart5
- .globl __irq_uart5
- .set __irq_uart5, __default_handler
- .weak __irq_tim6
- .globl __irq_tim6
- .set __irq_tim6, __default_handler
- .weak __irq_tim7
- .globl __irq_tim7
- .set __irq_tim7, __default_handler
- .weak __irq_dma2_channel1
- .globl __irq_dma2_channel1
- .set __irq_dma2_channel1, __default_handler
- .weak __irq_dma2_channel2
- .globl __irq_dma2_channel2
- .set __irq_dma2_channel2, __default_handler
- .weak __irq_dma2_channel3
- .globl __irq_dma2_channel3
- .set __irq_dma2_channel3, __default_handler
- .weak __irq_dma2_channel4_5
- .globl __irq_dma2_channel4_5
- .set __irq_dma2_channel4_5, __default_handler
-#endif /* STM32_HIGH_DENSITY */
+/* STM32 ISR weak declarations */
+
+ .thumb
+
+/* Default handler for all non-overridden interrupts and exceptions */
+ .globl __default_handler
+ .type __default_handler, %function
+
+__default_handler:
+ b .
+
+ .weak __exc_nmi
+ .globl __exc_nmi
+ .set __exc_nmi, __default_handler
+ .weak __exc_hardfault
+ .globl __exc_hardfault
+ .set __exc_hardfault, __default_handler
+ .weak __exc_memmanage
+ .globl __exc_memmanage
+ .set __exc_memmanage, __default_handler
+ .weak __exc_busfault
+ .globl __exc_busfault
+ .set __exc_busfault, __default_handler
+ .weak __exc_usagefault
+ .globl __exc_usagefault
+ .set __exc_usagefault, __default_handler
+ .weak __stm32reservedexception7
+ .globl __stm32reservedexception7
+ .set __stm32reservedexception7, __default_handler
+ .weak __stm32reservedexception8
+ .globl __stm32reservedexception8
+ .set __stm32reservedexception8, __default_handler
+ .weak __stm32reservedexception9
+ .globl __stm32reservedexception9
+ .set __stm32reservedexception9, __default_handler
+ .weak __stm32reservedexception10
+ .globl __stm32reservedexception10
+ .set __stm32reservedexception10, __default_handler
+ .weak __exc_svc
+ .globl __exc_svc
+ .set __exc_svc, __default_handler
+ .weak __exc_debug_monitor
+ .globl __exc_debug_monitor
+ .set __exc_debug_monitor, __default_handler
+ .weak __stm32reservedexception13
+ .globl __stm32reservedexception13
+ .set __stm32reservedexception13, __default_handler
+ .weak __exc_pendsv
+ .globl __exc_pendsv
+ .set __exc_pendsv, __default_handler
+ .weak __exc_systick
+ .globl __exc_systick
+ .set __exc_systick, __default_handler
+ .weak __irq_wwdg
+ .globl __irq_wwdg
+ .set __irq_wwdg, __default_handler
+ .weak __irq_pvd
+ .globl __irq_pvd
+ .set __irq_pvd, __default_handler
+ .weak __irq_tamper
+ .globl __irq_tamper
+ .set __irq_tamper, __default_handler
+ .weak __irq_rtc
+ .globl __irq_rtc
+ .set __irq_rtc, __default_handler
+ .weak __irq_flash
+ .globl __irq_flash
+ .set __irq_flash, __default_handler
+ .weak __irq_rcc
+ .globl __irq_rcc
+ .set __irq_rcc, __default_handler
+ .weak __irq_exti0
+ .globl __irq_exti0
+ .set __irq_exti0, __default_handler
+ .weak __irq_exti1
+ .globl __irq_exti1
+ .set __irq_exti1, __default_handler
+ .weak __irq_exti2
+ .globl __irq_exti2
+ .set __irq_exti2, __default_handler
+ .weak __irq_exti3
+ .globl __irq_exti3
+ .set __irq_exti3, __default_handler
+ .weak __irq_exti4
+ .globl __irq_exti4
+ .set __irq_exti4, __default_handler
+ .weak __irq_dma1_channel1
+ .globl __irq_dma1_channel1
+ .set __irq_dma1_channel1, __default_handler
+ .weak __irq_dma1_channel2
+ .globl __irq_dma1_channel2
+ .set __irq_dma1_channel2, __default_handler
+ .weak __irq_dma1_channel3
+ .globl __irq_dma1_channel3
+ .set __irq_dma1_channel3, __default_handler
+ .weak __irq_dma1_channel4
+ .globl __irq_dma1_channel4
+ .set __irq_dma1_channel4, __default_handler
+ .weak __irq_dma1_channel5
+ .globl __irq_dma1_channel5
+ .set __irq_dma1_channel5, __default_handler
+ .weak __irq_dma1_channel6
+ .globl __irq_dma1_channel6
+ .set __irq_dma1_channel6, __default_handler
+ .weak __irq_dma1_channel7
+ .globl __irq_dma1_channel7
+ .set __irq_dma1_channel7, __default_handler
+ .weak __irq_adc
+ .globl __irq_adc
+ .set __irq_adc, __default_handler
+ .weak __irq_usb_hp_can_tx
+ .globl __irq_usb_hp_can_tx
+ .set __irq_usb_hp_can_tx, __default_handler
+ .weak __irq_usb_lp_can_rx0
+ .globl __irq_usb_lp_can_rx0
+ .set __irq_usb_lp_can_rx0, __default_handler
+ .weak __irq_can_rx1
+ .globl __irq_can_rx1
+ .set __irq_can_rx1, __default_handler
+ .weak __irq_can_sce
+ .globl __irq_can_sce
+ .set __irq_can_sce, __default_handler
+ .weak __irq_exti9_5
+ .globl __irq_exti9_5
+ .set __irq_exti9_5, __default_handler
+ .weak __irq_tim1_brk
+ .globl __irq_tim1_brk
+ .set __irq_tim1_brk, __default_handler
+ .weak __irq_tim1_up
+ .globl __irq_tim1_up
+ .set __irq_tim1_up, __default_handler
+ .weak __irq_tim1_trg_com
+ .globl __irq_tim1_trg_com
+ .set __irq_tim1_trg_com, __default_handler
+ .weak __irq_tim1_cc
+ .globl __irq_tim1_cc
+ .set __irq_tim1_cc, __default_handler
+ .weak __irq_tim2
+ .globl __irq_tim2
+ .set __irq_tim2, __default_handler
+ .weak __irq_tim3
+ .globl __irq_tim3
+ .set __irq_tim3, __default_handler
+ .weak __irq_tim4
+ .globl __irq_tim4
+ .set __irq_tim4, __default_handler
+ .weak __irq_i2c1_ev
+ .globl __irq_i2c1_ev
+ .set __irq_i2c1_ev, __default_handler
+ .weak __irq_i2c1_er
+ .globl __irq_i2c1_er
+ .set __irq_i2c1_er, __default_handler
+ .weak __irq_i2c2_ev
+ .globl __irq_i2c2_ev
+ .set __irq_i2c2_ev, __default_handler
+ .weak __irq_i2c2_er
+ .globl __irq_i2c2_er
+ .set __irq_i2c2_er, __default_handler
+ .weak __irq_spi1
+ .globl __irq_spi1
+ .set __irq_spi1, __default_handler
+ .weak __irq_spi2
+ .globl __irq_spi2
+ .set __irq_spi2, __default_handler
+ .weak __irq_usart1
+ .globl __irq_usart1
+ .set __irq_usart1, __default_handler
+ .weak __irq_usart2
+ .globl __irq_usart2
+ .set __irq_usart2, __default_handler
+ .weak __irq_usart3
+ .globl __irq_usart3
+ .set __irq_usart3, __default_handler
+ .weak __irq_exti15_10
+ .globl __irq_exti15_10
+ .set __irq_exti15_10, __default_handler
+ .weak __irq_rtcalarm
+ .globl __irq_rtcalarm
+ .set __irq_rtcalarm, __default_handler
+ .weak __irq_usbwakeup
+ .globl __irq_usbwakeup
+ .set __irq_usbwakeup, __default_handler
+#if defined (STM32_HIGH_DENSITY)
+ .weak __irq_tim8_brk
+ .globl __irq_tim8_brk
+ .set __irq_tim8_brk, __default_handler
+ .weak __irq_tim8_up
+ .globl __irq_tim8_up
+ .set __irq_tim8_up, __default_handler
+ .weak __irq_tim8_trg_com
+ .globl __irq_tim8_trg_com
+ .set __irq_tim8_trg_com, __default_handler
+ .weak __irq_tim8_cc
+ .globl __irq_tim8_cc
+ .set __irq_tim8_cc, __default_handler
+ .weak __irq_adc3
+ .globl __irq_adc3
+ .set __irq_adc3, __default_handler
+ .weak __irq_fsmc
+ .globl __irq_fsmc
+ .set __irq_fsmc, __default_handler
+ .weak __irq_sdio
+ .globl __irq_sdio
+ .set __irq_sdio, __default_handler
+ .weak __irq_tim5
+ .globl __irq_tim5
+ .set __irq_tim5, __default_handler
+ .weak __irq_spi3
+ .globl __irq_spi3
+ .set __irq_spi3, __default_handler
+ .weak __irq_uart4
+ .globl __irq_uart4
+ .set __irq_uart4, __default_handler
+ .weak __irq_uart5
+ .globl __irq_uart5
+ .set __irq_uart5, __default_handler
+ .weak __irq_tim6
+ .globl __irq_tim6
+ .set __irq_tim6, __default_handler
+ .weak __irq_tim7
+ .globl __irq_tim7
+ .set __irq_tim7, __default_handler
+ .weak __irq_dma2_channel1
+ .globl __irq_dma2_channel1
+ .set __irq_dma2_channel1, __default_handler
+ .weak __irq_dma2_channel2
+ .globl __irq_dma2_channel2
+ .set __irq_dma2_channel2, __default_handler
+ .weak __irq_dma2_channel3
+ .globl __irq_dma2_channel3
+ .set __irq_dma2_channel3, __default_handler
+ .weak __irq_dma2_channel4_5
+ .globl __irq_dma2_channel4_5
+ .set __irq_dma2_channel4_5, __default_handler
+#endif /* STM32_HIGH_DENSITY */
diff --git a/support/ld/libcs3_stm32_src/stm32_vector_table.S b/support/ld/libcs3_stm32_src/stm32_vector_table.S
index c3f0fc7..868cb6c 100644
--- a/support/ld/libcs3_stm32_src/stm32_vector_table.S
+++ b/support/ld/libcs3_stm32_src/stm32_vector_table.S
@@ -1,90 +1,90 @@
-/* STM32 vector table */
-
- .section ".cs3.interrupt_vector"
-
- .globl __cs3_stm32_vector_table
- .type __cs3_stm32_vector_table, %object
-
-__cs3_stm32_vector_table:
-/* CM3 core interrupts */
- .long __cs3_stack
- .long __cs3_reset
- .long __exc_nmi
- .long __exc_hardfault
- .long __exc_memmanage
- .long __exc_busfault
- .long __exc_usagefault
- .long __stm32reservedexception7
- .long __stm32reservedexception8
- .long __stm32reservedexception9
- .long __stm32reservedexception10
- .long __exc_svc
- .long __exc_debug_monitor
- .long __stm32reservedexception13
- .long __exc_pendsv
- .long __exc_systick
-/* Peripheral interrupts */
- .long __irq_wwdg
- .long __irq_pvd
- .long __irq_tamper
- .long __irq_rtc
- .long __irq_flash
- .long __irq_rcc
- .long __irq_exti0
- .long __irq_exti1
- .long __irq_exti2
- .long __irq_exti3
- .long __irq_exti4
- .long __irq_dma1_channel1
- .long __irq_dma1_channel2
- .long __irq_dma1_channel3
- .long __irq_dma1_channel4
- .long __irq_dma1_channel5
- .long __irq_dma1_channel6
- .long __irq_dma1_channel7
- .long __irq_adc
- .long __irq_usb_hp_can_tx
- .long __irq_usb_lp_can_rx0
- .long __irq_can_rx1
- .long __irq_can_sce
- .long __irq_exti9_5
- .long __irq_tim1_brk
- .long __irq_tim1_up
- .long __irq_tim1_trg_com
- .long __irq_tim1_cc
- .long __irq_tim2
- .long __irq_tim3
- .long __irq_tim4
- .long __irq_i2c1_ev
- .long __irq_i2c1_er
- .long __irq_i2c2_ev
- .long __irq_i2c2_er
- .long __irq_spi1
- .long __irq_spi2
- .long __irq_usart1
- .long __irq_usart2
- .long __irq_usart3
- .long __irq_exti15_10
- .long __irq_rtcalarm
- .long __irq_usbwakeup
-#if defined (STM32_HIGH_DENSITY)
- .long __irq_tim8_brk
- .long __irq_tim8_up
- .long __irq_tim8_trg_com
- .long __irq_tim8_cc
- .long __irq_adc3
- .long __irq_fsmc
- .long __irq_sdio
- .long __irq_tim5
- .long __irq_spi3
- .long __irq_uart4
- .long __irq_uart5
- .long __irq_tim6
- .long __irq_tim7
- .long __irq_dma2_channel1
- .long __irq_dma2_channel2
- .long __irq_dma2_channel3
- .long __irq_dma2_channel4_5
-#endif /* STM32_HIGH_DENSITY */
-
- .size __cs3_stm32_vector_table, . - __cs3_stm32_vector_table
+/* STM32 vector table */
+
+ .section ".cs3.interrupt_vector"
+
+ .globl __cs3_stm32_vector_table
+ .type __cs3_stm32_vector_table, %object
+
+__cs3_stm32_vector_table:
+/* CM3 core interrupts */
+ .long __cs3_stack
+ .long __cs3_reset
+ .long __exc_nmi
+ .long __exc_hardfault
+ .long __exc_memmanage
+ .long __exc_busfault
+ .long __exc_usagefault
+ .long __stm32reservedexception7
+ .long __stm32reservedexception8
+ .long __stm32reservedexception9
+ .long __stm32reservedexception10
+ .long __exc_svc
+ .long __exc_debug_monitor
+ .long __stm32reservedexception13
+ .long __exc_pendsv
+ .long __exc_systick
+/* Peripheral interrupts */
+ .long __irq_wwdg
+ .long __irq_pvd
+ .long __irq_tamper
+ .long __irq_rtc
+ .long __irq_flash
+ .long __irq_rcc
+ .long __irq_exti0
+ .long __irq_exti1
+ .long __irq_exti2
+ .long __irq_exti3
+ .long __irq_exti4
+ .long __irq_dma1_channel1
+ .long __irq_dma1_channel2
+ .long __irq_dma1_channel3
+ .long __irq_dma1_channel4
+ .long __irq_dma1_channel5
+ .long __irq_dma1_channel6
+ .long __irq_dma1_channel7
+ .long __irq_adc
+ .long __irq_usb_hp_can_tx
+ .long __irq_usb_lp_can_rx0
+ .long __irq_can_rx1
+ .long __irq_can_sce
+ .long __irq_exti9_5
+ .long __irq_tim1_brk
+ .long __irq_tim1_up
+ .long __irq_tim1_trg_com
+ .long __irq_tim1_cc
+ .long __irq_tim2
+ .long __irq_tim3
+ .long __irq_tim4
+ .long __irq_i2c1_ev
+ .long __irq_i2c1_er
+ .long __irq_i2c2_ev
+ .long __irq_i2c2_er
+ .long __irq_spi1
+ .long __irq_spi2
+ .long __irq_usart1
+ .long __irq_usart2
+ .long __irq_usart3
+ .long __irq_exti15_10
+ .long __irq_rtcalarm
+ .long __irq_usbwakeup
+#if defined (STM32_HIGH_DENSITY)
+ .long __irq_tim8_brk
+ .long __irq_tim8_up
+ .long __irq_tim8_trg_com
+ .long __irq_tim8_cc
+ .long __irq_adc3
+ .long __irq_fsmc
+ .long __irq_sdio
+ .long __irq_tim5
+ .long __irq_spi3
+ .long __irq_uart4
+ .long __irq_uart5
+ .long __irq_tim6
+ .long __irq_tim7
+ .long __irq_dma2_channel1
+ .long __irq_dma2_channel2
+ .long __irq_dma2_channel3
+ .long __irq_dma2_channel4_5
+#endif /* STM32_HIGH_DENSITY */
+
+ .size __cs3_stm32_vector_table, . - __cs3_stm32_vector_table
diff --git a/support/ld/maple/flash.ld b/support/ld/maple/flash.ld
index 9c3efcb..44b0854 100644
--- a/support/ld/maple/flash.ld
+++ b/support/ld/maple/flash.ld
@@ -1,28 +1,28 @@
-/*
- * Linker script for STM32.
- * STM32F103RBT6 medium density chip linker script for use with
- * maple bootloader. Loads to flash.
- */
-
-/*
- * Define memory spaces.
- */
-MEMORY
-{
- ram (rwx) : ORIGIN = 0x20000C00, LENGTH = 17K
- rom (rx) : ORIGIN = 0x08005000, LENGTH = 108K
-}
-
-/*
- * Use medium density device vector table
- */
-GROUP(libcs3_stm32_med_density.a)
-
-REGION_ALIAS("REGION_TEXT", rom);
-REGION_ALIAS("REGION_DATA", ram);
-REGION_ALIAS("REGION_BSS", ram);
-
-/*
- * Define the rest of the sections
- */
-INCLUDE common_rom.inc
+/*
+ * Linker script for STM32.
+ * STM32F103RBT6 medium density chip linker script for use with
+ * maple bootloader. Loads to flash.
+ */
+
+/*
+ * Define memory spaces.
+ */
+MEMORY
+{
+ ram (rwx) : ORIGIN = 0x20000C00, LENGTH = 17K
+ rom (rx) : ORIGIN = 0x08005000, LENGTH = 108K
+}
+
+/*
+ * Use medium density device vector table
+ */
+GROUP(libcs3_stm32_med_density.a)
+
+REGION_ALIAS("REGION_TEXT", rom);
+REGION_ALIAS("REGION_DATA", ram);
+REGION_ALIAS("REGION_BSS", ram);
+
+/*
+ * Define the rest of the sections
+ */
+INCLUDE common_rom.inc
diff --git a/support/ld/maple/jtag.ld b/support/ld/maple/jtag.ld
index caf90ee..ceda9c9 100644
--- a/support/ld/maple/jtag.ld
+++ b/support/ld/maple/jtag.ld
@@ -1,28 +1,28 @@
-/*
- * Linker script for STM32.
- * STM32F103RBT6 medium density chip linker script.
- */
-
-/*
- * Define memory spaces.
- */
-MEMORY
-{
- ram (rwx) : ORIGIN = 0x20000000, LENGTH = 20K
- rom (rx) : ORIGIN = 0x08000000, LENGTH = 128K
-}
-
-/*
- * Use medium density device vector table
- */
-GROUP(libcs3_stm32_med_density.a)
-
-REGION_ALIAS("REGION_TEXT", rom);
-REGION_ALIAS("REGION_DATA", ram);
-REGION_ALIAS("REGION_BSS", ram);
-
-/*
- * Define the rest of the sections
- */
-INCLUDE common_rom.inc
-
+/*
+ * Linker script for STM32.
+ * STM32F103RBT6 medium density chip linker script.
+ */
+
+/*
+ * Define memory spaces.
+ */
+MEMORY
+{
+ ram (rwx) : ORIGIN = 0x20000000, LENGTH = 20K
+ rom (rx) : ORIGIN = 0x08000000, LENGTH = 128K
+}
+
+/*
+ * Use medium density device vector table
+ */
+GROUP(libcs3_stm32_med_density.a)
+
+REGION_ALIAS("REGION_TEXT", rom);
+REGION_ALIAS("REGION_DATA", ram);
+REGION_ALIAS("REGION_BSS", ram);
+
+/*
+ * Define the rest of the sections
+ */
+INCLUDE common_rom.inc
+
diff --git a/support/ld/maple/ram.ld b/support/ld/maple/ram.ld
index b1e285e..67391be 100644
--- a/support/ld/maple/ram.ld
+++ b/support/ld/maple/ram.ld
@@ -1,27 +1,27 @@
-/*
- * Linker script for STM32.
- * STM32F103RBT6 medium density chip linker script. Loads to ram.
- */
-
-/*
- * Define memory spaces.
- */
-MEMORY
-{
- ram (rwx) : ORIGIN = 0x20000C00, LENGTH = 17K
- rom (rx) : ORIGIN = 0x08005000, LENGTH = 0K
-}
-
-/*
- * Use medium density device vector table
- */
-GROUP(libcs3_stm32_med_density.a)
-
-REGION_ALIAS("REGION_TEXT", ram);
-REGION_ALIAS("REGION_DATA", ram);
-REGION_ALIAS("REGION_BSS", ram);
-
-/*
- * Define the rest of the sections
- */
-INCLUDE common_ram.inc
+/*
+ * Linker script for STM32.
+ * STM32F103RBT6 medium density chip linker script. Loads to ram.
+ */
+
+/*
+ * Define memory spaces.
+ */
+MEMORY
+{
+ ram (rwx) : ORIGIN = 0x20000C00, LENGTH = 17K
+ rom (rx) : ORIGIN = 0x08005000, LENGTH = 0K
+}
+
+/*
+ * Use medium density device vector table
+ */
+GROUP(libcs3_stm32_med_density.a)
+
+REGION_ALIAS("REGION_TEXT", ram);
+REGION_ALIAS("REGION_DATA", ram);
+REGION_ALIAS("REGION_BSS", ram);
+
+/*
+ * Define the rest of the sections
+ */
+INCLUDE common_ram.inc
diff --git a/support/ld/maple_mini/flash.ld b/support/ld/maple_mini/flash.ld
index 4c26da2..b3eb557 100644
--- a/support/ld/maple_mini/flash.ld
+++ b/support/ld/maple_mini/flash.ld
@@ -1,27 +1,27 @@
-/*
- * Linker script for STM32.
- * Maple mini flash linker script.
- */
-
-/*
- * Define memory spaces.
- */
-MEMORY
-{
- ram (rwx) : ORIGIN = 0x20000C00, LENGTH = 17K
- rom (rx) : ORIGIN = 0x08005000, LENGTH = 108K
-}
-
-/*
- * Use medium density device vector table
- */
-GROUP(libcs3_stm32_med_density.a)
-
-REGION_ALIAS("REGION_TEXT", rom);
-REGION_ALIAS("REGION_DATA", ram);
-REGION_ALIAS("REGION_BSS", ram);
-
-/*
- * Define the rest of the sections
- */
-INCLUDE common_rom.inc
+/*
+ * Linker script for STM32.
+ * Maple mini flash linker script.
+ */
+
+/*
+ * Define memory spaces.
+ */
+MEMORY
+{
+ ram (rwx) : ORIGIN = 0x20000C00, LENGTH = 17K
+ rom (rx) : ORIGIN = 0x08005000, LENGTH = 108K
+}
+
+/*
+ * Use medium density device vector table
+ */
+GROUP(libcs3_stm32_med_density.a)
+
+REGION_ALIAS("REGION_TEXT", rom);
+REGION_ALIAS("REGION_DATA", ram);
+REGION_ALIAS("REGION_BSS", ram);
+
+/*
+ * Define the rest of the sections
+ */
+INCLUDE common_rom.inc
diff --git a/support/ld/maple_mini/jtag.ld b/support/ld/maple_mini/jtag.ld
index 31768ed..cdf2cc9 100644
--- a/support/ld/maple_mini/jtag.ld
+++ b/support/ld/maple_mini/jtag.ld
@@ -1,28 +1,28 @@
-/*
- * Linker script for STM32.
- * Maple mini linker script bare metal target linker script.
- */
-
-/*
- * Define memory spaces.
- */
-MEMORY
-{
- ram (rwx) : ORIGIN = 0x20000000, LENGTH = 20K
- rom (rx) : ORIGIN = 0x08000000, LENGTH = 128K
-}
-
-/*
- * Use medium density device vector table
- */
-GROUP(libcs3_stm32_med_density.a)
-
-REGION_ALIAS("REGION_TEXT", rom);
-REGION_ALIAS("REGION_DATA", ram);
-REGION_ALIAS("REGION_BSS", ram);
-
-/*
- * Define the rest of the sections
- */
-INCLUDE common_rom.inc
-
+/*
+ * Linker script for STM32.
+ * Maple mini linker script bare metal target linker script.
+ */
+
+/*
+ * Define memory spaces.
+ */
+MEMORY
+{
+ ram (rwx) : ORIGIN = 0x20000000, LENGTH = 20K
+ rom (rx) : ORIGIN = 0x08000000, LENGTH = 128K
+}
+
+/*
+ * Use medium density device vector table
+ */
+GROUP(libcs3_stm32_med_density.a)
+
+REGION_ALIAS("REGION_TEXT", rom);
+REGION_ALIAS("REGION_DATA", ram);
+REGION_ALIAS("REGION_BSS", ram);
+
+/*
+ * Define the rest of the sections
+ */
+INCLUDE common_rom.inc
+
diff --git a/support/ld/maple_mini/ram.ld b/support/ld/maple_mini/ram.ld
index 7dd7ee5..b8516de 100644
--- a/support/ld/maple_mini/ram.ld
+++ b/support/ld/maple_mini/ram.ld
@@ -1,27 +1,27 @@
-/*
- * Linker script for STM32.
- * Maple mini ram target linker script.
- */
-
-/*
- * Define memory spaces.
- */
-MEMORY
-{
- ram (rwx) : ORIGIN = 0x20000C00, LENGTH = 17K
- rom (rx) : ORIGIN = 0x08005000, LENGTH = 0K
-}
-
-/*
- * Use medium density device vector table
- */
-GROUP(libcs3_stm32_med_density.a)
-
-REGION_ALIAS("REGION_TEXT", ram);
-REGION_ALIAS("REGION_DATA", ram);
-REGION_ALIAS("REGION_BSS", ram);
-
-/*
- * Define the rest of the sections
- */
-INCLUDE common_ram.inc
+/*
+ * Linker script for STM32.
+ * Maple mini ram target linker script.
+ */
+
+/*
+ * Define memory spaces.
+ */
+MEMORY
+{
+ ram (rwx) : ORIGIN = 0x20000C00, LENGTH = 17K
+ rom (rx) : ORIGIN = 0x08005000, LENGTH = 0K
+}
+
+/*
+ * Use medium density device vector table
+ */
+GROUP(libcs3_stm32_med_density.a)
+
+REGION_ALIAS("REGION_TEXT", ram);
+REGION_ALIAS("REGION_DATA", ram);
+REGION_ALIAS("REGION_BSS", ram);
+
+/*
+ * Define the rest of the sections
+ */
+INCLUDE common_ram.inc
diff --git a/support/ld/maple_native/flash.ld b/support/ld/maple_native/flash.ld
index 4358419..e4d61d1 100644
--- a/support/ld/maple_native/flash.ld
+++ b/support/ld/maple_native/flash.ld
@@ -1,22 +1,22 @@
-/*
- * Linker script for STM32.
- * STM32 high density chip linker script. Loads to flash with Maple bootloader
- */
-
-MEMORY
-{
- ram (rwx) : ORIGIN = 0x20000C00, LENGTH = 61K
- rom (rx) : ORIGIN = 0x08005000, LENGTH = 492K
-}
-
-/*
- * Use high density device vector table
- */
-GROUP(libcs3_stm32_high_density.a)
-
-REGION_ALIAS("REGION_TEXT", rom);
-REGION_ALIAS("REGION_DATA", ram);
-REGION_ALIAS("REGION_BSS", ram);
-
-INCLUDE common_rom.inc
-
+/*
+ * Linker script for STM32.
+ * STM32 high density chip linker script. Loads to flash with Maple bootloader
+ */
+
+MEMORY
+{
+ ram (rwx) : ORIGIN = 0x20000C00, LENGTH = 61K
+ rom (rx) : ORIGIN = 0x08005000, LENGTH = 492K
+}
+
+/*
+ * Use high density device vector table
+ */
+GROUP(libcs3_stm32_high_density.a)
+
+REGION_ALIAS("REGION_TEXT", rom);
+REGION_ALIAS("REGION_DATA", ram);
+REGION_ALIAS("REGION_BSS", ram);
+
+INCLUDE common_rom.inc
+
diff --git a/support/ld/maple_native/jtag.ld b/support/ld/maple_native/jtag.ld
index 0e99c3b..2264d69 100644
--- a/support/ld/maple_native/jtag.ld
+++ b/support/ld/maple_native/jtag.ld
@@ -1,21 +1,21 @@
-/*
- * Linker script for STM32.
- * STM32 high density chip linker script. Bare metal linker script.
- */
-MEMORY
-{
- ram (rwx) : ORIGIN = 0x20000000, LENGTH = 64K
- rom (rx) : ORIGIN = 0x08000000, LENGTH = 512K
-}
-
-/*
- * Use high density device vector table
- */
-GROUP(libcs3_stm32_high_density.a)
-
-REGION_ALIAS("REGION_TEXT", rom);
-REGION_ALIAS("REGION_DATA", ram);
-REGION_ALIAS("REGION_BSS", ram);
-
-INCLUDE common_rom.inc
-
+/*
+ * Linker script for STM32.
+ * STM32 high density chip linker script. Bare metal linker script.
+ */
+MEMORY
+{
+ ram (rwx) : ORIGIN = 0x20000000, LENGTH = 64K
+ rom (rx) : ORIGIN = 0x08000000, LENGTH = 512K
+}
+
+/*
+ * Use high density device vector table
+ */
+GROUP(libcs3_stm32_high_density.a)
+
+REGION_ALIAS("REGION_TEXT", rom);
+REGION_ALIAS("REGION_DATA", ram);
+REGION_ALIAS("REGION_BSS", ram);
+
+INCLUDE common_rom.inc
+
diff --git a/support/ld/maple_native/ram.ld b/support/ld/maple_native/ram.ld
index d5bd3b0..c3f418f 100644
--- a/support/ld/maple_native/ram.ld
+++ b/support/ld/maple_native/ram.ld
@@ -1,21 +1,21 @@
-/*
- * Linker script for STM32.
- * STM32 high density chip linker script. Loads to RAM with Maple bootloader
- */
-
-MEMORY
-{
- ram (rwx) : ORIGIN = 0x20000C00, LENGTH = 61K
- rom (rx) : ORIGIN = 0x08005000, LENGTH = 0K
-}
-
-/*
- * Use high density device vector table
- */
-GROUP(libcs3_stm32_high_density.a)
-
-REGION_ALIAS("REGION_TEXT", ram);
-REGION_ALIAS("REGION_DATA", ram);
-REGION_ALIAS("REGION_BSS", ram);
-
-INCLUDE common_ram.inc
+/*
+ * Linker script for STM32.
+ * STM32 high density chip linker script. Loads to RAM with Maple bootloader
+ */
+
+MEMORY
+{
+ ram (rwx) : ORIGIN = 0x20000C00, LENGTH = 61K
+ rom (rx) : ORIGIN = 0x08005000, LENGTH = 0K
+}
+
+/*
+ * Use high density device vector table
+ */
+GROUP(libcs3_stm32_high_density.a)
+
+REGION_ALIAS("REGION_TEXT", ram);
+REGION_ALIAS("REGION_DATA", ram);
+REGION_ALIAS("REGION_BSS", ram);
+
+INCLUDE common_ram.inc
diff --git a/support/ld/names.inc b/support/ld/names.inc
index 9fab36c..4045836 100644
--- a/support/ld/names.inc
+++ b/support/ld/names.inc
@@ -1,78 +1,78 @@
-EXTERN(__cs3_stack)
-EXTERN(__cs3_reset)
-EXTERN(__exc_nmi)
-EXTERN(__exc_hardfault)
-EXTERN(__exc_memmanage)
-EXTERN(__exc_busfault)
-EXTERN(__exc_usagefault)
-EXTERN(__stm32reservedexception7)
-EXTERN(__stm32reservedexception8)
-EXTERN(__stm32reservedexception9)
-EXTERN(__stm32reservedexception10)
-EXTERN(__exc_svc)
-EXTERN(__exc_debug_monitor)
-EXTERN(__stm32reservedexception13)
-EXTERN(__exc_pendsv)
-EXTERN(__exc_systick)
-
-EXTERN(__irq_wwdg)
-EXTERN(__irq_pvd)
-EXTERN(__irq_tamper)
-EXTERN(__irq_rtc)
-EXTERN(__irq_flash)
-EXTERN(__irq_rcc)
-EXTERN(__irq_exti0)
-EXTERN(__irq_exti1)
-EXTERN(__irq_exti2)
-EXTERN(__irq_exti3)
-EXTERN(__irq_exti4)
-EXTERN(__irq_dma_channel1)
-EXTERN(__irq_dma_channel2)
-EXTERN(__irq_dma_channel3)
-EXTERN(__irq_dma_channel4)
-EXTERN(__irq_dma_channel5)
-EXTERN(__irq_dma_channel6)
-EXTERN(__irq_dma_channel7)
-EXTERN(__irq_adc)
-EXTERN(__irq_usb_hp_can_tx)
-EXTERN(__irq_usb_lp_can_rx0)
-EXTERN(__irq_can_rx1)
-EXTERN(__irq_can_sce)
-EXTERN(__irq_exti9_5)
-EXTERN(__irq_tim1_brk)
-EXTERN(__irq_tim1_up)
-EXTERN(__irq_tim1_trg_com)
-EXTERN(__irq_tim1_cc)
-EXTERN(__irq_tim2)
-EXTERN(__irq_tim3)
-EXTERN(__irq_tim4)
-EXTERN(__irq_i2c1_ev)
-EXTERN(__irq_i2c1_er)
-EXTERN(__irq_i2c2_ev)
-EXTERN(__irq_i2c2_er)
-EXTERN(__irq_spi1)
-EXTERN(__irq_spi2)
-EXTERN(__irq_usart1)
-EXTERN(__irq_usart2)
-EXTERN(__irq_usart3)
-EXTERN(__irq_exti15_10)
-EXTERN(__irq_rtcalarm)
-EXTERN(__irq_usbwakeup)
-
-EXTERN(__irq_tim8_brk)
-EXTERN(__irq_tim8_up)
-EXTERN(__irq_tim8_trg_com)
-EXTERN(__irq_tim8_cc)
-EXTERN(__irq_adc3)
-EXTERN(__irq_fsmc)
-EXTERN(__irq_sdio)
-EXTERN(__irq_tim5)
-EXTERN(__irq_spi3)
-EXTERN(__irq_uart4)
-EXTERN(__irq_uart5)
-EXTERN(__irq_tim6)
-EXTERN(__irq_tim7)
-EXTERN(__irq_dma2_channel1)
-EXTERN(__irq_dma2_channel2)
-EXTERN(__irq_dma2_channel3)
-EXTERN(__irq_dma2_channel4_5)
+EXTERN(__cs3_stack)
+EXTERN(__cs3_reset)
+EXTERN(__exc_nmi)
+EXTERN(__exc_hardfault)
+EXTERN(__exc_memmanage)
+EXTERN(__exc_busfault)
+EXTERN(__exc_usagefault)
+EXTERN(__stm32reservedexception7)
+EXTERN(__stm32reservedexception8)
+EXTERN(__stm32reservedexception9)
+EXTERN(__stm32reservedexception10)
+EXTERN(__exc_svc)
+EXTERN(__exc_debug_monitor)
+EXTERN(__stm32reservedexception13)
+EXTERN(__exc_pendsv)
+EXTERN(__exc_systick)
+
+EXTERN(__irq_wwdg)
+EXTERN(__irq_pvd)
+EXTERN(__irq_tamper)
+EXTERN(__irq_rtc)
+EXTERN(__irq_flash)
+EXTERN(__irq_rcc)
+EXTERN(__irq_exti0)
+EXTERN(__irq_exti1)
+EXTERN(__irq_exti2)
+EXTERN(__irq_exti3)
+EXTERN(__irq_exti4)
+EXTERN(__irq_dma_channel1)
+EXTERN(__irq_dma_channel2)
+EXTERN(__irq_dma_channel3)
+EXTERN(__irq_dma_channel4)
+EXTERN(__irq_dma_channel5)
+EXTERN(__irq_dma_channel6)
+EXTERN(__irq_dma_channel7)
+EXTERN(__irq_adc)
+EXTERN(__irq_usb_hp_can_tx)
+EXTERN(__irq_usb_lp_can_rx0)
+EXTERN(__irq_can_rx1)
+EXTERN(__irq_can_sce)
+EXTERN(__irq_exti9_5)
+EXTERN(__irq_tim1_brk)
+EXTERN(__irq_tim1_up)
+EXTERN(__irq_tim1_trg_com)
+EXTERN(__irq_tim1_cc)
+EXTERN(__irq_tim2)
+EXTERN(__irq_tim3)
+EXTERN(__irq_tim4)
+EXTERN(__irq_i2c1_ev)
+EXTERN(__irq_i2c1_er)
+EXTERN(__irq_i2c2_ev)
+EXTERN(__irq_i2c2_er)
+EXTERN(__irq_spi1)
+EXTERN(__irq_spi2)
+EXTERN(__irq_usart1)
+EXTERN(__irq_usart2)
+EXTERN(__irq_usart3)
+EXTERN(__irq_exti15_10)
+EXTERN(__irq_rtcalarm)
+EXTERN(__irq_usbwakeup)
+
+EXTERN(__irq_tim8_brk)
+EXTERN(__irq_tim8_up)
+EXTERN(__irq_tim8_trg_com)
+EXTERN(__irq_tim8_cc)
+EXTERN(__irq_adc3)
+EXTERN(__irq_fsmc)
+EXTERN(__irq_sdio)
+EXTERN(__irq_tim5)
+EXTERN(__irq_spi3)
+EXTERN(__irq_uart4)
+EXTERN(__irq_uart5)
+EXTERN(__irq_tim6)
+EXTERN(__irq_tim7)
+EXTERN(__irq_dma2_channel1)
+EXTERN(__irq_dma2_channel2)
+EXTERN(__irq_dma2_channel3)
+EXTERN(__irq_dma2_channel4_5)
diff --git a/wirish/bits.h b/wirish/bits.h
index b2c9d5c..3e755b7 100644
--- a/wirish/bits.h
+++ b/wirish/bits.h
@@ -1,30 +1,30 @@
-/******************************************************************************
- * The MIT License
- *
- * Copyright (c) 2010 LeafLabs, LLC.
- *
- * 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 AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *****************************************************************************/
-
-/* Note: Use of this header file is deprecated. Use bit_constants.h
- instead. */
-
-#include "bit_constants.h"
+/******************************************************************************
+ * The MIT License
+ *
+ * Copyright (c) 2010 LeafLabs, LLC.
+ *
+ * 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 AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *****************************************************************************/
+
+/* Note: Use of this header file is deprecated. Use bit_constants.h
+ instead. */
+
+#include "bit_constants.h"
diff --git a/wirish/main.cxx b/wirish/main.cxx
index dd5e296..ffa58dc 100644
--- a/wirish/main.cxx
+++ b/wirish/main.cxx
@@ -1,38 +1,38 @@
-/******************************************************************************
- * The MIT License
- *
- * Copyright (c) 2010 LeafLabs LLC.
- *
- * 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
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *****************************************************************************/
-
-// Force init to be called *first*, i.e. before static object allocation.
-// Otherwise, statically allocated objects that need libmaple may fail.
- __attribute__(( constructor )) void premain() {
- init();
-}
-
-int main(void) {
- setup();
-
- while (1) {
- loop();
- }
- return 0;
-}
+/******************************************************************************
+ * The MIT License
+ *
+ * Copyright (c) 2010 LeafLabs LLC.
+ *
+ * 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
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *****************************************************************************/
+
+// Force init to be called *first*, i.e. before static object allocation.
+// Otherwise, statically allocated objects that need libmaple may fail.
+ __attribute__(( constructor )) void premain() {
+ init();
+}
+
+int main(void) {
+ setup();
+
+ while (1) {
+ loop();
+ }
+ return 0;
+}