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);
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;
/* 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
* 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;
/* 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)
* 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
/****************************************************************************
- * lib/utils.c
+ * lib/utils.h
*
* Copyright 2014 Nathael Pajani <nathael.pajani@ed3l.fr>
*
/* Library routines */
/***************************************************************************** */
-#include <stddef.h>
#include <stdint.h>
-/*
+/****************************************************************************
* lib/utils.c
*
- * Library routines..
+ * Copyright 2014 Nathael Pajani <nathael.pajani@ed3l.fr>
*
- */
+ * 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 <http://www.gnu.org/licenses/>.
+ *
+ *************************************************************************** */
-#include <stddef.h>
#include <stdint.h>