From: Dean Camera Date: Mon, 25 Jan 2010 13:02:25 +0000 (+0000) Subject: Move TWI.c driver into the straight LUFA/Drivers/Peripheral/ directory. X-Git-Tag: LUFA-110528-BETA~660 X-Git-Url: http://git.linex4red.de/pub/USBasp.git/commitdiff_plain/4bd44139b1d120e73c6b8863578b0ef6996f7368?ds=inline Move TWI.c driver into the straight LUFA/Drivers/Peripheral/ directory. Fix TemperatureDataLogger and Webserver project builds. --- diff --git a/LUFA.pnproj b/LUFA.pnproj index 88eb57175..870cf4cf0 100644 --- a/LUFA.pnproj +++ b/LUFA.pnproj @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/LUFA/Drivers/Peripheral/AVRU4U6U7/TWI.c b/LUFA/Drivers/Peripheral/AVRU4U6U7/TWI.c deleted file mode 100644 index dda88f8ba..000000000 --- a/LUFA/Drivers/Peripheral/AVRU4U6U7/TWI.c +++ /dev/null @@ -1,54 +0,0 @@ -/* - Copyright (C) Dean Camera, 2010. - - dean [at] fourwalledcubicle [dot] com - www.fourwalledcubicle.com -*/ - -#include "../TWI.h" - -bool TWI_StartTransmission(uint8_t SlaveAddress) -{ - for (;;) - { - uint8_t IterationsRemaining = 50; - bool BusCaptured = false; - - while (IterationsRemaining-- && !BusCaptured) - { - TWCR = ((1 << TWINT) | (1 << TWSTA) | (1 << TWEN)); - while (!(TWCR & (1 << TWINT))); - - switch (TWSR & TW_STATUS_MASK) - { - case TW_START: - case TW_REP_START: - BusCaptured = true; - break; - case TW_MT_ARB_LOST: - continue; - default: - return false; - } - } - - if (!(BusCaptured)) - return false; - - TWDR = SlaveAddress; - TWCR = ((1 << TWINT) | (1 << TWEN)); - while (!(TWCR & (1 << TWINT))); - - GPIOR0 = (TWSR & TW_STATUS_MASK); - - switch (TWSR & TW_STATUS_MASK) - { - case TW_MT_SLA_ACK: - case TW_MR_SLA_ACK: - return true; - default: - TWI_StopTransmission(); - break; - } - } -} diff --git a/LUFA/Drivers/Peripheral/TWI.c b/LUFA/Drivers/Peripheral/TWI.c new file mode 100644 index 000000000..6028bbae9 --- /dev/null +++ b/LUFA/Drivers/Peripheral/TWI.c @@ -0,0 +1,54 @@ +/* + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.fourwalledcubicle.com +*/ + +#include "TWI.h" + +bool TWI_StartTransmission(uint8_t SlaveAddress) +{ + for (;;) + { + uint8_t IterationsRemaining = 50; + bool BusCaptured = false; + + while (IterationsRemaining-- && !BusCaptured) + { + TWCR = ((1 << TWINT) | (1 << TWSTA) | (1 << TWEN)); + while (!(TWCR & (1 << TWINT))); + + switch (TWSR & TW_STATUS_MASK) + { + case TW_START: + case TW_REP_START: + BusCaptured = true; + break; + case TW_MT_ARB_LOST: + continue; + default: + return false; + } + } + + if (!(BusCaptured)) + return false; + + TWDR = SlaveAddress; + TWCR = ((1 << TWINT) | (1 << TWEN)); + while (!(TWCR & (1 << TWINT))); + + GPIOR0 = (TWSR & TW_STATUS_MASK); + + switch (TWSR & TW_STATUS_MASK) + { + case TW_MT_SLA_ACK: + case TW_MR_SLA_ACK: + return true; + default: + TWI_StopTransmission(); + break; + } + } +} diff --git a/LUFA/Drivers/Peripheral/TWI.h b/LUFA/Drivers/Peripheral/TWI.h index 2a97e1899..7432a1691 100644 --- a/LUFA/Drivers/Peripheral/TWI.h +++ b/LUFA/Drivers/Peripheral/TWI.h @@ -41,7 +41,7 @@ * * \section Sec_Dependencies Module Source Dependencies * The following files must be built with any user project that uses this module: - * - LUFA/Drivers/Peripheral/AVRU4U6U7/TWI.c (for U4, U6 and U7 AVR models) + * - LUFA/Drivers/Peripheral/TWI.c * * \section Module Description * Master Mode Hardware TWI driver. This module provides an easy to use driver for the hardware diff --git a/Projects/TemperatureDataLogger/makefile b/Projects/TemperatureDataLogger/makefile index ab29bb1be..990156f26 100644 --- a/Projects/TemperatureDataLogger/makefile +++ b/Projects/TemperatureDataLogger/makefile @@ -132,6 +132,7 @@ SRC = $(TARGET).c \ Lib/FATFs/ff.c \ Lib/DS1307.c \ $(LUFA_PATH)/LUFA/Drivers/Board/Temperature.c \ + $(LUFA_PATH)/LUFA/Drivers/Peripheral/TWI.c \ $(LUFA_PATH)/LUFA/Drivers/USB/LowLevel/DevChapter9.c \ $(LUFA_PATH)/LUFA/Drivers/USB/LowLevel/Endpoint.c \ $(LUFA_PATH)/LUFA/Drivers/USB/LowLevel/Host.c \ diff --git a/Projects/Webserver/Webserver.c b/Projects/Webserver/Webserver.c index 15eb73358..d1764ee84 100644 --- a/Projects/Webserver/Webserver.c +++ b/Projects/Webserver/Webserver.c @@ -245,9 +245,9 @@ void SetupHardware(void) /* uIP Stack Initialization */ uip_init(); uip_ipaddr_t IPAddress, Netmask, GatewayIPAddress; - uip_ipaddr(&IPAddress, DEVICE_IP_ADDRESS); - uip_ipaddr(&Netmask, DEVICE_NETMASK); - uip_ipaddr(&GatewayIPAddress, ); + uip_ipaddr(&IPAddress, DEVICE_IP_ADDRESS[0], DEVICE_IP_ADDRESS[1], DEVICE_IP_ADDRESS[2], DEVICE_IP_ADDRESS[3]); + uip_ipaddr(&Netmask, DEVICE_NETMASK[0], DEVICE_NETMASK[1], DEVICE_NETMASK[2], DEVICE_NETMASK[3]); + uip_ipaddr(&GatewayIPAddress, DEVICE_GATEWAY[0], DEVICE_GATEWAY[1], DEVICE_GATEWAY[2], DEVICE_GATEWAY[3]); uip_sethostaddr(&IPAddress); uip_setnetmask(&Netmask); uip_setdraddr(&GatewayIPAddress); diff --git a/Projects/Webserver/Webserver.h b/Projects/Webserver/Webserver.h index f3aa8d7b8..8d23bc1d5 100644 --- a/Projects/Webserver/Webserver.h +++ b/Projects/Webserver/Webserver.h @@ -56,13 +56,13 @@ /* Macros: */ /** IP address that the webserver should use once connected to a RNDIS device. */ - #define DEVICE_IP_ADDRESS 192, 168, 1, 10 + #define DEVICE_IP_ADDRESS (uint8_t[]){192, 168, 1, 10} /** Netmask that the webserver should once connected to a RNDIS device. */ - #define DEVICE_NETMASK 255, 255, 255, 0 + #define DEVICE_NETMASK (uint8_t[]){255, 255, 255, 0} /** IP address of the default gateway the webserver should use when routing outside the local subnet. */ - #define DEVICE_GATEWAY 192, 168, 1, 1 + #define DEVICE_GATEWAY (uint8_t[]){192, 168, 1, 1} /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ #define LEDMASK_USB_NOTREADY LEDS_LED1 diff --git a/Projects/Webserver/makefile b/Projects/Webserver/makefile index d3b3667c7..27a7850aa 100644 --- a/Projects/Webserver/makefile +++ b/Projects/Webserver/makefile @@ -112,7 +112,7 @@ OBJDIR = . # Path to the LUFA library -LUFA_PATH = ../../../ +LUFA_PATH = ../../ # LUFA library compile-time options