Permalink
Browse files

working version of f1611 port

  • Loading branch information...
1 parent f70b633 commit 63431587612e2eff8651fd80796c3c43d63ce9e1 @anroOfCode committed Nov 27, 2012
@@ -32,7 +32,12 @@
private int _currentEdgeLength = 0;
private boolean _currentEdgeHigh = false;
- private int _threshold = 7;
+ // FOR THE MSP430FR5969:
+ //private int _threshold = 7;
+
+ // FOR THE MSP430F1611:
+ private int _threshold = 12;
+
private int _deltaT = 0;
private ReceiveState _rxState = ReceiveState.IDLE;
@@ -126,7 +131,8 @@ else if (isWithinThreshold(_currentEdgeLength, _deltaT * 2)) {
advanceReceiveDataState();
}
else {
- System.out.println("Error.");
+ System.out.println("EL: " + _currentEdgeLength + " DT: " + _deltaT);
+ //System.out.println("Error.");
_rxState = ReceiveState.IDLE;
}
}
@@ -141,8 +147,9 @@ private void receiveDataNext() {
advanceReceiveDataState();
}
else {
+ System.out.println("BEL: " + _currentEdgeLength + " DT: " + _deltaT);
_rxState = ReceiveState.IDLE;
- System.out.println("Error.");
+ //System.out.println("Error.");
}
}
@@ -36,7 +36,7 @@
// Used by the coding state machine to identify
// long and short pulses.
-#define THRESHOLD 8
-#define DELTAT 17
+#define THRESHOLD 4
+#define DELTAT 20
#endif
@@ -27,6 +27,9 @@
typedef void timer_captureCallback(uint16_t);
typedef void timer_periodicCallback(void);
+timer_captureCallback *timer_captureCbPtr;
+timer_periodicCallback *timer_periodicCbPtr;
+
void timer_init (void);
void timer_start (void);
void timer_setCaptureCallback (timer_captureCallback* cb);
View
@@ -180,7 +180,9 @@ void pal_startTimers(void) {
timer_init();
timer_setCaptureCallback(pal_captureTimerFn);
timer_setPeriodicCallback(pal_periodicTimerFn);
+
timer_start();
+
util_delayMs(100);
}
View
@@ -57,6 +57,7 @@ void captureTimerFn(uint16_t elapsedTime, uint8_t isHigh) {
void packetReceivedCallback(uint8_t * buf, uint8_t len) {
if (len == 1) {
+ pal_setDigitalGpio(pal_gpio_led, 1);
pal_setDigitalGpio(pal_gpio_dout1, ((buf[0] >> 0) & 0x01));
pal_setDigitalGpio(pal_gpio_dout2, ((buf[0] >> 1) & 0x01));
pal_setDigitalGpio(pal_gpio_dout3, ((buf[0] >> 2) & 0x01));
@@ -118,13 +119,7 @@ void initializeSystem(void) {
// Start the interrupt-driven timers.
pal_startTimers();
-
- while(1)
- {
- pal_setDigitalGpio(pal_gpio_led, 1);
- pal_setDigitalGpio(pal_gpio_led, 0);
- }
-
+
// Start the transmit callback-driven
// loop
fe_writeTxBuffer(outMessage, 9);
@@ -139,11 +134,20 @@ int main () {
initializeSystem();
// TODO: Add sleep commands!
+ /*while(1)
+ {
+ pal_setDigitalGpio(pal_gpio_led, 1);
+ pal_setDigitalGpio(pal_gpio_led, 0);
+ }*/
+
+
while(1) {
+ //pal_setDigitalGpio(pal_gpio_led, 0);
updateDigitalOutputBuffer();
updateAnalogOutputBuffer();
-
+ //pal_setDigitalGpio(pal_gpio_led, 1);
pal_loopDelay();
+
}
return 0;
}
@@ -22,6 +22,8 @@
#include "ptimer.h"
#include "ctimer.h"
+#include "pal.h"
+
#include <msp430.h>
void timer_init (void) {
@@ -40,14 +42,14 @@ void timer_init (void) {
///////////////////////////
// TimerA - Capture Timer
- TACTL = TASSEL_1 + TACLR + TAIE;
- TACCTL0 = CM_3 + CCIS_1 + CAP + CCIE;
+ TACTL = TASSEL_1 + TACLR;
+ TACCTL1 = CM_3 + CCIS_1 + CAP + CCIE;
///////////////////////////
// TimerB - Periodic Timer
TBCTL = TBSSEL_1 + TBIE + TBCLR;
- TBCCTL0 = CCIE;
- TBCCR0 = 17;
+ TBCCTL0 = 0;
+ TBCCR0 = DELTAT;
}
void timer_start (void) {
@@ -56,11 +58,11 @@ void timer_start (void) {
}
void timer_setCaptureCallback (timer_captureCallback* cb) {
-
+ timer_captureCbPtr = cb;
}
void timer_setPeriodicCallback (timer_periodicCallback* cb) {
-
+ timer_periodicCbPtr = cb;
}
void timer_stop (void) {
@@ -69,7 +71,27 @@ void timer_stop (void) {
}
uint8_t timer_readCaptureLine (void) {
- return !!(TACCTL0 & CCI);
+ return !(TACCTL1 & CCI);
+}
+
+#pragma vector = TIMERA1_VECTOR
+__interrupt void Timer_A1 (void) {
+
+ uint16_t captureReg = TAR;
+
+ if (captureReg > 5) {
+ TAR = 0;
+ timer_captureCbPtr(captureReg);
+ }
+
+ TACCTL1 &= ~CCIFG;
}
+#pragma vector = TIMERB1_VECTOR
+__interrupt void Timer_B1 (void) {
+ timer_periodicCbPtr();
+ TBCTL &= ~TBIFG;
+}
+
+
#endif
@@ -145,13 +145,16 @@ void util_boardInit(void) {
// .RSEL, do not modify
BCSCTL1 = XT2OFF | (BCSCTL1 & (RSEL2|RSEL1|RSEL0));
+ BCSCTL1 |= RSEL0 + RSEL1 + RSEL2;
+ DCOCTL |= DCO0 + DCO1 + DCO2;
// BCSCTL2
// .SELM = 0; select DCOCLK as source for MCLK
// .DIVM = 0; set the divisor of MCLK to 1
// .SELS = 0; select DCOCLK as source for SCLK
// .DIVS = 2; set the divisor of SCLK to 4
// .DCOR = 1; select internal resistor for DCO
- BCSCTL2 = DIVS1 | DCOR;
+ //BCSCTL2 = DIVS1 | DCOR;
+
#endif
}

0 comments on commit 6343158

Please sign in to comment.