int main() { // Initialize the hardware sp_timer_init(); led_init(); adc_init(); systime_init(); // Initalize the routines for preemption spk_init(); // Initialize the data_ready semaphore TASK_SEM_INIT(&data_ready, 0); // Create the fft_task sp_create( fft_task, 1 ); // Init the radio cc1k_radio_init(); // Create the sampling_task sp_create( sampling_task, 2 ); /* if( sp_node_address == 1 ) { sp_create( test_radio, 1 ); led_yellow_toggle(); } else { sp_create( test_receiver, 1 ); led_yellow_toggle(); } */ //ENABLE_INT(); // Call the scheduler spk_sched(); return 0; }
void sp_stream_init (struct sp_stream *self, struct sp_epbase *epbase, struct sp_usock *usock) { int rc; /* Redirect the underlying socket's events to this state machine. */ self->usock = usock; self->sink = &sp_stream_state_start; self->original_sink = sp_usock_setsink (usock, &self->sink); /* Initialise the pipe to communicate with the user. */ /* TODO: Socket type may reject the pipe. What then? */ rc = sp_pipebase_init (&self->pipebase, &sp_stream_pipebase_vfptr, epbase); sp_assert (rc == 0); /* Start the header timeout timer. */ sp_timer_init (&self->hdr_timeout, &self->sink, usock->cp); sp_timer_start (&self->hdr_timeout, 1000); /* Send the protocol header. */ sp_usock_send (usock, "\0\0SP\0\0\0\0", 8); /* Receive the protocol header from the peer. */ sp_usock_recv (usock, self->hdr, 8); }