Merge pull request #793 from alistair23/alistair/tock
NonArduino: Tock: Fixup some bugs and expand the example
This commit is contained in:
commit
9fa8434e47
3 changed files with 15 additions and 8 deletions
|
@ -45,8 +45,8 @@ add_executable(${PROJECT_NAME} main.cpp)
|
|||
# link with RadioLib and libtock-c
|
||||
target_link_libraries(${PROJECT_NAME} PUBLIC
|
||||
RadioLib
|
||||
gcc
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libtock-c/libtock/build/cortex-m4/libtock.a
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libtock-c/libc++/cortex-m/libgcc.a
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libtock-c/libc++/cortex-m/libstdc++.a
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libtock-c/newlib/cortex-m/v7-m/libc.a
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libtock-c/newlib/cortex-m/v7-m/libm.a
|
||||
|
|
|
@ -190,6 +190,10 @@ class TockHal : public RadioLibHal {
|
|||
void spiEnd() {
|
||||
}
|
||||
|
||||
void yield() {
|
||||
::yield();
|
||||
}
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
|
||||
// the entry point for the program
|
||||
int main(void) {
|
||||
printf("[SX1261] Initializing ... \n");
|
||||
printf("[SX1261] Initialising Radio ... \r\n");
|
||||
|
||||
// create a new instance of the HAL class
|
||||
TockHal* hal = new TockHal();
|
||||
|
@ -46,29 +46,32 @@ int main(void) {
|
|||
Module* tock_module = new Module(hal, RADIO_NSS, RADIO_DIO_1, RADIO_RESET, RADIO_BUSY);
|
||||
SX1262* radio = new SX1262(tock_module);
|
||||
|
||||
int state = radio->begin();
|
||||
// Setup the radio
|
||||
// The settings here work for the SparkFun LoRa Thing Plus - expLoRaBLE
|
||||
int state = radio->begin(915.0, 125.0, 9, 7, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, 10, 8, 0, false);
|
||||
|
||||
if (state != RADIOLIB_ERR_NONE) {
|
||||
printf("failed, code %d\n", state);
|
||||
printf("failed, code %d\r\n", state);
|
||||
return 1;
|
||||
}
|
||||
printf("success!\n");
|
||||
printf("success!\r\n");
|
||||
|
||||
// loop forever
|
||||
for(;;) {
|
||||
yield_no_wait();
|
||||
// send a packet
|
||||
printf("[SX1261] Transmitting packet ... \n");
|
||||
printf("[SX1261] Transmitting '%s' \r\n", transmit_string);
|
||||
|
||||
state = radio->transmit("Hello World!");
|
||||
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
// the packet was successfully transmitted
|
||||
printf("success!\n");
|
||||
printf("success!\r\n");
|
||||
|
||||
// wait for a second before transmitting again
|
||||
hal->delay(1000);
|
||||
} else {
|
||||
printf("failed, code %d\n", state);
|
||||
printf("failed, code %d\r\n", state);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue