From 69730bb131e133983dd9986d4733fe536b2086ea Mon Sep 17 00:00:00 2001 From: Nathael Pajani Date: Thu, 24 Apr 2014 18:30:54 +0200 Subject: [PATCH] Comments improved or corrected. --- core/system.c | 4 ++-- drivers/cc1101.c | 3 +-- drivers/ssp.c | 7 ++++++- include/drivers/cc1101.h | 2 +- include/drivers/ssp.h | 2 +- include/lib/utils.h | 3 +-- lib/utils.c | 20 ++++++++++++++++---- 7 files changed, 28 insertions(+), 13 deletions(-) diff --git a/core/system.c b/core/system.c index f0ab8ba..5f28188 100644 --- a/core/system.c +++ b/core/system.c @@ -199,10 +199,10 @@ void clock_config(uint32_t freq_sel) switch (freq_sel) { case 3: /* FREQ_SEL_36MHz */ case 2: /* FREQ_SEL_24MHz */ - N = 2; + N = 2; /* P = 4 */ break; default: /* 48MHz to 60 MHz */ - N = 1; + N = 1; /* P = 2 */ break; } lpc_private.main_clock = (((freq_sel >> 3) & 0xFF) * 12 * 1000 * 1000); diff --git a/drivers/cc1101.c b/drivers/cc1101.c index b626581..0550bbf 100644 --- a/drivers/cc1101.c +++ b/drivers/cc1101.c @@ -64,8 +64,7 @@ uint8_t cc1101_spi_transfer(uint8_t addr, uint8_t* out, uint8_t* in, uint8_t siz if (size != 0) { spi_transfer_multiple_frames(cc1101.spi_num, out, in, size, 8); } - - /* Wait for 20ns before pulling CS back high ... 20ns is one nop() at 50MHz */ + /* Release Chip select */ gpio->set = (1 << cc1101.cs_pin.pin); return status; diff --git a/drivers/ssp.c b/drivers/ssp.c index 4953a6b..98f7c83 100644 --- a/drivers/ssp.c +++ b/drivers/ssp.c @@ -207,11 +207,16 @@ static int spi_transfer_bytes(struct lpc_ssp* ssp, uint8_t* data_out, uint8_t* d /* Multiple words (4 to 16 bits) transfer function on the SPI bus. * The SSP fifo is used to leave as little time between frames as possible. * Parameters : + * ssp_num : ssp device number. The SSP device number is not checked, thus a value above + * the number of SSP devices present on the micro-controller may break your + * programm. Double check the value of the ssp_num parameter. The check is made + * on the call to ssp_master_on() or ssp_slave_on(). * size is the number of frames, each one having the configured data width (4 to 16 bits). * data_out : data to be sent. Data will be read in the lower bits of the 16 bits values * pointed by "data_out" for each frame. If NULL, then the content of data_in * will be used. * data_in : buffer for read data. If NULL, read data will be discarded. + * Returns the number of data words transfered or negative value on error. * As the SPI bus is full duplex, data can flow in both directions, but the clock is * always provided by the master. The SPI clock cannont be activated without sending * data, which means we must send data to the device when we want to read data from @@ -323,7 +328,7 @@ static void ssp_set_pin_func(uint32_t ssp_num) * handling highly depends on the device on the other end of the wires. Use a GPIO * to activate the device's chip select (usually active low) */ -int ssp_master_on(uint8_t ssp_num, uint8_t frame_type, uint8_t data_width, uint32_t rate ) +int ssp_master_on(uint8_t ssp_num, uint8_t frame_type, uint8_t data_width, uint32_t rate) { struct ssp_device* ssp = NULL; struct lpc_ssp* ssp_regs = NULL; diff --git a/include/drivers/cc1101.h b/include/drivers/cc1101.h index 8b869f1..069552e 100644 --- a/include/drivers/cc1101.h +++ b/include/drivers/cc1101.h @@ -202,7 +202,7 @@ int cc1101_rx_fifo_state(void); /* Tx fifo state : * Return 0 when fifo is empty, or number of remaining bytes when non empty and no - * overflow occured. + * underflow occured. * Return a negative value on error: * when an underflow occured, return value is -1 * on other errors return value is (-1) * (global status byte) diff --git a/include/drivers/ssp.h b/include/drivers/ssp.h index d5382e2..c3659c3 100644 --- a/include/drivers/ssp.h +++ b/include/drivers/ssp.h @@ -73,7 +73,7 @@ uint16_t spi_transfer_single_frame(uint8_t ssp_num, uint16_t data); * pointed by "data_out" for each frame. If NULL, then the content of data_in will be used. * data_in : buffer for read data. If NULL, read data will be discarded. - * Returns the number of data words transfered. + * Returns the number of data words transfered or negative value on error. * As the SPI bus is full duplex, data can flow in both directions, but the clock is * always provided by the master. The SPI clock cannont be activated without sending * data, which means we must send data to the device when we want to read data from diff --git a/include/lib/utils.h b/include/lib/utils.h index 9a0a867..b477321 100644 --- a/include/lib/utils.h +++ b/include/lib/utils.h @@ -1,5 +1,5 @@ /**************************************************************************** - * lib/utils.c + * lib/utils.h * * Copyright 2014 Nathael Pajani * @@ -25,7 +25,6 @@ /* Library routines */ /***************************************************************************** */ -#include #include diff --git a/lib/utils.c b/lib/utils.c index a207d08..cc4186d 100644 --- a/lib/utils.c +++ b/lib/utils.c @@ -1,11 +1,23 @@ -/* +/**************************************************************************** * lib/utils.c * - * Library routines.. + * Copyright 2014 Nathael Pajani * - */ + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program. If not, see . + * + *************************************************************************** */ -#include #include -- 2.43.0