From 07acdbd4c4c4f3bd1e022b6c6108a682c9ac2190 Mon Sep 17 00:00:00 2001 From: Nathael Pajani Date: Mon, 28 Jul 2014 10:51:23 +0200 Subject: [PATCH] Argh ! hidden, silent bug, as I always used port 0 for the pins. (Thank you cyprien for seeing this one :) Use the port number from the provided pio struct, not from our onw un-initialized one. And make sure both pio struct pointers are not NULL before using them .... --- drivers/cc1101.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/cc1101.c b/drivers/cc1101.c index 0550bbf..b0a228e 100644 --- a/drivers/cc1101.c +++ b/drivers/cc1101.c @@ -404,7 +404,12 @@ static uint8_t paTable[] = {0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; /* Configure pins, reset the CC1101, and put the CC1101 chip in idle state */ void cc1101_init(uint8_t ssp_num, struct pio* cs_pin, struct pio* miso_pin) { - struct lpc_gpio* gpio = LPC_GPIO_REGS(cc1101.cs_pin.port);; + struct lpc_gpio* gpio = NULL; + + if ((cs_pin == NULL) || (miso_pin == NULL)) { + return; + } + gpio = LPC_GPIO_REGS(cs_pin->port); cc1101.spi_num = ssp_num; /* Copy CS pin info and configure pin as GPIO output */ -- 2.43.0