GR-MANGO sample using mbed-os library from my repository.

Dependencies:   mbed-http

Committer:
RyoheiHagimoto
Date:
Mon Oct 12 02:25:49 2020 +0000
Revision:
0:b4c1e32627f2
replaced mbed-os library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
RyoheiHagimoto 0:b4c1e32627f2 1 /*******************************************************************************
RyoheiHagimoto 0:b4c1e32627f2 2 * DISCLAIMER
RyoheiHagimoto 0:b4c1e32627f2 3 * This software is supplied by Renesas Electronics Corporation and is only
RyoheiHagimoto 0:b4c1e32627f2 4 * intended for use with Renesas products. No other uses are authorized. This
RyoheiHagimoto 0:b4c1e32627f2 5 * software is owned by Renesas Electronics Corporation and is protected under
RyoheiHagimoto 0:b4c1e32627f2 6 * all applicable laws, including copyright laws.
RyoheiHagimoto 0:b4c1e32627f2 7 * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
RyoheiHagimoto 0:b4c1e32627f2 8 * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
RyoheiHagimoto 0:b4c1e32627f2 9 * LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
RyoheiHagimoto 0:b4c1e32627f2 10 * AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
RyoheiHagimoto 0:b4c1e32627f2 11 * TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
RyoheiHagimoto 0:b4c1e32627f2 12 * ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
RyoheiHagimoto 0:b4c1e32627f2 13 * FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
RyoheiHagimoto 0:b4c1e32627f2 14 * ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
RyoheiHagimoto 0:b4c1e32627f2 15 * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
RyoheiHagimoto 0:b4c1e32627f2 16 * Renesas reserves the right, without notice, to make changes to this software
RyoheiHagimoto 0:b4c1e32627f2 17 * and to discontinue the availability of this software. By using this software,
RyoheiHagimoto 0:b4c1e32627f2 18 * you agree to the additional terms and conditions found by accessing the
RyoheiHagimoto 0:b4c1e32627f2 19 * following link:
RyoheiHagimoto 0:b4c1e32627f2 20 * http://www.renesas.com/disclaimer
RyoheiHagimoto 0:b4c1e32627f2 21 *
RyoheiHagimoto 0:b4c1e32627f2 22 * Copyright (C) 2019 Renesas Electronics Corporation. All rights reserved.
RyoheiHagimoto 0:b4c1e32627f2 23 *******************************************************************************/
RyoheiHagimoto 0:b4c1e32627f2 24 #include "sample_select.h"
RyoheiHagimoto 0:b4c1e32627f2 25
RyoheiHagimoto 0:b4c1e32627f2 26 #if (SAMPLE_PROGRAM_NO == 21)
RyoheiHagimoto 0:b4c1e32627f2 27 // SAMPLE_PROGRAM_NO 21 : Deep standby and RTC alarm sample
RyoheiHagimoto 0:b4c1e32627f2 28 //
RyoheiHagimoto 0:b4c1e32627f2 29 // Wake up from deep standby every 5 seconds using RTC alarm interrupt.
RyoheiHagimoto 0:b4c1e32627f2 30 // It also wakes up when BUTTON1(SW2) is pressed.
RyoheiHagimoto 0:b4c1e32627f2 31
RyoheiHagimoto 0:b4c1e32627f2 32 #include "mbed.h"
RyoheiHagimoto 0:b4c1e32627f2 33 #include "AlarmTimer.h"
RyoheiHagimoto 0:b4c1e32627f2 34 #include "DeepStandby.h"
RyoheiHagimoto 0:b4c1e32627f2 35
RyoheiHagimoto 0:b4c1e32627f2 36 // On-Chip Data Retention RAM
RyoheiHagimoto 0:b4c1e32627f2 37 #if defined ( __CC_ARM ) || (defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))
RyoheiHagimoto 0:b4c1e32627f2 38 #define DATA_RETENTION_RAM ".bss.NoInit"
RyoheiHagimoto 0:b4c1e32627f2 39 #else
RyoheiHagimoto 0:b4c1e32627f2 40 #define DATA_RETENTION_RAM "NV_DATA"
RyoheiHagimoto 0:b4c1e32627f2 41 #endif
RyoheiHagimoto 0:b4c1e32627f2 42 static int wake_up_cnt __attribute((section(DATA_RETENTION_RAM)));
RyoheiHagimoto 0:b4c1e32627f2 43
RyoheiHagimoto 0:b4c1e32627f2 44 int main() {
RyoheiHagimoto 0:b4c1e32627f2 45 time_t seconds;
RyoheiHagimoto 0:b4c1e32627f2 46 DeepStandby::cancel_src_simple_t cancel_src;
RyoheiHagimoto 0:b4c1e32627f2 47
RyoheiHagimoto 0:b4c1e32627f2 48 if (DeepStandby::GetCancelSourceSimple(&cancel_src) == false) {
RyoheiHagimoto 0:b4c1e32627f2 49 // Reset start
RyoheiHagimoto 0:b4c1e32627f2 50 printf("Reset start\r\n");
RyoheiHagimoto 0:b4c1e32627f2 51 // initialization of On-Chip Data Retention RAM
RyoheiHagimoto 0:b4c1e32627f2 52 wake_up_cnt = 0;
RyoheiHagimoto 0:b4c1e32627f2 53 } else {
RyoheiHagimoto 0:b4c1e32627f2 54 // Deep standby cancel
RyoheiHagimoto 0:b4c1e32627f2 55 wake_up_cnt++;
RyoheiHagimoto 0:b4c1e32627f2 56 printf("Deep standby cancel %d :", wake_up_cnt);
RyoheiHagimoto 0:b4c1e32627f2 57 if (cancel_src.button0) { // Works with RZ_A2M_EVB and SEMB1402.
RyoheiHagimoto 0:b4c1e32627f2 58 printf(" BUTTON0");
RyoheiHagimoto 0:b4c1e32627f2 59 }
RyoheiHagimoto 0:b4c1e32627f2 60 if (cancel_src.button1) { // Works with RZ_A2M_EVB and RZ_A2M_SBEV.
RyoheiHagimoto 0:b4c1e32627f2 61 printf(" BUTTON1");
RyoheiHagimoto 0:b4c1e32627f2 62 }
RyoheiHagimoto 0:b4c1e32627f2 63 if (cancel_src.rtc) { // Works with RZ_A1H, RZ_A2M_EVB, RZ_A2M_SBEV and SEMB1402.
RyoheiHagimoto 0:b4c1e32627f2 64 printf(" RTC");
RyoheiHagimoto 0:b4c1e32627f2 65 }
RyoheiHagimoto 0:b4c1e32627f2 66 printf("\r\n");
RyoheiHagimoto 0:b4c1e32627f2 67 }
RyoheiHagimoto 0:b4c1e32627f2 68
RyoheiHagimoto 0:b4c1e32627f2 69 // RTC time
RyoheiHagimoto 0:b4c1e32627f2 70 seconds = time(NULL);
RyoheiHagimoto 0:b4c1e32627f2 71 struct tm *t = localtime(&seconds);
RyoheiHagimoto 0:b4c1e32627f2 72 printf("RTC time : %02d/%02d/%04d %02d:%02d:%02d\r\n\r\n",
RyoheiHagimoto 0:b4c1e32627f2 73 t->tm_mon + 1, t->tm_mday, t->tm_year + 1900, t->tm_hour, t->tm_min, t->tm_sec);
RyoheiHagimoto 0:b4c1e32627f2 74
RyoheiHagimoto 0:b4c1e32627f2 75 // Set alarm interrupt
RyoheiHagimoto 0:b4c1e32627f2 76 AlarmTimer::set(seconds + 5); // 5 seconds later
RyoheiHagimoto 0:b4c1e32627f2 77
RyoheiHagimoto 0:b4c1e32627f2 78 // Set deep standby mode
RyoheiHagimoto 0:b4c1e32627f2 79 cancel_src.button0 = false; // Works with RZ_A2M_EVB and SEMB1402. (Used with custom boot loader)
RyoheiHagimoto 0:b4c1e32627f2 80 cancel_src.button1 = true; // Works with RZ_A2M_EVB and RZ_A2M_SBEV.
RyoheiHagimoto 0:b4c1e32627f2 81 cancel_src.rtc = true; // Works with RZ_A1H, RZ_A2M_EVB, RZ_A2M_SBEV and SEMB1402.
RyoheiHagimoto 0:b4c1e32627f2 82 DeepStandby::SetDeepStandbySimple(&cancel_src);
RyoheiHagimoto 0:b4c1e32627f2 83 }
RyoheiHagimoto 0:b4c1e32627f2 84
RyoheiHagimoto 0:b4c1e32627f2 85 #endif