From 7de78a8253ec9ea49e37183218986ea81e45a653 Mon Sep 17 00:00:00 2001 From: Jon Medhurst Date: Mon, 24 Apr 2017 16:11:21 +0100 Subject: [PATCH 1/5] i2c: i2c_sbcon: Driver for ARM's SBCon 2-wire serial interface SBCon is a simple device which allows directly setting and getting the hardware state of two-bit serial interfaces like I2C. Therefore to be useable we need to drive the lines with the appropriate protocol under software control. Change-Id: If9000bb75f7b0ad7bbb256b1cb38cc70fa6ca8ea Signed-off-by: Jon Medhurst --- drivers/i2c/Kconfig | 2 + drivers/i2c/Kconfig.sbcon | 51 ++++++++++++++ drivers/i2c/Makefile | 1 + drivers/i2c/i2c_sbcon.c | 140 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 194 insertions(+) create mode 100644 drivers/i2c/Kconfig.sbcon create mode 100644 drivers/i2c/i2c_sbcon.c diff --git a/drivers/i2c/Kconfig b/drivers/i2c/Kconfig index f8f869395aabd..afd85b06c0588 100644 --- a/drivers/i2c/Kconfig +++ b/drivers/i2c/Kconfig @@ -111,6 +111,8 @@ config I2C_BITBANG help Enable library used for software driven (bit banging) I2C support +source "drivers/i2c/Kconfig.sbcon" + source "drivers/i2c/Kconfig.gpio" config I2C_INIT_PRIORITY diff --git a/drivers/i2c/Kconfig.sbcon b/drivers/i2c/Kconfig.sbcon new file mode 100644 index 0000000000000..10241711604f2 --- /dev/null +++ b/drivers/i2c/Kconfig.sbcon @@ -0,0 +1,51 @@ +# +# Copyright (c) 2016 Linaro Ltd. +# +# SPDX-License-Identifier: Apache-2.0 +# + +menuconfig I2C_SBCON + bool "I2C driver for ARM's SBCon two-wire serial bus interface" + depends on I2C + select I2C_BITBANG + default n + +if I2C_SBCON + +config I2C_SBCON_0 + bool "Enable SBCon device 0" + default n + +config I2C_SBCON_0_NAME + depends on I2C_SBCON_0 + string "SBCon device 0 Device Name" + default "SBCON_0" + +config I2C_SBCON_1 + bool "Enable SBCon device 1" + default n + +config I2C_SBCON_1_NAME + depends on I2C_SBCON_1 + string "SBCon device 1 Device Name" + default "SBCON_1" + +config I2C_SBCON_2 + bool "Enable SBCon device 2" + default n + +config I2C_SBCON_2_NAME + depends on I2C_SBCON_2 + string "SBCon device 2 Device Name" + default "SBCON_2" + +config I2C_SBCON_3 + bool "Enable SBCon device 3" + default n + +config I2C_SBCON_3_NAME + depends on I2C_SBCON_3 + string "SBCon device 0 Device Name" + default "SBCON_3" + +endif diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile index b3db3e81d31cb..c998d3cfd9386 100644 --- a/drivers/i2c/Makefile +++ b/drivers/i2c/Makefile @@ -6,5 +6,6 @@ obj-$(CONFIG_I2C_MCUX) += i2c_mcux.o obj-$(CONFIG_I2C_NRF5) += i2c_nrf5.o obj-$(CONFIG_I2C_QMSI) += i2c_qmsi.o obj-$(CONFIG_I2C_QMSI_SS) += i2c_qmsi_ss.o +obj-$(CONFIG_I2C_SBCON) += i2c_sbcon.o obj-$(CONFIG_I2C_STM32LX) += i2c_stm32lx.o obj-$(CONFIG_TWIHS_SAM) += twihs_sam.o diff --git a/drivers/i2c/i2c_sbcon.c b/drivers/i2c/i2c_sbcon.c new file mode 100644 index 0000000000000..ed256cebe96b2 --- /dev/null +++ b/drivers/i2c/i2c_sbcon.c @@ -0,0 +1,140 @@ +/* + * Copyright (c) 2017 Linaro Ltd. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/** + * @file + * @brief Driver for ARM's SBCon 2-wire serial bus interface + * + * SBCon is a simple device which allows directly setting and getting the + * hardware state of two-bit serial interfaces like I2C. + */ + +#include +#include +#include +#include +#include + +/* SBCon hardware registers layout */ +struct sbcon { + union { + volatile u32_t SB_CONTROLS; /* Write to set pins high */ + volatile u32_t SB_CONTROL; /* Read for state of pins */ + }; + volatile u32_t SB_CONTROLC; /* Write to set pins low */ +}; + +/* Bits values for SCL and SDA lines in struct sbcon registers */ +#define SCL BIT(0) +#define SDA BIT(1) + +/* Driver config */ +struct i2c_sbcon_config { + struct sbcon *sbcon; /* Address of hardware registers */ +}; + +/* Driver instance data */ +struct i2c_sbcon_context { + struct i2c_bitbang bitbang; /* Bit-bang library data */ +}; + +static void i2c_sbcon_set_scl(void *io_context, int state) +{ + struct sbcon *sbcon = io_context; + + if (state) { + sbcon->SB_CONTROLS = SCL; + } else { + sbcon->SB_CONTROLC = SCL; + } +} + +static void i2c_sbcon_set_sda(void *io_context, int state) +{ + struct sbcon *sbcon = io_context; + + if (state) { + sbcon->SB_CONTROLS = SDA; + } else { + sbcon->SB_CONTROLC = SDA; + } +} + +static int i2c_sbcon_get_sda(void *io_context) +{ + struct sbcon *sbcon = io_context; + + return sbcon->SB_CONTROL & SDA; +} + +static const struct i2c_bitbang_io io_fns = { + .set_scl = &i2c_sbcon_set_scl, + .set_sda = &i2c_sbcon_set_sda, + .get_sda = &i2c_sbcon_get_sda, +}; + +static int i2c_sbcon_configure(struct device *dev, u32_t dev_config) +{ + struct i2c_sbcon_context *context = dev->driver_data; + + return i2c_bitbang_configure(&context->bitbang, dev_config); +} + +static int i2c_sbcon_transfer(struct device *dev, struct i2c_msg *msgs, + u8_t num_msgs, u16_t slave_address) +{ + struct i2c_sbcon_context *context = dev->driver_data; + + return i2c_bitbang_transfer(&context->bitbang, msgs, num_msgs, + slave_address); +} + +static struct i2c_driver_api api = { + .configure = i2c_sbcon_configure, + .transfer = i2c_sbcon_transfer, +}; + +static int i2c_sbcon_init(struct device *dev) +{ + struct i2c_sbcon_context *context = dev->driver_data; + const struct i2c_sbcon_config *config = dev->config->config_info; + + i2c_bitbang_init(&context->bitbang, &io_fns, config->sbcon); + + dev->driver_api = &api; + + return 0; +} + +#define DEFINE_I2C_SBCON(_num) \ + \ +static struct i2c_sbcon_context i2c_sbcon_dev_data_##_num; \ + \ +static const struct i2c_sbcon_config i2c_sbcon_dev_cfg_##_num = { \ + .sbcon = (void *)I2C_SBCON_##_num##_BASE_ADDR, \ +}; \ + \ +DEVICE_INIT(i2c_sbcon_##_num, CONFIG_I2C_SBCON_##_num##_NAME, \ + i2c_sbcon_init, \ + &i2c_sbcon_dev_data_##_num, \ + &i2c_sbcon_dev_cfg_##_num, \ + PRE_KERNEL_2, CONFIG_I2C_INIT_PRIORITY) + +#ifdef CONFIG_I2C_SBCON_0 +DEFINE_I2C_SBCON(0); +#endif + +#ifdef CONFIG_I2C_SBCON_1 +DEFINE_I2C_SBCON(1); +#endif + +#ifdef CONFIG_I2C_SBCON_2 +DEFINE_I2C_SBCON(2); +#endif + +#ifdef CONFIG_I2C_SBCON_3 +DEFINE_I2C_SBCON(3); +#endif From c7cb68931faff1c2ba0f952ae7f44ba0c403c178 Mon Sep 17 00:00:00 2001 From: Jon Medhurst Date: Fri, 24 Mar 2017 16:32:38 +0000 Subject: [PATCH 2/5] boards: mps2_an385: Enable I2C devices The FPGA on the MPS2 board implements 4 SBCon devices for I2C which are connected to: - a touchscreen controller - the audio device (for configuration) - both shield connectors Change-Id: I55ca985e18b45d68f5e7421c4768dfc9bf2fcb3f Signed-off-by: Jon Medhurst --- arch/arm/soc/arm/mps2/soc_devices.h | 7 +++++ arch/arm/soc/arm/mps2/soc_memory_map.h | 6 ++++- boards/arm/mps2_an385/Kconfig.defconfig | 31 ++++++++++++++++++++++ boards/arm/mps2_an385/mps2_an385_defconfig | 2 ++ 4 files changed, 45 insertions(+), 1 deletion(-) diff --git a/arch/arm/soc/arm/mps2/soc_devices.h b/arch/arm/soc/arm/mps2/soc_devices.h index 5afa2b6171a43..e87e0698986a9 100644 --- a/arch/arm/soc/arm/mps2/soc_devices.h +++ b/arch/arm/soc/arm/mps2/soc_devices.h @@ -58,6 +58,13 @@ #define CMSDK_APB_DUALTIMER_IRQ IRQ_DUAL_TIMER #endif /* CONFIG_COUNTER */ +#if defined(CONFIG_I2C_SBCON) +#define I2C_SBCON_0_BASE_ADDR I2C_TOUCH_BASE_ADDR +#define I2C_SBCON_1_BASE_ADDR I2C_AUDIO_CONF_BASE_ADDR +#define I2C_SBCON_2_BASE_ADDR I2C_SHIELD0_BASE_ADDR +#define I2C_SBCON_3_BASE_ADDR I2C_SHIELD1_BASE_ADDR +#endif + #ifndef _ASMLANGUAGE #include "soc_registers.h" diff --git a/arch/arm/soc/arm/mps2/soc_memory_map.h b/arch/arm/soc/arm/mps2/soc_memory_map.h index 4fd95234dad49..a80ea8c19c6bd 100644 --- a/arch/arm/soc/arm/mps2/soc_memory_map.h +++ b/arch/arm/soc/arm/mps2/soc_memory_map.h @@ -35,6 +35,10 @@ #define UART_4_BASE_ADDR (MPS2_APB_BASE_ADDR + 0x9000) /* MPS2 peripherals in FPGA APB subsystem */ -#define FPGAIO_BASE_ADDR (MPS2_FPGA_APB_BASE_ADDR + 0x8000) +#define I2C_TOUCH_BASE_ADDR (MPS2_FPGA_APB_BASE_ADDR + 0x2000) +#define I2C_AUDIO_CONF_BASE_ADDR (MPS2_FPGA_APB_BASE_ADDR + 0x3000) +#define FPGAIO_BASE_ADDR (MPS2_FPGA_APB_BASE_ADDR + 0x8000) +#define I2C_SHIELD0_BASE_ADDR (MPS2_FPGA_APB_BASE_ADDR + 0x9000) +#define I2C_SHIELD1_BASE_ADDR (MPS2_FPGA_APB_BASE_ADDR + 0xa000) #endif /* _SOC_MEMORY_MAP_H_ */ diff --git a/boards/arm/mps2_an385/Kconfig.defconfig b/boards/arm/mps2_an385/Kconfig.defconfig index 1ada42a138931..f8cf08b0d396d 100644 --- a/boards/arm/mps2_an385/Kconfig.defconfig +++ b/boards/arm/mps2_an385/Kconfig.defconfig @@ -105,4 +105,35 @@ endif # TIMER_DTMR_CMSDK_APB endif # COUNTER +if I2C + +config I2C_SBCON + def_bool y + +config I2C_SBCON_0 + def_bool y + +config I2C_SBCON_0_NAME + default I2C_TOUCH + +config I2C_SBCON_1 + def_bool y + +config I2C_SBCON_1_NAME + default I2C_AUDIO_CONF + +config I2C_SBCON_2 + def_bool y + +config I2C_SBCON_2_NAME + default I2C_SHIELD0 + +config I2C_SBCON_3 + def_bool y + +config I2C_SBCON_3_NAME + default I2C_SHIELD1 + +endif # I2C + endif diff --git a/boards/arm/mps2_an385/mps2_an385_defconfig b/boards/arm/mps2_an385/mps2_an385_defconfig index 2a1485df4a8d3..427e50246df48 100644 --- a/boards/arm/mps2_an385/mps2_an385_defconfig +++ b/boards/arm/mps2_an385/mps2_an385_defconfig @@ -28,3 +28,5 @@ CONFIG_UART_CONSOLE_ON_DEV_NAME="UART_0" # Watchdog CONFIG_WATCHDOG=y + +CONFIG_I2C=y \ No newline at end of file From 7e0dcfca13a88cdb33103863f63cd748151ca7c2 Mon Sep 17 00:00:00 2001 From: Justin Watson Date: Mon, 1 May 2017 14:57:26 -0700 Subject: [PATCH 3/5] arch: sam3x: update Kconfig options after move to SAM SoC family tree The files for the Arduino Due needed to be updated to use the new configuration when the SoC moved from the atmel_sam3 directory to the atmel_sam/sam3x directory. Jira: ZEP-2067 Signed-off-by: Justin Watson --- arch/arm/soc/atmel_sam/Kconfig | 5 -- arch/arm/soc/atmel_sam/Kconfig.defconfig | 2 +- .../atmel_sam/sam3x/Kconfig.defconfig.series | 59 ++----------------- arch/arm/soc/atmel_sam/sam3x/Kconfig.series | 10 ---- arch/arm/soc/atmel_sam/sam3x/Kconfig.soc | 4 +- arch/arm/soc/atmel_sam/sam3x/soc.c | 4 +- boards/arm/arduino_due/Kconfig.board | 7 ++- boards/arm/arduino_due/Kconfig.defconfig | 45 ++++++++++++++ boards/arm/arduino_due/arduino_due_defconfig | 7 ++- drivers/gpio/Kconfig.atmel_sam3 | 2 +- drivers/i2c/Kconfig | 5 +- drivers/pinmux/dev/Kconfig | 2 +- drivers/serial/Kconfig.atmel_sam3 | 2 +- samples/drivers/gpio/src/main.c | 2 +- samples/drivers/lcd_hd44780/src/main.c | 4 +- samples/drivers/lcd_hd44780/testcase.ini | 2 +- tests/kernel/test_tickless/src/timestamps.c | 2 +- tests/kernel/test_tickless/testcase.ini | 2 +- 18 files changed, 78 insertions(+), 88 deletions(-) diff --git a/arch/arm/soc/atmel_sam/Kconfig b/arch/arm/soc/atmel_sam/Kconfig index 759f70525c702..1988dd2005ab0 100644 --- a/arch/arm/soc/atmel_sam/Kconfig +++ b/arch/arm/soc/atmel_sam/Kconfig @@ -4,10 +4,5 @@ # SPDX-License-Identifier: Apache-2.0 # -config SOC_ATMEL_SAM3 - bool - depends on ARM - default n - # Select SoC Part No. and configuration options source "arch/arm/soc/atmel_sam/*/Kconfig.soc" diff --git a/arch/arm/soc/atmel_sam/Kconfig.defconfig b/arch/arm/soc/atmel_sam/Kconfig.defconfig index 1f5550b230c4d..bdddffc438751 100644 --- a/arch/arm/soc/atmel_sam/Kconfig.defconfig +++ b/arch/arm/soc/atmel_sam/Kconfig.defconfig @@ -16,7 +16,7 @@ config SOC_FAMILY default atmel_sam config WATCHDOG - def_bool y if !SOC_ATMEL_SAM3X8E + def_bool y endif #SOC_FAMILY_SAM diff --git a/arch/arm/soc/atmel_sam/sam3x/Kconfig.defconfig.series b/arch/arm/soc/atmel_sam/sam3x/Kconfig.defconfig.series index 30159e2ebf0d6..8ed2fecfcf417 100644 --- a/arch/arm/soc/atmel_sam/sam3x/Kconfig.defconfig.series +++ b/arch/arm/soc/atmel_sam/sam3x/Kconfig.defconfig.series @@ -6,7 +6,7 @@ # SPDX-License-Identifier: Apache-2.0 # -if SOC_SERIES_SAM3X || SOC_ATMEL_SAM3X8E +if SOC_SERIES_SAM3X config SOC_SERIES string @@ -14,7 +14,7 @@ config SOC_SERIES config SOC_PART_NUMBER string - default sam3x8e if SOC_PART_NUMBER_SAM3X8E || SOC_ATMEL_SAM3X8E + default sam3x8e if SOC_PART_NUMBER_SAM3X8E config NUM_IRQ_PRIO_BITS int @@ -42,66 +42,19 @@ config SYS_CLOCK_HW_CYCLES_PER_SEC # to provide one continuous 96K block. # config SRAM_SIZE - default 96 if SOC_PART_NUMBER_SAM3X8E || SOC_ATMEL_SAM3X8E + default 96 if SOC_PART_NUMBER_SAM3X8E config SRAM_BASE_ADDRESS - default 0x20000000 if !SOC_PART_NUMBER_SAM3X8E && !SOC_ATMEL_SAM3X8E - default 0x20070000 if SOC_PART_NUMBER_SAM3X8E || SOC_ATMEL_SAM3X8E + default 0x20000000 if !SOC_PART_NUMBER_SAM3X8E + default 0x20070000 if SOC_PART_NUMBER_SAM3X8E # # Atmel SAM3X family has flash starting @ 0x00080000. # config FLASH_SIZE - default 512 if SOC_PART_NUMBER_SAM3X8E || SOC_ATMEL_SAM3X8E + default 512 if SOC_PART_NUMBER_SAM3X8E config FLASH_BASE_ADDRESS default 0x00080000 -if UART_ATMEL_SAM3 - -config UART_ATMEL_SAM3_BAUD_RATE - default 115200 - -config UART_ATMEL_SAM3_CLK_FREQ - default 84000000 - -endif # UART_ATMEL_SAM3 - -if GPIO - -config GPIO_ATMEL_SAM3 - def_bool y - -config GPIO_ATMEL_SAM3_PORTA - default y - -config GPIO_ATMEL_SAM3_PORTB - default y - -config GPIO_ATMEL_SAM3_PORTC - default y - -config GPIO_ATMEL_SAM3_PORTD - default y - -endif # GPIO - -if I2C - -config I2C_ATMEL_SAM3 - def_bool y - -config I2C_0 - default y -config I2C_0_IRQ_PRI - default 0 - -config I2C_1 - default y - -config I2C_1_IRQ_PRI - default 0 - -endif # I2C - endif # SOC_SERIES_SAM3X diff --git a/arch/arm/soc/atmel_sam/sam3x/Kconfig.series b/arch/arm/soc/atmel_sam/sam3x/Kconfig.series index 59bb0f4ea8672..9d77cb7a8e814 100644 --- a/arch/arm/soc/atmel_sam/sam3x/Kconfig.series +++ b/arch/arm/soc/atmel_sam/sam3x/Kconfig.series @@ -16,13 +16,3 @@ config SOC_SERIES_SAM3X help Enable support for Atmel SAM3X Cortex-M3 microcontrollers. Part No.: SAM3X8E - -config SOC_ATMEL_SAM3X8E - bool "Atmel SAM3X8E Processor" - select SOC_PART_NUMBER_SAM3X8E - select CPU_CORTEX_M - select CPU_CORTEX_M3 - select SOC_FAMILY_SAM - select SYS_POWER_LOW_POWER_STATE_SUPPORTED - select CPU_HAS_SYSTICK - select SOC_ATMEL_SAM3 diff --git a/arch/arm/soc/atmel_sam/sam3x/Kconfig.soc b/arch/arm/soc/atmel_sam/sam3x/Kconfig.soc index 06bf046725faa..1277d9e53b9c5 100644 --- a/arch/arm/soc/atmel_sam/sam3x/Kconfig.soc +++ b/arch/arm/soc/atmel_sam/sam3x/Kconfig.soc @@ -15,7 +15,7 @@ choice bool "SAM3X8E" endchoice -if SOC_SERIES_SAM3X || SOC_ATMEL_SAM3X8E +if SOC_SERIES_SAM3X config SOC_ATMEL_SAM3X_EXT_SLCK bool "Atmel SAM3 to use external crystal oscillator for slow clock" @@ -75,7 +75,7 @@ config SOC_ATMEL_SAM3X_PLLA_DIVA config SOC_ATMEL_SAM3X_WAIT_MODE bool "Atmel SAM3 goes to Wait mode instead of Sleep mode" - depends on SOC_ATMEL_SAM3_EXT_MAINCK + depends on SOC_ATMEL_SAM3X_EXT_MAINCK default y if DEBUG help For JTAG debugging CPU clock (HCLK) should not stop. In order diff --git a/arch/arm/soc/atmel_sam/sam3x/soc.c b/arch/arm/soc/atmel_sam/sam3x/soc.c index 1e8b01fb400e3..98215571a1b52 100644 --- a/arch/arm/soc/atmel_sam/sam3x/soc.c +++ b/arch/arm/soc/atmel_sam/sam3x/soc.c @@ -50,7 +50,7 @@ static ALWAYS_INLINE void clock_init(void) /* Wait for oscillator to be stablized */ while (!(__SUPC->sr & SUPC_SR_OSCSEL)) ; -#endif /* CONFIG_SOC_ATMEL_SAM3_EXT_SLCK */ +#endif /* CONFIG_SOC_ATMEL_SAM3X_EXT_SLCK */ #ifdef CONFIG_SOC_ATMEL_SAM3X_EXT_MAINCK /* Start the external main oscillator */ @@ -88,7 +88,7 @@ static ALWAYS_INLINE void clock_init(void) /* Wait for main fast RC oscillator to be stablized */ while (!(__PMC->sr & PMC_INT_MOSCRCS)) ; -#endif /* CONFIG_SOC_ATMEL_SAM3_EXT_MAINCK */ +#endif /* CONFIG_SOC_ATMEL_SAM3X_EXT_MAINCK */ /* Use PLLA as master clock. * According to datasheet, PMC_MCKR must not be programmed in diff --git a/boards/arm/arduino_due/Kconfig.board b/boards/arm/arduino_due/Kconfig.board index 552742e6fb6bf..5818773a88228 100644 --- a/boards/arm/arduino_due/Kconfig.board +++ b/boards/arm/arduino_due/Kconfig.board @@ -1,4 +1,9 @@ +# Kconfig - Arduino Due Board configuration +# +# Copyright (c) 2017 Justin Watson +# SPDX-License-Identifier: Apache-2.0 +# config BOARD_ARDUINO_DUE bool "Arduino Due Board" - depends on SOC_ATMEL_SAM3X8E + depends on SOC_PART_NUMBER_SAM3X8E diff --git a/boards/arm/arduino_due/Kconfig.defconfig b/boards/arm/arduino_due/Kconfig.defconfig index 952d4e0d3e2c6..b5d1d0ebcacd2 100644 --- a/boards/arm/arduino_due/Kconfig.defconfig +++ b/boards/arm/arduino_due/Kconfig.defconfig @@ -1,14 +1,59 @@ +# Kconfig - Arduino Due Board configuration +# +# Copyright (c) 2017 Justin Watson +# SPDX-License-Identifier: Apache-2.0 +# if BOARD_ARDUINO_DUE config BOARD default arduino_due +if UART_ATMEL_SAM3 + +config UART_ATMEL_SAM3_BAUD_RATE + default 115200 + +config UART_ATMEL_SAM3_CLK_FREQ + default 84000000 + +endif # UART_ATMEL_SAM3 + +if GPIO + +config GPIO_ATMEL_SAM3 + def_bool y + +config GPIO_ATMEL_SAM3_PORTA + default y + +config GPIO_ATMEL_SAM3_PORTB + default y + +config GPIO_ATMEL_SAM3_PORTC + default y + +config GPIO_ATMEL_SAM3_PORTD + default y + +endif # GPIO + if I2C config I2C_ATMEL_SAM3 + def_bool y + +config I2C_0 + default y +config I2C_0_IRQ_PRI + default 0 + +config I2C_1 default y +config I2C_1_IRQ_PRI + default 0 + endif # I2C endif # BOARD_ARDUINO_DUE diff --git a/boards/arm/arduino_due/arduino_due_defconfig b/boards/arm/arduino_due/arduino_due_defconfig index 625064ef5be85..73b61fd8844a3 100644 --- a/boards/arm/arduino_due/arduino_due_defconfig +++ b/boards/arm/arduino_due/arduino_due_defconfig @@ -1,10 +1,13 @@ CONFIG_ARM=y -CONFIG_SOC_ATMEL_SAM3X8E=y +CONFIG_SOC_FAMILY_SAM=y +CONFIG_SOC_SERIES_SAM3X=y +CONFIG_SOC_PART_NUMBER_SAM3X8E=y CONFIG_BOARD_ARDUINO_DUE=y CONFIG_CORTEX_M_SYSTICK=y CONFIG_CONSOLE=y CONFIG_UART_CONSOLE=y CONFIG_SERIAL=y CONFIG_UART_ATMEL_SAM3=y -CONFIG_SOC_ATMEL_SAM3_EXT_MAINCK=y +CONFIG_SOC_ATMEL_SAM3X_EXT_MAINCK=y CONFIG_PINMUX=y +CONFIG_WATCHDOG=n diff --git a/drivers/gpio/Kconfig.atmel_sam3 b/drivers/gpio/Kconfig.atmel_sam3 index 8413a8b606ce0..584b6aef0c171 100644 --- a/drivers/gpio/Kconfig.atmel_sam3 +++ b/drivers/gpio/Kconfig.atmel_sam3 @@ -8,7 +8,7 @@ menuconfig GPIO_ATMEL_SAM3 bool "Atmel SAM3 PIO Controllers" - depends on GPIO && SOC_ATMEL_SAM3 + depends on GPIO && SOC_SERIES_SAM3X default n help Enable config options to support the PIO controllers diff --git a/drivers/i2c/Kconfig b/drivers/i2c/Kconfig index afd85b06c0588..9b4993892f9ed 100644 --- a/drivers/i2c/Kconfig +++ b/drivers/i2c/Kconfig @@ -45,12 +45,11 @@ config I2C_QMSI provided by the QMSI BSP. config I2C_ATMEL_SAM3 - bool "Atmel SAM3 I2C Driver" - depends on SOC_ATMEL_SAM3 + bool "Atmel SAM3X I2C Driver" + depends on SOC_SERIES_SAM3X default n help Enable I2C support on the Atmel SAM3 family processor. - Says y to enable additional options to enable support for individual controllers. diff --git a/drivers/pinmux/dev/Kconfig b/drivers/pinmux/dev/Kconfig index 418b5eaa3cc45..87a93cb9db9f4 100644 --- a/drivers/pinmux/dev/Kconfig +++ b/drivers/pinmux/dev/Kconfig @@ -24,7 +24,7 @@ config PINMUX_DEV_NAME config PINMUX_DEV_ATMEL_SAM3X bool "Enable pinmux dev driver for Atmel SAM3X boards" - depends on PINMUX_DEV && SOC_ATMEL_SAM3X8E + depends on PINMUX_DEV && SOC_SERIES_SAM3X help Enables the pinmux dev driver for boards based on the Atmel SAM3X family of microcontrollers. diff --git a/drivers/serial/Kconfig.atmel_sam3 b/drivers/serial/Kconfig.atmel_sam3 index ef678fd30e298..d87e92da9314b 100644 --- a/drivers/serial/Kconfig.atmel_sam3 +++ b/drivers/serial/Kconfig.atmel_sam3 @@ -2,7 +2,7 @@ menuconfig UART_ATMEL_SAM3 bool "Atmel SAM3 family processor UART driver" default n select SERIAL_HAS_DRIVER - depends on SOC_ATMEL_SAM3 + depends on SOC_SERIES_SAM3X help This option enables the UART driver for Atmel SAM3 family processors. Note that there is only one diff --git a/samples/drivers/gpio/src/main.c b/samples/drivers/gpio/src/main.c index 8a19726bb1fb9..07ce642339d32 100644 --- a/samples/drivers/gpio/src/main.c +++ b/samples/drivers/gpio/src/main.c @@ -114,7 +114,7 @@ #define GPIO_OUT_PIN 16 #define GPIO_INT_PIN 19 #define GPIO_NAME "GPIO_" -#elif defined(CONFIG_SOC_ATMEL_SAM3) +#elif defined(CONFIG_SOC_PART_NUMBER_SAM3X8E) #define GPIO_OUT_PIN 25 #define GPIO_INT_PIN 27 #define GPIO_NAME "GPIO_" diff --git a/samples/drivers/lcd_hd44780/src/main.c b/samples/drivers/lcd_hd44780/src/main.c index 1ed57a7a5d10f..4b015bea08f51 100644 --- a/samples/drivers/lcd_hd44780/src/main.c +++ b/samples/drivers/lcd_hd44780/src/main.c @@ -71,13 +71,13 @@ #include -#if defined(CONFIG_GPIO_ATMEL_SAM3) +#if defined(CONFIG_SOC_PART_NUMBER_SAM3X8E) #define GPIO_DRV_NAME CONFIG_GPIO_ATMEL_SAM3_PORTC_DEV_NAME #else #error "Unsupported GPIO driver" #endif -#if defined(CONFIG_SOC_ATMEL_SAM3) +#if defined(CONFIG_SOC_PART_NUMBER_SAM3X8E) /* Define GPIO OUT to LCD */ #define GPIO_PIN_PC12_D0 12 /* PC12 - pin 51 */ #define GPIO_PIN_PC13_D1 13 /* PC13 - pin 50 */ diff --git a/samples/drivers/lcd_hd44780/testcase.ini b/samples/drivers/lcd_hd44780/testcase.ini index c0d4933d98dc5..2d8e8587b8ecf 100644 --- a/samples/drivers/lcd_hd44780/testcase.ini +++ b/samples/drivers/lcd_hd44780/testcase.ini @@ -1,5 +1,5 @@ [test] tags = samples build_only = true -filter = CONFIG_SOC_ATMEL_SAM3 +filter = CONFIG_SOC_SERIES_SAM3X diff --git a/tests/kernel/test_tickless/src/timestamps.c b/tests/kernel/test_tickless/src/timestamps.c index 8c097c4b324f2..ff8bac1da06a7 100644 --- a/tests/kernel/test_tickless/src/timestamps.c +++ b/tests/kernel/test_tickless/src/timestamps.c @@ -237,7 +237,7 @@ void _TimestampClose(void) _TIMESTAMP_CTRL = 0x0; /* disable oscillator */ } -#elif defined(CONFIG_SOC_ATMEL_SAM3) +#elif defined(CONFIG_SOC_SERIES_SAM3X) /* Atmel SAM3 family processor - use RTT (Real-time Timer) */ #include diff --git a/tests/kernel/test_tickless/testcase.ini b/tests/kernel/test_tickless/testcase.ini index d217bfd1d61ae..8903dde6c3fbd 100644 --- a/tests/kernel/test_tickless/testcase.ini +++ b/tests/kernel/test_tickless/testcase.ini @@ -2,5 +2,5 @@ tags = core arch_exclude = nios2 filter = CONFIG_X86 or (CONFIG_ARM and - (CONFIG_SOC_MK64F12 or CONFIG_SOC_ATMEL_SAM3)) or + (CONFIG_SOC_MK64F12 or CONFIG_SOC_SERIES_SAM3X)) or (CONFIG_ARC and CONFIG_SOC_QUARK_SE_C1000_SS) From 19b0b99f58078a0376aaa33aa9e04aac272e39b1 Mon Sep 17 00:00:00 2001 From: Erwan Gouriou Date: Tue, 2 May 2017 14:28:50 +0200 Subject: [PATCH 4/5] boards: disco_l475_iot1: Remove unexpected I2C address for HTS221 I2C address could not be configured for HTS221. Remove non existing configuration in disco_l475_iot1 board Change-Id: Ib5ed8e0f770c16b124cf918bdf9ecd42cdd9b213 Signed-off-by: Erwan Gouriou --- boards/arm/disco_l475_iot1/disco_l475_iot1_defconfig | 1 - 1 file changed, 1 deletion(-) diff --git a/boards/arm/disco_l475_iot1/disco_l475_iot1_defconfig b/boards/arm/disco_l475_iot1/disco_l475_iot1_defconfig index 63e0d7409836d..2863475c4324b 100644 --- a/boards/arm/disco_l475_iot1/disco_l475_iot1_defconfig +++ b/boards/arm/disco_l475_iot1/disco_l475_iot1_defconfig @@ -55,4 +55,3 @@ CONFIG_I2C_STM32LX=y #configure HTS221 sensor CONFIG_HTS221_I2C_MASTER_DEV_NAME="I2C_2" CONFIG_HTS221_TRIGGER_NONE=y -CONFIG_HTS221_I2C_ADDR=0x5F From 344fd237e3a533b842c4e7d49aca481a49967c39 Mon Sep 17 00:00:00 2001 From: Erwan Gouriou Date: Fri, 28 Apr 2017 13:44:07 +0200 Subject: [PATCH 5/5] samples: sensor: hts221 This commit provides sample application for sensor hts221. By default, it is enabled on board disco_l475_iot1 Change-Id: I535fac8a670fa89cc1cae15ea1abe9cfe4b6c56b Signed-off-by: Erwan Gouriou --- samples/sensor/hts221/Makefile | 4 +++ samples/sensor/hts221/README.rst | 47 +++++++++++++++++++++++++++++ samples/sensor/hts221/prj.conf | 4 +++ samples/sensor/hts221/src/Makefile | 1 + samples/sensor/hts221/src/main.c | 48 ++++++++++++++++++++++++++++++ samples/sensor/hts221/testcase.ini | 4 +++ 6 files changed, 108 insertions(+) create mode 100644 samples/sensor/hts221/Makefile create mode 100644 samples/sensor/hts221/README.rst create mode 100644 samples/sensor/hts221/prj.conf create mode 100644 samples/sensor/hts221/src/Makefile create mode 100644 samples/sensor/hts221/src/main.c create mode 100644 samples/sensor/hts221/testcase.ini diff --git a/samples/sensor/hts221/Makefile b/samples/sensor/hts221/Makefile new file mode 100644 index 0000000000000..63cb452ce0e06 --- /dev/null +++ b/samples/sensor/hts221/Makefile @@ -0,0 +1,4 @@ +BOARD ?= disco_l475_iot1 +CONF_FILE = prj.conf + +include ${ZEPHYR_BASE}/Makefile.inc diff --git a/samples/sensor/hts221/README.rst b/samples/sensor/hts221/README.rst new file mode 100644 index 0000000000000..bdd91fbc51dcd --- /dev/null +++ b/samples/sensor/hts221/README.rst @@ -0,0 +1,47 @@ +.. _hts221: + +HTS221: Temperature and Humidity Monitor +######################################## + +Overview +******** +This sample periodically reads temperature and humidity from the HTS221 +Temperature & Humidity Sensor and displays it on the console + + +Requirements +************ + +This sample uses the HTS221 sensor controlled using the I2C interface. + +References +********** + + - HTS211: http://www.st.com/en/mems-and-sensors/hts221.html + +Building and Running +******************** + + This project outputs sensor data to the console. It requires an HTS221 + sensor, which is present on the disco_l475_iot1 board. + + .. code-block:: console + + $ cd samples/sensors/hts221 + $ make BOARD=disco_l475_iot1 + +Sample Output +============= + + .. code-block:: console + + Temperature:25.3 C + Relative Humidity:40% + Temperature:25.3 C + Relative Humidity:40% + Temperature:25.3 C + Relative Humidity:40% + Temperature:25.3 C + Relative Humidity:40% + + diff --git a/samples/sensor/hts221/prj.conf b/samples/sensor/hts221/prj.conf new file mode 100644 index 0000000000000..6031b70dff747 --- /dev/null +++ b/samples/sensor/hts221/prj.conf @@ -0,0 +1,4 @@ +CONFIG_STDOUT_CONSOLE=y +CONFIG_I2C=y +CONFIG_SENSOR=y +CONFIG_HTS221=y diff --git a/samples/sensor/hts221/src/Makefile b/samples/sensor/hts221/src/Makefile new file mode 100644 index 0000000000000..b666967fd5706 --- /dev/null +++ b/samples/sensor/hts221/src/Makefile @@ -0,0 +1 @@ +obj-y += main.o diff --git a/samples/sensor/hts221/src/main.c b/samples/sensor/hts221/src/main.c new file mode 100644 index 0000000000000..2a5f856ad9dee --- /dev/null +++ b/samples/sensor/hts221/src/main.c @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2017 Linaro Limited + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include +#include +#include + +void main(void) +{ + struct sensor_value temp, hum; + struct device *dev = device_get_binding("HTS221"); + + if (dev == NULL) { + printf("Could not get HTS221 device\n"); + return; + } + + while (1) { + if (sensor_sample_fetch(dev) < 0) { + printf("Sensor sample update error\n"); + return; + } + + if (sensor_channel_get(dev, SENSOR_CHAN_TEMP, &temp) < 0) { + printf("Cannot read HTS221 temperature channel\n"); + return; + } + + if (sensor_channel_get(dev, SENSOR_CHAN_HUMIDITY, &hum) < 0) { + printf("Cannot read HTS221 humidity channel\n"); + return; + } + + /* display temperature */ + printf("Temperature:%.1f C\n", sensor_value_to_double(&temp)); + + /* display humidity (converted from millipercent) */ + printf("Relative Humidity:%.0f%%\n", + sensor_value_to_double(&hum) / 1000); + + k_sleep(2000); + } +} diff --git a/samples/sensor/hts221/testcase.ini b/samples/sensor/hts221/testcase.ini new file mode 100644 index 0000000000000..7260b929f7194 --- /dev/null +++ b/samples/sensor/hts221/testcase.ini @@ -0,0 +1,4 @@ +[test] +build_only = true +tags = samples sensor +platform_whitelist = disco_l475_iot1