Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

getChannelData

  • Loading branch information...
commit 13cbb2e133e6818ea0aa3ce15dc7d51bed6b12ce 1 parent 69e3063
@grantmd authored
Showing with 30 additions and 1 deletion.
  1. +17 −0 Spektrum.c
  2. +12 −0 Spektrum.h
  3. +1 −1  main.c
View
17 Spektrum.c
@@ -17,6 +17,8 @@ static const SerialConfig sd3cfg = {
0
};
+int receiver_data[MAX_RC_CHANNELS];
+
/*
* Activates the serial driver 3
* PD8(TX) and PD9(RX) are routed to USART3.
@@ -27,4 +29,19 @@ void SpektrumInit(void){
sdStart(&SD3, &sd3cfg);
palSetPadMode(GPIOD, 8, PAL_MODE_ALTERNATE(7)); // not currently connected
palSetPadMode(GPIOD, 9, PAL_MODE_ALTERNATE(7)); // incoming data from the receiver
+
+ unsigned i;
+ for (i=0; i<MAX_RC_CHANNELS; i++){
+ receiver_data[i] = 0;
+ }
+}
+
+/*
+ * Returns the most recent data for the given channel
+ */
+
+int getChannelData(int channel){
+ if (channel < 0 || channel >= MAX_RC_CHANNELS) return 0;
+
+ return receiver_data[channel];
}
View
12 Spektrum.h
@@ -8,6 +8,18 @@
#ifndef _SPEKTRUM_H_
#define _SPEKTRUM_H_
+// Warning: Possibly only accurate for the DX6i TX
+#define MAX_RC_CHANNELS 6
+#define AILE_CHANNEL 0
+#define AUX1_CHANNEL 1 // Flaps?
+#define ELEV_CHANNEL 2
+#define RUDD_CHANNEL 3
+#define THROTTLE_CHANNEL 4
+#define GEAR_CHANNEL 5
+#define AUX2_CHANNEL 6
+
void SpektrumInit(void);
+int getChannelData(int channel);
+
#endif /* _SPEKTRUM_H_ */
View
2  main.c
@@ -114,7 +114,7 @@ int main(void) {
chprintf(chp, "Configurating I/O.\r\n");
/*
- * Activates the serial driver 1 using the driver default configuration, but at 38400
+ * Activates the serial driver 1 using the driver default configuration, but at 57600
* PA9(TX) and PA10(RX) are routed to USART1.
*/
Please sign in to comment.
Something went wrong with that request. Please try again.