Permalink
Browse files

fixed up periphs

  • Loading branch information...
1 parent e119ade commit e34d5cf6a7907c0a0d44c526cf1e0fb0e67568a7 @anroOfCode committed Nov 15, 2012
@@ -1,70 +0,0 @@
-/*
- * 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/>.
- */
-
-#include "msp430.h"
-#include <inttypes.h>
-#include <stddef.h>
-
-#include "adc.h"
-#include "utility.h"
-
-void adc_runConversion () {
- ADC12CTL0 |= ADC12ENC + ADC12SC;
- while (ADC12CTL1 & ADC12BUSY);
-}
-
-void adc_init2(void) {
- // Enable multiple conversions.
- // 16ADCclks, MSC, ADC ON
- ADC12CTL0 = ADC12SHT0_2 + ADC12MSC + ADC12ON;
-
- // sampling timer, s/w trig.,single sequence
- ADC12CTL1 = ADC12SHP + ADC12CONSEQ_1;
- ADC12CTL2 = ADC12RES__12BIT;
-
- // 3.1
- P3SEL0 |= (1<<1);
- P3SEL1 |= (1<<1);
-
- // 1.4
- P1SEL0 |= (1<<4);
- P1SEL1 |= (1<<4);
-
- // 1.5
- P1SEL0 |= (1<<5);
- P1SEL1 |= (1<<5);
-
- // 4.2
- P4SEL0 |= (1<<2);
- P4SEL1 |= (1<<2);
-
- // Configure the memory banks
- ADC12MCTL0 = ADC12INCH_4 + ADC12VRSEL1;
- ADC12MCTL1 = ADC12INCH_5 + ADC12VRSEL1;
- ADC12MCTL2 = ADC12INCH_10 + ADC12VRSEL1;
- ADC12MCTL3 = ADC12INCH_13 + ADC12VRSEL1 + ADC12EOS;
-
- // Clear the ADC results - for debugging purposes.
- ADC12MEM0 = 0;
- ADC12MEM1 = 0;
- ADC12MEM2 = 0;
- ADC12MEM3 = 0;
-}
-
-uint16_t adc_getResult (uint8_t conv_num) {
- return *((&ADC12MEM0) + conv_num * 2);
-}
@@ -1,51 +0,0 @@
-/*
- * 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/>.
- */
-
-#include "msp430.h"
-#include <inttypes.h>
-#include <stddef.h>
-
-#include "analog.h"
-#include "adc.h"
-#include "reference.h"
-#include "hardware.h"
-
-void analog_init(void) {
- // Turn on the 2.0V Reference Generator
- reference_set(REFVOLT_20);
- reference_enable();
- adc_init2();
-}
-
-void analog_sampleAll(void) {
- adc_runConversion();
-}
-
-uint16_t analog_readInput(enum analog_inputEnum input) {
- switch (input) {
- case analog_input_vcc:
- return adc_getResult(0);
- case analog_input_extTemp:
- return adc_getResult(1);
- case analog_input_in1:
- return adc_getResult(2);
- case analog_input_in2:
- return adc_getResult(3);
- }
-
- return -1;
-}
@@ -1,136 +0,0 @@
-/*
- * 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/>.
- */
-
-#include "msp430.h"
-#include <inttypes.h>
-#include "comparator.h"
-#include "hardware.h"
-
-comparator_callback* comparator_callback_fn;
-
-void comparator_enablePin (uint8_t port, uint8_t pin) {
- if (comparator_getChannel(port, pin) == 0xFF) {
- return;
- }
-
- switch (port) {
- case 1:
- P1SEL0 |= 1 << pin;
- P1SEL1 |= 1 << pin;
- break;
- case 2:
- P2SEL0 |= 1 << pin;
- P2SEL1 |= 1 << pin;
- break;
- case 3:
- P3SEL0 |= 1 << pin;
- P3SEL1 |= 1 << pin;
- break;
- }
-}
-
-void comparator_disablePin (uint8_t port, uint8_t pin) {
- if (comparator_getChannel(port, pin) == 0xFF) {
- return;
- }
-
- switch (port) {
- case 1:
- P1SEL0 &= ~(1 << pin);
- P1SEL1 &= ~(1 << pin);
- break;
- case 2:
- P2SEL0 &= ~(1 << pin);
- P2SEL1 &= ~(1 << pin);
- break;
- case 3:
- P3SEL0 &= ~(1 << pin);
- P3SEL1 &= ~(1 << pin);
- break;
- }
-}
-
-uint8_t comparator_getChannel (uint8_t port, uint8_t pin) {
-
- uint8_t channel = 0xFF;
-
- switch (port) {
- case 1:
- if (pin < 6) {
- channel = pin;
- }
- break;
- case 2:
- if (pin == 3 || pin == 4) {
- channel = pin + 7;
- }
- break;
- case 3:
- if (pin < 4) {
- channel = pin + 12;
- }
- break;
- }
-
- return channel;
-}
-
-void comparator_init () {
- // set the comparator in normal power mode
-// CBCTL1 = (CBCTL1 & ~CBPWRMD_0) | CBPWRMD_1;
-
- // set the comparator in high speed mode
- CBCTL1 &= ~CBPWRMD_0;
-
-
-}
-
-void comparator_on () {
- CBCTL1 |= CBON;
-}
-
-void comparator_off () {
- CBCTL1 &= ~CBON;
-}
-
-void comparator_setup (uint8_t compare_pin_neg, uint8_t compare_pin_pos) {
- // enable external inputs for both inputs of the comparator
- CBCTL0 = CBIMEN + (compare_pin_neg << 8) + CBIPEN + compare_pin_pos;
-
- // disable the input buffers for the pins being used
- CBCTL3 = (1 << compare_pin_neg) + (1 << compare_pin_pos);
-
-}
-
-void comparator_enableInterrupt (comparator_callback* cb) {
- // clear any interrupts
- CBINT &= ~(CBIFG + CBIIFG);
- CBINT |= CBIE;
-
- comparator_callback_fn = cb;
-}
-
-#pragma vector=COMP_B_VECTOR
-__interrupt void Comp_B_ISR (void) {
- CBCTL1 ^= CBIES; // Toggles interrupt edge
- CBINT &= ~CBIFG; // Clear Interrupt flag
-
- comparator_callback_fn();
-}
-
-
-
@@ -1,68 +0,0 @@
-/*
- * 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/>.
- */
-
-#include "msp430.h"
-#include <inttypes.h>
-#include "ctimer.h"
-
-// Comparator timer
-// A2
-
-ctimer_callback* ctimer_callback_fn;
-
-
-void ctimer_init (void) {
- TA2CTL = TASSEL__SMCLK + MC__CONTINUOUS + ID__8;
-
- // CM = capture on both edges
- // CCIS = select comparator e
- // CAP = capture mode
- // CCIE = interrupt enable
- TA2CCTL1 = CM_3 + CCIS_1 + CAP + CCIE;
-}
-
-void ctimer_set_callback (ctimer_callback* cb) {
- ctimer_callback_fn = cb;
-}
-
-void ctimer_clear (void) {
- TA2R = 0x00;
-}
-
-void ctimer_stop (void) {
- TA2CTL &= MC__STOP;
-}
-
-uint8_t ctimer_readLine (void) {
- return !!(TA2CCTL1 & CCI);
-}
-
-#pragma vector = TIMER2_A1_VECTOR
-__interrupt void Timer_A2 (void) {
- uint16_t capture_reg;
- capture_reg = TA2CCR1;
-
- if (capture_reg > 0x100) {
- ctimer_clear();
- ctimer_callback_fn(capture_reg);
- }
-
- TA2CCTL1 &= ~CCIFG;
-}
-
-
-
Oops, something went wrong.

0 comments on commit e34d5cf

Please sign in to comment.