Mostly cosmetic changes from Uros

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3575 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2011-05-07 19:22:15 +00:00
parent 65a6ec4693
commit 9a9ebcd417
9 changed files with 87 additions and 86 deletions

View File

@ -37,12 +37,12 @@
* \author Uros Platise
* \brief STM32 Flash - Program and Data Memory
*
* Provides standard flash access function, to be used also by the
* Provides standard flash access functions, to be used also by the
* drivers/mtd/progmem.c program memory flash mtd driver.
* The interface is to be defined in the include/nuttx/progmem.h
* The interface is defined in the include/nuttx/progmem.h
*
* Requirements:
* - During write/erase operatoins on FLASH, HSI must be ON.
* Requirements during write/erase operations on FLASH:
* - HSI must be ON.
* - Low Power Modes are not permitted during write/erase
*/

View File

@ -77,7 +77,7 @@
#include <nuttx/progmem.h>
#include <nuttx/i2c.h>
#include <nuttx/sensors/st_lis331dl.h>
#include <nuttx/sensors/lis331dl.h>
#include <stdio.h>
#include <stdlib.h>
@ -285,7 +285,7 @@ int sif_gpios_unlock(vsn_sif_state_t peripheral)
* Analog Outputs
****************************************************************************/
static volatile int test = 0, test_irq;
static volatile int test = 0, teirq;
static int sif_anout_isr(int irq, void *context)
@ -293,7 +293,7 @@ static int sif_anout_isr(int irq, void *context)
STM32_TIM_ACKINT(vsn_sif.tim8, 0);
test++;
test_irq = irq;
teirq = irq;
return OK;
}
@ -531,10 +531,12 @@ int sif_main(int argc, char *argv[])
}
}
while (status >= 0);
return 0;
}
else if (!strcmp(argv[1], "erase") && argc == 3 ) {
int page = atoi(argv[2]);
printf("Erase result: %d\n", up_progmem_erasepage(page) );
return 0;
}
else if (!strcmp(argv[1], "flash") && argc == 3 ) {
uint16_t page = atoi(argv[2]);
@ -542,27 +544,28 @@ int sif_main(int argc, char *argv[])
printf("Write result: %d (writing to address %xh)\n",
up_progmem_write( addr, "Test", 4 ), addr);
return 0;
}
else if (!strcmp(argv[1], "i2c") && argc == 3) {
int val = atoi(argv[2]);
I2C_SETFREQUENCY(vsn_sif.i2c1, 100000);
struct st_lis331dl_dev_s * lis = st_lis331dl_init(vsn_sif.i2c1, val);
struct lis331dl_dev_s * lis = lis331dl_init(vsn_sif.i2c1, val);
if (lis) {
const struct st_lis331dl_vector_s * a;
const struct lis331dl_vector_s * a;
int i;
uint32_t time_stamp = clock_systimer();
/* Set to 400 Hz : 3 = 133 Hz/axis */
st_lis331dl_setconversion(lis, false, true);
lis331dl_setconversion(lis, false, true);
/* Sample some values */
for (i=0; i<1000; ) {
if ( (a = st_lis331dl_getreadings(lis)) ) {
if ( (a = lis331dl_getreadings(lis)) ) {
i++;
printf("%d %d %d\n", a->x, a->y, a->z);
}
@ -574,7 +577,7 @@ int sif_main(int argc, char *argv[])
printf("Time diff = %d\n", clock_systimer() - time_stamp);
st_lis331dl_deinit(lis);
lis331dl_deinit(lis);
}
else printf("Exit point: errno=%d\n", errno);

View File

@ -39,6 +39,6 @@ SENSOR_CSRCS =
# These drivers depend on I2C support
ifeq ($(CONFIG_I2C),y)
SENSOR_CSRCS += st_lis331dl.c
SENSOR_CSRCS += lis331dl.c
endif

View File

@ -1,5 +1,5 @@
/****************************************************************************
* drivers/sensors/st_lis331dl.c
* drivers/sensors/lis331dl.c
*
* Copyright (C) 2011 Uros Platise. All rights reserved.
*
@ -47,7 +47,7 @@
#include <stdio.h>
#include <nuttx/kmalloc.h>
#include <nuttx/sensors/st_lis331dl.h>
#include <nuttx/sensors/lis331dl.h>
/************************************************************************************
* LIS331DL Internal Registers
@ -89,11 +89,11 @@
* Private Data Types
************************************************************************************/
struct st_lis331dl_dev_s {
struct lis331dl_dev_s {
struct i2c_dev_s * i2c;
uint8_t address;
struct st_lis331dl_vector_s a;
struct lis331dl_vector_s a;
uint8_t cr1;
uint8_t cr2;
uint8_t cr3;
@ -112,7 +112,7 @@ struct st_lis331dl_dev_s {
* \param length when >0 it denotes read access, when <0 it denotes write access of -length
* \return OK on success or errno is set.
**/
int st_lis331dl_access(struct st_lis331dl_dev_s * dev, uint8_t subaddr, uint8_t *buf, int length)
int lis331dl_access(struct lis331dl_dev_s * dev, uint8_t subaddr, uint8_t *buf, int length)
{
uint16_t flags = 0;
int retval;
@ -170,9 +170,9 @@ int st_lis331dl_access(struct st_lis331dl_dev_s * dev, uint8_t subaddr, uint8_t
}
int st_lis331dl_readregs(struct st_lis331dl_dev_s * dev)
int lis331dl_readregs(struct lis331dl_dev_s * dev)
{
if (st_lis331dl_access(dev, ST_LIS331DL_CTRL_REG1, &dev->cr1, 3) != 3) return ERROR;
if (lis331dl_access(dev, ST_LIS331DL_CTRL_REG1, &dev->cr1, 3) != 3) return ERROR;
return OK;
}
@ -181,24 +181,24 @@ int st_lis331dl_readregs(struct st_lis331dl_dev_s * dev)
* Public Functions
****************************************************************************/
struct st_lis331dl_dev_s * st_lis331dl_init(struct i2c_dev_s * i2c, uint16_t address)
struct lis331dl_dev_s * lis331dl_init(struct i2c_dev_s * i2c, uint16_t address)
{
struct st_lis331dl_dev_s * dev;
struct lis331dl_dev_s * dev;
uint8_t retval;
ASSERT(i2c);
ASSERT(address);
if ( (dev = kmalloc( sizeof(struct st_lis331dl_dev_s) )) == NULL )
if ( (dev = kmalloc( sizeof(struct lis331dl_dev_s) )) == NULL )
return NULL;
memset(dev, 0, sizeof(struct st_lis331dl_dev_s));
memset(dev, 0, sizeof(struct lis331dl_dev_s));
dev->i2c = i2c;
dev->address = address;
/* Probe device */
if (st_lis331dl_access(dev, ST_LIS331DL_WHOAMI, &retval, 1) > 0) {
if (lis331dl_access(dev, ST_LIS331DL_WHOAMI, &retval, 1) > 0) {
/* Check chip identification, in the future several more compatible parts
* may be added here.
@ -208,7 +208,7 @@ struct st_lis331dl_dev_s * st_lis331dl_init(struct i2c_dev_s * i2c, uint16_t add
/* Copy LIS331DL registers to our private structure and power-up device */
if (st_lis331dl_readregs(dev)==OK && st_lis331dl_powerup(dev)==OK) {
if (lis331dl_readregs(dev)==OK && lis331dl_powerup(dev)==OK) {
/* Normal exit point */
errno = 0;
@ -232,52 +232,52 @@ struct st_lis331dl_dev_s * st_lis331dl_init(struct i2c_dev_s * i2c, uint16_t add
}
int st_lis331dl_deinit(struct st_lis331dl_dev_s * dev)
int lis331dl_deinit(struct lis331dl_dev_s * dev)
{
ASSERT(dev);
st_lis331dl_powerdown(dev);
lis331dl_powerdown(dev);
kfree(dev);
return OK;
}
int st_lis331dl_powerup(struct st_lis331dl_dev_s * dev)
int lis331dl_powerup(struct lis331dl_dev_s * dev)
{
dev->cr1 = ST_LIS331DL_CR1_PD |
ST_LIS331DL_CR1_ZEN | ST_LIS331DL_CR1_YEN | ST_LIS331DL_CR1_XEN;
dev->cr2 = 0;
dev->cr3 = 0;
if (st_lis331dl_access(dev, ST_LIS331DL_CTRL_REG1, &dev->cr1, -3) == 3) return OK;
if (lis331dl_access(dev, ST_LIS331DL_CTRL_REG1, &dev->cr1, -3) == 3) return OK;
return ERROR;
}
int st_lis331dl_powerdown(struct st_lis331dl_dev_s * dev)
int lis331dl_powerdown(struct lis331dl_dev_s * dev)
{
dev->cr1 = ST_LIS331DL_CR1_ZEN | ST_LIS331DL_CR1_YEN | ST_LIS331DL_CR1_XEN;
dev->cr2 = 0;
dev->cr3 = 0;
if (st_lis331dl_access(dev, ST_LIS331DL_CTRL_REG1, &dev->cr1, -3) == 3) return OK;
if (lis331dl_access(dev, ST_LIS331DL_CTRL_REG1, &dev->cr1, -3) == 3) return OK;
return ERROR;
}
int st_lis331dl_setconversion(struct st_lis331dl_dev_s * dev, bool full, bool fast)
int lis331dl_setconversion(struct lis331dl_dev_s * dev, bool full, bool fast)
{
dev->cr1 = ST_LIS331DL_CR1_PD |
(full ? ST_LIS331DL_CR1_FS : 0) | (fast ? ST_LIS331DL_CR1_DR : 0) |
ST_LIS331DL_CR1_ZEN | ST_LIS331DL_CR1_YEN | ST_LIS331DL_CR1_XEN;
if (st_lis331dl_access(dev, ST_LIS331DL_CTRL_REG1, &dev->cr1, -1) == 1) return OK;
if (lis331dl_access(dev, ST_LIS331DL_CTRL_REG1, &dev->cr1, -1) == 1) return OK;
return ERROR;
}
int st_lis331dl_getprecision(struct st_lis331dl_dev_s * dev)
int lis331dl_getprecision(struct lis331dl_dev_s * dev)
{
if (dev->cr1 & ST_LIS331DL_CR1_FS)
return 9200/127; /* typ. 9.2g full scale */
@ -285,7 +285,7 @@ int st_lis331dl_getprecision(struct st_lis331dl_dev_s * dev)
}
int st_lis331dl_getsamplerate(struct st_lis331dl_dev_s * dev)
int lis331dl_getsamplerate(struct lis331dl_dev_s * dev)
{
if (dev->cr1 & ST_LIS331DL_CR1_DR)
return 400;
@ -293,13 +293,13 @@ int st_lis331dl_getsamplerate(struct st_lis331dl_dev_s * dev)
}
const struct st_lis331dl_vector_s * st_lis331dl_getreadings(struct st_lis331dl_dev_s * dev)
const struct lis331dl_vector_s * lis331dl_getreadings(struct lis331dl_dev_s * dev)
{
uint8_t retval[7];
ASSERT(dev);
if (st_lis331dl_access(dev, ST_LIS331DL_STATUS_REG, retval, 7) == 7) {
if (lis331dl_access(dev, ST_LIS331DL_STATUS_REG, retval, 7) == 7) {
/* If result is not yet ready, return NULL */

View File

@ -37,5 +37,5 @@ WIRELESS_ASRCS =
WIRELESS_CSRCS =
ifeq ($(CONFIG_WIRELESS),y)
WIRELESS_CSRCS += chipcon_cc1101.c
WIRELESS_CSRCS += cc1101.c
endif

View File

@ -1,5 +1,5 @@
/****************************************************************************
* drivers/wireless/chipcon_cc1101.c
* drivers/wireless/cc1101.c
*
* Copyright (C) 2011 Uros Platise. All rights reserved.
*
@ -49,7 +49,7 @@
#include <stdio.h>
#include <nuttx/kmalloc.h>
#include <nuttx/wireless/chipcon_cc1101.h>
#include <nuttx/wireless/cc1101.h>
/************************************************************************************
@ -351,7 +351,7 @@
* Private Data Types
************************************************************************************/
struct chipcon_c1101_rfsettings_s {
struct c1101_rfsettings_s {
uint8_t FSCTRL1; /* Frequency synthesizer control. */
uint8_t IOCFG0; /* GDO0 output pin configuration */
uint8_t FSCTRL0; /* Frequency synthesizer control. */
@ -389,9 +389,9 @@ struct chipcon_c1101_rfsettings_s {
uint8_t PKTLEN; /* Packet length. */
};
struct chipcon_cc1101_dev_s {
struct cc1101_dev_s {
struct spi_dev_s * spi;
struct chipcon_c1101_rfsettings_s * settings;
struct c1101_rfsettings_s * settings;
};
@ -408,7 +408,7 @@ struct chipcon_cc1101_dev_s {
* \param length when >0 it denotes read access, when <0 it denotes write access of -length
* \return OK on success or errno is set.
**/
int chipcon_cc1101_access(struct chipcon_cc1101_dev_s * dev, uint8_t subaddr, uint8_t *buf, int length)
int cc1101_access(struct cc1101_dev_s * dev, uint8_t subaddr, uint8_t *buf, int length)
{
return 0;
}
@ -427,7 +427,7 @@ int chipcon_cc1101_access(struct chipcon_cc1101_dev_s * dev, uint8_t subaddr, ui
* its callback, and it is up to peripheral to find, whether the cause
* of EXTI ISR was itself.
**/
void chipcon_cc1101_eventcb(void)
void cc1101_eventcb(void)
{
}
@ -436,7 +436,7 @@ void chipcon_cc1101_eventcb(void)
* Public Functions
****************************************************************************/
struct chipcon_cc1101_dev_s * chipcon_cc1101_init(struct spi_dev_s * spi)
struct cc1101_dev_s * cc1101_init(struct spi_dev_s * spi)
{
/* Powerup or wake-up, if it was previously set into some power-down state */
@ -452,7 +452,7 @@ struct chipcon_cc1101_dev_s * chipcon_cc1101_init(struct spi_dev_s * spi)
}
int chipcon_cc1101_deinit(struct chipcon_cc1101_dev_s * dev)
int cc1101_deinit(struct cc1101_dev_s * dev)
{
/* Power down chip, possibly in some inactive state */
@ -460,55 +460,55 @@ int chipcon_cc1101_deinit(struct chipcon_cc1101_dev_s * dev)
}
int chipcon_cc1101_setgdo(struct chipcon_cc1101_dev_s * dev, uint8_t pin, uint8_t function)
int cc1101_setgdo(struct cc1101_dev_s * dev, uint8_t pin, uint8_t function)
{
return 0;
}
int chipcon_cc1101_setrf(struct chipcon_cc1101_dev_s * dev, uint32_t frequency, int modulation)
int cc1101_setrf(struct cc1101_dev_s * dev, uint32_t frequency, int modulation)
{
return 0;
}
int chipcon_cc1101_read(struct chipcon_cc1101_dev_s * dev, uint8_t * data, size_t size)
int cc1101_read(struct cc1101_dev_s * dev, uint8_t * data, size_t size)
{
return 0;
}
int chipcon_cc1101_write(struct chipcon_cc1101_dev_s * dev, const uint8_t * data, size_t size)
int cc1101_write(struct cc1101_dev_s * dev, const uint8_t * data, size_t size)
{
return 0;
}
int chipcon_cc1101_listen(struct chipcon_cc1101_dev_s * dev)
int cc1101_listen(struct cc1101_dev_s * dev)
{
return 0;
}
int chipcon_cc1101_send(struct chipcon_cc1101_dev_s * dev)
int cc1101_send(struct cc1101_dev_s * dev)
{
return 0;
}
int chipcon_cc1101_idle(struct chipcon_cc1101_dev_s * dev)
int cc1101_idle(struct cc1101_dev_s * dev)
{
return 0;
}
int chipcon_cc1101_powerup(struct chipcon_cc1101_dev_s * dev)
int cc1101_powerup(struct cc1101_dev_s * dev)
{
return 0;
}
int chipcon_cc1101_powerdown(struct chipcon_cc1101_dev_s * dev)
int cc1101_powerdown(struct cc1101_dev_s * dev)
{
return 0;
}

View File

@ -41,6 +41,7 @@
****************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include <stdint.h>
#include <stdbool.h>

View File

@ -1,5 +1,5 @@
/****************************************************************************
* include/nuttx/sensors/st_lis331dl.h
* include/nuttx/sensors/lis331dl.h
*
* Copyright (C) 2011 Uros Platise. All rights reserved.
*
@ -39,8 +39,8 @@
* \brief ST LIS331DL I2C Device Driver
**/
#ifndef __INCLUDE_NUTTX_SENSORS_ST_LIS331DL_H
#define __INCLUDE_NUTTX_SENSORS_ST_LIS331DL_H
#ifndef __INCLUDE_NUTTX_SENSORS_LIS331DL_H
#define __INCLUDE_NUTTX_SENSORS_LIS331DL_H
#include <nuttx/i2c.h>
#include <stdbool.h>
@ -64,9 +64,9 @@ extern "C" {
* Public Data Types
************************************************************************************/
struct st_lis331dl_dev_s;
struct lis331dl_dev_s;
struct st_lis331dl_vector_s {
struct lis331dl_vector_s {
int8_t x, y, z;
};
@ -86,21 +86,21 @@ struct st_lis331dl_vector_s {
* - EFAULT: When there is no device at given address.
* - EBUSY: When device is already addressed by other device driver (not yet supported by low-level driver)
**/
EXTERN struct st_lis331dl_dev_s * st_lis331dl_init(struct i2c_dev_s * i2c, uint16_t address);
EXTERN struct lis331dl_dev_s * lis331dl_init(struct i2c_dev_s * i2c, uint16_t address);
/** Deinitialize ST LIS331DL Chip
*
* \param dev Device to LIS331DL device structure, as returned by the st_lis331dl_init()
* \param dev Device to LIS331DL device structure, as returned by the lis331dl_init()
* \return OK On success
*
**/
EXTERN int st_lis331dl_deinit(struct st_lis331dl_dev_s * dev);
EXTERN int lis331dl_deinit(struct lis331dl_dev_s * dev);
/** Power up device, start conversion */
EXTERN int st_lis331dl_powerup(struct st_lis331dl_dev_s * dev);
EXTERN int lis331dl_powerup(struct lis331dl_dev_s * dev);
/** Power down device, stop conversion */
EXTERN int st_lis331dl_powerdown(struct st_lis331dl_dev_s * dev);
EXTERN int lis331dl_powerdown(struct lis331dl_dev_s * dev);
/** Configure conversion
*
@ -109,19 +109,19 @@ EXTERN int st_lis331dl_powerdown(struct st_lis331dl_dev_s * dev);
* \param fast When set, conversion operates at 400 Hz, otherwise at 100 Hz
* \return OK on success or errno is set
**/
EXTERN int st_lis331dl_setconversion(struct st_lis331dl_dev_s * dev, bool full, bool fast);
EXTERN int lis331dl_setconversion(struct lis331dl_dev_s * dev, bool full, bool fast);
/** Get precision
*
* \return Precision of 1 LSB in terms of unit [mg]
**/
EXTERN int st_lis331dl_getprecision(struct st_lis331dl_dev_s * dev);
EXTERN int lis331dl_getprecision(struct lis331dl_dev_s * dev);
/** Get sample rate
*
* \return Sample rate in unit of [Hz]
**/
EXTERN int st_lis331dl_getsamplerate(struct st_lis331dl_dev_s * dev);
EXTERN int lis331dl_getsamplerate(struct lis331dl_dev_s * dev);
/** Get readings, updates internal data structure
*
@ -130,8 +130,7 @@ EXTERN int st_lis331dl_getsamplerate(struct st_lis331dl_dev_s * dev);
* If data is not yet ready to be read from the LIS331 then errno is set to EAGAIN otherwise
* errno is set by I2C_TRANSFER().
*/
EXTERN const struct st_lis331dl_vector_s * st_lis331dl_getreadings(struct st_lis331dl_dev_s * dev);
EXTERN const struct lis331dl_vector_s * lis331dl_getreadings(struct lis331dl_dev_s * dev);
#undef EXTERN
@ -140,5 +139,4 @@ EXTERN const struct st_lis331dl_vector_s * st_lis331dl_getreadings(struct st_lis
#endif
#endif /* __ASSEMBLY__ */
#endif /* __INCLUDE_NUTTX_SENSORS_ST_LIS331DL_H */
#endif /* __INCLUDE_NUTTX_SENSORS_LIS331DL_H */

View File

@ -1,5 +1,5 @@
/****************************************************************************
* include/nuttx/wireless/chipcon_cc1101.h
* include/nuttx/wireless/cc1101.h
*
* Copyright (C) 2011 Uros Platise. All rights reserved.
*
@ -39,8 +39,8 @@
* \brief Chipcon CC1101 Device Driver
**/
#ifndef __INCLUDE_NUTTX_WIRELESS_CHIPCON_CC1101_H
#define __INCLUDE_NUTTX_WIRELESS_CHIPCON_CC1101_H
#ifndef __INCLUDE_NUTTX_WIRELESS_CC1101_H
#define __INCLUDE_NUTTX_WIRELESS_CC1101_H
#include <nuttx/config.h>
#include <nuttx/spi.h>
@ -67,7 +67,7 @@ extern "C" {
* Public Data Types
************************************************************************************/
struct chipcon_cc1101_dev_s;
struct cc1101_dev_s;
/************************************************************************************
@ -84,24 +84,24 @@ struct chipcon_cc1101_dev_s;
* - EFAULT: When there is no device
* - EBUSY: When device is already addressed by other device driver (not yet supported by low-level driver)
**/
EXTERN struct chipcon_cc1101_dev_s * chipcon_cc1101_init(struct spi_dev_s * spi);
EXTERN struct cc1101_dev_s * cc1101_init(struct spi_dev_s * spi);
/** Deinitialize Chipcon CC1101 Chip
*
* \param dev Device to CC1101 device structure, as returned by the chipcon_cc1101_init()
* \param dev Device to CC1101 device structure, as returned by the cc1101_init()
* \return OK On success
*
**/
EXTERN int chipcon_cc1101_deinit(struct chipcon_cc1101_dev_s * dev);
EXTERN int cc1101_deinit(struct cc1101_dev_s * dev);
/** Power up device, start conversion */
EXTERN int chipcon_cc1101_powerup(struct chipcon_cc1101_dev_s * dev);
EXTERN int cc1101_powerup(struct cc1101_dev_s * dev);
/** Power down device, stop conversion */
EXTERN int chipcon_cc1101_powerdown(struct chipcon_cc1101_dev_s * dev);
EXTERN int cc1101_powerdown(struct cc1101_dev_s * dev);
/** Set Multi Purpose Output Function */
EXTERN int chipcon_cc1101_setgdo(struct chipcon_cc1101_dev_s * dev, uint8_t pin, uint8_t function);
EXTERN int cc1101_setgdo(struct cc1101_dev_s * dev, uint8_t pin, uint8_t function);
#undef EXTERN
@ -109,5 +109,4 @@ EXTERN int chipcon_cc1101_setgdo(struct chipcon_cc1101_dev_s * dev, uint8_t pin,
}
#endif
#endif /* __ASSEMBLY__ */
#endif /* __INCLUDE_NUTTX_WIRELESS_CHIPCON_CC1101_H */
#endif /* __INCLUDE_NUTTX_WIRELESS_CC1101_H */