Skip to content

Commit

Permalink
[Moo1.2.1] Fixing digital accel for Moo1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
schultetwin committed Oct 20, 2014
1 parent 9e05385 commit 5fe1f6a
Show file tree
Hide file tree
Showing 9 changed files with 1,239 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -5,4 +5,5 @@ settings/
/path.txt
Moo1.1-Debug/
Moo1.2-Debug/
Moo1.2.1-Debug/
TEST_ACCEL/
2 changes: 2 additions & 0 deletions board.h
Expand Up @@ -6,6 +6,8 @@
#include "board_1_1.h"
#elif MOO_VERSION == MOO1_2
#include "board_1_2.h"
#elif MOO_VERSION == MOO1_2_1
#include "board_1_2_1.h"
#else
#error "Moo Version Not Supported"
#endif
Expand Down
4 changes: 2 additions & 2 deletions board_1_2.h
Expand Up @@ -65,8 +65,8 @@
#define DEBUG_5_7 BIT7 // output unless externally driven

// Port 6
#define DIGITAL_ACCEL_INT1 BIT0 // input
#define DIGITAL_ACCEL_INT2 BIT1 // input
#define DIGITAL_ACCEL_INT2 BIT0 // input
#define DIGITAL_ACCEL_INT1 BIT1 // input
#define IDLE_6_2 BIT2 // input
#define TEMP_EXT_IN BIT3 // input
#define VSENSE_IN BIT4 // input
Expand Down
123 changes: 123 additions & 0 deletions board_1_2_1.h
@@ -0,0 +1,123 @@
/* See license.txt for license information. */

#ifndef BOARD_H
#define BOARD_H

#include <msp430x26x.h>

// Hardware definitions for Moo 1.0 and 1.1 (MSP430F2618)
// (derived from Intel WISP 4.1 DL ["Blue WISP"] definitions)
// See the schematics/ directory for pinouts and diagrams.

#define USE_2618 1

// Define what each bit of each port is used for

// Port 1
#define TEMP_POWER BIT0 // output
#define TX_PIN BIT1 // output
#define RX_PIN BIT2 // input
#define RX_EN_PIN BIT3 // output
#define DIGITAL_ACCEL_POWER BIT4 // output
#define DEBUG_1_5 BIT5 // output/input
#define DEBUG_1_6 BIT6 // output/input
#define DEBUG_1_7 BIT7 // output/input

// Port 2
//Supervisor in: PCB is designed to P6.7, should wire connect P6.7 and P2.0
#define VOLTAGE_SV_PIN BIT0 // output/input
#define DIGITAL_ACCEL_INT1 BIT1 // output/input
#define DIGITAL_ACCEL_INT2 BIT2 // output/input
#define IDLE_2_3 BIT3 // idle pin
#define IDLE_2_4 BIT4 // idle pin
#define IDLE_2_5 BIT5 // idle pin
#define IDLE_2_6 BIT6 // idle pin
#define IDLE_2_7 BIT7 // idle pin

// Port 3
#define DIGITAL_ACCEL_CLK BIT0 // output
#define SDA_B BIT1 // input (connected to 10k pullup res)
#define SCL_B BIT2 // input (connected to 10k pullup res)
#define CLK_B BIT3 // output unless externally driven
#define DIGITAL_ACCEL_MOSI BIT4 // output
#define DIGITAL_ACCEL_MISO BIT5 // input
#define DIGITAL_ACCEL_SEL BIT6 // output
#define DEBUG_3_7 BIT7 // output/input

// Port 4
#define DEBUG_4_0 BIT0 // connect to SV_IN by 0 ohm
#define CAP_SENSE BIT1 // output/input
#define LED_POWER BIT2 // output
#define VSENSE_POWER BIT3 // output
#define DEBUG_4_4 BIT4 // output/input
#define DEBUG_4_5 BIT5 // output/input
#define DEBUG_4_6 BIT6 // output/input
#define DEBUG_4_7 BIT7 // output/input

// Port 5
#define FLASH_CE BIT0 // output
#define FLASH_SIMO BIT1 // output
#define FLASH_SOMI BIT2 // input
#define FLASH_SCK BIT3 // output
#define DEBUG_5_4 BIT4 // output unless externally driven
#define DEBUG_5_5 BIT5 // output unless externally driven
#define IDLE_5_6 BIT6 // idle pin
#define DEBUG_5_7 BIT7 // output unless externally driven

// Port 6
#define DEBUG_6_0 BIT0 // input
#define DEBUG_6_1 BIT1 // input
#define IDLE_6_2 BIT2 // input
#define TEMP_EXT_IN BIT3 // input
#define VSENSE_IN BIT4 // input
#define DEBUG_6_5 BIT5 // output unless externally driven
#define DEBUG_6_6 BIT6 // output unless externally driven
#define DEBUG_6_7 BIT7 // input

// Port 8: Zhangh, need to reconfirm
#define CRYSTAL_IN BIT7 // input
#define CRYSTAL_OUT BIT6 // output

// Analog Inputs (ADC In Channel)
#define INCH_DEBUG_6_0 INCH_0
#define INCH_DEBUG_6_1 INCH_1
#define INCH_DEBUG_6_2 INCH_2
#define INCH_TEMP_EXT_IN INCH_3
#define INCH_VSENSE_IN INCH_4
#define INCH_DEBUG_6_5 INCH_5
#define INCH_DEBUG_6_6 INCH_6

#define DRIVE_ALL_PINS \
P1OUT = 0; \
P2OUT = 0; \
P3OUT = 0; \
P4OUT = 0; \
P5OUT = 0; \
P6OUT = 0; \
P8OUT = 0; \
P1DIR = TEMP_POWER | DIGITAL_ACCEL_POWER | TX_PIN | RX_EN_PIN; \
P4DIR = CAP_SENSE | LED_POWER | VSENSE_POWER; \
P5DIR = FLASH_CE | FLASH_SIMO | FLASH_SCK; \
P8DIR = CRYSTAL_OUT;

/* Between 1.6MHz and 3.0 MHz (from datasheet) */
#define SEND_CLOCK \
BCSCTL1 = XT2OFF + RSEL3 + RSEL0 ; \
DCOCTL = DCO2 + DCO1 ;
/* Between 2.60MHz and 4.75MHz (from datasheet + datasheet equations) */
#define RECEIVE_CLOCK \
BCSCTL1 = XT2OFF + RSEL3 + RSEL1 + RSEL0; \
DCOCTL = 0; \
BCSCTL2 = 0; // Rext = ON


#define DEBUG_PINS_ENABLED 0
#if DEBUG_PINS_ENABLED
#define DEBUG_PIN5_HIGH P3OUT |= BIT5;
#define DEBUG_PIN5_LOW P3OUT &= ~BIT5;
#else
#define DEBUG_PIN5_HIGH
#define DEBUG_PIN5_LOW
#endif

#endif
4 changes: 2 additions & 2 deletions digital_accel_moo_interface.c
Expand Up @@ -5,7 +5,7 @@
#include "rfid.h" /* sensor_counter */
#include "moo.h"

#if MOO_VERSION != MOO1_2
#if MOO_VERSION != MOO1_2 && MOO_VERSION != MOO1_2_1
#error "Unsupported moo version. Must be version 1.2"
#endif

Expand Down Expand Up @@ -57,7 +57,7 @@ static void read_accel_sensor(unsigned char volatile *target, unsigned long len)
target[6] = (sensor_counter & 0xff00) >> 8; // grab msb bits and store it
}

if (!digital_accel_spi_in_use() && (P2IN & BIT1)) {
if (!digital_accel_spi_in_use() && digital_accel_has_data()) {
digital_accel_spi_start(DIGITAL_ACCEL_READ, DIGITAL_ACCEL_REG_XDATA_L, buf, BUF_SIZE);
}
}
19 changes: 19 additions & 0 deletions digital_accel_sensor.c
Expand Up @@ -28,6 +28,7 @@ void _digital_accel_spi_deselect();
/* End private helper functions */

void digital_accel_spi_start(uint8_t op, uint8_t address, uint8_t * data, uint16_t len) {
IE2 &= ~(UCA0TXIE | UCA0RXIE);
_accel_spi_state.op = op;
_accel_spi_state.address = address;
_accel_spi_state.buf = data;
Expand All @@ -41,6 +42,16 @@ uint8_t digital_accel_spi_in_use() {
return _accel_spi_state.state != EDigitalAccelStateWaiting;
}

uint8_t digital_accel_has_data() {
uint8_t data = 0;
#if MOO_VERSION == MOO1_2
data = P6IN & DIGITAL_ACCEL_INT1;
#else
data = P2IN & DIGITAL_ACCEL_INT1;
#endif
return data;
}

uint8_t digital_accel_spi_complete() {
return _accel_spi_state.state == EDigitalAccelStateComplete;
}
Expand Down Expand Up @@ -124,6 +135,14 @@ void digital_accel_setup_pins() {
P3SEL &= ~(DIGITAL_ACCEL_SEL); // Non-standard select pin by design
P3DIR |= DIGITAL_ACCEL_SEL; // Again, setting up non-standard sel pin
/* End configure UCA0* Pins */

#if MOO_VERSION == MOO1_2
P6SEL &= ~DIGITAL_ACCEL_INT1;
P6DIR &= ~DIGITAL_ACCEL_INT1;
#else
P2SEL &= ~DIGITAL_ACCEL_INT1;
P2DIR &= ~DIGITAL_ACCEL_INT1;
#endif
}

/*
Expand Down
1 change: 1 addition & 0 deletions digital_accel_sensor.h
Expand Up @@ -196,6 +196,7 @@ void digital_accel_write_burst(uint8_t start_address, uint8_t * data, uint8_t le
void digital_accel_spi_start(uint8_t op, uint8_t address, uint8_t * data, uint16_t len);
uint8_t digital_accel_spi_in_use();
uint8_t digital_accel_spi_complete();
uint8_t digital_accel_has_data();
void digital_accel_spi_buf_mark_read();

#endif

0 comments on commit 5fe1f6a

Please sign in to comment.