summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hw/bsp/msp_exp430f5529lp/msp_exp430f5529lp.c33
-rw-r--r--src/portable/ti/msp430x5xx/dcd_msp430x5xx.c5
2 files changed, 37 insertions, 1 deletions
diff --git a/hw/bsp/msp_exp430f5529lp/msp_exp430f5529lp.c b/hw/bsp/msp_exp430f5529lp/msp_exp430f5529lp.c
index 5fa69465d..29f88ccf5 100644
--- a/hw/bsp/msp_exp430f5529lp/msp_exp430f5529lp.c
+++ b/hw/bsp/msp_exp430f5529lp/msp_exp430f5529lp.c
@@ -36,6 +36,8 @@
#define BUTTON_PIN BIT1
#define BUTTON_STATE_ACTIVE 1
+uint32_t cnt = 0;
+
static void SystemClock_Config(void)
{
WDTCTL = WDTPW + WDTHOLD; // Disable watchdog.
@@ -86,16 +88,45 @@ static void SystemClock_Config(void)
TA0CCTL0 |= CCIE;
TA0CCR0 = 999; // 1000 ticks.
TA0CTL |= TASSEL_2 + ID_3 + MC__UP; // Use SMCLK, divide by 8, start timer.
+
+ // Initialize USB power and PLL.
+ USBKEYPID = USBKEY;
+
+ // VUSB enabled automatically.
+ // Wait two milliseconds to stabilize, per manual recommendation.
+ uint32_t ms_elapsed = board_millis();
+ do
+ {
+ while((board_millis() - ms_elapsed) < 2);
+ }while(!(USBPWRCTL & USBBGVBV));
+
+ // USB uses XT2 (4 MHz) directly. Enable the PLL.
+ USBPLLDIVB |= USBPLL_SETCLK_4_0;
+ USBPLLCTL |= (UPFDEN | UPLLEN);
+
+ // Wait until PLL locks. Check every 2ms, per manual.
+ ms_elapsed = board_millis();
+ do
+ {
+ USBPLLIR &= ~USBOOLIFG;
+ while((board_millis() - ms_elapsed) < 2);
+ }while(USBPLLIR & USBOOLIFG);
+
+ USBKEYPID = 0;
}
void board_init(void)
{
- SystemClock_Config();
__bis_SR_register(GIE); // Enable interrupts.
+ SystemClock_Config();
P1DIR |= LED_PIN; // LED output.
P1REN |= BUTTON_PIN; // Internal resistor enable.
P1OUT |= BUTTON_PIN; // Pullup.
+
+ USBKEYPID = USBKEY;
+ USBPHYCTL |= PUSEL; // Convert USB D+/D- pins to USB functionality.
+ USBKEYPID = 0;
}
//--------------------------------------------------------------------+
diff --git a/src/portable/ti/msp430x5xx/dcd_msp430x5xx.c b/src/portable/ti/msp430x5xx/dcd_msp430x5xx.c
index b2df9e3b6..e9ca76853 100644
--- a/src/portable/ti/msp430x5xx/dcd_msp430x5xx.c
+++ b/src/portable/ti/msp430x5xx/dcd_msp430x5xx.c
@@ -43,6 +43,11 @@
void dcd_init (uint8_t rhport)
{
(void) rhport;
+
+ // Enable the module!
+ USBKEYPID = USBKEY;
+ USBCNF |= (PUR_EN | USB_EN);
+ USBKEYPID = 0;
}
void dcd_int_enable (uint8_t rhport)