Subversion Repositories Code-Repo

Rev

Rev 201 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 201 Rev 212
Line 17... Line 17...
17
    BTN3_TRIS = 1;
17
    BTN3_TRIS = 1;
18
 
18
 
19
    INTDisableInterrupts();
19
    INTDisableInterrupts();
20
    
20
    
21
    CNCONSET = 0x8000;  // Turn on change notice interrupt
21
    CNCONSET = 0x8000;  // Turn on change notice interrupt
-
 
22
#if defined CEREBOT_32MX7
22
    CNENSET = 0x80300;  // Set interrupt on CN8/9/19
23
    CNENSET = 0x80300;  // Set interrupt on CN8/9/19
-
 
24
#elif defined CEREBOT_MX7CK
-
 
25
    CNENSET = 0x00300;  // Set interrupt on CN8/9
-
 
26
#endif
23
    int tmp = BTN1_PORT;
27
    int tmp = BTN1_PORT;
24
    tmp = BTN2_PORT;
28
    tmp = BTN2_PORT;
25
    tmp = BTN3_PORT;
29
    tmp = BTN3_PORT;
26
    IPC6SET = 0x50000;  // Set priority level = 1, sub-priority level = 1
30
    IPC6SET = 0xD0000;  // Set priority level = 3, sub-priority level = 1
27
    IFS1CLR = 0x1;      // Clear interrupt flag
31
    IFS1CLR = 0x1;      // Clear interrupt flag
28
    IEC1SET = 0x1;      // Enable interrupt
32
    IEC1SET = 0x1;      // Enable interrupt
29
 
33
 
30
    INTEnableInterrupts();
34
    INTEnableInterrupts();
31
}
35
}
32
 
36
 
33
void __ISR(_CHANGE_NOTICE_VECTOR, ipl1) __CN_Interrupt_Handler(void) {
37
void __ISR(_CHANGE_NOTICE_VECTOR, ipl3) __CN_Interrupt_Handler(void) {
34
    // Upon interrupt, debounce input and call saved function
38
    // Upon interrupt, debounce input and call saved function
35
    if (BTN1_PORT == 1) {
39
    if (BTN1_PORT == 1) {
36
        Delay_MS(BTN_DEBOUNCE_MS);
40
        Delay_MS(BTN_DEBOUNCE_MS);
37
        if (BTN1_PORT == 1) {
41
        if (BTN1_PORT == 1) {
38
            if (btn_data_ptr->callback_function_1 != NULL)
42
            if (btn_data_ptr->callback_function_1 != NULL)
Line 44... Line 48...
44
        if (BTN2_PORT == 1) {
48
        if (BTN2_PORT == 1) {
45
            if (btn_data_ptr->callback_function_2 != NULL)
49
            if (btn_data_ptr->callback_function_2 != NULL)
46
                (*btn_data_ptr->callback_function_2)();
50
                (*btn_data_ptr->callback_function_2)();
47
        }
51
        }
48
    }
52
    }
-
 
53
#ifdef CEREBOT_32MX7
49
    if (BTN3_PORT == 1) {
54
    if (BTN3_PORT == 1) {
50
        Delay_MS(BTN_DEBOUNCE_MS);
55
        Delay_MS(BTN_DEBOUNCE_MS);
51
        if (BTN3_PORT == 1) {
56
        if (BTN3_PORT == 1) {
52
            if (btn_data_ptr->callback_function_3 != NULL)
57
            if (btn_data_ptr->callback_function_3 != NULL)
53
                (*btn_data_ptr->callback_function_3)();
58
                (*btn_data_ptr->callback_function_3)();
54
        }
59
        }
55
    }
60
    }
-
 
61
#endif
56
    IFS1CLR = 0x1; // Clear interrupt flag
62
    IFS1CLR = 0x1; // Clear interrupt flag
57
}
63
}
58
64