SingingCat 0
application
ti1101_netdev.c
1#include "main-header.h"
2#include "networkif.h"
3#include "ti1101.h"
4int internal_ti1101_init(struct network_context *nctx);
5int ti1101_probe(struct network_context *nc);
6int ti1101_init(struct network_context *nc);
7//int ti1101_loop(struct network_context *nc);
8void ti1101_irq(struct network_context *ctx, int pin);
9int ti1101_probe(struct network_context *ctx);
10int ti1101_loop(struct network_context *ctx);
11struct networkif ti1101dev = {
12 .probe = &ti1101_probe,
13 .init = &ti1101_init,
14 .loop = &ti1101_loop,
15 .transmit = &ti1101_transmit,
16 .info = NULL,
17 .stop = NULL,
18 .busy = NULL,
19};
20
21struct networkif *ti1101_get_netdev() {
22 return &ti1101dev;
23}
24
25
26// 0 if ok
27int detect_and_init_ti1101(struct network_context *nctx) {
28 ti1101_disable_irq(nctx);
29 packet_buf_init(PACKETBUFFER_CC1101);
30 if (config_get_ti1101disable()) {
31 ti1101_off();
32 return 1;
33 }
34 int tir = 0;
35
36
37 tir = internal_ti1101_init(nctx);
38 if (tir) {
39 IPLOG("No TI1101 found!\r\n");
40 return 2;
41 }
42 IPLOG("\r\nDone.\r\n");
43 IPLOG("CC1101 version: %i\r\n", ti1101_read_version());
44 return 0;
45}
46
47int ti1101_init(struct network_context *nctx) {
48 IPLOG("********* Init CC1101 start ***********\r\n");
49 int p;
50
51 p = detect_and_init_ti1101(nctx);
52 if (p != 0) {
53 return p;
54 }
55 ti1101_enable_irq();
56 nic_set_transmit_status(nctx, 1);
57 IPLOG("********* Init CC1101 completed ***********\r\n");
58 return 0;
59}
60int ti1101_probe(struct network_context *nctx) {
61 int p;
62
63 IPLOG("********* Probe CC1101 start ***********\r\n");
64 p = detect_and_init_ti1101(nctx);
65 IPLOG("********* Probe CC1101 done ***********\r\n");
66 return p;
67}
int ti1101_loop(struct network_context *ctx)
this is called in the main thread periodically
Definition: ti1101.c:801
int ti1101_off()
diable processing of ti1101 commands
Definition: ti1101.c:629
void packet_buf_init(const int num)
initialize (reset, clear) a given buffer
Definition: packetbuffer.c:37