STM First Test

This commit is contained in:
2024-04-16 15:52:59 +03:00
parent ff306e7fae
commit 27a5b28a17
6 changed files with 375 additions and 297 deletions

View File

@ -20,31 +20,33 @@ public:
/// @param decPair Приёмник, для которого отключается приём в момент передачи передатчиком
IR_Encoder(uint16_t addr, IR_DecoderRaw *decPair = nullptr);
static void timerSetup()
{
// TIMER2 Ini
uint8_t oldSREG = SREG; // Save global interupts settings
cli();
// DDRB |= (1 << PORTB3); //OC2A (17)
TCCR2A = 0;
TCCR2B = 0;
// static void timerSetup()
// {
// // // TIMER2 Ini
// // uint8_t oldSREG = SREG; // Save global interupts settings
// // cli();
// // // DDRB |= (1 << PORTB3); //OC2A (17)
// // TCCR2A = 0;
// // TCCR2B = 0;
// TCCR2A |= (1 << COM2A0); //Переключение состояния
// // // TCCR2A |= (1 << COM2A0); //Переключение состояния
TCCR2A |= (1 << WGM21); // Clear Timer On Compare (Сброс по совпадению)
TCCR2B |= (1 << CS20); // Предделитель 1
TIMSK2 |= (1 << OCIE2A); // Прерывание по совпадению
// // TCCR2A |= (1 << WGM21); // Clear Timer On Compare (Сброс по совпадению)
// // TCCR2B |= (1 << CS20); // Предделитель 1
// // TIMSK2 |= (1 << OCIE2A); // Прерывание по совпадению
OCR2A = /* 465 */ ((F_CPU / (38000 * 2)) - 2); // 38кГц
// // OCR2A = /* 465 */ ((F_CPU / (38000 * 2)) - 2); // 38кГц
SREG = oldSREG; // Return interrupt settings
}
static void timerOFFSetup()
{
TIMSK2 &= ~(1 << OCIE2A); // Прерывание по совпадению выкл
}
// // SREG = oldSREG; // Return interrupt settings
void IR_Encoder::setBlindDecoders(IR_DecoderRaw *decoders[], uint8_t count);
// }
// static void timerOFFSetup()
// {
// TIMSK2 &= ~(1 << OCIE2A); // Прерывание по совпадению выкл
// }
void setBlindDecoders(IR_DecoderRaw *decoders[], uint8_t count);
void rawSend(uint8_t *ptr, uint8_t len);
void sendData(uint16_t addrTo, uint8_t dataByte, bool needAccept = false);
@ -63,9 +65,9 @@ public:
volatile bool ir_out_virtual;
private:
void IR_Encoder::_sendBack(bool isAdressed, uint16_t addrTo, uint8_t *data, uint8_t len);
void _sendBack(bool isAdressed, uint16_t addrTo, uint8_t *data, uint8_t len);
void IR_Encoder::setDecoder_isSending();
void setDecoder_isSending();
void sendByte(uint8_t byte, bool *prev, bool LOW_FIRST);
void addSync(bool *prev, bool *next);
void send_HIGH(bool = 1);
@ -105,12 +107,9 @@ private:
uint8_t low;
uint8_t high;
};
static inline uint8_t *bitHigh = new uint8_t[2]{
(bitPauseTakts * 2) * 2 - 1,
(bitActiveTakts) * 2 - 1};
static inline uint8_t *bitLow = new uint8_t[2]{
(bitPauseTakts + bitActiveTakts) * 2 - 1,
(bitPauseTakts) * 2 - 1};
static uint8_t *bitHigh;
static uint8_t *bitLow;
uint8_t *currentBitSequence = bitLow;
volatile SignalPart signal;
};