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:
parent
df5ed6e08a
commit
4d78132c46
@ -111,7 +111,7 @@ static int ez80_setalarm(FAR struct rtc_lowerhalf_s *lower,
|
||||
FAR const struct lower_setalarm_s *alarminfo);
|
||||
static int ez80_setrelative(FAR struct rtc_lowerhalf_s *lower,
|
||||
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,
|
||||
FAR struct lower_rdalarm_s *alarminfo);
|
||||
#endif
|
||||
@ -124,24 +124,24 @@ static int ez80_rdalarm(FAR struct rtc_lowerhalf_s *lower,
|
||||
|
||||
static const struct rtc_ops_s g_rtc_ops =
|
||||
{
|
||||
.rdtime = ez80_rdtime,
|
||||
.settime = ez80_settime,
|
||||
.havesettime = ez80_havesettime,
|
||||
ez80_rdtime, /* rdtime */
|
||||
ez80_settime, /* settime */
|
||||
ez80_havesettime /* havesettime */
|
||||
#ifdef CONFIG_RTC_ALARM
|
||||
.setalarm = ez80_setalarm,
|
||||
.setrelative = ez80_setrelative,
|
||||
.cancelalarm = ez80_cancelalarm,
|
||||
.rdalarm = ez80_rdalarm,
|
||||
, ez80_setalarm, /* setalarm */
|
||||
ez80_setrelative, /* setrelative */
|
||||
ez80_cancelalarm, /* cancelalarm */
|
||||
ez80_rdalarm /* rdalarm */
|
||||
#endif
|
||||
#ifdef CONFIG_RTC_PERIODIC
|
||||
.setperiodic = NULL,
|
||||
.cancelperiodic = NULL,
|
||||
, NULL, /* setperiodic */
|
||||
NULL /* cancelperiodic */
|
||||
#endif
|
||||
#ifdef CONFIG_RTC_IOCTL
|
||||
.ioctl = NULL,
|
||||
, NULL /* ioctl */
|
||||
#endif
|
||||
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
|
||||
.destroy = NULL,
|
||||
, NULL /* destroy */
|
||||
#endif
|
||||
};
|
||||
|
||||
@ -149,7 +149,7 @@ static const struct rtc_ops_s g_rtc_ops =
|
||||
|
||||
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)
|
||||
{
|
||||
cb(priv);
|
||||
cb(priv, 0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -326,7 +326,7 @@ static int ez80_settime(FAR struct rtc_lowerhalf_s *lower,
|
||||
* Implements the havesettime() method of the RTC driver interface
|
||||
*
|
||||
* Input Parameters:
|
||||
* lower - A reference to RTC lower half driver state structure
|
||||
* lower - A reference to RTC lower half driver state structure
|
||||
*
|
||||
* Returned Value:
|
||||
* 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)
|
||||
{
|
||||
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 */
|
||||
|
||||
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;
|
||||
|
||||
ret = nxsem_wait(&priv->devsem);
|
||||
@ -381,11 +382,9 @@ static int ez80_setalarm(FAR struct rtc_lowerhalf_s *lower,
|
||||
cbinfo = &priv->cbinfo;
|
||||
cbinfo->cb = alarminfo->cb;
|
||||
cbinfo->priv = alarminfo->priv;
|
||||
cbinfo->id = alarminfo->id;
|
||||
|
||||
/* Set the alarm */
|
||||
|
||||
lowerinfo.as_id = alarminfo->id;
|
||||
lowerinfo.as_cb = ez80_alarm_callback;
|
||||
lowerinfo.as_arg = priv;
|
||||
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;
|
||||
int ret = -EINVAL;
|
||||
|
||||
DEBUGASSERT(lower != NULL && alarminfo != NULL);
|
||||
DEBUGASSERT(alarminfo->id == RTC_ALARMA || alarminfo->id == RTC_ALARMB);
|
||||
DEBUGASSERT(lower != NULL && alarminfo != NULL && alarminfo->id == 0);
|
||||
|
||||
if ((alarminfo->id == RTC_ALARMA || alarminfo->id == RTC_ALARMB) &&
|
||||
alarminfo->reltime > 0)
|
||||
/* Disable pre-emption while we do this so that we don't have to worry
|
||||
* 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
|
||||
* about being suspended and working on an old time.
|
||||
/* Convert to seconds since the epoch */
|
||||
|
||||
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);
|
||||
if (ret >= 0)
|
||||
{
|
||||
/* Convert to seconds since the epoch */
|
||||
(void)gmtime_r(&seconds, (FAR struct tm *)&setalarm.time);
|
||||
|
||||
seconds = mktime(&time);
|
||||
/* The set the alarm using this absolute time */
|
||||
|
||||
/* Add the seconds offset. Add one to the number of seconds
|
||||
* because we are unsure of the phase of the timer.
|
||||
*/
|
||||
setalarm.cb = alarminfo->cb;
|
||||
setalarm.priv = alarminfo->priv;
|
||||
|
||||
seconds += (alarminfo->reltime + 1);
|
||||
|
||||
/* 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();
|
||||
ret = ez80_setalarm(lower, &setalarm);
|
||||
}
|
||||
|
||||
sched_unlock();
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
@ -486,8 +478,8 @@ static int ez80_setrelative(FAR struct rtc_lowerhalf_s *lower,
|
||||
* method of the RTC driver interface
|
||||
*
|
||||
* Input Parameters:
|
||||
* lower - A reference to RTC lower half driver state structure
|
||||
* alarminfo - Provided information needed to set the alarm
|
||||
* lower - A reference to RTC lower half driver state structure
|
||||
* alarmid - Must be zero
|
||||
*
|
||||
* Returned Value:
|
||||
* 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
|
||||
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_cbinfo_s *cbinfo;
|
||||
int ret;
|
||||
|
||||
DEBUGASSERT(lower != NULL);
|
||||
DEBUGASSERT(lower != NULL && alarmid == 0);
|
||||
|
||||
priv = (FAR struct ez80_lowerhalf_s *)lower;
|
||||
|
||||
ret = nxsem_wait(&priv->devsem);
|
||||
@ -533,7 +526,7 @@ static int ez80_cancelalarm(FAR struct rtc_lowerhalf_s *lower)
|
||||
* Query the RTC alarm.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* Returned Value:
|
||||
@ -544,24 +537,19 @@ static int ez80_cancelalarm(FAR struct rtc_lowerhalf_s *lower)
|
||||
|
||||
#ifdef CONFIG_RTC_ALARM
|
||||
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;
|
||||
|
||||
DEBUGASSERT(lower != NULL && alarminfo != NULL && alarminfo->time != NULL);
|
||||
DEBUGASSERT(alarminfo->id == RTC_ALARMA || alarminfo->id == RTC_ALARMB);
|
||||
DEBUGASSERT(lower != NULL && alarminfo != NULL &&
|
||||
alarminfo->time != NULL && alarminfo->id == 0);
|
||||
|
||||
/* Disable pre-emption while we do this so that we don't have to worry
|
||||
* about being suspended and working on an old time.
|
||||
*/
|
||||
|
||||
sched_lock();
|
||||
|
||||
lowerinfo.ar_id = alarminfo->id;
|
||||
lowerinfo.ar_time = alarminfo->time;
|
||||
|
||||
ret = ez80_rtc_rdalarm(&lowerinfo);
|
||||
ret = ez80_rtc_rdalarm((FAR struct tm *)alarminfo->time);
|
||||
sched_unlock();
|
||||
|
||||
return ret;
|
||||
|
@ -369,8 +369,6 @@ static int spi_transfer(uint8_t chout, FAR uint8_t *chin)
|
||||
uint8_t response;
|
||||
int ret;
|
||||
|
||||
spiinfo("chout: %02x\n", chout);
|
||||
|
||||
/* Send the byte, repeating if some error occurs */
|
||||
|
||||
for (; ; )
|
||||
|
@ -1,6 +1,5 @@
|
||||
/************************************************************************************
|
||||
* arch/z80/src/ez80/ez80f91.h
|
||||
* arch/z80/src/chip/ez80f91.h
|
||||
*
|
||||
* Copyright (C) 2008, 2009 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
@ -315,7 +314,7 @@
|
||||
#define EZ80_SPI_CTL 0xba
|
||||
#define EZ80_SPI_SR 0xbb
|
||||
#define EZ80_SPI_RBR 0xbc
|
||||
#define EZ80_SPI_TSR 0xbd
|
||||
#define EZ80_SPI_TSR 0xbc
|
||||
|
||||
/* UART Register Offsets *************************************************************/
|
||||
/* DLAB=0: */
|
||||
|
@ -305,9 +305,35 @@ Configuration Subdirectories
|
||||
nsh> date
|
||||
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> 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
|
||||
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
|
||||
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
|
||||
indication that the transfer completed. The SPI problem has not been
|
||||
fixed, but timeout logic was added to avoid the hang.
|
||||
indication that the transfer completed. That SPI problem has been
|
||||
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.
|
||||
|
Loading…
Reference in New Issue
Block a user