PDCP for AVR – top layer interface

overview

This document describes the top level interface of the High Level Layer of PDCP for AVR. PDCP for AVR consists of 2 layers:

  1. hll – High Level Layer
  2. hal – Hardware Abstraction Layer

Only the High Level Layer is considered here, which is hopefully the most important part for the application programmer.

synopsis

#include <socket.h>
struct can_msg;
struct canel;
struct socket;
typedef void (*sock_recv_hook)(struct socket* this);
void sock_init(struct socket* this);
void sock_register_recv_hook(struct socket* this, sock_recv_hook fn);
void sock_push(struct socket* this, struct can_msg* msg);
struct can_msg *sock_pull(struct socket* this);

#include <hll.h>
extern struct hll hll_global;
typedef socknum_t;
typedef void (*hll_handled_hook)(uint8_t fncode);
void hll_init(sock_recv_hook app_callback, hll_handled_hook app_notify);
struct can_msg* hll_msg_pull(socknum_t sd);
void hll_msg_push(struct can_msg *msg, socknum_t sd);

struct can_msg* hll_msg_alloc();
void hll_msg_commit(struct can_msg* msg);
struct can_msg* hll_msg_get();
void hll_msg_free(struct can_msg* msg);

description

hll_.

hll_.

hll_.

hll_.

hll_.

hll_.

hll_.

hll_.

hll_.

hll_.


hll_msg_alloc shall reserve unused memory in the high level layer for an incoming CAN message. This memory shall contain a can_msg structure, to which a pointer shall be returned to the caller. The caller must initialze the structure and send it back by calling hll_msg_commit.

hll_msg_commit shall pass the CAN message referenced by msg to the high level layer's input queue.

hll_msg_get shall look for an outgoing CAN message, and if found, return the contained can_msg structure. Otherwise, it shall return NULL. The caller must signify when it is finished with the pointed-to memory by calling hll_msg_free.

hll_msg_free shall mark the memory in use by the CAN message containing msg as unused.

failure modes

If no memory for an incoming CAN message is found, hll_msg_alloc shall return NULL.

If no outgoing CAN message is found, hll_msg_get shall return NULL.

These functions shall not fail:

note