From 1cd3b3f590bf821e8f93e14f5c5318ebce16f982 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 5 May 2017 14:47:11 -0600 Subject: [PATCH 1/9] Fix errors introduced into Kinetis serial when I unsuccessfully tried to correct coding standard violations. Folks, things will be better for everyone if you just follow that standard. --- arch/arm/src/kinetis/kinetis_lpserial.c | 10 +++++++--- arch/arm/src/kinetis/kinetis_serial.c | 6 +++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/arch/arm/src/kinetis/kinetis_lpserial.c b/arch/arm/src/kinetis/kinetis_lpserial.c index 117dd3de4a1..515f1f370e0 100644 --- a/arch/arm/src/kinetis/kinetis_lpserial.c +++ b/arch/arm/src/kinetis/kinetis_lpserial.c @@ -615,12 +615,12 @@ static int kinetis_ioctl(struct file *filep, int cmd, unsigned long arg) { #if defined(CONFIG_SERIAL_TERMIOS) || defined(CONFIG_SERIAL_TIOCSERGSTRUCT) || \ defined(CONFIG_KINETIS_SERIALBRK_BSDCOMPAT) - struct inode *inode = filep->f_inode; - struct uart_dev_s *dev = inode->i_private; + struct inode *inode; + struct uart_dev_s *dev; uint8_t regval; #endif #if defined(CONFIG_SERIAL_TERMIOS) || defined(CONFIG_KINETIS_SERIALBRK_BSDCOMPAT) - struct kinetis_dev_s *priv = (struct kinetis_dev_s *)dev->priv; + struct kinetis_dev_s *priv; bool iflow = false; bool oflow = false; #endif @@ -634,6 +634,10 @@ static int kinetis_ioctl(struct file *filep, int cmd, unsigned long arg) DEBUGASSERT(dev != NULL && dev->priv != NULL); #endif +#if defined(CONFIG_SERIAL_TERMIOS) || defined(CONFIG_KINETIS_SERIALBRK_BSDCOMPAT) + priv = (struct kinetis_dev_s *)dev->priv; +#endif + switch (cmd) { #ifdef CONFIG_SERIAL_TIOCSERGSTRUCT diff --git a/arch/arm/src/kinetis/kinetis_serial.c b/arch/arm/src/kinetis/kinetis_serial.c index b7c6aeebc76..0f2a4b2ee46 100644 --- a/arch/arm/src/kinetis/kinetis_serial.c +++ b/arch/arm/src/kinetis/kinetis_serial.c @@ -980,7 +980,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg) uint8_t regval; #endif #if defined(CONFIG_SERIAL_TERMIOS) || defined(CONFIG_KINETIS_SERIALBRK_BSDCOMPAT) - struct up_dev_s *priv = (struct up_dev_s *)dev->priv; + struct up_dev_s *priv; bool iflow = false; bool oflow = false; #endif @@ -994,6 +994,10 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg) DEBUGASSERT(dev != NULL && dev->priv != NULL); #endif +#if defined(CONFIG_SERIAL_TERMIOS) || defined(CONFIG_KINETIS_SERIALBRK_BSDCOMPAT) + priv = (struct up_dev_s *)dev->priv; +#endif + switch (cmd) { #ifdef CONFIG_SERIAL_TIOCSERGSTRUCT From 979e671cf0e403540a2c20093417894d77db5a9d Mon Sep 17 00:00:00 2001 From: David Sidrane Date: Fri, 5 May 2017 15:02:55 -1000 Subject: [PATCH 2/9] kinetis:k20 Pin mux configure all I2C signals as Open Drain The output structure of the GPIO for I2C needs to be open drain. When left at the default, one can observe on a scope the slave contending with the push-pull during the ACK --- arch/arm/src/kinetis/chip/kinetis_k20pinmux.h | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/arch/arm/src/kinetis/chip/kinetis_k20pinmux.h b/arch/arm/src/kinetis/chip/kinetis_k20pinmux.h index ca708acfdf8..d77ea962704 100644 --- a/arch/arm/src/kinetis/chip/kinetis_k20pinmux.h +++ b/arch/arm/src/kinetis/chip/kinetis_k20pinmux.h @@ -1,8 +1,9 @@ /******************************************************************************************** * arch/arm/src/kinetis/chip/kinetis_k20pinmux.h * - * Copyright (C) 2015-2016 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt + * Copyright (C) 2015-2017 Gregory Nutt. All rights reserved. + * Authors: Gregory Nutt + * David Sidrane * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -159,14 +160,14 @@ # define PIN_FTM2_QD_PHA (PIN_ALT6 | PIN_PORTB | PIN18) # define PIN_FTM2_QD_PHB (PIN_ALT6 | PIN_PORTB | PIN19) -# define PIN_I2C0_SCL_1 (PIN_ALT2 | PIN_PORTB | PIN0) -# define PIN_I2C0_SCL_2 (PIN_ALT2 | PIN_PORTB | PIN2) -# define PIN_I2C0_SDA_1 (PIN_ALT2 | PIN_PORTB | PIN1) -# define PIN_I2C0_SDA_2 (PIN_ALT2 | PIN_PORTB | PIN3) -# define PIN_I2C1_SCL_1 (PIN_ALT2 | PIN_PORTC | PIN10) -# define PIN_I2C1_SCL_2 (PIN_ALT6 | PIN_PORTE | PIN1) -# define PIN_I2C1_SDA_1 (PIN_ALT2 | PIN_PORTC | PIN11) -# define PIN_I2C1_SDA_2 (PIN_ALT6 | PIN_PORTE | PIN0) +# define PIN_I2C0_SCL_1 (PIN_ALT2_OPENDRAIN | PIN_PORTB | PIN0) +# define PIN_I2C0_SCL_2 (PIN_ALT2_OPENDRAIN | PIN_PORTB | PIN2) +# define PIN_I2C0_SDA_1 (PIN_ALT2_OPENDRAIN | PIN_PORTB | PIN1) +# define PIN_I2C0_SDA_2 (PIN_ALT2_OPENDRAIN | PIN_PORTB | PIN3) +# define PIN_I2C1_SCL_1 (PIN_ALT2_OPENDRAIN | PIN_PORTC | PIN10) +# define PIN_I2C1_SCL_2 (PIN_ALT6_OPENDRAIN | PIN_PORTE | PIN1) +# define PIN_I2C1_SDA_1 (PIN_ALT2_OPENDRAIN | PIN_PORTC | PIN11) +# define PIN_I2C1_SDA_2 (PIN_ALT6_OPENDRAIN | PIN_PORTE | PIN0) # define PIN_I2S0_MCLK_1 (PIN_ALT4 | PIN_PORTC | PIN8) # define PIN_I2S0_MCLK_2 (PIN_ALT6 | PIN_PORTC | PIN6) From 1d9d13c426d9463fb7c14d66329bb8d08e05789b Mon Sep 17 00:00:00 2001 From: David Sidrane Date: Fri, 5 May 2017 15:02:55 -1000 Subject: [PATCH 3/9] kinetis:k40 Pin mux configure all I2C signals as Open Drain The output structure of the GPIO for I2C needs to be open drain. When left at the default, one can observe on a scope the slave contending with the push-pull during the ACK --- arch/arm/src/kinetis/chip/kinetis_k40pinmux.h | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/arch/arm/src/kinetis/chip/kinetis_k40pinmux.h b/arch/arm/src/kinetis/chip/kinetis_k40pinmux.h index 7083b0caf7c..c7570edaf9a 100644 --- a/arch/arm/src/kinetis/chip/kinetis_k40pinmux.h +++ b/arch/arm/src/kinetis/chip/kinetis_k40pinmux.h @@ -1,8 +1,9 @@ /******************************************************************************************** * arch/arm/src/kinetis/chip/kinetis_k40pinmux.h * - * Copyright (C) 2011, 2016 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt + * Copyright (C) 2011, 2016-2017 Gregory Nutt. All rights reserved. + * Authors: Gregory Nutt + * David Sidrane * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -160,7 +161,7 @@ #define PIN_ADC0_SE8 (PIN_ANALOG | PIN_PORTB | PIN0) #define PIN_ADC1_SE8 (PIN_ANALOG | PIN_PORTB | PIN0) #define PIN_TSI0_CH0 (PIN_ANALOG | PIN_PORTB | PIN0) -#define PIN_I2C0_SCL_1 (PIN_ALT2 | PIN_PORTB | PIN0) +#define PIN_I2C0_SCL_1 (PIN_ALT2_OPENDRAIN | PIN_PORTB | PIN0) #define PIN_FTM1_CH0_3 (PIN_ALT3 | PIN_PORTB | PIN0) #define PIN_FTM1_QD_PHA_3 (PIN_ALT6 | PIN_PORTB | PIN0) #define PIN_LCD_P0F (PIN_ALT7 | PIN_PORTB | PIN0) @@ -168,21 +169,21 @@ #define PIN_ADC0_SE9 (PIN_ANALOG | PIN_PORTB | PIN1) #define PIN_ADC1_SE9 (PIN_ANALOG | PIN_PORTB | PIN1) #define PIN_TSI0_CH6 (PIN_ANALOG | PIN_PORTB | PIN1) -#define PIN_I2C0_SDA_1 (PIN_ALT2 | PIN_PORTB | PIN1) +#define PIN_I2C0_SDA_1 (PIN_ALT2_OPENDRAIN | PIN_PORTB | PIN1) #define PIN_FTM1_CH1_3 (PIN_ALT3 | PIN_PORTB | PIN1) #define PIN_FTM1_QD_PHB (PIN_ALT6 | PIN_PORTB | PIN1) #define PIN_LCD_P1F (PIN_ALT7 | PIN_PORTB | PIN1) #define PIN_LCD_P2 (PIN_ANALOG | PIN_PORTB | PIN2) #define PIN_ADC0_SE12 (PIN_ANALOG | PIN_PORTB | PIN2) #define PIN_TSI0_CH7 (PIN_ANALOG | PIN_PORTB | PIN2) -#define PIN_I2C0_SCL_2 (PIN_ALT2 | PIN_PORTB | PIN2) +#define PIN_I2C0_SCL_2 (PIN_ALT2_OPENDRAIN| PIN_PORTB | PIN2) #define PIN_UART0_RTS_3 (PIN_ALT3 | PIN_PORTB | PIN2) #define PIN_FTM0_FLT3 (PIN_ALT6 | PIN_PORTB | PIN2) #define PIN_LCD_P2F (PIN_ALT7 | PIN_PORTB | PIN2) #define PIN_LCD_P3 (PIN_ANALOG | PIN_PORTB | PIN3) #define PIN_ADC0_SE13 (PIN_ANALOG | PIN_PORTB | PIN3) #define PIN_TSI0_CH8 (PIN_ANALOG | PIN_PORTB | PIN3) -#define PIN_I2C0_SDA_2 (PIN_ALT2 | PIN_PORTB | PIN3) +#define PIN_I2C0_SDA_2 (PIN_ALT2_OPENDRAIN | PIN_PORTB | PIN3) #define PIN_UART0_CTS_3 (PIN_ALT3 | PIN_PORTB | PIN3) #define PIN_FTM0_FLT0_1 (PIN_ALT6 | PIN_PORTB | PIN3) #define PIN_LCD_P3F (PIN_ALT7 | PIN_PORTB | PIN3) @@ -325,12 +326,12 @@ #define PIN_LCD_P30 (PIN_ANALOG | PIN_PORTC | PIN10) #define PIN_ADC1_SE6B (PIN_ANALOG | PIN_PORTC | PIN10) #define PIN_CMP0_IN4 (PIN_ANALOG | PIN_PORTC | PIN10) -#define PIN_I2C1_SCL_1 (PIN_ALT2 | PIN_PORTC | PIN10) +#define PIN_I2C1_SCL_1 (PIN_ALT2_OPENDRAIN | PIN_PORTC | PIN10) #define PIN_I2S0_RX_FS_2 (PIN_ALT4 | PIN_PORTC | PIN10) #define PIN_LCD_P30F (PIN_ALT7 | PIN_PORTC | PIN10) #define PIN_LCD_P31 (PIN_ANALOG | PIN_PORTC | PIN11) #define PIN_ADC1_SE7B (PIN_ANALOG | PIN_PORTC | PIN11) -#define PIN_I2C1_SDA_1 (PIN_ALT2 | PIN_PORTC | PIN11) +#define PIN_I2C1_SDA_1 (PIN_ALT2_OPENDRAIN | PIN_PORTC | PIN11) #define PIN_I2S0_RXD_2 (PIN_ALT4 | PIN_PORTC | PIN11) #define PIN_LCD_P31F (PIN_ALT7 | PIN_PORTC | PIN11) #define PIN_LCD_P32 (PIN_ANALOG | PIN_PORTC | PIN12) @@ -427,13 +428,13 @@ #define PIN_UART1_TX_2 (PIN_ALT3 | PIN_PORTE | PIN0) #define PIN_SDHC0_D1 (PIN_ALT4 | PIN_PORTE | PIN0) #define PIN_FB_AD27 (PIN_ALT5 | PIN_PORTE | PIN0) -#define PIN_I2C1_SDA_2 (PIN_ALT6 | PIN_PORTE | PIN0) +#define PIN_I2C1_SDA_2 (PIN_ALT6_OPENDRAIN | PIN_PORTE | PIN0) #define PIN_ADC1_SE5A (PIN_ANALOG | PIN_PORTE | PIN1) #define PIN_SPI1_SOUT_2 (PIN_ALT2 | PIN_PORTE | PIN1) #define PIN_UART1_RX_2 (PIN_ALT3 | PIN_PORTE | PIN1) #define PIN_SDHC0_D0 (PIN_ALT4 | PIN_PORTE | PIN1) #define PIN_FB_AD26 (PIN_ALT5 | PIN_PORTE | PIN1) -#define PIN_I2C1_SCL_2 (PIN_ALT6 | PIN_PORTE | PIN1) +#define PIN_I2C1_SCL_2 (PIN_ALT6_OPENDRAIN | PIN_PORTE | PIN1) #define PIN_ADC1_SE6A (PIN_ANALOG | PIN_PORTE | PIN2) #define PIN_SPI1_SCK_2 (PIN_ALT2 | PIN_PORTE | PIN2) #define PIN_UART1_CTS_2 (PIN_ALT3 | PIN_PORTE | PIN2) From af1f48c1c55f6ece27522f1082b554c6a246b9cc Mon Sep 17 00:00:00 2001 From: David Sidrane Date: Fri, 5 May 2017 15:02:56 -1000 Subject: [PATCH 4/9] kinetis:k60 Pin mux configure all I2C signals as Open Drain The output structure of the GPIO for I2C needs to be open drain. When left at the default, one can observe on a scope the slave contending with the push-pull during the ACK --- arch/arm/src/kinetis/chip/kinetis_k60pinmux.h | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/arch/arm/src/kinetis/chip/kinetis_k60pinmux.h b/arch/arm/src/kinetis/chip/kinetis_k60pinmux.h index 888a5955840..b1ca87746f3 100644 --- a/arch/arm/src/kinetis/chip/kinetis_k60pinmux.h +++ b/arch/arm/src/kinetis/chip/kinetis_k60pinmux.h @@ -1,8 +1,9 @@ /******************************************************************************************** * arch/arm/src/kinetis/chip/kinetis_k60pinset.h * - * Copyright (C) 2011, 2016 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt + * Copyright (C) 2011, 2016-2017 Gregory Nutt. All rights reserved. + * Authors: Gregory Nutt + * David Sidrane * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -172,7 +173,7 @@ #define PIN_ADC0_SE8 (PIN_ANALOG | PIN_PORTB | PIN0) #define PIN_ADC1_SE8 (PIN_ANALOG | PIN_PORTB | PIN0) #define PIN_TSI0_CH0 (PIN_ANALOG | PIN_PORTB | PIN0) -#define PIN_I2C0_SCL_1 (PIN_ALT2 | PIN_PORTB | PIN0) +#define PIN_I2C0_SCL_1 (PIN_ALT2_OPENDRAIN | PIN_PORTB | PIN0) #define PIN_FTM1_CH0_3 (PIN_ALT3 | PIN_PORTB | PIN0) #ifdef CONFIG_KINETIS_ENET_MDIOPULLUP # define PIN_RMII0_MDIO (PIN_ALT4_PULLUP | PIN_PORTB | PIN0) @@ -184,20 +185,20 @@ #define PIN_ADC0_SE9 (PIN_ANALOG | PIN_PORTB | PIN1) #define PIN_ADC1_SE9 (PIN_ANALOG | PIN_PORTB | PIN1) #define PIN_TSI0_CH6 (PIN_ANALOG | PIN_PORTB | PIN1) -#define PIN_I2C0_SDA_1 (PIN_ALT2 | PIN_PORTB | PIN1) +#define PIN_I2C0_SDA_1 (PIN_ALT2_OPENDRAIN | PIN_PORTB | PIN1) #define PIN_FTM1_CH1_3 (PIN_ALT3 | PIN_PORTB | PIN1) #define PIN_RMII0_MDC (PIN_ALT4 | PIN_PORTB | PIN1) #define PIN_MII0_MDC (PIN_ALT4 | PIN_PORTB | PIN1) #define PIN_FTM1_QD_PHB_3 (PIN_ALT6 | PIN_PORTB | PIN1) #define PIN_ADC0_SE12 (PIN_ANALOG | PIN_PORTB | PIN2) #define PIN_TSI0_CH7 (PIN_ANALOG | PIN_PORTB | PIN2) -#define PIN_I2C0_SCL_2 (PIN_ALT2 | PIN_PORTB | PIN2) +#define PIN_I2C0_SCL_2 (PIN_ALT2_OPENDRAIN | PIN_PORTB | PIN2) #define PIN_UART0_RTS_3 (PIN_ALT3 | PIN_PORTB | PIN2) #define PIN_ENET0_1588_TMR0_1 (PIN_ALT4 | PIN_PORTB | PIN2) #define PIN_FTM0_FLT3 (PIN_ALT6 | PIN_PORTB | PIN2) #define PIN_ADC0_SE13 (PIN_ANALOG | PIN_PORTB | PIN3) #define PIN_TSI0_CH8 (PIN_ANALOG | PIN_PORTB | PIN3) -#define PIN_I2C0_SDA_2 (PIN_ALT2 | PIN_PORTB | PIN3) +#define PIN_I2C0_SDA_2 (PIN_ALT2_OPENDRAIN | PIN_PORTB | PIN3) #define PIN_UART0_CTS_3 (PIN_ALT3 | PIN_PORTB | PIN3) #define PIN_ENET0_1588_TMR1_1 (PIN_ALT4 | PIN_PORTB | PIN3) #define PIN_FTM0_FLT0_2 (PIN_ALT6 | PIN_PORTB | PIN3) @@ -313,11 +314,11 @@ #define PIN_FTM2_FLT0_2 (PIN_ALT6 | PIN_PORTC | PIN9) #define PIN_ADC1_SE6B (PIN_ANALOG | PIN_PORTC | PIN10) #define PIN_CMP0_IN4 (PIN_ANALOG | PIN_PORTC | PIN10) -#define PIN_I2C1_SCL_1 (PIN_ALT2 | PIN_PORTC | PIN10) +#define PIN_I2C1_SCL_1 (PIN_ALT2_OPENDRAIN | PIN_PORTC | PIN10) #define PIN_I2S0_RX_FS_2 (PIN_ALT4 | PIN_PORTC | PIN10) #define PIN_FB_AD5 (PIN_ALT5 | PIN_PORTC | PIN10) #define PIN_ADC1_SE7B (PIN_ANALOG | PIN_PORTC | PIN11) -#define PIN_I2C1_SDA_1 (PIN_ALT2 | PIN_PORTC | PIN11) +#define PIN_I2C1_SDA_1 (PIN_ALT2_OPENDRAIN | PIN_PORTC | PIN11) #define PIN_I2S0_RXD_2 (PIN_ALT4 | PIN_PORTC | PIN11) #define PIN_FB_RW (PIN_ALT5 | PIN_PORTC | PIN11) #define PIN_UART4_RTS_1 (PIN_ALT3 | PIN_PORTC | PIN12) @@ -387,10 +388,10 @@ #define PIN_UART0_TX_4 (PIN_ALT3 | PIN_PORTD | PIN7) #define PIN_FTM0_CH7_2 (PIN_ALT4 | PIN_PORTD | PIN7) #define PIN_FTM0_FLT1_2 (PIN_ALT6 | PIN_PORTD | PIN7) -#define PIN_I2C0_SCL_3 (PIN_ALT2 | PIN_PORTD | PIN8) +#define PIN_I2C0_SCL_3 (PIN_ALT2_OPENDRAIN | PIN_PORTD | PIN8) #define PIN_UART5_RX_1 (PIN_ALT3 | PIN_PORTD | PIN8) #define PIN_FB_A16 (PIN_ALT6 | PIN_PORTD | PIN8) -#define PIN_I2C0_SDA_3 (PIN_ALT2 | PIN_PORTD | PIN9) +#define PIN_I2C0_SDA_3 (PIN_ALT2_OPENDRAIN | PIN_PORTD | PIN9) #define PIN_UART5_TX_1 (PIN_ALT3 | PIN_PORTD | PIN9) #define PIN_FB_A17 (PIN_ALT6 | PIN_PORTD | PIN9) #define PIN_UART5_RTS_1 (PIN_ALT3 | PIN_PORTD | PIN10) @@ -416,12 +417,12 @@ #define PIN_SPI1_PCS1_2 (PIN_ALT2 | PIN_PORTE | PIN0) #define PIN_UART1_TX_2 (PIN_ALT3 | PIN_PORTE | PIN0) #define PIN_SDHC0_D1 (PIN_ALT4 | PIN_PORTE | PIN0) -#define PIN_I2C1_SDA_2 (PIN_ALT6 | PIN_PORTE | PIN0) +#define PIN_I2C1_SDA_2 (PIN_ALT6_OPENDRAIN | PIN_PORTE | PIN0) #define PIN_ADC1_SE5A (PIN_ANALOG | PIN_PORTE | PIN1) #define PIN_SPI1_SOUT_2 (PIN_ALT2 | PIN_PORTE | PIN1) #define PIN_UART1_RX_2 (PIN_ALT3 | PIN_PORTE | PIN1) #define PIN_SDHC0_D0 (PIN_ALT4 | PIN_PORTE | PIN1) -#define PIN_I2C1_SCL_2 (PIN_ALT6 | PIN_PORTE | PIN1) +#define PIN_I2C1_SCL_2 (PIN_ALT6_OPENDRAIN | PIN_PORTE | PIN1) #define PIN_ADC1_SE6A (PIN_ANALOG | PIN_PORTE | PIN2) #define PIN_SPI1_SCK_2 (PIN_ALT2 | PIN_PORTE | PIN2) #define PIN_UART1_CTS_2 (PIN_ALT3 | PIN_PORTE | PIN2) From ce98cedb17f0852eb93a08afb23447ef137848ff Mon Sep 17 00:00:00 2001 From: David Sidrane Date: Fri, 5 May 2017 15:02:56 -1000 Subject: [PATCH 5/9] kinetis:k64 Pin mux configure all I2C signals as Open Drain The output structure of the GPIO for I2C needs to be open drain. When left at the default, one can observe on a scope the slave contending with the push-pull during the ACK --- arch/arm/src/kinetis/chip/kinetis_k64pinmux.h | 41 ++++++++++--------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/arch/arm/src/kinetis/chip/kinetis_k64pinmux.h b/arch/arm/src/kinetis/chip/kinetis_k64pinmux.h index 3479099bf6c..d9894b3ff70 100644 --- a/arch/arm/src/kinetis/chip/kinetis_k64pinmux.h +++ b/arch/arm/src/kinetis/chip/kinetis_k64pinmux.h @@ -1,8 +1,9 @@ /******************************************************************************************** * arch/arm/src/kinetis/chip/kinetis_k64pinmux.h * - * Copyright (C) 2016 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt + * Copyright (C) 2016-2017 Gregory Nutt. All rights reserved. + * Authors: Gregory Nutt + * David Sidrane * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -305,26 +306,26 @@ /* I2C */ -#define PIN_I2C0_SCL_1 (PIN_ALT2 | PIN_PORTB | PIN0) -#define PIN_I2C0_SCL_2 (PIN_ALT2 | PIN_PORTB | PIN2) -#define PIN_I2C0_SCL_3 (PIN_ALT2 | PIN_PORTD | PIN8) -#define PIN_I2C0_SCL_4 (PIN_ALT5 | PIN_PORTE | PIN24) -#define PIN_I2C0_SCL_5 (PIN_ALT7 | PIN_PORTD | PIN2) -#define PIN_I2C0_SDA_1 (PIN_ALT2 | PIN_PORTB | PIN1) -#define PIN_I2C0_SDA_2 (PIN_ALT2 | PIN_PORTB | PIN3) -#define PIN_I2C0_SDA_3 (PIN_ALT2 | PIN_PORTD | PIN9) -#define PIN_I2C0_SDA_4 (PIN_ALT5 | PIN_PORTE | PIN25) -#define PIN_I2C0_SDA_5 (PIN_ALT7 | PIN_PORTD | PIN3) +#define PIN_I2C0_SCL_1 (PIN_ALT2_OPENDRAIN | PIN_PORTB | PIN0) +#define PIN_I2C0_SCL_2 (PIN_ALT2_OPENDRAIN | PIN_PORTB | PIN2) +#define PIN_I2C0_SCL_3 (PIN_ALT2_OPENDRAIN | PIN_PORTD | PIN8) +#define PIN_I2C0_SCL_4 (PIN_ALT5_OPENDRAIN | PIN_PORTE | PIN24) +#define PIN_I2C0_SCL_5 (PIN_ALT7_OPENDRAIN | PIN_PORTD | PIN2) +#define PIN_I2C0_SDA_1 (PIN_ALT2_OPENDRAIN | PIN_PORTB | PIN1) +#define PIN_I2C0_SDA_2 (PIN_ALT2_OPENDRAIN | PIN_PORTB | PIN3) +#define PIN_I2C0_SDA_3 (PIN_ALT2_OPENDRAIN | PIN_PORTD | PIN9) +#define PIN_I2C0_SDA_4 (PIN_ALT5_OPENDRAIN | PIN_PORTE | PIN25) +#define PIN_I2C0_SDA_5 (PIN_ALT7_OPENDRAIN | PIN_PORTD | PIN3) -#define PIN_I2C1_SCL_1 (PIN_ALT2 | PIN_PORTC | PIN10) -#define PIN_I2C1_SCL_2 (PIN_ALT6 | PIN_PORTE | PIN1) -#define PIN_I2C1_SDA_1 (PIN_ALT2 | PIN_PORTC | PIN11) -#define PIN_I2C1_SDA_2 (PIN_ALT6 | PIN_PORTE | PIN0) +#define PIN_I2C1_SCL_1 (PIN_ALT2_OPENDRAIN | PIN_PORTC | PIN10) +#define PIN_I2C1_SCL_2 (PIN_ALT6_OPENDRAIN | PIN_PORTE | PIN1) +#define PIN_I2C1_SDA_1 (PIN_ALT2_OPENDRAIN | PIN_PORTC | PIN11) +#define PIN_I2C1_SDA_2 (PIN_ALT6_OPENDRAIN | PIN_PORTE | PIN0) -#define PIN_I2C2_SCL_1 (PIN_ALT5 | PIN_PORTA | PIN12) -#define PIN_I2C2_SCL_2 (PIN_ALT5 | PIN_PORTA | PIN14) -#define PIN_I2C2_SDA_1 (PIN_ALT5 | PIN_PORTA | PIN11) -#define PIN_I2C2_SDA_2 (PIN_ALT5 | PIN_PORTA | PIN13) +#define PIN_I2C2_SCL_1 (PIN_ALT5_OPENDRAIN | PIN_PORTA | PIN12) +#define PIN_I2C2_SCL_2 (PIN_ALT5_OPENDRAIN | PIN_PORTA | PIN14) +#define PIN_I2C2_SDA_1 (PIN_ALT5_OPENDRAIN | PIN_PORTA | PIN11) +#define PIN_I2C2_SDA_2 (PIN_ALT5_OPENDRAIN | PIN_PORTA | PIN13) /* I2S */ From 97260321f2ef52407b6d5e6dc274a9e5945177da Mon Sep 17 00:00:00 2001 From: David Sidrane Date: Fri, 5 May 2017 15:02:57 -1000 Subject: [PATCH 6/9] kinetis:k66 Pin mux configure all I2C signals as Open Drain The output structure of the GPIO for I2C needs to be open drain. When left at the default, one can observe on a scope the slave contending with the push-pull during the ACK --- arch/arm/src/kinetis/chip/kinetis_k66pinmux.h | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/arch/arm/src/kinetis/chip/kinetis_k66pinmux.h b/arch/arm/src/kinetis/chip/kinetis_k66pinmux.h index b549f5c76d1..ad15c5ac024 100644 --- a/arch/arm/src/kinetis/chip/kinetis_k66pinmux.h +++ b/arch/arm/src/kinetis/chip/kinetis_k66pinmux.h @@ -317,31 +317,31 @@ /* I2C */ -#define PIN_I2C0_SCL_1 (PIN_ALT2 | PIN_PORTB | PIN0) -#define PIN_I2C0_SCL_2 (PIN_ALT2 | PIN_PORTB | PIN2) -#define PIN_I2C0_SCL_3 (PIN_ALT2 | PIN_PORTD | PIN8) -#define PIN_I2C0_SCL_4 (PIN_ALT5 | PIN_PORTE | PIN24) -#define PIN_I2C0_SCL_5 (PIN_ALT7 | PIN_PORTD | PIN2) -#define PIN_I2C0_SDA_1 (PIN_ALT2 | PIN_PORTB | PIN1) -#define PIN_I2C0_SDA_2 (PIN_ALT2 | PIN_PORTB | PIN3) -#define PIN_I2C0_SDA_3 (PIN_ALT2 | PIN_PORTD | PIN9) -#define PIN_I2C0_SDA_4 (PIN_ALT5 | PIN_PORTE | PIN25) -#define PIN_I2C0_SDA_5 (PIN_ALT7 | PIN_PORTD | PIN3) +#define PIN_I2C0_SCL_1 (PIN_ALT2_OPENDRAIN | PIN_PORTB | PIN0) +#define PIN_I2C0_SCL_2 (PIN_ALT2_OPENDRAIN | PIN_PORTB | PIN2) +#define PIN_I2C0_SCL_3 (PIN_ALT2_OPENDRAIN | PIN_PORTD | PIN8) +#define PIN_I2C0_SCL_4 (PIN_ALT5_OPENDRAIN | PIN_PORTE | PIN24) +#define PIN_I2C0_SCL_5 (PIN_ALT7_OPENDRAIN | PIN_PORTD | PIN2) +#define PIN_I2C0_SDA_1 (PIN_ALT2_OPENDRAIN | PIN_PORTB | PIN1) +#define PIN_I2C0_SDA_2 (PIN_ALT2_OPENDRAIN | PIN_PORTB | PIN3) +#define PIN_I2C0_SDA_3 (PIN_ALT2_OPENDRAIN | PIN_PORTD | PIN9) +#define PIN_I2C0_SDA_4 (PIN_ALT5_OPENDRAIN | PIN_PORTE | PIN25) +#define PIN_I2C0_SDA_5 (PIN_ALT7_OPENDRAIN | PIN_PORTD | PIN3) -#define PIN_I2C1_SCL_1 (PIN_ALT2 | PIN_PORTC | PIN10) -#define PIN_I2C1_SCL_2 (PIN_ALT6 | PIN_PORTE | PIN1) -#define PIN_I2C1_SDA_1 (PIN_ALT2 | PIN_PORTC | PIN11) -#define PIN_I2C1_SDA_2 (PIN_ALT6 | PIN_PORTE | PIN0) +#define PIN_I2C1_SCL_1 (PIN_ALT2_OPENDRAIN | PIN_PORTC | PIN10) +#define PIN_I2C1_SCL_2 (PIN_ALT6_OPENDRAIN | PIN_PORTE | PIN1) +#define PIN_I2C1_SDA_1 (PIN_ALT2_OPENDRAIN | PIN_PORTC | PIN11) +#define PIN_I2C1_SDA_2 (PIN_ALT6_OPENDRAIN | PIN_PORTE | PIN0) -#define PIN_I2C2_SCL_1 (PIN_ALT5 | PIN_PORTA | PIN12) -#define PIN_I2C2_SCL_2 (PIN_ALT5 | PIN_PORTA | PIN14) -#define PIN_I2C2_SDA_1 (PIN_ALT5 | PIN_PORTA | PIN11) -#define PIN_I2C2_SDA_2 (PIN_ALT5 | PIN_PORTA | PIN13) +#define PIN_I2C2_SCL_1 (PIN_ALT5_OPENDRAIN | PIN_PORTA | PIN12) +#define PIN_I2C2_SCL_2 (PIN_ALT5_OPENDRAIN | PIN_PORTA | PIN14) +#define PIN_I2C2_SDA_1 (PIN_ALT5_OPENDRAIN | PIN_PORTA | PIN11) +#define PIN_I2C2_SDA_2 (PIN_ALT5_OPENDRAIN | PIN_PORTA | PIN13) -#define PIN_I2C3_SCL_1 (PIN_ALT2 | PIN_PORTE | PIN11) -#define PIN_I2C3_SCL_2 (PIN_ALT4 | PIN_PORTA | PIN2) -#define PIN_I2C3_SDA_1 (PIN_ALT2 | PIN_PORTE | PIN10) -#define PIN_I2C3_SDA_2 (PIN_ALT4 | PIN_PORTA | PIN1) +#define PIN_I2C3_SCL_1 (PIN_ALT2_OPENDRAIN | PIN_PORTE | PIN11) +#define PIN_I2C3_SCL_2 (PIN_ALT4_OPENDRAIN | PIN_PORTA | PIN2) +#define PIN_I2C3_SDA_1 (PIN_ALT2_OPENDRAIN | PIN_PORTE | PIN10) +#define PIN_I2C3_SDA_2 (PIN_ALT4_OPENDRAIN | PIN_PORTA | PIN1) /* I2S */ From 5d6da5f4bb3296c42fd0ebdc34639a8b756bff88 Mon Sep 17 00:00:00 2001 From: David Sidrane Date: Sat, 6 May 2017 04:52:48 -1000 Subject: [PATCH 7/9] kinetis:Add ARCH_HAVE_I2CRESET --- arch/arm/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index c71fc987736..c8964e3c813 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -76,6 +76,7 @@ config ARCH_CHIP_KINETIS select ARCH_HAVE_FPU select ARCH_HAVE_RAMFUNCS select ARCH_HAVE_CMNVECTOR + select ARCH_HAVE_I2CRESET ---help--- Freescale Kinetis Architectures (ARM Cortex-M4) From 606255374820059331aa35a128d5ef4ed539335d Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sat, 6 May 2017 09:38:26 -0600 Subject: [PATCH 8/9] Refresh a configuration --- configs/photon/wlan/defconfig | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/configs/photon/wlan/defconfig b/configs/photon/wlan/defconfig index a616dd914f1..5f6b7e3ec79 100644 --- a/configs/photon/wlan/defconfig +++ b/configs/photon/wlan/defconfig @@ -16,7 +16,7 @@ CONFIG_HOST_LINUX=y # # Build Configuration # -CONFIG_APPS_DIR="../apps" +# CONFIG_APPS_DIR="../apps" CONFIG_BUILD_FLAT=y # CONFIG_BUILD_2PASS is not set @@ -1595,4 +1595,3 @@ CONFIG_WIRELESS_WAPI=y CONFIG_WIRELESS_WAPI_CMDTOOL=y CONFIG_WIRELESS_WAPI_STACKSIZE=2048 CONFIG_WIRELESS_WAPI_PRIORITY=100 -CONFIG_WIRELESS_WEXT=y From 5e81391d791d9e0d77941ab87c8a3b165df74052 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sat, 6 May 2017 11:25:39 -0600 Subject: [PATCH 9/9] Update a configuration. --- configs/photon/wlan/defconfig | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/configs/photon/wlan/defconfig b/configs/photon/wlan/defconfig index 5f6b7e3ec79..1892e56c10d 100644 --- a/configs/photon/wlan/defconfig +++ b/configs/photon/wlan/defconfig @@ -1552,6 +1552,16 @@ CONFIG_NSH_DRIPADDR=0xc0a80001 CONFIG_NSH_NETMASK=0xffffff00 # CONFIG_NSH_DNS is not set # CONFIG_NSH_NOMAC is not set + +# +# WAPI Configuration +# +CONFIG_NSH_WAPI_STAMODE=2 +CONFIG_NSH_WAPI_AUTHWPA=0x00000004 +CONFIG_NSH_WAPI_CIPHERMODE=0x00000008 +CONFIG_NSH_WAPI_ALG=3 +CONFIG_NSH_WAPI_SSID="myApSSID" +CONFIG_NSH_WAPI_PASSPHRASE="mySSIDpassphrase" CONFIG_NSH_MAX_ROUNDTRIP=20 # CONFIG_NSH_LOGIN is not set # CONFIG_NSH_CONSOLE_LOGIN is not set