Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onewire: Implement scan for multiple devices #139

Merged
merged 6 commits into from
Sep 28, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Reformat code
The file was given to `astyle -t --style=linux --lineend=linux hydrabus_mode_onewire.c`.
However, the crc constants array was left untouched to keep the commas aligned.
  • Loading branch information
jbglaw committed Sep 27, 2022
commit 2799fcd64cf1ea9fa87485338f86f3a09deab6ae
22 changes: 11 additions & 11 deletions src/hydrabus/hydrabus_mode_onewire.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,21 @@ static void show_params(t_hydra_console *con)
mode_config_proto_t* proto = &con->mode->proto;

cprintf(con, "Device: onewire%d\r\nGPIO resistor: %s\r\n",
proto->dev_num + 1,
proto->config.onewire.dev_gpio_pull == MODE_CONFIG_DEV_GPIO_PULLUP ? "pull-up" :
proto->config.onewire.dev_gpio_pull == MODE_CONFIG_DEV_GPIO_PULLDOWN ? "pull-down" :
"floating");
proto->dev_num + 1,
proto->config.onewire.dev_gpio_pull == MODE_CONFIG_DEV_GPIO_PULLUP ? "pull-up" :
proto->config.onewire.dev_gpio_pull == MODE_CONFIG_DEV_GPIO_PULLDOWN ? "pull-down" :
"floating");

cprintf(con, "Bit order: %s first\r\n",
proto->config.onewire.dev_bit_lsb_msb == DEV_FIRSTBIT_MSB ? "MSB" : "LSB");
proto->config.onewire.dev_bit_lsb_msb == DEV_FIRSTBIT_MSB ? "MSB" : "LSB");
}

bool onewire_pin_init(t_hydra_console *con)
{
mode_config_proto_t* proto = &con->mode->proto;

bsp_gpio_init(BSP_GPIO_PORTB, ONEWIRE_PIN,
proto->config.onewire.dev_gpio_mode, proto->config.onewire.dev_gpio_pull);
proto->config.onewire.dev_gpio_mode, proto->config.onewire.dev_gpio_pull);
return true;
}

Expand Down Expand Up @@ -111,11 +111,11 @@ void onewire_write_bit(t_hydra_console *con, uint8_t bit)
{
onewire_mode_output(con);
onewire_low();
if(bit){
if(bit) {
DelayUs(6);
onewire_high();
DelayUs(64);
}else{
} else {
DelayUs(60);
onewire_high();
DelayUs(10);
Expand Down Expand Up @@ -434,7 +434,7 @@ static uint32_t write(t_hydra_console *con, uint8_t *tx_data, uint8_t nb_data)
cprintf(con, hydrabus_mode_str_mul_write);
for(i = 0; i < nb_data; i++) {
cprintf(con, hydrabus_mode_str_mul_value_u8,
tx_data[i]);
tx_data[i]);
}
cprintf(con, hydrabus_mode_str_mul_br);
}
Expand All @@ -456,7 +456,7 @@ static uint32_t read(t_hydra_console *con, uint8_t *rx_data, uint8_t nb_data)
cprintf(con, hydrabus_mode_str_mul_read);
for(i = 0; i < nb_data; i++) {
cprintf(con, hydrabus_mode_str_mul_value_u8,
rx_data[i]);
rx_data[i]);
}
cprintf(con, hydrabus_mode_str_mul_br);
}
Expand All @@ -468,7 +468,7 @@ static uint32_t dump(t_hydra_console *con, uint8_t *rx_data, uint8_t nb_data)
uint8_t i;

i = 0;
while(i < nb_data){
while(i < nb_data) {
rx_data[i] = onewire_read_u8(con);
i++;
}
Expand Down