forked from pavius/rotary-encoder-timer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsys.c
78 lines (63 loc) · 2.21 KB
/
sys.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/**************************************************************************
*
* FILE NAME: system.h
* FILE DESCRIPTION: DLS specific system definitions
*
* FILE CREATION DATE: 24-05-2004
*
*==========================================================================
* Copyright (c) 2004 NIR Diagnostics Inc., Ontario, Canada
*
* This document contains confidential information which is protected by
* copyright and is proprietary to NIR Diagnostics Inc., Ontario, Canada. No part
* of this document may be used, copied, disclosed, or conveyed to another
* party without prior written consent of NIR Diagnostics Inc., Ontario, Canada.
***************************************************************************
*
* Modification history:
* --------------------
* 01a,24may03 erd written
*
***************************************************************************/
#include "sys_prv.h"
// ==========================================================================
// sys_init
//
// Initializes all I/O pinouts
//
BOOL sys_init()
{
// disable interrupts
sys_bitClear(GIE);
// disable A2D and comparators
ADCON1 = 0b0001111;
CMCON = 0;
//
// Set GPIO port directions
//
sys_setIoDirection(IO_LED_TMR0, IO_PIN_OUTPUT);
sys_setIoDirection(IO_LED_TMR1, IO_PIN_OUTPUT);
sys_setIoDirection(IO_LED_TMR2, IO_PIN_OUTPUT);
sys_setIoDirection(IO_ROTENC_CH0, IO_PIN_INPUT);
sys_setIoDirection(IO_ROTENC_CH1, IO_PIN_INPUT);
sys_setIoDirection(IO_BUTTON, IO_PIN_INPUT);
sys_setIoDirection(IO_BUZZER, IO_PIN_OUTPUT);
//
// Initialize port values
//
sys_bitClear(IO_LED_TMR0);
sys_bitClear(IO_LED_TMR1);
sys_bitClear(IO_LED_TMR2);
sys_bitClear(IO_BUZZER);
// zero out seven segment ports
IO_SSEG_SELECT = 0;
IO_SSEG_DISPLAY = 0xFF;
// set port values
IO_SSEG_SELECT_DIR = 0x0; // output
IO_SSEG_DISPLAY_DIR = 0x0; // output
// enable interrupts
sys_bitSet(GIE);
sys_bitSet(PEIE);
// success
return TRUE;
}