Skip to content
Browse files

refactoring and building skeleton for msp430f1611 support

  • Loading branch information...
1 parent eefb1ce commit cd18194ce7f98c5710fc544e132f3a8233e98320 @anroOfCode committed
View
2 hijack/Makefile
@@ -6,6 +6,8 @@
TARGET = out
MCU = msp430fr5969
+#MCU = msp430f1611
+
BUILD = build
SOURCES = $(wildcard src/*.c)
SOURCES += $(wildcard src/peripherals/*.c)
View
6 hijack/src/include/adc.h
@@ -15,12 +15,12 @@
* along with hijack-infinity. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "config.h"
-
#ifndef __ADC_H__
#define __ADC_H__
-#if defined(MSP430FR5969) || defined(MSP430F1611)
+#include "config.h"
+
+#if defined(MSP430FR5969)
#include "msp430.h"
#include <inttypes.h>
View
6 hijack/src/include/analog.h
@@ -20,6 +20,8 @@
#include "config.h"
+#if defined(MSP430FR5969) || defined(MSP430F1611)
+
#include <stdint.h>
#include "msp430.h"
#include <inttypes.h>
@@ -27,9 +29,7 @@
#include "adc.h"
#include "reference.h"
#include "hardware.h"
-
-#if defined(MSP430FR5969) || defined(MSP430F1611)
-
+
enum analog_inputEnum {
analog_input_vcc,
analog_input_extTemp,
View
4 hijack/src/include/codingStateMachine.h
@@ -15,11 +15,11 @@
* along with hijack-infinity. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "config.h"
-
#ifndef __CSM_H__
#define __CSM_H__
+#include "config.h"
+
#include <inttypes.h>
////////////////////////////////////////
View
8 hijack/src/include/comparator.h
@@ -15,15 +15,13 @@
* along with hijack-infinity. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "config.h"
-
#ifndef __COMPARATOR_H__
#define __COMPARATOR_H__
-#if defined(MSP430FR5969) || defined(MSP430F1611)
+#include "config.h"
+
+#if defined(MSP430FR5969)
-#include "hardware.h"
-#include "msp430.h"
#include <inttypes.h>
typedef void comparator_callback(void);
View
9 hijack/src/include/config.h
@@ -15,8 +15,13 @@
* along with hijack-infinity. If not, see <http://www.gnu.org/licenses/>.
*/
-#define MSP430FR5969
-//#define MSP430F1611
+#ifdef __MSP430F1611__
+ #define MSP430F1611
+#endif
+
+#ifdef __MSP430FR5969__
+ #define MSP430FR5969
+#endif
#if defined(MSP430FR5969)
View
8 hijack/src/include/ctimer.h
@@ -14,15 +14,15 @@
* You should have received a copy of the GNU General Public License
* along with hijack-infinity. If not, see <http://www.gnu.org/licenses/>.
*/
-
-#include "config.h"
#ifndef __CTIMER_H__
#define __CTIMER_H__
-#if defined(MSP430FR5969) || defined(MSP430F1611)
+#include "config.h"
+
+#if defined(MSP430FR5969)
+
-#include "msp430.h"
#include <inttypes.h>
typedef void ctimer_callback(uint16_t);
View
39 hijack/src/include/f1611_timer.h
@@ -0,0 +1,39 @@
+/*
+ * This file is part of hijack-infinity.
+ *
+ * hijack-infinity is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * hijack-infinity is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with hijack-infinity. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __F1611_TIMER_H__
+#define __F1611_TIMER_H__
+
+#include "config.h"
+
+#if defined(MSP430F1611)
+
+#include <inttypes.h>
+
+typedef void timer_captureCallback(uint16_t);
+typedef void timer_periodicCallback(void);
+
+void timer_init (void);
+void timer_start (void);
+void timer_setCaptureCallback (timer_captureCallback* cb);
+void timer_setPeriodicCallback (timer_periodicCallback* cb);
+void timer_stop (void);
+uint8_t timer_readCaptureLine (void);
+
+#endif
+
+#endif
View
4 hijack/src/include/framingEngine.h
@@ -15,11 +15,11 @@
* along with hijack-infinity. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "config.h"
-
#ifndef __FRAMINGENGINE_H__
#define __FRAMINGENGINE_H__
+#include "config.h"
+
#include <inttypes.h>
#include "gpio.h"
View
4 hijack/src/include/gpio.h
@@ -15,11 +15,11 @@
* along with hijack-infinity. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "config.h"
-
#ifndef __GPIO_H__
#define __GPIO_H__
+#include "config.h"
+
#if defined(MSP430FR5969) || defined(MSP430F1611)
#include <msp430.h>
View
5 hijack/src/include/hardware.h
@@ -29,12 +29,11 @@
// Analog In 2: J2 (right), P6
//////////////////////////////////////
-
-#include "config.h"
-
#ifndef __HARDWARE_H__
#define __HARDWARE_H__
+#include "config.h"
+
#ifdef MSP430FR5969
#define LED_0 BIT0
View
8 hijack/src/include/interrupt.h
@@ -15,13 +15,15 @@
* along with hijack-infinity. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "config.h"
-
#ifndef __INTERRUPT_H__
#define __INTERRUPT_H__
-#if defined(MSP430FR5969) || defined(MSP430F1611)
+#include "config.h"
+
+#if defined(MSP430FR5969)
+#include <inttypes.h>
+
typedef void interrupt_callback(void);
typedef enum interrupt_edge {
View
20 hijack/src/include/pal.h
@@ -24,30 +24,14 @@
* in config.h.
*/
-#include "config.h"
-
#ifndef __PAL_H__
#define __PAL_H__
+#include "config.h"
+
#include <inttypes.h>
#include <stdio.h>
-#if defined(MSP430FR5969) || defined(MSP430F1611)
-
-#include <msp430.h>
-
-#include "ptimer.h"
-#include "ctimer.h"
-#include "comparator.h"
-
-#include "gpio.h"
-
-#include "utility.h"
-#include "hardware.h"
-#include "analog.h"
-
-#endif
-
//////////////////////
// Public Interface
//////////////////////
View
7 hijack/src/include/ptimer.h
@@ -15,14 +15,13 @@
* along with hijack-infinity. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "config.h"
-
#ifndef __PTIMER_H__
#define __PTIMER_H__
-#if defined(MSP430FR5969) || defined(MSP430F1611)
+#include "config.h"
+
+#if defined(MSP430FR5969)
-#include "msp430.h"
#include <inttypes.h>
typedef void ptimer_callback(void);
View
6 hijack/src/include/reference.h
@@ -15,12 +15,12 @@
* along with hijack-infinity. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "config.h"
-
#ifndef __REFERENCE_H__
#define __REFERENCE_H__
-#if defined(MSP430FR5969) || defined(MSP430F1611)
+#include "config.h"
+
+#if defined(MSP430FR5969)
#include <inttypes.h>
#include "msp430.h"
View
4 hijack/src/include/utility.h
@@ -15,11 +15,11 @@
* along with hijack-infinity. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "config.h"
-
#ifndef __UTILITY_H__
#define __UTILITY_H__
+#include "config.h"
+
#if defined(MSP430FR5969) || defined(MSP430F1611)
#include <msp430.h>
View
125 hijack/src/lib/pal.c
@@ -17,6 +17,26 @@
#include "pal.h"
+#if defined(MSP430FR5969) || defined(MSP430F1611)
+
+#include <msp430.h>
+#include "gpio.h"
+#include "utility.h"
+#include "hardware.h"
+#include "analog.h"
+
+#endif
+
+#if defined(MSP430FR5969)
+#include "comparator.h"
+#include "ptimer.h"
+#include "ctimer.h"
+#endif
+
+#if defined(MSP430F1611)
+#include "f1611_timer.h"
+#endif
+
pal_periodicTimerCb * pal_periodicTimerCbPtr;
pal_captureTimerCb * pal_captureTimerCbPtr;
@@ -52,42 +72,6 @@ void pal_init(void) {
gpio_clear(LED_PORT, LED_PIN);
util_enableInterrupt();
-
- ctimer_set_callback(pal_captureTimerFn);
-}
-
-void pal_startTimers(void) {
- // Initialize the hardware to drive the
- // signal processing layers.
- comparator_enablePin(LEFT_PORT, LEFT_PIN);
- comparator_enablePin(VREF_PORT, VREF_PIN);
-
- comparator_init();
- comparator_setup(
- comparator_getChannel(LEFT_PORT, LEFT_PIN),
- comparator_getChannel(VREF_PORT, VREF_PIN)
- );
- comparator_on();
-
- ctimer_init();
- ptimer_init();
-
- ptimer_start(TIMER_TICKS, pal_periodicTimerFn);
- // Wait 100ms for everything to stabalize.
- util_delayMs(100);
-}
-
-void pal_periodicTimerFn(void) {
- if (pal_periodicTimerCbPtr != 0) {
- pal_periodicTimerCbPtr();
- }
-}
-
-void pal_captureTimerFn(uint16_t elapsedTime) {
- uint8_t pinValue = !!ctimer_readLine();
- if (pal_captureTimerCbPtr != 0) {
- pal_captureTimerCbPtr(elapsedTime, pinValue);
- }
}
void pal_sampleAnalogGpios(void) {
@@ -141,9 +125,76 @@ uint16_t pal_readAnalogGpio(enum pal_gpioEnum pin) {
return 0;
}
}
+#endif
+
+#if defined(MSP430FR5969)
+void pal_startTimers(void) {
+ // Initialize the hardware to drive the
+ // signal processing layers.
+ ctimer_set_callback(pal_captureTimerFn);
+
+ comparator_enablePin(LEFT_PORT, LEFT_PIN);
+ comparator_enablePin(VREF_PORT, VREF_PIN);
+
+ comparator_init();
+ comparator_setup(
+ comparator_getChannel(LEFT_PORT, LEFT_PIN),
+ comparator_getChannel(VREF_PORT, VREF_PIN)
+ );
+ comparator_on();
+
+ ctimer_init();
+ ptimer_init();
+
+ ptimer_start(TIMER_TICKS, pal_periodicTimerFn);
+ // Wait 100ms for everything to stabalize.
+ util_delayMs(100);
+}
+
+void pal_periodicTimerFn(void) {
+ if (pal_periodicTimerCbPtr != 0) {
+ pal_periodicTimerCbPtr();
+ }
+}
+
+void pal_captureTimerFn(uint16_t elapsedTime) {
+ uint8_t pinValue = !!ctimer_readLine();
+ if (pal_captureTimerCbPtr != 0) {
+ pal_captureTimerCbPtr(elapsedTime, pinValue);
+ }
+}
+
+
void pal_loopDelay(void) {
__delay_cycles(400000);
}
+#endif
+
+#if defined(MSP430F1611)
-#endif
+void pal_startTimers(void) {
+ timer_init();
+ timer_setCaptureCallback(pal_captureTimerFn);
+ timer_setPeriodicCallback(pal_periodicTimerFn);
+ timer_start();
+ util_delayMs(100);
+}
+
+void pal_periodicTimerFn(void) {
+ if (pal_periodicTimerCbPtr != 0) {
+ pal_periodicTimerCbPtr();
+ }
+}
+
+void pal_captureTimerFn(uint16_t elapsedTime) {
+ uint8_t pinValue = !!timer_readCaptureLine();
+ if (pal_captureTimerCbPtr != 0) {
+ pal_captureTimerCbPtr(elapsedTime, pinValue);
+ }
+}
+
+void pal_loopDelay(void) {
+ __delay_cycles(400000);
+}
+#endif
View
4 hijack/src/peripherals/msp/adc.c
@@ -15,9 +15,9 @@
* along with hijack-infinity. If not, see <http://www.gnu.org/licenses/>.
*/
- #include "adc.h"
+#include "adc.h"
- #if defined(MSP430FR5969) || defined(MSP430F1611)
+#if defined(MSP430FR5969)
void adc_runConversion () {
ADC12CTL0 |= ADC12ENC + ADC12SC;
View
18 hijack/src/peripherals/msp/analog.c
@@ -15,9 +15,9 @@
* along with hijack-infinity. If not, see <http://www.gnu.org/licenses/>.
*/
- #include "analog.h"
+#include "analog.h"
- #if defined(MSP430FR5969) || defined(MSP430F1611)
+#if defined(MSP430FR5969)
void analog_init(void) {
// Turn on the 2.0V Reference Generator
@@ -45,4 +45,18 @@ uint16_t analog_readInput(enum analog_inputEnum input) {
return -1;
}
+#endif
+
+#if defined(MSP430F1611)
+void analog_init(void) {
+;
+}
+
+void analog_sampleAll(void) {
+}
+
+uint16_t analog_readInput(enum analog_inputEnum input) {
+ return 0;
+}
+
#endif
View
7 hijack/src/peripherals/msp/comparator.c
@@ -17,8 +17,11 @@
#include "comparator.h"
-#if defined(MSP430FR5969) || defined(MSP430F1611)
-
+#if defined(MSP430FR5969)
+
+#include "hardware.h"
+#include "msp430.h"
+
comparator_callback* comparator_callback_fn;
void comparator_enablePin (uint8_t port, uint8_t pin) {
View
6 hijack/src/peripherals/msp/ctimer.c
@@ -16,9 +16,11 @@
*/
#include "ctimer.h"
-
-#if defined(MSP430FR5969) || defined(MSP430F1611)
+\
+#if defined(MSP430FR5969)
+#include "msp430.h"
+
// Comparator timer
// A2
View
37 hijack/src/include/sstimer.h → hijack/src/peripherals/msp/f1611_timer.c
@@ -15,22 +15,37 @@
* along with hijack-infinity. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "config.h"
+#include "f1611_timer.h"
-#ifndef __SSTIMER_H__
-#define __SSTIMER_H__
+#ifdef MSP430F1611
-#if defined(MSP430FR5969) || defined(MSP430F1611)
+#include "ptimer.h"
+#include "ctimer.h"
-#include "msp430.h"
-#include <inttypes.h>
+#include <msp430.h>
-typedef void sstimer_callback(void);
+void timer_init (void) {
+}
-void sstimer_init ();
-void sstimer_set (uint16_t ms, sstimer_callback* cb);
+void timer_start (void) {
-#endif
+}
+
+void timer_setCaptureCallback (timer_captureCallback* cb) {
+
+}
+
+void timer_setPeriodicCallback (timer_periodicCallback* cb) {
+
+}
-#endif
+void timer_stop (void) {
+
+}
+
+uint8_t timer_readCaptureLine (void) {
+ return 0;
+}
+
+#endif
View
14 hijack/src/peripherals/msp/gpio.c
@@ -35,6 +35,10 @@ void gpio_init (uint8_t port, uint8_t pin, gpio_dir_e dir) {
case 2: P2DIR = (P2DIR & clear) | set; break;
case 3: P3DIR = (P3DIR & clear) | set; break;
case 4: P4DIR = (P4DIR & clear) | set; break;
+#ifdef MSP430F1611
+ case 5: P5DIR = (P5DIR & clear) | set; break;
+ case 6: P6DIR = (P6DIR & clear) | set; break;
+#endif
}
}
@@ -48,6 +52,10 @@ void gpio_set_clear (uint8_t port, uint8_t pin, uint8_t set) {
case 2: P2OUT = (P2OUT & clear) | set; break;
case 3: P3OUT = (P3OUT & clear) | set; break;
case 4: P4OUT = (P4OUT & clear) | set; break;
+#ifdef MSP430F1611
+ case 5: P5OUT = (P5OUT & clear) | set; break;
+ case 6: P6OUT = (P6OUT & clear) | set; break;
+#endif
}
}
@@ -77,6 +85,12 @@ uint8_t gpio_read(uint8_t port, uint8_t pin) {
return (P3IN >> pin) & 0x01;
case 4:
return (P4IN >> pin) & 0x01;
+#ifdef MSP430F1611
+ case 5:
+ return (P5IN >> pin) & 0x01;
+ case 6:
+ return (P6IN >> pin) & 0x01;
+#endif
}
return 0;
}
View
10 hijack/src/peripherals/msp/interrupt.c
@@ -15,15 +15,13 @@
* along with hijack-infinity. If not, see <http://www.gnu.org/licenses/>.
*/
-#if defined(MSP430FR5969) || defined(MSP430F1611)
+ #include "interrupt.h"
-#include "msp430.h"
-#include <inttypes.h>
-#include <stddef.h>
-
-#include "interrupt.h"
+#if defined(MSP430FR5969)
+#include "msp430.h"
+#include <stddef.h>
interrupt_callback* cb_fns[32];
View
5 hijack/src/peripherals/msp/ptimer.c
@@ -17,9 +17,10 @@
#include "ptimer.h"
- #if defined(MSP430FR5969) || defined(MSP430F1611)
-
+#if defined(MSP430FR5969)
+
// Periodic timer
+#include "msp430.h"
uint8_t ptimer_inuse = 0;
ptimer_callback* ptimer_callback_fn;
View
4 hijack/src/peripherals/msp/reference.c
@@ -15,9 +15,9 @@
* along with hijack-infinity. If not, see <http://www.gnu.org/licenses/>.
*/
- #include "reference.h"
+#include "reference.h"
-#if defined(MSP430FR5969) || defined(MSP430F1611)
+#if defined(MSP430FR5969)
void reference_enable () {
while (REFCTL0 & REFGENBUSY);
View
2 hijack/src/peripherals/msp/utility.c
@@ -15,7 +15,7 @@
* along with hijack-infinity. If not, see <http://www.gnu.org/licenses/>.
*/
- #include "utility.h"
+#include "utility.h"
#if defined(MSP430FR5969) || defined(MSP430F1611)

0 comments on commit cd18194

Please sign in to comment.
Something went wrong with that request. Please try again.