Specifications

* Nut/OS automatically calls this entry after initialization.
*/
THREAD(NutMain, arg)
{
TCPSOCKET *sock;
int bytes;
int buffer_in = 0;
int buffer_shuffle;
int buffer_count;
/*
* Allocate the space required for the buffer
* Prevents the OS and the compiler writing to it
* Set the transmit and recieve pointer to the start of the space
*/
mem_start = NutHeapAlloc (BUFFER_SIZE) ;
mem_end = mem_start + BUFFER_SIZE;
tx_ptr = mem_start;
wr_ptr = mem_start;
mem_flip = mem_end;
/* Intialise the decoder and software reset it */
VsInit(4);
VsReset(0);
/* Configuration for the buttons*/
PORTD = 0xFF;
DDRD = 0x00;
/* Enable interrupts for the buttons */
EICR = 0x30;
EIMSK = 0x4F;
/* Register the decoder interupt with the OS */
NutRegisterInterrupt(IRQ_INT6, VsDataRequest, 0);
/* Register the button interupts with the OS */
NutRegisterInterrupt(IRQ_INT0, PauseButton, 0);
NutRegisterInterrupt(IRQ_INT1, PreviousButton, 0);
NutRegisterInterrupt(IRQ_INT2, StopButton, 0);
NutRegisterInterrupt(IRQ_INT3, NextButton, 0);
/* enable global interrupts */
sei();
/* intialise the LCD */
initialise_lcd();
/* Start the debounce thread with stack of 100 */
NutThreadCreate("debounce", debounce, NULL, 100);
/* Enable the decoder access to the buffer */
tx_act = 1;
/*
* Register Realtek controller at address 8300 hex
* and interrupt 5.
76