This repository has been archived by the owner on Sep 17, 2022. It is now read-only.
forked from lokthelok/aj2019-kit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaj_hal.h
75 lines (63 loc) · 2.04 KB
/
aj_hal.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
* File: aj_hal.h
* Author: Lachlan
*
* Created on September 9, 2018, 5:10 PM
*/
#ifndef AJ_HAL_H
#define AJ_HAL_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdbool.h>
#include <stdint.h>
//################# APPLICATION ##################
typedef enum {
game,
connect,
scoreGame,
scoreConnect,
sleep
} appState;
//################### BUTTONS ####################
//checkButtons - Disable Serial, Read the ADC (blocking), update buttons states.
//Pass in buttons[3] which contains boolean states (1=pressed) of each button.
void checkButtons(bool buttons[]); //buttons[3]
//################### LED PWM ####################
// setupLEDs - Turn off PWM Channels, set period, phase=0, duty=0
void setupLEDs (uint16_t period);
//stopLEDs - Turn off PWM Channels
void stopLEDs ();
//startLEDs - Turn on PWM Channels
void startLEDs ();
//setLEDs - Set duty cycle for all LEDs
void setLEDs (uint16_t led1, uint16_t led2, uint16_t led3);
//setLED - Set duty cycle for one LED. Pass led number (1-3)
void setLED (uint16_t duty, uint8_t LEDno);
//################### SERIAL #####################
//enableSerial - Enable TX channel
void enableSerial ();
//disableSerial - Disable RX channel
void disableSerial ();
//EUSART_RxCheck - Check for received bytes
bool EUSART_RxCheck ();
//connectHandler - interrupt handler for RX detecting HIGH (idle TX signal)
void connectHandler ();
//setupConnectInterrupt - sets buttonHandler as interrupt handler
void setupConnectInterrupt ();
//#################### SLEEP #####################
//buttonHandler - interrupt handler for Button, checks for reset/wake
void buttonHandler ();
//setupButtonInterrupt - sets buttonHandler as interrupt handler
void setupButtonInterrupt ();
//goToSleep - Sets RA0 digital in, Turn off LEDs, Serial off, sleep, wake-up nop
void goToSleep ();
//################## INTERRUPT ###################
//Interrupts on - Global and Peripheral
void enableInterrupts ();
//Interrupts off - Global and Peripheral
void disableInterrupts ();
#ifdef __cplusplus
}
#endif
#endif /* AJ_HAL_H */