-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
47 lines (37 loc) · 869 Bytes
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
* Copyright (c) 2022 Gerhard Schiller
* SPDX-License-Identifier: GPL-3.0-or-later
* https://www.gnu.org/licenses/gpl-3.0.txt
*/
#include <stdio.h>
#include "pico/stdlib.h"
// "hardware/clocks.h" gets included by "sn74165.pio.h"
#include "sn74165.pio.h"
int main()
{
int x;
stdio_init_all();
printf("SN74xx165 PIO-Interface for %d device(s) with %.2f kHz clock.\n",
sn74165_NUM_DEVICES, (float)(sn74165::SHIFT_CLK) / 1000.0) ;
sn74165::shiftreg_init();
uint32_t data;
uint32_t data2;
bool inpChanged;
int loop = 0;
while (true)
{
data = sn74165::shiftreg_get(&inpChanged);
if(inpChanged){
loop++;
printf("\n%4d 0x%08X\t\t", loop, data);
printf("%08b %08b %08b %08b\n",
(data >> 24) & 0xFF,
(data >> 16) & 0xFF,
(data >> 8) & 0xFF,
data & 0xFF);
}
else
printf(".");
sleep_ms(200);
}
}