5 * th9x - http://code.google.com/p/th9x
6 * er9x - http://code.google.com/p/er9x
7 * gruvin9x - http://code.google.com/p/gruvin9x
9 * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
21 #ifndef _PULSES_PXX_H_
22 #define _PULSES_PXX_H_
24 #include "pulses_common.h"
26 #define PXX_SEND_BIND 0x01
27 #define PXX_SEND_FAILSAFE (1 << 4)
28 #define PXX_SEND_RANGECHECK (1 << 5)
30 #define PXX2_LOWSPEED_BAUDRATE 230400
31 #define PXX2_HIGHSPEED_BAUDRATE 450000
32 #define PXX2_PERIOD 4 // 4ms
33 #define PXX2_TOOLS_PERIOD 1 // 1ms
34 #define PXX2_FRAME_MAXLENGTH 64
36 #define PXX_PULSES_PERIOD 9/*ms*/
37 #define EXTMODULE_PXX1_SERIAL_PERIOD 4/*ms*/
38 #define EXTMODULE_PXX1_SERIAL_BAUDRATE 420000
40 #if defined(PXX_FREQUENCY_HIGH)
41 #define INTMODULE_PXX1_SERIAL_BAUDRATE 450000
42 #define INTMODULE_PXX1_SERIAL_PERIOD 4/*ms*/
44 #define INTMODULE_PXX1_SERIAL_BAUDRATE 115200
45 #define INTMODULE_PXX1_SERIAL_PERIOD 9/*ms*/
48 // Used by the Sky9x family boards
49 class SerialPxxBitTransport
: public DataBuffer
<uint8_t, 64> {
54 void initFrame(uint32_t period
)
61 void addSerialBit(uint8_t bit
)
67 if (++bits_count
>= 8) {
73 // 8uS/bit 01 = 0, 001 = 1
74 void addPart(uint8_t value
)
85 while (bits_count
!= 0) {
91 class PwmPxxBitTransport
: public PulsesBuffer
<pulse_duration_t
, 200> {
95 void initFrame(uint32_t period
)
98 rest
= period
* 2000; // 0.5uS (2Mhz)
101 void addPart(uint8_t value
)
103 pulse_duration_t duration
= value
? 47 : 31;
105 rest
-= duration
+ 1;
110 // rest min value is 18000 - 200 * 48 = 8400 (4.2ms)