add_compile_options(-Wall -Wextra -pedantic)
-add_executable(libsi24 libsi24.c)
+add_library(libsi24 libsi24.c)
target_include_directories(libsi24
PUBLIC
{
free(si);
}
-
-/* hardware linkage */
-int spi_w_r(unsigned char *data, size_t sz)
-{
- if (sz >= 2)
- data[1] = (1 << RX_DR);
- return sz;
-}
-
-void ce(unsigned val)
-{
- (void) val;
-}
-
-void eh(si24_t *si, si24_event_t * e)
-{
- (void) si;
-
- switch(e->type) {
- case EV_TX_COMPLETE:
- printf("SENT SUCCESFUL\n");
- break;
- case EV_RX_COMPLETE:
- printf("RECV COMPLETE\n");
- break;
- case EV_RX_EMPTY:
- printf("NO NEW DATA\n");
- break;
- case EV_ERR_TIMEOUT:
- printf("TIMEOUT\n");
- break;
- default:
- printf("EVENT: %x\n", e->type);
- break;
- }
-}
-
-int main(void)
-{
- /* const unsigned char buf[] = "THIS IS A WIRELESS TEST MESSAGE!";*/
- unsigned char recv_buf[29];
-
- si24_ioctl_t ctl = {
- .write_and_read = spi_w_r,
- .chip_enable = ce,
- };
-
- const si24_opts_t opts = {
- .mode = RECV_MODE,
- .enable_ack = 1,
- .non_blocking = 0,
- .enable_crc = 1,
- .enable_dynpd = 1,
- .crc = TWO_BYTE,
- .ioctl = &ctl,
- .speed = MBPS2,
- .txpwr = PLUS4DB,
- .payload = 5,
- .timeout = 1,
- .retries = 5,
- .mac_addr = 0xAAAAAAAAAA
- };
-
- struct si24_t * si = si24_init(&opts, eh);
- /* si24_send(si, buf, sizeof(buf)); */
- printf("READ: %ld\n", si24_recv(si, recv_buf, sizeof(recv_buf)));
-
-}