SDK  23.9.2
For IoT System Software Development
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
McuNRF51 Class Reference

Nordic Semiconductor nRF51 MCU. More...

#include <McuNRF51.hpp>

Inheritance diagram for McuNRF51:
McuARMCortexM RTCCalendar McuGeneric McuNRF52 System_nRf52_DK

Public Types

enum  {
  RESET_REASON_RESETPIN = (1ul << 0), RESET_REASON_DOG = (1ul << 1), RESET_REASON_SREQ = (1ul << 2), RESET_REASON_LOCKUP = (1ul << 3),
  RESET_REASON_OFF = (1ul << 16), RESET_REASON_LPCOMP = (1ul << 17), RESET_REASON_DIF = (1ul << 18)
}
 
enum  AdcReference_t {
  VREF_INTERNAL1V2 = 0, VREF_INTERNAL1V8 = 1, VREF_INTERNAL3V6 = 2, VREF_INTERNALVDD = 3,
  VREF_INTERNALVDD_3div6 = 4, VREF_INTERNALVDD_1div3 = 5, VREF_INTERNALVDD_3div2 = 6, VREF_INTERNALVDD_3div4 = 7,
  VREF_INTERNALVDD_1div2 = 8, VREF_EXTERNAL1_3div1 = 9, VREF_EXTERNAL1_3div2 = 10, VREF_EXTERNAL1 = 11,
  VREF_EXTERNAL2_3div1 = 12, VREF_EXTERNAL2_3div2 = 13, VREF_EXTERNAL2 = 14, VREF_DEFAULT = 2,
  VREF_INTERNAL = 2
}
 ADC (analogRead()) 기준 전압 More...
 

Public Member Functions

 McuNRF51 (uint32_t clockHz, int adcRef)
 
void feedWatchdog () override
 Watchdog reset을 방지하기 위하여 watchdog에 신호를 줍니다. More...
 
virtual void sleep ()
 
uint32_t getSystickCount ()
 Get system tick count.
 
void waitSystick (uint32_t startTick, uint32_t numTicks)
 Wait numTicks from startTick.
 
uint32_t MicrosToSystick (uint32_t usec) override
 
uint32_t SystickToMicros (uint32_t ticks) override
 
uint32_t getResetReason ()
 마지막으로 리셋된 원인을 가져옵니다. More...
 
void getTimeSinceBoot (struct timeval *tv) override
 보드 부팅 이후부터 현재까지의 경과 시간을 구합니다. More...
 
- Public Member Functions inherited from McuARMCortexM
 McuARMCortexM (uint32_t clockHz, uint32_t systickHz, uint32_t maxSystickCount)
 
const CoreRegisterDumpgetLastCoreRegisterDump ()
 
void saveCoreRegisterValues (uint32_t r0, uint32_t r1, uint32_t r2, uint32_t r3, uint32_t r12, uint32_t lr, uint32_t pc, uint32_t psr)
 
- Public Member Functions inherited from McuGeneric
 McuGeneric (uint32_t clockHz, uint32_t systickHz, uint32_t maxSystickCount)
 
- Public Member Functions inherited from RTCCalendar
void getDateTime (struct tm &t)
 현재 로컬 시간을 가져옵니다. More...
 
time_t getDateTime ()
 현재 로컬 시간을 가져옵니다. More...
 
void getUTC (struct tm &t)
 현재 UTC 시간을 가져옵니다. More...
 
time_t getUTC ()
 현재 UTC 시간을 가져옵니다. More...
 
void setDateTime (struct tm &t)
 현재 로컬 시간을 설정합니다. More...
 
void setDateTime (time_t t)
 현재 로컬 시간을 설정합니다. More...
 
void setUTC (struct tm &t)
 현재 UTC 시간을 설정합니다. More...
 
void setUTC (time_t t)
 현재 UTC 시간을 설정합니다. More...
 
void setDateTimeAlarm (struct tm &t)
 현재 로컬 시간을 기준으로 알람을 설정합니다. More...
 
void setDateTimeAlarm (time_t t)
 현재 로컬 시간을 기준으로 알람을 설정합니다. More...
 
error_t setTimeAlarm (uint8_t hour, uint8_t min, uint8_t sec=0)
 현재 로컬 시간을 기준으로 알람을 설정합니다. More...
 
void onDateTimeAlarm (void(*func)())
 알람 발생시 호출될 콜백함수를 지정합니다. More...
 
void setTimeDiff (int16_t diffMinutes)
 UTC와 로컬 시간과의 차이를 분 단위로 지정합니다. More...
 
int16_t getTimeDiff ()
 UTC와 로컬 시간과의 차이를 반환합니다. More...
 
virtual void signalAlarm ()
 

Protected Member Functions

void initialize () override
 
void analogWrite (int pin, int32_t val)
 
void tone (int pin, uint32_t frequency)
 
void noTone (int pin)
 
int32_t analogRead (int8_t pin)
 
void getUTCFromHardware (uint16_t *year, uint8_t *month, uint8_t *day, uint8_t *hour, uint8_t *min, uint8_t *sec, uint32_t *subsec=NULL) override
 
void setUTCToHardware (uint16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t min, uint8_t sec, int32_t subsec=-1) override
 
void setUTCAlarmToHardware (uint8_t hour, uint8_t min, uint8_t sec) override
 
- Protected Member Functions inherited from McuGeneric
virtual void wakeup ()
 

Protected Attributes

uint32_t resetReason
 
uint8_t adcResolutionBits = 12
 
int adcReference
 
uint64_t nextAlarm = 0
 
uint64_t countSeconds = 0
 
HardwareTimerTick_t countAtLastSec = 0
 
struct timeval bootTime
 
- Protected Attributes inherited from RTCCalendar
void(* handlerAlarm )()
 

Additional Inherited Members

- Public Attributes inherited from McuGeneric
const uint32_t CLOCK_HZ
 CPU clock frequency in unit of Hz.
 
const uint32_t SYSTICK_HZ
 System tick frequency in unit of Hz.
 
const uint32_t MAX_SYSTICK_COUNT
 Maximum value of systick counter.
 
bool useSleep = true
 true 이면 MCU가 유휴(idle) 상태일 때 저전력을 위하여 sleep 합니다. More...
 

Detailed Description

Nordic Semiconductor nRF51 MCU.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
RESET_REASON_RESETPIN 

Reset from pin-reset detected

RESET_REASON_DOG 

Reset from watchdog detected

RESET_REASON_SREQ 

Reset from soft reset detected

RESET_REASON_LOCKUP 

Reset from CPU lock-up detected

RESET_REASON_OFF 

Reset due to wake up from System OFF mode when wakeup is triggered from DETECT signal from GPIO

RESET_REASON_LPCOMP 

Reset due to wake up from System OFF mode when wakeup is triggered from ANADETECT signal from LPCOMP

RESET_REASON_DIF 

Reset due to wake up from System OFF mode when wakeup is triggered from entering into debug interface mode

94  { RESET_REASON_RESETPIN = (1ul << 0),
95  RESET_REASON_DOG = (1ul << 1),
96  RESET_REASON_SREQ = (1ul << 2),
97  RESET_REASON_LOCKUP = (1ul << 3),
98  RESET_REASON_OFF = (1ul << 16),
99  RESET_REASON_LPCOMP = (1ul << 17),
100  RESET_REASON_DIF = (1ul << 18),
101  };

◆ AdcReference_t

ADC (analogRead()) 기준 전압

Enumerator
VREF_INTERNAL1V2 

Internal static 3.6V (Reference: 0.6V, Gain: 1/6)

VREF_INTERNAL1V8 

Internal static 3.0V (Reference: 0.6V, Gain: 1/5)

VREF_INTERNAL3V6 

Internal static 2.4V (Reference: 0.6V, Gain: 1/4)

VREF_INTERNALVDD 

Internal VDD / 3 * 3 (Reference: VDD/3, Gain: 1/3)

VREF_INTERNALVDD_3div6 

Internal VDD / 2 (Reference: VDD/3, Gain: 2/3)

VREF_INTERNALVDD_1div3 

Internal VDD / 3 (Reference: VDD/3, Gain: 1)

VREF_INTERNALVDD_3div2 

Internal VDD / 2 * 3 (Reference: VDD/2, Gain: 1/3

VREF_INTERNALVDD_3div4 

Internal VDD / 4 * 3 (Reference: VDD/2, Gain: 2/3)

VREF_INTERNALVDD_1div2 

Internal VDD / 2 (Reference: VDD/2, Gain: 1)

VREF_EXTERNAL1_3div1 

External AREF1 * 3 (Reference: AREF1, Gain: 1/3)

VREF_EXTERNAL1_3div2 

External AREF1 * 3 / 2 (Reference: AREF1, Gain: 2/3)

VREF_EXTERNAL1 

External AREF1 (Reference: AREF1, Gain: 1)

VREF_EXTERNAL2_3div1 

External AREF2 * 3 (Reference: AREF2, Gain: 1/3)

VREF_EXTERNAL2_3div2 

External AREF2 * 3 / 2 (Reference: AREF2, Gain: 2/3)

VREF_EXTERNAL2 

External AREF2 (Reference: AREF2, Gain: 1)

VREF_DEFAULT 

Default: VREF_INTERNAL3V6

VREF_INTERNAL 

Internal default: VREF_INTERNAL3V6

128  { VREF_INTERNAL1V2 = 0,
129  VREF_INTERNAL1V8 = 1,
130  VREF_INTERNAL3V6 = 2,
131  VREF_INTERNALVDD = 3,
138  VREF_EXTERNAL1_3div2 = 10,
139  VREF_EXTERNAL1 = 11,
140  VREF_EXTERNAL2_3div1 = 12,
141  VREF_EXTERNAL2_3div2 = 13,
142  VREF_EXTERNAL2 = 14,
143  VREF_DEFAULT = 2,
144  VREF_INTERNAL = 2,
145  };

Member Function Documentation

◆ feedWatchdog()

void McuNRF51::feedWatchdog ( )
overridevirtual

Watchdog reset을 방지하기 위하여 watchdog에 신호를 줍니다.

Nol.A-SDK에서는 특정 태스크의 MCU 점유 시간이 길어지는 경우 watchdog reset이 발생합니다. 따라서 postTask(), Timer 등으로 실행되는 태스크의 실행시간은 가능한 짧아야 합니다. 하지만, 간혹 busy wait를 해야 하거나 blocking 함수로 인해 실행시간이 길어질 수 있습니다. 이 경우 태스크의 중간 중간마다 이 함수를 호출하여 watchdog reset이 발생하는 것을 방지할 수 있습니다.

Implements McuGeneric.

◆ getResetReason()

uint32_t McuNRF51::getResetReason ( )

마지막으로 리셋된 원인을 가져옵니다.

마지막으로 보드가 리셋된 원인을 반환합니다. 원인이 둘 이상인 경우, OR 된 값이 반환됩니다.

Returns

리셋 원인에 대한 자세한 정보는 Nordic Semiconductor의 nRF51 Series Reference Manual의 12. Power management (POWER) 를 참고하시기 바랍니다.

◆ getTimeSinceBoot()

void McuNRF51::getTimeSinceBoot ( struct timeval *  tv)
overridevirtual

보드 부팅 이후부터 현재까지의 경과 시간을 구합니다.

Parameters
tv[out]경과 시간이 반환될 timeval 포인터

Implements RTCCalendar.


The documentation for this class was generated from the following file:
McuNRF51::VREF_INTERNALVDD_1div2
@ VREF_INTERNALVDD_1div2
Definition: McuNRF51.hpp:136
McuNRF51::VREF_INTERNAL3V6
@ VREF_INTERNAL3V6
Definition: McuNRF51.hpp:130
McuNRF51::VREF_INTERNALVDD_3div2
@ VREF_INTERNALVDD_3div2
Definition: McuNRF51.hpp:134
McuNRF51::RESET_REASON_OFF
@ RESET_REASON_OFF
Definition: McuNRF51.hpp:98
McuNRF51::VREF_EXTERNAL1_3div1
@ VREF_EXTERNAL1_3div1
Definition: McuNRF51.hpp:137
McuNRF51::VREF_INTERNALVDD_1div3
@ VREF_INTERNALVDD_1div3
Definition: McuNRF51.hpp:133
McuNRF51::RESET_REASON_RESETPIN
@ RESET_REASON_RESETPIN
Definition: McuNRF51.hpp:94
McuNRF51::VREF_EXTERNAL1_3div2
@ VREF_EXTERNAL1_3div2
Definition: McuNRF51.hpp:138
McuNRF51::RESET_REASON_LPCOMP
@ RESET_REASON_LPCOMP
Definition: McuNRF51.hpp:99
McuNRF51::VREF_INTERNAL1V2
@ VREF_INTERNAL1V2
Definition: McuNRF51.hpp:128
McuNRF51::RESET_REASON_DOG
@ RESET_REASON_DOG
Definition: McuNRF51.hpp:95
McuNRF51::VREF_INTERNAL
@ VREF_INTERNAL
Definition: McuNRF51.hpp:144
McuNRF51::VREF_EXTERNAL1
@ VREF_EXTERNAL1
Definition: McuNRF51.hpp:139
McuNRF51::VREF_INTERNALVDD_3div4
@ VREF_INTERNALVDD_3div4
Definition: McuNRF51.hpp:135
McuNRF51::VREF_DEFAULT
@ VREF_DEFAULT
Definition: McuNRF51.hpp:143
McuNRF51::RESET_REASON_LOCKUP
@ RESET_REASON_LOCKUP
Definition: McuNRF51.hpp:97
McuNRF51::VREF_EXTERNAL2
@ VREF_EXTERNAL2
Definition: McuNRF51.hpp:142
McuNRF51::VREF_EXTERNAL2_3div2
@ VREF_EXTERNAL2_3div2
Definition: McuNRF51.hpp:141
McuNRF51::RESET_REASON_SREQ
@ RESET_REASON_SREQ
Definition: McuNRF51.hpp:96
McuNRF51::VREF_EXTERNAL2_3div1
@ VREF_EXTERNAL2_3div1
Definition: McuNRF51.hpp:140
McuNRF51::VREF_INTERNAL1V8
@ VREF_INTERNAL1V8
Definition: McuNRF51.hpp:129
McuNRF51::VREF_INTERNALVDD
@ VREF_INTERNALVDD
Definition: McuNRF51.hpp:131
McuNRF51::VREF_INTERNALVDD_3div6
@ VREF_INTERNALVDD_3div6
Definition: McuNRF51.hpp:132
McuNRF51::RESET_REASON_DIF
@ RESET_REASON_DIF
Definition: McuNRF51.hpp:100