Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
L2HBAT_pico
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LOFAR2.0
L2HBAT_pico
Commits
23a8061c
Commit
23a8061c
authored
4 years ago
by
Paulus Kruger
Browse files
Options
Downloads
Patches
Plain Diff
Added decoding, simulate HBAT
parent
84145774
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
CMakeLists.txt
+1
-0
1 addition, 0 deletions
CMakeLists.txt
README.md
+4
-1
4 additions, 1 deletion
README.md
test.c
+109
-28
109 additions, 28 deletions
test.c
with
114 additions
and
29 deletions
CMakeLists.txt
+
1
−
0
View file @
23a8061c
...
...
@@ -8,6 +8,7 @@ add_executable(test
test.c
)
pico_enable_stdio_usb
(
test 1
)
pico_enable_stdio_uart
(
test 0
)
pico_add_extra_outputs
(
test
)
pico_generate_pio_header
(
test
${
CMAKE_CURRENT_LIST_DIR
}
/hba_tx.pio
)
pico_generate_pio_header
(
test
${
CMAKE_CURRENT_LIST_DIR
}
/hba_rx.pio
)
...
...
This diff is collapsed.
Click to expand it.
README.md
+
4
−
1
View file @
23a8061c
...
...
@@ -16,7 +16,10 @@ pico-sdk
-
copy test.uf2 to pico
# Controlling tile
Use jupyter scripts in scripts directory
Use jupyter scripts in scripts directory (currently using raw timing)
# Monitor tile
minicom -b 115200 -D /dev/ttyACM0
# Program structure
-
hba_tx.pio: Load delay from FIFO, thereafter continiously clock data out as they arrive in FIFO
...
...
This diff is collapsed.
Click to expand it.
test.c
+
109
−
28
View file @
23a8061c
...
...
@@ -8,21 +8,38 @@
#include
"hba_tx.pio.h"
#include
"hba_rx.pio.h"
//#define TX_RAW_TIME //This will give the raw time between edges instead of decoding it
#define SIMULATE_HBAT //Reply on request
const
uint
TX_PIN
=
14
;
//25=LED to test
const
uint
RX_PIN
=
14
;
///#define TXtimeout 0x1000
#define TXtimeout 0x80
//Need to change norm delay constants if time is changed!! This can be done using TX_RAW_TIME and python scripts.
inline
uint16_t
NormDelay
(
uint16_t
x
){
return
(
TXtimeout
-
x
+
19
)
/
20
;
}
#define BUFFERSIZE 512
char
buffer1
[
BUFFERSIZE
];
uint16_t
buffer2
[
BUFFERSIZE
];
int
bcnt1
=
0
,
bcnt2
=
0
;
int
bcnt3
=
0
,
bcnt4
=
0
;
uint8_t
bcnt1
=
0
,
bcnt2
=
0
;
uint8_t
bcnt3
=
0
,
bcnt4
=
0
;
uint16_t
dummy
;
void
core1_entry
()
{
while
(
1
)
{
// printf("3");
if
(
bcnt3
!=
bcnt4
)
{
#ifdef TX_RAW_TIME
printf
(
"%08x
\n
"
,
buffer2
[
bcnt4
]);
#else
if
(
buffer2
[
bcnt4
]
==
0x100
)
printf
(
"S"
,
buffer2
[
bcnt4
]);
else
if
(
buffer2
[
bcnt4
]
==
0x200
)
printf
(
"E
\n
"
,
buffer2
[
bcnt4
]);
else
printf
(
"%02x"
,
buffer2
[
bcnt4
]);
#endif
bcnt4
++
;
bcnt4
%=
BUFFERSIZE
;
}
else
{
...
...
@@ -38,7 +55,6 @@ int main() {
// bi_decl(bi_program_description("This is a test binary."));
// bi_decl(bi_1pin_with_name(LED_PIN, "On-board LED"));
stdio_init_all
();
PIO
pio_rx
=
pio1
;
uint
offset1
=
pio_add_program
(
pio_rx
,
&
hba_rx_program
);
...
...
@@ -51,42 +67,107 @@ int main() {
hba_tx_program_init
(
pio_tx
,
sm
,
offset
,
TX_PIN
);
printf
(
"Init
\n
"
);
// gpio_init(LED_PIN);
// gpio_set_dir(LED_PIN, GPIO_OUT);
gpio_set_pulls
(
TX_PIN
,
true
,
false
);
//
gpio_set_pulls(TX_PIN,true,false);
// gpio_set_pulls(RX_PIN,true,false);
pio_sm_put_blocking
(
pio_tx
,
sm
,
12500
);
//Bitrate = 150e6 / val. e.g. 15k = 10kHz
pio_sm_put_blocking
(
pio_rx
,
sm1
,
0x1000
);
//Timeout
pio_sm_put_blocking
(
pio_rx
,
sm1
,
TXtimeout
);
//Timeout
pio_sm_put_blocking
(
pio_tx
,
sm
,
0x00
);
multicore_launch_core1
(
core1_entry
);
printf
(
"Starting
\n
"
);
#ifdef TX_RAW_TIME
while
(
1
)
{
// gpio_put(LED_PIN, 0);
// printf("TX:%08x\n",pio_sm_get_tx_fifo_level(pio_tx, sm));
// printf("%32x\n", pio_sm_get_blocking(pio_rx, sm1));
if
(
pio_sm_get_rx_fifo_level
(
pio_rx
,
sm1
)
>
0
)
{
//First priority: Keep RX FIFO empty
buffer2
[
bcnt3
]
=
(
uint16_t
)(
pio_sm_get_blocking
(
pio_rx
,
sm1
));
bcnt3
++
;
bcnt3
%=
BUFFERSIZE
;
}
else
if
((
pio_sm_get_tx_fifo_level
(
pio_tx
,
sm
)
<
4
)
&&
(
bcnt1
!=
bcnt2
))
{
//Second priority: Keep TX FIFO full
// printf("TX%x\n",buffer1[bcnt2]);
pio_sm_put_blocking
(
pio_tx
,
sm
,
buffer1
[
bcnt2
]);
bcnt2
++
;
bcnt2
%=
BUFFERSIZE
;
};
/* else if (bcnt3!=bcnt4) {
printf("%08x\n", buffer2[bcnt4]);
bcnt4++;bcnt4%=BUFFERSIZE;
}
else
if
(
dummy
++==
0
)
printf
(
"."
);
}
else {
int x = getchar_timeout_us(0);
if (x!=PICO_ERROR_TIMEOUT){
buffer1[bcnt1]=x;
bcnt1++;bcnt1%=BUFFERSIZE;
#endif //TX_RAW_TIME
uint16_t
delay
;
uint8_t
previous
=
0
,
bit
=
0
,
ch
=
0
,
cnt
=
0
;
#ifdef SIMULATE_HBAT
inline
void
addTX
(
uint8_t
data
)
{
buffer1
[
bcnt1
++
]
=
255
-
data
;
bcnt1
%=
BUFFERSIZE
;
}
inline
void
TX_manchester
(
uint8_t
data
){
const
uint8_t
HBA_lookup
[
16
]
=
{
0xAA
,
0x6A
,
0x9A
,
0x5A
,
0xA6
,
0x66
,
0x96
,
0x56
,
0xA9
,
0x69
,
0x99
,
0x59
,
0xA5
,
0x65
,
0x95
,
0x55
};
addTX
(
HBA_lookup
[(
data
>>
4
)
&
0x0F
]);
addTX
(
HBA_lookup
[
data
&
0x0F
]);
}
inline
void
GiveAnswer
(
uint8_t
start
,
uint8_t
cnt
)
//Store broadcast data, give back per server when asked
{
static
uint8_t
tiledata
[
32
];
uint8_t
x
,
addr
;
addr
=
buffer2
[
start
];
if
(
addr
==
0
)
{
//Broadcast
if
(
cnt
!=
40
)
return
;
start
+=
6
;
start
%=
BUFFERSIZE
;
for
(
x
=
0
;
x
<
32
;
x
++
)
{
tiledata
[
x
]
=
buffer2
[
start
++
];
start
%=
BUFFERSIZE
;}
return
;
}
*/
// sleep_ms(250);
// pio_sm_put_blocking(pio, sm, 0);
// gpio_put(LED_PIN, 1);
// puts("Hello World\n");
// sleep_ms(1000);
if
((
addr
>=
1
)
&&
(
addr
<=
16
))
{
//Replay on request
if
(
cnt
!=
6
)
return
;
addTX
(
0xff
);
addTX
(
0x0F
);
addTX
(
0xa8
);
TX_manchester
(
buffer2
[
start
++
]
|
0x80
);
start
%=
BUFFERSIZE
;
//Adress + 0x80
TX_manchester
(
buffer2
[
start
++
]);
start
%=
BUFFERSIZE
;
//Length the same
TX_manchester
(
tiledata
[
2
*
addr
-
2
]);
//X data
TX_manchester
(
tiledata
[
2
*
addr
-
1
]);
//Y data
TX_manchester
(
0x11
);
//CRC1
TX_manchester
(
0x22
);
//CRC2
//for (x=1;x<cnt;x++){TX_manchester(buffer2[start++]);start%=BUFFERSIZE;}
addTX
(
0xfd
);
return
;
}
}
#else
inline
void
GiveAnswer
(
uint8_t
start
,
uint8_t
cnt
)
{};
#endif
inline
void
TXrestart
()
{
if
(
cnt
>
2
)
{
GiveAnswer
((
bcnt3
-
cnt
+
1
)
%
BUFFERSIZE
,
cnt
-
1
);
buffer2
[
bcnt3
++
]
=
0x200
;
bcnt3
%=
BUFFERSIZE
;
}
previous
=
0
;
bit
=
6
;
ch
=
0
;
cnt
=
0
;
//start new character
}
inline
void
TXchar
()
{
if
(
bit
>
0
)
{
if
(
cnt
++==
0
)
buffer2
[
bcnt3
++
]
=
0x100
;
else
buffer2
[
bcnt3
++
]
=
ch
;}
bcnt3
%=
BUFFERSIZE
;
//store last charater
previous
=
0
;
bit
=
0
;
ch
=
0
;
//start new character
}
inline
void
addbit0
(){
ch
<<=
1
;
if
(
++
bit
>=
8
)
TXchar
();
previous
=
0
;
}
inline
void
addbit1
(){
ch
<<=
1
;
ch
++
;
if
(
++
bit
>=
8
)
TXchar
();
previous
=
1
;
}
TXrestart
();
while
(
1
)
{
if
(
pio_sm_get_rx_fifo_level
(
pio_rx
,
sm1
)
>
0
)
{
//First priority: Keep RX FIFO empty
delay
=
NormDelay
(
(
uint16_t
)(
pio_sm_get_blocking
(
pio_rx
,
sm1
)));
// buffer2[bcnt3++]=delay; bcnt3%=BUFFERSIZE;
if
(
delay
==
0
)
TXrestart
();
//Timeout
else
if
(
delay
>=
6
)
TXrestart
();
//Long delay
else
if
(
previous
==
0
)
if
(
delay
<=
2
)
addbit0
();
else
{
addbit0
();
addbit1
();}
else
if
(
delay
==
2
)
addbit1
();
else
if
(
delay
==
3
)
addbit0
();
else
{
addbit0
();
addbit1
();}
}
else
if
((
pio_sm_get_tx_fifo_level
(
pio_tx
,
sm
)
<
4
)
&&
(
bcnt1
!=
bcnt2
))
{
//Second priority: Keep TX FIFO full
pio_sm_put_blocking
(
pio_tx
,
sm
,
buffer1
[
bcnt2
]);
bcnt2
++
;
bcnt2
%=
BUFFERSIZE
;
}
else
if
((
dummy
++==
0
)
&&
(
cnt
==
0
))
printf
(
"."
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment