Skip to content

Add RTC driver for GRiSP2 Charger #50

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
23 changes: 23 additions & 0 deletions demo/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
*/

#undef EVENT_RECORDING
#define RTC_ENABLED

#include <assert.h>
#include <stdlib.h>
Expand All @@ -45,6 +46,10 @@
#include <rtems/stringto.h>
#include <rtems/ftpd.h>
#include <machine/rtems-bsd-commands.h>
#ifdef RTC_ENABLED
#include <libchip/rtc.h>
#include <libchip/mcp7940m-rtc.h>
#endif
#ifdef EVENT_RECORDING
#include <rtems/record.h>
#include <rtems/recordserver.h>
Expand Down Expand Up @@ -259,6 +264,10 @@ Init(rtems_task_argument arg)
assert(rv == 0);
#endif /* IS_GRISP2 */

#ifdef RTC_ENABLED
setRealTimeToRTEMS();
#endif

printf("Init EEPROM\n");
grisp_eeprom_init();
rv = grisp_eeprom_get(&eeprom);
Expand Down Expand Up @@ -307,6 +316,17 @@ Init(rtems_task_argument arg)
exit(0);
}

#ifdef RTC_ENABLED
static struct mcp7940m_rtc rtc_ctx =
MCP7940M_RTC_INITIALIZER("/dev/i2c-1", 0x6f, false);

rtc_tbl RTC_Table[] = {
MCP7940M_RTC_TBL_ENTRY("/dev/rtc", &rtc_ctx),
};

size_t RTC_Count = (sizeof(RTC_Table)/sizeof(rtc_tbl));
#endif

/*
* Configure LibBSD.
*/
Expand All @@ -321,6 +341,9 @@ Init(rtems_task_argument arg)
*/
#define CONFIGURE_MICROSECONDS_PER_TICK 10000

#ifdef RTC_ENABLED
#define CONFIGURE_APPLICATION_NEEDS_RTC_DRIVER
#endif
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_STUB_DRIVER
Expand Down