From 56b98a5e01430c0a4b0c91b9db16e172fd604de7 Mon Sep 17 00:00:00 2001 From: Nathael Pajani Date: Sat, 6 Dec 2014 02:51:20 +0100 Subject: [PATCH] Separate internal LPC drivers and external ones Place the external ones in extdrv Split i2c and eeprom in two different headers --- {drivers => extdrv}/cc1101.c | 4 +- {drivers => extdrv}/eeprom.c | 3 +- {drivers => extdrv}/status_led.c | 4 +- {drivers => extdrv}/tmp101_temp_sensor.c | 4 +- include/drivers/i2c.h | 64 ------------- include/{drivers => extdrv}/cc1101.h | 6 +- include/extdrv/eeprom.h | 96 +++++++++++++++++++ include/{drivers => extdrv}/status_led.h | 8 +- .../{drivers => extdrv}/tmp101_temp_sensor.h | 8 +- 9 files changed, 115 insertions(+), 82 deletions(-) rename {drivers => extdrv}/cc1101.c (99%) rename {drivers => extdrv}/eeprom.c (99%) rename {drivers => extdrv}/status_led.c (98%) rename {drivers => extdrv}/tmp101_temp_sensor.c (99%) rename include/{drivers => extdrv}/cc1101.h (99%) create mode 100644 include/extdrv/eeprom.h rename include/{drivers => extdrv}/status_led.h (91%) rename include/{drivers => extdrv}/tmp101_temp_sensor.h (97%) diff --git a/drivers/cc1101.c b/extdrv/cc1101.c similarity index 99% rename from drivers/cc1101.c rename to extdrv/cc1101.c index c49b7e4..b788648 100644 --- a/drivers/cc1101.c +++ b/extdrv/cc1101.c @@ -1,5 +1,5 @@ /**************************************************************************** - * drivers/cc1101.c + * extdrv/cc1101.c * * Copyright 2014 Nathael Pajani * @@ -25,7 +25,7 @@ #include "core/pio.h" #include "lib/string.h" #include "drivers/ssp.h" -#include "drivers/cc1101.h" +#include "extdrv/cc1101.h" /***************************************************************************** */ diff --git a/drivers/eeprom.c b/extdrv/eeprom.c similarity index 99% rename from drivers/eeprom.c rename to extdrv/eeprom.c index 8a0f8c1..2f35fec 100644 --- a/drivers/eeprom.c +++ b/extdrv/eeprom.c @@ -1,5 +1,5 @@ /**************************************************************************** - * drivers/eeprom.c + * extdrv/eeprom.c * * * Copyright 2012 Nathael Pajani @@ -28,6 +28,7 @@ #include "core/pio.h" #include "lib/string.h" #include "drivers/i2c.h" +#include "extdrv/eeprom.h" /***************************************************************************** */ diff --git a/drivers/status_led.c b/extdrv/status_led.c similarity index 98% rename from drivers/status_led.c rename to extdrv/status_led.c index e499524..8ae531a 100644 --- a/drivers/status_led.c +++ b/extdrv/status_led.c @@ -1,5 +1,5 @@ /**************************************************************************** - * drivers/status_led.c + * extdrv/status_led.c * * Copyright 2012 Nathael Pajani * @@ -27,7 +27,7 @@ #include "core/lpc_regs_12xx.h" #include "core/system.h" #include "core/pio.h" -#include "drivers/status_led.h" +#include "extdrv/status_led.h" /***************************************************************************** */ diff --git a/drivers/tmp101_temp_sensor.c b/extdrv/tmp101_temp_sensor.c similarity index 99% rename from drivers/tmp101_temp_sensor.c rename to extdrv/tmp101_temp_sensor.c index e358c75..3571c18 100644 --- a/drivers/tmp101_temp_sensor.c +++ b/extdrv/tmp101_temp_sensor.c @@ -1,5 +1,5 @@ /**************************************************************************** - * drivers/temp.c + * extdrv/temp.c * * * Copyright 2012 Nathael Pajani @@ -26,7 +26,7 @@ #include "core/lpc_core_cm0.h" #include "core/system.h" #include "drivers/i2c.h" -#include "drivers/tmp101_temp_sensor.h" +#include "extdrv/tmp101_temp_sensor.h" /***************************************************************************** */ diff --git a/include/drivers/i2c.h b/include/drivers/i2c.h index 1782298..de21457 100644 --- a/include/drivers/i2c.h +++ b/include/drivers/i2c.h @@ -74,70 +74,6 @@ enum i2c_state_machine_states { }; -/***************************************************************************** */ -/* Module identification support for DTPlug and DomoTab */ -/***************************************************************************** */ - -/* Module capabilities */ -#define UEXT_MOD_HAS_NONE 0 -#define UEXT_MOD_HAS_UART (1 << 0) -#define UEXT_MOD_HAS_I2C (1 << 1) -#define UEXT_MOD_HAS_SPI (1 << 2) - -struct module_desc { - uint16_t serial_number; - uint8_t version; - uint8_t header_size; - uint8_t capabilities; /* Bit mask of UEXT_MOD_HAS_* */ - uint8_t name_offset; - uint8_t name_size; - uint8_t image_offset; - uint16_t image_size; -} __attribute__ ((packed)); - -enum i2c_eeprom_type { - EEPROM_TYPE_NONE = 0, - EEPROM_TYPE_SMALL, - EEPROM_TYPE_BIG, -}; - - - -/***************************************************************************** */ -/* Read and Write for system eeprom */ -/***************************************************************************** */ -/* EEPROM Read - * Performs a non-blocking read on the eeprom. - * address : data offset in eeprom. - * RETURN VALUE - * Upon successfull completion, returns the number of bytes read. On error, returns a negative - * integer equivalent to errors from glibc. - * -EFAULT : address above eeprom size - * -EBADFD : Device not initialized - * -EBUSY : Device or ressource Busy or Arbitration lost - * -EAGAIN : Device already in use - * -EINVAL : Invalid argument (buf) - * -EREMOTEIO : Device did not acknowledge - * -EIO : Bad one: Illegal start or stop, or illegal state in i2c state machine - */ -int eeprom_read(uint32_t offset, void *buf, size_t count); - -/* EEPROM Write - * Performs a non-blocking write on the eeprom. - * address : data offset in eeprom. - * RETURN VALUE - * Upon successfull completion, returns the number of bytes written. On error, returns a negative - * integer equivalent to errors from glibc. - * -EFAULT : address above eeprom size - * -EBADFD : Device not initialized - * -EBUSY : Device or ressource Busy or Arbitration lost - * -EAGAIN : Device already in use - * -EINVAL : Invalid argument (buf) - * -EREMOTEIO : Device did not acknowledge - * -EIO : Bad one: Illegal start or stop, or illegal state in i2c state machine - */ -int eeprom_write(uint32_t offset, const void *buf, size_t count); - /***************************************************************************** */ diff --git a/include/drivers/cc1101.h b/include/extdrv/cc1101.h similarity index 99% rename from include/drivers/cc1101.h rename to include/extdrv/cc1101.h index c9c4c11..2f7b4e7 100644 --- a/include/drivers/cc1101.h +++ b/include/extdrv/cc1101.h @@ -32,8 +32,8 @@ * http://focus.ti.com/lit/ds/swrs061f/swrs061f.pdf */ -#ifndef DRIVERS_CC1101_H -#define DRIVERS_CC1101_H +#ifndef EXTDRV_CC1101_H +#define EXTDRV_CC1101_H #include "lib/stddef.h" @@ -266,4 +266,4 @@ void cc1101_init(uint8_t ssp_num, struct pio* cs_pin, struct pio* miso_pin); void cc1101_config(void); -#endif /* DRIVERS_CC1101_H */ +#endif /* EXTDRV_CC1101_H */ diff --git a/include/extdrv/eeprom.h b/include/extdrv/eeprom.h new file mode 100644 index 0000000..2034b7c --- /dev/null +++ b/include/extdrv/eeprom.h @@ -0,0 +1,96 @@ +/**************************************************************************** + * extdrv/eeprom.h + * + * + * Copyright 2012 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 . + * + *************************************************************************** */ + +#ifndef EXTDRV_EEPROM_H +#define EXTDRV_EEPROM_H + +#include + + +/***************************************************************************** */ +/* Module identification support for DTPlug and DomoTab */ +/***************************************************************************** */ + +/* Module capabilities */ +#define UEXT_MOD_HAS_NONE 0 +#define UEXT_MOD_HAS_UART (1 << 0) +#define UEXT_MOD_HAS_I2C (1 << 1) +#define UEXT_MOD_HAS_SPI (1 << 2) + +struct module_desc { + uint16_t serial_number; + uint8_t version; + uint8_t header_size; + uint8_t capabilities; /* Bit mask of UEXT_MOD_HAS_* */ + uint8_t name_offset; + uint8_t name_size; + uint8_t image_offset; + uint16_t image_size; +} __attribute__ ((packed)); + +enum i2c_eeprom_type { + EEPROM_TYPE_NONE = 0, + EEPROM_TYPE_SMALL, + EEPROM_TYPE_BIG, +}; + + + +/***************************************************************************** */ +/* Read and Write for system eeprom */ +/***************************************************************************** */ +/* EEPROM Read + * Performs a non-blocking read on the eeprom. + * address : data offset in eeprom. + * RETURN VALUE + * Upon successfull completion, returns the number of bytes read. On error, returns a negative + * integer equivalent to errors from glibc. + * -EFAULT : address above eeprom size + * -EBADFD : Device not initialized + * -EBUSY : Device or ressource Busy or Arbitration lost + * -EAGAIN : Device already in use + * -EINVAL : Invalid argument (buf) + * -EREMOTEIO : Device did not acknowledge + * -EIO : Bad one: Illegal start or stop, or illegal state in i2c state machine + */ +int eeprom_read(uint32_t offset, void *buf, size_t count); + +/* EEPROM Write + * Performs a non-blocking write on the eeprom. + * address : data offset in eeprom. + * RETURN VALUE + * Upon successfull completion, returns the number of bytes written. On error, returns a negative + * integer equivalent to errors from glibc. + * -EFAULT : address above eeprom size + * -EBADFD : Device not initialized + * -EBUSY : Device or ressource Busy or Arbitration lost + * -EAGAIN : Device already in use + * -EINVAL : Invalid argument (buf) + * -EREMOTEIO : Device did not acknowledge + * -EIO : Bad one: Illegal start or stop, or illegal state in i2c state machine + */ +int eeprom_write(uint32_t offset, const void *buf, size_t count); + + + + +#endif /* EXTDRV_EEPROM_H */ diff --git a/include/drivers/status_led.h b/include/extdrv/status_led.h similarity index 91% rename from include/drivers/status_led.h rename to include/extdrv/status_led.h index 50ecc96..02f2c00 100644 --- a/include/drivers/status_led.h +++ b/include/extdrv/status_led.h @@ -1,5 +1,5 @@ /**************************************************************************** - * drivers/status_led.h + * extdrv/status_led.h * * Copyright 2012 Nathael Pajani * @@ -18,8 +18,8 @@ * *************************************************************************** */ -#ifndef DRIVERS_STATUS_LED_H -#define DRIVERS_STATUS_LED_H +#ifndef EXTDRV_STATUS_LED_H +#define EXTDRV_STATUS_LED_H #include @@ -49,4 +49,4 @@ enum led_status { }; -#endif /* DRIVERS_STATUS_LED_H */ +#endif /* EXTDRV_STATUS_LED_H */ diff --git a/include/drivers/tmp101_temp_sensor.h b/include/extdrv/tmp101_temp_sensor.h similarity index 97% rename from include/drivers/tmp101_temp_sensor.h rename to include/extdrv/tmp101_temp_sensor.h index a3f4369..e84f4e3 100644 --- a/include/drivers/tmp101_temp_sensor.h +++ b/include/extdrv/tmp101_temp_sensor.h @@ -1,5 +1,5 @@ /**************************************************************************** - * drivers/temp.h + * extdrv/temp.h * * * Copyright 2012 Nathael Pajani @@ -20,8 +20,8 @@ * *************************************************************************** */ -#ifndef DRIVERS_TEMP_H -#define DRIVERS_TEMP_H +#ifndef EXTDRV_TEMP_H +#define EXTDRV_TEMP_H #include @@ -99,5 +99,5 @@ int tmp101_sensor_config(uint32_t resolution); int tmp101_sensor_start_conversion(void); -#endif /* DRIVERS_TEMP_H */ +#endif /* EXTDRV_TEMP_H */ -- 2.43.0