예제 #1
0
파일: main.c 프로젝트: cuijfboy/SurTracker
void get_ready(void)
{
	menu_init();
#if DEBUG	
	uart_puts_p(PSTR("menu_init() Completed! \n"));
#endif

	LED_on(LED_0);
	LED_on(LED_1);
	LED_on(LED_2);
	LED_on(LED_3);
	
	set_screen(SPLASH_SCN);
	_delay_ms(2000);
	
	gps_set_arg();
	
	LED_off(LED_0);
	LED_off(LED_1);
	LED_off(LED_2);
	LED_off(LED_3);
	
	set_screen(READY_SCN);
	menu_start();	
}
예제 #2
0
static void led_display(){
	alt_16 switch_value = 0;
	int i = 0;
	switch_value = ReadSwitches();
	_Bool press_flag = true;
	edge_capture = 0;
	init_button_pio();
	while(1 == 1){
		if(edge_capture && press_flag){
			press_flag = false;
			edge_capture = 0;
			switch_value = ReadSwitches();
			/*displaying switches' value to LED or seven-segment*/
			for(i = 0; i < 8; i ++){
				if (edge_capture && !press_flag){//get interruption from button release
					edge_capture = 0;
					press_flag = true;
				}else if(edge_capture)//get interruption from reseting the switches
					break;
				/*If the next bit is 1 then turn on the led*/
				if (switch_value & 1)
					LED_on();
				else
				/*If the next bit is 0 then turn off the led*/
					LED_off();
				switch_value >>=  1;
			}
			LED_off();
		}else if(edge_capture){//get interruption from button release
예제 #3
0
// This routine is called once to allow you to set up any other variables in your
//program
// You can use 'clock' function here.
// The loopStart parameter has the current clock value in ìS
TICK_COUNT appInitSoftware(TICK_COUNT loopStart){

    LED_off(&RightRed); 
    LED_off(&LeftRed); 
    LED_off(&SpotLightWhite); 
    LED_on(&PowerGreen);

    sonyPS2_setAnalogMode(&controller1);
    sonyPS2_calibrate(&controller1, 25);

return 0; // dont pause after
}
예제 #4
0
static void FA_NOINLINE( Flash_LED_12MS ) ( void )
{
    LED_on() ;
    Delay_1024( T0DEL4MS ) ;
    LED_off() ;
    Delay_1024( T0DEL8MS ) ;
}
예제 #5
0
파일: rf_dngl.c 프로젝트: nodep/7g-wireless
uint8_t rf_dngl_recv(__xdata void* buff, uint8_t buff_size)
{
	uint8_t ret_val = 0;
	
	// check if there's data in the RX FIFO
	nRF_ReadReg(FIFO_STATUS);
	if ((nRF_data[1] & vRX_EMPTY) == 0)
	{
		LED_on();
		
		// read the payload
		nRF_ReadRxPayloadWidth();
		ret_val = nRF_data[1];

		// the nRF specs state I have to drop the packet if the length is > 32
		if (ret_val > 32)
		{
			nRF_FlushRX();
			ret_val = 0;
		} else {
			nRF_ReadRxPayload(ret_val);
			memcpy_X(buff, nRF_data + 1, ret_val > buff_size ? buff_size : ret_val);
		}

		// reset the TX_DS
		if (nRF_data[0] & vTX_DS)
			nRF_WriteReg(STATUS, vTX_DS);

		LED_off();
	}
	
	return ret_val;
}
예제 #6
0
파일: bomb.c 프로젝트: westlicht/camcontrol
/*..........................................................................*/
QState Bomb_timing(Bomb *me) {
    switch (Q_SIG(me)) {
        case Q_ENTRY_SIG: {
            QActive_arm((QActive *)me, BSP_TICKS_PER_SEC/4);
            return Q_HANDLED();
        }
        case Q_TIMEOUT_SIG: {
            QActive_arm((QActive *)me, BSP_TICKS_PER_SEC/4);
            if (me->ctr > (uint8_t)0) {
                if ((me->ctr & 0x01) != 0) {
                    LED_on();
                }
                else {
                    LED_off();
                }
                --me->ctr;
            }
            else {                                       /* timeout expired */
                return Q_TRAN(&Bomb_blast);
            }
            return Q_HANDLED();
        }
    }
    return Q_IGNORED();
}
예제 #7
0
파일: main.c 프로젝트: PlugaruT/PAIIP
int main(void)
{
	char ch;
	serial_init(51);
	LED_init();
	
	while(1)
	{
		//print messages on the screen
		printf("Press 1 to turn LED on. \r");
		printf("Press 0 to turn LED off. \r\r");
		//get the input char from keyboard
		ch = serial_getchar();
		
		switch(ch)
		{
			case '0':
				//turn off LED
				printf("LED off!\r");
				LED_off();
				break;
			case '1':
				//turn on LED
				printf("LED on!\r");
				LED_on();
				break;
			default:
				printf("Wrong key!\r");
				break;
		}
	}
}
예제 #8
0
파일: Blinky.c 프로젝트: nganthony/ECE254
/*----------------------------------------------------------------------------
 * switch LED off
 *---------------------------------------------------------------------------*/
void LED_Off (unsigned char led) {
  LED_off(led);
  os_mut_wait(mut_GLCD, 0xffff);
  GLCD_SetBackColor(White);                         /* Set the Back Color */
  GLCD_SetTextColor(Green);                         /* Set the Text Color */
  GLCD_DisplayChar(4, 5+led, 1, 0x80+0);            /* Circle Empty       */
  os_mut_release(mut_GLCD);
}
예제 #9
0
/*----------------------------------------------------------------------------
  Thread 5 'clock': Signal Clock
 *---------------------------------------------------------------------------*/
void clock (void const *argument) {
  for (;;) {
    osSignalWait(0x0100, osWaitForever);    /* wait for an event flag 0x0100 */
    LED_on (LED_CLK);
    osDelay(80);                            /* delay 80ms                    */
    LED_off(LED_CLK);
  }
}
예제 #10
0
/*----------------------------------------------------------------------------
  Thread 1 'phaseA': Phase A output
 *---------------------------------------------------------------------------*/
void phaseA (void const *argument) {
  for (;;) {
    osSignalWait(0x0001, osWaitForever);    /* wait for an event flag 0x0001 */
    LED_on (LED_A);
    signal_func (tid_phaseB);               /* call common signal function   */
    LED_off(LED_A);
  }
}
예제 #11
0
파일: main.c 프로젝트: blinkyshit/dro
void blink_LED(int n){
	int i;
	for(i=0;i<n;i++){
		LED_on();
		_delay_ms(500);
		LED_off();
		_delay_ms(500);
	}
}
예제 #12
0
void leaveProgramMode( ) {
	spiMaster_disable( );
	drivePin( B, AVRISP_PIN_RESET, low );
	floatingInput_init( B, AVRISP_PIN_RESET );
	
	LED_off( );
	
	uart_putc( BYTE_CR ); // done!
}
예제 #13
0
/** Mass Storage class driver callback function the reception of SCSI commands from the host, which must be processed.
 *
 *  \param[in] MSInterfaceInfo  Pointer to the Mass Storage class interface configuration structure being referenced
 */
bool CALLBACK_MS_Device_SCSICommandReceived(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
{
	bool CommandSuccess;

	LED_off();
	CommandSuccess = SCSI_DecodeSCSICommand(MSInterfaceInfo);
	LED_on();

	return CommandSuccess;
}
예제 #14
0
파일: main.c 프로젝트: henrychoi/realtime
int main(void) {
	uint16_t status;

	WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
	LED_init();
	LED_on();
    /* configure the Basic Clock Module */
    DCOCTL = CALDCO_1MHZ;
    BCSCTL1 = CALBC1_1MHZ;

    BCSCTL2 = SELM_3 + DIVM_0;//MCLK = LFXTCLK/1
#ifdef NECESSARY
    do {
    	int i;
        IFG1 &= ~OFIFG;                           // Clear OSCFault flag
        for (i = 0xFF; i > 0; i--);               // Time for flag to set
    } while ((IFG1 & OFIFG)); // OSCFault flag still set?
#endif
    TACTL = TASSEL_2 | MC_1; /* SMCLK, upmode */
    TACCR0 = TIMER_CLK_HZ/SYSTICK_HZ;
	TACCTL0 = CCIE; /*Enable timer A0 interrupt*/

	//Enable SCLK, SDI, SDO, master
	USICTL0 |= USIPE7 | USIPE6 | USIPE5 | USIMST | USIOE;
	USICKCTL |= USIDIV_0 //this actually means divide by 1
			  | USISSEL_2//Use SMCLK to drive the SPI clk
			  //| USICKPL
			  ;
	USICTL1 |= USICKPH;//delay?
	//USICTL1 |= USIIE;//interrupt enable
	//		;
	P1OUT = BIT4;//Pull up nCS at first
	P1DIR |= BIT4;//nCS is P1.4
	//P1REN |= 0x10;?

	_enable_interrupts();//vs. _BIS_SR(LPM0_bits + GIE);
	LED_off();

	dSPIN_Soft_Stop();
	dSPIN_Reset_Device();

	status = dSPIN_Get_Status();
   	if(status & dSPIN_STATUS_SW_EVN
   		|| (status & dSPIN_STATUS_MOT_STATUS) != dSPIN_STATUS_MOT_STATUS_STOPPED
   		|| status & dSPIN_STATUS_NOTPERF_CMD
   		|| status & dSPIN_STATUS_WRONG_CMD
   		// !(status & dSPIN_STATUS_UVLO)
   		|| !(status & dSPIN_STATUS_TH_SD)
   		|| !(status & dSPIN_STATUS_OCD))
		Q_ERROR();
    if(dSPIN_Busy_HW()) Q_ERROR();
    return 0;
}
예제 #15
0
/** Main program entry point. This routine contains the overall program flow, including initial
 *  setup of all components and the main program loop.
 */
int main(void)
{
	SetupHardware();

	LED_off();
	sei();

	for (;;)
	{
		MS_Device_USBTask(&Disk_MS_Interface);
		USB_USBTask();
	}
}
예제 #16
0
파일: bomb.c 프로젝트: westlicht/camcontrol
/*..........................................................................*/
QState Bomb_off(Bomb *me) {
    switch (Q_SIG(me)) {
        case Q_ENTRY_SIG: {
            LED_off();
            return Q_HANDLED();
        }
        case ARM_SIG: {
            me->ctr = Q_PAR(me) * 4;                 /* arm the downcounter */
            return Q_TRAN(&Bomb_timing);
        }
    }
    return Q_IGNORED();
}
예제 #17
0
void LED_loop(void){
//	xprintf(INFO "LED_loop(void)");FFL_();
	Led_loopp++;
	if (LED_INT_OCCURED){
		count++;
//		xprintf(INFO "LED_INT_OCCURED=%d LED_LOOP=%d",count,Led_loopp);FFL_();
		Led_loopp=0;
		switch(LED_PATTERN){
			case LEDP_off:
				LED_off();
				break;
			case LEDP_time:
				LED_time();
				break;
			case LEDP_one_by_one:
				LED_one_by_one();
				break;
			case LEDP_rotating_rainbow:
				LED_rotating_rainbow();
				break;
			case LEDP_simple_all_colors:
				LED_simple_all_colors();
				break;
			case LEDP_one_by_one_smooth_all_on_all_off0:
				LED_one_by_one_smooth_all_on_all_off(0);
				break;
			case LEDP_one_by_one_smooth_all_on_all_off1:
				LED_one_by_one_smooth_all_on_all_off(1);
				break;
			case LEDP_one_by_one_smooth_all_on_all_off2:
				LED_one_by_one_smooth_all_on_all_off(2);
				break;
			case LEDP_rainbow_all:
				LED_rainbow_all();
				break;
			case LEDP_Pause:
				Pause(); // dont rearange
				break;
			case LEDP_Play:
				Play(); // dont rearange
				break;
			case LEDP_RAW:
				//raw  dont remove!!
				break;
			default:
				LED_time();
				break;
		}
		LED_INT_OCCURED = 0;
	}
}
예제 #18
0
파일: main.c 프로젝트: Ntkrell/brain
// kill function for field debug.  flash n times forever
void kill(int n) {

    int i;
    while (1) {
        for (i = 0; i < n; i++) {
            LED_on();
            _delay_ms(100);

            LED_off();
            _delay_ms(200);
        }
        _delay_ms(2000);
    }
}
예제 #19
0
/** Event handler for the library USB Configuration Changed event. */
void EVENT_USB_Device_ConfigurationChanged(void)
{
	bool ConfigSuccess = true;

	ConfigSuccess &= MS_Device_ConfigureEndpoints(&Disk_MS_Interface);

    if (ConfigSuccess)
    {
        LED_on();
    }
    else
    {
        LED_off();
    }
}
예제 #20
0
/**
 * \ingroup sd_raw
 * Send a command to the memory card which responses with a R1 response (and possibly others).
 *
 * \param[in] command The command to send.
 * \param[in] arg The argument for command.
 * \returns The command answer.
 */
uint8_t sd_raw_send_command(uint8_t command, uint32_t arg)
{
  uint8_t response;
  uint8_t n_try = 0;

  do
  {
    n_try++;

    // wait before retrying
    if (n_try > 1)
    {
      delay(50);
      printf("Retry ");
    }
    //printf("C %hd %ld\r\n", command, arg);

    LED_on();

    /* interrupt request */
    irq_high();

    /* send command via SPI */
    sd_raw_send_byte(0x40 | command);
    sd_raw_send_byte((arg >> 24) & 0xff);
    sd_raw_send_byte((arg >> 16) & 0xff);
    sd_raw_send_byte((arg >> 8) & 0xff);
    sd_raw_send_byte((arg >> 0) & 0xff);

    /* receive response */
    response = sd_raw_rec_byte();

    /* finish interrupt request */
    irq_low();

    LED_off();

    // after 255 trials, fail
    if (n_try == 0xff)
    {
      response = R1_FAILURE;
      break;
    }
  }
  while (response == R1_WAIT_RETRY);

  return response;
}
예제 #21
0
void pulse_led(int8_t speed) {
  // blink D13
  pulse_tick++;
  if (pulse_tick==BOOT_PULSE_MAX) {
    pulse_tick = 0;
    pulse_pwm += pulse_dir * speed;
    if (pulse_pwm > 255) {
      pulse_pwm = 255;
      pulse_dir = -1;
    }
    if (pulse_pwm < 0) {
      pulse_pwm = 0;
      pulse_dir = +1;
    }
    LED_on();
  }
  if (pulse_tick==pulse_pwm) 
    LED_off();
}
예제 #22
0
//enter your code in control here
//photovore is just a default sample program and can be deleted
void control(void)
	{
	//photovore();//run photovore algorithm, or comment out for your own code

	for(int x = 0; x < 10000; x++)
	{
		LED_on();
	}

	for(int x = 0; x < 10000; x++)
	{
		LED_off();
	}






	}
예제 #23
0
파일: bsp.c 프로젝트: henrychoi/realtime
/*..........................................................................*/
void BSP_init(void) {
	int i;
    WDTCTL = (WDTPW | WDTHOLD);                               /* Stop WDT */

    //P1DIR = 0; P2DIR = 0; P3DIR = 0; P4DIR = 0; P5DIR = 0;
    P6DIR = 0x20;
    //P1OUT = 0; P2OUT = 0; P3OUT = 0; P4OUT = 0; P5OUT = 0; P6OUT = 0;

    LED_on();//begin startup

    /* configure the Basic Clock Module */
#ifdef CALDCO_8MHZ//feature available on MSP430F2xxxx
    DCOCTL   = CALDCO_8MHZ;                              /* Set DCO to 8MHz */
    BCSCTL1  = CALBC1_8MHZ;
#else
    DCOCTL = 0x7 << 5 //frequency; looks like 8 MHz: the fastest for this chip
    	   + 0x00;// modulation; useless (set to 0) when DCO = 7
    BCSCTL1 = XT2OFF + XTS /* LFXTCLK 0:Low Freq. / 1: High Freq. */
    		+ DIVA_0 /* Auxiliary Clock Divider; ACLK Divider 0: /1 */
    		+ 0x7;//RSEL: the value of the resistor defines the nominal frequency
#endif
    do {
        IFG1 &= ~OFIFG;                           // Clear OSCFault flag
        for (i = 0xFF; i > 0; i--);               // Time for flag to set
    } while ((IFG1 & OFIFG)); // OSCFault flag still set?

    BCSCTL2 = SELM_3 + DIVM_0;//MCLK = LFXTCLK/1
    //Configure timer
    //The up mode is used if the timer period must be different from TBR(max)
    //counts. The timer repeatedly counts up to the value of compare latch
    //TBCL0, which defines the period.
    TBCTL = ID_3 | // DIV_8
    		TASSEL_2 | MC_1;//SMCLK, upmode
    TBCCR0 = TIMER_VAL;
    //TBCCR0 = ((BSP_SMCLK)//divide by 1 since we use ID_0 mode (DIV1)
    //          + BSP_TICKS_PER_SEC/2)
    //       / BSP_TICKS_PER_SEC;

    LED_off();//end startup
}
예제 #24
0
//*****************************************************************************
//
// Print "Hello World!" to the UART on the evaluation board.
//
//*****************************************************************************
int
main(void)
{

	//Configure all the hardware
	HW_Configure();

	//volatile uint32_t ui32Loop;


    UARTprintf("\r\nTimerTest\r\n");

    //
    // We are finished.  Hang around doing nothing.
    //
    while(1)
    {
        LED_on(LED_GREEN);
        SysCtlDelay(SysCtlClockGet() / 10 / 10);
        LED_off(LED_GREEN);
        SysCtlDelay(SysCtlClockGet() / 10 / 1);
        UARTprintf(".");
    }
}
예제 #25
0
void processCommand( unsigned char cmd ) {
	
	if ( cmd == CMD_SELECT_DEVICE ) {
		selectedDevice = uart_getc( );
		uart_putc( BYTE_CR );
	} else if ( cmd == CMD_SHOW_ID ) {
		uart_puts( AVRISP_IDENTIFIER );
	} else if ( cmd == CMD_SOFTWARE_VERSION ) {
		uart_puts( AVRISP_SWVER );
	} else if ( cmd == CMD_HARDWARE_VERSION ) {
		uart_puts( AVRISP_HWVER );
	} else if ( cmd == CMD_LIST_SUPPORTED_DEVICES ) {
		uart_puts( AVRISP_SUPPORTED_DEVICES );
		uart_putc( 0 ); // terminating null character needs to be sent
	} else if ( cmd == CMD_PROGRAMMER_TYPE ) {
		uart_putc( AVRISP_PROGRAMMER_TYPE );
	} else if ( cmd == CMD_SUPPORTS_AUTOINCREMENT ) {
		uart_putc( AVRISP_RESP_YES );
	} else if ( cmd == CMD_SET_LED ) {
		LED_on( );
		uart_putc( BYTE_CR );
	} else if ( cmd == CMD_CLEAR_LED ) {
		LED_off( );
		uart_putc( BYTE_CR );
	} else if ( selectedDevice == 0 ) {
		// require a device for the rest of the commands
		uart_putc( AVRISP_RESP_UNKNOWN );
		return;
	}
	
	// command not specified above
	
	if ( cmd == CMD_ENTER_PROGRAM_MODE ) {
		enableProgramMode( );
	} else if ( cmd == CMD_LEAVE_PROGRAM_MODE ) {
		leaveProgramMode( );
	} else if ( cmd == CMD_WRITE_PROG_H ) {
		writeProgH( );
	} else if ( cmd == CMD_WRITE_PROG_L ) {
		writeProgL( );
	} else if ( cmd == CMD_READ_PROG ) {
		readProg( );
	} else if ( cmd == CMD_LOAD_ADDRESS ) {
		loadAddress( );
	} else if ( cmd == CMD_WRITE_DATA ) {
		writeData( );
	} else if ( cmd == CMD_READ_DATA ) {
		readData( );
	} else if ( cmd == CMD_CHIP_ERASE ) {
		chipErase( );
	} else if ( cmd == CMD_WRITE_LOCK_BITS ) {
		writeLockBits( );
	} else if ( cmd == CMD_READ_SIGNATURE ) {
		readSignature( );
	} else if ( cmd == CMD_WRITE_PROGRAM_PAGE ) {
		writeProgramPage( );
	} else if ( cmd == CMD_UNIVERSAL_3 ) {
		universalWrite3( );
	} else if ( cmd == CMD_UNIVERSAL_4 ) {
		universalWrite4( );
	} else if ( cmd == CMD_LOAD_ADDRESS_0 ) {
		currentAddress = 0;
		uart_putc( BYTE_CR );
	}
}
예제 #26
0
파일: main.c 프로젝트: jthen/7g-wireless
void main()
{
	bool keyboard_report_ready = false;
	bool consumer_report_ready = false;

	uint8_t prev_keycode = KC_NO;
	
	__xdata uint8_t recv_buffer[RECV_BUFF_SIZE];
	__xdata uint8_t bytes_received;
	
	P0DIR = 0x00;	// all outputs
	P0ALT = 0x00;	// all GPIO default behavior
	
	LED_off();

	usbInit();
	//dbgInit();
	
	rf_dngl_init();

	reset_keyboard_report();
	
	for (;;)
	{
		usbPoll();	// handles USB interrupts
		//dbgPoll();	// send chars from the uart TX buffer
		
		// try to read the recv buffer
		bytes_received = rf_dngl_recv(recv_buffer, RECV_BUFF_SIZE);

		if (bytes_received)
		{
			// we have new data, so what is it?
			if (recv_buffer[0] == MT_KEY_STATE)
			{
				process_key_state_msg(recv_buffer, bytes_received);

				consumer_report_ready = true;
				keyboard_report_ready = true;
			} else if (recv_buffer[0] == MT_TEXT) {
				process_text_msg(recv_buffer, bytes_received);
			}
		}

		if (!keyboard_report_ready  &&  !msg_empty())
		{
			// get the next char from the stored text message
			uint8_t c = msg_peek();
			uint8_t new_keycode = get_keycode_for_char(c);

			reset_keyboard_report();

			// if the keycode is different than the previous
			// otherwise just send an empty report to simulate key went up
			if (new_keycode != prev_keycode  ||  new_keycode == KC_NO)
			{
				usb_keyboard_report.keys[0] = new_keycode;
				usb_keyboard_report.modifiers = get_modifiers_for_char(c);
				
				msg_pop();	// remove char from the buffer
			} else {
				new_keycode = KC_NO;
			}
			
			keyboard_report_ready = true;
			
			prev_keycode = new_keycode;		// remember for later
		}
		
		// send the report if the endpoint is not busy
		if ((in1cs & 0x02) == 0   &&   (keyboard_report_ready  ||  usbHasIdleElapsed()))
		{
			// copy the keyboard report into the endpoint buffer
			in1buf[0] = usb_keyboard_report.modifiers;
			in1buf[1] = 0;
			in1buf[2] = usb_keyboard_report.keys[0];
			in1buf[3] = usb_keyboard_report.keys[1];
			in1buf[4] = usb_keyboard_report.keys[2];
			in1buf[5] = usb_keyboard_report.keys[3];
			in1buf[6] = usb_keyboard_report.keys[4];
			in1buf[7] = usb_keyboard_report.keys[5];

			// send the data on it's way
			in1bc = 8;
			
			keyboard_report_ready = false;
		}

		// send the consumer report if the endpoint is not busy
		if ((in2cs & 0x02) == 0   &&   (consumer_report_ready  ||  usbHasIdleElapsed()))
		{
			in2buf[0] = usb_consumer_report;
			in2bc = 1;
		
			consumer_report_ready = false;
		}
	}
}
예제 #27
0
/*!
 * Initialisiert die LEDs
 */
void LED_init(){
	shift_init();
	LED_off(LED_ALL);
}
예제 #28
0
void LEDTask( void * Parameters )
{
    uint8_t cycle = 0;
    LED_activity_desc_t new_cfg;
    LED_state_rec_t* pLED;
    uint8_t led_id;
    /* Task will run every 50ms */
    TickType_t xFrequency = 100 / portTICK_PERIOD_MS;
    TickType_t xLastWakeTime;

    /* Initialise the xLastWakeTime variable with the current time. */
    xLastWakeTime = xTaskGetTickCount();

    for (;;) {
        for (led_id = 0; led_id < LED_CNT; led_id++) {
            pLED = &LEDstate[led_id];
            /* Update the led configuration only after perfoming a full cycle on each action */
            if (cycle == 0) {
                if (xQueueReceive( pLED->queue, &new_cfg, 0 ) == pdTRUE) {
                    /* Save the last config */
                    memcpy(&(pLED->last_cfg), &(pLED->cur_cfg), sizeof(LED_activity_desc_t));

                    /* Update the config struct */
                    memcpy(&(pLED->cur_cfg), &new_cfg, sizeof(LED_activity_desc_t));
                    LED_set_state(pLED->pin_cfg, pLED->cur_cfg.initstate);
                    pLED->counter = pLED->cur_cfg.delay_init;
                }
            }

            switch (pLED->cur_cfg.action) {
            case LED_ACTV_ON:
                LED_on(pLED->pin_cfg);
                break;

            case LED_ACTV_OFF:
                LED_off(pLED->pin_cfg);
                break;

            case LED_ACTV_BLINK:
                if (pLED->counter == 0) {
                    if (pLED->cur_cfg.initstate == LED_get_state(pLED->pin_cfg)) {
                        /* LED is in initial state */
                        pLED->counter = pLED->cur_cfg.delay_tog;
                    } else {
                        /* LED is in toggled state */
                        pLED->counter = pLED->cur_cfg.delay_init;
                    }

                    LED_toggle(pLED->pin_cfg);

                    if ( pLED->counter == 0 ) {
                        /* Loaded a zero prescale value--means the activity descriptor is a single-shot descriptor
                         * that has expired--like a lamp test or a pulse.
                         * Revert the LED to the last know state and stay in toggled state until next cycle
                         */
                        pLED->counter = cycle;
                        memcpy(&(pLED->cur_cfg), &(pLED->last_cfg), sizeof(LED_activity_desc_t));
                    }
                } else {
                    (pLED->counter)--;
                }
                break;
            }
        }
        if (cycle == 0) {
            /* Reload the cycle counter */
            cycle = LED_CYCLE_COUNTER;
        } else {
            cycle--;
        }
        vTaskDelayUntil( &xLastWakeTime, xFrequency );
    }

}
예제 #29
0
/* -----------------------------------------------------------------------------------------------------------*/
int LEDTAFEL_sendblock( char line ) 
{
	char data ;
	int i, block ;
	char * gfx_buffer, * lum_buffer;

	// Zeile setzen und SEL setzen
	DATA_PORT = line + 1;
	CONTROL_PORT |= CONTROL_SEL;

	LED_on(1);
	i = 0 ;
	// auf SYNC gleich HIGH warten oder in den Timeout laufen und abbrechen
	while( !( CONTROL_SYNC & CONTROL_SYNC_PIN ) )
	{
		i++;
		if ( i > TIMEOUTLOOP )
		{
			CONTROL_PORT &= ~CONTROL_SEL;
			LED_off(1);
			return( TAFELSENDERR );
		}
	}

	// SEL auf Low setzen
	CONTROL_PORT &= ~CONTROL_SEL;

	 i = 0;
	// auf SYNC gleich LOW warten oder in den Timeout laufen und abbrechen
	while( ( CONTROL_SYNC & CONTROL_SYNC_PIN ) )
	{
		i++;
		if ( i > TIMEOUTLOOP )
		{
			LED_off(1);
			return( TAFELSENDERR );
		}
	}

	gfx_buffer = &LEDTAFEL_screen_graphic[ line * LEDTAFEL_ROW * 8 ];
	block = LEDTAFEL_ROW;
		
	while( block )
	{
		data = *gfx_buffer;
		gfx_buffer++;
		CONTROL_PORT |= CONTROL_REQ;
		DATA_PORT = data;

		data = *gfx_buffer;
		gfx_buffer++;
		CONTROL_PORT &= ~CONTROL_REQ;
		DATA_PORT = data;

		data = *gfx_buffer;
		gfx_buffer++;
		CONTROL_PORT |= CONTROL_REQ;
		DATA_PORT = data;

		data = *gfx_buffer;
		gfx_buffer++;
		CONTROL_PORT &= ~CONTROL_REQ;
		DATA_PORT = data;

		data = *gfx_buffer;
		gfx_buffer++;
		CONTROL_PORT |= CONTROL_REQ;
		DATA_PORT = data;

		data = *gfx_buffer;
		gfx_buffer++;
		CONTROL_PORT &= ~CONTROL_REQ;
		DATA_PORT = data;

		data = *gfx_buffer;
		gfx_buffer++;
		CONTROL_PORT |= CONTROL_REQ;
		DATA_PORT = data;

		data = *gfx_buffer;
		gfx_buffer++;
		CONTROL_PORT &= ~CONTROL_REQ;
		DATA_PORT = data;

		block--;
	}

	lum_buffer = &LEDTAFEL_screenlum[ line * LEDTAFEL_ROW ];
	block = LEDTAFEL_ROW;

	while( block )
	{
		data = *lum_buffer;
		lum_buffer++;
		CONTROL_PORT |= CONTROL_REQ;
		DATA_PORT = data;

		data = *lum_buffer;
		lum_buffer++;
		CONTROL_PORT &= ~CONTROL_REQ;
		DATA_PORT = data;

		data = *lum_buffer;
		lum_buffer++;
		CONTROL_PORT |= CONTROL_REQ;
		DATA_PORT = data;

		data = *lum_buffer;
		lum_buffer++;
		CONTROL_PORT &= ~CONTROL_REQ;
		DATA_PORT = data;

		data = *lum_buffer;
		lum_buffer++;
		CONTROL_PORT |= CONTROL_REQ;
		DATA_PORT = data;

		data = *lum_buffer;
		lum_buffer++;
		CONTROL_PORT &= ~CONTROL_REQ;
		DATA_PORT = data;

		data = *lum_buffer;
		lum_buffer++;
		CONTROL_PORT |= CONTROL_REQ;
		DATA_PORT = data;

		data = *lum_buffer;
		lum_buffer++;
		CONTROL_PORT &= ~CONTROL_REQ;
		DATA_PORT = data;

		block--;
	}

	lum_buffer = &LEDTAFEL_screenlum[ line * LEDTAFEL_ROW ];
	block = LEDTAFEL_ROW;

	while( block )
	{
		data = *lum_buffer;
		lum_buffer++;
		CONTROL_PORT |= CONTROL_REQ;
		DATA_PORT = data;

		data = *lum_buffer;
		lum_buffer++;
		CONTROL_PORT &= ~CONTROL_REQ;
		DATA_PORT = data;

		data = *lum_buffer;
		lum_buffer++;
		CONTROL_PORT |= CONTROL_REQ;
		DATA_PORT = data;

		data = *lum_buffer;
		lum_buffer++;
		CONTROL_PORT &= ~CONTROL_REQ;
		DATA_PORT = data;

		data = *lum_buffer;
		lum_buffer++;
		CONTROL_PORT |= CONTROL_REQ;
		DATA_PORT = data;

		data = *lum_buffer;
		lum_buffer++;
		CONTROL_PORT &= ~CONTROL_REQ;
		DATA_PORT = data;

		data = *lum_buffer;
		lum_buffer++;
		CONTROL_PORT |= CONTROL_REQ;
		DATA_PORT = data;

		data = *lum_buffer;
		lum_buffer++;
		CONTROL_PORT &= ~CONTROL_REQ;
		DATA_PORT = data;

		block--;
	}

	LED_off(1);

	return( TAFELSENDOK );
}
예제 #30
0
파일: led.c 프로젝트: jdkaplan/ASTRO
void blink(unsigned int on, unsigned int off) {
  LED_on(on);
  LED_off(off);
}