Initial public release of SystemK.

This commit is contained in:
Joe Kearney 2025-01-25 13:45:14 -06:00
parent 387f57cdda
commit 6f51f5b006
129 changed files with 11654 additions and 2 deletions

76
Events/KEvents.c Executable file
View file

@ -0,0 +1,76 @@
/*
* This program source code file is part of SystemK, a library in the KTag project.
*
* 🛡 <https://ktag.clubk.club> 🃞
*
* Copyright © 2016-2025 Joseph P. Kearney and the KTag developers.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* There should be a copy of the GNU Affero General Public License in the LICENSE
* file in the root of this repository. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdbool.h>
#include <stdio.h>
#include "SystemK.h"
#include "Command_Mapping.h"
#define QUEUE_LENGTH 10
#define ITEM_SIZE sizeof(KEvent_T)
static StaticQueue_t StaticQueue;
static uint8_t QueueStorageArea[QUEUE_LENGTH * ITEM_SIZE];
QueueHandle_t xQueueEvents;
static void Remap_Event(KEvent_T *event)
{
switch (event->ID)
{
case KEVENT_COMMAND_RECEIVED:
{
if (((DecodedPacket_T *)(event->Data))->Command.protocol == NEC_PROTOCOL)
{
uint32_t NEC_data = ((DecodedPacket_T *)(event->Data))->Command.data;
Remap_NEC_Command(event, NEC_data);
}
FreeDecodedPacketBuffer(event->Data);
}
break;
default:
// No remapping necessary.
break;
}
}
void Init_KEvents(void)
{
xQueueEvents = xQueueCreateStatic(QUEUE_LENGTH, ITEM_SIZE, QueueStorageArea, &StaticQueue);
}
void Post_KEvent(KEvent_T *event)
{
Remap_Event(event);
xQueueSend(xQueueEvents, event, 0);
}
void Post_KEvent_From_ISR(KEvent_T *event, portBASE_TYPE *xHigherPriorityTaskWoken)
{
Remap_Event(event);
xQueueSendFromISR(xQueueEvents, event, xHigherPriorityTaskWoken);
}
portBASE_TYPE Receive_KEvent(KEvent_T *event)
{
return xQueueReceive(xQueueEvents, event, 0);
}