S32K118EVB cleanup

This commit is contained in:
Jari van Ewijk 2021-09-14 17:44:41 +02:00 committed by Xiang Xiao
parent e8d7779ab1
commit 6cb29053a0
15 changed files with 471 additions and 163 deletions

View File

@ -20,16 +20,24 @@ Status
2019-08-17: The port is code complete. It compiles with no errors or
warnings but is untested. Still waiting for hardware.
2019-08-20: The very first image that I wrote to FLASH seems to
have "bricked" the board. The board is sensitive to (1) resetting
into a bad state and (2) incorrect flash configurations. It is
difficult to impossiblel to recover from these start-up errors.
2019-08-20: The very first image that I wrote to FLASH seems to have
"bricked" the board. The board is sensitive to (1) resetting into a bad
state and (2) incorrect flash configurations. It is difficult to
impossible to recover from these start-up errors.
2019-80-22: My S32K118EVB is still borked, but after some additional
changes, Fabio Balzano has verified that the NSH is functional on
that board.
2019-08-22: My S32K118EVB is still borked, but after some additional
changes, Fabio Balzano has verified that the NSH is functional on that
board.
TODO: Need calibrate the delay loop. The current value of
2019-10-19: The aforementioned fixes for the FLASH issues were converted
into a set of FLASH configuration options, with a proven default state.
2020-06-15: Added FlexCAN driver with SocketCAN support to the S32K1XX
arch. Might work on the S32K118EVB as well, but remains untested.
2020-06-16: Added Emulated EEPROM driver and initialization.
TODO: Need to calibrate the delay loop. The current value of
CONFIG_BOARD_LOOPSPERMSEC is a bogus value retained from a copy-paste
(see apps/examples/calib_udelay).
@ -38,10 +46,10 @@ Serial Console
By default, the serial console will be provided on the OpenSDA VCOM port:
OpenSDA UART TX PTB1(LPUART0_TX)
OpenSDA UART RX PTB0(LPUART0_RX)
OpenSDA UART RX PTB0 (LPUART0_RX)
OpenSDA UART TX PTB1 (LPUART0_TX)
USB drivers for the PEMIcro CDC Serial port are available here:
USB drivers for the PEmicro CDC Serial Port are available here:
http://www.pemicro.com/opensda/
LEDs and Buttons
@ -51,17 +59,21 @@ LEDs and Buttons
----
The S32K118EVB has one RGB LED:
RedLED PTD16 (FTM0 CH1)
GreenLED PTD15 (FTM0 CH0)
BlueLED PTE8 (FTM0 CH6)
RedLED PTD16 (FTM0 CH1)
GreenLED PTD15 (FTM0 CH0)
BlueLED PTE8 (FTM0 CH6)
An output of '1' illuminates the LED.
If CONFIG_ARCH_LEDS is not defined, then the user can control the LEDs in
any way. The following definitions are used to access individual RGB
components.
components (see s32k118evb.h):
The RGB components could, alternatively be controlled through PWM using
GPIO_LED_R
GPIO_LED_G
GPIO_LED_B
The RGB components could, alternatively, be controlled through PWM using
the common RGB LED driver.
If CONFIG_ARCH_LEDs is defined, then NuttX will control the LEDs on board
@ -80,7 +92,7 @@ LEDs and Buttons
LED_SIGNAL In a signal handler (no change)
LED_ASSERTION An assertion failed (no change)
LED_PANIC The system has crashed FLASH OFF OFF
LED_IDLE S32K118EVB in sleep mode (no change)
LED_IDLE S32K118 in sleep mode (no change)
==========================================+========+========+=========
Buttons
@ -93,7 +105,7 @@ LEDs and Buttons
OpenSDA Notes
=============
- USB drivers for the PEMIcro CDC Serial port are available here:
- USB drivers for the PEmicro CDC Serial Port are available here:
http://www.pemicro.com/opensda/
- The drag'n'drog interface expects files in .srec format.
@ -107,20 +119,20 @@ Configurations
Common Information
------------------
Each S32K118EVB configuration is maintained in a sub-directory and
can be selected as follow:
Each S32K118EVB configuration is maintained in a sub-directory and can be
selected as follows:
tools/configure.sh s32k118evb:<subdir>
Where <subdir> is one of the sub-directories listed in the next paragraph
Where <subdir> is one of the sub-directories listed in the next paragraph.
NOTES (common for all configurations):
1. This configuration uses the mconf-based configuration tool. To
change this configuration using that tool, you should:
1. This configuration uses the mconf-based configuration tool. To change
this configuration using that tool, you should:
a. Build and install the kconfig-mconf tool. See nuttx/README.txt
see additional README.txt files in the NuttX tools repository.
a. Build and install the kconfig-mconf tool. See nuttx/README.txt.
Also see additional README.txt files in the NuttX tools repository.
b. Execute 'make menuconfig' in nuttx/ in order to start the
reconfiguration process.
@ -129,7 +141,7 @@ Configurations
115,200 8N1. This corresponds to the OpenSDA VCOM port.
Configuration Sub-directories
-------------------------
-----------------------------
nsh:
---

View File

@ -45,13 +45,14 @@ CONFIG_PREALLOC_TIMERS=0
CONFIG_PTHREAD_STACK_DEFAULT=1536
CONFIG_RAM_SIZE=23552
CONFIG_RAM_START=0x1ffffc00
CONFIG_RAW_BINARY=y
CONFIG_RR_INTERVAL=200
CONFIG_S32K1XX_LPUART0=y
CONFIG_SCHED_WAITPID=y
CONFIG_SDCLONE_DISABLE=y
CONFIG_START_DAY=14
CONFIG_START_MONTH=8
CONFIG_START_YEAR=2019
CONFIG_START_DAY=6
CONFIG_START_MONTH=9
CONFIG_START_YEAR=2021
CONFIG_STDIO_DISABLE_BUFFERING=y
CONFIG_SYMTAB_ORDEREDBYNAME=y
CONFIG_SYSTEM_NSH=y

View File

@ -18,8 +18,8 @@
*
****************************************************************************/
#ifndef __BOARDS_ARM_S32K118EVB_INCLUDE_BOARD_H
#define __BOARDS_ARM_S32K118EVB_INCLUDE_BOARD_H
#ifndef __BOARDS_ARM_S32K1XX_S32K118EVB_INCLUDE_BOARD_H
#define __BOARDS_ARM_S32K1XX_S32K118EVB_INCLUDE_BOARD_H
/****************************************************************************
* Included Files
@ -27,30 +27,25 @@
#include <nuttx/config.h>
#ifndef __ASSEMBLY__
# include <stdint.h>
# include <stdbool.h>
#endif
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Clocking *****************************************************************/
/* The S32K118EVB is fitted with a 40MHz Crystal */
/* The S32K118EVB is fitted with a 40 MHz crystal */
#define BOARD_XTAL_FREQUENCY 40000000
#define BOARD_XTAL_FREQUENCY 40000000
/* The S32K118 will run at 48MHz */
/* The S32K118 will run at 48 MHz */
/* LED definitions **********************************************************/
/* The S32K118EVB has one RGB LED:
*
* RedLED PTD16 (FTM0 CH1)
* GreenLED PTD15 (FTM0 CH0)
* BlueLED PTE8 (FTM0 CH6)
* RedLED PTD16 (FTM0 CH1)
* GreenLED PTD15 (FTM0 CH0)
* BlueLED PTE8 (FTM0 CH6)
*
* If CONFIG_ARCH_LEDS is not defined, then the user can control the LEDs in
* any way. The following definitions are used to access individual RGB
@ -77,20 +72,20 @@
* the S32K118EVB. The following definitions describe how NuttX controls the
* LEDs:
*
* SYMBOL Meaning LED state
* RED GREEN BLUE
* ------------------- ---------------------------- -----------------
* SYMBOL Meaning LED state
* RED GREEN BLUE
* ---------------- ----------------------------- -------------------
*/
#define LED_STARTED 1 /* NuttX has been started OFF OFF OFF */
#define LED_HEAPALLOCATE 2 /* Heap has been allocated OFF OFF ON */
#define LED_IRQSENABLED 0 /* Interrupts enabled OFF OFF ON */
#define LED_STACKCREATED 3 /* Idle stack created OFF ON OFF */
#define LED_INIRQ 0 /* In an interrupt (no change) */
#define LED_SIGNAL 0 /* In a signal handler (no change) */
#define LED_ASSERTION 0 /* An assertion failed (no change) */
#define LED_PANIC 4 /* The system has crashed FLASH OFF OFF */
#undef LED_IDLE /* S32K118EVB in sleep mode (Not used) */
#define LED_STARTED 1 /* NuttX has been started OFF OFF OFF */
#define LED_HEAPALLOCATE 2 /* Heap has been allocated OFF OFF ON */
#define LED_IRQSENABLED 0 /* Interrupts enabled OFF OFF ON */
#define LED_STACKCREATED 3 /* Idle stack created OFF ON OFF */
#define LED_INIRQ 0 /* In an interrupt (No change) */
#define LED_SIGNAL 0 /* In a signal handler (No change) */
#define LED_ASSERTION 0 /* An assertion failed (No change) */
#define LED_PANIC 4 /* The system has crashed FLASH OFF OFF */
#undef LED_IDLE /* S32K118 is in sleep mode (Not used) */
/* Button definitions *******************************************************/
@ -100,22 +95,38 @@
* SW3 PTD5
*/
#define BUTTON_SW2 0
#define BUTTON_SW3 1
#define NUM_BUTTONS 2
#define BUTTON_SW2 0
#define BUTTON_SW3 1
#define NUM_BUTTONS 2
#define BUTTON_SW2_BIT (1 << BUTTON_SW2)
#define BUTTON_SW3_BIT (1 << BUTTON_SW3)
/* Alternate function pin selections ****************************************/
/* UART selections **********************************************************/
/* By default, the serial console will be provided on the OpenSDA VCOM port:
*
* OpenSDA UART TX PTB1(LPUART0_TX)
* OpenSDA UART RX PTB0(LPUART0_RX)
* OpenSDA UART RX PTB0 (LPUART0_RX)
* OpenSDA UART TX PTB1 (LPUART0_TX)
*/
#define PIN_LPUART0_RX PIN_LPUART0_RX_1 /* PTB0 */
#define PIN_LPUART0_TX PIN_LPUART0_TX_1 /* PTB1 */
#define PIN_LPUART0_RX PIN_LPUART0_RX_1 /* PTB0 */
#define PIN_LPUART0_TX PIN_LPUART0_TX_1 /* PTB1 */
#endif /* __BOARDS_ARM_S32K118EVB_INCLUDE_BOARD_H */
/* SPI selections ***********************************************************/
/* UJA1169TK/F SBC SPI (LPSPI0) */
#define PIN_LPSPI0_SCK PIN_LPSPI0_SOUT_2 /* PTB2 */
#define PIN_LPSPI0_MISO PIN_LPSPI0_SIN_2 /* PTB3 */
#define PIN_LPSPI0_MOSI PIN_LPSPI0_SOUT_1 /* PTB4 */
#define PIN_LPSPI0_PCS PIN_LPSPI0_PCS0_2 /* PTB5 */
/* CAN selections ***********************************************************/
/* UJA1169TK/F SBC CAN (CAN0) */
#define PIN_CAN0_RX PIN_CAN0_RX_3 /* PTE4 */
#define PIN_CAN0_TX PIN_CAN0_TX_3 /* PTE5 */
#endif /* __BOARDS_ARM_S32K1XX_S32K118EVB_INCLUDE_BOARD_H */

View File

@ -23,18 +23,26 @@ include $(TOPDIR)/Make.defs
CSRCS = s32k1xx_boot.c s32k1xx_bringup.c s32k1xx_clockconfig.c
CSRCS += s32k1xx_periphclocks.c
ifeq ($(CONFIG_ARCH_BUTTONS),y)
CSRCS += s32k1xx_buttons.c
endif
ifeq ($(CONFIG_ARCH_LEDS),y)
CSRCS += s32k1xx_autoleds.c
else
CSRCS += s32k1xx_userleds.c
endif
ifeq ($(CONFIG_ARCH_BUTTONS),y)
CSRCS += s32k1xx_buttons.c
endif
ifeq ($(CONFIG_BOARDCTL),y)
CSRCS += s32k1xx_appinit.c
endif
ifeq ($(CONFIG_S32K1XX_LPI2C),y)
CSRCS += s32k1xx_i2c.c
endif
ifeq ($(CONFIG_S32K1XX_LPSPI),y)
CSRCS += s32k1xx_spi.c
endif
include $(TOPDIR)/boards/Board.mk

View File

@ -32,6 +32,7 @@
#include "hardware/s32k1xx_pinmux.h"
#include "s32k1xx_periphclocks.h"
#include "s32k1xx_pin.h"
/****************************************************************************
* Pre-processor Definitions
@ -43,16 +44,16 @@
/* LEDs. The S32K118EVB has one RGB LED:
*
* RedLED PTD16 (FTM0CH1)
* GreenLED PTD15 (FTM0CH0)
* BlueLED PTE8 (FTM0CH6)
* RedLED PTD16 (FTM0 CH1)
* GreenLED PTD15 (FTM0 CH0)
* BlueLED PTE8 (FTM0 CH6)
*
* An output of '1' illuminates the LED.
*/
#define GPIO_LED_R (PIN_PTD16 | GPIO_LOWDRIVE | GPIO_OUTPUT_ZERO)
#define GPIO_LED_G (PIN_PTD15 | GPIO_LOWDRIVE | GPIO_OUTPUT_ZERO)
#define GPIO_LED_B (PIN_PTE8 | GPIO_LOWDRIVE | GPIO_OUTPUT_ZERO)
#define GPIO_LED_R (PIN_PTD16 | GPIO_LOWDRIVE | GPIO_OUTPUT_ZERO)
#define GPIO_LED_G (PIN_PTD15 | GPIO_LOWDRIVE | GPIO_OUTPUT_ZERO)
#define GPIO_LED_B (PIN_PTE8 | GPIO_LOWDRIVE | GPIO_OUTPUT_ZERO)
/* Buttons. The S32K118EVB supports two buttons:
*
@ -60,19 +61,13 @@
* SW3 PTD5
*/
#define GPIO_SW2 (PIN_PTD3 | PIN_INT_BOTH)
#define GPIO_SW3 (PIN_PTD5 | PIN_INT_BOTH)
/* SPI chip selects */
#define GPIO_SW2 (PIN_PTD3 | PIN_INT_BOTH)
#define GPIO_SW3 (PIN_PTD5 | PIN_INT_BOTH)
/* Count of peripheral clock user configurations */
#define NUM_OF_PERIPHERAL_CLOCKS_0 11
/****************************************************************************
* Public Types
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
@ -104,17 +99,25 @@ extern const struct peripheral_clock_config_s g_peripheral_clockconfig0[];
int s32k1xx_bringup(void);
/****************************************************************************
* Name: s32k1xx_spidev_initialize
* Name: s32k1xx_i2cdev_initialize
*
* Description:
* Called to configure SPI chip select GPIO pins for the S32K118EVB
* board.
* Initialize I2C driver and register /dev/i2cN devices.
*
****************************************************************************/
#ifdef CONFIG_S32K1XX_SPI
void s32k1xx_spidev_initialize(void);
#endif
int s32k1xx_i2cdev_initialize(void);
/****************************************************************************
* Name: s32k1xx_spidev_initialize
*
* Description:
* Configure chip select pins, initialize the SPI driver and register
* /dev/spiN devices.
*
****************************************************************************/
int s32k1xx_spidev_initialize(void);
#endif /* __ASSEMBLY__ */
#endif /* __BOARDS_ARM_S32K1XX_S32K118EVB_SRC_S32K118EVB_H */

View File

@ -23,9 +23,10 @@
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/board.h>
#include <stdint.h>
#include "s32k118evb.h"
/****************************************************************************
@ -50,14 +51,14 @@
*
* Input Parameters:
* arg - The boardctl() argument is passed to the board_app_initialize()
* implementation without modification. The argument has no
* meaning to NuttX; the meaning of the argument is a contract
* between the board-specific initialization logic and the
* matching application logic. The value could be such things as a
* mode enumeration value, a set of DIP switch switch settings, a
* pointer to configuration data read from a file or serial FLASH,
* or whatever you would like to do with it. Every implementation
* should accept zero/NULL as a default configuration.
* implementation without modification. The argument has no meaning
* to NuttX; the meaning of the argument is a contract between the
* board-specific initialization logic and the matching application
* logic. The value could be such things as a mode enumeration
* value, a set of DIP switch settings, a pointer to configuration
* data read from a file or serial FLASH, or whatever you would like
* to do with it. Every implementation should accept zero/NULL as a
* default configuration.
*
* Returned Value:
* Zero (OK) is returned on success; a negated errno value is returned on

View File

@ -20,28 +20,28 @@
/* The S32K118EVB has one RGB LED:
*
* RedLED PTD16 (FTM0CH1)
* GreenLED PTD15 (FTM0CH0)
* BlueLED PTE8 (FTM0CH6)
* RedLED PTD16 (FTM0 CH1)
* GreenLED PTD15 (FTM0 CH0)
* BlueLED PTE8 (FTM0 CH6)
*
* An output of '1' illuminates the LED.
*
* If CONFIG_ARCH_LEDs is defined, then NuttX will control the LED on board
* the Freedom K66F. The following definitions describe how NuttX controls
* the LEDs:
* the S32K118EVB. The following definitions describe how NuttX controls the
* LEDs:
*
* SYMBOL Meaning LED state
* RED GREEN BLUE
* ------------------- ----------------------- -----------------
* LED_STARTED NuttX has been started OFF OFF OFF
* LED_HEAPALLOCATE Heap has been allocated OFF OFF ON
* LED_IRQSENABLED Interrupts enabled OFF OFF ON
* LED_STACKCREATED Idle stack created OFF ON OFF
* LED_INIRQ In an interrupt (no change)
* LED_SIGNAL In a signal handler (no change)
* LED_ASSERTION An assertion failed (no change)
* LED_PANIC The system has crashed FLASH OFF OFF
* LED_IDLE K66 is in sleep mode (Optional, not used)
* SYMBOL Meaning LED state
* RED GREEN BLUE
* ---------------- ------------------------ --------------------
* LED_STARTED NuttX has been started OFF OFF OFF
* LED_HEAPALLOCATE Heap has been allocated OFF OFF ON
* LED_IRQSENABLED Interrupts enabled OFF OFF ON
* LED_STACKCREATED Idle stack created OFF ON OFF
* LED_INIRQ In an interrupt (No change)
* LED_SIGNAL In a signal handler (No change)
* LED_ASSERTION An assertion failed (No change)
* LED_PANIC The system has crashed FLASH OFF OFF
* LED_IDLE S32K118 is in sleep mode (Optional, not used)
*/
/****************************************************************************
@ -52,18 +52,12 @@
#include <stdint.h>
#include <stdbool.h>
#include <debug.h>
#include <nuttx/board.h>
#include <arch/board/board.h>
#include "arm_arch.h"
#include "arm_internal.h"
#include "s32k1xx_pin.h"
#include "s32k118evb.h"
#include <arch/board/board.h>
#include "s32k118evb.h"
#ifdef CONFIG_ARCH_LEDS
@ -73,11 +67,11 @@
/* Summary of all possible settings */
#define LED_NOCHANGE 0 /* LED_IRQSENABLED, LED_INIRQ, LED_SIGNAL, LED_ASSERTION */
#define LED_OFF_OFF_OFF 1 /* LED_STARTED */
#define LED_OFF_OFF_ON 2 /* LED_HEAPALLOCATE */
#define LED_OFF_ON_OFF 3 /* LED_STACKCREATED */
#define LED_ON_OFF_OFF 4 /* LED_PANIC */
#define LED_NOCHANGE 0 /* LED_IRQSENABLED, LED_INIRQ, LED_SIGNAL, LED_ASSERTION */
#define LED_OFF_OFF_OFF 1 /* LED_STARTED */
#define LED_OFF_OFF_ON 2 /* LED_HEAPALLOCATE */
#define LED_OFF_ON_OFF 3 /* LED_STACKCREATED */
#define LED_ON_OFF_OFF 4 /* LED_PANIC */
/****************************************************************************
* Public Functions

View File

@ -23,9 +23,6 @@
****************************************************************************/
#include <nuttx/config.h>
#include <debug.h>
#include <nuttx/board.h>
#include "s32k118evb.h"
@ -47,16 +44,8 @@
void s32k1xx_board_initialize(void)
{
#ifdef CONFIG_S32K1XX_SPI
/* Configure SPI chip selects if 1) SPI is not disabled, and 2) the weak
* function s32k1xx_spidev_initialize() has been brought into the link.
*/
s32k1xx_spidev_initialize();
#endif
#ifdef CONFIG_ARCH_LEDS
/* Configure on-board LEDs if LED support has been selected. */
/* Configure on-board LEDs if LED support has been selected */
board_autoled_initialize();
#endif

View File

@ -25,10 +25,9 @@
#include <nuttx/config.h>
#include <sys/types.h>
#include <stdint.h>
#include <syslog.h>
#include <nuttx/fs/fs.h>
#ifdef CONFIG_INPUT_BUTTONS
# include <nuttx/input/buttons.h>
#endif
@ -37,6 +36,14 @@
# include <nuttx/leds/userled.h>
#endif
#ifdef CONFIG_FS_PROCFS
# include <nuttx/fs/fs.h>
#endif
#ifdef CONFIG_S32K1XX_PROGMEM
# include <nuttx/mtd/mtd.h>
#endif
#ifdef CONFIG_S32K1XX_EEEPROM
# include "s32k1xx_eeeprom.h"
#endif
@ -97,19 +104,44 @@ int s32k1xx_bringup(void)
#ifdef CONFIG_S32K1XX_PROGMEM
FAR struct mtd_dev_s *mtd;
int minor = 0;
mtd = progmem_initialize();
if (!mtd)
if (mtd == NULL)
{
syslog(LOG_ERR, "ERROR: progmem_initialize failed\n");
syslog(LOG_ERR, "ERROR: progmem_initialize() failed\n");
}
#endif
#ifdef CONFIG_S32K1XX_EEEPROM
/* Register EEEPROM block device */
s32k1xx_eeeprom_register(0, 2048);
ret = s32k1xx_eeeprom_register(0, 4096);
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: s32k1xx_eeeprom_register() failed\n");
}
#endif
#ifdef CONFIG_S32K1XX_LPI2C
/* Initialize I2C driver */
ret = s32k1xx_i2cdev_initialize();
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: s32k1xx_i2cdev_initialize() failed: %d\n",
ret);
}
#endif
#ifdef CONFIG_S32K1XX_LPSPI
/* Initialize SPI driver */
ret = s32k1xx_spidev_initialize();
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: s32k1xx_spidev_initialize() failed: %d\n",
ret);
}
#endif
return ret;

View File

@ -33,14 +33,14 @@
#include <stdint.h>
#include <errno.h>
#include <nuttx/arch.h>
#include <nuttx/board.h>
#include "s32k1xx_pin.h"
#include "s32k118evb.h"
#include <arch/board/board.h>
#include "s32k118evb.h"
#ifdef CONFIG_ARCH_BUTTONS
/****************************************************************************
@ -60,10 +60,11 @@
uint32_t board_button_initialize(void)
{
/* Configure the GPIO pins as interrupting inputs. */
/* Configure the GPIO pins as interrupting inputs */
s32k1xx_pinconfig(GPIO_SW2);
s32k1xx_pinconfig(GPIO_SW3);
return NUM_BUTTONS;
}
@ -88,6 +89,7 @@ uint32_t board_buttons(void)
return ret;
}
#ifdef CONFIG_ARCH_IRQBUTTONS
/****************************************************************************
* Button support.
*
@ -103,20 +105,19 @@ uint32_t board_buttons(void)
* BUTTON_*_BIT definitions in board.h for the meaning of each bit.
*
* board_button_irq() may be called to register an interrupt handler that
* will be called when a button is depressed or released. The ID value is
* a button enumeration value that uniquely identifies a button resource.
* will be called when a button is pressed or released. The ID value is a
* button enumeration value that uniquely identifies a button resource.
* See the BUTTON_* definitions in board.h for the meaning of enumeration
* value.
*
****************************************************************************/
#ifdef CONFIG_ARCH_IRQBUTTONS
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
uint32_t pinset;
int ret;
/* Map the button id to the GPIO bit set. */
/* Map the button id to the GPIO bit set */
if (id == BUTTON_SW2)
{
@ -147,5 +148,5 @@ int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
return ret;
}
#endif
#endif /* CONFIG_ARCH_IRQBUTTONS */
#endif /* CONFIG_ARCH_BUTTONS */

View File

@ -58,11 +58,9 @@
#include <nuttx/config.h>
#include <stdint.h>
#include <stdbool.h>
#include "s32k1xx_clockconfig.h"
#include "s32k1xx_start.h"
#include "s32k118evb.h"
/****************************************************************************

View File

@ -0,0 +1,81 @@
/****************************************************************************
* boards/arm/s32k1xx/s32k118evb/src/s32k1xx_i2c.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/compiler.h>
#include <sys/types.h>
#include <stdint.h>
#include <errno.h>
#include <debug.h>
#include <nuttx/i2c/i2c_master.h>
#include "s32k1xx_lpi2c.h"
#include "s32k118evb.h"
#ifdef CONFIG_S32K1XX_LPI2C
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: s32k1xx_i2cdev_initialize
*
* Description:
* Initialize I2C driver and register /dev/i2cN devices.
*
****************************************************************************/
int weak_function s32k1xx_i2cdev_initialize(void)
{
int ret = OK;
#if defined(CONFIG_S32K1XX_LPI2C0) && defined(CONFIG_I2C_DRIVER)
/* LPI2C0 *****************************************************************/
/* Initialize the I2C driver for LPI2C0 */
struct i2c_master_s *lpi2c0 = s32k1xx_i2cbus_initialize(0);
if (lpi2c0 == NULL)
{
i2cerr("ERROR: FAILED to initialize LPI2C0\n");
return -ENODEV;
}
ret = i2c_register(lpi2c0, 0);
if (ret < 0)
{
i2cerr("ERROR: FAILED to register LPI2C0 driver\n");
s32k1xx_i2cbus_uninitialize(lpi2c0);
return ret;
}
#endif /* CONFIG_S32K1XX_LPI2C0 && CONFIG_I2C_DRIVER */
return ret;
}
#endif /* CONFIG_S32K1XX_LPSPI */

View File

@ -58,7 +58,9 @@
#include <nuttx/config.h>
#include "s32k11x/s32k11x_clocknames.h"
#include "s32k1xx_periphclocks.h"
#include "s32k118evb.h"
/****************************************************************************
@ -73,7 +75,7 @@ const struct peripheral_clock_config_s g_peripheral_clockconfig0[] =
{
{
.clkname = FLEXCAN0_CLK,
#ifdef CONFIG_S32K1XX_FLEXCAN
#ifdef CONFIG_S32K1XX_FLEXCAN0
.clkgate = true,
#else
.clkgate = false,

View File

@ -0,0 +1,179 @@
/****************************************************************************
* boards/arm/s32k1xx/s32k118evb/src/s32k1xx_spi.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/compiler.h>
#include <sys/types.h>
#include <stdint.h>
#include <stdbool.h>
#include <errno.h>
#include <debug.h>
#include <nuttx/spi/spi.h>
#include <nuttx/spi/spi_transfer.h>
#include "s32k1xx_pin.h"
#include "s32k1xx_lpspi.h"
#include <arch/board/board.h>
#include "s32k118evb.h"
#ifdef CONFIG_S32K1XX_LPSPI
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: s32k1xx_spidev_initialize
*
* Description:
* Configure chip select pins, initialize the SPI driver and register
* /dev/spiN devices.
*
****************************************************************************/
int weak_function s32k1xx_spidev_initialize(void)
{
int ret = OK;
#ifdef CONFIG_S32K1XX_LPSPI0
/* LPSPI0 *****************************************************************/
/* Configure LPSPI0 peripheral chip select */
s32k1xx_pinconfig(PIN_LPSPI0_PCS);
# ifdef CONFIG_SPI_DRIVER
/* Initialize the SPI driver for LPSPI0 */
struct spi_dev_s *g_lpspi0 = s32k1xx_lpspibus_initialize(0);
if (g_lpspi0 == NULL)
{
spierr("ERROR: FAILED to initialize LPSPI0\n");
return -ENODEV;
}
ret = spi_register(g_lpspi0, 0);
if (ret < 0)
{
spierr("ERROR: FAILED to register LPSPI0 driver\n");
return ret;
}
# endif /* CONFIG_SPI_DRIVER */
#endif /* CONFIG_S32K1XX_LPSPI0 */
#ifdef CONFIG_S32K1XX_LPSPI1
/* LPSPI1 *****************************************************************/
/* Configure LPSPI1 peripheral chip select */
s32k1xx_pinconfig(PIN_LPSPI1_PCS);
# ifdef CONFIG_SPI_DRIVER
/* Initialize the SPI driver for LPSPI1 */
struct spi_dev_s *g_lpspi1 = s32k1xx_lpspibus_initialize(1);
if (g_lpspi1 == NULL)
{
spierr("ERROR: FAILED to initialize LPSPI1\n");
return -ENODEV;
}
ret = spi_register(g_lpspi1, 1);
if (ret < 0)
{
spierr("ERROR: FAILED to register LPSPI1 driver\n");
return ret;
}
# endif /* CONFIG_SPI_DRIVER */
#endif /* CONFIG_S32K1XX_LPSPI1 */
return ret;
}
/****************************************************************************
* Name: s32k1xx_lpspiNselect and s32k1xx_lpspiNstatus
*
* Description:
* The external functions, s32k1xx_lpspiNselect and s32k1xx_lpspiNstatus
* must be provided by board-specific logic. They are implementations of
* the select and status methods of the SPI interface defined by struct
* spi_ops_s (see include/nuttx/spi/spi.h). All other methods (including
* s32k1xx_lpspibus_initialize()) are provided by common logic. To use
* this common SPI logic on your board:
*
* 1. Provide logic in s32k1xx_boardinitialize() to configure SPI chip
* select pins.
* 2. Provide s32k1xx_lpspiNselect() and s32k1xx_lpspiNstatus() functions
* in your board-specific logic. These functions will perform chip
* selection and status operations using GPIOs in the way your board is
* configured.
* 3. Add a calls to s32k1xx_lpspibus_initialize() in your low level
* application initialization logic.
* 4. The handle returned by s32k1xx_lpspibus_initialize() may then be used
* to bind the SPI driver to higher level logic (e.g., calling
* mmcsd_spislotinitialize(), for example, will bind the SPI driver to
* the SPI MMC/SD driver).
*
****************************************************************************/
#ifdef CONFIG_S32K1XX_LPSPI0
/* LPSPI0 *******************************************************************/
void s32k1xx_lpspi0select(FAR struct spi_dev_s *dev, uint32_t devid,
bool selected)
{
spiinfo("devid: %" PRId32 ", CS: %s\n", devid,
selected ? "assert" : "de-assert");
s32k1xx_gpiowrite(PIN_LPSPI0_PCS, !selected);
}
uint8_t s32k1xx_lpspi0status(FAR struct spi_dev_s *dev, uint32_t devid)
{
return 0;
}
#endif /* CONFIG_S32K1XX_LPSPI0 */
#ifdef CONFIG_S32K1XX_LPSPI1
/* LPSPI1 *******************************************************************/
void s32k1xx_lpspi1select(FAR struct spi_dev_s *dev, uint32_t devid,
bool selected)
{
spiinfo("devid: %" PRId32 ", CS: %s\n", devid,
selected ? "assert" : "de-assert");
s32k1xx_gpiowrite(PIN_LPSPI1_PCS, !selected);
}
uint8_t s32k1xx_lpspi1status(FAR struct spi_dev_s *dev, uint32_t devid)
{
return 0;
}
#endif /* CONFIG_S32K1XX_LPSPI1 */
#endif /* CONFIG_S32K1XX_LPSPI */

View File

@ -26,18 +26,15 @@
#include <stdint.h>
#include <stdbool.h>
#include <debug.h>
#include <nuttx/board.h>
#include "arm_arch.h"
#include "arm_internal.h"
#include "s32k1xx_pin.h"
#include "s32k118evb.h"
#include <arch/board/board.h>
#include "s32k118evb.h"
#ifndef CONFIG_ARCH_LEDS
/****************************************************************************
@ -55,6 +52,7 @@ uint32_t board_userled_initialize(void)
s32k1xx_pinconfig(GPIO_LED_R);
s32k1xx_pinconfig(GPIO_LED_G);
s32k1xx_pinconfig(GPIO_LED_B);
return BOARD_NLEDS;
}
@ -83,7 +81,7 @@ void board_userled(int led, bool ledon)
return;
}
s32k1xx_gpiowrite(ledcfg, ledon); /* High illuminates */
s32k1xx_gpiowrite(ledcfg, ledon);
}
/****************************************************************************
@ -92,8 +90,6 @@ void board_userled(int led, bool ledon)
void board_userled_all(uint32_t ledset)
{
/* Low illuminates */
s32k1xx_gpiowrite(GPIO_LED_R, (ledset & BOARD_LED_R_BIT) != 0);
s32k1xx_gpiowrite(GPIO_LED_G, (ledset & BOARD_LED_G_BIT) != 0);
s32k1xx_gpiowrite(GPIO_LED_B, (ledset & BOARD_LED_B_BIT) != 0);