configs/makerlisp/nsh/defconfig: Enable Procfs, RTC, and SPI-based SD support. Various fixes under arch/z80/src/ez80 for a clean compile.
This commit is contained in:
parent
a02858365a
commit
1fd6c432fc
@ -48,6 +48,7 @@
|
|||||||
|
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/irq.h>
|
#include <nuttx/irq.h>
|
||||||
|
#include <nuttx/timers/rtc.h>
|
||||||
|
|
||||||
#include <arch/io.h>
|
#include <arch/io.h>
|
||||||
|
|
||||||
@ -142,15 +143,13 @@ static void rtc_dumptime(FAR const struct tm *tp, FAR const char *msg);
|
|||||||
static void rtc_unlock(void);
|
static void rtc_unlock(void);
|
||||||
static void rtc_lock(void);
|
static void rtc_lock(void);
|
||||||
|
|
||||||
static void get_raw_time(struct rtc_timeregs_s *rtcregs);
|
static void get_raw_time(FAR struct rtc_timeregs_s *rtcregs);
|
||||||
static void set_raw_time(const struct rtc_timeregs_s *rtcregs);
|
static void set_raw_time(FAR const struct rtc_timeregs_s *rtcregs);
|
||||||
|
|
||||||
#ifdef CONFIG_RTC_ALARM
|
#ifdef CONFIG_RTC_ALARM
|
||||||
static void get_raw_alarm(struct rtc_timeregs_s *almregs);
|
static void get_raw_alarm(FAR struct rtc_almregs_s *almregs);
|
||||||
static void set_raw_alarm(const struct rtc_timeregs_s *almregs);
|
static void set_raw_alarm(FAR const struct rtc_almregs_s *almregs);
|
||||||
static int ez80_alarm_interrupt(int irq, void *context, void *arg);
|
static int ez80_alarm_interrupt(int irq, FAR void *context, FAR void *arg);
|
||||||
static int ez80_rtc_getalarmdatetime(const struct rtc_almregs_s almregs
|
|
||||||
FAR struct tm *tp);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -197,6 +196,9 @@ static void rtc_dumptime(FAR const struct tm *tp, FAR const char *msg)
|
|||||||
rtcinfo(" tm_sec: %08x\n", tp->tm_sec);
|
rtcinfo(" tm_sec: %08x\n", tp->tm_sec);
|
||||||
rtcinfo(" tm_min: %08x\n", tp->tm_min);
|
rtcinfo(" tm_min: %08x\n", tp->tm_min);
|
||||||
rtcinfo(" tm_hour: %08x\n", tp->tm_hour);
|
rtcinfo(" tm_hour: %08x\n", tp->tm_hour);
|
||||||
|
#if defined(CONFIG_LIBC_LOCALTIME) || defined(CONFIG_TIME_EXTENDED)
|
||||||
|
rtcinfo(" tm_wday: %08x\n", tp->tm_wday);
|
||||||
|
#endif
|
||||||
rtcinfo(" tm_mday: %08x\n", tp->tm_mday);
|
rtcinfo(" tm_mday: %08x\n", tp->tm_mday);
|
||||||
rtcinfo(" tm_mon: %08x\n", tp->tm_mon);
|
rtcinfo(" tm_mon: %08x\n", tp->tm_mon);
|
||||||
rtcinfo(" tm_year: %08x\n", tp->tm_year);
|
rtcinfo(" tm_year: %08x\n", tp->tm_year);
|
||||||
@ -265,7 +267,7 @@ static void rtc_lock(void)
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static void get_raw_time(struct rtc_timeregs_s *rtcregs)
|
static void get_raw_time(FAR struct rtc_timeregs_s *rtcregs)
|
||||||
{
|
{
|
||||||
rtcregs->sec = inp(EZ80_RTC_SEC);
|
rtcregs->sec = inp(EZ80_RTC_SEC);
|
||||||
rtcregs->min = inp(EZ80_RTC_MIN);
|
rtcregs->min = inp(EZ80_RTC_MIN);
|
||||||
@ -291,7 +293,7 @@ static void get_raw_time(struct rtc_timeregs_s *rtcregs)
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static void set_raw_time(const struct rtc_timeregs_s *rtcregs)
|
static void set_raw_time(FAR const struct rtc_timeregs_s *rtcregs)
|
||||||
{
|
{
|
||||||
rtc_unlock();
|
rtc_unlock();
|
||||||
outp(EZ80_RTC_SEC, rtcregs->sec);
|
outp(EZ80_RTC_SEC, rtcregs->sec);
|
||||||
@ -319,7 +321,7 @@ static void set_raw_time(const struct rtc_timeregs_s *rtcregs)
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static void get_raw_alarm(struct rtc_timeregs_s *almregs)
|
static void get_raw_alarm(FAR struct rtc_almregs_s *almregs)
|
||||||
{
|
{
|
||||||
almregs->sec = inp(EZ80_RTC_ASEC);
|
almregs->sec = inp(EZ80_RTC_ASEC);
|
||||||
almregs->min = inp(EZ80_RTC_AMIN);
|
almregs->min = inp(EZ80_RTC_AMIN);
|
||||||
@ -341,7 +343,7 @@ static void get_raw_alarm(struct rtc_timeregs_s *almregs)
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static void set_raw_alarm(const struct rtc_timeregs_s *almregs)
|
static void set_raw_alarm(FAR const struct rtc_almregs_s *almregs)
|
||||||
{
|
{
|
||||||
rtc_unlock();
|
rtc_unlock();
|
||||||
outp(EZ80_RTC_ASEC, almregs->sec);
|
outp(EZ80_RTC_ASEC, almregs->sec);
|
||||||
@ -367,15 +369,18 @@ static void set_raw_alarm(const struct rtc_timeregs_s *almregs)
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_RTC_ALARM
|
#ifdef CONFIG_RTC_ALARM
|
||||||
static int ez80_alarm_interrupt(int irq, void *context, void *arg)
|
static int ez80_alarm_interrupt(int irq, FAR void *context, FAR void *arg)
|
||||||
{
|
{
|
||||||
uint_t regval;
|
uint8_t regval;
|
||||||
|
|
||||||
/* Verify that the alarm iinterrupt is pending */
|
/* Verify that the alarm interrupt is pending */
|
||||||
|
|
||||||
regval = inp(EZ80_RTC_CTRL);
|
regval = inp(EZ80_RTC_CTRL);
|
||||||
if ((regval & EZ80_RTC_ALARM) != 0)
|
if ((regval & EZ80_RTC_ALARM) != 0)
|
||||||
{
|
{
|
||||||
|
alm_callback_t cb;
|
||||||
|
FAR void *cb_arg;
|
||||||
|
|
||||||
/* Disable the alarm and disable the alarm interrupt */
|
/* Disable the alarm and disable the alarm interrupt */
|
||||||
|
|
||||||
rtc_unlock();
|
rtc_unlock();
|
||||||
@ -386,12 +391,12 @@ static int ez80_alarm_interrupt(int irq, void *context, void *arg)
|
|||||||
outp(EZ80_RTC_CTRL, regval);
|
outp(EZ80_RTC_CTRL, regval);
|
||||||
rtc_lock();
|
rtc_lock();
|
||||||
|
|
||||||
up_irq_disble(EZ80_RTC_IRQ);
|
up_disable_irq(EZ80_RTC_IRQ);
|
||||||
|
|
||||||
/* Perform the alarm callback */
|
/* Perform the alarm callback */
|
||||||
|
|
||||||
cb = g_alarmcb.ac_cb;
|
cb = g_alarmcb.ac_cb;
|
||||||
cb_arg = (FAR void *)g_alarmcb.ac_arg;
|
cb_arg = g_alarmcb.ac_arg;
|
||||||
|
|
||||||
g_alarmcb.ac_cb = NULL;
|
g_alarmcb.ac_cb = NULL;
|
||||||
g_alarmcb.ac_arg = NULL;
|
g_alarmcb.ac_arg = NULL;
|
||||||
@ -403,46 +408,6 @@ static int ez80_alarm_interrupt(int irq, void *context, void *arg)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: ez80_rtc_getalarmdatetime
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Get the current date and time for a RTC alarm.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* reg - RTC alarm register
|
|
||||||
* tp - The location to return the high resolution time value.
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* Zero (OK) on success; a negated errno on failure
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifdef CONFIG_RTC_ALARM
|
|
||||||
static int ez80_rtc_getalarmdatetime(const struct rtc_almregs_s almregs
|
|
||||||
FAR struct tm *tp)
|
|
||||||
{
|
|
||||||
uint32_t data, tmp;
|
|
||||||
|
|
||||||
DEBUGASSERT(tp != NULL);
|
|
||||||
|
|
||||||
/* Sample the data time register. */
|
|
||||||
|
|
||||||
data = inp(reg);
|
|
||||||
|
|
||||||
/* Convert the RTC time to fields in struct tm format. All of the EZ80
|
|
||||||
* ranges of values correspond between struct tm and the time register.
|
|
||||||
*/
|
|
||||||
|
|
||||||
tp->tm_sec = xxx(tmp);
|
|
||||||
tp->tm_min = xxx(tmp);
|
|
||||||
tp->tm_hour = xxx(tmp);
|
|
||||||
tp->tm_mday = xxx(tmp);
|
|
||||||
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: up_rtc_initialize
|
* Name: up_rtc_initialize
|
||||||
*
|
*
|
||||||
@ -504,7 +469,7 @@ int up_rtc_initialize(void)
|
|||||||
#ifdef CONFIG_RTC_ALARM
|
#ifdef CONFIG_RTC_ALARM
|
||||||
int z80_rtc_irqinitialize(void)
|
int z80_rtc_irqinitialize(void)
|
||||||
{
|
{
|
||||||
DEBUGVERIFY(irq_attach(EZ80_RTC_IRQ, ez80_alarm_interrupt, NULL));
|
return irq_attach(EZ80_RTC_IRQ, ez80_alarm_interrupt, NULL);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -530,9 +495,11 @@ int up_rtc_getdatetime(FAR struct tm *tp)
|
|||||||
struct rtc_timeregs_s timeregs;
|
struct rtc_timeregs_s timeregs;
|
||||||
struct rtc_timeregs_s tmpregs;
|
struct rtc_timeregs_s tmpregs;
|
||||||
|
|
||||||
|
rtc_dumpregs("Reading Time");
|
||||||
|
|
||||||
/* Sample the data time registers. There is a race condition here... ,
|
/* Sample the data time registers. There is a race condition here... ,
|
||||||
* for example, we sample the time just before midnight on December 31,
|
* for example, we sample the time just before midnight on December 31,
|
||||||
* the date couldbe wrong because the day rolled over while were
|
* the date could be wrong because the day rolled over while were
|
||||||
* sampling. Thus loop for checking wrap here is needed.
|
* sampling. Thus loop for checking wrap here is needed.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -548,8 +515,6 @@ int up_rtc_getdatetime(FAR struct tm *tp)
|
|||||||
tmpregs.yr != timeregs.yr &&
|
tmpregs.yr != timeregs.yr &&
|
||||||
tmpregs.cen != timeregs.cen);
|
tmpregs.cen != timeregs.cen);
|
||||||
|
|
||||||
rtc_dumpregs("Reading Time");
|
|
||||||
|
|
||||||
/* Convert the RTC time to fields in struct tm format. All of the EZ80
|
/* Convert the RTC time to fields in struct tm format. All of the EZ80
|
||||||
* ranges of values correspond between struct tm and the time register.
|
* ranges of values correspond between struct tm and the time register.
|
||||||
*/
|
*/
|
||||||
@ -655,6 +620,7 @@ int up_rtc_settime(FAR const struct timespec *tp)
|
|||||||
int ez80_rtc_setalarm(FAR struct alm_setalarm_s *alminfo)
|
int ez80_rtc_setalarm(FAR struct alm_setalarm_s *alminfo)
|
||||||
{
|
{
|
||||||
struct rtc_almregs_s almregs;
|
struct rtc_almregs_s almregs;
|
||||||
|
uint8_t regval;
|
||||||
int ret = -EINVAL;
|
int ret = -EINVAL;
|
||||||
|
|
||||||
DEBUGASSERT(alminfo != NULL);
|
DEBUGASSERT(alminfo != NULL);
|
||||||
@ -668,19 +634,21 @@ int ez80_rtc_setalarm(FAR struct alm_setalarm_s *alminfo)
|
|||||||
|
|
||||||
/* Set the alarm time */
|
/* Set the alarm time */
|
||||||
|
|
||||||
almregs.sec = alminfo->as_time.sec;
|
almregs.sec = alminfo->as_time.tm_sec;
|
||||||
almregs.min = alminfo->as_time.min;
|
almregs.min = alminfo->as_time.tm_min;
|
||||||
almregs.hrs = alminfo->as_time.hrs;
|
almregs.hrs = alminfo->as_time.tm_hour;
|
||||||
almregs.dow = alminfo->as_time.dow;
|
#if defined(CONFIG_LIBC_LOCALTIME) || defined(CONFIG_TIME_EXTENDED)
|
||||||
|
almregs.dow = alminfo->as_time.tm_wday;
|
||||||
|
#endif
|
||||||
|
|
||||||
set_raw_alarm(&alarmregs);
|
set_raw_alarm(&almregs);
|
||||||
|
|
||||||
/* Enable the alarm */
|
/* Enable the alarm */
|
||||||
|
|
||||||
rtc_unlock();
|
rtc_unlock();
|
||||||
outp(EZ80_RTC_ACTRL, EZ80_RTX_AALL);
|
outp(EZ80_RTC_ACTRL, EZ80_RTX_AALL);
|
||||||
|
|
||||||
regval = inp(EZ80_RTC_CTRL);
|
regval = inp(EZ80_RTC_CTRL);
|
||||||
regval |= ~EZ80_RTC_INTEN;
|
regval |= ~EZ80_RTC_INTEN;
|
||||||
outp(EZ80_RTC_CTRL, regval);
|
outp(EZ80_RTC_CTRL, regval);
|
||||||
rtc_lock();
|
rtc_lock();
|
||||||
@ -689,7 +657,7 @@ int ez80_rtc_setalarm(FAR struct alm_setalarm_s *alminfo)
|
|||||||
|
|
||||||
/* Enable the alarm interrupt at the interrupt controller */
|
/* Enable the alarm interrupt at the interrupt controller */
|
||||||
|
|
||||||
up_irq_enable(EZ80_RTC_IRQ);
|
up_enable_irq(EZ80_RTC_IRQ);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -701,7 +669,7 @@ int ez80_rtc_setalarm(FAR struct alm_setalarm_s *alminfo)
|
|||||||
* Cancel an alarm.
|
* Cancel an alarm.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* alarmid - Identifies the alarm to be cancelled
|
* None
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* Zero (OK) on success; a negated errno on failure
|
* Zero (OK) on success; a negated errno on failure
|
||||||
@ -711,10 +679,12 @@ int ez80_rtc_setalarm(FAR struct alm_setalarm_s *alminfo)
|
|||||||
#ifdef CONFIG_RTC_ALARM
|
#ifdef CONFIG_RTC_ALARM
|
||||||
int ez80_rtc_cancelalarm(void)
|
int ez80_rtc_cancelalarm(void)
|
||||||
{
|
{
|
||||||
|
uint8_t regval;
|
||||||
|
|
||||||
/* Cancel the global callback function */
|
/* Cancel the global callback function */
|
||||||
|
|
||||||
g_alarmcb[alarmid].ac_cb = NULL;
|
g_alarmcb.ac_cb = NULL;
|
||||||
g_alarmcb[alarmid].ac_arg = NULL;
|
g_alarmcb.ac_arg = NULL;
|
||||||
|
|
||||||
/* Disable RTC alarm and and the alarm interrupt */
|
/* Disable RTC alarm and and the alarm interrupt */
|
||||||
|
|
||||||
@ -726,7 +696,7 @@ int ez80_rtc_cancelalarm(void)
|
|||||||
outp(EZ80_RTC_CTRL, regval);
|
outp(EZ80_RTC_CTRL, regval);
|
||||||
rtc_lock();
|
rtc_lock();
|
||||||
|
|
||||||
up_irq_disable(EZ80_RTC_IRQ);
|
up_disable_irq(EZ80_RTC_IRQ);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -738,7 +708,7 @@ int ez80_rtc_cancelalarm(void)
|
|||||||
* Return the current alarm setting.
|
* Return the current alarm setting.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* almtime - Location to retun the current alarm ime.
|
* almtime - Location to return the current alarm time.
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* Zero (OK) on success; a negated errno on failure
|
* Zero (OK) on success; a negated errno on failure
|
||||||
@ -746,20 +716,38 @@ int ez80_rtc_cancelalarm(void)
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_RTC_ALARM
|
#ifdef CONFIG_RTC_ALARM
|
||||||
int ez80_rtc_rdalarm(FAR struct rtc_time *almtime)
|
int ez80_rtc_rdalarm(FAR struct tm *almtime)
|
||||||
{
|
{
|
||||||
struct rtc_almregs_s almregs;
|
struct rtc_almregs_s almregs;
|
||||||
int ret = -EINVAL;
|
int ret = -EINVAL;
|
||||||
|
|
||||||
DEBUGASSERT(almtime != NULL);
|
rtc_dumpregs("Reading Alarm");
|
||||||
|
|
||||||
/* Read the alarm time from the RTC */
|
/* Get the current time for the month and year */
|
||||||
|
|
||||||
|
ret = up_rtc_getdatetime(almtime);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Sample the alarm time registers. There is no race condition in this
|
||||||
|
* case.
|
||||||
|
*/
|
||||||
|
|
||||||
get_raw_alarm(&almregs);
|
get_raw_alarm(&almregs);
|
||||||
|
|
||||||
/* A return that as struct tm */
|
/* Overwrite to get the full alarm time */
|
||||||
|
|
||||||
return ez80_rtc_getalarmdatetime(&almregs, almtime);
|
almtime->tm_sec = almregs.sec;
|
||||||
|
almtime->tm_min = almregs.min;
|
||||||
|
almtime->tm_hour = almregs.hrs;
|
||||||
|
#if defined(CONFIG_LIBC_LOCALTIME) || defined(CONFIG_TIME_EXTENDED)
|
||||||
|
almtime->tm_wday = almregs.dow;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
rtc_dumptime((FAR const struct tm *)almtime, "Returning");
|
||||||
|
return OK;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -186,7 +186,7 @@ int ez80_rtc_setalarm(FAR struct alm_setalarm_s *alminfo);
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int ez80_rtc_rdalarm(FAR struct rtc_time *almtime);
|
int ez80_rtc_rdalarm(FAR struct tm *almtime);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: ez80_rtc_cancelalarm
|
* Name: ez80_rtc_cancelalarm
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* arch/z80/src/ez80/ez80_spi.c
|
* arch/z80/src/ez80/ez80_spi.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2009-2010, 2016-2017 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2009-2010, 2016-2017, 2019 Gregory Nutt. All rights
|
||||||
|
* reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@ -61,7 +62,7 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_CHIP_EZ80F91
|
#ifdef CONFIG_ARCH_CHIP_EZ80F91
|
||||||
# define GPIOB_SPI_PINSET 0x38 /* MISO+MSOI+SCK. Excludes SS */
|
# define GPIOB_SPI_PINSET 0x38 /* MISO+MSOI+SCK. Excludes SS */
|
||||||
#else
|
#else
|
||||||
# error "Check GPIO initialization for this chip"
|
# error "Check GPIO initialization for this chip"
|
||||||
#endif
|
#endif
|
||||||
@ -75,10 +76,16 @@ static uint32_t spi_setfrequency(FAR struct spi_dev_s *dev,
|
|||||||
uint32_t frequency);
|
uint32_t frequency);
|
||||||
static void spi_setmode(FAR struct spi_dev_s *dev, enum spi_mode_e mode);
|
static void spi_setmode(FAR struct spi_dev_s *dev, enum spi_mode_e mode);
|
||||||
static uint16_t spi_send(FAR struct spi_dev_s *dev, uint16_t wd);
|
static uint16_t spi_send(FAR struct spi_dev_s *dev, uint16_t wd);
|
||||||
|
#ifdef CONFIG_SPI_EXCHANGE
|
||||||
|
static void spi_exchange(FAR struct spi_dev_s *dev,
|
||||||
|
FAR const void *txbuffer, FAR void *rxbuffer,
|
||||||
|
size_t nwords);
|
||||||
|
#else
|
||||||
static void spi_sndblock(FAR struct spi_dev_s *dev,
|
static void spi_sndblock(FAR struct spi_dev_s *dev,
|
||||||
FAR const uint8_t *buffer, size_t buflen);
|
FAR const uint8_t *buffer, size_t buflen);
|
||||||
static void spi_recvblock(FAR struct spi_dev_s *dev, FAR uint8_t *buffer,
|
static void spi_recvblock(FAR struct spi_dev_s *dev, FAR uint8_t *buffer,
|
||||||
size_t buflen);
|
size_t buflen);
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Data
|
* Private Data
|
||||||
@ -86,26 +93,36 @@ static void spi_recvblock(FAR struct spi_dev_s *dev, FAR uint8_t *buffer,
|
|||||||
|
|
||||||
static const struct spi_ops_s g_spiops =
|
static const struct spi_ops_s g_spiops =
|
||||||
{
|
{
|
||||||
spi_lock,
|
spi_lock, /* lock() */
|
||||||
ez80_spiselect, /* select: Provided externally by board logic */
|
ez80_spiselect, /* select(): Provided externally by board logic */
|
||||||
spi_setfrequency,
|
spi_setfrequency, /* setfrequency() */
|
||||||
|
#ifdef CONFIG_SPI_CS_DELAY_CONTROL
|
||||||
|
NULL, /* setdelay() */
|
||||||
|
#endif
|
||||||
spi_setmode,
|
spi_setmode,
|
||||||
NULL, /* setbits: Variable number of bits not implemented */
|
NULL, /* setbits() */
|
||||||
#ifdef CONFIG_SPI_HWFEATURES
|
#ifdef CONFIG_SPI_HWFEATURES
|
||||||
NULL, /* hwfeatures: Not supported */
|
NULL, /* hwfeatures() */
|
||||||
#endif
|
#endif
|
||||||
ez80_spistatus, /* status: Provided externally by board logic */
|
ez80_spistatus, /* status(): Provided externally by board logic */
|
||||||
#ifdef CONFIG_SPI_CMDDATA
|
#ifdef CONFIG_SPI_CMDDATA
|
||||||
ez80_spicmddata,
|
ez80_spicmddata, /* cmddata(): Provided externally by board logic */
|
||||||
#endif
|
#endif
|
||||||
spi_send,
|
spi_send, /* send() */
|
||||||
spi_sndblock,
|
#ifdef CONFIG_SPI_EXCHANGE
|
||||||
spi_recvblock,
|
spi_exchange, /* exchange() */
|
||||||
0 /* registercallback: Not yet implemented */
|
#else
|
||||||
|
spi_sndblock, /* sndblock() */
|
||||||
|
spi_recvblock, /* recvblock() */
|
||||||
|
#endif
|
||||||
|
#ifdef CONFIG_SPI_TRIGGER
|
||||||
|
NULL, /* trigger() */
|
||||||
|
#endif
|
||||||
|
NULL /* registercallback() */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* This supports is only a single SPI bus/port. If you port this to an
|
/* This supports is only a single SPI bus/port. If you port this to an
|
||||||
* architecture with multiple SPI busses/ports, then (1) you must create
|
* architecture with multiple SPI buses/ports, then (1) you must create
|
||||||
* a structure, say ez80_spidev_s, containing both struct spi_dev_s and
|
* a structure, say ez80_spidev_s, containing both struct spi_dev_s and
|
||||||
* the mutual exclusion semaphored, and (2) the following must become an
|
* the mutual exclusion semaphored, and (2) the following must become an
|
||||||
* array with one 'struct spi_dev_s' instance per bus.
|
* array with one 'struct spi_dev_s' instance per bus.
|
||||||
@ -128,8 +145,8 @@ static sem_t g_exclsem = SEM_INITIALIZER(1);
|
|||||||
* Name: spi_lock
|
* Name: spi_lock
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* On SPI busses where there are multiple devices, it will be necessary to
|
* On SPI buses where there are multiple devices, it will be necessary to
|
||||||
* lock SPI to have exclusive access to the busses for a sequence of
|
* lock SPI to have exclusive access to the buses for a sequence of
|
||||||
* transfers. The bus should be locked before the chip is selected. After
|
* transfers. The bus should be locked before the chip is selected. After
|
||||||
* locking the SPI bus, the caller should then also call the setfrequency,
|
* locking the SPI bus, the caller should then also call the setfrequency,
|
||||||
* setbits, and setmode methods to make sure that the SPI is properly
|
* setbits, and setmode methods to make sure that the SPI is properly
|
||||||
@ -363,6 +380,57 @@ static uint16_t spi_send(FAR struct spi_dev_s *dev, uint16_t wd)
|
|||||||
return spi_transfer((uint8_t)wd);
|
return spi_transfer((uint8_t)wd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: spi_exchange
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Exchange a block of data from SPI. Required.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* dev - Device-specific state data
|
||||||
|
* txbuffer - A pointer to the buffer of data to be sent
|
||||||
|
* rxbuffer - A pointer to the buffer in which to receive data
|
||||||
|
* nwords - the length of data that to be exchanged in units of words.
|
||||||
|
* The wordsize is determined by the number of bits-per-word
|
||||||
|
* selected for the SPI interface. If nbits <= 8, the data is
|
||||||
|
* packed into uint8_t's; if nbits >8, the data is packed into
|
||||||
|
* uint16_t's
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_SPI_EXCHANGE
|
||||||
|
static void spi_exchange(FAR struct spi_dev_s *dev,
|
||||||
|
FAR const void *txbuffer, FAR void *rxbuffer,
|
||||||
|
size_t nwords)
|
||||||
|
{
|
||||||
|
FAR const uint8_t *inptr = (FAR const uint8_t *)txbuffer;
|
||||||
|
FAR uint8_t *outptr = (FAR const uint8_t *)rxbuffer;
|
||||||
|
|
||||||
|
/* Loop while there are bytes remaining to be sent */
|
||||||
|
|
||||||
|
while (nwords-- > 0)
|
||||||
|
{
|
||||||
|
/* Send 0xff if there is no outgoing TX stream */
|
||||||
|
|
||||||
|
uint8_t outword = (inptr == NULL) ? 0xff : *inptr++;
|
||||||
|
|
||||||
|
/* Send the outgoing word and obtain the respoonse */
|
||||||
|
|
||||||
|
uint8_t inword = spi_transfer(outword);
|
||||||
|
|
||||||
|
/* Save the response if there is an incoming RX stream */
|
||||||
|
|
||||||
|
if (outptr != NULL)
|
||||||
|
{
|
||||||
|
*outptr++ = inword;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: spi_sndblock
|
* Name: spi_sndblock
|
||||||
*
|
*
|
||||||
@ -383,6 +451,7 @@ static uint16_t spi_send(FAR struct spi_dev_s *dev, uint16_t wd)
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef CONFIG_SPI_EXCHANGE
|
||||||
static void spi_sndblock(FAR struct spi_dev_s *dev, FAR const void *buffer,
|
static void spi_sndblock(FAR struct spi_dev_s *dev, FAR const void *buffer,
|
||||||
size_t buflen)
|
size_t buflen)
|
||||||
{
|
{
|
||||||
@ -395,6 +464,7 @@ static void spi_sndblock(FAR struct spi_dev_s *dev, FAR const void *buffer,
|
|||||||
(void)spi_transfer(*ptr++);
|
(void)spi_transfer(*ptr++);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: spi_recvblock
|
* Name: spi_recvblock
|
||||||
@ -416,6 +486,7 @@ static void spi_sndblock(FAR struct spi_dev_s *dev, FAR const void *buffer,
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef CONFIG_SPI_EXCHANGE
|
||||||
static void spi_recvblock(FAR struct spi_dev_s *dev, FAR void *buffer,
|
static void spi_recvblock(FAR struct spi_dev_s *dev, FAR void *buffer,
|
||||||
size_t buflen)
|
size_t buflen)
|
||||||
{
|
{
|
||||||
@ -428,6 +499,7 @@ static void spi_recvblock(FAR struct spi_dev_s *dev, FAR void *buffer,
|
|||||||
*ptr++ = spi_transfer(0xff);
|
*ptr++ = spi_transfer(0xff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
@ -459,9 +531,9 @@ FAR struct spi_dev_s *ez80_spibus_initialize(int port)
|
|||||||
{
|
{
|
||||||
uint8_t regval;
|
uint8_t regval;
|
||||||
|
|
||||||
|
#ifdef CONFIG_DEBUG_FEATURES
|
||||||
/* Only the SPI1 interface is supported */
|
/* Only the SPI1 interface is supported */
|
||||||
|
|
||||||
#ifdef CONFIG_DEBUG_FEATURES
|
|
||||||
if (port != 1)
|
if (port != 1)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -501,7 +573,7 @@ FAR struct spi_dev_s *ez80_spibus_initialize(int port)
|
|||||||
# error "Check GPIO initialization for this chip"
|
# error "Check GPIO initialization for this chip"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Set the initial clock frequency for indentification mode < 400kHz */
|
/* Set the initial clock frequency for identification mode < 400kHz */
|
||||||
|
|
||||||
spi_setfrequency(NULL, 400000);
|
spi_setfrequency(NULL, 400000);
|
||||||
|
|
||||||
|
@ -110,14 +110,14 @@ extern "C"
|
|||||||
*
|
*
|
||||||
* One GPIO, SS (PB2 on the eZ8F091) is reserved as a chip select. However,
|
* One GPIO, SS (PB2 on the eZ8F091) is reserved as a chip select. However,
|
||||||
* If multiple devices on on the bus, then multiple chip selects will be
|
* If multiple devices on on the bus, then multiple chip selects will be
|
||||||
* required. Theregore, all GPIO chip management is deferred to board-
|
* required. Therefore, all GPIO chip management is deferred to board-
|
||||||
* specific logic.
|
* specific logic.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* Port number (for hardware that has mutiple SPI interfaces)
|
* Port number (for hardware that has multiple SPI interfaces)
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* Valid SPI device structre reference on succcess; a NULL on failure
|
* Valid SPI device structure reference on success; a NULL on failure
|
||||||
*
|
*
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
|
|
||||||
|
@ -290,3 +290,10 @@ Configuration Subdirectories
|
|||||||
|
|
||||||
The PC terminal software should be configured as described in the
|
The PC terminal software should be configured as described in the
|
||||||
MakerLisp Putty HOWTO document: 115200N1 BAUD.
|
MakerLisp Putty HOWTO document: 115200N1 BAUD.
|
||||||
|
|
||||||
|
STATUS:
|
||||||
|
2109-06-16: The basic NSH configuration appears to be fully functional
|
||||||
|
using only the CPU and I/O expansion card. Console is provided over
|
||||||
|
USB.
|
||||||
|
|
||||||
|
Added support for SPI-based SD cards, the RTC and procFS.
|
@ -5,8 +5,10 @@
|
|||||||
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
||||||
# modifications.
|
# modifications.
|
||||||
#
|
#
|
||||||
# CONFIG_NSH_DISABLE_IFCONFIG is not set
|
# CONFIG_MMCSD_HAVE_CARDDETECT is not set
|
||||||
# CONFIG_NSH_DISABLE_PS is not set
|
# CONFIG_MMCSD_HAVE_WRITEPROTECT is not set
|
||||||
|
# CONFIG_MMCSD_MMCSUPPORT is not set
|
||||||
|
# CONFIG_SPI_CALLBACK is not set
|
||||||
CONFIG_ARCH="z80"
|
CONFIG_ARCH="z80"
|
||||||
CONFIG_ARCH_BOARD="makerlisp"
|
CONFIG_ARCH_BOARD="makerlisp"
|
||||||
CONFIG_ARCH_BOARD_MAKERLISP=y
|
CONFIG_ARCH_BOARD_MAKERLISP=y
|
||||||
@ -15,12 +17,23 @@ CONFIG_ARCH_CHIP_EZ80F91=y
|
|||||||
CONFIG_ARCH_Z80=y
|
CONFIG_ARCH_Z80=y
|
||||||
CONFIG_BOARD_LOOPSPERMSEC=1250
|
CONFIG_BOARD_LOOPSPERMSEC=1250
|
||||||
CONFIG_DISABLE_MQUEUE=y
|
CONFIG_DISABLE_MQUEUE=y
|
||||||
|
CONFIG_EZ80_RTC=y
|
||||||
|
CONFIG_EZ80_SPI=y
|
||||||
CONFIG_EZ80_UART0=y
|
CONFIG_EZ80_UART0=y
|
||||||
|
CONFIG_FAT_LCNAMES=y
|
||||||
|
CONFIG_FAT_LFN=y
|
||||||
|
CONFIG_FS_FAT=y
|
||||||
|
CONFIG_FS_PROCFS=y
|
||||||
CONFIG_HOST_WINDOWS=y
|
CONFIG_HOST_WINDOWS=y
|
||||||
CONFIG_MAX_TASKS=16
|
CONFIG_MAX_TASKS=16
|
||||||
CONFIG_MAX_WDOGPARMS=2
|
CONFIG_MAX_WDOGPARMS=2
|
||||||
|
CONFIG_MMCSD=y
|
||||||
|
CONFIG_MMCSD_MULTIBLOCK_DISABLE=y
|
||||||
CONFIG_NFILE_DESCRIPTORS=8
|
CONFIG_NFILE_DESCRIPTORS=8
|
||||||
CONFIG_NFILE_STREAMS=8
|
CONFIG_NFILE_STREAMS=8
|
||||||
|
CONFIG_NSH_ARCHINIT=y
|
||||||
|
CONFIG_NSH_DISABLE_DATE=y
|
||||||
|
CONFIG_NSH_DISABLE_IFUPDOWN=y
|
||||||
CONFIG_NSH_FILEIOSIZE=512
|
CONFIG_NSH_FILEIOSIZE=512
|
||||||
CONFIG_NSH_LINELEN=64
|
CONFIG_NSH_LINELEN=64
|
||||||
CONFIG_NSH_READLINE=y
|
CONFIG_NSH_READLINE=y
|
||||||
@ -29,11 +42,13 @@ CONFIG_PREALLOC_WDOGS=8
|
|||||||
CONFIG_PTHREAD_STACK_DEFAULT=1024
|
CONFIG_PTHREAD_STACK_DEFAULT=1024
|
||||||
CONFIG_RAM_SIZE=65536
|
CONFIG_RAM_SIZE=65536
|
||||||
CONFIG_RR_INTERVAL=200
|
CONFIG_RR_INTERVAL=200
|
||||||
|
CONFIG_RTC_ALARM=y
|
||||||
CONFIG_SCHED_HPWORK=y
|
CONFIG_SCHED_HPWORK=y
|
||||||
CONFIG_SDCLONE_DISABLE=y
|
CONFIG_SDCLONE_DISABLE=y
|
||||||
CONFIG_START_DAY=14
|
CONFIG_SPI=y
|
||||||
CONFIG_START_MONTH=3
|
CONFIG_START_DAY=16
|
||||||
CONFIG_START_YEAR=2009
|
CONFIG_START_MONTH=6
|
||||||
|
CONFIG_START_YEAR=2019
|
||||||
CONFIG_SYSTEM_NSH=y
|
CONFIG_SYSTEM_NSH=y
|
||||||
CONFIG_TASK_NAME_SIZE=0
|
CONFIG_TASK_NAME_SIZE=0
|
||||||
CONFIG_UART0_BITS=0
|
CONFIG_UART0_BITS=0
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/mount.h>
|
#include <sys/mount.h>
|
||||||
#include <debug.h>
|
#include <syslog.h>
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
@ -71,7 +71,7 @@ int ez80_bringup(void)
|
|||||||
ret = mount(NULL, "/proc", "procfs", 0, NULL);
|
ret = mount(NULL, "/proc", "procfs", 0, NULL);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
serr("ERROR: Failed to mount procfs at /proc: %d\n", ret);
|
syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ int ez80_bringup(void)
|
|||||||
ret = ez80_mmcsd_initialize(void);
|
ret = ez80_mmcsd_initialize(void);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
serr("ERROR: Failed to initialize SD card: %d\n", ret);
|
syslog(LOG_ERR, "ERROR: Failed to initialize SD card: %d\n", ret);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int ez80_mmcsd_initialize(void)
|
void ez80_spidev_initialize(void)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_MMCSD
|
#ifdef HAVE_MMCSD
|
||||||
uint8_t regval;
|
uint8_t regval;
|
||||||
@ -163,5 +163,3 @@ int ez80_spicmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd)
|
|||||||
{
|
{
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* HAVE_MMCSD */
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* fs/mount/fs_procfs_mount.c
|
* fs/mount/fs_procfs_mount.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2017-2018 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2017-2019 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@ -483,6 +483,7 @@ static ssize_t mount_read(FAR struct file *filep, FAR char *buffer,
|
|||||||
size_t buflen)
|
size_t buflen)
|
||||||
{
|
{
|
||||||
FAR struct mount_file_s *procfile;
|
FAR struct mount_file_s *procfile;
|
||||||
|
struct mount_info_s info;
|
||||||
foreach_mountpoint_t handler;
|
foreach_mountpoint_t handler;
|
||||||
ssize_t ret;
|
ssize_t ret;
|
||||||
|
|
||||||
@ -495,8 +496,6 @@ static ssize_t mount_read(FAR struct file *filep, FAR char *buffer,
|
|||||||
|
|
||||||
/* Provide the requested data */
|
/* Provide the requested data */
|
||||||
|
|
||||||
struct mount_info_s info;
|
|
||||||
|
|
||||||
memset(&info, 0, sizeof(struct mount_info_s));
|
memset(&info, 0, sizeof(struct mount_info_s));
|
||||||
info.line = procfile->line;
|
info.line = procfile->line;
|
||||||
info.buffer = buffer;
|
info.buffer = buffer;
|
||||||
|
@ -386,7 +386,7 @@
|
|||||||
* Name: SPI_EXCHANGE
|
* Name: SPI_EXCHANGE
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Exahange a block of data from SPI. Required.
|
* Exchange a block of data from SPI. Required.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* dev - Device-specific state data
|
* dev - Device-specific state data
|
||||||
|
@ -209,7 +209,6 @@
|
|||||||
|
|
||||||
#define RTC_USER_IOCBASE 0x000a
|
#define RTC_USER_IOCBASE 0x000a
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Types
|
* Public Types
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
Loading…
Reference in New Issue
Block a user