forked from stm32duino/Arduino_Core_STM32
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathSubGhz.cpp
100 lines (84 loc) · 1.87 KB
/
SubGhz.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*
*******************************************************************************
* Copyright (c) 2022, STMicroelectronics
* All rights reserved.
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
*******************************************************************************
*/
#include <Arduino.h>
#include "SubGhz.h"
SubGhzClass SubGhz;
extern "C" void SUBGHZ_Radio_IRQHandler(void)
{
SubGhz.handleIrq();
}
void SubGhzClass::handleIrq()
{
if (callback) {
callback();
}
}
void SubGhzClass::attachInterrupt(callback_function_t callback)
{
this->callback = callback;
HAL_NVIC_ClearPendingIRQ(SUBGHZ_Radio_IRQn);
enableInterrupt();
}
void SubGhzClass::detachInterrupt()
{
disableInterrupt();
this->callback = nullptr;
}
bool SubGhzClass::hasInterrupt()
{
return (bool)this->callback;
}
void SubGhzClass::enableInterrupt()
{
HAL_NVIC_EnableIRQ(SUBGHZ_Radio_IRQn);
}
void SubGhzClass::disableInterrupt()
{
HAL_NVIC_DisableIRQ(SUBGHZ_Radio_IRQn);
}
void SubGhzClass::clearPendingInterrupt()
{
HAL_NVIC_ClearPendingIRQ(SUBGHZ_Radio_IRQn);
}
bool SubGhzClass::isInterruptPending()
{
return HAL_NVIC_GetPendingIRQ(SUBGHZ_Radio_IRQn);
}
void SubGhzClass::setNssActive(bool value)
{
if (value) {
LL_PWR_SelectSUBGHZSPI_NSS();
} else {
LL_PWR_UnselectSUBGHZSPI_NSS();
}
}
bool SubGhzClass::isNssActive()
{
return LL_PWR_IsSUBGHZSPI_NSS_Selected();
}
void SubGhzClass::setResetActive(bool value)
{
if (value) {
LL_RCC_RF_EnableReset();
} else {
LL_RCC_RF_DisableReset();
}
}
bool SubGhzClass::isResetActive()
{
return LL_RCC_RF_IsEnabledReset();
}
bool SubGhzClass::isBusy()
{
return (LL_PWR_IsActiveFlag_RFBUSYS());
}