Пример #1
0
/*
 Name:
 LED_Matrix_Init
 Input:
 nothing
 Output:
 nothing
 Description:
 Initialize the matrix pins and latch.
 Initialize watchdog timer as timer interval.
 */
void LEDmatrix::Init(void) {
	// configure SPI pins and latch
	P1DIR |= DATA_LATCH_PIN | SPI_DATA_OUT_PIN | SPI_CLK_OUT_PIN;

	// set latch pin to inactive
	P1OUT &= ~DATA_LATCH_PIN;

	// using WatchDog Timer as interval timer for Matrix refresh interrupts
	WDTCTL = WDT_MDLY_0_5;    // Set Watchdog Timer interval to 0.5ms
	IE1 |= WDTIE;             // Enable WDT interrupt

	USI_Init();
	return;
}
Пример #2
0
// user input finitestate machine
void USI_fsm(uint8_t button)
{
    switch(button){
        case LEFT:
            deleteStr();
            USI_Init();
            break;
        case UP:
            deleteStr();
            usi_previous();
            break;
        case RIGHT:
            deleteStr();
            if(userTextIndex == (sizeof(LOCK)-2)) // real array elements (\0)
            {
                /* Device Unlocked */
                //if(strcmp_P(userText+sizeof(PIN_str)-1, LOCK) == 0)
                if(USI_pinCheck(userText+sizeof(PIN_str)-1) == 1)
            	{
                    CRD_fsmStart();
                    UCP_Unlock();
                }
                /* Device Locked */
                else
                {
                    printStr((void*)LOCKED_str,FLASH);
                    userTextIndex = 0;
                    UIF_userInputIndex = 0;
                    memcpy_P((void*)userText, (void*)PIN_str, sizeof(PIN_str));
                    userText[sizeof(PIN_str)-1+userTextIndex] = pgm_read_byte(&USI_keys[UIF_userInputIndex]);
                    userText[sizeof(PIN_str)-1+userTextIndex+1] = 0;
                }
            }
            else
            {
                userTextIndex++;
                usi_print();
            }
            break;
        case DOWN:
            deleteStr();
            usi_next();
            break;
        default:
            break;
        }
}
Пример #3
0
void UIF_Task(void){
    if((UIB_buttonChanged == 1u) && (UIB_buttonPressed != NOT_PRESSED))
    {
        switch(UIF_state)
        {
        case START:
            UIF_state = USER_INPUT;
            deleteStr();
            USI_Init();
            break;
        case OPTIONS:
            OPT_fsm(UIB_buttonPressed);
            break;
        case USER_INPUT:
            USI_fsm(UIB_buttonPressed);
            break;
        default:         //CREDENTIALS
            CRD_fsm(UIB_buttonPressed);
            break;
        }
    }

    return;
}