forked from haraldwolff/avr-fw-modules
39 lines
949 B
C
39 lines
949 B
C
#include <hwo/fifo.h>
|
|
#include <hwo/utils.h>
|
|
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
#include <rb2/regbus.h>
|
|
|
|
RB2_INSTANCE __rb2_instance;
|
|
|
|
uint8_t rb2_init(uint8_t ax)
|
|
{
|
|
memset(&__rb2_instance,0x00,sizeof(__rb2_instance));
|
|
|
|
__rb2_instance.ax = ax;
|
|
__rb2_instance.enabled = 1;
|
|
__rb2_instance.timeout = RB2_REQUEST_TIMEOUT;
|
|
|
|
if (__rb2_instance.ax == RB_AX_MASTER)
|
|
__rb2_instance.ringmaster = 1;
|
|
|
|
list_init( (list_t*)&__rb2_instance.links.list );
|
|
list_init( (list_t*)&__rb2_instance.queues.router );
|
|
list_init( (list_t*)&__rb2_instance.queues.pending );
|
|
|
|
list_init( (list_t*)&__rb2_instance.proxy );
|
|
|
|
__rb2_instance.links.lock = SPINLOCK_INIT_UNLOCKED;
|
|
__rb2_instance.queues.sl_router = SPINLOCK_INIT_UNLOCKED;
|
|
__rb2_instance.queues.sl_pending= SPINLOCK_INIT_UNLOCKED;
|
|
|
|
__rb2_instance.threads.router = thread_alloc( rb2_router, NULL, 192);
|
|
thread_set_priority( __rb2_instance.threads.router, TP_LOW );
|
|
|
|
yield();
|
|
|
|
return 0;
|
|
};
|