add basic library for flexki messaging

This commit is contained in:
Johannes Wirth 2025-02-18 09:54:19 +01:00
parent a9aa746f81
commit db3ff44066
3 changed files with 61 additions and 2 deletions

View File

@ -36,7 +36,9 @@
#define i2s PERIPH(i2s_t, APB_BASE + 0x90000)
#define camera PERIPH(camera_t, APB_BASE + 0xA0000)
#define dma PERIPH(dma_t, APB_BASE + 0xB0000)
#define msgif PERIPH(msgif_t, APB_BASE + 0xC0000)
#define msgif PERIPH(mkcontrolclusterstreamcontroller_t, APB_BASE + 0xC0000)
#include "ehrenberg/devices/flexki_messages.h"
#define XIP_START_LOC 0xE0040000
#define RAM_START_LOC 0x80000000

View File

@ -0,0 +1,57 @@
#ifndef _FLEXKI_MESSAGES_H
#define _FLEXKI_MESSAGES_H
#include <stdbool.h>
static void send_msg(uint32_t cluster, uint32_t component, uint32_t msg_len, uint32_t msg_id, uint32_t* words) {
set_mkcontrolclusterstreamcontroller_REG_HEADER_RECIPIENT_COMPONENT(msgif, component);
set_mkcontrolclusterstreamcontroller_REG_HEADER_RECIPIENT_CLUSTER(msgif, cluster);
set_mkcontrolclusterstreamcontroller_REG_HEADER_MESSAGE_LENGTH(msgif, msg_len);
set_mkcontrolclusterstreamcontroller_REG_HEADER_MESSAGE_ID(msgif, msg_id);
for (uint32_t i = 0; i < msg_len; i = i + 1) {
switch (i) {
case 0:
set_mkcontrolclusterstreamcontroller_REG_PAYLOAD_0(msgif, words[i]);
break;
case 1:
set_mkcontrolclusterstreamcontroller_REG_PAYLOAD_1(msgif, words[i]);
break;
case 2:
set_mkcontrolclusterstreamcontroller_REG_PAYLOAD_2(msgif, words[i]);
break;
case 3:
set_mkcontrolclusterstreamcontroller_REG_PAYLOAD_3(msgif, words[i]);
break;
case 4:
set_mkcontrolclusterstreamcontroller_REG_PAYLOAD_4(msgif, words[i]);
break;
case 5:
set_mkcontrolclusterstreamcontroller_REG_PAYLOAD_5(msgif, words[i]);
break;
case 6:
set_mkcontrolclusterstreamcontroller_REG_PAYLOAD_6(msgif, words[i]);
break;
case 7:
set_mkcontrolclusterstreamcontroller_REG_PAYLOAD_7(msgif, words[i]);
break;
default:
}
}
set_mkcontrolclusterstreamcontroller_REG_SEND(msgif, 1);
}
static uint32_t wait_response(uint32_t msg_id) {
while (true) {
if (get_mkcontrolclusterstreamcontroller_REG_ACK_PENDING_RESPONSE(msgif) != 0) {
if (get_mkcontrolclusterstreamcontroller_REG_RECV_ID_RECV_ID(msgif) == msg_id) {
break;
}
}
}
uint32_t response_payload = get_mkcontrolclusterstreamcontroller_REG_RECV_PAYLOAD(msgif);
set_mkcontrolclusterstreamcontroller_REG_ACK_ACK(msgif, 1);
return response_payload;
}
#endif /* _FLEXKI_MESSAGES_H */

View File

@ -1,6 +1,6 @@
#ifndef _DEVICES_MSG_IF_H
#define _DEVICES_MSG_IF_H
#include "gen/msgif.h"
#include "gen/mkcontrolclusterstreamcontroller.h"
#endif /* _DEVICES_MSG_IF_H */