Barometer program : Data Logger function includes Barometer & temperature (BMP180), Humidity & temp. (RHT03), Sunshine (Cds), RTC(M41T62) data. : Logging data saves into EEPROM (AT24C1024) using ring buffer function.
Dependencies: AT24C1024 RHT03 TextLCD BMP180 M41T62
Fork of mbed_blinky by
Please see https://mbed.org/users/kenjiArai/notebook/mbed-lpc1114fn28-barometer-with-data-logging/#
Diff: mon_hw.cpp
- Revision:
- 18:b3a27f681171
- Parent:
- 16:f164f8912201
diff -r f81a6c9e5f7b -r b3a27f681171 mon_hw.cpp --- a/mon_hw.cpp Thu Jul 03 23:07:13 2014 +0000 +++ b/mon_hw.cpp Sat Aug 08 07:01:19 2020 +0000 @@ -1,19 +1,17 @@ +#if 0 +//?????????????????????????????????????????????????????????????????????????????? +// Due to ROM & RAM size limitation +//?????????????????????????????????????????????????????????????????????????????? + /* * mbed Application program for the mbed LPC1114FN28 * Monitor program Ver.2 for only LPC1114FN28 * - * Copyright (c) 2010-2014 Kenji Arai / JH1PJL - * http://www.page.sannet.ne.jp/kenjia/index.html - * http://mbed.org/users/kenjiArai/ - * Created: May 15th, 2010 - * Spareted: June 25th, 2014 mon() & mon_hw() - * Revised: July 3rd, 2014 - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, - * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE - * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * Copyright (c) 2014,'20 Kenji Arai / JH1PJL + * http://www7b.biglobe.ne.jp/~kenjia/ + * https://os.mbed.com/users/kenjiArai/ + * Created: June 1st, 2014 + * Revised: August 8th, 2020 */ /* * Function @@ -26,11 +24,11 @@ #include "mbed.h" #include "AT24C1024.h" // Own lib. / EEPROM control #include "mon_hw_config.h" +#include "redirect_stdio.h" // Object ---------------------------------------------------------------------------------------- -extern Serial pcx(dp16,dp15); -extern I2C xxi2c(dp5,dp27); // SDA, SCL -extern AT24C1024 xat24c1024(xxi2c); // Atmel 1Mbit EE-PROM +extern I2C xxi2c; // SDA, SCL +extern AT24C1024 xat24c1024; // Atmel 1Mbit EE-PROM // Definition ------------------------------------------------------------------------------------ // Define clocks @@ -53,11 +51,10 @@ #define IO_ALL 0 #define IO_I2C 1 -#define BAUD(x) pcx.baud(x) -#define GETC(x) pcx.getc(x) -#define PUTC(x) pcx.putc(x) -#define PRINTF(...) pcx.printf(__VA_ARGS__) -#define READABLE(x) pcx.readable(x) +#define GETC(x) getc(x) +#define PUTC(x) putc(x) +#define PRINTF(...) printf(__VA_ARGS__) +#define READABLE(x) readable(x) typedef struct { unsigned long mstr; @@ -95,11 +92,11 @@ { 0x50000000, 0x501fffff } // IO area }; -static char *const rmsg0 = "FLASH "; -static char *const rmsg1 = "SRAM "; -static char *const rmsg2 = "BOOT ROM "; -static char *const rmsg3 = "IO "; -static char *const rmsg4 = "IO "; +static const char *const rmsg0 = "FLASH "; +static const char *const rmsg1 = "SRAM "; +static const char *const rmsg2 = "BOOT ROM "; +static const char *const rmsg3 = "IO "; +static const char *const rmsg4 = "IO "; #endif // USE_MEM #if USE_EEP @@ -113,7 +110,7 @@ #endif // ROM / Constant data --------------------------------------------------------------------------- -static char *const mon_msg_hw = "HW monitor only for mbed LPC1114FN28"; +static const char *const mon_msg_hw = "HW monitor only for mbed LPC1114FN28"; // Function prototypes --------------------------------------------------------------------------- extern char linebuf[]; @@ -183,25 +180,25 @@ put_rn(); } -char *const imsg2 = "-->Control Reg."; -char *const imsg3 = "-->Status Reg."; -char *const imsg4 = "-->Data Reg."; -//static char *const imsg5 = "-->Baud rate Reg."; -//static char *const imsg6 = "-->Own address Reg."; -char *const imsg7 = "-->Clock control Reg."; -//static char *const imsg8 = "-->TRISE Reg."; +const char *const imsg2 = "-->Control Reg."; +const char *const imsg3 = "-->Status Reg."; +const char *const imsg4 = "-->Data Reg."; +//static const char *const imsg5 = "-->Baud rate Reg."; +//static const char *const imsg6 = "-->Own address Reg."; +const char *const imsg7 = "-->Clock control Reg."; +//static const char *const imsg8 = "-->TRISE Reg."; -static char *const io_port_name0 = "PIO0_"; -static char *const io_port_name1 = "PIO1_"; -static char *const iomsg0 = "Func->select "; -static char *const iomsg1 = "IO"; -static char *const iomsg2 = "Reserved"; -static char *const iomsg30 = "B0_MAT"; -static char *const iomsg31 = "B1_MAT"; -static char *const iomsg4 = "Std/F-md I2C"; -static char *const iomsg5 = "func. R"; -static char *const iomsg6 = "D-Mode"; -static char *const iomsg7 = "A-Mode"; +static const char *const io_port_name0 = "PIO0_"; +static const char *const io_port_name1 = "PIO1_"; +static const char *const iomsg0 = "Func->select "; +static const char *const iomsg1 = "IO"; +static const char *const iomsg2 = "Reserved"; +static const char *const iomsg30 = "B0_MAT"; +static const char *const iomsg31 = "B1_MAT"; +static const char *const iomsg4 = "Std/F-md I2C"; +static const char *const iomsg5 = "func. R"; +static const char *const iomsg6 = "D-Mode"; +static const char *const iomsg7 = "A-Mode"; // Show 16bit register contents void reg_print(uint16_t size, uint16_t reg){ @@ -802,22 +799,22 @@ put_rn(); } m2 = (m1 >> 20) & 0x0f; - PRINTF("Variant:%x", m2); + PRINTF("Variant:%x", (int)m2); put_rn(); m2 = m1 & 0x7; - PRINTF("Revision:%x", m2); + PRINTF("Revision:%x", (int)m2); put_rn(); } // Calculate CPU System Clock Frequency /refrence: system_LPCxx.c -static char *const fmsg0 = "Internal RC Oscillator"; -static char *const fmsg1 = "Xtal Osc Clock"; -static char *const fmsg2 = "Watch dog Osc Clock"; -static char *const fmsg3 = "with PLL"; -static char *const fmsg4 = "System Clock ="; -static char *const fmsg5 = "PLL Post divider ratio ="; -static char *const fmsg6 = "feedback devider ="; -static char *const fmsg7 = "NO Clock ?!"; +static const char *const fmsg0 = "Internal RC Oscillator"; +static const char *const fmsg1 = "Xtal Osc Clock"; +static const char *const fmsg2 = "Watch dog Osc Clock"; +static const char *const fmsg3 = "with PLL"; +static const char *const fmsg4 = "System Clock ="; +static const char *const fmsg5 = "PLL Post divider ratio ="; +static const char *const fmsg6 = "feedback devider ="; +static const char *const fmsg7 = "NO Clock ?!"; void get_freq_w_print (void){ // Get Core Clock Frequency uint32_t wdt_osc = 0, pll_fct0 = 0, pll_fct1 = 0; @@ -882,7 +879,7 @@ pll_fct0 = (LPC_SYSCON->SYSPLLCTRL & 0x01F) + 1; pll_fct1 = (LPC_SYSCON->SYSPLLCTRL & 0x060) >> 5UL; SystemCoreClock = __IRC_OSC_CLK * pll_fct0; - PRINTF("Use Internal RC = %dHz", __IRC_OSC_CLK); + PRINTF("Use Internal RC = %dHz", (int)__IRC_OSC_CLK); put_rn(); PRINTF("%s %s = %dHz", fmsg0, fmsg3, SystemCoreClock); put_rn(); @@ -897,7 +894,7 @@ pll_fct0 = (LPC_SYSCON->SYSPLLCTRL & 0x01F) + 1; pll_fct1 = (LPC_SYSCON->SYSPLLCTRL & 0x060) >> 5UL; SystemCoreClock = __SYS_OSC_CLK * pll_fct0; - PRINTF("Use XTAL = %dHz", __XTAL); + PRINTF("Use XTAL = %dHz", (int)__XTAL); put_rn(); PRINTF("%s %s = %dHz", fmsg1, fmsg3, SystemCoreClock); put_rn(); @@ -1382,8 +1379,9 @@ ){ uint32_t i; uint8_t eep[16]; - - PRINTF("%08lx ", addr); // address + //????????????????????????????????????????????????????????????????????????? + #warning "?????" + PRINTF("%08x ", (int)addr); // address for (i = 0; i < len; i++) { // Hexdecimal dump eep[i] = xat24c1024.read(addr++); PRINTF(" %02x", eep[i]); @@ -1509,7 +1507,7 @@ if (xatoi(&ptr, &p2)) { // 2nd parameter is given do { xat24c1024.write((uint16_t)p1, (uint8_t)p2); - wait(0.01); + ThisThread::sleep_for(10ms); dt = xat24c1024.read((uint16_t)p1); if (dt != (uint8_t)p2){ PRINTF("?\r\n"); @@ -1519,7 +1517,7 @@ break; } for (;;) {// 2nd parameter is not given (interactive mode) - PRINTF("%08x 0x%02x-", p1, *(BYTE*)p1); + PRINTF("%08x 0x%02x-", (int)p1, *(BYTE*)p1); ptr = linebuf; get_line(ptr, buf_size); if (*ptr == '.'){ break;} @@ -1527,7 +1525,7 @@ if ((BYTE)*ptr >= ' ') { if (!xatoi(&ptr, &p2)){ continue;} xat24c1024.write((uint16_t)p1, (uint8_t)p2); - wait(0.01); + ThisThread::sleep_for(10ms); dt = xat24c1024.read((uint16_t)p1); if (dt != (uint8_t)p2){ PRINTF("?\r\n"); @@ -1539,7 +1537,9 @@ case 's' : PRINTF("AT24C1024B"); put_rn(); - PRINTF("EEPROM 0x%08lx to 0x%08lx", eepmem_range[0], eepmem_range[1]); + //????????????????????????????????????????????????????????????????????????? + #warning "?????" + PRINTF("EEPROM 0x%08lx to 0x%08lx", (int)eepmem_range[0], (int)eepmem_range[1]); put_rn(); break; case '?' : @@ -1804,3 +1804,5 @@ } } } + +#endif \ No newline at end of file