summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam D. Jones <[email protected]>2019-09-24 03:43:51 -0400
committerWilliam D. Jones <[email protected]>2019-09-24 03:43:51 -0400
commit550e8215f3ee60c13548e623925ca870023b20e4 (patch)
treed6744ef749cd3ef79aa0d3ee32ce3db2f3aa535d
parentd2e4af5a7b42ab54510bc8507ca28aed3604d9d1 (diff)
dcd_msp430x5xx: Setup packets are now received successfully (with delay).
-rw-r--r--src/portable/ti/msp430x5xx/dcd_msp430x5xx.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/portable/ti/msp430x5xx/dcd_msp430x5xx.c b/src/portable/ti/msp430x5xx/dcd_msp430x5xx.c
index 9ff63f839..4b35cd984 100644
--- a/src/portable/ti/msp430x5xx/dcd_msp430x5xx.c
+++ b/src/portable/ti/msp430x5xx/dcd_msp430x5xx.c
@@ -35,6 +35,8 @@
/*------------------------------------------------------------------*/
/* MACRO TYPEDEF CONSTANT ENUM
*------------------------------------------------------------------*/
+#define USB_BUF_PTR(_x) (uint8_t *) ((uint16_t) _x)
+
// usbpllir_mirror and usbmaintl_mirror can be added later if needed.
static volatile uint16_t usbiepie_mirror = 0;
static volatile uint16_t usboepie_mirror = 0;
@@ -46,7 +48,19 @@ uint8_t _setup_packet[8];
static void bus_reset(void)
{
+ // Enable the control EP 0. Also enable Indication Enable- a guard flag
+ // separate from the Interrupt Enable mask.
+ USBOEPCNF_0 |= (UBME | USBIIE);
+ USBIEPCNF_0 |= (UBME | USBIIE);
+
+ // Enable interrupts for this endpoint.
+ USBOEPIE |= BIT0;
+ USBIEPIE |= BIT0;
+ // Clear NAK so packets can be received.
+ // Dedicated buffers in hardware for SETUP and EP0, no setup needed.
+ USBOEPCNT_0 &= ~NAK;
+ USBIEPCNT_0 &= ~NAK;
}
@@ -180,9 +194,26 @@ void dcd_edpt_clear_stall (uint8_t rhport, uint8_t ep_addr)
/*------------------------------------------------------------------*/
+static void receive_packet(void)
+{
+
+}
+
+static void transmit_packet(void)
+{
+
+}
+
static void handle_setup_packet(void)
{
+ volatile uint8_t * setup_buf = &USBSUBLK;
+
+ for(int i = 0; i < 8; i++)
+ {
+ _setup_packet[i] = setup_buf[i];
+ }
+ dcd_event_setup_received(0, (uint8_t*) &_setup_packet[0], true);
}
void __attribute__ ((interrupt(USB_UBM_VECTOR))) USB_UBM_ISR(void)
@@ -209,6 +240,14 @@ void __attribute__ ((interrupt(USB_UBM_VECTOR))) USB_UBM_ISR(void)
case USBVECINT_SETUP_PACKET_RECEIVED:
break;
+ case USBVECINT_INPUT_ENDPOINT0:
+ transmit_packet();
+ break;
+
+ case USBVECINT_OUTPUT_ENDPOINT0:
+ receive_packet();
+ break;
+
default:
break;
}