чуть структурирована, добавлено описение по подключению в шапке

добавлен пример для stm32
This commit is contained in:
2025-06-21 09:05:50 +03:00
parent c2dca42be6
commit 7ef076e289
928 changed files with 481793 additions and 461 deletions

View File

@@ -24,13 +24,13 @@ void OneWire_WriteBit(OneWire_t* OW, uint8_t bit)
OneWire_Pin_Mode(OW, Output);
/* Forming pulse */
OneWire_Delay_uw(ONEWIRE_WRITE_1_US);
OneWire_Delay_us(ONEWIRE_WRITE_1_US);
/* Release line (pull up line) */
OneWire_Pin_Mode(OW, Input);
/* Wait for 55 us and release the line */
OneWire_Delay_uw(ONEWIRE_COMMAND_SLOT_US - ONEWIRE_WRITE_1_US);
OneWire_Delay_us(ONEWIRE_COMMAND_SLOT_US - ONEWIRE_WRITE_1_US);
OneWire_Pin_Mode(OW, Input);
}else{
/* Set line low */
@@ -38,13 +38,13 @@ void OneWire_WriteBit(OneWire_t* OW, uint8_t bit)
OneWire_Pin_Mode(OW, Output);
/* Forming pulse */
OneWire_Delay_uw(ONEWIRE_WRITE_0_US);
OneWire_Delay_us(ONEWIRE_WRITE_0_US);
/* Release line (pull up line) */
OneWire_Pin_Mode(OW, Input);
/* Wait for 5 us and release the line */
OneWire_Delay_uw(ONEWIRE_COMMAND_SLOT_US - ONEWIRE_WRITE_0_US);
OneWire_Delay_us(ONEWIRE_COMMAND_SLOT_US - ONEWIRE_WRITE_0_US);
OneWire_Pin_Mode(OW, Input);
}
__enable_irq();
@@ -69,17 +69,17 @@ uint8_t OneWire_ReadBit(OneWire_t* OW)
/* Line low */
OneWire_Pin_Level(OW, 0);
OneWire_Pin_Mode(OW, Output);
OneWire_Delay_uw(ONEWIRE_READ_CMD_US);
OneWire_Delay_us(ONEWIRE_READ_CMD_US);
/* Release line */
OneWire_Pin_Mode(OW, Input);
OneWire_Delay_uw(ONEWIRE_READ_DELAY_US);
OneWire_Delay_us(ONEWIRE_READ_DELAY_US);
/* Read line value */
bit = OneWire_Pin_Read(OW);
/* Wait 50us to complete 60us period */
OneWire_Delay_uw(ONEWIRE_COMMAND_SLOT_US - ONEWIRE_READ_CMD_US - ONEWIRE_READ_DELAY_US);
OneWire_Delay_us(ONEWIRE_COMMAND_SLOT_US - ONEWIRE_READ_CMD_US - ONEWIRE_READ_DELAY_US);
__enable_irq();
#else
bit = OneWireUART_ProcessBit(onewire_uart, 1);
@@ -149,17 +149,17 @@ uint8_t OneWire_Reset(OneWire_t* OW)
/* Line low, and wait 480us */
OneWire_Pin_Level(OW, 0);
OneWire_Pin_Mode(OW, Output);
OneWire_Delay_uw(ONEWIRE_RESET_PULSE_US);
OneWire_Delay_us(ONEWIRE_RESET_PULSE_US);
/* Release line and wait for 70us */
OneWire_Pin_Mode(OW, Input);
OneWire_Delay_uw(ONEWIRE_PRESENCE_WAIT_US);
OneWire_Delay_us(ONEWIRE_PRESENCE_WAIT_US);
/* Check bit value */
uint8_t rslt = OneWire_Pin_Read(OW);
/* Delay for 410 us */
OneWire_Delay_uw(ONEWIRE_PRESENCE_DURATION_US);
OneWire_Delay_us(ONEWIRE_PRESENCE_DURATION_US);
#else
uint8_t rslt = 0;
@@ -316,11 +316,11 @@ void OneWire_Init(OneWire_t* OW)
{
OneWire_Pin_Mode(OW, Output);
OneWire_Pin_Level(OW, 1);
OneWire_Delay_uw(1000);
OneWire_Delay_us(1000);
OneWire_Pin_Level(OW, 0);
OneWire_Delay_uw(1000);
OneWire_Delay_us(1000);
OneWire_Pin_Level(OW, 1);
OneWire_Delay_uw(2000);
OneWire_Delay_us(2000);
/* Reset the search state */
OW->LastDiscrepancy = 0;