29 #ifndef TEMU_MIL_STD_1553_H
30 #define TEMU_MIL_STD_1553_H
56 #define TEMU_1553_MSG_FLAG_INHIBIT_A 0x1
57 #define TEMU_1553_MSG_FLAG_INHIBIT_B 0x2
76 #define TEMU_1553_NS_PER_WORD 20000
77 static inline uint64_t
78 temu_mil1553TransferTime(
unsigned Words)
84 #define TEMU_1553_BITS_PER_WORD 20
85 static inline uint64_t
86 temu_mil1553BitCount(
unsigned Words)
93 static inline uint16_t
96 return (Msg->
Data[0] >> 11) & 0x1f;
99 static inline uint16_t
102 return (Msg->
Data[0] >> 10) & 1;
105 static inline uint16_t
108 return (Msg->
Data[0] >> 5) & 0x1f;
111 static inline uint16_t
114 return Msg->
Data[0] & 0x1f;
122 if (temu_mil1553CmdSubAddr(Msg) == 0x00 ||
123 temu_mil1553CmdSubAddr(Msg) == 0x1f) {
132 temu_mil1553CreateCmd(uint16_t *Cmd)
145 temu_mil1553CreateModeTransmittMsg0(uint16_t *Mode, uint16_t RTAddr,
152 *Mode = (RTAddr << 11) | (1 << 10) | MC;
160 temu_mil1553CreateModeRecvMsg0(uint16_t *Mode, uint16_t RTAddr, uint16_t MC)
166 *Mode = (RTAddr << 11) | MC;
174 temu_mil1553CreateModeTransmittMsg1(uint16_t *Mode, uint16_t RTAddr,
181 *Mode = (RTAddr << 11) | (1 << 10) | (0x1f << 5) | MC;
189 temu_mil1553CreateModeRecvMsg1(uint16_t *Mode, uint16_t RTAddr, uint16_t MC)
195 *Mode = (RTAddr << 11) | (0x1f << 5) | MC;
202 temu_mil1553CreateStatMsg(uint16_t *Stat, uint16_t RTAddr)
208 *Stat = RTAddr << 11;
215 temu_mil1553CreateDataMsg(uint16_t *Data,
size_t Words)
227 temu_mil1553CreateRecvCmdMsg(uint16_t *CmdWord, uint16_t RTAddr,
228 uint16_t SubAddr, uint16_t Words)
235 *CmdWord = (RTAddr << 11) | (SubAddr << 5) | (Words & 0x1f);
241 temu_mil1553CreateTransmittCmdMsg(uint16_t *CmdWord, uint16_t RTAddr,
242 uint16_t SubAddr, uint16_t Words)
249 *CmdWord = (RTAddr << 11) | (1 << 10) | (SubAddr << 5) | (Words & 0x1f);
272 void (*
connected)(
void *Device, temu_Mil1553BusIfaceRef Bus,
int SubAddr);
274 void (*
disconnected)(
void *Device, temu_Mil1553BusIfaceRef Bus,
int SubAddr);
281 #define TEMU_MIL1553_DEV_IFACE_TYPE "Mil1553DevIface"
284 void (*
connect)(
void *Bus,
int RTAddr, temu_Mil1553DevIfaceRef Device);
294 #define TEMU_MIL1553_BUS_IFACE_TYPE "Mil1553BusIface"
302 static inline uint16_t
303 temu_mil1553CmdWordRa(uint16_t Msg)
305 return (Msg >> 11) & 0x1f;
308 static inline uint16_t
309 temu_mil1553CmdWordSa(uint16_t Msg)
311 return (Msg >> 5) & 0x1f;
314 static inline uint16_t
315 temu_mil1553CmdWordTr(uint16_t Msg)
317 return (Msg >> 10) & 0x1;
320 static inline uint16_t
321 temu_mil1553CmdWordCount(uint16_t Msg)
326 static inline uint16_t
327 temu_mil1553ModeWordCode(uint16_t Msg)
332 static inline uint16_t
333 temu_mil1553StatWordRtAddr(uint16_t Msg)
335 return (Msg >> 11) & 0x1f;
338 static inline uint16_t
339 temu_mil1553StatWordME(uint16_t Msg)
341 return (Msg >> 10) & 1;
344 static inline uint16_t
345 temu_mil1553StatWordInst(uint16_t Msg)
347 return (Msg >> 9) & 1;
350 static inline uint16_t
351 temu_mil1553StatWordSR(uint16_t Msg)
353 return (Msg >> 8) & 1;
356 static inline uint16_t
357 temu_mil1553StatWordBC(uint16_t Msg)
359 return (Msg >> 4) & 1;
362 static inline uint16_t
363 temu_mil1553StatWordBusy(uint16_t Msg)
365 return (Msg >> 3) & 1;
368 static inline uint16_t
369 temu_mil1553StatWordSubFlag(uint16_t Msg)
371 return (Msg >> 2) & 1;
374 static inline uint16_t
375 temu_mil1553StatWordDynBusCtrl(uint16_t Msg)
377 return (Msg >> 1) & 1;
380 static inline uint16_t
381 temu_mil1553StatWordTermFlag(uint16_t Msg)
387 static inline uint16_t
390 return Msg->
Data[0] & 0x1f;
393 static inline uint16_t
396 return Msg->
Data[0] & 0x1f;
399 static inline uint16_t
402 return (Msg->
Data[0] >> 11) & 0x1f;
405 static inline uint16_t
408 return (Msg->
Data[0] >> 10) & 1;
411 static inline uint16_t
414 return (Msg->
Data[0] >> 9) & 1;
417 static inline uint16_t
420 return (Msg->
Data[0] >> 8) & 1;
423 static inline uint16_t
426 return (Msg->
Data[0] >> 4) & 1;
429 static inline uint16_t
432 return (Msg->
Data[0] >> 3) & 1;
435 static inline uint16_t
438 return (Msg->
Data[0] >> 2) & 1;
441 static inline uint16_t
444 return (Msg->
Data[0] >> 1) & 1;
447 static inline uint16_t
450 return Msg->
Data[0] & 1;
469 #define TEMU_1553_TR_BIT 0x20
471 #define TEMU_1553_DYN_BUS_CTRL 0x00
472 #define TEMU_1553_SYNC_NO_DATA 0x01
473 #define TEMU_1553_TRANSMIT_STATUS_WORD 0x02
474 #define TEMU_1553_INITIATE_SELF_TEST 0x03
475 #define TEMU_1553_TRANSMITTER_SHUTDOWN 0x04
476 #define TEMU_1553_OVERRIDE_TRANSMITTER 0x05
477 #define TEMU_1553_INHIBIT_TERM_FLAG_BIT 0x06
478 #define TEMU_1553_OVERRIDE_INHIBIT_TERM_FLAG_BIT 0x07
479 #define TEMU_1553_RESET_RT 0x08
480 #define TEMU_1553_TRANSMIT_VECTOR_WORD 0x10
481 #define TEMU_1553_SYNC_WITH_DATA 0x11
482 #define TEMU_1553_TRANSMIT_LAST_CMD 0x12
483 #define TEMU_1553_TRANSMIT_BIT_WORD 0x13
484 #define TEMU_1553_SELECTED_TRANSMITTER 0x14
485 #define TEMU_1553_OVERRIDE_SELECTED_TRANSMITTER 0x15
temu_Mil1553BusResetType ResetType
uint64_t LastReportSentWords
void(* disconnect)(void *Bus, int RTAddr)
void(* setBusController)(void *Bus, temu_Mil1553DevIfaceRef Device)
#define TEMU_1553_MSG_FLAG_INHIBIT_B
#define TEMU_1553_MSG_FLAG_INHIBIT_A
void(* busEnteredIdle)(void *Bus, temu_Mil1553BusIdleInfo *idleInfo)
Notifies the bus controller the bus enters an idle.
void(* disableSendEvents)(void *Bus)
void(* enableSendEvents)(void *Bus)
#define TEMU_IFACE_REFERENCE_TYPE(N)
void(* reportStats)(void *Bus)
temu_Mil1553MsgType MsgTyp
struct temu_Mil1553Msg temu_Mil1553Msg
void(* disconnected)(void *Device, temu_Mil1553BusIfaceRef Bus, int SubAddr)
Called after device is disconnected.
void(* send)(void *Bus, void *Sender, temu_Mil1553Msg *Msg)
void(* receive)(void *Device, temu_Mil1553Msg *Msg)
Receive of 1553 message.
void(* connect)(void *Bus, int RTAddr, temu_Mil1553DevIfaceRef Device)
#define TEMU_1553_BITS_PER_WORD
#define TEMU_1553_NS_PER_WORD
void(* connected)(void *Device, temu_Mil1553BusIfaceRef Bus, int SubAddr)
Called after device is connected to bus.