hx711-pico-c
hx711_multi_awaiter.pio.h
Go to the documentation of this file.
1 // -------------------------------------------------- //
2 // This file is autogenerated by pioasm; do not edit! //
3 // -------------------------------------------------- //
4 
5 #pragma once
6 
7 #if !PICO_NO_HARDWARE
8 #include "hardware/pio.h"
9 #endif
10 
11 // ------------------- //
12 // hx711_multi_awaiter //
13 // ------------------- //
14 
15 #define hx711_multi_awaiter_wrap_target 0
16 #define hx711_multi_awaiter_wrap 6
17 
18 #define hx711_multi_awaiter_offset_wait_in_pins_bit_count 0u
19 
20 static const uint16_t hx711_multi_awaiter_program_instructions[] = {
21  // .wrap_target
22  0x4001, // 0: in pins, 1
23  0xa046, // 1: mov y, isr
24  0x8000, // 2: push noblock
25  0x0066, // 3: jmp !y, 6
26  0xc044, // 4: irq clear 4
27  0x0000, // 5: jmp 0
28  0xc004, // 6: irq nowait 4
29  // .wrap
30 };
31 
32 #if !PICO_NO_HARDWARE
33 static const struct pio_program hx711_multi_awaiter_program = {
35  .length = 7,
36  .origin = -1,
37 };
38 
39 static inline pio_sm_config hx711_multi_awaiter_program_get_default_config(uint offset) {
40  pio_sm_config c = pio_get_default_sm_config();
41  sm_config_set_wrap(&c, offset + hx711_multi_awaiter_wrap_target, offset + hx711_multi_awaiter_wrap);
42  return c;
43 }
44 
45 // MIT License
46 //
47 // Copyright (c) 2023 Daniel Robertson
48 //
49 // Permission is hereby granted, free of charge, to any person obtaining a copy
50 // of this software and associated documentation files (the "Software"), to deal
51 // in the Software without restriction, including without limitation the rights
52 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
53 // copies of the Software, and to permit persons to whom the Software is
54 // furnished to do so, subject to the following conditions:
55 //
56 // The above copyright notice and this permission notice shall be included in all
57 // copies or substantial portions of the Software.
58 //
59 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
60 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
61 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
62 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
63 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
64 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
65 // SOFTWARE.
66 #include <assert.h>
67 #include <stddef.h>
68 #include "hardware/pio.h"
69 #include "hardware/pio_instructions.h"
70 #include "hx711_multi.h"
72  assert(hxm != NULL);
73  assert(hxm->_pio != NULL);
74  assert(hxm->_chips_len > 0);
76  hxm->_awaiter_offset);
77  //replace placeholder in instruction with the number of pins
78  //to read
80  pio_encode_in(pio_pins, hxm->_chips_len);
81  //data pins
82  pio_sm_set_in_pins(
83  hxm->_pio,
84  hxm->_awaiter_sm,
85  hxm->_data_pin_base);
86  pio_sm_set_consecutive_pindirs(
87  hxm->_pio,
88  hxm->_awaiter_sm,
89  hxm->_data_pin_base,
90  hxm->_chips_len,
91  false); //false = output pins
92  sm_config_set_in_pins(
93  &cfg,
94  hxm->_data_pin_base);
95  //even though the program reads data into the ISR,
96  //it does not push any data, so make sure autopushing
97  //is disabled
98  sm_config_set_in_shift(
99  &cfg,
100  false, //false = shift left
101  false, //false = autopush disabled
102  hxm->_chips_len); //autopush threshold
103  pio_sm_clear_fifos(
104  hxm->_pio,
105  hxm->_awaiter_sm);
106  hxm->_awaiter_default_config = cfg;
107 }
108 
109 #endif
110 
#define hx711_multi_awaiter_wrap
static const struct pio_program hx711_multi_awaiter_program
static const uint16_t hx711_multi_awaiter_program_instructions[]
void hx711_multi_awaiter_program_init(hx711_multi_t *const hxm)
#define hx711_multi_awaiter_wrap_target
static pio_sm_config hx711_multi_awaiter_program_get_default_config(uint offset)
#define hx711_multi_awaiter_offset_wait_in_pins_bit_count
uint _data_pin_base
Definition: hx711_multi.h:95
pio_sm_config _awaiter_default_config
Definition: hx711_multi.h:101
size_t _chips_len
Definition: hx711_multi.h:96
uint _awaiter_offset
Definition: hx711_multi.h:103