Mercurial > ~darius > hgwebdir.cgi > tempctrl
diff usb.c @ 41:5898fba6593c
Add temperature control.
- Split out console stuff to cons.[ch]. Set up stdio so we can use printf etc.
- Use \r\n as the line terminator consistently.
- Add OWGetTemp to get temperatures from a device.
- Load/save settings in EEPROM, defaults loaded from flash.
Nearly feature complete except you can't edit ROM IDs without a programming tool :)
(To be fixed)
Needs more testing.
author | darius@inchoate.localdomain |
---|---|
date | Sun, 06 Jul 2008 22:19:53 +0930 |
parents | fed32b382de2 |
children |
line wrap: on
line diff
--- a/usb.c Thu Nov 22 16:02:40 2007 +0000 +++ b/usb.c Sun Jul 06 22:19:53 2008 +0930 @@ -285,7 +285,7 @@ uart_putsP(PSTR("PDIUSBD12 does not appear to be present/working, chip ID = 0x")); uart_puts_hex(buffer[0]); uart_puts_hex(buffer[1]); - uart_putsP(PSTR(", expected 0x1210\n\r")); + uart_putsP(PSTR(", expected 0x1210\r\n")); return; } @@ -333,16 +333,16 @@ if (irq[0] == 0) return; - uart_putsP(PSTR("usb_intr() called\n\r")); + uart_putsP(PSTR("usb_intr() called\r\n")); if (irq[0] & D12_INT_BUS_RESET) { - uart_putsP(PSTR("Bus reset\n\r")); + uart_putsP(PSTR("Bus reset\r\n")); usb_init(); return; } if (irq[0] & D12_INT_SUSPEND) { - uart_putsP(PSTR("Suspend change\n\r")); + uart_putsP(PSTR("Suspend change\r\n")); } if (irq[0] & D12_INT_EP0_IN) { @@ -350,7 +350,7 @@ if ((buffer[0] & D12_LAST_TRAN_ERRMSK) != 0) { uart_putsP(PSTR("EP0_IN error ")); uart_puts_hex((buffer[0] & D12_LAST_TRAN_ERRMSK) >> 1); - uart_putsP(PSTR("\n\r")); + uart_putsP(PSTR("\r\n")); } /* Handle any outgoing data for EP0 */ @@ -363,7 +363,7 @@ if ((buffer[0] & D12_LAST_TRAN_ERRMSK) != 0) { uart_putsP(PSTR("EP0_OUT error ")); uart_puts_hex((buffer[0] & D12_LAST_TRAN_ERRMSK) >> 1); - uart_putsP(PSTR("\n\r")); + uart_putsP(PSTR("\r\n")); } if (buffer[0] & D12_LAST_TRAN_SETUP) @@ -379,17 +379,17 @@ if ((buffer[0] & D12_LAST_TRAN_ERRMSK) != 0) { uart_putsP(PSTR("EP1_IN error ")); uart_puts_hex((buffer[0] & D12_LAST_TRAN_ERRMSK) >> 1); - uart_putsP(PSTR("\n\r")); + uart_putsP(PSTR("\r\n")); } /* Select endpoint */ d12_read_cmd(D12_ENDPOINT_EP1_IN, buffer, 1); if (buffer[0] & 0x01) - uart_putsP(PSTR("EP1_IN is full\n\r")); + uart_putsP(PSTR("EP1_IN is full\r\n")); if (buffer[0] & 0x02) - uart_putsP(PSTR("EP1_IN is stalled\n\r")); + uart_putsP(PSTR("EP1_IN is stalled\r\n")); d12_write_endpt(D12_ENDPOINT_EP1_IN, NULL, 0); } @@ -400,7 +400,7 @@ if ((buffer[0] & D12_LAST_TRAN_ERRMSK) != 0) { uart_putsP(PSTR("EP1_OUT error ")); uart_puts_hex((buffer[0] & D12_LAST_TRAN_ERRMSK) >> 1); - uart_putsP(PSTR("\n\r")); + uart_putsP(PSTR("\r\n")); } d12_receive_data_ep1(); @@ -411,7 +411,7 @@ if ((buffer[0] & D12_LAST_TRAN_ERRMSK) != 0) { uart_putsP(PSTR("EP2_IN error ")); uart_puts_hex((buffer[0] & D12_LAST_TRAN_ERRMSK) >> 1); - uart_putsP(PSTR("\n\r")); + uart_putsP(PSTR("\r\n")); } d12_send_data_ep2(); @@ -422,7 +422,7 @@ if ((buffer[0] & D12_LAST_TRAN_ERRMSK) != 0) { uart_putsP(PSTR("EP2_OUT error ")); uart_puts_hex((buffer[0] & D12_LAST_TRAN_ERRMSK) >> 1); - uart_putsP(PSTR("\n\r")); + uart_putsP(PSTR("\r\n")); } d12_receive_data_ep2(); } @@ -705,7 +705,7 @@ */ void reset(void) { - uart_putsP(PSTR("Resetting!\n\r")); + uart_putsP(PSTR("Resetting!\r\n")); _delay_us(1000); /* Disable the interrupts */ @@ -848,7 +848,7 @@ if ((status & 0x01) != 0) { uart_putsP(PSTR("Endpoint ")); uart_puts_dec(endpt / 2, 0); - uart_putsP(PSTR(" IN is full..\n\r")); + uart_putsP(PSTR(" IN is full..\r\n")); return; } @@ -964,7 +964,7 @@ uart_putsP(PSTR("Got ")); uart_puts_dec(bytes, 0); - uart_putsP(PSTR(" bytes from the host\n\r")); + uart_putsP(PSTR(" bytes from the host\r\n")); parsebuf(packet2, D12_ENDPOINT_EP2_IN); @@ -1002,7 +1002,7 @@ uart_putsP(PSTR("Got ")); uart_puts_dec(bytes, 0); - uart_putsP(PSTR(" bytes from the host\n\r")); + uart_putsP(PSTR(" bytes from the host\r\n")); /* Allow new packets to be accepted */ d12_write_cmd(D12_CLEAR_BUFFER, NULL, 0); @@ -1016,24 +1016,24 @@ switch (buffer[0]) { case 0x00: - uart_putsP(PSTR("OWTouchReset()\n\r")); + uart_putsP(PSTR("OWTouchReset()\r\n")); buffer[0] = OWTouchReset(); d12_write_endpt(ep, buffer, 1); break; case 0x01: - uart_putsP(PSTR("OWFirst()\n\r")); + uart_putsP(PSTR("OWFirst()\r\n")); buffer[0] = OWFirst(&buffer[1], 1, 0); for (i = 0; i < 9; i++) { uart_puts_hex(buffer[i + 1]); uart_putsP(PSTR(" ")); } - uart_putsP(PSTR("\n\r")); + uart_putsP(PSTR("\r\n")); d12_write_endpt(ep, buffer, 9); break; case 0x02: - uart_putsP(PSTR("OWNext()\n\r")); + uart_putsP(PSTR("OWNext()\r\n")); buffer[0] = OWNext(&buffer[1], 1, 0); d12_write_endpt(ep, buffer, 9); break; @@ -1046,13 +1046,13 @@ uart_putsP(PSTR(":")); } - uart_putsP(PSTR("\n\r")); + uart_putsP(PSTR("\r\n")); d12_write_endpt(ep, buffer, 9); break; default: - uart_putsP(PSTR("Unknown command on endpoint 1\n\r")); + uart_putsP(PSTR("Unknown command on endpoint 1\r\n")); break; } }