Project

General

Profile

Revision 437

Added by Kevin Woo about 16 years ago

Cleaned up analog.c code. Recompiled library. Mostly commenting and
documentation fixes. No changes made to actual code.

View differences:

dio.c
72 72
 *
73 73
 * @return 1 or 0, depending on the value of the portpin.
74 74
 **/
75
int digital_input(int portpin){
75
int digital_input(int portpin) {
76 76
  int pin = portpin & 0x7;
77 77
  int pin_val = 0;
78 78
  
79
  switch(portpin >> 3){
79
  switch(portpin >> 3) {
80 80
  case _PORT_A:
81 81
    DDRA &= ~_BV(pin);
82 82
    pin_val = PINA;
......
98 98
    pin_val = PINE;
99 99
    return (pin_val >> pin) & 1;
100 100
  case _PORT_F:
101
    if(pin>=4){
101
    if(pin>=4) {
102 102
      MCUSR|=1<<7;
103 103
      MCUSR|=1<<7;
104 104
    }
......
194 194
      PORTG &= (0XFF - _BV(pins));
195 195
      break;
196 196
    }
197
  }else { /* ( val == 1) */ 
197
  } else { /* ( val == 1) */ 
198 198
    switch(portpin >> 3) {
199 199
    case _PORT_A:
200 200
      DDRA |= _BV(pins);
......
235 235
 *
236 236
 * @see button1_wait, button1_click
237 237
 **/
238
int button1_read( void )
239
{
240
	int pin_val;
241
	DDRG &= ~_BV(PING0);
242
	PORTG|= _BV(PING0);
243
    pin_val = PING;
244
	return !((pin_val & _BV(PING0)));
245
  
238
int button1_read( void ) {
239
  int pin_val;
240
  DDRG &= ~_BV(PING0);
241
  PORTG|= _BV(PING0);
242
  pin_val = PING;
243
  return !((pin_val & _BV(PING0)));
246 244
}
247 245

  
248 246
/**
......
250 248
 *
251 249
 * @see button1_read, button1_click
252 250
 **/
253
void button1_wait( void )
254
{
251
void button1_wait( void ) {
255 252
  while(!button1_read() ) {
256 253
    delay_ms(15);
257 254
  }
......
265 262
 *
266 263
 * @see button1_read, button1_wait
267 264
 **/
268
int button1_click()
269
{
270
  if(button1_read()){
265
int button1_click() {
266
  if(button1_read()) {
271 267
    while(button1_read());
272 268
    return 1;
273
  }else{
269
  } else {
274 270
    return 0;
275 271
  }
276 272
}
......
282 278
 *
283 279
 * @see button2_wait, button2_click
284 280
 **/
285
int button2_read( void )
286
{
287
	int pin_val;
288
	DDRG &= ~_BV(PING1);
289
	PORTG|= _BV(PING1);
290
    pin_val = PING;
291
	return !((pin_val & _BV(PING1)));
281
int button2_read( void ) {
282
  int pin_val;
283
  DDRG &= ~_BV(PING1);
284
  PORTG|= _BV(PING1);
285
  pin_val = PING;
286
  return !((pin_val & _BV(PING1)));
292 287
}
293 288

  
294 289
/**
......
296 291
 *
297 292
 * @see button2_read, button2_click
298 293
 **/
299
void button2_wait( void )
300
{
294
void button2_wait( void ) {
301 295
  while(!button2_read()){
302 296
    delay_ms(15);
303 297
  }
......
311 305
 *
312 306
 * @see button2_read, button2_wait
313 307
 **/
314
int button2_click()
315
{
316
	if(button2_read()){
308
int button2_click() {
309
  if(button2_read()) {
317 310
    while(button2_read());
318 311
    return 1;
319
  }else{
320
		return 0;
312
  } else {
313
    return 0;
321 314
  }
322 315
}
323 316

  

Also available in: Unified diff