Lizzy project

Dependencies:   aconno_I2C Lis2dh12 adc52832_common aconno_SEGGER_RTT

Committer:
dbartolovic
Date:
Tue Mar 20 15:13:51 2018 +0000
Revision:
8:7ba4f82de9b6
Child:
19:2681edc2f2b9
Added lizzy service.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dbartolovic 8:7ba4f82de9b6 1 #ifndef __BSP_BUZZ_H__
dbartolovic 8:7ba4f82de9b6 2 #define __BSP_BUZZ_H__
dbartolovic 8:7ba4f82de9b6 3
dbartolovic 8:7ba4f82de9b6 4 #include "main.h"
dbartolovic 8:7ba4f82de9b6 5 #include "acn_nrf52_pwm.h"
dbartolovic 8:7ba4f82de9b6 6
dbartolovic 8:7ba4f82de9b6 7 #if NANO_MODULE
dbartolovic 8:7ba4f82de9b6 8 #else
dbartolovic 8:7ba4f82de9b6 9 #define BUZZER_PIN (p18)
dbartolovic 8:7ba4f82de9b6 10 #endif
dbartolovic 8:7ba4f82de9b6 11
dbartolovic 8:7ba4f82de9b6 12 #define BUZZER_FREQUENCY_HZ (4000)
dbartolovic 8:7ba4f82de9b6 13 #define BUZZ_TIME_S (2) /* Buzz time in s */
dbartolovic 8:7ba4f82de9b6 14
dbartolovic 8:7ba4f82de9b6 15 class Buzz
dbartolovic 8:7ba4f82de9b6 16 {
dbartolovic 8:7ba4f82de9b6 17 typedef typeof(NRF_PWM0) NRF_PWM_TYPE;
dbartolovic 8:7ba4f82de9b6 18
dbartolovic 8:7ba4f82de9b6 19 public:
dbartolovic 8:7ba4f82de9b6 20
dbartolovic 8:7ba4f82de9b6 21 Buzz(NRF_PWM_TYPE pwmInstance, uint8_t pin) :
dbartolovic 8:7ba4f82de9b6 22 buzzer(pwmInstance), pwm_pin(pin), state(false){}
dbartolovic 8:7ba4f82de9b6 23
dbartolovic 8:7ba4f82de9b6 24 void enable();
dbartolovic 8:7ba4f82de9b6 25 void disable();
dbartolovic 8:7ba4f82de9b6 26
dbartolovic 8:7ba4f82de9b6 27 inline bool get_state(){ return state; }
dbartolovic 8:7ba4f82de9b6 28
dbartolovic 8:7ba4f82de9b6 29 private:
dbartolovic 8:7ba4f82de9b6 30
dbartolovic 8:7ba4f82de9b6 31 uint8_t pwm_pin;
dbartolovic 8:7ba4f82de9b6 32 NRF52_PWM buzzer;
dbartolovic 8:7ba4f82de9b6 33
dbartolovic 8:7ba4f82de9b6 34 bool state;
dbartolovic 8:7ba4f82de9b6 35 };
dbartolovic 8:7ba4f82de9b6 36
dbartolovic 8:7ba4f82de9b6 37 #endif //__BSP_BUZZ_H__