mirror of
https://github.com/apache/nuttx.git
synced 2026-05-30 13:27:01 +08:00
arch/z80/src/ez80: Fix a bad SPI register address definition. Clean up RTC lower half driver problems. Update a README.
This commit is contained in:
@@ -111,7 +111,7 @@ static int ez80_setalarm(FAR struct rtc_lowerhalf_s *lower,
|
|||||||
FAR const struct lower_setalarm_s *alarminfo);
|
FAR const struct lower_setalarm_s *alarminfo);
|
||||||
static int ez80_setrelative(FAR struct rtc_lowerhalf_s *lower,
|
static int ez80_setrelative(FAR struct rtc_lowerhalf_s *lower,
|
||||||
FAR const struct lower_setrelative_s *alarminfo);
|
FAR const struct lower_setrelative_s *alarminfo);
|
||||||
static int ez80_cancelalarm(FAR struct rtc_lowerhalf_s *lower);
|
static int ez80_cancelalarm(FAR struct rtc_lowerhalf_s *lower, int alarmid);
|
||||||
static int ez80_rdalarm(FAR struct rtc_lowerhalf_s *lower,
|
static int ez80_rdalarm(FAR struct rtc_lowerhalf_s *lower,
|
||||||
FAR struct lower_rdalarm_s *alarminfo);
|
FAR struct lower_rdalarm_s *alarminfo);
|
||||||
#endif
|
#endif
|
||||||
@@ -124,24 +124,24 @@ static int ez80_rdalarm(FAR struct rtc_lowerhalf_s *lower,
|
|||||||
|
|
||||||
static const struct rtc_ops_s g_rtc_ops =
|
static const struct rtc_ops_s g_rtc_ops =
|
||||||
{
|
{
|
||||||
.rdtime = ez80_rdtime,
|
ez80_rdtime, /* rdtime */
|
||||||
.settime = ez80_settime,
|
ez80_settime, /* settime */
|
||||||
.havesettime = ez80_havesettime,
|
ez80_havesettime /* havesettime */
|
||||||
#ifdef CONFIG_RTC_ALARM
|
#ifdef CONFIG_RTC_ALARM
|
||||||
.setalarm = ez80_setalarm,
|
, ez80_setalarm, /* setalarm */
|
||||||
.setrelative = ez80_setrelative,
|
ez80_setrelative, /* setrelative */
|
||||||
.cancelalarm = ez80_cancelalarm,
|
ez80_cancelalarm, /* cancelalarm */
|
||||||
.rdalarm = ez80_rdalarm,
|
ez80_rdalarm /* rdalarm */
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_RTC_PERIODIC
|
#ifdef CONFIG_RTC_PERIODIC
|
||||||
.setperiodic = NULL,
|
, NULL, /* setperiodic */
|
||||||
.cancelperiodic = NULL,
|
NULL /* cancelperiodic */
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_RTC_IOCTL
|
#ifdef CONFIG_RTC_IOCTL
|
||||||
.ioctl = NULL,
|
, NULL /* ioctl */
|
||||||
#endif
|
#endif
|
||||||
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
|
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
|
||||||
.destroy = NULL,
|
, NULL /* destroy */
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -149,7 +149,7 @@ static const struct rtc_ops_s g_rtc_ops =
|
|||||||
|
|
||||||
static struct ez80_lowerhalf_s g_rtc_lowerhalf =
|
static struct ez80_lowerhalf_s g_rtc_lowerhalf =
|
||||||
{
|
{
|
||||||
.ops = &g_rtc_ops,
|
&g_rtc_ops /* ops */
|
||||||
};
|
};
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -197,7 +197,7 @@ static void ez80_alarm_callback(FAR void *arg)
|
|||||||
|
|
||||||
if (cb != NULL)
|
if (cb != NULL)
|
||||||
{
|
{
|
||||||
cb(priv);
|
cb(priv, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -326,7 +326,7 @@ static int ez80_settime(FAR struct rtc_lowerhalf_s *lower,
|
|||||||
* Implements the havesettime() method of the RTC driver interface
|
* Implements the havesettime() method of the RTC driver interface
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* lower - A reference to RTC lower half driver state structure
|
* lower - A reference to RTC lower half driver state structure
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* Returns true if RTC date-time have been previously set.
|
* Returns true if RTC date-time have been previously set.
|
||||||
@@ -335,7 +335,7 @@ static int ez80_settime(FAR struct rtc_lowerhalf_s *lower,
|
|||||||
|
|
||||||
static bool ez80_havesettime(FAR struct rtc_lowerhalf_s *lower)
|
static bool ez80_havesettime(FAR struct rtc_lowerhalf_s *lower)
|
||||||
{
|
{
|
||||||
return getreg32(RTC_MAGIC_REG) == RTC_MAGIC_TIME_SET;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -367,7 +367,8 @@ static int ez80_setalarm(FAR struct rtc_lowerhalf_s *lower,
|
|||||||
/* ID0-> Alarm A; ID1 -> Alarm B */
|
/* ID0-> Alarm A; ID1 -> Alarm B */
|
||||||
|
|
||||||
DEBUGASSERT(lower != NULL && alarminfo != NULL);
|
DEBUGASSERT(lower != NULL && alarminfo != NULL);
|
||||||
DEBUGASSERT(alarminfo->id == RTC_ALARMA || alarminfo->id == RTC_ALARMB);
|
DEBUGASSERT(alarminfo->id == 0);
|
||||||
|
|
||||||
priv = (FAR struct ez80_lowerhalf_s *)lower;
|
priv = (FAR struct ez80_lowerhalf_s *)lower;
|
||||||
|
|
||||||
ret = nxsem_wait(&priv->devsem);
|
ret = nxsem_wait(&priv->devsem);
|
||||||
@@ -381,11 +382,9 @@ static int ez80_setalarm(FAR struct rtc_lowerhalf_s *lower,
|
|||||||
cbinfo = &priv->cbinfo;
|
cbinfo = &priv->cbinfo;
|
||||||
cbinfo->cb = alarminfo->cb;
|
cbinfo->cb = alarminfo->cb;
|
||||||
cbinfo->priv = alarminfo->priv;
|
cbinfo->priv = alarminfo->priv;
|
||||||
cbinfo->id = alarminfo->id;
|
|
||||||
|
|
||||||
/* Set the alarm */
|
/* Set the alarm */
|
||||||
|
|
||||||
lowerinfo.as_id = alarminfo->id;
|
|
||||||
lowerinfo.as_cb = ez80_alarm_callback;
|
lowerinfo.as_cb = ez80_alarm_callback;
|
||||||
lowerinfo.as_arg = priv;
|
lowerinfo.as_arg = priv;
|
||||||
memcpy(&lowerinfo.as_time, &alarminfo->time, sizeof(struct tm));
|
memcpy(&lowerinfo.as_time, &alarminfo->time, sizeof(struct tm));
|
||||||
@@ -431,49 +430,42 @@ static int ez80_setrelative(FAR struct rtc_lowerhalf_s *lower,
|
|||||||
time_t seconds;
|
time_t seconds;
|
||||||
int ret = -EINVAL;
|
int ret = -EINVAL;
|
||||||
|
|
||||||
DEBUGASSERT(lower != NULL && alarminfo != NULL);
|
DEBUGASSERT(lower != NULL && alarminfo != NULL && alarminfo->id == 0);
|
||||||
DEBUGASSERT(alarminfo->id == RTC_ALARMA || alarminfo->id == RTC_ALARMB);
|
|
||||||
|
|
||||||
if ((alarminfo->id == RTC_ALARMA || alarminfo->id == RTC_ALARMB) &&
|
/* Disable pre-emption while we do this so that we don't have to worry
|
||||||
alarminfo->reltime > 0)
|
* about being suspended and working on an old time.
|
||||||
|
*/
|
||||||
|
|
||||||
|
sched_lock();
|
||||||
|
|
||||||
|
/* Get the current time in broken out format */
|
||||||
|
|
||||||
|
ret = up_rtc_getdatetime(&time);
|
||||||
|
if (ret >= 0)
|
||||||
{
|
{
|
||||||
/* Disable pre-emption while we do this so that we don't have to worry
|
/* Convert to seconds since the epoch */
|
||||||
* about being suspended and working on an old time.
|
|
||||||
|
seconds = mktime(&time);
|
||||||
|
|
||||||
|
/* Add the seconds offset. Add one to the number of seconds
|
||||||
|
* because we are unsure of the phase of the timer.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
sched_lock();
|
seconds += (alarminfo->reltime + 1);
|
||||||
|
|
||||||
/* Get the current time in broken out format */
|
/* And convert the time back to broken out format */
|
||||||
|
|
||||||
ret = up_rtc_getdatetime(&time);
|
(void)gmtime_r(&seconds, (FAR struct tm *)&setalarm.time);
|
||||||
if (ret >= 0)
|
|
||||||
{
|
|
||||||
/* Convert to seconds since the epoch */
|
|
||||||
|
|
||||||
seconds = mktime(&time);
|
/* The set the alarm using this absolute time */
|
||||||
|
|
||||||
/* Add the seconds offset. Add one to the number of seconds
|
setalarm.cb = alarminfo->cb;
|
||||||
* because we are unsure of the phase of the timer.
|
setalarm.priv = alarminfo->priv;
|
||||||
*/
|
|
||||||
|
|
||||||
seconds += (alarminfo->reltime + 1);
|
ret = ez80_setalarm(lower, &setalarm);
|
||||||
|
|
||||||
/* And convert the time back to broken out format */
|
|
||||||
|
|
||||||
(void)gmtime_r(&seconds, (FAR struct tm *)&setalarm.time);
|
|
||||||
|
|
||||||
/* The set the alarm using this absolute time */
|
|
||||||
|
|
||||||
setalarm.id = alarminfo->id;
|
|
||||||
setalarm.cb = alarminfo->cb;
|
|
||||||
setalarm.priv = alarminfo->priv;
|
|
||||||
|
|
||||||
ret = ez80_setalarm(lower, &setalarm);
|
|
||||||
}
|
|
||||||
|
|
||||||
sched_unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sched_unlock();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -486,8 +478,8 @@ static int ez80_setrelative(FAR struct rtc_lowerhalf_s *lower,
|
|||||||
* method of the RTC driver interface
|
* method of the RTC driver interface
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* lower - A reference to RTC lower half driver state structure
|
* lower - A reference to RTC lower half driver state structure
|
||||||
* alarminfo - Provided information needed to set the alarm
|
* alarmid - Must be zero
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* Zero (OK) is returned on success; a negated errno value is returned
|
* Zero (OK) is returned on success; a negated errno value is returned
|
||||||
@@ -496,13 +488,14 @@ static int ez80_setrelative(FAR struct rtc_lowerhalf_s *lower,
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_RTC_ALARM
|
#ifdef CONFIG_RTC_ALARM
|
||||||
static int ez80_cancelalarm(FAR struct rtc_lowerhalf_s *lower)
|
static int ez80_cancelalarm(FAR struct rtc_lowerhalf_s *lower, int alarmid)
|
||||||
{
|
{
|
||||||
FAR struct ez80_lowerhalf_s *priv;
|
FAR struct ez80_lowerhalf_s *priv;
|
||||||
FAR struct ez80_cbinfo_s *cbinfo;
|
FAR struct ez80_cbinfo_s *cbinfo;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
DEBUGASSERT(lower != NULL);
|
DEBUGASSERT(lower != NULL && alarmid == 0);
|
||||||
|
|
||||||
priv = (FAR struct ez80_lowerhalf_s *)lower;
|
priv = (FAR struct ez80_lowerhalf_s *)lower;
|
||||||
|
|
||||||
ret = nxsem_wait(&priv->devsem);
|
ret = nxsem_wait(&priv->devsem);
|
||||||
@@ -533,7 +526,7 @@ static int ez80_cancelalarm(FAR struct rtc_lowerhalf_s *lower)
|
|||||||
* Query the RTC alarm.
|
* Query the RTC alarm.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* lower - A reference to RTC lower half driver state structure
|
* lower - A reference to RTC lower half driver state structure
|
||||||
* alarminfo - Provided information needed to query the alarm
|
* alarminfo - Provided information needed to query the alarm
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
@@ -544,24 +537,19 @@ static int ez80_cancelalarm(FAR struct rtc_lowerhalf_s *lower)
|
|||||||
|
|
||||||
#ifdef CONFIG_RTC_ALARM
|
#ifdef CONFIG_RTC_ALARM
|
||||||
static int ez80_rdalarm(FAR struct rtc_lowerhalf_s *lower,
|
static int ez80_rdalarm(FAR struct rtc_lowerhalf_s *lower,
|
||||||
FAR struct lower_rdalarm_s *alarminfo)
|
FAR struct lower_rdalarm_s *alarminfo)
|
||||||
{
|
{
|
||||||
struct alm_rdalarm_s lowerinfo;
|
|
||||||
int ret = -EINVAL;
|
int ret = -EINVAL;
|
||||||
|
|
||||||
DEBUGASSERT(lower != NULL && alarminfo != NULL && alarminfo->time != NULL);
|
DEBUGASSERT(lower != NULL && alarminfo != NULL &&
|
||||||
DEBUGASSERT(alarminfo->id == RTC_ALARMA || alarminfo->id == RTC_ALARMB);
|
alarminfo->time != NULL && alarminfo->id == 0);
|
||||||
|
|
||||||
/* Disable pre-emption while we do this so that we don't have to worry
|
/* Disable pre-emption while we do this so that we don't have to worry
|
||||||
* about being suspended and working on an old time.
|
* about being suspended and working on an old time.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
sched_lock();
|
sched_lock();
|
||||||
|
ret = ez80_rtc_rdalarm((FAR struct tm *)alarminfo->time);
|
||||||
lowerinfo.ar_id = alarminfo->id;
|
|
||||||
lowerinfo.ar_time = alarminfo->time;
|
|
||||||
|
|
||||||
ret = ez80_rtc_rdalarm(&lowerinfo);
|
|
||||||
sched_unlock();
|
sched_unlock();
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
@@ -369,8 +369,6 @@ static int spi_transfer(uint8_t chout, FAR uint8_t *chin)
|
|||||||
uint8_t response;
|
uint8_t response;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
spiinfo("chout: %02x\n", chout);
|
|
||||||
|
|
||||||
/* Send the byte, repeating if some error occurs */
|
/* Send the byte, repeating if some error occurs */
|
||||||
|
|
||||||
for (; ; )
|
for (; ; )
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* arch/z80/src/ez80/ez80f91.h
|
* arch/z80/src/ez80/ez80f91.h
|
||||||
* arch/z80/src/chip/ez80f91.h
|
|
||||||
*
|
*
|
||||||
* Copyright (C) 2008, 2009 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2008, 2009 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
@@ -315,7 +314,7 @@
|
|||||||
#define EZ80_SPI_CTL 0xba
|
#define EZ80_SPI_CTL 0xba
|
||||||
#define EZ80_SPI_SR 0xbb
|
#define EZ80_SPI_SR 0xbb
|
||||||
#define EZ80_SPI_RBR 0xbc
|
#define EZ80_SPI_RBR 0xbc
|
||||||
#define EZ80_SPI_TSR 0xbd
|
#define EZ80_SPI_TSR 0xbc
|
||||||
|
|
||||||
/* UART Register Offsets *************************************************************/
|
/* UART Register Offsets *************************************************************/
|
||||||
/* DLAB=0: */
|
/* DLAB=0: */
|
||||||
|
|||||||
@@ -305,9 +305,35 @@ Configuration Subdirectories
|
|||||||
nsh> date
|
nsh> date
|
||||||
Sun, Jun 16 15:09:01 2019
|
Sun, Jun 16 15:09:01 2019
|
||||||
|
|
||||||
The SD card can be be mounted with the following NSH mount command:
|
When the system boots, it will probe the SD card and create a
|
||||||
|
block driver called mmcsd0:
|
||||||
|
|
||||||
|
nsh> ls /dev
|
||||||
|
/dev:
|
||||||
|
console
|
||||||
|
mmcsd0
|
||||||
|
null
|
||||||
|
ttyS0
|
||||||
|
nsh> mount
|
||||||
|
/proc type procfs
|
||||||
|
|
||||||
|
The SD card can be mounted with the following NSH mount command:
|
||||||
|
|
||||||
nsh> mount -t vfat /dev/mmcsd0 /mnt/sdcard
|
nsh> mount -t vfat /dev/mmcsd0 /mnt/sdcard
|
||||||
|
nsh> ls /mnt
|
||||||
|
/mnt:
|
||||||
|
sdcard/
|
||||||
|
nsh> mount
|
||||||
|
/mnt/sdcard type vfat
|
||||||
|
/proc type procfs
|
||||||
|
nsh> ls -lR /mnt/sdcard
|
||||||
|
/mnt/sdcard:
|
||||||
|
drw-rw-rw- 0 System Volume Information/
|
||||||
|
/mnt/sdcard/System Volume Information:
|
||||||
|
-rw-rw-rw- 76 IndexerVolumeGuid
|
||||||
|
-rw-rw-rw- 12 WPSettings.dat
|
||||||
|
|
||||||
|
You can they use the SD card as any other file system.
|
||||||
|
|
||||||
NOTE: The is no card detect signal so the microSD card must be
|
NOTE: The is no card detect signal so the microSD card must be
|
||||||
placed in the card slot before the system is started.
|
placed in the card slot before the system is started.
|
||||||
@@ -322,10 +348,11 @@ Configuration Subdirectories
|
|||||||
hangs and prevents booting, and (2) RTC does not preserve time across a
|
hangs and prevents booting, and (2) RTC does not preserve time across a
|
||||||
power cycle.
|
power cycle.
|
||||||
|
|
||||||
2019-06-17: The SD initialization is due to some error in the SPI driver:
|
2019-06-17: The SD initialization was due to some error in the SPI driver:
|
||||||
It waits for a byte transfer to complete but it never receives the
|
It waits for a byte transfer to complete but it never receives the
|
||||||
indication that the transfer completed. The SPI problem has not been
|
indication that the transfer completed. That SPI problem has been
|
||||||
fixed, but timeout logic was added to avoid the hang.
|
fixed and now the SD card is partially functional.
|
||||||
|
|
||||||
|
Reads from the SD are successful, but writes to the SD card (creating
|
||||||
|
files, creating directories, etc) hang.
|
||||||
|
|
||||||
The MMC/SD start-up failures do effect the boot-up time. You might want
|
|
||||||
to disable SPI to avoid start-up delays.
|
|
||||||
|
|||||||
Reference in New Issue
Block a user