MODBUS laajempi esimerkki
hw.h
Go to the documentation of this file.
1 
11 /* HW related parameters */
12 
13 #ifndef F_CPU
14 #define F_CPU 8000000
15 #endif
16 
17 /****************** Configurable parameters **********************/
18 
19 
21 #define INDICATION_PORT_DDR DDRB
22 #define INDICATION_PORT PORTB
23 #define ISF_LED 0
24 #define COM_ERR_LED 1
25 #define RESET_LED 3
26 #define RS_LED 2
27 
28 /* button definitions */
29 #define CONFIGURATION_PORT_DDR DDRC
30 #define CONFIGURATION_PORT PORTC
31 #define DEBUG_BUTTON 0x04
32 #define CLEAR_BUTTON 0x04 /* Possible to use the same */
33 
34 /* ModBus address definitions */
35 #define ADDRESS_SELECT_PORT_DDR DDRC
36 #define ADDRESS_SELECT_PORT PINC
37 #define ADDRESS_SELECT_PIN 4
38 #define ADDRESS_SELECT_BIT_MASK 0x0F
40 /* Sensor definitions */
41 #define NRO_OF_SENSORS 4
42 #define SENSOR_PORT_DDR DDRA
43 #define SENSOR_PORT PORTA
44 #define SENSOR_PORT_IN PINA
45 #define SENSOR1 0x01
46 #define SENSOR2 0x02
47 #define SENSOR3 0x03
48 #define SENSOR4 0x04
49 #define SENSOR_CLK 0x00 /* Changed on 21.1.2010 (Previous value 0x06) */
50 
51 
52 /************************** MACROS *******************************/
53 
54 #define RESET_LED_ON INDICATION_PORT |= (1 << RESET_LED)
55 #define RESET_LED_OFF INDICATION_PORT &= ~(1 << RESET_LED)
56 
57 #define ISF_OFF INDICATION_PORT |= (1<<ISF_LED)
58 #define ISF_ON INDICATION_PORT &= ~(1<<ISF_LED)
59 
60 #define ENABLE_SENSOR_MEASUREMENT TIMSK |= (1<<TOIE0)
61 #define DISENABLE_SENSOR_MEASUREMENT TIMSK &= ~(1<<TOIE0)
62 
63 #define IF_CLEAR_BUTTON_IS_ON (CONFIGURATION_PORT | (1<<CLEAR_BUTTON))==CLEAR_BUTTON
64 #define IF_DEBUG_BUTTON_IS_ON (CONFIGURATION_PORT | (1<<DEBUG_BUTTON))==DEBUG_BUTTON
65 
66 #define RS_LED_OFF INDICATION_PORT |= (1 << RS_LED)
67 #define RS_LED_ON INDICATION_PORT &= ~(1 << RS_LED)
68 
69 
70 /************************** Prototypes *******************************/
71 
72 void port_init ( void );
73 void Timer0_init ( void );
void port_init(void)
Initializes all needed ports.
Definition: hw.c:48
void Timer0_init(void)
Initializes Timer/Counter overflow Interrupt.
Definition: hw.c:35