-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathteensy3_morse_bsp.h
131 lines (89 loc) · 3.13 KB
/
teensy3_morse_bsp.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
// -*- mode: C++; -*-
/**\file teensy3_morse_bsp.h
\brief Teensy 3.0 board support package
*/
#pragma once
#include "Arduino.h"
/// Return a pointer to a static string that identifies the processor chip.
char* identifyProcessor();
/// Establish a baseline for a touch sensor when no touch is present.
void calibrateTouch(uint8_t pin);
/// Return the capacitance threshold in internal units of approximately
/// pF/20 per count.
uint16_t getPinThreshold(uint8_t pin);
/// Use calibration data to determine whether or not a touch is present
/// on a given sensor.
bool touchPoll(uint8_t pin);
/// 50% duty cycle for analogWrite
const size_t duty50 = 255/2;
size_t getDuty();
void setDuty(uint8_t);
bool isEarphonePresent();
/// Generate a tone using PWM.
void beep(uint32_t frequency, uint32_t durationMicros);
/// Teensy 3.0 LED
const int ledPin = 13; // Not used in the appliance.
/// Pin attached to a small speaker in the PDA hardware.
const int beepPin = 10;
const int earphoneRightDetectPin = 3;
const int earphoneRightPin = 4;
/// Note: earphoneLeftPin isn't actually wired up in the appliance.
const int piezoTxP = 22;
const int piezoTxN = 20;
/// Sends audio to the radio.
const int txPin = 23;
/// Provides "push to talk" open collector enabling the radio.
const int txEnablePin = 14;
const int ledRedP = 27;
const int ledRedN = 30;
const int ledGreenP = 29;
const int ledGreenN = 28;
#if defined(PDA)
/// A touchRead() pin. Auto-repeats a dit.
const int ditPin = 0;
/// A touchRead() pin. Auto-repeats a dah.
const int dahPin = 1;
#else
/// A touchRead() pin. Auto-repeats a dit.
const int ditPin = 19;
/// A touchRead() pin. Auto-repeats a dah.
const int dahPin = 17;
#endif
/// Voltage measurement 0 - 3.3V
const int analogInput = 21;
const int temperatureSensor = 38;
bool getSenseMode();
void setSenseMode(bool mode);
/// Transmit the internal temperature in integer Celcius.
/// From https://community.freescale.com/thread/304728
float getInternalTemperatureC();
///\brief Return the most recent ADC measurement of the input voltage.
/// Perform analog to digital conversion on the analogInput pin,
/// callibrated to the protection diode and voltage divider on the
/// interface/power board.
int32_t readMillivolts();
/// Increment the voltage sampling and filtering.
void sampleVoltage();
/// Report register settings related to the external clock crystal.
void describeRTC();
/// Sense whether or not a realtime clock crystal is present.
bool hasRTC();
///\brief Initialize the input and output ports used by appliance or
/// PDA hardware.
void initPorts();
///\brief Set the PWM frequency for the audio output pins.
void pwmFrequency(int Hz);
///\brief Generate a tone on the audio output pins.
void pwmWrite(int duty);
///\brief Perform digital writes to all the output pins.
void dWrite(int value);
///\brief Turn the red LED on (1) or off (0).
void redLED(int value);
///\brief Turn the green LED on (1) or off (0).
void greenLED(int value);
///\brief Change the state of the green LED.
void toggleGreenLED();
///\brief Change the state of the red LED.
void toggleRedLED();
///\brief Get the raw analog input.
uint32_t getRawVoltage();