summaryrefslogtreecommitdiff
path: root/software/avr.lib/cc1101.h
blob: ce97d9d94485abda7fff37511d2430d45d7e32cd (plain) (blame)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
 *  spreadspace avr utils
 *
 *
 *  Copyright (C) 2013-2015 Christian Pointner <equinox@spreadspace.org>
 *
 *  This file is part of spreadspace avr utils.
 *
 *  spreadspace avr utils is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  any later version.
 *
 *  spreadspace avr utils is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with spreadspace avr utils. If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef SPREADAVR_cc1101_h_INCLUDED
#define SPREADAVR_cc1101_h_INCLUDED

typedef enum { unknown, sleep, idle, xoff, mancal, fs_wakeup, calibrate, settling, rx, txrx_settling,
               rxfifo_overflow, fstxon, tx, rxtx_settling, txfifo_underflow } cc1101_state_t;
char* cc1101_state_to_string(cc1101_state_t);

#define CC1101_FREQ_CORR(xtal) ((float)(xtal/65536.0))

typedef struct {
  void (*spi_cs_enable)(void);
  void (*spi_cs_disable)(void);
  uint8_t (*spi_read_miso)(void);
  void (*spi_write_byte)(const uint8_t);
  uint8_t (*spi_read_byte)(void);
  uint8_t (*spi_transfer_byte)(const uint8_t);
  float freq_corr;
} cc1101_driver_conf_t;

void cc1101_init(cc1101_driver_conf_t conf);
void cc1101_reg_init(void);
void cc1101_soft_reset(void);

void cc1101_powerdown(void);
void cc1101_idle(void);
void cc1101_osc_off(void);
void cc1101_calibrate(void);
void cc1101_fasttxon(void);
cc1101_state_t cc1101_get_state(void);

void cc1101_set_freq_hz(uint32_t hz);
uint32_t cc1101_get_freq_hz(void);

void cc1101_dump_register(void);

#endif