Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions os/arch/arm/src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ else
CFLAGS += -I$(ARCH_SRCDIR)/common
CFLAGS += -I$(ARCH_SRCDIR)/$(ARCH_SUBDIR)
CFLAGS += -I$(TOPDIR)/kernel
CFLAGS += -I$(TOPDIR)/board/common
endif
endif

Expand Down
2 changes: 1 addition & 1 deletion os/arch/arm/src/amebasmart/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ endif

ARCH_SRCDIR = $(TOPDIR)/arch/$(CONFIG_ARCH)/src/

CFLAGS += -I$(TOPDIR)/board/common
CFLAGS += -I$(TOPDIR)/board/$(CONFIG_ARCH_BOARD)/include
CFLAGS += -I$(TOPDIR)/board/$(CONFIG_ARCH_BOARD)/src/component/soc/amebad2/fwlib/include
CFLAGS += -I$(TOPDIR)/board/$(CONFIG_ARCH_BOARD)/src/component/soc/amebad2/cmsis
Expand Down Expand Up @@ -309,4 +310,3 @@ else
#EXTRA_LIBS += $(TOPDIR)/board/
endif
endif

29 changes: 18 additions & 11 deletions os/arch/arm/src/amebasmart/amebasmart_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#include <arch/board/board.h>

#include "PinNames.h"
#include "board_pins.h"
#include <board_pins.h>

#include "up_arch.h"
#include "ameba_i2c.h"
Expand Down Expand Up @@ -172,7 +172,7 @@ typedef struct i2c_m i2c_t;

struct amebasmart_i2c_priv_s {
const struct i2c_ops_s *ops; /* Standard I2C operations */
const struct amebasmart_i2c_config_s *config; /* Port configuration */
struct amebasmart_i2c_config_s *config; /* Port configuration */
int refs; /* Referernce count */
sem_t sem_excl; /* Mutual exclusion semaphore */
#ifndef CONFIG_I2C_POLLED
Expand Down Expand Up @@ -302,8 +302,6 @@ static const struct amebasmart_i2c_config_s amebasmart_i2c0_config = {
//.busy_idle = CONFIG_I2C0_BUSYIDLE,
//.filtscl = CONFIG_I2C0_FILTSCL,
//.filtsda = CONFIG_I2C0_FILTSDA,
.scl_pin = I2C0_SCL,
.sda_pin = I2C0_SDA,
#ifndef CONFIG_I2C_SLAVE
.mode = AMEBASMART_I2C_MASTER,
#else
Expand Down Expand Up @@ -334,8 +332,6 @@ static const struct amebasmart_i2c_config_s amebasmart_i2c1_config = {
//.busy_idle = CONFIG_I2C1_BUSYIDLE,
//.filtscl = CONFIG_I2C1_FILTSCL,
//.filtsda = CONFIG_I2C1_FILTSDA,
.scl_pin = I2C1_SCL,
.sda_pin = I2C1_SDA,
#ifndef CONFIG_I2C_SLAVE
.mode = AMEBASMART_I2C_MASTER,
#else
Expand Down Expand Up @@ -366,8 +362,6 @@ static const struct amebasmart_i2c_config_s amebasmart_i2c2_config = {
//.busy_idle = CONFIG_I2C2_BUSYIDLE,
//.filtscl = CONFIG_I2C2_FILTSCL,
//.filtsda = CONFIG_I2C2_FILTSDA,
.scl_pin = I2C2_SCL,
.sda_pin = I2C2_SDA,
#ifndef CONFIG_I2C_SLAVE
.mode = AMEBASMART_I2C_MASTER,
#else
Expand Down Expand Up @@ -1150,6 +1144,9 @@ static int amebasmart_i2c_transfer(FAR struct i2c_dev_s *dev, FAR struct i2c_msg
*
************************************************************************************/

/* Global I2C initialization completion flags */
static volatile bool g_i2c_board_init_complete = false; /* Board I2C initialization complete */

FAR struct i2c_dev_s *up_i2cinitialize(int port)
{
struct amebasmart_i2c_priv_s *priv = NULL;
Expand All @@ -1159,16 +1156,25 @@ FAR struct i2c_dev_s *up_i2cinitialize(int port)
#ifdef CONFIG_AMEBASMART_I2C0
if (port == 0) {
priv = (struct amebasmart_i2c_priv_s *)&amebasmart_i2c0_priv;
lldbg("\n");
priv->config->scl_pin = I2C_PIN(I2C0, I2C_SCL);
priv->config->sda_pin = I2C_PIN(I2C0, I2C_SDA);
} else
#endif
#ifdef CONFIG_AMEBASMART_I2C1
if (port == 1) {
priv = (struct amebasmart_i2c_priv_s *)&amebasmart_i2c1_priv;

priv->config->scl_pin = I2C_PIN(I2C1, I2C_SCL);
priv->config->sda_pin = I2C_PIN(I2C1, I2C_SDA);
} else
#endif
#ifdef CONFIG_AMEBASMART_I2C2
if (port == 2) {
priv = (struct amebasmart_i2c_priv_s *)&amebasmart_i2c2_priv;

priv->config->scl_pin = I2C_PIN(I2C2, I2C_SCL);
priv->config->sda_pin = I2C_PIN(I2C2, I2C_SDA);
} else
#endif
{
Expand All @@ -1180,9 +1186,10 @@ FAR struct i2c_dev_s *up_i2cinitialize(int port)
if (priv->i2c_object != NULL) {
return (struct i2c_dev_s *)priv;
}
/* Initialize private data for the first time, increment reference count,
* power-up hardware and configure GPIOs.
*/

/* Initialize private data for the first time, increment reference count,
* power-up hardware and configure GPIOs.
*/
flags = enter_critical_section();

if ((volatile int)priv->refs++ == 0) {
Expand Down
28 changes: 15 additions & 13 deletions os/arch/arm/src/amebasmart/amebasmart_i2s.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@

#include "PinNames.h"
#include "i2s_api.h"
#include "board_pins.h"
#include <board_pins.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
Expand Down Expand Up @@ -216,12 +216,7 @@ struct amebasmart_i2s_s {
};
#ifdef CONFIG_AMEBASMART_I2S2
/* I2S device structures */
static const struct amebasmart_i2s_config_s amebasmart_i2s2_config = {
.i2s_mclk_pin = I2S2_MCLK,
.i2s_sclk_pin = I2S2_SCLK,
.i2s_ws_pin = I2S2_WS,
.i2s_sd_tx_pin = I2S2_SD_TX,
.i2s_sd_rx_pin = I2S2_SD_RX,
static struct amebasmart_i2s_config_s amebasmart_i2s2_config = {

.i2s_idx = I2S_NUM_2,
.rxenab = 0,
Expand All @@ -230,12 +225,7 @@ static const struct amebasmart_i2s_config_s amebasmart_i2s2_config = {
#endif

#ifdef CONFIG_AMEBASMART_I2S3
static const struct amebasmart_i2s_config_s amebasmart_i2s3_config = {
.i2s_mclk_pin = I2S3_MCLK,
.i2s_sclk_pin = I2S3_SCLK,
.i2s_ws_pin = I2S3_WS,
.i2s_sd_tx_pin = I2S3_SD_TX,
.i2s_sd_rx_pin = I2S3_SD_RX,
static struct amebasmart_i2s_config_s amebasmart_i2s3_config = {

.i2s_idx = I2S_NUM_3,
.rxenab = 1,
Expand Down Expand Up @@ -1811,11 +1801,23 @@ struct i2s_dev_s *amebasmart_i2s_initialize(uint16_t port)
#ifdef CONFIG_AMEBASMART_I2S2
if (port == I2S_NUM_2) {
hw_config_s = (struct amebasmart_i2s_config_s *)&amebasmart_i2s2_config;

hw_config_s->i2s_mclk_pin = I2S_PIN(I2S2, I2S_MCLK);
hw_config_s->i2s_sclk_pin = I2S_PIN(I2S2, I2S_SCLK);
hw_config_s->i2s_ws_pin = I2S_PIN(I2S2, I2S_WS);
hw_config_s->i2s_sd_tx_pin = I2S_PIN(I2S2, I2S_SD_TX);
hw_config_s->i2s_sd_rx_pin = I2S_PIN(I2S2, I2S_SD_RX);
} else
#endif
#ifdef CONFIG_AMEBASMART_I2S3
if (port == I2S_NUM_3) {
hw_config_s = (struct amebasmart_i2s_config_s *)&amebasmart_i2s3_config;

hw_config_s->i2s_mclk_pin = I2S_PIN(I2S3, I2S_MCLK);
hw_config_s->i2s_sclk_pin = I2S_PIN(I2S3, I2S_SCLK);
hw_config_s->i2s_ws_pin = I2S_PIN(I2S3, I2S_WS);
hw_config_s->i2s_sd_tx_pin = I2S_PIN(I2S3, I2S_SD_TX);
hw_config_s->i2s_sd_rx_pin = I2S_PIN(I2S3, I2S_SD_RX);
} else
#endif
{
Expand Down
59 changes: 43 additions & 16 deletions os/arch/arm/src/amebasmart/amebasmart_serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@

#include "serial_api.h"
#include "PinNames.h"
#include "board_pins.h"
#include <board_pins.h>
#include "objects.h"
#include "ameba_uart.h"
#include "tinyara/kmalloc.h"
Expand Down Expand Up @@ -234,6 +234,8 @@ struct rtl8730e_up_dev_s {
#ifdef CONFIG_SERIAL_OFLOWCONTROL
uint8_t oflow:1; /* output flow control (CTS) enabled */
#endif
uint8_t uart_type:3; /* identifies the uart type */

uint8_t tx_level;
};

Expand Down Expand Up @@ -348,11 +350,10 @@ static struct rtl8730e_up_dev_s g_uart0priv = {
#endif
.baud = CONFIG_UART0_BAUD,
.irq = RTL8730E_UART0_IRQ,
.tx = UART0_TX,
.rx = UART0_RX,
.FlowControl = FlowControlNone,
.txint_enable = false,
.rxint_enable = false,
.uart_type = 0,
};

static uart_dev_t g_uart0port = {
Expand Down Expand Up @@ -382,11 +383,10 @@ static struct rtl8730e_up_dev_s g_uart1priv = {
#endif
.baud = CONFIG_UART1_BAUD,
.irq = RTL8730E_UART1_IRQ,
.tx = UART1_TX,
.rx = UART1_RX,
.FlowControl = FlowControlNone,
.txint_enable = false,
.rxint_enable = false,
.uart_type = 1,
};

static uart_dev_t g_uart1port = {
Expand Down Expand Up @@ -416,13 +416,10 @@ static struct rtl8730e_up_dev_s g_uart2priv = {
#endif
.baud = CONFIG_UART2_BAUD,
.irq = RTL8730E_UART2_IRQ,
.tx = UART2_TX,
.rx = UART2_RX,
.rts = UART2_RTS,
.cts = UART2_CTS,
.FlowControl = FlowControlNone,
.txint_enable = false,
.rxint_enable = false,
.uart_type = 2,
};

static uart_dev_t g_uart2port = {
Expand Down Expand Up @@ -484,11 +481,10 @@ static struct rtl8730e_up_dev_s g_uart4priv = {
#endif
.baud = CONFIG_UART4_BAUD,
.irq = RTL8730E_UART_LOG_IRQ,
.tx = UART4_TX,
.rx = UART4_RX,
.FlowControl = FlowControlNone,
.txint_enable = false,
.rxint_enable = false,
.uart_type = 4,
};

static uart_dev_t g_uart4port = {
Expand Down Expand Up @@ -830,6 +826,15 @@ static int rtl8730e_up_setup(struct uart_dev_s *dev)
{
struct rtl8730e_up_dev_s *priv = (struct rtl8730e_up_dev_s *)dev->priv;
DEBUGASSERT(priv);

#ifdef CONFIG_RTL8730E_UART4
if (priv->uart_type == 4) {
priv->tx = UART_PIN(UART4, UART_TX);
priv->rx = UART_PIN(UART4, UART_RX);
}
#endif


DEBUGASSERT(!sdrv[uart_index_get(priv->tx)]);
sdrv[uart_index_get(priv->tx)] = (serial_t *)kmm_malloc(sizeof(serial_t));
DEBUGASSERT(sdrv[uart_index_get(priv->tx)]);
Expand Down Expand Up @@ -868,8 +873,32 @@ static int rtl8730e_up_setup_pin(struct uart_dev_s *dev)
struct rtl8730e_up_dev_s *priv = (struct rtl8730e_up_dev_s *)dev->priv;
DEBUGASSERT(priv);

serial_pin_init(priv->tx, priv->rx);
return OK;
#ifdef CONFIG_RTL8730E_UART0
if (priv->uart_type == 0) {
priv->tx = UART_PIN(UART0, UART_TX);
priv->rx = UART_PIN(UART0, UART_RX);
}
#endif

#ifdef CONFIG_RTL8730E_UART1
if (priv->uart_type == 1) {
#if defined(CONFIG_RTL8730E_BOARD_AIL) || defined(CONFIG_RTL8730E_BOARD_AILP) || defined(CONFIG_RTL8730E_BOARD_AILPW) || defined(CONFIG_RTL8730E_BOARD_AID)
priv->tx = UART_PIN(UART1, UART_TX);
priv->rx = UART_PIN(UART1, UART_RX);
#endif
}
#endif

#ifdef CONFIG_RTL8730E_UART2
if (priv->uart_type == 2) {
priv->tx = UART_PIN(UART2, UART_TX);
priv->rx = UART_PIN(UART2, UART_RX);
priv->cts = UART_PIN(UART2, UART_CTS);
priv->rts = UART_PIN(UART2, UART_RTS);
}
#endif
serial_pin_init(priv->tx, priv->rx);
return OK;
}

/****************************************************************************
Expand Down Expand Up @@ -1244,7 +1273,6 @@ void up_serialinit(void)
/* Register the console */
uart_register("/dev/console", &CONSOLE_DEV);
#endif

/* Register all UARTs */
#ifdef TTYS0_DEV
/* Default LOGUART(UART4) is already running and could not be reinit or stopped */
Expand All @@ -1268,6 +1296,7 @@ void up_serialinit(void)
pmu_register_sleep_callback(PMU_LOGUART_DEVICE, (PSM_HOOK_FUN)rtk_loguart_suspend, NULL, (PSM_HOOK_FUN)rtk_loguart_resume, NULL);
pmu_register_sleep_callback(PMU_UART1_DEVICE, (PSM_HOOK_FUN)rtk_uart_suspend, NULL, (PSM_HOOK_FUN)rtk_uart_resume, NULL);
#endif

}

/****************************************************************************
Expand Down Expand Up @@ -1426,5 +1455,3 @@ int up_getc(void)
return ch;
}
#endif /* USE_SERIALDRIVER */


31 changes: 16 additions & 15 deletions os/arch/arm/src/amebasmart/amebasmart_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

#include "chip.h"

#include "board_pins.h"
#include <board_pins.h>
#include "amebasmart_spi.h"
#include "PinNames.h"
#include "spi_api.h"
Expand Down Expand Up @@ -235,13 +235,6 @@ static struct amebasmart_spidev_s g_spi0dev = {
.spi_object = {0},
.refs = 0,
.spi_idx = MBED_SPI0,
.spi_mosi = SPI0_MOSI,
.spi_miso = SPI0_MISO,
.spi_sclk = SPI0_SCLK,
.spi_cs0 = SPI0_CS0,
#if defined(CONFIG_SPI_CS) && defined(CONFIG_AMEBASMART_SPI0_CS)
.spi_cs1 = SPI0_CS1,
#endif
.nbits = 8,
.mode = SPIDEV_MODE0,
.role = AMEBASMART_SPI_MASTER,
Expand Down Expand Up @@ -294,13 +287,6 @@ static struct amebasmart_spidev_s g_spi1dev = {
.spi_object = {0},
.refs = 0,
.spi_idx = MBED_SPI1,
.spi_mosi = SPI1_MOSI,
.spi_miso = SPI1_MISO,
.spi_sclk = SPI1_SCLK,
.spi_cs0 = SPI1_CS0,
#if defined(CONFIG_SPI_CS) && defined(CONFIG_AMEBASMART_SPI1_CS)
.spi_cs1 = SPI1_CS1,
#endif
.nbits = 8,
.mode = SPIDEV_MODE0,
.role = AMEBASMART_SPI_MASTER
Expand Down Expand Up @@ -1558,6 +1544,13 @@ FAR struct spi_dev_s *up_spiinitialize(int port)

priv = &g_spi0dev;

priv->spi_mosi = SPI_PIN(SPI0, SPI_MOSI);
priv->spi_miso = SPI_PIN(SPI0, SPI_MISO);
priv->spi_sclk = SPI_PIN(SPI0, SPI_SCLK);
priv->spi_cs0 = SPI_PIN(SPI0, SPI_CS0);
#if defined(CONFIG_SPI_CS) && defined(CONFIG_AMEBASMART_SPI0_CS)
priv->spi_cs1 = SPI_PIN(SPI0, SPI_CS1);
#endif
if (priv->refs > 0) {
dbg("SPI port%d has been initialized before!\n", port);
leave_critical_section(flags);
Expand All @@ -1579,6 +1572,14 @@ FAR struct spi_dev_s *up_spiinitialize(int port)

priv = &g_spi1dev;

priv->spi_mosi = SPI_PIN(SPI1, SPI_MOSI);
priv->spi_miso = SPI_PIN(SPI1, SPI_MISO);
priv->spi_sclk = SPI_PIN(SPI1, SPI_SCLK);
priv->spi_cs0 = SPI_PIN(SPI1, SPI_CS0);
#if defined(CONFIG_SPI_CS) && defined(CONFIG_AMEBASMART_SPI1_CS)
priv->spi_cs1 = SPI_PIN(SPI1, SPI_CS1);
#endif

if (priv->refs > 0) {
dbg("SPI port%d has been initialized before!\n", port);
leave_critical_section(flags);
Expand Down
Loading