* @brief Send a 1-Wire write bit, with recovery time. * @param[in] bus Initialised bus instance. * @param[in] bit The value to send. */
| 145 | * @param[in] bit The value to send. |
| 146 | */ |
| 147 | static void _write_bit(const OneWireBus * bus, int bit) |
| 148 | { |
| 149 | struct modGPIOConfigurationRecord *config = bus->config; |
| 150 | |
| 151 | modCriticalSectionBegin(); |
| 152 | |
| 153 | modGPIOWrite(config, 0); // Drive DQ low |
| 154 | #if MODDEF_ONEWIRE_DIRECTGPIO |
| 155 | DIRECT_MODE_OUTPUT(REG, PIN_TO_BITMASK(config->pin)); |
| 156 | #else |
| 157 | modGPIOSetMode(config, kModGPIOOutputOpenDrain); |
| 158 | #endif |
| 159 | if (bit) { |
| 160 | ets_delay_us(bus->timing->A); |
| 161 | modGPIOWrite(config, 1); // Release the bus |
| 162 | modCriticalSectionEnd(); |
| 163 | ets_delay_us(bus->timing->B); |
| 164 | } |
| 165 | else { |
| 166 | ets_delay_us(bus->timing->C); |
| 167 | modGPIOWrite(config, 1); // Release the bus |
| 168 | modCriticalSectionEnd(); |
| 169 | ets_delay_us(bus->timing->D); |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | /** |
| 174 | * @brief Read a bit from the 1-Wire bus and return the value, with recovery time. |
no test coverage detected