Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: Hotboards_rtcc mbed
Revision 0:7c98016e3c5e, committed 2016-02-10
- Comitter:
- Hotboards
- Date:
- Wed Feb 10 18:12:48 2016 +0000
- Commit message:
- first release
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Hotboards_rtcc.lib Wed Feb 10 18:12:48 2016 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/users/Hotboards/code/Hotboards_rtcc/#0790bcaf8b8f
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Wed Feb 10 18:12:48 2016 +0000
@@ -0,0 +1,62 @@
+
+/*
+ Hotboards_rtcc Library - alarm
+ Demonstrates the use a MCP7941x clock calendar. The Hotboards_rtcc
+ library works with this microchip real time clock
+ (http://www.hotboards.org).
+
+ This sketch set an single alarm that will be active
+ after one minute.
+ The circuit:
+ * VDD --> 3.3v
+ * GND --> GND
+ * SDA --> SDA
+ * SCL --> SCL
+
+*/
+#include "mbed.h"
+#include "Hotboards_rtcc.h"
+
+/* days of the week */
+const char *week[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
+/* months of the year */
+const char *months[] = {"JAN","FEB","MAR","APR","MAY","JUN", "JUL", "AUG","SEPT","OCT","NOV","DEC"};
+
+/*serial port init*/
+Serial pc(USBTX,USBRX);
+/*i2c instance delaration for use with the rtcc library*/
+I2C device(PB_9, PB_8);
+/*lets declare and rtcc instance */
+Hotboards_rtcc rtcc(device);
+
+int main()
+{
+ /*i2c bus clock set to 100khz*/
+ device.frequency(100000);
+ /* init the rtcc, just enable the clock if not already enable */
+ rtcc.begin();
+ /* set the time when is compiled*/
+ DateTime time( __DATE__, __TIME__);
+ rtcc.adjust(time);
+
+ /* Set an alarm after one minute */
+ DateTime alarm = time + TimeSpan( 0, 0, 1, 0 );
+ rtcc.setAlarm( alarm );
+ /* enable the alarm */
+ rtcc.turnOnAlarm( );
+
+ printf("The alarm will be active in one minute \n");
+
+ while(1)
+ {
+ /* is the alarm active?? */
+ if( rtcc.getAlarmStatus( ) == 1 )
+ {
+ /* clear the alarm */
+ rtcc.clearAlarm( );
+ /* display the time */
+ DateTime time = rtcc.now( );
+ printf( "Alarm active at: Time- %d:%d:%d Date- %s/ %d/ %s/ %d\n",time.hour( ),time.minute( ),time.second( ),week[time.dayOfTheWeek( )],time.day( ),months[time.month( )],time.year());
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Feb 10 18:12:48 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/f141b2784e32 \ No newline at end of file