Flipklok
 
Loading...
Searching...
No Matches
gpio.h File Reference
#include <msp430.h>
#include <pins.h>

Go to the source code of this file.

Functions

void setupGpio ()
 Setup of all GPIO's on startup, gets called from main()
 
void setupClockIO ()
 Setup of the external clock pins, gets called from setupGpio(), wakeup(), sleep()
 
void wakeUp ()
 Setup of all GPIO's after wakeup, gets called from ADC10_ISR(void)
 
void sleep ()
 Setup of all GPIO's after sleep, gets called from ADC10_ISR(void)
 

Function Documentation

◆ setupClockIO()

void setupClockIO ( )

Setup of the external clock pins, gets called from setupGpio(), wakeup(), sleep()

Definition at line 120 of file gpio.c.

121{
122 //Clock
123 P2SEL |= BIT6 | BIT7; // Select XIN and XOUT functionality
124 P2SEL2 &= ~(BIT6 | BIT7); // Ensure secondary function is not selected
125}

Referenced by setupGpio(), and sleep().

◆ setupGpio()

void setupGpio ( )

Setup of all GPIO's on startup, gets called from main()

Definition at line 19 of file gpio.c.

20{
21 //Enable pull-up on PCB
22 P1DIR |= BIT3;
23 P1OUT |= BIT3;
24
25 //Stepper pins
26 P2OUT &= ~(STEPPER1 + STEPPER2 + STEPPER3 + STEPPER4); // Clear stepper pins output latch for a defined power-on state
27 P2DIR |= STEPPER1 + STEPPER2 + STEPPER3 + STEPPER4; // Set stepper pins to output direction
28
30
31 //fwdButton
32 P2DIR &= ~BIT1; // Input
33// P1REN |= BIT1; // Enable pull
34// P1OUT |= BIT1; // Enable pull up
35 P2IES &= ~BIT1; // low to high
36 P2IFG &= ~BIT1; // Clear flag
37 P2IE |= BIT1; // Enable interrupt
38 toggleFwdInterruptISR = 1; // Enable the ISR
39
40 //LED for lightning the clock
41 P1DIR |= BIT6; //LED0 as output
42 P1OUT &= ~BIT6; //Turn off LED0
43
44 //Indicator L
45 P1DIR |= BIT7; // Output
46 P1OUT &= ~BIT7; //Turn off
47
48 //EX-btn
49 P2DIR &= ~BIT2; // Input
50// P2REN |= BIT2; // Enable pull
51// P2OUT |= BIT2; // Enable pull up
52 P2IES &= ~BIT2; // low to high
53 P2IFG &= ~BIT2; // Clear interrupt flag
54// __delay_cycles(1000); // Small delay for stabilization otherwise a trigger is registered on boot up of dev board
55// P2IFG &= ~BIT2; // Clear it again
56 P2IE |= BIT2; // Enable interrupt
57
58 //DCF77 input
59 P1DIR &= ~BIT5; // Input
60 P1IES |= BIT5; // high to low, first trigger on a low going pulse to detect 1800 ms sync pulse after bit 58
61 P1IFG &= ~BIT5; // Clear interrupt flag
62 __delay_cycles(1000); // Small delay for stabilization otherwise a trigger is registered on boot up of dev board
63 P1IFG &= ~BIT5; // Clear it again
64 P1IE |= BIT5; // Enable interrupt
65
66 //5V converter
67 P1DIR |= BIT0; // Output
68 P1OUT &= ~BIT0; //Turn off
69
70 //See for ADC pin setup adc.c
71
72 __enable_interrupt(); // Enable global interrupts
73}
void setupClockIO()
Setup of the external clock pins, gets called from setupGpio(), wakeup(), sleep()
Definition gpio.c:120
bool toggleFwdInterruptISR
#define STEPPER2
Definition pins.h:14
#define STEPPER3
Definition pins.h:15
#define STEPPER4
Definition pins.h:16
#define STEPPER1
Definition pins.h:13

References setupClockIO(), STEPPER1, STEPPER2, STEPPER3, STEPPER4, and toggleFwdInterruptISR.

Referenced by main(), and wakeUp().

◆ sleep()

void sleep ( )

Setup of all GPIO's after sleep, gets called from ADC10_ISR(void)

Definition at line 90 of file gpio.c.

91{
92 // Configure GPIOs to it's lowest power state
94 P2IE &= ~BIT1; // Disable interrupt fwdButton
95 P2IE &= ~BIT2; // Disable interrupt exButton
96 P1IE &= ~BIT5; // Disable interrupt DCF77
97
98 P1OUT = 0; // All P1.x reset
99 P1DIR = 0xFF; // All P1.x outputs
100 P2OUT = 0; // All P2.x reset
101 P2DIR = 0xFF; // All P2.x outputs
102 P3OUT = 0; // All P3.x reset
103 P3DIR = 0xFF; // All P3.x outputs
104
105 P2DIR &= ~BIT1; // Input fwdButton
106 P2DIR &= ~BIT2; // Input exButton
107 P1DIR &= ~BIT5; // Input DCF77
108
109 //Keep ADC pins as input
110 P1DIR &= ~BIT1; // Set P1.1 as input: Battery
111 P1DIR &= ~BIT2; // Set P1.2 as input: Ignition switch
112
113 setupClockIO();
114}
void sleepTimer0()
Definition timer.c:36

References setupClockIO(), and sleepTimer0().

Referenced by ADC10_ISR().

◆ wakeUp()

void wakeUp ( )

Setup of all GPIO's after wakeup, gets called from ADC10_ISR(void)

Definition at line 79 of file gpio.c.

80{
81 setupGpio();
82 P1OUT |= BIT0; //Turn on 5v supply so stepper can spin
84}
void setupGpio()
Setup of all GPIO's on startup, gets called from main()
Definition gpio.c:19
void wakeUpTimer0()
Definition timer.c:43

References setupGpio(), and wakeUpTimer0().

Referenced by ADC10_ISR().