Change MAVLink function mask back to 256 (#489)
[betaflight.git] / docs / 1wire.md
blob68924f50b58e703ba30c54a758e5491ee92d97ea
1 # 1-wire passthrough esc programming
3 ### ESCs must have the BlHeli Bootloader.
5 If your ESCs didn't come with BlHeli Bootloader, you'll need to flash them with an ArduinoISP programmer first. [Here's a guide](http://bit.ly/blheli-f20).
7 This is the option you need to select for the bootloader:
9 ![Flashing BlHeli Bootloader](assets/images/blheli-bootloader.png)
11 Currently supported on the SPRACINGF3, STM32F3DISCOVERY, NAZE32 (including clones such as the FLIP32) and CC3D.
13 ## Wiring
15   - For the NAZE, no external wiring is necessary. Simply plug in the board via USB cable.
17   - For the CC3D, connect [a USB to UART adapter](http://bit.ly/cf-cp2102) to the flex port.
19     - Ensure MSP is enabled on the flex port. Unfortunatly the main port cannot be used in the current configuration due to the inverter on this port.
21     - You'll only need this connection to the CC3D, do not plug in the normal USB connection.
23     - If you need one, I prefer the [CP2102](http://bit.ly/cf-cp2102) as it is cheap and [the driver](https://www.silabs.com/products/mcu/Pages/USBtoUARTBridgeVCPDrivers.aspx) is readily available.
25   - In the case that your board does not power on fully without a battery attached, it is OK to attach the battery before following the steps below. However, it may not be necessary in all cases.
27 ## Usage
29   - Plug in the USB cable and connect to your board with the INAV configurator.
31     - For boards without a built in USB/UART adapter, you'll need to plug an external one in. Here is how you wire up the CC3D. Plug your USB/UART adapter into the Flexi port:
33       ![Flashing BlHeli Bootloader](assets/images/serial1wire-cc3d-wiring.jpg)
35   - Open the BlHeli Suite.
37   - Ensure you have selected the correct Atmel or SILABS "Cleanflight" option under the "Select ATMEL / SILABS Interface" menu option.
39   - Ensure you have port for your external USB/UART adapter selected, if you're using one, otherwise pick the same COM port that you normally use for INAV.
41   - Click "Connect" and wait for the connection to complete. If you get a COM error, hit connect again. It will probably work.
43   - Use the boxes at the bottom to select the ESCs you have connected. Note that the boxes correspond directly to the ports on your flight controller. For example if you have motors on ports 1-4, pick boxes 1-4 or in the case of a tri-copter that uses motors on ports 3, 4 and 5, select those ports in BlHeli.
45   - Click "Read Setup"
47   - Use BlHeli suite as normal.
49   - When you're finished with one ESC, click "Disconnect"
51 ## Implementing and Configuring targets
53 The following parameters can be used to enable and configure this in the related target.h file:
55     USE_SERIAL_1WIRE              Enables the 1wire code, defined in target.h
58   - For new targets
60     - in `target.h`
62         ```
63         // Turn on serial 1wire passthrough
64         #define USE_SERIAL_1WIRE
65         // How many escs does this board support?
66         #define ESC_COUNT 6
67         // STM32F3DISCOVERY TX - PC3 connects to UART RX
68         #define S1W_TX_GPIO         GPIOC
69         #define S1W_TX_PIN          GPIO_Pin_3
70         // STM32F3DISCOVERY RX - PC1 connects to UART TX
71         #define S1W_RX_GPIO         GPIOC
72         #define S1W_RX_PIN          GPIO_Pin_1
73         ```
75     - in `serial_1wire.c`
77        ```
78        // Define your esc hardware
79        #if defined(STM32F3DISCOVERY) && !(defined(CHEBUZZF3))
80        const escHardware_t escHardware[ESC_COUNT] = {
81          { GPIOD, 12 },
82          { GPIOD, 13 },
83          { GPIOD, 14 },
84          { GPIOD, 15 },
85          { GPIOA, 1 },
86          { GPIOA, 2 }
87        };
88        ```
90 ## Development Notes
92 On the STM32F3DISCOVERY, an external pullup on the ESC line may be necessary. I needed a 3v, 4.7k pullup.