#include <avr/io.h>
#include <avr/signal.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#include <inttypes.h>
#include <stdlib.h>
#include <string.h>
#include "net/link.h"
#include "net/buffers.h"
#include "net.h"
Go to the source code of this file.
Data Structures | |
struct | receive_info_t |
Structure containing all variables concerning packet reception. More... | |
struct | send_info_t |
Variables needed for transmitting. More... | |
Defines | |
#define | ext_init() sbi(MCUCR, LNK_EXT_ISCx1) |
#define | ext_enable() {GIFR = _BV(LNK_EXT_INT); sbi(GIMSK, LNK_EXT_INT);} |
#define | ext_disable() cbi(GIMSK, LNK_EXT_INT) |
#define | UDR UDR0 |
#define | USR UCSR0A |
#define | UCR UCSR0B |
#define | UBRR UBRR0 |
#define | RENAME_ISR |
#define | POLY_CRC16 0x1021 |
CCITT CRC polynominal. | |
Enumerations | |
enum | recv_stat_e { RECV_STAT_FREE, RECV_STAT_RECEIVING, RECV_STAT_EXAMINE } |
Actual receive state. More... | |
enum | send_stat_e { SEND_STAT_IDLE, SEND_STAT_WAIT, SEND_STAT_SEND_DATA, SEND_STAT_INFORM } |
Actual send state. More... | |
Functions | |
void | lnk_con (void) |
Called from link layer if a packet was delivered. | |
void | lnk_init (void) |
Perform initialization of link layer. | |
void | lnk_process (void) |
Process link layer specific tasks. | |
int8_t | lnk_requ (net_buf_t *buf, uint8_t backlog) |
Schedule a packet for sending. | |
uint8_t | lnk_clear_to_send (void) |
Check if link layer is able to process further packets. | |
void | lnk_get_error_stats (struct lnk_err_t *buf) |
Fill a buffer with link layer error statistics. |
This layer is rather hardware specific. Read the following carefully to understand what parts are used and how. I assume you are familiar with the protocol itself. If not read OpenHome.doc.
In the first place it uses Timer/Counter0 exclusively for slot timing. The timer is configured through to following definitions located in your net.h:
Both values must be adjusted that Timer/Counter0 meets the desired slot time. Use the lowest prescaler that is possible to reach a maximum resulution. Otherwise the timing is prone to jitter and might be inconsistent between different nodes in the network which increases the possibility of collisions!
Definition in file link.c.
|
Actual receive state.
|
|
Actual send state.
|
|
Check if link layer is able to process further packets.
Definition at line 426 of file link.c. References SEND_STAT_IDLE, and send_info_t::status. Referenced by net_clear_to_send(), and net_requ(). |
|
Called from link layer if a packet was delivered. Simply passes event to upper layers. Definition at line 139 of file network.c. References net_con(). Referenced by lnk_process(). |
|
Fill a buffer with link layer error statistics.
|
|
Perform initialization of link layer. This function must be called before any other network functions are called. Definition at line 289 of file link.c. References receive_info_t::crc16, send_info_t::slot, and receive_info_t::slots. |
|
Process link layer specific tasks. Call this function as often as possible from your main loop. It processes link layer specific tasks such as passing received packets to upper layers and scheduling send requests.
Definition at line 317 of file link.c. References send_info_t::backlog, send_info_t::backlog_add, receive_info_t::buf, receive_info_t::crc16, lnk_con(), lnk_ind(), receive_info_t::pos, RECV_STAT_EXAMINE, RECV_STAT_FREE, lnk_err_t::rx_crc, lnk_err_t::rx_len, SEND_STAT_IDLE, SEND_STAT_INFORM, SEND_STAT_WAIT, send_info_t::slot, receive_info_t::slots, send_info_t::status, and receive_info_t::status. |
|
Schedule a packet for sending. This function returns without waiting for the packet to be sent. If the packet is fully transmitted then lnk_con is called.
Definition at line 383 of file link.c. References send_info_t::backlog_add, send_info_t::data, POLY_CRC16, SEND_STAT_IDLE, SEND_STAT_WAIT, send_info_t::slot, and send_info_t::status. Referenced by net_requ(). |