-
-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
54 changed files
with
1,939 additions
and
1,606 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
atmelavr-and-arduino/engduino-magnetometer/.piolibdeps | ||
.pioenvs | ||
.piolibdeps |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
; PlatformIO Project Configuration File | ||
; | ||
; Build options: build flags, source filter, extra scripting | ||
; Upload options: custom port, speed and extra flags | ||
; Library options: dependencies, extra library storages | ||
; | ||
; Please visit documentation for the other options and examples | ||
; http://docs.platformio.org/page/projectconf.html | ||
|
||
[env:nrf51_dk] | ||
platform = nordicnrf51 | ||
framework = mbed | ||
board = nrf51_dk | ||
build_flags = -DPIO_FRAMEWORK_MBED_RTOS_PRESENT | ||
|
||
[env:nrf51_dongle] | ||
platform = nordicnrf51 | ||
framework = mbed | ||
board = nrf51_dongle | ||
build_flags = -DPIO_FRAMEWORK_MBED_RTOS_PRESENT | ||
|
||
[env:nrf52_dk] | ||
platform = nordicnrf52 | ||
framework = mbed | ||
board = nrf52_dk | ||
build_flags = -DPIO_FRAMEWORK_MBED_RTOS_PRESENT | ||
|
||
[env:delta_dfbm_nq620] | ||
platform = nordicnrf52 | ||
framework = mbed | ||
board = delta_dfbm_nq620 | ||
build_flags = -DPIO_FRAMEWORK_MBED_RTOS_PRESENT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
/* mbed Microcontroller Library | ||
* Copyright (c) 2006-2013 ARM Limited | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include <mbed_events.h> | ||
#include <rtos.h> | ||
#include "mbed.h" | ||
#include "ble/BLE.h" | ||
#include "ble/services/HealthThermometerService.h" | ||
|
||
DigitalOut led1(LED1, 1); | ||
|
||
const static char DEVICE_NAME[] = "PIOTherm"; | ||
static const uint16_t uuid16_list[] = {GattService::UUID_HEALTH_THERMOMETER_SERVICE}; | ||
|
||
static float currentTemperature = 39.6; | ||
static HealthThermometerService *thermometerServicePtr; | ||
|
||
static EventQueue eventQueue(/* event count */ 16 * EVENTS_EVENT_SIZE); | ||
|
||
/* Restart Advertising on disconnection*/ | ||
void disconnectionCallback(const Gap::DisconnectionCallbackParams_t *) | ||
{ | ||
BLE::Instance().gap().startAdvertising(); | ||
} | ||
|
||
void updateSensorValue(void) { | ||
/* Do blocking calls or whatever is necessary for sensor polling. | ||
In our case, we simply update the Temperature measurement. */ | ||
currentTemperature = (currentTemperature + 0.1 > 43.0) ? 39.6 : currentTemperature + 0.1; | ||
thermometerServicePtr->updateTemperature(currentTemperature); | ||
} | ||
|
||
void periodicCallback(void) | ||
{ | ||
led1 = !led1; /* Do blinky on LED1 while we're waiting for BLE events */ | ||
|
||
if (BLE::Instance().gap().getState().connected) { | ||
eventQueue.call(updateSensorValue); | ||
} | ||
} | ||
|
||
void onBleInitError(BLE &ble, ble_error_t error) | ||
{ | ||
/* Initialization error handling should go here */ | ||
} | ||
|
||
void bleInitComplete(BLE::InitializationCompleteCallbackContext *params) | ||
{ | ||
BLE& ble = params->ble; | ||
ble_error_t error = params->error; | ||
|
||
if (error != BLE_ERROR_NONE) { | ||
onBleInitError(ble, error); | ||
return; | ||
} | ||
|
||
if (ble.getInstanceID() != BLE::DEFAULT_INSTANCE) { | ||
return; | ||
} | ||
|
||
ble.gap().onDisconnection(disconnectionCallback); | ||
|
||
/* Setup primary service. */ | ||
thermometerServicePtr = new HealthThermometerService(ble, currentTemperature, HealthThermometerService::LOCATION_EAR); | ||
|
||
/* setup advertising */ | ||
ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE); | ||
ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS, (uint8_t *)uuid16_list, sizeof(uuid16_list)); | ||
ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::THERMOMETER_EAR); | ||
ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LOCAL_NAME, (uint8_t *)DEVICE_NAME, sizeof(DEVICE_NAME)); | ||
ble.gap().setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED); | ||
ble.gap().setAdvertisingInterval(1000); /* 1000ms */ | ||
ble.gap().startAdvertising(); | ||
} | ||
|
||
void scheduleBleEventsProcessing(BLE::OnEventsToProcessCallbackContext* context) { | ||
BLE &ble = BLE::Instance(); | ||
eventQueue.call(Callback<void()>(&ble, &BLE::processEvents)); | ||
} | ||
|
||
int main() | ||
{ | ||
eventQueue.call_every(500, periodicCallback); | ||
|
||
BLE &ble = BLE::Instance(); | ||
ble.onEventsToProcess(scheduleBleEventsProcessing); | ||
ble.init(bleInitComplete); | ||
|
||
eventQueue.dispatch_forever(); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.pioenvs | ||
.clang_complete | ||
.gcc-flags.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
|
||
This directory is intended for the project specific (private) libraries. | ||
PlatformIO will compile them to static libraries and link to executable file. | ||
|
||
The source code of each library should be placed in separate directory, like | ||
"lib/private_lib/[here are source files]". | ||
|
||
For example, see how can be organized `Foo` and `Bar` libraries: | ||
|
||
|--lib | ||
| |--Bar | ||
| | |--docs | ||
| | |--examples | ||
| | |--src | ||
| | |- Bar.c | ||
| | |- Bar.h | ||
| |--Foo | ||
| | |- Foo.c | ||
| | |- Foo.h | ||
| |- readme.txt --> THIS FILE | ||
|- platformio.ini | ||
|--src | ||
|- main.c | ||
|
||
Then in `src/main.c` you should use: | ||
|
||
#include <Foo.h> | ||
#include <Bar.h> | ||
|
||
// rest H/C/CPP code | ||
|
||
PlatformIO will find your libraries automatically, configure preprocessor's | ||
include paths and build them. | ||
|
||
See additional options for PlatformIO Library Dependency Finder `lib_*`: | ||
|
||
http://docs.platformio.org/page/projectconf.html#lib-install | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
; PlatformIO Project Configuration File | ||
; | ||
; Build options: build flags, source filter, extra scripting | ||
; Upload options: custom port, speed and extra flags | ||
; Library options: dependencies, extra library storages | ||
; | ||
; Please visit documentation for the other options and examples | ||
; http://docs.platformio.org/page/projectconf.html | ||
|
||
# NXP LPC Platform | ||
[env:lpc11u35] | ||
platform = nxplpc | ||
framework = mbed | ||
board = lpc11u35 | ||
|
||
[env:lpc1768] | ||
platform = nxplpc | ||
framework = mbed | ||
board = lpc1768 | ||
build_flags = -DPIO_FRAMEWORK_MBED_RTOS_PRESENT | ||
|
||
# Nordic nRF51 Platform | ||
[env:redBearLab] | ||
platform = nordicnrf51 | ||
framework = mbed | ||
board = redBearLab | ||
|
||
# Nordic nRF52 Platform | ||
[env:nrf52_dk] | ||
platform = nordicnrf52 | ||
framework = mbed | ||
board = nrf52_dk | ||
|
||
[env:delta_dfbm_nq620] | ||
platform = nordicnrf52 | ||
framework = mbed | ||
board = delta_dfbm_nq620 | ||
build_flags = -DPIO_FRAMEWORK_MBED_RTOS_PRESENT | ||
|
||
# Freescale FRDM Platform | ||
[env:frdm_kl25z] | ||
platform = freescalekinetis | ||
framework = mbed | ||
board = frdm_kl25z | ||
|
||
[env:frdm_k64f] | ||
platform = freescalekinetis | ||
framework = mbed | ||
board = frdm_k64f | ||
build_flags = -DPIO_FRAMEWORK_MBED_RTOS_PRESENT | ||
|
||
# Maxim32 Platform | ||
[env:max32600mbed] | ||
platform = maxim32 | ||
framework = mbed | ||
board = max32600mbed | ||
|
||
[env:maxwsnenv] | ||
platform = maxim32 | ||
framework = mbed | ||
board = maxwsnenv | ||
build_flags = -DPIO_FRAMEWORK_MBED_RTOS_PRESENT | ||
|
||
# ST STM32 Platform | ||
[env:nucleo_f401re] | ||
platform = ststm32 | ||
framework = mbed | ||
board = nucleo_f401re | ||
|
||
[env:mote_l152rc] | ||
platform = ststm32 | ||
framework = mbed | ||
board = mote_l152rc | ||
build_flags = -DPIO_FRAMEWORK_MBED_RTOS_PRESENT | ||
|
||
# Teensy Platform | ||
[env:teensy31] | ||
platform = teensy | ||
framework = mbed | ||
board = teensy31 | ||
build_flags = -DPIO_FRAMEWORK_MBED_RTOS_PRESENT | ||
|
||
# Silicon Labs EFM32 Platform | ||
[env:efm32hg_stk3400] | ||
platform = siliconlabsefm32 | ||
framework = mbed | ||
board = efm32hg_stk3400 | ||
|
||
[env:efm32wg_stk3800] | ||
platform = siliconlabsefm32 | ||
framework = mbed | ||
board = efm32wg_stk3800 | ||
build_flags = -DPIO_FRAMEWORK_MBED_RTOS_PRESENT | ||
|
||
# WIZNet7500 Platform | ||
[env:wizwiki_w7500] | ||
platform = wiznet7500 | ||
framework = mbed | ||
board = wizwiki_w7500 | ||
|
||
[env:wizwiki_w7500eco] | ||
platform = wiznet7500 | ||
framework = mbed | ||
board = wizwiki_w7500eco | ||
build_flags = -DPIO_FRAMEWORK_MBED_RTOS_PRESENT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#include "mbed_events.h" | ||
#include <stdio.h> | ||
|
||
int main() { | ||
// creates a queue with the default size | ||
EventQueue queue; | ||
|
||
// events are simple callbacks | ||
queue.call(printf, "called immediately\n"); | ||
queue.call_in(2000, printf, "called in 2 seconds\n"); | ||
queue.call_every(1000, printf, "called every 1 seconds\n"); | ||
|
||
// events are executed by the dispatch method | ||
queue.dispatch(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.pioenvs | ||
.clang_complete | ||
.gcc-flags.json |
Oops, something went wrong.