Skip to content

Commit 4b3ab06

Browse files
authored
Merge pull request #6 from disk91/add-murata-lora-sigfox
Add murata lora sigfox
2 parents 0fe37d9 + 61648f6 commit 4b3ab06

File tree

6 files changed

+30
-16
lines changed

6 files changed

+30
-16
lines changed

Examples/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Disk91 IoT SDK - Examples
2+
The different examples are located in different GitHub projects. This way you can easily clone the project locally and get all the dependencies. this is not poluting the main SDK.
3+
4+
## STM32 platform
5+
* Make a led blinking - https://github.com/disk91/stm32-s2lp-sigfox/releases/tag/STEP1
6+
* Communicate over Sigfox Network - https://github.com/disk91/stm32-s2lp-sigfox
7+
* Communicate over LoRaWan Network - https://github.com/disk91/itsdk-example-murata-lora

Inc/it_sdk/sched/scheduler.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,13 @@
4242

4343
#define ITSDK_SCHED_ERROR 0xFF
4444

45+
#define ITSDK_SCHED_MAX_PERIOD 0x00FFFFFF // 24b is the max duration
4546
/**
4647
* schedule configuration
4748
*/
4849
typedef struct s_sched {
4950
uint64_t nextRun; // Next run time in ms
50-
uint16_t period; // Period between 2 execution
51+
uint32_t period:24; // Period between 2 execution (24 bits)
5152
// Mode as a bitfield for task configuration see ITSDK_SCHED_CONF_XXX
5253
uint8_t skip:1; // skip missed execution
5354
uint8_t halt:1; // stop for next executions
@@ -59,7 +60,7 @@ typedef struct s_sched {
5960
* Functions
6061
*/
6162
void itdt_sched_execute();
62-
uint8_t itdt_sched_registerSched(uint16_t periodMs,uint16_t mode, void (*f)(void));
63+
uint8_t itdt_sched_registerSched(uint32_t periodMs,uint16_t mode, void (*f)(void));
6364
void itdf_sched_haltSched(uint8_t schedId);
6465
void itdf_sched_runSched(uint8_t schedId);
6566

Inc/it_sdk/time/timer.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929

3030
#include <stdbool.h>
3131

32-
#define ITSDK_STIMER_INFINITE 0xFFFFFFFF
32+
#define ITSDK_STIMER_INFINITE 0xFFFFFFFF
33+
#define ITSDK_STIMER_INFINITE_64 0xFFFFFFFFFFFFFFFF
3334

3435
typedef enum {
3536
TIMER_INIT_SUCCESS=0,
@@ -63,7 +64,7 @@ itsdk_timer_return_t itsdk_hwtimer_sync_run(
6364
typedef struct s_itsdk_stimer_slot {
6465
bool inUse; // This structure is in use
6566
bool allowLowPower; // when true a deep sleep switch is authorized during time wait
66-
uint32_t timeoutMs; // End of the timer value
67+
uint64_t timeoutMs; // End of the timer value
6768
void (*callback_func)(uint32_t value); // Callback function
6869
uint32_t customValue;
6970
} itsdk_stimer_slot_t;

Src/it_sdk/sched/scheduler.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,12 @@ uint8_t __sNum = 0;
4242
* associated function to call. The mode params defines the sheduler behavior
4343
* Returns the scedId on sucees or ITSDK_SCHED_ERROR on error.
4444
*/
45-
uint8_t itdt_sched_registerSched(uint16_t periodMs,uint16_t mode, void (*f)(void)) {
45+
uint8_t itdt_sched_registerSched(uint32_t periodMs,uint16_t mode, void (*f)(void)) {
4646

47+
if ( periodMs > ITSDK_SCHED_MAX_PERIOD ) {
48+
log_error("[Sched] Period exceed Max\r\n");
49+
return ITSDK_SCHED_ERROR;
50+
}
4751
if ( __sNum < ITSDK_SHEDULER_TASKS ) {
4852
__scheds[__sNum].func=f;
4953
__scheds[__sNum].period=periodMs;
@@ -69,7 +73,7 @@ void itdt_sched_execute() {
6973
_LOG_SCHED(("[sched] (%d) exec @%ld\r\n",i,t));
7074
(*__scheds[i].func)();
7175
}
72-
__scheds[i].nextRun += __scheds[i].period;
76+
__scheds[i].nextRun += (uint64_t)__scheds[i].period;
7377
}
7478
} while (!__scheds[i].skip && __scheds[i].nextRun <= t );
7579
while (__scheds[i].skip &&__scheds[i].nextRun <= t) __scheds[i].nextRun += __scheds[i].period;

Src/it_sdk/time/timer.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ itsdk_timer_return_t itsdk_stimer_register(
110110
__stimer_slots[i].allowLowPower = ((allowLowPower==TIMER_ACCEPT_LOWPOWER)?true:false);
111111
__stimer_slots[i].customValue = value;
112112
__stimer_slots[i].callback_func = callback_func;
113-
__stimer_slots[i].timeoutMs = itsdk_time_get_ms()+ms;
113+
__stimer_slots[i].timeoutMs = itsdk_time_get_ms()+(uint64_t)ms;
114114
return TIMER_INIT_SUCCESS;
115115
}
116116
#if (ITSDK_LOGGER_MODULE & __LOG_MOD_STIMER) > 0
@@ -199,7 +199,7 @@ itsdk_stimer_slot_t * itsdk_stimer_get(
199199
* possible. At least on every wake-up from sleep
200200
*/
201201
void itsdk_stimer_run() {
202-
uint32_t t = itsdk_time_get_ms();
202+
uint64_t t = itsdk_time_get_ms();
203203
for ( int i = 0 ; i < ITSDK_TIMER_SLOTS ; i++ ) {
204204
if ( __stimer_slots[i].inUse && __stimer_slots[i].timeoutMs <= t ) {
205205
__stimer_slots[i].inUse = false;
@@ -215,17 +215,18 @@ void itsdk_stimer_run() {
215215
* return ITSDK_STIMER_INFINITE when none are in execution or in the future.
216216
*/
217217
uint32_t itsdk_stimer_nextTimeoutMs(){
218-
uint32_t t = itsdk_time_get_ms();
219-
uint32_t min = ITSDK_STIMER_INFINITE;
218+
uint64_t t = itsdk_time_get_ms();
219+
uint64_t min = ITSDK_STIMER_INFINITE_64;
220220
for ( int i = 0 ; i < ITSDK_TIMER_SLOTS ; i++ ) {
221221
if ( __stimer_slots[i].inUse && __stimer_slots[i].timeoutMs >= t ) {
222222
if ( __stimer_slots[i].timeoutMs < min ) min = __stimer_slots[i].timeoutMs;
223223
}
224224
}
225-
if ( min < ITSDK_STIMER_INFINITE ) {
225+
if ( min < ITSDK_STIMER_INFINITE_64 ) {
226226
min = min - t;
227+
return min;
227228
}
228-
return min;
229+
return ITSDK_STIMER_INFINITE;
229230
}
230231

231232
#endif

Src/stm32l_sdk/rtc/rtc.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ uint64_t rtc_getTimestampMsRaw(bool adjust) {
127127
#else
128128
RTC_TimeTypeDef _time;
129129
RTC_DateTypeDef _date;
130-
uint32_t ms;
130+
uint64_t ms;
131131
HAL_RTC_GetTime(&hrtc, &_time, RTC_FORMAT_BIN);
132132
HAL_RTC_GetDate(&hrtc, &_date, RTC_FORMAT_BIN);
133133
ms = (uint32_t)_time.Hours*3600*1000;
@@ -140,16 +140,16 @@ uint64_t rtc_getTimestampMsRaw(bool adjust) {
140140
__rtc_days++;
141141
}
142142
__rtc_lastTick = ms;
143-
ms = ( uint64_t )(__rtc_days*3600000L*24L)+ms;
143+
ms = ( uint64_t )((uint64_t)__rtc_days*3600000L*24L)+(uint64_t)ms;
144144
#endif
145145
// apply the RTC clock correction and add previous offset
146146
#if ITSDK_WITH_CLK_ADJUST > 0
147147
if (adjust && __rtc_init > 0) {
148-
ms = (ms * __rtc_currentRatio) / 1000;
148+
ms = (ms * (uint64_t)__rtc_currentRatio) / 1000L;
149149
ms += __rtc_offset;
150150
}
151151
#else
152-
ms = (adjust)?(ms * ITSDK_CLK_CORRECTION) / 1000:ms;
152+
ms = (adjust)?(ms * ITSDK_CLK_CORRECTION) / 1000L:ms;
153153
#endif
154154
return ms;
155155
}

0 commit comments

Comments
 (0)