hx711-pico-c
common.c
Go to the documentation of this file.
1 // MIT License
2 //
3 // Copyright (c) 2023 Daniel Robertson
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
6 // of this software and associated documentation files (the "Software"), to deal
7 // in the Software without restriction, including without limitation the rights
8 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 // copies of the Software, and to permit persons to whom the Software is
10 // furnished to do so, subject to the following conditions:
11 //
12 // The above copyright notice and this permission notice shall be included in all
13 // copies or substantial portions of the Software.
14 //
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 // SOFTWARE.
22 
23 #include <assert.h>
24 #include <stddef.h>
25 #include "hardware/pio.h"
26 #include "../include/common.h"
27 #include "../include/hx711.h"
28 #include "../include/hx711_reader.pio.h"
29 #include "../include/hx711_multi.h"
30 #include "../include/hx711_multi_awaiter.pio.h"
31 #include "../include/hx711_multi_reader.pio.h"
32 
34  .clock_pin = 0,
35  .data_pin = 0,
36  .pio = pio0,
37  .pio_init = hx711_reader_pio_init,
38  .reader_prog = &hx711_reader_program,
39  .reader_prog_init = hx711_reader_program_init
40 };
41 
43  .clock_pin = 0,
44  .data_pin_base = 0,
45  .chips_len = 0,
46  .pio_irq_index = HX711_MULTI_ASYNC_PIO_IRQ_IDX,
47  .dma_irq_index = HX711_MULTI_ASYNC_DMA_IRQ_IDX,
48  .pio = pio0,
49  .pio_init = hx711_multi_pio_init,
50  .awaiter_prog = &hx711_multi_awaiter_program,
51  .awaiter_prog_init = hx711_multi_awaiter_program_init,
52  .reader_prog = &hx711_multi_reader_program,
53  .reader_prog_init = hx711_multi_reader_program_init
54 };
55 
57  assert(cfg != NULL);
58  *cfg = HX711__DEFAULT_CONFIG;
59 }
60 
62  assert(cfg != NULL);
64 }
const hx711_config_t HX711__DEFAULT_CONFIG
Definition: common.c:33
void hx711_multi_get_default_config(hx711_multi_config_t *const cfg)
Definition: common.c:61
void hx711_get_default_config(hx711_config_t *const cfg)
Definition: common.c:56
const hx711_multi_config_t HX711__MULTI_DEFAULT_CONFIG
Definition: common.c:42
#define HX711_MULTI_ASYNC_PIO_IRQ_IDX
IRQ index defaults for PIO and DMA.
Definition: hx711_multi.h:65
#define HX711_MULTI_ASYNC_DMA_IRQ_IDX
Definition: hx711_multi.h:66
static const struct pio_program hx711_multi_awaiter_program
void hx711_multi_awaiter_program_init(hx711_multi_t *const hxm)
void hx711_multi_reader_program_init(hx711_multi_t *const hxm)
static const struct pio_program hx711_multi_reader_program
void hx711_multi_pio_init(hx711_multi_t *const hxm)
static const struct pio_program hx711_reader_program
void hx711_reader_program_init(hx711_t *const hx)
void hx711_reader_pio_init(hx711_t *const hx)
uint clock_pin
Definition: hx711.h:95
uint clock_pin
GPIO pin number connected to all HX711 chips.
Definition: hx711_multi.h:132