ASK module library for microcontrollers
Based on: Sisoog Algorithm
-
- Any microcontrollers
non
uint8_t ASK_IsValidRemote(ASK_TypeDef *ASK);
uint32_t ASK_GetRemoteCode(ASK_TypeDef *ASK);
void ASK_GetRemoteInfo(ASK_TypeDef *ASK, uint32_t *RemoteID, uint8_t *PressedKey);
/* ::::: ISR Handling ::::: */
void ASK_ISRHandle_Rising(ASK_TypeDef *ASK);
void ASK_ISRHandle_Falling(ASK_TypeDef *ASK);
/* ~~~~~~~~ Timer ~~~~~~~~ */
#define _ASKTimer_GetTick() Timer1_GetTick()
#define _ASK_TIMER_MAX_TICK UINT16_MAX
/* ~~~ ASK sensitivity ~~~ */
#define _ASK_USE_LOW_SENSITIVITY
/* ~~~~~~~~~~~~~~~ Include files ~~~~~~~~~~~~~~~ */
/* PGMSPACE header */
#include <avr/pgmspace.h>
/* Timer header */
#include "timer.h"
/* HAL or MCU header */
#include <avr/io.h>
/* ~~~~~~~~~~~~~~~~~~ Options ~~~~~~~~~~~~~~~~~~ */
/* ~~~~~~~~ Timer ~~~~~~~~ */
#define _ASKTimer_GetTick() Timer1_GetTick()
#define _ASK_TIMER_MAX_TICK UINT16_MAX
/* ~~~ ASK sensitivity ~~~ */
#define _ASK_USE_LOW_SENSITIVITY
ASK_TypeDef RF433;
ISR(INT4_vect)
{
if (GPIO_ReadPin(&PORTA, GPIO_PIN_4) == 1)
{
ASK_ISRHandle_Rising(&RF433);
}
else
{
ASK_ISRHandle_Falling(&RF433);
}
}
int main(void)
{
uint8_t key;
uint32_t id;
while (1)
{
if (ASK_IsValidRemote(&RF433) == 1)
{
ASK_GetRemoteInfo(&RF433, &id, &key);
printf("RemoteID:%u --- Key:%u", id, key);
}
}
}
#include <avr/io.h>
#include <avr/interrupt.h>
#include "ask_decoder.h"
ASK_TypeDef RF433;
int main(void)
{
uint8_t key;
uint32_t id;
/* Serial initialize */
UART0_Init(9600);
/* External Interrupt GPIO */
DDRE = 0x00;
PORTE = (1 << PORTE4);
/* External Interrupt Config */
EICRB = (1 << ISC40); // Set EXTI4 in any change mode
EIMSK = (1 << INT4); // Enable EXTI4
asm("sei"); // Enable global interrupt
while (1)
{
if (ASK_IsValidRemote(&RF433) == 1)
{
ASK_GetRemoteInfo(&RF433, &id, &key);
printf("RemoteID:%u --- Key:%u", id, key);
}
}
}
ISR(INT4_vect)
{
if (((PINE >> PORTE4) & 0x01) == 1)
{
ASK_ISRHandle_Rising(&RF433);
}
else
{
ASK_ISRHandle_Falling(&RF433);
}
}
- Run on STM32 Fx cores
- Run on AVR