Пример #1
0
/**
 * @brief Initialize and enable SysTick.
 *
 * Clocks the system timer with the core clock, turns it on, and
 * enables interrupts.
 *
 * @param reload_val Appropriate reload counter to tick every 1 ms.
 */
void systick_init(uint32_t reload_val) {
    memset(systick_handlers, 0, sizeof(systick_handlers));

    SysTick->LOAD = reload_val;
    systick_uptime_millis=0;
    systick_enable();
}
Пример #2
0
void setup()
{
    pinMode(CH_PD, OUTPUT);
    pinMode(ESP8266_RST, OUTPUT);
    pinMode(BOARD_BUTTON_PIN, INPUT);
    pinMode(BOARD_LED_PIN, OUTPUT);
    pinMode(LEFT_LIGHT, OUTPUT);
    pinMode(RIGHT_LIGHT, OUTPUT);

    light_blink_counter = -1;
    systick_enable();

    esp8266_serial_init(&esp8266_serial, ESP_SERIAL, ESP_SERIAL_BAUD);
    if (!esp8266_serial) {
        debug("Serial Initialization failed, no memory\r\n");
        return;
    }

    RFID_READER.begin(RFID_BAUD_RATE);

    kaa_client_props_t props;
    props.serial = esp8266_serial;
    props.wifi_ssid = SSID;
    props.wifi_pswd = PWD;
    bool need_deallocation;
    ext_get_endpoint_public_key(&props.kaa_public_key, &props.kaa_public_key_length, &need_deallocation);
    kaa_error_t error = kaa_client_create(&kaa_client, &props);
    if (error) {
        debug("Failed to init Kaa client, error code %d\r\n", error);
        return;
    }

    error = kaa_user_manager_default_attach_to_user(kaa_client_get_context(kaa_client)->user_manager
                                                  , KAA_USER_ID
                                                  , KAA_USER_ACCESS_TOKEN);
    if (error) {
        debug("Failed to attach to user '%s', error code %d\r\n", KAA_USER_ID, error);
        return;
    }


}
Пример #3
0
void loop() {
    volatile int i = 0;
    toggleLED();

    // An artificial delay
    for(i = 0; i < 150000; i++)
        ;

    if (isButtonPressed()) {
        if (disable) {
            systick_disable();
            SerialUSB.println("Disabling SysTick");
        } else {
            SerialUSB.println("Re-enabling SysTick");
            systick_enable();
        }
        disable = !disable;
    }

    SerialUSB.println(millis());
}
Пример #4
0
/**
 * @brief Initialize and enable SysTick.
 *
 * Clocks the system timer with the core clock, turns it on, and
 * enables interrupts.
 *
 * @param reload_val Appropriate reload counter to tick every 1 ms.
 */
void systick_init(uint32 reload_val) {
    SYSTICK_BASE->RVR = reload_val;
    systick_enable();
}
Пример #5
0
/**
 * @brief Initialize and enable SysTick.
 *
 * Clocks the system timer with the core clock, turns it on, and
 * enables interrupts.
 *
 * @param reload_val Appropriate reload counter to tick every 1 ms.
 */
void systick_init(uint32_t reload_val) {
    SysTick->LOAD = reload_val;
    systick_enable();
}