Rev 1683 | Rev 1744 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1683 | Rev 1743 | ||
---|---|---|---|
Line 91... | Line 91... | ||
91 | 91 | ||
92 | /**************************************************/ |
92 | /**************************************************/ |
93 | /* Initialize I2C (TWI) */ |
93 | /* Initialize I2C (TWI) */ |
Line 94... | Line 94... | ||
94 | /**************************************************/ |
94 | /**************************************************/ |
95 | 95 | ||
96 | void I2C_Init(void) |
96 | void I2C_Init(char clear) |
97 | { |
97 | { |
98 | uint8_t i; |
98 | uint8_t i; |
Line 115... | Line 115... | ||
115 | 115 | ||
116 | twi_state = TWI_STATE_MOTOR_TX; |
116 | twi_state = TWI_STATE_MOTOR_TX; |
117 | motor_write = 0; |
117 | motor_write = 0; |
Line 118... | Line 118... | ||
118 | motor_read = 0; |
118 | motor_read = 0; |
119 | 119 | ||
120 | for(i=0; i < MAX_MOTORS; i++) |
120 | if(clear) for(i=0; i < MAX_MOTORS; i++) |
121 | { |
121 | { |
122 | Motor[i].Version = 0; |
122 | Motor[i].Version = 0; |
123 | Motor[i].SetPoint = 0; |
123 | Motor[i].SetPoint = 0; |
124 | Motor[i].SetPointLowerBits = 0; |
124 | Motor[i].SetPointLowerBits = 0; |
125 | Motor[i].State = 0; |
125 | Motor[i].State = 0; |
126 | Motor[i].ReadMode = BL_READMODE_STATUS; |
126 | Motor[i].ReadMode = BL_READMODE_STATUS; |
127 | Motor[i].Current = 0; |
127 | Motor[i].Current = 0; |
128 | Motor[i].MaxPWM = 0; |
128 | Motor[i].MaxPWM = 0; |
129 | Motor[i].Temperature = 0; |
129 | Motor[i].Temperature = 0; |
130 | } |
130 | } |
131 | 131 | sei(); |
|
Line 132... | Line 132... | ||
132 | SREG = sreg; |
132 | SREG = sreg; |
133 | } |
133 | } |
Line 142... | Line 142... | ||
142 | TWAMR = 0; |
142 | TWAMR = 0; |
143 | TWAR = 0; |
143 | TWAR = 0; |
144 | TWDR = 0; |
144 | TWDR = 0; |
145 | TWSR = 0; |
145 | TWSR = 0; |
146 | TWBR = 0; |
146 | TWBR = 0; |
147 | I2C_Init(); |
147 | I2C_Init(0); |
148 | I2C_WriteByte(0); |
148 | I2C_WriteByte(0); |
149 | BLFlags |= BLFLAG_READ_VERSION; |
149 | BLFlags |= BLFLAG_READ_VERSION; |
150 | } |
150 | } |
Line 151... | Line 151... | ||
151 | 151 |