Skip to content

Commit

Permalink
wip: add more options to dts
Browse files Browse the repository at this point in the history
  • Loading branch information
everedero committed Mar 10, 2024
1 parent 4a52c43 commit e09c9e0
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 18 deletions.
2 changes: 2 additions & 0 deletions ccapp/boards/nucleo_f756zg.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
compatible = "ti,cc2500";
status = "okay";
spi-max-frequency = <500000>; // Max 10 MHz for cc2500, min 420k for driver
channel-frequency = <3>;
start-frequency = <2412>;
irq-gpios = <&gpiod 14 GPIO_ACTIVE_LOW>;
payload-crc;
/* From 0x07 to 0x2E */
Expand Down
24 changes: 12 additions & 12 deletions drivers/cc2500/cc2500.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@ struct cc2500_config {
const int array_len;
struct gpio_dt_spec irq;
bool gpio2_as_irq;
bool payload_crc;
};

struct cc2500_data {
int channel_frequency;
int start_frequency;
int modulation_format;
bool payload_crc;
#ifdef CONFIG_CC2500_TRIGGER
/** RX queue buffer. */
uint8_t rx_queue_buf[SPI_MSG_QUEUE_LEN * SPI_MAX_MSG_LEN];
Expand Down Expand Up @@ -434,13 +437,13 @@ static int cc2500_read(const struct device *dev, uint8_t *buffer, uint8_t data_l
int ret = 0;
uint8_t status = 0;
const struct cc2500_config *config = dev->config;
struct cc2500_data *data = dev->data;
cc2500_idle(dev);
k_msleep(1);
cc2500_flush_rx(dev);
cc2500_set_pkt_len(dev, data_len);
cc2500_set_rx(dev);
#ifdef CONFIG_CC2500_TRIGGER
struct cc2500_data *data = dev->data;
uint8_t buffer_full[SPI_MAX_MSG_LEN] = {0};

if (k_msgq_get(&data->rx_queue, buffer_full, K_MSEC(CONFIG_CC2500_READ_TIMEOUT)) < 0) {
Expand All @@ -452,7 +455,7 @@ static int cc2500_read(const struct device *dev, uint8_t *buffer, uint8_t data_l
while (!cc2500_has_data(dev)){
k_msleep(1);
}
if (config->payload_crc && !cc2500_is_crc_ok(dev)) {
if (data->payload_crc && !cc2500_is_crc_ok(dev)) {
LOG_WRN("Wrong CRC");
return -EIO;
}
Expand Down Expand Up @@ -591,6 +594,7 @@ static int cc2500_init(const struct device *dev)
//uint8_t pa_data[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
uint8_t pa_data[] = {0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6};
const struct cc2500_config *config = dev->config;
struct cc2500_data *data = dev->data;
uint8_t reg_value;
int ret;

Expand All @@ -611,7 +615,6 @@ static int cc2500_init(const struct device *dev)
return(-EIO);
}
#ifdef CONFIG_CC2500_TRIGGER
struct cc2500_data *data = dev->data;
uint8_t irq_mode;
LOG_INF("Trigger config");
data->dev = dev;
Expand Down Expand Up @@ -640,7 +643,7 @@ static int cc2500_init(const struct device *dev)

/* Setup GPIO 0 or GPIO 2 as RX FIFO */
irq_mode = 0x00;
if (config->payload_crc) {
if (data->payload_crc) {
/* IRQ on CRC OK */
irq_mode = 0x07;
}
Expand Down Expand Up @@ -676,14 +679,8 @@ static int cc2500_init(const struct device *dev)
cc2500_flush_tx(dev);
cc2500_idle(dev);

cc2500_write_register(dev, IOCFG2, 0x5C);
cc2500_write_register(dev, IOCFG0, 0x5B);
/* FIFO threshold */
//cc2500_write_register(dev, FIFOTHR, 0x7);
cc2500_cmd_register(dev, SFSTXON);

cc2500_rssi_process(dev);

return 0;
}

Expand All @@ -695,12 +692,15 @@ static int cc2500_init(const struct device *dev)
.array = DT_INST_PROP_OR(i, conf_array, {}), \
.array_len = DT_INST_PROP_LEN_OR(i, conf_array, 0), \
.gpio2_as_irq = DT_INST_PROP_OR(i, use_gpio_2_as_irq, false), \
.payload_crc = DT_INST_PROP_OR(i, payload_crc, true), \
IF_ENABLED(CONFIG_CC2500_TRIGGER, \
(.irq = GPIO_DT_SPEC_INST_GET(i, irq_gpios),)) \
}; \
\
static struct cc2500_data cc2500_##i = { \
.channel_frequency = DT_INST_PROP(i, channel_frequency), \
.start_frequency = DT_INST_PROP(i, start_frequency), \
.modulation_format = DT_INST_PROP(i, modulation_format), \
.payload_crc = DT_INST_PROP_OR(i, payload_crc, true) \
}; \
DEVICE_DT_INST_DEFINE(i, cc2500_init, NULL, &cc2500_##i, \
&cc2500_config_##i, POST_KERNEL, \
Expand Down
2 changes: 1 addition & 1 deletion dts/bindings/propy_radio/nordic,nrf24l01.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ properties:
type: int
required: true
description: |
Channel selection, from 0 to 126. 0 is 2400MHz, each channel is 1MHz wide and 126 is 2526MHz. Default is 16.
Channel selection, from 0 to 126. 0 is 2400MHz. Max available frequency is 2483.5MHz. Each channel is 200kHz wide by default, and 126 is 2526MHz. Default is 16.
default: 16

data-rate-2mbps:
Expand Down
34 changes: 29 additions & 5 deletions dts/bindings/propy_radio/ti,cc2500.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,42 @@ properties:
irq-gpios:
type: phandle-array
required: false
description: |
Chip parametric GPIO 0 or 2. Default is GPIO 0, use use-gpio-2-as-irq to select GPIO 2 instead.
Chip parametric GPIO 0 or 2. Default is GPIO 0, use use-gpio-2-as-irq to select GPIO 2 instead. Default as none.
use-gpio-2-as-irq:
type: boolean
required: false
description: |
Use GPIO 2 instead of GPIO 0 as IRQ input pin.
Use GPIO 2 instead of GPIO 0 as IRQ input pin. Default false.
payload-crc:
type: boolean
required: false
description: |
Use payload CRC. Default true.
start-frequency:
type: int
default: 2464
description: |
Base frequency, center of the lowest channel to be selected by channel-frequency, in MHz. Default is 2464 MHz.
channel-frequency:
type: int
description: |
Channel selection. Each channel is 200kHz wide by default, to be added to start-frequency. Default is 0.
default: 0

modulation-format:
type: int
description: |
Modulation format. Default is 2-FSK.
- 2-FSK
- GFSK
- OOK
- MSK
enum:
- "2-FSK"
- "GFSK"
- "OOK"
- "MSK"
default: 0

0 comments on commit e09c9e0

Please sign in to comment.