transmit example for LMIC_MOTE_L152RC

Dependencies:   lmic_MOTE_L152RC mbed-src

hello_main.cpp

Committer:
dudmuck
Date:
2015-06-02
Revision:
1:1ff358d55507
Parent:
0:cf8cd2f1ab24

File content as of revision 1:1ff358d55507:

#if 0

/*******************************************************************************
 * Copyright (c) 2014-2015 IBM Corporation.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    IBM Zurich Research Lab - initial API, implementation and documentation
 *******************************************************************************/

#include "lmic.h"
#include "debug.h"
#include "mbed.h"

/*#include "gps.h"
#include "sx9500.h"
#include "mma8451q.h"
#include "mpl3115a2.h"

GPS gps;
I2C i2c(I2C_SDA, I2C_SCL);
SX9500 sx9500(i2c, PA_9);
MMA8451Q mma8451q(i2c);
MPL3115A2 mpl3115a2(i2c);*/

// LMIC application callbacks not used in his example
void os_getArtEui (u1_t* buf) {
}

void os_getDevEui (u1_t* buf) {
}

void os_getDevKey (u1_t* buf) {
}

void onEvent (ev_t ev) {
}

/*static u1_t readReg (u1_t addr) {
    hal_pin_nss(0);
    hal_spi(addr & 0x7F);
    u1_t val = hal_spi(0x00);
    hal_pin_nss(1);
    return val;
}

void print_gpio()
{
    printf("GPIOA->MODER:%08x\r\n", GPIOA->MODER);
    printf("GPIOA->IDR:%04x\r\n", GPIOA->IDR);
    printf("GPIOA->ODR:%04x\r\n", GPIOA->ODR);
    printf("GPIOA->AFR:%x %x\r\n", GPIOA->AFR[0], GPIOA->AFR[1]);   // 0x40020020 0x40020024

    printf("GPIOB->MODER:%08x\r\n", GPIOB->MODER);
    printf("GPIOB->IDR:%04x\r\n", GPIOB->IDR);
    printf("GPIOB->ODR:%04x\r\n", GPIOB->ODR);
    printf("GPIOB->AFR:%x %x\r\n", GPIOB->AFR[0], GPIOB->AFR[1]);

    printf("GPIOC->MODER:%08x\r\n", GPIOC->MODER);
    printf("GPIOC->IDR:%04x\r\n", GPIOC->IDR);
    printf("GPIOC->ODR:%04x\r\n", GPIOC->ODR);
    printf("GPIOC->AFR:%x %x\r\n", GPIOC->AFR[0], GPIOC->AFR[1]);
    printf("opmode:%02x\r\n", readReg(0x01));
}*/
 
// counter
static int cnt = 0;

// log text to USART and toggle LED
static void initfunc (osjob_t* job) {
    //int ms = rand() & 0x7ff;    // 0 to 2sec
    //int ms = rand() & 0x7f;    //
    //int ms = 1000;
    //int ms_ticks = ms2osticks(ms);
    // say hello
    //debug_str("Hello World!\r\n");
    // log counter
    debug_val("cnt = ", cnt);
    //print_gpio();
    //debug("%d cnt = %d\r\n", ms_ticks, cnt);
    // toggle LED
    debug_led(++cnt & 1);
    // reschedule job every second
    os_setTimedCallback(job, os_getTime()+sec2osticks(1), initfunc);
    //os_setTimedCallback(job, os_getTime()+ms_ticks, initfunc);
    //os_setTimedCallback(job, os_getTime()+sec2osticks(10), initfunc);
    //os_setTimedCallback(job, os_getTime()+ms2osticks(50), initfunc);
}

// application entry point
int main () {
    osjob_t initjob;    
    
    /*gps.init();
    sx9500.standby();
    mpl3115a2.SetModeStandby();
    mma8451q.set_active(0);
    gps.enable(false);    */

    // initialize runtime env
    os_init();
    // initialize debug library
    debug_init();
    // setup initial job
    os_setCallback(&initjob, initfunc);
    // execute scheduled jobs and events
    os_runloop();
    // (not reached)
    return 0;
}
#endif /* #if 0 */