diff --git a/Quantum Controller/SW/testapplication-0.0.1/.configured b/Quantum Controller/SW/testapplication-0.0.1/.configured new file mode 100644 index 0000000..e69de29 diff --git a/Quantum Controller/SW/testapplication-0.0.1/.unpacked b/Quantum Controller/SW/testapplication-0.0.1/.unpacked new file mode 100644 index 0000000..e69de29 diff --git a/Quantum Controller/SW/testapplication-0.0.1/AUTHORS b/Quantum Controller/SW/testapplication-0.0.1/AUTHORS new file mode 100644 index 0000000..e69de29 diff --git a/Quantum Controller/SW/testapplication-0.0.1/BUS_test.c b/Quantum Controller/SW/testapplication-0.0.1/BUS_test.c new file mode 100644 index 0000000..a13f0c5 --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/BUS_test.c @@ -0,0 +1 @@ +/* --------------------------------------------------------------------------- * BUS_test.c (c) 2008 Micro-key bv * --------------------------------------------------------------------------- * Micro-key bv * Industrieweg 28, 9804 TG Noordhorn * Postbus 92, 9800 AB Zuidhorn * The Netherlands * Tel: +31 594 503020 * Fax: +31 594 505825 * Email: support@microkey.nl * Web: www.microkey.nl * --------------------------------------------------------------------------- * Description: Test file for the bus system * --------------------------------------------------------------------------- * Version(s): 0.1, Dez 11, 2008, MMi * Creation. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * System include files * --------------------------------------------------------------------------- */ #include /* --------------------------------------------------------------------------- * Application include files * --------------------------------------------------------------------------- */ #include "BUS_test.h" /* --------------------------------------------------------------------------- * Local constant and macro definitions * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Global variable definitions * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Local variable definitions * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Local function definitions * --------------------------------------------------------------------------- */ void bus_test_execute (void) { printf ("THIS IS THE BUS TEST SEQUENCE"); } \ No newline at end of file diff --git a/Quantum Controller/SW/testapplication-0.0.1/BUS_test.h b/Quantum Controller/SW/testapplication-0.0.1/BUS_test.h new file mode 100644 index 0000000..fa6bdd0 --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/BUS_test.h @@ -0,0 +1 @@ +/* --------------------------------------------------------------------------- * BUS_test.h (c) 2008 Micro-key bv * --------------------------------------------------------------------------- * Micro-key bv * Industrieweg 28, 9804 TG Noordhorn * Postbus 92, 9800 AB Zuidhorn * The Netherlands * Tel: +31 594 503020 * Fax: +31 594 505825 * Email: support@microkey.nl * Web: www.microkey.nl * --------------------------------------------------------------------------- * Description: * --------------------------------------------------------------------------- * Version(s): 0.1, Dez 11, 2008, MMi * Creation. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * System include files. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Application include files. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Constant and macro definitions. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Type definitions. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Variable declarations. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Function declarations. * --------------------------------------------------------------------------- */ void bus_test_execute (void); \ No newline at end of file diff --git a/Quantum Controller/SW/testapplication-0.0.1/BpMessageFormat.c b/Quantum Controller/SW/testapplication-0.0.1/BpMessageFormat.c new file mode 100644 index 0000000..4d27f62 --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/BpMessageFormat.c @@ -0,0 +1,131 @@ +/* --------------------------------------------------------------------------- + * BpMessageFormat.c - v0.1 (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Jan 29, 2008, FSc + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "BpMessageFormat.h" +#include "Crc.h" + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ + + +/** \brief Calculates the CRC over payload etc... and sets unique start byte + * + * \param msg Message over which the CRC should be calculated + */ +void bpmsgEncodeMessage( t_bpmsg_message * msg ) +{ + UINT16 crc; + + crc = crcCalc( &msg->payloadSize, 1, 0); + crc = crcCalc( msg->payload, msg->payloadSize, crc); + + msg->crc = crc; +} + + +void bpmsgAdd16bit(UINT8 *payloadlocation, UINT16 data) +{ + UINT8 index = 0; + + payloadlocation[index] = (UINT8)(data >> 8); + index++; + payloadlocation[index] = (UINT8)(data & 0x00FF); +} + + +void bpmsgAdd32bit(UINT8 *payloadlocation, UINT32 data) +{ + UINT8 index = 0; + + payloadlocation[index] = (UINT8)(data >> 24); + index++; + payloadlocation[index] = (UINT8)(data >> 16); + index++; + payloadlocation[index] = (UINT8)(data >> 8); + index++; + payloadlocation[index] = (UINT8)(data & 0xFF); + +} + +UINT8 bpmsgGet8bit(UINT8 *payload, UINT8 *payloadIndex) +{ + UINT8 result; + + result = (UINT8)payload[*payloadIndex]; + (*payloadIndex)++; + + return result; +} + + +UINT16 bpmsgGet16bit(UINT8 *payload, UINT8 *payloadIndex) +{ + UINT16 result; + + result = ((UINT16)payload[*payloadIndex]) << 8; + (*payloadIndex)++; + result += ((UINT16)payload[*payloadIndex] & 0x00FF); + (*payloadIndex)++; + + return result; +} + + +UINT32 bpmsgGet32bit(UINT8 *payload, UINT8 *payloadIndex) +{ + UINT32 result; + + result = ((UINT32)payload[*payloadIndex]) << 24; + (*payloadIndex)++; + result += ((UINT32)payload[*payloadIndex]) << 16; + (*payloadIndex)++; + result += ((UINT32)payload[*payloadIndex]) << 8; + (*payloadIndex)++; + result += ((UINT32)payload[*payloadIndex] & 0x000000FF); + (*payloadIndex)++; + + return result; +} + diff --git a/Quantum Controller/SW/testapplication-0.0.1/BpMessageFormat.h b/Quantum Controller/SW/testapplication-0.0.1/BpMessageFormat.h new file mode 100644 index 0000000..fdf1920 --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/BpMessageFormat.h @@ -0,0 +1,102 @@ +/* --------------------------------------------------------------------------- + * BpMessageFormat.h - v0.1 (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Jan 29, 2008, FSc + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef __BPMESSAGEFORMAT_H__ +#define __BPMESSAGEFORMAT_H__ +/** \file BpMessageFormat.h + \brief +*/ + +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ +#include "BpPort.h" + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ +#define BPMSG_STARTBYTE (0xAA) + +#define BPMSG_MSGID_PASSTURN (0x00) +#define BPMSG_MSGID_RESETCLIENT (0x01) +#define BPMSG_MSGID_GIVEELECTRONICSTATUS (0x02) +#define BPMSG_MSGID_SETDACVALUE (0x03) +#define BPMSG_MSGID_SETDIGITALOUTVALUE (0x04) +#define BPMSG_MSGID_SETADCMODE (0x05) +#define BPMSG_MSGID_SETALLDIGITALOUT (0x06) +#define BPMSG_MSGID_SETALLDACVALUES (0x07) +#define BPMSG_MSGID_SETALLDOUTPUT (0x08) +#define BPMSG_MSGID_CALLRPC (0x10) +#define BPMSG_MSGID_GIVERPCRESULTS (0x11) + +#define BPMSG_BROADCAST_ID (0xFF) +#define BPMSG_MASTER_DEVID (0x01) +#define BPMSG_STATUS_FINISHEDSENDING (0xC0) +#define BPMSG_STATUS_BUSYSENDING (0x40) +#define BPMSG_DACMODE_VOLTAGE (0x00) +#define BPMSG_DACMODE_CURRENT (0x01) +#define BPMSG_ADCMODE_VOLTAGE (0x00) +#define BPMSG_ADCMODE_CURRENT (0x01) +#define BPMSG_RPC_ERRORRESULT (0xFF) + +#define BPMSG_UINT32_SIZE (4) +#define BPMSG_UINT16_SIZE (2) +#define BPMSG_UINT8_SIZE (1) + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ +typedef struct t_BPMSG_MESSAGE { + UINT8 uniqueStartByte; + UINT8 senderId; + UINT8 targetId; + UINT8 packetNr; + UINT8 status; + UINT8 messageId; + UINT8 payloadSize; + UINT8 *payload; + UINT16 crc; +} t_bpmsg_message; + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ + +/** \brief Calculates the CRC over payload and sets unique start byte */ +void bpmsgEncodeMessage( t_bpmsg_message * msg ); +void bpmsgAdd16bit(UINT8 *payloadlocation, UINT16 data); +void bpmsgAdd32bit(UINT8 *payloadlocation, UINT32 data); +UINT8 bpmsgGet8bit(UINT8 *payload, UINT8 *payloadIndex); +UINT16 bpmsgGet16bit(UINT8 *payload, UINT8 *payloadIndex); +UINT32 bpmsgGet32bit(UINT8 *payload, UINT8 *payloadIndex); + +#endif /* __BPMESSAGEFORMAT_H__ */ diff --git a/Quantum Controller/SW/testapplication-0.0.1/BpPort.c b/Quantum Controller/SW/testapplication-0.0.1/BpPort.c new file mode 100644 index 0000000..7aec83c --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/BpPort.c @@ -0,0 +1,18 @@ +#include +#include "BpPort.h" +#include +#include + +portTickType xTaskGetTickCount() +{ + struct timeval tv; + portTickType result; + unsigned long intermediate; + + gettimeofday(&tv, NULL); + + intermediate = tv.tv_sec * 1000; + result = intermediate + (tv.tv_usec / 1000); + + return result; +} diff --git a/Quantum Controller/SW/testapplication-0.0.1/BpPort.h b/Quantum Controller/SW/testapplication-0.0.1/BpPort.h new file mode 100644 index 0000000..dc2c59c --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/BpPort.h @@ -0,0 +1,136 @@ +/* --------------------------------------------------------------------------- + * BpPort.h - v0.1 (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Jan 29, 2008, FSc + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef __BPPORT_H__ +#define __BPPORT_H__ +/** \file BpPort.h + \brief +*/ + +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ +#include +#include +#include // Required for usleep +#include + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ +#include "types.h" + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ + + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ +typedef pthread_t xTaskHandle; +//typedef mqd_t xQueueHandle; +typedef long portTickType; + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ +//void *pvPortMalloc( size_t xWantedSize ); +#define pvPortMalloc(wantedsize) malloc(wantedsize) + +//void vPortFree( void *pv ); +#define vPortFree(buffer) free(buffer) + +// +// signed portBASE_TYPE xTaskCreate( pdTASK_CODE pvTaskCode, +// const signed portCHAR * pcName, +// unsigned portSHORT usStackDepth, +// void *pvParameters, +// unsigned portBASE_TYPE uxPriority, +// xTaskHandle *pvCreatedTask ); +// +// extern int pthread_create (pthread_t *__restrict __newthread, +// __const pthread_attr_t *__restrict __attr, +// void *(*__start_routine) (void *), +// void *__restrict __arg) __THROW __nonnull ((1, 3)); +// +#define xTaskCreate(start_function, name, stackdepth, params, priority, handle) \ + pthread_create(handle, NULL, start_function, params) + +// +// void vTaskDelete( xTaskHandle pxTask ); +// +// void pthread_exit(void *value_ptr); +// +// note: Het deleten van een taak moet nog worden uitgezocht. Waarschijnlijk kan de thread niet zomaar gestopt worden +#define vTaskDelete( a ) // pthread_exit( a ) + +// +// portTickType xTaskGetTickCount( void ); +// +// ? +// +portTickType xTaskGetTickCount(); + +// +// +// +// void usleep(unsigned long usec); +// +#define vTaskDelay( msec ) usleep( 1000 * msec ); + +// +// xQueueHandle xQueueCreate( unsigned portBASE_TYPE uxQueueLength, unsigned portBASE_TYPE uxItemSize ); +// +// extern mqd_t mq_open (const char *__name, int __oflag, ...) __THROW; +// + +// +// signed portBASE_TYPE xQueueGenericReceive( xQueueHandle xQueue, const void * const pvBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeek ); +// +// #define xQueueReceive( xQueue, pvBuffer, xTicksToWait ) xQueueGenericReceive( xQueue, pvBuffer, xTicksToWait, pdFALSE ) +// +// /* Receive the oldest from highest priority messages in message queue +// MQDES. */ +// extern ssize_t mq_receive (mqd_t __mqdes, char *__msg_ptr, size_t __msg_len, +// unsigned int *__msg_prio); +// +//#define xQueueReceive( handle, buffer, ticks2wait ) + +// +// signed portBASE_TYPE xQueueGenericSend( xQueueHandle xQueue, const void * const pvItemToQueue, portTickType xTicksToWait, portBASE_TYPE xCopyPosition ); +// +// #define xQueueSendToBack( xQueue, pvItemToQueue, xTicksToWait ) xQueueGenericSend( xQueue, pvItemToQueue, xTicksToWait, queueSEND_TO_BACK ) +// +// /* Add message pointed by MSG_PTR to message queue MQDES. */ +// extern int mq_send (mqd_t __mqdes, const char *__msg_ptr, size_t __msg_len, +// unsigned int __msg_prio); +// + +#endif /* __BPPORT_H__ */ + diff --git a/Quantum Controller/SW/testapplication-0.0.1/BusProtocol.c b/Quantum Controller/SW/testapplication-0.0.1/BusProtocol.c new file mode 100644 index 0000000..a4885e9 --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/BusProtocol.c @@ -0,0 +1,680 @@ +/* --------------------------------------------------------------------------- + * BusProtocol.c - v0.1 (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Jan 28, 2008, FSc + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +#include +#include + +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "BpPort.h" +#include "BusProtocol.h" +#include "ProtocolThread.h" +#include "MessageHandlerQueue.h" +#include "RemoteProcedureCalls.h" +#include "RpcResults.h" +#include "bus.h" +//#include "ElecStatusCache.h" +#include "mem_mod.h" + + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ +typedef struct t_BP_ADMIN { + UINT8 deviceId; + UINT8 rpcRequestNr; + int rpcHandle; + int rpcrHandle; + int bpthreadHandle; + int messageHandlerHandle; +} t_bp_admin; + +memman *bpMessagePool; + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ +static void WriteElectricStatusCallback( int handle, BOOLEAN isDigital, UINT8 device, UINT8 channel, UINT16 value ); + +/** \brief Initialises the BusProtocol + * + * \param bus The bus to communicate on + * \param deviceId the bus identity for this device + * \retval the handle for the BusProtocol-driver (0 = unsuccesfull) + */ +int bpInit( t_bus_devices bus, UINT8 deviceId, UINT8 highestDeviceId, UINT8 inputQueueSize ) +{ + t_bp_admin *newBusProtocol = (t_bp_admin *)pvPortMalloc( sizeof(t_bp_admin)); + + if (newBusProtocol != NULL) + { + // Fill administration + newBusProtocol->deviceId = deviceId; + newBusProtocol->rpcRequestNr = 0; + newBusProtocol->rpcHandle = rpcInit(); + newBusProtocol->rpcrHandle = rpcrInit(); + newBusProtocol->messageHandlerHandle = mhqInit(); + + // Allocate payload queue + bpMessagePool = Memmod_Create( inputQueueSize, 64); // Make sure size is dividable by 4 + + // Register RPC Callback + mhqAdd( newBusProtocol->messageHandlerHandle, BPMSG_MSGID_CALLRPC, rpcRequestHandler, newBusProtocol->rpcHandle ); + + // Register RPC-result Callback + mhqAdd( newBusProtocol->messageHandlerHandle, BPMSG_MSGID_GIVERPCRESULTS, rpcrRequestHandler, newBusProtocol->rpcrHandle ); + + // Register Write electronic status callbac ) + bpecAttachWriteCallback(newBusProtocol, WriteElectricStatusCallback); + + // Open bus + busInit(bus); + + // Create & start thread to poll bus + newBusProtocol->bpthreadHandle = bpthreadStart( bus, deviceId, highestDeviceId, (int)newBusProtocol, newBusProtocol->messageHandlerHandle ); + } + + return (int)newBusProtocol; +} + +/** \brief Closes the active BusProtocol + * + * \post Protocol on this handle cannot be used anymore + * \param handle The handle for the BusProtocol (received with bpInit()) + */ +void bpDeinit( int handle ) +{ + // Stop & Destroy the bus poll thread + + // Close bus + /* \todo busDeinit( (t_bp_admin *)handle)->bus ); */ + + rpcDeinit( ((t_bp_admin *)handle)->rpcHandle ); + rpcrDeinit( ((t_bp_admin *)handle)->rpcrHandle ); + bpthreadStop( ((t_bp_admin *)handle)->bpthreadHandle ); + + // Free BusProtocol-administration + vPortFree( (void *)handle ); +} + + +/** \brief Indicates whether a message a device is received in the last 10 seconds + * Only used by the master + */ +BOOLEAN bpDeviceIsDetected( int handle, UINT8 deviceId ) +{ + return bpthreadDeviceIsDetected(((t_bp_admin *)handle)->bpthreadHandle, deviceId); +} + + +/** \brief Sends message to pass turn (Nothing to send) + * + * \param handle The handle for the BusProtocol (received with bpInit()) + */ +void bpSendPassTurn( int handle ) +{ + t_bpmsg_message sendPassTurnMessage; + + BP_DEBUG_OUT('p');BP_DEBUG_OUT('>'); + + // Create new message + sendPassTurnMessage.uniqueStartByte = BPMSG_STARTBYTE; + sendPassTurnMessage.senderId = ((t_bp_admin *)handle)->deviceId; + sendPassTurnMessage.targetId = BPMSG_BROADCAST_ID; + sendPassTurnMessage.packetNr = 0; // packetNr filled at transmitting time + sendPassTurnMessage.status = 0; // Clear status (filled by ProtocolThread) + sendPassTurnMessage.messageId = BPMSG_MSGID_PASSTURN; + sendPassTurnMessage.payloadSize = 0; + sendPassTurnMessage.payload = NULL; + + // Calculate CRC + bpmsgEncodeMessage(&sendPassTurnMessage); + + bpthreadAddMessage(((t_bp_admin *)handle)->bpthreadHandle, &sendPassTurnMessage); +} + +/** \brief Sends message to reset another bus device + * + * \param handle The handle for the BusProtocol (received with bpInit()) + * \param deviceId Identity of targeted bus device (0xFF = all devices) + */ +void bpSendResetClient( int handle, UINT8 deviceId ) +{ + t_bpmsg_message sendResetClientMessage; + + // Create new message + sendResetClientMessage.uniqueStartByte = BPMSG_STARTBYTE; + sendResetClientMessage.senderId = ((t_bp_admin *)handle)->deviceId; + sendResetClientMessage.targetId = deviceId; + sendResetClientMessage.packetNr = 0; // packetNr filled at transmitting time + sendResetClientMessage.status = 0; // Clear status (filled by ProtocolThread) + sendResetClientMessage.messageId = BPMSG_MSGID_RESETCLIENT; + sendResetClientMessage.payloadSize = 0; + sendResetClientMessage.payload = NULL; + + // Calculate CRC + bpmsgEncodeMessage(&sendResetClientMessage); + + bpthreadAddMessage(((t_bp_admin *)handle)->bpthreadHandle, &sendResetClientMessage); +} + +/** \brief Sends message with all electronic information (DAC's, ADC's and digital I/O) + * + * Broadcasts the electronic status of the device + * + * \param handle The handle for the BusProtocol (received with bpInit()) + * \param nrOfAdcValues Number of ADC-values included in the message + * \param adcValues Pointer to a UINT16 array + * \param nrOfDacValues Number of DAC-values included in the message + * \param dacValues Pointer to a UINT16 array + * \param nrOfDiValues Number of digital input values included in the message + * \param diValues Digital input channel values (8 channels per byte) + * \param nrOfDoValues Number of digital output values inculded in the message + * \param doValues Digital output channel values (8 channels per byte) + */ +void bpSendGiveElectronicStatus( int handle, + UINT8 nrOfAdcValues, + UINT16 *adcValues, + UINT8 nrOfDacValues, + UINT16 *dacValues, + UINT8 nrOfDiValues, + UINT8 *diValues, + UINT8 nrOfDoValues, + UINT8 *doValues + ) +{ + t_bpmsg_message sendGiveElectronicStatusMessage; + UINT8 *payload; + UINT16 payloadSize; + UINT8 payloadIndex = 0; + UINT8 index; + + // Determine payload size + payloadSize = BPMSG_UINT8_SIZE; + payloadSize += nrOfAdcValues * BPMSG_UINT16_SIZE; + payloadSize += BPMSG_UINT8_SIZE; + payloadSize += nrOfDacValues * BPMSG_UINT16_SIZE; + payloadSize += BPMSG_UINT8_SIZE; + payloadSize += nrOfDiValues * BPMSG_UINT8_SIZE; + payloadSize += BPMSG_UINT8_SIZE; + payloadSize += nrOfDoValues * BPMSG_UINT8_SIZE; + + payload = (UINT8 *)Memmod_Alloc( bpMessagePool ); + if (payload == 0) return; + + // Create new message + sendGiveElectronicStatusMessage.uniqueStartByte = BPMSG_STARTBYTE; + sendGiveElectronicStatusMessage.senderId = ((t_bp_admin *)handle)->deviceId; + sendGiveElectronicStatusMessage.targetId = BPMSG_BROADCAST_ID; + sendGiveElectronicStatusMessage.packetNr = 0; // packetNr filled at transmitting time + sendGiveElectronicStatusMessage.status = 0; // Clear status (filled by ProtocolThread) + sendGiveElectronicStatusMessage.messageId = BPMSG_MSGID_GIVEELECTRONICSTATUS; + sendGiveElectronicStatusMessage.payloadSize = payloadSize; + sendGiveElectronicStatusMessage.payload = payload; + + // Fill Payload + payload[payloadIndex] = nrOfAdcValues; + payloadIndex += BPMSG_UINT8_SIZE; + for (index = 0; index < nrOfAdcValues; index++) + { + bpmsgAdd16bit( &payload[payloadIndex], adcValues[index]); + payloadIndex += BPMSG_UINT16_SIZE; + } + + payload[payloadIndex] = nrOfDacValues; + payloadIndex += BPMSG_UINT8_SIZE; + for (index = 0; index < nrOfDacValues; index++) + { + bpmsgAdd16bit( &payload[payloadIndex], dacValues[index]); + payloadIndex += BPMSG_UINT16_SIZE; + } + + payload[payloadIndex] = nrOfDiValues; + payloadIndex += BPMSG_UINT8_SIZE; + for (index = 0; index < nrOfDiValues; index++) + { + payload[payloadIndex] = diValues[index]; + payloadIndex += BPMSG_UINT8_SIZE; + } + + payload[payloadIndex] = nrOfDoValues; + payloadIndex += BPMSG_UINT8_SIZE; + for (index = 0; index < nrOfDoValues; index++) + { + payload[payloadIndex] = doValues[index]; + payloadIndex += BPMSG_UINT8_SIZE; + } + + // Calculate CRC + bpmsgEncodeMessage(&sendGiveElectronicStatusMessage); + + bpthreadAddMessage(((t_bp_admin *)handle)->bpthreadHandle, &sendGiveElectronicStatusMessage); +} + +/** \brief Sends message to set a DAC on another bus device + * + * \param handle The handle for the BusProtocol (received with bpInit()) + * \param deviceId Identity of targeted bus device + * \param channelNr Number of the DAC-channel + * \param dacMode Voltage (0) / Ampere (<> 0) + * \param davValue New DAC value (voltage: 0-10000mV, ampere: 0-20000uA) + */ +void bpSendSetDacValue( int handle, UINT8 deviceId, UINT8 channelNr, UINT8 dacMode, UINT16 dacValue ) +{ + t_bpmsg_message sendSetDacMessage; + UINT8 *payload = (UINT8 *) Memmod_Alloc( bpMessagePool ); + if (payload == 0) return; + + BP_DEBUG_OUT('a'); BP_DEBUG_OUT('>'); + + // Create new message + sendSetDacMessage.uniqueStartByte = BPMSG_STARTBYTE; + sendSetDacMessage.senderId = ((t_bp_admin *)handle)->deviceId; + sendSetDacMessage.targetId = deviceId; + sendSetDacMessage.packetNr = 0; // packetNr filled at transmitting time + sendSetDacMessage.status = 0; // Clear status (filled by ProtocolThread) + sendSetDacMessage.messageId = BPMSG_MSGID_SETDACVALUE; + sendSetDacMessage.payloadSize = 4; + sendSetDacMessage.payload = payload; + + // Fill Payload + payload[0] = channelNr; + payload[1] = dacMode; + bpmsgAdd16bit( &payload[2], dacValue); + + // Calculate CRC + bpmsgEncodeMessage(&sendSetDacMessage); + + bpthreadAddMessage(((t_bp_admin *)handle)->bpthreadHandle, &sendSetDacMessage); +} + +/** \brief Sends message to set the values of all DAC's on another bus device + * + * \param handle The handle for the BusProtocol (received with bpInit()) + * \param deviceId Identity of targeted bus device + * \param davValue pointer to array with 4 DAC value, i.e. DAC-value position 0 for Channel 0 etc... (voltage: 0-10000mV, ampere: 0-20000uA) + */ +void bpSendSetAllDacValues( int handle, UINT8 deviceId, UINT16 *dacValue ) +{ + t_bpmsg_message sendSetDacMessage; + UINT8 *payload = (UINT8 *) Memmod_Alloc( bpMessagePool ); + if (payload == 0) return; + + BP_DEBUG_OUT('a'); BP_DEBUG_OUT('>'); + + // Create new message + sendSetDacMessage.uniqueStartByte = BPMSG_STARTBYTE; + sendSetDacMessage.senderId = ((t_bp_admin *)handle)->deviceId; + sendSetDacMessage.targetId = deviceId; + sendSetDacMessage.packetNr = 0; // packetNr filled at transmitting time + sendSetDacMessage.status = 0; // Clear status (filled by ProtocolThread) + sendSetDacMessage.messageId = BPMSG_MSGID_SETALLDACVALUES; + sendSetDacMessage.payloadSize = 4 * 2; + sendSetDacMessage.payload = payload; + + // Fill Payload + bpmsgAdd16bit( &payload[0], dacValue[0]); + bpmsgAdd16bit( &payload[2], dacValue[1]); + bpmsgAdd16bit( &payload[4], dacValue[2]); + bpmsgAdd16bit( &payload[6], dacValue[3]); + + // Calculate CRC + bpmsgEncodeMessage(&sendSetDacMessage); + + bpthreadAddMessage(((t_bp_admin *)handle)->bpthreadHandle, &sendSetDacMessage); +} + + +/** \brief Sends message to set a digital out on another bus device + * + * \param handle The handle for the BusProtocol (received with bpInit()) + * \param bitNr Number of the digital output pin + * \param value Low-level (0) or High-level (<> 0) + */ +void bpSendSetDigitalOutValue( int handle, UINT8 deviceId, UINT8 bitNr, UINT8 value ) +{ + t_bpmsg_message sendSetDoMessage; + UINT8 *payload = (UINT8 *)Memmod_Alloc( bpMessagePool ); + if (payload == 0) return; + + BP_DEBUG_OUT('d'); BP_DEBUG_OUT('>'); + + // Create new message + sendSetDoMessage.uniqueStartByte = BPMSG_STARTBYTE; + sendSetDoMessage.senderId = ((t_bp_admin *)handle)->deviceId; + sendSetDoMessage.targetId = deviceId; + sendSetDoMessage.packetNr = 0; // packetNr filled at transmitting time + sendSetDoMessage.status = 0; // Clear status (filled by ProtocolThread) + sendSetDoMessage.messageId = BPMSG_MSGID_SETDIGITALOUTVALUE; + sendSetDoMessage.payloadSize = 2; + sendSetDoMessage.payload = payload; + + // Fill Payload + payload[0] = bitNr; + payload[1] = value; + + // Calculate CRC + bpmsgEncodeMessage(&sendSetDoMessage); + + bpthreadAddMessage(((t_bp_admin *)handle)->bpthreadHandle, &sendSetDoMessage); +} + +/** \brief Sends message to set all digital out ports at once on another bus device + * + * \param handle The handle for the BusProtocol (received with bpInit()) + * \param deviceId The ID of the other bus device + * \param bits All bitsNumber of the digital output pin + */ +void bpSendSetAllDigitalOut( int handle, UINT8 deviceId, UINT8 bits) +{ + t_bpmsg_message sendSetDoMessage; + UINT8 *payload = (UINT8 *)Memmod_Alloc( bpMessagePool ); + if (payload == 0) return; + + BP_DEBUG_OUT('d'); BP_DEBUG_OUT('>'); + + // Create new message + sendSetDoMessage.uniqueStartByte = BPMSG_STARTBYTE; + sendSetDoMessage.senderId = ((t_bp_admin *)handle)->deviceId; + sendSetDoMessage.targetId = deviceId; + sendSetDoMessage.packetNr = 0; // packetNr filled at transmitting time + sendSetDoMessage.status = 0; // Clear status (filled by ProtocolThread) + sendSetDoMessage.messageId = BPMSG_MSGID_SETALLDIGITALOUT; + sendSetDoMessage.payloadSize = 1; + sendSetDoMessage.payload = payload; + + // Fill Payload + payload[0] = bits; + + // Calculate CRC + bpmsgEncodeMessage(&sendSetDoMessage); + + bpthreadAddMessage(((t_bp_admin *)handle)->bpthreadHandle, &sendSetDoMessage); +} + +/** \brief Sends message to set all outputs (analogue & digital) on another bus device +* +* \param handle The handle for the BusProtocol (received with bpInit()) +* \param deviceId Identity of targeted bus device +* \param bits All bitsNumber of the digital output pin +* \param davValue pointer to array with 4 DAC value, i.e. DAC-value position 0 for Channel 0 etc... (voltage: 0-10000mV, ampere: 0-20000uA) +*/ +void bpSendSetAllOutput( int handle, UINT8 deviceId, UINT8 bits, UINT16 *dacValue ) +{ + t_bpmsg_message sendSetAllOutpuntMessage; + UINT8 *payload = (UINT8 *) Memmod_Alloc( bpMessagePool ); + if (payload == 0) return; + + BP_DEBUG_OUT('a'); BP_DEBUG_OUT('o'); BP_DEBUG_OUT('>'); + + // Create new message + sendSetAllOutpuntMessage.uniqueStartByte = BPMSG_STARTBYTE; + sendSetAllOutpuntMessage.senderId = ((t_bp_admin *)handle)->deviceId; + sendSetAllOutpuntMessage.targetId = deviceId; + sendSetAllOutpuntMessage.packetNr = 0; // packetNr filled at transmitting time + sendSetAllOutpuntMessage.status = 0; // Clear status (filled by ProtocolThread) + sendSetAllOutpuntMessage.messageId = BPMSG_MSGID_SETALLDOUTPUT; + sendSetAllOutpuntMessage.payloadSize = (4 * 2) + 1; + sendSetAllOutpuntMessage.payload = payload; + + // Fill Payload + payload[0] = bits; + bpmsgAdd16bit( &payload[1], dacValue[0]); + bpmsgAdd16bit( &payload[3], dacValue[1]); + bpmsgAdd16bit( &payload[5], dacValue[2]); + bpmsgAdd16bit( &payload[7], dacValue[3]); + + // Calculate CRC + bpmsgEncodeMessage(&sendSetAllOutpuntMessage); + + bpthreadAddMessage(((t_bp_admin *)handle)->bpthreadHandle, &sendSetAllOutpuntMessage); +} + + +/** \brief Sends message to call an Remote Procedure Call on an other bus device + * + * Request to execute a procedure on another device + * + * \param handle The handle for the BusProtocol (received with bpInit()) + * \param deviceId Identity of targeted bus device + * \param functionId Identity of the RPC-function + * \param nrOfParams Number of parameters for the RPC-function + * \param params Pointer to an array of 32-bit integers + */ +void bpSendCallRpc( int handle, UINT8 deviceId, UINT8 functionId, UINT8 nrOfParams, INT32 *params ) +{ + t_bpmsg_message sendCallRpcMessage; + UINT8 *payload; + UINT8 payloadSize; + UINT8 payloadIndex = 0; + UINT8 index; + + BP_DEBUG_OUT('c'); BP_DEBUG_OUT('>'); + + // Determine payload size + payloadSize = 3 * BPMSG_UINT8_SIZE; + payloadSize += nrOfParams * BPMSG_UINT32_SIZE; + + payload = (UINT8 *)Memmod_Alloc( bpMessagePool ); + if (payload == 0) return; + + // Create new message + sendCallRpcMessage.uniqueStartByte = BPMSG_STARTBYTE; + sendCallRpcMessage.senderId = ((t_bp_admin *)handle)->deviceId; + sendCallRpcMessage.targetId = deviceId; + sendCallRpcMessage.packetNr = 0; // packetNr filled at transmitting time + sendCallRpcMessage.status = 0; // Clear status (filled by ProtocolThread) + sendCallRpcMessage.messageId = BPMSG_MSGID_CALLRPC; + sendCallRpcMessage.payloadSize = payloadSize; + sendCallRpcMessage.payload = payload; + + // Fill Payload + payload[payloadIndex] = ((t_bp_admin *)handle)->rpcRequestNr; + ((t_bp_admin *)handle)->rpcRequestNr++; + payloadIndex += BPMSG_UINT8_SIZE; + + payload[payloadIndex] = functionId; + payloadIndex += BPMSG_UINT8_SIZE; + + payload[payloadIndex] = nrOfParams; + payloadIndex += BPMSG_UINT8_SIZE; + + for (index = 0; index < nrOfParams; index++) + { + bpmsgAdd32bit( payload + payloadIndex, (UINT32)params[index]); + payloadIndex += BPMSG_UINT32_SIZE; + } + + + // Calculate CRC + bpmsgEncodeMessage(&sendCallRpcMessage); + + bpthreadAddMessage(((t_bp_admin *)handle)->bpthreadHandle, &sendCallRpcMessage); +} + +/** \brief Sends message to give result on issued RPC-function + * + * \param handle The handle for the BusProtocol (received with bpInit()) + * \param nrOfResults Number of results to be send + * \param results Pointer to array with results. + */ +void bpSendRpcResult( int handle, UINT8 deviceId, UINT8 functionId, UINT8 requestNr, UINT8 nrOfResults, INT32 *results ) +{ + t_bpmsg_message sendCallRpcResultMessage; + UINT8 *payload; + UINT8 payloadSize; + UINT8 payloadIndex = 0; + UINT8 index; + + BP_DEBUG_OUT('r'); BP_DEBUG_OUT('>'); + + // Determine payload size + payloadSize = 3 * BPMSG_UINT8_SIZE; + payloadSize += nrOfResults * BPMSG_UINT32_SIZE; + + payload = (UINT8 *)Memmod_Alloc( bpMessagePool ); + if (payload == 0) return; + + // Create new message + sendCallRpcResultMessage.uniqueStartByte = BPMSG_STARTBYTE; + sendCallRpcResultMessage.senderId = ((t_bp_admin *)handle)->deviceId; + sendCallRpcResultMessage.targetId = deviceId; + sendCallRpcResultMessage.packetNr = 0; // packetNr filled at transmitting time + sendCallRpcResultMessage.status = 0; // Clear status (filled by ProtocolThread) + sendCallRpcResultMessage.messageId = BPMSG_MSGID_GIVERPCRESULTS; + sendCallRpcResultMessage.payloadSize = payloadSize; + sendCallRpcResultMessage.payload = payload; + + // Fill Payload + payload[payloadIndex] = requestNr; + payloadIndex += BPMSG_UINT8_SIZE; + + payload[payloadIndex] = functionId; + payloadIndex += BPMSG_UINT8_SIZE; + + payload[payloadIndex] = nrOfResults; + payloadIndex += BPMSG_UINT8_SIZE; + + for (index = 0; index < nrOfResults; index++) + { + bpmsgAdd32bit( &payload[payloadIndex], (UINT32)results[index]); + payloadIndex += BPMSG_UINT32_SIZE; + } + + // Calculate CRC + bpmsgEncodeMessage(&sendCallRpcResultMessage); + + bpthreadAddMessage(((t_bp_admin *)handle)->bpthreadHandle, &sendCallRpcResultMessage); +} + + +/** \brief Attachs a callback, which is called when it is the device its turn to send data on the bus + * + * \param handle The handle for the BusProtocol (received with bpInit()) + * \param onMyTurnCallback pointer to the callback function + */ +void bpAttachOnMyTurn( int handle, t_bp_myturn_callback onMyTurnCallback ) +{ + t_bp_admin *bpAdmin = (t_bp_admin *)handle; + + bpthreadAttachMyTurn( bpAdmin->bpthreadHandle, onMyTurnCallback); +} + +/** \brief Detaches the above callback + * + * \param handle The handle for the BusProtocol (received with bpInit()) + * \param onMyTurnCallback pointer to the callback function + */ +void bpDetachOnMyTurn( int handle, t_bp_myturn_callback onMyTurnCallback ) +{ + t_bp_admin *bpAdmin = (t_bp_admin *)handle; + + bpthreadDetachMyTurn( bpAdmin->bpthreadHandle, onMyTurnCallback); +} + +/** \brief Attachs a RPC-function, which can be called by another bus device + * + * \param handle The handle for the BusProtocol (received with bpInit()) + * \param functionId The identity of the RPC-function + * \param functionPointer Pointer to actual RPC-function + * \param nrOfParams Number of parameters, required by RPC + */ +void bpAttachRpc( int handle, UINT8 functionId, char * functionName, t_rpc_remote_procedure_call functionPointer, UINT8 nrOfParams ) +{ + t_bp_admin *bpAdmin = (t_bp_admin *)handle; + + rpcAdd( bpAdmin->rpcHandle, functionId, functionName, functionPointer, nrOfParams); +} + +/** \brief Detaches the above RPC-function + * + * \post RPC-function is not supported anymore + * \param handle The handle for the BusProtocol (received with bpInit()) + * \param functionId Identity of the detached RPC-function + */ +void bpDetachRpc( int handle, UINT8 functionId ) +{ + t_bp_admin *bpAdmin = (t_bp_admin *)handle; + + rpcRemove( bpAdmin->rpcHandle, functionId ); +} + +/** \brief Attachs a "RPC result"-function, which is a result of a requeste RPC-call on another bus device + * + * \param handle The handle for the BusProtocol (returned by bpInit()) + * \param functionId The functionId on which the result should be catched + * \param functionPointer The funtion which must be called when a RPC-result is received. + */ +void bpAttachRpcResult( int handle, UINT8 functionId, t_bp_rpcresult_callback functionPointer, UINT8 nrOfResults ) +{ + t_bp_admin *bpAdmin = (t_bp_admin *)handle; + + rpcrAdd( bpAdmin->rpcrHandle, functionId, functionPointer, nrOfResults); +} + +/** \brief Detaches the above "RPC result"-function + * + * \param handle The handle for the BusProtocol (returned by bpInit()) + * \param functionId The functionId on which the result should be catched + */ +void bpDetachRpcResult( int handle, UINT8 functionId ) +{ + t_bp_admin *bpAdmin = (t_bp_admin *)handle; + + rpcrRemove( bpAdmin->rpcrHandle, functionId ); +} + + +t_rpc_entity *bpLookupRpcEntry( int handle, UINT8 functionId ) +{ + t_bp_admin *bpAdmin = (t_bp_admin *)handle; + + return rpcLookupEntry( bpAdmin->rpcHandle, functionId ); +} + +void WriteElectricStatusCallback( int handle, BOOLEAN isDigital, UINT8 device, UINT8 channel, UINT16 value ) +{ + if (isDigital) + { + bpSendSetDigitalOutValue( handle, device, channel, (BOOLEAN)value ) ; + } + else + { + bpSendSetDacValue( handle, device, channel, 0, value ); + } +} + diff --git a/Quantum Controller/SW/testapplication-0.0.1/BusProtocol.h b/Quantum Controller/SW/testapplication-0.0.1/BusProtocol.h new file mode 100644 index 0000000..15b809f --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/BusProtocol.h @@ -0,0 +1,142 @@ +/* --------------------------------------------------------------------------- + * BusProtocol.h - v0.1 (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Jan 28, 2008, FSc + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef __BUSPROTOCOL_H__ +#define __BUSPROTOCOL_H__ +/** \file BusProtocol.h + \brief Implementation of BusProtocol +*/ + +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ +#include +#include "BpPort.h" +#include "bus.h" +#include "RemoteProcedureCalls.h" +#include "BpMessageFormat.h" + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ +#define MASTER_DEVICE_ID (1) +#define MAX_PAYLOAD_SIZE (50) +#define BP_DEBUG_OUT(a) /*printf("%c", a); fflush( stdout );*/ + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ +typedef void (*t_bp_myturn_callback)(void); +typedef void (*t_bp_rpcresult_callback)( UINT8 requestNr, UINT8 nrOfResults, UINT32 *results ); +typedef void (*t_bp_messagehandler)(t_bpmsg_message *receivedMessage, int ownHandler ); + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ + +/** \brief Initialises the BusProtocol */ +int bpInit( t_bus_devices bus, UINT8 deviceId, UINT8 highestDeviceId, UINT8 inputQueueSize ); + +/** \brief Closes the active BusProtocol */ +void bpDeinit( int handle ); + +/** \brief Indicates whether a message a device is received in the last 10 seconds + * Only used by the master + */ +BOOLEAN bpDeviceIsDetected( int handle, UINT8 deviceId ); + +/** \brief Sends message to pass turn (Nothing to send) */ +void bpSendPassTurn( int handle ); + +/** \brief Sends message to reset another bus device */ +void bpSendResetClient( int handle, UINT8 deviceId ); + +/** \brief Sends message with all electronic information (DAC's, ADC's and digital I/O) */ +void bpSendGiveElectronicStatus( int handle, + UINT8 nrOfAdcValues, + UINT16 *adcValues, + UINT8 nrOfDacValues, + UINT16 *dacValues, + UINT8 nrOfDiValues, + UINT8 *diValues, + UINT8 nrOfDoValues, + UINT8 *doValues + ); + +/** \brief Sends message to set a DAC on another bus device */ +void bpSendSetDacValue( int handle, UINT8 deviceId, UINT8 channelNr, UINT8 dacMode, UINT16 dacValue ); + +/** \brief Sends message to set the values of all DAC's on another bus device */ +void bpSendSetAllDacValues( int handle, UINT8 deviceId, UINT16 *dacValue ); + +/** \brief Sends message to set a digital out on another bus device */ +void bpSendSetDigitalOutValue( int handle, UINT8 deviceId, UINT8 bitNr, UINT8 value ); + +/** \brief Sends message to set all digital out ports at once on another bus device */ +void bpSendSetAllDigitalOut( int handle, UINT8 deviceId, UINT8 bits); + +/** \brief Sends message to set all outputs (analogue & digital) on another bus device */ +void bpSendSetAllOutput( int handle, UINT8 deviceId, UINT8 bits, UINT16 *dacValue); + +/** \brief Sends message to call an Remote Procedure Call on an other bus device */ +void bpSendCallRpc( int handle, UINT8 deviceId, UINT8 functionId, UINT8 nrOfParams, INT32 *params ); + +/** \brief Attachs a callback, which is called when it is the device its turn to send data on the bus */ +void bpAttachOnMyTurn( int handle, t_bp_myturn_callback onMyTurnCallback ); + +/** \brief Detaches the above callback */ +void bpDetachOnMyTurn( int handle, t_bp_myturn_callback onMyTurnCallback ); + +/** \brief Attach callback on receiving a specific message */ +void bpAttachMessageHandler( int handle, UINT8 messageId, t_bp_messagehandler messageHandler); + +/** \brief Attach callback on receiving a specific message */ +void bpDetachMessageHandler( int handle, UINT8 messageId, t_bp_messagehandler messageHandler); + +/** \brief Attachs a RPC-function, which can be called by another bus device */ +void bpAttachRpc( int handle, UINT8 functionId, char * functionName, t_rpc_remote_procedure_call functionPointer, UINT8 nrOfParams ); + +/** \brief Detaches the above RPC-function */ +void bpDetachRpc( int handle, UINT8 functionId ); + +/** \brief Attachs a "RPC result"-function, which is a result of a requeste RPC-call on another bus device */ +void bpAttachRpcResult( int handle, UINT8 functionId, t_bp_rpcresult_callback functionPointer, UINT8 nrOfResult ); + +/** \brief Detaches the above "RPC result"-function */ +void bpDetachRpcResult( int handle, UINT8 functionId ); + +t_rpc_entity *bpLookupRpcEntry( int handle, UINT8 functionId ); + +/** \brief Sends message to give result on issued RPC-function */ +void bpSendRpcResult( int handle, UINT8 deviceId, UINT8 functionId, UINT8 requestNr, UINT8 nrOfResults, INT32 *results ); + +#endif /* __BUSPROTOCOL_H__ */ diff --git a/Quantum Controller/SW/testapplication-0.0.1/CAN_test.c b/Quantum Controller/SW/testapplication-0.0.1/CAN_test.c new file mode 100644 index 0000000..158dd3e --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/CAN_test.c @@ -0,0 +1 @@ +/* --------------------------------------------------------------------------- * CAN_test.c (c) 2008 Micro-key bv * --------------------------------------------------------------------------- * Micro-key bv * Industrieweg 28, 9804 TG Noordhorn * Postbus 92, 9800 AB Zuidhorn * The Netherlands * Tel: +31 594 503020 * Fax: +31 594 505825 * Email: support@microkey.nl * Web: www.microkey.nl * --------------------------------------------------------------------------- * Description: Test file for the CAN interface * --------------------------------------------------------------------------- * Version(s): 0.1, Dez 11, 2008, MMi * Creation. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * System include files * --------------------------------------------------------------------------- */ #include /* --------------------------------------------------------------------------- * Application include files * --------------------------------------------------------------------------- */ #include "CAN_test.h" /* --------------------------------------------------------------------------- * Local constant and macro definitions * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Global variable definitions * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Local variable definitions * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Local function definitions * --------------------------------------------------------------------------- */ void can_test_execute (void) { printf ("THIS IS THE CAN TEST SEQUENCE"); } \ No newline at end of file diff --git a/Quantum Controller/SW/testapplication-0.0.1/CAN_test.h b/Quantum Controller/SW/testapplication-0.0.1/CAN_test.h new file mode 100644 index 0000000..ce25f31 --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/CAN_test.h @@ -0,0 +1 @@ +/* --------------------------------------------------------------------------- * CAN_test.h (c) 2008 Micro-key bv * --------------------------------------------------------------------------- * Micro-key bv * Industrieweg 28, 9804 TG Noordhorn * Postbus 92, 9800 AB Zuidhorn * The Netherlands * Tel: +31 594 503020 * Fax: +31 594 505825 * Email: support@microkey.nl * Web: www.microkey.nl * --------------------------------------------------------------------------- * Description: * --------------------------------------------------------------------------- * Version(s): 0.1, Dez 11, 2008, MMi * Creation. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * System include files. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Application include files. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Constant and macro definitions. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Type definitions. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Variable declarations. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Function declarations. * --------------------------------------------------------------------------- */ void can_test_execute (void); \ No newline at end of file diff --git a/Quantum Controller/SW/testapplication-0.0.1/CF_test.c b/Quantum Controller/SW/testapplication-0.0.1/CF_test.c new file mode 100644 index 0000000..bba77b5 --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/CF_test.c @@ -0,0 +1 @@ +/* --------------------------------------------------------------------------- * CF_test.c (c) 2008 Micro-key bv * --------------------------------------------------------------------------- * Micro-key bv * Industrieweg 28, 9804 TG Noordhorn * Postbus 92, 9800 AB Zuidhorn * The Netherlands * Tel: +31 594 503020 * Fax: +31 594 505825 * Email: support@microkey.nl * Web: www.microkey.nl * --------------------------------------------------------------------------- * Description: Test file for the Compact Flash reader interface * --------------------------------------------------------------------------- * Version(s): 0.1, Dez 11, 2008, MMi * Creation. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * System include files * --------------------------------------------------------------------------- */ #include /* --------------------------------------------------------------------------- * Application include files * --------------------------------------------------------------------------- */ #include "CF_test.h" /* --------------------------------------------------------------------------- * Local constant and macro definitions * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Global variable definitions * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Local variable definitions * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Local function definitions * --------------------------------------------------------------------------- */ void cf_test_execute (void) { printf ("THIS IS THE CF TEST SEQUENCE"); } \ No newline at end of file diff --git a/Quantum Controller/SW/testapplication-0.0.1/CF_test.h b/Quantum Controller/SW/testapplication-0.0.1/CF_test.h new file mode 100644 index 0000000..3ace346 --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/CF_test.h @@ -0,0 +1 @@ +/* --------------------------------------------------------------------------- * CF_test.h (c) 2008 Micro-key bv * --------------------------------------------------------------------------- * Micro-key bv * Industrieweg 28, 9804 TG Noordhorn * Postbus 92, 9800 AB Zuidhorn * The Netherlands * Tel: +31 594 503020 * Fax: +31 594 505825 * Email: support@microkey.nl * Web: www.microkey.nl * --------------------------------------------------------------------------- * Description: * --------------------------------------------------------------------------- * Version(s): 0.1, Dez 11, 2008, MMi * Creation. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * System include files. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Application include files. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Constant and macro definitions. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Type definitions. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Variable declarations. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Function declarations. * --------------------------------------------------------------------------- */ void cf_test_execute (void); \ No newline at end of file diff --git a/Quantum Controller/SW/testapplication-0.0.1/COPYING b/Quantum Controller/SW/testapplication-0.0.1/COPYING new file mode 100644 index 0000000..94a9ed0 --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/COPYING @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/Quantum Controller/SW/testapplication-0.0.1/ChangeLog b/Quantum Controller/SW/testapplication-0.0.1/ChangeLog new file mode 100644 index 0000000..e69de29 diff --git a/Quantum Controller/SW/testapplication-0.0.1/Crc.c b/Quantum Controller/SW/testapplication-0.0.1/Crc.c new file mode 100644 index 0000000..a8f4a27 --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/Crc.c @@ -0,0 +1,123 @@ +/* --------------------------------------------------------------------------- + * Crc.c - v0.1 (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Jan 31, 2008, FSc + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "Crc.h" + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ +const UINT16 CRC_table[256] = +{ + 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7, + 0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF, + 0x1231, 0x0210, 0x3273, 0x2252, 0x52B5, 0x4294, 0x72F7, 0x62D6, + 0x9339, 0x8318, 0xB37B, 0xA35A, 0xD3BD, 0xC39C, 0xF3FF, 0xE3DE, + 0x2462, 0x3443, 0x0420, 0x1401, 0x64E6, 0x74C7, 0x44A4, 0x5485, + 0xA56A, 0xB54B, 0x8528, 0x9509, 0xE5EE, 0xF5CF, 0xC5AC, 0xD58D, + 0x3653, 0x2672, 0x1611, 0x0630, 0x76D7, 0x66F6, 0x5695, 0x46B4, + 0xB75B, 0xA77A, 0x9719, 0x8738, 0xF7DF, 0xE7FE, 0xD79D, 0xC7BC, + 0x48C4, 0x58E5, 0x6886, 0x78A7, 0x0840, 0x1861, 0x2802, 0x3823, + 0xC9CC, 0xD9ED, 0xE98E, 0xF9AF, 0x8948, 0x9969, 0xA90A, 0xB92B, + 0x5AF5, 0x4AD4, 0x7AB7, 0x6A96, 0x1A71, 0x0A50, 0x3A33, 0x2A12, + 0xDBFD, 0xCBDC, 0xFBBF, 0xEB9E, 0x9B79, 0x8B58, 0xBB3B, 0xAB1A, + 0x6CA6, 0x7C87, 0x4CE4, 0x5CC5, 0x2C22, 0x3C03, 0x0C60, 0x1C41, + 0xEDAE, 0xFD8F, 0xCDEC, 0xDDCD, 0xAD2A, 0xBD0B, 0x8D68, 0x9D49, + 0x7E97, 0x6EB6, 0x5ED5, 0x4EF4, 0x3E13, 0x2E32, 0x1E51, 0x0E70, + 0xFF9F, 0xEFBE, 0xDFDD, 0xCFFC, 0xBF1B, 0xAF3A, 0x9F59, 0x8F78, + 0x9188, 0x81A9, 0xB1CA, 0xA1EB, 0xD10C, 0xC12D, 0xF14E, 0xE16F, + 0x1080, 0x00A1, 0x30C2, 0x20E3, 0x5004, 0x4025, 0x7046, 0x6067, + 0x83B9, 0x9398, 0xA3FB, 0xB3DA, 0xC33D, 0xD31C, 0xE37F, 0xF35E, + 0x02B1, 0x1290, 0x22F3, 0x32D2, 0x4235, 0x5214, 0x6277, 0x7256, + 0xB5EA, 0xA5CB, 0x95A8, 0x8589, 0xF56E, 0xE54F, 0xD52C, 0xC50D, + 0x34E2, 0x24C3, 0x14A0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405, + 0xA7DB, 0xB7FA, 0x8799, 0x97B8, 0xE75F, 0xF77E, 0xC71D, 0xD73C, + 0x26D3, 0x36F2, 0x0691, 0x16B0, 0x6657, 0x7676, 0x4615, 0x5634, + 0xD94C, 0xC96D, 0xF90E, 0xE92F, 0x99C8, 0x89E9, 0xB98A, 0xA9AB, + 0x5844, 0x4865, 0x7806, 0x6827, 0x18C0, 0x08E1, 0x3882, 0x28A3, + 0xCB7D, 0xDB5C, 0xEB3F, 0xFB1E, 0x8BF9, 0x9BD8, 0xABBB, 0xBB9A, + 0x4A75, 0x5A54, 0x6A37, 0x7A16, 0x0AF1, 0x1AD0, 0x2AB3, 0x3A92, + 0xFD2E, 0xED0F, 0xDD6C, 0xCD4D, 0xBDAA, 0xAD8B, 0x9DE8, 0x8DC9, + 0x7C26, 0x6C07, 0x5C64, 0x4C45, 0x3CA2, 0x2C83, 0x1CE0, 0x0CC1, + 0xEF1F, 0xFF3E, 0xCF5D, 0xDF7C, 0xAF9B, 0xBFBA, 0x8FD9, 0x9FF8, + 0x6E17, 0x7E36, 0x4E55, 0x5E74, 0x2E93, 0x3EB2, 0x0ED1, 0x1EF0 +}; + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ + +/*! +* \brief Calculate 16 bit CRC +* +* a function to calculate an serial 16 bit CRC +* according to the CCITT V.024 standard +* To short down the calculation time of the serial CRC +* a hash table is used. +* This CRC is a fast (with hash table) and good CRC for +* data transfer and integrity test of data storage. It can effectively +* can detect errors by data transfer. 16 Bit is good for data blocks from +* 0 - 4 KByte with a residual risk for non detection of 10E-8 per transfer. +* (Multiply this with the error factor of the transmit line) +* +* The polynoom of CRC-16-CCIT = x^16 + x^12 + x^5 + 1 +* +* \param data Build the crc from this data block +* \param length Length of the data block +* \param feed Initial CRC value (take 0 by default) +*/ +UINT16 crcCalc(UINT8 * data, UINT32 length, UINT16 feed) +{ + unsigned short crc = feed; + unsigned char index; + unsigned int count; + + for(count=0; count> 8); + crc = crc & 0x00FF; + crc = (crc << 8); + crc &= 0xFF00; + crc = crc ^ CRC_table[index] ^ (*data & 0x00FF); + data++; + } + + return crc; +} + diff --git a/Quantum Controller/SW/testapplication-0.0.1/Crc.h b/Quantum Controller/SW/testapplication-0.0.1/Crc.h new file mode 100644 index 0000000..0eaa135 --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/Crc.h @@ -0,0 +1,59 @@ +/* --------------------------------------------------------------------------- + * Crc.h - v0.1 (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Jan 31, 2008, FSc + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef __CRC_H__ +#define __CRC_H__ +/** \file Crc.h + \brief +*/ + +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ +#include "BpPort.h" + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ + +UINT16 crcCalc(UINT8 * pData, UINT32 length, UINT16 feed); + +#endif /* __CRC_H__ */ + diff --git a/Quantum Controller/SW/testapplication-0.0.1/EEPROM_test.c b/Quantum Controller/SW/testapplication-0.0.1/EEPROM_test.c new file mode 100644 index 0000000..98ea98d --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/EEPROM_test.c @@ -0,0 +1 @@ +/* --------------------------------------------------------------------------- * EEPROM_test.c (c) 2008 Micro-key bv * --------------------------------------------------------------------------- * Micro-key bv * Industrieweg 28, 9804 TG Noordhorn * Postbus 92, 9800 AB Zuidhorn * The Netherlands * Tel: +31 594 503020 * Fax: +31 594 505825 * Email: support@microkey.nl * Web: www.microkey.nl * --------------------------------------------------------------------------- * Description: Test file for the EEPROM * --------------------------------------------------------------------------- * Version(s): 0.1, Dez 11, 2008, MMi * Creation. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * System include files * --------------------------------------------------------------------------- */ #include /* --------------------------------------------------------------------------- * Application include files * --------------------------------------------------------------------------- */ #include "EEPROM_test.h" /* --------------------------------------------------------------------------- * Local constant and macro definitions * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Global variable definitions * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Local variable definitions * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Local function definitions * --------------------------------------------------------------------------- */ void eeprom_test_execute (void) { printf ("THIS IS THE EEPROM TEST SEQUENCE"); } \ No newline at end of file diff --git a/Quantum Controller/SW/testapplication-0.0.1/EEPROM_test.h b/Quantum Controller/SW/testapplication-0.0.1/EEPROM_test.h new file mode 100644 index 0000000..5528323 --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/EEPROM_test.h @@ -0,0 +1 @@ +/* --------------------------------------------------------------------------- * EEPROM_test.h (c) 2008 Micro-key bv * --------------------------------------------------------------------------- * Micro-key bv * Industrieweg 28, 9804 TG Noordhorn * Postbus 92, 9800 AB Zuidhorn * The Netherlands * Tel: +31 594 503020 * Fax: +31 594 505825 * Email: support@microkey.nl * Web: www.microkey.nl * --------------------------------------------------------------------------- * Description: * --------------------------------------------------------------------------- * Version(s): 0.1, Dez 11, 2008, MMi * Creation. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * System include files. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Application include files. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Constant and macro definitions. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Type definitions. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Variable declarations. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Function declarations. * --------------------------------------------------------------------------- */ void eeprom_test_execute (void); \ No newline at end of file diff --git a/Quantum Controller/SW/testapplication-0.0.1/ElecStatusCache.c b/Quantum Controller/SW/testapplication-0.0.1/ElecStatusCache.c new file mode 100644 index 0000000..4645992 --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/ElecStatusCache.c @@ -0,0 +1,270 @@ +/* --------------------------------------------------------------------------- + * BusProtocol.c - v0.1 (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Jan 28, 2008, FSc + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +#include +#include +#include + +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "BpPort.h" +#include "types.h" +#include "ElecStatusCache.h" + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ +#define MAX_NR_DEVICES 20 +#define CACHE_NOT_USED 0xFF + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ + + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ +static UINT16 *bpecAdcReadCache[MAX_NR_DEVICES]; +static UINT8 bpecAdcReadCacheSize[MAX_NR_DEVICES]; +static UINT16 *bpecDacReadBackCache[MAX_NR_DEVICES]; +static UINT8 bpecDacReadBackCacheSize[MAX_NR_DEVICES]; +static BOOLEAN *bpecDioReadCache[MAX_NR_DEVICES]; +static UINT8 bpecDioReadCacheSize[MAX_NR_DEVICES]; +static BOOLEAN *bpecDioReadBackCache[MAX_NR_DEVICES]; +static UINT8 bpecDioReadBackCacheSize[MAX_NR_DEVICES]; +static t_bpec_write_callback bpecWriteCallback; +static int bpecBusProtocolHandle; + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ + +void bpecInit() +{ + int i; + + bpecWriteCallback = NULL; + bpecBusProtocolHandle = -1; + + // Empty the administration + for (i = 0; i < MAX_NR_DEVICES; i++) + { + bpecAdcReadCache[i] = NULL; + bpecAdcReadCacheSize[i] = CACHE_NOT_USED; + bpecDacReadBackCache[i] = NULL; + bpecDacReadBackCacheSize[i] = CACHE_NOT_USED; + bpecDioReadCache[i] = NULL; + bpecDioReadCacheSize[i] = CACHE_NOT_USED; + bpecDioReadBackCache[i] = NULL; + bpecDioReadBackCacheSize[i] = CACHE_NOT_USED; + } +} + +void bpecAttachWriteCallback(int busProtocolHandle, t_bpec_write_callback callback) +{ + bpecBusProtocolHandle = busProtocolHandle; + bpecWriteCallback = callback; +} + +void bpecDetachWriteCallback() +{ + bpecBusProtocolHandle = -1; + bpecWriteCallback = NULL; +} + +void bpecWriteDacValue( UINT8 device, UINT8 channel, UINT16 dacValue ) +{ + if (bpecWriteCallback != NULL) + { + bpecWriteCallback( bpecBusProtocolHandle, FALSE, device, channel, dacValue ); + } +} + +void bpecWriteDioValue( UINT8 device, UINT8 channel, BOOLEAN doValue ) +{ + if (bpecWriteCallback != NULL) + { + bpecWriteCallback( bpecBusProtocolHandle, TRUE, device, channel, (UINT16)doValue ); + } +} + +void bpecSetAdcReadCache( UINT8 device, UINT16 adcValues[], UINT8 nrOfAdcValues) +{ + static int NrOfAllocs = 0; + if (bpecAdcReadCacheSize[device] != nrOfAdcValues) + { + if (bpecAdcReadCacheSize[device] == CACHE_NOT_USED) + { + NrOfAllocs++; + bpecAdcReadCache[device] = pvPortMalloc( nrOfAdcValues * sizeof(UINT16) ); + if (bpecAdcReadCache[device] != NULL) + { + bpecAdcReadCacheSize[device] = nrOfAdcValues; + memcpy(bpecAdcReadCache[device], adcValues, nrOfAdcValues * sizeof(UINT16)); + } /* else Failure */ + } + /* else Failure */ + } + else + { + memcpy(bpecAdcReadCache[device], adcValues, nrOfAdcValues * sizeof(UINT16)); + } +} + +void bpecSetDioReadCache( UINT8 device, BOOLEAN dioValues[], UINT8 nrOfDioValues) +{ + if (bpecDioReadCacheSize[device] != nrOfDioValues) + { + if (bpecDioReadCacheSize[device] == CACHE_NOT_USED) + { + bpecDioReadCache[device] = pvPortMalloc( nrOfDioValues * sizeof(BOOLEAN) ); + if (bpecDioReadCache[device] != NULL) + { + bpecDioReadCacheSize[device] = nrOfDioValues; + memcpy(bpecDioReadCache[device], dioValues, nrOfDioValues * sizeof(BOOLEAN)); + } /* else Failure */ + } + /* else Failure */ + } + else + { + memcpy(bpecDioReadCache[device], dioValues, nrOfDioValues * sizeof(BOOLEAN)); + } +} + +void bpecSetDioReadBackCache( UINT8 device, BOOLEAN dioValues[], UINT8 nrOfDioValues) +{ + static int NrOfWritings = 0; + static int LastSetDevice = 0; + static int LastSetNrOfDioValues = 0; + NrOfWritings++; + LastSetDevice = device; + LastSetNrOfDioValues = nrOfDioValues; + + if (bpecDioReadBackCacheSize[device] != nrOfDioValues) + { + if (bpecDioReadBackCacheSize[device] == CACHE_NOT_USED) + { + bpecDioReadBackCache[device] = pvPortMalloc( nrOfDioValues * sizeof(BOOLEAN) ); + if (bpecDioReadBackCache[device] != NULL) + { + bpecDioReadBackCacheSize[device] = nrOfDioValues; + memcpy(bpecDioReadBackCache[device], dioValues, nrOfDioValues * sizeof(BOOLEAN)); + } /* else Failure */ + } + /* else Failure */ + } + else + { + memcpy(bpecDioReadBackCache[device], dioValues, nrOfDioValues * sizeof(BOOLEAN)); + } + +} + +void bpecSetDacReadBackCache( UINT8 device, UINT16 dacValues[], UINT8 nrOfDacValues) +{ + if (bpecDacReadBackCacheSize[device] != nrOfDacValues) + { + if (bpecDacReadBackCacheSize[device] == CACHE_NOT_USED) + { + bpecDacReadBackCache[device] = pvPortMalloc( nrOfDacValues * sizeof(UINT16) ); + if (bpecDacReadBackCache[device] != NULL) + { + bpecDacReadBackCacheSize[device] = nrOfDacValues; + memcpy(bpecDacReadBackCache[device], dacValues, nrOfDacValues * sizeof(UINT16)); + } /* else Failure */ + } + /* else Failure */ + } + else + { + memcpy(bpecDacReadBackCache[device], dacValues, nrOfDacValues * sizeof(UINT16)); + } +} + +UINT16 bpecAdcRead( UINT8 device, UINT8 channel ) +{ + UINT16 result = 0; + + if (bpecAdcReadCacheSize[device] != CACHE_NOT_USED) + { + if (channel < bpecAdcReadCacheSize[device]) + { + result = (bpecAdcReadCache[device])[channel]; + } + } + + return result; +} + +BOOLEAN bpecDioRead( UINT8 device, UINT8 channel ) +{ + BOOLEAN result = FALSE; + + if (bpecDioReadCacheSize[device] != CACHE_NOT_USED) + { + if (channel < bpecDioReadCacheSize[device]) + { + result = (bpecDioReadCache[device])[channel]; + } + } + + return result; +} + +BOOLEAN bpecDioReadBack( UINT8 device, UINT8 channel ) +{ + BOOLEAN result = FALSE; + + if (bpecDioReadBackCacheSize[device] != CACHE_NOT_USED) + { + if (channel < bpecDioReadBackCacheSize[device]) + { + result = (bpecDioReadBackCache[device])[channel]; + } + } + + return result; +} + +UINT16 bpecDacReadBack( UINT8 device, UINT8 channel ) +{ + UINT16 result = 0; + + if (bpecDacReadBackCacheSize[device] != CACHE_NOT_USED) + { + if (channel < bpecDacReadBackCacheSize[device]) + { + result = (bpecDacReadBackCache[device])[channel]; + } + } + + return result; +} diff --git a/Quantum Controller/SW/testapplication-0.0.1/ElecStatusCache.h b/Quantum Controller/SW/testapplication-0.0.1/ElecStatusCache.h new file mode 100644 index 0000000..65cb24e --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/ElecStatusCache.h @@ -0,0 +1,71 @@ +/* --------------------------------------------------------------------------- + * ElecStatusCache.h - v0.1 (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: Stores all electronic status of other IO-controllers + * --------------------------------------------------------------------------- + * Version(s): 0.1, Jan 29, 2008, FSc + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef __ELECSTATUSCACHE_H__ +#define __ELECSTATUSCACHE_H__ +/** \file ElecStatusCache.h + \brief +*/ + +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ +//#include "BpMessageFormat.h" + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ +typedef void (*t_bpec_write_callback)( int handle, BOOLEAN isDigital, UINT8 device, UINT8 channel, UINT16 value ); + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ + +void bpecInit(); +void bpecAttachWriteCallback(int busProtocolHandle, t_bpec_write_callback callback); +void bpecDetachWriteCallback(); +void bpecWriteDacValue( UINT8 device, UINT8 channel, UINT16 dacValue ); +void bpecWriteDioValue( UINT8 device, UINT8 channel, BOOLEAN doValue ); +void bpecSetAdcReadCache( UINT8 device, UINT16 adcValues[], UINT8 nrOfAdcValues); +void bpecSetDioReadCache( UINT8 device, BOOLEAN dioValues[], UINT8 nrOfDioValues); +void bpecSetDioReadBackCache( UINT8 device, BOOLEAN dioValues[], UINT8 nrOfDioValues); +void bpecSetDacReadBackCache( UINT8 device, UINT16 dacValues[], UINT8 nrOfDacValues); +UINT16 bpecAdcRead( UINT8 device, UINT8 channel ); +BOOLEAN bpecDioRead( UINT8 device, UINT8 channel ); +BOOLEAN bpecDioReadBack( UINT8 device, UINT8 channel ); +UINT16 bpecDacReadBack( UINT8 device, UINT8 channel ); + +#endif /* __ELECSTATUSCACHE_H__ */ diff --git a/Quantum Controller/SW/testapplication-0.0.1/INSTALL b/Quantum Controller/SW/testapplication-0.0.1/INSTALL new file mode 100644 index 0000000..d3c5b40 --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/INSTALL @@ -0,0 +1,237 @@ +Installation Instructions +************************* + +Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, +2006, 2007 Free Software Foundation, Inc. + +This file is free documentation; the Free Software Foundation gives +unlimited permission to copy, distribute and modify it. + +Basic Installation +================== + +Briefly, the shell commands `./configure; make; make install' should +configure, build, and install this package. The following +more-detailed instructions are generic; see the `README' file for +instructions specific to this package. + + The `configure' shell script attempts to guess correct values for +various system-dependent variables used during compilation. It uses +those values to create a `Makefile' in each directory of the package. +It may also create one or more `.h' files containing system-dependent +definitions. Finally, it creates a shell script `config.status' that +you can run in the future to recreate the current configuration, and a +file `config.log' containing compiler output (useful mainly for +debugging `configure'). + + It can also use an optional file (typically called `config.cache' +and enabled with `--cache-file=config.cache' or simply `-C') that saves +the results of its tests to speed up reconfiguring. Caching is +disabled by default to prevent problems with accidental use of stale +cache files. + + If you need to do unusual things to compile the package, please try +to figure out how `configure' could check whether to do them, and mail +diffs or instructions to the address given in the `README' so they can +be considered for the next release. If you are using the cache, and at +some point `config.cache' contains results you don't want to keep, you +may remove or edit it. + + The file `configure.ac' (or `configure.in') is used to create +`configure' by a program called `autoconf'. You need `configure.ac' if +you want to change it or regenerate `configure' using a newer version +of `autoconf'. + +The simplest way to compile this package is: + + 1. `cd' to the directory containing the package's source code and type + `./configure' to configure the package for your system. + + Running `configure' might take a while. While running, it prints + some messages telling which features it is checking for. + + 2. Type `make' to compile the package. + + 3. Optionally, type `make check' to run any self-tests that come with + the package. + + 4. Type `make install' to install the programs and any data files and + documentation. + + 5. You can remove the program binaries and object files from the + source code directory by typing `make clean'. To also remove the + files that `configure' created (so you can compile the package for + a different kind of computer), type `make distclean'. There is + also a `make maintainer-clean' target, but that is intended mainly + for the package's developers. If you use it, you may have to get + all sorts of other programs in order to regenerate files that came + with the distribution. + + 6. Often, you can also type `make uninstall' to remove the installed + files again. + +Compilers and Options +===================== + +Some systems require unusual options for compilation or linking that the +`configure' script does not know about. Run `./configure --help' for +details on some of the pertinent environment variables. + + You can give `configure' initial values for configuration parameters +by setting variables in the command line or in the environment. Here +is an example: + + ./configure CC=c99 CFLAGS=-g LIBS=-lposix + + *Note Defining Variables::, for more details. + +Compiling For Multiple Architectures +==================================== + +You can compile the package for more than one kind of computer at the +same time, by placing the object files for each architecture in their +own directory. To do this, you can use GNU `make'. `cd' to the +directory where you want the object files and executables to go and run +the `configure' script. `configure' automatically checks for the +source code in the directory that `configure' is in and in `..'. + + With a non-GNU `make', it is safer to compile the package for one +architecture at a time in the source code directory. After you have +installed the package for one architecture, use `make distclean' before +reconfiguring for another architecture. + +Installation Names +================== + +By default, `make install' installs the package's commands under +`/usr/local/bin', include files under `/usr/local/include', etc. You +can specify an installation prefix other than `/usr/local' by giving +`configure' the option `--prefix=PREFIX'. + + You can specify separate installation prefixes for +architecture-specific files and architecture-independent files. If you +pass the option `--exec-prefix=PREFIX' to `configure', the package uses +PREFIX as the prefix for installing programs and libraries. +Documentation and other data files still use the regular prefix. + + In addition, if you use an unusual directory layout you can give +options like `--bindir=DIR' to specify different values for particular +kinds of files. Run `configure --help' for a list of the directories +you can set and what kinds of files go in them. + + If the package supports it, you can cause programs to be installed +with an extra prefix or suffix on their names by giving `configure' the +option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. + +Optional Features +================= + +Some packages pay attention to `--enable-FEATURE' options to +`configure', where FEATURE indicates an optional part of the package. +They may also pay attention to `--with-PACKAGE' options, where PACKAGE +is something like `gnu-as' or `x' (for the X Window System). The +`README' should mention any `--enable-' and `--with-' options that the +package recognizes. + + For packages that use the X Window System, `configure' can usually +find the X include and library files automatically, but if it doesn't, +you can use the `configure' options `--x-includes=DIR' and +`--x-libraries=DIR' to specify their locations. + +Specifying the System Type +========================== + +There may be some features `configure' cannot figure out automatically, +but needs to determine by the type of machine the package will run on. +Usually, assuming the package is built to be run on the _same_ +architectures, `configure' can figure that out, but if it prints a +message saying it cannot guess the machine type, give it the +`--build=TYPE' option. TYPE can either be a short name for the system +type, such as `sun4', or a canonical name which has the form: + + CPU-COMPANY-SYSTEM + +where SYSTEM can have one of these forms: + + OS KERNEL-OS + + See the file `config.sub' for the possible values of each field. If +`config.sub' isn't included in this package, then this package doesn't +need to know the machine type. + + If you are _building_ compiler tools for cross-compiling, you should +use the option `--target=TYPE' to select the type of system they will +produce code for. + + If you want to _use_ a cross compiler, that generates code for a +platform different from the build platform, you should specify the +"host" platform (i.e., that on which the generated programs will +eventually be run) with `--host=TYPE'. + +Sharing Defaults +================ + +If you want to set default values for `configure' scripts to share, you +can create a site shell script called `config.site' that gives default +values for variables like `CC', `cache_file', and `prefix'. +`configure' looks for `PREFIX/share/config.site' if it exists, then +`PREFIX/etc/config.site' if it exists. Or, you can set the +`CONFIG_SITE' environment variable to the location of the site script. +A warning: not all `configure' scripts look for a site script. + +Defining Variables +================== + +Variables not defined in a site shell script can be set in the +environment passed to `configure'. However, some packages may run +configure again during the build, and the customized values of these +variables may be lost. In order to avoid this problem, you should set +them in the `configure' command line, using `VAR=value'. For example: + + ./configure CC=/usr/local2/bin/gcc + +causes the specified `gcc' to be used as the C compiler (unless it is +overridden in the site shell script). + +Unfortunately, this technique does not work for `CONFIG_SHELL' due to +an Autoconf bug. Until the bug is fixed you can use this workaround: + + CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash + +`configure' Invocation +====================== + +`configure' recognizes the following options to control how it operates. + +`--help' +`-h' + Print a summary of the options to `configure', and exit. + +`--version' +`-V' + Print the version of Autoconf used to generate the `configure' + script, and exit. + +`--cache-file=FILE' + Enable the cache: use and save the results of the tests in FILE, + traditionally `config.cache'. FILE defaults to `/dev/null' to + disable caching. + +`--config-cache' +`-C' + Alias for `--cache-file=config.cache'. + +`--quiet' +`--silent' +`-q' + Do not print messages saying which checks are being made. To + suppress all normal output, redirect it to `/dev/null' (any error + messages will still be shown). + +`--srcdir=DIR' + Look for the package's source code in directory DIR. Usually + `configure' can determine that directory automatically. + +`configure' also accepts some other, not widely useful, options. Run +`configure --help' for more details. + diff --git a/Quantum Controller/SW/testapplication-0.0.1/LED_test.c b/Quantum Controller/SW/testapplication-0.0.1/LED_test.c new file mode 100644 index 0000000..174a497 --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/LED_test.c @@ -0,0 +1 @@ +/* --------------------------------------------------------------------------- * LED_test.c (c) 2008 Micro-key bv * --------------------------------------------------------------------------- * Micro-key bv * Industrieweg 28, 9804 TG Noordhorn * Postbus 92, 9800 AB Zuidhorn * The Netherlands * Tel: +31 594 503020 * Fax: +31 594 505825 * Email: support@microkey.nl * Web: www.microkey.nl * --------------------------------------------------------------------------- * Description: * --------------------------------------------------------------------------- * Version(s): 0.1, Dez 11, 2008, MMi * Creation. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * System include files * --------------------------------------------------------------------------- */ #include /* --------------------------------------------------------------------------- * Application include files * --------------------------------------------------------------------------- */ #include "LED_test.h" /* --------------------------------------------------------------------------- * Local constant and macro definitions * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Global variable definitions * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Local variable definitions * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Local function definitions * --------------------------------------------------------------------------- */ void led_test_execute (void) { printf ("THIS IS THE LED TEST SEQUENCE"); } \ No newline at end of file diff --git a/Quantum Controller/SW/testapplication-0.0.1/LED_test.h b/Quantum Controller/SW/testapplication-0.0.1/LED_test.h new file mode 100644 index 0000000..09ded59 --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/LED_test.h @@ -0,0 +1 @@ +/* --------------------------------------------------------------------------- * LED_test.h (c) 2008 Micro-key bv * --------------------------------------------------------------------------- * Micro-key bv * Industrieweg 28, 9804 TG Noordhorn * Postbus 92, 9800 AB Zuidhorn * The Netherlands * Tel: +31 594 503020 * Fax: +31 594 505825 * Email: support@microkey.nl * Web: www.microkey.nl * --------------------------------------------------------------------------- * Description: * --------------------------------------------------------------------------- * Version(s): 0.1, Dez 11, 2008, MMi * Creation. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * System include files. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Application include files. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Constant and macro definitions. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Type definitions. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Variable declarations. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Function declarations. * --------------------------------------------------------------------------- */ void led_test_execute (void); \ No newline at end of file diff --git a/Quantum Controller/SW/testapplication-0.0.1/Makefile b/Quantum Controller/SW/testapplication-0.0.1/Makefile new file mode 100644 index 0000000..9fb7f94 --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/Makefile @@ -0,0 +1,596 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# Makefile. Generated from Makefile.in by configure. + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + + + + +pkgdatadir = $(datadir)/cregpiodae +pkglibdir = $(libdir)/cregpiodae +pkgincludedir = $(includedir)/cregpiodae +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +bin_PROGRAMS = testapp$(EXEEXT) +subdir = . +DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in $(top_srcdir)/configure AUTHORS COPYING \ + ChangeLog INSTALL NEWS depcomp install-sh missing +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ + configure.lineno config.status.lineno +mkinstalldirs = $(install_sh) -d +CONFIG_CLEAN_FILES = +am__installdirs = "$(DESTDIR)$(bindir)" +binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) +PROGRAMS = $(bin_PROGRAMS) +am_testapp_OBJECTS = analogue_test.$(OBJEXT) BpMessageFormat.$(OBJEXT) \ + BpPort.$(OBJEXT) bus.$(OBJEXT) BusProtocol.$(OBJEXT) \ + BUS_test.$(OBJEXT) CAN_test.$(OBJEXT) CF_test.$(OBJEXT) \ + Crc.$(OBJEXT) digital_test.$(OBJEXT) EEPROM_test.$(OBJEXT) \ + ElecStatusCache.$(OBJEXT) ethernet_test.$(OBJEXT) \ + LED_test.$(OBJEXT) main.$(OBJEXT) mem_mod.$(OBJEXT) \ + MessageHandlerQueue.$(OBJEXT) MessageQueue.$(OBJEXT) \ + protocolfunctions.$(OBJEXT) ProtocolThread.$(OBJEXT) \ + relay_test.$(OBJEXT) RemoteProcedureCalls.$(OBJEXT) \ + RpcResults.$(OBJEXT) smc4000io.$(OBJEXT) USB_test.$(OBJEXT) +testapp_OBJECTS = $(am_testapp_OBJECTS) +testapp_DEPENDENCIES = +testapp_LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(testapp_LDFLAGS) \ + $(LDFLAGS) -o $@ +DEFAULT_INCLUDES = -I. +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +SOURCES = $(testapp_SOURCES) +DIST_SOURCES = $(testapp_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +distdir = $(PACKAGE)-$(VERSION) +top_distdir = $(distdir) +am__remove_distdir = \ + { test ! -d $(distdir) \ + || { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \ + && rm -fr $(distdir); }; } +DIST_ARCHIVES = $(distdir).tar.gz +GZIP_ENV = --best +distuninstallcheck_listfiles = find . -type f -print +distcleancheck_listfiles = find . -type f -print +ACLOCAL = ${SHELL} /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/testapplication-0.0.1/missing --run aclocal-1.10 +AMTAR = ${SHELL} /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/testapplication-0.0.1/missing --run tar +AUTOCONF = ${SHELL} /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/testapplication-0.0.1/missing --run autoconf +AUTOHEADER = ${SHELL} /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/testapplication-0.0.1/missing --run autoheader +AUTOMAKE = ${SHELL} /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/testapplication-0.0.1/missing --run automake-1.10 +AWK = gawk +CC = /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-gcc -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e +CCDEPMODE = depmode=gcc3 +CFLAGS = -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e +CPP = /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-cpp -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e +CPPFLAGS = +CYGPATH_W = echo +DEFS = -DPACKAGE_NAME=\"creGpioDae\" -DPACKAGE_TARNAME=\"cregpiodae\" -DPACKAGE_VERSION=\"0.0.1\" -DPACKAGE_STRING=\"creGpioDae\ 0.0.1\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE=\"cregpiodae\" -DVERSION=\"0.0.1\" -D_GNU_SOURCE=1 -DHAVE_DIRENT_H=1 -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_MATH_H=1 -DHAVE_STDIO_H=1 -DHAVE_FCNTL_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_LIMITS_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STDDEF_H=1 -DHAVE_STDINT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_STRINGS_H=1 -DHAVE_UNISTD_H=1 +DEPDIR = .deps +ECHO_C = +ECHO_N = -n +ECHO_T = +EGREP = /bin/grep -E +EXEEXT = +GREP = /bin/grep +INSTALL = /usr/bin/install -c +INSTALL_DATA = ${INSTALL} -m 644 +INSTALL_PROGRAM = ${INSTALL} +INSTALL_SCRIPT = ${INSTALL} +INSTALL_STRIP_PROGRAM = $(install_sh) -c -s +LDFLAGS = -L/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/lib -L/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/lib --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ +LIBOBJS = +LIBS = +LTLIBOBJS = +MAKEINFO = ${SHELL} /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/testapplication-0.0.1/missing --run makeinfo +MKDIR_P = /bin/mkdir -p +OBJEXT = o +PACKAGE = cregpiodae +PACKAGE_BUGREPORT = +PACKAGE_NAME = creGpioDae +PACKAGE_STRING = creGpioDae 0.0.1 +PACKAGE_TARNAME = cregpiodae +PACKAGE_VERSION = 0.0.1 +PATH_SEPARATOR = : +SET_MAKE = +SHELL = /bin/bash +STRIP = /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-strip +VERSION = 0.0.1 +abs_builddir = /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/testapplication-0.0.1 +abs_srcdir = /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/testapplication-0.0.1 +abs_top_builddir = /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/testapplication-0.0.1 +abs_top_srcdir = /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/testapplication-0.0.1 +ac_ct_CC = +am__include = include +am__leading_dot = . +am__quote = +am__tar = ${AMTAR} chof - "$$tardir" +am__untar = ${AMTAR} xf - +bindir = ${exec_prefix}/bin +build_alias = x86_64-pc-linux-gnu +builddir = . +datadir = ${datarootdir} +datarootdir = ${prefix}/share +docdir = ${datarootdir}/doc/${PACKAGE_TARNAME} +dvidir = ${docdir} +exec_prefix = ${prefix} +host_alias = powerpc-linux +htmldir = ${docdir} +includedir = ${prefix}/include +infodir = ${datarootdir}/info +install_sh = $(SHELL) /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/testapplication-0.0.1/install-sh +libdir = ${exec_prefix}/lib +libexecdir = ${exec_prefix}/libexec +localedir = ${datarootdir}/locale +localstatedir = ${prefix}/var +mandir = ${datarootdir}/man +mkdir_p = /bin/mkdir -p +oldincludedir = /usr/include +pdfdir = ${docdir} +prefix = /usr +program_transform_name = s,x,x, +psdir = ${docdir} +sbindir = ${exec_prefix}/sbin +sharedstatedir = ${prefix}/com +srcdir = . +sysconfdir = /etc +target_alias = powerpc-linux +top_builddir = . +top_srcdir = . +testapp_SOURCES = \ +analogue_test.c \ +BpMessageFormat.c \ +BpPort.c \ +bus.c \ +BusProtocol.c \ +BUS_test.c \ +CAN_test.c \ +CF_test.c \ +Crc.c \ +digital_test.c \ +EEPROM_test.c \ +ElecStatusCache.c \ +ethernet_test.c \ +LED_test.c \ +main.c \ +mem_mod.c \ +MessageHandlerQueue.c \ +MessageQueue.c \ +protocolfunctions.c \ +ProtocolThread.c \ +relay_test.c \ +RemoteProcedureCalls.c \ +RpcResults.c \ +smc4000io.c \ +USB_test.c + +testapp_LDFLAGS = -static +testapp_LDADD = -L. -lm -lpthread +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .o .obj +am--refresh: + @: +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + echo ' cd $(srcdir) && $(AUTOMAKE) --gnu '; \ + cd $(srcdir) && $(AUTOMAKE) --gnu \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + echo ' $(SHELL) ./config.status'; \ + $(SHELL) ./config.status;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + $(SHELL) ./config.status --recheck + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(srcdir) && $(AUTOCONF) +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + if test -f $$p \ + ; then \ + f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \ + $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \ + else :; fi; \ + done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ + rm -f "$(DESTDIR)$(bindir)/$$f"; \ + done + +clean-binPROGRAMS: + -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) +testapp$(EXEEXT): $(testapp_OBJECTS) $(testapp_DEPENDENCIES) + @rm -f testapp$(EXEEXT) + $(testapp_LINK) $(testapp_OBJECTS) $(testapp_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +include ./$(DEPDIR)/BUS_test.Po +include ./$(DEPDIR)/BpMessageFormat.Po +include ./$(DEPDIR)/BpPort.Po +include ./$(DEPDIR)/BusProtocol.Po +include ./$(DEPDIR)/CAN_test.Po +include ./$(DEPDIR)/CF_test.Po +include ./$(DEPDIR)/Crc.Po +include ./$(DEPDIR)/EEPROM_test.Po +include ./$(DEPDIR)/ElecStatusCache.Po +include ./$(DEPDIR)/LED_test.Po +include ./$(DEPDIR)/MessageHandlerQueue.Po +include ./$(DEPDIR)/MessageQueue.Po +include ./$(DEPDIR)/ProtocolThread.Po +include ./$(DEPDIR)/RemoteProcedureCalls.Po +include ./$(DEPDIR)/RpcResults.Po +include ./$(DEPDIR)/USB_test.Po +include ./$(DEPDIR)/analogue_test.Po +include ./$(DEPDIR)/bus.Po +include ./$(DEPDIR)/digital_test.Po +include ./$(DEPDIR)/ethernet_test.Po +include ./$(DEPDIR)/main.Po +include ./$(DEPDIR)/mem_mod.Po +include ./$(DEPDIR)/protocolfunctions.Po +include ./$(DEPDIR)/relay_test.Po +include ./$(DEPDIR)/smc4000io.Po + +.c.o: + $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< + mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +# source='$<' object='$@' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(COMPILE) -c $< + +.c.obj: + $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` + mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +# source='$<' object='$@' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(COMPILE) -c `$(CYGPATH_W) '$<'` + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + $(am__remove_distdir) + test -d $(distdir) || mkdir $(distdir) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done + -find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \ + ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ + ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ + ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ + || chmod -R a+r $(distdir) +dist-gzip: distdir + tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz + $(am__remove_distdir) + +dist-bzip2: distdir + tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2 + $(am__remove_distdir) + +dist-lzma: distdir + tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma + $(am__remove_distdir) + +dist-tarZ: distdir + tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z + $(am__remove_distdir) + +dist-shar: distdir + shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz + $(am__remove_distdir) + +dist-zip: distdir + -rm -f $(distdir).zip + zip -rq $(distdir).zip $(distdir) + $(am__remove_distdir) + +dist dist-all: distdir + tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz + $(am__remove_distdir) + +# This target untars the dist file and tries a VPATH configuration. Then +# it guarantees that the distribution is self-contained by making another +# tarfile. +distcheck: dist + case '$(DIST_ARCHIVES)' in \ + *.tar.gz*) \ + GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\ + *.tar.bz2*) \ + bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\ + *.tar.lzma*) \ + unlzma -c $(distdir).tar.lzma | $(am__untar) ;;\ + *.tar.Z*) \ + uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ + *.shar.gz*) \ + GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\ + *.zip*) \ + unzip $(distdir).zip ;;\ + esac + chmod -R a-w $(distdir); chmod a+w $(distdir) + mkdir $(distdir)/_build + mkdir $(distdir)/_inst + chmod a-w $(distdir) + dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ + && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ + && cd $(distdir)/_build \ + && ../configure --srcdir=.. --prefix="$$dc_install_base" \ + $(DISTCHECK_CONFIGURE_FLAGS) \ + && $(MAKE) $(AM_MAKEFLAGS) \ + && $(MAKE) $(AM_MAKEFLAGS) dvi \ + && $(MAKE) $(AM_MAKEFLAGS) check \ + && $(MAKE) $(AM_MAKEFLAGS) install \ + && $(MAKE) $(AM_MAKEFLAGS) installcheck \ + && $(MAKE) $(AM_MAKEFLAGS) uninstall \ + && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ + distuninstallcheck \ + && chmod -R a-w "$$dc_install_base" \ + && ({ \ + (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ + distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ + } || { rm -rf "$$dc_destdir"; exit 1; }) \ + && rm -rf "$$dc_destdir" \ + && $(MAKE) $(AM_MAKEFLAGS) dist \ + && rm -rf $(DIST_ARCHIVES) \ + && $(MAKE) $(AM_MAKEFLAGS) distcleancheck + $(am__remove_distdir) + @(echo "$(distdir) archives ready for distribution: "; \ + list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ + sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' +distuninstallcheck: + @cd $(distuninstallcheck_dir) \ + && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \ + || { echo "ERROR: files left after uninstall:" ; \ + if test -n "$(DESTDIR)"; then \ + echo " (check DESTDIR support)"; \ + fi ; \ + $(distuninstallcheck_listfiles) ; \ + exit 1; } >&2 +distcleancheck: distclean + @if test '$(srcdir)' = . ; then \ + echo "ERROR: distcleancheck can only run from a VPATH build" ; \ + exit 1 ; \ + fi + @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ + || { echo "ERROR: files left in build directory after distclean:" ; \ + $(distcleancheck_listfiles) ; \ + exit 1; } >&2 +check-am: all-am +check: check-am +all-am: Makefile $(PROGRAMS) +installdirs: + for dir in "$(DESTDIR)$(bindir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-binPROGRAMS clean-generic mostlyclean-am + +distclean: distclean-am + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-exec-am: install-binPROGRAMS + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -rf $(top_srcdir)/autom4te.cache + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-binPROGRAMS + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am am--refresh check check-am clean \ + clean-binPROGRAMS clean-generic ctags dist dist-all dist-bzip2 \ + dist-gzip dist-lzma dist-shar dist-tarZ dist-zip distcheck \ + distclean distclean-compile distclean-generic distclean-tags \ + distcleancheck distdir distuninstallcheck dvi dvi-am html \ + html-am info info-am install install-am install-binPROGRAMS \ + install-data install-data-am install-dvi install-dvi-am \ + install-exec install-exec-am install-html install-html-am \ + install-info install-info-am install-man install-pdf \ + install-pdf-am install-ps install-ps-am install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ + uninstall-am uninstall-binPROGRAMS + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/Quantum Controller/SW/testapplication-0.0.1/Makefile.am b/Quantum Controller/SW/testapplication-0.0.1/Makefile.am new file mode 100644 index 0000000..d294ced --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/Makefile.am @@ -0,0 +1,34 @@ +bin_PROGRAMS = testapp +testapp_SOURCES = \ +analogue_test.c \ +BpMessageFormat.c \ +BpPort.c \ +bus.c \ +BusProtocol.c \ +BUS_test.c \ +CAN_test.c \ +CF_test.c \ +Crc.c \ +digital_test.c \ +EEPROM_test.c \ +ElecStatusCache.c \ +ethernet_test.c \ +LED_test.c \ +main.c \ +mem_mod.c \ +MessageHandlerQueue.c \ +MessageQueue.c \ +protocolfunctions.c \ +ProtocolThread.c \ +relay_test.c \ +RemoteProcedureCalls.c \ +RpcResults.c \ +smc4000io.c \ +USB_test.c + + +testapp_LDFLAGS = -static +testapp_LDADD = -L. -lm -lpthread + + + diff --git a/Quantum Controller/SW/testapplication-0.0.1/Makefile.in b/Quantum Controller/SW/testapplication-0.0.1/Makefile.in new file mode 100644 index 0000000..620dc13 --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/Makefile.in @@ -0,0 +1,596 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +bin_PROGRAMS = testapp$(EXEEXT) +subdir = . +DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in $(top_srcdir)/configure AUTHORS COPYING \ + ChangeLog INSTALL NEWS depcomp install-sh missing +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ + configure.lineno config.status.lineno +mkinstalldirs = $(install_sh) -d +CONFIG_CLEAN_FILES = +am__installdirs = "$(DESTDIR)$(bindir)" +binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) +PROGRAMS = $(bin_PROGRAMS) +am_testapp_OBJECTS = analogue_test.$(OBJEXT) BpMessageFormat.$(OBJEXT) \ + BpPort.$(OBJEXT) bus.$(OBJEXT) BusProtocol.$(OBJEXT) \ + BUS_test.$(OBJEXT) CAN_test.$(OBJEXT) CF_test.$(OBJEXT) \ + Crc.$(OBJEXT) digital_test.$(OBJEXT) EEPROM_test.$(OBJEXT) \ + ElecStatusCache.$(OBJEXT) ethernet_test.$(OBJEXT) \ + LED_test.$(OBJEXT) main.$(OBJEXT) mem_mod.$(OBJEXT) \ + MessageHandlerQueue.$(OBJEXT) MessageQueue.$(OBJEXT) \ + protocolfunctions.$(OBJEXT) ProtocolThread.$(OBJEXT) \ + relay_test.$(OBJEXT) RemoteProcedureCalls.$(OBJEXT) \ + RpcResults.$(OBJEXT) smc4000io.$(OBJEXT) USB_test.$(OBJEXT) +testapp_OBJECTS = $(am_testapp_OBJECTS) +testapp_DEPENDENCIES = +testapp_LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(testapp_LDFLAGS) \ + $(LDFLAGS) -o $@ +DEFAULT_INCLUDES = -I.@am__isrc@ +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +SOURCES = $(testapp_SOURCES) +DIST_SOURCES = $(testapp_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +distdir = $(PACKAGE)-$(VERSION) +top_distdir = $(distdir) +am__remove_distdir = \ + { test ! -d $(distdir) \ + || { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \ + && rm -fr $(distdir); }; } +DIST_ARCHIVES = $(distdir).tar.gz +GZIP_ENV = --best +distuninstallcheck_listfiles = find . -type f -print +distcleancheck_listfiles = find . -type f -print +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build_alias = @build_alias@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host_alias = @host_alias@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +testapp_SOURCES = \ +analogue_test.c \ +BpMessageFormat.c \ +BpPort.c \ +bus.c \ +BusProtocol.c \ +BUS_test.c \ +CAN_test.c \ +CF_test.c \ +Crc.c \ +digital_test.c \ +EEPROM_test.c \ +ElecStatusCache.c \ +ethernet_test.c \ +LED_test.c \ +main.c \ +mem_mod.c \ +MessageHandlerQueue.c \ +MessageQueue.c \ +protocolfunctions.c \ +ProtocolThread.c \ +relay_test.c \ +RemoteProcedureCalls.c \ +RpcResults.c \ +smc4000io.c \ +USB_test.c + +testapp_LDFLAGS = -static +testapp_LDADD = -L. -lm -lpthread +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .o .obj +am--refresh: + @: +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + echo ' cd $(srcdir) && $(AUTOMAKE) --gnu '; \ + cd $(srcdir) && $(AUTOMAKE) --gnu \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + echo ' $(SHELL) ./config.status'; \ + $(SHELL) ./config.status;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + $(SHELL) ./config.status --recheck + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(srcdir) && $(AUTOCONF) +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + if test -f $$p \ + ; then \ + f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \ + $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \ + else :; fi; \ + done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ + rm -f "$(DESTDIR)$(bindir)/$$f"; \ + done + +clean-binPROGRAMS: + -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) +testapp$(EXEEXT): $(testapp_OBJECTS) $(testapp_DEPENDENCIES) + @rm -f testapp$(EXEEXT) + $(testapp_LINK) $(testapp_OBJECTS) $(testapp_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BUS_test.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BpMessageFormat.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BpPort.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BusProtocol.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CAN_test.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CF_test.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Crc.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/EEPROM_test.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ElecStatusCache.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LED_test.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MessageHandlerQueue.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MessageQueue.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ProtocolThread.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RemoteProcedureCalls.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RpcResults.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/USB_test.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/analogue_test.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bus.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/digital_test.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ethernet_test.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mem_mod.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/protocolfunctions.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/relay_test.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/smc4000io.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + $(am__remove_distdir) + test -d $(distdir) || mkdir $(distdir) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done + -find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \ + ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ + ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ + ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ + || chmod -R a+r $(distdir) +dist-gzip: distdir + tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz + $(am__remove_distdir) + +dist-bzip2: distdir + tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2 + $(am__remove_distdir) + +dist-lzma: distdir + tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma + $(am__remove_distdir) + +dist-tarZ: distdir + tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z + $(am__remove_distdir) + +dist-shar: distdir + shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz + $(am__remove_distdir) + +dist-zip: distdir + -rm -f $(distdir).zip + zip -rq $(distdir).zip $(distdir) + $(am__remove_distdir) + +dist dist-all: distdir + tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz + $(am__remove_distdir) + +# This target untars the dist file and tries a VPATH configuration. Then +# it guarantees that the distribution is self-contained by making another +# tarfile. +distcheck: dist + case '$(DIST_ARCHIVES)' in \ + *.tar.gz*) \ + GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\ + *.tar.bz2*) \ + bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\ + *.tar.lzma*) \ + unlzma -c $(distdir).tar.lzma | $(am__untar) ;;\ + *.tar.Z*) \ + uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ + *.shar.gz*) \ + GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\ + *.zip*) \ + unzip $(distdir).zip ;;\ + esac + chmod -R a-w $(distdir); chmod a+w $(distdir) + mkdir $(distdir)/_build + mkdir $(distdir)/_inst + chmod a-w $(distdir) + dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ + && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ + && cd $(distdir)/_build \ + && ../configure --srcdir=.. --prefix="$$dc_install_base" \ + $(DISTCHECK_CONFIGURE_FLAGS) \ + && $(MAKE) $(AM_MAKEFLAGS) \ + && $(MAKE) $(AM_MAKEFLAGS) dvi \ + && $(MAKE) $(AM_MAKEFLAGS) check \ + && $(MAKE) $(AM_MAKEFLAGS) install \ + && $(MAKE) $(AM_MAKEFLAGS) installcheck \ + && $(MAKE) $(AM_MAKEFLAGS) uninstall \ + && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ + distuninstallcheck \ + && chmod -R a-w "$$dc_install_base" \ + && ({ \ + (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ + distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ + } || { rm -rf "$$dc_destdir"; exit 1; }) \ + && rm -rf "$$dc_destdir" \ + && $(MAKE) $(AM_MAKEFLAGS) dist \ + && rm -rf $(DIST_ARCHIVES) \ + && $(MAKE) $(AM_MAKEFLAGS) distcleancheck + $(am__remove_distdir) + @(echo "$(distdir) archives ready for distribution: "; \ + list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ + sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' +distuninstallcheck: + @cd $(distuninstallcheck_dir) \ + && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \ + || { echo "ERROR: files left after uninstall:" ; \ + if test -n "$(DESTDIR)"; then \ + echo " (check DESTDIR support)"; \ + fi ; \ + $(distuninstallcheck_listfiles) ; \ + exit 1; } >&2 +distcleancheck: distclean + @if test '$(srcdir)' = . ; then \ + echo "ERROR: distcleancheck can only run from a VPATH build" ; \ + exit 1 ; \ + fi + @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ + || { echo "ERROR: files left in build directory after distclean:" ; \ + $(distcleancheck_listfiles) ; \ + exit 1; } >&2 +check-am: all-am +check: check-am +all-am: Makefile $(PROGRAMS) +installdirs: + for dir in "$(DESTDIR)$(bindir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-binPROGRAMS clean-generic mostlyclean-am + +distclean: distclean-am + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-exec-am: install-binPROGRAMS + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -rf $(top_srcdir)/autom4te.cache + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-binPROGRAMS + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am am--refresh check check-am clean \ + clean-binPROGRAMS clean-generic ctags dist dist-all dist-bzip2 \ + dist-gzip dist-lzma dist-shar dist-tarZ dist-zip distcheck \ + distclean distclean-compile distclean-generic distclean-tags \ + distcleancheck distdir distuninstallcheck dvi dvi-am html \ + html-am info info-am install install-am install-binPROGRAMS \ + install-data install-data-am install-dvi install-dvi-am \ + install-exec install-exec-am install-html install-html-am \ + install-info install-info-am install-man install-pdf \ + install-pdf-am install-ps install-ps-am install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ + uninstall-am uninstall-binPROGRAMS + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/Quantum Controller/SW/testapplication-0.0.1/MessageHandlerQueue.c b/Quantum Controller/SW/testapplication-0.0.1/MessageHandlerQueue.c new file mode 100644 index 0000000..4ecbd66 --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/MessageHandlerQueue.c @@ -0,0 +1,208 @@ +/* --------------------------------------------------------------------------- + * MessageHandlerQueue.c - v0.1 (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Jan 30, 2008, FSc + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +#include + +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "BpPort.h" +#include "MessageHandlerQueue.h" + + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ + +typedef struct t_mhq_ENTITY +{ + UINT8 messageId; + t_bp_messagehandler messageHandler; + int ownHandle; + struct t_mhq_ENTITY *next; + struct t_mhq_ENTITY *previous; +} t_mhq_entity; + +typedef struct t_mhq_ADMIN +{ + struct t_mhq_ENTITY *head; + struct t_mhq_ENTITY *tail; + pthread_mutex_t mutex; +} t_mhq_admin; + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ +static t_mhq_entity *lookupMhqEntry(int handle, UINT8 messageId); + + +int mhqInit() +{ + t_mhq_admin *newAdmin = (t_mhq_admin *)pvPortMalloc( sizeof(t_mhq_admin) ); + + newAdmin->head = NULL; + + // initialise Mutex + pthread_mutex_init(&(newAdmin->mutex), NULL); + + return (int)newAdmin; +} + +void mhqDeinit(int handle) +{ + t_mhq_entity *iterator = ((t_mhq_admin *)handle)->head; + + while (iterator != NULL) + { + t_mhq_entity *nextItem = iterator->next; + vPortFree( iterator ); + iterator = nextItem; + } + + vPortFree( (t_mhq_admin *)handle ); +} + +void mhqAdd(int handle, UINT8 messageId, t_bp_messagehandler messageHandler, int ownHandle) +{ + t_mhq_admin *theAdmin = (t_mhq_admin *)handle; + t_mhq_entity *newEntry = (t_mhq_entity *)pvPortMalloc( sizeof(t_mhq_entity) ); + + // fill entry + newEntry->messageId = messageId; + newEntry->messageHandler = messageHandler; + newEntry->ownHandle = ownHandle; + newEntry->next = NULL; + newEntry->previous = NULL; + + pthread_mutex_lock(&(theAdmin->mutex)); + { + // Add to linked list + if (theAdmin->head != NULL) + { + theAdmin->tail->next = newEntry; + newEntry->previous = theAdmin->tail; + theAdmin->tail = newEntry; + } + else + { + theAdmin->head = newEntry; + theAdmin->tail = newEntry; + } + } + pthread_mutex_unlock(&(theAdmin->mutex)); +} + +void mhqRemove(int handle, UINT8 messageId, t_bp_messagehandler messageHandler) +{ + t_mhq_entity *entry = lookupMhqEntry(handle, messageId); + t_mhq_admin *theAdmin = (t_mhq_admin *)handle; + + pthread_mutex_lock(&(theAdmin->mutex)); + { + if (entry != NULL) + { + // rebuild linked list + if (entry->next != NULL) + { + entry->next->previous = entry->previous; + } + else + { + theAdmin->tail = entry->previous; + } + + if (entry->previous != NULL) + { + entry->previous->next = entry->next; + } + else + { + theAdmin->head = entry->next; + } + + // remove entry + vPortFree( entry ); + } + } + pthread_mutex_unlock(&(theAdmin->mutex)); +} + +RESULT mhqExecute(int handle, UINT8 messageId, t_bpmsg_message *message) +{ + t_mhq_entity *item = lookupMhqEntry(handle, messageId); + + if (item != NULL) + { + item->messageHandler( message, item->ownHandle ); + + return OK; + } + else + { + return ERROR; + } +} + + +t_mhq_entity *lookupMhqEntry(int handle, UINT8 messageId) +{ + t_mhq_admin *theAdmin = (t_mhq_admin *)handle; + t_mhq_entity *result = NULL; + t_mhq_entity *iterator; + + pthread_mutex_lock(&(theAdmin->mutex)); + { + iterator = theAdmin->head; + while ((result == NULL) && (iterator != NULL)) + { + if (iterator->messageId == messageId) + { + result = iterator; + } + else + { + iterator = iterator->next; + } + } + } + pthread_mutex_unlock(&(theAdmin->mutex)); + + return result; +} + + + + diff --git a/Quantum Controller/SW/testapplication-0.0.1/MessageHandlerQueue.h b/Quantum Controller/SW/testapplication-0.0.1/MessageHandlerQueue.h new file mode 100644 index 0000000..0817a64 --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/MessageHandlerQueue.h @@ -0,0 +1,65 @@ +/* --------------------------------------------------------------------------- + * MessageHandlerQueue.h - v0.1 (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Jan 30, 2008, FSc + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef __MESSAGEHANDLERQUEUE_H__ +#define __MESSAGEHANDLERQUEUE_H__ +/** \file MessageHandlerQueue.h + \brief Contains a list of message handlers +*/ + +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ +#include "BusProtocol.h" +#include "BpMessageFormat.h" + + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ + +int mhqInit(); +void mhqAdd(int handle, UINT8 messageId, t_bp_messagehandler messageHandler, int ownHandle); +void mhqRemove(int handle, UINT8 messageId, t_bp_messagehandler messageHandler); +RESULT mhqExecute(int handle, UINT8 messageId, t_bpmsg_message *message); + + +#endif /* __MESSAGEHANDLERQUEUE_H__ */ + diff --git a/Quantum Controller/SW/testapplication-0.0.1/MessageQueue.c b/Quantum Controller/SW/testapplication-0.0.1/MessageQueue.c new file mode 100644 index 0000000..f5bf243 --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/MessageQueue.c @@ -0,0 +1,127 @@ +/* --------------------------------------------------------------------------- + * MessageQueue.c - v0.1 (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Jan 29, 2008, FSc + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +#include +#include +#include + + +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "BpPort.h" +#include "MessageQueue.h" + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ + + t_mq_messagequeue *mqInit() + { + t_mq_messagequeue *newMessageQueue = (t_mq_messagequeue *)pvPortMalloc( sizeof(t_mq_messagequeue) ); + + newMessageQueue->count = 0; + newMessageQueue->head = 0; + newMessageQueue->tail = 0; + + // initialise Mutex + pthread_mutex_init(&(newMessageQueue->mutex), NULL); + + return newMessageQueue; + } + +RESULT mqAdd( t_mq_messagequeue *queue, t_bpmsg_message *message) +{ + RESULT result = OK; + + pthread_mutex_lock(&(queue->mutex)); + { + if(queue->count >= TX_QUEUE_SIZE) + { + printf("messagequeue full\n"); fflush(stdout); + result = ERROR; + } + else + { + memcpy( &(queue->messages[queue->tail]), message, sizeof(t_bpmsg_message) ); + queue->count++; + queue->tail = (queue->tail + 1) % TX_QUEUE_SIZE; + } + } + pthread_mutex_unlock(&(queue->mutex)); + + return result; +} + +RESULT mqGet( t_mq_messagequeue *queue, t_bpmsg_message *message) +{ + RESULT result = OK; + + pthread_mutex_lock(&(queue->mutex)); + { + if(queue->count > 0) + { + memcpy( message, &(queue->messages[queue->head]), sizeof(t_bpmsg_message) ); + queue->head = (queue->head + 1) % TX_QUEUE_SIZE; + queue->count--; + } + else + { + result = ERROR; + } + } + pthread_mutex_unlock(&(queue->mutex)); + + return result; +} + +BOOLEAN mqEmpty( t_mq_messagequeue *queue ) +{ + UINT8 count; + + pthread_mutex_lock(&(queue->mutex)); + { + count = queue->count; + } + pthread_mutex_unlock(&(queue->mutex)); + + return ( count == 0 ? TRUE : FALSE); +} + diff --git a/Quantum Controller/SW/testapplication-0.0.1/MessageQueue.h b/Quantum Controller/SW/testapplication-0.0.1/MessageQueue.h new file mode 100644 index 0000000..73d374d --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/MessageQueue.h @@ -0,0 +1,73 @@ +/* --------------------------------------------------------------------------- + * MessageQueue.h - v0.1 (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Jan 29, 2008, FSc + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef __MESSAGEQUEUE_H__ +#define __MESSAGEQUEUE_H__ +/** \file MessageQueue.h + \brief +*/ + +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ +#include + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ +#include "BpMessageFormat.h" + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ +#define TX_QUEUE_SIZE (20) + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ +typedef struct t_mq_MESSAGEQUEUE +{ + t_bpmsg_message messages[TX_QUEUE_SIZE]; + UINT8 head; + UINT8 tail; + UINT8 count; + pthread_mutex_t mutex; +} t_mq_messagequeue; + + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ +t_mq_messagequeue *mqInit(); +RESULT mqAdd( t_mq_messagequeue *queue, t_bpmsg_message *message); +RESULT mqGet( t_mq_messagequeue *queue, t_bpmsg_message *message); +BOOLEAN mqEmpty( t_mq_messagequeue *queue ); + + +#endif /* __MESSAGEQUEUE_H__ */ + diff --git a/Quantum Controller/SW/testapplication-0.0.1/NEWS b/Quantum Controller/SW/testapplication-0.0.1/NEWS new file mode 100644 index 0000000..e69de29 diff --git a/Quantum Controller/SW/testapplication-0.0.1/ProtocolThread.c b/Quantum Controller/SW/testapplication-0.0.1/ProtocolThread.c new file mode 100644 index 0000000..55440f9 --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/ProtocolThread.c @@ -0,0 +1,879 @@ +/* --------------------------------------------------------------------------- + * ProtocolThread.c - v0.1 (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Jan 29, 2008, FSc + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +#include +#include +#include + +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "BpPort.h" +#include "BusProtocol.h" +#include "ProtocolThread.h" +#include "bus.h" +#include "MessageQueue.h" +#include "MessageHandlerQueue.h" +#include "BpMessageFormat.h" +#include "Crc.h" +#include "ElecStatusCache.h" +#include "mem_mod.h" + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ +#define TX_QUEUE_SIZE (20) +#define MAX_TX_MESSAGES (12) /**< Maximum number of message to be send in 1 turn */ +#define THREAD_NAME_BUS1 "Bus1Pb" +#define THREAD_NAME_BUS2 "Bus2Pb" +#define MESSAGE_THREAD_NAME_BUS1 "Bus1MsgH" +#define MESSAGE_THREAD_NAME_BUS2 "Bus2MsgH" +#define MAX_NR_CHANNELS (32) +#define MSG_QUEUE_NAME "/BpMsgQueue" + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ +typedef enum +{ + IDLE, + SENDER_ID, + TARGET_ID, + PACKET_NR, + STATUS, + MESSAGE_ID, + PAYLOAD_SIZE, + PAYLOAD, + CRC +} t_bpthread_decodestatus; + + +typedef struct t_BPTHREAD_ADMIN { + t_bus_devices bus; + UINT8 deviceId; + UINT8 highestDeviceId; + int busProtocolHandle; + int messageHandlerHandle; + t_bp_myturn_callback myTurnCallback; + pthread_t threadHandle; + pthread_t threadMessageHandle; + t_mq_messagequeue *messageQueue; + t_mq_messagequeue *messageHandlerQueue; + UINT8 lastReceivedPacketNr; + UINT8 lastReceivedSenderId; + t_bpthread_decodestatus decodeStatus; + t_bpmsg_message rxMessage; + BOOLEAN rxStartByteDetected; + UINT8 rxFillIdx; + UINT16 rxCrc; + UINT16 cyclusTimeout; + UINT32 cyclusEndTick; + UINT16 messageTimeout; + UINT32 messageEndTick; + UINT16 backoffTime; + portTickType *timestampLastRecvMsgDevices; +} t_bpthread_admin; + +extern memman *bpMessagePool; +memman *bpRecvMessagePool; + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ +static void *protocolThread( void *pvParameters ); +static void *messageHandlerThread( void *pvParameters ); +static t_bpmsg_message *decodeByte( t_bpthread_admin *threadAdmin, UINT8 byte ); +static void handleMessage(t_bpthread_admin *threadAdmin, t_bpmsg_message *message); +static void detectMyTurn(t_bpthread_admin *threadAdmin, t_bpmsg_message *message); +static void doMyTurnActions(t_bpthread_admin *threadAdmin); +static void checkTimeouts(t_bpthread_admin *threadAdmin); +static void resetMessageTimeout(t_bpthread_admin *threadAdmin); +static void resetCyclusTimeout(t_bpthread_admin *threadAdmin); +static void sendMessage( t_bus_devices bus, t_bpmsg_message *message ); +static UINT32 calcEndTick( UINT16 timeoutPeriod ); +static BOOLEAN hasTimeoutPast( UINT32 endTick ); +static BOOLEAN ignoreFirstStartByte(t_bpthread_admin *threadAdmin, UINT8 byte); +static void putOnLine( t_bus_devices bus, UINT8 dataLength, UINT8 *data); +static void DecodeAndCacheElectronicStatus(t_bpmsg_message *message); +static void SendLocalElectronicStatus(t_bpthread_admin *threadAdmin); + +static int bpthreadMessageReceived = 0; +static int bpthreadMessageSend = 0; +static int bpthreadBadCrcMessage = 0; +static int bpthreadDecodeError = 0; +static UINT16 bpthreadArrayAdcValue[MAX_NR_CHANNELS]; +static UINT16 bpthreadArrayDacValue[MAX_NR_CHANNELS]; +static BOOLEAN bpthreadArrayDoValue[MAX_NR_CHANNELS]; +static BOOLEAN bpthreadArrayDiValue[MAX_NR_CHANNELS]; + +/** \brief Starts the protocol handling thread + * + * \param bus The communicaiton bus + * \param deviceId Identifier for this device + * \param highestDeviceId The highest deviceId on the bus (only required for master device (deviceId = 0x01)) + * \param bpHandle Handle of busprotocol + * \parma mhqHandle Handle of MessageHandlerQueue + */ +int bpthreadStart(t_bus_devices bus, UINT8 deviceId, UINT8 highestDeviceId, int bpHandle, int mhqHandle) +{ + t_bpthread_admin *newAdmin = (t_bpthread_admin *)pvPortMalloc( sizeof(t_bpthread_admin) ); + signed char *threadName; + signed char *messageHandlerThreadName; + int i; + + /* init administration */ + newAdmin->bus = bus; + newAdmin->deviceId = deviceId; + newAdmin->highestDeviceId = highestDeviceId; + newAdmin->busProtocolHandle = bpHandle; + newAdmin->myTurnCallback = NULL; + newAdmin->messageQueue = mqInit(); + newAdmin->decodeStatus = IDLE; + newAdmin->lastReceivedSenderId = 0; + newAdmin->lastReceivedPacketNr = 0; + newAdmin->rxStartByteDetected = FALSE; + newAdmin->rxMessage.payload = NULL; + newAdmin->messageHandlerHandle = mhqHandle; + newAdmin->messageTimeout = 50; //was 50; /// \todo tune timeouts + newAdmin->cyclusTimeout = 500; // was 500; + newAdmin->backoffTime = 5; // Was 5 + newAdmin->messageHandlerQueue = mqInit(); // xQueueCreate( 25, sizeof(t_bpmsg_message)); + newAdmin->timestampLastRecvMsgDevices = (portTickType *)pvPortMalloc( sizeof(portTickType) * highestDeviceId ); + + // Reset buffer + for (i =0; i < highestDeviceId; i++) + { + newAdmin->timestampLastRecvMsgDevices[i] = xTaskGetTickCount(); + } + + + bpRecvMessagePool = Memmod_Create(8,64); // Make sure size is dividable by 4 + + if (bus == BUS1) + { + threadName = (signed char *)THREAD_NAME_BUS1; + messageHandlerThreadName = (signed char *)MESSAGE_THREAD_NAME_BUS1; + } + else + { + threadName = (signed char *)THREAD_NAME_BUS2; + messageHandlerThreadName = (signed char *)MESSAGE_THREAD_NAME_BUS2; + } + + pthread_create( &(newAdmin->threadHandle), NULL, protocolThread, newAdmin ); // Was: xTaskCreate( protocolThread, threadName, configMINIMAL_STACK_SIZE + 100, newAdmin, tskIDLE_PRIORITY + 3, &(newAdmin->threadHandle) ); + pthread_create( &(newAdmin->threadMessageHandle), NULL, messageHandlerThread, newAdmin ); // Was: xTaskCreate( messageHandlerThread, messageHandlerThreadName, configMINIMAL_STACK_SIZE + 400, newAdmin, tskIDLE_PRIORITY + 2, &(newAdmin->threadMessageHandle) ); + + return (int)newAdmin; +} + +/** \brief Stops the protocol handling thread + * + * \note this function is never tested (reconsider implementation) + * \post handle is not valid anymore + * \param handle Handle to the protocol thread + */ +void bpthreadStop( int handle ) +{ + // \todo Test + //vTaskDelete( ((t_bpthread_admin *)handle)->threadHandle ); + //vTaskDelete( ((t_bpthread_admin *)handle)->threadMessageHandle ); + + vPortFree( (void *)handle ); +} + +/** \brief Add a message to the tx-queue. Message will be send when its this device its turn */ +void bpthreadAddMessage( int handle, t_bpmsg_message *message ) +{ + t_bpthread_admin *theAdmin = (t_bpthread_admin *)handle; + mqAdd( theAdmin->messageQueue, message ); +} + +/** \brief Indicates whether a message a device is received in the last 10 seconds + * Only used by the master + */ +BOOLEAN bpthreadDeviceIsDetected( int handle, UINT8 deviceId ) +{ + t_bpthread_admin *theAdmin = (t_bpthread_admin *)handle; + portTickType currentTimeout; + BOOLEAN retval; + + // if difference is larger than 10 seconds return FALSE + currentTimeout = xTaskGetTickCount() - theAdmin->timestampLastRecvMsgDevices[deviceId - 1]; + if (currentTimeout < 0) + { + currentTimeout = LONG_MAX - theAdmin->timestampLastRecvMsgDevices[deviceId] + xTaskGetTickCount(); + } + + if (currentTimeout > 10000) // Timeout larger than 10 seconds + { + retval = FALSE; + } + else + { + retval = TRUE; + } + + return retval; +} + + +/** \brief Attaches a callback function to MyTurn-event, which notifies when it is this device its turn + * + * \param handle Handle to the protocol thread + * \param callback Pointer to callback-function + */ +void bpthreadAttachMyTurn( int handle, t_bp_myturn_callback callback) +{ + t_bpthread_admin *theAdmin = (t_bpthread_admin *)handle; + + theAdmin->myTurnCallback = callback; +} + +/** \brief Detaches the callback function to MyTurn-event + * + * \param handle Handle to the protocol thread + * \param callback Pointer to callback-function + */ +void bpthreadDetachMyTurn( int handle, t_bp_myturn_callback callback) +{ + t_bpthread_admin *theAdmin = (t_bpthread_admin *)handle; + + theAdmin->myTurnCallback = NULL; +} + +/** \brief The thread which handles the in & output on the bus. + * + * \param pvParameters Pointer to parameters + */ +void *protocolThread( void *pvParameters ) +{ + t_bpthread_admin *threadAdmin = (t_bpthread_admin *)pvParameters; + t_bpmsg_message *rxMessage; + UINT8 rxByte; + + if (threadAdmin->deviceId == MASTER_DEVICE_ID) + { + /* This is the master so start sending messages */ + doMyTurnActions( threadAdmin ); + + resetMessageTimeout( threadAdmin ); + resetCyclusTimeout( threadAdmin ); + } + else + { + resetMessageTimeout( threadAdmin ); + } + + for (;;) + { + // Read all bytes received on bus + while (busGet( threadAdmin->bus, &rxByte ) == TRUE) + { + rxMessage = decodeByte( threadAdmin, rxByte ); + if (rxMessage != NULL) + { + bpthreadMessageReceived++; + threadAdmin->lastReceivedSenderId = rxMessage->senderId; + + // Complete message is received, handle message + handleMessage( threadAdmin, rxMessage); + resetMessageTimeout( threadAdmin ); + if (rxMessage->status == BPMSG_STATUS_FINISHEDSENDING ) + { + detectMyTurn( threadAdmin, rxMessage ); + } + } + } + + // Verify timeouts + checkTimeouts( threadAdmin ); + + vTaskDelay( 5 ); // 5 milliseconden sleep + } + + return NULL; +} + +t_bpmsg_message *decodeByte( t_bpthread_admin *threadAdmin, UINT8 byte ) +{ + switch (threadAdmin->decodeStatus) + { + case(IDLE): + if (byte == BPMSG_STARTBYTE) + { + threadAdmin->decodeStatus = SENDER_ID; + } + else + { + bpthreadDecodeError++; + } + break; + case(SENDER_ID): + if (byte != BPMSG_STARTBYTE) /* 0xAA is not allowed as SENDER_ID, must be a START BYTE */ + { + threadAdmin->rxMessage.senderId = byte; + threadAdmin->decodeStatus = TARGET_ID; + } + else + { + bpthreadDecodeError++; + } + break; + case(TARGET_ID): + if (byte != BPMSG_STARTBYTE) /* 0xAA is not allowed as SENDER_ID, must be a START BYTE */ + { + threadAdmin->rxMessage.targetId = byte; + threadAdmin->decodeStatus = PACKET_NR; + } + else + { + bpthreadDecodeError++; + threadAdmin->decodeStatus = SENDER_ID; + } + break; + case(PACKET_NR): + if (byte != BPMSG_STARTBYTE) /* 0xAA is not allowed as PACKET_NR, must be a START BYTE */ + { + threadAdmin->rxMessage.packetNr = byte; + threadAdmin->decodeStatus = STATUS; + } + else + { + bpthreadDecodeError++; + threadAdmin->decodeStatus = SENDER_ID; + } + break; + case(STATUS): + if ( (byte & 0x40) == 0x40) /* bit 6 must be high */ + { + threadAdmin->rxMessage.status = byte; + threadAdmin->decodeStatus = MESSAGE_ID; + } + else + { + bpthreadDecodeError++; + threadAdmin->decodeStatus = IDLE; + } + break; + case(MESSAGE_ID): + if (byte != BPMSG_STARTBYTE) /* 0xAA is not allowed as PACKET_NR, must be a START BYTE */ + { + threadAdmin->rxMessage.messageId = byte; + threadAdmin->decodeStatus = PAYLOAD_SIZE; + threadAdmin->rxStartByteDetected = FALSE; + } + else + { + bpthreadDecodeError++; + threadAdmin->decodeStatus = SENDER_ID; + } + break; + case(PAYLOAD_SIZE): + if (!ignoreFirstStartByte(threadAdmin, byte )) + { + threadAdmin->rxCrc = crcCalc(&byte, 1, 0); + threadAdmin->rxMessage.payloadSize = byte; + if (byte > 0) + { + threadAdmin->decodeStatus = PAYLOAD; + threadAdmin->rxMessage.payload = (UINT8 *)Memmod_Alloc(bpRecvMessagePool); + threadAdmin->rxFillIdx = 0; + } + else + { + threadAdmin->decodeStatus = CRC; + threadAdmin->rxMessage.payload = NULL; + } + } + break; + case(PAYLOAD): + if (!ignoreFirstStartByte(threadAdmin, byte )) + { + threadAdmin->rxCrc = crcCalc(&byte, 1, threadAdmin->rxCrc); + threadAdmin->rxMessage.payload[threadAdmin->rxFillIdx] = byte; + threadAdmin->rxFillIdx++; + } + + if (threadAdmin->rxFillIdx == threadAdmin->rxMessage.payloadSize) + { + threadAdmin->rxFillIdx = 0; + threadAdmin->decodeStatus = CRC; + } + break; + case(CRC): + if (!ignoreFirstStartByte(threadAdmin, byte) ) + { + if (threadAdmin->rxFillIdx == 0) + { + threadAdmin->rxMessage.crc = ((UINT16)byte) << 8; + } + else + { + threadAdmin->rxMessage.crc |= (UINT16)byte; + } + threadAdmin->rxFillIdx++; + } + + if (threadAdmin->rxFillIdx == 2) + { + threadAdmin->rxFillIdx = 0; + threadAdmin->decodeStatus = IDLE; + + if (threadAdmin->rxCrc == threadAdmin->rxMessage.crc) + { + return &(threadAdmin->rxMessage); + } + else + { + if (threadAdmin->rxMessage.payload != NULL) + { + Memmod_Free( bpRecvMessagePool, threadAdmin->rxMessage.payload ); + threadAdmin->rxMessage.payload = NULL; + } + + bpthreadBadCrcMessage++; + } + } + break; + } + + return NULL; +} + + +void handleMessage(t_bpthread_admin *threadAdmin, t_bpmsg_message *message) +{ + // Record packet nr. + threadAdmin->lastReceivedPacketNr = message->packetNr; + + // Reset Device detected timeout + if ((message->senderId > 0) && (message->senderId <= threadAdmin->highestDeviceId)) // Safety first + { + threadAdmin->timestampLastRecvMsgDevices[message->senderId - 1] = xTaskGetTickCount(); + } + + // is message ment for this device + if ( (message->targetId == BPMSG_BROADCAST_ID) + || (message->targetId == threadAdmin->deviceId) + ) + { + // Add to queue + mqAdd( threadAdmin->messageHandlerQueue, message); // Was: xQueueSendToBack( threadAdmin->messageHandlerQueue, message, 100); + + // Make sure the payload isn't freed + //message->payload = NULL; + } + else + { + // Delete message stuff + if (message->payload != NULL) + { + Memmod_Free( bpRecvMessagePool, message->payload ); + message->payload = NULL; + } + } +} + +void detectMyTurn(t_bpthread_admin *threadAdmin, t_bpmsg_message *message) +{ + BOOLEAN isMyTurn = FALSE; + + if ((message->status & BPMSG_STATUS_FINISHEDSENDING) == BPMSG_STATUS_FINISHEDSENDING) + { + if (threadAdmin->deviceId == BPMSG_MASTER_DEVID) + { + if (message->senderId == threadAdmin->highestDeviceId) + { + resetCyclusTimeout( threadAdmin ); + isMyTurn = TRUE; + } + } + else + { + if ( (message->senderId + 1) == threadAdmin->deviceId) + { + isMyTurn = TRUE; + } + } + } + + if (isMyTurn == TRUE) + { + doMyTurnActions(threadAdmin); + } +} + +void checkTimeouts( t_bpthread_admin *threadAdmin ) +{ + if (threadAdmin->deviceId == MASTER_DEVICE_ID) + { + if (hasTimeoutPast( threadAdmin->cyclusEndTick ) == TRUE) + { + BP_DEBUG_OUT( 't'); BP_DEBUG_OUT( 'c'); + resetCyclusTimeout( threadAdmin ); + doMyTurnActions( threadAdmin ); + } + } + else + { + // If slave device than check if master is seen in the last 10 seconds + if (bpthreadDeviceIsDetected( (int)threadAdmin, MASTER_DEVICE_ID ) == FALSE) + { + // Put slave in save mode and reset device + // secureSlave(); NOTE NOTE : This is not intended for the Webcontroller + + } + } + + // Can safely do test again, cause above actions have reset this + // timeout in doMyTurnActions. + if (hasTimeoutPast( threadAdmin->messageEndTick ) == TRUE) + { + resetMessageTimeout( threadAdmin ); + + // Test if it is possible my turn + if ((threadAdmin->lastReceivedSenderId + 1) == threadAdmin->deviceId) + { + BP_DEBUG_OUT('t'); BP_DEBUG_OUT('m'); + doMyTurnActions( threadAdmin ); + } + else + { + if ( (threadAdmin->deviceId == MASTER_DEVICE_ID) + && (threadAdmin->lastReceivedSenderId == threadAdmin->highestDeviceId) + ) + { + BP_DEBUG_OUT('t'); BP_DEBUG_OUT('m'); + resetCyclusTimeout( threadAdmin ); + doMyTurnActions( threadAdmin ); + } + else + { + threadAdmin->lastReceivedSenderId++; + } + } + } +} + +void doMyTurnActions(t_bpthread_admin *threadAdmin) +{ + int nrOfMessagesSend = 0; + t_bpmsg_message message; + UINT16 multipleTimeout; + + // Backoff for some time + vTaskDelay( threadAdmin->backoffTime ); + + /* Notify MyTurn-event listeners */ + if (threadAdmin->myTurnCallback != NULL) + { + // If MyTurn is handled by application -> then application is responsible for send give electronicStatus + threadAdmin->myTurnCallback(); + } + + if (mqEmpty(threadAdmin->messageQueue) == TRUE) + bpSendPassTurn(threadAdmin->busProtocolHandle); + + + // Send MAX messages on the bus + while ( (nrOfMessagesSend < MAX_TX_MESSAGES) + && (mqEmpty(threadAdmin->messageQueue) == FALSE) + ) + { + if (mqGet(threadAdmin->messageQueue, &message) != ERROR) + { + // If last message in a row then set status LAST_MESSAGE + if ( (mqEmpty(threadAdmin->messageQueue) == TRUE ) + || ((nrOfMessagesSend + 1)>= MAX_TX_MESSAGES) + ) + { + message.status = BPMSG_STATUS_FINISHEDSENDING; + } + else + { + message.status = BPMSG_STATUS_BUSYSENDING; + } + + // Fill packetNr + threadAdmin->lastReceivedPacketNr++; + if (threadAdmin->lastReceivedPacketNr == BPMSG_STARTBYTE) threadAdmin->lastReceivedPacketNr++; // 0xAA cannot be used as packetNr + message.packetNr = threadAdmin->lastReceivedPacketNr; + + sendMessage( threadAdmin->bus, &message ); + nrOfMessagesSend++; + + // Throw payload away (dynamic part of message) + if (message.payload != NULL) + { + Memmod_Free( bpMessagePool, message.payload ); + } + } + } + + threadAdmin->lastReceivedSenderId = threadAdmin->deviceId; + + // Reset message timeout multiple times + multipleTimeout = nrOfMessagesSend * threadAdmin->messageTimeout; + threadAdmin->messageEndTick = calcEndTick( multipleTimeout ); +} + +void resetMessageTimeout(t_bpthread_admin *threadAdmin) +{ + threadAdmin->messageEndTick = calcEndTick( threadAdmin->messageTimeout); +} + +void resetCyclusTimeout(t_bpthread_admin *threadAdmin) +{ + threadAdmin->cyclusEndTick = calcEndTick( threadAdmin->cyclusTimeout); +} + +void sendMessage( t_bus_devices bus, t_bpmsg_message *message ) +{ + bpthreadMessageSend++; + UINT8 crcByte; + + // Put message on the bus + busPut( bus, message->uniqueStartByte); + busPut( bus, message->senderId); + busPut( bus, message->targetId); + busPut( bus, message->packetNr); + busPut( bus, message->status); + busPut( bus, message->messageId); + putOnLine( bus, 1, &(message->payloadSize)); + putOnLine( bus, message->payloadSize, message->payload ); + crcByte = (UINT8)(message->crc >> 8); + putOnLine( bus, 1, &crcByte); + crcByte = (UINT8)message->crc; + putOnLine( bus, 1, &crcByte); +} + +void putOnLine( t_bus_devices bus, UINT8 dataLength, UINT8 *data) +{ + int index; + + for (index = 0; index < dataLength; index++) + { + if (data[index] == BPMSG_STARTBYTE) + { + // Write double AA + busPut( bus, BPMSG_STARTBYTE); + busPut( bus, BPMSG_STARTBYTE); + } + else + { + busPut( bus, data[index]); + } + } +} + +UINT32 calcEndTick( UINT16 timeoutPeriod ) +{ + UINT32 result = xTaskGetTickCount() + timeoutPeriod; + + return result; +} + +BOOLEAN hasTimeoutPast( UINT32 endTick ) +{ + UINT32 nowTick = xTaskGetTickCount(); + + if (nowTick >= endTick) + { + if ((nowTick - endTick) > 0x0000FFFF) + { + // the endTick has gone through 0 point, nowTick is at end of range + return FALSE; + } + else + { + // nowTick passed endTick. + return TRUE; + } + } + else + { + if ((endTick - nowTick) > 0x0000FFFF) + { + + // the endTick was at end of range, nowTick has gone through 0 point + return TRUE; + } + else + { + // nowTick still has to pass endTick + return FALSE; + } + } +} + +BOOLEAN ignoreFirstStartByte(t_bpthread_admin *threadAdmin, UINT8 byte) +{ + if (threadAdmin->rxStartByteDetected == FALSE) + { + if (byte == BPMSG_STARTBYTE) + { + threadAdmin->rxStartByteDetected = TRUE; + } + else + { + threadAdmin->rxStartByteDetected = FALSE; + } + } + else + { + if (byte == BPMSG_STARTBYTE) + { + // Correctly received the second StartByte + threadAdmin->rxStartByteDetected = FALSE; + } + else + { + // Expected a second StartByte but didn't => ERROR + threadAdmin->rxStartByteDetected = TRUE; + threadAdmin->decodeStatus = IDLE; + } + } + + return threadAdmin->rxStartByteDetected; +} + +void *messageHandlerThread( void *pvParameters ) +{ + t_bpthread_admin *threadAdmin = (t_bpthread_admin *)pvParameters; + t_bpmsg_message message; + + for (;;) + { + if (mqGet( threadAdmin->messageHandlerQueue, &message) == OK) // Was: if (xQueueReceive(threadAdmin->messageHandlerQueue, &message, 200)) + { + // If "Give Electronic status"-update then store in bpec of driver + if (message.messageId == BPMSG_MSGID_GIVEELECTRONICSTATUS) + { + DecodeAndCacheElectronicStatus( &message ); + } + + // Lookup message and execute handler + mhqExecute( threadAdmin->messageHandlerHandle, message.messageId, &message ); + + if (message.payload != NULL) + { + Memmod_Free( bpRecvMessagePool, message.payload ); + } + } + vTaskDelay(5); + } + + return NULL; +} + +void DecodeAndCacheElectronicStatus(t_bpmsg_message *message) +{ + UINT8 index; + UINT8 arraySize; + UINT8 payloadIndex = 0; + + BP_DEBUG_OUT( 'e'); BP_DEBUG_OUT( '<'); + + // Decode ADC-values + arraySize = message->payload[payloadIndex++]; + for (index = 0; index < arraySize; index++) + { + bpthreadArrayAdcValue[index] = bpmsgGet16bit( message->payload, &payloadIndex); + } + bpecSetAdcReadCache( message->senderId, bpthreadArrayAdcValue, arraySize); + + // Decode DAC-values + arraySize = message->payload[payloadIndex++]; + for (index = 0; index < arraySize; index++) + { + bpthreadArrayDacValue[index] = bpmsgGet16bit( message->payload, &payloadIndex); + } + bpecSetDacReadBackCache( message->senderId, bpthreadArrayDacValue, arraySize); + + // Decode DIO input-values + arraySize = message->payload[payloadIndex++]; + for (index = 0; index < arraySize; index++) + { + bpthreadArrayDiValue[index] = bpmsgGet8bit( message->payload, &payloadIndex); + } + bpecSetDioReadCache( message->senderId, bpthreadArrayDiValue, arraySize); + + // Decode DIO output-values + arraySize = message->payload[payloadIndex++]; + for (index = 0; index < arraySize; index++) + { + bpthreadArrayDoValue[index] = bpmsgGet8bit( message->payload, &payloadIndex); + } + bpecSetDioReadBackCache( message->senderId, bpthreadArrayDoValue, arraySize); +} + +void SendLocalElectronicStatus(t_bpthread_admin *threadAdmin) +{ +#ifdef DO_NOT_COMPILE + int i; + + BP_DEBUG_OUT( 'e'); BP_DEBUG_OUT( '>'); + + // Assemble information + for (i = 0; i < maxADC_Channels; i++ ) + { + bpthreadArrayAdcValue[i] = adcRead( 0, i ); + } + + for (i = 0; i < maxDAC_Channels; i++ ) + { + bpthreadArrayDacValue[i] = dacReadBack( 0, i ); + } + + for (i = 0; i < maxDI_Channels; i++ ) + { + bpthreadArrayDiValue[i] = dioRead( 0, i ); + } + + for (i = 0; i < maxDO_Channels; i++ ) + { + bpthreadArrayDoValue[i] = dioReadBack( 0, i ); + } + + // Send message + bpSendGiveElectronicStatus( threadAdmin->busProtocolHandle, + maxADC_Channels, + bpthreadArrayAdcValue, + maxDAC_Channels, + bpthreadArrayDacValue, + maxDI_Channels, + (UINT8 *)bpthreadArrayDiValue, + maxDO_Channels, + (UINT8 *)bpthreadArrayDoValue + ); +#endif +} diff --git a/Quantum Controller/SW/testapplication-0.0.1/ProtocolThread.h b/Quantum Controller/SW/testapplication-0.0.1/ProtocolThread.h new file mode 100644 index 0000000..6da94e2 --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/ProtocolThread.h @@ -0,0 +1,80 @@ +/* --------------------------------------------------------------------------- + * ProtocolThread.h - v0.1 (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Jan 29, 2008, FSc + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef __PROTOCOLTHREAD_H__ +#define __PROTOCOLTHREAD_H__ +/** \file ProtocolThread.h + \brief Thread which handles the messaging of the protocol. +*/ + +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ +#include "bus.h" +#include "BpMessageFormat.h" +#include "BusProtocol.h" + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ + + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ +/** \brief Starts the protocol handling thread */ +int bpthreadStart( t_bus_devices bus, UINT8 deviceId, UINT8 highestDeviceId, int bpHandle, int mhqHandle ); + +/** \brief Stops the protocol handling thread */ +void bpthreadStop( int handle ); + +/** \brief Indicates whether a message a device is received in the last 10 seconds + * Only used by the master + */ +BOOLEAN bpthreadDeviceIsDetected( int handle, UINT8 deviceId ); + +/** \brief Add a message to the tx-queue. Message will be send when its this device its turn */ +void bpthreadAddMessage( int handle, t_bpmsg_message *message ); + +/** \brief Attaches a callback function to MyTurn-event, which notifies when it is this device its turn */ +void bpthreadAttachMyTurn( int handle, t_bp_myturn_callback callback); + +/** \brief Detaches the callback function to MyTurn-event */ +void bpthreadDetachMyTurn( int handle, t_bp_myturn_callback callback); + + +#endif /* __PROTOCOLTHREAD_H__ */ + diff --git a/Quantum Controller/SW/testapplication-0.0.1/README b/Quantum Controller/SW/testapplication-0.0.1/README new file mode 100644 index 0000000..e69de29 diff --git a/Quantum Controller/SW/testapplication-0.0.1/RemoteProcedureCalls.c b/Quantum Controller/SW/testapplication-0.0.1/RemoteProcedureCalls.c new file mode 100644 index 0000000..30ffab5 --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/RemoteProcedureCalls.c @@ -0,0 +1,297 @@ +/* --------------------------------------------------------------------------- + * RemoteProcedureCalls.c - v0.1 (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Jan 29, 2008, FSc + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +#include + + +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "BpPort.h" +#include "RemoteProcedureCalls.h" +#include "BusProtocol.h" +#include "mem_mod.h" + + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ + +#define RPC_DISPATCH_QUEUE_SIZE (10) + +extern memman *bpMessagePool; + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ + + + +/** \brief Initialises a Remote Procedure Call administration + * + * \returns Handle to Remote Procedure Call administration (0 = failure) + */ +int rpcInit() +{ + t_rpc_admin *newAdmin = (t_rpc_admin *)pvPortMalloc( sizeof(t_rpc_admin) ); + if (newAdmin != NULL) + { + newAdmin->firstEntry = NULL; + newAdmin->lastEntry = NULL; + } + + return (int)newAdmin; +} + +/** \brief Deinitialises the Remote Procedure Call administration + * + * \param handle Handle to RPC-adminstration + */ +void rpcDeinit( int handle ) +{ + t_rpc_admin *theAdmin = (t_rpc_admin *)handle; + + // Remove whole list + if (theAdmin->firstEntry != NULL) + { + t_rpc_entity *entry = theAdmin->firstEntry; + + while (entry != NULL) + { + t_rpc_entity *nextEntry = entry->next; + + vPortFree( entry ); + + entry = nextEntry; + } + } + + // Remove admin + vPortFree( (void *)handle ); +} + +/** \brief Adds a Remote Procedure Call to the administration + * + * \param handle Handle to RPC-administration + * \param functionId Identifier for RPC + * \param nrOfParams Nr of parameters required by RPC-function + */ +void rpcAdd( int handle, UINT8 functionId, char * functionName, t_rpc_remote_procedure_call funcptr, UINT8 nrOfParams ) +{ + t_rpc_entity *newEntry = (t_rpc_entity *)pvPortMalloc( sizeof(t_rpc_entity) ); + t_rpc_admin *theAdmin = (t_rpc_admin *)handle; + + // fill entry + newEntry->functionId = functionId; + newEntry->functionName = functionName; + newEntry->rpcFunction = funcptr; + newEntry->nrOfParams = nrOfParams; + newEntry->next = NULL; + newEntry->previous = NULL; + + // Add to linked list + if (theAdmin->firstEntry != NULL) + { + theAdmin->lastEntry->next = newEntry; + newEntry->previous = theAdmin->lastEntry; + theAdmin->lastEntry = newEntry; + } + else + { + theAdmin->firstEntry = newEntry; + theAdmin->lastEntry = newEntry; + } +} + +/** \brief Removes a Remote Procedure Call to the administration + * + * \param handle Handle to RPC-administration + * \param functionId Identifier for RPC-function + */ +void rpcRemove( int handle, UINT8 functionId ) +{ + t_rpc_entity *entry = rpcLookupEntry(handle, functionId); + t_rpc_admin *theAdmin = (t_rpc_admin *)handle; + + if (entry != NULL) + { + // rebuild linked list + if (entry->next != NULL) + { + entry->next->previous = entry->previous; + } + else + { + theAdmin->lastEntry = entry->previous; + } + + if (entry->previous != NULL) + { + entry->previous->next = entry->next; + } + else + { + theAdmin->firstEntry = entry->next; + } + + // remove entry + vPortFree( entry ); + } + +} + +/** \brief Looks up a Remote Procedure Call to the administration + * + * \param handle Handle to RPC-administration + * \param functionId Identifier for RPC-function + * \retval Pointer to RPC-function (NULL when not found) + */ +t_rpc_remote_procedure_call rpcLookup( int handle, UINT8 functionId ) +{ + t_rpc_remote_procedure_call result = NULL; + t_rpc_entity *entry = rpcLookupEntry(handle, functionId); + + if (entry != NULL) + { + result = entry->rpcFunction; + } + + return result; +} + +/** \brief Executes a Remote Procedure Call + * + * \param handle Handle to RPC-administration + * \param nrOfParams Nr of parameters in params-array + * \param params Pointer to array with all parameters + * \retval OK RPC request is send + * \retval ERROR Unable to send RPC request + */ +RESULT rpcExecute( int handle, UINT8 functionId, UINT8 nrOfParams, const UINT32 *params ) +{ + t_rpc_entity *entry = rpcLookupEntry(handle, functionId); + if (entry != NULL) + { + // Dispatch function to rpcThread + // execute function + //result = entry->rpcFunction; + return OK; + } + else + { + return ERROR; + } +} + + +t_rpc_entity *rpcLookupEntry( int handle, UINT8 functionId ) +{ + t_rpc_admin *theAdmin = (t_rpc_admin *)handle; + t_rpc_entity *result = NULL; + t_rpc_entity *iterator; + + iterator = theAdmin->firstEntry; + while ((result == NULL) && (iterator != NULL)) + { + if (iterator->functionId == functionId) + { + result = iterator; + } + else + { + iterator = iterator->next; + } + } + + return result; +} + + +void rpcRequestHandler(t_bpmsg_message *msg, int ownHandler) +{ + UINT8 index = 0; + UINT8 count; + UINT8 targetId, senderId, requestNr, functionId, nrOfParams; + UINT32 *params; + t_rpc_entity *rpcEntry; + + // Decode message + targetId = msg->targetId; + senderId = msg->senderId; + requestNr = bpmsgGet8bit( msg->payload, &index); + functionId = bpmsgGet8bit( msg->payload, &index); + nrOfParams = bpmsgGet8bit( msg->payload, &index); + + BP_DEBUG_OUT('{'); + BP_DEBUG_OUT('a' + functionId); + + // Allocate an array for the params + if (nrOfParams > 0) + { + params = (UINT32 *)Memmod_Alloc( bpMessagePool ); + if (params != NULL) + { + for (count = 0; count < nrOfParams; count++) + { + params[count] = bpmsgGet32bit(msg->payload, &index); + } + } + else + { + /// \todo Error handling + return; + } + } + else + { + params = NULL; + } + + // Call RPC-function + rpcEntry = rpcLookupEntry(ownHandler, functionId); + if (rpcEntry != NULL) + { + BP_DEBUG_OUT('a' + functionId); + // execute function + rpcEntry->rpcFunction( senderId, targetId, requestNr, functionId, nrOfParams, params ); + } + + if (params != NULL) + { + Memmod_Free( bpMessagePool, params ); + } +} + diff --git a/Quantum Controller/SW/testapplication-0.0.1/RemoteProcedureCalls.h b/Quantum Controller/SW/testapplication-0.0.1/RemoteProcedureCalls.h new file mode 100644 index 0000000..94788bf --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/RemoteProcedureCalls.h @@ -0,0 +1,94 @@ +/* --------------------------------------------------------------------------- + * RemoteProcedureCalls.h - v0.1 (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: Holds supported Remote Procedure Calls + * --------------------------------------------------------------------------- + * Version(s): 0.1, Jan 29, 2008, FSc + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef __REMOTEPROCEDURECALLS_H__ +#define __REMOTEPROCEDURECALLS_H__ +/** \file RemoteProcedureCalls.h + \brief +*/ + +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ +#include "BpMessageFormat.h" + + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ +typedef void (*t_rpc_remote_procedure_call)( UINT8 senderId, UINT8 targetId, UINT8 requestNr, UINT8 functionId, UINT8 nrOfParams, UINT32 *params ); + +typedef struct t_RPC_ENTITY { + UINT8 functionId; + char * functionName; + UINT8 nrOfParams; + t_rpc_remote_procedure_call rpcFunction; + struct t_RPC_ENTITY *next; + struct t_RPC_ENTITY *previous; +} t_rpc_entity; + +typedef struct t_RPC_ADMIN { + t_rpc_entity *firstEntry; + t_rpc_entity *lastEntry; +} t_rpc_admin; + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ +/** \brief Initialises a Remote Procedure Call administration */ +int rpcInit(); + +/** \brief Deinitialises the Remote Procedure Call administration */ +void rpcDeinit( int handle ); + +/** \brief Adds a Remote Procedure Call to the administration */ +void rpcAdd( int handle, UINT8 functionId, char * functionName, t_rpc_remote_procedure_call funcptr, UINT8 nrOfParams ); + +/** \brief Removes a Remote Procedure Call to the administration */ +void rpcRemove( int handle, UINT8 functionId ); + +/** \brief Looks up a Remote Procedure Call to the administration */ +t_rpc_remote_procedure_call rpcLookup( int handle, UINT8 functionId ); + +/** \brief Executes a Remote Procedure Call */ +RESULT rpcExecute( int handle, UINT8 functionId, UINT8 nrOfParams, const UINT32 *params ); + +t_rpc_entity *rpcLookupEntry( int handle, UINT8 functionId ); + +/** \brief Message handler for RPC-requests */ +void rpcRequestHandler(t_bpmsg_message *msg, int ownHandler); + +#endif /* __REMOTEPROCEDURECALLS_H__ */ diff --git a/Quantum Controller/SW/testapplication-0.0.1/RpcResults.c b/Quantum Controller/SW/testapplication-0.0.1/RpcResults.c new file mode 100644 index 0000000..deda907 --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/RpcResults.c @@ -0,0 +1,285 @@ +/* --------------------------------------------------------------------------- + * RemoteProcedureCalls.c - v0.1 (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Jan 29, 2008, FSc + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +#include + + +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "BpPort.h" +#include "RpcResults.h" +#include "BusProtocol.h" +#include "mem_mod.h" + + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ + +#define RPCR_DISPATCH_QUEUE_SIZE (10) + +typedef struct t_RPCR_ENTITY { + UINT8 functionId; + UINT8 nrOfParams; + t_bp_rpcresult_callback rpcrFunction; + struct t_RPCR_ENTITY *next; + struct t_RPCR_ENTITY *previous; +} t_rpcr_entity; + +typedef struct t_RPCR_ADMIN { + t_rpcr_entity *firstEntry; + t_rpcr_entity *lastEntry; +} t_rpcr_admin; + +extern memman *bpMessagePool; + + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ +static t_rpcr_entity *lookupRpcrEntry( int handle, UINT8 functionId ); + + +/** \brief Initialises a Remote Procedure Call administration + * + * \returns Handle to Remote Procedure Call administration (0 = failure) + */ +int rpcrInit() +{ + t_rpcr_admin *newAdmin = (t_rpcr_admin *)pvPortMalloc( sizeof(t_rpcr_admin) ); + if (newAdmin != NULL) + { + newAdmin->firstEntry = NULL; + newAdmin->lastEntry = NULL; + } + + return (int)newAdmin; +} + +/** \brief Deinitialises the Remote Procedure Call administration + * + * \param handle Handle to RPC-adminstration + */ +void rpcrDeinit( int handle ) +{ + t_rpcr_admin *theAdmin = (t_rpcr_admin *)handle; + + // Remove whole list + if (theAdmin->firstEntry != NULL) + { + t_rpcr_entity *entry = theAdmin->firstEntry; + + while (entry != NULL) + { + t_rpcr_entity *nextEntry = entry->next; + + vPortFree( entry ); + + entry = nextEntry; + } + } + + // Remove admin + vPortFree( (void *)handle ); +} + +/** \brief Adds a Remote Procedure Call to the administration + * + * \param handle Handle to RPC-administration + * \param functionId Identifier for RPC + * \param nrOfParams Nr of parameters required by RPC-function + */ +void rpcrAdd( int handle, UINT8 functionId, t_bp_rpcresult_callback funcptr, UINT8 nrOfParams ) +{ + t_rpcr_entity *newEntry = (t_rpcr_entity *)pvPortMalloc( sizeof(t_rpcr_entity) ); + t_rpcr_admin *theAdmin = (t_rpcr_admin *)handle; + + // fill entry + newEntry->functionId = functionId; + newEntry->rpcrFunction = funcptr; + newEntry->nrOfParams = nrOfParams; + newEntry->next = NULL; + newEntry->previous = NULL; + + // Add to linked list + if (theAdmin->firstEntry != NULL) + { + theAdmin->lastEntry->next = newEntry; + newEntry->previous = theAdmin->lastEntry; + theAdmin->lastEntry = newEntry; + } + else + { + theAdmin->firstEntry = newEntry; + theAdmin->lastEntry = newEntry; + } +} + +/** \brief Removes a Remote Procedure Call to the administration + * + * \param handle Handle to RPC-administration + * \param functionId Identifier for RPC-function + */ +void rpcrRemove( int handle, UINT8 functionId ) +{ + t_rpcr_entity *entry = lookupRpcrEntry(handle, functionId); + t_rpcr_admin *theAdmin = (t_rpcr_admin *)handle; + + if (entry != NULL) + { + // rebuild linked list + if (entry->next != NULL) + { + entry->next->previous = entry->previous; + } + else + { + theAdmin->lastEntry = entry->previous; + } + + if (entry->previous != NULL) + { + entry->previous->next = entry->next; + } + else + { + theAdmin->firstEntry = entry->next; + } + + // remove entry + vPortFree( entry ); + } + +} + +/** \brief Looks up a Remote Procedure Call to the administration + * + * \param handle Handle to RPC-administration + * \param functionId Identifier for RPC-function + * \retval Pointer to RPC-function (NULL when not found) + */ +t_bp_rpcresult_callback rpcrLookup( int handle, UINT8 functionId ) +{ + t_bp_rpcresult_callback result = NULL; + t_rpcr_entity *entry = lookupRpcrEntry(handle, functionId); + + if (entry != NULL) + { + result = entry->rpcrFunction; + } + + return result; +} + + +t_rpcr_entity *lookupRpcrEntry( int handle, UINT8 functionId ) +{ + t_rpcr_admin *theAdmin = (t_rpcr_admin *)handle; + t_rpcr_entity *result = NULL; + t_rpcr_entity *iterator; + + iterator = theAdmin->firstEntry; + while ((result == NULL) && (iterator != NULL)) + { + if (iterator->functionId == functionId) + { + result = iterator; + } + else + { + iterator = iterator->next; + } + } + + return result; +} + + +void rpcrRequestHandler(t_bpmsg_message *msg, int ownHandler) +{ + UINT8 index = 0; + UINT8 count; + UINT8 targetId, senderId, requestNr, functionId, nrOfResults; + UINT32 *results; + t_rpcr_entity *rpcrEntry; + + BP_DEBUG_OUT( '!'); + + // Decode message + targetId = msg->targetId; + senderId = msg->senderId; + requestNr = bpmsgGet8bit( msg->payload, &index); + functionId = bpmsgGet8bit( msg->payload, &index); + nrOfResults = bpmsgGet8bit( msg->payload, &index); + + // Allocate an array for the params + if (nrOfResults > 0) + { + results = (UINT32 *)Memmod_Alloc( bpMessagePool ); + if (results != NULL) + { + for (count = 0; count < nrOfResults; count++) + { + results[count] = bpmsgGet32bit(msg->payload, &index); + } + } + else + { + /// \todo Error handling + return; + } + } + else + { + results = NULL; + } + + // Call RPC-function + rpcrEntry = lookupRpcrEntry(ownHandler, functionId); + if (rpcrEntry != NULL) + { + // execute function + BP_DEBUG_OUT('#'); + rpcrEntry->rpcrFunction( requestNr, nrOfResults, results ); + } + + if (results != NULL) + { + Memmod_Free( bpMessagePool, results ); + } +} + diff --git a/Quantum Controller/SW/testapplication-0.0.1/RpcResults.h b/Quantum Controller/SW/testapplication-0.0.1/RpcResults.h new file mode 100644 index 0000000..e1ee7c2 --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/RpcResults.h @@ -0,0 +1,76 @@ +/* --------------------------------------------------------------------------- + * RpcResults.h - v0.1 (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: Holds supported Remote Procedure Calls + * --------------------------------------------------------------------------- + * Version(s): 0.1, Jan 29, 2008, FSc + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef __RPCRESULTS_H__ +#define __RPCRESULTS_H__ +/** \file RpcResults.h + \brief +*/ + +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ +#include "BusProtocol.h" +#include "BpMessageFormat.h" + + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ + + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ +/** \brief Initialises a Remote Procedure Call-Result administration */ +int rpcrInit(); + +/** \brief Deinitialises the Remote Procedure Call-Result administration */ +void rpcrDeinit( int handle ); + +/** \brief Adds a RPC-result handler to the administration */ +void rpcrAdd( int handle, UINT8 functionId, t_bp_rpcresult_callback funcptr, UINT8 nrOfParams); + +/** \brief Removes a RPC-result handler to the administration */ +void rpcrRemove( int handle, UINT8 functionId ); + +/** \brief Looks up a RPC-result handler to the administration */ +t_bp_rpcresult_callback rpcrLookup( int handle, UINT8 functionId ); + +/** \brief Message handler for RPC-requests */ +void rpcrRequestHandler(t_bpmsg_message *msg, int ownHandler); + +#endif /* __RPCRESULTS_H__ */ diff --git a/Quantum Controller/SW/testapplication-0.0.1/USB_test.c b/Quantum Controller/SW/testapplication-0.0.1/USB_test.c new file mode 100644 index 0000000..f71ad36 --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/USB_test.c @@ -0,0 +1 @@ +/* --------------------------------------------------------------------------- * USB_test.c (c) 2008 Micro-key bv * --------------------------------------------------------------------------- * Micro-key bv * Industrieweg 28, 9804 TG Noordhorn * Postbus 92, 9800 AB Zuidhorn * The Netherlands * Tel: +31 594 503020 * Fax: +31 594 505825 * Email: support@microkey.nl * Web: www.microkey.nl * --------------------------------------------------------------------------- * Description: * --------------------------------------------------------------------------- * Version(s): 0.1, Dez 11, 2008, MMi * Creation. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * System include files * --------------------------------------------------------------------------- */ #include /* --------------------------------------------------------------------------- * Application include files * --------------------------------------------------------------------------- */ #include "USB_test.h" /* --------------------------------------------------------------------------- * Local constant and macro definitions * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Global variable definitions * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Local variable definitions * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Local function definitions * --------------------------------------------------------------------------- */ void usb_test_execute (void) { printf ("THIS IS THE USB TEST SEQUENCE"); } \ No newline at end of file diff --git a/Quantum Controller/SW/testapplication-0.0.1/USB_test.h b/Quantum Controller/SW/testapplication-0.0.1/USB_test.h new file mode 100644 index 0000000..8798035 --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/USB_test.h @@ -0,0 +1 @@ +/* --------------------------------------------------------------------------- * USB_test.h (c) 2008 Micro-key bv * --------------------------------------------------------------------------- * Micro-key bv * Industrieweg 28, 9804 TG Noordhorn * Postbus 92, 9800 AB Zuidhorn * The Netherlands * Tel: +31 594 503020 * Fax: +31 594 505825 * Email: support@microkey.nl * Web: www.microkey.nl * --------------------------------------------------------------------------- * Description: * --------------------------------------------------------------------------- * Version(s): 0.1, Dez 11, 2008, MMi * Creation. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * System include files. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Application include files. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Constant and macro definitions. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Type definitions. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Variable declarations. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Function declarations. * --------------------------------------------------------------------------- */ void usb_test_execute (void); \ No newline at end of file diff --git a/Quantum Controller/SW/testapplication-0.0.1/aclocal.m4 b/Quantum Controller/SW/testapplication-0.0.1/aclocal.m4 new file mode 100644 index 0000000..eb3b99a --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/aclocal.m4 @@ -0,0 +1,868 @@ +# generated automatically by aclocal 1.10.1 -*- Autoconf -*- + +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, +# 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +m4_ifndef([AC_AUTOCONF_VERSION], + [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl +m4_if(AC_AUTOCONF_VERSION, [2.61],, +[m4_warning([this file was generated for autoconf 2.61. +You have another version of autoconf. It may work, but is not guaranteed to. +If you have problems, you may need to regenerate the build system entirely. +To do so, use the procedure documented by the package, typically `autoreconf'.])]) + +# Copyright (C) 2002, 2003, 2005, 2006, 2007 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_AUTOMAKE_VERSION(VERSION) +# ---------------------------- +# Automake X.Y traces this macro to ensure aclocal.m4 has been +# generated from the m4 files accompanying Automake X.Y. +# (This private macro should not be called outside this file.) +AC_DEFUN([AM_AUTOMAKE_VERSION], +[am__api_version='1.10' +dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to +dnl require some minimum version. Point them to the right macro. +m4_if([$1], [1.10.1], [], + [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl +]) + +# _AM_AUTOCONF_VERSION(VERSION) +# ----------------------------- +# aclocal traces this macro to find the Autoconf version. +# This is a private macro too. Using m4_define simplifies +# the logic in aclocal, which can simply ignore this definition. +m4_define([_AM_AUTOCONF_VERSION], []) + +# AM_SET_CURRENT_AUTOMAKE_VERSION +# ------------------------------- +# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. +# This function is AC_REQUIREd by AC_INIT_AUTOMAKE. +AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], +[AM_AUTOMAKE_VERSION([1.10.1])dnl +m4_ifndef([AC_AUTOCONF_VERSION], + [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl +_AM_AUTOCONF_VERSION(AC_AUTOCONF_VERSION)]) + +# AM_AUX_DIR_EXPAND -*- Autoconf -*- + +# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets +# $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to +# `$srcdir', `$srcdir/..', or `$srcdir/../..'. +# +# Of course, Automake must honor this variable whenever it calls a +# tool from the auxiliary directory. The problem is that $srcdir (and +# therefore $ac_aux_dir as well) can be either absolute or relative, +# depending on how configure is run. This is pretty annoying, since +# it makes $ac_aux_dir quite unusable in subdirectories: in the top +# source directory, any form will work fine, but in subdirectories a +# relative path needs to be adjusted first. +# +# $ac_aux_dir/missing +# fails when called from a subdirectory if $ac_aux_dir is relative +# $top_srcdir/$ac_aux_dir/missing +# fails if $ac_aux_dir is absolute, +# fails when called from a subdirectory in a VPATH build with +# a relative $ac_aux_dir +# +# The reason of the latter failure is that $top_srcdir and $ac_aux_dir +# are both prefixed by $srcdir. In an in-source build this is usually +# harmless because $srcdir is `.', but things will broke when you +# start a VPATH build or use an absolute $srcdir. +# +# So we could use something similar to $top_srcdir/$ac_aux_dir/missing, +# iff we strip the leading $srcdir from $ac_aux_dir. That would be: +# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` +# and then we would define $MISSING as +# MISSING="\${SHELL} $am_aux_dir/missing" +# This will work as long as MISSING is not called from configure, because +# unfortunately $(top_srcdir) has no meaning in configure. +# However there are other variables, like CC, which are often used in +# configure, and could therefore not use this "fixed" $ac_aux_dir. +# +# Another solution, used here, is to always expand $ac_aux_dir to an +# absolute PATH. The drawback is that using absolute paths prevent a +# configured tree to be moved without reconfiguration. + +AC_DEFUN([AM_AUX_DIR_EXPAND], +[dnl Rely on autoconf to set up CDPATH properly. +AC_PREREQ([2.50])dnl +# expand $ac_aux_dir to an absolute path +am_aux_dir=`cd $ac_aux_dir && pwd` +]) + +# AM_CONDITIONAL -*- Autoconf -*- + +# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 8 + +# AM_CONDITIONAL(NAME, SHELL-CONDITION) +# ------------------------------------- +# Define a conditional. +AC_DEFUN([AM_CONDITIONAL], +[AC_PREREQ(2.52)dnl + ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], + [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl +AC_SUBST([$1_TRUE])dnl +AC_SUBST([$1_FALSE])dnl +_AM_SUBST_NOTMAKE([$1_TRUE])dnl +_AM_SUBST_NOTMAKE([$1_FALSE])dnl +if $2; then + $1_TRUE= + $1_FALSE='#' +else + $1_TRUE='#' + $1_FALSE= +fi +AC_CONFIG_COMMANDS_PRE( +[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then + AC_MSG_ERROR([[conditional "$1" was never defined. +Usually this means the macro was only invoked conditionally.]]) +fi])]) + +# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 9 + +# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be +# written in clear, in which case automake, when reading aclocal.m4, +# will think it sees a *use*, and therefore will trigger all it's +# C support machinery. Also note that it means that autoscan, seeing +# CC etc. in the Makefile, will ask for an AC_PROG_CC use... + + +# _AM_DEPENDENCIES(NAME) +# ---------------------- +# See how the compiler implements dependency checking. +# NAME is "CC", "CXX", "GCJ", or "OBJC". +# We try a few techniques and use that to set a single cache variable. +# +# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was +# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular +# dependency, and given that the user is not expected to run this macro, +# just rely on AC_PROG_CC. +AC_DEFUN([_AM_DEPENDENCIES], +[AC_REQUIRE([AM_SET_DEPDIR])dnl +AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl +AC_REQUIRE([AM_MAKE_INCLUDE])dnl +AC_REQUIRE([AM_DEP_TRACK])dnl + +ifelse([$1], CC, [depcc="$CC" am_compiler_list=], + [$1], CXX, [depcc="$CXX" am_compiler_list=], + [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'], + [$1], UPC, [depcc="$UPC" am_compiler_list=], + [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'], + [depcc="$$1" am_compiler_list=]) + +AC_CACHE_CHECK([dependency style of $depcc], + [am_cv_$1_dependencies_compiler_type], +[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_$1_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` + fi + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with + # Solaris 8's {/usr,}/bin/sh. + touch sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + case $depmode in + nosideeffect) + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + none) break ;; + esac + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. + if depmode=$depmode \ + source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_$1_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_$1_dependencies_compiler_type=none +fi +]) +AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) +AM_CONDITIONAL([am__fastdep$1], [ + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) +]) + + +# AM_SET_DEPDIR +# ------------- +# Choose a directory name for dependency files. +# This macro is AC_REQUIREd in _AM_DEPENDENCIES +AC_DEFUN([AM_SET_DEPDIR], +[AC_REQUIRE([AM_SET_LEADING_DOT])dnl +AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl +]) + + +# AM_DEP_TRACK +# ------------ +AC_DEFUN([AM_DEP_TRACK], +[AC_ARG_ENABLE(dependency-tracking, +[ --disable-dependency-tracking speeds up one-time build + --enable-dependency-tracking do not reject slow dependency extractors]) +if test "x$enable_dependency_tracking" != xno; then + am_depcomp="$ac_aux_dir/depcomp" + AMDEPBACKSLASH='\' +fi +AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) +AC_SUBST([AMDEPBACKSLASH])dnl +_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl +]) + +# Generate code to set up dependency tracking. -*- Autoconf -*- + +# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +#serial 3 + +# _AM_OUTPUT_DEPENDENCY_COMMANDS +# ------------------------------ +AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], +[for mf in $CONFIG_FILES; do + # Strip MF so we end up with the name of the file. + mf=`echo "$mf" | sed -e 's/:.*$//'` + # Check whether this is an Automake generated Makefile or not. + # We used to match only the files named `Makefile.in', but + # some people rename them; so instead we look at the file content. + # Grep'ing the first line is not enough: some people post-process + # each Makefile.in and add a new line on top of each file to say so. + # Grep'ing the whole file is not good either: AIX grep has a line + # limit of 2048, but all sed's we know have understand at least 4000. + if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then + dirpart=`AS_DIRNAME("$mf")` + else + continue + fi + # Extract the definition of DEPDIR, am__include, and am__quote + # from the Makefile without running `make'. + DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` + test -z "$DEPDIR" && continue + am__include=`sed -n 's/^am__include = //p' < "$mf"` + test -z "am__include" && continue + am__quote=`sed -n 's/^am__quote = //p' < "$mf"` + # When using ansi2knr, U may be empty or an underscore; expand it + U=`sed -n 's/^U = //p' < "$mf"` + # Find all dependency output files, they are included files with + # $(DEPDIR) in their names. We invoke sed twice because it is the + # simplest approach to changing $(DEPDIR) to its actual value in the + # expansion. + for file in `sed -n " + s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ + sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do + # Make sure the directory exists. + test -f "$dirpart/$file" && continue + fdir=`AS_DIRNAME(["$file"])` + AS_MKDIR_P([$dirpart/$fdir]) + # echo "creating $dirpart/$file" + echo '# dummy' > "$dirpart/$file" + done +done +])# _AM_OUTPUT_DEPENDENCY_COMMANDS + + +# AM_OUTPUT_DEPENDENCY_COMMANDS +# ----------------------------- +# This macro should only be invoked once -- use via AC_REQUIRE. +# +# This code is only required when automatic dependency tracking +# is enabled. FIXME. This creates each `.P' file that we will +# need in order to bootstrap the dependency handling code. +AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], +[AC_CONFIG_COMMANDS([depfiles], + [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], + [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) +]) + +# Do all the work for Automake. -*- Autoconf -*- + +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, +# 2005, 2006, 2008 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 13 + +# This macro actually does too much. Some checks are only needed if +# your package does certain things. But this isn't really a big deal. + +# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) +# AM_INIT_AUTOMAKE([OPTIONS]) +# ----------------------------------------------- +# The call with PACKAGE and VERSION arguments is the old style +# call (pre autoconf-2.50), which is being phased out. PACKAGE +# and VERSION should now be passed to AC_INIT and removed from +# the call to AM_INIT_AUTOMAKE. +# We support both call styles for the transition. After +# the next Automake release, Autoconf can make the AC_INIT +# arguments mandatory, and then we can depend on a new Autoconf +# release and drop the old call support. +AC_DEFUN([AM_INIT_AUTOMAKE], +[AC_PREREQ([2.60])dnl +dnl Autoconf wants to disallow AM_ names. We explicitly allow +dnl the ones we care about. +m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl +AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl +AC_REQUIRE([AC_PROG_INSTALL])dnl +if test "`cd $srcdir && pwd`" != "`pwd`"; then + # Use -I$(srcdir) only when $(srcdir) != ., so that make's output + # is not polluted with repeated "-I." + AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl + # test to see if srcdir already configured + if test -f $srcdir/config.status; then + AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) + fi +fi + +# test whether we have cygpath +if test -z "$CYGPATH_W"; then + if (cygpath --version) >/dev/null 2>/dev/null; then + CYGPATH_W='cygpath -w' + else + CYGPATH_W=echo + fi +fi +AC_SUBST([CYGPATH_W]) + +# Define the identity of the package. +dnl Distinguish between old-style and new-style calls. +m4_ifval([$2], +[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl + AC_SUBST([PACKAGE], [$1])dnl + AC_SUBST([VERSION], [$2])], +[_AM_SET_OPTIONS([$1])dnl +dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. +m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,, + [m4_fatal([AC_INIT should be called with package and version arguments])])dnl + AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl + AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl + +_AM_IF_OPTION([no-define],, +[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) + AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl + +# Some tools Automake needs. +AC_REQUIRE([AM_SANITY_CHECK])dnl +AC_REQUIRE([AC_ARG_PROGRAM])dnl +AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}) +AM_MISSING_PROG(AUTOCONF, autoconf) +AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}) +AM_MISSING_PROG(AUTOHEADER, autoheader) +AM_MISSING_PROG(MAKEINFO, makeinfo) +AM_PROG_INSTALL_SH +AM_PROG_INSTALL_STRIP +AC_REQUIRE([AM_PROG_MKDIR_P])dnl +# We need awk for the "check" target. The system "awk" is bad on +# some platforms. +AC_REQUIRE([AC_PROG_AWK])dnl +AC_REQUIRE([AC_PROG_MAKE_SET])dnl +AC_REQUIRE([AM_SET_LEADING_DOT])dnl +_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], + [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], + [_AM_PROG_TAR([v7])])]) +_AM_IF_OPTION([no-dependencies],, +[AC_PROVIDE_IFELSE([AC_PROG_CC], + [_AM_DEPENDENCIES(CC)], + [define([AC_PROG_CC], + defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl +AC_PROVIDE_IFELSE([AC_PROG_CXX], + [_AM_DEPENDENCIES(CXX)], + [define([AC_PROG_CXX], + defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl +AC_PROVIDE_IFELSE([AC_PROG_OBJC], + [_AM_DEPENDENCIES(OBJC)], + [define([AC_PROG_OBJC], + defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl +]) +]) + + +# When config.status generates a header, we must update the stamp-h file. +# This file resides in the same directory as the config header +# that is generated. The stamp files are numbered to have different names. + +# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the +# loop where config.status creates the headers, so we can generate +# our stamp files there. +AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], +[# Compute $1's index in $config_headers. +_am_arg=$1 +_am_stamp_count=1 +for _am_header in $config_headers :; do + case $_am_header in + $_am_arg | $_am_arg:* ) + break ;; + * ) + _am_stamp_count=`expr $_am_stamp_count + 1` ;; + esac +done +echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) + +# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_PROG_INSTALL_SH +# ------------------ +# Define $install_sh. +AC_DEFUN([AM_PROG_INSTALL_SH], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +install_sh=${install_sh-"\$(SHELL) $am_aux_dir/install-sh"} +AC_SUBST(install_sh)]) + +# Copyright (C) 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 2 + +# Check whether the underlying file-system supports filenames +# with a leading dot. For instance MS-DOS doesn't. +AC_DEFUN([AM_SET_LEADING_DOT], +[rm -rf .tst 2>/dev/null +mkdir .tst 2>/dev/null +if test -d .tst; then + am__leading_dot=. +else + am__leading_dot=_ +fi +rmdir .tst 2>/dev/null +AC_SUBST([am__leading_dot])]) + +# Check to see how 'make' treats includes. -*- Autoconf -*- + +# Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 3 + +# AM_MAKE_INCLUDE() +# ----------------- +# Check to see how make treats includes. +AC_DEFUN([AM_MAKE_INCLUDE], +[am_make=${MAKE-make} +cat > confinc << 'END' +am__doit: + @echo done +.PHONY: am__doit +END +# If we don't find an include directive, just comment out the code. +AC_MSG_CHECKING([for style of include used by $am_make]) +am__include="#" +am__quote= +_am_result=none +# First try GNU make style include. +echo "include confinc" > confmf +# We grep out `Entering directory' and `Leaving directory' +# messages which can occur if `w' ends up in MAKEFLAGS. +# In particular we don't look at `^make:' because GNU make might +# be invoked under some other name (usually "gmake"), in which +# case it prints its new name instead of `make'. +if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then + am__include=include + am__quote= + _am_result=GNU +fi +# Now try BSD make style include. +if test "$am__include" = "#"; then + echo '.include "confinc"' > confmf + if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then + am__include=.include + am__quote="\"" + _am_result=BSD + fi +fi +AC_SUBST([am__include]) +AC_SUBST([am__quote]) +AC_MSG_RESULT([$_am_result]) +rm -f confinc confmf +]) + +# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- + +# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 5 + +# AM_MISSING_PROG(NAME, PROGRAM) +# ------------------------------ +AC_DEFUN([AM_MISSING_PROG], +[AC_REQUIRE([AM_MISSING_HAS_RUN]) +$1=${$1-"${am_missing_run}$2"} +AC_SUBST($1)]) + + +# AM_MISSING_HAS_RUN +# ------------------ +# Define MISSING if not defined so far and test if it supports --run. +# If it does, set am_missing_run to use it, otherwise, to nothing. +AC_DEFUN([AM_MISSING_HAS_RUN], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +AC_REQUIRE_AUX_FILE([missing])dnl +test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing" +# Use eval to expand $SHELL +if eval "$MISSING --run true"; then + am_missing_run="$MISSING --run " +else + am_missing_run= + AC_MSG_WARN([`missing' script is too old or missing]) +fi +]) + +# Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_PROG_MKDIR_P +# --------------- +# Check for `mkdir -p'. +AC_DEFUN([AM_PROG_MKDIR_P], +[AC_PREREQ([2.60])dnl +AC_REQUIRE([AC_PROG_MKDIR_P])dnl +dnl Automake 1.8 to 1.9.6 used to define mkdir_p. We now use MKDIR_P, +dnl while keeping a definition of mkdir_p for backward compatibility. +dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile. +dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of +dnl Makefile.ins that do not define MKDIR_P, so we do our own +dnl adjustment using top_builddir (which is defined more often than +dnl MKDIR_P). +AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl +case $mkdir_p in + [[\\/$]]* | ?:[[\\/]]*) ;; + */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; +esac +]) + +# Helper functions for option handling. -*- Autoconf -*- + +# Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 3 + +# _AM_MANGLE_OPTION(NAME) +# ----------------------- +AC_DEFUN([_AM_MANGLE_OPTION], +[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) + +# _AM_SET_OPTION(NAME) +# ------------------------------ +# Set option NAME. Presently that only means defining a flag for this option. +AC_DEFUN([_AM_SET_OPTION], +[m4_define(_AM_MANGLE_OPTION([$1]), 1)]) + +# _AM_SET_OPTIONS(OPTIONS) +# ---------------------------------- +# OPTIONS is a space-separated list of Automake options. +AC_DEFUN([_AM_SET_OPTIONS], +[AC_FOREACH([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) + +# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) +# ------------------------------------------- +# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. +AC_DEFUN([_AM_IF_OPTION], +[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) + +# Check to make sure that the build environment is sane. -*- Autoconf -*- + +# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 4 + +# AM_SANITY_CHECK +# --------------- +AC_DEFUN([AM_SANITY_CHECK], +[AC_MSG_CHECKING([whether build environment is sane]) +# Just in case +sleep 1 +echo timestamp > conftest.file +# Do `set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null` + if test "$[*]" = "X"; then + # -L didn't work. + set X `ls -t $srcdir/configure conftest.file` + fi + rm -f conftest.file + if test "$[*]" != "X $srcdir/configure conftest.file" \ + && test "$[*]" != "X conftest.file $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken +alias in your environment]) + fi + + test "$[2]" = conftest.file + ) +then + # Ok. + : +else + AC_MSG_ERROR([newly created file is older than distributed files! +Check your system clock]) +fi +AC_MSG_RESULT(yes)]) + +# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_PROG_INSTALL_STRIP +# --------------------- +# One issue with vendor `install' (even GNU) is that you can't +# specify the program used to strip binaries. This is especially +# annoying in cross-compiling environments, where the build's strip +# is unlikely to handle the host's binaries. +# Fortunately install-sh will honor a STRIPPROG variable, so we +# always use install-sh in `make install-strip', and initialize +# STRIPPROG with the value of the STRIP variable (set by the user). +AC_DEFUN([AM_PROG_INSTALL_STRIP], +[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl +# Installed binaries are usually stripped using `strip' when the user +# run `make install-strip'. However `strip' might not be the right +# tool to use in cross-compilation environments, therefore Automake +# will honor the `STRIP' environment variable to overrule this program. +dnl Don't test for $cross_compiling = yes, because it might be `maybe'. +if test "$cross_compiling" != no; then + AC_CHECK_TOOL([STRIP], [strip], :) +fi +INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" +AC_SUBST([INSTALL_STRIP_PROGRAM])]) + +# Copyright (C) 2006 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# _AM_SUBST_NOTMAKE(VARIABLE) +# --------------------------- +# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. +# This macro is traced by Automake. +AC_DEFUN([_AM_SUBST_NOTMAKE]) + +# Check how to create a tarball. -*- Autoconf -*- + +# Copyright (C) 2004, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 2 + +# _AM_PROG_TAR(FORMAT) +# -------------------- +# Check how to create a tarball in format FORMAT. +# FORMAT should be one of `v7', `ustar', or `pax'. +# +# Substitute a variable $(am__tar) that is a command +# writing to stdout a FORMAT-tarball containing the directory +# $tardir. +# tardir=directory && $(am__tar) > result.tar +# +# Substitute a variable $(am__untar) that extract such +# a tarball read from stdin. +# $(am__untar) < result.tar +AC_DEFUN([_AM_PROG_TAR], +[# Always define AMTAR for backward compatibility. +AM_MISSING_PROG([AMTAR], [tar]) +m4_if([$1], [v7], + [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'], + [m4_case([$1], [ustar],, [pax],, + [m4_fatal([Unknown tar format])]) +AC_MSG_CHECKING([how to create a $1 tar archive]) +# Loop over all known methods to create a tar archive until one works. +_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' +_am_tools=${am_cv_prog_tar_$1-$_am_tools} +# Do not fold the above two line into one, because Tru64 sh and +# Solaris sh will not grok spaces in the rhs of `-'. +for _am_tool in $_am_tools +do + case $_am_tool in + gnutar) + for _am_tar in tar gnutar gtar; + do + AM_RUN_LOG([$_am_tar --version]) && break + done + am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' + am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' + am__untar="$_am_tar -xf -" + ;; + plaintar) + # Must skip GNU tar: if it does not support --format= it doesn't create + # ustar tarball either. + (tar --version) >/dev/null 2>&1 && continue + am__tar='tar chf - "$$tardir"' + am__tar_='tar chf - "$tardir"' + am__untar='tar xf -' + ;; + pax) + am__tar='pax -L -x $1 -w "$$tardir"' + am__tar_='pax -L -x $1 -w "$tardir"' + am__untar='pax -r' + ;; + cpio) + am__tar='find "$$tardir" -print | cpio -o -H $1 -L' + am__tar_='find "$tardir" -print | cpio -o -H $1 -L' + am__untar='cpio -i -H $1 -d' + ;; + none) + am__tar=false + am__tar_=false + am__untar=false + ;; + esac + + # If the value was cached, stop now. We just wanted to have am__tar + # and am__untar set. + test -n "${am_cv_prog_tar_$1}" && break + + # tar/untar a dummy directory, and stop if the command works + rm -rf conftest.dir + mkdir conftest.dir + echo GrepMe > conftest.dir/file + AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) + rm -rf conftest.dir + if test -s conftest.tar; then + AM_RUN_LOG([$am__untar /dev/null 2>&1 && break + fi +done +rm -rf conftest.dir + +AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) +AC_MSG_RESULT([$am_cv_prog_tar_$1])]) +AC_SUBST([am__tar]) +AC_SUBST([am__untar]) +]) # _AM_PROG_TAR + diff --git a/Quantum Controller/SW/testapplication-0.0.1/analogue_test.c b/Quantum Controller/SW/testapplication-0.0.1/analogue_test.c new file mode 100644 index 0000000..9af1fe5 --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/analogue_test.c @@ -0,0 +1 @@ +/* --------------------------------------------------------------------------- * analogue_test.c (c) 2008 Micro-key bv * --------------------------------------------------------------------------- * Micro-key bv * Industrieweg 28, 9804 TG Noordhorn * Postbus 92, 9800 AB Zuidhorn * The Netherlands * Tel: +31 594 503020 * Fax: +31 594 505825 * Email: support@microkey.nl * Web: www.microkey.nl * --------------------------------------------------------------------------- * Description: * --------------------------------------------------------------------------- * Version(s): 0.1, Dez 11, 2008, MMi * Creation. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * System include files * --------------------------------------------------------------------------- */ #include /* --------------------------------------------------------------------------- * Application include files * --------------------------------------------------------------------------- */ #include "analogue_test.h" #include "smc4000io.h" #include "BusProtocol.h" #include "protocolfunctions.h" /* --------------------------------------------------------------------------- * Local constant and macro definitions * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Global variable definitions * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Local variable definitions * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Local function definitions * --------------------------------------------------------------------------- */ void analogueWrite (UINT8 senderId, UINT8 targetId, UINT8 requestNr, UINT8 functionId, UINT8 nrOfParams, UINT32 *params) { /* nrOfParams = 2 * params[0]: analogue output channel number * params[1]: analogue output value */ printf ("Called function: analogueWrite"); // system ("cat aioWrite0_0); } void analogueWriteAll (UINT8 senderId, UINT8 targetId, UINT8 requestNr, UINT8 functionId, UINT8 nrOfParams, UINT32 *params) { /* nrOfParams = 2 * params[0]: board type (0: MB, 1: EB) * params[1]: digital output value (0: LOW, !0: HIGH) */ printf ("Called function: analogueWriteAll"); /* Release analogue semaphore on calling device with result function */ bpSendRpcResult(bushandler, REMOTEDEVICENUMBER, 21, 1, 0, NULL); } void analogueRead (UINT8 senderId, UINT8 targetId, UINT8 requestNr, UINT8 functionId, UINT8 nrOfParams, UINT32 *params) { INT32 dioReadResult; /* nrOfParams = 1 * params[0]: analogue output channel number */ printf ("Called function: analogueRead"); // system ("echo dioWrite0_0); bpSendRpcResult(bushandler, REMOTEDEVICENUMBER, 11, 1, 1, &dioReadResult); } void analogueReadAll (UINT8 senderId, UINT8 targetId, UINT8 requestNr, UINT8 functionId, UINT8 nrOfParams, UINT32 *params) { /* nrOfParams = 1 * params[0]: board type (0: MB, 1: EB) */ INT32 aioReadAllResult[NUMBEROFAI_MB]; UINT8 channelcnt; if (params[0] == 0) { channelcnt = NUMBEROFAI_MB; } else if (params[0] == 1) { channelcnt = NUMBEROFAI_EB; } printf ("Called function: analogueReadAll"); // system ("echo dioWrite0_0); bpSendRpcResult(bushandler, REMOTEDEVICENUMBER, 14, 1, channelcnt, aioReadAllResult); } void analogueMB_test_execute (void) { printf ("THIS IS THE ANALOGUE TEST SEQUENCE"); } void analogueEB_test_execute (void) { printf ("THIS IS THE ANALOGUE TEST SEQUENCE"); } \ No newline at end of file diff --git a/Quantum Controller/SW/testapplication-0.0.1/analogue_test.h b/Quantum Controller/SW/testapplication-0.0.1/analogue_test.h new file mode 100644 index 0000000..7fa814c --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/analogue_test.h @@ -0,0 +1 @@ +/* --------------------------------------------------------------------------- * analogue_test.h (c) 2008 Micro-key bv * --------------------------------------------------------------------------- * Micro-key bv * Industrieweg 28, 9804 TG Noordhorn * Postbus 92, 9800 AB Zuidhorn * The Netherlands * Tel: +31 594 503020 * Fax: +31 594 505825 * Email: support@microkey.nl * Web: www.microkey.nl * --------------------------------------------------------------------------- * Description: * --------------------------------------------------------------------------- * Version(s): 0.1, Dez 11, 2008, MMi * Creation. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * System include files. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Application include files. * --------------------------------------------------------------------------- */ #include "BusProtocol.h" /* --------------------------------------------------------------------------- * Constant and macro definitions. * --------------------------------------------------------------------------- */ #define NUMBEROFAI_MB 6 #define NUMBEROFAO_MB 8 #define NUMBEROFAI_EB 6 #define NUMBEROFAO_EB 8 /* --------------------------------------------------------------------------- * Type definitions. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Variable declarations. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Function declarations. * --------------------------------------------------------------------------- */ void analogueWrite (UINT8 senderId, UINT8 targetId, UINT8 requestNr, UINT8 functionId, UINT8 nrOfParams, UINT32 *params); void analogueWriteAll (UINT8 senderId, UINT8 targetId, UINT8 requestNr, UINT8 functionId, UINT8 nrOfParams, UINT32 *params); void analogueRead (UINT8 senderId, UINT8 targetId, UINT8 requestNr, UINT8 functionId, UINT8 nrOfParams, UINT32 *params); void analogueReadAll (UINT8 senderId, UINT8 targetId, UINT8 requestNr, UINT8 functionId, UINT8 nrOfParams, UINT32 *params); void analogueMB_test_execute (void); void analogueEB_test_execute (void); \ No newline at end of file diff --git a/Quantum Controller/SW/testapplication-0.0.1/bus.c b/Quantum Controller/SW/testapplication-0.0.1/bus.c new file mode 100644 index 0000000..cd55558 --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/bus.c @@ -0,0 +1,175 @@ +/* --------------------------------------------------------------------------- + * bus.c - v0.1 (c) 2007 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: RS-485 bus driver + * --------------------------------------------------------------------------- + * Version(s): 0.1, 28-11-2007, fvds. + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +#include +#include +#include +#include +#include +#include +#include + +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "bus.h" +#include "protocolfunctions.h" + + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ +#define BAUDRATE B38400 +#define BUS1_DEVICE "/dev/ttyPSC1" + + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ +static int sigio_interrupt = 0; + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ + + +void busInit (t_bus_devices device) +{ + struct termios newtio; + + + bus1Handle = -1; + bus2Handle = -1; + + if (device == BUS1) + { + bus1Handle = open(BUS1_DEVICE, (O_RDWR | O_NOCTTY | O_NONBLOCK)); + if (bus1Handle == -1) + { + printf ("Failed to initialise bus interface\n"); + } + //bus1Handle = open(BUS1_DEVICE, O_RDWR | O_NOCTTY | O_NONBLOCK); + if (bus1Handle < 0) + { + perror(BUS1_DEVICE); + } + + } + + if (bus1Handle > 0) + { + bzero(&newtio, sizeof(newtio)); + + newtio.c_cflag = BAUDRATE | CRTSCTS | CS8 | CLOCAL | CREAD; + newtio.c_iflag = IGNPAR; + newtio.c_oflag = 0; + + /* set input mode (non-canonical, no echo,...) */ + newtio.c_lflag = 0; + + newtio.c_cc[VTIME] = 0; /* inter-character timer unused */ + newtio.c_cc[VMIN] = 5; /* blocking read until 5 chars received */ + + + tcflush(bus1Handle, TCIFLUSH); + tcsetattr(bus1Handle,TCSANOW,&newtio); + } +} + +/** \brief Write data of a certain length to a serial port.*/ +void busWrite ( + t_bus_devices device, + UINT16 length, /**< Lengh of data in bytes */ + UINT8 *data /**< Pointer to data */ +) +{ + int handle = (device == BUS1 ? bus1Handle: bus2Handle); + + write(handle, data, length); +} + +/** \brief Reads data from serial port. + \retval Length of received data in bytes*/ +UINT16 busRead ( + t_bus_devices device, + UINT8 * data /**< Pointer to data */ +) +{ + int handle = (device == BUS1 ? bus1Handle: bus2Handle); + + return read(handle, data, 255); +} + +/** \brief Get byte from serial port. + \retval bool Returns true if there was data */ +BOOLEAN busGet( + t_bus_devices device, + UINT8 * byte /**< Pointer to byte to return data*/ +) +{ + int handle = (device == BUS1 ? bus1Handle: bus2Handle); + + return read(handle, byte, 1); +} + +/** \brief Send byte to serial port. */ +void busPut( + t_bus_devices device, + UINT8 value /**< Byte to send*/ +) +{ + int handle = (device == BUS1 ? bus1Handle: bus2Handle); + + write(handle, &value, 1); +} + +/** \brief Flush serial port buffers. */ +void busFlush( + t_bus_devices device +) +{ + int handle = (device == BUS1 ? bus1Handle: bus2Handle); + + tcflush(handle, TCIOFLUSH); // Flushes both input as output +} + +/** \brief Check if receive buffers is empty. + \retval bool Returns true if recieve buffer is empty */ +BOOLEAN busEmpty( + t_bus_devices device +) +{ + return FALSE; +} + + + diff --git a/Quantum Controller/SW/testapplication-0.0.1/bus.h b/Quantum Controller/SW/testapplication-0.0.1/bus.h new file mode 100644 index 0000000..af79a5e --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/bus.h @@ -0,0 +1,106 @@ +/* --------------------------------------------------------------------------- + * bus.h - v0.1 (c) 2007 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: RS485 interface. + * --------------------------------------------------------------------------- + * Version(s): 0.1, 10-09-2007, Marcel Mulder. + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef __BUS_H__ +#define __BUS_H__ + +/** \file bus.h + \brief RS485 (UART) interface. +*/ +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ +#include "BpPort.h" + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ +typedef enum +{ + BUS1, /**< First RS485 port*/ + BUS2 /**< Second RS485 port*/ +} t_bus_devices; + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ +int bus1Handle; +int bus2Handle; + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ +/** \brief Initialize of serial bus interface.*/ +void busInit ( + t_bus_devices device +); + +/** \brief Write data of a certain length to a serial bus.*/ +void busWrite ( + t_bus_devices device, + UINT16 length, /**< Lengh of data in bytes */ + UINT8 * data /**< Pointer to data */ +); + +/** \brief Reads data from serial bus. + \retval Lengt of received data in bytes*/ +UINT16 busRead ( + t_bus_devices device, + UINT8 * data /**< Pointer to data */ +); + +/** \brief Get byte from serial bus. + \retval bool Returns true if there was data */ +BOOLEAN busGet( + t_bus_devices device, + UINT8 * byte /**< Pointer to byte to return data*/ +); + +/** \brief Send byte to serial bus. */ +void busPut( + t_bus_devices device, + UINT8 value /**< Byte to send*/ +); + +/** \brief Flush serial bus buffers. */ +void busFlush( + t_bus_devices device +); + +/** \brief Check if receive buffers is empty. + \retval bool Returns true if recieve buffer is empty +*/ +BOOLEAN busEmpty( + t_bus_devices device +); + +#endif /* __BUS_H__ */ diff --git a/Quantum Controller/SW/testapplication-0.0.1/config.log b/Quantum Controller/SW/testapplication-0.0.1/config.log new file mode 100644 index 0000000..d97b7e2 --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/config.log @@ -0,0 +1,827 @@ +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. + +It was created by creGpioDae configure 0.0.1, which was +generated by GNU Autoconf 2.61. Invocation command line was + + $ ./configure --target=powerpc-linux --host=powerpc-linux --build=x86_64-pc-linux-gnu --prefix=/usr --sysconfdir=/etc --disable-nls --disable-largefile + +## --------- ## +## Platform. ## +## --------- ## + +hostname = marvin +uname -m = x86_64 +uname -r = 2.6.27-9-server +uname -s = Linux +uname -v = #1 SMP Thu Nov 20 22:56:07 UTC 2008 + +/usr/bin/uname -p = unknown +/bin/uname -X = unknown + +/bin/arch = unknown +/usr/bin/arch -k = unknown +/usr/convex/getsysinfo = unknown +/usr/bin/hostinfo = unknown +/bin/machine = unknown +/usr/bin/oslevel = unknown +/bin/universe = unknown + +PATH: /home/microkey/mmi/Projects/QUA_2475/buildroot/toolchain_build_powerpc/bin +PATH: /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/bin +PATH: /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin +PATH: /home/microkey/mmi/usr/local/arm/arm-2007q3/bin +PATH: /usr/local/sbin +PATH: /usr/local/bin +PATH: /usr/sbin +PATH: /usr/bin +PATH: /sbin +PATH: /bin +PATH: /usr/games + + +## ----------- ## +## Core tests. ## +## ----------- ## + +configure:1773: checking for a BSD-compatible install +configure:1829: result: /usr/bin/install -c +configure:1840: checking whether build environment is sane +configure:1883: result: yes +configure:1911: checking for a thread-safe mkdir -p +configure:1950: result: /bin/mkdir -p +configure:1963: checking for gawk +configure:1979: found /usr/bin/gawk +configure:1990: result: gawk +configure:2001: checking whether make sets $(MAKE) +configure:2022: result: yes +configure:2102: checking for powerpc-linux-strip +configure:2129: result: /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-strip +configure:2228: checking for powerpc-linux-gcc +configure:2255: result: /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-gcc -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e +configure:2533: checking for C compiler version +configure:2540: /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-gcc -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e --version >&5 +powerpc-linux-uclibc-gcc (GCC) 4.2.4 +Copyright (C) 2007 Free Software Foundation, Inc. +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +configure:2543: $? = 0 +configure:2550: /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-gcc -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e -v >&5 +Using built-in specs. +Target: powerpc-linux-uclibc +Configured with: /home/microkey/mmi/Projects/QUA_2475/buildroot/toolchain_build_powerpc/gcc-4.2.4/configure --prefix=/usr --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --target=powerpc-linux-uclibc --enable-languages=c --with-sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir --with-build-time-tools=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/powerpc-linux-uclibc/bin --disable-__cxa_atexit --enable-target-optspace --with-gnu-ld --enable-shared --with-gmp=/home/microkey/mmi/Projects/QUA_2475/buildroot/toolchain_build_powerpc/gmp --with-mpfr=/home/microkey/mmi/Projects/QUA_2475/buildroot/toolchain_build_powerpc/mpfr --disable-nls --enable-threads --disable-multilib --with-tune=603e --disable-largefile +Thread model: posix +gcc version 4.2.4 +configure:2553: $? = 0 +configure:2560: /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-gcc -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e -V >&5 +powerpc-linux-uclibc-gcc: '-V' must come at the start of the command line +configure:2563: $? = 1 +configure:2586: checking for C compiler default output file name +configure:2613: /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-gcc -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e -L/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/lib -L/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/lib --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ conftest.c >&5 +configure:2616: $? = 0 +configure:2654: result: a.out +configure:2671: checking whether the C compiler works +configure:2701: result: yes +configure:2708: checking whether we are cross compiling +configure:2710: result: yes +configure:2713: checking for suffix of executables +configure:2720: /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-gcc -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e -o conftest -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e -L/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/lib -L/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/lib --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ conftest.c >&5 +configure:2723: $? = 0 +configure:2747: result: +configure:2753: checking for suffix of object files +configure:2779: /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-gcc -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e -c -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e conftest.c >&5 +configure:2782: $? = 0 +configure:2805: result: o +configure:2809: checking whether we are using the GNU C compiler +configure:2838: /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-gcc -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e -c -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e conftest.c >&5 +configure:2844: $? = 0 +configure:2861: result: yes +configure:2866: checking whether /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-gcc -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e accepts -g +configure:2896: /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-gcc -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e -c -g conftest.c >&5 +configure:2902: $? = 0 +configure:3001: result: yes +configure:3018: checking for /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-gcc -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e option to accept ISO C89 +configure:3092: /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-gcc -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e -c -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e conftest.c >&5 +configure:3098: $? = 0 +configure:3121: result: none needed +configure:3150: checking for style of include used by make +configure:3178: result: GNU +configure:3203: checking dependency style of /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-gcc -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e +configure:3294: result: gcc3 +configure:3322: checking for a BSD-compatible install +configure:3378: result: /usr/bin/install -c +configure:3400: checking for dirent.h that defines DIR +configure:3429: /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-gcc -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e -c -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e conftest.c >&5 +configure:3435: $? = 0 +configure:3451: result: yes +configure:3464: checking for library containing opendir +configure:3505: /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-gcc -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e -o conftest -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e -L/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/lib -L/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/lib --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ conftest.c >&5 +configure:3511: $? = 0 +configure:3539: result: none required +configure:3638: checking how to run the C preprocessor +configure:3754: result: /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-cpp -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e +configure:3783: /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-cpp -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e conftest.c +configure:3789: $? = 0 +configure:3820: /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-cpp -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e conftest.c +conftest.c:12:28: error: ac_nonexistent.h: No such file or directory +configure:3826: $? = 1 +configure: failed program was: +| /* confdefs.h. */ +| #define PACKAGE_NAME "creGpioDae" +| #define PACKAGE_TARNAME "cregpiodae" +| #define PACKAGE_VERSION "0.0.1" +| #define PACKAGE_STRING "creGpioDae 0.0.1" +| #define PACKAGE_BUGREPORT "" +| #define PACKAGE "cregpiodae" +| #define VERSION "0.0.1" +| #define _GNU_SOURCE 1 +| #define HAVE_DIRENT_H 1 +| /* end confdefs.h. */ +| #include +configure:3864: checking for grep that handles long lines and -e +configure:3938: result: /bin/grep +configure:3943: checking for egrep +configure:4021: result: /bin/grep -E +configure:4026: checking for ANSI C header files +configure:4056: /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-gcc -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e -c -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e conftest.c >&5 +configure:4062: $? = 0 +configure:4190: result: yes +configure:4214: checking for sys/types.h +configure:4235: /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-gcc -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e -c -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e conftest.c >&5 +configure:4241: $? = 0 +configure:4257: result: yes +configure:4214: checking for sys/stat.h +configure:4235: /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-gcc -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e -c -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e conftest.c >&5 +configure:4241: $? = 0 +configure:4257: result: yes +configure:4214: checking for stdlib.h +configure:4235: /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-gcc -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e -c -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e conftest.c >&5 +configure:4241: $? = 0 +configure:4257: result: yes +configure:4214: checking for string.h +configure:4235: /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-gcc -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e -c -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e conftest.c >&5 +configure:4241: $? = 0 +configure:4257: result: yes +configure:4214: checking for memory.h +configure:4235: /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-gcc -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e -c -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e conftest.c >&5 +configure:4241: $? = 0 +configure:4257: result: yes +configure:4214: checking for strings.h +configure:4235: /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-gcc -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e -c -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e conftest.c >&5 +configure:4241: $? = 0 +configure:4257: result: yes +configure:4214: checking for inttypes.h +configure:4235: /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-gcc -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e -c -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e conftest.c >&5 +configure:4241: $? = 0 +configure:4257: result: yes +configure:4214: checking for stdint.h +configure:4235: /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-gcc -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e -c -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e conftest.c >&5 +configure:4241: $? = 0 +configure:4257: result: yes +configure:4214: checking for unistd.h +configure:4235: /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-gcc -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e -c -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e conftest.c >&5 +configure:4241: $? = 0 +configure:4257: result: yes +configure:4285: checking parser.h usability +configure:4302: /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-gcc -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e -c -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e conftest.c >&5 +conftest.c:55:20: error: parser.h: No such file or directory +configure:4308: $? = 1 +configure: failed program was: +| /* confdefs.h. */ +| #define PACKAGE_NAME "creGpioDae" +| #define PACKAGE_TARNAME "cregpiodae" +| #define PACKAGE_VERSION "0.0.1" +| #define PACKAGE_STRING "creGpioDae 0.0.1" +| #define PACKAGE_BUGREPORT "" +| #define PACKAGE "cregpiodae" +| #define VERSION "0.0.1" +| #define _GNU_SOURCE 1 +| #define HAVE_DIRENT_H 1 +| #define STDC_HEADERS 1 +| #define HAVE_SYS_TYPES_H 1 +| #define HAVE_SYS_STAT_H 1 +| #define HAVE_STDLIB_H 1 +| #define HAVE_STRING_H 1 +| #define HAVE_MEMORY_H 1 +| #define HAVE_STRINGS_H 1 +| #define HAVE_INTTYPES_H 1 +| #define HAVE_STDINT_H 1 +| #define HAVE_UNISTD_H 1 +| /* end confdefs.h. */ +| #include +| #ifdef HAVE_SYS_TYPES_H +| # include +| #endif +| #ifdef HAVE_SYS_STAT_H +| # include +| #endif +| #ifdef STDC_HEADERS +| # include +| # include +| #else +| # ifdef HAVE_STDLIB_H +| # include +| # endif +| #endif +| #ifdef HAVE_STRING_H +| # if !defined STDC_HEADERS && defined HAVE_MEMORY_H +| # include +| # endif +| # include +| #endif +| #ifdef HAVE_STRINGS_H +| # include +| #endif +| #ifdef HAVE_INTTYPES_H +| # include +| #endif +| #ifdef HAVE_STDINT_H +| # include +| #endif +| #ifdef HAVE_UNISTD_H +| # include +| #endif +| #include +configure:4322: result: no +configure:4326: checking parser.h presence +configure:4341: /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-cpp -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e conftest.c +conftest.c:22:20: error: parser.h: No such file or directory +configure:4347: $? = 1 +configure: failed program was: +| /* confdefs.h. */ +| #define PACKAGE_NAME "creGpioDae" +| #define PACKAGE_TARNAME "cregpiodae" +| #define PACKAGE_VERSION "0.0.1" +| #define PACKAGE_STRING "creGpioDae 0.0.1" +| #define PACKAGE_BUGREPORT "" +| #define PACKAGE "cregpiodae" +| #define VERSION "0.0.1" +| #define _GNU_SOURCE 1 +| #define HAVE_DIRENT_H 1 +| #define STDC_HEADERS 1 +| #define HAVE_SYS_TYPES_H 1 +| #define HAVE_SYS_STAT_H 1 +| #define HAVE_STDLIB_H 1 +| #define HAVE_STRING_H 1 +| #define HAVE_MEMORY_H 1 +| #define HAVE_STRINGS_H 1 +| #define HAVE_INTTYPES_H 1 +| #define HAVE_STDINT_H 1 +| #define HAVE_UNISTD_H 1 +| /* end confdefs.h. */ +| #include +configure:4361: result: no +configure:4389: checking for parser.h +configure:4397: result: no +configure:4285: checking iniparser.h usability +configure:4302: /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-gcc -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e -c -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e conftest.c >&5 +conftest.c:55:23: error: iniparser.h: No such file or directory +configure:4308: $? = 1 +configure: failed program was: +| /* confdefs.h. */ +| #define PACKAGE_NAME "creGpioDae" +| #define PACKAGE_TARNAME "cregpiodae" +| #define PACKAGE_VERSION "0.0.1" +| #define PACKAGE_STRING "creGpioDae 0.0.1" +| #define PACKAGE_BUGREPORT "" +| #define PACKAGE "cregpiodae" +| #define VERSION "0.0.1" +| #define _GNU_SOURCE 1 +| #define HAVE_DIRENT_H 1 +| #define STDC_HEADERS 1 +| #define HAVE_SYS_TYPES_H 1 +| #define HAVE_SYS_STAT_H 1 +| #define HAVE_STDLIB_H 1 +| #define HAVE_STRING_H 1 +| #define HAVE_MEMORY_H 1 +| #define HAVE_STRINGS_H 1 +| #define HAVE_INTTYPES_H 1 +| #define HAVE_STDINT_H 1 +| #define HAVE_UNISTD_H 1 +| /* end confdefs.h. */ +| #include +| #ifdef HAVE_SYS_TYPES_H +| # include +| #endif +| #ifdef HAVE_SYS_STAT_H +| # include +| #endif +| #ifdef STDC_HEADERS +| # include +| # include +| #else +| # ifdef HAVE_STDLIB_H +| # include +| # endif +| #endif +| #ifdef HAVE_STRING_H +| # if !defined STDC_HEADERS && defined HAVE_MEMORY_H +| # include +| # endif +| # include +| #endif +| #ifdef HAVE_STRINGS_H +| # include +| #endif +| #ifdef HAVE_INTTYPES_H +| # include +| #endif +| #ifdef HAVE_STDINT_H +| # include +| #endif +| #ifdef HAVE_UNISTD_H +| # include +| #endif +| #include +configure:4322: result: no +configure:4326: checking iniparser.h presence +configure:4341: /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-cpp -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e conftest.c +conftest.c:22:23: error: iniparser.h: No such file or directory +configure:4347: $? = 1 +configure: failed program was: +| /* confdefs.h. */ +| #define PACKAGE_NAME "creGpioDae" +| #define PACKAGE_TARNAME "cregpiodae" +| #define PACKAGE_VERSION "0.0.1" +| #define PACKAGE_STRING "creGpioDae 0.0.1" +| #define PACKAGE_BUGREPORT "" +| #define PACKAGE "cregpiodae" +| #define VERSION "0.0.1" +| #define _GNU_SOURCE 1 +| #define HAVE_DIRENT_H 1 +| #define STDC_HEADERS 1 +| #define HAVE_SYS_TYPES_H 1 +| #define HAVE_SYS_STAT_H 1 +| #define HAVE_STDLIB_H 1 +| #define HAVE_STRING_H 1 +| #define HAVE_MEMORY_H 1 +| #define HAVE_STRINGS_H 1 +| #define HAVE_INTTYPES_H 1 +| #define HAVE_STDINT_H 1 +| #define HAVE_UNISTD_H 1 +| /* end confdefs.h. */ +| #include +configure:4361: result: no +configure:4389: checking for iniparser.h +configure:4397: result: no +configure:4426: checking dictionary.h usability +configure:4443: /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-gcc -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e -c -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e conftest.c >&5 +conftest.c:55:24: error: dictionary.h: No such file or directory +configure:4449: $? = 1 +configure: failed program was: +| /* confdefs.h. */ +| #define PACKAGE_NAME "creGpioDae" +| #define PACKAGE_TARNAME "cregpiodae" +| #define PACKAGE_VERSION "0.0.1" +| #define PACKAGE_STRING "creGpioDae 0.0.1" +| #define PACKAGE_BUGREPORT "" +| #define PACKAGE "cregpiodae" +| #define VERSION "0.0.1" +| #define _GNU_SOURCE 1 +| #define HAVE_DIRENT_H 1 +| #define STDC_HEADERS 1 +| #define HAVE_SYS_TYPES_H 1 +| #define HAVE_SYS_STAT_H 1 +| #define HAVE_STDLIB_H 1 +| #define HAVE_STRING_H 1 +| #define HAVE_MEMORY_H 1 +| #define HAVE_STRINGS_H 1 +| #define HAVE_INTTYPES_H 1 +| #define HAVE_STDINT_H 1 +| #define HAVE_UNISTD_H 1 +| /* end confdefs.h. */ +| #include +| #ifdef HAVE_SYS_TYPES_H +| # include +| #endif +| #ifdef HAVE_SYS_STAT_H +| # include +| #endif +| #ifdef STDC_HEADERS +| # include +| # include +| #else +| # ifdef HAVE_STDLIB_H +| # include +| # endif +| #endif +| #ifdef HAVE_STRING_H +| # if !defined STDC_HEADERS && defined HAVE_MEMORY_H +| # include +| # endif +| # include +| #endif +| #ifdef HAVE_STRINGS_H +| # include +| #endif +| #ifdef HAVE_INTTYPES_H +| # include +| #endif +| #ifdef HAVE_STDINT_H +| # include +| #endif +| #ifdef HAVE_UNISTD_H +| # include +| #endif +| #include +configure:4463: result: no +configure:4467: checking dictionary.h presence +configure:4482: /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-cpp -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e conftest.c +conftest.c:22:24: error: dictionary.h: No such file or directory +configure:4488: $? = 1 +configure: failed program was: +| /* confdefs.h. */ +| #define PACKAGE_NAME "creGpioDae" +| #define PACKAGE_TARNAME "cregpiodae" +| #define PACKAGE_VERSION "0.0.1" +| #define PACKAGE_STRING "creGpioDae 0.0.1" +| #define PACKAGE_BUGREPORT "" +| #define PACKAGE "cregpiodae" +| #define VERSION "0.0.1" +| #define _GNU_SOURCE 1 +| #define HAVE_DIRENT_H 1 +| #define STDC_HEADERS 1 +| #define HAVE_SYS_TYPES_H 1 +| #define HAVE_SYS_STAT_H 1 +| #define HAVE_STDLIB_H 1 +| #define HAVE_STRING_H 1 +| #define HAVE_MEMORY_H 1 +| #define HAVE_STRINGS_H 1 +| #define HAVE_INTTYPES_H 1 +| #define HAVE_STDINT_H 1 +| #define HAVE_UNISTD_H 1 +| /* end confdefs.h. */ +| #include +configure:4502: result: no +configure:4530: checking for dictionary.h +configure:4538: result: no +configure:4426: checking inistrings.h usability +configure:4443: /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-gcc -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e -c -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e conftest.c >&5 +conftest.c:55:24: error: inistrings.h: No such file or directory +configure:4449: $? = 1 +configure: failed program was: +| /* confdefs.h. */ +| #define PACKAGE_NAME "creGpioDae" +| #define PACKAGE_TARNAME "cregpiodae" +| #define PACKAGE_VERSION "0.0.1" +| #define PACKAGE_STRING "creGpioDae 0.0.1" +| #define PACKAGE_BUGREPORT "" +| #define PACKAGE "cregpiodae" +| #define VERSION "0.0.1" +| #define _GNU_SOURCE 1 +| #define HAVE_DIRENT_H 1 +| #define STDC_HEADERS 1 +| #define HAVE_SYS_TYPES_H 1 +| #define HAVE_SYS_STAT_H 1 +| #define HAVE_STDLIB_H 1 +| #define HAVE_STRING_H 1 +| #define HAVE_MEMORY_H 1 +| #define HAVE_STRINGS_H 1 +| #define HAVE_INTTYPES_H 1 +| #define HAVE_STDINT_H 1 +| #define HAVE_UNISTD_H 1 +| /* end confdefs.h. */ +| #include +| #ifdef HAVE_SYS_TYPES_H +| # include +| #endif +| #ifdef HAVE_SYS_STAT_H +| # include +| #endif +| #ifdef STDC_HEADERS +| # include +| # include +| #else +| # ifdef HAVE_STDLIB_H +| # include +| # endif +| #endif +| #ifdef HAVE_STRING_H +| # if !defined STDC_HEADERS && defined HAVE_MEMORY_H +| # include +| # endif +| # include +| #endif +| #ifdef HAVE_STRINGS_H +| # include +| #endif +| #ifdef HAVE_INTTYPES_H +| # include +| #endif +| #ifdef HAVE_STDINT_H +| # include +| #endif +| #ifdef HAVE_UNISTD_H +| # include +| #endif +| #include +configure:4463: result: no +configure:4467: checking inistrings.h presence +configure:4482: /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-cpp -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e conftest.c +conftest.c:22:24: error: inistrings.h: No such file or directory +configure:4488: $? = 1 +configure: failed program was: +| /* confdefs.h. */ +| #define PACKAGE_NAME "creGpioDae" +| #define PACKAGE_TARNAME "cregpiodae" +| #define PACKAGE_VERSION "0.0.1" +| #define PACKAGE_STRING "creGpioDae 0.0.1" +| #define PACKAGE_BUGREPORT "" +| #define PACKAGE "cregpiodae" +| #define VERSION "0.0.1" +| #define _GNU_SOURCE 1 +| #define HAVE_DIRENT_H 1 +| #define STDC_HEADERS 1 +| #define HAVE_SYS_TYPES_H 1 +| #define HAVE_SYS_STAT_H 1 +| #define HAVE_STDLIB_H 1 +| #define HAVE_STRING_H 1 +| #define HAVE_MEMORY_H 1 +| #define HAVE_STRINGS_H 1 +| #define HAVE_INTTYPES_H 1 +| #define HAVE_STDINT_H 1 +| #define HAVE_UNISTD_H 1 +| /* end confdefs.h. */ +| #include +configure:4502: result: no +configure:4530: checking for inistrings.h +configure:4538: result: no +configure:4567: checking math.h usability +configure:4584: /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-gcc -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e -c -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e conftest.c >&5 +configure:4590: $? = 0 +configure:4604: result: yes +configure:4608: checking math.h presence +configure:4623: /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-cpp -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e conftest.c +configure:4629: $? = 0 +configure:4643: result: yes +configure:4671: checking for math.h +configure:4679: result: yes +configure:4567: checking stdio.h usability +configure:4584: /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-gcc -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e -c -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e conftest.c >&5 +configure:4590: $? = 0 +configure:4604: result: yes +configure:4608: checking stdio.h presence +configure:4623: /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-cpp -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e conftest.c +configure:4629: $? = 0 +configure:4643: result: yes +configure:4671: checking for stdio.h +configure:4679: result: yes +configure:4716: checking fcntl.h usability +configure:4733: /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-gcc -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e -c -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e conftest.c >&5 +configure:4739: $? = 0 +configure:4753: result: yes +configure:4757: checking fcntl.h presence +configure:4772: /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-cpp -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e conftest.c +configure:4778: $? = 0 +configure:4792: result: yes +configure:4820: checking for fcntl.h +configure:4828: result: yes +configure:4706: checking for inttypes.h +configure:4712: result: yes +configure:4716: checking limits.h usability +configure:4733: /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-gcc -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e -c -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e conftest.c >&5 +configure:4739: $? = 0 +configure:4753: result: yes +configure:4757: checking limits.h presence +configure:4772: /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-cpp -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e conftest.c +configure:4778: $? = 0 +configure:4792: result: yes +configure:4820: checking for limits.h +configure:4828: result: yes +configure:4706: checking for memory.h +configure:4712: result: yes +configure:4716: checking stddef.h usability +configure:4733: /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-gcc -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e -c -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e conftest.c >&5 +configure:4739: $? = 0 +configure:4753: result: yes +configure:4757: checking stddef.h presence +configure:4772: /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-cpp -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e conftest.c +configure:4778: $? = 0 +configure:4792: result: yes +configure:4820: checking for stddef.h +configure:4828: result: yes +configure:4706: checking for stdint.h +configure:4712: result: yes +configure:4706: checking for stdlib.h +configure:4712: result: yes +configure:4706: checking for string.h +configure:4712: result: yes +configure:4706: checking for strings.h +configure:4712: result: yes +configure:4706: checking for unistd.h +configure:4712: result: yes +configure:4844: checking for an ANSI C-conforming const +configure:4919: /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-gcc -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e -c -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e conftest.c >&5 +configure:4925: $? = 0 +configure:4940: result: yes +configure:5107: creating ./config.status + +## ---------------------- ## +## Running config.status. ## +## ---------------------- ## + +This file was extended by creGpioDae config.status 0.0.1, which was +generated by GNU Autoconf 2.61. Invocation command line was + + CONFIG_FILES = + CONFIG_HEADERS = + CONFIG_LINKS = + CONFIG_COMMANDS = + $ ./config.status + +on marvin + +config.status:5808: creating Makefile +config.status:6005: executing depfiles commands + +## ---------------- ## +## Cache variables. ## +## ---------------- ## + +ac_cv_c_bigendian='yes' +ac_cv_c_compiler_gnu='yes' +ac_cv_c_const='yes' +ac_cv_env_CC_set='set' +ac_cv_env_CC_value='/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-gcc -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e' +ac_cv_env_CFLAGS_set='set' +ac_cv_env_CFLAGS_value='-Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e' +ac_cv_env_CPPFLAGS_set='' +ac_cv_env_CPPFLAGS_value='' +ac_cv_env_CPP_set='set' +ac_cv_env_CPP_value='/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-cpp -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e' +ac_cv_env_LDFLAGS_set='set' +ac_cv_env_LDFLAGS_value='-L/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/lib -L/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/lib --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/' +ac_cv_env_LIBS_set='' +ac_cv_env_LIBS_value='' +ac_cv_env_build_alias_set='set' +ac_cv_env_build_alias_value='x86_64-pc-linux-gnu' +ac_cv_env_host_alias_set='set' +ac_cv_env_host_alias_value='powerpc-linux' +ac_cv_env_target_alias_set='set' +ac_cv_env_target_alias_value='powerpc-linux' +ac_cv_func_calloc_0_nonnull='yes' +ac_cv_func_malloc_0_nonnull='yes' +ac_cv_func_memcmp_working='yes' +ac_cv_func_mmap_fixed_mapped='yes' +ac_cv_func_realloc_0_nonnull='yes' +ac_cv_have_decl_malloc='yes' +ac_cv_header_dictionary_h='no' +ac_cv_header_dirent_dirent_h='yes' +ac_cv_header_fcntl_h='yes' +ac_cv_header_iniparser_h='no' +ac_cv_header_inistrings_h='no' +ac_cv_header_inttypes_h='yes' +ac_cv_header_limits_h='yes' +ac_cv_header_math_h='yes' +ac_cv_header_memory_h='yes' +ac_cv_header_parser_h='no' +ac_cv_header_stdc='yes' +ac_cv_header_stddef_h='yes' +ac_cv_header_stdint_h='yes' +ac_cv_header_stdio_h='yes' +ac_cv_header_stdlib_h='yes' +ac_cv_header_string_h='yes' +ac_cv_header_strings_h='yes' +ac_cv_header_sys_stat_h='yes' +ac_cv_header_sys_types_h='yes' +ac_cv_header_unistd_h='yes' +ac_cv_lbl_unaligned_fail='yes' +ac_cv_objext='o' +ac_cv_path_EGREP='/bin/grep -E' +ac_cv_path_GREP='/bin/grep' +ac_cv_path_install='/usr/bin/install -c' +ac_cv_path_mkdir='/bin/mkdir' +ac_cv_prog_AWK='gawk' +ac_cv_prog_CC='/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-gcc -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e' +ac_cv_prog_CPP='/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-cpp -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e' +ac_cv_prog_STRIP='/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-strip' +ac_cv_prog_cc_c89='' +ac_cv_prog_cc_g='yes' +ac_cv_prog_make_make_set='yes' +ac_cv_search_opendir='none required' +am_cv_CC_dependencies_compiler_type='gcc3' +gl_cv_func_malloc_0_nonnull='yes' + +## ----------------- ## +## Output variables. ## +## ----------------- ## + +ACLOCAL='${SHELL} /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/testapplication-0.0.1/missing --run aclocal-1.10' +AMDEPBACKSLASH='\' +AMDEP_FALSE='#' +AMDEP_TRUE='' +AMTAR='${SHELL} /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/testapplication-0.0.1/missing --run tar' +AUTOCONF='${SHELL} /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/testapplication-0.0.1/missing --run autoconf' +AUTOHEADER='${SHELL} /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/testapplication-0.0.1/missing --run autoheader' +AUTOMAKE='${SHELL} /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/testapplication-0.0.1/missing --run automake-1.10' +AWK='gawk' +CC='/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-gcc -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e' +CCDEPMODE='depmode=gcc3' +CFLAGS='-Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e' +CPP='/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-cpp -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e' +CPPFLAGS='' +CYGPATH_W='echo' +DEFS='-DPACKAGE_NAME=\"creGpioDae\" -DPACKAGE_TARNAME=\"cregpiodae\" -DPACKAGE_VERSION=\"0.0.1\" -DPACKAGE_STRING=\"creGpioDae\ 0.0.1\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE=\"cregpiodae\" -DVERSION=\"0.0.1\" -D_GNU_SOURCE=1 -DHAVE_DIRENT_H=1 -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_MATH_H=1 -DHAVE_STDIO_H=1 -DHAVE_FCNTL_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_LIMITS_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STDDEF_H=1 -DHAVE_STDINT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_STRINGS_H=1 -DHAVE_UNISTD_H=1' +DEPDIR='.deps' +ECHO_C='' +ECHO_N='-n' +ECHO_T='' +EGREP='/bin/grep -E' +EXEEXT='' +GREP='/bin/grep' +INSTALL_DATA='${INSTALL} -m 644' +INSTALL_PROGRAM='${INSTALL}' +INSTALL_SCRIPT='${INSTALL}' +INSTALL_STRIP_PROGRAM='$(install_sh) -c -s' +LDFLAGS='-L/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/lib -L/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/lib --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/' +LIBOBJS='' +LIBS='' +LTLIBOBJS='' +MAKEINFO='${SHELL} /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/testapplication-0.0.1/missing --run makeinfo' +OBJEXT='o' +PACKAGE='cregpiodae' +PACKAGE_BUGREPORT='' +PACKAGE_NAME='creGpioDae' +PACKAGE_STRING='creGpioDae 0.0.1' +PACKAGE_TARNAME='cregpiodae' +PACKAGE_VERSION='0.0.1' +PATH_SEPARATOR=':' +SET_MAKE='' +SHELL='/bin/bash' +STRIP='/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-strip' +VERSION='0.0.1' +ac_ct_CC='' +am__fastdepCC_FALSE='#' +am__fastdepCC_TRUE='' +am__include='include' +am__isrc='' +am__leading_dot='.' +am__quote='' +am__tar='${AMTAR} chof - "$$tardir"' +am__untar='${AMTAR} xf -' +bindir='${exec_prefix}/bin' +build_alias='x86_64-pc-linux-gnu' +datadir='${datarootdir}' +datarootdir='${prefix}/share' +docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' +dvidir='${docdir}' +exec_prefix='${prefix}' +host_alias='powerpc-linux' +htmldir='${docdir}' +includedir='${prefix}/include' +infodir='${datarootdir}/info' +install_sh='$(SHELL) /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/testapplication-0.0.1/install-sh' +libdir='${exec_prefix}/lib' +libexecdir='${exec_prefix}/libexec' +localedir='${datarootdir}/locale' +localstatedir='${prefix}/var' +mandir='${datarootdir}/man' +mkdir_p='/bin/mkdir -p' +oldincludedir='/usr/include' +pdfdir='${docdir}' +prefix='/usr' +program_transform_name='s,x,x,' +psdir='${docdir}' +sbindir='${exec_prefix}/sbin' +sharedstatedir='${prefix}/com' +sysconfdir='/etc' +target_alias='powerpc-linux' + +## ----------- ## +## confdefs.h. ## +## ----------- ## + +#define PACKAGE_NAME "creGpioDae" +#define PACKAGE_TARNAME "cregpiodae" +#define PACKAGE_VERSION "0.0.1" +#define PACKAGE_STRING "creGpioDae 0.0.1" +#define PACKAGE_BUGREPORT "" +#define PACKAGE "cregpiodae" +#define VERSION "0.0.1" +#define _GNU_SOURCE 1 +#define HAVE_DIRENT_H 1 +#define STDC_HEADERS 1 +#define HAVE_SYS_TYPES_H 1 +#define HAVE_SYS_STAT_H 1 +#define HAVE_STDLIB_H 1 +#define HAVE_STRING_H 1 +#define HAVE_MEMORY_H 1 +#define HAVE_STRINGS_H 1 +#define HAVE_INTTYPES_H 1 +#define HAVE_STDINT_H 1 +#define HAVE_UNISTD_H 1 +#define HAVE_MATH_H 1 +#define HAVE_STDIO_H 1 +#define HAVE_FCNTL_H 1 +#define HAVE_INTTYPES_H 1 +#define HAVE_LIMITS_H 1 +#define HAVE_MEMORY_H 1 +#define HAVE_STDDEF_H 1 +#define HAVE_STDINT_H 1 +#define HAVE_STDLIB_H 1 +#define HAVE_STRING_H 1 +#define HAVE_STRINGS_H 1 +#define HAVE_UNISTD_H 1 + +configure: exit 0 diff --git a/Quantum Controller/SW/testapplication-0.0.1/config.status b/Quantum Controller/SW/testapplication-0.0.1/config.status new file mode 100644 index 0000000..cf500c5 --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/config.status @@ -0,0 +1,945 @@ +#! /bin/bash +# Generated by configure. +# Run this file to recreate the current configuration. +# Compiler output produced by configure, useful for debugging +# configure, is in config.log if it exists. + +debug=false +ac_cs_recheck=false +ac_cs_silent=false +SHELL=${CONFIG_SHELL-/bin/bash} +## --------------------- ## +## M4sh Initialization. ## +## --------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + + + +# PATH needs CR +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + +# Support unset when possible. +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +as_nl=' +' +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +case $0 in + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + { (exit 1); exit 1; } +fi + +# Work around bugs in pre-3.0 UWIN ksh. +for as_var in ENV MAIL MAILPATH +do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +for as_var in \ + LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ + LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ + LC_TELEPHONE LC_TIME +do + if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then + eval $as_var=C; export $as_var + else + ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var + fi +done + +# Required to use basename. +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + + +# Name of the executable. +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# CDPATH. +$as_unset CDPATH + + + + as_lineno_1=5269 + as_lineno_2=5270 + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { + + # Create $as_me.lineno as a copy of $as_myself, but with 5274 + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line after each line using 5276; the second 'sed' + # does the real work. The second script uses 'N' to pair each + # line-number line with the line containing 5278, and appends + # trailing '-' during substitution so that 5279 is not a special + # case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # scripts with optimization help from Paolo Bonzini. Blame Lee + # E. McMahon (1931-1989) for sed's syntax. :-) + sed -n ' + p + /[$]LINENO/= + ' <$as_myself | + sed ' + s/[$]LINENO.*/&-/ + t lineno + b + :lineno + N + :loop + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ + t loop + s/-\n.*// + ' >$as_me.lineno && + chmod +x "$as_me.lineno" || + { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 + { (exit 1); exit 1; }; } + + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensitive to this). + . "./$as_me.lineno" + # Exit status is that of the last command. + exit +} + + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in +-n*) + case `echo 'x\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + *) ECHO_C='\c';; + esac;; +*) + ECHO_N='-n';; +esac + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir +fi +echo >conf$$.file +if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -p' +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + +if mkdir -p . 2>/dev/null; then + as_mkdir_p=: +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +exec 6>&1 + +# Save the log message, to keep $[0] and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. +ac_log=" +This file was extended by creGpioDae $as_me 0.0.1, which was +generated by GNU Autoconf 2.61. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +on `(hostname || uname -n) 2>/dev/null | sed 1q` +" + +# Files that config.status was made for. +config_files=" Makefile" +config_commands=" depfiles" + +ac_cs_usage="\ +\`$as_me' instantiates files from templates according to the +current configuration. + +Usage: $0 [OPTIONS] [FILE]... + + -h, --help print this help, then exit + -V, --version print version number and configuration settings, then exit + -q, --quiet do not print progress messages + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE + +Configuration files: +$config_files + +Configuration commands: +$config_commands + +Report bugs to ." + +ac_cs_version="\ +creGpioDae config.status 0.0.1 +configured by ./configure, generated by GNU Autoconf 2.61, + with options \"'--target=powerpc-linux' '--host=powerpc-linux' '--build=x86_64-pc-linux-gnu' '--prefix=/usr' '--sysconfdir=/etc' '--disable-nls' '--disable-largefile' 'build_alias=x86_64-pc-linux-gnu' 'host_alias=powerpc-linux' 'target_alias=powerpc-linux' 'CC=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-gcc -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e' 'CFLAGS=-Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e' 'LDFLAGS=-L/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/lib -L/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/lib --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/' 'CPP=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-cpp -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e'\" + +Copyright (C) 2006 Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." + +ac_pwd='/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/testapplication-0.0.1' +srcdir='.' +INSTALL='/usr/bin/install -c' +MKDIR_P='/bin/mkdir -p' +# If no file are specified by the user, then we need to provide default +# value. By we need to know if files were specified by the user. +ac_need_defaults=: +while test $# != 0 +do + case $1 in + --*=*) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` + ac_shift=: + ;; + *) + ac_option=$1 + ac_optarg=$2 + ac_shift=shift + ;; + esac + + case $ac_option in + # Handling of the options. + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + ac_cs_recheck=: ;; + --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) + echo "$ac_cs_version"; exit ;; + --debug | --debu | --deb | --de | --d | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + $ac_shift + CONFIG_FILES="$CONFIG_FILES $ac_optarg" + ac_need_defaults=false;; + --he | --h | --help | --hel | -h ) + echo "$ac_cs_usage"; exit ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil | --si | --s) + ac_cs_silent=: ;; + + # This is an error. + -*) { echo "$as_me: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&2 + { (exit 1); exit 1; }; } ;; + + *) ac_config_targets="$ac_config_targets $1" + ac_need_defaults=false ;; + + esac + shift +done + +ac_configure_extra_args= + +if $ac_cs_silent; then + exec 6>/dev/null + ac_configure_extra_args="$ac_configure_extra_args --silent" +fi + +if $ac_cs_recheck; then + echo "running CONFIG_SHELL=/bin/bash /bin/bash ./configure " '--target=powerpc-linux' '--host=powerpc-linux' '--build=x86_64-pc-linux-gnu' '--prefix=/usr' '--sysconfdir=/etc' '--disable-nls' '--disable-largefile' 'build_alias=x86_64-pc-linux-gnu' 'host_alias=powerpc-linux' 'target_alias=powerpc-linux' 'CC=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-gcc -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e' 'CFLAGS=-Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e' 'LDFLAGS=-L/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/lib -L/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/lib --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/' 'CPP=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-cpp -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e' $ac_configure_extra_args " --no-create --no-recursion" >&6 + CONFIG_SHELL=/bin/bash + export CONFIG_SHELL + exec /bin/bash "./configure" '--target=powerpc-linux' '--host=powerpc-linux' '--build=x86_64-pc-linux-gnu' '--prefix=/usr' '--sysconfdir=/etc' '--disable-nls' '--disable-largefile' 'build_alias=x86_64-pc-linux-gnu' 'host_alias=powerpc-linux' 'target_alias=powerpc-linux' 'CC=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-gcc -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e' 'CFLAGS=-Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e' 'LDFLAGS=-L/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/lib -L/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/lib --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/' 'CPP=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-cpp -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e' $ac_configure_extra_args --no-create --no-recursion +fi + +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX + echo "$ac_log" +} >&5 + +# +# INIT-COMMANDS +# +AMDEP_TRUE="" ac_aux_dir="." + + +# Handling of arguments. +for ac_config_target in $ac_config_targets +do + case $ac_config_target in + "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; + "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; + + *) { { echo "$as_me:5558: error: invalid argument: $ac_config_target" >&5 +echo "$as_me: error: invalid argument: $ac_config_target" >&2;} + { (exit 1); exit 1; }; };; + esac +done + + +# If the user did not use the arguments to specify the items to instantiate, +# then the envvar interface is used. Set only those that are not. +# We use the long form for the default assignment because of an extremely +# bizarre bug on SunOS 4.1.3. +if $ac_need_defaults; then + test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files + test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands +fi + +# Have a temporary directory for convenience. Make it in the build tree +# simply because there is no reason against having it here, and in addition, +# creating and moving files from /tmp can sometimes cause problems. +# Hook for its removal unless debugging. +# Note that there is a small window in which the directory will not be cleaned: +# after its creation but before its name has been assigned to `$tmp'. +$debug || +{ + tmp= + trap 'exit_status=$? + { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status +' 0 + trap '{ (exit 1); exit 1; }' 1 2 13 15 +} +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && + test -n "$tmp" && test -d "$tmp" +} || +{ + tmp=./conf$$-$RANDOM + (umask 077 && mkdir "$tmp") +} || +{ + echo "$me: cannot create a temporary directory in ." >&2 + { (exit 1); exit 1; } +} + +# +# Set up the sed scripts for CONFIG_FILES section. +# + +# No need to generate the scripts if there are no CONFIG_FILES. +# This happens for instance when ./config.status config.h +if test -n "$CONFIG_FILES"; then + +cat >"$tmp/subs-1.sed" <<\CEOF +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b end +s,@SHELL@,|#_!!_#|/bin/bash,g +s,@PATH_SEPARATOR@,|#_!!_#|:,g +s,@PACKAGE_NAME@,|#_!!_#|creGpioDae,g +s,@PACKAGE_TARNAME@,|#_!!_#|cregpiodae,g +s,@PACKAGE_VERSION@,|#_!!_#|0.0.1,g +s,@PACKAGE_STRING@,|#_!!_#|creGpioDae 0.0.1,g +s,@PACKAGE_BUGREPORT@,|#_!!_#|,g +s,@exec_prefix@,|#_!!_#|${prefix},g +s,@prefix@,|#_!!_#|/usr,g +s,@program_transform_name@,|#_!!_#|s\,x\,x\,,g +s,@bindir@,|#_!!_#|${exec_prefix}/bin,g +s,@sbindir@,|#_!!_#|${exec_prefix}/sbin,g +s,@libexecdir@,|#_!!_#|${exec_prefix}/libexec,g +s,@datarootdir@,|#_!!_#|${prefix}/share,g +s,@datadir@,|#_!!_#|${datarootdir},g +s,@sysconfdir@,|#_!!_#|/etc,g +s,@sharedstatedir@,|#_!!_#|${prefix}/com,g +s,@localstatedir@,|#_!!_#|${prefix}/var,g +s,@includedir@,|#_!!_#|${prefix}/include,g +s,@oldincludedir@,|#_!!_#|/usr/include,g +s,@docdir@,|#_!!_#|${datarootdir}/doc/${PACKAGE_TARNAME},g +s,@infodir@,|#_!!_#|${datarootdir}/info,g +s,@htmldir@,|#_!!_#|${docdir},g +s,@dvidir@,|#_!!_#|${docdir},g +s,@pdfdir@,|#_!!_#|${docdir},g +s,@psdir@,|#_!!_#|${docdir},g +s,@libdir@,|#_!!_#|${exec_prefix}/lib,g +s,@localedir@,|#_!!_#|${datarootdir}/locale,g +s,@mandir@,|#_!!_#|${datarootdir}/man,g +s,@DEFS@,|#_!!_#|-DPACKAGE_NAME=\\"creGpioDae\\" -DPACKAGE_TARNAME=\\"cregpiodae\\" -DPACKAGE_VERSION=\\"0.0.1\\" -DPACKAGE_STRING=\\"creGpioDae\\ 0.0.1\\" -DPACKAGE_BUGREPORT=\\"\\" -DPACKAGE=\\"cregpiodae\\" -DVERSION=\\"0.0.1\\" -D_GNU_SOURCE=1 -DHAVE_DIRENT_H=1 -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_MATH_H=1 -DHAVE_STDIO_H=1 -DHAVE_FCNTL_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_LIMITS_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STDDEF_H=1 -DHAVE_STDINT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_STRINGS_H=1 -DHAVE_UNISTD_H=1,g +s,@ECHO_C@,|#_!!_#|,g +s,@ECHO_N@,|#_!!_#|-n,g +s,@ECHO_T@,|#_!!_#|,g +s,@LIBS@,|#_!!_#|,g +s,@build_alias@,|#_!!_#|x86_64-pc-linux-gnu,g +s,@host_alias@,|#_!!_#|powerpc-linux,g +s,@target_alias@,|#_!!_#|powerpc-linux,g +s,@INSTALL_PROGRAM@,|#_!!_#|${INSTALL},g +s,@INSTALL_SCRIPT@,|#_!!_#|${INSTALL},g +s,@INSTALL_DATA@,|#_!!_#|${INSTALL} -m 644,g +s,@am__isrc@,|#_!!_#|,g +s,@CYGPATH_W@,|#_!!_#|echo,g +s,@PACKAGE@,|#_!!_#|cregpiodae,g +s,@VERSION@,|#_!!_#|0.0.1,g +s,@ACLOCAL@,|#_!!_#|${SHELL} /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/testapplication-0.0.1/missing --run aclocal-1.10,g +s,@AUTOCONF@,|#_!!_#|${SHELL} /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/testapplication-0.0.1/missing --run autoconf,g +s,@AUTOMAKE@,|#_!!_#|${SHELL} /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/testapplication-0.0.1/missing --run automake-1.10,g +s,@AUTOHEADER@,|#_!!_#|${SHELL} /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/testapplication-0.0.1/missing --run autoheader,g +s,@MAKEINFO@,|#_!!_#|${SHELL} /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/testapplication-0.0.1/missing --run makeinfo,g +s,@install_sh@,|#_!!_#|$(SHELL) /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/testapplication-0.0.1/install-sh,g +s,@STRIP@,|#_!!_#|/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-strip,g +s,@INSTALL_STRIP_PROGRAM@,|#_!!_#|$(install_sh) -c -s,g +s,@mkdir_p@,|#_!!_#|/bin/mkdir -p,g +s,@AWK@,|#_!!_#|gawk,g +s,@SET_MAKE@,|#_!!_#|,g +s,@am__leading_dot@,|#_!!_#|.,g +s,@AMTAR@,|#_!!_#|${SHELL} /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/testapplication-0.0.1/missing --run tar,g +s,@am__tar@,|#_!!_#|${AMTAR} chof - "$$tardir",g +s,@am__untar@,|#_!!_#|${AMTAR} xf -,g +s,@CC@,|#_!!_#|/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-gcc -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e,g +s,@CFLAGS@,|#_!!_#|-Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e,g +s,@LDFLAGS@,|#_!!_#|-L/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/lib -L/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/lib --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/,g +s,@CPPFLAGS@,|#_!!_#|,g +s,@ac_ct_CC@,|#_!!_#|,g +s,@EXEEXT@,|#_!!_#|,g +s,@OBJEXT@,|#_!!_#|o,g +s,@DEPDIR@,|#_!!_#|.deps,g +s,@am__include@,|#_!!_#|include,g +s,@am__quote@,|#_!!_#|,g +s,@AMDEP_TRUE@,|#_!!_#|,g +s,@AMDEP_FALSE@,|#_!!_#|#,g +s,@AMDEPBACKSLASH@,|#_!!_#|\\,g +s,@CCDEPMODE@,|#_!!_#|depmode=gcc3,g +s,@am__fastdepCC_TRUE@,|#_!!_#|,g +s,@am__fastdepCC_FALSE@,|#_!!_#|#,g +s,@CPP@,|#_!!_#|/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-cpp -Os -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/usr/include -I/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/include --sysroot=/home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir/ -isysroot /home/microkey/mmi/Projects/QUA_2475/buildroot/build_powerpc/staging_dir -mtune=603e,g +s,@GREP@,|#_!!_#|/bin/grep,g +s,@EGREP@,|#_!!_#|/bin/grep -E,g +s,@LIBOBJS@,|#_!!_#|,g +s,@LTLIBOBJS@,|#_!!_#|,g +:end +s/|#_!!_#|//g +CEOF +fi # test -n "$CONFIG_FILES" + + +for ac_tag in :F $CONFIG_FILES :C $CONFIG_COMMANDS +do + case $ac_tag in + :[FHLC]) ac_mode=$ac_tag; continue;; + esac + case $ac_mode$ac_tag in + :[FHL]*:*);; + :L* | :C*:*) { { echo "$as_me:5764: error: Invalid tag $ac_tag." >&5 +echo "$as_me: error: Invalid tag $ac_tag." >&2;} + { (exit 1); exit 1; }; };; + :[FH]-) ac_tag=-:-;; + :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; + esac + ac_save_IFS=$IFS + IFS=: + set x $ac_tag + IFS=$ac_save_IFS + shift + ac_file=$1 + shift + + case $ac_mode in + :L) ac_source=$1;; + :[FH]) + ac_file_inputs= + for ac_f + do + case $ac_f in + -) ac_f="$tmp/stdin";; + *) # Look for the file first in the build tree, then in the source tree + # (if the path is not absolute). The absolute path cannot be DOS-style, + # because $ac_f cannot contain `:'. + test -f "$ac_f" || + case $ac_f in + [\\/$]*) false;; + *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; + esac || + { { echo "$as_me:5794: error: cannot find input file: $ac_f" >&5 +echo "$as_me: error: cannot find input file: $ac_f" >&2;} + { (exit 1); exit 1; }; };; + esac + ac_file_inputs="$ac_file_inputs $ac_f" + done + + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + configure_input="Generated from "`IFS=: + echo $* | sed 's|^[^:]*/||;s|:[^:]*/|, |g'`" by configure." + if test x"$ac_file" != x-; then + configure_input="$ac_file. $configure_input" + { echo "$as_me:5808: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + fi + + case $ac_tag in + *:-:* | *:-) cat >"$tmp/stdin";; + esac + ;; + esac + + ac_dir=`$as_dirname -- "$ac_file" || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || +echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + { as_dir="$ac_dir" + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || { { echo "$as_me:5879: error: cannot create directory $as_dir" >&5 +echo "$as_me: error: cannot create directory $as_dir" >&2;} + { (exit 1); exit 1; }; }; } + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + + case $ac_mode in + :F) + # + # CONFIG_FILE + # + + case $INSTALL in + [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; + *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; + esac + ac_MKDIR_P=$MKDIR_P + case $MKDIR_P in + [\\/$]* | ?:[\\/]* ) ;; + */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; + esac +# If the template does not know about datarootdir, expand it. +# FIXME: This hack should be removed a few years after 2.60. +ac_datarootdir_hack=; ac_datarootdir_seen= + +case `sed -n '/datarootdir/ { + p + q +} +/@datadir@/p +/@docdir@/p +/@infodir@/p +/@localedir@/p +/@mandir@/p +' $ac_file_inputs` in +*datarootdir*) ac_datarootdir_seen=yes;; +*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) + { echo "$as_me:5951: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 +echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} + ac_datarootdir_hack=' + s&@datadir@&${datarootdir}&g + s&@docdir@&${datarootdir}/doc/${PACKAGE_TARNAME}&g + s&@infodir@&${datarootdir}/info&g + s&@localedir@&${datarootdir}/locale&g + s&@mandir@&${datarootdir}/man&g + s&\${datarootdir}&${prefix}/share&g' ;; +esac + sed "/^[ ]*VPATH[ ]*=/{ +s/:*\$(srcdir):*/:/ +s/:*\${srcdir}:*/:/ +s/:*@srcdir@:*/:/ +s/^\([^=]*=[ ]*\):*/\1/ +s/:*$// +s/^[^=]*=[ ]*$// +} + +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s&@configure_input@&$configure_input&;t t +s&@top_builddir@&$ac_top_builddir_sub&;t t +s&@srcdir@&$ac_srcdir&;t t +s&@abs_srcdir@&$ac_abs_srcdir&;t t +s&@top_srcdir@&$ac_top_srcdir&;t t +s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t +s&@builddir@&$ac_builddir&;t t +s&@abs_builddir@&$ac_abs_builddir&;t t +s&@abs_top_builddir@&$ac_abs_top_builddir&;t t +s&@INSTALL@&$ac_INSTALL&;t t +s&@MKDIR_P@&$ac_MKDIR_P&;t t +$ac_datarootdir_hack +" $ac_file_inputs | sed -f "$tmp/subs-1.sed" >$tmp/out + +test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && + { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && + { echo "$as_me:5992: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined." >&5 +echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined." >&2;} + + rm -f "$tmp/stdin" + case $ac_file in + -) cat "$tmp/out"; rm -f "$tmp/out";; + *) rm -f "$ac_file"; mv "$tmp/out" $ac_file;; + esac + ;; + + + :C) { echo "$as_me:6005: executing $ac_file commands" >&5 +echo "$as_me: executing $ac_file commands" >&6;} + ;; + esac + + + case $ac_file$ac_mode in + "depfiles":C) test x"$AMDEP_TRUE" != x"" || for mf in $CONFIG_FILES; do + # Strip MF so we end up with the name of the file. + mf=`echo "$mf" | sed -e 's/:.*$//'` + # Check whether this is an Automake generated Makefile or not. + # We used to match only the files named `Makefile.in', but + # some people rename them; so instead we look at the file content. + # Grep'ing the first line is not enough: some people post-process + # each Makefile.in and add a new line on top of each file to say so. + # Grep'ing the whole file is not good either: AIX grep has a line + # limit of 2048, but all sed's we know have understand at least 4000. + if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then + dirpart=`$as_dirname -- "$mf" || +$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$mf" : 'X\(//\)[^/]' \| \ + X"$mf" : 'X\(//\)$' \| \ + X"$mf" : 'X\(/\)' \| . 2>/dev/null || +echo X"$mf" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + else + continue + fi + # Extract the definition of DEPDIR, am__include, and am__quote + # from the Makefile without running `make'. + DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` + test -z "$DEPDIR" && continue + am__include=`sed -n 's/^am__include = //p' < "$mf"` + test -z "am__include" && continue + am__quote=`sed -n 's/^am__quote = //p' < "$mf"` + # When using ansi2knr, U may be empty or an underscore; expand it + U=`sed -n 's/^U = //p' < "$mf"` + # Find all dependency output files, they are included files with + # $(DEPDIR) in their names. We invoke sed twice because it is the + # simplest approach to changing $(DEPDIR) to its actual value in the + # expansion. + for file in `sed -n " + s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ + sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do + # Make sure the directory exists. + test -f "$dirpart/$file" && continue + fdir=`$as_dirname -- "$file" || +$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$file" : 'X\(//\)[^/]' \| \ + X"$file" : 'X\(//\)$' \| \ + X"$file" : 'X\(/\)' \| . 2>/dev/null || +echo X"$file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + { as_dir=$dirpart/$fdir + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || { { echo "$as_me:6128: error: cannot create directory $as_dir" >&5 +echo "$as_me: error: cannot create directory $as_dir" >&2;} + { (exit 1); exit 1; }; }; } + # echo "creating $dirpart/$file" + echo '# dummy' > "$dirpart/$file" + done +done + ;; + + esac +done # for ac_tag + + +{ (exit 0); exit 0; } diff --git a/Quantum Controller/SW/testapplication-0.0.1/configure b/Quantum Controller/SW/testapplication-0.0.1/configure new file mode 100644 index 0000000..9813b99 --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/configure @@ -0,0 +1,6168 @@ +#! /bin/sh +# Guess values for system-dependent variables and create Makefiles. +# Generated by GNU Autoconf 2.61 for creGpioDae 0.0.1. +# +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, +# 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. +## --------------------- ## +## M4sh Initialization. ## +## --------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + + + +# PATH needs CR +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + +# Support unset when possible. +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +as_nl=' +' +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +case $0 in + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + { (exit 1); exit 1; } +fi + +# Work around bugs in pre-3.0 UWIN ksh. +for as_var in ENV MAIL MAILPATH +do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +for as_var in \ + LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ + LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ + LC_TELEPHONE LC_TIME +do + if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then + eval $as_var=C; export $as_var + else + ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var + fi +done + +# Required to use basename. +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + + +# Name of the executable. +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# CDPATH. +$as_unset CDPATH + + +if test "x$CONFIG_SHELL" = x; then + if (eval ":") 2>/dev/null; then + as_have_required=yes +else + as_have_required=no +fi + + if test $as_have_required = yes && (eval ": +(as_func_return () { + (exit \$1) +} +as_func_success () { + as_func_return 0 +} +as_func_failure () { + as_func_return 1 +} +as_func_ret_success () { + return 0 +} +as_func_ret_failure () { + return 1 +} + +exitcode=0 +if as_func_success; then + : +else + exitcode=1 + echo as_func_success failed. +fi + +if as_func_failure; then + exitcode=1 + echo as_func_failure succeeded. +fi + +if as_func_ret_success; then + : +else + exitcode=1 + echo as_func_ret_success failed. +fi + +if as_func_ret_failure; then + exitcode=1 + echo as_func_ret_failure succeeded. +fi + +if ( set x; as_func_ret_success y && test x = \"\$1\" ); then + : +else + exitcode=1 + echo positional parameters were not saved. +fi + +test \$exitcode = 0) || { (exit 1); exit 1; } + +( + as_lineno_1=\$LINENO + as_lineno_2=\$LINENO + test \"x\$as_lineno_1\" != \"x\$as_lineno_2\" && + test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; } +") 2> /dev/null; then + : +else + as_candidate_shells= + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + case $as_dir in + /*) + for as_base in sh bash ksh sh5; do + as_candidate_shells="$as_candidate_shells $as_dir/$as_base" + done;; + esac +done +IFS=$as_save_IFS + + + for as_shell in $as_candidate_shells $SHELL; do + # Try only shells that exist, to save several forks. + if { test -f "$as_shell" || test -f "$as_shell.exe"; } && + { ("$as_shell") 2> /dev/null <<\_ASEOF +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + +: +_ASEOF +}; then + CONFIG_SHELL=$as_shell + as_have_required=yes + if { "$as_shell" 2> /dev/null <<\_ASEOF +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + +: +(as_func_return () { + (exit $1) +} +as_func_success () { + as_func_return 0 +} +as_func_failure () { + as_func_return 1 +} +as_func_ret_success () { + return 0 +} +as_func_ret_failure () { + return 1 +} + +exitcode=0 +if as_func_success; then + : +else + exitcode=1 + echo as_func_success failed. +fi + +if as_func_failure; then + exitcode=1 + echo as_func_failure succeeded. +fi + +if as_func_ret_success; then + : +else + exitcode=1 + echo as_func_ret_success failed. +fi + +if as_func_ret_failure; then + exitcode=1 + echo as_func_ret_failure succeeded. +fi + +if ( set x; as_func_ret_success y && test x = "$1" ); then + : +else + exitcode=1 + echo positional parameters were not saved. +fi + +test $exitcode = 0) || { (exit 1); exit 1; } + +( + as_lineno_1=$LINENO + as_lineno_2=$LINENO + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2") || { (exit 1); exit 1; } + +_ASEOF +}; then + break +fi + +fi + + done + + if test "x$CONFIG_SHELL" != x; then + for as_var in BASH_ENV ENV + do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var + done + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} +fi + + + if test $as_have_required = no; then + echo This script requires a shell more modern than all the + echo shells that I found on your system. Please install a + echo modern shell, or manually run the script under such a + echo shell if you do have one. + { (exit 1); exit 1; } +fi + + +fi + +fi + + + +(eval "as_func_return () { + (exit \$1) +} +as_func_success () { + as_func_return 0 +} +as_func_failure () { + as_func_return 1 +} +as_func_ret_success () { + return 0 +} +as_func_ret_failure () { + return 1 +} + +exitcode=0 +if as_func_success; then + : +else + exitcode=1 + echo as_func_success failed. +fi + +if as_func_failure; then + exitcode=1 + echo as_func_failure succeeded. +fi + +if as_func_ret_success; then + : +else + exitcode=1 + echo as_func_ret_success failed. +fi + +if as_func_ret_failure; then + exitcode=1 + echo as_func_ret_failure succeeded. +fi + +if ( set x; as_func_ret_success y && test x = \"\$1\" ); then + : +else + exitcode=1 + echo positional parameters were not saved. +fi + +test \$exitcode = 0") || { + echo No shell found that supports shell functions. + echo Please tell autoconf@gnu.org about your system, + echo including any error possibly output before this + echo message +} + + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { + + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line after each line using $LINENO; the second 'sed' + # does the real work. The second script uses 'N' to pair each + # line-number line with the line containing $LINENO, and appends + # trailing '-' during substitution so that $LINENO is not a special + # case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # scripts with optimization help from Paolo Bonzini. Blame Lee + # E. McMahon (1931-1989) for sed's syntax. :-) + sed -n ' + p + /[$]LINENO/= + ' <$as_myself | + sed ' + s/[$]LINENO.*/&-/ + t lineno + b + :lineno + N + :loop + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ + t loop + s/-\n.*// + ' >$as_me.lineno && + chmod +x "$as_me.lineno" || + { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 + { (exit 1); exit 1; }; } + + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensitive to this). + . "./$as_me.lineno" + # Exit status is that of the last command. + exit +} + + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in +-n*) + case `echo 'x\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + *) ECHO_C='\c';; + esac;; +*) + ECHO_N='-n';; +esac + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir +fi +echo >conf$$.file +if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -p' +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + +if mkdir -p . 2>/dev/null; then + as_mkdir_p=: +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + + +exec 7<&0 &1 + +# Name of the host. +# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, +# so uname gets run too. +ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` + +# +# Initializations. +# +ac_default_prefix=/usr/local +ac_clean_files= +ac_config_libobj_dir=. +LIBOBJS= +cross_compiling=no +subdirs= +MFLAGS= +MAKEFLAGS= +SHELL=${CONFIG_SHELL-/bin/sh} + +# Identity of this package. +PACKAGE_NAME='creGpioDae' +PACKAGE_TARNAME='cregpiodae' +PACKAGE_VERSION='0.0.1' +PACKAGE_STRING='creGpioDae 0.0.1' +PACKAGE_BUGREPORT='' + +# Factoring default headers for most tests. +ac_includes_default="\ +#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif +#ifdef HAVE_SYS_STAT_H +# include +#endif +#ifdef STDC_HEADERS +# include +# include +#else +# ifdef HAVE_STDLIB_H +# include +# endif +#endif +#ifdef HAVE_STRING_H +# if !defined STDC_HEADERS && defined HAVE_MEMORY_H +# include +# endif +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif +#ifdef HAVE_INTTYPES_H +# include +#endif +#ifdef HAVE_STDINT_H +# include +#endif +#ifdef HAVE_UNISTD_H +# include +#endif" + +ac_subst_vars='SHELL +PATH_SEPARATOR +PACKAGE_NAME +PACKAGE_TARNAME +PACKAGE_VERSION +PACKAGE_STRING +PACKAGE_BUGREPORT +exec_prefix +prefix +program_transform_name +bindir +sbindir +libexecdir +datarootdir +datadir +sysconfdir +sharedstatedir +localstatedir +includedir +oldincludedir +docdir +infodir +htmldir +dvidir +pdfdir +psdir +libdir +localedir +mandir +DEFS +ECHO_C +ECHO_N +ECHO_T +LIBS +build_alias +host_alias +target_alias +INSTALL_PROGRAM +INSTALL_SCRIPT +INSTALL_DATA +am__isrc +CYGPATH_W +PACKAGE +VERSION +ACLOCAL +AUTOCONF +AUTOMAKE +AUTOHEADER +MAKEINFO +install_sh +STRIP +INSTALL_STRIP_PROGRAM +mkdir_p +AWK +SET_MAKE +am__leading_dot +AMTAR +am__tar +am__untar +CC +CFLAGS +LDFLAGS +CPPFLAGS +ac_ct_CC +EXEEXT +OBJEXT +DEPDIR +am__include +am__quote +AMDEP_TRUE +AMDEP_FALSE +AMDEPBACKSLASH +CCDEPMODE +am__fastdepCC_TRUE +am__fastdepCC_FALSE +CPP +GREP +EGREP +LIBOBJS +LTLIBOBJS' +ac_subst_files='' + ac_precious_vars='build_alias +host_alias +target_alias +CC +CFLAGS +LDFLAGS +LIBS +CPPFLAGS +CPP' + + +# Initialize some variables set by options. +ac_init_help= +ac_init_version=false +# The variables have the same names as the options, with +# dashes changed to underlines. +cache_file=/dev/null +exec_prefix=NONE +no_create= +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +verbose= +x_includes=NONE +x_libraries=NONE + +# Installation directory options. +# These are left unexpanded so users can "make install exec_prefix=/foo" +# and all the variables that are supposed to be based on exec_prefix +# by default will actually change. +# Use braces instead of parens because sh, perl, etc. also accept them. +# (The list follows the same order as the GNU Coding Standards.) +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datarootdir='${prefix}/share' +datadir='${datarootdir}' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +includedir='${prefix}/include' +oldincludedir='/usr/include' +docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' +infodir='${datarootdir}/info' +htmldir='${docdir}' +dvidir='${docdir}' +pdfdir='${docdir}' +psdir='${docdir}' +libdir='${exec_prefix}/lib' +localedir='${datarootdir}/locale' +mandir='${datarootdir}/man' + +ac_prev= +ac_dashdash= +for ac_option +do + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval $ac_prev=\$ac_option + ac_prev= + continue + fi + + case $ac_option in + *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; + *) ac_optarg=yes ;; + esac + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case $ac_dashdash$ac_option in + --) + ac_dashdash=yes ;; + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir=$ac_optarg ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build_alias ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build_alias=$ac_optarg ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file=$ac_optarg ;; + + --config-cache | -C) + cache_file=config.cache ;; + + -datadir | --datadir | --datadi | --datad) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=*) + datadir=$ac_optarg ;; + + -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ + | --dataroo | --dataro | --datar) + ac_prev=datarootdir ;; + -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ + | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) + datarootdir=$ac_optarg ;; + + -disable-* | --disable-*) + ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'` + eval enable_$ac_feature=no ;; + + -docdir | --docdir | --docdi | --doc | --do) + ac_prev=docdir ;; + -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) + docdir=$ac_optarg ;; + + -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) + ac_prev=dvidir ;; + -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) + dvidir=$ac_optarg ;; + + -enable-* | --enable-*) + ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'` + eval enable_$ac_feature=\$ac_optarg ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix=$ac_optarg ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he | -h) + ac_init_help=long ;; + -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) + ac_init_help=recursive ;; + -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) + ac_init_help=short ;; + + -host | --host | --hos | --ho) + ac_prev=host_alias ;; + -host=* | --host=* | --hos=* | --ho=*) + host_alias=$ac_optarg ;; + + -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) + ac_prev=htmldir ;; + -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ + | --ht=*) + htmldir=$ac_optarg ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir=$ac_optarg ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir=$ac_optarg ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir=$ac_optarg ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir=$ac_optarg ;; + + -localedir | --localedir | --localedi | --localed | --locale) + ac_prev=localedir ;; + -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) + localedir=$ac_optarg ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst | --locals) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) + localstatedir=$ac_optarg ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir=$ac_optarg ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c | -n) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir=$ac_optarg ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix=$ac_optarg ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix=$ac_optarg ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix=$ac_optarg ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name=$ac_optarg ;; + + -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) + ac_prev=pdfdir ;; + -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) + pdfdir=$ac_optarg ;; + + -psdir | --psdir | --psdi | --psd | --ps) + ac_prev=psdir ;; + -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) + psdir=$ac_optarg ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir=$ac_optarg ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir=$ac_optarg ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site=$ac_optarg ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir=$ac_optarg ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir=$ac_optarg ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target_alias ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target_alias=$ac_optarg ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers | -V) + ac_init_version=: ;; + + -with-* | --with-*) + ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } + ac_package=`echo $ac_package | sed 's/[-.]/_/g'` + eval with_$ac_package=\$ac_optarg ;; + + -without-* | --without-*) + ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } + ac_package=`echo $ac_package | sed 's/[-.]/_/g'` + eval with_$ac_package=no ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes=$ac_optarg ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries=$ac_optarg ;; + + -*) { echo "$as_me: error: unrecognized option: $ac_option +Try \`$0 --help' for more information." >&2 + { (exit 1); exit 1; }; } + ;; + + *=*) + ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` + # Reject names that are not valid shell variable names. + expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 + { (exit 1); exit 1; }; } + eval $ac_envvar=\$ac_optarg + export $ac_envvar ;; + + *) + # FIXME: should be removed in autoconf 3.0. + echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && + echo "$as_me: WARNING: invalid host type: $ac_option" >&2 + : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} + ;; + + esac +done + +if test -n "$ac_prev"; then + ac_option=--`echo $ac_prev | sed 's/_/-/g'` + { echo "$as_me: error: missing argument to $ac_option" >&2 + { (exit 1); exit 1; }; } +fi + +# Be sure to have absolute directory names. +for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ + datadir sysconfdir sharedstatedir localstatedir includedir \ + oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ + libdir localedir mandir +do + eval ac_val=\$$ac_var + case $ac_val in + [\\/$]* | ?:[\\/]* ) continue;; + NONE | '' ) case $ac_var in *prefix ) continue;; esac;; + esac + { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; } +done + +# There might be people who depend on the old broken behavior: `$host' +# used to hold the argument of --host etc. +# FIXME: To remove some day. +build=$build_alias +host=$host_alias +target=$target_alias + +# FIXME: To remove some day. +if test "x$host_alias" != x; then + if test "x$build_alias" = x; then + cross_compiling=maybe + echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. + If a cross compiler is detected then cross compile mode will be used." >&2 + elif test "x$build_alias" != "x$host_alias"; then + cross_compiling=yes + fi +fi + +ac_tool_prefix= +test -n "$host_alias" && ac_tool_prefix=$host_alias- + +test "$silent" = yes && exec 6>/dev/null + + +ac_pwd=`pwd` && test -n "$ac_pwd" && +ac_ls_di=`ls -di .` && +ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || + { echo "$as_me: error: Working directory cannot be determined" >&2 + { (exit 1); exit 1; }; } +test "X$ac_ls_di" = "X$ac_pwd_ls_di" || + { echo "$as_me: error: pwd does not report name of working directory" >&2 + { (exit 1); exit 1; }; } + + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then the parent directory. + ac_confdir=`$as_dirname -- "$0" || +$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$0" : 'X\(//\)[^/]' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +echo X"$0" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + srcdir=$ac_confdir + if test ! -r "$srcdir/$ac_unique_file"; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r "$srcdir/$ac_unique_file"; then + test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." + { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 + { (exit 1); exit 1; }; } +fi +ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" +ac_abs_confdir=`( + cd "$srcdir" && test -r "./$ac_unique_file" || { echo "$as_me: error: $ac_msg" >&2 + { (exit 1); exit 1; }; } + pwd)` +# When building in place, set srcdir=. +if test "$ac_abs_confdir" = "$ac_pwd"; then + srcdir=. +fi +# Remove unnecessary trailing slashes from srcdir. +# Double slashes in file names in object file debugging info +# mess up M-x gdb in Emacs. +case $srcdir in +*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; +esac +for ac_var in $ac_precious_vars; do + eval ac_env_${ac_var}_set=\${${ac_var}+set} + eval ac_env_${ac_var}_value=\$${ac_var} + eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} + eval ac_cv_env_${ac_var}_value=\$${ac_var} +done + +# +# Report the --help message. +# +if test "$ac_init_help" = "long"; then + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat <<_ACEOF +\`configure' configures creGpioDae 0.0.1 to adapt to many kinds of systems. + +Usage: $0 [OPTION]... [VAR=VALUE]... + +To assign environment variables (e.g., CC, CFLAGS...), specify them as +VAR=VALUE. See below for descriptions of some of the useful variables. + +Defaults for the options are specified in brackets. + +Configuration: + -h, --help display this help and exit + --help=short display options specific to this package + --help=recursive display the short help of all the included packages + -V, --version display version information and exit + -q, --quiet, --silent do not print \`checking...' messages + --cache-file=FILE cache test results in FILE [disabled] + -C, --config-cache alias for \`--cache-file=config.cache' + -n, --no-create do not create output files + --srcdir=DIR find the sources in DIR [configure dir or \`..'] + +Installation directories: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [PREFIX] + +By default, \`make install' will install all the files in +\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify +an installation prefix other than \`$ac_default_prefix' using \`--prefix', +for instance \`--prefix=\$HOME'. + +For better control, use the options below. + +Fine tuning of the installation directories: + --bindir=DIR user executables [EPREFIX/bin] + --sbindir=DIR system admin executables [EPREFIX/sbin] + --libexecdir=DIR program executables [EPREFIX/libexec] + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] + --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] + --datadir=DIR read-only architecture-independent data [DATAROOTDIR] + --infodir=DIR info documentation [DATAROOTDIR/info] + --localedir=DIR locale-dependent data [DATAROOTDIR/locale] + --mandir=DIR man documentation [DATAROOTDIR/man] + --docdir=DIR documentation root [DATAROOTDIR/doc/cregpiodae] + --htmldir=DIR html documentation [DOCDIR] + --dvidir=DIR dvi documentation [DOCDIR] + --pdfdir=DIR pdf documentation [DOCDIR] + --psdir=DIR ps documentation [DOCDIR] +_ACEOF + + cat <<\_ACEOF + +Program names: + --program-prefix=PREFIX prepend PREFIX to installed program names + --program-suffix=SUFFIX append SUFFIX to installed program names + --program-transform-name=PROGRAM run sed PROGRAM on installed program names +_ACEOF +fi + +if test -n "$ac_init_help"; then + case $ac_init_help in + short | recursive ) echo "Configuration of creGpioDae 0.0.1:";; + esac + cat <<\_ACEOF + +Optional Features: + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --disable-dependency-tracking speeds up one-time build + --enable-dependency-tracking do not reject slow dependency extractors + +Some influential environment variables: + CC C compiler command + CFLAGS C compiler flags + LDFLAGS linker flags, e.g. -L if you have libraries in a + nonstandard directory + LIBS libraries to pass to the linker, e.g. -l + CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I if + you have headers in a nonstandard directory + CPP C preprocessor + +Use these variables to override the choices made by `configure' or to help +it to find libraries and programs with nonstandard names/locations. + +_ACEOF +ac_status=$? +fi + +if test "$ac_init_help" = "recursive"; then + # If there are subdirs, report their specific --help. + for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue + test -d "$ac_dir" || continue + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + cd "$ac_dir" || { ac_status=$?; continue; } + # Check for guested configure. + if test -f "$ac_srcdir/configure.gnu"; then + echo && + $SHELL "$ac_srcdir/configure.gnu" --help=recursive + elif test -f "$ac_srcdir/configure"; then + echo && + $SHELL "$ac_srcdir/configure" --help=recursive + else + echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + fi || ac_status=$? + cd "$ac_pwd" || { ac_status=$?; break; } + done +fi + +test -n "$ac_init_help" && exit $ac_status +if $ac_init_version; then + cat <<\_ACEOF +creGpioDae configure 0.0.1 +generated by GNU Autoconf 2.61 + +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, +2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +This configure script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it. +_ACEOF + exit +fi +cat >config.log <<_ACEOF +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. + +It was created by creGpioDae $as_me 0.0.1, which was +generated by GNU Autoconf 2.61. Invocation command line was + + $ $0 $@ + +_ACEOF +exec 5>>config.log +{ +cat <<_ASUNAME +## --------- ## +## Platform. ## +## --------- ## + +hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` + +/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` +/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` +/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` +/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` + +_ASUNAME + +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + echo "PATH: $as_dir" +done +IFS=$as_save_IFS + +} >&5 + +cat >&5 <<_ACEOF + + +## ----------- ## +## Core tests. ## +## ----------- ## + +_ACEOF + + +# Keep a trace of the command line. +# Strip out --no-create and --no-recursion so they do not pile up. +# Strip out --silent because we don't want to record it for future runs. +# Also quote any args containing shell meta-characters. +# Make two passes to allow for proper duplicate-argument suppression. +ac_configure_args= +ac_configure_args0= +ac_configure_args1= +ac_must_keep_next=false +for ac_pass in 1 2 +do + for ac_arg + do + case $ac_arg in + -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + continue ;; + *\'*) + ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + case $ac_pass in + 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; + 2) + ac_configure_args1="$ac_configure_args1 '$ac_arg'" + if test $ac_must_keep_next = true; then + ac_must_keep_next=false # Got value, back to normal. + else + case $ac_arg in + *=* | --config-cache | -C | -disable-* | --disable-* \ + | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ + | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ + | -with-* | --with-* | -without-* | --without-* | --x) + case "$ac_configure_args0 " in + "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; + esac + ;; + -* ) ac_must_keep_next=true ;; + esac + fi + ac_configure_args="$ac_configure_args '$ac_arg'" + ;; + esac + done +done +$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; } +$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; } + +# When interrupted or exit'd, cleanup temporary files, and complete +# config.log. We remove comments because anyway the quotes in there +# would cause problems or look ugly. +# WARNING: Use '\'' to represent an apostrophe within the trap. +# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. +trap 'exit_status=$? + # Save into config.log some information that might help in debugging. + { + echo + + cat <<\_ASBOX +## ---------------- ## +## Cache variables. ## +## ---------------- ## +_ASBOX + echo + # The following way of writing the cache mishandles newlines in values, +( + for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5 +echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + *) $as_unset $ac_var ;; + esac ;; + esac + done + (set) 2>&1 | + case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + sed -n \ + "s/'\''/'\''\\\\'\'''\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" + ;; #( + *) + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) + echo + + cat <<\_ASBOX +## ----------------- ## +## Output variables. ## +## ----------------- ## +_ASBOX + echo + for ac_var in $ac_subst_vars + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + echo "$ac_var='\''$ac_val'\''" + done | sort + echo + + if test -n "$ac_subst_files"; then + cat <<\_ASBOX +## ------------------- ## +## File substitutions. ## +## ------------------- ## +_ASBOX + echo + for ac_var in $ac_subst_files + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + echo "$ac_var='\''$ac_val'\''" + done | sort + echo + fi + + if test -s confdefs.h; then + cat <<\_ASBOX +## ----------- ## +## confdefs.h. ## +## ----------- ## +_ASBOX + echo + cat confdefs.h + echo + fi + test "$ac_signal" != 0 && + echo "$as_me: caught signal $ac_signal" + echo "$as_me: exit $exit_status" + } >&5 + rm -f core *.core core.conftest.* && + rm -f -r conftest* confdefs* conf$$* $ac_clean_files && + exit $exit_status +' 0 +for ac_signal in 1 2 13 15; do + trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal +done +ac_signal=0 + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -f -r conftest* confdefs.h + +# Predefined preprocessor variables. + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_NAME "$PACKAGE_NAME" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_TARNAME "$PACKAGE_TARNAME" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_VERSION "$PACKAGE_VERSION" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_STRING "$PACKAGE_STRING" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" +_ACEOF + + +# Let the site file select an alternate cache file if it wants to. +# Prefer explicitly selected file to automatically selected ones. +if test -n "$CONFIG_SITE"; then + set x "$CONFIG_SITE" +elif test "x$prefix" != xNONE; then + set x "$prefix/share/config.site" "$prefix/etc/config.site" +else + set x "$ac_default_prefix/share/config.site" \ + "$ac_default_prefix/etc/config.site" +fi +shift +for ac_site_file +do + if test -r "$ac_site_file"; then + { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 +echo "$as_me: loading site script $ac_site_file" >&6;} + sed 's/^/| /' "$ac_site_file" >&5 + . "$ac_site_file" + fi +done + +if test -r "$cache_file"; then + # Some versions of bash will fail to source /dev/null (special + # files actually), so we avoid doing that. + if test -f "$cache_file"; then + { echo "$as_me:$LINENO: loading cache $cache_file" >&5 +echo "$as_me: loading cache $cache_file" >&6;} + case $cache_file in + [\\/]* | ?:[\\/]* ) . "$cache_file";; + *) . "./$cache_file";; + esac + fi +else + { echo "$as_me:$LINENO: creating cache $cache_file" >&5 +echo "$as_me: creating cache $cache_file" >&6;} + >$cache_file +fi + +# Check that the precious variables saved in the cache have kept the same +# value. +ac_cache_corrupted=false +for ac_var in $ac_precious_vars; do + eval ac_old_set=\$ac_cv_env_${ac_var}_set + eval ac_new_set=\$ac_env_${ac_var}_set + eval ac_old_val=\$ac_cv_env_${ac_var}_value + eval ac_new_val=\$ac_env_${ac_var}_value + case $ac_old_set,$ac_new_set in + set,) + { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,set) + { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 +echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,);; + *) + if test "x$ac_old_val" != "x$ac_new_val"; then + { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 +echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 +echo "$as_me: former value: $ac_old_val" >&2;} + { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 +echo "$as_me: current value: $ac_new_val" >&2;} + ac_cache_corrupted=: + fi;; + esac + # Pass precious variables to config.status. + if test "$ac_new_set" = set; then + case $ac_new_val in + *\'*) ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *) ac_arg=$ac_var=$ac_new_val ;; + esac + case " $ac_configure_args " in + *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. + *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; + esac + fi +done +if $ac_cache_corrupted; then + { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 +echo "$as_me: error: changes in the environment can compromise the build" >&2;} + { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 +echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} + { (exit 1); exit 1; }; } +fi + + + + + + + + + + + + + + + + + + + + + + + + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + +# builtin(include, [m4/ac_func_snprintf.m4])dnl +# builtin(include, [m4/ac_func_scanf_can_malloc.m4])dnl + +am__api_version='1.10' + +ac_aux_dir= +for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do + if test -f "$ac_dir/install-sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f "$ac_dir/install.sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + elif test -f "$ac_dir/shtool"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/shtool install -c" + break + fi +done +if test -z "$ac_aux_dir"; then + { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&5 +echo "$as_me: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&2;} + { (exit 1); exit 1; }; } +fi + +# These three variables are undocumented and unsupported, +# and are intended to be withdrawn in a future Autoconf release. +# They can cause serious problems if a builder's source tree is in a directory +# whose full name contains unusual characters. +ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. +ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. +ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. + + +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AmigaOS /C/install, which installs bootblocks on floppy discs +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# OS/2's system install, which has a completely different semantic +# ./install, which can be erroneously created by make from ./install.sh. +{ echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 +echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6; } +if test -z "$INSTALL"; then +if test "${ac_cv_path_install+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + # Account for people who put trailing slashes in PATH elements. +case $as_dir/ in + ./ | .// | /cC/* | \ + /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ + ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \ + /usr/ucb/* ) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then + if test $ac_prog = install && + grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + elif test $ac_prog = install && + grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : + else + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" + break 3 + fi + fi + done + done + ;; +esac +done +IFS=$as_save_IFS + + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL=$ac_cv_path_install + else + # As a last resort, use the slow shell script. Don't cache a + # value for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the value is a relative name. + INSTALL=$ac_install_sh + fi +fi +{ echo "$as_me:$LINENO: result: $INSTALL" >&5 +echo "${ECHO_T}$INSTALL" >&6; } + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + +{ echo "$as_me:$LINENO: checking whether build environment is sane" >&5 +echo $ECHO_N "checking whether build environment is sane... $ECHO_C" >&6; } +# Just in case +sleep 1 +echo timestamp > conftest.file +# Do `set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null` + if test "$*" = "X"; then + # -L didn't work. + set X `ls -t $srcdir/configure conftest.file` + fi + rm -f conftest.file + if test "$*" != "X $srcdir/configure conftest.file" \ + && test "$*" != "X conftest.file $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + { { echo "$as_me:$LINENO: error: ls -t appears to fail. Make sure there is not a broken +alias in your environment" >&5 +echo "$as_me: error: ls -t appears to fail. Make sure there is not a broken +alias in your environment" >&2;} + { (exit 1); exit 1; }; } + fi + + test "$2" = conftest.file + ) +then + # Ok. + : +else + { { echo "$as_me:$LINENO: error: newly created file is older than distributed files! +Check your system clock" >&5 +echo "$as_me: error: newly created file is older than distributed files! +Check your system clock" >&2;} + { (exit 1); exit 1; }; } +fi +{ echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } +test "$program_prefix" != NONE && + program_transform_name="s&^&$program_prefix&;$program_transform_name" +# Use a double $ so make ignores it. +test "$program_suffix" != NONE && + program_transform_name="s&\$&$program_suffix&;$program_transform_name" +# Double any \ or $. echo might interpret backslashes. +# By default was `s,x,x', remove it if useless. +cat <<\_ACEOF >conftest.sed +s/[\\$]/&&/g;s/;s,x,x,$// +_ACEOF +program_transform_name=`echo $program_transform_name | sed -f conftest.sed` +rm -f conftest.sed + +# expand $ac_aux_dir to an absolute path +am_aux_dir=`cd $ac_aux_dir && pwd` + +test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing" +# Use eval to expand $SHELL +if eval "$MISSING --run true"; then + am_missing_run="$MISSING --run " +else + am_missing_run= + { echo "$as_me:$LINENO: WARNING: \`missing' script is too old or missing" >&5 +echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} +fi + +{ echo "$as_me:$LINENO: checking for a thread-safe mkdir -p" >&5 +echo $ECHO_N "checking for a thread-safe mkdir -p... $ECHO_C" >&6; } +if test -z "$MKDIR_P"; then + if test "${ac_cv_path_mkdir+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in mkdir gmkdir; do + for ac_exec_ext in '' $ac_executable_extensions; do + { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue + case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( + 'mkdir (GNU coreutils) '* | \ + 'mkdir (coreutils) '* | \ + 'mkdir (fileutils) '4.1*) + ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext + break 3;; + esac + done + done +done +IFS=$as_save_IFS + +fi + + if test "${ac_cv_path_mkdir+set}" = set; then + MKDIR_P="$ac_cv_path_mkdir -p" + else + # As a last resort, use the slow shell script. Don't cache a + # value for MKDIR_P within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the value is a relative name. + test -d ./--version && rmdir ./--version + MKDIR_P="$ac_install_sh -d" + fi +fi +{ echo "$as_me:$LINENO: result: $MKDIR_P" >&5 +echo "${ECHO_T}$MKDIR_P" >&6; } + +mkdir_p="$MKDIR_P" +case $mkdir_p in + [\\/$]* | ?:[\\/]*) ;; + */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; +esac + +for ac_prog in gawk mawk nawk awk +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_AWK+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$AWK"; then + ac_cv_prog_AWK="$AWK" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_AWK="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +AWK=$ac_cv_prog_AWK +if test -n "$AWK"; then + { echo "$as_me:$LINENO: result: $AWK" >&5 +echo "${ECHO_T}$AWK" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + + test -n "$AWK" && break +done + +{ echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5 +echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6; } +set x ${MAKE-make}; ac_make=`echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` +if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.make <<\_ACEOF +SHELL = /bin/sh +all: + @echo '@@@%%%=$(MAKE)=@@@%%%' +_ACEOF +# GNU make sometimes prints "make[1]: Entering...", which would confuse us. +case `${MAKE-make} -f conftest.make 2>/dev/null` in + *@@@%%%=?*=@@@%%%*) + eval ac_cv_prog_make_${ac_make}_set=yes;; + *) + eval ac_cv_prog_make_${ac_make}_set=no;; +esac +rm -f conftest.make +fi +if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } + SET_MAKE= +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } + SET_MAKE="MAKE=${MAKE-make}" +fi + +rm -rf .tst 2>/dev/null +mkdir .tst 2>/dev/null +if test -d .tst; then + am__leading_dot=. +else + am__leading_dot=_ +fi +rmdir .tst 2>/dev/null + +if test "`cd $srcdir && pwd`" != "`pwd`"; then + # Use -I$(srcdir) only when $(srcdir) != ., so that make's output + # is not polluted with repeated "-I." + am__isrc=' -I$(srcdir)' + # test to see if srcdir already configured + if test -f $srcdir/config.status; then + { { echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5 +echo "$as_me: error: source directory already configured; run \"make distclean\" there first" >&2;} + { (exit 1); exit 1; }; } + fi +fi + +# test whether we have cygpath +if test -z "$CYGPATH_W"; then + if (cygpath --version) >/dev/null 2>/dev/null; then + CYGPATH_W='cygpath -w' + else + CYGPATH_W=echo + fi +fi + + +# Define the identity of the package. + PACKAGE='cregpiodae' + VERSION='0.0.1' + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE "$PACKAGE" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define VERSION "$VERSION" +_ACEOF + +# Some tools Automake needs. + +ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} + + +AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} + + +AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} + + +AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} + + +MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} + +install_sh=${install_sh-"\$(SHELL) $am_aux_dir/install-sh"} + +# Installed binaries are usually stripped using `strip' when the user +# run `make install-strip'. However `strip' might not be the right +# tool to use in cross-compilation environments, therefore Automake +# will honor the `STRIP' environment variable to overrule this program. +if test "$cross_compiling" != no; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. +set dummy ${ac_tool_prefix}strip; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_STRIP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$STRIP"; then + ac_cv_prog_STRIP="$STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_STRIP="${ac_tool_prefix}strip" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +STRIP=$ac_cv_prog_STRIP +if test -n "$STRIP"; then + { echo "$as_me:$LINENO: result: $STRIP" >&5 +echo "${ECHO_T}$STRIP" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_STRIP"; then + ac_ct_STRIP=$STRIP + # Extract the first word of "strip", so it can be a program name with args. +set dummy strip; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_STRIP"; then + ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_STRIP="strip" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP +if test -n "$ac_ct_STRIP"; then + { echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5 +echo "${ECHO_T}$ac_ct_STRIP" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + if test "x$ac_ct_STRIP" = x; then + STRIP=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&5 +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&2;} +ac_tool_warned=yes ;; +esac + STRIP=$ac_ct_STRIP + fi +else + STRIP="$ac_cv_prog_STRIP" +fi + +fi +INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" + +# We need awk for the "check" target. The system "awk" is bad on +# some platforms. +# Always define AMTAR for backward compatibility. + +AMTAR=${AMTAR-"${am_missing_run}tar"} + +am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -' + + + + + +# AC_CONFIG_HEADER([config.h]) + + +cat >>confdefs.h <<\_ACEOF +#define _GNU_SOURCE 1 +_ACEOF + + + +# Checks for programs. +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_CC="gcc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&5 +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +else + CC="$ac_cv_prog_CC" +fi + +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + + fi +fi +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_prog_rejected=no +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# != 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" + fi +fi +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl.exe + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl.exe +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_CC="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + + test -n "$ac_ct_CC" && break +done + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&5 +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +fi + +fi + + +test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&5 +echo "$as_me: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } + +# Provide some information about the compiler. +echo "$as_me:$LINENO: checking for C compiler version" >&5 +ac_compiler=`set X $ac_compile; echo $2` +{ (ac_try="$ac_compiler --version >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compiler --version >&5") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (ac_try="$ac_compiler -v >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compiler -v >&5") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (ac_try="$ac_compiler -V >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compiler -V >&5") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files a.out a.exe b.out" +# Try to create an executable without -o first, disregard a.out. +# It will help us diagnose broken compilers, and finding out an intuition +# of exeext. +{ echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 +echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6; } +ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` +# +# List of possible output files, starting from the most likely. +# The algorithm is not robust to junk in `.', hence go to wildcards (a.*) +# only as a last resort. b.out is created by i960 compilers. +ac_files='a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out' +# +# The IRIX 6 linker writes into existing files which may not be +# executable, retaining their permissions. Remove them first so a +# subsequent execution test works. +ac_rmfiles= +for ac_file in $ac_files +do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;; + * ) ac_rmfiles="$ac_rmfiles $ac_file";; + esac +done +rm -f $ac_rmfiles + +if { (ac_try="$ac_link_default" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link_default") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. +# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' +# in a Makefile. We should not override ac_cv_exeext if it was cached, +# so that the user can short-circuit this test for compilers unknown to +# Autoconf. +for ac_file in $ac_files '' +do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) + ;; + [ab].out ) + # We found the default executable, but exeext='' is most + # certainly right. + break;; + *.* ) + if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; + then :; else + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + fi + # We set ac_cv_exeext here because the later test for it is not + # safe: cross compilers may not add the suffix if given an `-o' + # argument, so we may need to know it at that point already. + # Even if this section looks crufty: it has the advantage of + # actually working. + break;; + * ) + break;; + esac +done +test "$ac_cv_exeext" = no && ac_cv_exeext= + +else + ac_file='' +fi + +{ echo "$as_me:$LINENO: result: $ac_file" >&5 +echo "${ECHO_T}$ac_file" >&6; } +if test -z "$ac_file"; then + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { echo "$as_me:$LINENO: error: C compiler cannot create executables +See \`config.log' for more details." >&5 +echo "$as_me: error: C compiler cannot create executables +See \`config.log' for more details." >&2;} + { (exit 77); exit 77; }; } +fi + +ac_exeext=$ac_cv_exeext + +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ echo "$as_me:$LINENO: checking whether the C compiler works" >&5 +echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6; } +# FIXME: These cross compiler hacks should be removed for Autoconf 3.0 +# If not cross compiling, check that we can run a simple program. +if test "$cross_compiling" != yes; then + if { ac_try='./$ac_file' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { echo "$as_me:$LINENO: error: cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } + fi + fi +fi +{ echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } + +rm -f a.out a.exe conftest$ac_cv_exeext b.out +ac_clean_files=$ac_clean_files_save +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 +echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $cross_compiling" >&5 +echo "${ECHO_T}$cross_compiling" >&6; } + +{ echo "$as_me:$LINENO: checking for suffix of executables" >&5 +echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6; } +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # If both `conftest.exe' and `conftest' are `present' (well, observable) +# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will +# work properly (i.e., refer to `conftest.exe'), while it won't with +# `rm'. +for ac_file in conftest.exe conftest conftest.*; do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + break;; + * ) break;; + esac +done +else + { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +rm -f conftest$ac_cv_exeext +{ echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 +echo "${ECHO_T}$ac_cv_exeext" >&6; } + +rm -f conftest.$ac_ext +EXEEXT=$ac_cv_exeext +ac_exeext=$EXEEXT +{ echo "$as_me:$LINENO: checking for suffix of object files" >&5 +echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6; } +if test "${ac_cv_objext+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.o conftest.obj +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + for ac_file in conftest.o conftest.obj conftest.*; do + test -f "$ac_file" || continue; + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf ) ;; + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` + break;; + esac +done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute suffix of object files: cannot compile +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +rm -f conftest.$ac_cv_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 +echo "${ECHO_T}$ac_cv_objext" >&6; } +OBJEXT=$ac_cv_objext +ac_objext=$OBJEXT +{ echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 +echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6; } +if test "${ac_cv_c_compiler_gnu+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_compiler_gnu=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_compiler_gnu=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 +echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6; } +GCC=`test $ac_compiler_gnu = yes && echo yes` +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +{ echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 +echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6; } +if test "${ac_cv_prog_cc_g+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_save_c_werror_flag=$ac_c_werror_flag + ac_c_werror_flag=yes + ac_cv_prog_cc_g=no + CFLAGS="-g" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_prog_cc_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + CFLAGS="" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_c_werror_flag=$ac_save_c_werror_flag + CFLAGS="-g" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_prog_cc_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag=$ac_save_c_werror_flag +fi +{ echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_g" >&6; } +if test "$ac_test_CFLAGS" = set; then + CFLAGS=$ac_save_CFLAGS +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi +{ echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5 +echo $ECHO_N "checking for $CC option to accept ISO C89... $ECHO_C" >&6; } +if test "${ac_cv_prog_cc_c89+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_prog_cc_c89=no +ac_save_CC=$CC +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include +#include +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} + +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not '\xHH' hex character constants. + These don't provoke an error unfortunately, instead are silently treated + as 'x'. The following induces an error, until -std is added to get + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an + array size at least. It's necessary to write '\x00'==0 to get something + that's true only with -std. */ +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; + +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters + inside strings and character constants. */ +#define FOO(x) 'x' +int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; + +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_prog_cc_c89=$ac_arg +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext + test "x$ac_cv_prog_cc_c89" != "xno" && break +done +rm -f conftest.$ac_ext +CC=$ac_save_CC + +fi +# AC_CACHE_VAL +case "x$ac_cv_prog_cc_c89" in + x) + { echo "$as_me:$LINENO: result: none needed" >&5 +echo "${ECHO_T}none needed" >&6; } ;; + xno) + { echo "$as_me:$LINENO: result: unsupported" >&5 +echo "${ECHO_T}unsupported" >&6; } ;; + *) + CC="$CC $ac_cv_prog_cc_c89" + { echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_c89" >&6; } ;; +esac + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +DEPDIR="${am__leading_dot}deps" + +ac_config_commands="$ac_config_commands depfiles" + + +am_make=${MAKE-make} +cat > confinc << 'END' +am__doit: + @echo done +.PHONY: am__doit +END +# If we don't find an include directive, just comment out the code. +{ echo "$as_me:$LINENO: checking for style of include used by $am_make" >&5 +echo $ECHO_N "checking for style of include used by $am_make... $ECHO_C" >&6; } +am__include="#" +am__quote= +_am_result=none +# First try GNU make style include. +echo "include confinc" > confmf +# We grep out `Entering directory' and `Leaving directory' +# messages which can occur if `w' ends up in MAKEFLAGS. +# In particular we don't look at `^make:' because GNU make might +# be invoked under some other name (usually "gmake"), in which +# case it prints its new name instead of `make'. +if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then + am__include=include + am__quote= + _am_result=GNU +fi +# Now try BSD make style include. +if test "$am__include" = "#"; then + echo '.include "confinc"' > confmf + if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then + am__include=.include + am__quote="\"" + _am_result=BSD + fi +fi + + +{ echo "$as_me:$LINENO: result: $_am_result" >&5 +echo "${ECHO_T}$_am_result" >&6; } +rm -f confinc confmf + +# Check whether --enable-dependency-tracking was given. +if test "${enable_dependency_tracking+set}" = set; then + enableval=$enable_dependency_tracking; +fi + +if test "x$enable_dependency_tracking" != xno; then + am_depcomp="$ac_aux_dir/depcomp" + AMDEPBACKSLASH='\' +fi + if test "x$enable_dependency_tracking" != xno; then + AMDEP_TRUE= + AMDEP_FALSE='#' +else + AMDEP_TRUE='#' + AMDEP_FALSE= +fi + + + +depcc="$CC" am_compiler_list= + +{ echo "$as_me:$LINENO: checking dependency style of $depcc" >&5 +echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6; } +if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_CC_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` + fi + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with + # Solaris 8's {/usr,}/bin/sh. + touch sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + case $depmode in + nosideeffect) + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + none) break ;; + esac + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. + if depmode=$depmode \ + source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_CC_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_CC_dependencies_compiler_type=none +fi + +fi +{ echo "$as_me:$LINENO: result: $am_cv_CC_dependencies_compiler_type" >&5 +echo "${ECHO_T}$am_cv_CC_dependencies_compiler_type" >&6; } +CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type + + if + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then + am__fastdepCC_TRUE= + am__fastdepCC_FALSE='#' +else + am__fastdepCC_TRUE='#' + am__fastdepCC_FALSE= +fi + + +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AmigaOS /C/install, which installs bootblocks on floppy discs +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# OS/2's system install, which has a completely different semantic +# ./install, which can be erroneously created by make from ./install.sh. +{ echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 +echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6; } +if test -z "$INSTALL"; then +if test "${ac_cv_path_install+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + # Account for people who put trailing slashes in PATH elements. +case $as_dir/ in + ./ | .// | /cC/* | \ + /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ + ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \ + /usr/ucb/* ) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then + if test $ac_prog = install && + grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + elif test $ac_prog = install && + grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : + else + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" + break 3 + fi + fi + done + done + ;; +esac +done +IFS=$as_save_IFS + + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL=$ac_cv_path_install + else + # As a last resort, use the slow shell script. Don't cache a + # value for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the value is a relative name. + INSTALL=$ac_install_sh + fi +fi +{ echo "$as_me:$LINENO: result: $INSTALL" >&5 +echo "${ECHO_T}$INSTALL" >&6; } + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + + +# Checks for header files. + + + + + + +ac_header_dirent=no +for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do + as_ac_Header=`echo "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_hdr that defines DIR" >&5 +echo $ECHO_N "checking for $ac_hdr that defines DIR... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include <$ac_hdr> + +int +main () +{ +if ((DIR *) 0) +return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + eval "$as_ac_Header=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_Header=no" +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_hdr" | $as_tr_cpp` 1 +_ACEOF + +ac_header_dirent=$ac_hdr; break +fi + +done +# Two versions of opendir et al. are in -ldir and -lx on SCO Xenix. +if test $ac_header_dirent = dirent.h; then + { echo "$as_me:$LINENO: checking for library containing opendir" >&5 +echo $ECHO_N "checking for library containing opendir... $ECHO_C" >&6; } +if test "${ac_cv_search_opendir+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_func_search_save_LIBS=$LIBS +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char opendir (); +int +main () +{ +return opendir (); + ; + return 0; +} +_ACEOF +for ac_lib in '' dir; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_search_opendir=$ac_res +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext + if test "${ac_cv_search_opendir+set}" = set; then + break +fi +done +if test "${ac_cv_search_opendir+set}" = set; then + : +else + ac_cv_search_opendir=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ echo "$as_me:$LINENO: result: $ac_cv_search_opendir" >&5 +echo "${ECHO_T}$ac_cv_search_opendir" >&6; } +ac_res=$ac_cv_search_opendir +if test "$ac_res" != no; then + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + +fi + +else + { echo "$as_me:$LINENO: checking for library containing opendir" >&5 +echo $ECHO_N "checking for library containing opendir... $ECHO_C" >&6; } +if test "${ac_cv_search_opendir+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_func_search_save_LIBS=$LIBS +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char opendir (); +int +main () +{ +return opendir (); + ; + return 0; +} +_ACEOF +for ac_lib in '' x; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_search_opendir=$ac_res +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext + if test "${ac_cv_search_opendir+set}" = set; then + break +fi +done +if test "${ac_cv_search_opendir+set}" = set; then + : +else + ac_cv_search_opendir=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ echo "$as_me:$LINENO: result: $ac_cv_search_opendir" >&5 +echo "${ECHO_T}$ac_cv_search_opendir" >&6; } +ac_res=$ac_cv_search_opendir +if test "$ac_res" != no; then + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + +fi + +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 +echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6; } +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then + if test "${ac_cv_prog_CPP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi + +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi + +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + break +fi + + done + ac_cv_prog_CPP=$CPP + +fi + CPP=$ac_cv_prog_CPP +else + ac_cv_prog_CPP=$CPP +fi +{ echo "$as_me:$LINENO: result: $CPP" >&5 +echo "${ECHO_T}$CPP" >&6; } +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi + +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi + +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + : +else + { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." >&5 +echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +{ echo "$as_me:$LINENO: checking for grep that handles long lines and -e" >&5 +echo $ECHO_N "checking for grep that handles long lines and -e... $ECHO_C" >&6; } +if test "${ac_cv_path_GREP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # Extract the first word of "grep ggrep" to use in msg output +if test -z "$GREP"; then +set dummy grep ggrep; ac_prog_name=$2 +if test "${ac_cv_path_GREP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_path_GREP_found=false +# Loop through the user's path and test for each of PROGNAME-LIST +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in grep ggrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue + # Check for GNU ac_path_GREP and select it if it is found. + # Check for GNU $ac_path_GREP +case `"$ac_path_GREP" --version 2>&1` in +*GNU*) + ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; +*) + ac_count=0 + echo $ECHO_N "0123456789$ECHO_C" >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + echo 'GREP' >> "conftest.nl" + "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + ac_count=`expr $ac_count + 1` + if test $ac_count -gt ${ac_path_GREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_GREP="$ac_path_GREP" + ac_path_GREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + + $ac_path_GREP_found && break 3 + done +done + +done +IFS=$as_save_IFS + + +fi + +GREP="$ac_cv_path_GREP" +if test -z "$GREP"; then + { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 +echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} + { (exit 1); exit 1; }; } +fi + +else + ac_cv_path_GREP=$GREP +fi + + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_path_GREP" >&5 +echo "${ECHO_T}$ac_cv_path_GREP" >&6; } + GREP="$ac_cv_path_GREP" + + +{ echo "$as_me:$LINENO: checking for egrep" >&5 +echo $ECHO_N "checking for egrep... $ECHO_C" >&6; } +if test "${ac_cv_path_EGREP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 + then ac_cv_path_EGREP="$GREP -E" + else + # Extract the first word of "egrep" to use in msg output +if test -z "$EGREP"; then +set dummy egrep; ac_prog_name=$2 +if test "${ac_cv_path_EGREP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_path_EGREP_found=false +# Loop through the user's path and test for each of PROGNAME-LIST +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in egrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue + # Check for GNU ac_path_EGREP and select it if it is found. + # Check for GNU $ac_path_EGREP +case `"$ac_path_EGREP" --version 2>&1` in +*GNU*) + ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; +*) + ac_count=0 + echo $ECHO_N "0123456789$ECHO_C" >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + echo 'EGREP' >> "conftest.nl" + "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + ac_count=`expr $ac_count + 1` + if test $ac_count -gt ${ac_path_EGREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_EGREP="$ac_path_EGREP" + ac_path_EGREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + + $ac_path_EGREP_found && break 3 + done +done + +done +IFS=$as_save_IFS + + +fi + +EGREP="$ac_cv_path_EGREP" +if test -z "$EGREP"; then + { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 +echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} + { (exit 1); exit 1; }; } +fi + +else + ac_cv_path_EGREP=$EGREP +fi + + + fi +fi +{ echo "$as_me:$LINENO: result: $ac_cv_path_EGREP" >&5 +echo "${ECHO_T}$ac_cv_path_EGREP" >&6; } + EGREP="$ac_cv_path_EGREP" + + +{ echo "$as_me:$LINENO: checking for ANSI C header files" >&5 +echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6; } +if test "${ac_cv_header_stdc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include +#include + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_header_stdc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_header_stdc=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then + : +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then + : +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then + : +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + return 2; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_header_stdc=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + +fi +fi +{ echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 +echo "${ECHO_T}$ac_cv_header_stdc" >&6; } +if test $ac_cv_header_stdc = yes; then + +cat >>confdefs.h <<\_ACEOF +#define STDC_HEADERS 1 +_ACEOF + +fi + +# On IRIX 5.3, sys/types and inttypes.h are conflicting. + + + + + + + + + +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ + inttypes.h stdint.h unistd.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + eval "$as_ac_Header=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_Header=no" +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + + +for ac_header in parser.h iniparser.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +else + # Is the header compilable? +{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } + +# Is the header present? +{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + +for ac_header in dictionary.h inistrings.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +else + # Is the header compilable? +{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } + +# Is the header present? +{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + +for ac_header in math.h stdio.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +else + # Is the header compilable? +{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } + +# Is the header present? +{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + + + + + + + + + +for ac_header in fcntl.h inttypes.h limits.h memory.h stddef.h stdint.h stdlib.h string.h strings.h unistd.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +else + # Is the header compilable? +{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } + +# Is the header present? +{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + +# AC_CHECK_HEADERS([libgen.h getopt.h]) + +# Checks for typedefs, structures, and compiler characteristics. +{ echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5 +echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6; } +if test "${ac_cv_c_const+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +/* FIXME: Include the comments suggested by Paul. */ +#ifndef __cplusplus + /* Ultrix mips cc rejects this. */ + typedef int charset[2]; + const charset cs; + /* SunOS 4.1.1 cc rejects this. */ + char const *const *pcpcc; + char **ppc; + /* NEC SVR4.0.2 mips cc rejects this. */ + struct point {int x, y;}; + static struct point const zero = {0,0}; + /* AIX XL C 1.02.0.0 rejects this. + It does not let you subtract one const X* pointer from another in + an arm of an if-expression whose if-part is not a constant + expression */ + const char *g = "string"; + pcpcc = &g + (g ? g-g : 0); + /* HPUX 7.0 cc rejects these. */ + ++pcpcc; + ppc = (char**) pcpcc; + pcpcc = (char const *const *) ppc; + { /* SCO 3.2v4 cc rejects this. */ + char *t; + char const *s = 0 ? (char *) 0 : (char const *) 0; + + *t++ = 0; + if (s) return 0; + } + { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ + int x[] = {25, 17}; + const int *foo = &x[0]; + ++foo; + } + { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ + typedef const int *iptr; + iptr p = 0; + ++p; + } + { /* AIX XL C 1.02.0.0 rejects this saying + "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ + struct s { int j; const int *ap[3]; }; + struct s *b; b->j = 5; + } + { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ + const int foo = 10; + if (!foo) return 0; + } + return !cs[0] && !zero.x; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_c_const=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_c_const=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_c_const" >&5 +echo "${ECHO_T}$ac_cv_c_const" >&6; } +if test $ac_cv_c_const = no; then + +cat >>confdefs.h <<\_ACEOF +#define const +_ACEOF + +fi + +# AC_TYPE_UID_T +# AC_C_INLINE +# AC_CHECK_TYPE(size_t, unsigned) +# AC_CHECK_TYPE(ssize_t, signed) +# AC_CHECK_MEMBERS([struct stat.st_rdev]) + +# Checks for library functions. +# AC_CHECK_FUNCS([getopt_long getline strtof]) +# AC_FUNC_SNPRINTF +# AC_FUNC_SCANF_CAN_MALLOC + +ac_config_files="$ac_config_files Makefile" + +cat >confcache <<\_ACEOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs, see configure's option --config-cache. +# It is not useful on other systems. If it contains results you don't +# want to keep, you may remove or edit it. +# +# config.status only pays attention to the cache file if you give it +# the --recheck option to rerun configure. +# +# `ac_cv_env_foo' variables (set or unset) will be overridden when +# loading this file, other *unset* `ac_cv_foo' will be assigned the +# following values. + +_ACEOF + +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, we kill variables containing newlines. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +( + for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5 +echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + *) $as_unset $ac_var ;; + esac ;; + esac + done + + (set) 2>&1 | + case $as_nl`(ac_space=' '; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + # `set' does not quote correctly, so add quotes (double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \). + sed -n \ + "s/'/'\\\\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" + ;; #( + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) | + sed ' + /^ac_cv_env_/b end + t clear + :clear + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ + t end + s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + :end' >>confcache +if diff "$cache_file" confcache >/dev/null 2>&1; then :; else + if test -w "$cache_file"; then + test "x$cache_file" != "x/dev/null" && + { echo "$as_me:$LINENO: updating cache $cache_file" >&5 +echo "$as_me: updating cache $cache_file" >&6;} + cat confcache >$cache_file + else + { echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5 +echo "$as_me: not updating unwritable cache $cache_file" >&6;} + fi +fi +rm -f confcache + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +# Transform confdefs.h into DEFS. +# Protect against shell expansion while executing Makefile rules. +# Protect against Makefile macro expansion. +# +# If the first sed substitution is executed (which looks for macros that +# take arguments), then branch to the quote section. Otherwise, +# look for a macro that doesn't take arguments. +ac_script=' +t clear +:clear +s/^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\)/-D\1=\2/g +t quote +s/^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)/-D\1=\2/g +t quote +b any +:quote +s/[ `~#$^&*(){}\\|;'\''"<>?]/\\&/g +s/\[/\\&/g +s/\]/\\&/g +s/\$/$$/g +H +:any +${ + g + s/^\n// + s/\n/ /g + p +} +' +DEFS=`sed -n "$ac_script" confdefs.h` + + +ac_libobjs= +ac_ltlibobjs= +for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue + # 1. Remove the extension, and $U if already installed. + ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' + ac_i=`echo "$ac_i" | sed "$ac_script"` + # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR + # will be set to the directory where LIBOBJS objects are built. + ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext" + ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$ac_i"'$U.lo' +done +LIBOBJS=$ac_libobjs + +LTLIBOBJS=$ac_ltlibobjs + + +if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"AMDEP\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"AMDEP\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi +if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCC\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"am__fastdepCC\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi + +: ${CONFIG_STATUS=./config.status} +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files $CONFIG_STATUS" +{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 +echo "$as_me: creating $CONFIG_STATUS" >&6;} +cat >$CONFIG_STATUS <<_ACEOF +#! $SHELL +# Generated by $as_me. +# Run this file to recreate the current configuration. +# Compiler output produced by configure, useful for debugging +# configure, is in config.log if it exists. + +debug=false +ac_cs_recheck=false +ac_cs_silent=false +SHELL=\${CONFIG_SHELL-$SHELL} +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +## --------------------- ## +## M4sh Initialization. ## +## --------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + + + +# PATH needs CR +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + +# Support unset when possible. +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +as_nl=' +' +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +case $0 in + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + { (exit 1); exit 1; } +fi + +# Work around bugs in pre-3.0 UWIN ksh. +for as_var in ENV MAIL MAILPATH +do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +for as_var in \ + LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ + LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ + LC_TELEPHONE LC_TIME +do + if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then + eval $as_var=C; export $as_var + else + ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var + fi +done + +# Required to use basename. +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + + +# Name of the executable. +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# CDPATH. +$as_unset CDPATH + + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { + + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line after each line using $LINENO; the second 'sed' + # does the real work. The second script uses 'N' to pair each + # line-number line with the line containing $LINENO, and appends + # trailing '-' during substitution so that $LINENO is not a special + # case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # scripts with optimization help from Paolo Bonzini. Blame Lee + # E. McMahon (1931-1989) for sed's syntax. :-) + sed -n ' + p + /[$]LINENO/= + ' <$as_myself | + sed ' + s/[$]LINENO.*/&-/ + t lineno + b + :lineno + N + :loop + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ + t loop + s/-\n.*// + ' >$as_me.lineno && + chmod +x "$as_me.lineno" || + { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 + { (exit 1); exit 1; }; } + + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensitive to this). + . "./$as_me.lineno" + # Exit status is that of the last command. + exit +} + + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in +-n*) + case `echo 'x\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + *) ECHO_C='\c';; + esac;; +*) + ECHO_N='-n';; +esac + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir +fi +echo >conf$$.file +if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -p' +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + +if mkdir -p . 2>/dev/null; then + as_mkdir_p=: +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +exec 6>&1 + +# Save the log message, to keep $[0] and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. +ac_log=" +This file was extended by creGpioDae $as_me 0.0.1, which was +generated by GNU Autoconf 2.61. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +on `(hostname || uname -n) 2>/dev/null | sed 1q` +" + +_ACEOF + +cat >>$CONFIG_STATUS <<_ACEOF +# Files that config.status was made for. +config_files="$ac_config_files" +config_commands="$ac_config_commands" + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +ac_cs_usage="\ +\`$as_me' instantiates files from templates according to the +current configuration. + +Usage: $0 [OPTIONS] [FILE]... + + -h, --help print this help, then exit + -V, --version print version number and configuration settings, then exit + -q, --quiet do not print progress messages + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE + +Configuration files: +$config_files + +Configuration commands: +$config_commands + +Report bugs to ." + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF +ac_cs_version="\\ +creGpioDae config.status 0.0.1 +configured by $0, generated by GNU Autoconf 2.61, + with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" + +Copyright (C) 2006 Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." + +ac_pwd='$ac_pwd' +srcdir='$srcdir' +INSTALL='$INSTALL' +MKDIR_P='$MKDIR_P' +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +# If no file are specified by the user, then we need to provide default +# value. By we need to know if files were specified by the user. +ac_need_defaults=: +while test $# != 0 +do + case $1 in + --*=*) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` + ac_shift=: + ;; + *) + ac_option=$1 + ac_optarg=$2 + ac_shift=shift + ;; + esac + + case $ac_option in + # Handling of the options. + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + ac_cs_recheck=: ;; + --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) + echo "$ac_cs_version"; exit ;; + --debug | --debu | --deb | --de | --d | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + $ac_shift + CONFIG_FILES="$CONFIG_FILES $ac_optarg" + ac_need_defaults=false;; + --he | --h | --help | --hel | -h ) + echo "$ac_cs_usage"; exit ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil | --si | --s) + ac_cs_silent=: ;; + + # This is an error. + -*) { echo "$as_me: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&2 + { (exit 1); exit 1; }; } ;; + + *) ac_config_targets="$ac_config_targets $1" + ac_need_defaults=false ;; + + esac + shift +done + +ac_configure_extra_args= + +if $ac_cs_silent; then + exec 6>/dev/null + ac_configure_extra_args="$ac_configure_extra_args --silent" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF +if \$ac_cs_recheck; then + echo "running CONFIG_SHELL=$SHELL $SHELL $0 "$ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 + CONFIG_SHELL=$SHELL + export CONFIG_SHELL + exec $SHELL "$0"$ac_configure_args \$ac_configure_extra_args --no-create --no-recursion +fi + +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX + echo "$ac_log" +} >&5 + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF +# +# INIT-COMMANDS +# +AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF + +# Handling of arguments. +for ac_config_target in $ac_config_targets +do + case $ac_config_target in + "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; + "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; + + *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 +echo "$as_me: error: invalid argument: $ac_config_target" >&2;} + { (exit 1); exit 1; }; };; + esac +done + + +# If the user did not use the arguments to specify the items to instantiate, +# then the envvar interface is used. Set only those that are not. +# We use the long form for the default assignment because of an extremely +# bizarre bug on SunOS 4.1.3. +if $ac_need_defaults; then + test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files + test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands +fi + +# Have a temporary directory for convenience. Make it in the build tree +# simply because there is no reason against having it here, and in addition, +# creating and moving files from /tmp can sometimes cause problems. +# Hook for its removal unless debugging. +# Note that there is a small window in which the directory will not be cleaned: +# after its creation but before its name has been assigned to `$tmp'. +$debug || +{ + tmp= + trap 'exit_status=$? + { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status +' 0 + trap '{ (exit 1); exit 1; }' 1 2 13 15 +} +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && + test -n "$tmp" && test -d "$tmp" +} || +{ + tmp=./conf$$-$RANDOM + (umask 077 && mkdir "$tmp") +} || +{ + echo "$me: cannot create a temporary directory in ." >&2 + { (exit 1); exit 1; } +} + +# +# Set up the sed scripts for CONFIG_FILES section. +# + +# No need to generate the scripts if there are no CONFIG_FILES. +# This happens for instance when ./config.status config.h +if test -n "$CONFIG_FILES"; then + +_ACEOF + + + +ac_delim='%!_!# ' +for ac_last_try in false false false false false :; do + cat >conf$$subs.sed <<_ACEOF +SHELL!$SHELL$ac_delim +PATH_SEPARATOR!$PATH_SEPARATOR$ac_delim +PACKAGE_NAME!$PACKAGE_NAME$ac_delim +PACKAGE_TARNAME!$PACKAGE_TARNAME$ac_delim +PACKAGE_VERSION!$PACKAGE_VERSION$ac_delim +PACKAGE_STRING!$PACKAGE_STRING$ac_delim +PACKAGE_BUGREPORT!$PACKAGE_BUGREPORT$ac_delim +exec_prefix!$exec_prefix$ac_delim +prefix!$prefix$ac_delim +program_transform_name!$program_transform_name$ac_delim +bindir!$bindir$ac_delim +sbindir!$sbindir$ac_delim +libexecdir!$libexecdir$ac_delim +datarootdir!$datarootdir$ac_delim +datadir!$datadir$ac_delim +sysconfdir!$sysconfdir$ac_delim +sharedstatedir!$sharedstatedir$ac_delim +localstatedir!$localstatedir$ac_delim +includedir!$includedir$ac_delim +oldincludedir!$oldincludedir$ac_delim +docdir!$docdir$ac_delim +infodir!$infodir$ac_delim +htmldir!$htmldir$ac_delim +dvidir!$dvidir$ac_delim +pdfdir!$pdfdir$ac_delim +psdir!$psdir$ac_delim +libdir!$libdir$ac_delim +localedir!$localedir$ac_delim +mandir!$mandir$ac_delim +DEFS!$DEFS$ac_delim +ECHO_C!$ECHO_C$ac_delim +ECHO_N!$ECHO_N$ac_delim +ECHO_T!$ECHO_T$ac_delim +LIBS!$LIBS$ac_delim +build_alias!$build_alias$ac_delim +host_alias!$host_alias$ac_delim +target_alias!$target_alias$ac_delim +INSTALL_PROGRAM!$INSTALL_PROGRAM$ac_delim +INSTALL_SCRIPT!$INSTALL_SCRIPT$ac_delim +INSTALL_DATA!$INSTALL_DATA$ac_delim +am__isrc!$am__isrc$ac_delim +CYGPATH_W!$CYGPATH_W$ac_delim +PACKAGE!$PACKAGE$ac_delim +VERSION!$VERSION$ac_delim +ACLOCAL!$ACLOCAL$ac_delim +AUTOCONF!$AUTOCONF$ac_delim +AUTOMAKE!$AUTOMAKE$ac_delim +AUTOHEADER!$AUTOHEADER$ac_delim +MAKEINFO!$MAKEINFO$ac_delim +install_sh!$install_sh$ac_delim +STRIP!$STRIP$ac_delim +INSTALL_STRIP_PROGRAM!$INSTALL_STRIP_PROGRAM$ac_delim +mkdir_p!$mkdir_p$ac_delim +AWK!$AWK$ac_delim +SET_MAKE!$SET_MAKE$ac_delim +am__leading_dot!$am__leading_dot$ac_delim +AMTAR!$AMTAR$ac_delim +am__tar!$am__tar$ac_delim +am__untar!$am__untar$ac_delim +CC!$CC$ac_delim +CFLAGS!$CFLAGS$ac_delim +LDFLAGS!$LDFLAGS$ac_delim +CPPFLAGS!$CPPFLAGS$ac_delim +ac_ct_CC!$ac_ct_CC$ac_delim +EXEEXT!$EXEEXT$ac_delim +OBJEXT!$OBJEXT$ac_delim +DEPDIR!$DEPDIR$ac_delim +am__include!$am__include$ac_delim +am__quote!$am__quote$ac_delim +AMDEP_TRUE!$AMDEP_TRUE$ac_delim +AMDEP_FALSE!$AMDEP_FALSE$ac_delim +AMDEPBACKSLASH!$AMDEPBACKSLASH$ac_delim +CCDEPMODE!$CCDEPMODE$ac_delim +am__fastdepCC_TRUE!$am__fastdepCC_TRUE$ac_delim +am__fastdepCC_FALSE!$am__fastdepCC_FALSE$ac_delim +CPP!$CPP$ac_delim +GREP!$GREP$ac_delim +EGREP!$EGREP$ac_delim +LIBOBJS!$LIBOBJS$ac_delim +LTLIBOBJS!$LTLIBOBJS$ac_delim +_ACEOF + + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 80; then + break + elif $ac_last_try; then + { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 +echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} + { (exit 1); exit 1; }; } + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done + +ac_eof=`sed -n '/^CEOF[0-9]*$/s/CEOF/0/p' conf$$subs.sed` +if test -n "$ac_eof"; then + ac_eof=`echo "$ac_eof" | sort -nru | sed 1q` + ac_eof=`expr $ac_eof + 1` +fi + +cat >>$CONFIG_STATUS <<_ACEOF +cat >"\$tmp/subs-1.sed" <<\CEOF$ac_eof +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b end +_ACEOF +sed ' +s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g +s/^/s,@/; s/!/@,|#_!!_#|/ +:n +t n +s/'"$ac_delim"'$/,g/; t +s/$/\\/; p +N; s/^.*\n//; s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g; b n +' >>$CONFIG_STATUS >$CONFIG_STATUS <<_ACEOF +:end +s/|#_!!_#|//g +CEOF$ac_eof +_ACEOF + + +# VPATH may cause trouble with some makes, so we remove $(srcdir), +# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and +# trailing colons and then remove the whole line if VPATH becomes empty +# (actually we leave an empty line to preserve line numbers). +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=/{ +s/:*\$(srcdir):*/:/ +s/:*\${srcdir}:*/:/ +s/:*@srcdir@:*/:/ +s/^\([^=]*=[ ]*\):*/\1/ +s/:*$// +s/^[^=]*=[ ]*$// +}' +fi + +cat >>$CONFIG_STATUS <<\_ACEOF +fi # test -n "$CONFIG_FILES" + + +for ac_tag in :F $CONFIG_FILES :C $CONFIG_COMMANDS +do + case $ac_tag in + :[FHLC]) ac_mode=$ac_tag; continue;; + esac + case $ac_mode$ac_tag in + :[FHL]*:*);; + :L* | :C*:*) { { echo "$as_me:$LINENO: error: Invalid tag $ac_tag." >&5 +echo "$as_me: error: Invalid tag $ac_tag." >&2;} + { (exit 1); exit 1; }; };; + :[FH]-) ac_tag=-:-;; + :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; + esac + ac_save_IFS=$IFS + IFS=: + set x $ac_tag + IFS=$ac_save_IFS + shift + ac_file=$1 + shift + + case $ac_mode in + :L) ac_source=$1;; + :[FH]) + ac_file_inputs= + for ac_f + do + case $ac_f in + -) ac_f="$tmp/stdin";; + *) # Look for the file first in the build tree, then in the source tree + # (if the path is not absolute). The absolute path cannot be DOS-style, + # because $ac_f cannot contain `:'. + test -f "$ac_f" || + case $ac_f in + [\\/$]*) false;; + *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; + esac || + { { echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5 +echo "$as_me: error: cannot find input file: $ac_f" >&2;} + { (exit 1); exit 1; }; };; + esac + ac_file_inputs="$ac_file_inputs $ac_f" + done + + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + configure_input="Generated from "`IFS=: + echo $* | sed 's|^[^:]*/||;s|:[^:]*/|, |g'`" by configure." + if test x"$ac_file" != x-; then + configure_input="$ac_file. $configure_input" + { echo "$as_me:$LINENO: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + fi + + case $ac_tag in + *:-:* | *:-) cat >"$tmp/stdin";; + esac + ;; + esac + + ac_dir=`$as_dirname -- "$ac_file" || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || +echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + { as_dir="$ac_dir" + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || { { echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 +echo "$as_me: error: cannot create directory $as_dir" >&2;} + { (exit 1); exit 1; }; }; } + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + + case $ac_mode in + :F) + # + # CONFIG_FILE + # + + case $INSTALL in + [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; + *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; + esac + ac_MKDIR_P=$MKDIR_P + case $MKDIR_P in + [\\/$]* | ?:[\\/]* ) ;; + */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; + esac +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +# If the template does not know about datarootdir, expand it. +# FIXME: This hack should be removed a few years after 2.60. +ac_datarootdir_hack=; ac_datarootdir_seen= + +case `sed -n '/datarootdir/ { + p + q +} +/@datadir@/p +/@docdir@/p +/@infodir@/p +/@localedir@/p +/@mandir@/p +' $ac_file_inputs` in +*datarootdir*) ac_datarootdir_seen=yes;; +*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) + { echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 +echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF + ac_datarootdir_hack=' + s&@datadir@&$datadir&g + s&@docdir@&$docdir&g + s&@infodir@&$infodir&g + s&@localedir@&$localedir&g + s&@mandir@&$mandir&g + s&\\\${datarootdir}&$datarootdir&g' ;; +esac +_ACEOF + +# Neutralize VPATH when `$srcdir' = `.'. +# Shell code in configure.ac might set extrasub. +# FIXME: do we really want to maintain this feature? +cat >>$CONFIG_STATUS <<_ACEOF + sed "$ac_vpsub +$extrasub +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s&@configure_input@&$configure_input&;t t +s&@top_builddir@&$ac_top_builddir_sub&;t t +s&@srcdir@&$ac_srcdir&;t t +s&@abs_srcdir@&$ac_abs_srcdir&;t t +s&@top_srcdir@&$ac_top_srcdir&;t t +s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t +s&@builddir@&$ac_builddir&;t t +s&@abs_builddir@&$ac_abs_builddir&;t t +s&@abs_top_builddir@&$ac_abs_top_builddir&;t t +s&@INSTALL@&$ac_INSTALL&;t t +s&@MKDIR_P@&$ac_MKDIR_P&;t t +$ac_datarootdir_hack +" $ac_file_inputs | sed -f "$tmp/subs-1.sed" >$tmp/out + +test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && + { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && + { echo "$as_me:$LINENO: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined." >&5 +echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined." >&2;} + + rm -f "$tmp/stdin" + case $ac_file in + -) cat "$tmp/out"; rm -f "$tmp/out";; + *) rm -f "$ac_file"; mv "$tmp/out" $ac_file;; + esac + ;; + + + :C) { echo "$as_me:$LINENO: executing $ac_file commands" >&5 +echo "$as_me: executing $ac_file commands" >&6;} + ;; + esac + + + case $ac_file$ac_mode in + "depfiles":C) test x"$AMDEP_TRUE" != x"" || for mf in $CONFIG_FILES; do + # Strip MF so we end up with the name of the file. + mf=`echo "$mf" | sed -e 's/:.*$//'` + # Check whether this is an Automake generated Makefile or not. + # We used to match only the files named `Makefile.in', but + # some people rename them; so instead we look at the file content. + # Grep'ing the first line is not enough: some people post-process + # each Makefile.in and add a new line on top of each file to say so. + # Grep'ing the whole file is not good either: AIX grep has a line + # limit of 2048, but all sed's we know have understand at least 4000. + if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then + dirpart=`$as_dirname -- "$mf" || +$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$mf" : 'X\(//\)[^/]' \| \ + X"$mf" : 'X\(//\)$' \| \ + X"$mf" : 'X\(/\)' \| . 2>/dev/null || +echo X"$mf" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + else + continue + fi + # Extract the definition of DEPDIR, am__include, and am__quote + # from the Makefile without running `make'. + DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` + test -z "$DEPDIR" && continue + am__include=`sed -n 's/^am__include = //p' < "$mf"` + test -z "am__include" && continue + am__quote=`sed -n 's/^am__quote = //p' < "$mf"` + # When using ansi2knr, U may be empty or an underscore; expand it + U=`sed -n 's/^U = //p' < "$mf"` + # Find all dependency output files, they are included files with + # $(DEPDIR) in their names. We invoke sed twice because it is the + # simplest approach to changing $(DEPDIR) to its actual value in the + # expansion. + for file in `sed -n " + s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ + sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do + # Make sure the directory exists. + test -f "$dirpart/$file" && continue + fdir=`$as_dirname -- "$file" || +$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$file" : 'X\(//\)[^/]' \| \ + X"$file" : 'X\(//\)$' \| \ + X"$file" : 'X\(/\)' \| . 2>/dev/null || +echo X"$file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + { as_dir=$dirpart/$fdir + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || { { echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 +echo "$as_me: error: cannot create directory $as_dir" >&2;} + { (exit 1); exit 1; }; }; } + # echo "creating $dirpart/$file" + echo '# dummy' > "$dirpart/$file" + done +done + ;; + + esac +done # for ac_tag + + +{ (exit 0); exit 0; } +_ACEOF +chmod +x $CONFIG_STATUS +ac_clean_files=$ac_clean_files_save + + +# configure is writing to config.log, and then calls config.status. +# config.status does its own redirection, appending to config.log. +# Unfortunately, on DOS this fails, as config.log is still kept open +# by configure, so config.status won't be able to write to it; its +# output is simply discarded. So we exec the FD to /dev/null, +# effectively closing config.log, so it can be properly (re)opened and +# appended to by config.status. When coming back to configure, we +# need to make the FD available again. +if test "$no_create" != yes; then + ac_cs_success=: + ac_config_status_args= + test "$silent" = yes && + ac_config_status_args="$ac_config_status_args --quiet" + exec 5>/dev/null + $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false + exec 5>>config.log + # Use ||, not &&, to avoid exiting from the if with $? = 1, which + # would make configure fail if this is the last instruction. + $ac_cs_success || { (exit 1); exit 1; } +fi + +# AC_OUTPUT([Makefile],[chmod a+x test-mount.sh test.sh]) diff --git a/Quantum Controller/SW/testapplication-0.0.1/configure.in b/Quantum Controller/SW/testapplication-0.0.1/configure.in new file mode 100644 index 0000000..139fb6d --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/configure.in @@ -0,0 +1,43 @@ +# -*- Autoconf -*- +# Process this file with autoconf to produce a configure script. + +AC_PREREQ(2.59) +AC_INIT(creGpioDae, 0.0.1) + +# builtin(include, [m4/ac_func_snprintf.m4])dnl +# builtin(include, [m4/ac_func_scanf_can_malloc.m4])dnl + +AM_INIT_AUTOMAKE() +# AC_CONFIG_HEADER([config.h]) + +AC_GNU_SOURCE + +# Checks for programs. +AC_PROG_CC +AC_PROG_INSTALL + +# Checks for header files. +AC_HEADER_DIRENT +AC_HEADER_STDC +AC_CHECK_HEADERS([parser.h iniparser.h]) +AC_CHECK_HEADERS([dictionary.h inistrings.h]) +AC_CHECK_HEADERS([math.h stdio.h]) +AC_CHECK_HEADERS([fcntl.h inttypes.h limits.h memory.h stddef.h stdint.h stdlib.h string.h strings.h unistd.h]) +# AC_CHECK_HEADERS([libgen.h getopt.h]) + +# Checks for typedefs, structures, and compiler characteristics. +AC_C_CONST +# AC_TYPE_UID_T +# AC_C_INLINE +# AC_CHECK_TYPE(size_t, unsigned) +# AC_CHECK_TYPE(ssize_t, signed) +# AC_CHECK_MEMBERS([struct stat.st_rdev]) + +# Checks for library functions. +# AC_CHECK_FUNCS([getopt_long getline strtof]) +# AC_FUNC_SNPRINTF +# AC_FUNC_SCANF_CAN_MALLOC + +AC_CONFIG_FILES([Makefile]) +AC_OUTPUT +# AC_OUTPUT([Makefile],[chmod a+x test-mount.sh test.sh]) diff --git a/Quantum Controller/SW/testapplication-0.0.1/configure.lineno b/Quantum Controller/SW/testapplication-0.0.1/configure.lineno new file mode 100644 index 0000000..bb4255c --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/configure.lineno @@ -0,0 +1,6168 @@ +#! /bin/sh +# Guess values for system-dependent variables and create Makefiles. +# Generated by GNU Autoconf 2.61 for creGpioDae 0.0.1. +# +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, +# 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. +## --------------------- ## +## M4sh Initialization. ## +## --------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + + + +# PATH needs CR +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + +# Support unset when possible. +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +as_nl=' +' +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +case $0 in + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + { (exit 1); exit 1; } +fi + +# Work around bugs in pre-3.0 UWIN ksh. +for as_var in ENV MAIL MAILPATH +do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +for as_var in \ + LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ + LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ + LC_TELEPHONE LC_TIME +do + if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then + eval $as_var=C; export $as_var + else + ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var + fi +done + +# Required to use basename. +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + + +# Name of the executable. +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# CDPATH. +$as_unset CDPATH + + +if test "x$CONFIG_SHELL" = x; then + if (eval ":") 2>/dev/null; then + as_have_required=yes +else + as_have_required=no +fi + + if test $as_have_required = yes && (eval ": +(as_func_return () { + (exit \$1) +} +as_func_success () { + as_func_return 0 +} +as_func_failure () { + as_func_return 1 +} +as_func_ret_success () { + return 0 +} +as_func_ret_failure () { + return 1 +} + +exitcode=0 +if as_func_success; then + : +else + exitcode=1 + echo as_func_success failed. +fi + +if as_func_failure; then + exitcode=1 + echo as_func_failure succeeded. +fi + +if as_func_ret_success; then + : +else + exitcode=1 + echo as_func_ret_success failed. +fi + +if as_func_ret_failure; then + exitcode=1 + echo as_func_ret_failure succeeded. +fi + +if ( set x; as_func_ret_success y && test x = \"\$1\" ); then + : +else + exitcode=1 + echo positional parameters were not saved. +fi + +test \$exitcode = 0) || { (exit 1); exit 1; } + +( + as_lineno_1=\213 + as_lineno_2=\214 + test \"x\$as_lineno_1\" != \"x\$as_lineno_2\" && + test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; } +") 2> /dev/null; then + : +else + as_candidate_shells= + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + case $as_dir in + /*) + for as_base in sh bash ksh sh5; do + as_candidate_shells="$as_candidate_shells $as_dir/$as_base" + done;; + esac +done +IFS=$as_save_IFS + + + for as_shell in $as_candidate_shells $SHELL; do + # Try only shells that exist, to save several forks. + if { test -f "$as_shell" || test -f "$as_shell.exe"; } && + { ("$as_shell") 2> /dev/null <<\_ASEOF +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + +: +_ASEOF +}; then + CONFIG_SHELL=$as_shell + as_have_required=yes + if { "$as_shell" 2> /dev/null <<\_ASEOF +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + +: +(as_func_return () { + (exit $1) +} +as_func_success () { + as_func_return 0 +} +as_func_failure () { + as_func_return 1 +} +as_func_ret_success () { + return 0 +} +as_func_ret_failure () { + return 1 +} + +exitcode=0 +if as_func_success; then + : +else + exitcode=1 + echo as_func_success failed. +fi + +if as_func_failure; then + exitcode=1 + echo as_func_failure succeeded. +fi + +if as_func_ret_success; then + : +else + exitcode=1 + echo as_func_ret_success failed. +fi + +if as_func_ret_failure; then + exitcode=1 + echo as_func_ret_failure succeeded. +fi + +if ( set x; as_func_ret_success y && test x = "$1" ); then + : +else + exitcode=1 + echo positional parameters were not saved. +fi + +test $exitcode = 0) || { (exit 1); exit 1; } + +( + as_lineno_1=328 + as_lineno_2=329 + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2") || { (exit 1); exit 1; } + +_ASEOF +}; then + break +fi + +fi + + done + + if test "x$CONFIG_SHELL" != x; then + for as_var in BASH_ENV ENV + do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var + done + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} +fi + + + if test $as_have_required = no; then + echo This script requires a shell more modern than all the + echo shells that I found on your system. Please install a + echo modern shell, or manually run the script under such a + echo shell if you do have one. + { (exit 1); exit 1; } +fi + + +fi + +fi + + + +(eval "as_func_return () { + (exit \$1) +} +as_func_success () { + as_func_return 0 +} +as_func_failure () { + as_func_return 1 +} +as_func_ret_success () { + return 0 +} +as_func_ret_failure () { + return 1 +} + +exitcode=0 +if as_func_success; then + : +else + exitcode=1 + echo as_func_success failed. +fi + +if as_func_failure; then + exitcode=1 + echo as_func_failure succeeded. +fi + +if as_func_ret_success; then + : +else + exitcode=1 + echo as_func_ret_success failed. +fi + +if as_func_ret_failure; then + exitcode=1 + echo as_func_ret_failure succeeded. +fi + +if ( set x; as_func_ret_success y && test x = \"\$1\" ); then + : +else + exitcode=1 + echo positional parameters were not saved. +fi + +test \$exitcode = 0") || { + echo No shell found that supports shell functions. + echo Please tell autoconf@gnu.org about your system, + echo including any error possibly output before this + echo message +} + + + + as_lineno_1=423 + as_lineno_2=424 + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { + + # Create $as_me.lineno as a copy of $as_myself, but with 428 + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line after each line using 430; the second 'sed' + # does the real work. The second script uses 'N' to pair each + # line-number line with the line containing 432, and appends + # trailing '-' during substitution so that 433 is not a special + # case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # scripts with optimization help from Paolo Bonzini. Blame Lee + # E. McMahon (1931-1989) for sed's syntax. :-) + sed -n ' + p + /[$]LINENO/= + ' <$as_myself | + sed ' + s/[$]LINENO.*/&-/ + t lineno + b + :lineno + N + :loop + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ + t loop + s/-\n.*// + ' >$as_me.lineno && + chmod +x "$as_me.lineno" || + { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 + { (exit 1); exit 1; }; } + + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensitive to this). + . "./$as_me.lineno" + # Exit status is that of the last command. + exit +} + + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in +-n*) + case `echo 'x\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + *) ECHO_C='\c';; + esac;; +*) + ECHO_N='-n';; +esac + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir +fi +echo >conf$$.file +if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -p' +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + +if mkdir -p . 2>/dev/null; then + as_mkdir_p=: +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + + +exec 7<&0 &1 + +# Name of the host. +# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, +# so uname gets run too. +ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` + +# +# Initializations. +# +ac_default_prefix=/usr/local +ac_clean_files= +ac_config_libobj_dir=. +LIBOBJS= +cross_compiling=no +subdirs= +MFLAGS= +MAKEFLAGS= +SHELL=${CONFIG_SHELL-/bin/sh} + +# Identity of this package. +PACKAGE_NAME='creGpioDae' +PACKAGE_TARNAME='cregpiodae' +PACKAGE_VERSION='0.0.1' +PACKAGE_STRING='creGpioDae 0.0.1' +PACKAGE_BUGREPORT='' + +# Factoring default headers for most tests. +ac_includes_default="\ +#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif +#ifdef HAVE_SYS_STAT_H +# include +#endif +#ifdef STDC_HEADERS +# include +# include +#else +# ifdef HAVE_STDLIB_H +# include +# endif +#endif +#ifdef HAVE_STRING_H +# if !defined STDC_HEADERS && defined HAVE_MEMORY_H +# include +# endif +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif +#ifdef HAVE_INTTYPES_H +# include +#endif +#ifdef HAVE_STDINT_H +# include +#endif +#ifdef HAVE_UNISTD_H +# include +#endif" + +ac_subst_vars='SHELL +PATH_SEPARATOR +PACKAGE_NAME +PACKAGE_TARNAME +PACKAGE_VERSION +PACKAGE_STRING +PACKAGE_BUGREPORT +exec_prefix +prefix +program_transform_name +bindir +sbindir +libexecdir +datarootdir +datadir +sysconfdir +sharedstatedir +localstatedir +includedir +oldincludedir +docdir +infodir +htmldir +dvidir +pdfdir +psdir +libdir +localedir +mandir +DEFS +ECHO_C +ECHO_N +ECHO_T +LIBS +build_alias +host_alias +target_alias +INSTALL_PROGRAM +INSTALL_SCRIPT +INSTALL_DATA +am__isrc +CYGPATH_W +PACKAGE +VERSION +ACLOCAL +AUTOCONF +AUTOMAKE +AUTOHEADER +MAKEINFO +install_sh +STRIP +INSTALL_STRIP_PROGRAM +mkdir_p +AWK +SET_MAKE +am__leading_dot +AMTAR +am__tar +am__untar +CC +CFLAGS +LDFLAGS +CPPFLAGS +ac_ct_CC +EXEEXT +OBJEXT +DEPDIR +am__include +am__quote +AMDEP_TRUE +AMDEP_FALSE +AMDEPBACKSLASH +CCDEPMODE +am__fastdepCC_TRUE +am__fastdepCC_FALSE +CPP +GREP +EGREP +LIBOBJS +LTLIBOBJS' +ac_subst_files='' + ac_precious_vars='build_alias +host_alias +target_alias +CC +CFLAGS +LDFLAGS +LIBS +CPPFLAGS +CPP' + + +# Initialize some variables set by options. +ac_init_help= +ac_init_version=false +# The variables have the same names as the options, with +# dashes changed to underlines. +cache_file=/dev/null +exec_prefix=NONE +no_create= +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +verbose= +x_includes=NONE +x_libraries=NONE + +# Installation directory options. +# These are left unexpanded so users can "make install exec_prefix=/foo" +# and all the variables that are supposed to be based on exec_prefix +# by default will actually change. +# Use braces instead of parens because sh, perl, etc. also accept them. +# (The list follows the same order as the GNU Coding Standards.) +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datarootdir='${prefix}/share' +datadir='${datarootdir}' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +includedir='${prefix}/include' +oldincludedir='/usr/include' +docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' +infodir='${datarootdir}/info' +htmldir='${docdir}' +dvidir='${docdir}' +pdfdir='${docdir}' +psdir='${docdir}' +libdir='${exec_prefix}/lib' +localedir='${datarootdir}/locale' +mandir='${datarootdir}/man' + +ac_prev= +ac_dashdash= +for ac_option +do + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval $ac_prev=\$ac_option + ac_prev= + continue + fi + + case $ac_option in + *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; + *) ac_optarg=yes ;; + esac + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case $ac_dashdash$ac_option in + --) + ac_dashdash=yes ;; + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir=$ac_optarg ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build_alias ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build_alias=$ac_optarg ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file=$ac_optarg ;; + + --config-cache | -C) + cache_file=config.cache ;; + + -datadir | --datadir | --datadi | --datad) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=*) + datadir=$ac_optarg ;; + + -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ + | --dataroo | --dataro | --datar) + ac_prev=datarootdir ;; + -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ + | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) + datarootdir=$ac_optarg ;; + + -disable-* | --disable-*) + ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'` + eval enable_$ac_feature=no ;; + + -docdir | --docdir | --docdi | --doc | --do) + ac_prev=docdir ;; + -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) + docdir=$ac_optarg ;; + + -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) + ac_prev=dvidir ;; + -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) + dvidir=$ac_optarg ;; + + -enable-* | --enable-*) + ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'` + eval enable_$ac_feature=\$ac_optarg ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix=$ac_optarg ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he | -h) + ac_init_help=long ;; + -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) + ac_init_help=recursive ;; + -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) + ac_init_help=short ;; + + -host | --host | --hos | --ho) + ac_prev=host_alias ;; + -host=* | --host=* | --hos=* | --ho=*) + host_alias=$ac_optarg ;; + + -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) + ac_prev=htmldir ;; + -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ + | --ht=*) + htmldir=$ac_optarg ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir=$ac_optarg ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir=$ac_optarg ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir=$ac_optarg ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir=$ac_optarg ;; + + -localedir | --localedir | --localedi | --localed | --locale) + ac_prev=localedir ;; + -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) + localedir=$ac_optarg ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst | --locals) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) + localstatedir=$ac_optarg ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir=$ac_optarg ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c | -n) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir=$ac_optarg ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix=$ac_optarg ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix=$ac_optarg ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix=$ac_optarg ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name=$ac_optarg ;; + + -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) + ac_prev=pdfdir ;; + -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) + pdfdir=$ac_optarg ;; + + -psdir | --psdir | --psdi | --psd | --ps) + ac_prev=psdir ;; + -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) + psdir=$ac_optarg ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir=$ac_optarg ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir=$ac_optarg ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site=$ac_optarg ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir=$ac_optarg ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir=$ac_optarg ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target_alias ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target_alias=$ac_optarg ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers | -V) + ac_init_version=: ;; + + -with-* | --with-*) + ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } + ac_package=`echo $ac_package | sed 's/[-.]/_/g'` + eval with_$ac_package=\$ac_optarg ;; + + -without-* | --without-*) + ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } + ac_package=`echo $ac_package | sed 's/[-.]/_/g'` + eval with_$ac_package=no ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes=$ac_optarg ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries=$ac_optarg ;; + + -*) { echo "$as_me: error: unrecognized option: $ac_option +Try \`$0 --help' for more information." >&2 + { (exit 1); exit 1; }; } + ;; + + *=*) + ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` + # Reject names that are not valid shell variable names. + expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 + { (exit 1); exit 1; }; } + eval $ac_envvar=\$ac_optarg + export $ac_envvar ;; + + *) + # FIXME: should be removed in autoconf 3.0. + echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && + echo "$as_me: WARNING: invalid host type: $ac_option" >&2 + : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} + ;; + + esac +done + +if test -n "$ac_prev"; then + ac_option=--`echo $ac_prev | sed 's/_/-/g'` + { echo "$as_me: error: missing argument to $ac_option" >&2 + { (exit 1); exit 1; }; } +fi + +# Be sure to have absolute directory names. +for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ + datadir sysconfdir sharedstatedir localstatedir includedir \ + oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ + libdir localedir mandir +do + eval ac_val=\$$ac_var + case $ac_val in + [\\/$]* | ?:[\\/]* ) continue;; + NONE | '' ) case $ac_var in *prefix ) continue;; esac;; + esac + { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; } +done + +# There might be people who depend on the old broken behavior: `$host' +# used to hold the argument of --host etc. +# FIXME: To remove some day. +build=$build_alias +host=$host_alias +target=$target_alias + +# FIXME: To remove some day. +if test "x$host_alias" != x; then + if test "x$build_alias" = x; then + cross_compiling=maybe + echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. + If a cross compiler is detected then cross compile mode will be used." >&2 + elif test "x$build_alias" != "x$host_alias"; then + cross_compiling=yes + fi +fi + +ac_tool_prefix= +test -n "$host_alias" && ac_tool_prefix=$host_alias- + +test "$silent" = yes && exec 6>/dev/null + + +ac_pwd=`pwd` && test -n "$ac_pwd" && +ac_ls_di=`ls -di .` && +ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || + { echo "$as_me: error: Working directory cannot be determined" >&2 + { (exit 1); exit 1; }; } +test "X$ac_ls_di" = "X$ac_pwd_ls_di" || + { echo "$as_me: error: pwd does not report name of working directory" >&2 + { (exit 1); exit 1; }; } + + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then the parent directory. + ac_confdir=`$as_dirname -- "$0" || +$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$0" : 'X\(//\)[^/]' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +echo X"$0" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + srcdir=$ac_confdir + if test ! -r "$srcdir/$ac_unique_file"; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r "$srcdir/$ac_unique_file"; then + test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." + { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 + { (exit 1); exit 1; }; } +fi +ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" +ac_abs_confdir=`( + cd "$srcdir" && test -r "./$ac_unique_file" || { echo "$as_me: error: $ac_msg" >&2 + { (exit 1); exit 1; }; } + pwd)` +# When building in place, set srcdir=. +if test "$ac_abs_confdir" = "$ac_pwd"; then + srcdir=. +fi +# Remove unnecessary trailing slashes from srcdir. +# Double slashes in file names in object file debugging info +# mess up M-x gdb in Emacs. +case $srcdir in +*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; +esac +for ac_var in $ac_precious_vars; do + eval ac_env_${ac_var}_set=\${${ac_var}+set} + eval ac_env_${ac_var}_value=\$${ac_var} + eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} + eval ac_cv_env_${ac_var}_value=\$${ac_var} +done + +# +# Report the --help message. +# +if test "$ac_init_help" = "long"; then + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat <<_ACEOF +\`configure' configures creGpioDae 0.0.1 to adapt to many kinds of systems. + +Usage: $0 [OPTION]... [VAR=VALUE]... + +To assign environment variables (e.g., CC, CFLAGS...), specify them as +VAR=VALUE. See below for descriptions of some of the useful variables. + +Defaults for the options are specified in brackets. + +Configuration: + -h, --help display this help and exit + --help=short display options specific to this package + --help=recursive display the short help of all the included packages + -V, --version display version information and exit + -q, --quiet, --silent do not print \`checking...' messages + --cache-file=FILE cache test results in FILE [disabled] + -C, --config-cache alias for \`--cache-file=config.cache' + -n, --no-create do not create output files + --srcdir=DIR find the sources in DIR [configure dir or \`..'] + +Installation directories: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [PREFIX] + +By default, \`make install' will install all the files in +\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify +an installation prefix other than \`$ac_default_prefix' using \`--prefix', +for instance \`--prefix=\$HOME'. + +For better control, use the options below. + +Fine tuning of the installation directories: + --bindir=DIR user executables [EPREFIX/bin] + --sbindir=DIR system admin executables [EPREFIX/sbin] + --libexecdir=DIR program executables [EPREFIX/libexec] + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] + --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] + --datadir=DIR read-only architecture-independent data [DATAROOTDIR] + --infodir=DIR info documentation [DATAROOTDIR/info] + --localedir=DIR locale-dependent data [DATAROOTDIR/locale] + --mandir=DIR man documentation [DATAROOTDIR/man] + --docdir=DIR documentation root [DATAROOTDIR/doc/cregpiodae] + --htmldir=DIR html documentation [DOCDIR] + --dvidir=DIR dvi documentation [DOCDIR] + --pdfdir=DIR pdf documentation [DOCDIR] + --psdir=DIR ps documentation [DOCDIR] +_ACEOF + + cat <<\_ACEOF + +Program names: + --program-prefix=PREFIX prepend PREFIX to installed program names + --program-suffix=SUFFIX append SUFFIX to installed program names + --program-transform-name=PROGRAM run sed PROGRAM on installed program names +_ACEOF +fi + +if test -n "$ac_init_help"; then + case $ac_init_help in + short | recursive ) echo "Configuration of creGpioDae 0.0.1:";; + esac + cat <<\_ACEOF + +Optional Features: + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --disable-dependency-tracking speeds up one-time build + --enable-dependency-tracking do not reject slow dependency extractors + +Some influential environment variables: + CC C compiler command + CFLAGS C compiler flags + LDFLAGS linker flags, e.g. -L if you have libraries in a + nonstandard directory + LIBS libraries to pass to the linker, e.g. -l + CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I if + you have headers in a nonstandard directory + CPP C preprocessor + +Use these variables to override the choices made by `configure' or to help +it to find libraries and programs with nonstandard names/locations. + +_ACEOF +ac_status=$? +fi + +if test "$ac_init_help" = "recursive"; then + # If there are subdirs, report their specific --help. + for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue + test -d "$ac_dir" || continue + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + cd "$ac_dir" || { ac_status=$?; continue; } + # Check for guested configure. + if test -f "$ac_srcdir/configure.gnu"; then + echo && + $SHELL "$ac_srcdir/configure.gnu" --help=recursive + elif test -f "$ac_srcdir/configure"; then + echo && + $SHELL "$ac_srcdir/configure" --help=recursive + else + echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + fi || ac_status=$? + cd "$ac_pwd" || { ac_status=$?; break; } + done +fi + +test -n "$ac_init_help" && exit $ac_status +if $ac_init_version; then + cat <<\_ACEOF +creGpioDae configure 0.0.1 +generated by GNU Autoconf 2.61 + +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, +2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +This configure script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it. +_ACEOF + exit +fi +cat >config.log <<_ACEOF +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. + +It was created by creGpioDae $as_me 0.0.1, which was +generated by GNU Autoconf 2.61. Invocation command line was + + $ $0 $@ + +_ACEOF +exec 5>>config.log +{ +cat <<_ASUNAME +## --------- ## +## Platform. ## +## --------- ## + +hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` + +/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` +/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` +/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` +/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` + +_ASUNAME + +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + echo "PATH: $as_dir" +done +IFS=$as_save_IFS + +} >&5 + +cat >&5 <<_ACEOF + + +## ----------- ## +## Core tests. ## +## ----------- ## + +_ACEOF + + +# Keep a trace of the command line. +# Strip out --no-create and --no-recursion so they do not pile up. +# Strip out --silent because we don't want to record it for future runs. +# Also quote any args containing shell meta-characters. +# Make two passes to allow for proper duplicate-argument suppression. +ac_configure_args= +ac_configure_args0= +ac_configure_args1= +ac_must_keep_next=false +for ac_pass in 1 2 +do + for ac_arg + do + case $ac_arg in + -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + continue ;; + *\'*) + ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + case $ac_pass in + 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; + 2) + ac_configure_args1="$ac_configure_args1 '$ac_arg'" + if test $ac_must_keep_next = true; then + ac_must_keep_next=false # Got value, back to normal. + else + case $ac_arg in + *=* | --config-cache | -C | -disable-* | --disable-* \ + | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ + | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ + | -with-* | --with-* | -without-* | --without-* | --x) + case "$ac_configure_args0 " in + "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; + esac + ;; + -* ) ac_must_keep_next=true ;; + esac + fi + ac_configure_args="$ac_configure_args '$ac_arg'" + ;; + esac + done +done +$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; } +$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; } + +# When interrupted or exit'd, cleanup temporary files, and complete +# config.log. We remove comments because anyway the quotes in there +# would cause problems or look ugly. +# WARNING: Use '\'' to represent an apostrophe within the trap. +# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. +trap 'exit_status=$? + # Save into config.log some information that might help in debugging. + { + echo + + cat <<\_ASBOX +## ---------------- ## +## Cache variables. ## +## ---------------- ## +_ASBOX + echo + # The following way of writing the cache mishandles newlines in values, +( + for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { echo "$as_me:1494: WARNING: Cache variable $ac_var contains a newline." >&5 +echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + *) $as_unset $ac_var ;; + esac ;; + esac + done + (set) 2>&1 | + case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + sed -n \ + "s/'\''/'\''\\\\'\'''\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" + ;; #( + *) + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) + echo + + cat <<\_ASBOX +## ----------------- ## +## Output variables. ## +## ----------------- ## +_ASBOX + echo + for ac_var in $ac_subst_vars + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + echo "$ac_var='\''$ac_val'\''" + done | sort + echo + + if test -n "$ac_subst_files"; then + cat <<\_ASBOX +## ------------------- ## +## File substitutions. ## +## ------------------- ## +_ASBOX + echo + for ac_var in $ac_subst_files + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + echo "$ac_var='\''$ac_val'\''" + done | sort + echo + fi + + if test -s confdefs.h; then + cat <<\_ASBOX +## ----------- ## +## confdefs.h. ## +## ----------- ## +_ASBOX + echo + cat confdefs.h + echo + fi + test "$ac_signal" != 0 && + echo "$as_me: caught signal $ac_signal" + echo "$as_me: exit $exit_status" + } >&5 + rm -f core *.core core.conftest.* && + rm -f -r conftest* confdefs* conf$$* $ac_clean_files && + exit $exit_status +' 0 +for ac_signal in 1 2 13 15; do + trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal +done +ac_signal=0 + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -f -r conftest* confdefs.h + +# Predefined preprocessor variables. + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_NAME "$PACKAGE_NAME" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_TARNAME "$PACKAGE_TARNAME" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_VERSION "$PACKAGE_VERSION" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_STRING "$PACKAGE_STRING" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" +_ACEOF + + +# Let the site file select an alternate cache file if it wants to. +# Prefer explicitly selected file to automatically selected ones. +if test -n "$CONFIG_SITE"; then + set x "$CONFIG_SITE" +elif test "x$prefix" != xNONE; then + set x "$prefix/share/config.site" "$prefix/etc/config.site" +else + set x "$ac_default_prefix/share/config.site" \ + "$ac_default_prefix/etc/config.site" +fi +shift +for ac_site_file +do + if test -r "$ac_site_file"; then + { echo "$as_me:1619: loading site script $ac_site_file" >&5 +echo "$as_me: loading site script $ac_site_file" >&6;} + sed 's/^/| /' "$ac_site_file" >&5 + . "$ac_site_file" + fi +done + +if test -r "$cache_file"; then + # Some versions of bash will fail to source /dev/null (special + # files actually), so we avoid doing that. + if test -f "$cache_file"; then + { echo "$as_me:1630: loading cache $cache_file" >&5 +echo "$as_me: loading cache $cache_file" >&6;} + case $cache_file in + [\\/]* | ?:[\\/]* ) . "$cache_file";; + *) . "./$cache_file";; + esac + fi +else + { echo "$as_me:1638: creating cache $cache_file" >&5 +echo "$as_me: creating cache $cache_file" >&6;} + >$cache_file +fi + +# Check that the precious variables saved in the cache have kept the same +# value. +ac_cache_corrupted=false +for ac_var in $ac_precious_vars; do + eval ac_old_set=\$ac_cv_env_${ac_var}_set + eval ac_new_set=\$ac_env_${ac_var}_set + eval ac_old_val=\$ac_cv_env_${ac_var}_value + eval ac_new_val=\$ac_env_${ac_var}_value + case $ac_old_set,$ac_new_set in + set,) + { echo "$as_me:1653: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,set) + { echo "$as_me:1657: error: \`$ac_var' was not set in the previous run" >&5 +echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,);; + *) + if test "x$ac_old_val" != "x$ac_new_val"; then + { echo "$as_me:1663: error: \`$ac_var' has changed since the previous run:" >&5 +echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + { echo "$as_me:1665: former value: $ac_old_val" >&5 +echo "$as_me: former value: $ac_old_val" >&2;} + { echo "$as_me:1667: current value: $ac_new_val" >&5 +echo "$as_me: current value: $ac_new_val" >&2;} + ac_cache_corrupted=: + fi;; + esac + # Pass precious variables to config.status. + if test "$ac_new_set" = set; then + case $ac_new_val in + *\'*) ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *) ac_arg=$ac_var=$ac_new_val ;; + esac + case " $ac_configure_args " in + *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. + *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; + esac + fi +done +if $ac_cache_corrupted; then + { echo "$as_me:1685: error: changes in the environment can compromise the build" >&5 +echo "$as_me: error: changes in the environment can compromise the build" >&2;} + { { echo "$as_me:1687: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 +echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} + { (exit 1); exit 1; }; } +fi + + + + + + + + + + + + + + + + + + + + + + + + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + +# builtin(include, [m4/ac_func_snprintf.m4])dnl +# builtin(include, [m4/ac_func_scanf_can_malloc.m4])dnl + +am__api_version='1.10' + +ac_aux_dir= +for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do + if test -f "$ac_dir/install-sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f "$ac_dir/install.sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + elif test -f "$ac_dir/shtool"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/shtool install -c" + break + fi +done +if test -z "$ac_aux_dir"; then + { { echo "$as_me:1746: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&5 +echo "$as_me: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&2;} + { (exit 1); exit 1; }; } +fi + +# These three variables are undocumented and unsupported, +# and are intended to be withdrawn in a future Autoconf release. +# They can cause serious problems if a builder's source tree is in a directory +# whose full name contains unusual characters. +ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. +ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. +ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. + + +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AmigaOS /C/install, which installs bootblocks on floppy discs +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# OS/2's system install, which has a completely different semantic +# ./install, which can be erroneously created by make from ./install.sh. +{ echo "$as_me:1773: checking for a BSD-compatible install" >&5 +echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6; } +if test -z "$INSTALL"; then +if test "${ac_cv_path_install+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + # Account for people who put trailing slashes in PATH elements. +case $as_dir/ in + ./ | .// | /cC/* | \ + /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ + ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \ + /usr/ucb/* ) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then + if test $ac_prog = install && + grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + elif test $ac_prog = install && + grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : + else + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" + break 3 + fi + fi + done + done + ;; +esac +done +IFS=$as_save_IFS + + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL=$ac_cv_path_install + else + # As a last resort, use the slow shell script. Don't cache a + # value for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the value is a relative name. + INSTALL=$ac_install_sh + fi +fi +{ echo "$as_me:1829: result: $INSTALL" >&5 +echo "${ECHO_T}$INSTALL" >&6; } + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + +{ echo "$as_me:1840: checking whether build environment is sane" >&5 +echo $ECHO_N "checking whether build environment is sane... $ECHO_C" >&6; } +# Just in case +sleep 1 +echo timestamp > conftest.file +# Do `set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null` + if test "$*" = "X"; then + # -L didn't work. + set X `ls -t $srcdir/configure conftest.file` + fi + rm -f conftest.file + if test "$*" != "X $srcdir/configure conftest.file" \ + && test "$*" != "X conftest.file $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + { { echo "$as_me:1864: error: ls -t appears to fail. Make sure there is not a broken +alias in your environment" >&5 +echo "$as_me: error: ls -t appears to fail. Make sure there is not a broken +alias in your environment" >&2;} + { (exit 1); exit 1; }; } + fi + + test "$2" = conftest.file + ) +then + # Ok. + : +else + { { echo "$as_me:1877: error: newly created file is older than distributed files! +Check your system clock" >&5 +echo "$as_me: error: newly created file is older than distributed files! +Check your system clock" >&2;} + { (exit 1); exit 1; }; } +fi +{ echo "$as_me:1883: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } +test "$program_prefix" != NONE && + program_transform_name="s&^&$program_prefix&;$program_transform_name" +# Use a double $ so make ignores it. +test "$program_suffix" != NONE && + program_transform_name="s&\$&$program_suffix&;$program_transform_name" +# Double any \ or $. echo might interpret backslashes. +# By default was `s,x,x', remove it if useless. +cat <<\_ACEOF >conftest.sed +s/[\\$]/&&/g;s/;s,x,x,$// +_ACEOF +program_transform_name=`echo $program_transform_name | sed -f conftest.sed` +rm -f conftest.sed + +# expand $ac_aux_dir to an absolute path +am_aux_dir=`cd $ac_aux_dir && pwd` + +test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing" +# Use eval to expand $SHELL +if eval "$MISSING --run true"; then + am_missing_run="$MISSING --run " +else + am_missing_run= + { echo "$as_me:1907: WARNING: \`missing' script is too old or missing" >&5 +echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} +fi + +{ echo "$as_me:1911: checking for a thread-safe mkdir -p" >&5 +echo $ECHO_N "checking for a thread-safe mkdir -p... $ECHO_C" >&6; } +if test -z "$MKDIR_P"; then + if test "${ac_cv_path_mkdir+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in mkdir gmkdir; do + for ac_exec_ext in '' $ac_executable_extensions; do + { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue + case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( + 'mkdir (GNU coreutils) '* | \ + 'mkdir (coreutils) '* | \ + 'mkdir (fileutils) '4.1*) + ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext + break 3;; + esac + done + done +done +IFS=$as_save_IFS + +fi + + if test "${ac_cv_path_mkdir+set}" = set; then + MKDIR_P="$ac_cv_path_mkdir -p" + else + # As a last resort, use the slow shell script. Don't cache a + # value for MKDIR_P within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the value is a relative name. + test -d ./--version && rmdir ./--version + MKDIR_P="$ac_install_sh -d" + fi +fi +{ echo "$as_me:1950: result: $MKDIR_P" >&5 +echo "${ECHO_T}$MKDIR_P" >&6; } + +mkdir_p="$MKDIR_P" +case $mkdir_p in + [\\/$]* | ?:[\\/]*) ;; + */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; +esac + +for ac_prog in gawk mawk nawk awk +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ echo "$as_me:1963: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_AWK+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$AWK"; then + ac_cv_prog_AWK="$AWK" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_AWK="$ac_prog" + echo "$as_me:1979: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +AWK=$ac_cv_prog_AWK +if test -n "$AWK"; then + { echo "$as_me:1990: result: $AWK" >&5 +echo "${ECHO_T}$AWK" >&6; } +else + { echo "$as_me:1993: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + + test -n "$AWK" && break +done + +{ echo "$as_me:2001: checking whether ${MAKE-make} sets \$(MAKE)" >&5 +echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6; } +set x ${MAKE-make}; ac_make=`echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` +if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.make <<\_ACEOF +SHELL = /bin/sh +all: + @echo '@@@%%%=$(MAKE)=@@@%%%' +_ACEOF +# GNU make sometimes prints "make[1]: Entering...", which would confuse us. +case `${MAKE-make} -f conftest.make 2>/dev/null` in + *@@@%%%=?*=@@@%%%*) + eval ac_cv_prog_make_${ac_make}_set=yes;; + *) + eval ac_cv_prog_make_${ac_make}_set=no;; +esac +rm -f conftest.make +fi +if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then + { echo "$as_me:2022: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } + SET_MAKE= +else + { echo "$as_me:2026: result: no" >&5 +echo "${ECHO_T}no" >&6; } + SET_MAKE="MAKE=${MAKE-make}" +fi + +rm -rf .tst 2>/dev/null +mkdir .tst 2>/dev/null +if test -d .tst; then + am__leading_dot=. +else + am__leading_dot=_ +fi +rmdir .tst 2>/dev/null + +if test "`cd $srcdir && pwd`" != "`pwd`"; then + # Use -I$(srcdir) only when $(srcdir) != ., so that make's output + # is not polluted with repeated "-I." + am__isrc=' -I$(srcdir)' + # test to see if srcdir already configured + if test -f $srcdir/config.status; then + { { echo "$as_me:2046: error: source directory already configured; run \"make distclean\" there first" >&5 +echo "$as_me: error: source directory already configured; run \"make distclean\" there first" >&2;} + { (exit 1); exit 1; }; } + fi +fi + +# test whether we have cygpath +if test -z "$CYGPATH_W"; then + if (cygpath --version) >/dev/null 2>/dev/null; then + CYGPATH_W='cygpath -w' + else + CYGPATH_W=echo + fi +fi + + +# Define the identity of the package. + PACKAGE='cregpiodae' + VERSION='0.0.1' + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE "$PACKAGE" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define VERSION "$VERSION" +_ACEOF + +# Some tools Automake needs. + +ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} + + +AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} + + +AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} + + +AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} + + +MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} + +install_sh=${install_sh-"\$(SHELL) $am_aux_dir/install-sh"} + +# Installed binaries are usually stripped using `strip' when the user +# run `make install-strip'. However `strip' might not be the right +# tool to use in cross-compilation environments, therefore Automake +# will honor the `STRIP' environment variable to overrule this program. +if test "$cross_compiling" != no; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. +set dummy ${ac_tool_prefix}strip; ac_word=$2 +{ echo "$as_me:2102: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_STRIP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$STRIP"; then + ac_cv_prog_STRIP="$STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_STRIP="${ac_tool_prefix}strip" + echo "$as_me:2118: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +STRIP=$ac_cv_prog_STRIP +if test -n "$STRIP"; then + { echo "$as_me:2129: result: $STRIP" >&5 +echo "${ECHO_T}$STRIP" >&6; } +else + { echo "$as_me:2132: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_STRIP"; then + ac_ct_STRIP=$STRIP + # Extract the first word of "strip", so it can be a program name with args. +set dummy strip; ac_word=$2 +{ echo "$as_me:2142: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_STRIP"; then + ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_STRIP="strip" + echo "$as_me:2158: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP +if test -n "$ac_ct_STRIP"; then + { echo "$as_me:2169: result: $ac_ct_STRIP" >&5 +echo "${ECHO_T}$ac_ct_STRIP" >&6; } +else + { echo "$as_me:2172: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + if test "x$ac_ct_STRIP" = x; then + STRIP=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ echo "$as_me:2181: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&5 +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&2;} +ac_tool_warned=yes ;; +esac + STRIP=$ac_ct_STRIP + fi +else + STRIP="$ac_cv_prog_STRIP" +fi + +fi +INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" + +# We need awk for the "check" target. The system "awk" is bad on +# some platforms. +# Always define AMTAR for backward compatibility. + +AMTAR=${AMTAR-"${am_missing_run}tar"} + +am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -' + + + + + +# AC_CONFIG_HEADER([config.h]) + + +cat >>confdefs.h <<\_ACEOF +#define _GNU_SOURCE 1 +_ACEOF + + + +# Checks for programs. +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +{ echo "$as_me:2228: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + echo "$as_me:2244: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { echo "$as_me:2255: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } +else + { echo "$as_me:2258: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +{ echo "$as_me:2268: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_CC="gcc" + echo "$as_me:2284: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { echo "$as_me:2295: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6; } +else + { echo "$as_me:2298: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ echo "$as_me:2307: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&5 +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +else + CC="$ac_cv_prog_CC" +fi + +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 +{ echo "$as_me:2325: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + echo "$as_me:2341: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { echo "$as_me:2352: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } +else + { echo "$as_me:2355: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + + fi +fi +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +{ echo "$as_me:2365: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_prog_rejected=no +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + echo "$as_me:2386: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# != 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" + fi +fi +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { echo "$as_me:2409: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } +else + { echo "$as_me:2412: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl.exe + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ echo "$as_me:2424: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + echo "$as_me:2440: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { echo "$as_me:2451: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } +else + { echo "$as_me:2454: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl.exe +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ echo "$as_me:2468: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_CC="$ac_prog" + echo "$as_me:2484: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { echo "$as_me:2495: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6; } +else + { echo "$as_me:2498: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + + test -n "$ac_ct_CC" && break +done + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ echo "$as_me:2511: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&5 +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +fi + +fi + + +test -z "$CC" && { { echo "$as_me:2526: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&5 +echo "$as_me: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } + +# Provide some information about the compiler. +echo "$as_me:2533: checking for C compiler version" >&5 +ac_compiler=`set X $ac_compile; echo $2` +{ (ac_try="$ac_compiler --version >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:2540: $ac_try_echo\"") >&5 + (eval "$ac_compiler --version >&5") 2>&5 + ac_status=$? + echo "$as_me:2543: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (ac_try="$ac_compiler -v >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:2550: $ac_try_echo\"") >&5 + (eval "$ac_compiler -v >&5") 2>&5 + ac_status=$? + echo "$as_me:2553: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (ac_try="$ac_compiler -V >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:2560: $ac_try_echo\"") >&5 + (eval "$ac_compiler -V >&5") 2>&5 + ac_status=$? + echo "$as_me:2563: \$? = $ac_status" >&5 + (exit $ac_status); } + +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files a.out a.exe b.out" +# Try to create an executable without -o first, disregard a.out. +# It will help us diagnose broken compilers, and finding out an intuition +# of exeext. +{ echo "$as_me:2586: checking for C compiler default output file name" >&5 +echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6; } +ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` +# +# List of possible output files, starting from the most likely. +# The algorithm is not robust to junk in `.', hence go to wildcards (a.*) +# only as a last resort. b.out is created by i960 compilers. +ac_files='a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out' +# +# The IRIX 6 linker writes into existing files which may not be +# executable, retaining their permissions. Remove them first so a +# subsequent execution test works. +ac_rmfiles= +for ac_file in $ac_files +do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;; + * ) ac_rmfiles="$ac_rmfiles $ac_file";; + esac +done +rm -f $ac_rmfiles + +if { (ac_try="$ac_link_default" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:2613: $ac_try_echo\"") >&5 + (eval "$ac_link_default") 2>&5 + ac_status=$? + echo "$as_me:2616: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. +# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' +# in a Makefile. We should not override ac_cv_exeext if it was cached, +# so that the user can short-circuit this test for compilers unknown to +# Autoconf. +for ac_file in $ac_files '' +do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) + ;; + [ab].out ) + # We found the default executable, but exeext='' is most + # certainly right. + break;; + *.* ) + if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; + then :; else + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + fi + # We set ac_cv_exeext here because the later test for it is not + # safe: cross compilers may not add the suffix if given an `-o' + # argument, so we may need to know it at that point already. + # Even if this section looks crufty: it has the advantage of + # actually working. + break;; + * ) + break;; + esac +done +test "$ac_cv_exeext" = no && ac_cv_exeext= + +else + ac_file='' +fi + +{ echo "$as_me:2654: result: $ac_file" >&5 +echo "${ECHO_T}$ac_file" >&6; } +if test -z "$ac_file"; then + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { echo "$as_me:2660: error: C compiler cannot create executables +See \`config.log' for more details." >&5 +echo "$as_me: error: C compiler cannot create executables +See \`config.log' for more details." >&2;} + { (exit 77); exit 77; }; } +fi + +ac_exeext=$ac_cv_exeext + +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ echo "$as_me:2671: checking whether the C compiler works" >&5 +echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6; } +# FIXME: These cross compiler hacks should be removed for Autoconf 3.0 +# If not cross compiling, check that we can run a simple program. +if test "$cross_compiling" != yes; then + if { ac_try='./$ac_file' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:2681: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:2684: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { echo "$as_me:2691: error: cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } + fi + fi +fi +{ echo "$as_me:2701: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } + +rm -f a.out a.exe conftest$ac_cv_exeext b.out +ac_clean_files=$ac_clean_files_save +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ echo "$as_me:2708: checking whether we are cross compiling" >&5 +echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6; } +{ echo "$as_me:2710: result: $cross_compiling" >&5 +echo "${ECHO_T}$cross_compiling" >&6; } + +{ echo "$as_me:2713: checking for suffix of executables" >&5 +echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6; } +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:2720: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:2723: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # If both `conftest.exe' and `conftest' are `present' (well, observable) +# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will +# work properly (i.e., refer to `conftest.exe'), while it won't with +# `rm'. +for ac_file in conftest.exe conftest conftest.*; do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + break;; + * ) break;; + esac +done +else + { { echo "$as_me:2739: error: cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +rm -f conftest$ac_cv_exeext +{ echo "$as_me:2747: result: $ac_cv_exeext" >&5 +echo "${ECHO_T}$ac_cv_exeext" >&6; } + +rm -f conftest.$ac_ext +EXEEXT=$ac_cv_exeext +ac_exeext=$EXEEXT +{ echo "$as_me:2753: checking for suffix of object files" >&5 +echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6; } +if test "${ac_cv_objext+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.o conftest.obj +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:2779: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>&5 + ac_status=$? + echo "$as_me:2782: \$? = $ac_status" >&5 + (exit $ac_status); }; then + for ac_file in conftest.o conftest.obj conftest.*; do + test -f "$ac_file" || continue; + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf ) ;; + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` + break;; + esac +done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { echo "$as_me:2796: error: cannot compute suffix of object files: cannot compile +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute suffix of object files: cannot compile +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +rm -f conftest.$ac_cv_objext conftest.$ac_ext +fi +{ echo "$as_me:2805: result: $ac_cv_objext" >&5 +echo "${ECHO_T}$ac_cv_objext" >&6; } +OBJEXT=$ac_cv_objext +ac_objext=$OBJEXT +{ echo "$as_me:2809: checking whether we are using the GNU C compiler" >&5 +echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6; } +if test "${ac_cv_c_compiler_gnu+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:2838: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:2844: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_compiler_gnu=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_compiler_gnu=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +{ echo "$as_me:2861: result: $ac_cv_c_compiler_gnu" >&5 +echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6; } +GCC=`test $ac_compiler_gnu = yes && echo yes` +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +{ echo "$as_me:2866: checking whether $CC accepts -g" >&5 +echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6; } +if test "${ac_cv_prog_cc_g+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_save_c_werror_flag=$ac_c_werror_flag + ac_c_werror_flag=yes + ac_cv_prog_cc_g=no + CFLAGS="-g" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:2896: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:2902: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_prog_cc_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + CFLAGS="" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:2934: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:2940: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_c_werror_flag=$ac_save_c_werror_flag + CFLAGS="-g" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:2973: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:2979: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_prog_cc_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag=$ac_save_c_werror_flag +fi +{ echo "$as_me:3001: result: $ac_cv_prog_cc_g" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_g" >&6; } +if test "$ac_test_CFLAGS" = set; then + CFLAGS=$ac_save_CFLAGS +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi +{ echo "$as_me:3018: checking for $CC option to accept ISO C89" >&5 +echo $ECHO_N "checking for $CC option to accept ISO C89... $ECHO_C" >&6; } +if test "${ac_cv_prog_cc_c89+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_prog_cc_c89=no +ac_save_CC=$CC +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include +#include +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} + +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not '\xHH' hex character constants. + These don't provoke an error unfortunately, instead are silently treated + as 'x'. The following induces an error, until -std is added to get + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an + array size at least. It's necessary to write '\x00'==0 to get something + that's true only with -std. */ +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; + +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters + inside strings and character constants. */ +#define FOO(x) 'x' +int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; + +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:3092: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:3098: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_prog_cc_c89=$ac_arg +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext + test "x$ac_cv_prog_cc_c89" != "xno" && break +done +rm -f conftest.$ac_ext +CC=$ac_save_CC + +fi +# AC_CACHE_VAL +case "x$ac_cv_prog_cc_c89" in + x) + { echo "$as_me:3121: result: none needed" >&5 +echo "${ECHO_T}none needed" >&6; } ;; + xno) + { echo "$as_me:3124: result: unsupported" >&5 +echo "${ECHO_T}unsupported" >&6; } ;; + *) + CC="$CC $ac_cv_prog_cc_c89" + { echo "$as_me:3128: result: $ac_cv_prog_cc_c89" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_c89" >&6; } ;; +esac + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +DEPDIR="${am__leading_dot}deps" + +ac_config_commands="$ac_config_commands depfiles" + + +am_make=${MAKE-make} +cat > confinc << 'END' +am__doit: + @echo done +.PHONY: am__doit +END +# If we don't find an include directive, just comment out the code. +{ echo "$as_me:3150: checking for style of include used by $am_make" >&5 +echo $ECHO_N "checking for style of include used by $am_make... $ECHO_C" >&6; } +am__include="#" +am__quote= +_am_result=none +# First try GNU make style include. +echo "include confinc" > confmf +# We grep out `Entering directory' and `Leaving directory' +# messages which can occur if `w' ends up in MAKEFLAGS. +# In particular we don't look at `^make:' because GNU make might +# be invoked under some other name (usually "gmake"), in which +# case it prints its new name instead of `make'. +if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then + am__include=include + am__quote= + _am_result=GNU +fi +# Now try BSD make style include. +if test "$am__include" = "#"; then + echo '.include "confinc"' > confmf + if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then + am__include=.include + am__quote="\"" + _am_result=BSD + fi +fi + + +{ echo "$as_me:3178: result: $_am_result" >&5 +echo "${ECHO_T}$_am_result" >&6; } +rm -f confinc confmf + +# Check whether --enable-dependency-tracking was given. +if test "${enable_dependency_tracking+set}" = set; then + enableval=$enable_dependency_tracking; +fi + +if test "x$enable_dependency_tracking" != xno; then + am_depcomp="$ac_aux_dir/depcomp" + AMDEPBACKSLASH='\' +fi + if test "x$enable_dependency_tracking" != xno; then + AMDEP_TRUE= + AMDEP_FALSE='#' +else + AMDEP_TRUE='#' + AMDEP_FALSE= +fi + + + +depcc="$CC" am_compiler_list= + +{ echo "$as_me:3203: checking dependency style of $depcc" >&5 +echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6; } +if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_CC_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` + fi + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with + # Solaris 8's {/usr,}/bin/sh. + touch sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + case $depmode in + nosideeffect) + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + none) break ;; + esac + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. + if depmode=$depmode \ + source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_CC_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_CC_dependencies_compiler_type=none +fi + +fi +{ echo "$as_me:3294: result: $am_cv_CC_dependencies_compiler_type" >&5 +echo "${ECHO_T}$am_cv_CC_dependencies_compiler_type" >&6; } +CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type + + if + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then + am__fastdepCC_TRUE= + am__fastdepCC_FALSE='#' +else + am__fastdepCC_TRUE='#' + am__fastdepCC_FALSE= +fi + + +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AmigaOS /C/install, which installs bootblocks on floppy discs +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# OS/2's system install, which has a completely different semantic +# ./install, which can be erroneously created by make from ./install.sh. +{ echo "$as_me:3322: checking for a BSD-compatible install" >&5 +echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6; } +if test -z "$INSTALL"; then +if test "${ac_cv_path_install+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + # Account for people who put trailing slashes in PATH elements. +case $as_dir/ in + ./ | .// | /cC/* | \ + /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ + ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \ + /usr/ucb/* ) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then + if test $ac_prog = install && + grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + elif test $ac_prog = install && + grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : + else + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" + break 3 + fi + fi + done + done + ;; +esac +done +IFS=$as_save_IFS + + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL=$ac_cv_path_install + else + # As a last resort, use the slow shell script. Don't cache a + # value for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the value is a relative name. + INSTALL=$ac_install_sh + fi +fi +{ echo "$as_me:3378: result: $INSTALL" >&5 +echo "${ECHO_T}$INSTALL" >&6; } + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + + +# Checks for header files. + + + + + + +ac_header_dirent=no +for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do + as_ac_Header=`echo "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh` +{ echo "$as_me:3400: checking for $ac_hdr that defines DIR" >&5 +echo $ECHO_N "checking for $ac_hdr that defines DIR... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include <$ac_hdr> + +int +main () +{ +if ((DIR *) 0) +return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:3429: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:3435: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + eval "$as_ac_Header=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_Header=no" +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:3451: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_hdr" | $as_tr_cpp` 1 +_ACEOF + +ac_header_dirent=$ac_hdr; break +fi + +done +# Two versions of opendir et al. are in -ldir and -lx on SCO Xenix. +if test $ac_header_dirent = dirent.h; then + { echo "$as_me:3464: checking for library containing opendir" >&5 +echo $ECHO_N "checking for library containing opendir... $ECHO_C" >&6; } +if test "${ac_cv_search_opendir+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_func_search_save_LIBS=$LIBS +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char opendir (); +int +main () +{ +return opendir (); + ; + return 0; +} +_ACEOF +for ac_lib in '' dir; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:3505: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:3511: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_search_opendir=$ac_res +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext + if test "${ac_cv_search_opendir+set}" = set; then + break +fi +done +if test "${ac_cv_search_opendir+set}" = set; then + : +else + ac_cv_search_opendir=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ echo "$as_me:3539: result: $ac_cv_search_opendir" >&5 +echo "${ECHO_T}$ac_cv_search_opendir" >&6; } +ac_res=$ac_cv_search_opendir +if test "$ac_res" != no; then + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + +fi + +else + { echo "$as_me:3548: checking for library containing opendir" >&5 +echo $ECHO_N "checking for library containing opendir... $ECHO_C" >&6; } +if test "${ac_cv_search_opendir+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_func_search_save_LIBS=$LIBS +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char opendir (); +int +main () +{ +return opendir (); + ; + return 0; +} +_ACEOF +for ac_lib in '' x; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:3589: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:3595: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_search_opendir=$ac_res +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext + if test "${ac_cv_search_opendir+set}" = set; then + break +fi +done +if test "${ac_cv_search_opendir+set}" = set; then + : +else + ac_cv_search_opendir=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ echo "$as_me:3623: result: $ac_cv_search_opendir" >&5 +echo "${ECHO_T}$ac_cv_search_opendir" >&6; } +ac_res=$ac_cv_search_opendir +if test "$ac_res" != no; then + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + +fi + +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ echo "$as_me:3638: checking how to run the C preprocessor" >&5 +echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6; } +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then + if test "${ac_cv_prog_CPP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:3678: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:3684: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi + +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:3715: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:3721: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi + +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + break +fi + + done + ac_cv_prog_CPP=$CPP + +fi + CPP=$ac_cv_prog_CPP +else + ac_cv_prog_CPP=$CPP +fi +{ echo "$as_me:3754: result: $CPP" >&5 +echo "${ECHO_T}$CPP" >&6; } +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:3783: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:3789: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi + +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:3820: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:3826: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi + +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + : +else + { { echo "$as_me:3850: error: C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." >&5 +echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +{ echo "$as_me:3864: checking for grep that handles long lines and -e" >&5 +echo $ECHO_N "checking for grep that handles long lines and -e... $ECHO_C" >&6; } +if test "${ac_cv_path_GREP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # Extract the first word of "grep ggrep" to use in msg output +if test -z "$GREP"; then +set dummy grep ggrep; ac_prog_name=$2 +if test "${ac_cv_path_GREP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_path_GREP_found=false +# Loop through the user's path and test for each of PROGNAME-LIST +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in grep ggrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue + # Check for GNU ac_path_GREP and select it if it is found. + # Check for GNU $ac_path_GREP +case `"$ac_path_GREP" --version 2>&1` in +*GNU*) + ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; +*) + ac_count=0 + echo $ECHO_N "0123456789$ECHO_C" >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + echo 'GREP' >> "conftest.nl" + "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + ac_count=`expr $ac_count + 1` + if test $ac_count -gt ${ac_path_GREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_GREP="$ac_path_GREP" + ac_path_GREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + + $ac_path_GREP_found && break 3 + done +done + +done +IFS=$as_save_IFS + + +fi + +GREP="$ac_cv_path_GREP" +if test -z "$GREP"; then + { { echo "$as_me:3927: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 +echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} + { (exit 1); exit 1; }; } +fi + +else + ac_cv_path_GREP=$GREP +fi + + +fi +{ echo "$as_me:3938: result: $ac_cv_path_GREP" >&5 +echo "${ECHO_T}$ac_cv_path_GREP" >&6; } + GREP="$ac_cv_path_GREP" + + +{ echo "$as_me:3943: checking for egrep" >&5 +echo $ECHO_N "checking for egrep... $ECHO_C" >&6; } +if test "${ac_cv_path_EGREP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 + then ac_cv_path_EGREP="$GREP -E" + else + # Extract the first word of "egrep" to use in msg output +if test -z "$EGREP"; then +set dummy egrep; ac_prog_name=$2 +if test "${ac_cv_path_EGREP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_path_EGREP_found=false +# Loop through the user's path and test for each of PROGNAME-LIST +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in egrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue + # Check for GNU ac_path_EGREP and select it if it is found. + # Check for GNU $ac_path_EGREP +case `"$ac_path_EGREP" --version 2>&1` in +*GNU*) + ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; +*) + ac_count=0 + echo $ECHO_N "0123456789$ECHO_C" >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + echo 'EGREP' >> "conftest.nl" + "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + ac_count=`expr $ac_count + 1` + if test $ac_count -gt ${ac_path_EGREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_EGREP="$ac_path_EGREP" + ac_path_EGREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + + $ac_path_EGREP_found && break 3 + done +done + +done +IFS=$as_save_IFS + + +fi + +EGREP="$ac_cv_path_EGREP" +if test -z "$EGREP"; then + { { echo "$as_me:4009: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 +echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} + { (exit 1); exit 1; }; } +fi + +else + ac_cv_path_EGREP=$EGREP +fi + + + fi +fi +{ echo "$as_me:4021: result: $ac_cv_path_EGREP" >&5 +echo "${ECHO_T}$ac_cv_path_EGREP" >&6; } + EGREP="$ac_cv_path_EGREP" + + +{ echo "$as_me:4026: checking for ANSI C header files" >&5 +echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6; } +if test "${ac_cv_header_stdc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include +#include + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:4056: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:4062: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_header_stdc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_header_stdc=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then + : +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then + : +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then + : +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + return 2; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:4161: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:4164: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:4170: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:4173: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_header_stdc=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + +fi +fi +{ echo "$as_me:4190: result: $ac_cv_header_stdc" >&5 +echo "${ECHO_T}$ac_cv_header_stdc" >&6; } +if test $ac_cv_header_stdc = yes; then + +cat >>confdefs.h <<\_ACEOF +#define STDC_HEADERS 1 +_ACEOF + +fi + +# On IRIX 5.3, sys/types and inttypes.h are conflicting. + + + + + + + + + +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ + inttypes.h stdint.h unistd.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +{ echo "$as_me:4214: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:4235: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:4241: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + eval "$as_ac_Header=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_Header=no" +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:4257: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + + +for ac_header in parser.h iniparser.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { echo "$as_me:4275: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:4281: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +else + # Is the header compilable? +{ echo "$as_me:4285: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:4302: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:4308: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ echo "$as_me:4322: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } + +# Is the header present? +{ echo "$as_me:4326: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:4341: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:4347: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ echo "$as_me:4361: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:4367: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:4369: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:4374: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:4376: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:4378: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:4380: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:4382: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:4384: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ echo "$as_me:4389: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:4397: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + +for ac_header in dictionary.h inistrings.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { echo "$as_me:4416: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:4422: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +else + # Is the header compilable? +{ echo "$as_me:4426: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:4443: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:4449: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ echo "$as_me:4463: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } + +# Is the header present? +{ echo "$as_me:4467: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:4482: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:4488: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ echo "$as_me:4502: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:4508: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:4510: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:4515: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:4517: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:4519: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:4521: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:4523: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:4525: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ echo "$as_me:4530: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:4538: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + +for ac_header in math.h stdio.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { echo "$as_me:4557: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:4563: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +else + # Is the header compilable? +{ echo "$as_me:4567: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:4584: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:4590: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ echo "$as_me:4604: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } + +# Is the header present? +{ echo "$as_me:4608: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:4623: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:4629: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ echo "$as_me:4643: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:4649: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:4651: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:4656: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:4658: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:4660: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:4662: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:4664: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:4666: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ echo "$as_me:4671: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:4679: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + + + + + + + + + +for ac_header in fcntl.h inttypes.h limits.h memory.h stddef.h stdint.h stdlib.h string.h strings.h unistd.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { echo "$as_me:4706: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:4712: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +else + # Is the header compilable? +{ echo "$as_me:4716: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:4733: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:4739: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ echo "$as_me:4753: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } + +# Is the header present? +{ echo "$as_me:4757: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:4772: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:4778: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ echo "$as_me:4792: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:4798: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:4800: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:4805: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:4807: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:4809: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:4811: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:4813: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:4815: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ echo "$as_me:4820: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:4828: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + +# AC_CHECK_HEADERS([libgen.h getopt.h]) + +# Checks for typedefs, structures, and compiler characteristics. +{ echo "$as_me:4844: checking for an ANSI C-conforming const" >&5 +echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6; } +if test "${ac_cv_c_const+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +/* FIXME: Include the comments suggested by Paul. */ +#ifndef __cplusplus + /* Ultrix mips cc rejects this. */ + typedef int charset[2]; + const charset cs; + /* SunOS 4.1.1 cc rejects this. */ + char const *const *pcpcc; + char **ppc; + /* NEC SVR4.0.2 mips cc rejects this. */ + struct point {int x, y;}; + static struct point const zero = {0,0}; + /* AIX XL C 1.02.0.0 rejects this. + It does not let you subtract one const X* pointer from another in + an arm of an if-expression whose if-part is not a constant + expression */ + const char *g = "string"; + pcpcc = &g + (g ? g-g : 0); + /* HPUX 7.0 cc rejects these. */ + ++pcpcc; + ppc = (char**) pcpcc; + pcpcc = (char const *const *) ppc; + { /* SCO 3.2v4 cc rejects this. */ + char *t; + char const *s = 0 ? (char *) 0 : (char const *) 0; + + *t++ = 0; + if (s) return 0; + } + { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ + int x[] = {25, 17}; + const int *foo = &x[0]; + ++foo; + } + { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ + typedef const int *iptr; + iptr p = 0; + ++p; + } + { /* AIX XL C 1.02.0.0 rejects this saying + "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ + struct s { int j; const int *ap[3]; }; + struct s *b; b->j = 5; + } + { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ + const int foo = 10; + if (!foo) return 0; + } + return !cs[0] && !zero.x; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:4919: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:4925: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_c_const=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_c_const=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:4940: result: $ac_cv_c_const" >&5 +echo "${ECHO_T}$ac_cv_c_const" >&6; } +if test $ac_cv_c_const = no; then + +cat >>confdefs.h <<\_ACEOF +#define const +_ACEOF + +fi + +# AC_TYPE_UID_T +# AC_C_INLINE +# AC_CHECK_TYPE(size_t, unsigned) +# AC_CHECK_TYPE(ssize_t, signed) +# AC_CHECK_MEMBERS([struct stat.st_rdev]) + +# Checks for library functions. +# AC_CHECK_FUNCS([getopt_long getline strtof]) +# AC_FUNC_SNPRINTF +# AC_FUNC_SCANF_CAN_MALLOC + +ac_config_files="$ac_config_files Makefile" + +cat >confcache <<\_ACEOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs, see configure's option --config-cache. +# It is not useful on other systems. If it contains results you don't +# want to keep, you may remove or edit it. +# +# config.status only pays attention to the cache file if you give it +# the --recheck option to rerun configure. +# +# `ac_cv_env_foo' variables (set or unset) will be overridden when +# loading this file, other *unset* `ac_cv_foo' will be assigned the +# following values. + +_ACEOF + +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, we kill variables containing newlines. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +( + for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { echo "$as_me:4990: WARNING: Cache variable $ac_var contains a newline." >&5 +echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + *) $as_unset $ac_var ;; + esac ;; + esac + done + + (set) 2>&1 | + case $as_nl`(ac_space=' '; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + # `set' does not quote correctly, so add quotes (double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \). + sed -n \ + "s/'/'\\\\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" + ;; #( + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) | + sed ' + /^ac_cv_env_/b end + t clear + :clear + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ + t end + s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + :end' >>confcache +if diff "$cache_file" confcache >/dev/null 2>&1; then :; else + if test -w "$cache_file"; then + test "x$cache_file" != "x/dev/null" && + { echo "$as_me:5027: updating cache $cache_file" >&5 +echo "$as_me: updating cache $cache_file" >&6;} + cat confcache >$cache_file + else + { echo "$as_me:5031: not updating unwritable cache $cache_file" >&5 +echo "$as_me: not updating unwritable cache $cache_file" >&6;} + fi +fi +rm -f confcache + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +# Transform confdefs.h into DEFS. +# Protect against shell expansion while executing Makefile rules. +# Protect against Makefile macro expansion. +# +# If the first sed substitution is executed (which looks for macros that +# take arguments), then branch to the quote section. Otherwise, +# look for a macro that doesn't take arguments. +ac_script=' +t clear +:clear +s/^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\)/-D\1=\2/g +t quote +s/^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)/-D\1=\2/g +t quote +b any +:quote +s/[ `~#$^&*(){}\\|;'\''"<>?]/\\&/g +s/\[/\\&/g +s/\]/\\&/g +s/\$/$$/g +H +:any +${ + g + s/^\n// + s/\n/ /g + p +} +' +DEFS=`sed -n "$ac_script" confdefs.h` + + +ac_libobjs= +ac_ltlibobjs= +for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue + # 1. Remove the extension, and $U if already installed. + ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' + ac_i=`echo "$ac_i" | sed "$ac_script"` + # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR + # will be set to the directory where LIBOBJS objects are built. + ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext" + ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$ac_i"'$U.lo' +done +LIBOBJS=$ac_libobjs + +LTLIBOBJS=$ac_ltlibobjs + + +if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then + { { echo "$as_me:5090: error: conditional \"AMDEP\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"AMDEP\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi +if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then + { { echo "$as_me:5097: error: conditional \"am__fastdepCC\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"am__fastdepCC\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi + +: ${CONFIG_STATUS=./config.status} +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files $CONFIG_STATUS" +{ echo "$as_me:5107: creating $CONFIG_STATUS" >&5 +echo "$as_me: creating $CONFIG_STATUS" >&6;} +cat >$CONFIG_STATUS <<_ACEOF +#! $SHELL +# Generated by $as_me. +# Run this file to recreate the current configuration. +# Compiler output produced by configure, useful for debugging +# configure, is in config.log if it exists. + +debug=false +ac_cs_recheck=false +ac_cs_silent=false +SHELL=\${CONFIG_SHELL-$SHELL} +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +## --------------------- ## +## M4sh Initialization. ## +## --------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + + + +# PATH needs CR +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + +# Support unset when possible. +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +as_nl=' +' +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +case $0 in + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + { (exit 1); exit 1; } +fi + +# Work around bugs in pre-3.0 UWIN ksh. +for as_var in ENV MAIL MAILPATH +do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +for as_var in \ + LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ + LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ + LC_TELEPHONE LC_TIME +do + if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then + eval $as_var=C; export $as_var + else + ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var + fi +done + +# Required to use basename. +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + + +# Name of the executable. +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# CDPATH. +$as_unset CDPATH + + + + as_lineno_1=5269 + as_lineno_2=5270 + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { + + # Create $as_me.lineno as a copy of $as_myself, but with 5274 + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line after each line using 5276; the second 'sed' + # does the real work. The second script uses 'N' to pair each + # line-number line with the line containing 5278, and appends + # trailing '-' during substitution so that 5279 is not a special + # case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # scripts with optimization help from Paolo Bonzini. Blame Lee + # E. McMahon (1931-1989) for sed's syntax. :-) + sed -n ' + p + /[$]LINENO/= + ' <$as_myself | + sed ' + s/[$]LINENO.*/&-/ + t lineno + b + :lineno + N + :loop + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ + t loop + s/-\n.*// + ' >$as_me.lineno && + chmod +x "$as_me.lineno" || + { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 + { (exit 1); exit 1; }; } + + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensitive to this). + . "./$as_me.lineno" + # Exit status is that of the last command. + exit +} + + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in +-n*) + case `echo 'x\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + *) ECHO_C='\c';; + esac;; +*) + ECHO_N='-n';; +esac + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir +fi +echo >conf$$.file +if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -p' +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + +if mkdir -p . 2>/dev/null; then + as_mkdir_p=: +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +exec 6>&1 + +# Save the log message, to keep $[0] and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. +ac_log=" +This file was extended by creGpioDae $as_me 0.0.1, which was +generated by GNU Autoconf 2.61. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +on `(hostname || uname -n) 2>/dev/null | sed 1q` +" + +_ACEOF + +cat >>$CONFIG_STATUS <<_ACEOF +# Files that config.status was made for. +config_files="$ac_config_files" +config_commands="$ac_config_commands" + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +ac_cs_usage="\ +\`$as_me' instantiates files from templates according to the +current configuration. + +Usage: $0 [OPTIONS] [FILE]... + + -h, --help print this help, then exit + -V, --version print version number and configuration settings, then exit + -q, --quiet do not print progress messages + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE + +Configuration files: +$config_files + +Configuration commands: +$config_commands + +Report bugs to ." + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF +ac_cs_version="\\ +creGpioDae config.status 0.0.1 +configured by $0, generated by GNU Autoconf 2.61, + with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" + +Copyright (C) 2006 Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." + +ac_pwd='$ac_pwd' +srcdir='$srcdir' +INSTALL='$INSTALL' +MKDIR_P='$MKDIR_P' +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +# If no file are specified by the user, then we need to provide default +# value. By we need to know if files were specified by the user. +ac_need_defaults=: +while test $# != 0 +do + case $1 in + --*=*) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` + ac_shift=: + ;; + *) + ac_option=$1 + ac_optarg=$2 + ac_shift=shift + ;; + esac + + case $ac_option in + # Handling of the options. + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + ac_cs_recheck=: ;; + --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) + echo "$ac_cs_version"; exit ;; + --debug | --debu | --deb | --de | --d | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + $ac_shift + CONFIG_FILES="$CONFIG_FILES $ac_optarg" + ac_need_defaults=false;; + --he | --h | --help | --hel | -h ) + echo "$ac_cs_usage"; exit ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil | --si | --s) + ac_cs_silent=: ;; + + # This is an error. + -*) { echo "$as_me: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&2 + { (exit 1); exit 1; }; } ;; + + *) ac_config_targets="$ac_config_targets $1" + ac_need_defaults=false ;; + + esac + shift +done + +ac_configure_extra_args= + +if $ac_cs_silent; then + exec 6>/dev/null + ac_configure_extra_args="$ac_configure_extra_args --silent" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF +if \$ac_cs_recheck; then + echo "running CONFIG_SHELL=$SHELL $SHELL $0 "$ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 + CONFIG_SHELL=$SHELL + export CONFIG_SHELL + exec $SHELL "$0"$ac_configure_args \$ac_configure_extra_args --no-create --no-recursion +fi + +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX + echo "$ac_log" +} >&5 + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF +# +# INIT-COMMANDS +# +AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF + +# Handling of arguments. +for ac_config_target in $ac_config_targets +do + case $ac_config_target in + "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; + "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; + + *) { { echo "$as_me:5558: error: invalid argument: $ac_config_target" >&5 +echo "$as_me: error: invalid argument: $ac_config_target" >&2;} + { (exit 1); exit 1; }; };; + esac +done + + +# If the user did not use the arguments to specify the items to instantiate, +# then the envvar interface is used. Set only those that are not. +# We use the long form for the default assignment because of an extremely +# bizarre bug on SunOS 4.1.3. +if $ac_need_defaults; then + test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files + test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands +fi + +# Have a temporary directory for convenience. Make it in the build tree +# simply because there is no reason against having it here, and in addition, +# creating and moving files from /tmp can sometimes cause problems. +# Hook for its removal unless debugging. +# Note that there is a small window in which the directory will not be cleaned: +# after its creation but before its name has been assigned to `$tmp'. +$debug || +{ + tmp= + trap 'exit_status=$? + { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status +' 0 + trap '{ (exit 1); exit 1; }' 1 2 13 15 +} +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && + test -n "$tmp" && test -d "$tmp" +} || +{ + tmp=./conf$$-$RANDOM + (umask 077 && mkdir "$tmp") +} || +{ + echo "$me: cannot create a temporary directory in ." >&2 + { (exit 1); exit 1; } +} + +# +# Set up the sed scripts for CONFIG_FILES section. +# + +# No need to generate the scripts if there are no CONFIG_FILES. +# This happens for instance when ./config.status config.h +if test -n "$CONFIG_FILES"; then + +_ACEOF + + + +ac_delim='%!_!# ' +for ac_last_try in false false false false false :; do + cat >conf$$subs.sed <<_ACEOF +SHELL!$SHELL$ac_delim +PATH_SEPARATOR!$PATH_SEPARATOR$ac_delim +PACKAGE_NAME!$PACKAGE_NAME$ac_delim +PACKAGE_TARNAME!$PACKAGE_TARNAME$ac_delim +PACKAGE_VERSION!$PACKAGE_VERSION$ac_delim +PACKAGE_STRING!$PACKAGE_STRING$ac_delim +PACKAGE_BUGREPORT!$PACKAGE_BUGREPORT$ac_delim +exec_prefix!$exec_prefix$ac_delim +prefix!$prefix$ac_delim +program_transform_name!$program_transform_name$ac_delim +bindir!$bindir$ac_delim +sbindir!$sbindir$ac_delim +libexecdir!$libexecdir$ac_delim +datarootdir!$datarootdir$ac_delim +datadir!$datadir$ac_delim +sysconfdir!$sysconfdir$ac_delim +sharedstatedir!$sharedstatedir$ac_delim +localstatedir!$localstatedir$ac_delim +includedir!$includedir$ac_delim +oldincludedir!$oldincludedir$ac_delim +docdir!$docdir$ac_delim +infodir!$infodir$ac_delim +htmldir!$htmldir$ac_delim +dvidir!$dvidir$ac_delim +pdfdir!$pdfdir$ac_delim +psdir!$psdir$ac_delim +libdir!$libdir$ac_delim +localedir!$localedir$ac_delim +mandir!$mandir$ac_delim +DEFS!$DEFS$ac_delim +ECHO_C!$ECHO_C$ac_delim +ECHO_N!$ECHO_N$ac_delim +ECHO_T!$ECHO_T$ac_delim +LIBS!$LIBS$ac_delim +build_alias!$build_alias$ac_delim +host_alias!$host_alias$ac_delim +target_alias!$target_alias$ac_delim +INSTALL_PROGRAM!$INSTALL_PROGRAM$ac_delim +INSTALL_SCRIPT!$INSTALL_SCRIPT$ac_delim +INSTALL_DATA!$INSTALL_DATA$ac_delim +am__isrc!$am__isrc$ac_delim +CYGPATH_W!$CYGPATH_W$ac_delim +PACKAGE!$PACKAGE$ac_delim +VERSION!$VERSION$ac_delim +ACLOCAL!$ACLOCAL$ac_delim +AUTOCONF!$AUTOCONF$ac_delim +AUTOMAKE!$AUTOMAKE$ac_delim +AUTOHEADER!$AUTOHEADER$ac_delim +MAKEINFO!$MAKEINFO$ac_delim +install_sh!$install_sh$ac_delim +STRIP!$STRIP$ac_delim +INSTALL_STRIP_PROGRAM!$INSTALL_STRIP_PROGRAM$ac_delim +mkdir_p!$mkdir_p$ac_delim +AWK!$AWK$ac_delim +SET_MAKE!$SET_MAKE$ac_delim +am__leading_dot!$am__leading_dot$ac_delim +AMTAR!$AMTAR$ac_delim +am__tar!$am__tar$ac_delim +am__untar!$am__untar$ac_delim +CC!$CC$ac_delim +CFLAGS!$CFLAGS$ac_delim +LDFLAGS!$LDFLAGS$ac_delim +CPPFLAGS!$CPPFLAGS$ac_delim +ac_ct_CC!$ac_ct_CC$ac_delim +EXEEXT!$EXEEXT$ac_delim +OBJEXT!$OBJEXT$ac_delim +DEPDIR!$DEPDIR$ac_delim +am__include!$am__include$ac_delim +am__quote!$am__quote$ac_delim +AMDEP_TRUE!$AMDEP_TRUE$ac_delim +AMDEP_FALSE!$AMDEP_FALSE$ac_delim +AMDEPBACKSLASH!$AMDEPBACKSLASH$ac_delim +CCDEPMODE!$CCDEPMODE$ac_delim +am__fastdepCC_TRUE!$am__fastdepCC_TRUE$ac_delim +am__fastdepCC_FALSE!$am__fastdepCC_FALSE$ac_delim +CPP!$CPP$ac_delim +GREP!$GREP$ac_delim +EGREP!$EGREP$ac_delim +LIBOBJS!$LIBOBJS$ac_delim +LTLIBOBJS!$LTLIBOBJS$ac_delim +_ACEOF + + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 80; then + break + elif $ac_last_try; then + { { echo "$as_me:5703: error: could not make $CONFIG_STATUS" >&5 +echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} + { (exit 1); exit 1; }; } + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done + +ac_eof=`sed -n '/^CEOF[0-9]*$/s/CEOF/0/p' conf$$subs.sed` +if test -n "$ac_eof"; then + ac_eof=`echo "$ac_eof" | sort -nru | sed 1q` + ac_eof=`expr $ac_eof + 1` +fi + +cat >>$CONFIG_STATUS <<_ACEOF +cat >"\$tmp/subs-1.sed" <<\CEOF$ac_eof +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b end +_ACEOF +sed ' +s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g +s/^/s,@/; s/!/@,|#_!!_#|/ +:n +t n +s/'"$ac_delim"'$/,g/; t +s/$/\\/; p +N; s/^.*\n//; s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g; b n +' >>$CONFIG_STATUS >$CONFIG_STATUS <<_ACEOF +:end +s/|#_!!_#|//g +CEOF$ac_eof +_ACEOF + + +# VPATH may cause trouble with some makes, so we remove $(srcdir), +# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and +# trailing colons and then remove the whole line if VPATH becomes empty +# (actually we leave an empty line to preserve line numbers). +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=/{ +s/:*\$(srcdir):*/:/ +s/:*\${srcdir}:*/:/ +s/:*@srcdir@:*/:/ +s/^\([^=]*=[ ]*\):*/\1/ +s/:*$// +s/^[^=]*=[ ]*$// +}' +fi + +cat >>$CONFIG_STATUS <<\_ACEOF +fi # test -n "$CONFIG_FILES" + + +for ac_tag in :F $CONFIG_FILES :C $CONFIG_COMMANDS +do + case $ac_tag in + :[FHLC]) ac_mode=$ac_tag; continue;; + esac + case $ac_mode$ac_tag in + :[FHL]*:*);; + :L* | :C*:*) { { echo "$as_me:5764: error: Invalid tag $ac_tag." >&5 +echo "$as_me: error: Invalid tag $ac_tag." >&2;} + { (exit 1); exit 1; }; };; + :[FH]-) ac_tag=-:-;; + :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; + esac + ac_save_IFS=$IFS + IFS=: + set x $ac_tag + IFS=$ac_save_IFS + shift + ac_file=$1 + shift + + case $ac_mode in + :L) ac_source=$1;; + :[FH]) + ac_file_inputs= + for ac_f + do + case $ac_f in + -) ac_f="$tmp/stdin";; + *) # Look for the file first in the build tree, then in the source tree + # (if the path is not absolute). The absolute path cannot be DOS-style, + # because $ac_f cannot contain `:'. + test -f "$ac_f" || + case $ac_f in + [\\/$]*) false;; + *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; + esac || + { { echo "$as_me:5794: error: cannot find input file: $ac_f" >&5 +echo "$as_me: error: cannot find input file: $ac_f" >&2;} + { (exit 1); exit 1; }; };; + esac + ac_file_inputs="$ac_file_inputs $ac_f" + done + + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + configure_input="Generated from "`IFS=: + echo $* | sed 's|^[^:]*/||;s|:[^:]*/|, |g'`" by configure." + if test x"$ac_file" != x-; then + configure_input="$ac_file. $configure_input" + { echo "$as_me:5808: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + fi + + case $ac_tag in + *:-:* | *:-) cat >"$tmp/stdin";; + esac + ;; + esac + + ac_dir=`$as_dirname -- "$ac_file" || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || +echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + { as_dir="$ac_dir" + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || { { echo "$as_me:5879: error: cannot create directory $as_dir" >&5 +echo "$as_me: error: cannot create directory $as_dir" >&2;} + { (exit 1); exit 1; }; }; } + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + + case $ac_mode in + :F) + # + # CONFIG_FILE + # + + case $INSTALL in + [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; + *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; + esac + ac_MKDIR_P=$MKDIR_P + case $MKDIR_P in + [\\/$]* | ?:[\\/]* ) ;; + */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; + esac +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +# If the template does not know about datarootdir, expand it. +# FIXME: This hack should be removed a few years after 2.60. +ac_datarootdir_hack=; ac_datarootdir_seen= + +case `sed -n '/datarootdir/ { + p + q +} +/@datadir@/p +/@docdir@/p +/@infodir@/p +/@localedir@/p +/@mandir@/p +' $ac_file_inputs` in +*datarootdir*) ac_datarootdir_seen=yes;; +*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) + { echo "$as_me:5951: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 +echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF + ac_datarootdir_hack=' + s&@datadir@&$datadir&g + s&@docdir@&$docdir&g + s&@infodir@&$infodir&g + s&@localedir@&$localedir&g + s&@mandir@&$mandir&g + s&\\\${datarootdir}&$datarootdir&g' ;; +esac +_ACEOF + +# Neutralize VPATH when `$srcdir' = `.'. +# Shell code in configure.ac might set extrasub. +# FIXME: do we really want to maintain this feature? +cat >>$CONFIG_STATUS <<_ACEOF + sed "$ac_vpsub +$extrasub +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s&@configure_input@&$configure_input&;t t +s&@top_builddir@&$ac_top_builddir_sub&;t t +s&@srcdir@&$ac_srcdir&;t t +s&@abs_srcdir@&$ac_abs_srcdir&;t t +s&@top_srcdir@&$ac_top_srcdir&;t t +s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t +s&@builddir@&$ac_builddir&;t t +s&@abs_builddir@&$ac_abs_builddir&;t t +s&@abs_top_builddir@&$ac_abs_top_builddir&;t t +s&@INSTALL@&$ac_INSTALL&;t t +s&@MKDIR_P@&$ac_MKDIR_P&;t t +$ac_datarootdir_hack +" $ac_file_inputs | sed -f "$tmp/subs-1.sed" >$tmp/out + +test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && + { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && + { echo "$as_me:5992: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined." >&5 +echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined." >&2;} + + rm -f "$tmp/stdin" + case $ac_file in + -) cat "$tmp/out"; rm -f "$tmp/out";; + *) rm -f "$ac_file"; mv "$tmp/out" $ac_file;; + esac + ;; + + + :C) { echo "$as_me:6005: executing $ac_file commands" >&5 +echo "$as_me: executing $ac_file commands" >&6;} + ;; + esac + + + case $ac_file$ac_mode in + "depfiles":C) test x"$AMDEP_TRUE" != x"" || for mf in $CONFIG_FILES; do + # Strip MF so we end up with the name of the file. + mf=`echo "$mf" | sed -e 's/:.*$//'` + # Check whether this is an Automake generated Makefile or not. + # We used to match only the files named `Makefile.in', but + # some people rename them; so instead we look at the file content. + # Grep'ing the first line is not enough: some people post-process + # each Makefile.in and add a new line on top of each file to say so. + # Grep'ing the whole file is not good either: AIX grep has a line + # limit of 2048, but all sed's we know have understand at least 4000. + if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then + dirpart=`$as_dirname -- "$mf" || +$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$mf" : 'X\(//\)[^/]' \| \ + X"$mf" : 'X\(//\)$' \| \ + X"$mf" : 'X\(/\)' \| . 2>/dev/null || +echo X"$mf" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + else + continue + fi + # Extract the definition of DEPDIR, am__include, and am__quote + # from the Makefile without running `make'. + DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` + test -z "$DEPDIR" && continue + am__include=`sed -n 's/^am__include = //p' < "$mf"` + test -z "am__include" && continue + am__quote=`sed -n 's/^am__quote = //p' < "$mf"` + # When using ansi2knr, U may be empty or an underscore; expand it + U=`sed -n 's/^U = //p' < "$mf"` + # Find all dependency output files, they are included files with + # $(DEPDIR) in their names. We invoke sed twice because it is the + # simplest approach to changing $(DEPDIR) to its actual value in the + # expansion. + for file in `sed -n " + s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ + sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do + # Make sure the directory exists. + test -f "$dirpart/$file" && continue + fdir=`$as_dirname -- "$file" || +$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$file" : 'X\(//\)[^/]' \| \ + X"$file" : 'X\(//\)$' \| \ + X"$file" : 'X\(/\)' \| . 2>/dev/null || +echo X"$file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + { as_dir=$dirpart/$fdir + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || { { echo "$as_me:6128: error: cannot create directory $as_dir" >&5 +echo "$as_me: error: cannot create directory $as_dir" >&2;} + { (exit 1); exit 1; }; }; } + # echo "creating $dirpart/$file" + echo '# dummy' > "$dirpart/$file" + done +done + ;; + + esac +done # for ac_tag + + +{ (exit 0); exit 0; } +_ACEOF +chmod +x $CONFIG_STATUS +ac_clean_files=$ac_clean_files_save + + +# configure is writing to config.log, and then calls config.status. +# config.status does its own redirection, appending to config.log. +# Unfortunately, on DOS this fails, as config.log is still kept open +# by configure, so config.status won't be able to write to it; its +# output is simply discarded. So we exec the FD to /dev/null, +# effectively closing config.log, so it can be properly (re)opened and +# appended to by config.status. When coming back to configure, we +# need to make the FD available again. +if test "$no_create" != yes; then + ac_cs_success=: + ac_config_status_args= + test "$silent" = yes && + ac_config_status_args="$ac_config_status_args --quiet" + exec 5>/dev/null + $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false + exec 5>>config.log + # Use ||, not &&, to avoid exiting from the if with $? = 1, which + # would make configure fail if this is the last instruction. + $ac_cs_success || { (exit 1); exit 1; } +fi + +# AC_OUTPUT([Makefile],[chmod a+x test-mount.sh test.sh]) diff --git a/Quantum Controller/SW/testapplication-0.0.1/depcomp b/Quantum Controller/SW/testapplication-0.0.1/depcomp new file mode 100644 index 0000000..e5f9736 --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/depcomp @@ -0,0 +1,589 @@ +#! /bin/sh +# depcomp - compile a program generating dependencies as side-effects + +scriptversion=2007-03-29.01 + +# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007 Free Software +# Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Originally written by Alexandre Oliva . + +case $1 in + '') + echo "$0: No command. Try \`$0 --help' for more information." 1>&2 + exit 1; + ;; + -h | --h*) + cat <<\EOF +Usage: depcomp [--help] [--version] PROGRAM [ARGS] + +Run PROGRAMS ARGS to compile a file, generating dependencies +as side-effects. + +Environment variables: + depmode Dependency tracking mode. + source Source file read by `PROGRAMS ARGS'. + object Object file output by `PROGRAMS ARGS'. + DEPDIR directory where to store dependencies. + depfile Dependency file to output. + tmpdepfile Temporary file to use when outputing dependencies. + libtool Whether libtool is used (yes/no). + +Report bugs to . +EOF + exit $? + ;; + -v | --v*) + echo "depcomp $scriptversion" + exit $? + ;; +esac + +if test -z "$depmode" || test -z "$source" || test -z "$object"; then + echo "depcomp: Variables source, object and depmode must be set" 1>&2 + exit 1 +fi + +# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. +depfile=${depfile-`echo "$object" | + sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} +tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} + +rm -f "$tmpdepfile" + +# Some modes work just like other modes, but use different flags. We +# parameterize here, but still list the modes in the big case below, +# to make depend.m4 easier to write. Note that we *cannot* use a case +# here, because this file can only contain one case statement. +if test "$depmode" = hp; then + # HP compiler uses -M and no extra arg. + gccflag=-M + depmode=gcc +fi + +if test "$depmode" = dashXmstdout; then + # This is just like dashmstdout with a different argument. + dashmflag=-xM + depmode=dashmstdout +fi + +case "$depmode" in +gcc3) +## gcc 3 implements dependency tracking that does exactly what +## we want. Yay! Note: for some reason libtool 1.4 doesn't like +## it if -MD -MP comes after the -MF stuff. Hmm. +## Unfortunately, FreeBSD c89 acceptance of flags depends upon +## the command line argument order; so add the flags where they +## appear in depend2.am. Note that the slowdown incurred here +## affects only configure: in makefiles, %FASTDEP% shortcuts this. + for arg + do + case $arg in + -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; + *) set fnord "$@" "$arg" ;; + esac + shift # fnord + shift # $arg + done + "$@" + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + mv "$tmpdepfile" "$depfile" + ;; + +gcc) +## There are various ways to get dependency output from gcc. Here's +## why we pick this rather obscure method: +## - Don't want to use -MD because we'd like the dependencies to end +## up in a subdir. Having to rename by hand is ugly. +## (We might end up doing this anyway to support other compilers.) +## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like +## -MM, not -M (despite what the docs say). +## - Using -M directly means running the compiler twice (even worse +## than renaming). + if test -z "$gccflag"; then + gccflag=-MD, + fi + "$@" -Wp,"$gccflag$tmpdepfile" + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + echo "$object : \\" > "$depfile" + alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz +## The second -e expression handles DOS-style file names with drive letters. + sed -e 's/^[^:]*: / /' \ + -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" +## This next piece of magic avoids the `deleted header file' problem. +## The problem is that when a header file which appears in a .P file +## is deleted, the dependency causes make to die (because there is +## typically no way to rebuild the header). We avoid this by adding +## dummy dependencies for each header file. Too bad gcc doesn't do +## this for us directly. + tr ' ' ' +' < "$tmpdepfile" | +## Some versions of gcc put a space before the `:'. On the theory +## that the space means something, we add a space to the output as +## well. +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +hp) + # This case exists only to let depend.m4 do its work. It works by + # looking at the text of this script. This case will never be run, + # since it is checked for above. + exit 1 + ;; + +sgi) + if test "$libtool" = yes; then + "$@" "-Wp,-MDupdate,$tmpdepfile" + else + "$@" -MDupdate "$tmpdepfile" + fi + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + + if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files + echo "$object : \\" > "$depfile" + + # Clip off the initial element (the dependent). Don't try to be + # clever and replace this with sed code, as IRIX sed won't handle + # lines with more than a fixed number of characters (4096 in + # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; + # the IRIX cc adds comments like `#:fec' to the end of the + # dependency line. + tr ' ' ' +' < "$tmpdepfile" \ + | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ + tr ' +' ' ' >> $depfile + echo >> $depfile + + # The second pass generates a dummy entry for each header file. + tr ' ' ' +' < "$tmpdepfile" \ + | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ + >> $depfile + else + # The sourcefile does not contain any dependencies, so just + # store a dummy comment line, to avoid errors with the Makefile + # "include basename.Plo" scheme. + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" + ;; + +aix) + # The C for AIX Compiler uses -M and outputs the dependencies + # in a .u file. In older versions, this file always lives in the + # current directory. Also, the AIX compiler puts `$object:' at the + # start of each line; $object doesn't have directory information. + # Version 6 uses the directory in both cases. + dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` + test "x$dir" = "x$object" && dir= + base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` + if test "$libtool" = yes; then + tmpdepfile1=$dir$base.u + tmpdepfile2=$base.u + tmpdepfile3=$dir.libs/$base.u + "$@" -Wc,-M + else + tmpdepfile1=$dir$base.u + tmpdepfile2=$dir$base.u + tmpdepfile3=$dir$base.u + "$@" -M + fi + stat=$? + + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" + exit $stat + fi + + for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" + do + test -f "$tmpdepfile" && break + done + if test -f "$tmpdepfile"; then + # Each line is of the form `foo.o: dependent.h'. + # Do two passes, one to just change these to + # `$object: dependent.h' and one to simply `dependent.h:'. + sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" + # That's a tab and a space in the []. + sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" + else + # The sourcefile does not contain any dependencies, so just + # store a dummy comment line, to avoid errors with the Makefile + # "include basename.Plo" scheme. + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" + ;; + +icc) + # Intel's C compiler understands `-MD -MF file'. However on + # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c + # ICC 7.0 will fill foo.d with something like + # foo.o: sub/foo.c + # foo.o: sub/foo.h + # which is wrong. We want: + # sub/foo.o: sub/foo.c + # sub/foo.o: sub/foo.h + # sub/foo.c: + # sub/foo.h: + # ICC 7.1 will output + # foo.o: sub/foo.c sub/foo.h + # and will wrap long lines using \ : + # foo.o: sub/foo.c ... \ + # sub/foo.h ... \ + # ... + + "$@" -MD -MF "$tmpdepfile" + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + # Each line is of the form `foo.o: dependent.h', + # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. + # Do two passes, one to just change these to + # `$object: dependent.h' and one to simply `dependent.h:'. + sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" + # Some versions of the HPUX 10.20 sed can't process this invocation + # correctly. Breaking it into two sed invocations is a workaround. + sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | + sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +hp2) + # The "hp" stanza above does not work with aCC (C++) and HP's ia64 + # compilers, which have integrated preprocessors. The correct option + # to use with these is +Maked; it writes dependencies to a file named + # 'foo.d', which lands next to the object file, wherever that + # happens to be. + # Much of this is similar to the tru64 case; see comments there. + dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` + test "x$dir" = "x$object" && dir= + base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` + if test "$libtool" = yes; then + tmpdepfile1=$dir$base.d + tmpdepfile2=$dir.libs/$base.d + "$@" -Wc,+Maked + else + tmpdepfile1=$dir$base.d + tmpdepfile2=$dir$base.d + "$@" +Maked + fi + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile1" "$tmpdepfile2" + exit $stat + fi + + for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" + do + test -f "$tmpdepfile" && break + done + if test -f "$tmpdepfile"; then + sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" + # Add `dependent.h:' lines. + sed -ne '2,${; s/^ *//; s/ \\*$//; s/$/:/; p;}' "$tmpdepfile" >> "$depfile" + else + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" "$tmpdepfile2" + ;; + +tru64) + # The Tru64 compiler uses -MD to generate dependencies as a side + # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. + # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put + # dependencies in `foo.d' instead, so we check for that too. + # Subdirectories are respected. + dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` + test "x$dir" = "x$object" && dir= + base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` + + if test "$libtool" = yes; then + # With Tru64 cc, shared objects can also be used to make a + # static library. This mechanism is used in libtool 1.4 series to + # handle both shared and static libraries in a single compilation. + # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. + # + # With libtool 1.5 this exception was removed, and libtool now + # generates 2 separate objects for the 2 libraries. These two + # compilations output dependencies in $dir.libs/$base.o.d and + # in $dir$base.o.d. We have to check for both files, because + # one of the two compilations can be disabled. We should prefer + # $dir$base.o.d over $dir.libs/$base.o.d because the latter is + # automatically cleaned when .libs/ is deleted, while ignoring + # the former would cause a distcleancheck panic. + tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 + tmpdepfile2=$dir$base.o.d # libtool 1.5 + tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 + tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 + "$@" -Wc,-MD + else + tmpdepfile1=$dir$base.o.d + tmpdepfile2=$dir$base.d + tmpdepfile3=$dir$base.d + tmpdepfile4=$dir$base.d + "$@" -MD + fi + + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" + exit $stat + fi + + for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" + do + test -f "$tmpdepfile" && break + done + if test -f "$tmpdepfile"; then + sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" + # That's a tab and a space in the []. + sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" + else + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" + ;; + +#nosideeffect) + # This comment above is used by automake to tell side-effect + # dependency tracking mechanisms from slower ones. + +dashmstdout) + # Important note: in order to support this mode, a compiler *must* + # always write the preprocessed file to stdout, regardless of -o. + "$@" || exit $? + + # Remove the call to Libtool. + if test "$libtool" = yes; then + while test $1 != '--mode=compile'; do + shift + done + shift + fi + + # Remove `-o $object'. + IFS=" " + for arg + do + case $arg in + -o) + shift + ;; + $object) + shift + ;; + *) + set fnord "$@" "$arg" + shift # fnord + shift # $arg + ;; + esac + done + + test -z "$dashmflag" && dashmflag=-M + # Require at least two characters before searching for `:' + # in the target name. This is to cope with DOS-style filenames: + # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. + "$@" $dashmflag | + sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" + rm -f "$depfile" + cat < "$tmpdepfile" > "$depfile" + tr ' ' ' +' < "$tmpdepfile" | \ +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +dashXmstdout) + # This case only exists to satisfy depend.m4. It is never actually + # run, as this mode is specially recognized in the preamble. + exit 1 + ;; + +makedepend) + "$@" || exit $? + # Remove any Libtool call + if test "$libtool" = yes; then + while test $1 != '--mode=compile'; do + shift + done + shift + fi + # X makedepend + shift + cleared=no + for arg in "$@"; do + case $cleared in + no) + set ""; shift + cleared=yes ;; + esac + case "$arg" in + -D*|-I*) + set fnord "$@" "$arg"; shift ;; + # Strip any option that makedepend may not understand. Remove + # the object too, otherwise makedepend will parse it as a source file. + -*|$object) + ;; + *) + set fnord "$@" "$arg"; shift ;; + esac + done + obj_suffix="`echo $object | sed 's/^.*\././'`" + touch "$tmpdepfile" + ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" + rm -f "$depfile" + cat < "$tmpdepfile" > "$depfile" + sed '1,2d' "$tmpdepfile" | tr ' ' ' +' | \ +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" "$tmpdepfile".bak + ;; + +cpp) + # Important note: in order to support this mode, a compiler *must* + # always write the preprocessed file to stdout. + "$@" || exit $? + + # Remove the call to Libtool. + if test "$libtool" = yes; then + while test $1 != '--mode=compile'; do + shift + done + shift + fi + + # Remove `-o $object'. + IFS=" " + for arg + do + case $arg in + -o) + shift + ;; + $object) + shift + ;; + *) + set fnord "$@" "$arg" + shift # fnord + shift # $arg + ;; + esac + done + + "$@" -E | + sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ + -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | + sed '$ s: \\$::' > "$tmpdepfile" + rm -f "$depfile" + echo "$object : \\" > "$depfile" + cat < "$tmpdepfile" >> "$depfile" + sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +msvisualcpp) + # Important note: in order to support this mode, a compiler *must* + # always write the preprocessed file to stdout, regardless of -o, + # because we must use -o when running libtool. + "$@" || exit $? + IFS=" " + for arg + do + case "$arg" in + "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") + set fnord "$@" + shift + shift + ;; + *) + set fnord "$@" "$arg" + shift + shift + ;; + esac + done + "$@" -E | + sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" + rm -f "$depfile" + echo "$object : \\" > "$depfile" + . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" + echo " " >> "$depfile" + . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +none) + exec "$@" + ;; + +*) + echo "Unknown depmode $depmode" 1>&2 + exit 1 + ;; +esac + +exit 0 + +# Local Variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-end: "$" +# End: diff --git a/Quantum Controller/SW/testapplication-0.0.1/digital_test.c b/Quantum Controller/SW/testapplication-0.0.1/digital_test.c new file mode 100644 index 0000000..040ebc7 --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/digital_test.c @@ -0,0 +1 @@ +/* --------------------------------------------------------------------------- * digital_test.c (c) 2008 Micro-key bv * --------------------------------------------------------------------------- * Micro-key bv * Industrieweg 28, 9804 TG Noordhorn * Postbus 92, 9800 AB Zuidhorn * The Netherlands * Tel: +31 594 503020 * Fax: +31 594 505825 * Email: support@microkey.nl * Web: www.microkey.nl * --------------------------------------------------------------------------- * Description: Test file for the digital connections * --------------------------------------------------------------------------- * Version(s): 0.1, Dez 11, 2008, MMi * Creation. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * System include files * --------------------------------------------------------------------------- */ #include #include #include #include /* --------------------------------------------------------------------------- * Application include files * --------------------------------------------------------------------------- */ #include "digital_test.h" #include "smc4000io.h" #include "BusProtocol.h" #include "protocolfunctions.h" /* --------------------------------------------------------------------------- * Local constant and macro definitions * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Global variable definitions * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Local variable definitions * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Local function definitions * --------------------------------------------------------------------------- */ void digitalWrite (UINT8 senderId, UINT8 targetId, UINT8 requestNr, UINT8 functionId, UINT8 nrOfParams, UINT32 *params) { /* nrOfParams = 2 * params[0]: digital output channel number * params[1]: digital output value (0: LOW, !0: HIGH) */ int result; UINT32 channel; UINT16 doutValue; printf ("\nCalled function: digitalWrite\n"); printf ("params[0]: %i\n", params[0]); printf ("params[1]: %i\n", params[1]); channel = params[0]; if (params[1] != 0) { params[1] = 1; } if (channel < NUMBEROFDO_MB) { /* Channel is located in mainboard */ din0_7Read (IOCTL_interface, & doutValue); /* Get actual DoutValue */ doutValue &=~(1 << channel); /* Reset channel bit to Zero */ doutValue |= (params[1] << channel);/* Set channel bit */ /* Write built Bitmask to IO-Control Processor */ result = dout0_15Write (IOCTL_interface, & doutValue); } else if ((channel >= NUMBEROFDO_MB) && (channel < NUMBEROFTOTALDO)) { /* Channel is located in extensionboard */ dinext0_3Read (IOCTL_interface, &doutValue); doutValue &=~(1 << channel); /* Reset channel bit to Zero */ doutValue |= (params[1] << channel);/* Set channel bit */ /* Write built Bitmask to IO-Control Processor */ result = doutext0_3Write (IOCTL_interface, & doutValue); } /* Release digital semaphore on calling device with result function */ bpSendRpcResult(bushandler, REMOTEDEVICENUMBER, 20, 1, 0, NULL); printf ("dout_Write returned: %d\n", result); } void digitalWriteAll (UINT8 senderId, UINT8 targetId, UINT8 requestNr, UINT8 functionId, UINT8 nrOfParams, UINT32 *params) { /* nrOfParams = 2 * params[0]: board type (0: MB, 1: EB) * params[1]: digital output value (0: LOW, !0: HIGH) */ int result; UINT16 doutValue = 9; if (params[1] == 0) { /* All effected Outputs should be written to LOW */ doutValue = 0x0000; } else if (params[1] == 1) { /* All effected Outputs should be written to HIGH */ doutValue = 0x00FF; printf ("params[1] recognised as 1"); } if (params[0] == 0) { /* Maindboard Outputs should be effected */ result = dout0_15Write (IOCTL_interface, & doutValue); } else if (params[0] == 1) { /* Extensionboard Outputs should be effected */ result = doutext0_3Write (IOCTL_interface, & doutValue); } /* Release digital semaphore on calling device with result function */ bpSendRpcResult(bushandler, REMOTEDEVICENUMBER, 20, 1, 0, NULL); printf ("dout_Write returned: %d\n", result); } void digitalRead (UINT8 senderId, UINT8 targetId, UINT8 requestNr, UINT8 functionId, UINT8 nrOfParams, UINT32 *params) { int result; INT32 dioReadResult; UINT32 channel; UINT16 doutValue; /* nrOfParams = 1 * params[0]: digital input channel number */ channel = params[0]; printf ("\nCalled function: digitalRead\n"); if (channel < NUMBEROFDI_MB) { /* work on digital input of Mainboard */ result = din0_7Read (IOCTL_interface, & doutValue); printf ("digital read: %h\n", doutValue); dioReadResult = (doutValue & (0x0000 | (1 << channel))); } else if ((channel >= NUMBEROFDI_MB) && (channel < NUMBEROFTOTALDI)) { /* Work on digital input of Extensionboard */ result = doutext0_3Write (IOCTL_interface, & doutValue); printf ("digital read: %h\n", doutValue); } printf ("dout_Write returned: %d\n", result); bpSendRpcResult(bushandler, MASTERDEVICENUMBER, 11, 1, 1, &dioReadResult); } void digitalReadAll (UINT8 senderId, UINT8 targetId, UINT8 requestNr, UINT8 functionId, UINT8 nrOfParams, UINT32 *params) { /* nrOfParams = 1 * params[0]: board type (0: MB, 1: EB) */ int result; UINT32 doutValue[2]; UINT8 channelcnt; printf ("Called function: digitalReadAll\n"); printf ("params[0]: %i\n", params[0]); fflush( stdout ); if (params[0] == 0) { doutValue[0] = params[0]; result = din0_7Read (IOCTL_interface, & doutValue[1]); printf ("digital read: %x\n", doutValue[1]); } else if (params[0] == 1) { doutValue[0] = params[0]; result = doutext0_3Write (IOCTL_interface, & doutValue[1]); printf ("digital read: %x\n", doutValue[1]); } printf ("digitalReadAll returned: %d\n", result); bpSendRpcResult(bushandler, REMOTEDEVICENUMBER, 13, 1, 2, &doutValue); } void digitalMB_test_execute (void) { printf ("THIS IS THE DIGITAL TEST SEQUENCE"); } void digitalEB_test_execute (void) { printf ("THIS IS THE DIGITAL TEST SEQUENCE"); } \ No newline at end of file diff --git a/Quantum Controller/SW/testapplication-0.0.1/digital_test.h b/Quantum Controller/SW/testapplication-0.0.1/digital_test.h new file mode 100644 index 0000000..0809398 --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/digital_test.h @@ -0,0 +1 @@ +/* --------------------------------------------------------------------------- * digital_test.h (c) 2008 Micro-key bv * --------------------------------------------------------------------------- * Micro-key bv * Industrieweg 28, 9804 TG Noordhorn * Postbus 92, 9800 AB Zuidhorn * The Netherlands * Tel: +31 594 503020 * Fax: +31 594 505825 * Email: support@microkey.nl * Web: www.microkey.nl * --------------------------------------------------------------------------- * Description: * --------------------------------------------------------------------------- * Version(s): 0.1, Dez 11, 2008, MMi * Creation. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * System include files. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Application include files. * --------------------------------------------------------------------------- */ #include "BusProtocol.h" /* --------------------------------------------------------------------------- * Constant and macro definitions. * --------------------------------------------------------------------------- */ #define NUMBEROFDI_MB 8 #define NUMBEROFDO_MB 8 #define NUMBEROFDI_EB 4 #define NUMBEROFDO_EB 4 #define NUMBEROFTOTALDI (NUMBEROFDI_MB + NUMBEROFDI_EB) #define NUMBEROFTOTALDO (NUMBEROFDO_MB + NUMBEROFDO_EB) /* --------------------------------------------------------------------------- * Type definitions. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Variable declarations. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Function declarations. * --------------------------------------------------------------------------- */ void digitalWrite (UINT8 senderId, UINT8 targetId, UINT8 requestNr, UINT8 functionId, UINT8 nrOfParams, UINT32 *params); void digitalWriteAll (UINT8 senderId, UINT8 targetId, UINT8 requestNr, UINT8 functionId, UINT8 nrOfParams, UINT32 *params); void digitalRead (UINT8 senderId, UINT8 targetId, UINT8 requestNr, UINT8 functionId, UINT8 nrOfParams, UINT32 *params); void digitalReadAll (UINT8 senderId, UINT8 targetId, UINT8 requestNr, UINT8 functionId, UINT8 nrOfParams, UINT32 *params); void digitalMB_test_execute (void); void digitalEB_test_execute (void); \ No newline at end of file diff --git a/Quantum Controller/SW/testapplication-0.0.1/ethernet_test.c b/Quantum Controller/SW/testapplication-0.0.1/ethernet_test.c new file mode 100644 index 0000000..ec978e8 --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/ethernet_test.c @@ -0,0 +1 @@ +/* --------------------------------------------------------------------------- * ethernet_test.c (c) 2008 Micro-key bv * --------------------------------------------------------------------------- * Micro-key bv * Industrieweg 28, 9804 TG Noordhorn * Postbus 92, 9800 AB Zuidhorn * The Netherlands * Tel: +31 594 503020 * Fax: +31 594 505825 * Email: support@microkey.nl * Web: www.microkey.nl * --------------------------------------------------------------------------- * Description: * --------------------------------------------------------------------------- * Version(s): 0.1, Dez 11, 2008, MMi * Creation. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * System include files * --------------------------------------------------------------------------- */ #include /* --------------------------------------------------------------------------- * Application include files * --------------------------------------------------------------------------- */ #include "ethernet_test.h" /* --------------------------------------------------------------------------- * Local constant and macro definitions * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Global variable definitions * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Local variable definitions * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Local function definitions * --------------------------------------------------------------------------- */ void ethernet_test_execute (void) { printf ("THIS IS THE ETHERNET TEST SEQUENCE"); } \ No newline at end of file diff --git a/Quantum Controller/SW/testapplication-0.0.1/ethernet_test.h b/Quantum Controller/SW/testapplication-0.0.1/ethernet_test.h new file mode 100644 index 0000000..4a40404 --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/ethernet_test.h @@ -0,0 +1 @@ +/* --------------------------------------------------------------------------- * ethernet_test.h (c) 2008 Micro-key bv * --------------------------------------------------------------------------- * Micro-key bv * Industrieweg 28, 9804 TG Noordhorn * Postbus 92, 9800 AB Zuidhorn * The Netherlands * Tel: +31 594 503020 * Fax: +31 594 505825 * Email: support@microkey.nl * Web: www.microkey.nl * --------------------------------------------------------------------------- * Description: * --------------------------------------------------------------------------- * Version(s): 0.1, Dez 11, 2008, MMi * Creation. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * System include files. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Application include files. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Constant and macro definitions. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Type definitions. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Variable declarations. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Function declarations. * --------------------------------------------------------------------------- */ void ethernet_test_execute (void); \ No newline at end of file diff --git a/Quantum Controller/SW/testapplication-0.0.1/install-sh b/Quantum Controller/SW/testapplication-0.0.1/install-sh new file mode 100644 index 0000000..a5897de --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/install-sh @@ -0,0 +1,519 @@ +#!/bin/sh +# install - install a program, script, or datafile + +scriptversion=2006-12-25.00 + +# This originates from X11R5 (mit/util/scripts/install.sh), which was +# later released in X11R6 (xc/config/util/install.sh) with the +# following copyright and license. +# +# Copyright (C) 1994 X Consortium +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- +# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# +# Except as contained in this notice, the name of the X Consortium shall not +# be used in advertising or otherwise to promote the sale, use or other deal- +# ings in this Software without prior written authorization from the X Consor- +# tium. +# +# +# FSF changes to this file are in the public domain. +# +# Calling this script install-sh is preferred over install.sh, to prevent +# `make' implicit rules from creating a file called install from it +# when there is no Makefile. +# +# This script is compatible with the BSD install script, but was written +# from scratch. + +nl=' +' +IFS=" "" $nl" + +# set DOITPROG to echo to test this script + +# Don't use :- since 4.3BSD and earlier shells don't like it. +doit=${DOITPROG-} +if test -z "$doit"; then + doit_exec=exec +else + doit_exec=$doit +fi + +# Put in absolute file names if you don't have them in your path; +# or use environment vars. + +chgrpprog=${CHGRPPROG-chgrp} +chmodprog=${CHMODPROG-chmod} +chownprog=${CHOWNPROG-chown} +cmpprog=${CMPPROG-cmp} +cpprog=${CPPROG-cp} +mkdirprog=${MKDIRPROG-mkdir} +mvprog=${MVPROG-mv} +rmprog=${RMPROG-rm} +stripprog=${STRIPPROG-strip} + +posix_glob='?' +initialize_posix_glob=' + test "$posix_glob" != "?" || { + if (set -f) 2>/dev/null; then + posix_glob= + else + posix_glob=: + fi + } +' + +posix_mkdir= + +# Desired mode of installed file. +mode=0755 + +chgrpcmd= +chmodcmd=$chmodprog +chowncmd= +mvcmd=$mvprog +rmcmd="$rmprog -f" +stripcmd= + +src= +dst= +dir_arg= +dst_arg= + +copy_on_change=false +no_target_directory= + +usage="\ +Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE + or: $0 [OPTION]... SRCFILES... DIRECTORY + or: $0 [OPTION]... -t DIRECTORY SRCFILES... + or: $0 [OPTION]... -d DIRECTORIES... + +In the 1st form, copy SRCFILE to DSTFILE. +In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. +In the 4th, create DIRECTORIES. + +Options: + --help display this help and exit. + --version display version info and exit. + + -c (ignored) + -C install only if different (preserve the last data modification time) + -d create directories instead of installing files. + -g GROUP $chgrpprog installed files to GROUP. + -m MODE $chmodprog installed files to MODE. + -o USER $chownprog installed files to USER. + -s $stripprog installed files. + -t DIRECTORY install into DIRECTORY. + -T report an error if DSTFILE is a directory. + +Environment variables override the default commands: + CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG + RMPROG STRIPPROG +" + +while test $# -ne 0; do + case $1 in + -c) ;; + + -C) copy_on_change=true;; + + -d) dir_arg=true;; + + -g) chgrpcmd="$chgrpprog $2" + shift;; + + --help) echo "$usage"; exit $?;; + + -m) mode=$2 + case $mode in + *' '* | *' '* | *' +'* | *'*'* | *'?'* | *'['*) + echo "$0: invalid mode: $mode" >&2 + exit 1;; + esac + shift;; + + -o) chowncmd="$chownprog $2" + shift;; + + -s) stripcmd=$stripprog;; + + -t) dst_arg=$2 + shift;; + + -T) no_target_directory=true;; + + --version) echo "$0 $scriptversion"; exit $?;; + + --) shift + break;; + + -*) echo "$0: invalid option: $1" >&2 + exit 1;; + + *) break;; + esac + shift +done + +if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then + # When -d is used, all remaining arguments are directories to create. + # When -t is used, the destination is already specified. + # Otherwise, the last argument is the destination. Remove it from $@. + for arg + do + if test -n "$dst_arg"; then + # $@ is not empty: it contains at least $arg. + set fnord "$@" "$dst_arg" + shift # fnord + fi + shift # arg + dst_arg=$arg + done +fi + +if test $# -eq 0; then + if test -z "$dir_arg"; then + echo "$0: no input file specified." >&2 + exit 1 + fi + # It's OK to call `install-sh -d' without argument. + # This can happen when creating conditional directories. + exit 0 +fi + +if test -z "$dir_arg"; then + trap '(exit $?); exit' 1 2 13 15 + + # Set umask so as not to create temps with too-generous modes. + # However, 'strip' requires both read and write access to temps. + case $mode in + # Optimize common cases. + *644) cp_umask=133;; + *755) cp_umask=22;; + + *[0-7]) + if test -z "$stripcmd"; then + u_plus_rw= + else + u_plus_rw='% 200' + fi + cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; + *) + if test -z "$stripcmd"; then + u_plus_rw= + else + u_plus_rw=,u+rw + fi + cp_umask=$mode$u_plus_rw;; + esac +fi + +for src +do + # Protect names starting with `-'. + case $src in + -*) src=./$src;; + esac + + if test -n "$dir_arg"; then + dst=$src + dstdir=$dst + test -d "$dstdir" + dstdir_status=$? + else + + # Waiting for this to be detected by the "$cpprog $src $dsttmp" command + # might cause directories to be created, which would be especially bad + # if $src (and thus $dsttmp) contains '*'. + if test ! -f "$src" && test ! -d "$src"; then + echo "$0: $src does not exist." >&2 + exit 1 + fi + + if test -z "$dst_arg"; then + echo "$0: no destination specified." >&2 + exit 1 + fi + + dst=$dst_arg + # Protect names starting with `-'. + case $dst in + -*) dst=./$dst;; + esac + + # If destination is a directory, append the input filename; won't work + # if double slashes aren't ignored. + if test -d "$dst"; then + if test -n "$no_target_directory"; then + echo "$0: $dst_arg: Is a directory" >&2 + exit 1 + fi + dstdir=$dst + dst=$dstdir/`basename "$src"` + dstdir_status=0 + else + # Prefer dirname, but fall back on a substitute if dirname fails. + dstdir=` + (dirname "$dst") 2>/dev/null || + expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$dst" : 'X\(//\)[^/]' \| \ + X"$dst" : 'X\(//\)$' \| \ + X"$dst" : 'X\(/\)' \| . 2>/dev/null || + echo X"$dst" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q' + ` + + test -d "$dstdir" + dstdir_status=$? + fi + fi + + obsolete_mkdir_used=false + + if test $dstdir_status != 0; then + case $posix_mkdir in + '') + # Create intermediate dirs using mode 755 as modified by the umask. + # This is like FreeBSD 'install' as of 1997-10-28. + umask=`umask` + case $stripcmd.$umask in + # Optimize common cases. + *[2367][2367]) mkdir_umask=$umask;; + .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; + + *[0-7]) + mkdir_umask=`expr $umask + 22 \ + - $umask % 100 % 40 + $umask % 20 \ + - $umask % 10 % 4 + $umask % 2 + `;; + *) mkdir_umask=$umask,go-w;; + esac + + # With -d, create the new directory with the user-specified mode. + # Otherwise, rely on $mkdir_umask. + if test -n "$dir_arg"; then + mkdir_mode=-m$mode + else + mkdir_mode= + fi + + posix_mkdir=false + case $umask in + *[123567][0-7][0-7]) + # POSIX mkdir -p sets u+wx bits regardless of umask, which + # is incompatible with FreeBSD 'install' when (umask & 300) != 0. + ;; + *) + tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ + trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 + + if (umask $mkdir_umask && + exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 + then + if test -z "$dir_arg" || { + # Check for POSIX incompatibilities with -m. + # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or + # other-writeable bit of parent directory when it shouldn't. + # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. + ls_ld_tmpdir=`ls -ld "$tmpdir"` + case $ls_ld_tmpdir in + d????-?r-*) different_mode=700;; + d????-?--*) different_mode=755;; + *) false;; + esac && + $mkdirprog -m$different_mode -p -- "$tmpdir" && { + ls_ld_tmpdir_1=`ls -ld "$tmpdir"` + test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" + } + } + then posix_mkdir=: + fi + rmdir "$tmpdir/d" "$tmpdir" + else + # Remove any dirs left behind by ancient mkdir implementations. + rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null + fi + trap '' 0;; + esac;; + esac + + if + $posix_mkdir && ( + umask $mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" + ) + then : + else + + # The umask is ridiculous, or mkdir does not conform to POSIX, + # or it failed possibly due to a race condition. Create the + # directory the slow way, step by step, checking for races as we go. + + case $dstdir in + /*) prefix='/';; + -*) prefix='./';; + *) prefix='';; + esac + + eval "$initialize_posix_glob" + + oIFS=$IFS + IFS=/ + $posix_glob set -f + set fnord $dstdir + shift + $posix_glob set +f + IFS=$oIFS + + prefixes= + + for d + do + test -z "$d" && continue + + prefix=$prefix$d + if test -d "$prefix"; then + prefixes= + else + if $posix_mkdir; then + (umask=$mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break + # Don't fail if two instances are running concurrently. + test -d "$prefix" || exit 1 + else + case $prefix in + *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; + *) qprefix=$prefix;; + esac + prefixes="$prefixes '$qprefix'" + fi + fi + prefix=$prefix/ + done + + if test -n "$prefixes"; then + # Don't fail if two instances are running concurrently. + (umask $mkdir_umask && + eval "\$doit_exec \$mkdirprog $prefixes") || + test -d "$dstdir" || exit 1 + obsolete_mkdir_used=true + fi + fi + fi + + if test -n "$dir_arg"; then + { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && + { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && + { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || + test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 + else + + # Make a couple of temp file names in the proper directory. + dsttmp=$dstdir/_inst.$$_ + rmtmp=$dstdir/_rm.$$_ + + # Trap to clean up those temp files at exit. + trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 + + # Copy the file name to the temp name. + (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && + + # and set any options; do chmod last to preserve setuid bits. + # + # If any of these fail, we abort the whole thing. If we want to + # ignore errors from any of these, just make sure not to ignore + # errors from the above "$doit $cpprog $src $dsttmp" command. + # + { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && + { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && + { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && + { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && + + # If -C, don't bother to copy if it wouldn't change the file. + if $copy_on_change && + old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && + new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && + + eval "$initialize_posix_glob" && + $posix_glob set -f && + set X $old && old=:$2:$4:$5:$6 && + set X $new && new=:$2:$4:$5:$6 && + $posix_glob set +f && + + test "$old" = "$new" && + $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 + then + rm -f "$dsttmp" + else + # Rename the file to the real destination. + $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || + + # The rename failed, perhaps because mv can't rename something else + # to itself, or perhaps because mv is so ancient that it does not + # support -f. + { + # Now remove or move aside any old file at destination location. + # We try this two ways since rm can't unlink itself on some + # systems and the destination file might be busy for other + # reasons. In this case, the final cleanup might fail but the new + # file should still install successfully. + { + test ! -f "$dst" || + $doit $rmcmd -f "$dst" 2>/dev/null || + { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && + { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } + } || + { echo "$0: cannot unlink or rename $dst" >&2 + (exit 1); exit 1 + } + } && + + # Now rename the file to the real destination. + $doit $mvcmd "$dsttmp" "$dst" + } + fi || exit 1 + + trap '' 0 + fi +done + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-end: "$" +# End: diff --git a/Quantum Controller/SW/testapplication-0.0.1/main.c b/Quantum Controller/SW/testapplication-0.0.1/main.c new file mode 100644 index 0000000..56b27ce --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/main.c @@ -0,0 +1,88 @@ +/* --------------------------------------------------------------------------- + * main.c (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: main file to QUA_2475 Test application + * --------------------------------------------------------------------------- + * Version(s): 0.1, Dez 11, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +#include +#include +#include +#include + + + +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "bus.h" +#include "BusProtocol.h" +#include "protocolfunctions.h" + +#include "digital_test.h" +#include "smc4000io.h" +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ + +int main() +{ + int result; + UINT16 testdata; + + IO_CPU_Init(); + + testdata = 1; + pwrrelmbWrite (IOCTL_interface, & testdata); + printf ("dout_Write returned: %d\n", result); + testdata = 0xFF; + dout0_15Write (IOCTL_interface, & testdata); + printf ("dout_Write returned: %d\n", result); + + // /* Initialisation section */ + protocolInit(THISDEVICENUMBER, MAXDEVICENUMBER); + + for (;;) + { + // printf ("Hallo\n"); + fflush( stdout ); + usleep ( 1000 ); + } + + return 0; +} + + diff --git a/Quantum Controller/SW/testapplication-0.0.1/mem_mod.c b/Quantum Controller/SW/testapplication-0.0.1/mem_mod.c new file mode 100644 index 0000000..65feeb6 --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/mem_mod.c @@ -0,0 +1,88 @@ +#include +#include "BpPort.h" +#include "mem_mod.h" + + +extern void serWrite ( + int device, + short length, /**< Lengh of data in bytes */ + char * data /**< Pointer to data */ +); + +void Memmod_Init(memman *me,unsigned char buf_count,unsigned short buf_size) +{ + unsigned char *buffer; + unsigned short i; + me->count = buf_count; + me->size = buf_size; + buffer = pvPortMalloc(buf_count*buf_size); + me->buffer = buffer; + me->free_index = buf_count; + me->freelist = pvPortMalloc(buf_count*sizeof(link_item)); + for(i=0;ifreelist[i].data = buffer; + buffer = buffer+buf_size; + } + + pthread_mutex_init(&(me->mutex), NULL); +} + +unsigned char* Memmod_GetBuffer(memman *me) +{ + return me->buffer; +} + +memman *Memmod_Create(unsigned char buf_count,unsigned short buf_size) +{ + memman *new_item; + new_item = (memman *)pvPortMalloc(sizeof(memman)); + Memmod_Init(new_item,buf_count,buf_size); + return new_item; +} + +void *Memmod_Alloc(memman *me) +{ + unsigned char index; + void *retval; + + pthread_mutex_lock(&(me->mutex)); + { + index = me->free_index; + if(index > 0) + { + index--; + me->free_index=index; + retval = me->freelist[index].data; + } + else + { + retval = 0; + } + } + pthread_mutex_unlock(&(me->mutex)); + + if (retval == 0) + { + printf("mem_mod.c> no buffer available\n"); fflush(stdout); + } + + return retval; +} + +void Memmod_Free(memman *me,void *buffer) +{ + unsigned char index; + + pthread_mutex_lock(&(me->mutex)); + { + index = me->free_index; + if(index < me->count) + { + me->freelist[index].data = buffer; + index++; + me->free_index=index; + } + } + pthread_mutex_unlock(&(me->mutex)); +} diff --git a/Quantum Controller/SW/testapplication-0.0.1/mem_mod.h b/Quantum Controller/SW/testapplication-0.0.1/mem_mod.h new file mode 100644 index 0000000..59d274b --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/mem_mod.h @@ -0,0 +1,35 @@ +#ifndef _MEM_MODH +#define _MEM_MODH + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +typedef struct link_item +{ + void *data; +} link_item; + +typedef struct +{ + unsigned char count; + unsigned char size; + unsigned char free_index; + void *buffer; + link_item *freelist; + pthread_mutex_t mutex; +} memman; + +void Memmod_Init(memman *me,unsigned char buf_count,unsigned short buf_size); +memman *Memmod_Create(unsigned char buf_count,unsigned short buf_size); +unsigned char* Memmod_GetBuffer(memman *me); +void *Memmod_Alloc(memman *me); +void Memmod_Free(memman *me,void *buffer); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/Quantum Controller/SW/testapplication-0.0.1/missing b/Quantum Controller/SW/testapplication-0.0.1/missing new file mode 100644 index 0000000..1c8ff70 --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/missing @@ -0,0 +1,367 @@ +#! /bin/sh +# Common stub for a few missing GNU programs while installing. + +scriptversion=2006-05-10.23 + +# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006 +# Free Software Foundation, Inc. +# Originally by Fran,cois Pinard , 1996. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +if test $# -eq 0; then + echo 1>&2 "Try \`$0 --help' for more information" + exit 1 +fi + +run=: +sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p' +sed_minuso='s/.* -o \([^ ]*\).*/\1/p' + +# In the cases where this matters, `missing' is being run in the +# srcdir already. +if test -f configure.ac; then + configure_ac=configure.ac +else + configure_ac=configure.in +fi + +msg="missing on your system" + +case $1 in +--run) + # Try to run requested program, and just exit if it succeeds. + run= + shift + "$@" && exit 0 + # Exit code 63 means version mismatch. This often happens + # when the user try to use an ancient version of a tool on + # a file that requires a minimum version. In this case we + # we should proceed has if the program had been absent, or + # if --run hadn't been passed. + if test $? = 63; then + run=: + msg="probably too old" + fi + ;; + + -h|--h|--he|--hel|--help) + echo "\ +$0 [OPTION]... PROGRAM [ARGUMENT]... + +Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an +error status if there is no known handling for PROGRAM. + +Options: + -h, --help display this help and exit + -v, --version output version information and exit + --run try to run the given command, and emulate it if it fails + +Supported PROGRAM values: + aclocal touch file \`aclocal.m4' + autoconf touch file \`configure' + autoheader touch file \`config.h.in' + autom4te touch the output file, or create a stub one + automake touch all \`Makefile.in' files + bison create \`y.tab.[ch]', if possible, from existing .[ch] + flex create \`lex.yy.c', if possible, from existing .c + help2man touch the output file + lex create \`lex.yy.c', if possible, from existing .c + makeinfo touch the output file + tar try tar, gnutar, gtar, then tar without non-portable flags + yacc create \`y.tab.[ch]', if possible, from existing .[ch] + +Send bug reports to ." + exit $? + ;; + + -v|--v|--ve|--ver|--vers|--versi|--versio|--version) + echo "missing $scriptversion (GNU Automake)" + exit $? + ;; + + -*) + echo 1>&2 "$0: Unknown \`$1' option" + echo 1>&2 "Try \`$0 --help' for more information" + exit 1 + ;; + +esac + +# Now exit if we have it, but it failed. Also exit now if we +# don't have it and --version was passed (most likely to detect +# the program). +case $1 in + lex|yacc) + # Not GNU programs, they don't have --version. + ;; + + tar) + if test -n "$run"; then + echo 1>&2 "ERROR: \`tar' requires --run" + exit 1 + elif test "x$2" = "x--version" || test "x$2" = "x--help"; then + exit 1 + fi + ;; + + *) + if test -z "$run" && ($1 --version) > /dev/null 2>&1; then + # We have it, but it failed. + exit 1 + elif test "x$2" = "x--version" || test "x$2" = "x--help"; then + # Could not run --version or --help. This is probably someone + # running `$TOOL --version' or `$TOOL --help' to check whether + # $TOOL exists and not knowing $TOOL uses missing. + exit 1 + fi + ;; +esac + +# If it does not exist, or fails to run (possibly an outdated version), +# try to emulate it. +case $1 in + aclocal*) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`acinclude.m4' or \`${configure_ac}'. You might want + to install the \`Automake' and \`Perl' packages. Grab them from + any GNU archive site." + touch aclocal.m4 + ;; + + autoconf) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`${configure_ac}'. You might want to install the + \`Autoconf' and \`GNU m4' packages. Grab them from any GNU + archive site." + touch configure + ;; + + autoheader) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`acconfig.h' or \`${configure_ac}'. You might want + to install the \`Autoconf' and \`GNU m4' packages. Grab them + from any GNU archive site." + files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` + test -z "$files" && files="config.h" + touch_files= + for f in $files; do + case $f in + *:*) touch_files="$touch_files "`echo "$f" | + sed -e 's/^[^:]*://' -e 's/:.*//'`;; + *) touch_files="$touch_files $f.in";; + esac + done + touch $touch_files + ;; + + automake*) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. + You might want to install the \`Automake' and \`Perl' packages. + Grab them from any GNU archive site." + find . -type f -name Makefile.am -print | + sed 's/\.am$/.in/' | + while read f; do touch "$f"; done + ;; + + autom4te) + echo 1>&2 "\ +WARNING: \`$1' is needed, but is $msg. + You might have modified some files without having the + proper tools for further handling them. + You can get \`$1' as part of \`Autoconf' from any GNU + archive site." + + file=`echo "$*" | sed -n "$sed_output"` + test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` + if test -f "$file"; then + touch $file + else + test -z "$file" || exec >$file + echo "#! /bin/sh" + echo "# Created by GNU Automake missing as a replacement of" + echo "# $ $@" + echo "exit 0" + chmod +x $file + exit 1 + fi + ;; + + bison|yacc) + echo 1>&2 "\ +WARNING: \`$1' $msg. You should only need it if + you modified a \`.y' file. You may need the \`Bison' package + in order for those modifications to take effect. You can get + \`Bison' from any GNU archive site." + rm -f y.tab.c y.tab.h + if test $# -ne 1; then + eval LASTARG="\${$#}" + case $LASTARG in + *.y) + SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` + if test -f "$SRCFILE"; then + cp "$SRCFILE" y.tab.c + fi + SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` + if test -f "$SRCFILE"; then + cp "$SRCFILE" y.tab.h + fi + ;; + esac + fi + if test ! -f y.tab.h; then + echo >y.tab.h + fi + if test ! -f y.tab.c; then + echo 'main() { return 0; }' >y.tab.c + fi + ;; + + lex|flex) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified a \`.l' file. You may need the \`Flex' package + in order for those modifications to take effect. You can get + \`Flex' from any GNU archive site." + rm -f lex.yy.c + if test $# -ne 1; then + eval LASTARG="\${$#}" + case $LASTARG in + *.l) + SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` + if test -f "$SRCFILE"; then + cp "$SRCFILE" lex.yy.c + fi + ;; + esac + fi + if test ! -f lex.yy.c; then + echo 'main() { return 0; }' >lex.yy.c + fi + ;; + + help2man) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified a dependency of a manual page. You may need the + \`Help2man' package in order for those modifications to take + effect. You can get \`Help2man' from any GNU archive site." + + file=`echo "$*" | sed -n "$sed_output"` + test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` + if test -f "$file"; then + touch $file + else + test -z "$file" || exec >$file + echo ".ab help2man is required to generate this page" + exit 1 + fi + ;; + + makeinfo) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified a \`.texi' or \`.texinfo' file, or any other file + indirectly affecting the aspect of the manual. The spurious + call might also be the consequence of using a buggy \`make' (AIX, + DU, IRIX). You might want to install the \`Texinfo' package or + the \`GNU make' package. Grab either from any GNU archive site." + # The file to touch is that specified with -o ... + file=`echo "$*" | sed -n "$sed_output"` + test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` + if test -z "$file"; then + # ... or it is the one specified with @setfilename ... + infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` + file=`sed -n ' + /^@setfilename/{ + s/.* \([^ ]*\) *$/\1/ + p + q + }' $infile` + # ... or it is derived from the source name (dir/f.texi becomes f.info) + test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info + fi + # If the file does not exist, the user really needs makeinfo; + # let's fail without touching anything. + test -f $file || exit 1 + touch $file + ;; + + tar) + shift + + # We have already tried tar in the generic part. + # Look for gnutar/gtar before invocation to avoid ugly error + # messages. + if (gnutar --version > /dev/null 2>&1); then + gnutar "$@" && exit 0 + fi + if (gtar --version > /dev/null 2>&1); then + gtar "$@" && exit 0 + fi + firstarg="$1" + if shift; then + case $firstarg in + *o*) + firstarg=`echo "$firstarg" | sed s/o//` + tar "$firstarg" "$@" && exit 0 + ;; + esac + case $firstarg in + *h*) + firstarg=`echo "$firstarg" | sed s/h//` + tar "$firstarg" "$@" && exit 0 + ;; + esac + fi + + echo 1>&2 "\ +WARNING: I can't seem to be able to run \`tar' with the given arguments. + You may want to install GNU tar or Free paxutils, or check the + command line arguments." + exit 1 + ;; + + *) + echo 1>&2 "\ +WARNING: \`$1' is needed, and is $msg. + You might have modified some files without having the + proper tools for further handling them. Check the \`README' file, + it often tells you about the needed prerequisites for installing + this package. You may also peek at any GNU archive site, in case + some other package would contain this missing \`$1' program." + exit 1 + ;; +esac + +exit 0 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-end: "$" +# End: diff --git a/Quantum Controller/SW/testapplication-0.0.1/protocolfunctions.c b/Quantum Controller/SW/testapplication-0.0.1/protocolfunctions.c new file mode 100644 index 0000000..7ced80e --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/protocolfunctions.c @@ -0,0 +1,232 @@ +/* --------------------------------------------------------------------------- + * protocolfunctions. (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: collection of protocol-depending functions and + initialisations + * --------------------------------------------------------------------------- + * Version(s): 0.1, Dez 11, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +#include +#include +#include +#include +#include + +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "bus.h" +#include "BusProtocol.h" +#include "protocolfunctions.h" + +/* testfile includes */ +#include "analogue_test.h" +#include "BUS_test.h" +#include "CAN_test.h" +#include "CF_test.h" +#include "digital_test.h" +#include "EEPROM_test.h" +#include "ethernet_test.h" +#include "LED_test.h" +#include "relay_test.h" +#include "USB_test.h" +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ +static int sigio_interrupt = 0; +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ + +void protocolInit (UINT32 DEV_ID, UINT32 MAX_ID) +{ + bushandler = bpInit( BUS1, THISDEVICENUMBER, MAXDEVICENUMBER, 20 ); + BUS_ATTACHED = TRUE; + + + /* Attach Handshake and Handshake return Functions to every device */ + bpAttachRpc (bushandler, 1, "Available BusID", (t_rpc_remote_procedure_call) availableBusID, 0); + bpAttachRpcResult(bushandler, 1, (t_bp_rpcresult_callback) generalResultFunction, 0); + + if (THISDEVICENUMBER == MASTERDEVICENUMBER) + { + /* This device is Master, attach Master functions to Bus */ + } + + else if (THISDEVICENUMBER > MASTERDEVICENUMBER) + { + /* This device is slave, attach slave test functions to bus */ + /* Functions 0-9 are for general controlling options */ + bpAttachRpc (bushandler, 9, "Return attached functions", (t_rpc_remote_procedure_call) returnAttachedFunctions, 1); + + /* Functions 10-19 are for calibrations purpose */ + /* Functions 20-29 re for single channel in-/output driving */ + bpAttachRpc (bushandler, 20, "Digital write channel", (t_rpc_remote_procedure_call) digitalWrite, 2); + bpAttachRpc (bushandler, 21, "Digital write all", (t_rpc_remote_procedure_call) digitalWriteAll, 2); + bpAttachRpc (bushandler, 22, "Digital read channel", (t_rpc_remote_procedure_call) digitalRead, 1); + bpAttachRpc (bushandler, 23, "Digital read all", (t_rpc_remote_procedure_call) digitalReadAll, 1); + + bpAttachRpc (bushandler, 24, "Analogue write channel", (t_rpc_remote_procedure_call) analogueWrite, 2); + bpAttachRpc (bushandler, 25, "Analogue write all", (t_rpc_remote_procedure_call) analogueWriteAll, 2); + bpAttachRpc (bushandler, 26, "Analogue read channel", (t_rpc_remote_procedure_call) analogueRead, 1); + bpAttachRpc (bushandler, 27, "Analogue read all", (t_rpc_remote_procedure_call) analogueReadAll, 1); + + bpAttachRpc (bushandler, 28, "Relay set channel", (t_rpc_remote_procedure_call) relaySet, 1); + bpAttachRpc (bushandler, 29, "Relay set all", (t_rpc_remote_procedure_call) relaySetAll, 1); + + + /* Functions 30-49 are for single test sequences */ + bpAttachRpc (bushandler, 30, "AnalogueMB Test", (t_rpc_remote_procedure_call) analogueMB_test_execute, 0); + bpAttachRpc (bushandler, 31, "AnalogueEB Test", (t_rpc_remote_procedure_call) analogueEB_test_execute, 0); + bpAttachRpc (bushandler, 32, "BUS Test", (t_rpc_remote_procedure_call) bus_test_execute, 0); + bpAttachRpc (bushandler, 33, "CAN Test", (t_rpc_remote_procedure_call) can_test_execute, 0); + bpAttachRpc (bushandler, 34, "CF Test", (t_rpc_remote_procedure_call) cf_test_execute, 0); + bpAttachRpc (bushandler, 35, "digitalMB Test", (t_rpc_remote_procedure_call) digitalMB_test_execute, 2); + bpAttachRpc (bushandler, 36, "digitalEB Test", (t_rpc_remote_procedure_call) digitalEB_test_execute, 0); + bpAttachRpc (bushandler, 37, "EEPROM Test", (t_rpc_remote_procedure_call) eeprom_test_execute, 0); + bpAttachRpc (bushandler, 38, "ethernet Test", (t_rpc_remote_procedure_call) ethernet_test_execute, 0); + bpAttachRpc (bushandler, 39, "LED Test", (t_rpc_remote_procedure_call) led_test_execute, 0); + bpAttachRpc (bushandler, 40, "relayMB Test", (t_rpc_remote_procedure_call) relayMB_test_execute, 0); + bpAttachRpc (bushandler, 41, "relayEB Test", (t_rpc_remote_procedure_call) relayEB_test_execute, 0); + bpAttachRpc (bushandler, 42, "USB Test", (t_rpc_remote_procedure_call) usb_test_execute, 0); + /* Functions 50-59 are for miscellaneous purpose */ + } +} + + +void returnAttachedFunctions (UINT8 senderId, UINT8 targetId, UINT8 requestNr, + UINT8 functionId, UINT8 nrOfParams, UINT32 *params) +{ + UINT8 functioncnt = 0; + t_rpc_entity *lookupEntry; + + if (nrOfParams == 0) + { + while (functioncnt < 61) /* Currently 60 functions in */ + { + lookupEntry = bpLookupRpcEntry(bushandler, functioncnt); + if (lookupEntry != 0) + { + bpSendRpcResult (bushandler, REMOTEDEVICENUMBER, 9, 1, 1, (INT32 *) lookupEntry->functionName); + } + functioncnt++; + } + } + else + { + lookupEntry = bpLookupRpcEntry(bushandler, (UINT8) params); + + if (lookupEntry != NULL) + { + bpSendRpcResult (bushandler, REMOTEDEVICENUMBER, 9, 1, 1, (INT32 *) lookupEntry->functionName); + } + } +} + + +void availableBusID (UINT8 senderId, UINT8 targetId, UINT8 requestNr, + UINT8 functionId, UINT8 nrOfParams, UINT32 *params) +{ + /* Call Result Function to release Semaphore on Master */ + bpSendRpcResult(bushandler, 1, 1, 1, 0, NULL); +} + + +void generalResultFunction (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results) +{ + /* Release generalSemaphore on Call of this Function from the Master */ + // xSemaphoreGive (generalSemaphore); +} + + +void IO_CPU_Init (void) +{ + IOCTL_interface = -1; + + unsigned int oflags; + int err; + /* Install signal handler for the control+c signal. */ + signal(SIGINT,sigintHandler); + + /* Install signal handler for the SIGIO signal from the IO controller. */ + signal(SIGIO, sigintHandler); + + /* Open the interface with the IO controller. */ + IOCTL_interface = open("/dev/ioc", O_RDONLY); + if (IOCTL_interface == -1) + { + printf ("Failed to open IO controller (error %s)\n", + strerror(errno)); + } + + // /* Register this process' as SIGIO signal receiver from IO controller. */ + // if (fcntl(IOCTL_interface, F_SETOWN, getpid()) == -1) + // { + // printf ("Failed to F_SETOWN for IO controller (error %s)\n", + // strerror(errno)); + // } + + // /* Enable asynchronous notification. */ + // oflags = fcntl (IOCTL_interface, F_GETFL); + // if (fcntl(IOCTL_interface, F_SETFL, oflags | FASYNC) == -1) + // { + // printf ("Failed to F_SETFL for IO controller (error %s)\n", + // strerror(errno)); + // } +} + + +void appExit (int err) +{ + if (IOCTL_interface > 0) + { + close (IOCTL_interface); + } + exit (err); +} + +void sigintHandler (int s) +{ + switch (s) + { + case SIGINT: + printf("received SIGINT signal.\n"); + appExit (0); + break; + case SIGIO: + sigio_interrupt = 1; + break; + } +} + + + diff --git a/Quantum Controller/SW/testapplication-0.0.1/protocolfunctions.h b/Quantum Controller/SW/testapplication-0.0.1/protocolfunctions.h new file mode 100644 index 0000000..946bc2d --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/protocolfunctions.h @@ -0,0 +1,70 @@ +/* --------------------------------------------------------------------------- + * protocolfunctions.h (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Dez 11, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ +#include "bus.h" +#include "BusProtocol.h" +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ +#define MASTERDEVICENUMBER 1 +#define THISDEVICENUMBER 2 +#define REMOTEDEVICENUMBER 1 +#define MAXDEVICENUMBER 2 +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ +int bushandler; /* Bus system identifier */ +int IOCTL_interface; +BOOLEAN BUS_ATTACHED; +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ + +void protocolInit (UINT32 DEV_ID, UINT32 MAX_ID); + +void returnAttachedFunctions (UINT8 senderId, UINT8 targetId, UINT8 requestNr, + UINT8 functionId, UINT8 nrOfParams, UINT32 *params); + +void availableBusID (UINT8 senderId, UINT8 targetId, UINT8 requestNr, + UINT8 functionId, UINT8 nrOfParams, UINT32 *params); + +void generalResultFunction (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results); + +void IO_CPU_Init (void); + +void appExit (int err); + +void sigintHandler (int s); diff --git a/Quantum Controller/SW/testapplication-0.0.1/relay_test.c b/Quantum Controller/SW/testapplication-0.0.1/relay_test.c new file mode 100644 index 0000000..d8e121a --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/relay_test.c @@ -0,0 +1 @@ +/* --------------------------------------------------------------------------- * relay_test.c (c) 2008 Micro-key bv * --------------------------------------------------------------------------- * Micro-key bv * Industrieweg 28, 9804 TG Noordhorn * Postbus 92, 9800 AB Zuidhorn * The Netherlands * Tel: +31 594 503020 * Fax: +31 594 505825 * Email: support@microkey.nl * Web: www.microkey.nl * --------------------------------------------------------------------------- * Description: * --------------------------------------------------------------------------- * Version(s): 0.1, Dez 11, 2008, MMi * Creation. * --------------------------------------------------------------------------- */ /* Channel 0-3: Mainboard Relays; Channel 4-5: Extensionboard Relays */ /* --------------------------------------------------------------------------- * System include files * --------------------------------------------------------------------------- */ #include /* --------------------------------------------------------------------------- * Application include files * --------------------------------------------------------------------------- */ #include "relay_test.h" #include "smc4000io.h" #include "BusProtocol.h" #include "protocolfunctions.h" /* --------------------------------------------------------------------------- * Local constant and macro definitions * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Global variable definitions * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Local variable definitions * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Local function definitions * --------------------------------------------------------------------------- */ void relaySet (UINT8 senderId, UINT8 targetId, UINT8 requestNr, UINT8 functionId, UINT8 nrOfParams, UINT32 *params) { /* nrOfParams = 2 * params[0]: channel * params[1]: relay value (0: OFF, !0: ON) */ printf ("Called function: relaySet"); // WRITE VALUE } void relaySetAll (UINT8 senderId, UINT8 targetId, UINT8 requestNr, UINT8 functionId, UINT8 nrOfParams, UINT32 *params) { /* nrOfParams = 2 * params[0]: board type (0: MB, 1: EB) * params[1]: relay value (0: OFF, !0: ON) */ if (params[0] == 0) { // MAINBOARD } else if (params[0] == 1) { // EXTENSIONBOARD } printf ("Called function: relaySetAll"); /* Release relay semaphore on calling device with result function */ bpSendRpcResult(bushandler, REMOTEDEVICENUMBER, 22, 1, 0, NULL); } void relayMB_test_execute (void) { printf ("THIS IS THE RELAY TEST SEQUENCE"); } void relayEB_test_execute (void) { printf ("THIS IS THE RELAY TEST SEQUENCE"); } \ No newline at end of file diff --git a/Quantum Controller/SW/testapplication-0.0.1/relay_test.h b/Quantum Controller/SW/testapplication-0.0.1/relay_test.h new file mode 100644 index 0000000..3a1478c --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/relay_test.h @@ -0,0 +1 @@ +/* --------------------------------------------------------------------------- * relay_test.h (c) 2008 Micro-key bv * --------------------------------------------------------------------------- * Micro-key bv * Industrieweg 28, 9804 TG Noordhorn * Postbus 92, 9800 AB Zuidhorn * The Netherlands * Tel: +31 594 503020 * Fax: +31 594 505825 * Email: support@microkey.nl * Web: www.microkey.nl * --------------------------------------------------------------------------- * Description: * --------------------------------------------------------------------------- * Version(s): 0.1, Dez 11, 2008, MMi * Creation. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * System include files. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Application include files. * --------------------------------------------------------------------------- */ #include "BusProtocol.h" /* --------------------------------------------------------------------------- * Constant and macro definitions. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Type definitions. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Variable declarations. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Function declarations. * --------------------------------------------------------------------------- */ void relaySet (UINT8 senderId, UINT8 targetId, UINT8 requestNr, UINT8 functionId, UINT8 nrOfParams, UINT32 *params); void relaySetAll (UINT8 senderId, UINT8 targetId, UINT8 requestNr, UINT8 functionId, UINT8 nrOfParams, UINT32 *params); void relayMB_test_execute (void); void relayEB_test_execute (void); \ No newline at end of file diff --git a/Quantum Controller/SW/testapplication-0.0.1/smc4000io.c b/Quantum Controller/SW/testapplication-0.0.1/smc4000io.c new file mode 100644 index 0000000..d844e62 --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/smc4000io.c @@ -0,0 +1,228 @@ +/* --------------------------------------------------------------------------- + * smc4000io.c - v1.2 (c) 2007 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AA Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: SMC4000 IO functions. + * --------------------------------------------------------------------------- + * Version(s): 1.0, 31-07-2006, Henk Stegeman. + * Creation. + * 1.1, 12-10-2007, Jos Pasop. + * Added extenderboard support. + * 1.2, 27-11-2007, Jos Pasop. + * Added callibration tables for DAC. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ +#include +#include + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ +#include "types.h" +#include "smc4000io.h" + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions. + * --------------------------------------------------------------------------- + */ +#define AIN0_7 0x1 +#define AOUT0_5 0x2 +#define DIN0_7 0x3 +#define DOUT0_15 0x4 +#define REL0_5 0x5 +#define RTC 0x6 +#define VCC 0x7 +#define VCORE 0x8 +#define VDDAT 0x9 +#define VBAT 0xa +#define TEMP 0xb +#define REVNUM 0xc +#define EXTBOARD 0xd +#define DINEXT0_3 0xe +#define DOUTEXT0_3 0xf +#define PWRRELMB 0x10 +#define PWRRELEB 0x11 +#define AIN0_15 0x12 +#define AOUT0_11 0x13 +#define SERMB 0x14 +#define SEREB 0x15 +#define ADCCALMB 0x16 +#define ADCCALEB 0x17 +#define DACCALMB 0x18 +#define DACCALEB 0x19 + +#define READ_CMD(id) (id | 0x8000) +#define WRITE_CMD(id) (id) + +/* --------------------------------------------------------------------------- + * Local type definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Global variable definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local variable definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local function declarations. + * --------------------------------------------------------------------------- + */ +int ain0_7Read (int file, UINT16 * data) + { + return ioctl (file, READ_CMD(AIN0_7), data); + } + +int aout0_5Write (int file, UINT16 * data) + { + return ioctl (file, WRITE_CMD(AOUT0_5), data); + } + +int din0_7Read (int file, UINT16 * data) + { + return ioctl (file, READ_CMD(DIN0_7), data); + } + +int dout0_15Write (int file, UINT16 * data) + { + return ioctl (file, WRITE_CMD(DOUT0_15), data); + } + +int rel0_5Write (int file, UINT16 * data) + { + return ioctl (file, WRITE_CMD(REL0_5), data); + } + +int vccRead (int file, UINT16 * data) + { + return ioctl (file, READ_CMD(VCC), data); + } + +int vddatRead (int file, UINT16 * data) + { + return ioctl (file, READ_CMD(VDDAT), data); + } + +int vbatRead (int file, UINT16 * data) + { + return ioctl (file, READ_CMD(VBAT), data); + } + +int vcoreRead (int file, UINT16 * data) + { + return ioctl (file, READ_CMD(VCORE), data); + } + +int tempRead (int file, UINT16 * data) + { + return ioctl (file, READ_CMD(TEMP), data); + } + +int revnumRead (int file, UINT16 * data) + { + return ioctl (file, READ_CMD(REVNUM), data); + } + +int extboardRead (int file, UINT16 * data) + { + return ioctl (file, READ_CMD(EXTBOARD), data); + } + +int dinext0_3Read (int file, UINT16 * data) + { + return ioctl (file, READ_CMD(DINEXT0_3), data); + } + +int doutext0_3Write (int file, UINT16 * data) + { + return ioctl (file, WRITE_CMD(DOUTEXT0_3), data); + } + +int pwrrelmbWrite (int file, UINT16 * data) + { + return ioctl (file, WRITE_CMD(PWRRELMB), data); + } + +int pwrrelebWrite (int file, UINT16 * data) + { + return ioctl (file, WRITE_CMD(PWRRELEB), data); + } + +int ain0_15Read (int file, UINT16 * data) + { + return ioctl (file, READ_CMD(AIN0_15), data); + } + +int aout0_11Write (int file, UINT16 * data) + { + return ioctl (file, WRITE_CMD(AOUT0_11), data); + } + +int sermbRead (int file, UINT16 * data) + { + return ioctl (file, READ_CMD(SERMB), data); + } + +int serebRead (int file, UINT16 * data) + { + return ioctl (file, READ_CMD(SEREB), data); + } + +int adccalmbRead (int file, CALIBRATION_VALUE_DESCR data []) + { + return ioctl (file, READ_CMD(ADCCALMB), (UINT16 * ) data); + } + +int adccalmbWrite (int file, CALIBRATION_VALUE_DESCR data []) + { + return ioctl (file, WRITE_CMD(ADCCALMB), (UINT16 * ) data); + } + +int adccalebRead (int file, CALIBRATION_VALUE_DESCR data []) + { + return ioctl (file, READ_CMD(ADCCALEB), (UINT16 *) data); + } + +int adccalebWrite (int file, CALIBRATION_VALUE_DESCR data []) + { + return ioctl (file, WRITE_CMD(ADCCALEB), (UINT16 *) data); + } + +int daccalmbRead (int file, CALIBRATION_VALUE_DESCR data []) + { + return ioctl (file, READ_CMD(DACCALMB), (UINT16 * ) data); + } + +int daccalmbWrite (int file, CALIBRATION_VALUE_DESCR data []) + { + return ioctl (file, WRITE_CMD(DACCALMB), (UINT16 * ) data); + } + +int daccalebRead (int file, CALIBRATION_VALUE_DESCR data []) + { + return ioctl (file, READ_CMD(DACCALEB), (UINT16 *) data); + } + +int daccalebWrite (int file, CALIBRATION_VALUE_DESCR data []) + { + return ioctl (file, WRITE_CMD(DACCALEB), (UINT16 *) data); + } diff --git a/Quantum Controller/SW/testapplication-0.0.1/smc4000io.h b/Quantum Controller/SW/testapplication-0.0.1/smc4000io.h new file mode 100644 index 0000000..6802236 --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/smc4000io.h @@ -0,0 +1,99 @@ +/* --------------------------------------------------------------------------- + * smc4000io.h - v1.2 (c) 2007 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AA Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: Modbus IO functions interface description. + * --------------------------------------------------------------------------- + * Version(s): 1.0, 31-06-2006, Henk Stegeman. + * Creation. + * 1.1, 12-10-2007, Jos Pasop. + * Added extenderboard support. + * 1.2, 27-11-2007, Jos Pasop. + * Added callibration tables for DAC. + * --------------------------------------------------------------------------- + */ + /*!\file smc4000io.h + * \brief SMC4000 IO functions interface description. + */ +#ifndef SMC4000IO_H_ +#define SMC4000IO_H_ +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ +#include "types.h" + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ +typedef struct + { + UINT16 iCal4; + UINT16 iCal12; + UINT16 iCal20; + } CALIBRATION_VALUE_DESCR; + +/* ADC calibration values for the motherboard and extenderboard can be stored + * in arrays defined as. + * + * CALIBRATION_VALUE_DESCR calMB [8]; + * CALIBRATION_VALUE_DESCR calEB [8]; + * + */ +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ +int ain0_7Read (int file, UINT16 * data); +int aout0_5Write (int file, UINT16 * data); +int din0_7Read (int file, UINT16 * data); +int dout0_15Write (int file, UINT16 * data); +int rel0_5Write (int file, UINT16 * data); +int vccRead (int file, UINT16 * data); +int vddatRead (int file, UINT16 * data); +int vbatRead (int file, UINT16 * data); +int vcoreRead (int file, UINT16 * data); +int tempRead (int file, UINT16 * data); +int revnumRead (int file, UINT16 * data); +int extboardRead (int file, UINT16 * data); +int dinext0_3Read (int file, UINT16 * data); +int doutext0_3Write (int file, UINT16 * data); +int pwrrelmbWrite (int file, UINT16 * data); +int pwrrelebWrite (int file, UINT16 * data); +int ain0_15Read (int file, UINT16 * data); +int aout0_11Write (int file, UINT16 * data); +int sermbRead (int file, UINT16 * data); +int serebRead (int file, UINT16 * data); +int adccalmbRead (int file, CALIBRATION_VALUE_DESCR data []); +int adccalmbWrite (int file, CALIBRATION_VALUE_DESCR data []); +int adccalebRead (int file, CALIBRATION_VALUE_DESCR data []); +int adccalebWrite (int file, CALIBRATION_VALUE_DESCR data []); +int daccalmbRead (int file, CALIBRATION_VALUE_DESCR data []); +int daccalmbWrite (int file, CALIBRATION_VALUE_DESCR data []); +int daccalebRead (int file, CALIBRATION_VALUE_DESCR data []); +int daccalebWrite (int file, CALIBRATION_VALUE_DESCR data []); +#endif /*SMC4000IO_H_*/ diff --git a/Quantum Controller/SW/testapplication-0.0.1/testapp b/Quantum Controller/SW/testapplication-0.0.1/testapp new file mode 100644 index 0000000..e83e7bc Binary files /dev/null and b/Quantum Controller/SW/testapplication-0.0.1/testapp differ diff --git a/Quantum Controller/SW/testapplication-0.0.1/types.h b/Quantum Controller/SW/testapplication-0.0.1/types.h new file mode 100644 index 0000000..b5c0444 --- /dev/null +++ b/Quantum Controller/SW/testapplication-0.0.1/types.h @@ -0,0 +1,108 @@ +/* --------------------------------------------------------------------------- + * types.h - v0.1 (c) 2007 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: Contains definitions of native types. + * --------------------------------------------------------------------------- + * Version(s): 0.1, 10-09-2007, Marcel Mulder. + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef __TYPES_H__ +#define __TYPES_H__ +/** \file types.h + \brief Contains the native types of LPC2378 +*/ +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ +#define UINT8 unsigned char +#define UINT16 unsigned short +#define UINT32 unsigned int + + +typedef unsigned long long UINT64; // Unsigned 64 bit quantity + + +#define pUINT8 unsigned char * +#define pUINT16 unsigned short * +#define pUINT32 unsigned int * + + +#define INT8 char +#define INT16 short +#define INT32 int + + +#define pINT8 char * +#define pINT16 short * +#define pINT32 int * + + +#ifndef BIT +#define BIT(n) (1L << (n)) +#endif + +#ifndef NULL +#define NULL (0) +#endif + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ +#ifdef fsasfd +typedef enum +{ + FALSE = 0, /**< Definition of false*/ + TRUE +} BOOLEAN; +#endif + +#ifndef FALSE +#define FALSE (1 == 0) +#endif + +#ifndef TRUE +#define TRUE (1==1) +#endif + +#define BOOLEAN char + + +typedef enum +{ + ERROR = 0, /**< Definition for ERROR*/ + OK +} RESULT; + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ + +#endif /* __TYPES_H__ */ diff --git a/Tester/SW/Applications/.cproject b/Tester/SW/Applications/.cproject new file mode 100644 index 0000000..08326c0 --- /dev/null +++ b/Tester/SW/Applications/.cproject @@ -0,0 +1,1162 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tester/SW/Applications/.project b/Tester/SW/Applications/.project new file mode 100644 index 0000000..011c09a --- /dev/null +++ b/Tester/SW/Applications/.project @@ -0,0 +1,85 @@ + + + Applications + + + BusProtocol + Drivers + FreeRTOS + inc + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + org.eclipse.cdt.make.core.cleanBuildTarget + clean + + + org.eclipse.cdt.make.core.enableCleanBuild + true + + + ?name? + + + + org.eclipse.cdt.make.core.append_environment + true + + + org.eclipse.cdt.make.core.stopOnError + true + + + org.eclipse.cdt.make.core.buildCommand + make + + + org.eclipse.cdt.make.core.contents + org.eclipse.cdt.make.core.activeConfigSettings + + + org.eclipse.cdt.make.core.buildLocation + ${workspace_loc:/Applications/Debug} + + + org.eclipse.cdt.make.core.useDefaultBuildCmd + true + + + org.eclipse.cdt.make.core.enableAutoBuild + false + + + org.eclipse.cdt.make.core.enableFullBuild + true + + + org.eclipse.cdt.make.core.buildArguments + + + + org.eclipse.cdt.make.core.fullBuildTarget + all + + + org.eclipse.cdt.make.core.autoBuildTarget + all + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.core.cnature + + diff --git a/Tester/SW/Applications/bootapp.s b/Tester/SW/Applications/bootapp.s new file mode 100644 index 0000000..effc9b7 --- /dev/null +++ b/Tester/SW/Applications/bootapp.s @@ -0,0 +1,146 @@ + /* Sample initialization file */ + + .extern main + .extern exit + + .text + .code 32 + + + .align 4 + + .extern __bss_beg__ + .extern __bss_end__ + .extern __stack_end__ + .extern __data_beg__ + .extern __data_end__ + .extern __data+beg_src__ + + .global start + .global endless_loop + + /* Stack Sizes */ + .set UND_STACK_SIZE, 0x00000004 + .set ABT_STACK_SIZE, 0x00000004 + .set FIQ_STACK_SIZE, 0x00000004 + .set IRQ_STACK_SIZE, 0X00000100 + .set SVC_STACK_SIZE, 0x00000100 + + /* Standard definitions of Mode bits and Interrupt (I & F) flags in PSRs */ + .set MODE_USR, 0x10 /* User Mode */ + .set MODE_FIQ, 0x11 /* FIQ Mode */ + .set MODE_IRQ, 0x12 /* IRQ Mode */ + .set MODE_SVC, 0x13 /* Supervisor Mode */ + .set MODE_ABT, 0x17 /* Abort Mode */ + .set MODE_UND, 0x1B /* Undefined Mode */ + .set MODE_SYS, 0x1F /* System Mode */ + + .equ I_BIT, 0x80 /* when I bit is set, IRQ is disabled */ + .equ F_BIT, 0x40 /* when F bit is set, FIQ is disabled */ + +start: +_start: +_mainCRTStartup: + + /* Setup a stack for each mode - note that this only sets up a usable stack + for system/user, SWI and IRQ modes. Also each mode is setup with + interrupts initially disabled. */ + ldr r0, .LC6 + msr CPSR_c, #MODE_UND|I_BIT|F_BIT /* Undefined Instruction Mode + mov sp, r0 + sub r0, r0, #UND_STACK_SIZE + msr CPSR_c, #MODE_ABT|I_BIT|F_BIT /* Abort Mode */ + mov sp, r0 + sub r0, r0, #ABT_STACK_SIZE + msr CPSR_c, #MODE_FIQ|I_BIT|F_BIT /* FIQ Mode */ + mov sp, r0 + sub r0, r0, #FIQ_STACK_SIZE + msr CPSR_c, #MODE_IRQ|I_BIT|F_BIT /* IRQ Mode */ + mov sp, r0 + sub r0, r0, #IRQ_STACK_SIZE + msr CPSR_c, #MODE_SVC|I_BIT|F_BIT /* Supervisor Mode */ + mov sp, r0 + sub r0, r0, #SVC_STACK_SIZE + msr CPSR_c, #MODE_SYS|I_BIT|F_BIT /* System Mode */ + mov sp, r0 + + /* We want to start in supervisor mode. Operation will switch to system + mode when the first task starts. */ + msr CPSR_c, #MODE_SVC|I_BIT|F_BIT + + /* Clear BSS. */ + + mov a2, #0 /* Fill value */ + mov fp, a2 /* Null frame pointer */ + mov r7, a2 /* Null frame pointer for Thumb */ + + ldr r1, .LC1 /* Start of memory block */ + ldr r3, .LC2 /* End of memory block */ + subs r3, r3, r1 /* Length of block */ + beq .end_clear_loop + mov r2, #0 + +.clear_loop: + strb r2, [r1], #1 + subs r3, r3, #1 + bgt .clear_loop + +.end_clear_loop: + + /* Initialise data. */ + + ldr r1, .LC3 /* Start of memory block */ + ldr r2, .LC4 /* End of memory block */ + ldr r3, .LC5 + subs r3, r3, r1 /* Length of block */ + beq .end_set_loop + +.set_loop: + ldrb r4, [r2], #1 + strb r4, [r1], #1 + subs r3, r3, #1 + bgt .set_loop + +.end_set_loop: + + mov r0, #0 /* no arguments */ + mov r1, #0 /* no argv either */ + + bl main + +endless_loop: + b endless_loop + + + .align 0 + + .LC1: + .word __bss_beg__ + .LC2: + .word __bss_end__ + .LC3: + .word __data_beg__ + .LC4: + .word __data_beg_src__ + .LC5: + .word __data_end__ + .LC6: + .word __stack_end__ + + + /* Setup vector table. Note that undf, pabt, dabt, fiq just execute + a null loop. */ + +.section .startup,"ax" + .code 32 + .align 0 + + .word 0x11111111 /* +0x0, product_id */ + .word 0x10101010 /* +0x4, version */ + .word 0x0 /* +0x8, length (filled by firmware loader) */ + .word 0x0 /* +0xC, CRC (filled by firmware loader) */ + .word 0x0 /* +0x10, reserved */ + .word 0x0 /* +0x14, reserved */ + .word 0x0 /* +0x18, reserved */ + .word 0x0 /* +0x1C, reserved */ + b _start /* +0x20, Firmware start */ diff --git a/Tester/SW/Applications/groupings/ledfunctions.c b/Tester/SW/Applications/groupings/ledfunctions.c new file mode 100644 index 0000000..fbba60f --- /dev/null +++ b/Tester/SW/Applications/groupings/ledfunctions.c @@ -0,0 +1,274 @@ +/* --------------------------------------------------------------------------- + * ledfunctions.c (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * Some handy Functions for the status and the Digital Output LEDs + * --------------------------------------------------------------------------- + * Version(s): 0.1, Mar 11, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +#include "lpc23xx.h" +#include "types.h" + + +/* FreeRTOS includes */ +#include "FreeRTOS.h" +#include "Task.h" +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "leds.h" +#include "dio.h" + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ + + +void LEDPauseFlash (t_led_ids LEDnum, UINT8 counts, INT16 delay_length) +{ + /* Local Variable Declaration */ + UINT16 loopcnt; /* loop index */ + + for ( loopcnt=0; loopcnt <= (counts*2); loopcnt++) + { + if (LEDnum == LED0) /* RED LED */ + { + ledToggle (LED0); /* Toggle LED Status */ + vTaskDelay (delay_length); /* Wait for defined time */ + } + if (LEDnum == LED1) /* GREEN LED */ + { + ledToggle (LED1); + vTaskDelay (delay_length); + } + } + if (ledGet (LED1) == FALSE) /* GREEN LED should be switched on */ + { + ledToggle (LED1); + } +} + + +void LEDResult (BOOLEAN TestResult) +{ + if (TestResult == TRUE) /* If Test was passed */ + { + ledSet (LED0, 1); /* switch on RED LED */ + } + if (TestResult == FALSE) /* If test failed */ + { + ledSet (LED0, 0); /* Switch off RED LED */ + } +} + +void LEDResultDIO (BOOLEAN TestResult, UINT16 dioNo) +{ + if (TestResult == TRUE) /* If Test was passed */ + { + dioWrite (0, dioNo, TRUE); /* switch on DIO LED */ + } + if (TestResult == FALSE) /* If test failed */ + { + dioWrite (0, dioNo, FALSE); /* Switch off DIO LED */ + } +} + +void LEDToggleForever (void) +{ + ledSet (LED0, FALSE); /* Set both LEDs to StartUp */ + ledSet (LED1, TRUE); + vTaskDelay (500); /* Wait for 500 ms */ + + for (;;) /* endless loop */ + { + ledToggle (LED0); /* Toggle RED LED */ + ledToggle (LED1); /* Toggle GREEN LED */ + + vTaskDelay (500); + } +} + +void LEDToggle (UINT16 cnts) +{ + /* Local Variable Declaration */ + UINT16 loopcnt; /* loop index */ + + ledSet (LED0, FALSE); /* Set both LEDs to StartUp */ + ledSet (LED1, TRUE); + vTaskDelay (500); /* Wait for 500 ms */ + + for ( loopcnt = 0; loopcnt <= cnts; loopcnt++) + { + ledToggle(LED0); /* Toggle RED LED */ + ledToggle(LED1); /* Toggle GREEN LED */ + + vTaskDelay (500); + } +} + +void LEDShowStatus (UINT16 status) +{ + /* Local Variable Declaration */ + UINT16 loopcnt; /* loop index */ + + if (ledGet (LED0) == TRUE) /* If current LED Status is TRUE */ + { + ledSet( LED0, FALSE); /* Switch of RED LED */ + vTaskDelay (500); /* Wait for 500 ms */ + } + + for (loopcnt = 0; loopcnt <= (status*2); loopcnt++) + { + ledToggle (LED0); /* Toggle RED LED */ + vTaskDelay (500); + } + vTaskDelay (1000); +} + +void gLEDToggle (UINT16 time) +{ + for (;;) /* Endless loop */ + { + ledToggle (LED1); /* Toggle GREEN LED */ + vTaskDelay (time); /* Wait for defined time */ + } +} + +void rLEDToggle (UINT16 time) +{ + for (;;) /* Endless loop */ + { + ledToggle (LED0); /* Toggle RED LED */ + vTaskDelay (time); /* Wait for defined Time */ + } +} + +void dioToggle (UINT16 LEDnr) +{ + UINT16 time = 100; /* LED Toggle-time definition */ + + for (;;) /* Endless loop */ + { + dioWrite (0, LEDnr, TRUE); /* Write defined digitalOut to HIGH */ + vTaskDelay (time); /* Wait for defined Toggle-time */ + dioWrite (0, LEDnr, FALSE); /* Write defined digitalOut to LOW */ + vTaskDelay (time); + } +} + +void dioToggleNC (UINT16 LEDnr) +{ + UINT16 time = 1000; /* LED Toggle-time definition */ + + for (;;) /* Endless loop */ + { + dioWrite (0, LEDnr, TRUE); /* Write defined digitalOut to HIGH */ + vTaskDelay (time); /* Wait for defined Toggle-time */ + dioWrite (0, LEDnr, FALSE); /* Write defined digitalOut to LOW */ + vTaskDelay (time); + } +} + +void dio2x4 (UINT32 ToggleTime) +{ + + for (;;) /* endless loop */ + { + dioWrite (0,0,TRUE); /* ON-OFF-ON-OFF-ON-OFF-ON-OFF */ + dioWrite (0,1,FALSE); + dioWrite (0,2,TRUE); + dioWrite (0,3,FALSE); + dioWrite (0,4,TRUE); + dioWrite (0,5,FALSE); + dioWrite (0,6,TRUE); + dioWrite (0,7,FALSE); + + vTaskDelay(ToggleTime); /* Wait Toggle Time */ + + dioWrite (0,0,FALSE); /* OFF-ON-OFF-ON-OFF-ON-OFF-ON */ + dioWrite (0,1,TRUE); + dioWrite (0,2,FALSE); + dioWrite (0,3,TRUE); + dioWrite (0,4,FALSE); + dioWrite (0,5,TRUE); + dioWrite (0,6,FALSE); + dioWrite (0,7,TRUE); + + vTaskDelay (ToggleTime); + } +} + +void dioClean (void) +{ + dioWrite (0,0,FALSE); /* Write digital Output to LOW */ + dioWrite (0,1,FALSE); + dioWrite (0,2,FALSE); + dioWrite (0,3,FALSE); + dioWrite (0,4,FALSE); + dioWrite (0,5,FALSE); + dioWrite (0,6,FALSE); + dioWrite (0,7,FALSE); +} +UINT8 dioCapture (void) +{ + /* Local Variable Declaration */ + UINT8 dioCaptureResult = 0; + + dioCaptureResult |= (dioReadBack (0,0) << 0); /*Save current DIO Status */ + dioCaptureResult |= (dioReadBack (0,1) << 1); + dioCaptureResult |= (dioReadBack (0,2) << 2); + dioCaptureResult |= (dioReadBack (0,3) << 3); + dioCaptureResult |= (dioReadBack (0,4) << 4); + dioCaptureResult |= (dioReadBack (0,5) << 5); + dioCaptureResult |= (dioReadBack (0,6) << 6); + dioCaptureResult |= (dioReadBack (0,7) << 7); + + return dioCaptureResult; /* Return saved DIO Status */ +} + +void dioResume (UINT8 dioResumeValue) +{ + dioWrite (0,0,((dioResumeValue >> 0) & 1)); /* Set DIO to defined Value */ + dioWrite (0,1,((dioResumeValue >> 1) & 1)); + dioWrite (0,2,((dioResumeValue >> 2) & 1)); + dioWrite (0,3,((dioResumeValue >> 3) & 1)); + dioWrite (0,4,((dioResumeValue >> 4) & 1)); + dioWrite (0,5,((dioResumeValue >> 5) & 1)); + dioWrite (0,6,((dioResumeValue >> 6) & 1)); + dioWrite (0,7,((dioResumeValue >> 7) & 1)); + +} + diff --git a/Tester/SW/Applications/groupings/ledfunctions.h b/Tester/SW/Applications/groupings/ledfunctions.h new file mode 100644 index 0000000..0e390ce --- /dev/null +++ b/Tester/SW/Applications/groupings/ledfunctions.h @@ -0,0 +1,220 @@ +/* --------------------------------------------------------------------------- + * ledfunctions.h (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * Headerfile for ledfunctions.c + * --------------------------------------------------------------------------- + * Version(s): 0.1, Mar 11, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef LEDFUNCTIONS_H_ +#define LEDFUNCTIONS_H_ +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ +#include "lpc23xx.h" +#include "types.h" +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ +#include "leds.h" +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function: LEDPauseFlash + * + * Function that flashes either the RED or the GREEN LED in user defined + * length and number. + * + * Parameters: t_led_ids LEDnum - Defines the LED to flash + * UINT8 counts - Number of flash events + * INT16 delay_length - length of single flash event + * + * Return: void + * --------------------------------------------------------------------------- + */ +void LEDPauseFlash(t_led_ids LEDnum, UINT8 counts, INT16 delay_length); + +/* --------------------------------------------------------------------------- + * Function: LEDResult + * + * Function to display a BOOLEAN Variable either on RED or GREEN LED + * + * Parameters: BOOLEAN TestResult - Gives the BOOLEAN Variable to display + * + * Return: void + * --------------------------------------------------------------------------- + */ +void LEDResult (BOOLEAN TestResult); + +/* --------------------------------------------------------------------------- + * Function: LEDResultDIO + * + * Function to display a BOOLEAN Variable on a DIO LED + * + * Parameters: BOOLEAN TestResult - Gives the BOOLEAN Variable to display + * UINT 16 dioNo - Number of DIO channel + * + * Return: void + * --------------------------------------------------------------------------- + */ +void LEDResultDIO (BOOLEAN TestResult, UINT16 dioNo); + +/* --------------------------------------------------------------------------- + * Function: LEDToggleForever + * + * Function that simply toggles RED and GREEN LED in an endless loop + * + * Parameters: void + * + * Return: void + * --------------------------------------------------------------------------- + */ +void LEDToggleForever( void); + +/* --------------------------------------------------------------------------- + * Function: LEDToggle + * + * Function that simply toggles RED and GREEN LED for user defined number + * + * Parameters: UINT16 cnts - user defined toggle number + * + * Return: void + * --------------------------------------------------------------------------- + */ +void LEDToggle( UINT16 cnts); + +/* --------------------------------------------------------------------------- + * Function: LEDShowStatus + * + * Function to display a Variable value by flashing that amount of. + * + * Parameters: UINT16 status - Value of Variable to flash like + * + * Return: void + * --------------------------------------------------------------------------- + */ +void LEDShowStatus (UINT16 status); + +/* --------------------------------------------------------------------------- + * Functions: gLEDToggle / rLEDToggle + * + * Functions to toggle either RED or GREEN LED forever with user defined + * flash time + * + * Parameters: UINT16 time + * + * Return: void + * --------------------------------------------------------------------------- + */ +void gLEDToggle (UINT16 time); +void rLEDToggle (UINT16 time); + +/* --------------------------------------------------------------------------- + * Function: dioToggle + * + * Function to toggle LED Status of a user defined Digital Output with 100 ms + * flash time. + * + * Parameters: UINT16 LEDnr + * + * Return: void + * --------------------------------------------------------------------------- + */ +void dioToggle (UINT16 LEDnr); + +/* --------------------------------------------------------------------------- + * Function: dioToggleNC + * + * Function to toggle LED Status of a user defined Digital Output with 1000 ms + * flash time. + * + * Parameters: UINT16 LEDnr + * + * Return: void + * --------------------------------------------------------------------------- + */ +void dioToggleNC (UINT16 LEDnr); + +/* --------------------------------------------------------------------------- + * Function: dio2x4 + * + * Function to constantly flash the DIO LEDs in ON-OFF-ON-OFF pattern with + * userdefined toggle Time. + * Normaly used to note the user for something + * + * Parameters: UINT32 ToggleTime + * + * Return: void + * --------------------------------------------------------------------------- + */ +void dio2x4 (UINT32 ToggleTime); + +/* --------------------------------------------------------------------------- + * Function: dioClean + * + * Sets all Digital Outputs back to LOW + * + * Parameters: void + * + * Return: void + * --------------------------------------------------------------------------- + */ +void dioClean (void); + +/* --------------------------------------------------------------------------- + * Function: dioCapture + * + * Function to capture and save up to all 8 Digital Output Levels + * + * Parameters: void + * + * Return: UINT8 - up to all 8 Digital Output Levels + * --------------------------------------------------------------------------- + */ +UINT8 dioCapture (void); + +/* --------------------------------------------------------------------------- + * Function: dioResume + * + * Function to set or restore up to all 8 Digital Output Levels + * + * Parameters: UINT8 dioResumeValue - Value for setting Output Levels + * + * Return: void + * --------------------------------------------------------------------------- + */ +void dioResume (UINT8 dioResumeValue); + + +#endif /*LEDFUNCTIONS_H_*/ diff --git a/Tester/SW/Applications/groupings/protocolfunctions.c b/Tester/SW/Applications/groupings/protocolfunctions.c new file mode 100644 index 0000000..3b7d398 --- /dev/null +++ b/Tester/SW/Applications/groupings/protocolfunctions.c @@ -0,0 +1,176 @@ +/* --------------------------------------------------------------------------- + * protocolfunctions.c - v0.1 (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: Initialisation and direct usage of the Bus Protocol + * --------------------------------------------------------------------------- + * Version(s): 0.1, Jun 2, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +#include "LPC23xx.h" +#include "types.h" + +#include "FreeRTOS.h" +#include "task.h" +#include "semphr.h" +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "protocolfunctions.h" +#include "BusProtocol.h" + +#include "adc.h" +#include "dac.h" +#include "bus.h" +#include "dio.h" +#include "serial.h" +#include "SerOut.h" +#include "topoftest.h" + +#include "remote_digital.h" +#include "remote_analogue.h" +#include "remote_relay.h" +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ + + +extern BOOLEAN auto_testResult; +extern UINT32 UINT32result; +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ + +void protocolInit (t_bus_devices BUS_ID, UINT32 DEV_ID, UINT32 MAX_ID) +{ + /* Create both needed Semaphores to be able to use them */ + vSemaphoreCreateBinary (generalSemaphore); + vSemaphoreCreateBinary (slaveRestartSemaphore); + + /* Init Device as Master of BUS1 System */ + handleBus1 = bpInit (BUS2, BUS1, DEV_ID, MAX_ID, 16); + + /* Attach basicly needed Handshake Functions */ + bpAttachRpc (handleBus1, 1, "AvailableID", (t_rpc_remote_procedure_call) availableBusID, 0); + bpAttachRpcResult(handleBus1, 1, (t_bp_rpcresult_callback) generalResultFunction, 0); + + /* Following Attachments depend on Device ID */ + if (DEV_ID == 1) + { + /* If Device is Master, attach these functions */ + /* Attach Slave Result Functions (called by Slave on the Master) */ + bpAttachRpcResult(handleBus1, 2, (t_bp_rpcresult_callback) testResultFunction, 1); + bpAttachRpcResult(handleBus1, 3, (t_bp_rpcresult_callback) slaveRestartFunction, 0); + bpAttachRpcResult(handleBus1, 4, (t_bp_rpcresult_callback) UINT32ResultFunction, 1); + bpAttachRpcResult(handleBus1, 9, (t_bp_rpcresult_callback) receiveRemoteAttachedFunctions, 1); + + /* Attach test result functions */ + bpAttachRpcResult(handleBus1, 11, (t_bp_rpcresult_callback) digitalReadResult, 1); + bpAttachRpcResult(handleBus1, 12, (t_bp_rpcresult_callback) analogueReadResult, 1); + bpAttachRpcResult(handleBus1, 13, (t_bp_rpcresult_callback) digitalReadAllResult, maxDI_Channels); + bpAttachRpcResult(handleBus1, 14, (t_bp_rpcresult_callback) analogueReadAllResult, maxDAC_Channels); + + /* Attach semaphore release functions */ + bpAttachRpcResult(handleBus1, 20, (t_bp_rpcresult_callback) remoteDigitalSemaphoreRelease, 0); + bpAttachRpcResult(handleBus1, 21, (t_bp_rpcresult_callback) remoteAnalogueSemaphoreRelease, 0); + bpAttachRpcResult(handleBus1, 22, (t_bp_rpcresult_callback) remoteRelaySemaphoreRelease, 0); + + } + + if (DEV_ID > 1) + { + /* If Device is Slave, attach these functions */ + } +} + +void availableBusID (UINT8 senderId, UINT8 targetId, UINT8 requestNr, + UINT8 functionId, UINT8 nrOfParams, UINT32 *params) +{ + /* Just call first Result Function on Slave */ + bpSendRpcResult(handleBus1, 2, 1, 1, 0, NULL); +} + +/* generalResultFunction is the easiest Way to realise a Handshake between + * Master and Slave. Master software takes a Semaphore and calls a function + * on Slave, that is only calling generalResultfunction() on Master. If this + * happens, the Semaphore will be released and Handshake is done + */ +void generalResultFunction (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results) +{ + /* If called, release the generalSemaphore */ + if (xSemaphoreGive (generalSemaphore) == pdTRUE) + { + } + else + { + } +} + +/* Test functions called on Slave will return their Test Results with a + * call on this function. Results on Slave are from type BOOLEAN + */ +void testResultFunction (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results) +{ + /* Set Slave Test result depending on what slave sends back as parameter*/ + if (*results == 1) + { + /* Test was successfull */ + auto_testResult = TRUE; + } + else + { + /* Test was a failure */ + auto_testResult = FALSE; + } +} + + +void slaveRestartFunction (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results) +{ + /* Release slaveRestartSemaphore if Slave calls this Function on Reboot */ + if (xSemaphoreGive (slaveRestartSemaphore) == pdTRUE) + { + } + else + { + } +} + + +void UINT32ResultFunction (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results) +{ + UINT32result = *results; +} + + +void receiveRemoteAttachedFunctions (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results) +{ + sendString (SerOutPort, TRUE, importantMessage, (char *) results, Dummy, Dummy); +} diff --git a/Tester/SW/Applications/groupings/protocolfunctions.h b/Tester/SW/Applications/groupings/protocolfunctions.h new file mode 100644 index 0000000..f5bf4c7 --- /dev/null +++ b/Tester/SW/Applications/groupings/protocolfunctions.h @@ -0,0 +1,162 @@ +/* --------------------------------------------------------------------------- + * protocolfunctions.h - v0.1 (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Jun 2, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef __PROTOCOLTEST_H__ +#define __PROTOCOLTEST_H__ + +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ +#include "LPC23xx.h" +#include "types.h" + +/* FreeRTOS includes */ +#include "FreeRTOS.h" +#include "task.h" +#include "semphr.h" +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ +#include "Bus.h" +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ +int handleBus1; + +UINT8 remoteDeviceNumber; +UINT8 thisDeviceNumber; + +xSemaphoreHandle generalSemaphore; +xSemaphoreHandle slaveRestartSemaphore; + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function: protocolInit + * + * Function to calibrate slaves Voltage Output + * + * Parameters: t_bus_devices BUS_ID - ID of the BUS system + * UINT32 DEV_ID - ID of the local Device + * UINT32 MAX_ID - Max ID in System + * + * Return: void + * --------------------------------------------------------------------------- + */ +void protocolInit (t_bus_devices BUS_ID, UINT32 DEV_ID, UINT32 MAX_ID); + + +/* --------------------------------------------------------------------------- + * Function: availableBusID + * + * Function that just calls a Result on the Caller. It's just a Handshake + * + * Parameters: UINT8 senderId - ID of Caller + * UINT8 targetId - ID of Target + * UINT8 requestNr - Number of the request + * UINT8 functionId - Numer of function to call + * UINT8 nrOfParams - Number of attached Paramters + * UINT32 *params - Attached Paramters + * + * Return: void + * --------------------------------------------------------------------------- + */ +void availableBusID (UINT8 senderId, UINT8 targetId, UINT8 requestNr, + UINT8 functionId, UINT8 nrOfParams, UINT32 *params); + + +/* --------------------------------------------------------------------------- + * Function: generalResultfunction + * + * Function that is called be Slave on the Master to release a Semaphore + * + * Parameters: UINT8 requestNr - number of the request + * UINT8 nrOfResult - Number of Attached Results + * UIN32 *results - Attached Results + * + * Return: void + * --------------------------------------------------------------------------- + */ +void generalResultFunction (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results); + + +/* --------------------------------------------------------------------------- + * Function: testResultfunction + * + * Function that is called be Slave for telling a Test Result + * + * Parameters: UINT8 requestNr - number of the request + * UINT8 nrOfResult - Number of Attached Results + * UIN32 *results - Attached Results + * + * Return: void + * --------------------------------------------------------------------------- + */ +void testResultFunction (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results); + + +/* --------------------------------------------------------------------------- + * Function: slaveRestartfunction + * + * Function that is called be Slave on the Master to tell about a Restart + * + * Parameters: UINT8 requestNr - number of the request + * UINT8 nrOfResult - Number of Attached Results + * UIN32 *results - Attached Results + * + * Return: void + * --------------------------------------------------------------------------- + */ +void slaveRestartFunction (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results); + + +/* --------------------------------------------------------------------------- + * Function: UINT32ResultFunction + * + * Function to receive a UINT32 Result from Slave. Result is stored then in + * the global variable UINT32 UINT32result + * + * Parameters: UINT8 requestNr - number of the request + * UINT8 nrOfResult - Number of Attached Results + * UIN32 *results - Attached Results + * + * Return: void + * --------------------------------------------------------------------------- + */ +void UINT32ResultFunction (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results); + + +void receiveRemoteAttachedFunctions (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results); + +#endif /* __PROTOCOLTEST_H__ */ diff --git a/Tester/SW/Applications/groupings/taskfunctions.c b/Tester/SW/Applications/groupings/taskfunctions.c new file mode 100644 index 0000000..8df7d10 --- /dev/null +++ b/Tester/SW/Applications/groupings/taskfunctions.c @@ -0,0 +1,284 @@ +/* --------------------------------------------------------------------------- + * taskfunctions.c (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * Contains Functions to control the TestLED Tasks + * --------------------------------------------------------------------------- + * Version(s): 0.1, Apr 09, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +#include "lpc23xx.h" +#include "types.h" + +/* FreeRTOS includes */ +#include "FreeRTOS.h" +#include "task.h" +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "taskfunctions.h" +#include "dio.h" +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ +void taskInit (void) +{ + d_gLED = 0; /* Initialize TaskStatus with 0 */ + d_ledtestled = 0; + d_dioled = 0; + d_aioled = 0; + d_busled = 0; + d_eepromled = 0; + d_flashled = 0; + d_mmcled = 0; + d_logled = 0; + d_comled = 0; + d_powerled = 0; + d_rtcled = 0; +} + +void diotasksdelete(void) +{ + if (d_dioled == pdPASS) /* If defined Task exists */ + { + vTaskDelete (dioled); /* Delete Task */ + dioWrite (0,DIOLED,FALSE); /* Switch off corresponding DIO-LED */ + d_dioled = 0; /* Set TaskStatus to 0 */ + } + if (d_ledtestled == pdPASS) + { + vTaskDelete (ledtestled); + dioWrite (0,LEDTESTLED,FALSE); + d_ledtestled = 0; + } + if (d_aioled == pdPASS) + { + vTaskDelete (aioled); + dioWrite (0,AIOLED,FALSE); + d_aioled = 0; + } + if (d_busled == pdPASS) + { + vTaskDelete (busled); + dioWrite (0,BUSLED,FALSE); + d_busled = 0; + } +#if (allMemoryUseSameLED == 0) + if (d_eepromled == pdPASS) + { + vTaskDelete (eepromled); + dioWrite (0,EEPROMLED,FALSE); + d_eepromled = 0; + } + if (d_flashled == pdPASS) + { + vTaskDelete (flashled); + dioWrite (0,FLASHLED,FALSE); + d_flashled = 0; + } + if (d_logled == pdPASS) + { + vTaskDelete (logled); + dioWrite (0,LOGLED,FALSE); + d_logled = 0; + } +#else + if (d_batteryled == pdPASS) + { + vTaskDelete (batteryled); + dioWrite (0,BATTERYLED,FALSE); + d_batteryled = 0; + } + + if (d_memoryled == pdPASS) + { + vTaskDelete (memoryled); + dioWrite (0,MEMORYLED,FALSE); + d_memoryled = 0; + } +#endif + if (d_mmcled == pdPASS) + { + vTaskDelete (mmcled); + dioWrite (0,MMCLED,FALSE); + d_mmcled = 0; + } + if (d_comled == pdPASS) + { + vTaskDelete (comled); + dioWrite (0,COMLED,FALSE); + d_comled = 0; + } + if (d_powerled == pdPASS) + { + vTaskDelete (powerled); + dioWrite (0,POWERLED,FALSE); + d_powerled = 0; + } + if (d_rtcled == pdPASS) + { + vTaskDelete (rtcled); + dioWrite (0,RTCLED,FALSE); + d_rtcled = 0; + } +} + +void diotaskssuspend(void) +{ + if (d_dioled == pdPASS) /* If defined Task exists */ + { + vTaskSuspend (dioled); /* Suspend Task */ + dioWrite (0,DIOLED,FALSE); /* Switch off corresponding DIO-LED */ + } + if (d_ledtestled == pdPASS) + { + vTaskSuspend (ledtestled); + dioWrite (0,LEDTESTLED,FALSE); + } + if (d_aioled == pdPASS) + { + vTaskSuspend (aioled); + dioWrite (0,AIOLED,FALSE); + } + if (d_busled == pdPASS) + { + vTaskSuspend (busled); + dioWrite (0,BUSLED,FALSE); + } +#if (allMemoryUseSameLED == 0) + if (d_eepromled == pdPASS) + { + vTaskSuspend (eepromled); + dioWrite (0,EEPROMLED,FALSE); + } + if (d_flashled == pdPASS) + { + vTaskSuspend (flashled); + dioWrite (0,FLASHLED,FALSE); + } + if (d_logled == pdPASS) + { + vTaskSuspend (logled); + dioWrite (0,LOGLED,FALSE); + } +#else + if (d_batteryled == pdPASS) + { + vTaskSuspend (batteryled); + dioWrite (0,BATTERYLED,FALSE); + } + if (d_memoryled == pdPASS) + { + vTaskSuspend (memoryled); + dioWrite (0,MEMORYLED,FALSE); + } +#endif + if (d_mmcled == pdPASS) + { + vTaskSuspend (mmcled); + dioWrite (0,MMCLED,FALSE); + } + if (d_comled == pdPASS) + { + vTaskSuspend (comled); + dioWrite (0,COMLED,FALSE); + } + if (d_powerled == pdPASS) + { + vTaskSuspend (powerled); + dioWrite (0,POWERLED,FALSE); + } + if (d_rtcled == pdPASS) + { + vTaskSuspend (rtcled); + dioWrite (0,RTCLED,FALSE); + } +} + +void diotasksresume(void) +{ + if (d_batteryled == pdPASS) /* If defined Task exists */ + { + vTaskResume(batteryled); /* Resume Task */ + } + if (d_dioled == pdPASS) + { + vTaskResume(dioled); + } + if (d_ledtestled == pdPASS) + { + vTaskResume(ledtestled); + } + if (d_aioled == pdPASS) + { + vTaskResume(aioled); + } + if (d_busled == pdPASS) + { + vTaskResume(busled); + } + if (d_eepromled == pdPASS) + { + vTaskResume(eepromled); + } + if (d_flashled == pdPASS) + { + vTaskResume(flashled); + } + if (d_logled == pdPASS) + { + vTaskResume(logled); + } + if (d_memoryled == pdPASS) + { + vTaskResume (memoryled); + } + if (d_mmcled == pdPASS) + { + vTaskResume(mmcled); + } + if (d_comled == pdPASS) + { + vTaskResume(comled); + } + if (d_powerled == pdPASS) + { + vTaskResume(powerled); + } + if (d_rtcled == pdPASS) + { + vTaskResume(rtcled); + } +} diff --git a/Tester/SW/Applications/groupings/taskfunctions.h b/Tester/SW/Applications/groupings/taskfunctions.h new file mode 100644 index 0000000..aa1fdac --- /dev/null +++ b/Tester/SW/Applications/groupings/taskfunctions.h @@ -0,0 +1,177 @@ +/* --------------------------------------------------------------------------- + * taskfunctions.h (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * Headerfile for taskfunctions.c + * --------------------------------------------------------------------------- + * Version(s): 0.1, Apr 09, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef TASKFUNCTIONS_H_ +#define TASKFUNCTIONS_H_ +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ +#include "lpc23xx.h" +#include "types.h" + +/* FreeRTOS includes */ +#include "FreeRTOS.h" +#include "task.h" + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ +#define allMemoryUseSameLED 1 + + +/* Allocation of digital Output LEDs to a single Test */ +/* LED Setting correspond to if all memory Test should share the same LED */ +#if (allMemoryUseSameLED == 0) +#define LEDTESTLED 0 +#define EEPROMLED 1 +#define FLASHLED 2 +#define LOGLED 3 +#define DIOLED 4 +#define MMCLED 5 +#define POWERLED 6 +#define RTCLED 7 +#define AIOLED 8 +#define BUSLED 8 +#define COMLED 8 +#else +#define BATTERYLED 0 +#define LEDTESTLED 1 +#define MEMORYLED 2 +#define DIOLED 3 +#define AIOLED 4 +#define MMCLED 5 +#define POWERLED 6 +#define RTCLED 7 +#define BUSLED 8 +#define COMLED 8 +#endif + + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* Taskhandler + * Last Argument called in xTaskCreate + * Needed to identify a Task + */ +xTaskHandle batteryled; +xTaskHandle gLED; +xTaskHandle ledtestled; +xTaskHandle dioled; +xTaskHandle aioled; +xTaskHandle busled; +xTaskHandle eepromled; +xTaskHandle flashled; +xTaskHandle logled; +xTaskHandle memoryled; +xTaskHandle mmcled; +xTaskHandle comled; +xTaskHandle powerled; +xTaskHandle rtcled; +xTaskHandle spinWheel; + +/* BaseType + * Return of xTaskCreate + * Indicates wether a Function was created (=pdPASS) oder not (= 0) + */ +portBASE_TYPE d_batteryled; +portBASE_TYPE d_gLED; +portBASE_TYPE d_ledtestled; +portBASE_TYPE d_dioled; +portBASE_TYPE d_aioled; +portBASE_TYPE d_busled; +portBASE_TYPE d_eepromled; +portBASE_TYPE d_flashled; +portBASE_TYPE d_logled; +portBASE_TYPE d_memoryled; +portBASE_TYPE d_mmcled; +portBASE_TYPE d_comled; +portBASE_TYPE d_powerled; +portBASE_TYPE d_rtcled; +portBASE_TYPE d_spinWheel; + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ + + +/* --------------------------------------------------------------------------- + * Function: taskInit + * + * Function to initialize TaskStatus Variables + * + * Parameter: void + * + * Return: void + * --------------------------------------------------------------------------- + */ +void taskInit (void); + +/* --------------------------------------------------------------------------- + * Function: diotasksdelete + * + * Function to delete ALL existing Tasks flashing a DIO-LED + * + * Parameter: void + * + * Return: void + * --------------------------------------------------------------------------- + */ +void diotasksdelete(void); + +/* --------------------------------------------------------------------------- + * Function: diotaskssuspend + * + * Function to suspend ALL existing Tasks flashing a DIO-LED + * + * Parameter: void + * + * Return: void + * --------------------------------------------------------------------------- + */ +void diotaskssuspend (void); + +/* --------------------------------------------------------------------------- + * Function: diotasksresume + * + * Function to resume ALL existing and suspended Tasks flashing a DIO-LED + * + * Parameter: void + * + * Return: void + * --------------------------------------------------------------------------- + */ +void diotasksresume (void); + +#endif /*TASKFUNCTIONS_H_*/ diff --git a/Tester/SW/Applications/main.c b/Tester/SW/Applications/main.c new file mode 100644 index 0000000..6dc7264 --- /dev/null +++ b/Tester/SW/Applications/main.c @@ -0,0 +1,347 @@ +/* + FreeRTOS.org V4.6.1 - Copyright (C) 2003-2007 Richard Barry. + + This file is part of the FreeRTOS.org distribution. + + FreeRTOS.org is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + FreeRTOS.org is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with FreeRTOS.org; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + A special exception to the GPL can be applied should you wish to distribute + a combined work that includes FreeRTOS.org, without being obliged to provide + the source code for any proprietary components. See the licensing section + of http://www.FreeRTOS.org for full details of how and when the exception + can be applied. + + *************************************************************************** + See http://www.FreeRTOS.org for documentation, latest information, license + and contact details. Please ensure to read the configuration and relevant + port sections of the online documentation. + + Also see http://www.SafeRTOS.com a version that has been certified for use + in safety critical systems, plus commercial licensing, development and + support options. + *************************************************************************** + */ + +/* --------------------------------------------------------------------------- + * Description: MAIN File to Application Project + * --------------------------------------------------------------------------- + * Version(s): 0.1, Jul 07, 2008, MMi + * + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +#include "types.h" +#include "sys_config.h" + +/* Scheduler includes. */ +#include "FreeRTOS.h" +#include "task.h" +#include "queue.h" +#include "semphr.h" +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +/* Drivers */ +#include "adc.h" +#include "bus.h" +#include "BusProtocol.h" +#include "calibrateaio.h" +#include "can.h" +#include "dac.h" +#include "dio.h" +#include "eeprom.h" +#include "ElecStatusCache.h" +#include "ethernet.h" +#include "irq.h" +#include "leds.h" +#include "menuargs.h" +#include "mmc.h" +#include "power.h" +#include "relay.h" +#include "rtc.h" +#include "serial.h" +#include "SerOut.h" +#include "ssp0.h" +#include "ssp1.h" + +/* testfiles */ +#include "topoftest.h" + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ +/* Demo application definitions. */ +#define mainQUEUE_SIZE ( 3 ) +#define mainCHECK_DELAY (( portTickType ) 5000 / portTICK_RATE_MS ) +#define mainBASIC_WEB_STACK_SIZE ( configMINIMAL_STACK_SIZE * 6 ) + +/* Task priorities. */ +#define mainQUEUE_POLL_PRIORITY ( tskIDLE_PRIORITY + 2 ) +#define mainCHECK_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 ) +#define mainBLOCK_Q_PRIORITY ( tskIDLE_PRIORITY + 2 ) +#define mainFLASH_PRIORITY ( tskIDLE_PRIORITY + 2 ) +#define mainCREATOR_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 ) +#define mainGEN_QUEUE_TASK_PRIORITY ( tskIDLE_PRIORITY ) + +/* Constants to setup the PLL. */ +#define mainPLL_ENABLE (( unsigned portLONG ) 0x0001 ) +#define mainPLL_CONNECT ((( unsigned portLONG ) 0x0002 ) | mainPLL_ENABLE ) +#define mainPLL_FEED_BYTE1 (( unsigned portLONG ) 0xaa ) +#define mainPLL_FEED_BYTE2 (( unsigned portLONG ) 0x55 ) +#define mainPLL_LOCK (( unsigned portLONG ) 0x4000000 ) +#define mainPLL_CONNECTED (( unsigned portLONG ) 0x2000000 ) +#define mainOSC_ENABLE (( unsigned portLONG ) 0x20 ) +#define mainOSC_STAT (( unsigned portLONG ) 0x40 ) +#define mainOSC_SELECT (( unsigned portLONG ) 0x01 ) + +/* Constants to setup the MAM. */ +#define mainMAM_TIM_3 (( unsigned portCHAR ) 0x03 ) +#define mainMAM_MODE_FULL (( unsigned portCHAR ) 0x02 ) + +#define SWI_RAM_ADDR 0x40000008 +#define SWI_RAM_FUNC_ADDR 0x40000028 +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ + + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ +BOOLEAN StopFlashing= FALSE; +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ +extern void vPortYieldProcessor (void); + +/* Configure Hardware */ +static inline void prvSetVectors (void); +static void prvSetupHardware (void); +static void prvSetupDrivers (void); + +/* Main Task */ +static void ExecuteTestsTask (void *pvParameters); + +/*-----------------------------------------------------------*/ + +extern void *pvPortMalloc(size_t xWantedSize); + +int main(void) +{ + static portBASE_TYPE taskCreationResult = -20; + + prvSetVectors(); + prvSetupHardware(); + + + /* Start the tasks defined within this file/specific to this demo. */ + taskCreationResult = xTaskCreate(ExecuteTestsTask, + ( signed portCHAR * ) "Tests", configMINIMAL_STACK_SIZE + 400, + NULL, mainCHECK_TASK_PRIORITY - 1, NULL); + + + /* Start the scheduler. */ + vTaskStartScheduler(); + + /* Will only get here if there was insufficient memory to create + * the idle task. + */ + return 0; +} + +/*-----------------------------------------------------------*/ +void vApplicationTickHook(void) +{ +} + +/*-----------------------------------------------------------*/ + +void ExecuteTestsTask(void *pvParameters) +{ + prvSetupDrivers(); + +// \MARK NEW PINSETTINGS FOR TESTER (2) +#if (PINSET_TESTER == 2) + ledSet(LED1, 1); + ledSet(LED0, 1); +#endif + + mainInit(); + + /* IDLE MODE */ + for (;;) + { +// \MARK NEW PINSETTINGS FOR TESTER (2) +#if (PINSET_TESTER == 2) + vTaskDelay (1000); + ledSet (LED0, FALSE); + vTaskDelay (1000); + ledSet (LED1, TRUE); +#else + vTaskDelay (100); +#endif + + } +} + +/*-----------------------------------------------------------*/ + +inline void prvSetVectors() +{ + unsigned int *ptr; + // Set vectors of interrupt and software interupt + + // Set interrupt vectors + ptr = (unsigned int *)SWI_RAM_ADDR; + *ptr = 0xE59FF018; // This is a ldr pc, [pc,#24] instruction + + // Put SWI, IRQ vectors in RAM + ptr = (unsigned int *)SWI_RAM_FUNC_ADDR; + *ptr = (unsigned int)&vPortYieldProcessor; // Reserved for FreeRTOS +} + +/*-----------------------------------------------------------*/ + +void prvSetupHardware(void) +{ + //UINT32 i = 0; + //volatile UINT32 *vect_addr, *vect_prio; + +#ifdef RUN_FROM_RAM + /* Remap the interrupt vectors to RAM if we are are running from RAM. */ + SCB_MEMMAP = 2; +#endif + + /* Disable the PLL. */ + PLLCON = 0; + PLLFEED = mainPLL_FEED_BYTE1; + PLLFEED = mainPLL_FEED_BYTE2; + /* Configure clock source. */ + SCS |= mainOSC_ENABLE; + while ( !( SCS & mainOSC_STAT )) + ; + CLKSRCSEL = mainOSC_SELECT; + + /* Setup the PLL to multiply the XTAL input by 4. */ + PLLCFG = ( PLL_MUL | PLL_DIV ); + PLLFEED = mainPLL_FEED_BYTE1; + PLLFEED = mainPLL_FEED_BYTE2; + + /* Turn on and wait for the PLL to lock... */ + PLLCON = mainPLL_ENABLE; + PLLFEED = mainPLL_FEED_BYTE1; + PLLFEED = mainPLL_FEED_BYTE2; + CCLKCFG = CCLK_DIV; + while ( !( PLLSTAT & mainPLL_LOCK )) + ; + + /* Connecting the clock. */ + PLLCON = mainPLL_CONNECT; + PLLFEED = mainPLL_FEED_BYTE1; + PLLFEED = mainPLL_FEED_BYTE2; + while ( !( PLLSTAT & mainPLL_CONNECTED )) + ; + + /* Setup and turn on the MAM. Three cycle access is used due to the fast + PLL used. It is possible faster overall performance could be obtained by + tuning the MAM and PLL settings. */ + MAMCR = 0; + MAMTIM = mainMAM_TIM_3; + MAMCR = mainMAM_MODE_FULL; + + // Enable power on ethernet chip for using its RAM + PCONP |= (1 << 30); + + init_VIC(); +} + +void prvSetupDrivers(void) +{ + +#if (PINSET_TESTER == 0) + /* Load Inits necessary for the Olimex DemoBoard */ + ssp0Init(); + ssp0Enable(); + ssp1Init(); + ssp1Enable(); + rtcInit(); + MmcInit(); + CANInit(CANBitrate125k_12MHz); + CANSetFilter (0x00000101); +// ethInit(); + +#endif +#if (PINSET_TESTER == 1) + /* Load Inits necessary and available on IO Controller --> REV_C <-- */ + bpecInit(); + dioInit(); + ledInit(); + ssp0Init(); + ssp0Enable(); + ssp1Init(); + ssp1Enable(); + eepromInit(); + adcInit(); + dacInit(); + powerInit(); + rtcInit(); + MmcInit(); + calibrationInit(); +#endif + +#if (PINSET_TESTER == 2) + /* Load Inits necessary and available on QUA_2475_TESTER */ + bpecInit(); + dioInit(); + rlyInit(); + ledInit(); + ssp0Init(); + ssp0Enable(); + ssp1Init(); + ssp1Enable(); + eepromInit(); + adcInit(); + dacInit(); + powerInit(); + rtcInit(); + MmcInit(); + calibrationInit(); + CANInit(CANBitrate125k_12MHz); +// ethInit(); + +#endif + + menuInit(); /* Init the Menu in every Case */ + + // Open both COM-ports + serInit(COM1, B115200, UART_8N1, UART_FIFO_8); + serInit(COM2, B115200, UART_8N1, UART_FIFO_8); + +#if ((PINSET_TESTER == 1) || (PINSET_TESTER == 2)) + /* BusInit only necessary on IO_CTRL or TESTER, DemoBoard got no Busses */ + busInit(BUS1); + busInit(BUS2); +#endif +} + diff --git a/Tester/SW/Applications/menu/menu.c b/Tester/SW/Applications/menu/menu.c new file mode 100644 index 0000000..2f47f79 --- /dev/null +++ b/Tester/SW/Applications/menu/menu.c @@ -0,0 +1,422 @@ +/* --------------------------------------------------------------------------- + * menu.c (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Apr 01, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +/* Compiler includes */ +#include +#include + +/* Hardware includes */ +#include "lpc23xx.h" +#include "types.h" + +/* FreeRTOS includes */ +#include "FreeRTOS.h" +#include "Task.h" +#include "semphr.h" + +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "topoftest.h" +#include "menu.h" +#include "menufunctions.h" +#include "menuargs.h" +#include "dac.h" +#include "adc.h" +#include "dio.h" +#include "logging.h" +#include "SerOut.h" + +#include "ledfunctions.h" +#include "taskfunctions.h" +#include "BusProtocol.h" + +#include "remote_tests.h" +#include "remote_misc.h" + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ + + +extern const char *command_table[NUMBER_OF_COMMANDS]; +extern const fpointer command_pointer[NUMBER_OF_COMMANDS]; +extern UINT8 cmd_table_offset[ALPHABET_DIGITS]; +extern const char * menuHelptextArray [NUMBER_OF_COMMANDS]; +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ +UINT32 arg1 = 0; +UINT32 arg2 = 0; +UINT32 arg3 = 0; + +BOOLEAN quit = FALSE; +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ +void TABfunction (char * command); + + + +void CallMenu(void) + { + /* local Variable Declaration */ + UINT32 bytesreceived = 0; + static UINT8 receiveString[60]; + static UINT8 backupString[60]; + UINT8 buffer; + BOOLEAN receive; + + char separator[] = " "; + char *commandt; + char *pcmd; + char *arg1t; + char *arg2t; + char *arg3t; + UINT8 command[15]; + UINT8 cmd_len; + + UINT8 loopcnt; + BOOLEAN callhelp = FALSE; + + + do /* do-while loop for Main Menu */ + { + /* Display PROMPT to Console */ + serWrite(MenuPort, strlen("\n\r\n\rCMD> "), (UINT8 *)"\n\r\n\rCMD> "); + + /* Reset String input Variables */ + buffer = 0; + bytesreceived = 0; + + commandt = 0; + cmd_len = 0; + arg1 = 0; + arg2 = 0; + arg3 = 0; + + do /* do-while loop for String input */ + { + if ((receive = serGet(MenuPort, &buffer) == TRUE)) + { + if (buffer == '\t') + { + receiveString[bytesreceived] = '\0'; + TABfunction((char *) receiveString); + } + + /* Detection of Escape characters. VT100 Commands are 4 Bytes, + * so software takes out three more bytes from the buffer. + */ + else if (buffer == 27) + { + serGet(MenuPort, &buffer); + serGet(MenuPort, &buffer); +// serGet(MenuPort, &buffer); + + /* Detection for LEFT and RIGHT Arrow keys. + * Future implementation may be done for advanced shell + */ + if (buffer =='A') + { + serWrite(MenuPort, strlen("\x1B[1B"), (UINT8 *)"\x1B[1B"); + /* UP arrow Key detected */ + if (bytesreceived == 0) + { + /* If Cursor is on the beginning position */ + strcpy ((char *)receiveString, (char *)backupString); + bytesreceived = strlen((char *)backupString); + serWrite(MenuPort, bytesreceived, backupString); + } + } +// else if (buffer == 'B') +// { +// /* DOWN arrow Key detected */ +// } +// +// else if (buffer == 'C') +// { +// /* RIGHT arrow Key detected */ +// bytesreceived++; +// } +// else if (buffer == 'D') +// { +// /* LEFT arrow Key detected */ +// if (bytesreceived > 0) +// { +// /* If cursor is not on first position */ +// bytesreceived--; +// } +// else +// { +// /* Move Cursor one position to right (VT100) */ +// serWrite(SerOutPort, sizeof("\x1B[1C"), "\x1B[1C"); +// } +// } + else + { + /* Any other Control Key detected. Read and ignore */ + serGet(MenuPort, &buffer); + } + } + + else if (buffer == 127) + { + /* If pressed key was BackSpace (NOTE KEYCODE, NOT 0x08)*/ + if (bytesreceived > 0) + { + /* Cursor is not first position, step back in array */ + receiveString[bytesreceived--] = 0; + } + else + { + /* Cursor ist on first position, do not step back */ + /* Move Cursor one position to right (VT100) */ + serWrite(SerOutPort, strlen("\x1B[1C"), (UINT8 *)"\x1B[1C"); + } + } + else if (buffer == 13) + { + receiveString[bytesreceived] = '\0'; + } + else + { + /* Write Byte in String and increase String index */ + receiveString[bytesreceived] = buffer; + bytesreceived++; + } + vTaskDelay(10); /* Share Calculation Time */ + } + }while (buffer != 13); /*Read input until ENTER-Key */ + + writeLog(LogInput, MenuPort, menuMessage, (char *)receiveString); + + /* Copy actual received command string to a backup string */ + strcpy ((char *)backupString, (char *)receiveString); + sendString (MenuPort, GotoNewLine, menuMessage, + "receiveString: ", (char *)receiveString, Dummy); + sendString (MenuPort, GotoNewLine, menuMessage, + "backupString: ", (char *)backupString, Dummy); + + /* Split command and arguments with strtok() function, where a + * SPACE letter is used as devider. + */ + commandt = strtok ((char *)receiveString, (char *)separator); + arg1t = strtok (NULL, (char *)separator); + arg2t = strtok (NULL, (char *)separator); + arg3t = strtok (NULL, (char *)separator); + + if ((pcmd = strstr ((char *)commandt, "_help")) != NULL) + { + callhelp = TRUE; + sendString (MenuPort, GotoNewLine, menuMessage, + "Help Stat recognised ", Dummy, Dummy); + + /* Copy command to an own string */ + cmd_len = strlen (commandt); + strncpy ((char *)command, commandt, (cmd_len - 5)); + command[cmd_len - 5] = '\0'; + } + else + { + callhelp = FALSE; + + /* Copy command to an own string */ + strcpy ((char *)command, commandt); + + /* Detect if arguments are given dezimal or hexadezimal. Detection + * looks for a leading "0x" on the string. Afterwards, the given + * Value is transformed to an integer value with sscanf. No Error + * checking. The value is transformed step by step until the string- + * end token or the first not-hex symbol. + */ + if ((arg1t[0] == 48) && (arg1t[1] == 120)) + { + /* First Argument is given in Hex, transform value */ + sscanf((char *)(arg1t), "%x", &arg1); + } + else + { + /* First argument is given dezimal, cast to integer */ + arg1 = (UINT32) atoi((char *) (arg1t)); + } + + if ((arg2t[0] == 48) && (arg2t[1] == 120)) + { + /* Second Argument is given in Hex, transform value */ + sscanf((char *)(arg2t), "%x", &arg2); + } + else + { + /* Second argument is given dezimal, cast to integer */ + arg2 = (UINT32) atoi((char *) (arg2t)); + } + + if ((arg3t[0] == 48) && (arg3t[1] == 120)) + { + /* Third Argument is given in Hex, transform value */ + sscanf((char *)(arg3t), "%x", &arg3); + } + else + { + /* Third argument is given dezimal, cast to integer */ + arg3 = (UINT32) atoi((char *) (arg3t)); + + } + } + + sendString (MenuPort, GotoNewLine, menuMessage, + "commandt: ", (char *)commandt, Dummy); + sendString (MenuPort, FALSE, menuMessage, + "\tcommand: ", (char *)command, Dummy); + sendString (MenuPort, GotoNewLine, menuMessage, + "arg1t: ", (char *)arg1t, Dummy); + sendString (MenuPort, FALSE, menuMessage, + "\targ1: ", ItoDStr(arg1), Dummy); + sendString (MenuPort, GotoNewLine, menuMessage, + "arg2t: ", (char *)arg2t, Dummy); + sendString (MenuPort, FALSE, menuMessage, + "\targ2: ", ItoDStr(arg2), Dummy); + sendString (MenuPort, GotoNewLine, menuMessage, + "arg3t: ", (char *)arg3t, Dummy); + sendString (MenuPort, FALSE, menuMessage, + "\targ3: ", ItoDStr(arg3), Dummy); + + + /* Advanced Search algorithm for commands */ + /* Menu structure is based on 2 tables for the commands and one more + * as offset. + * The given command is first checked on a valid first letter. If + * valid, this letter is compared with the offset table. If an offset + * is defines for the first letter, at least commands with this first + * letter exist. Do a string compare starting at the address in the + * command array given by the offset for the first letter. This + * prevents of scanning all commands beginning with a different letter + */ + + if ((command[0] >= 97) && (command[0] <= 122)) + { + /* First sign of command is within specified Range */ + if (cmd_table_offset[(command[0] - 97)] != 0xFF) + { + /* If Offset for specified letter is available */ + for (loopcnt = (cmd_table_offset[(command[0] - 97)]); + loopcnt < NUMBER_OF_COMMANDS; + loopcnt++) + { + /* Try to find the typed in command starting on the + * offset position given with the first letter. + */ + if (strcmp ((char *)command, command_table[loopcnt]) == 0) + { + /* Found a valid command! + * Use the found array-index to grip the corresponding + * function pointer from pointer-array + */ + if (callhelp == FALSE) + { + (*command_pointer[loopcnt])(); + } + else + { + sendString (MenuPort, TRUE, importantMessage, + (char *) menuHelptextArray[loopcnt], Dummy, Dummy); +// debugPrint((char *)menuHelptextArray[loopcnt]); + } + break; + } + if (loopcnt == (NUMBER_OF_COMMANDS - 1)) + { + /* No valid command was found. give Error Emssage */ + sendString (MenuPort, TRUE, importantMessage, + (char *) command," - No such command!", Dummy); + } + } + } + else + { + /* No Offset available for the specified letter */ + sendString (MenuPort, TRUE, importantMessage, + (char *) command," - No such command!", Dummy); + } + } + else + { + /* First letter is out of the specified Range */ + sendString (MenuPort, TRUE, importantMessage, + (char *) command," - No such command!", Dummy); + } + + + receiveString[0] = '\0'; + + vTaskDelay(100); + } while (quit == FALSE); +} + + +void TABfunction (char * command) +{ + UINT32 loopcnt; + UINT32 commandlength; + + commandlength = strlen (command); + serWrite (MenuPort, strlen ("\n\r\t\t"), (UINT8 *)"\n\r\t\t"); + + if ((command[0] >= 97) && (command[0] <= 122)) + { + /* First sign of command is within specified Range */ + if (cmd_table_offset[(command[0] - 97)] != 0xFF) + { + /* If Offset for specified letter is available */ + for (loopcnt = (cmd_table_offset[(command[0] - 97)]); + loopcnt < NUMBER_OF_COMMANDS; + loopcnt++) + { + if (strncmp ((char *)command, command_table[loopcnt], commandlength) == 0) + { + sendString (MenuPort, FALSE, importantMessage, + " ", (char *)command_table[loopcnt], Dummy); + } + } + } + else + { + + } + } + + /* Display PROMPT to Console */ + serWrite(MenuPort, strlen("\n\r\n\rCMD> "), (UINT8 *)"\n\r\n\rCMD> "); + serWrite (MenuPort, strlen (command), (UINT8 *)command); + +} diff --git a/Tester/SW/Applications/menu/menu.h b/Tester/SW/Applications/menu/menu.h new file mode 100644 index 0000000..5b6aa5a --- /dev/null +++ b/Tester/SW/Applications/menu/menu.h @@ -0,0 +1,68 @@ +/* --------------------------------------------------------------------------- + * testmenu.h (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * Headfile for the CMD Prompt File testmenu.c + * --------------------------------------------------------------------------- + * Version(s): 0.1, Apr 01, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef TESTMENU_H_ +#define TESTMENU_H_ + +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ +#include "lpc23xx.h" +#include "types.h" + + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function: CallMenu + * + * Function to display a simplyfied PROMPT on COM-Port. + * + * Parameter: void + * + * Return: void + * --------------------------------------------------------------------------- + */ +void CallMenu(void); + + +#endif /*TESTMENU_H_*/ diff --git a/Tester/SW/Applications/menu/menuargs.c b/Tester/SW/Applications/menu/menuargs.c new file mode 100644 index 0000000..64b45b5 --- /dev/null +++ b/Tester/SW/Applications/menu/menuargs.c @@ -0,0 +1,383 @@ +/* --------------------------------------------------------------------------- + * menuargs.c (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Nov 13, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +/* Compiler includes */ +#include + +#include "LPC23xx.h" +#include "types.h" +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "menuargs.h" +#include "menufunctions.h" + +#include "SerOut.h" + +#include "can.h" + +#include "remote_tests.h" + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ +#define ASCII_START 97 +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ + +/* Make Sure that at least the first letter of this is in alphabetical order*/ +const char *command_table[NUMBER_OF_COMMANDS] = +{ + "aio", + "battery", + "bus", + "canread", + "cantest", + "canwrite", + "ccin", + "ccout", + "cdel", + "cload", + "confin", + "confout", + "cslave", + "curout", + "curin", + "cvin", + "cvout", + "digiin", + "digiout", + "dio", + "eeprom", + "fattest", + "help", + "initSD", + "initTest", + "ledclean", + "ledtest", + "listlocal", +// "listremoteattach", + "logenable", + "logmount", + "logstart", + "logstop", + "ls", + "menudebug", + "mmc", + "power", + "quit", + "readrtc", + "remotecall", + "rtc", + "run", + "stat_cal", + "stat_def", + "stat_kill", + "stat_show", + "stat_showall", + "setmux", + "setrtc", + "tasksdelete", + "volin", + "volout" +}; + +/* Make Sure that at least the first letter of this is in alphabetical order*/ +const fpointer command_pointer[NUMBER_OF_COMMANDS] = +{ + m_aio, + m_battery, + m_bus, + m_canread, + m_cantest, + m_canwrite, + m_ccin, + m_ccout, + m_cdel, + m_cload, + m_confin, + m_confout, + m_cslave, + m_curout, + m_curin, + m_cvin, + m_cvout, + m_digiin, + m_digiout, + m_dio, + m_eeprom, + m_fattest, + m_help, + m_initSD, + r_TestInit, + m_clean, + m_ledtest, + m_listLocalattachments, +// m_listremoteattachments, + m_logEnable, + m_sdMount, + m_logStart, + m_logStop, + m_loglist, + m_menuDebug, + m_mmc, + m_power, + m_quit, + m_readRTC, + m_callRemoteFunction, + m_rtc, + m_run, + m_c_cal, + m_c_def, + m_c_kill, + m_c_stat, + m_c_show, + m_switchMux, + m_setRTC, + m_tasksdelete, + m_volin, + m_volout, +}; + +/* Array to store the offsets to the first letters of commands */ +UINT8 cmd_table_offset[ALPHABET_DIGITS]; + +const char * menuHelptextArray [NUMBER_OF_COMMANDS] = +{ + "\n\r\n\r\taio arg1 arg2\n\r\ttests the analogue in- and outputs" + "\n\r\n\r\t\targ1: device number. 0 sets up a self test" + "\n\r\t\targ2: test type (0: MB, 1: EB) (Only on remote test)", + + "\n\r\n\r\tbattery arg1\n\r\ttests the battery supply of a remote device" + "\n\r\n\r\t\targ1: device number. 0 is self device", + + "\n\r\n\r\tbus\n\r\ttests the local bus connections with transmit and receive strings", + + "\n\r\n\r\tcanread\n\r\tPrints out the actual frame received on CAN", + + "\n\r\n\r\tcantest\n\r\tTests the CAN interface with a Self Test", + + "\n\r\n\r\tcanwrite arg1 arg2 arg3\n\r\twrites a message in a CAN frame" + "\n\r\n\r\t\targ1 - Bits 0-10: Identifier, 13-15: Interface Number, 16-19: Data Length" + "\n\r\t\targ2 - first 4 Bytes of Message" + "\n\r\t\targ3 - last 4 Bytes of Message", + + "\n\r\n\r\tccin\n\r\tcalibrate the local analogue current inputs" + "\n\r\tPut calibration Value (e.g.20 mA) on each line separately when asked for", + + "\n\r\n\r\tccout\n\r\tcalibrate the local analogue current outputs" + "\n\r\tOnly useful with already calibrated analogue current inputs" + "\n\r\tConnect outputs 0-5 to inputs 0-5. Software works automated", + + "\n\r\n\r\tcdel arg1 arg2\n\r\tDeletes and resets the calibration values in eeprom" + "\n\r\n\r\t\targ1: number of target device" + "\n\r\t\targ2=0-3: kind of values to reset - 0=VI, 1=VO, 2=CI, 3=CO", + + "\n\r\n\r\tcload arg1 arg2\n\r\treloads calibration values from EEPROM to system" + "\n\r\n\r\t\targ1: number of target device" + "\n\r\t\targ2=0-3: kind of values to reset - 0=VI, 1=VO, 2=CI, 3=CO", + + "\n\r\n\r\tconfin arg1 arg2\n\r\tConfigures an analogue input on local device" + "\n\r\n\r\t\targ1=0-7, 9: chose channel 0-7 or chose all channels with 9" + "\n\r\t\targ2=0-1: 0: Sets mode to Voltage, 1: Sets mode to Current", + + "\n\r\n\r\tconfout arg1 arg2\n\r\tConfigures an analogue input on local device" + "\n\r\n\r\t\targ1=0-5, 9: chose channel 0-7 or chose all channels with 9" + "\n\r\t\targ2=0-1: 0: Sets mode to Voltage, 1: Sets mode to Current", + + "\n\r\n\r\tcslave\n\r\tcalibrates the slave with number 2", + + "\n\r\n\r\tcurout arg1 arg2 arg3\n\r\tDrives an analogue Output with current value" + "\n\r\n\r\t\targ1: device number" + "\n\r\t\targ2=0-5: channel number" + "\n\r\t\targ3=0-20000: value", + + "\n\r\n\r\tcurin arg1 arg2\n\r\t Reads the actual current value from a analogue input" + "\n\r\n\r\t\targ1: device number" + "\n\r\t\targ2: channel number", + + "\n\r\n\r\tcvin\n\r\tCalibrates the analogue voltage inputs" + "\n\r\tPut calibration value (e.g.10 V) on all inputs at the same time." + "\n\r\tSoftware works automated", + + "\n\r\n\r\tcvout\n\r\tCalibrate the analogue voltage outputs" + "\n\r\tOnly useful with already calibrated analogue voltage inputs" + "\n\r\tConnect outputs 0-5 to inputs 0-5. Software works automated", + + "\n\r\n\r\tdigiin arg1 arg2\n\r\tReads the actual value of a digital input" + "\n\r\n\r\t\targ1: device number" + "\n\r\t\targ2: channel number", + + "\n\r\n\r\tdigiout arg1 arg2 arg3\n\r\tWrites to a digital output" + "\n\r\n\r\t\targ1: device number" + "\n\r\t\targ2: channel number" + "\n\r\t\targ3=0-1: 0: FALSE/LOW, 1: TRUE/HIGH", + + "\n\r\n\r\tdio arg1 arg2\n\r\tTests the digital in- and outputs" + "\n\r\n\r\t\targ1: device number. 0 sets up a self test" + "\n\r\t\targ2: test type (0: MB, 1: EB) (Only on remote test)", + + "\n\r\n\r\teeprom arg1\n\r\tTests the connection and algorithms of the EEPROM" + "\n\r\n\r\t\targ1: device number. 0 sets up a self test", + + "\n\r\n\r\tfattest\n\r\tTest sequence for FAT Filesystem on SD/MMC", + + "\n\r\n\r\thelp\n\r\tCALLS HELP, WHAT ELSE???", + + "\n\r\n\r\tinitSD\n\r\tInitialises the SD Card", + + "\n\r\n\r\tinitTest\n\r\tInitialises the remote test applications", + + "\n\r\n\r\tledclean arg1\n\r\tSets all digital output LEDs to OFF" + "\n\r\n\r\t\targ1: device number", + + "\n\r\n\r\tledtest arg1\n\r\tTests all LEDs available" + "\n\r\n\r\t\targ1: device number. 0 sets up a self test", + + "\n\r\n\r\tlistlocalattach\n\r\tLists all local bus-attached functions", + +// "\n\r\n\r\tlistremoteattach\n\r\tLists all remote bus-attached functions", + + "\n\r\n\r\tlogenable arg1\n\r\tEnables/Disables Output logging" + "\n\r\n\r\targ1=0-1: 0: disable, 1: enable", + + "\n\r\n\r\tlogmount\n\r\tmounts the SD Card to file system", + + "\n\r\n\r\tlogstart arg1\n\r\tStarts logging on file" + "\n\r\n\r\targ1: serial number of device and filename of log-file", + + "\n\r\n\r\tlogstop\n\r\tstops logging on file", + + "\n\r\n\r\tls\n\rlists all existing logfiles", + + "\n\r\n\r\tmenudebug arg1\n\r\tEnables detailed messages from the menu" + "\n\r\n\r\t\targ1=0-1: 1: enable, 0: disable", + + "\n\r\n\r\tmmc arg1\n\r\tTests the memory card interface" + "\n\r\n\r\t\targ1: device number. 0 sets up a self test", + + "\n\r\n\r\tpower arg1\n\r\tTests the devices power connections" + "\n\r\n\r\t\targ1: device number. 0 sets up a self test", + + "\n\r\n\r\tquit\n\r\tEXITS MENU", + + "\n\r\n\r\treadrtc\n\r\tReads the RTC", + + "\n\r\n\r\tremotecall arg1 arg2 arg3\n\r\tCalls remote functions on Salve" + "\n\r\n\r\t\targ1: Remote function number" + "\n\r\t\targ2: Number of function parameters" + "\n\r\t\targ3: Function paramters", + + "\n\r\n\r\trtc arg1\n\r\tTests the RealTime Clock" + "\n\r\n\r\t\targ1: device number. 0 sets up a self test", + + "\n\r\n\r\trun\n\r\tRuns a complete test sequence", + + "\n\r\n\r\tstat_cal arg1\n\r\tSets the status of the analogue in- and outputs to CALIBRATED" + "\n\r\n\r\t\targ1: device number. 0 is self device", + + "\n\r\n\r\tstat_def arg1\n\r\tSets the status of the analogue in- and outputs to DEFAULT" + "\n\r\n\r\t\targ1: device number. 0 is self device", + + "\n\r\n\r\tstat_kill arg1\n\r\tDeletes the status of the analogue in- and outputs" + "\n\r\n\r\targ1: device number. 0 is self device", + + "\n\r\n\r\tstat_show arg1 arg2\n\r\tShows the status of the analogue in- and outputs" + "\n\r\n\r\t\targ1: device number" + "\n\r\t\targ2: Status type - 0=VI, 1=VO, 2=CI, 3=CO", + + "\n\r\n\r\tstat_showall arg1\n\r\tShows the status of ALL analogue in- and outputs" + "\n\r\n\r\t\targ1: device number", + + "\n\r\n\r\tsetMux arg1 arg2\n\r\tSets the in- and ouput mux devices" + "\n\r\n\r\t\targ1: Mux type (0: DI; 1: DO; 2: AI; 3: AO)" + "\n\r\t\targ2: Mode (0: Main board; 1: Extension board)", + + "\n\r\n\r\tsetRTC arg1 arg2 arg3\n\r\tSets Date and Time in the RTC" + "\n\r\n\r\targ1:|day|hour|minutes|seconds| (each 8 bit)" + "\n\r\targ2: |0|0|0|0|month|dayOfWeek (each 8 bit)" + "\n\r\targ3: |dayOfYear|year| (each 16 bit)", + + "\n\r\n\r\ttasksdelete\n\r\tDeletes all testLED tasks", + + "\n\r\n\r\tvolin arg1 arg2\n\r\tReads actual value on analogue voltage input" + "\n\r\n\r\t\targ1: device number. 0 is self device" + "\n\r\t\targ2=0-7: channel number", + + "\n\r\n\r\tvolout arg1 arg2 arg3\n\r\tDrives analogue voltage output" + "\n\r\n\r\t\targ1: device number. 0 is self device" + "\n\r\t\targ2=0-5: channel number" + "\n\r\t\targ3=0-10000: Value" + + +}; +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ + +void menuInit (void) +{ + UINT8 loopcnt = 0; + UINT8 asciicnt; + BOOLEAN breakout; + + /* Calculate Array-Offsets for each possible first letter + * The actual Letter is mentioned in asciicnt, which starts with dezimal + * code of the first, small letter (a = 97). + */ + for (asciicnt = ASCII_START; asciicnt < (ASCII_START + ALPHABET_DIGITS); asciicnt++) + { + loopcnt = 0; + breakout = FALSE; + /* Perform search as long as no accordance was found or array ends */ + while (breakout == FALSE) + { + if (loopcnt < NUMBER_OF_COMMANDS) + { + if (command_table[loopcnt][0] == asciicnt) + { + /* Accordance found! Save Offset in offset-array */ + cmd_table_offset[(asciicnt - ASCII_START)] = loopcnt; + breakout = TRUE; /* Enable breakout of loop */ + } + } + else + { + /* No Accordance found. Save "NO OFFSET" to offset-array */ + cmd_table_offset[(asciicnt - ASCII_START)] = 0xFF; + breakout = TRUE; /* Enable breakout of loop */ + } + loopcnt++; + } + } +} diff --git a/Tester/SW/Applications/menu/menuargs.h b/Tester/SW/Applications/menu/menuargs.h new file mode 100644 index 0000000..461e9fd --- /dev/null +++ b/Tester/SW/Applications/menu/menuargs.h @@ -0,0 +1,54 @@ +/* --------------------------------------------------------------------------- + * menuargs.h (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Nov 13, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef MENUARGS_H_ +#define MENUARGS_H_ +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ +#define ALPHABET_DIGITS 26 +#define NUMBER_OF_COMMANDS 55 +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ +typedef void (*fpointer)(void); +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ + +void menuInit (void); + +#endif /*MENUARGS_H_*/ diff --git a/Tester/SW/Applications/menu/menufunctions.c b/Tester/SW/Applications/menu/menufunctions.c new file mode 100644 index 0000000..2faff66 --- /dev/null +++ b/Tester/SW/Applications/menu/menufunctions.c @@ -0,0 +1,1439 @@ +/* --------------------------------------------------------------------------- + * menufunctions.c (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Nov 14, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +#include "LPC23xx.h" +#include "types.h" + +/* FreeRTOS includes */ +#include "FreeRTOS.h" +#include "Task.h" +#include "semphr.h" +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "topoftest.h" +#include "logging.h" + +#include "BusProtocol.h" + +#include "menufunctions.h" +#include "menuargs.h" + +#include "remote_misc.h" +#include "remote_tests.h" + +#include "ledfunctions.h" +#include "taskfunctions.h" +#include "protocolfunctions.h" + +/* Driver includes */ +#include "serOut.h" +#include "adc.h" +#include "can.h" +#include "dac.h" +#include "dio.h" +#include "calibrateaio.h" +#include "logging.h" +#include "rtc.h" + +/* Test includes */ +#include "testLED.h" +#include "testdio.h" +#include "testaio.h" +#include "testBUS.h" +#include "testcan.h" +#include "testeeprom.h" +#include "testMMC.h" +#include "testpower.h" +#include "testrtc.h" +#include "calibrateaio.h" + +/* remote drivers */ +#include "remote_analogue.h" +#include "remote_digital.h" +#include "remote_relay.h" + +/* Remote test includes */ +#include "test_analogue.h" +#include "test_digital.h" +#include "test_leds.h" + +#include "fat_test.h" +#include "fat_public.h" + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ +extern const char *command_table[NUMBER_OF_COMMANDS]; + +extern UINT32 arg1; +extern UINT32 arg2; +extern UINT32 arg3; + +extern BOOLEAN quit; + +extern UINT32 UINT32result; + + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ + + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ + + +void m_run(void) +{ + dioClean(); + diotasksdelete(); + // \MARK Automatic Test not necessary on Olimex Board +#if ((PINSET_TESTER == 1) || (PINSET_TESTER == 2)) +// automaticdesigntest(); // \TODO NO AUTOMATIC TEST AVAILABLE +#else + sendString(MenuPort, TRUE, importantMessage, + "Automatic Test not available! -> OlimexBoard", Dummy, Dummy); +#endif +} + +/* + * INPUT AND OUTPUT SECTION + */ + +/* Set analogue Output */ +void m_confout (void) + { + /* arg1: Channel + * arg2: Mode + */ + if ((arg2 == 1) && ((arg1 >= 0) && (arg1 < 10))) + { + if (arg1 == 9) + { + dacModeAll(dacCURRENT); + } + else + { + dacMode(arg1, dacCURRENT); + } + sendString(MenuPort, TRUE, importantMessage, "Configured Output ", + ItoDStr(arg1), " to CURRENT"); + + } + else if ((arg2 == 0) && ((arg1 >= 0) && (arg1 < 10))) + { + if (arg1 == 9) + { + dacModeAll(dacVOLTAGE); + } + else + { + dacMode(arg1, dacVOLTAGE); + } + sendString(MenuPort, TRUE, importantMessage, "Configured Output ", + ItoDStr(arg1), " to VOLTAGE"); + + } + else + { + sendString(MenuPort, TRUE, importantMessage, "ARGUMENT ERROR! Did nothing... ", + Dummy, Dummy); + } +} + + +/* Set analogue Input */ +void m_confin (void) + { + /* arg1: Channel + * arg2: Mode + */ + if ((arg2 == 1) && ((arg1 >= 0) && (arg1 < 10))) + { + if (arg1 == 9) + { + adcModeAll(adcCURRENT); + } + else + { + adcMode(arg1, dacCURRENT); + } + sendString(MenuPort, TRUE, importantMessage, "Configured Input ", + ItoDStr(arg1), " to CURRENT"); + + } + else if ((arg2 == 0) && ((arg1 >= 0) && (arg1 < 10))) + { + if (arg1 == 9) + { + adcModeAll(adcVOLTAGE); + } + else + { + adcMode(arg1, dacVOLTAGE); + } + sendString(MenuPort, TRUE, importantMessage, "Configured Input ", + ItoDStr(arg1), " to VOLTAGE"); + + } + else + { + sendString(MenuPort, TRUE, importantMessage, "ARGUMENT ERROR! Did nothing... ", + Dummy, Dummy); + } +} + + +void m_switchMux(void) +{ + /* arg1: Mux type (0: DI; 1: DO; 2: AI; 3: AO) + * arg2: value (0: main board; 1: extensionboard) + */ + + if (((arg1 >= 0) && (arg1 < 4)) && ((arg2 == 0) || (arg2 == 1))) + { + switch (arg1) + { + case 0: + /* Effect Mux of digital input */ + dio_inMuxEn(arg2); + if (arg2 == 0) + { + sendString (SerOutPort, GotoNewLine, importantMessage, + "Switched digital input mux to Mainboard", Dummy, Dummy); + } + else if (arg2 == 1) + { + sendString (SerOutPort, GotoNewLine, importantMessage, + "Switched digital input mux to Extensionboard", Dummy, Dummy); + } + break; + case 1: + /* Effect Mux of digital output */ + dio_outMuxEn(arg2); + if (arg2 == 0) + { + sendString (SerOutPort, GotoNewLine, importantMessage, + "Switched digital output mux to Mainboard", Dummy, Dummy); + } + else if (arg2 == 1) + { + sendString (SerOutPort, GotoNewLine, importantMessage, + "Switched digital output mux to Extensionboard", Dummy, Dummy); + } + break; + case 2: + /* Effect Mux of analogue input */ + adc_MuxEn(arg2); + if (arg2 == 0) + { + sendString (SerOutPort, GotoNewLine, importantMessage, + "Switched analogue input mux to Mainboard", Dummy, Dummy); + } + else if (arg2 == 1) + { + sendString (SerOutPort, GotoNewLine, importantMessage, + "Switched analogue input mux to Extensionboard", Dummy, Dummy); + } + break; + case 3: + /* Effect Mux of analogue output */ + dac_MuxEn(arg2); + if (arg2 == 0) + { + sendString (SerOutPort, GotoNewLine, importantMessage, + "Switched analogue output mux to Mainboard", Dummy, Dummy); + } + else if (arg2 == 1) + { + sendString (SerOutPort, GotoNewLine, importantMessage, + "Switched analogue output mux to Extensionboard", Dummy, Dummy); + } + break; + + } + } +} + + +/* Drive local or remote Current Output */ +void m_curout(void) +{ + /* arg1: device + * arg2: channel + * arg3: value + */ + + RESULT writeResult; + + /* check arguments: vaild device number, valid channel, valid value */ + if ((arg1 >= 0) && (arg2 < maxDAC_Channels) && ((arg3 >= 0) && (arg3 + <= maxDAC_CURRENT))) + { + if (arg1 == remoteDeviceNumber) + { + adcMode(arg2, dacCURRENT); + vTaskDelay(100); + writeResult = remoteAioWrite(arg1, arg2, arg3); + + if (writeResult == OK) + { + sendString(MenuPort, TRUE, importantMessage, + "Wrote Output to: ", ItoDStr(arg3), " uA"); + } + else + { + sendString (SerOutPort, TRUE, importantMessage, + "\tan error occured on writing", Dummy, Dummy); + } + } + else + { + adcMode(arg2, adcCURRENT); + dacMode(arg2, dacCURRENT); + + vTaskDelay(100); + dacWrite(arg1, arg2, arg3); + + sendString(MenuPort, TRUE, importantMessage, "Wrote Output to: ", + ItoDStr(dacReadBack(arg1, arg2)), " uA"); + } + } else + { + sendString(MenuPort, TRUE, importantMessage, + "ARGUMENT ERROR! Did nothing... ", Dummy, Dummy); + } +} + + +/* Drive local or remote Voltage Output x */ +void m_volout(void) +{ + /* arg1: device + * arg2: channel + * arg3: value + */ + if ((arg1 >= 0) && (arg2 < maxDAC_Channels) && ((arg3 >= 0) && (arg3 + <= maxDAC_VOLTAGE))) + { + if (arg1 == 0) + { + dacMode(arg2, dacVOLTAGE); + adcMode(arg2, dacVOLTAGE); + if (arg2 < 4) + { + adcMode((arg2 + 4), dacVOLTAGE); + } + else + { + adcMode((arg2 - 4), dacVOLTAGE); + } + vTaskDelay(100); + dacWrite(arg1, arg2, arg3); + sendString(MenuPort, TRUE, importantMessage, "Wrote Output to: ", + ItoDStr(dacReadBack(arg1, arg2)), " mV"); + } + + else + { + sendString(MenuPort, TRUE, importantMessage, + "\tremote device does not support voltage outputs", Dummy, + Dummy); + } + } + else + { + sendString(MenuPort, TRUE, importantMessage, + "ARGUMENT ERROR! Did nothing... ", Dummy, Dummy); + } + +} + + +/* Drive local or remote digital Output x */ +void m_digiout(void) +{ + /* arg1: device + * arg2: channel + * arg3: value + */ + + RESULT writeStatus; + + if ((arg1 >= 0) && (arg2 < NUMBER_OF_TOTAL_DO) && ((arg3 >= 0) && (arg3 + < 2))) + { + if (arg1 == remoteDeviceNumber) + { + /* working on slave device of test environment */ + + if (arg3 == 0) + { + writeStatus = remoteDioWrite((UINT8)arg1, (UINT8)arg2, FALSE); + } + else + { + writeStatus = remoteDioWrite((UINT8)arg1, (UINT8)arg2, TRUE); + } + if (writeStatus == OK) + { + sendString(MenuPort, TRUE, importantMessage, + "Wrote Output to: ", + BooltoStr(remoteDigitalOutputs[arg2]), Dummy); + } + else + { + sendString (SerOutPort, TRUE, importantMessage, + "\tan error occured on writing", Dummy, Dummy); + } + } + else + { + if (arg3 == 0) + { + dioWrite(arg1, arg2, FALSE); + } else if (arg3 == 1) + { + dioWrite(arg1, arg2, TRUE); + } + sendString(MenuPort, TRUE, importantMessage, "Wrote Output to: ", + BooltoStr(arg3), Dummy); + } + } + else + { + sendString(MenuPort, TRUE, importantMessage, + "ARGUMENT ERROR! Did nothing... ", Dummy, Dummy); + } +} + + +/* Read Voltage on Input x */ +void m_volin(void) +{ + /* arg1: device + * arg2: channel + */ + + if ((arg1 >= 0) && (arg2 < maxADC_Channels)) + { + if (arg1 != remoteDeviceNumber) + { + adcMode(arg2, adcVOLTAGE); + sendString(MenuPort, TRUE, importantMessage, "Voltage on Input ", + ItoDStr(arg2), ": "); + sendString(MenuPort, FALSE, importantMessage, ItoDStr(adcRead( + arg1, arg2)), Dummy, Dummy); + } + else + { + sendString (SerOutPort, TRUE, importantMessage, + "\tremote device does not support voltage inputs", Dummy, Dummy); + } + } + else + { + sendString(MenuPort, TRUE, importantMessage, + "ARGUMENT ERROR! Did nothing... ", Dummy, Dummy); + } + +} + + +/* Read Current on specific analogue Input */ +void m_curin(void) +{ + /* arg1: device + * arg2: channel + */ + if ((arg1 >= 0) && (arg2 < maxADC_Channels)) + { + adcMode(arg2, adcCURRENT); + sendString(MenuPort, TRUE, importantMessage, "Current on Input ", + ItoDStr(arg2), ": "); + sendString(MenuPort, FALSE, importantMessage, + ItoDStr(adcRead(arg1, arg2)), Dummy, Dummy); + } + else + { + sendString(MenuPort, TRUE, importantMessage, + "ARGUMENT ERROR! Did nothing... ", Dummy, Dummy); + } +} + + +/* Read local or remote digital Output x */ +void m_digiin(void) +{ + /* arg1: device + * arg2: channel + */ + + if ((arg1 >= 0) && (arg2 < NUMBER_OF_TOTAL_DI)) + { + if (arg1 == remoteDeviceNumber) + { + /* working on the slave device of test environment */ + sendString(MenuPort, TRUE, importantMessage, "Value on Input ", + ItoDStr(arg2), ": "); + sendString(MenuPort, FALSE, importantMessage, + BooltoStr(remoteDioRead(arg1, arg2)), Dummy, Dummy); + } + else + { + sendString(MenuPort, TRUE, importantMessage, "Value on Input ", + ItoDStr(arg2), ": "); + sendString(MenuPort, FALSE, importantMessage, + BooltoStr(dioRead(arg1, arg2)), Dummy, Dummy); + } + } + else + { + sendString(MenuPort, TRUE, importantMessage, + "ARGUMENT ERROR! Did nothing... ", Dummy, Dummy); + } +} + + +void m_canread (void) +{ + CAN_MSG ReceiveMessage; + + CANPullMessage(&ReceiveMessage); + + sendString (SerOutPort, TRUE, resultMessage, + "read on CAN: \n\r", "\tData1: ", ItoHStr (ReceiveMessage.Dat1)); + sendString (SerOutPort, TRUE, resultMessage, + "\tDataA: ", ItoHStr (ReceiveMessage.DatA), Dummy); + sendString (SerOutPort, TRUE, resultMessage, + "\tDataB: ", ItoHStr (ReceiveMessage.DatB), Dummy); +} + + +/* Write on the CAN bus */ +void m_canwrite (void) +{ + CAN_MSG SendMessage; + + SendMessage.Dat1 = arg1; /* Set Length and Filter */ + SendMessage.DatA = arg2; /* Define first 4 Bytes */ + SendMessage.DatB = arg3; /* Define last 4 bytes */ + + CANPushMessage(&SendMessage); + + sendString (SerOutPort, TRUE, importantMessage, + "wrote to CAN: \n\r", "\tData1: ", ItoHStr (SendMessage.Dat1)); + sendString (SerOutPort, TRUE, importantMessage, + "\tDataA: ", ItoHStr (SendMessage.DatA), Dummy); + sendString (SerOutPort, TRUE, importantMessage, + "\tDataB: ", ItoHStr (SendMessage.DatB), Dummy); +} + + +/* + * CALIBRATION SECTION + */ + +/* Calibrate Voltage Outputs */ +void m_cvout (void) +{ + dioClean(); + diotasksdelete(); + calibrateVoltageOutput(); +} + + +/* Calibrate Voltage Inputs */ +void m_cvin (void) +{ + dioClean(); + diotasksdelete(); + calibrateVoltageInput(); +} + + +/* Calibrate Current Outputs */ +void m_ccout (void) +{ + dioClean(); + diotasksdelete(); + calibrateCurrentOutput(); +} + + +/* Calibrate Current Inputs */ +void m_ccin (void) +{ + dioClean(); + diotasksdelete(); + calibrateCurrentInput(); +} + + +/* Delete calibrate values in EEPROM */ +void m_cdel(void) +{ + // \TODO TEST ARG2, WAS INT32 BEFORE + /* arg1: device + * arg2: calibration type + */ + if ((arg1 >= 0) && (arg2 < maxCAL_types)) + { + if (arg1 == remoteDeviceNumber) + { + /* Overwrite old Values in EEPROM with default Value 0xFFF */ + bpSendCallRpc(handleBus1, 2, 12, 1, (INT32)&arg2); + sendString(MenuPort, TRUE, importantMessage, + "Calibration Values on Slave for Type ", ItoDStr(arg2), + " deleted"); + } + else if (arg1 == thisDeviceNumber) + { + deleteCorrectionValue(arg2); + sendString(MenuPort, TRUE, importantMessage, + "Calibration Values for Type ", ItoDStr(arg2), " deleted"); + } + } + else + { + sendString(MenuPort, TRUE, importantMessage, + "ARGUMENT ERROR! Did nothing... ", Dummy, Dummy); + } +} + + +/* Load calibration Values from EEPROM */ +void m_cload(void) +{ + // \TODO TEST ARG2, WAS INT32 BEFORE + /* arg1: device + * arg2: calibration type + */ + if ((arg1 >= 0) && (arg2 < maxCAL_types)) + { + if (arg1 == remoteDeviceNumber) + { + /* Overwrite old Values in EEPROM with default Value 0xFFF */ + bpSendCallRpc(handleBus1, 2, 11, 1, (INT32)&arg2); + sendString(MenuPort, TRUE, importantMessage, + "Calibration Values on Slave for Type ", ItoDStr(arg2), + " loaded from EEPROM"); + } + else if (arg1 == thisDeviceNumber) + { + loadCorrectionValue_defaultTarget(arg2); + sendString(MenuPort, TRUE, importantMessage, + "Calibration Values for Type ", ItoDStr(arg2), + " loaded from EEPROM"); + } + } + else + { + sendString(MenuPort, TRUE, importantMessage, + "ARGUMENT ERROR! Did nothing... ", Dummy, Dummy); + } +} + + +/* Show Status of Calibration Values in EEPROM */ +void m_c_stat(void) +{ + UINT8 readback; + // \TODO TEST ARG2, WAS INT32 BEFORE + /* arg1: device + * arg2: calibration type + */ + if ((arg1 >= 0) && (arg2 < maxCAL_types)) + { + if (arg1 == thisDeviceNumber) + { + readback = returnCalibrationStatus(arg2); + if (readback == ident_default) + { + sendString(MenuPort, TRUE, importantMessage, + "Values are in DEFAULT Mode", Dummy, Dummy); + } + else if (readback == ident_calibrated) + { + sendString(MenuPort, TRUE, importantMessage, + "Values are in CALIBRATED Mode", Dummy, Dummy); + } + else + { + sendString(MenuPort, TRUE, importantMessage, + "NO VALID VALUES IN EEPROM", Dummy, Dummy); + } + } + + else if (arg1 == remoteDeviceNumber) + { + xSemaphoreTake(generalSemaphore, 0); + bpSendCallRpc(handleBus1, arg1, 13, 1, (INT32)&arg2); + if (xSemaphoreTake(generalSemaphore, 5000) != pdPASS) + { + /* Semaphore is not released, timeout in transmission */ + sendString(SerOutPort, TRUE, importantMessage, + "\tTimeout occoured!", Dummy, Dummy); + xSemaphoreGive(generalSemaphore); + + } + else + { + if (UINT32result & ident_default) + { + sendString(MenuPort, TRUE, importantMessage, + "Values are in DEFAULT Mode", Dummy, Dummy); + } + else if (UINT32result & ident_calibrated) + { + sendString(MenuPort, TRUE, importantMessage, + "Values are in CALIBRATED Mode", Dummy, Dummy); + } + else + { + sendString(MenuPort, TRUE, importantMessage, + "NO VALID VALUES IN EEPROM", Dummy, Dummy); + } + } + } + } + else + { + sendString(MenuPort, TRUE, importantMessage, + "ARGUMENT ERROR! Did nothing... ", Dummy, Dummy); + } +} + + +/* Kill Status of Calibration in EEPROM */ +void m_c_kill(void) +{ + /* arg1: device + * arg2: calibration type + */ + if ((arg1 >= 0) && (arg2 < maxCAL_types)) + { + if (arg1 == thisDeviceNumber) + { + killStats(); + } + else if (arg1 == remoteDeviceNumber) + { + xSemaphoreTake(generalSemaphore, 0); + bpSendCallRpc(handleBus1, arg1, 14, 0, NULL); + if (xSemaphoreTake(generalSemaphore, 5000) != pdPASS) + { + /* Semaphore is not released, timeout in transmission */ + sendString(MenuPort, TRUE, importantMessage, + "\tTimeout occoured!", Dummy, Dummy); + xSemaphoreGive(generalSemaphore); + + } + else + { + sendString(MenuPort, TRUE, importantMessage, + "\tKilled all Calibration Stats!", Dummy, Dummy); + } + } + } + else + { + sendString(MenuPort, TRUE, importantMessage, + "ARGUMENT ERROR! Did nothing... ", Dummy, Dummy); + } +} + + +/* Reset Status of Calibration in EEPROM */ +void m_c_def(void) +{ + /* arg1: device + */ + if (arg1 >= 0) + { + if (arg1 == thisDeviceNumber) + { + defaultStats(); + } + else if (arg1 == remoteDeviceNumber) + { + xSemaphoreTake(generalSemaphore, 0); + bpSendCallRpc(handleBus1, arg1, 15, 0, NULL); + if (xSemaphoreTake(generalSemaphore, 5000) != pdPASS) + { + /* Semaphore is not released, timeout in transmission */ + sendString(MenuPort, TRUE, importantMessage, + "\tTimeout occoured!", Dummy, Dummy); + xSemaphoreGive(generalSemaphore); + + } + else + { + sendString(MenuPort, TRUE, importantMessage, + "\tKilled all Calibration Stats!", Dummy, Dummy); + } + } + } + else + { + sendString(MenuPort, TRUE, importantMessage, + "ARGUMENT ERROR! Did nothing... ", Dummy, Dummy); + } +} + + +/* Set "Calibrated" of Calibration-Status in EEPROM */ +void m_c_cal(void) +{ + /* arg1: device + */ + if (arg1 >= 0) + { + if (arg1 == thisDeviceNumber) + { + defaultStats(); + } + else if (arg1 == remoteDeviceNumber) + { + xSemaphoreTake(generalSemaphore, 0); + bpSendCallRpc(handleBus1, arg1, 16, 0, NULL); + if (xSemaphoreTake(generalSemaphore, 5000) != pdPASS) + { + /* Semaphore is not released, timeout in transmission */ + sendString(MenuPort, TRUE, importantMessage, + "\tTimeout occoured!", Dummy, Dummy); + xSemaphoreGive(generalSemaphore); + + } + else + { + sendString(MenuPort, TRUE, importantMessage, + "\tKilled all Calibration Stats!", Dummy, Dummy); + } + } + } + else + { + sendString(MenuPort, TRUE, importantMessage, + "ARGUMENT ERROR! Did nothing... ", Dummy, Dummy); + } +} + + +/* Show all Stats from EEPROM */ +void m_c_show(void) +{ + /* arg1: device + */ + if (arg1 >= 0) + { + if (arg1 == remoteDeviceNumber) + { + sendString(MenuPort, TRUE, importantMessage, "\tVoltage Input:\t", + Dummy, Dummy); + showRemoteCalibrationStatus(VoltageInput); + sendString(MenuPort, TRUE, importantMessage, + "\tVoltage Output:\t", Dummy, Dummy); + showRemoteCalibrationStatus(VoltageOutput); + sendString(MenuPort, TRUE, importantMessage, "\tCurrent Input:\t", + Dummy, Dummy); + showRemoteCalibrationStatus(CurrentInput); + sendString(MenuPort, TRUE, importantMessage, + "\tCurrent Output:\t", Dummy, Dummy); + showRemoteCalibrationStatus(CurrentOutput); + } + else if (arg1 == thisDeviceNumber) + { + sendString(MenuPort, TRUE, importantMessage, "\tVoltage Input:\t", + Dummy, Dummy); + showLocalCalibrationStatus(VoltageInput); + sendString(MenuPort, TRUE, importantMessage, + "\tVoltage Output:\t", Dummy, Dummy); + showLocalCalibrationStatus(VoltageOutput); + sendString(MenuPort, TRUE, importantMessage, "\tCurrent Input:\t", + Dummy, Dummy); + showLocalCalibrationStatus(CurrentInput); + sendString(MenuPort, TRUE, importantMessage, + "\tCurrent Output:\t", Dummy, Dummy); + showLocalCalibrationStatus(CurrentOutput); + } + } + else + { + sendString(MenuPort, TRUE, importantMessage, + "ARGUMENT ERROR! Did nothing... ", Dummy, Dummy); + } +} + + +/* Call Analogue Calibration Procedure on Slave Device */ +void m_cslave(void) +{ + dioClean(); + diotasksdelete(); +// \TODO NO REMOTE +#if NO_REMOTE + calibrateSlaveInOut(); +#endif +} + + + +/* + * TEST COMMAND SECTION + */ + + + +/* Call Battery Test */ +// \TODO IS THIS NECESSARY? BATTERYTEST ON TESTEE? +void m_battery(void) +{ + /* arg1: device + */ + if (arg1 >= 0) + { + if (arg1 == remoteDeviceNumber) + { + dioClean(); + bpSendCallRpc(handleBus1, arg1, 4, 0, NULL); /* remote clean */ + xSemaphoreTake(generalSemaphore, 0); + r_BatteryTest(&g_batterytest); + } + else if (arg1 == thisDeviceNumber) + { + sendString(MenuPort, TRUE, resultMessage, "\t\tDONE NOTHING", + Dummy, Dummy); + } + } + else + { + sendString(MenuPort, TRUE, importantMessage, + "ARGUMENT ERROR! Did nothing... ", Dummy, Dummy); + } +} + + +/* Call LED Test */ +void m_ledtest(void) +{ + /* arg1: device + */ + if (arg1 >= 0) + { + if (arg1 == remoteDeviceNumber) + { + dioClean(); + bpSendCallRpc(handleBus1, arg1, 4, 0, NULL); /* remote clean */ + xSemaphoreTake(generalSemaphore, 0); + r_LEDTest(&g_ledtest); + } + else if (arg1 == thisDeviceNumber) + { + sendString(MenuPort, TRUE, resultMessage, "\t\t\t\tLED Test\t", + BoolRestoStr(g_ledtest = testledStart()), Dummy); + } + } + else + { + sendString(MenuPort, TRUE, importantMessage, + "ARGUMENT ERROR! Did nothing... ", Dummy, Dummy); + } +} + + +/* Call Digital Input/Output Test */ +void m_dio(void) +{ + /* arg1: device + * arg2: board (0: MB, 1: EB) (Only on remote tests) + */ + if (arg1 >= 0) + { + if (arg1 == remoteDeviceNumber) + { + dioClean(); + bpSendCallRpc(handleBus1, arg1, 4, 0, NULL); /* remote clean */ + xSemaphoreTake(generalSemaphore, 0); + if (arg2 == 0) + { + remoteDigitalLinetestMBExecute(); + } + else if (arg2 == 1) + { + remoteDigitalLinetestEBExecute(); + } + } + else if (arg1 == thisDeviceNumber) + { + sendString(MenuPort, TRUE, resultMessage, "\t\t\t\tDIO Test\t", + BoolRestoStr(g_diotest = testdioStart()), Dummy); + } + } + else + { + sendString(MenuPort, TRUE, importantMessage, + "ARGUMENT ERROR! Did nothing... ", Dummy, Dummy); + } +} + + +/* Call AnalogueInput/Output Test */ +void m_aio(void) +{ + /* arg1: device + * arg2: board (0: MB, 1: EB) (Only on remote tests) + */ + if (arg1 >= 0) + { + if (arg1 == remoteDeviceNumber) + { + dioClean(); + bpSendCallRpc(handleBus1, arg1, 4, 0, NULL); /* remote clean */ + xSemaphoreTake(generalSemaphore, 0); + if (arg2 == 0) + { + remoteAnalogueLinetestMBExecute(); + } + else if (arg2 == 1) + { + remoteAnalogueLinetestEBExecute(); + } + } + else if (arg1 == thisDeviceNumber) + { + sendString(MenuPort, TRUE, resultMessage, "\t\t\t\tAIO Test\t", + BoolRestoStr(g_diotest = testaioStart()), Dummy); + } + } + else + { + sendString(MenuPort, TRUE, importantMessage, + "ARGUMENT ERROR! Did nothing... ", Dummy, Dummy); + } +} + + +/* Call Bus System Test */ +void m_bus (void) + { + sendString (MenuPort, TRUE, resultMessage, "\t\t\t\tBus Test\t", + BoolRestoStr(g_diotest = testbusStart()), Dummy); + } + +void m_cantest (void) +{ + dioClean(); + sendString (MenuPort, TRUE, resultMessage, "\t\t\t\tCAN Test\t", + BoolRestoStr(g_cantest = testCanStart()), Dummy); +} + + +/* Call EEPROM Test */ +void m_eeprom(void) +{ + /* arg1: device + */ + if (arg1 >= 0) + { + if (arg1 == remoteDeviceNumber) + { + dioClean(); + bpSendCallRpc(handleBus1, arg1, 4, 0, NULL); /* remote clean */ + xSemaphoreTake(generalSemaphore, 0); + r_EEPROMTest(&g_eepromtest); + } + else if (arg1 == thisDeviceNumber) + { + sendString(MenuPort, TRUE, resultMessage, "\t\t\t\tEEPROM Test\t", + BoolRestoStr(g_eepromtest = testeepromStart()), Dummy); + } + } + else + { + sendString(MenuPort, TRUE, importantMessage, + "ARGUMENT ERROR! Did nothing... ", Dummy, Dummy); + } +} + + +/* Call MemoryCard Test */ +void m_mmc(void) +{ + /* arg1: device + */ + if ((arg1 >= 0) && (LogFlag != TRUE)) + { + if (arg1 == remoteDeviceNumber) + { + dioClean(); + bpSendCallRpc(handleBus1, arg1, 4, 0, NULL); /* remote clean */ + xSemaphoreTake(generalSemaphore, 0); + r_MMCTest(&g_mmctest); + } + else if (arg1 == thisDeviceNumber) + { + sendString(MenuPort, TRUE, resultMessage, "\t\t\t\tMMC Test\t", + BoolRestoStr(g_mmctest = testmmcStart()), Dummy); + } + } + else if (arg1 < 0) + { + sendString(MenuPort, TRUE, importantMessage, + "ARGUMENT ERROR! Did nothing... ", Dummy, Dummy); + } + else if (LogFlag == TRUE) + { + { + sendString(MenuPort, TRUE, importantMessage, + "Logflag active, card test impossible ", Dummy, Dummy); + } + } +} + + +/* Call PowerSupply Test */ +void m_power(void) +{ + /* arg1: device + */ + if (arg1 >= 0) + { + if (arg1 == remoteDeviceNumber) + { + dioClean(); + bpSendCallRpc(handleBus1, arg1, 4, 0, NULL); /* remote clean */ + xSemaphoreTake(generalSemaphore, 0); + r_PowerTest(&g_powertest); + } + else if (arg1 == thisDeviceNumber) + { + sendString(MenuPort, TRUE, resultMessage, "\t\t\t\tPower Test\t", + BoolRestoStr(g_powertest = testpowerStart()), Dummy); + } + } + else + { + sendString(MenuPort, TRUE, importantMessage, + "ARGUMENT ERROR! Did nothing... ", Dummy, Dummy); + } +} + + +/* Call RealTime Clock Test */ +void m_rtc(void) +{ + /* arg1: device + */ + if (arg1 >= 0) + { + if (arg1 == remoteDeviceNumber) + { + dioClean(); + bpSendCallRpc(handleBus1, arg1, 4, 0, NULL); /* remote clean */ + xSemaphoreTake(generalSemaphore, 0); + r_RTCTest(&g_rtctest); + } + else if (arg1 == thisDeviceNumber) + { + sendString(MenuPort, TRUE, resultMessage, "\t\t\t\tRTC Test\t", + BoolRestoStr(g_rtctest = testrtcStart()), Dummy); + } + } + else + { + sendString(MenuPort, TRUE, importantMessage, + "ARGUMENT ERROR! Did nothing... ", Dummy, Dummy); + } +} + +void m_fattest (void) +{ + sendString (MenuPort, GotoNewLine, importantMessage, + "Start SD/MMC Filesystem Test Sequence", Dummy, Dummy); + ffTestStart(); +} + +/* + * LOGGING SECTION + */ +void m_initSD (void) +{ + MMC_StatusOut(MmcInitMedia()); /* Init Card and give Status */ +} + + +/* Mount device (SD-CARD) to MMC Filesystem */ +void m_sdMount (void) +{ + FAT_StatusOut (f_mount (0, &SD_CARD)); +} + + +void m_logEnable (void) +{ + /* arg1: Enable / Disable + */ + + if (arg1 == 1) + { + sendString(MenuPort, TRUE, importantMessage, + "Logging enabled", Dummy, Dummy); + enableLog(); + } + + else if (arg1 == 0) + { + sendString(MenuPort, TRUE, importantMessage, + "Logging disabled", Dummy, Dummy); + disableLog(); + + } + else + { + sendString(MenuPort, TRUE, importantMessage, + "ARGUMENT ERROR! Did nothing... ", Dummy, Dummy); + } +} + + +void m_logStart (void) +{ + /* arg1: file name + */ + + if (arg1 >= 0) + { + startLog(arg1); + } +} + +void m_logStop (void) +{ + stopLog(); +} + + +void m_loglist (void) +{ + listLog ("/"); +} + + + +/* + * MISC SECTION + */ + +void m_setRTC (void) +{ + /* arg1: UINT8 |day|hour|min|sec| (arg1 is 32bit) + * arg2: UINT8 |0|0|0|0|dow|mon| (arg2 is 32bit) + * arg3: UINT16 |doy|year| (arg3 is 32bit) + */ + + t_rtc timedate; + + timedate.sec = (arg1 & 0x000000FF); /* Get seconds from arg1 */ + timedate.min = ((arg1 & 0x0000FF00) >> 8); /* Get minutes from arg1*/ + timedate.hour = ((arg1 & 0x00FF0000) >> 16); /* Get hours from arg1 */ + timedate.day = ((arg1 & 0xFF000000) >> 24); /* get day from arg1 */ + + timedate.dow = (arg2 & 0x000000FF); /* Get day of week from arg2 */ + timedate.mon = ((arg2 & 0x0000FF00) >> 8); /* get month from arg2 */ + + timedate.year = (arg3 & 0x0000FFFF); /* Get year from arg3 */ + timedate.doy = ((arg3 & 0xFFFF0000) >> 16); /* get day of year */ + + rtcWrite (&timedate); /* Write Time&Date to RTC */ +} + + +void m_readRTC (void) +{ + t_rtc timedate; + + rtcRead (&timedate); /* Read RTC values */ + + sendString (SerOutPort, TRUE, importantMessage, + "Seconds: \t", ItoDStr (timedate.sec), Dummy); + sendString (SerOutPort, TRUE, importantMessage, + "Minutes: \t", ItoDStr (timedate.min), Dummy); + sendString (SerOutPort, TRUE, importantMessage, + "Hours: \t\t", ItoDStr (timedate.hour), Dummy); + sendString (SerOutPort, TRUE, importantMessage, + "Day: \t\t", ItoDStr (timedate.day), Dummy); + sendString (SerOutPort, TRUE, importantMessage, + "Day of Week: \t", ItoDStr (timedate.dow), Dummy); + sendString (SerOutPort, TRUE, importantMessage, + "Month: \t\t", ItoDStr (timedate.mon), Dummy); + sendString (SerOutPort, TRUE, importantMessage, + "Year: \t\t", ItoDStr (timedate.year), Dummy); +} + + +void m_callRemoteFunction (void) +{ + /* arg1: Remote function number + * arg2: Number of function Arguments + * arg3: arguments + */ + + bpSendCallRpc (handleBus1, remoteDeviceNumber, arg1, arg2, arg3); +} + + +void m_listLocalattachments(void) +{ + /* arg1 : function ID + */ + + UINT8 functioncnt = 0; + t_rpc_entity *lookupEntry; + + if (arg1 == 0) + { + while (functioncnt < 61) + { + lookupEntry = bpLookupRpcEntry(handleBus1, functioncnt); + if (lookupEntry != NULL) + { + sendString(MenuPort, TRUE, importantMessage, + ItoDStr(functioncnt), s_tab, lookupEntry->functionName); + } + + functioncnt++; + } + } + + else + { + lookupEntry = bpLookupRpcEntry(handleBus1, (UINT8) arg1); + + if (lookupEntry != NULL) + { + + sendString(MenuPort, TRUE, importantMessage, + lookupEntry->functionName, s_tab, ItoDStr(arg1)); + } + } +} + + +void m_listRemoteattachments(void) +{ + +} + + +void m_clean(void) +{ + /* arg1: device + */ + if (arg1 >= 0) + { + if (arg1 == thisDeviceNumber) + { + dioClean(); + } + else if (arg1 == remoteDeviceNumber) + { + bpSendCallRpc(handleBus1, remoteDeviceNumber, 4, 0, NULL); + } + + } + else + { + sendString(MenuPort, TRUE, importantMessage, + "ARGUMENT ERROR! Did nothing... ", Dummy, Dummy); + } +} + +/* Call DIO Tasks delete sequence */ +void m_tasksdelete(void) +{ + diotasksdelete(); +} + + +/* Quit Prompt Menu */ +void m_quit(void) +{ + sendString(MenuPort, TRUE, importantMessage, "quit", Dummy, Dummy); + quit = TRUE; +} + + +/* Call Help Menu */ +void m_help(void) +{ + UINT32 loopcnt; + for (loopcnt = 0; loopcnt < NUMBER_OF_COMMANDS; loopcnt++) + { + sendString (MenuPort, GotoNewLine, importantMessage, + (char *)command_table[loopcnt], Dummy, Dummy); + vTaskDelay(10); + } + sendString (MenuPort, GotoNewLine, importantMessage, + NewLine, "Type command + _help for individual information", Dummy); +} + + +void m_menuDebug (void) +{ + /* arg1: enable/disable (0: disable; 1: enable) + */ + + if ((arg1 >= 0) && (arg1 < 2)) + { + if (arg1 == TRUE) + { + block_MenuMessage = FALSE; + sendString(MenuPort, TRUE, importantMessage, + "\n\r\tMenu debug messages enabled", Dummy, Dummy); + } + else if (arg1 == FALSE) + { + block_MenuMessage = TRUE; + sendString(MenuPort, TRUE, importantMessage, + "\n\r\tMenu debug messages disabled", Dummy, Dummy); + } + } + else + { + sendString(MenuPort, TRUE, importantMessage, + "ARGUMENT ERROR! Did nothing... ", Dummy, Dummy); + } + +} diff --git a/Tester/SW/Applications/menu/menufunctions.h b/Tester/SW/Applications/menu/menufunctions.h new file mode 100644 index 0000000..39bb42a --- /dev/null +++ b/Tester/SW/Applications/menu/menufunctions.h @@ -0,0 +1,119 @@ +/* --------------------------------------------------------------------------- + * menufunctions.h (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Nov 14, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef MENUFUNCTIONS_H_ +#define MENUFUNCTIONS_H_ +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ + +void m_run (void); +/* + * INPUT AND OUTPUT SECTION + */ +void m_confout (void); +void m_confin (void); +void m_switchMux(void); +void m_curout (void); +void m_volout (void); +void m_digiout (void); +void m_volin (void); +void m_curin (void); +void m_digiin (void); +void m_canread (void); +void m_canwrite (void); +/* + * CALIBRATION SECTION + */ +void m_cvout (void); +void m_cvin (void); +void m_ccout (void); +void m_ccin (void); +void m_cdel (void); +void m_cload (void); +void m_c_stat (void); +void m_c_kill (void); +void m_c_def (void); +void m_c_cal (void); +void m_c_show (void); +void m_cslave(void); +/* + * TEST COMMAND SECTION + */ +void m_battery (void); +void m_ledtest (void); +void m_dio (void); +void m_aio(void); +void m_bus (void); +void m_cantest (void); +void m_eeprom (void); +void m_mmc (void); +void m_power(void); +void m_rtc (void); +void m_fattest (void); +/* + * LOGGING SECTION + */ +void m_initSD (void); +void m_sdMount (void); +void m_logEnable (void); +void m_logStart (void); +void m_logStop (void); +void m_loglist (void); +/* + * MISC SECTION + */ +void m_setRTC (void); +void m_readRTC (void); +void m_callRemoteFunction (void); +void m_listLocalattachments (void); +void m_clean(void); +void m_tasksdelete(void); +void m_quit(void); +void m_help(void); +void m_menuDebug (void); + + + +#endif /*MENUFUNCTIONS_H_*/ diff --git a/Tester/SW/Applications/remote/remote_analogue.c b/Tester/SW/Applications/remote/remote_analogue.c new file mode 100644 index 0000000..04b1fd6 --- /dev/null +++ b/Tester/SW/Applications/remote/remote_analogue.c @@ -0,0 +1,333 @@ +/* --------------------------------------------------------------------------- + * remote_analogue.c (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: remote analogue test sequence + * --------------------------------------------------------------------------- + * Version(s): 0.1, Dez 15, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +#include "LPC23xx.h" +#include "types.h" + +#include "FreeRTOS.h" +#include "task.h" +#include "semphr.h" +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "remote_analogue.h" +#include "adc.h" +#include "dac.h" + +#include "protocolfunctions.h" +#include "BusProtocol.h" +#include "SerOut.h" + + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ +UINT32 remoteAioReadResult = 0; + +BOOLEAN remoteAnalogueInitialised = FALSE; + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ + +void remoteAioInit (void) +{ + UINT32 loopcnt; + RESULT set_mb; + RESULT set_eb; + + remoteAnalogueInitialised = TRUE; /* Mark driver as initialised */ + + sendString (SerOutPort, TRUE, importantMessage, + NewLine, "Initialise analogue remote buffers", Dummy); + sendString (SerOutPort, FALSE, importantMessage, + "\tInputs...", Dummy, Dummy); + for (loopcnt = 0; loopcnt < NUMBER_OF_TOTAL_AI; loopcnt++) + { + remoteAnalogueInputs[loopcnt] = 0; + } + sendString (SerOutPort, FALSE, importantMessage, + "Done", Dummy, Dummy); + + sendString (SerOutPort, FALSE, importantMessage, + "\tOutputs...", Dummy, Dummy); + for (loopcnt = 0; loopcnt < NUMBER_OF_TOTAL_AO; loopcnt++) + { + remoteAnalogueInputs[loopcnt] = 0; + } + sendString (SerOutPort, FALSE, importantMessage, + "Done", Dummy, Dummy); + + vSemaphoreCreateBinary (remoteAnalogueSemaphore); + sendString (SerOutPort, TRUE, importantMessage, + "Take analogue semaphore... ", Dummy, Dummy); + + if (xSemaphoreTake(remoteAnalogueSemaphore, 0) == pdTRUE) + { + sendString (SerOutPort, FALSE, importantMessage, + "Done", Dummy, Dummy); + } + else + { + sendString (SerOutPort, FALSE, importantMessage, + "Failed", Dummy, Dummy); + } + + + sendString(SerOutPort, TRUE, importantMessage, + "reset remote analogue outputs...", Dummy, Dummy); + set_mb = remoteAioWriteAll (remoteDeviceNumber, analogue_mb, 0); + set_eb = remoteAioWriteAll (remoteDeviceNumber, analogue_eb, 0); + if ((set_mb == OK) && (set_eb == OK)) + { + sendString(SerOutPort, FALSE, importantMessage, "Done", Dummy, Dummy); + } + else + { + sendString(SerOutPort, FALSE, importantMessage, "Failed", Dummy, Dummy); + } + +} + + +RESULT remoteAioWrite (UINT8 device, UINT8 channel, INT32 value) +{ + + INT32 sendArray[2]; + RESULT returnValue; + + if (remoteAnalogueInitialised == FALSE) + { + /* Remote digital driver is not initialised */ + sendString (SerOutPort, TRUE, importantMessage, + "\t\tanalogue not intialised", Dummy, Dummy); + return (ERROR); + } + + sendArray[0] = (INT32) channel; + sendArray[1] = (INT32) value; + + bpSendCallRpc(handleBus1, device, 22, 2, sendArray); + + if (xSemaphoreTake(remoteAnalogueSemaphore, 3000) != pdTRUE) + { + sendString (SerOutPort, TRUE, importantMessage, + s_tab, "analogue write was not successful", Dummy); + + returnValue = ERROR; + } + else + { + remoteAnalogueOutputs[channel] = value; + + returnValue = OK; + } + + return (returnValue); +} + + +RESULT remoteAioWriteAll(UINT8 device, t_boardtype_analogue board, BOOLEAN value) +{ + INT32 sendArray[2]; + UINT8 loopcnt = 0; + UINT8 loopend = 0; + RESULT returnValue; + + if (remoteAnalogueInitialised == FALSE) + { + /* Remote digital driver is not initialised */ + sendString (SerOutPort, TRUE, importantMessage, + "\t\tanalogue not intialised", Dummy, Dummy); + return (ERROR); + } + + sendArray[0] = (INT32)board; + sendArray[1] = (INT32)value; + + bpSendCallRpc(handleBus1, device, 25, 2, sendArray); + + if (xSemaphoreTake(remoteAnalogueSemaphore, 3000) != pdTRUE) + { + sendString(SerOutPort, TRUE, importantMessage, s_tab, + "analogue write was not successful", Dummy); + + returnValue = ERROR; + } + else + { + + switch (board) + { + case analogue_mb: + loopcnt = 0; + loopend = NUMBER_OF_AO_MB; + break; + + case analogue_eb: + loopcnt = NUMBER_OF_AO_MB; + loopend = NUMBER_OF_TOTAL_AO; + break; + } + + for (loopcnt; loopcnt < loopend; loopcnt++) + { + remoteAnalogueOutputs[loopcnt] = value; + // \TODO IS THIS LOOP WORKING?? + } + + returnValue = OK; + } + + return (returnValue); +} + + + +UINT32 remoteAioRead (UINT8 device, UINT8 channel) +{ + + if (remoteAnalogueInitialised == FALSE) + { + /* Remote digital driver is not initialised */ + sendString (SerOutPort, TRUE, importantMessage, + "\t\tanalogue not intialised", Dummy, Dummy); + return (ERROR); + } + + + bpSendCallRpc(handleBus1, device, 23, 1, (INT32)&channel); + if (xSemaphoreTake(remoteAnalogueSemaphore, 3000) != pdTRUE) + { + sendString (SerOutPort, TRUE, importantMessage, + s_tab, "analogue read did not receive a readback", Dummy); + } + else + { + remoteAnalogueInputs[channel] = remoteAioReadResult; + } + + return (remoteAioReadResult); + +} + + +void remoteAioReadAll (UINT8 device, t_boardtype_analogue board) +{ + + if (remoteAnalogueInitialised == FALSE) + { + /* Remote digital driver is not initialised */ + sendString (SerOutPort, TRUE, importantMessage, + "\t\tanalogue not intialised", Dummy, Dummy); + return; + } + + bpSendCallRpc(handleBus1, device, 27, 1, (INT32)&board); + if (xSemaphoreTake(remoteAnalogueSemaphore, 3000) != pdTRUE) + { + sendString (SerOutPort, TRUE, importantMessage, + s_tab, "analogue read all did not receive a readback", Dummy); + } + else + { + sendString (SerOutPort, TRUE, importantMessage, + f_tab, "analogue read all finished receiving", Dummy); + } +} + + +void remoteAnalogueSemaphoreRelease (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results) +{ + + if (remoteAnalogueInitialised == FALSE) + { + /* Remote digital driver is not initialised */ + sendString (SerOutPort, TRUE, importantMessage, + "\t\tanalogue not intialised", Dummy, Dummy); + return; + } + + xSemaphoreGive (remoteAnalogueSemaphore); +} + +void analogueReadResult (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results) +{ + /* nrOfResults = 2 + * results[0]: analogue input value + */ + + if (remoteAnalogueInitialised == FALSE) + { + /* Remote digital driver is not initialised */ + sendString (SerOutPort, TRUE, importantMessage, + "\t\tanalogue not intialised", Dummy, Dummy); + return; + } + + /* Asign remote analogue input result to local variable */ + remoteAioReadResult = (UINT32) results[0]; + + + xSemaphoreGive (remoteAnalogueSemaphore); +} + + +void analogueReadAllResult (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results) +{ + /* nrOfResults = maxDI_Channels + * results[x]: analogue input x value + */ + + UINT32 loopcnt; + + if (remoteAnalogueInitialised == FALSE) + { + /* Remote digital driver is not initialised */ + sendString (SerOutPort, TRUE, importantMessage, + "\t\tanalogue not intialised", Dummy, Dummy); + return; + } + + for (loopcnt = 0; loopcnt < maxDAC_Channels; loopcnt++) + { + /* Copy read result to value array */ + remoteAnalogueInputs[loopcnt] = results[loopcnt]; + + } + xSemaphoreGive (remoteAnalogueSemaphore); +} + diff --git a/Tester/SW/Applications/remote/remote_analogue.h b/Tester/SW/Applications/remote/remote_analogue.h new file mode 100644 index 0000000..6c9996c --- /dev/null +++ b/Tester/SW/Applications/remote/remote_analogue.h @@ -0,0 +1,85 @@ +/* --------------------------------------------------------------------------- + * remote_analogue.h (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Dez 15, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef REMOTE_ANALOGUE_H_ +#define REMOTE_ANALOGUE_H_ + +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ +#include "LPC23xx.h" +#include "types.h" +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ +#define NUMBER_OF_AI_MB 8 +#define NUMBER_OF_AO_MB 8 + +#define NUMBER_OF_AI_EB 4 +#define NUMBER_OF_AO_EB 4 + +#define NUMBER_OF_TOTAL_AI (NUMBER_OF_AI_MB + NUMBER_OF_AI_EB) +#define NUMBER_OF_TOTAL_AO (NUMBER_OF_AO_MB + NUMBER_OF_AO_EB) +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ +typedef enum +{ + analogue_mb = 0, + analogue_eb = 1 +} t_boardtype_analogue; +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ +INT32 remoteAnalogueInputs[(NUMBER_OF_TOTAL_AI)]; +INT32 remoteAnalogueOutputs[(NUMBER_OF_TOTAL_AO)]; + +xSemaphoreHandle remoteAnalogueSemaphore; +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ + +void remoteAioInit (void); + +RESULT remoteAioWrite (UINT8 device, UINT8 channel, INT32 value); + +RESULT remoteAioWriteAll (UINT8 device, t_boardtype_analogue board, BOOLEAN value); + +UINT32 remoteAioRead (UINT8 device, UINT8 channel); + +void remoteAioReadAll (UINT8 device, t_boardtype_analogue board); + +void remoteAnalogueSemaphoreRelease (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results); + +void analogueReadResult (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results); + +void analogueReadAllResult (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results); + + + +#endif /*REMOTE_ANALOGUE_H_*/ diff --git a/Tester/SW/Applications/remote/remote_digital.c b/Tester/SW/Applications/remote/remote_digital.c new file mode 100644 index 0000000..9162c11 --- /dev/null +++ b/Tester/SW/Applications/remote/remote_digital.c @@ -0,0 +1,376 @@ +/* --------------------------------------------------------------------------- + * remote_digital.c (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: remote digital test sequence + * --------------------------------------------------------------------------- + * Version(s): 0.1, Dez 15, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +#include "LPC23xx.h" +#include "types.h" + +#include "FreeRTOS.h" +#include "task.h" +#include "semphr.h" +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "remote_digital.h" +#include "dio.h" + +#include "protocolfunctions.h" +#include "BusProtocol.h" +#include "SerOut.h" + + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ +BOOLEAN remoteDigitalInitialised = FALSE; +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ +BOOLEAN remoteDioReadResult = FALSE; + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ + +void remoteDioInit (void) +{ + UINT32 loopcnt; + RESULT set_mb; + RESULT set_eb; + + remoteDigitalInitialised = TRUE; /* Mark driver as initialised */ + + sendString (SerOutPort, TRUE, importantMessage, + NewLine, "Initialise digital remote buffers", Dummy); + sendString (SerOutPort, FALSE, importantMessage, + "\tInputs...", Dummy, Dummy); + for (loopcnt = 0; loopcnt < NUMBER_OF_TOTAL_DI; loopcnt++) + { + remoteDigitalInputs[loopcnt] = FALSE; + } + sendString (SerOutPort, FALSE, importantMessage, + "Done", Dummy, Dummy); + + sendString (SerOutPort, FALSE, importantMessage, + "\tOutputs...", Dummy, Dummy); + for (loopcnt = 0; loopcnt < NUMBER_OF_TOTAL_DO; loopcnt++) + { + remoteDigitalOutputs[loopcnt] = FALSE; + } + sendString (SerOutPort, FALSE, importantMessage, + "Done", Dummy, Dummy); + + + vSemaphoreCreateBinary (remoteDigitalSemaphore); + sendString (SerOutPort, TRUE, importantMessage, + "Take digital semaphore... ", Dummy, Dummy); + if (xSemaphoreTake(remoteDigitalSemaphore, 0) == pdTRUE) + { + sendString (SerOutPort, FALSE, importantMessage, + "Done", Dummy, Dummy); + } + else + { + sendString (SerOutPort, FALSE, importantMessage, + "Failed", Dummy, Dummy); + } + + + sendString(SerOutPort, TRUE, importantMessage, + "reset remote digital outputs...", Dummy, Dummy); + set_mb = remoteDioWriteAll (remoteDeviceNumber, digital_mb, FALSE); + set_eb = remoteDioWriteAll (remoteDeviceNumber, digital_eb, FALSE); + + if ((set_mb == OK) && (set_eb == OK)) + { + sendString(SerOutPort, FALSE, importantMessage, "Done", Dummy, Dummy); + } + else + { + sendString(SerOutPort, FALSE, importantMessage, "Failed", Dummy, Dummy); + } + +} + + +RESULT remoteDioWrite (UINT8 device, UINT8 channel, BOOLEAN value) +{ + INT32 sendArray[2]; + RESULT returnValue; + + if (remoteDigitalInitialised == FALSE) + { + /* Remote digital driver is not initialised */ + sendString (SerOutPort, TRUE, importantMessage, + "\t\tdigital not intialised", Dummy, Dummy); + return (ERROR); + } + + sendArray[0] = (INT32) channel; + sendArray[1] = (INT32) value; + + bpSendCallRpc(handleBus1, device, 20, 2, sendArray); + + if (xSemaphoreTake(remoteDigitalSemaphore, 3000) != pdTRUE) + { + sendString (SerOutPort, TRUE, importantMessage, + s_tab, "digital write was not successful", Dummy); + + returnValue = ERROR; + } + else + { + remoteDigitalOutputs[channel] = value; + + returnValue = OK; + } + + return (returnValue); +} + + +RESULT remoteDioWriteAll(UINT8 device, t_boardtype_digital board, BOOLEAN value) +{ + INT32 sendArray[2]; + UINT8 loopcnt = 0; + UINT8 loopend = 0; + + RESULT returnValue; + + if (remoteDigitalInitialised == FALSE) + { + /* Remote digital driver is not initialised */ + sendString (SerOutPort, TRUE, importantMessage, + "\t\tdigital not intialised", Dummy, Dummy); + return (ERROR); + } + + sendArray[0] = (INT32)board; + sendArray[1] = (INT32)value; + + bpSendCallRpc(handleBus1, device, 21, 2, sendArray); + + if (xSemaphoreTake(remoteDigitalSemaphore, 3000) != pdTRUE) + { + sendString(SerOutPort, TRUE, importantMessage, s_tab, + "digital write was not successful", Dummy); + + returnValue = ERROR; + } + else + { + + switch (board) + { + case digital_mb: + loopcnt = 0; + loopend = NUMBER_OF_DO_MB; + break; + + case digital_eb: + loopcnt = NUMBER_OF_DO_MB; + loopend = NUMBER_OF_TOTAL_DO; + break; + } + + for (loopcnt; loopcnt < loopend; loopcnt++) + { + remoteDigitalOutputs[loopcnt] = value; + // \TODO IS THIS LOOP WORKING?? + } + + returnValue = OK; + } + + return (returnValue); +} + + +BOOLEAN remoteDioRead (UINT8 device, INT32 channel) +{ + INT32 channelArray[1]; + + channelArray[0] = channel; + + + if (remoteDigitalInitialised == FALSE) + { + /* Remote digital driver is not initialised */ + sendString (SerOutPort, TRUE, importantMessage, + "\t\tdigital not intialised", Dummy, Dummy); + return (ERROR); + } + + + bpSendCallRpc(handleBus1, device, 22, 1, channelArray); + if (xSemaphoreTake(remoteDigitalSemaphore, 3000) != pdTRUE) + { + sendString (SerOutPort, TRUE, importantMessage, + s_tab, "digital read did not receive a readback", Dummy); + } + else + { + remoteDigitalInputs[channel] = remoteDioReadResult; + } + + return (remoteDioReadResult); +} + + +void remoteDioReadAll (UINT8 device, t_boardtype_digital board) +{ + INT32 boardArray[1]; + + boardArray[0] = board; + + if (remoteDigitalInitialised == FALSE) + { + /* Remote digital driver is not initialised */ + sendString (SerOutPort, TRUE, importantMessage, + "\t\tdigital not intialised", Dummy, Dummy); + return; + } + + bpSendCallRpc(handleBus1, device, 23, 1, boardArray); + if (xSemaphoreTake(remoteDigitalSemaphore, 3000) != pdTRUE) + { + sendString (SerOutPort, TRUE, importantMessage, + s_tab, "digital read all did not receive a readback", Dummy); + } + else + { + sendString (SerOutPort, TRUE, importantMessage, + f_tab, "digital read all finished receiving", Dummy); + } + +} + + +void remoteDigitalSemaphoreRelease (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results) +{ + + if (remoteDigitalInitialised == FALSE) + { + /* Remote digital driver is not initialised */ + sendString (SerOutPort, TRUE, importantMessage, + "\t\tdigital not intialised", Dummy, Dummy); + return; + } + + xSemaphoreGive (remoteDigitalSemaphore); +} + +void digitalReadResult (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results) +{ + + if (remoteDigitalInitialised == FALSE) + { + /* Remote digital driver is not initialised */ + sendString (SerOutPort, TRUE, importantMessage, + "\t\tdigital not intialised", Dummy, Dummy); + return; + } + + /* nrOfResults = 2 + * results[0]: digital input value (0: LOW, !0: HIGH) + */ + if (results[0] == 0) + { + /* Remote digital input is LOW */ + remoteDioReadResult = FALSE; + } + else + { + /* Remote digital input is HIGH */ + remoteDioReadResult = TRUE; + } + xSemaphoreGive (remoteDigitalSemaphore); +} + + +void digitalReadAllResult (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results) +{ + /* nrOfResults = 2 + * results[0]: boardType (0: MB; 1: EB) + * results[1]: digital input value + */ + + UINT32 loopcnt; + UINT32 tempValue; + + if (remoteDigitalInitialised == FALSE) + { + /* Remote digital driver is not initialised */ + sendString (SerOutPort, TRUE, importantMessage, + "\t\tdigital not intialised", Dummy, Dummy); + return; + } + + sendString (SerOutPort, TRUE, importantMessage, + "\t\tdigital real all: ", ItoHStr (results[1]), Dummy); + + if (results[0] == 0) + { + /* Incoming Results are from Mainboard */ + for (loopcnt = 0; loopcnt < NUMBER_OF_DI_MB; loopcnt++) + { + tempValue = (results[1] & (0x0000 | (1 << loopcnt))); + if (tempValue == 0) + { + remoteDigitalInputs[loopcnt] = FALSE; + } + else + { + remoteDigitalInputs[loopcnt] = TRUE; + } + } + } + + else if (results[0] == 1) + { + /* Incoming Results are from Extensionboard */ + for (loopcnt = 0; loopcnt < NUMBER_OF_DI_EB; loopcnt++) + { + tempValue = (results[1] & (0x0000 | (1 << loopcnt))); + + if (tempValue == 0) + { + remoteDigitalInputs[(loopcnt + NUMBER_OF_DI_MB)] = FALSE; + } + else + { + remoteDigitalInputs[(loopcnt + NUMBER_OF_DI_MB)] = TRUE; + } + } + } + + xSemaphoreGive (remoteDigitalSemaphore); +} diff --git a/Tester/SW/Applications/remote/remote_digital.h b/Tester/SW/Applications/remote/remote_digital.h new file mode 100644 index 0000000..3526eff --- /dev/null +++ b/Tester/SW/Applications/remote/remote_digital.h @@ -0,0 +1,86 @@ +/* --------------------------------------------------------------------------- + * remote_digital.h (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Nov 11, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef DIGITAL_TEST_H_ +#define DIGITAL_TEST_H_ +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ +#include "LPC23xx.h" +#include "types.h" +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ +#define NUMBER_OF_DI_MB 8 +#define NUMBER_OF_DO_MB 8 + +#define NUMBER_OF_DI_EB 4 +#define NUMBER_OF_DO_EB 4 + +#define NUMBER_OF_TOTAL_DI (NUMBER_OF_DI_MB + NUMBER_OF_DI_EB) +#define NUMBER_OF_TOTAL_DO (NUMBER_OF_DO_MB + NUMBER_OF_DO_EB) + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ +typedef enum +{ + digital_mb = 0, + digital_eb = 1 +} t_boardtype_digital; +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + + +BOOLEAN remoteDigitalInputs[(NUMBER_OF_TOTAL_DI)]; +BOOLEAN remoteDigitalOutputs[(NUMBER_OF_TOTAL_DO)]; + +xSemaphoreHandle remoteDigitalSemaphore; + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ + +void remoteDioInit (void); + +RESULT remoteDioWrite (UINT8 device, UINT8 channel, BOOLEAN value); + +RESULT remoteDioWriteAll (UINT8 device, t_boardtype_digital board, BOOLEAN value); + +BOOLEAN remoteDioRead (UINT8 device, INT32 channel); + +void remoteDioReadAll (UINT8 device, t_boardtype_digital board); + +void remoteDigitalSemaphoreRelease (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results); + +void digitalReadResult (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results); + +void digitalReadAllResult (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results); + +#endif /*DIGITAL_TEST_H_*/ diff --git a/Tester/SW/Applications/remote/remote_misc.c b/Tester/SW/Applications/remote/remote_misc.c new file mode 100644 index 0000000..69780c2 --- /dev/null +++ b/Tester/SW/Applications/remote/remote_misc.c @@ -0,0 +1,144 @@ +/* --------------------------------------------------------------------------- + * remote_misc.c (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Nov 11, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +#include "lpc23xx.h" +#include "types.h" + +/* FreeRTOS includes */ +#include "FreeRTOS.h" +#include "Task.h" +#include "Semphr.h" +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "BusProtocol.h" +#include "protocolfunctions.h" + +#include "remote_misc.h" +#include "SerOut.h" + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ +#define ident_calibrated 0x55 +#define ident_default 0xAA +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ +extern UINT32 UINT32result; /* from topoftests.c */ +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ + +#if ((PINSET_TESTER == 1) || (PINSET_TESTER == 2)) +BOOLEAN makeHandshake (void) +{ +/* Make Handshake with first Slave device. + * Take Semaphore, call remote function and take Semaphore again with + * waitcycle. Semaphore can just be taken when remote function + * finished and returns call to release Semaphore. + */ + + BOOLEAN handshakeResult; + + xSemaphoreTake(generalSemaphore, 1); /* Take generalSemaphore */ + bpSendCallRpc (handleBus1, 2, 1, 0, NULL); /* Call Slaves Handshake */ + if (xSemaphoreTake(generalSemaphore, 2000) == pdPASS) + { /* Wait for Handshake done */ + handshakeResult = TRUE; + } + else + { + handshakeResult = FALSE; + } + + return (handshakeResult); +} +#endif + +UINT8 returnRemoteCalibrationStatus (INT32 correctionType) +{ + xSemaphoreTake(generalSemaphore, 0); + bpSendCallRpc(handleBus1, 2, 13, 1, &correctionType); + if (xSemaphoreTake(generalSemaphore, 5000) != pdPASS) + { + /* Semaphore is not released, timeout in transmission */ + xSemaphoreGive (generalSemaphore); + UINT32result = 0; + } + else + { + if (UINT32result & ident_default) + { + } + else if (UINT32result & ident_calibrated) + { + } + else + { + } + } + return ((UINT8) UINT32result); +} + + +UINT8 showRemoteCalibrationStatus (INT32 correctionType) +{ + xSemaphoreTake(generalSemaphore, 0); + bpSendCallRpc(handleBus1, 2, 13, 1, &correctionType); + if (xSemaphoreTake(generalSemaphore, 5000) != pdPASS) + { + /* Semaphore is not released, timeout in transmission */ + xSemaphoreGive (generalSemaphore); + } + else + { + if (UINT32result & ident_default) + { + sendString (SerOutPort, FALSE, testMessage, + "Values are in DEFAULT Mode", Dummy, Dummy); + } + else if (UINT32result & ident_calibrated) + { + sendString (SerOutPort, FALSE, testMessage, + "Values are in CALIBRATED Mode", Dummy, Dummy); + } + else + { + sendString (SerOutPort, FALSE, testMessage, + "NO VALID VALUES IN EEPROM", Dummy, Dummy); + } + } + return ((UINT8) UINT32result); +} + + diff --git a/Tester/SW/Applications/remote/remote_misc.h b/Tester/SW/Applications/remote/remote_misc.h new file mode 100644 index 0000000..bececc9 --- /dev/null +++ b/Tester/SW/Applications/remote/remote_misc.h @@ -0,0 +1,73 @@ +/* --------------------------------------------------------------------------- + * remote_misc.h (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Nov 11, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ +#include "lpc23xx.h" +#include "types.h" +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function: makeHandshake + * + * Functions Calls first Attached Function on Slave, which is sending an + * Answer back to Master + * + * Parameter: void + * + * Return: BOOLEAN - Result of Handshake + * --------------------------------------------------------------------------- + */ +BOOLEAN makeHandshake (void); + +UINT8 returnRemoteCalibrationStatus (INT32 correctionType); + +UINT8 showRemoteCalibrationStatus (INT32 correctionType); + +void digitalReadResult (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results); + +#ifndef REMOTE_MISC_H_ +#define REMOTE_MISC_H_ + +#endif /*REMOTE_MISC_H_*/ diff --git a/Tester/SW/Applications/remote/remote_relay.c b/Tester/SW/Applications/remote/remote_relay.c new file mode 100644 index 0000000..3a0aadb --- /dev/null +++ b/Tester/SW/Applications/remote/remote_relay.c @@ -0,0 +1,221 @@ +/* --------------------------------------------------------------------------- + * remote_relay.c (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Dez 16, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +#include "LPC23xx.h" +#include "types.h" + +#include "FreeRTOS.h" +#include "task.h" +#include "semphr.h" +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ + +#include "protocolfunctions.h" +#include "BusProtocol.h" +#include "SerOut.h" + +#include "remote_relay.h" + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ +BOOLEAN remoteRelayInitialised = FALSE; + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ + +void remoteRelayInit(void) +{ + UINT32 loopcnt; + RESULT set_mb; + RESULT set_eb; + + remoteRelayInitialised = TRUE; + + sendString(SerOutPort, TRUE, importantMessage, NewLine, + "Initialise relay remote buffers...", Dummy); + + for (loopcnt = 0; loopcnt < NUMBER_OF_TOTAL_RLY; loopcnt++) + { + remoteRelayInputs[loopcnt] = 0; + } + sendString(SerOutPort, FALSE, importantMessage, "Done", Dummy, Dummy); + + + vSemaphoreCreateBinary (remoteRelaySemaphore); + sendString (SerOutPort, TRUE, importantMessage, + "Take relay semaphore... ", Dummy, Dummy); + + if (xSemaphoreTake(remoteRelaySemaphore, 0) == pdTRUE) + { + sendString (SerOutPort, FALSE, importantMessage, + "Done", Dummy, Dummy); + } + else + { + sendString (SerOutPort, FALSE, importantMessage, + "Failed", Dummy, Dummy); + } + + + sendString(SerOutPort, TRUE, importantMessage, + "reset remote relays...", Dummy, Dummy); + set_mb = remoteRelaySetAll (remoteDeviceNumber, relay_mb, FALSE); + set_eb = remoteRelaySetAll (remoteDeviceNumber, relay_eb, FALSE); + if ((set_mb == OK) && (set_eb == OK)) + { + sendString(SerOutPort, FALSE, importantMessage, "Done", Dummy, Dummy); + } + else + { + sendString(SerOutPort, FALSE, importantMessage, "Failed", Dummy, Dummy); + } + +} + +RESULT remoteRelaySet (UINT8 device, UINT8 channel, BOOLEAN value) +{ + INT32 sendArray[2]; + RESULT returnValue; + + if (remoteRelayInitialised == FALSE) + { + /* Remote digital driver is not initialised */ + sendString (SerOutPort, TRUE, importantMessage, + "\t\trelay not intialised", Dummy, Dummy); + return (ERROR); + } + + + sendArray[0] = (INT32)channel; + sendArray[1] = (INT32)value; + + bpSendCallRpc(handleBus1, device, 28, 2, sendArray); + + if (xSemaphoreTake(remoteRelaySemaphore, 3000) != pdTRUE) + { + sendString (SerOutPort, TRUE, importantMessage, + s_tab, "relay set was not successful", Dummy); + + returnValue = ERROR; + } + else + { + remoteRelayInputs[channel] = value; + + returnValue = OK; + } + + return (returnValue); + +} + + +BOOLEAN remoteRelayRead (UINT8 device, UINT8 channel) +{ + + if (remoteRelayInitialised == FALSE) + { + /* Remote digital driver is not initialised */ + sendString (SerOutPort, TRUE, importantMessage, + "\t\trelay not intialised", Dummy, Dummy); + return; + } + +} + + +RESULT remoteRelaySetAll(UINT8 device, t_boardtype_relay board, BOOLEAN value) +{ + INT32 sendArray[2]; + UINT32 loopcnt = 0; + UINT32 loopend = 0; + RESULT returnValue; + + if (remoteRelayInitialised == FALSE) + { + /* Remote digital driver is not initialised */ + sendString (SerOutPort, TRUE, importantMessage, + "\t\trelay not intialised", Dummy, Dummy); + return (ERROR); + } + + sendArray[0] = (INT32)board; + sendArray[1] = (INT32)value; + + bpSendCallRpc(handleBus1, device, 29, 2, sendArray); + + if (xSemaphoreTake(remoteRelaySemaphore, 3000) != pdTRUE) + { + sendString(SerOutPort, TRUE, importantMessage, s_tab, + "relay set was not successful", Dummy); + + returnValue = ERROR; + } + else + { + + switch (board) + { + case relay_mb: + loopcnt = 0; + loopend = NUMBER_OF_RLY_MB; + break; + + case relay_eb: + loopcnt = NUMBER_OF_RLY_MB; + loopend = NUMBER_OF_TOTAL_RLY; + break; + } + + for (loopcnt; loopcnt < loopend; loopcnt++) + { + remoteRelayInputs[loopcnt] = value; + } + returnValue = OK; + } + + return (returnValue); +} + + +void remoteRelaySemaphoreRelease (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results) +{ + xSemaphoreGive (remoteRelaySemaphore); +} + diff --git a/Tester/SW/Applications/remote/remote_relay.h b/Tester/SW/Applications/remote/remote_relay.h new file mode 100644 index 0000000..ddd893e --- /dev/null +++ b/Tester/SW/Applications/remote/remote_relay.h @@ -0,0 +1,73 @@ +/* --------------------------------------------------------------------------- + * remote_relay.h (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Dez 16, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef REMOTE_RELAY_H_ +#define REMOTE_RELAY_H_ + +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ +#include "LPC23xx.h" +#include "types.h" +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ +#define NUMBER_OF_RLY_MB 4 +#define NUMBER_OF_RLY_EB 2 +#define NUMBER_OF_TOTAL_RLY (NUMBER_OF_RLY_MB + NUMBER_OF_RLY_EB) + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ +typedef enum +{ + relay_mb = 0, + relay_eb = 1 +} t_boardtype_relay; +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ +BOOLEAN remoteRelayInputs[(NUMBER_OF_TOTAL_RLY)]; + +xSemaphoreHandle remoteRelaySemaphore; +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ + +void remoteRelayInit(void); + +RESULT remoteRelaySet (UINT8 device, UINT8 channel, BOOLEAN value); + +BOOLEAN remoteRelayRead (UINT8 device, UINT8 channel); + +RESULT remoteRelaySetAll (UINT8 device, t_boardtype_relay board, BOOLEAN value); + +void remoteRelaySemaphoreRelease (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results); + + +#endif /*REMOTE_RELAY_H_*/ diff --git a/Tester/SW/Applications/remote/remote_tests.c b/Tester/SW/Applications/remote/remote_tests.c new file mode 100644 index 0000000..56ee858 --- /dev/null +++ b/Tester/SW/Applications/remote/remote_tests.c @@ -0,0 +1,331 @@ +/* --------------------------------------------------------------------------- + * remote_tests.c (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: Function to call single tests on remote system + * + * NOTE: allMemoryUseSameLED is defined in taskfunctions.h + * + * --------------------------------------------------------------------------- + * Version(s): 0.1, Aug 29, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +#include "LPC23xx.h" +#include "types.h" + +/* FreeRTOS includes */ +#include "FreeRTOS.h" +#include "Task.h" +#include "semphr.h" +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "remote_tests.h" +#include "SerOut.h" +#include "dio.h" +#include "ledfunctions.h" +#include "protocolfunctions.h" +#include "taskfunctions.h" +#include "BusProtocol.h" + +/* Test includes */ +#include "testLED.h" +#include "testdio.h" +#include "testaio.h" +#include "testBUS.h" +#include "testeeprom.h" +#include "testMMC.h" +#include "testpower.h" +#include "testrtc.h" + +#include "remote_analogue.h" +#include "remote_digital.h" +#include "remote_relay.h" +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ +extern BOOLEAN auto_testResult; +extern BOOLEAN GotoNewLine; +extern BOOLEAN block_SpinningWheel; + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ + +void r_TestInit (void) +{ + remoteDioInit(); + vTaskDelay (200); + remoteAioInit(); + vTaskDelay (200); + remoteRelayInit(); + vTaskDelay (200); +} + + +void r_BatteryTest (BOOLEAN * batterytest) +{ + /* Test for Battery and batterysupplied Memory */ + sendString(SerOutPort, TRUE, headerMessage, + StartMessage, f_lines, "Battery Test"); + bpSendCallRpc(handleBus1, 2, 17, 0, NULL); /* Write on Battery Memory */ + sendString(SerOutPort, TRUE, noteMessage, + NewLine, "\t\tSwitch SLAVE OFF for 5 Seconds", Dummy); + if (xSemaphoreTake(slaveRestartSemaphore, 60000) == pdPASS) + { /* Wait for slave Restart */ + bpSendCallRpc(handleBus1, 2, 18, 0, NULL); /* Read from Memory */ + xSemaphoreTake(generalSemaphore, 3000); + } + else + { + auto_testResult = FALSE; + xSemaphoreGive (slaveRestartSemaphore); + } + + *batterytest = auto_testResult; +#if (allMemoryUseSameLED == 1) + postpareTest(*batterytest, &d_batteryled, BATTERYLED, (void *)dioToggle, + (pUINT8) "batteryerror", &batteryled); +#endif + bpSendCallRpc(handleBus1, 2, 4, 0, NULL); /* Call dioClean() */ + sendString (SerOutPort, TRUE, resultMessage, + "n\rBATTERY Test Result: ", s_lines, BoolRestoStr (*batterytest)); + +} + + +void r_LEDTest (BOOLEAN * ledtest) +{ + /* Local Variable declaration */ + UINT8 buffer = 0; + UINT8 captureDio; + UINT8 dioAllOn = 0xFF; + BOOLEAN receive = FALSE; + + /* Test for all accessable LEDs */ + sendString(SerOutPort, TRUE, headerMessage, + StartMessage, f_lines, "LED TEST"); + captureDio = dioCapture(); + diotaskssuspend(); + dioResume (dioAllOn); + bpSendCallRpc(handleBus1, 2, 21, 0, NULL); /* Call ledTest() */ + sendString (SerOutPort, TRUE, noteMessage, + "\n\tAre all LEDs turned on? ", + "\n\r\tPRESS y (YES) oder n (NO): ", + NewLine); + + do /* do-while loop for String input */ + { + vTaskDelay (10); + buffer = 0; + receive = serGet(SerOutPort, &buffer); + + } while ((buffer != 121) && (buffer != 110)); + + if (buffer == 121) /* 121 = y (ScanCode) */ + { + *ledtest = TRUE; + } + else if (buffer == 110) /* 110 = n (ScanCode) */ + { + *ledtest = FALSE; + } + xSemaphoreTake(generalSemaphore, 5000); + dioResume(captureDio); + diotasksresume(); + bpSendCallRpc(handleBus1, 2, 32, 0, NULL); /* Postpare Test on Slave */ + postpareTest(*ledtest, &d_ledtestled, LEDTESTLED, (void *)dioToggle, + (pUINT8) "LEDerror", &ledtestled); + bpSendCallRpc(handleBus1, 2, 4, 0, NULL); /* Call dioClean() */ + sendString (SerOutPort, GotoNewLine, resultMessage, + "n\rLED Test Result: ", s_lines, BoolRestoStr (*ledtest)); +} + + +void r_EEPROMTest (BOOLEAN * eepromtest) +{ + /* Test for EEPROM Memory */ + sendString(SerOutPort, TRUE, headerMessage, + StartMessage, f_lines, "EEPROM"); + sendString (SerOutPort, FALSE, importantMessage, + "\t", Dummy, Dummy); + + block_SpinningWheel = FALSE; + bpSendCallRpc(handleBus1, 2, 22, 0, NULL); /* Call eepromTest() */ + + if (xSemaphoreTake(generalSemaphore, 5000) != pdPASS) + { + block_SpinningWheel = TRUE; + sendString (SerOutPort, TRUE, importantMessage, + "\tTimeout occoured!", Dummy, Dummy); + auto_testResult = FALSE; + xSemaphoreGive (generalSemaphore); + } + block_SpinningWheel = TRUE; + *eepromtest = auto_testResult; +#if (allMemoryUseSameLED == 0) + postpareTest(*eepromtest, &d_eepromled, EEPROMLED, (void *)dioToggle, + (pUINT8) "EEPROMerror", eepromled); +#else + postpareTest(*eepromtest, &d_memoryled, MEMORYLED, (void *)dioToggle, + (pUINT8) "memoryerror", &memoryled); +#endif + bpSendCallRpc(handleBus1, 2, 4, 0, NULL); /* Call dioClean() */ + sendString(SerOutPort, GotoNewLine, resultMessage, + "\n\rEEPROM Test Result:", + s_lines, BoolRestoStr(*eepromtest)); + + + +} + + +void r_MMCTest(BOOLEAN * mmctest) +{ + /* Test for Multimedia Card */ + sendString(SerOutPort, TRUE, headerMessage, + StartMessage, f_lines, "MMC"); + sendString (SerOutPort, FALSE, importantMessage, + "\t", Dummy, Dummy); + + block_SpinningWheel = FALSE; + bpSendCallRpc(handleBus1, 2, 27, 0, NULL); /* Call MMCTest() */ + + if (xSemaphoreTake(generalSemaphore, 5000) != pdPASS) + { + block_SpinningWheel = TRUE; + sendString(SerOutPort, TRUE, importantMessage, "\tTimeout occoured!", + Dummy, Dummy); + auto_testResult = FALSE; + xSemaphoreGive (generalSemaphore); + } + + block_SpinningWheel = TRUE; + *mmctest = auto_testResult; + + postpareTest(*mmctest, &d_mmcled, MMCLED, (void *)dioToggle, + (pUINT8) "MMCerror", &mmcled); + sendString(SerOutPort, GotoNewLine, resultMessage, + "\n\rMMC Test Result: ", s_lines, BoolRestoStr(*mmctest)); +} + + +void r_PowerTest (BOOLEAN * powertest) +{ /* Test for Power Supply */ + sendString(SerOutPort, TRUE, headerMessage, + StartMessage, f_lines, "Power Supply"); + sendString (SerOutPort, FALSE, importantMessage, + "\t", Dummy, Dummy); + + block_SpinningWheel = FALSE; + bpSendCallRpc(handleBus1, 2, 28, 0, NULL); /* Call eepromTest() */ + + if (xSemaphoreTake(generalSemaphore, 5000) != pdPASS) + { + block_SpinningWheel = TRUE; + sendString (SerOutPort, TRUE, importantMessage, + "\tTimeout occoured!", Dummy, Dummy); + auto_testResult = FALSE; + xSemaphoreGive (generalSemaphore); + } + block_SpinningWheel = TRUE; + *powertest = auto_testResult; + postpareTest(*powertest, &d_powerled, POWERLED, (void *)dioToggle, + (pUINT8) "POWERerror", &powerled); + + sendString(SerOutPort, GotoNewLine, resultMessage, + "\n\rPower Supply Test Result:", + f_lines, BoolRestoStr(*powertest)); +} + + +void r_RTCTest (BOOLEAN * rtctest) +{ /* Test for Real Time Clock */ + sendString(SerOutPort, TRUE, headerMessage, + StartMessage, f_lines, "RealTimeClock"); + sendString (SerOutPort, FALSE, importantMessage, + "\t", Dummy, Dummy); + + block_SpinningWheel = FALSE; + bpSendCallRpc(handleBus1, 2, 29, 0, NULL); /* Call eepromTest() */ + + if (xSemaphoreTake(generalSemaphore, 5000) != pdPASS) + { + block_SpinningWheel = TRUE; + sendString (SerOutPort, TRUE, importantMessage, + "\tTimeout occoured!", Dummy, Dummy); + auto_testResult = FALSE; + xSemaphoreGive (generalSemaphore); + } + block_SpinningWheel = TRUE; + *rtctest = auto_testResult; + postpareTest(*rtctest, &d_rtcled, RTCLED, (void *)dioToggle, + (pUINT8) "RTCerror", &rtcled); + + sendString(SerOutPort, GotoNewLine, resultMessage, + "\n\rRealTimeClock Test Result:", + f_lines, BoolRestoStr(*rtctest)); +} + + +/* Function to handle all necessary commands and calculations after a + * single test. Because these are all the same, they are done in a + * extra function + */ +void postpareTest (BOOLEAN TestResult, portBASE_TYPE *basetype, + UINT32 LEDNumber, pdTASK_CODE TaskCode, + pUINT8 taskname, xTaskHandle *pTaskHandler) +{ + + if (TestResult == TRUE) + { /* if Test is passed */ + if (*basetype == pdPASS) /* If defined Task exists */ + { + vTaskDelete (*pTaskHandler);/* Delete defined Task */ + *basetype = 0; /* Reset corresponding bastetype */ + } + dioWrite( 0, LEDNumber, TRUE); /* illume corresponding LED */ + } + else + { /* if DIO Test fails */ + if (*basetype == pdPASS) + { + /* Task already exists, so do nothing */ + } + else + { + *basetype = xTaskCreate((void *)TaskCode, + ( signed portCHAR * ) taskname, + configMINIMAL_STACK_SIZE, (UINT16 *)LEDNumber, + tskIDLE_PRIORITY + 2, pTaskHandler); + } /* Create Task to flash LED */ + } + +} diff --git a/Tester/SW/Applications/remote/remote_tests.h b/Tester/SW/Applications/remote/remote_tests.h new file mode 100644 index 0000000..5007fa1 --- /dev/null +++ b/Tester/SW/Applications/remote/remote_tests.h @@ -0,0 +1,104 @@ +/* --------------------------------------------------------------------------- + * remote_tests.h (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Aug 29, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef REMOTE_TESTS_H_ +#define REMOTE_TESTS_H_ +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ +#include "LPC23xx.h" +#include "types.h" + +/* FreeRTOS includes */ +#include "FreeRTOS.h" +#include "Task.h" +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ + +void r_TestInit (void); + + +/* --------------------------------------------------------------------------- + * Function: r_xyzTest + * + * Functions that call the corresponding test on remote Device and handle + * some optical commands like Result printout and LED controlling + * + * Parameter: BOOLEAN * xyztest - Test Result is written to this variable + * + * Return: void + * --------------------------------------------------------------------------- + */ +void r_BatteryTest (BOOLEAN * batterytest); +void r_LEDTest (BOOLEAN * ledtest); +void r_framTest (BOOLEAN * framtest); +void r_EEPROMTest (BOOLEAN * eepromtest); +void r_FLASHTest (BOOLEAN * flashtest); +void r_LogTest (BOOLEAN *logtest); +void r_DIOTest (BOOLEAN * diotest); +void r_AIOTest (BOOLEAN * aiotest); +void r_MMCTest (BOOLEAN * mmctest); +void r_PowerTest (BOOLEAN * powertest); +void r_RTCTest (BOOLEAN * rtctest); + + + +/* --------------------------------------------------------------------------- + * Function: postpareTest + * + * Function to manage all needed things after a Test - e.g. Restore + * DIO-Results or Create/Resume Tasks. + * + * Parameter: BOOLEAN TestResult - Testresult of current Test + * portBASE_TYPE *basetype - TaskCreation Result + * UINT32 LEDNumber - LEDNumber to be used for that Test + * pdTASK_CODE TaskCode - Function, that should be tasked + * pUINT8 taskname - Name for the Task + * xTaskHandle *pTaskHandler - TaskHandler + * + * Return: void + * --------------------------------------------------------------------------- + */ +void postpareTest (BOOLEAN TestResult, portBASE_TYPE *basetype, + UINT32 LEDNumber, pdTASK_CODE TaskCode, + pUINT8 taskname, xTaskHandle *pTaskHandler); + +#endif /*REMOTE_TESTS_H_*/ diff --git a/Tester/SW/Applications/remote/test_analogue.c b/Tester/SW/Applications/remote/test_analogue.c new file mode 100644 index 0000000..0d7b932 --- /dev/null +++ b/Tester/SW/Applications/remote/test_analogue.c @@ -0,0 +1,341 @@ +/* --------------------------------------------------------------------------- + * test_analogue.c (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Dez 15, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +#include "LPC23xx.h" +#include "types.h" + +/* FreeRTOS includes */ +#include "FreeRTOS.h" +#include "Task.h" +#include "semphr.h" +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "test_analogue.h" +#include "remote_analogue.h" +#include "adc.h" +#include "dac.h" + +#include "remote_tests.h" +#include "SerOut.h" +#include "protocolfunctions.h" +#include "BusProtocol.h" + + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ +#define cTestvalue 15000 +#define cNullvalue 0 + +#define ciTolerance_null 50 +#define ciTolerance_uncal 3500 +#define ciTolerance_cal 50 + +#define coTolerance_null 50 +#define coTolerance_uncal 3500 +#define coTolerance_cal 50 +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ + +BOOLEAN remoteAnalogueLinetestMBExecute (void) +{ + BOOLEAN returnValue; + BOOLEAN remoteAnalogueOutput; + BOOLEAN remoteAnalogueInput; + + remoteAnalogueOutput = remoteAnalogueOutputTest_MB(); + sendString (SerOutPort, TRUE, resultMessage, + "remote analogue output test: ", f_tab, BoolRestoStr(remoteAnalogueOutput)); + + remoteAnalogueInput = remoteAnalogueInputTest_MB(); + sendString (SerOutPort, TRUE, resultMessage, + "remote analogue input test: ", f_tab, BoolRestoStr(remoteAnalogueInput)); + + if ((remoteAnalogueOutput == TRUE) && (remoteAnalogueInput == TRUE)) + { + returnValue = TRUE; + } + else + { + returnValue = FALSE; + } + + return (returnValue); + +} + + +BOOLEAN remoteAnalogueLinetestEBExecute (void) +{ +// \MARK NEW PINSETTINGS FOR TESTER (2) +#if (PINSET_TESTER == 2) + BOOLEAN remoteAnalogueOutput; + BOOLEAN remoteAnalogueInput; + + remoteAnalogueOutput = remoteAnalogueOutputTest_MB(); + sendString (SerOutPort, TRUE, resultMessage, + "remote analogue output test: ", f_tab, BoolRestoStr(remoteAnalogueOutput)); + + remoteAnalogueInput = remoteAnalogueInputTest_MB(); + sendString (SerOutPort, TRUE, resultMessage, + "remote analogue input test: ", f_tab, BoolRestoStr(remoteAnalogueInput)); + + if ((remoteAnalogueOutput == TRUE) && (remoteAnalogueInput == TRUE)) + { + returnValue = TRUE; + } + else + { + returnValue = FALSE; + } + + return (returnValue); +#else + sendString (SerOutPort, TRUE, importantMessage, + "Extension Board test not available on this device", Dummy, Dummy); + + return (FALSE); +#endif +} + +BOOLEAN remoteAnalogueOutputTest_MB (void) +{ + UINT32 loopcnt; + UINT32 channelcnt; + UINT32 testTolerance; + UINT32 lowRead; + UINT32 highRead; + + BOOLEAN returnResult = TRUE; + BOOLEAN Low_Test = TRUE; + BOOLEAN High_Test = TRUE; + BOOLEAN AllOther_Test = TRUE; + + + // \TODO SET TEST TOLERANCE DEPENDING ON THE CALIBRATION STATUS + testTolerance = coTolerance_uncal; + + adcModeAll(adcCURRENT); /* Set local ADC to mode CURRENT*/ + remoteAioWriteAll(remoteDeviceNumber, analogue_mb, cNullvalue); + vTaskDelay (500); + + sendString (SerOutPort, FALSE, testMessage, NewLine, + "\tCurrent Test Value: ", ItoDStr (cTestvalue)); + sendString (SerOutPort, FALSE, testMessage, + "\t\tTolerance: ", ItoDStr (testTolerance), Dummy); + + for (channelcnt = 0; channelcnt < NUMBER_OF_AO_MB; channelcnt++) + { + lowRead = adcRead(thisDeviceNumber, channelcnt); + if (lowRead < (cNullvalue + coTolerance_null)) + { + /* Read a null-like value - LOW test passed */ + } + else + { + /* Read a too high value - LOW test failed */ + Low_Test = FALSE; + } + + remoteAioWrite(remoteDeviceNumber, channelcnt, cTestvalue); + vTaskDelay (500); + highRead = adcRead(thisDeviceNumber, channelcnt); + + if ((highRead < (cTestvalue + testTolerance)) && (highRead > (cTestvalue - testTolerance))) + { + /* Read a value within the test tolerances - High test passed */ + } + else + { + /* read a value out of the test tolerances - High test failed */ + High_Test = FALSE; + } + + for (loopcnt = 0; loopcnt < NUMBER_OF_AO_MB; loopcnt++) + { + if (loopcnt == channelcnt) + { + /* Skip actual test channel */ + } + else + { + /* Check channel for remaining LOW */ + if (adcRead(thisDeviceNumber, loopcnt) >= (cNullvalue + coTolerance_null)) + { + /* Actual channels value too high, AllOther test failed */ + AllOther_Test = FALSE; + } + } + } + + remoteAioWrite(remoteDeviceNumber, channelcnt, cNullvalue); + + /* Message out Test Results */ + sendString (SerOutPort, TRUE, testMessage, + "\tCurrent Test for Analogue Input ", ItoDStr(channelcnt), ": "); + sendString (SerOutPort, FALSE, testMessage, + " ", Dummy, ItoDStr (lowRead)); + sendString (SerOutPort, FALSE, testMessage, + " ", Dummy, ItoDStr (highRead)); + sendString (SerOutPort, FALSE, testMessage, + " All Other: ", Dummy, BoolRestoStr (AllOther_Test)); + + if ((Low_Test == FALSE) || (High_Test == FALSE) || (AllOther_Test == FALSE)) + { + returnResult = FALSE; + } + } + + return (returnResult); +} + + + +BOOLEAN remoteAnalogueInputTest_MB (void) +{ + UINT32 loopcnt; + UINT32 channelcnt; + UINT32 testTolerance; + UINT32 lowRead; + UINT32 highRead; + + BOOLEAN returnResult = TRUE; + BOOLEAN Low_Test = TRUE; + BOOLEAN High_Test = TRUE; + BOOLEAN AllOther_Test = TRUE; + + // \TODO SET TEST TOLERANCE DEPENDING ON THE CALIBRATION STATUS + testTolerance = coTolerance_uncal; + + dacModeAll(dacCURRENT); /* Set local DAC to mode CURRENT*/ + /* Reset all local DAC channels to zero ampere */ + for (loopcnt = 0; loopcnt < maxDAC_Channels; loopcnt++) + { + dacWrite(thisDeviceNumber, loopcnt, cNullvalue); + } + + vTaskDelay (500); + + sendString (SerOutPort, FALSE, testMessage, NewLine, + "\tCurrent Test Value: ", ItoDStr (cTestvalue)); + sendString (SerOutPort, FALSE, testMessage, + "\t\tTolerance: ", ItoDStr (testTolerance), Dummy); + + for (channelcnt = 0; channelcnt < NUMBER_OF_AI_MB; channelcnt++) + { + lowRead = remoteAioRead(remoteDeviceNumber, channelcnt); + if (lowRead < (cNullvalue + testTolerance)) + { + /* Read a null-like value - LOW test passed */ + Low_Test = TRUE; + } + else + { + /* Read a too high value - LOW test failed */ + Low_Test = FALSE; + } + + dacWrite(thisDeviceNumber, channelcnt, cTestvalue); + vTaskDelay (200); + highRead = remoteAioRead(remoteDeviceNumber, channelcnt); + + if ((highRead < (cTestvalue + testTolerance)) && (highRead > (cTestvalue - testTolerance))) + { + /* Read a value within the test tolerances - High test passed */ + High_Test = TRUE; + } + else + { + /* read a value out of the test tolerances - High test failed */ + High_Test = FALSE; + } + + remoteAioReadAll(remoteDeviceNumber, analogue_mb); + vTaskDelay (200); + + for (loopcnt = 0; loopcnt < NUMBER_OF_AO_MB; loopcnt++) + { + if (loopcnt == channelcnt) + { + /* Skip test channel */ + } + else + { + /* Check actual channel to remain LOW */ + if (remoteAnalogueOutputs[loopcnt] >= (cNullvalue + ciTolerance_null)) + { + /* Channel should remain LOW - AllOther test failed */ + AllOther_Test = FALSE; + break; /* Skip rest of loop */ + } + else + { + AllOther_Test = TRUE; + } + } + } + + dacWrite(thisDeviceNumber, channelcnt, cNullvalue); + + /* Message out Test Results */ + sendString (SerOutPort, TRUE, testMessage, + "\tCurrent Test for Analogue Input ", ItoDStr(channelcnt), ": "); + sendString (SerOutPort, FALSE, testMessage, + " ", Dummy, ItoDStr (lowRead)); + sendString (SerOutPort, FALSE, testMessage, + " ", Dummy, ItoDStr (highRead)); + sendString (SerOutPort, FALSE, testMessage, + " All Other: ", Dummy, BoolRestoStr (AllOther_Test)); + + if ((Low_Test == FALSE) || (High_Test == FALSE) || (AllOther_Test == FALSE)) + { + returnResult = FALSE; + } + } + + return (returnResult); + + +} + + + +BOOLEAN remoteAnalogueOutputTest_EB (void) +{ + +} diff --git a/Tester/SW/Applications/remote/test_analogue.h b/Tester/SW/Applications/remote/test_analogue.h new file mode 100644 index 0000000..8dcb2e7 --- /dev/null +++ b/Tester/SW/Applications/remote/test_analogue.h @@ -0,0 +1,69 @@ +/* --------------------------------------------------------------------------- + * test_analogue.h (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Dez 15, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef TEST_ANALOGUE_H_ +#define TEST_ANALOGUE_H_ +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ +#include "LPC23xx.h" +#include "types.h" + +/* FreeRTOS includes */ +#include "FreeRTOS.h" +#include "Task.h" +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ + +BOOLEAN remoteAnalogueLinetestMBExecute (void); + +BOOLEAN remoteAnalogueLinetestEBExecute (void); + +BOOLEAN remoteAnalogueOutputTest_MB (void); + +BOOLEAN remoteAnalogueInputTest_MB (void); + +BOOLEAN remoteAnalogueOutputTest_EB (void); + +BOOLEAN remoteAnalogueInputTest_EB (void); + + +#endif /*TEST_ANALOGUE_H_*/ diff --git a/Tester/SW/Applications/remote/test_digital.c b/Tester/SW/Applications/remote/test_digital.c new file mode 100644 index 0000000..b3e681a --- /dev/null +++ b/Tester/SW/Applications/remote/test_digital.c @@ -0,0 +1,499 @@ +/* --------------------------------------------------------------------------- + * test_digital.c (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Dez 15, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +#include "LPC23xx.h" +#include "types.h" + +/* FreeRTOS includes */ +#include "FreeRTOS.h" +#include "Task.h" +#include "semphr.h" +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "test_digital.h" +#include "remote_digital.h" + +#include "dio.h" +#include "remote_tests.h" +#include "SerOut.h" +#include "protocolfunctions.h" +#include "BusProtocol.h" +#include "ledfunctions.h" + + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ + +BOOLEAN remoteDigitalLinetestMBExecute (void) +{ + BOOLEAN returnValue; + BOOLEAN remoteDigitalOutput; + BOOLEAN remoteDigitalInput; + + + remoteDigitalOutput = remoteDigitalOutputTest_MB(); + sendString (SerOutPort, TRUE, resultMessage, + "remote digital_mb output test: ", f_tab, BoolRestoStr(remoteDigitalOutput)); + remoteDigitalInput = remoteDigitalInputTest_MB(); + sendString (SerOutPort, TRUE, resultMessage, + "remote digital_mb input test: ", f_tab, BoolRestoStr(remoteDigitalInput)); + + if ((remoteDigitalOutput == TRUE) && (remoteDigitalInput == TRUE)) + { + returnValue = TRUE; + } + else + { + returnValue = FALSE; + } + + return (returnValue); +} + +BOOLEAN remoteDigitalLinetestEBExecute (void) +{ +// \MARK NEW PINSETTINGS FOR TESTER (2) +#if (PINSET_TESTER == 2) + BOOLEAN returnValue; + BOOLEAN remoteDigitalOutput; + BOOLEAN remoteDigitalInput; + + remoteDigitalOutput = remoteDigitalOutputTest_EB(); + sendString (SerOutPort, TRUE, resultMessage, + "remote digital_eb output test: ", f_tab, BoolRestoStr(remoteDigitalOutput)); + + remoteDigitalInput = remoteDigitalInputTest_EB(); + sendString (SerOutPort, TRUE, resultMessage, + "remote digital_eb input test: ", f_tab, BoolRestoStr(remoteDigitalInput)); + + if ((remoteDigitalOutput == TRUE) && (remoteDigitalInput == TRUE)) + { + returnValue = TRUE; + } + else + { + returnValue = FALSE; + } + + return (returnValue); +#else + sendString (SerOutPort, TRUE, importantMessage, + "Extension Board test not available on this device", Dummy, Dummy); + + return (FALSE); +#endif +} + + +BOOLEAN remoteDigitalOutputTest_MB (void) +{ + UINT32 channelcnt; + UINT32 loopcnt; + + BOOLEAN returnResult = TRUE; + BOOLEAN Low_Test = TRUE; + BOOLEAN High_Test = TRUE; + BOOLEAN AllOther_Test = TRUE; + + /* Reset all remote digital outputs to LOW/OFF */ + remoteDioWriteAll(remoteDeviceNumber, digital_mb, FALSE); + vTaskDelay (200); + + for (channelcnt = 0; channelcnt < NUMBER_OF_DO_MB; channelcnt++) + { + + /* Read remote digital channel value for LOW test */ + if (dioRead(thisDeviceNumber, channelcnt) == FALSE) + { + /* Read back a LOW Value, which is correct - LOW test passed */ + Low_Test = TRUE; + } + else + { + /* read back a HIGH Value, which is incorrect - LOW test failed */ + Low_Test = FALSE; + } + + /* Drive testchannel to HIGH Output value */ + remoteDioWrite(remoteDeviceNumber, channelcnt, TRUE); + vTaskDelay (200); /* Assure command was executed */ + + if (dioRead(thisDeviceNumber, channelcnt) == TRUE) + { + /* Read back a HIGH Value, which is correct - HIGH test passed */ + High_Test = TRUE; + } + else + { + /* read back a LOW Value, which is incorrect - HIGH test failed */ + High_Test = FALSE; + } + + vTaskDelay (200); + /* Check all other channels for remaining at LOW */ + for (loopcnt = 0; loopcnt < NUMBER_OF_DO_MB; loopcnt++) + { + if (loopcnt == channelcnt) + { + /* Skip test channel */ + } + else + { + /* Check actual channel to remain LOW */ + if (dioRead(thisDeviceNumber, loopcnt) == TRUE) + { + /* Channel should remain LOW - AllOther test failed */ + AllOther_Test = FALSE; + break; /* Skip rest of loop */ + } + else + { + AllOther_Test = TRUE; + } + } + } + + remoteDioWrite(remoteDeviceNumber, channelcnt, FALSE); + + /* Message out Test Results */ + sendString (SerOutPort, TRUE, testMessage, + "\tLinetest for Digital Input ", ItoDStr(channelcnt), ": "); + sendString (SerOutPort, FALSE, testMessage, + " ", Dummy, BoolRestoStr (Low_Test)); + sendString (SerOutPort, FALSE, testMessage, + " ", Dummy, BoolRestoStr (AllOther_Test)); + sendString (SerOutPort, FALSE, testMessage, + " ", Dummy, BoolRestoStr (High_Test)); + vTaskDelay (50); + + if ((Low_Test == FALSE) || (High_Test == FALSE) || (AllOther_Test == FALSE)) + { + returnResult = FALSE; + } + } + + return (returnResult); +} + +BOOLEAN remoteDigitalInputTest_MB (void) +{ + UINT32 channelcnt; + UINT32 loopcnt; + + BOOLEAN returnResult = TRUE; + BOOLEAN Low_Test = TRUE; + BOOLEAN High_Test = TRUE; + BOOLEAN AllOther_Test = TRUE; + + dioClean(); /* Clean local digital outputs */ + vTaskDelay (500); + + for (channelcnt = 0; channelcnt < NUMBER_OF_DI_MB; channelcnt++) + { + if (remoteDioRead(remoteDeviceNumber, channelcnt) == FALSE) + { + /* Read back a LOW Value, which is correct - LOW test passed */ + Low_Test = TRUE; + } + else + { + /* read back a HIGH Value, which is incorrect - LOW test failed */ + Low_Test = FALSE; + } + + vTaskDelay (200); + dioWrite(thisDeviceNumber, channelcnt, TRUE); + vTaskDelay(200); + + if (remoteDioRead(remoteDeviceNumber, channelcnt) == TRUE) + { + /* Read back a HIGH Value, which is correct - HIGH test passed */ + vTaskDelay(500); + High_Test = TRUE; + } + else + { + /* read back a LOW Value, which is incorrect - HIGH test failed */ + vTaskDelay(500); + High_Test = FALSE; + } + + remoteDioReadAll(remoteDeviceNumber, digital_mb); + vTaskDelay (200); + + for (loopcnt = 0; loopcnt < NUMBER_OF_DI_MB; loopcnt++) + { + if (loopcnt == channelcnt) + { + /* Skip test channel */ + } + else + { + /* Check actual channel to remain LOW */ + if (remoteDigitalInputs[loopcnt] == TRUE) + { + /* Channel should remain LOW - AllOther test failed */ + AllOther_Test = FALSE; + break; /* Skip rest of loop */ + } + else + { + AllOther_Test = TRUE; + } + } + } + /* Return to LOW channel value */ + dioWrite (thisDeviceNumber, channelcnt, FALSE); + + /* Message out Test Results */ + sendString (SerOutPort, TRUE, testMessage, + "\tLinetest for Digital Input ", ItoDStr(channelcnt), ": "); + sendString (SerOutPort, FALSE, testMessage, + " ", Dummy, BoolRestoStr (Low_Test)); + sendString (SerOutPort, FALSE, testMessage, + " ", Dummy, BoolRestoStr (AllOther_Test)); + sendString (SerOutPort, FALSE, testMessage, + " ", Dummy, BoolRestoStr (High_Test)); + vTaskDelay (50); + + if ((Low_Test == FALSE) || (High_Test == FALSE) || (AllOther_Test == FALSE)) + { + returnResult = FALSE; + } + } + + return (returnResult); +} + + +BOOLEAN remoteDigitalOutputTest_EB (void) +{ + UINT32 channelcnt; + UINT32 loopcnt; + + BOOLEAN returnResult = TRUE; + BOOLEAN Low_Test = TRUE; + BOOLEAN High_Test = TRUE; + BOOLEAN AllOther_Test = TRUE; + +// \MARK NEW PINSETTINGS FOR TESTER (2) +#if (PINSET_TESTER == 2) + dio_inMuxEn (TRUE); /* Switch dio to Extension Board*/ +#endif + + /* Reset all remote digital outputs to LOW/OFF */ + remoteDioWriteAll(remoteDeviceNumber, digital_eb, FALSE); + vTaskDelay (200); + + for (channelcnt = NUMBER_OF_DO_MB; channelcnt < NUMBER_OF_TOTAL_DO; channelcnt++) + { + if (dioRead(thisDeviceNumber, (channelcnt - NUMBER_OF_DO_MB)) == FALSE) + { + /* Read back a LOW Value, which is correct - LOW test passed */ + Low_Test = TRUE; + } + else + { + /* read back a HIGH Value, which is incorrect - LOW test failed */ + Low_Test = FALSE; + } + + /* Drive testchannel to HIGH Output value */ + remoteDioWrite(remoteDeviceNumber, channelcnt, TRUE); + vTaskDelay (200); /* Assure command was executed */ + + if (dioRead(remoteDeviceNumber, (channelcnt - NUMBER_OF_DO_MB)) == TRUE) + { + /* Read back a HIGH Value, which is correct - HIGH test passed */ + High_Test = TRUE; + } + else + { + /* read back a LOW Value, which is incorrect - HIGH test failed */ + High_Test = FALSE; + } + + vTaskDelay (200); + for (loopcnt = 0; loopcnt < NUMBER_OF_DO_EB; loopcnt++) + { + if (loopcnt == channelcnt) + { + /* Skip test channel */ + } + else + { + /* Check actual channel to remain LOW */ + if (dioRead(thisDeviceNumber, loopcnt) == TRUE) + { + /* Channel should remain LOW - AllOther test failed */ + AllOther_Test = FALSE; + break; /* Skip rest of loop */ + } + else + { + AllOther_Test = TRUE; + } + } + } + /* Message out Test Results */ + sendString (SerOutPort, TRUE, testMessage, + "\tLinetest for Digital Input ", ItoDStr(channelcnt), ": "); + sendString (SerOutPort, FALSE, testMessage, + " ", Dummy, BoolRestoStr (Low_Test)); + sendString (SerOutPort, FALSE, testMessage, + " ", Dummy, BoolRestoStr (AllOther_Test)); + sendString (SerOutPort, FALSE, testMessage, + " ", Dummy, BoolRestoStr (High_Test)); + vTaskDelay (50); + + if ((Low_Test == FALSE) || (High_Test == FALSE) || (AllOther_Test == FALSE)) + { + returnResult = FALSE; + } + } + +// \MARK NEW PINSETTINGS FOR TESTER (2) +#if (PINSET_TESTER == 2) + dio_inMuxEn (FALSE); /* Switch dio back to main Board*/ +#endif + + return (returnResult); +} + + +BOOLEAN remoteDigitalInputTest_EB (void) +{ + UINT32 channelcnt; + UINT32 loopcnt; + + BOOLEAN returnResult = TRUE; + BOOLEAN Low_Test = TRUE; + BOOLEAN High_Test = TRUE; + BOOLEAN AllOther_Test = TRUE; + +// \MARK NEW PINSETTINGS FOR TESTER (2) +#if (PINSET_TESTER == 2) + dio_outMuxEn (TRUE); /* Switch dio to Extension Board*/ +#endif + + dioClean(); /* Clean local digital outputs */ + vTaskDelay (500); + + for (channelcnt = 0; channelcnt < NUMBER_OF_DI_EB; channelcnt++) + { + if (remoteDioRead(remoteDeviceNumber, (channelcnt + NUMBER_OF_DI_MB)) == FALSE) + { + /* Read back a LOW Value, which is correct - LOW test passed */ + Low_Test = TRUE; + } + else + { + /* read back a HIGH Value, which is incorrect - LOW test failed */ + Low_Test = FALSE; + } + + vTaskDelay (200); + dioWrite(thisDeviceNumber, channelcnt, TRUE); + + if (remoteDioRead(remoteDeviceNumber, (channelcnt + NUMBER_OF_DI_MB)) == TRUE) + { + /* Read back a HIGH Value, which is correct - HIGH test passed */ + High_Test = TRUE; + } + else + { + /* read back a LOW Value, which is incorrect - HIGH test failed */ + High_Test = FALSE; + } + + remoteDioReadAll(remoteDeviceNumber, digital_eb); + vTaskDelay (200); + + for (loopcnt = 0; loopcnt < NUMBER_OF_DI_EB; loopcnt++) + { + if (loopcnt == channelcnt) + { + /* Skip test channel */ + } + else + { + /* Check actual channel to remain LOW */ + if (remoteDigitalInputs[(loopcnt + NUMBER_OF_DI_MB)] == TRUE) + { + /* Channel should remain LOW - AllOther test failed */ + AllOther_Test = FALSE; + break; /* Skip rest of loop */ + } + else + { + AllOther_Test = TRUE; + } + } + } + /* Return to LOW channel value */ + dioWrite (thisDeviceNumber, channelcnt, FALSE); + + /* Message out Test Results */ + sendString (SerOutPort, TRUE, testMessage, + "\tLinetest for Digital Input ", ItoDStr(channelcnt), ": "); + sendString (SerOutPort, FALSE, testMessage, + " ", Dummy, BoolRestoStr (Low_Test)); + sendString (SerOutPort, FALSE, testMessage, + " ", Dummy, BoolRestoStr (AllOther_Test)); + sendString (SerOutPort, FALSE, testMessage, + " ", Dummy, BoolRestoStr (High_Test)); + vTaskDelay (50); + + if ((Low_Test == FALSE) || (High_Test == FALSE) || (AllOther_Test == FALSE)) + { + returnResult = FALSE; + } + } + +// \MARK NEW PINSETTINGS FOR TESTER (2) +#if (PINSET_TESTER == 2) + dio_outMuxEn (FALSE); /* Switch dio back to main Board*/ +#endif + + return (returnResult); +} + diff --git a/Tester/SW/Applications/remote/test_digital.h b/Tester/SW/Applications/remote/test_digital.h new file mode 100644 index 0000000..7c68fab --- /dev/null +++ b/Tester/SW/Applications/remote/test_digital.h @@ -0,0 +1,61 @@ +/* --------------------------------------------------------------------------- + * test_digital.h (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Dez 15, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef TEST_DIGITAL_H_ +#define TEST_DIGITAL_H_ +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ +#include "LPC23xx.h" +#include "types.h" + +/* FreeRTOS includes */ +#include "FreeRTOS.h" +#include "Task.h" +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ +BOOLEAN remoteDigitalLinetestMBExecute (void); +BOOLEAN remoteDigitalLinetestEBExecute (void); + +BOOLEAN remoteDigitalOutputTest_MB (void); +BOOLEAN remoteDigitalInputTest_MB (void); +BOOLEAN remoteDigitalOutputTest_EB (void); +#endif /*TEST_DIGITAL_H_*/ diff --git a/Tester/SW/Applications/remote/test_leds.c b/Tester/SW/Applications/remote/test_leds.c new file mode 100644 index 0000000..a56f910 --- /dev/null +++ b/Tester/SW/Applications/remote/test_leds.c @@ -0,0 +1,140 @@ +/* --------------------------------------------------------------------------- + * test_leds.c (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: remote LED test sequence + * --------------------------------------------------------------------------- + * Version(s): 0.1, Dez 16, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +#include "LPC23xx.h" +#include "types.h" + +#include "FreeRTOS.h" +#include "task.h" +#include "semphr.h" +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ + +#include "protocolfunctions.h" +#include "BusProtocol.h" +#include "SerOut.h" + +#include "remote_analogue.h" +#include "remote_digital.h" +#include "remote_relay.h" +#include "dio.h" + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ + + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ + +BOOLEAN remoteLEDTestMBexecute (void) +{ + UINT32 loopcnt; + UINT8 buffer; + BOOLEAN ledTest = TRUE; + BOOLEAN receive = FALSE; + + + /* Drive LEDs to status ON */ + sendString (SerOutPort, GotoNewLine, testMessage, + "Set local digital outputs to HIGH... ", Dummy, Dummy); + /* Set digital input LEDs to ON */ + for (loopcnt = 0; loopcnt < maxDO_Channels; loopcnt++) + { + dioWrite(thisDeviceNumber, loopcnt, TRUE); + } + sendString (SerOutPort, FALSE, testMessage, + "Done", Dummy, Dummy); + + /* Set remote digital output LEDs to on */ + sendString (SerOutPort, GotoNewLine, testMessage, + "Set remote digital outputs to HIGH... ", Dummy, Dummy); + if (remoteDioWriteAll(remoteDeviceNumber, digital_mb, TRUE) == OK) + { + sendString (SerOutPort, FALSE, testMessage, + "Done", Dummy, Dummy); + } + else + { + sendString (SerOutPort, FALSE, testMessage, + "Failed", Dummy, Dummy); + } + + /* Set remote relay througput LEDs to on */ + sendString (SerOutPort, GotoNewLine, testMessage, + "Set remote relay outputs to HIGH... ", Dummy, Dummy); + if (remoteRelaySetAll(remoteDeviceNumber, relay_mb, TRUE) == OK) + { + sendString (SerOutPort, FALSE, testMessage, + "Done", Dummy, Dummy); + } + else + { + sendString (SerOutPort, FALSE, testMessage, + "Failed", Dummy, Dummy); + } + + + + + sendString (SerOutPort, TRUE, noteMessage, + "\tAre all LEDs turned on? ", + "\n\r\tPRESS y (YES) oder n (NO): ", + NewLine); + + do /* do-while loop for String input */ + { + receive = serGet(SerOutPort, &buffer); + + } while ((buffer != 121) && (buffer != 110)); + + if (buffer == 121) /* 121 = y (ScanCode) */ + { + sendString (SerOutPort, TRUE, noteMessage, + "All LEDs working", Dummy, Dummy); + ledTest = TRUE; + } + else if (buffer == 110) /* 110 = n (ScanCode) */ + { + sendString (SerOutPort, TRUE, noteMessage, + "LEDs broken", Dummy, Dummy); + ledTest = FALSE; + } + + // \TODO CALCULATE RESULT +} diff --git a/Tester/SW/Applications/remote/test_leds.h b/Tester/SW/Applications/remote/test_leds.h new file mode 100644 index 0000000..a9529a2 --- /dev/null +++ b/Tester/SW/Applications/remote/test_leds.h @@ -0,0 +1,56 @@ +/* --------------------------------------------------------------------------- + * test_leds.h (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Dez 16, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef TEST_LEDS_H_ +#define TEST_LEDS_H_ + +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ +#include "LPC23xx.h" +#include "types.h" +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ + +BOOLEAN remoteLEDTestMBexecute (void); + + +#endif /*TEST_LEDS_H_*/ diff --git a/Tester/SW/Applications/testfiles/testBUS.c b/Tester/SW/Applications/testfiles/testBUS.c new file mode 100644 index 0000000..bdacf62 --- /dev/null +++ b/Tester/SW/Applications/testfiles/testBUS.c @@ -0,0 +1,216 @@ +/* --------------------------------------------------------------------------- + * testuart2.c (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * Contains BUS System Test Functions + * --------------------------------------------------------------------------- + * Version(s): 0.1, Mar 10, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ + +/* APPLICATION NOTE FOR BUS TEST!!!! + * + * THIS TEST ONLY WILL WORK IF DEVICE IS RUNNING IN A SINGLE MODE. IF DEVICE + * IS INITIALIZED WITH BUS PROTOCOL (ANYWAY IF MASTER OR SLAVE), THIS TEST + * WILL CAUSE THE HARDWARE TO CRASH + */ + + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +#include "lpc23xx.h" +#include "types.h" + +#include "FreeRTOS.h" +#include "task.h" +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "testBUS.h" +#include "bus.h" +#include "uart2.h" +#include "uart3.h" +#include "SerOut.h" +#include "taskfunctions.h" +#include "ledfunctions.h" + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ +char BUS1Buffer[20] = " 'BUSTEST first' "; /* first Teststring */ +char BUS2Buffer[20] = " 'BUSTEST second' "; /* second Teststring */ + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ + +extern void onUart2TxFinished(); +extern void onUart3TxFinished(); + + +BOOLEAN testbusStart(void) +{ + /*Local Variable Declaration */ + BOOLEAN BUSTestResult = FALSE; + BOOLEAN BUSTest11 = FALSE; + BOOLEAN BUSTest12 = FALSE; + BOOLEAN BUSTest21 = FALSE; + BOOLEAN BUSTest22 = FALSE; + BOOLEAN receive; + UINT8 buffer; + + + BUSTest11 = DoBUS1Test(); /* Test Bus1 */ + BUSTest12 = DoBUS2Test(); /* Test Bus2 */ + + + sendString (SerOutPort, TRUE, noteMessage, /* Send Text notification */ + NewLine, "\tSWITCH BUS CONNECTOR AND PRESS ENTER", NewLine); + + do /* do-while loop for String input */ + { + receive = serGet(SerOutPort, &buffer); + } while (buffer != 13); /*Read input until ENTER-Key */ + + BUSTest21 = DoBUS1Test(); /* Test Bus1 */ + BUSTest22 = DoBUS2Test(); /* Test Bus2 */ + + if ((BUSTest11 == TRUE) && (BUSTest12 == TRUE) + &&(BUSTest21 == TRUE) && (BUSTest22 == TRUE)) + { /* If both Bustests passed */ + BUSTestResult = TRUE; /* set Test Result to TRUE */ + } + + return BUSTestResult; /* Return Test Result */ +} + +BOOLEAN DoBUS1Test (void) +{ + /* Local Variable Declaration */ + BOOLEAN Uart2TestResult = TRUE; + UINT16 B1received_int = 0; + UINT16 B1send_int = 0; + UINT8 B1receiveBuffer[50]; + + + sendString (SerOutPort, TRUE, testMessage, + "\tWrite String ", BUS1Buffer, " on BUS1... "); + busWrite ( BUS1, sizeof (BUS1Buffer), (UINT8 *) BUS1Buffer); + /* Send Teststring on Bus1 */ + vTaskDelay (500); /* Wait to InputRegister to be ready*/ + B1send_int = sizeof (BUS1Buffer); /* calculate Length of Teststring */ + B1received_int = busRead (BUS2, (UINT8 *)B1receiveBuffer); + /* Read Teststring on Bus2 */ + sendString (SerOutPort, TRUE, testMessage, + "\tRead ", (char *) B1receiveBuffer, " on BUS2"); + /* Message out received String */ + if (B1send_int != B1received_int) /* If received String is a fault */ + { + Uart2TestResult = FALSE; /* Set Bus1 TestResult to FALSE */ + } + return Uart2TestResult; /* Return Test Result */ +} + +BOOLEAN DoBUS2Test (void) +{ + /* See "DoBUS1Test" for comments */ + + BOOLEAN Uart3TestResult = TRUE; + UINT16 B2received_int = 0; + UINT16 B2send_int = 0; + UINT8 B2receiveBuffer[50]; + + sendString (SerOutPort, TRUE, testMessage, + "\tWrite String ", BUS2Buffer, " on BUS2... "); + busWrite ( BUS2, sizeof (BUS2Buffer), (UINT8 *) BUS2Buffer); + vTaskDelay( 500 ); + B2send_int = sizeof (BUS2Buffer); + B2received_int = busRead (BUS1, (UINT8 *)B2receiveBuffer); + sendString (SerOutPort, TRUE, testMessage, + "\tRead ", (char *) B2receiveBuffer, " on BUS1"); + + if (B2send_int != B2received_int) + { + Uart3TestResult = FALSE; + } + return Uart3TestResult; +} + +BOOLEAN Uart2LoopBackTest (void) +{ + /* UART2 is in LoopBack by forcing it to receive its own Transmission */ + FIO4CLR |= (1 << 1); /* Enable Receiver */ + FIO4SET |= (1 << 0); /* Enable Transmitter */ + + /* Local Variable Declaration */ + BOOLEAN Result = TRUE; /* LoopBack Test Result */ + char EBBuffer[10] = "placed"; /* Teststring */ + UINT16 EBsend_int = 0; + UINT16 EBreceived_int = 0; + UINT8 EBreceiveBuffer[10]; + + uart2Write( (char *)EBBuffer, sizeof(EBBuffer)); /* Write Teststring */ + EBsend_int = sizeof (EBBuffer); /* Calculate Length */ + vTaskDelay (500); /* Wait to InputRegister to be ready*/ + EBreceived_int = busRead (BUS2, (UINT8 *)EBreceiveBuffer); + /* Read/Delete received String */ + EBreceived_int = busRead (BUS1, (UINT8 *)EBreceiveBuffer); + /* Read/Delete received String */ + if (EBsend_int != EBreceived_int) /* If received String is a fault */ + { + Result = FALSE; /* Set Result to FALSE */ + } + + onUart2TxFinished(); /* Switch back to receive Mode */ + return Result; /* Return Result */ +} + +BOOLEAN Uart3LoopBackTest (void) +{ + /* UART3 is in LoopBack by forcing it to receive its own Transmission */ + FIO4CLR |= (1 << 3); /* Enable Receiver */ + FIO4SET |= (1 << 2); /* Enable Transmitter */ + + BOOLEAN Result = TRUE; + + char EBBuffer[10] = "placed"; + UINT16 EBsend_int = 0; + UINT16 EBreceived_int = 0; + UINT8 EBreceiveBuffer[10]; + + uart3Write( (char *)EBBuffer, sizeof(EBBuffer)); + EBsend_int = sizeof (EBBuffer); + vTaskDelay (500); + EBreceived_int = busRead (BUS1, (UINT8 *)EBreceiveBuffer); + EBreceived_int = busRead (BUS2, (UINT8 *)EBreceiveBuffer); + if (EBsend_int != EBreceived_int) + { + Result = FALSE; + } + onUart3TxFinished(); + return Result; +} diff --git a/Tester/SW/Applications/testfiles/testBUS.h b/Tester/SW/Applications/testfiles/testBUS.h new file mode 100644 index 0000000..f24a73b --- /dev/null +++ b/Tester/SW/Applications/testfiles/testBUS.h @@ -0,0 +1,94 @@ +/* --------------------------------------------------------------------------- + * testuart2.h (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * Headerfile for testBus.c + * --------------------------------------------------------------------------- + * Version(s): 0.1, Mar 10, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef TESTUART2_H_ +#define TESTUART2_H_ +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ +#include "lpc23xx.h" +#include "types.h" + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function: testBUSStart + * + * Main Function of BUS Tests + * + * Parameters: void + * + * Return: BOOLEAN - Test Result + * --------------------------------------------------------------------------- + */ +BOOLEAN testbusStart(); + +/* --------------------------------------------------------------------------- + * Function: DoBUS1Test / DoBUS2Test + * + * Functions to Test both Busses + * + * Parameters: void + * + * Return: BOOLEAN - single Test Result + * --------------------------------------------------------------------------- + */ +BOOLEAN DoBUS1Test (void); +BOOLEAN DoBUS2Test (void); + +/* --------------------------------------------------------------------------- + * Function: Uart2LoopBackTest / Uart3LoopBackTest + * + * Functions to set either Uart2 or Uart3 in a Loopback Mode to receive it's + * own sent Message. Functions contain a Test that checks wether the received + * Message equals the sent one. + * + * Parameters: void + * + * Return: BOOLEAN - Test Result + * --------------------------------------------------------------------------- + */ +BOOLEAN Uart2LoopBackTest (void); +BOOLEAN Uart3LoopBackTest (void); + + +#endif /*TESTUART2_H_*/ diff --git a/Tester/SW/Applications/testfiles/testLED.c b/Tester/SW/Applications/testfiles/testLED.c new file mode 100644 index 0000000..3d07dc5 --- /dev/null +++ b/Tester/SW/Applications/testfiles/testLED.c @@ -0,0 +1,130 @@ +/* --------------------------------------------------------------------------- + * testLED.c (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Mei 16, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +#include "LPC23xx.h" +#include "types.h" + +/* FreeRTOS includes */ +#include "FreeRTOS.h" +#include "task.h" +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "testLED.h" +#include "serial.h" +#include "SerOut.h" +#include "dio.h" +#include "leds.h" +#include "taskfunctions.h" +#include "ledfunctions.h" +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ + + +BOOLEAN testledStart (void) +{ + BOOLEAN testledResult = FALSE; + + testledResult = doledTest (); + + return (testledResult); +} + +BOOLEAN doledTest (void) +{ + UINT8 buffer; + UINT8 captureDio; + BOOLEAN ledTest = TRUE; + BOOLEAN receive = FALSE; + + captureDio = dioCapture(); + + + /* Set all DIOs to HIGH */ + dioWrite (0, 0, TRUE); + dioWrite (0, 1, TRUE); + dioWrite (0, 2, TRUE); + dioWrite (0, 3, TRUE); + dioWrite (0, 4, TRUE); + dioWrite (0, 5, TRUE); + dioWrite (0, 6, TRUE); + dioWrite (0, 7, TRUE); + + ledSet (LED0, 1); /* Set RED Status LED to HIGH */ + + if (d_gLED == pdPASS) /* Check for existing LED Task */ + { + vTaskSuspend (gLED); /* Suspend existing Task */ + } + ledSet (LED1, 1); /* Set GREEN Status LED to HIGH */ + + + FIO0DIR |= (1 << 13); /* Set USB_LED PIN as GP Output */ + FIO0CLR1 |= (1 << 5); /* Drive USB_LED PIN to ZERO */ + + sendString (SerOutPort, TRUE, noteMessage, + "\tAre all LEDs turned on? ", + "\n\r\tPRESS y (YES) oder n (NO): ", + NewLine); + + do /* do-while loop for String input */ + { + receive = serGet(SerOutPort, &buffer); + + } while ((buffer != 121) && (buffer != 110)); + + if (buffer == 121) /* 121 = y (ScanCode) */ + { + ledTest = TRUE; + } + else if (buffer == 110) /* 110 = n (ScanCode) */ + { + ledTest = FALSE; + } + + vTaskResume (gLED); /* Resume ActiveLED Task */ + FIO0SET1 |= (1 << 5); /* Drive USB_LED PIN to HIGH */ + dioResume(captureDio); + + + return (ledTest); + +} diff --git a/Tester/SW/Applications/testfiles/testLED.h b/Tester/SW/Applications/testfiles/testLED.h new file mode 100644 index 0000000..7e2ca11 --- /dev/null +++ b/Tester/SW/Applications/testfiles/testLED.h @@ -0,0 +1,81 @@ +/* --------------------------------------------------------------------------- + * testLED.h (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: Digital inputs/outputs interface. + * --------------------------------------------------------------------------- + * Version(s): 0.1, Mei 16, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef TESTLED_H_ +#define TESTLED_H_ +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ +#include "LPC23xx.h" +#include "types.h" + +/* FreeRTOS includes */ +#include "FreeRTOS.h" +#include "task.h" + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ +/* --------------------------------------------------------------------------- + * Function: testledStart + * + * Main Function of LED test + * + * Parameters: void + * + * Return: BOOLEAN - Test Result + * --------------------------------------------------------------------------- + */ +BOOLEAN testledStart (void); + +/* --------------------------------------------------------------------------- + * Function: DoledTest + * + * Switchs on all accessable LEDs and asks the user to tell result + * + * Parameters: void + * + * Return: BOOLEAN - single Test Result + * --------------------------------------------------------------------------- + */ +BOOLEAN doledTest (void); + + +#endif /*TESTLED_H_*/ diff --git a/Tester/SW/Applications/testfiles/testMMC.c b/Tester/SW/Applications/testfiles/testMMC.c new file mode 100644 index 0000000..c5dd361 --- /dev/null +++ b/Tester/SW/Applications/testfiles/testMMC.c @@ -0,0 +1,288 @@ +/* --------------------------------------------------------------------------- + * testMMC.c (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * MemoryCard Test Application + * --------------------------------------------------------------------------- + * Version(s): 0.1, Apr 24, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +/* Compiler includes */ +#include + +#include "LPC23xx.h" +#include "types.h" + +/* FreeRTOS includes */ +#include "FreeRTOS.h" +#include "Task.h" +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "testMMC.h" +#include "mmc.h" +#include "mmc_transfer.h" +#include "ledfunctions.h" +#include "SerOut.h" +#include "dio.h" +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ +#define PageSize 512 /* MMC Card Memory Page Size */ +#define ArrayLength 0x1000 /* Length of test Arrays */ + +#define MaxNumberOfAddress 7 /* Number of Testadresses */ +#define MaxNumberOfLength 7 /* Number of Testlengths */ + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ +/* Array contains all Adresses, where Data should be written to */ +UINT32 AddressArray[MaxNumberOfAddress] = + { + 0x00, + 0x10, + 0x200, + 0x23E, + 0x3FF, + 0x400, + 0x401, + }; + +/* Array contains all Lengths, that should be written to the Testadresses */ +UINT32 LengthArray[MaxNumberOfLength]= + { + 0x00, + 0x80, + 0x199, + 0x200, + 0x201, + 0x800, + 0x1000 + }; + +UINT8 Write[0x1000]; /* used with MMC Write Function */ +UINT8 Read[0x1000]; /* used with MMC Read Function */ +UINT8 nullarray[0x1000]; + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ + +BOOLEAN testmmcStart(void) +{ + BOOLEAN testMMCResult = FALSE; + + testMMCResult = DoMMCTest(); + + return (testMMCResult); +} + +BOOLEAN DoMMCTest (void) +{ + UINT32 loopcnt; + UINT32 AddressIndex= 0; + UINT32 LengthIndex = 0; + UINT8 character = 4; + BOOLEAN MMCTestResult = FALSE; + BOOLEAN RWTest = TRUE; + BOOLEAN LengthTest = TRUE; + BOOLEAN MBSTest = TRUE; + BOOLEAN PresentTest = TRUE; + MmcState_t WriteStatus; + MmcState_t ReadStatus; + MmcState_t DiscStatus; + + /* Prepare Read and Write Array with writing Zero to every Position */ + for (loopcnt = 0; loopcnt < ArrayLength; loopcnt++) + { + Read[loopcnt] = 0; + Write[loopcnt] = 0; + nullarray[loopcnt] = 0; + + } + + /* Fill WriteArray with Characters */ + for (loopcnt = 0; loopcnt < ArrayLength; loopcnt++) + { + Write[loopcnt] = character; + character += 3; + } + + MMC_StatusOut (DiscStatus = MmcInitMedia()); /* Init Card, give Status */ + + if (DiscStatus == MmcNoPresent) + { + /* disc is not inserted, so Test will be aborted here */ + PresentTest = FALSE; + } + else + { + /* Nested Test + * Array "Write" is written with all available Lengths in LengthArray + * to all available Adresses in AdressArray. + */ + while (AddressIndex < MaxNumberOfAddress) + { + LengthIndex = 0; /* Reset LengthIndex */ + while (LengthIndex < MaxNumberOfLength) + { + WriteStatus = CardWrite ((pUINT8)Write, AddressArray[AddressIndex], + LengthArray[LengthIndex]); /* Write to MMC */ + + ReadStatus = CardRead ((pUINT8)Read, AddressArray[AddressIndex], + LengthArray[LengthIndex]); /* Read from MMC */ + + /* Check Status of Read and Write Events */ + if ((ReadStatus == MmcOk) && (WriteStatus == MmcOk)) + { + for (loopcnt = 0; loopcnt < LengthArray[LengthIndex]; loopcnt++) + { /* Compare both Arrays */ + if (Read[loopcnt] != Write[loopcnt]) + { /* If miscompare occures */ + dioWrite(0, 6, TRUE); + RWTest = FALSE; + } + else /* Everything's OK */ + { + dioWrite(0, 7, TRUE); + } + } + } + + /* Check if Length-Control in MMC-Read/Write works correctly*/ + else if (((LengthArray[LengthIndex] % PageSize) != 0) + || (LengthArray[LengthIndex] == 0)) + { + if ((WriteStatus == MmcMiscompare) + && (ReadStatus == MmcMiscompare)) + { + dioWrite (0,5,TRUE); /* Length Control works */ + } + else + { + dioWrite (0,4,TRUE); /* Length Control works not */ + LengthTest = FALSE; + } + } + /* Check if MasterBootSector Protection works */ + else if ((AddressArray[AddressIndex] < 0x200) + && (LengthArray[LengthIndex] != 0)) + { + if (WriteStatus == MmcCardError) + { + dioWrite (0,3,TRUE); /* MBS Protection works */ + } + else + { + dioWrite (0,2,TRUE); /* MBS Protection works not */ + MBSTest = FALSE; + } + } + + else + { + dioWrite (0,1,TRUE); + dioWrite (0,0,TRUE); + sendString (SerOutPort, TRUE, testMessage, + "\t Length: ", s_tab, ItoDStr (LengthArray[LengthIndex])); + sendString (SerOutPort, TRUE, testMessage, + "\t Address: ", s_tab, ItoDStr (AddressArray[AddressIndex])); + MMC_StatusOut (WriteStatus); + MMC_StatusOut (ReadStatus); + RWTest = FALSE; + } + + LengthIndex++; + } // End LENGTH WHILE-LOOP + AddressIndex++; + } // End ADDRESS WHILE-LOOP + } + + + vTaskDelay (1000); + /* Test Result Message Output */ + sendString (SerOutPort, TRUE, testMessage, + "\t Disc present: ", s_tab, BoolRestoStr (PresentTest)); + sendString (SerOutPort, TRUE, testMessage, + "\t Read and Write Test: ", f_tab, BoolRestoStr(RWTest)); + sendString (SerOutPort, TRUE, testMessage, + "\t Length Status Check: ", f_tab, BoolRestoStr(LengthTest)); + sendString (SerOutPort, TRUE, testMessage, + "\t MBS Defend Check: ", f_tab, BoolRestoStr(MBSTest)); + + /* Calculate complete Test Result out of single Tests */ + if ((RWTest == TRUE) && (LengthTest == TRUE) + && (MBSTest == TRUE) && (PresentTest == TRUE)) + { + MMCTestResult = TRUE; + } + else + { + MMCTestResult = FALSE; + } + + + return (MMCTestResult); +} + +void MMC_StatusOut (MmcState_t Status) +{ + switch (Status) + { + case MmcOk: + sendString (SerOutPort, TRUE, testMessage, + "MMC is OK", Dummy, Dummy); + break; + case MmcNoPresent: + sendString (SerOutPort, TRUE, testMessage, + "MMC is not present", Dummy, Dummy); + break; + case MmcNoResponse: + sendString (SerOutPort, TRUE, testMessage, + "MMC not responding", Dummy, Dummy); + break; + case MmcCardError: + sendString (SerOutPort, TRUE, testMessage, + "MMC Card Error", Dummy, Dummy); + break; + case MmcMiscompare: + sendString (SerOutPort, TRUE, testMessage, + "MMC Miscompare", Dummy, Dummy); + break; + case MmcDmaError: + sendString (SerOutPort, TRUE, testMessage, + "MMC DMA Error", Dummy, Dummy); + break; + case MmcProtect: + sendString (SerOutPort, TRUE, testMessage, + "Card is Protected", Dummy, Dummy); + break; + default: + break; + } +} diff --git a/Tester/SW/Applications/testfiles/testMMC.h b/Tester/SW/Applications/testfiles/testMMC.h new file mode 100644 index 0000000..a88b766 --- /dev/null +++ b/Tester/SW/Applications/testfiles/testMMC.h @@ -0,0 +1,93 @@ +/* --------------------------------------------------------------------------- + * testMMC.h (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Apr 24, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef TESTMMC_H_ +#define TESTMMC_H_ +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ +#include "LPC23xx.h" +#include "types.h" + +#include "mmc.h" +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function: testmmcStart + * + * Main Function of MemoryCard Test Application + * + * Parameters: void + * + * Return: BOOLEAN - Test Result + * --------------------------------------------------------------------------- + */ +BOOLEAN testmmcStart (void); + +/* --------------------------------------------------------------------------- + * Function:DoMMCTest + * + * Contains test Application + * + * Parameters: void + * + * Return: BOOLEAN - Test Result + * --------------------------------------------------------------------------- + */ +BOOLEAN DoMMCTest (void); + + +/* --------------------------------------------------------------------------- + * MMC_StatusOut + * + * Function to Printout MMC Status + * + * Parameters: MmcState_t Status - MMC Status to print out + * + * Return: void + * --------------------------------------------------------------------------- + */ +void MMC_StatusOut (MmcState_t Status); + + + +#endif /*TESTMMC_H_*/ diff --git a/Tester/SW/Applications/testfiles/testaio.c b/Tester/SW/Applications/testfiles/testaio.c new file mode 100644 index 0000000..007337a --- /dev/null +++ b/Tester/SW/Applications/testfiles/testaio.c @@ -0,0 +1,413 @@ +/* --------------------------------------------------------------------------- + * testaio.c (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * Analogue Test File + * + * Note: + * Output 0 is connected to Input 0 and 4 + * Output 1 is connected to Input 1 and 5 + * Output 2 is connected to Input 2 and 6 + * Output 3 is connected to Input 3 and 7 + * + * + * --------------------------------------------------------------------------- + * Version(s): 0.1, Sep 08, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +#include "lpc23xx.h" +#include "types.h" + + +/* FreeRTOS includes */ +#include "FreeRTOS.h" +#include "Task.h" + +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "adc.h" +#include "dac.h" +#include "dio.h" +#include "testaio.h" +#include "calibrateaio.h" + +#include "SerOut.h" +#include "BusProtocol.h" + +#include "remote_misc.h" +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ + +#define NumberOfAIs maxADC_Channels /* See adc.h */ +#define NumberOfAIOs maxDAC_Channels /* See dac.h */ + +#define vTestValue 5000 /* Value for Test Voltage Output in mV */ +#define cTestValue 10000 /* Value for Test Current Output in uA */ +#define vNullValue 0 +#define cNullValue 0 + +#define vLimit 20 /* Test Limit for Voltage Test */ +#define cLimit 100 /* Test Limit for Current Test */ + +#define vNullLimit 50 /* Test Limit for NULL-Voltage Test */ +#define cNullLimit 50 /* Test Limit for NULL-Current Test */ + +#define TestDelay 200 + +#define VoltageOutputCalibrationValue 10000 /* Calibration Value for V */ +#define CurrentOutputCalibrationValue 20000 /* Calibration Value for C */ + +#define VoltageOutputTestValue 7000 /* Remote Test Value for V */ +#define CurrentOutputTestValue 15000 /* Remote Test Value for C */ + +#define ident_calibrated 0x55 /* Calibrated status identifier */ +#define ident_default 0xAA /* Default status identifier */ + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ + +/* Bus informations from protocolfunctions.c */ +extern UINT8 remoteDeviceNumber; +extern UINT8 thisDeviceNumber; +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ + +BOOLEAN testaioStart (void) +{ + BOOLEAN AIOTestResult = FALSE; /* BOOLEAN Variable to return Result*/ + BOOLEAN VoltageTest_MB; + BOOLEAN CurrentTest_MB; + BOOLEAN VoltageTest_EB; + BOOLEAN CurrentTest_EB; + + /* Do analogue line test for Mainboard Connectors */ + VoltageTest_MB = doAIOVoltageTest(); /* Call Test Function */ + CurrentTest_MB = doAIOCurrentTest(); + +// \MARK NEW PINSETTINGS FOR TESTER (2) +#if (PINSET_TESTER == 2) + /* Enable extension-board channels by switching multiplexers */ + adc_MuxEn(TRUE); + dac_MuxEn(TRUE); + + /* Do analogue line test for extension Board Connectors */ + VoltageTest_EB = doAIOVoltageTest(); /* Call Test Function */ + CurrentTest_EB = doAIOCurrentTest(); + + /* Switch off multiplexers again to main-board connectors */ + adc_MuxEn(FALSE); + dac_MuxEn(FALSE); +#endif + + if ((VoltageTest_MB == TRUE) && (CurrentTest_MB == TRUE) +// \MARK NEW PINSETTINGS FOR TESTER (2) +#if (PINSET_TESTER == 2) + && (VoltageTest_EB == TRUE) && (CurrentTest_EB == TRUE) +#endif + ) + { + AIOTestResult = TRUE; + } + else + { + AIOTestResult = FALSE; + } + + return (AIOTestResult); /* Return Test Result */ +} + +BOOLEAN doAIOVoltageTest (void) +{ + UINT32 aiocnt; + BOOLEAN AIOLineTestResult = FALSE; + BOOLEAN LowTest = TRUE; + BOOLEAN AllOtherTest = TRUE; + BOOLEAN HighTest = TRUE; + UINT32 LowBuffer; + BOOLEAN AllOtherBuffer; + UINT32 HighBuffer; + + SetAnalogueInput(FALSE); /* Set Analogue Input to Voltage */ + dacMode (0, dacVOLTAGE); /* Set Output Types to Voltage */ + dacMode (1, dacVOLTAGE); + dacMode (2, dacVOLTAGE); + dacMode (3, dacVOLTAGE); + + dacWrite (thisDeviceNumber, 0, vNullValue); /* Write 0 Volts to Output */ + dacWrite (thisDeviceNumber, 1, vNullValue); + dacWrite (thisDeviceNumber, 2, vNullValue); + dacWrite (thisDeviceNumber, 3, vNullValue); + vTaskDelay (TestDelay); + + sendString (SerOutPort, FALSE, testMessage, NewLine, + "\tVoltage Test Value: ", ItoDStr (vTestValue)); + sendString (SerOutPort, FALSE, testMessage, + "\t\tTolerance: ", ItoDStr (vLimit), Dummy); + + for (aiocnt = 0; aiocnt < NumberOfAIs; aiocnt++) /*Test Line by Line */ + { + /* Test if Input Voltage is below NullLimit */ + if ((LowBuffer = adcRead (thisDeviceNumber, aiocnt)) > vNullLimit) + { + LowTest = FALSE; /* Failed, then set Test failed */ + } + + /* Write chosen Output to Test Value */ + if (aiocnt < NumberOfAIOs) + { + dacWrite (thisDeviceNumber, aiocnt, vTestValue); + } + else /* if selected Input is > possible */ + { /* Outputs, restart at Output 0 */ + dacWrite (thisDeviceNumber, (aiocnt - NumberOfAIOs), vTestValue); + } + vTaskDelay (TestDelay); /* Wait for Output to be set */ + + /* Check if all other Inputs are Zero */ + if ((AllOtherBuffer = CheckAllOtherAIOZero(aiocnt, TRUE)) == FALSE) + { + AllOtherTest = FALSE; + } + + /* Read Test Level on Input */ + HighBuffer = adcRead (thisDeviceNumber, aiocnt); + if ((HighBuffer < (vTestValue - vLimit)) + || (HighBuffer > (vTestValue + vLimit))) // \TODO is this working??? + { /* Is read Value in the Limits? */ + HighTest = FALSE; + } + + /* Write chosen Output back to Null */ + if (aiocnt < NumberOfAIOs) + { + dacWrite (thisDeviceNumber, aiocnt, vNullValue); + } + else /* if selected Input is > possible */ + { /* Outputs, restart at Output 0 */ + dacWrite (thisDeviceNumber, (aiocnt - NumberOfAIOs), vNullValue); + } + + /* Message out Test Results */ + sendString (SerOutPort, TRUE, testMessage, + "\tVoltage Test for Analogue Input ", ItoDStr(aiocnt), ": "); + sendString (SerOutPort, FALSE, testMessage, + " ", Dummy, ItoDStr (LowBuffer)); + sendString (SerOutPort, FALSE, testMessage, + " ", Dummy, ItoDStr (HighBuffer)); + sendString (SerOutPort, FALSE, testMessage, + " All Other: ", Dummy, BoolRestoStr (AllOtherBuffer)); + + vTaskDelay (TestDelay); + } + + /* Set complete LineTestResult */ + if ((LowTest == TRUE) && (HighTest == TRUE) && (AllOtherTest == TRUE)) + { + AIOLineTestResult = TRUE; + } + + return (AIOLineTestResult); +} + + +BOOLEAN doAIOCurrentTest (void) +{ + UINT32 aiocnt; + UINT32 LowBuffer; + UINT32 HighBuffer; + BOOLEAN AIOCurrentTest = TRUE; + BOOLEAN LowTest; + BOOLEAN HighTest; + + + + dacMode (0, dacCURRENT); /* Set Output Types to Current */ + dacMode (1, dacCURRENT); + dacMode (2, dacCURRENT); + dacMode (3, dacCURRENT); + + dacWrite (thisDeviceNumber, 0, cNullValue); /* Write 0 uA to Output */ + dacWrite (thisDeviceNumber, 1, cNullValue); + dacWrite (thisDeviceNumber, 2, cNullValue); + dacWrite (thisDeviceNumber, 3, cNullValue); + vTaskDelay (TestDelay); + + sendString (SerOutPort, TRUE, testMessage, NewLine, + "\tCurrent Test Value: ", ItoDStr (cTestValue)); + sendString (SerOutPort, FALSE, testMessage, + "\t\tTolerance: ", ItoDStr (cLimit), Dummy); + + for (aiocnt = 0; aiocnt < NumberOfAIs; aiocnt++) + { + adcMode( aiocnt, adcCURRENT ); /* Inputs set to Current */ + vTaskDelay (200); + + /* Read back the low Value on Input */ + LowBuffer = adcRead (thisDeviceNumber, aiocnt); + if (LowBuffer < cNullLimit) + { + /* If read Value is within the Limit, test passed */ + LowTest = TRUE; + } + else + { + /* If read Value is out of Limit, test failed */ + LowTest = FALSE; + } + + /* Write Output to defined Test Value */ + if (aiocnt < NumberOfAIOs) + { + dacWrite(thisDeviceNumber, aiocnt, cTestValue); + } + else + { + dacWrite(thisDeviceNumber, (aiocnt - NumberOfAIOs), cTestValue); + } + vTaskDelay (500); + + HighBuffer = adcRead(thisDeviceNumber, aiocnt); + if ((HighBuffer < (cTestValue - cLimit)) + || (HighBuffer > (cTestValue + cLimit))) + { + /* If read Value is within the Limit, test passed */ + HighTest = FALSE; + } + else + { + /* If read Value is out of Limit, test failed */ + HighTest = TRUE; + } + + /* Drive Output back to Zero Value */ + if (aiocnt < NumberOfAIOs) + { + dacWrite(thisDeviceNumber, aiocnt, cNullValue); + } + else + { + dacWrite(thisDeviceNumber, (aiocnt - NumberOfAIOs), cNullValue); + } + /* Set Input Mode to Voltage to prevent of leek Current */ + adcMode (aiocnt, adcVOLTAGE); + + /* Message out Test Results */ + sendString (SerOutPort, TRUE, testMessage, + "\tCurrent Test for Analogue Input ", ItoDStr(aiocnt), ": "); + sendString (SerOutPort, FALSE, testMessage, + " ", Dummy, ItoDStr (LowBuffer)); + sendString (SerOutPort, FALSE, testMessage, + " ", Dummy, ItoDStr (HighBuffer)); + + /* Set complete LineTestResult */ + if ((LowTest != TRUE) || (HighTest != TRUE)) + { + AIOCurrentTest = FALSE; + } + } + + return (AIOCurrentTest); +} + + +BOOLEAN CheckAllOtherAIOZero (UINT32 AIONumber, BOOLEAN local) +{ + + UINT32 loopcnt; + BOOLEAN AllZeroResult = TRUE; + + for (loopcnt = 0; loopcnt < NumberOfAIs; loopcnt++) /* Test Line by Line*/ + { + if ((loopcnt == AIONumber) || /* except currently tested Input */ + (loopcnt == (AIONumber + NumberOfAIOs)) || + (loopcnt == (AIONumber - NumberOfAIOs))) + { + if (loopcnt < (NumberOfAIOs - 1)) + { + loopcnt++; /* Skip currently tested Output */ + } + else + { + break; /* If tested Output is the last one,*/ + } /* simply break out of loop */ + } + if (local == TRUE) + { + if (adcRead (thisDeviceNumber, loopcnt) > vNullLimit) + { /* If Input Value exceeds Limit */ + AllZeroResult = FALSE; + } + } + else + { + if (adcRead (remoteDeviceNumber, loopcnt) > vNullLimit) + { /* If Input Value exceeds Limit */ + sendString (SerOutPort, TRUE, testMessage, + "line: ", ItoDStr (loopcnt), Dummy); + sendString (SerOutPort, TRUE, testMessage, + "Value: ", + ItoDStr (adcRead (remoteDeviceNumber, loopcnt)), Dummy); + + AllZeroResult = FALSE; + } + vTaskDelay (100); + } + } + return (AllZeroResult); +} + + +void SetAnalogueInput(BOOLEAN isCurrent) +{ + if (isCurrent == TRUE) + { + adcMode( 0, adcCURRENT ); /* Inputs set to Current */ + adcMode( 1, adcCURRENT ); + adcMode( 2, adcCURRENT ); + adcMode( 3, adcCURRENT ); + adcMode( 4, adcCURRENT ); + adcMode( 5, adcCURRENT ); + adcMode( 6, adcCURRENT ); + adcMode( 7, adcCURRENT ); + } + else + { + adcMode( 0, adcVOLTAGE ); /* Inputs set to Voltage */ + adcMode( 1, adcVOLTAGE ); + adcMode( 2, adcVOLTAGE ); + adcMode( 3, adcVOLTAGE ); + adcMode( 4, adcVOLTAGE ); + adcMode( 5, adcVOLTAGE ); + adcMode( 6, adcVOLTAGE ); + adcMode( 7, adcVOLTAGE ); + } +} + diff --git a/Tester/SW/Applications/testfiles/testaio.h b/Tester/SW/Applications/testfiles/testaio.h new file mode 100644 index 0000000..65fafa9 --- /dev/null +++ b/Tester/SW/Applications/testfiles/testaio.h @@ -0,0 +1,150 @@ +/* --------------------------------------------------------------------------- + * testaio.h (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * Headerfile for analogue Testfile testaio.c + * --------------------------------------------------------------------------- + * Version(s): 0.1, Sep 08, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef TESTAIO_H_ +#define TESTAIO_H_ + +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ +#include "lpc23xx.h" +#include "types.h" + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function: testioStart + * + * Main Function of Analogue Tests. + * + * Parameters: void + * + * Return : BOOLEAN - Test Result + * --------------------------------------------------------------------------- + */ +BOOLEAN testaioStart (void); /* Test analog Input/Output */ + +/* --------------------------------------------------------------------------- + * Function: doAIOVoltageTest / doAIOCurrentTest + * + * Function to test every single analogue Output and Input (either V or C) + * + * Parameters: void + * + * Return : BOOLEAN - Test Result + * --------------------------------------------------------------------------- + */ +BOOLEAN doAIOVoltageTest (void); + +BOOLEAN doAIOCurrentTest (void); + + +/* --------------------------------------------------------------------------- + * Function: CheckAllOtherAIOZero + * + * Function to check if all other analogue Inputs but the chosen one is + * Zero or below a certain test Limit. + * + * Parameters: UINT32 AIONumber - currently tested Input + * BOOLEAN local - check either local or remote lines + * + * Return : BOOLEAN - Test Result + * --------------------------------------------------------------------------- + */ +BOOLEAN CheckAllOtherAIOZero (UINT32 AIONumber, BOOLEAN local); + + +/* --------------------------------------------------------------------------- + * Function: Set AnalogueInput + * + * Function to set Inputs either to Voltage or Current Mode + * + * Parameters: BOOLEAN isCurrent - Indicates if Voltage or Current Mode + * + * Return : void + * --------------------------------------------------------------------------- + */ +void SetAnalogueInput(BOOLEAN isCurrent); + + +/* --------------------------------------------------------------------------- + * Function: testSlaveAnalogueLines + * + * Main function to remote AIO Test + * + * Parameters: void + * + * Return : BOOLEAN - TestResult + * --------------------------------------------------------------------------- + */ +BOOLEAN testSlaveAnalogueLines (void); + + +/* --------------------------------------------------------------------------- + * Function: remoteaioOutput + * + * Function to test remote analogue Outputs + * + * Parameters: BOOLEAN testmodeVOLTAGE - test in voltage (TRUE) or current + * (FALSE) mode + * + * Return : BOOLEAN - Test Result + * --------------------------------------------------------------------------- + */ +BOOLEAN remoteaioOutput (BOOLEAN testmodeVOLTAGE); + + +/* --------------------------------------------------------------------------- + * Function: remoteaioInput + * + * Function to test remote analogue Inputs + * + * Parameters: BOOLEAN testmodeVOLTAGE - test in voltage (TRUE) or current + * (FALSE) mode + * + * Return : BOOLEAN - Test Result + * --------------------------------------------------------------------------- + */ +BOOLEAN remoteaioInput (BOOLEAN testmodeVOLTAGE); + +#endif /*TESTAIO_H_*/ diff --git a/Tester/SW/Applications/testfiles/testcan.c b/Tester/SW/Applications/testfiles/testcan.c new file mode 100644 index 0000000..3699e0d --- /dev/null +++ b/Tester/SW/Applications/testfiles/testcan.c @@ -0,0 +1,121 @@ +/* --------------------------------------------------------------------------- + * testcan.c (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Nov 17, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +#include "lpc23xx.h" +#include "types.h" + +#include "FreeRTOS.h" +#include "task.h" +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "testcan.h" +#include "can.h" +#include "SerOut.h" +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ +#define CAN_FILTER1 0x00000101 +#define CAN_MSGLNG 0x00050000 +#define CAN_DATAA 0x01234567 +#define CAN_DATAB 0xFEDCBA98 + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ + +BOOLEAN testCanStart (void) +{ + BOOLEAN canResult; + + canResult = canSelftest (); + + return (canResult); +} + +BOOLEAN canSelftest (void) +{ + CAN_MSG SendMessage; + CAN_MSG ReceiveMessage; + + /* Set CAN2 in SelfTest Mode - CAN2 must be in RESET mode for that */ + CAN2MOD |= (1 << 0); /* Set Mode to Reset (Bit 0) */ + CAN2MOD |= (1 << 2); /* Set bit "selftest" */ + CAN2MOD &=~(1 << 0); /* Set Mode to normal */ + + vTaskDelay (500); + +// SendMessage.Dat1 = 0x00080102L; // 8 bytes, ID 0x102 +// SendMessage.DatA = 0x00000000L; // all zeros +// SendMessage.DatB = 0x00000000L; // all zeros + + SendMessage.Dat1 = (CAN_FILTER1 | CAN_MSGLNG); /* Set Length and Filter */ + SendMessage.DatA = CAN_DATAA; /* Define first 4 Bytes */ + SendMessage.DatB = CAN_DATAB; /* Define last 4 bytes */ + + CANPushMessage (&SendMessage); + + vTaskDelay (1000); + + CANPullMessage (&ReceiveMessage); + + if (SendMessage.Dat1 == ReceiveMessage.Dat1) + { + debugPrint("Dat1 is OK\n\r"); + if (SendMessage.DatA == ReceiveMessage.DatA) + { + debugPrint("DataA is OK\n\r"); + if (SendMessage.DatB == ReceiveMessage.DatB) + { + debugPrint("DataB is OK\n\r"); + } + else + { + debugPrint("DataB is not OK\n\r"); + } + } + else + { + debugPrint("DataA is not OK\n\r"); + } + } + else + { + debugPrint("Dat1 is not OK\n\r;"); + } + + return (TRUE); +} diff --git a/Tester/SW/Applications/testfiles/testcan.h b/Tester/SW/Applications/testfiles/testcan.h new file mode 100644 index 0000000..39fc773 --- /dev/null +++ b/Tester/SW/Applications/testfiles/testcan.h @@ -0,0 +1,56 @@ +/* --------------------------------------------------------------------------- + * testcan.h (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Nov 17, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef TESTCAN_H_ +#define TESTCAN_H_ +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ + +BOOLEAN testCanStart (void); + +BOOLEAN canSelftest (void); + + +#endif /*TESTCAN_H_*/ diff --git a/Tester/SW/Applications/testfiles/testdio.c b/Tester/SW/Applications/testfiles/testdio.c new file mode 100644 index 0000000..1ab86bb --- /dev/null +++ b/Tester/SW/Applications/testfiles/testdio.c @@ -0,0 +1,228 @@ +/* --------------------------------------------------------------------------- + * testdio.c (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * Contains the digital Input/Output test Function + * + * + * --------------------------------------------------------------------------- + * Version(s): 0.1, Mar 06, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +#include "LPC23xx.h" +#include "types.h" + +/* FreeRTOS includes */ +#include "FreeRTOS.h" +#include "task.h" + +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "dio.h" +#include "testdio.h" +#include "SerOut.h" +#include "ledfunctions.h" +#include "BusProtocol.h" +#include "protocolfunctions.h" +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ +// \MARK NEW PINSETTINGS FOR TESTER (2) +#if (PINSET_TESTER == 2) +#define NumberOfDIOs 8 +#else +#define NumberOfDIOs 11 /* Number of digital Inputs */ +#endif +#define NumberOfDOs 8 /* Number of digital Outputs */ +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ + + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ + +BOOLEAN testdioStart (void) +{ + BOOLEAN DIOTestResult; + BOOLEAN DIOTestResult_MB = FALSE; + BOOLEAN DIOTestResult_EB = FALSE; + + DIOTestResult_MB = doDIOLineTest(); + +// \MARK NEW PINSETTINGS FOR TESTER (2) +#if (PINSET_TESTER == 2) + dio_inMuxEn(); + + /* Do digital line test for extension Board Connectors */ + DIOTestResult_EB = doDIOLineTest(); + + dio_outMuxEn(); +#endif + + if ((DIOTestResult_MB == TRUE) +// \MARK NEW PINSETTINGS FOR TESTER (2) +#if (PINSET_TESTER == 2) + && (DIOTestResult_EB == TRUE) +#endif + ) + { + DIOTestResult = TRUE; + } + else + { + DIOTestResult = FALSE; + } + + return (DIOTestResult); + +} + + +BOOLEAN doDIOLineTest (void) +{ + UINT32 diocnt = 0; + BOOLEAN LineTestResult = FALSE; + BOOLEAN LowTest = TRUE; + BOOLEAN AllOther = TRUE; + BOOLEAN HighTest = TRUE; + BOOLEAN LowBuffer; + BOOLEAN AllOtherBuffer; + BOOLEAN HighBuffer; + + dioClean(); + vTaskDelay (100); + + + for (diocnt = 0; diocnt < NumberOfDIOs; diocnt++) + { + /* Read LOW Value on selected Digital Input and set Read Result */ + if ((LowBuffer = !dioRead (thisDeviceNumber, diocnt)) == FALSE) + { /* LowBuffer contains Read Result */ + LowTest = FALSE; + } + + /* Drive selected Digital Output to HIGH. */ + if (diocnt >= NumberOfDOs) + { + dioWrite (thisDeviceNumber, (diocnt - NumberOfDOs), TRUE); + } + else /* if selected Input is > possible */ + { /* Outputs, restart at Output 0 */ + dioWrite (thisDeviceNumber, diocnt, TRUE); + } + vTaskDelay (50); /* small Delay */ + + /* Check if all Lines but the selected one are LOW */ + if ((AllOtherBuffer = CheckAllOtherDIOZero(diocnt, TRUE)) == FALSE) + { + AllOther = FALSE; + } + + /* Read HIGH Value on selected Digital Input and set Read Result */ + if ((HighBuffer = dioRead (thisDeviceNumber, diocnt)) == FALSE) + { + HighTest = FALSE; + } + + /* Set selected digital Input back to LOW */ + if (diocnt >= NumberOfDOs) + { + dioWrite (thisDeviceNumber, (diocnt - NumberOfDOs), FALSE); + } + else /* if selected Input is > possible */ + { /* Outputs, restart at Output 0 */ + dioWrite (thisDeviceNumber, diocnt, FALSE); + } + + /* Message out Test Results */ + sendString (SerOutPort, TRUE, testMessage, + "\tLinetest for Digital Input ", ItoDStr(diocnt), ": "); + sendString (SerOutPort, FALSE, testMessage, + " ", Dummy, BoolRestoStr (LowBuffer)); + sendString (SerOutPort, FALSE, testMessage, + " ", Dummy, BoolRestoStr (AllOtherBuffer)); + sendString (SerOutPort, FALSE, testMessage, + " ", Dummy, BoolRestoStr (HighBuffer)); + vTaskDelay (50); + } + + /* Set complete LineTestResult */ + if ((LowTest == TRUE) && (HighTest == TRUE) && (AllOther == TRUE)) + { + LineTestResult = TRUE; + } + else + { + LineTestResult = FALSE; + } + + return (LineTestResult); +} + + +BOOLEAN CheckAllOtherDIOZero (UINT32 DIONumber, BOOLEAN local) +{ + UINT32 loopcnt = 0; + BOOLEAN allZeroResult = TRUE; + + for (loopcnt = 0; loopcnt < NumberOfDIOs; loopcnt++) /*Test Line by Line*/ + { + if ((loopcnt == DIONumber) || /* except currently tested Input */ + (loopcnt == (DIONumber + NumberOfDOs)) || + (loopcnt == (DIONumber - NumberOfDOs))) + { + if (loopcnt < (NumberOfDIOs - 1)) + { + loopcnt++; /* Skip currently tested Input */ + } + else + { + break; /* If currently tested Input is the */ + } /* last one, simply break out */ + } + + if (local == TRUE) + { + if (dioRead (thisDeviceNumber, loopcnt) == TRUE) + { + allZeroResult = FALSE; + } + } + else + { + if (dioRead (remoteDeviceNumber, loopcnt) == TRUE) + { + allZeroResult = FALSE; + } + vTaskDelay (100); + } + } + return (allZeroResult); +} diff --git a/Tester/SW/Applications/testfiles/testdio.h b/Tester/SW/Applications/testfiles/testdio.h new file mode 100644 index 0000000..eca32d5 --- /dev/null +++ b/Tester/SW/Applications/testfiles/testdio.h @@ -0,0 +1,135 @@ +/* --------------------------------------------------------------------------- + * testdio.h (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * Headerfile for digital Input/Output Test testdio.c + * --------------------------------------------------------------------------- + * Version(s): 0.1, Mar 06, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ + +#ifndef TESTDIO_H_ +#define TESTDIO_H_ + +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ +#include "lpc23xx.h" +#include "types.h" + + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function: testdioStart + * + * Main Function for Digital Tests + * + * Parameters: void + * + * Return: BOOLEAN - Test Result + * --------------------------------------------------------------------------- + */ +BOOLEAN testdioStart(void); + +/* --------------------------------------------------------------------------- + * Function: doDIOLineTest + * + * Function to test LOW and HIGH Level on every single digital Input + * + * Parameters: void + * + * Return: BOOLEAN - Test Result + * --------------------------------------------------------------------------- + */ +BOOLEAN doDIOLineTest (void); + +/* --------------------------------------------------------------------------- + * Function: CheckAllOtherDIOZero + * + * Function to test if all other Inputs but the chosen one is LOW + * + * Parameters: UINT32 DIONumber - currently tested Input + * BOOLEAN local - Check local or remote lines + * + * Return: BOOLEAN - Test Result + * --------------------------------------------------------------------------- + */ +BOOLEAN CheckAllOtherDIOZero (UINT32 DIONumber, BOOLEAN local); + + +/* --------------------------------------------------------------------------- + * Function: testremotedioStart + * + * Main function to remote Digital IO Test + * + * Parameters: void + * + * Return: BOOLEAN - Test Result + * --------------------------------------------------------------------------- + */ +BOOLEAN testremotedioStart (void); + + +/* --------------------------------------------------------------------------- + * Function: remotedioOutput + * + * Remote digital Output test + * + * Parameters: void + * + * Return: BOOLEAN - Test Result + * --------------------------------------------------------------------------- + */ +BOOLEAN remotedioOutput (void); + + +/* --------------------------------------------------------------------------- + * Function: remotedioInput + * + * Remote digital Input test + * + * Parameters: void + * + * Return: BOOLEAN - Test Result + * --------------------------------------------------------------------------- + */ +BOOLEAN remotedioInput (void); + + + +#endif /*TESTDIO_H_*/ diff --git a/Tester/SW/Applications/testfiles/testeeprom.c b/Tester/SW/Applications/testfiles/testeeprom.c new file mode 100644 index 0000000..a54b821 --- /dev/null +++ b/Tester/SW/Applications/testfiles/testeeprom.c @@ -0,0 +1,172 @@ +/* --------------------------------------------------------------------------- + * testeeprom.c (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Mar 11, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +#include "lpc23xx.h" +#include "types.h" + + +/* FreeRTOS includes */ +#include "FreeRTOS.h" +#include "Task.h" +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "testeeprom.h" +#include "eeprom.h" +#include "SerOut.h" +#include "dio.h" +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ +/* Use same Arrays as Flash Test to minimize Memory usage */ +// \MARK ARRAYS NOT NECESSARY ON OLIMEXBOARD +#if ((PINSET_TESTER == 1) || (PINSET_TESTER == 2)) +UINT8 eepromResponseString[3000]; +UINT8 eepromTestString[3000]; +#endif + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ +UINT16 adres_var[2]; + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ + + +BOOLEAN testeepromStart(void) +{ + BOOLEAN eepromTestResult; + + eepromTestResult = doeepromTest(); + + return (eepromTestResult); +} + +BOOLEAN doeepromTest (void) +{ + BOOLEAN testFailed= FALSE; + +// \MARK TEST NOT NECESSARY ON OLIMEXBOARD +#if ((PINSET_TESTER == 1) || (PINSET_TESTER == 2)) + /*Local Variable Declaration */ + UINT8 testByte; + UINT8 testString[] = "Dit is een oefening"; + UINT16 index; + UINT8 oneByte = 0; + + sendString (COM2, TRUE, testMessage, + "\tWrite Byte 0x34 to Adress 256", Dummy, Dummy); + eepromWrite (256, 0x34); /* Write one Byte to EEPROM */ + eepromRead (256, &testByte); /* Read written Byte from EEPROM */ + testFailed = (testByte != 0x34); /* compare read and written Bytes */ + if (testFailed == FALSE) + { + sendString (COM2, FALSE, testMessage, + "\t DONE", Dummy, Dummy); + dioWrite (0, 1, TRUE); + } + else + { + sendString (COM2, FALSE, testMessage, + "\t FAILURE", Dummy, Dummy); + dioWrite (0, 0, TRUE); + } + + if (!testFailed) /* If no Test fail up to here */ + { + sendString (COM2, TRUE, testMessage, + "\tWrite 10 Bytes to Adress 511", Dummy, Dummy); + eepromWriteBuffer( 511, testString, 10); + /* Write Teststring to EEPROM with */ + /* width of 10 Bytes */ + eepromReadBuffer( 511, eepromResponseString, 10); + /* Read written String from EEPROM */ + + for (index = 0; index < 10; index++) + { /* Compare both Strings */ + if (eepromResponseString[index] != testString[index]) + { /* If Strings are not equal */ + testFailed = TRUE; /* Set Test Result to FALSE */ + } + } + if (testFailed == FALSE) + { + sendString (COM2, FALSE, testMessage, + "\t DONE", Dummy, Dummy); + dioWrite (0, 3, TRUE); + } + else + { + sendString (COM2, FALSE, testMessage, + "\t FAILURE", Dummy, Dummy); + dioWrite (0, 2, TRUE); + } + } + + if (!testFailed) /* If no Test fail up to here */ + { + sendString (COM2, TRUE, testMessage, + "\tWrite 3000 Byte to Adress 500", Dummy, Dummy); + int loopcnt; + for (loopcnt=0; loopcnt < 3000; loopcnt++) + { /* Fill flashTestString */ + eepromTestString[loopcnt] = oneByte++; + } + eepromWriteBuffer( 500, eepromTestString, 3000); + /* Write flashTestString to EEPROM */ + /* with width of 3000 Bytes */ + eepromReadBuffer( 500, eepromResponseString, 3000); + /* Read written String from EEPROM */ + + for (index = 0; index < 3000; index++) + { /* Compare both Strings */ + if (eepromResponseString[index] != eepromTestString[index]) + { /* If Strings are not equal */ + testFailed = TRUE; /* Set Test Result to FALSE */ + } + } + if (testFailed == FALSE) + { + sendString (COM2, FALSE, testMessage, "\t DONE", Dummy, Dummy); + dioWrite (0, 5, TRUE); + } + else + { + sendString (COM2, FALSE, testMessage, "\t FAILURE", Dummy, Dummy); + dioWrite (0, 4, TRUE); + } + } +#endif + return (!testFailed); /* Return Test Result */ +} diff --git a/Tester/SW/Applications/testfiles/testeeprom.h b/Tester/SW/Applications/testfiles/testeeprom.h new file mode 100644 index 0000000..58c1bc4 --- /dev/null +++ b/Tester/SW/Applications/testfiles/testeeprom.h @@ -0,0 +1,84 @@ +/* --------------------------------------------------------------------------- + * testeeprom.h (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * Headerfile for the EEPROMtest File testeeprom.c + * --------------------------------------------------------------------------- + * Version(s): 0.1, Mar 11, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef TESTEEPROM_H_ +#define TESTEEPROM_H_ + + +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ +#include "lpc23xx.h" +#include "types.h" + + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ + + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ + + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function: testeepromStart + * + * Main Function for EEPROM Tests + * + * Parameter: void + * + * Return: BOOLEAN - Test result + * --------------------------------------------------------------------------- + */ +BOOLEAN testeepromStart(void); + +/* --------------------------------------------------------------------------- + * Function: doeepromTest + * + * Function containing EEPROM Test routines + * + * Parameter: void + * + * Return: BOOLEAN - Test result + * --------------------------------------------------------------------------- + */ +BOOLEAN doeepromTest (void); + + +#endif /*TESTEEPROM_H_*/ diff --git a/Tester/SW/Applications/testfiles/testpower.c b/Tester/SW/Applications/testfiles/testpower.c new file mode 100644 index 0000000..0dfafd4 --- /dev/null +++ b/Tester/SW/Applications/testfiles/testpower.c @@ -0,0 +1,120 @@ +/* --------------------------------------------------------------------------- + * testpower.c (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Mar 25, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +#include "lpc23xx.h" +#include "types.h" + +#include "FreeRTOS.h" +#include "task.h" +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "testpower.h" +#include "power.h" +#include "SerOut.h" + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ +#define lowerlimit5V 4800 /* Lower VCC Limit */ +#define higherlimit5V 5200 /* Higher VCC Limit */ + +#define lowerlimit24V 23000 /* Lower 24V Limit */ +#define higherlimit24V 25000 /* Higher 24V Limit */ + + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ +static UINT8 PWRTest; /* Debugable Variable, to show Bus Test Result */ +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ + +BOOLEAN testpowerStart(void) +{ + BOOLEAN PowerTestResult; /* BOOLEAN Variable for Test Result */ + + PowerTestResult = DoVoltageTest(); /* Do Power Test */ + return PowerTestResult; /* Return Test Result */ +} +BOOLEAN DoVoltageTest (void) +{ + /* Local Variable Declaration */ + BOOLEAN VTestResult = TRUE; + static UINT16 vMeasure5V; /* Debugable */ + static UINT16 vMeasure24V; + + PWRTest = 0x11; + + /* Test for 5 V VCC Power Supply */ + vMeasure5V = powerVccVoltage(); /* Read current VCC Voltage */ + /* Message out Measure Value and Test Limits */ + sendString (SerOutPort, TRUE, testMessage, "\t5V Powertest", NewLine, + "\tLimits (lower/higher): "); + sendString (SerOutPort, FALSE, testMessage, + ItoDStr (lowerlimit5V), devider, Dummy); + sendString (SerOutPort, FALSE, testMessage, + Dummy, Dummy, ItoDStr (higherlimit5V)); + sendString (SerOutPort, TRUE, testMessage, + "\tDetected ", ItoDStr(vMeasure5V), " mV"); + + if ((vMeasure5V < lowerlimit5V) || (vMeasure5V > higherlimit5V)) + { /* If measured Value out of Limits */ + VTestResult = FALSE; /* Set Test Result to FALSE */ + PWRTest &= ~(0x01); + } + + vTaskDelay (500); /* Wait for 500 ms */ + + /* Test for 24 V Power Supply */ + vMeasure24V = powerV24Voltage(); /* Read current power supply Voltage*/ + /* Message out Measure Value and Test Limits */ + sendString (SerOutPort, TRUE, testMessage, "\n\r\t24V Powertest", NewLine, + "\tLimits (lower/higher): "); + sendString (SerOutPort, FALSE, testMessage, + ItoDStr (lowerlimit24V), devider, Dummy); + sendString (SerOutPort, FALSE, testMessage, + Dummy, Dummy, ItoDStr (higherlimit24V)); + sendString (SerOutPort, TRUE, testMessage, + "\tDetected ", ItoDStr(vMeasure24V), " mV"); + + if ((vMeasure24V < lowerlimit24V) || (vMeasure24V > higherlimit24V)) + { /* If measured Value out of Limits */ + VTestResult = FALSE; /* Set Test Result to FALSE */ + PWRTest &= ~(0x10); + } + + return VTestResult; /* Return Test Result */ +} + + diff --git a/Tester/SW/Applications/testfiles/testpower.h b/Tester/SW/Applications/testfiles/testpower.h new file mode 100644 index 0000000..7e81387 --- /dev/null +++ b/Tester/SW/Applications/testfiles/testpower.h @@ -0,0 +1,79 @@ +/* --------------------------------------------------------------------------- + * testpower.h (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * Headerfile for powertest File testpower.c + * --------------------------------------------------------------------------- + * Version(s): 0.1, Mar 25, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef TESTPOWER_H_ +#define TESTPOWER_H_ +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ +#include "lpc23xx.h" +#include "types.h" + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function: testpowerStart + * + * Main Function for Power Tests + * + * Parameter: void + * + * Return: BOOLEAN - Test Result + * --------------------------------------------------------------------------- + */ +BOOLEAN testpowerStart(void); + +/* --------------------------------------------------------------------------- + * Function: DoVoltageTest + * + * Function to test VCC and 24V Power Supply + * + * Parameter: void + * + * Return: BOOLEAN - Test Result + * --------------------------------------------------------------------------- + */ +BOOLEAN DoVoltageTest (void); + + +#endif /*TESTPOWER_H_*/ diff --git a/Tester/SW/Applications/testfiles/testrly.c b/Tester/SW/Applications/testfiles/testrly.c new file mode 100644 index 0000000..b95c7db --- /dev/null +++ b/Tester/SW/Applications/testfiles/testrly.c @@ -0,0 +1,48 @@ +/* --------------------------------------------------------------------------- + * testrly.c (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Nov 17, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ diff --git a/Tester/SW/Applications/testfiles/testrly.h b/Tester/SW/Applications/testfiles/testrly.h new file mode 100644 index 0000000..a713685 --- /dev/null +++ b/Tester/SW/Applications/testfiles/testrly.h @@ -0,0 +1,52 @@ +/* --------------------------------------------------------------------------- + * testrly.h (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Nov 17, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef TESTRLY_H_ +#define TESTRLY_H_ + +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ + +#endif /*TESTRLY_H_*/ diff --git a/Tester/SW/Applications/testfiles/testrtc.c b/Tester/SW/Applications/testfiles/testrtc.c new file mode 100644 index 0000000..8d306ff --- /dev/null +++ b/Tester/SW/Applications/testfiles/testrtc.c @@ -0,0 +1,182 @@ +/* --------------------------------------------------------------------------- + * testrtc.c (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Feb 26, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +#include "lpc23xx.h" +#include "types.h" + +/* FreeRTOS includes */ +#include "FreeRTOS.h" +#include "task.h" +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "testrtc.h" +#include "rtc.h" +#include "SerOut.h" +#include "ledfunctions.h" +#include "dio.h" +#include "testdio.h" +#include "taskfunctions.h" +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ +/* Clock defines to set Clock to a known Value */ +#define dsec 5 +#define dmin 10 +#define dhour 15 +#define dday 20 +#define ddow 2 +#define dmon 3 +#define dyear 3250 +#define ddoy 350 +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ + +t_rtc rtcWriteValue = /* Variable of RTC-used Type to set */ +{ dsec, /* RTC to a known Value */ + dmin, + dhour, + dday, + ddow, + dmon, + dday, + dyear, + ddoy}; + +t_rtc rtcReadValue; /* Variable of RTC-used Type to */ + /* read RTC Values */ +t_rtc *rtcPtr; /* Pointer of RTC-Used Type */ +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ +BOOLEAN testrtcStart(void) +{ + BOOLEAN testrtcResult = TRUE; /* BOOLEAN Variable for Test Result */ + + DoRTCWrite(); /* Write known Value to RTC */ + dioWrite (0, 1, TRUE); + dioWrite (0, 3, TRUE); + testrtcResult = DoRTCRead(); /* Read RTC Values */ + + return (testrtcResult); /* Return Test Result */ +} + + +void DoRTCWrite (void) +{ + rtcPtr = &rtcWriteValue; /* Set Pointer */ + sendString (SerOutPort, TRUE, testMessage, + "\tWrite Custom CLOCK Data to RTC Register", + Dummy, NewLine); /* Message Output */ + rtcWrite (rtcPtr); /* Write Values to RTC */ +} + + +BOOLEAN DoRTCRead (void) +{ + BOOLEAN rtcReadResult; + rtcPtr = &rtcReadValue; /* Set Pointer */ + + sendString (SerOutPort, TRUE, testMessage, + "\tAttempt to read RTC Values: ", + Dummy, Dummy); /* Message Output */ + + rtcRead (rtcPtr); /* Read RTC Values */ + + /* Message out all read Values compared with written Values */ + sendString (SerOutPort, TRUE, testMessage, "\tRTC Seconds: ", + ItoDStr (rtcReadValue.sec), Dummy); + sendString (SerOutPort, FALSE, testMessage, + "\t(Should be: ", ItoDStr (dsec), ")"); + vTaskDelay (200); + sendString (SerOutPort, TRUE, testMessage, "\tRTC Minutes: ", + ItoDStr (rtcReadValue.min), Dummy); + sendString (SerOutPort, FALSE, testMessage, + "\t(Should be: ", ItoDStr (dmin), ")"); + vTaskDelay (200); + sendString (SerOutPort, TRUE, testMessage, "\tRTC Hours: ", + ItoDStr (rtcReadValue.hour), Dummy); + sendString (SerOutPort, FALSE, testMessage, + "\t(Should be: ", ItoDStr (dhour), ")"); + vTaskDelay (200); + sendString (SerOutPort, TRUE, testMessage, "\tRTC Day: ", + ItoDStr (rtcReadValue.day), Dummy); + sendString (SerOutPort, FALSE, testMessage, + "\t(Should be: ", ItoDStr (dday), ")"); + vTaskDelay (200); + sendString (SerOutPort, TRUE, testMessage, "\tRTC Day of Week: ", + ItoDStr (rtcReadValue.dow), Dummy); + sendString (SerOutPort, FALSE, testMessage, + "\t(Should be: ", ItoDStr (ddow), ")"); + vTaskDelay (200); + sendString (SerOutPort, TRUE, testMessage, "\tRTC Month: ", + ItoDStr (rtcReadValue.mon), Dummy); + sendString (SerOutPort, FALSE, testMessage, + "\t(Should be: ", ItoDStr (dmon), ")"); + vTaskDelay (200); + sendString (SerOutPort, TRUE, testMessage, "\tRTC Year: ", + ItoDStr (rtcReadValue.year), Dummy); + sendString (SerOutPort, FALSE, testMessage, + "\t(Should be: ", ItoDStr (dyear), ")"); + vTaskDelay (200); + sendString (SerOutPort, TRUE, testMessage, "\tRTC Day of Year: ", + ItoDStr (rtcReadValue.doy), Dummy); + sendString (SerOutPort, FALSE, testMessage, + "\t(Should be: ", ItoDStr (ddoy), ")"); + + if ((dsec == rtcReadValue.sec) && /* Compare read Values with */ + (dmin == rtcReadValue.min) && /* written Values */ + (dhour == rtcReadValue.hour) && + (dday == rtcReadValue.day) && + (ddow == rtcReadValue.dow) && + (dmon == rtcReadValue.mon) && + (dyear == rtcReadValue.year) && + (ddoy == rtcReadValue.doy)) + { /* If all Values equals */ + + rtcRead (rtcPtr); /* Read RTC Values again */ + if (dsec != rtcReadValue.sec) /* If RTC runs (seconds-compare) */ + { + rtcReadResult = TRUE; /* Set Test Result to TRUE */ + } + else /* If Run Test fails */ + { + rtcReadResult = FALSE; /* Set Test Result to FALSE */ + } + } + else /* If Read Test Fails */ + { + rtcReadResult = FALSE; /* Set Test Result to FALSE */ + } + + return rtcReadResult; /* Return Test Result */ +} diff --git a/Tester/SW/Applications/testfiles/testrtc.h b/Tester/SW/Applications/testfiles/testrtc.h new file mode 100644 index 0000000..6f73dc9 --- /dev/null +++ b/Tester/SW/Applications/testfiles/testrtc.h @@ -0,0 +1,95 @@ +/* --------------------------------------------------------------------------- + * testrtc.h (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * Headerfile for RTC test File testrtc.c + * --------------------------------------------------------------------------- + * Version(s): 0.1, Feb 26, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef TESTRTC_H_ +#define TESTRTC_H_ +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ +#include "lpc23xx.h" +#include "types.h" + + +/* FreeRTOS includes */ +#include "FreeRTOS.h" +#include "Task.h" +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function: testrtcStart + * + * Main Function for RTC Tests + * + * Parameter: void + * + * Return: BOOLEAN - Test Result + * --------------------------------------------------------------------------- + */ +BOOLEAN testrtcStart(void); + +/* --------------------------------------------------------------------------- + * Function: DoRTCWrite + * + * Writes defined Values to the RTC + * + * Parameter: void + * + * Return: void + * --------------------------------------------------------------------------- + */ +void DoRTCWrite (void); + +/* --------------------------------------------------------------------------- + * Function: DoRTCRead + * + * Reads Values from the RTC and compares them with written Values. Also does + * a check if RTC is running + * + * Parameter: void + * + * Return: BOOLEAN - Test Result + * --------------------------------------------------------------------------- + */ +BOOLEAN DoRTCRead (void); + +#endif /*TESTRTC_H_*/ diff --git a/Tester/SW/Applications/topoftest.c b/Tester/SW/Applications/topoftest.c new file mode 100644 index 0000000..f596475 --- /dev/null +++ b/Tester/SW/Applications/topoftest.c @@ -0,0 +1,180 @@ +/* --------------------------------------------------------------------------- + * topoftest.c (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * DesignTest MAIN File + * Contains automatic Test Application + * --------------------------------------------------------------------------- + * Version(s): 0.1, Mar 06, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +/* Compiler includes */ +#include + +#include "LPC23xx.h" +#include "types.h" + +/* FreeRTOS includes */ +#include "FreeRTOS.h" +#include "task.h" +#include "semphr.h" +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "topoftest.h" +#include "dio.h" +#include "ledfunctions.h" +#include "taskfunctions.h" +#include "menu.h" +#include "menuargs.h" +#include "serial.h" +#include "SerOut.h" +#include "bus.h" +#include "dac.h" +#include "BusProtocol.h" +#include "protocolfunctions.h" +#include "remote_tests.h" +#include "remote_misc.h" + +/*Test includes */ +#include "testLED.h" +#include "testdio.h" +#include "testaio.h" +#include "testBUS.h" +#include "testeeprom.h" +#include "testMMC.h" +#include "testpower.h" +#include "testrtc.h" + +/* temp includes */ +#include "fat_test.h" +#include "mmc_transfer.h" + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ + +/* Time in ms between single Tests */ +#define TestPause 100 + +/* BUS Communication IDs */ +#define BUS_ID 1 /* 1 for Master, >1 for Slave */ +#define BUS_numbers 2 /* Maximum Numbers of Devices */ + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ +UINT32 UINT32result; +BOOLEAN auto_testResult; +BOOLEAN placedEB = TRUE; /* Indicate whether Extension Board is connected */ + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ + +void mainInit(void) +{ +#if ((PINSET_TESTER == 0) || (PINSET_TESTER == 2)) + /* Olimex Board and Tester only have one serial port */ + SerOutPort = COM1; /* Set Message ComPort to COM2 */ + MenuPort = COM1; +#else + /* IO-CTRL got 2 serial ports to communicate */ + SerOutPort = COM2; /* Set Message ComPort to COM2 */ + MenuPort = COM2; +#endif + + thisDeviceNumber = 0; /* define this device as Master */ + remoteDeviceNumber = 2; /* define default remote device */ + + block_ImportantMessage = FALSE; + block_HeaderMessage = FALSE; + block_ResultMessage = FALSE; + block_NoteMessage = FALSE; + block_TestMessage = FALSE; + block_MenuMessage = TRUE; + block_SpinningWheel = TRUE; + GotoNewLine = TRUE; + + + /* Do Test Initialisations */ + taskInit(); /* Initialize TaskStatus Variables */ + protocolInit (BUS1, BUS_ID, BUS_numbers); /* Init Bus System */ + + + /* Indicate Board activity with flashing green LED */ + d_gLED = xTaskCreate( (void *)gLEDToggle, + ( signed portCHAR * ) "LedToggle", + configMINIMAL_STACK_SIZE, (UINT16 *)500, + tskIDLE_PRIORITY + 2, &gLED); + + /* Create Spinning Wheel Task and block it immediately */ + d_spinWheel = xTaskCreate( (void *)showSpinningWheel, + ( signed portCHAR * ) "SpinningWheel", + configMINIMAL_STACK_SIZE, NULL, + tskIDLE_PRIORITY + 2, &spinWheel); + + + +// dioClean(); + CallMenu(); /* Goto Menu */ + +} + + +void showSpinningWheel (void) +{ + static UINT32 arraycnt = 0; + UINT8 SpinningWheelArray[4] = {'-', '\\', '|', '/'}; + + + for (;;) + { + /* Make it possible to block the PrintOut of the Wheel */ + switch (block_SpinningWheel) + { + case TRUE: + break; + case FALSE: + /* Set cursor one Position to left, then Put Character */ + /* Don't care about the Warning */ + serWrite(SerOutPort, strlen("\x1B[1D"), (UINT8 *)"\x1B[1D"); + serPut(SerOutPort, SpinningWheelArray[arraycnt]); + + if (arraycnt == 3) + { + arraycnt = 0; + } + else + { + arraycnt += 1; + } + break; + } + vTaskDelay(100); + } +} diff --git a/Tester/SW/Applications/topoftest.h b/Tester/SW/Applications/topoftest.h new file mode 100644 index 0000000..9850a0b --- /dev/null +++ b/Tester/SW/Applications/topoftest.h @@ -0,0 +1,117 @@ +/* --------------------------------------------------------------------------- + * topoftest.h (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * Headfile for Main designtest File topoftest.c + * --------------------------------------------------------------------------- + * Version(s): 0.1, Mar 06, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef TOPOFTEST_H_ +#define TOPOFTEST_H_ + +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ +#include "lpc23xx.h" +#include "types.h" +#include "serial.h" + +/* FreeRTOS includes */ +#include "FreeRTOS.h" +#include "task.h" + + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ +/* Global Test Result Variables */ +BOOLEAN g_slaveaiotest; +BOOLEAN g_ledtest; +BOOLEAN g_framtest; +BOOLEAN g_diotest; +BOOLEAN g_aiotest; +BOOLEAN g_cantest; +BOOLEAN g_eepromtest; +BOOLEAN g_flashtest; +BOOLEAN g_comtest; +BOOLEAN g_mmctest; +BOOLEAN g_logtest; +BOOLEAN g_powertest; +BOOLEAN g_rtctest; +BOOLEAN g_batterytest; +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function: designtest + * + * Main Function to the design Test. + * Application Initialisations are called from here. + * + * Parameters: void + * + * Return: void + * --------------------------------------------------------------------------- + */ +void mainInit(void); + + +/* --------------------------------------------------------------------------- + * Function: CalcTestResult + * + * Calculates a "PASSED" oder "FAILED" Result out of the single, global + * Test Results + * + * Parameters: void + * + * Return: BOOLEAN - Calculation Result + * --------------------------------------------------------------------------- + */ +BOOLEAN CalcTestResult (void); + + +/* --------------------------------------------------------------------------- + * Function: showSpinningWheel + * + * Function to show a spinning wheel out of characters '/', '-', '\' and '|' + * The Wheel is used to indecate, that the system is still running but busy + * with a certain task. + * + * Parameter: void + * + * Return: void + * --------------------------------------------------------------------------- + */ +void showSpinningWheel (void); + +#endif /*TOPOFTEST_H_*/ diff --git a/Tester/SW/BootLoader/.cproject b/Tester/SW/BootLoader/.cproject new file mode 100644 index 0000000..f8348fe --- /dev/null +++ b/Tester/SW/BootLoader/.cproject @@ -0,0 +1,640 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tester/SW/BootLoader/.project b/Tester/SW/BootLoader/.project new file mode 100644 index 0000000..707cd09 --- /dev/null +++ b/Tester/SW/BootLoader/.project @@ -0,0 +1,83 @@ + + + BootLoader + + + Drivers + inc + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + org.eclipse.cdt.make.core.cleanBuildTarget + clean + + + org.eclipse.cdt.make.core.enableCleanBuild + true + + + org.eclipse.cdt.make.core.append_environment + true + + + ?name? + + + + org.eclipse.cdt.make.core.stopOnError + true + + + org.eclipse.cdt.make.core.buildCommand + make + + + org.eclipse.cdt.make.core.contents + org.eclipse.cdt.make.core.activeConfigSettings + + + org.eclipse.cdt.make.core.buildLocation + ${workspace_loc:/BootLoader/Debug} + + + org.eclipse.cdt.make.core.useDefaultBuildCmd + true + + + org.eclipse.cdt.make.core.enableFullBuild + true + + + org.eclipse.cdt.make.core.enableAutoBuild + false + + + org.eclipse.cdt.make.core.fullBuildTarget + all + + + org.eclipse.cdt.make.core.buildArguments + + + + org.eclipse.cdt.make.core.autoBuildTarget + all + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.core.cnature + + diff --git a/Tester/SW/BootLoader/CommListeners.c b/Tester/SW/BootLoader/CommListeners.c new file mode 100644 index 0000000..876dbc9 --- /dev/null +++ b/Tester/SW/BootLoader/CommListeners.c @@ -0,0 +1,187 @@ +/* --------------------------------------------------------------------------- + * CommListeners.c - v0.1 (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Feb 15, 2008, FSc + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "types.h" +#include "CommListeners.h" +#include "IspProtocol.h" +#include "serial.h" +#include "bus.h" +#include "crc.h" + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ +#define ACKNOWLEDGE_MSGSIZE 6 + + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ +int com1IspHandler; +int com2IspHandler; +int bus1IspHandler; +int bus2IspHandler; + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ +void sendAckOnCom1(t_isp_responses response); +void sendAckOnCom2(t_isp_responses response); +void sendAckOnBus1(t_isp_responses response); +void sendAckOnBus2(t_isp_responses response); +UINT8 *createAckMessage(t_isp_responses response ); + + /** \brief Initialises the COM1 listener for handling IspProtocol on COM1 */ +void initCom1Listener() +{ + com1IspHandler = ispInitProtocol( sendAckOnCom1 ); +} + +/** \brief Initialises the COM2 listener for handling IspProtocol on COM2 */ +void initCom2Listener() +{ + com2IspHandler = ispInitProtocol( sendAckOnCom2 ); + +} + +/** \brief Initialises the BUS1 listener for handling IspProtocol on BUS1 */ +void initBus1Listener() +{ + bus1IspHandler = ispInitProtocol( sendAckOnBus1 ); +} + +/** \brief Initialises the BUS2 listener for handling IspProtocol on BUS2 */ +void initBus2Listener() +{ + bus2IspHandler = ispInitProtocol( sendAckOnBus2 ); +} + + +/** \brief Does IspProtocol handling for fresh received bytes on COM1 */ +void listen2Com1() +{ + UINT8 byte; + if (serGet( COM1, &byte) == TRUE) + { + ispHandleRxByte( com1IspHandler, byte ); + } +} + +/** \brief Does IspProtocol handling for fresh received bytes on COM2 */ +void listen2Com2() +{ + UINT8 byte; + static int nrReceivedBytes = 0;; + if (serGet( COM2, &byte) == TRUE) + { + nrReceivedBytes++; + ispHandleRxByte( com2IspHandler, byte ); + } +} + +/** \brief Does IspProtocol handling for fresh received bytes on BUS1 */ +void listen2Bus1() +{ + UINT8 byte; + if (busGet( BUS1, &byte) == TRUE) + { + ispHandleRxByte( bus1IspHandler, byte ); + } + +} + +/** \brief Does IspProtocol handling for fresh received bytes on BUS2 */ +void listen2Bus2() +{ + UINT8 byte; + if (busGet( BUS2, &byte) == TRUE) + { + ispHandleRxByte( bus2IspHandler, byte ); + } +} + +void sendAckOnCom1(t_isp_responses response) +{ + UINT8 *message = createAckMessage( response ); + + // Send over COM1 + serWrite(COM1, ACKNOWLEDGE_MSGSIZE, message); +} + +void sendAckOnCom2(t_isp_responses response) +{ + UINT8 *message = createAckMessage( response ); + + // Send over COM2 + serWrite(COM2, ACKNOWLEDGE_MSGSIZE, message); +} + +void sendAckOnBus1(t_isp_responses response) +{ + UINT8 *message = createAckMessage( response ); + + // Send over BUS1 + busWrite(BUS1, ACKNOWLEDGE_MSGSIZE, message); +} + +void sendAckOnBus2(t_isp_responses response) +{ + UINT8 *message = createAckMessage( response ); + + // Send over BUS2 + busWrite(BUS2, ACKNOWLEDGE_MSGSIZE, message); +} + +// +UINT8 *createAckMessage(t_isp_responses response ) +{ + static UINT8 AcknowledgeMsg[ACKNOWLEDGE_MSGSIZE]; + UINT16 msgCrc; + + // Assemble message + AcknowledgeMsg[0] = ISP_START_BYTE; + AcknowledgeMsg[1] = ISP_MSGID_ACKNOWLEDGE; + AcknowledgeMsg[2] = 1; + AcknowledgeMsg[3] = (UINT8)response; + + // Calculate CRC + msgCrc = crcCalc( &(AcknowledgeMsg[1]), 3, 0 ); + + AcknowledgeMsg[4] = (UINT8)(msgCrc >> 8); + AcknowledgeMsg[5] = (UINT8)(msgCrc & 0x00FF); + + return AcknowledgeMsg; +} diff --git a/Tester/SW/BootLoader/CommListeners.h b/Tester/SW/BootLoader/CommListeners.h new file mode 100644 index 0000000..6188921 --- /dev/null +++ b/Tester/SW/BootLoader/CommListeners.h @@ -0,0 +1,74 @@ +/* --------------------------------------------------------------------------- + * CommListeners.h - v0.1 (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Feb 15, 2008, FSc + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef __COMMLISTENERS_H__ +#define __COMMLISTENERS_H__ +/** \file CommListeners.h + \brief +*/ + +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ + +/** \brief Initialises the COM1 listener for handling IspProtocol on COM1 */ +void initCom1Listener(); +/** \brief Initialises the COM2 listener for handling IspProtocol on COM2 */ +void initCom2Listener(); +/** \brief Initialises the BUS1 listener for handling IspProtocol on BUS1 */ +void initBus1Listener(); +/** \brief Initialises the BUS2 listener for handling IspProtocol on BUS2 */ +void initBus2Listener(); + +/** \brief Does IspProtocol handling for fresh received bytes on COM1 */ +void listen2Com1(); +/** \brief Does IspProtocol handling for fresh received bytes on COM2 */ +void listen2Com2(); +/** \brief Does IspProtocol handling for fresh received bytes on BUS1 */ +void listen2Bus1(); +/** \brief Does IspProtocol handling for fresh received bytes on BUS2 */ +void listen2Bus2(); + + +#endif /* __COMMLISTENERS_H__ */ diff --git a/Tester/SW/BootLoader/Crc.c b/Tester/SW/BootLoader/Crc.c new file mode 100644 index 0000000..bc3f34c --- /dev/null +++ b/Tester/SW/BootLoader/Crc.c @@ -0,0 +1,123 @@ +/* --------------------------------------------------------------------------- + * Crc.c - v0.1 (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Jan 31, 2008, FSc + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "crc.h" + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ +const UINT16 CRC_table[256] = +{ + 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7, + 0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF, + 0x1231, 0x0210, 0x3273, 0x2252, 0x52B5, 0x4294, 0x72F7, 0x62D6, + 0x9339, 0x8318, 0xB37B, 0xA35A, 0xD3BD, 0xC39C, 0xF3FF, 0xE3DE, + 0x2462, 0x3443, 0x0420, 0x1401, 0x64E6, 0x74C7, 0x44A4, 0x5485, + 0xA56A, 0xB54B, 0x8528, 0x9509, 0xE5EE, 0xF5CF, 0xC5AC, 0xD58D, + 0x3653, 0x2672, 0x1611, 0x0630, 0x76D7, 0x66F6, 0x5695, 0x46B4, + 0xB75B, 0xA77A, 0x9719, 0x8738, 0xF7DF, 0xE7FE, 0xD79D, 0xC7BC, + 0x48C4, 0x58E5, 0x6886, 0x78A7, 0x0840, 0x1861, 0x2802, 0x3823, + 0xC9CC, 0xD9ED, 0xE98E, 0xF9AF, 0x8948, 0x9969, 0xA90A, 0xB92B, + 0x5AF5, 0x4AD4, 0x7AB7, 0x6A96, 0x1A71, 0x0A50, 0x3A33, 0x2A12, + 0xDBFD, 0xCBDC, 0xFBBF, 0xEB9E, 0x9B79, 0x8B58, 0xBB3B, 0xAB1A, + 0x6CA6, 0x7C87, 0x4CE4, 0x5CC5, 0x2C22, 0x3C03, 0x0C60, 0x1C41, + 0xEDAE, 0xFD8F, 0xCDEC, 0xDDCD, 0xAD2A, 0xBD0B, 0x8D68, 0x9D49, + 0x7E97, 0x6EB6, 0x5ED5, 0x4EF4, 0x3E13, 0x2E32, 0x1E51, 0x0E70, + 0xFF9F, 0xEFBE, 0xDFDD, 0xCFFC, 0xBF1B, 0xAF3A, 0x9F59, 0x8F78, + 0x9188, 0x81A9, 0xB1CA, 0xA1EB, 0xD10C, 0xC12D, 0xF14E, 0xE16F, + 0x1080, 0x00A1, 0x30C2, 0x20E3, 0x5004, 0x4025, 0x7046, 0x6067, + 0x83B9, 0x9398, 0xA3FB, 0xB3DA, 0xC33D, 0xD31C, 0xE37F, 0xF35E, + 0x02B1, 0x1290, 0x22F3, 0x32D2, 0x4235, 0x5214, 0x6277, 0x7256, + 0xB5EA, 0xA5CB, 0x95A8, 0x8589, 0xF56E, 0xE54F, 0xD52C, 0xC50D, + 0x34E2, 0x24C3, 0x14A0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405, + 0xA7DB, 0xB7FA, 0x8799, 0x97B8, 0xE75F, 0xF77E, 0xC71D, 0xD73C, + 0x26D3, 0x36F2, 0x0691, 0x16B0, 0x6657, 0x7676, 0x4615, 0x5634, + 0xD94C, 0xC96D, 0xF90E, 0xE92F, 0x99C8, 0x89E9, 0xB98A, 0xA9AB, + 0x5844, 0x4865, 0x7806, 0x6827, 0x18C0, 0x08E1, 0x3882, 0x28A3, + 0xCB7D, 0xDB5C, 0xEB3F, 0xFB1E, 0x8BF9, 0x9BD8, 0xABBB, 0xBB9A, + 0x4A75, 0x5A54, 0x6A37, 0x7A16, 0x0AF1, 0x1AD0, 0x2AB3, 0x3A92, + 0xFD2E, 0xED0F, 0xDD6C, 0xCD4D, 0xBDAA, 0xAD8B, 0x9DE8, 0x8DC9, + 0x7C26, 0x6C07, 0x5C64, 0x4C45, 0x3CA2, 0x2C83, 0x1CE0, 0x0CC1, + 0xEF1F, 0xFF3E, 0xCF5D, 0xDF7C, 0xAF9B, 0xBFBA, 0x8FD9, 0x9FF8, + 0x6E17, 0x7E36, 0x4E55, 0x5E74, 0x2E93, 0x3EB2, 0x0ED1, 0x1EF0 +}; + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ + +/*! +* \brief Calculate 16 bit CRC +* +* a function to calculate an serial 16 bit CRC +* according to the CCITT V.024 standard +* To short down the calculation time of the serial CRC +* a hash table is used. +* This CRC is a fast (with hash table) and good CRC for +* data transfer and integrity test of data storage. It can effectively +* can detect errors by data transfer. 16 Bit is good for data blocks from +* 0 - 4 KByte with a residual risk for non detection of 10E-8 per transfer. +* (Multiply this with the error factor of the transmit line) +* +* The polynoom of CRC-16-CCIT = x^16 + x^12 + x^5 + 1 +* +* \param data Build the crc from this data block +* \param length Length of the data block +* \param feed Initial CRC value (take 0 by default) +*/ +UINT16 crcCalc(UINT8 * data, UINT32 length, UINT16 feed) +{ + unsigned short crc = feed; + unsigned char index; + unsigned int count; + + for(count=0; count> 8); + crc = crc & 0x00FF; + crc = (crc << 8); + crc &= 0xFF00; + crc = crc ^ CRC_table[index] ^ (*data & 0x00FF); + data++; + } + + return crc; +} + diff --git a/Tester/SW/BootLoader/Crc.h b/Tester/SW/BootLoader/Crc.h new file mode 100644 index 0000000..e398859 --- /dev/null +++ b/Tester/SW/BootLoader/Crc.h @@ -0,0 +1,59 @@ +/* --------------------------------------------------------------------------- + * Crc.h - v0.1 (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Jan 31, 2008, FSc + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef __CRC_H__ +#define __CRC_H__ +/** \file Crc.h + \brief +*/ + +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ +#include "types.h" + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ + +UINT16 crcCalc(UINT8 * pData, UINT32 length, UINT16 feed); + +#endif /* __CRC_H__ */ + diff --git a/Tester/SW/BootLoader/IspProtocol.c b/Tester/SW/BootLoader/IspProtocol.c new file mode 100644 index 0000000..cc5fbb5 --- /dev/null +++ b/Tester/SW/BootLoader/IspProtocol.c @@ -0,0 +1,620 @@ +/* --------------------------------------------------------------------------- + * IspProtocol.c - v0.1 (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Feb 13, 2008, FSc + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "types.h" +#include "IspProtocol.h" +#include "InternalFlash.h" +#include "Crc.h" +#include "Leds.h" +#include "appImage.h" + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ +#define MAX_ADMINS (4) +#define START_BYTE (0xAA) +#define MAX_PAYLOAD_SIZE (80) + +#define MSGID_ACKNOWLEDGE (0x01) +#define MSGID_UNLOCK (0x02) +#define MSGID_ERASEBLOCK (0x03) +#define MSGID_PROGRAMFLASH (0x04) +#define MSGID_VERIFYFLASH (0x05) +#define MSGID_FINISHPROGRAMMING (0x06) +#define MSGID_STARTPROGRAM (0x07) + +#define APP_FLASH_START_ADDR (0x00005000) +#define APP_FLASH_END_ADDR (0x0007DFFF) +#define APP_FLASH_START_SECTOR (5) +#define APP_FLASH_END_SECTOR (27) +#define APP_IMAGE_LENGTH_OFFS 0x0008 +#define APP_IMAGE_CRC_OFFS 0x000C + +#define PROGRAM_BLOCK_SIZE (256) +#define INVALID_ADDRESS (0xFFFFFFFF) + + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ +typedef enum +{ + IDLE, + MESSAGE_ID, + PAYLOAD_SIZE, + PAYLOAD, + CRC +} t_isp_decodestatus; + +typedef struct t_ISP_MESSAGE { + UINT8 messageId; + UINT8 payloadSize; + UINT8 payload[MAX_PAYLOAD_SIZE]; + UINT16 crc; +} t_isp_message; + +typedef struct t_ISP_ADMIN { + t_isp_decodestatus status; + UINT8 rxIndex; + UINT16 rxCrc; + t_isp_message rxMessage; + t_isp_ack_callback ackCallback; +} t_isp_admin; + +static t_isp_admin ispAdmins[MAX_ADMINS]; +static UINT8 lastReservedAdmin = 0; +static UINT32 maxProgrammedAddress = 0; +static UINT32 startAddress = INVALID_ADDRESS; +static UINT8 verifyBlock[PROGRAM_BLOCK_SIZE] __attribute__((aligned(PROGRAM_BLOCK_SIZE))); +static UINT8 programBlock[PROGRAM_BLOCK_SIZE] __attribute__((aligned(PROGRAM_BLOCK_SIZE))); +static UINT8 programFirstBlock[PROGRAM_BLOCK_SIZE] __attribute__((aligned(PROGRAM_BLOCK_SIZE))); + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ +void sendAcknowledge(t_isp_admin *handle, t_isp_responses response); +BOOLEAN ValidMessageId( UINT8 messageId); +void handleMessage(t_isp_admin *admin); +void handleUnlockMessage(t_isp_admin *admin); +void handleEraseBlockMessage(t_isp_admin *admin); +void handleStartProgram(t_isp_admin *admin); +void handleFinishProgramming(t_isp_admin *admin); +void handleVerifyFlashMessage(t_isp_admin *admin); +void handleProgramFlashMessage(t_isp_admin *admin); +iflashresult fillProgramBlock( UINT32 address, UINT8 size, UINT8 *data); +iflashresult programFlash(); +void resetRamBlock( UINT32 address ); +iflashresult StoreCrcAndLength( UINT32 imageSize ); + + + +/** \brief Initialises a instance of the ISP-protocol handler. + * + * For each communication port, one ISP-protocol handler must be initialised. + * + * \param ackCallback Callback-function used for parent to send acknowledge + * \returns handle Handle for this ISP-protocol handler. + */ +int ispInitProtocol(t_isp_ack_callback ackCallback ) +{ + int result; + if (lastReservedAdmin < MAX_ADMINS) + { + ispAdmins[lastReservedAdmin].status = IDLE; + ispAdmins[lastReservedAdmin].ackCallback = ackCallback; + + result = lastReservedAdmin; + lastReservedAdmin++; + } + else + { + result = -1; + } + return result; +} + +/** \brief Does the protocol handling by parsing each byte received on the communication port. + * + * \param handle Handle for the ISP-protocol handler + * \param byte The received byte on the communication port + */ +void ispHandleRxByte( int handle, UINT8 byte ) +{ + t_isp_admin *admin = &(ispAdmins[handle]); + + switch( admin->status ) + { + case(IDLE): + if (byte == START_BYTE) + { + admin->status = MESSAGE_ID; + } + break; + case(MESSAGE_ID): + if (ValidMessageId(byte) == TRUE ) + { + // Determine Payload-size + admin->rxCrc = crcCalc(&byte, 1, 0); + admin->rxMessage.messageId = byte; + admin->status = PAYLOAD_SIZE; + } + else + { + sendAcknowledge( admin, ISP_INVALID_MESSAGE_ID ); + admin->status = IDLE; + } + break; + case(PAYLOAD_SIZE): + // Determine Payload-size + if (byte <=MAX_PAYLOAD_SIZE) + { + admin->rxMessage.payloadSize = byte; + admin->rxCrc = crcCalc(&byte, 1, admin->rxCrc); + admin->rxIndex = 0; + if (byte > 0) + { + admin->status = PAYLOAD; + } + else + { + admin->status = CRC; + } + } + else + { + sendAcknowledge( admin, ISP_PAYLOAD_TOO_LARGE ); + admin->status = IDLE; + } + break; + case(PAYLOAD): + admin->rxMessage.payload[ admin->rxIndex ] = byte; + admin->rxCrc = crcCalc(&byte, 1, admin->rxCrc); + admin->rxIndex++; + + if (admin->rxIndex >= admin->rxMessage.payloadSize) + { + admin->rxIndex = 0; + admin->status = CRC; + } + break; + case(CRC): + // Receive and check CRC + if (admin->rxIndex == 0) + { + admin->rxMessage.crc = (byte << 8); + } + else + { + admin->rxMessage.crc |= (byte & 0x00FF); + } + + admin->rxIndex++; + + if (admin->rxIndex >= 2) + { + if (admin->rxCrc == admin->rxMessage.crc) + { + /* Crc was succesfully checked */ + handleMessage(admin); + } + else + { + sendAcknowledge( admin, ISP_RECV_BAD_CRC ); + } + admin->status = IDLE; + } + break; + default: + admin->status = IDLE; + break; + } +} + +void handleMessage(t_isp_admin *admin) +{ + switch( admin->rxMessage.messageId ) + { + case(MSGID_UNLOCK): + //sendAcknowledge( admin, ISP_CMD_SUCCESS); + handleUnlockMessage( admin ); + break; + case(MSGID_ERASEBLOCK): + handleEraseBlockMessage( admin ); + break; + case(MSGID_PROGRAMFLASH): + handleProgramFlashMessage( admin ); + break; + case(MSGID_VERIFYFLASH): + handleVerifyFlashMessage( admin ); + break; + case(MSGID_FINISHPROGRAMMING): + handleFinishProgramming( admin ); + break; + case(MSGID_STARTPROGRAM): + handleStartProgram( admin ); + break; + default: + sendAcknowledge( admin, ISP_INVALID_MESSAGE_ID); + break; + } +} + +BOOLEAN ValidMessageId( UINT8 messageId) +{ + if ((messageId >= 0x01) && (messageId <= 0x07)) + { + return TRUE; + } + else + { + return FALSE; + } +} + +void sendAcknowledge(t_isp_admin *handle, t_isp_responses response) +{ + handle->ackCallback( response ); +} + + +void handleUnlockMessage(t_isp_admin *admin) +{ + iflashresult unlockResult = ISP_CMD_SUCCESS; + + maxProgrammedAddress = 0; + unlockResult =iflashPrepare( APP_FLASH_START_SECTOR, APP_FLASH_END_SECTOR); + + admin->ackCallback( (t_isp_responses)unlockResult ); +} + +void handleEraseBlockMessage(t_isp_admin *admin) +{ + iflashresult result; + UINT8 blockNr; + + // Extract block nr from message + blockNr = admin->rxMessage.payload[0]; + + if ( ( blockNr >= APP_FLASH_START_SECTOR) + && ( blockNr <= APP_FLASH_END_SECTOR)) + { + result = iflashErase( blockNr ); + } + else + { + result = ISP_INVALID_SECTOR; + } + + admin->ackCallback( (t_isp_responses)result ); +} + +void handleProgramFlashMessage(t_isp_admin *admin) +{ + iflashresult result; + UINT32 address; + UINT8 size; + UINT8 *data; + UINT8 index = 0; + + // Extract address, datalength & data from message + address = ispGet32bit(admin->rxMessage.payload, &index); + size = ispGet8bit(admin->rxMessage.payload, &index); + data = &(admin->rxMessage.payload[index]); + + if (maxProgrammedAddress < address) maxProgrammedAddress = address; + + if ( (address >= APP_FLASH_START_ADDR) + && (address <= APP_FLASH_END_ADDR) + ) + { + result = fillProgramBlock(address, size, data ); + } + else + { + result = ISP_DST_ADDR_ERROR; + } + + admin->ackCallback( (t_isp_responses)result ); +} + +void handleVerifyFlashMessage(t_isp_admin *admin) +{ + iflashresult result; + UINT32 address; + UINT8 size; + UINT8 index = 0; + UINT8 bufferIdx; + + // Extract address, datalength & data from message + address = ispGet32bit(admin->rxMessage.payload, &index); + size = ispGet8bit(admin->rxMessage.payload, &index); + for (bufferIdx = 0; bufferIdx < size; bufferIdx++) + { + verifyBlock[bufferIdx] = ispGet8bit(admin->rxMessage.payload, &index); + } + + // Make size dividable by 4 + size = size - (size % 4); + + if ((size >= 4) && (address != APP_FLASH_START_ADDR)) + { + result = iflashVerify( address, size, verifyBlock ); + } + else + { + result = ISP_CMD_SUCCESS; + } + + admin->ackCallback( (t_isp_responses)result ); +} + +void handleFinishProgramming(t_isp_admin *admin) +{ + iflashresult result; + UINT32 imageSize; + + // Program remaining block on flash + fillProgramBlock(0, 0, 0 ); + + // Calculate image length + imageSize = maxProgrammedAddress - APP_FLASH_START_ADDR; + + // Calculate and store Crc & imageSize on flash + result = StoreCrcAndLength( imageSize ); + + admin->ackCallback( (t_isp_responses)result ); +} + +void handleStartProgram(t_isp_admin *admin) +{ + //if (appiValidAppImageAvail() == TRUE) + { + ledSet( LED1, 0 ); + ledSet( LED0, 0 ); + + appiJumpToAppImage(); + } + //else + //{ + // admin->ackCallback( ISP_BUSY ); + //} +} + + +void ispAdd16bit(UINT8 *payloadlocation, UINT16 data) +{ + UINT8 index = 0; + + payloadlocation[index] = (UINT8)(data >> 8); + index++; + payloadlocation[index] = (UINT8)(data & 0x00FF); +} + + +void ispAdd32bit(UINT8 *payloadlocation, UINT32 data) +{ + UINT8 index = 0; + + payloadlocation[index] = (UINT8)(data >> 24); + index++; + payloadlocation[index] = (UINT8)(data >> 16); + index++; + payloadlocation[index] = (UINT8)(data >> 8); + index++; + payloadlocation[index] = (UINT8)(data & 0xFF); + +} + +UINT8 ispGet8bit(UINT8 *payload, UINT8 *payloadIndex) +{ + UINT8 result; + + result = (UINT8)payload[*payloadIndex]; + (*payloadIndex)++; + + return result; +} + + +UINT16 ispGet16bit(UINT8 *payload, UINT8 *payloadIndex) +{ + UINT16 result; + + result = ((UINT16)payload[*payloadIndex]) << 8; + (*payloadIndex)++; + result += ((UINT16)payload[*payloadIndex] & 0x00FF); + (*payloadIndex)++; + + return result; +} + + +UINT32 ispGet32bit(UINT8 *payload, UINT8 *payloadIndex) +{ + UINT32 result; + + result = ((UINT32)payload[*payloadIndex]) << 24; + (*payloadIndex)++; + result += ((UINT32)payload[*payloadIndex]) << 16; + (*payloadIndex)++; + result += ((UINT32)payload[*payloadIndex]) << 8; + (*payloadIndex)++; + result += ((UINT32)payload[*payloadIndex] & 0x000000FF); + (*payloadIndex)++; + + return result; +} + + +iflashresult fillProgramBlock( UINT32 address, UINT8 size, UINT8 *data) +{ + UINT32 programIndex; + UINT32 beginIndex; + UINT32 dataIndex; + UINT32 endIndex; + iflashresult result = ISP_CMD_SUCCESS; + + if (data == 0) + { + // finish sending last block + if (startAddress > 0) + { + result = programFlash(); + } + else + { + result = ISP_CMD_SUCCESS; + } + startAddress = INVALID_ADDRESS; + return result; + } + + // Determine startAddress. + if (startAddress == INVALID_ADDRESS) + { + // Make sure address is alligned to 256 + resetRamBlock(address - (address % PROGRAM_BLOCK_SIZE)); + } + else + { + if (address > (startAddress + PROGRAM_BLOCK_SIZE)) + { + result = programFlash(); + resetRamBlock( address ); + } + } + + // Determine endIndex; + if ( (startAddress + PROGRAM_BLOCK_SIZE) > (address + size) ) + { + endIndex = (address - startAddress) + size; + } + else + { + endIndex = PROGRAM_BLOCK_SIZE; + } + + // Copy data into programblock + dataIndex = 0; + beginIndex = address - startAddress; + for (programIndex = beginIndex; programIndex < endIndex; programIndex++) + { + programBlock[programIndex] = data[dataIndex]; + dataIndex++; + } + + // if program block is full, program it + if (dataIndex < size) + { + result = programFlash(); + resetRamBlock( startAddress + PROGRAM_BLOCK_SIZE ); + + // Copy rest in new block + endIndex = size - dataIndex; + for (programIndex = 0; programIndex < endIndex; programIndex++) + { + programBlock[programIndex] = data[dataIndex]; + dataIndex++; + } + } + else + { + if ((startAddress + PROGRAM_BLOCK_SIZE) == (address + size)) + { + result = programFlash(); + resetRamBlock( INVALID_ADDRESS ); + } + } + + return result; +} + +void resetRamBlock( UINT32 address ) +{ + UINT32 programIndex; + + startAddress = address; + for (programIndex = 0; programIndex < PROGRAM_BLOCK_SIZE; programIndex++) + { + programBlock[programIndex] = 0x00; + } +} + +iflashresult programFlash() +{ + UINT16 index; + + if (startAddress != APP_FLASH_START_ADDR) + { + iflashPrepare( APP_FLASH_START_SECTOR, APP_FLASH_END_SECTOR); + return iflashProgram( startAddress, PROGRAM_BLOCK_SIZE, programBlock ); + } + else + { + // keep copy of first block, programmed later at FinishedProgramming + for (index = 0; index < PROGRAM_BLOCK_SIZE; index++) + { + programFirstBlock[index] = programBlock[index]; + } + + return ISP_CMD_SUCCESS; + } +} + +iflashresult StoreCrcAndLength( UINT32 imageSize ) +{ + static UINT16 crc = 0; + static UINT8 *image = 0; + + // Calculate Crc over part before Length & CRC + crc = crcCalc(programFirstBlock, APP_IMAGE_LENGTH_OFFS, crc); + + // Calculate Crc over part after Length & CRC in first program block + image = (UINT8 *)(programFirstBlock + APP_IMAGE_CRC_OFFS + 4); + crc = crcCalc(image, PROGRAM_BLOCK_SIZE - (APP_IMAGE_CRC_OFFS + 4), crc); + + // Calculate Crc over rest of image already programmed + image = (UINT8 *)(APP_FLASH_START_ADDR + PROGRAM_BLOCK_SIZE); + crc = crcCalc(image, imageSize - PROGRAM_BLOCK_SIZE, crc); + + // Fill in Length & CRC + ispAdd32bit(programFirstBlock + APP_IMAGE_LENGTH_OFFS, imageSize); + ispAdd16bit(programFirstBlock + APP_IMAGE_CRC_OFFS, crc); + + // Program first block on flash + iflashPrepare( APP_FLASH_START_SECTOR, APP_FLASH_START_SECTOR); + return iflashProgram( APP_FLASH_START_ADDR, PROGRAM_BLOCK_SIZE, programFirstBlock ); +} diff --git a/Tester/SW/BootLoader/IspProtocol.h b/Tester/SW/BootLoader/IspProtocol.h new file mode 100644 index 0000000..70f1f71 --- /dev/null +++ b/Tester/SW/BootLoader/IspProtocol.h @@ -0,0 +1,98 @@ +/* --------------------------------------------------------------------------- + * IspProtocol.h - v0.1 (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: Handles the ISP-protocol (standard In System Programming -protocol) + * --------------------------------------------------------------------------- + * Version(s): 0.1, Feb 13, 2008, FSc + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef __ISPPROTOCOL_H__ +#define __ISPPROTOCOL_H__ +/** \file IspProtocol.h + \brief Handles the ISP-protocol (standard In System Programming -protocol) +*/ + +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ +#define ISP_MAX_ADMINS (4) +#define ISP_START_BYTE (0xAA) +#define ISP_MAX_PAYLOAD_SIZE (80) + +#define ISP_MSGID_ACKNOWLEDGE (0x01) +#define ISP_MSGID_UNLOCK (0x02) +#define ISP_MSGID_ERASEBLOCK (0x03) +#define ISP_MSGID_PROGRAMFLASH (0x04) +#define ISP_MSGID_VERIFYFLASH (0x05) +#define ISP_MSGID_FINISHPROGRAMMING (0x06) +#define ISP_MSGID_STARTPROGRAM (0x07) + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ +typedef enum +{ + ISP_CMD_SUCCESS = 0, + ISP_INVALID_COMMAND = 1, + ISP_SRC_ADDR_ERROR = 2, + ISP_DST_ADDR_ERROR = 3, + ISP_SRC_ADDR_NOT_MAPPED = 4, + ISP_DST_ADDR_NOT_MAPPED = 5, + ISP_COUNT_ERROR = 6, + ISP_INVALID_SECTOR = 7, + ISP_SECTOR_NOT_BLANK = 8, + ISP_SECTOR_NOT_PREPARED_FOR_WRITE_OPERATION = 9, + ISP_COMPARE_ERROR = 10, + ISP_BUSY = 11, + ISP_PAYLOAD_TOO_LARGE = 12, + ISP_RECV_BAD_CRC = 13, + ISP_INVALID_MESSAGE_ID = 14 +} t_isp_responses; + +typedef void (*t_isp_ack_callback)(t_isp_responses response); + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ +/** \brief Initialises a instance of the ISP-protocol handler */ +int ispInitProtocol(t_isp_ack_callback); + +/** \brief Does the protocol handling by parsing each byte received on the communication port. */ +void ispHandleRxByte( int handle, UINT8 byte ); + +void ispAdd16bit(UINT8 *payloadlocation, UINT16 data); +void ispAdd32bit(UINT8 *payloadlocation, UINT32 data); +UINT8 ispGet8bit(UINT8 *payload, UINT8 *payloadIndex); +UINT16 ispGet16bit(UINT8 *payload, UINT8 *payloadIndex); +UINT32 ispGet32bit(UINT8 *payload, UINT8 *payloadIndex); + + +#endif /* __ISPPROTOCOL_H__ */ diff --git a/Tester/SW/BootLoader/appImage.c b/Tester/SW/BootLoader/appImage.c new file mode 100644 index 0000000..179f383 --- /dev/null +++ b/Tester/SW/BootLoader/appImage.c @@ -0,0 +1,158 @@ +/* --------------------------------------------------------------------------- + * appImage.c - v0.1 (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Feb 12, 2008, FSc + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "types.h" +#include "appImage.h" +#include "LPC23xx.h" +#include "crc.h" +#include "IspProtocol.h" +#include "bootloader.h" + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ +typedef void (*t_application_startup)(void); + +#define APPI_FLASH_START_ADDR 0x5000 +#define APPI_FLASH_END_ADDR 0x7E000 +#define APPI_C_ENTRY_OFFS 0x0020 +#define APPI_IMAGE_LENGTH_OFFS 0x0008 +#define APPI_IMAGE_CRC_OFFS 0x000C + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ +void appiCalculateCrc( UINT32 imageLength, UINT16 *crc ); + + +/** \brief Checks if the Application image requests a Image update + * + * When the application image wants to start an image update, it sets + * a pattern on a known RAM-location and resets the CPU. Now the bootloader + * can verify this pattern. + * + * \retval TRUE Application did request an update + * \retval FALSE Application did not request an update + */ +BOOLEAN appiApplicationRequestsUpdate() +{ + if (blGetBootmode() == STAY_IN_BOOTLOADER) + { + return TRUE; + } + else + { + return FALSE; + } +} + + + /** \brief Checks if a valid Application image. + * + * \retval TRUE Flash contains a valid Application image + * \retval FALSE Flash doesn't contain a valid Application image + */ +BOOLEAN appiValidAppImageAvail() +{ + static UINT32 imageSize = 0; + static UINT16 recordedCrc = 0; + UINT8 index; + static UINT16 calculatedCrc; + + index = APPI_IMAGE_LENGTH_OFFS; + imageSize = ispGet32bit((UINT8 *)APPI_FLASH_START_ADDR, &index); + recordedCrc = ispGet16bit((UINT8 *)APPI_FLASH_START_ADDR, &index); + + if ( (imageSize >= 100) + && (imageSize <= (APPI_FLASH_START_ADDR - APPI_FLASH_END_ADDR)) + ) + { + appiCalculateCrc(imageSize, &calculatedCrc); + + if (recordedCrc != calculatedCrc) + { + return FALSE; + } + else + { + return TRUE; + } + } + else + { + if (imageSize == 0) + { + // escape for debugging + return TRUE; + } + else + { + return FALSE; + } + + } +} + +/** \brief Jumps to the Application image. Function won't return. + */ +void appiJumpToAppImage() +{ + unsigned int application_start_addr = APPI_FLASH_START_ADDR + APPI_C_ENTRY_OFFS; + + blResetBootmode(); + + DISABLE_INTERRUPTS(); + + ((t_application_startup)application_start_addr)(); +} + +void appiCalculateCrc( UINT32 imageLength, UINT16 *crc ) +{ + UINT8 *image = (UINT8 *)(APPI_FLASH_START_ADDR); + *crc = 0; + + // Calculate Crc over part before Length & CRC + *crc = crcCalc(image, APPI_IMAGE_LENGTH_OFFS, *crc); + + // Calculate Crc over part after Length & CRC + image = (UINT8 *)(APPI_FLASH_START_ADDR + APPI_IMAGE_CRC_OFFS + 4); + *crc = crcCalc(image, imageLength - (APPI_IMAGE_CRC_OFFS + 4), *crc); +} + diff --git a/Tester/SW/BootLoader/appImage.h b/Tester/SW/BootLoader/appImage.h new file mode 100644 index 0000000..ca94bae --- /dev/null +++ b/Tester/SW/BootLoader/appImage.h @@ -0,0 +1,66 @@ +/* --------------------------------------------------------------------------- + * appImage.h - v0.1 (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Feb 12, 2008, FSc + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef __APPIMAGE_H__ +#define __APPIMAGE_H__ +/** \file appImage.h + \brief +*/ + +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ + +/** \brief Checks if the Application image requests a Image update */ +BOOLEAN appiApplicationRequestsUpdate(); + +/** \brief Checks if a valid Application image. */ +BOOLEAN appiValidAppImageAvail(); + +/** \brief Jumps to the Application image. Function won't return. */ +void appiJumpToAppImage(); + + + +#endif /* __APPIMAGE_H__ */ diff --git a/Tester/SW/BootLoader/bootbl.s b/Tester/SW/BootLoader/bootbl.s new file mode 100644 index 0000000..288f117 --- /dev/null +++ b/Tester/SW/BootLoader/bootbl.s @@ -0,0 +1,158 @@ + /* Sample initialization file */ + + .extern main + .extern exit + + .text + .code 32 + + + .align 0 + + .extern __bss_beg__ + .extern __bss_end__ + .extern __stack_end__ + .extern __data_beg__ + .extern __data_end__ + .extern __data+beg_src__ + + .global start + .global endless_loop + + /* Stack Sizes */ + .set UND_STACK_SIZE, 0x00000004 + .set ABT_STACK_SIZE, 0x00000004 + .set FIQ_STACK_SIZE, 0x00000004 + .set IRQ_STACK_SIZE, 0X00000100 + .set SVC_STACK_SIZE, 0x00000100 + + /* Standard definitions of Mode bits and Interrupt (I & F) flags in PSRs */ + .set MODE_USR, 0x10 /* User Mode */ + .set MODE_FIQ, 0x11 /* FIQ Mode */ + .set MODE_IRQ, 0x12 /* IRQ Mode */ + .set MODE_SVC, 0x13 /* Supervisor Mode */ + .set MODE_ABT, 0x17 /* Abort Mode */ + .set MODE_UND, 0x1B /* Undefined Mode */ + .set MODE_SYS, 0x1F /* System Mode */ + + .equ I_BIT, 0x80 /* when I bit is set, IRQ is disabled */ + .equ F_BIT, 0x40 /* when F bit is set, FIQ is disabled */ + +start: +_start: +_mainCRTStartup: + + /* Setup a stack for each mode - note that this only sets up a usable stack + for system/user, SWI and IRQ modes. Also each mode is setup with + interrupts initially disabled. */ + ldr r0, .LC6 + msr CPSR_c, #MODE_UND|I_BIT|F_BIT /* Undefined Instruction Mode */ + mov sp, r0 + sub r0, r0, #UND_STACK_SIZE + msr CPSR_c, #MODE_ABT|I_BIT|F_BIT /* Abort Mode */ + mov sp, r0 + sub r0, r0, #ABT_STACK_SIZE + msr CPSR_c, #MODE_FIQ|I_BIT|F_BIT /* FIQ Mode */ + mov sp, r0 + sub r0, r0, #FIQ_STACK_SIZE + msr CPSR_c, #MODE_IRQ|I_BIT|F_BIT /* IRQ Mode */ + mov sp, r0 + sub r0, r0, #IRQ_STACK_SIZE + msr CPSR_c, #MODE_SVC|I_BIT|F_BIT /* Supervisor Mode */ + mov sp, r0 + sub r0, r0, #SVC_STACK_SIZE + msr CPSR_c, #MODE_SYS|I_BIT|F_BIT /* System Mode */ + mov sp, r0 + + /* We want to start in supervisor mode. Operation will switch to system + mode when the first task starts. */ + msr CPSR_c, #MODE_SVC|I_BIT|F_BIT + + /* Clear BSS. */ + + mov a2, #0 /* Fill value */ + mov fp, a2 /* Null frame pointer */ + mov r7, a2 /* Null frame pointer for Thumb */ + + ldr r1, .LC1 /* Start of memory block */ + ldr r3, .LC2 /* End of memory block */ + subs r3, r3, r1 /* Length of block */ + beq .end_clear_loop + mov r2, #0 + +.clear_loop: + strb r2, [r1], #1 + subs r3, r3, #1 + bgt .clear_loop + +.end_clear_loop: + + /* Initialise data. */ + + ldr r1, .LC3 /* Start of memory block */ + ldr r2, .LC4 /* End of memory block */ + ldr r3, .LC5 + subs r3, r3, r1 /* Length of block */ + beq .end_set_loop + +.set_loop: + ldrb r4, [r2], #1 + strb r4, [r1], #1 + subs r3, r3, #1 + bgt .set_loop + +.end_set_loop: + + mov r0, #0 /* no arguments */ + mov r1, #0 /* no argv either */ + + bl main + +endless_loop: + b endless_loop + + + .align 0 + + .LC1: + .word __bss_beg__ + .LC2: + .word __bss_end__ + .LC3: + .word __data_beg__ + .LC4: + .word __data_beg_src__ + .LC5: + .word __data_end__ + .LC6: + .word __stack_end__ + + + /* Setup vector table. Note that undf, pabt, dabt, fiq just execute + a null loop. */ + +.section .startup,"ax" + .code 32 + .align 0 + + b _start /* reset - _start */ + ldr pc, _undf /* undefined - _undf */ + ldr pc, _swi /* SWI - _swi */ + ldr pc, _pabt /* program abort - _pabt */ + ldr pc, _dabt /* data abort - _dabt */ + nop /* reserved */ + ldr pc, [pc,#-0x120] /* IRQ - read the VIC */ + ldr pc, _fiq /* FIQ - _fiq */ + +_undf: .word __undf /* undefined */ +_swi: .word 0x40000008 /* SWI */ +_pabt: .word __pabt /* program abort */ +_dabt: .word __dabt /* data abort */ + .word 0 +_irq: .word 0 +_fiq: .word __fiq /* FIQ */ + +__undf: b . /* undefined */ +__pabt: b . /* program abort */ +__dabt: b . /* data abort */ +__fiq: b . /* FIQ */ diff --git a/Tester/SW/BootLoader/lpc2368bl.ld b/Tester/SW/BootLoader/lpc2368bl.ld new file mode 100644 index 0000000..84929a2 --- /dev/null +++ b/Tester/SW/BootLoader/lpc2368bl.ld @@ -0,0 +1,68 @@ +MEMORY +{ + flash : ORIGIN = 0x00000000, LENGTH = 20K + ramheader : ORIGIN = 0x40000000, LENGTH = 0x60 + ram : ORIGIN = 0x40000060, LENGTH = 32K - 0x60 + usbram : ORIGIN = 0x7FD00000, LENGTH = 8K + ethram : ORIGIN = 0x7FE00000, LENGTH = 16K +} + +__stack_end__ = 0x40000000 + 32K - 4; + +SECTIONS +{ + . = 0; + startup : { *(.startup)} >flash + + prog : + { + *(.text) + *(.rodata) + *(.rodata*) + *(.glue_7) + *(.glue_7t) + } >flash + + __end_of_text__ = .; + + .data : + { + __data_beg__ = .; + __data_beg_src__ = __end_of_text__; + *(.data) + __data_end__ = .; + } >ram AT>flash + + .bss : + { + __bss_beg__ = .; + *(.bss) + __bss_end__ = .; + } >ram + + /* Align here to ensure that the .bss section occupies space up to + _end. Align after .bss to ensure correct alignment even if the + .bss section disappears because there are no input sections. */ + . = ALIGN(32 / 8); + + .usbram (NOLOAD): + { + __usbram_beg__ = .; + *(.dmaram) + __usbram_end__ = .; + } >usbram + + .ethram (NOLOAD): + { + __ethram_beg__ = .; + *(.ethram) + __ethram_end__ = .; + } >ethram +} + . = ALIGN(32 / 8); + _end = .; + /*_bss_end__ = . ; __bss_end__ = . ; */ + __end__ = . ; + PROVIDE (end = .); + + diff --git a/Tester/SW/BootLoader/main.c b/Tester/SW/BootLoader/main.c new file mode 100644 index 0000000..285e5f9 --- /dev/null +++ b/Tester/SW/BootLoader/main.c @@ -0,0 +1,207 @@ +/* + FreeRTOS.org V4.6.1 - Copyright (C) 2003-2007 Richard Barry. + + This file is part of the FreeRTOS.org distribution. + + FreeRTOS.org is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + FreeRTOS.org is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with FreeRTOS.org; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + A special exception to the GPL can be applied should you wish to distribute + a combined work that includes FreeRTOS.org, without being obliged to provide + the source code for any proprietary components. See the licensing section + of http://www.FreeRTOS.org for full details of how and when the exception + can be applied. + + *************************************************************************** + See http://www.FreeRTOS.org for documentation, latest information, license + and contact details. Please ensure to read the configuration and relevant + port sections of the online documentation. + + Also see http://www.SafeRTOS.com a version that has been certified for use + in safety critical systems, plus commercial licensing, development and + support options. + *************************************************************************** +*/ + +/* includes */ +#include "types.h" +#include "sys_config.h" +#include "dio.h" +#include "leds.h" +#include "serial.h" +#include "irq.h" +#include "bus.h" +#include "appimage.h" +#include "LPC23xx.h" +#include "CommListeners.h" +#include "InternalFlash.h" +#include "Watchdog.h" + +/* Constants to setup the PLL. */ +#define mainPLL_ENABLE ( ( UINT32 ) 0x0001 ) +#define mainPLL_CONNECT ( ( ( UINT32 ) 0x0002 ) | mainPLL_ENABLE ) +#define mainPLL_FEED_BYTE1 ( ( UINT32 ) 0xaa ) +#define mainPLL_FEED_BYTE2 ( ( UINT32 ) 0x55 ) +#define mainPLL_LOCK ( ( UINT32 ) 0x4000000 ) +#define mainPLL_CONNECTED ( ( UINT32 ) 0x2000000 ) +#define mainOSC_ENABLE ( ( UINT32 ) 0x20 ) +#define mainOSC_STAT ( ( UINT32 ) 0x40 ) +#define mainOSC_SELECT ( ( UINT32 ) 0x01 ) + +#define SWI_RAM_ADDR 0x40000008 +#define SWI_RAM_FUNC_ADDR 0x40000028 + +/* Constants to setup the MAM. */ +#define mainMAM_TIM_3 ( ( UINT8 ) 0x03 ) +#define mainMAM_MODE_FULL ( ( UINT8 ) 0x02 ) + +/* Configure the hardware as required by the demo. */ +static inline void prvSetVectors(); +static void prvSetupHardware( void ); +static void prvSetupDrivers( void ); +static void cpu_swi_isr( void ); + +BOOLEAN StopFlashing = FALSE; + +/*-----------------------------------------------------------*/ + + +int main( void ) +{ + prvSetVectors(); + prvSetupHardware(); + prvSetupDrivers(); + + ENABLE_INTERRUPTS(); + + ledSet( LED1, 1 ); // Turn both LED's on to indicate Bootcode + ledSet( LED0, 1 ); + + //watchdogEnable( 10000 ); + + if ((appiValidAppImageAvail() == TRUE) && (appiApplicationRequestsUpdate() == FALSE)) + { + // Reset watchdog flag anyway + watchdogCausedReset(); + + ledSet( LED1, 0 ); + ledSet( LED0, 0 ); + + appiJumpToAppImage(); + } + + // Enter program state + initCom1Listener(); + initCom2Listener(); + initBus1Listener(); + initBus2Listener(); + + // for now stay in bootloader to test different things + for (;;) + { + listen2Com1(); + listen2Com2(); + listen2Bus1(); + listen2Bus2(); + + watchdogFeed(); + } +} + + +inline void prvSetVectors() +{ + unsigned int *ptr; + // Set vectors of interrupt, software interupt and fiq + + // Set interrupt vectors + ptr = (unsigned int *)SWI_RAM_ADDR; + *ptr = 0xE59FF018; // This is a ldr pc, [pc,#24] instruction + + // Put SWI, IRQ & FIQ vectors in RAM + ptr = (unsigned int *)SWI_RAM_FUNC_ADDR; + *ptr = (unsigned int)&cpu_swi_isr; +} + + +/*-----------------------------------------------------------*/ + +void prvSetupHardware( void ) +{ + //UINT32 i = 0; + //volatile UINT32 *vect_addr, *vect_prio; + + #ifdef RUN_FROM_RAM + /* Remap the interrupt vectors to RAM if we are are running from RAM. */ + SCB_MEMMAP = 2; + #endif + + /* Disable the PLL. */ + PLLCON = 0; + PLLFEED = mainPLL_FEED_BYTE1; + PLLFEED = mainPLL_FEED_BYTE2; + + /* Configure clock source. */ + SCS |= mainOSC_ENABLE; + while( !( SCS & mainOSC_STAT ) ); + CLKSRCSEL = mainOSC_SELECT; + + /* Setup the PLL to multiply the XTAL input by 4. */ + PLLCFG = ( PLL_MUL | PLL_DIV ); + PLLFEED = mainPLL_FEED_BYTE1; + PLLFEED = mainPLL_FEED_BYTE2; + + /* Turn on and wait for the PLL to lock... */ + PLLCON = mainPLL_ENABLE; + PLLFEED = mainPLL_FEED_BYTE1; + PLLFEED = mainPLL_FEED_BYTE2; + CCLKCFG = CCLK_DIV; + while( !( PLLSTAT & mainPLL_LOCK ) ); + + /* Connecting the clock. */ + PLLCON = mainPLL_CONNECT; + PLLFEED = mainPLL_FEED_BYTE1; + PLLFEED = mainPLL_FEED_BYTE2; + while( !( PLLSTAT & mainPLL_CONNECTED ) ); + + /* Setup and turn on the MAM. Three cycle access is used due to the fast + PLL used. It is possible faster overall performance could be obtained by + tuning the MAM and PLL settings. */ + MAMCR = 0; + MAMTIM = mainMAM_TIM_3; + MAMCR = mainMAM_MODE_FULL; + + init_VIC(); +} + +void prvSetupDrivers( void ) +{ + iflashInit(); + ledInit(); + ledSet( LED1, 1 ); + ledSet( LED0, 1 ); +//for(;;); + + // Open both COM-ports + serInit( COM1, B57600, UART_8N1, UART_FIFO_8); + serInit( COM2, B57600, UART_8N1, UART_FIFO_8); + busInit( BUS1 ); + busInit( BUS2 ); +} + +void cpu_swi_isr() +{ + for (;;); +} + diff --git a/Tester/SW/inc/.project b/Tester/SW/inc/.project new file mode 100644 index 0000000..93b96c3 --- /dev/null +++ b/Tester/SW/inc/.project @@ -0,0 +1,11 @@ + + + inc + + + + + + + + diff --git a/Tester/SW/inc/FreeRTOSConfig.h b/Tester/SW/inc/FreeRTOSConfig.h new file mode 100644 index 0000000..41f2ca5 --- /dev/null +++ b/Tester/SW/inc/FreeRTOSConfig.h @@ -0,0 +1,112 @@ +/* + FreeRTOS V4.6.1 - Copyright (C) 2003-2005 Richard Barry. + + This file is part of the FreeRTOS distribution. + + FreeRTOS is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + FreeRTOS is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with FreeRTOS; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + A special exception to the GPL can be applied should you wish to distribute + a combined work that includes FreeRTOS, without being obliged to provide + the source code for any proprietary components. See the licensing section + of http://www.FreeRTOS.org for full details of how and when the exception + can be applied. + + *************************************************************************** + See http://www.FreeRTOS.org for documentation, latest information, license + and contact details. Please ensure to read the configuration and relevant + port sections of the online documentation. + *************************************************************************** +*/ + +#ifndef FREERTOS_CONFIG_H +#define FREERTOS_CONFIG_H + +#include +#include "lpc23xx.h" +/*----------------------------------------------------------- + * Application specific definitions. + * + * These definitions should be adjusted for your particular hardware and + * application requirements. + * + * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE + * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE. + *----------------------------------------------------------*/ + +#define configPINSEL2_VALUE 0x50151105 + +#define configUSE_PREEMPTION 1 +#define configUSE_IDLE_HOOK 0 +#define configUSE_TICK_HOOK 1 +#define configCPU_CLOCK_HZ ( ( unsigned portLONG ) 48000000 ) /* =12Mhz xtal multiplied by 5 using the PLL. */ +#define configTICK_RATE_HZ ( ( portTickType ) 1000 ) +#define configMAX_PRIORITIES ( ( unsigned portBASE_TYPE ) 4 ) +#define configMINIMAL_STACK_SIZE ( ( unsigned portSHORT ) 104 ) +#define configTOTAL_HEAP_SIZE (( size_t ) ( 14 * 1024 ) ) +#define configMAX_TASK_NAME_LEN ( 20 ) +#define configUSE_TRACE_FACILITY 1 +#define configUSE_16_BIT_TICKS 0 +#define configIDLE_SHOULD_YIELD 1 +#define configUSE_MUTEXES 1 + +/* Co-routine definitions. */ +#define configUSE_CO_ROUTINES 0 +#define configMAX_CO_ROUTINE_PRIORITIES ( 2 ) + + +/* Set the following definitions to 1 to include the API function, or zero +to exclude the API function. */ + +#define INCLUDE_vTaskPrioritySet 1 +#define INCLUDE_uxTaskPriorityGet 1 +#define INCLUDE_vTaskDelete 1 +#define INCLUDE_vTaskCleanUpResources 0 +#define INCLUDE_vTaskSuspend 1 +#define INCLUDE_vTaskDelayUntil 1 +#define INCLUDE_vTaskDelay 1 +#define INCLUDE_xTaskGetCurrentTaskHandle 1 + + +#endif /* FREERTOS_CONFIG_H */ + + +#ifndef sbi +#define sbi(x,y) x|=(1 << (y)) +#endif + +#ifndef cbi +#define cbi(x,y) x&=~(1 << (y)) +#endif + +#ifndef tstb +#define tstb(x,y) (x & (1 << (y)) ? 1 : 0) +#endif + +#ifndef toggle +#define toggle(x,y) x^=(1 << (y)) +#endif + +#ifndef BIT +#define BIT(x) (1 << (x)) + +typedef struct +{ + long xColumn; + char *pcMessage; +} xLCDMessage; + +extern void vApplicationTickHook( void ); + +#endif diff --git a/Tester/SW/inc/LPC23xx.h b/Tester/SW/inc/LPC23xx.h new file mode 100644 index 0000000..71f5a50 --- /dev/null +++ b/Tester/SW/inc/LPC23xx.h @@ -0,0 +1,1376 @@ +/***************************************************************************** + * + * Project : lwIP Web + * Subproject : + * Name : LPC23xx.h + * Function : register definitions + * Designer : K. Sterckx + * Creation date : 22/01/2007 + * Compiler : GNU ARM + * Processor : LPC23xx + * Last update : + * Last updated by : + * History : + * + ***************************************************************************** + * + * Hardware specific macro's and defines + * + ****************************************************************************/ + +#ifndef __LPC23xx_H +#define __LPC23xx_H + +/* For Olimex DemoBoard : PINSET_TESTER = 0 + * For Pinsettings of IO-CTRL REV_C: PINSET_TESTER = 1 + * For QUA_2475_TESTER : PINSET_TESTER = 2 + */ +#define PINSET_TESTER 1 + +/* Vectored Interrupt Controller (VIC) */ +#define VIC_BASE_ADDR 0xFFFFF000 +#define VICIRQStatus (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x000)) +#define VICFIQStatus (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x004)) +#define VICRawIntr (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x008)) +#define VICIntSelect (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x00C)) +#define VICIntEnable (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x010)) +#define VICIntEnClr (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x014)) +#define VICSoftInt (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x018)) +#define VICSoftIntClr (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x01C)) +#define VICProtection (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x020)) +#define VICSWPrioMask (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x024)) + +#define VICVectAddr0 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x100)) +#define VICVectAddr1 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x104)) +#define VICVectAddr2 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x108)) +#define VICVectAddr3 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x10C)) +#define VICVectAddr4 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x110)) +#define VICVectAddr5 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x114)) +#define VICVectAddr6 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x118)) +#define VICVectAddr7 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x11C)) +#define VICVectAddr8 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x120)) +#define VICVectAddr9 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x124)) +#define VICVectAddr10 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x128)) +#define VICVectAddr11 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x12C)) +#define VICVectAddr12 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x130)) +#define VICVectAddr13 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x134)) +#define VICVectAddr14 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x138)) +#define VICVectAddr15 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x13C)) +#define VICVectAddr16 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x140)) +#define VICVectAddr17 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x144)) +#define VICVectAddr18 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x148)) +#define VICVectAddr19 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x14C)) +#define VICVectAddr20 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x150)) +#define VICVectAddr21 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x154)) +#define VICVectAddr22 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x158)) +#define VICVectAddr23 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x15C)) +#define VICVectAddr24 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x160)) +#define VICVectAddr25 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x164)) +#define VICVectAddr26 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x168)) +#define VICVectAddr27 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x16C)) +#define VICVectAddr28 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x170)) +#define VICVectAddr29 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x174)) +#define VICVectAddr30 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x178)) +#define VICVectAddr31 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x17C)) + +/* The name convention below is from previous LPC2000 family MCUs, in LPC230x, +these registers are known as "VICVectPriority(x)". */ +#define VICVectCntl0 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x200)) +#define VICVectCntl1 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x204)) +#define VICVectCntl2 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x208)) +#define VICVectCntl3 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x20C)) +#define VICVectCntl4 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x210)) +#define VICVectCntl5 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x214)) +#define VICVectCntl6 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x218)) +#define VICVectCntl7 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x21C)) +#define VICVectCntl8 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x220)) +#define VICVectCntl9 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x224)) +#define VICVectCntl10 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x228)) +#define VICVectCntl11 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x22C)) +#define VICVectCntl12 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x230)) +#define VICVectCntl13 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x234)) +#define VICVectCntl14 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x238)) +#define VICVectCntl15 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x23C)) +#define VICVectCntl16 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x240)) +#define VICVectCntl17 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x244)) +#define VICVectCntl18 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x248)) +#define VICVectCntl19 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x24C)) +#define VICVectCntl20 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x250)) +#define VICVectCntl21 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x254)) +#define VICVectCntl22 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x258)) +#define VICVectCntl23 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x25C)) +#define VICVectCntl24 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x260)) +#define VICVectCntl25 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x264)) +#define VICVectCntl26 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x268)) +#define VICVectCntl27 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x26C)) +#define VICVectCntl28 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x270)) +#define VICVectCntl29 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x274)) +#define VICVectCntl30 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x278)) +#define VICVectCntl31 (*(volatile unsigned int *)(VIC_BASE_ADDR + 0x27C)) + +// Same as above but required for standard LPC tooling +#define VICVectPriority0 (*(volatile unsigned long *)(VIC_BASE_ADDR + 0x200)) +#define VICVectPriority1 (*(volatile unsigned long *)(VIC_BASE_ADDR + 0x204)) +#define VICVectPriority2 (*(volatile unsigned long *)(VIC_BASE_ADDR + 0x208)) +#define VICVectPriority3 (*(volatile unsigned long *)(VIC_BASE_ADDR + 0x20C)) +#define VICVectPriority4 (*(volatile unsigned long *)(VIC_BASE_ADDR + 0x210)) +#define VICVectPriority5 (*(volatile unsigned long *)(VIC_BASE_ADDR + 0x214)) +#define VICVectPriority6 (*(volatile unsigned long *)(VIC_BASE_ADDR + 0x218)) +#define VICVectPriority7 (*(volatile unsigned long *)(VIC_BASE_ADDR + 0x21C)) +#define VICVectPriority8 (*(volatile unsigned long *)(VIC_BASE_ADDR + 0x220)) +#define VICVectPriority9 (*(volatile unsigned long *)(VIC_BASE_ADDR + 0x224)) +#define VICVectPriority10 (*(volatile unsigned long *)(VIC_BASE_ADDR + 0x228)) +#define VICVectPriority11 (*(volatile unsigned long *)(VIC_BASE_ADDR + 0x22C)) +#define VICVectPriority12 (*(volatile unsigned long *)(VIC_BASE_ADDR + 0x230)) +#define VICVectPriority13 (*(volatile unsigned long *)(VIC_BASE_ADDR + 0x234)) +#define VICVectPriority14 (*(volatile unsigned long *)(VIC_BASE_ADDR + 0x238)) +#define VICVectPriority15 (*(volatile unsigned long *)(VIC_BASE_ADDR + 0x23C)) +#define VICVectPriority16 (*(volatile unsigned long *)(VIC_BASE_ADDR + 0x240)) +#define VICVectPriority17 (*(volatile unsigned long *)(VIC_BASE_ADDR + 0x244)) +#define VICVectPriority18 (*(volatile unsigned long *)(VIC_BASE_ADDR + 0x248)) +#define VICVectPriority19 (*(volatile unsigned long *)(VIC_BASE_ADDR + 0x24C)) +#define VICVectPriority20 (*(volatile unsigned long *)(VIC_BASE_ADDR + 0x250)) +#define VICVectPriority21 (*(volatile unsigned long *)(VIC_BASE_ADDR + 0x254)) +#define VICVectPriority22 (*(volatile unsigned long *)(VIC_BASE_ADDR + 0x258)) +#define VICVectPriority23 (*(volatile unsigned long *)(VIC_BASE_ADDR + 0x25C)) +#define VICVectPriority24 (*(volatile unsigned long *)(VIC_BASE_ADDR + 0x260)) +#define VICVectPriority25 (*(volatile unsigned long *)(VIC_BASE_ADDR + 0x264)) +#define VICVectPriority26 (*(volatile unsigned long *)(VIC_BASE_ADDR + 0x268)) +#define VICVectPriority27 (*(volatile unsigned long *)(VIC_BASE_ADDR + 0x26C)) +#define VICVectPriority28 (*(volatile unsigned long *)(VIC_BASE_ADDR + 0x270)) +#define VICVectPriority29 (*(volatile unsigned long *)(VIC_BASE_ADDR + 0x274)) +#define VICVectPriority30 (*(volatile unsigned long *)(VIC_BASE_ADDR + 0x278)) +#define VICVectPriority31 (*(volatile unsigned long *)(VIC_BASE_ADDR + 0x27C)) + + +#define VICVectAddr (*(volatile unsigned int *)(VIC_BASE_ADDR + 0xF00)) + + +/* Pin Connect Block */ +#define PINSEL_BASE_ADDR 0xE002C000 +#define PINSEL0 (*(volatile unsigned int *)(PINSEL_BASE_ADDR + 0x00)) +#define PINSEL1 (*(volatile unsigned int *)(PINSEL_BASE_ADDR + 0x04)) +#define PINSEL2 (*(volatile unsigned int *)(PINSEL_BASE_ADDR + 0x08)) +#define PINSEL3 (*(volatile unsigned int *)(PINSEL_BASE_ADDR + 0x0C)) +#define PINSEL4 (*(volatile unsigned int *)(PINSEL_BASE_ADDR + 0x10)) +#define PINSEL5 (*(volatile unsigned int *)(PINSEL_BASE_ADDR + 0x14)) +#define PINSEL6 (*(volatile unsigned int *)(PINSEL_BASE_ADDR + 0x18)) +#define PINSEL7 (*(volatile unsigned int *)(PINSEL_BASE_ADDR + 0x1C)) +#define PINSEL8 (*(volatile unsigned int *)(PINSEL_BASE_ADDR + 0x20)) +#define PINSEL9 (*(volatile unsigned int *)(PINSEL_BASE_ADDR + 0x24)) +#define PINSEL10 (*(volatile unsigned int *)(PINSEL_BASE_ADDR + 0x28)) + +#define PINMODE0 (*(volatile unsigned int *)(PINSEL_BASE_ADDR + 0x40)) +#define PINMODE1 (*(volatile unsigned int *)(PINSEL_BASE_ADDR + 0x44)) +#define PINMODE2 (*(volatile unsigned int *)(PINSEL_BASE_ADDR + 0x48)) +#define PINMODE3 (*(volatile unsigned int *)(PINSEL_BASE_ADDR + 0x4C)) +#define PINMODE4 (*(volatile unsigned int *)(PINSEL_BASE_ADDR + 0x50)) +#define PINMODE5 (*(volatile unsigned int *)(PINSEL_BASE_ADDR + 0x54)) +#define PINMODE6 (*(volatile unsigned int *)(PINSEL_BASE_ADDR + 0x58)) +#define PINMODE7 (*(volatile unsigned int *)(PINSEL_BASE_ADDR + 0x5C)) +#define PINMODE8 (*(volatile unsigned int *)(PINSEL_BASE_ADDR + 0x60)) +#define PINMODE9 (*(volatile unsigned int *)(PINSEL_BASE_ADDR + 0x64)) + +/* General Purpose Input/Output (GPIO) */ +#define GPIO_BASE_ADDR 0xE0028000 +#define IOPIN0 (*(volatile unsigned int *)(GPIO_BASE_ADDR + 0x00)) +#define IOSET0 (*(volatile unsigned int *)(GPIO_BASE_ADDR + 0x04)) +#define IODIR0 (*(volatile unsigned int *)(GPIO_BASE_ADDR + 0x08)) +#define IOCLR0 (*(volatile unsigned int *)(GPIO_BASE_ADDR + 0x0C)) +#define IOPIN1 (*(volatile unsigned int *)(GPIO_BASE_ADDR + 0x10)) +#define IOSET1 (*(volatile unsigned int *)(GPIO_BASE_ADDR + 0x14)) +#define IODIR1 (*(volatile unsigned int *)(GPIO_BASE_ADDR + 0x18)) +#define IOCLR1 (*(volatile unsigned int *)(GPIO_BASE_ADDR + 0x1C)) + +/* GPIO Interrupt Registers */ +#define IO0_INT_EN_R (*(volatile unsigned int *)(GPIO_BASE_ADDR + 0x90)) +#define IO0_INT_EN_F (*(volatile unsigned int *)(GPIO_BASE_ADDR + 0x94)) +#define IO0_INT_STAT_R (*(volatile unsigned int *)(GPIO_BASE_ADDR + 0x84)) +#define IO0_INT_STAT_F (*(volatile unsigned int *)(GPIO_BASE_ADDR + 0x88)) +#define IO0_INT_CLR (*(volatile unsigned int *)(GPIO_BASE_ADDR + 0x8C)) + +#define IO2_INT_EN_R (*(volatile unsigned int *)(GPIO_BASE_ADDR + 0xB0)) +#define IO2_INT_EN_F (*(volatile unsigned int *)(GPIO_BASE_ADDR + 0xB4)) +#define IO2_INT_STAT_R (*(volatile unsigned int *)(GPIO_BASE_ADDR + 0xA4)) +#define IO2_INT_STAT_F (*(volatile unsigned int *)(GPIO_BASE_ADDR + 0xA8)) +#define IO2_INT_CLR (*(volatile unsigned int *)(GPIO_BASE_ADDR + 0xAC)) + +#define IO_INT_STAT (*(volatile unsigned int *)(GPIO_BASE_ADDR + 0x80)) + +#define PARTCFG_BASE_ADDR 0x3FFF8000 +#define PARTCFG (*(volatile unsigned int *)(PARTCFG_BASE_ADDR + 0x00)) + +/* Fast I/O setup */ +#define FIO_BASE_ADDR 0x3FFFC000 +#define FIO0DIR (*(volatile unsigned int *)(FIO_BASE_ADDR + 0x00)) +#define FIO0MASK (*(volatile unsigned int *)(FIO_BASE_ADDR + 0x10)) +#define FIO0PIN (*(volatile unsigned int *)(FIO_BASE_ADDR + 0x14)) +#define FIO0SET (*(volatile unsigned int *)(FIO_BASE_ADDR + 0x18)) +#define FIO0CLR (*(volatile unsigned int *)(FIO_BASE_ADDR + 0x1C)) + +#define FIO1DIR (*(volatile unsigned int *)(FIO_BASE_ADDR + 0x20)) +#define FIO1MASK (*(volatile unsigned int *)(FIO_BASE_ADDR + 0x30)) +#define FIO1PIN (*(volatile unsigned int *)(FIO_BASE_ADDR + 0x34)) +#define FIO1SET (*(volatile unsigned int *)(FIO_BASE_ADDR + 0x38)) +#define FIO1CLR (*(volatile unsigned int *)(FIO_BASE_ADDR + 0x3C)) + +#define FIO2DIR (*(volatile unsigned int *)(FIO_BASE_ADDR + 0x40)) +#define FIO2MASK (*(volatile unsigned int *)(FIO_BASE_ADDR + 0x50)) +#define FIO2PIN (*(volatile unsigned int *)(FIO_BASE_ADDR + 0x54)) +#define FIO2SET (*(volatile unsigned int *)(FIO_BASE_ADDR + 0x58)) +#define FIO2CLR (*(volatile unsigned int *)(FIO_BASE_ADDR + 0x5C)) + +#define FIO3DIR (*(volatile unsigned int *)(FIO_BASE_ADDR + 0x60)) +#define FIO3MASK (*(volatile unsigned int *)(FIO_BASE_ADDR + 0x70)) +#define FIO3PIN (*(volatile unsigned int *)(FIO_BASE_ADDR + 0x74)) +#define FIO3SET (*(volatile unsigned int *)(FIO_BASE_ADDR + 0x78)) +#define FIO3CLR (*(volatile unsigned int *)(FIO_BASE_ADDR + 0x7C)) + +#define FIO4DIR (*(volatile unsigned int *)(FIO_BASE_ADDR + 0x80)) +#define FIO4MASK (*(volatile unsigned int *)(FIO_BASE_ADDR + 0x90)) +#define FIO4PIN (*(volatile unsigned int *)(FIO_BASE_ADDR + 0x94)) +#define FIO4SET (*(volatile unsigned int *)(FIO_BASE_ADDR + 0x98)) +#define FIO4CLR (*(volatile unsigned int *)(FIO_BASE_ADDR + 0x9C)) + +/* FIOs can be accessed through WORD, HALF-WORD or BYTE. */ +#define FIO0DIR0 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x01)) +#define FIO1DIR0 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x21)) +#define FIO2DIR0 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x41)) +#define FIO3DIR0 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x61)) +#define FIO4DIR0 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x81)) + +#define FIO0DIR1 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x02)) +#define FIO1DIR1 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x22)) +#define FIO2DIR1 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x42)) +#define FIO3DIR1 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x62)) +#define FIO4DIR1 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x82)) + +#define FIO0DIR2 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x03)) +#define FIO1DIR2 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x23)) +#define FIO2DIR2 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x43)) +#define FIO3DIR2 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x63)) +#define FIO4DIR2 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x83)) + +#define FIO0DIR3 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x04)) +#define FIO1DIR3 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x24)) +#define FIO2DIR3 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x44)) +#define FIO3DIR3 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x64)) +#define FIO4DIR3 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x84)) + +#define FIO0DIRL (*(volatile unsigned short *)(FIO_BASE_ADDR + 0x00)) +#define FIO1DIRL (*(volatile unsigned short *)(FIO_BASE_ADDR + 0x20)) +#define FIO2DIRL (*(volatile unsigned short *)(FIO_BASE_ADDR + 0x40)) +#define FIO3DIRL (*(volatile unsigned short *)(FIO_BASE_ADDR + 0x60)) +#define FIO4DIRL (*(volatile unsigned short *)(FIO_BASE_ADDR + 0x80)) + +#define FIO0DIRU (*(volatile unsigned short *)(FIO_BASE_ADDR + 0x02)) +#define FIO1DIRU (*(volatile unsigned short *)(FIO_BASE_ADDR + 0x22)) +#define FIO2DIRU (*(volatile unsigned short *)(FIO_BASE_ADDR + 0x42)) +#define FIO3DIRU (*(volatile unsigned short *)(FIO_BASE_ADDR + 0x62)) +#define FIO4DIRU (*(volatile unsigned short *)(FIO_BASE_ADDR + 0x82)) + +#define FIO0MASK0 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x10)) +#define FIO1MASK0 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x30)) +#define FIO2MASK0 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x50)) +#define FIO3MASK0 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x70)) +#define FIO4MASK0 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x90)) + +#define FIO0MASK1 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x11)) +#define FIO1MASK1 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x21)) +#define FIO2MASK1 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x51)) +#define FIO3MASK1 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x71)) +#define FIO4MASK1 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x91)) + +#define FIO0MASK2 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x12)) +#define FIO1MASK2 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x32)) +#define FIO2MASK2 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x52)) +#define FIO3MASK2 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x72)) +#define FIO4MASK2 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x92)) + +#define FIO0MASK3 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x13)) +#define FIO1MASK3 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x33)) +#define FIO2MASK3 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x53)) +#define FIO3MASK3 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x73)) +#define FIO4MASK3 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x93)) + +#define FIO0MASKL (*(volatile unsigned short *)(FIO_BASE_ADDR + 0x10)) +#define FIO1MASKL (*(volatile unsigned short *)(FIO_BASE_ADDR + 0x30)) +#define FIO2MASKL (*(volatile unsigned short *)(FIO_BASE_ADDR + 0x50)) +#define FIO3MASKL (*(volatile unsigned short *)(FIO_BASE_ADDR + 0x70)) +#define FIO4MASKL (*(volatile unsigned short *)(FIO_BASE_ADDR + 0x90)) + +#define FIO0MASKU (*(volatile unsigned short *)(FIO_BASE_ADDR + 0x12)) +#define FIO1MASKU (*(volatile unsigned short *)(FIO_BASE_ADDR + 0x32)) +#define FIO2MASKU (*(volatile unsigned short *)(FIO_BASE_ADDR + 0x52)) +#define FIO3MASKU (*(volatile unsigned short *)(FIO_BASE_ADDR + 0x72)) +#define FIO4MASKU (*(volatile unsigned short *)(FIO_BASE_ADDR + 0x92)) + +#define FIO0PIN0 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x14)) +#define FIO1PIN0 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x34)) +#define FIO2PIN0 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x54)) +#define FIO3PIN0 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x74)) +#define FIO4PIN0 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x94)) + +#define FIO0PIN1 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x15)) +#define FIO1PIN1 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x25)) +#define FIO2PIN1 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x55)) +#define FIO3PIN1 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x75)) +#define FIO4PIN1 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x95)) + +#define FIO0PIN2 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x16)) +#define FIO1PIN2 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x36)) +#define FIO2PIN2 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x56)) +#define FIO3PIN2 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x76)) +#define FIO4PIN2 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x96)) + +#define FIO0PIN3 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x17)) +#define FIO1PIN3 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x37)) +#define FIO2PIN3 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x57)) +#define FIO3PIN3 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x77)) +#define FIO4PIN3 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x97)) + +#define FIO0PINL (*(volatile unsigned short *)(FIO_BASE_ADDR + 0x14)) +#define FIO1PINL (*(volatile unsigned short *)(FIO_BASE_ADDR + 0x34)) +#define FIO2PINL (*(volatile unsigned short *)(FIO_BASE_ADDR + 0x54)) +#define FIO3PINL (*(volatile unsigned short *)(FIO_BASE_ADDR + 0x74)) +#define FIO4PINL (*(volatile unsigned short *)(FIO_BASE_ADDR + 0x94)) + +#define FIO0PINU (*(volatile unsigned short *)(FIO_BASE_ADDR + 0x16)) +#define FIO1PINU (*(volatile unsigned short *)(FIO_BASE_ADDR + 0x36)) +#define FIO2PINU (*(volatile unsigned short *)(FIO_BASE_ADDR + 0x56)) +#define FIO3PINU (*(volatile unsigned short *)(FIO_BASE_ADDR + 0x76)) +#define FIO4PINU (*(volatile unsigned short *)(FIO_BASE_ADDR + 0x96)) + +#define FIO0SET0 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x18)) +#define FIO1SET0 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x38)) +#define FIO2SET0 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x58)) +#define FIO3SET0 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x78)) +#define FIO4SET0 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x98)) + +#define FIO0SET1 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x19)) +#define FIO1SET1 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x29)) +#define FIO2SET1 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x59)) +#define FIO3SET1 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x79)) +#define FIO4SET1 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x99)) + +#define FIO0SET2 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x1A)) +#define FIO1SET2 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x3A)) +#define FIO2SET2 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x5A)) +#define FIO3SET2 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x7A)) +#define FIO4SET2 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x9A)) + +#define FIO0SET3 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x1B)) +#define FIO1SET3 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x3B)) +#define FIO2SET3 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x5B)) +#define FIO3SET3 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x7B)) +#define FIO4SET3 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x9B)) + +#define FIO0SETL (*(volatile unsigned short *)(FIO_BASE_ADDR + 0x18)) +#define FIO1SETL (*(volatile unsigned short *)(FIO_BASE_ADDR + 0x38)) +#define FIO2SETL (*(volatile unsigned short *)(FIO_BASE_ADDR + 0x58)) +#define FIO3SETL (*(volatile unsigned short *)(FIO_BASE_ADDR + 0x78)) +#define FIO4SETL (*(volatile unsigned short *)(FIO_BASE_ADDR + 0x98)) + +#define FIO0SETU (*(volatile unsigned short *)(FIO_BASE_ADDR + 0x1A)) +#define FIO1SETU (*(volatile unsigned short *)(FIO_BASE_ADDR + 0x3A)) +#define FIO2SETU (*(volatile unsigned short *)(FIO_BASE_ADDR + 0x5A)) +#define FIO3SETU (*(volatile unsigned short *)(FIO_BASE_ADDR + 0x7A)) +#define FIO4SETU (*(volatile unsigned short *)(FIO_BASE_ADDR + 0x9A)) + +#define FIO0CLR0 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x1C)) +#define FIO1CLR0 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x3C)) +#define FIO2CLR0 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x5C)) +#define FIO3CLR0 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x7C)) +#define FIO4CLR0 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x9C)) + +#define FIO0CLR1 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x1D)) +#define FIO1CLR1 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x2D)) +#define FIO2CLR1 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x5D)) +#define FIO3CLR1 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x7D)) +#define FIO4CLR1 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x9D)) + +#define FIO0CLR2 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x1E)) +#define FIO1CLR2 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x3E)) +#define FIO2CLR2 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x5E)) +#define FIO3CLR2 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x7E)) +#define FIO4CLR2 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x9E)) + +#define FIO0CLR3 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x1F)) +#define FIO1CLR3 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x3F)) +#define FIO2CLR3 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x5F)) +#define FIO3CLR3 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x7F)) +#define FIO4CLR3 (*(volatile unsigned char *)(FIO_BASE_ADDR + 0x9F)) + +#define FIO0CLRL (*(volatile unsigned short *)(FIO_BASE_ADDR + 0x1C)) +#define FIO1CLRL (*(volatile unsigned short *)(FIO_BASE_ADDR + 0x3C)) +#define FIO2CLRL (*(volatile unsigned short *)(FIO_BASE_ADDR + 0x5C)) +#define FIO3CLRL (*(volatile unsigned short *)(FIO_BASE_ADDR + 0x7C)) +#define FIO4CLRL (*(volatile unsigned short *)(FIO_BASE_ADDR + 0x9C)) + +#define FIO0CLRU (*(volatile unsigned short *)(FIO_BASE_ADDR + 0x1E)) +#define FIO1CLRU (*(volatile unsigned short *)(FIO_BASE_ADDR + 0x3E)) +#define FIO2CLRU (*(volatile unsigned short *)(FIO_BASE_ADDR + 0x5E)) +#define FIO3CLRU (*(volatile unsigned short *)(FIO_BASE_ADDR + 0x7E)) +#define FIO4CLRU (*(volatile unsigned short *)(FIO_BASE_ADDR + 0x9E)) + + +/* System Control Block(SCB) modules include Memory Accelerator Module, +Phase Locked Loop, VPB divider, Power Control, External Interrupt, +Reset, and Code Security/Debugging */ +#define SCB_BASE_ADDR 0xE01FC000 + +/* Memory Accelerator Module (MAM) */ +#define MAMCR (*(volatile unsigned int *)(SCB_BASE_ADDR + 0x000)) +#define MAMTIM (*(volatile unsigned int *)(SCB_BASE_ADDR + 0x004)) +#define MEMMAP (*(volatile unsigned int *)(SCB_BASE_ADDR + 0x040)) + +/* Phase Locked Loop (PLL) */ +#define PLLCON (*(volatile unsigned int *)(SCB_BASE_ADDR + 0x080)) +#define PLLCFG (*(volatile unsigned int *)(SCB_BASE_ADDR + 0x084)) +#define PLLSTAT (*(volatile unsigned int *)(SCB_BASE_ADDR + 0x088)) +#define PLLFEED (*(volatile unsigned int *)(SCB_BASE_ADDR + 0x08C)) + +/* Power Control */ +#define PCON (*(volatile unsigned int *)(SCB_BASE_ADDR + 0x0C0)) +#define PCONP (*(volatile unsigned int *)(SCB_BASE_ADDR + 0x0C4)) + +/* Clock Divider */ +#define APBDIV (*(volatile unsigned int *)(SCB_BASE_ADDR + 0x100)) +#define CCLKCFG (*(volatile unsigned int *)(SCB_BASE_ADDR + 0x104)) +#define USBCLKCFG (*(volatile unsigned int *)(SCB_BASE_ADDR + 0x108)) +#define CLKSRCSEL (*(volatile unsigned int *)(SCB_BASE_ADDR + 0x10C)) +#define PCLKSEL0 (*(volatile unsigned int *)(SCB_BASE_ADDR + 0x1A8)) +#define PCLKSEL1 (*(volatile unsigned int *)(SCB_BASE_ADDR + 0x1AC)) + +/* External Interrupts */ +#define EXTINT (*(volatile unsigned int *)(SCB_BASE_ADDR + 0x140)) +#define INTWAKE (*(volatile unsigned int *)(SCB_BASE_ADDR + 0x144)) +#define EXTMODE (*(volatile unsigned int *)(SCB_BASE_ADDR + 0x148)) +#define EXTPOLAR (*(volatile unsigned int *)(SCB_BASE_ADDR + 0x14C)) + +/* Reset, reset source identification */ +#define RSIR (*(volatile unsigned int *)(SCB_BASE_ADDR + 0x180)) + +/* RSID, code security protection */ +#define CSPR (*(volatile unsigned int *)(SCB_BASE_ADDR + 0x184)) + +/* AHB configuration */ +#define AHBCFG1 (*(volatile unsigned int *)(SCB_BASE_ADDR + 0x188)) +#define AHBCFG2 (*(volatile unsigned int *)(SCB_BASE_ADDR + 0x18C)) + +/* System Controls and Status */ +#define SCS (*(volatile unsigned int *)(SCB_BASE_ADDR + 0x1A0)) + +/*MPMC(EMC) registers*/ +#define STATIC_MEM0_BASE 0x80000000 +#define STATIC_MEM1_BASE 0x81000000 +#define STATIC_MEM2_BASE 0x82000000 +#define STATIC_MEM3_BASE 0x83000000 + +#define DYNAMIC_MEM0_BASE 0xA0000000 +#define DYNAMIC_MEM1_BASE 0xB0000000 +#define DYNAMIC_MEM2_BASE 0xC0000000 +#define DYNAMIC_MEM3_BASE 0xD0000000 + +/* External Memory Controller (EMC) */ +#define EMC_BASE_ADDR 0xFFE08000 +#define EMC_CTRL (*(volatile unsigned int *)(EMC_BASE_ADDR + 0x000)) +#define EMC_STAT (*(volatile unsigned int *)(EMC_BASE_ADDR + 0x004)) +#define EMC_CONFIG (*(volatile unsigned int *)(EMC_BASE_ADDR + 0x008)) + +/* Dynamic RAM access registers */ +#define EMC_DYN_CTRL (*(volatile unsigned int *)(EMC_BASE_ADDR + 0x020)) +#define EMC_DYN_RFSH (*(volatile unsigned int *)(EMC_BASE_ADDR + 0x024)) +#define EMC_DYN_RD_CFG (*(volatile unsigned int *)(EMC_BASE_ADDR + 0x028)) +#define EMC_DYN_RP (*(volatile unsigned int *)(EMC_BASE_ADDR + 0x030)) +#define EMC_DYN_RAS (*(volatile unsigned int *)(EMC_BASE_ADDR + 0x034)) +#define EMC_DYN_SREX (*(volatile unsigned int *)(EMC_BASE_ADDR + 0x038)) +#define EMC_DYN_APR (*(volatile unsigned int *)(EMC_BASE_ADDR + 0x03C)) +#define EMC_DYN_DAL (*(volatile unsigned int *)(EMC_BASE_ADDR + 0x040)) +#define EMC_DYN_WR (*(volatile unsigned int *)(EMC_BASE_ADDR + 0x044)) +#define EMC_DYN_RC (*(volatile unsigned int *)(EMC_BASE_ADDR + 0x048)) +#define EMC_DYN_RFC (*(volatile unsigned int *)(EMC_BASE_ADDR + 0x04C)) +#define EMC_DYN_XSR (*(volatile unsigned int *)(EMC_BASE_ADDR + 0x050)) +#define EMC_DYN_RRD (*(volatile unsigned int *)(EMC_BASE_ADDR + 0x054)) +#define EMC_DYN_MRD (*(volatile unsigned int *)(EMC_BASE_ADDR + 0x058)) + +#define EMC_DYN_CFG0 (*(volatile unsigned int *)(EMC_BASE_ADDR + 0x100)) +#define EMC_DYN_RASCAS0 (*(volatile unsigned int *)(EMC_BASE_ADDR + 0x104)) +#define EMC_DYN_CFG1 (*(volatile unsigned int *)(EMC_BASE_ADDR + 0x140)) +#define EMC_DYN_RASCAS1 (*(volatile unsigned int *)(EMC_BASE_ADDR + 0x144)) +#define EMC_DYN_CFG2 (*(volatile unsigned int *)(EMC_BASE_ADDR + 0x160)) +#define EMC_DYN_RASCAS2 (*(volatile unsigned int *)(EMC_BASE_ADDR + 0x164)) +#define EMC_DYN_CFG3 (*(volatile unsigned int *)(EMC_BASE_ADDR + 0x180)) +#define EMC_DYN_RASCAS3 (*(volatile unsigned int *)(EMC_BASE_ADDR + 0x184)) + +/* static RAM access registers */ +#define EMC_STA_CFG0 (*(volatile unsigned int *)(EMC_BASE_ADDR + 0x200)) +#define EMC_STA_WAITWEN0 (*(volatile unsigned int *)(EMC_BASE_ADDR + 0x204)) +#define EMC_STA_WAITOEN0 (*(volatile unsigned int *)(EMC_BASE_ADDR + 0x208)) +#define EMC_STA_WAITRD0 (*(volatile unsigned int *)(EMC_BASE_ADDR + 0x20C)) +#define EMC_STA_WAITPAGE0 (*(volatile unsigned int *)(EMC_BASE_ADDR + 0x210)) +#define EMC_STA_WAITWR0 (*(volatile unsigned int *)(EMC_BASE_ADDR + 0x214)) +#define EMC_STA_WAITTURN0 (*(volatile unsigned int *)(EMC_BASE_ADDR + 0x218)) + +#define EMC_STA_CFG1 (*(volatile unsigned int *)(EMC_BASE_ADDR + 0x220)) +#define EMC_STA_WAITWEN1 (*(volatile unsigned int *)(EMC_BASE_ADDR + 0x224)) +#define EMC_STA_WAITOEN1 (*(volatile unsigned int *)(EMC_BASE_ADDR + 0x228)) +#define EMC_STA_WAITRD1 (*(volatile unsigned int *)(EMC_BASE_ADDR + 0x22C)) +#define EMC_STA_WAITPAGE1 (*(volatile unsigned int *)(EMC_BASE_ADDR + 0x230)) +#define EMC_STA_WAITWR1 (*(volatile unsigned int *)(EMC_BASE_ADDR + 0x234)) +#define EMC_STA_WAITTURN1 (*(volatile unsigned int *)(EMC_BASE_ADDR + 0x238)) + +#define EMC_STA_CFG2 (*(volatile unsigned int *)(EMC_BASE_ADDR + 0x240)) +#define EMC_STA_WAITWEN2 (*(volatile unsigned int *)(EMC_BASE_ADDR + 0x244)) +#define EMC_STA_WAITOEN2 (*(volatile unsigned int *)(EMC_BASE_ADDR + 0x248)) +#define EMC_STA_WAITRD2 (*(volatile unsigned int *)(EMC_BASE_ADDR + 0x24C)) +#define EMC_STA_WAITPAGE2 (*(volatile unsigned int *)(EMC_BASE_ADDR + 0x250)) +#define EMC_STA_WAITWR2 (*(volatile unsigned int *)(EMC_BASE_ADDR + 0x254)) +#define EMC_STA_WAITTURN2 (*(volatile unsigned int *)(EMC_BASE_ADDR + 0x258)) + +#define EMC_STA_CFG3 (*(volatile unsigned int *)(EMC_BASE_ADDR + 0x260)) +#define EMC_STA_WAITWEN3 (*(volatile unsigned int *)(EMC_BASE_ADDR + 0x264)) +#define EMC_STA_WAITOEN3 (*(volatile unsigned int *)(EMC_BASE_ADDR + 0x268)) +#define EMC_STA_WAITRD3 (*(volatile unsigned int *)(EMC_BASE_ADDR + 0x26C)) +#define EMC_STA_WAITPAGE3 (*(volatile unsigned int *)(EMC_BASE_ADDR + 0x270)) +#define EMC_STA_WAITWR3 (*(volatile unsigned int *)(EMC_BASE_ADDR + 0x274)) +#define EMC_STA_WAITTURN3 (*(volatile unsigned int *)(EMC_BASE_ADDR + 0x278)) + +#define EMC_STA_EXT_WAIT (*(volatile unsigned int *)(EMC_BASE_ADDR + 0x880)) + + +/* Timer 0 */ +#define TMR0_BASE_ADDR 0xE0004000 +#define T0IR (*(volatile unsigned int *)(TMR0_BASE_ADDR + 0x00)) +#define T0TCR (*(volatile unsigned int *)(TMR0_BASE_ADDR + 0x04)) +#define T0TC (*(volatile unsigned int *)(TMR0_BASE_ADDR + 0x08)) +#define T0PR (*(volatile unsigned int *)(TMR0_BASE_ADDR + 0x0C)) +#define T0PC (*(volatile unsigned int *)(TMR0_BASE_ADDR + 0x10)) +#define T0MCR (*(volatile unsigned int *)(TMR0_BASE_ADDR + 0x14)) +#define T0MR0 (*(volatile unsigned int *)(TMR0_BASE_ADDR + 0x18)) +#define T0MR1 (*(volatile unsigned int *)(TMR0_BASE_ADDR + 0x1C)) +#define T0MR2 (*(volatile unsigned int *)(TMR0_BASE_ADDR + 0x20)) +#define T0MR3 (*(volatile unsigned int *)(TMR0_BASE_ADDR + 0x24)) +#define T0CCR (*(volatile unsigned int *)(TMR0_BASE_ADDR + 0x28)) +#define T0CR0 (*(volatile unsigned int *)(TMR0_BASE_ADDR + 0x2C)) +#define T0CR1 (*(volatile unsigned int *)(TMR0_BASE_ADDR + 0x30)) +#define T0CR2 (*(volatile unsigned int *)(TMR0_BASE_ADDR + 0x34)) +#define T0CR3 (*(volatile unsigned int *)(TMR0_BASE_ADDR + 0x38)) +#define T0EMR (*(volatile unsigned int *)(TMR0_BASE_ADDR + 0x3C)) +#define T0CTCR (*(volatile unsigned int *)(TMR0_BASE_ADDR + 0x70)) + +/* Timer 1 */ +#define TMR1_BASE_ADDR 0xE0008000 +#define T1IR (*(volatile unsigned int *)(TMR1_BASE_ADDR + 0x00)) +#define T1TCR (*(volatile unsigned int *)(TMR1_BASE_ADDR + 0x04)) +#define T1TC (*(volatile unsigned int *)(TMR1_BASE_ADDR + 0x08)) +#define T1PR (*(volatile unsigned int *)(TMR1_BASE_ADDR + 0x0C)) +#define T1PC (*(volatile unsigned int *)(TMR1_BASE_ADDR + 0x10)) +#define T1MCR (*(volatile unsigned int *)(TMR1_BASE_ADDR + 0x14)) +#define T1MR0 (*(volatile unsigned int *)(TMR1_BASE_ADDR + 0x18)) +#define T1MR1 (*(volatile unsigned int *)(TMR1_BASE_ADDR + 0x1C)) +#define T1MR2 (*(volatile unsigned int *)(TMR1_BASE_ADDR + 0x20)) +#define T1MR3 (*(volatile unsigned int *)(TMR1_BASE_ADDR + 0x24)) +#define T1CCR (*(volatile unsigned int *)(TMR1_BASE_ADDR + 0x28)) +#define T1CR0 (*(volatile unsigned int *)(TMR1_BASE_ADDR + 0x2C)) +#define T1CR1 (*(volatile unsigned int *)(TMR1_BASE_ADDR + 0x30)) +#define T1CR2 (*(volatile unsigned int *)(TMR1_BASE_ADDR + 0x34)) +#define T1CR3 (*(volatile unsigned int *)(TMR1_BASE_ADDR + 0x38)) +#define T1EMR (*(volatile unsigned int *)(TMR1_BASE_ADDR + 0x3C)) +#define T1CTCR (*(volatile unsigned int *)(TMR1_BASE_ADDR + 0x70)) + +/* Timer 2 */ +#define TMR2_BASE_ADDR 0xE0070000 +#define T2IR (*(volatile unsigned int *)(TMR2_BASE_ADDR + 0x00)) +#define T2TCR (*(volatile unsigned int *)(TMR2_BASE_ADDR + 0x04)) +#define T2TC (*(volatile unsigned int *)(TMR2_BASE_ADDR + 0x08)) +#define T2PR (*(volatile unsigned int *)(TMR2_BASE_ADDR + 0x0C)) +#define T2PC (*(volatile unsigned int *)(TMR2_BASE_ADDR + 0x10)) +#define T2MCR (*(volatile unsigned int *)(TMR2_BASE_ADDR + 0x14)) +#define T2MR0 (*(volatile unsigned int *)(TMR2_BASE_ADDR + 0x18)) +#define T2MR1 (*(volatile unsigned int *)(TMR2_BASE_ADDR + 0x1C)) +#define T2MR2 (*(volatile unsigned int *)(TMR2_BASE_ADDR + 0x20)) +#define T2MR3 (*(volatile unsigned int *)(TMR2_BASE_ADDR + 0x24)) +#define T2CCR (*(volatile unsigned int *)(TMR2_BASE_ADDR + 0x28)) +#define T2CR0 (*(volatile unsigned int *)(TMR2_BASE_ADDR + 0x2C)) +#define T2CR1 (*(volatile unsigned int *)(TMR2_BASE_ADDR + 0x30)) +#define T2CR2 (*(volatile unsigned int *)(TMR2_BASE_ADDR + 0x34)) +#define T2CR3 (*(volatile unsigned int *)(TMR2_BASE_ADDR + 0x38)) +#define T2EMR (*(volatile unsigned int *)(TMR2_BASE_ADDR + 0x3C)) +#define T2CTCR (*(volatile unsigned int *)(TMR2_BASE_ADDR + 0x70)) + +/* Timer 3 */ +#define TMR3_BASE_ADDR 0xE0074000 +#define T3IR (*(volatile unsigned int *)(TMR3_BASE_ADDR + 0x00)) +#define T3TCR (*(volatile unsigned int *)(TMR3_BASE_ADDR + 0x04)) +#define T3TC (*(volatile unsigned int *)(TMR3_BASE_ADDR + 0x08)) +#define T3PR (*(volatile unsigned int *)(TMR3_BASE_ADDR + 0x0C)) +#define T3PC (*(volatile unsigned int *)(TMR3_BASE_ADDR + 0x10)) +#define T3MCR (*(volatile unsigned int *)(TMR3_BASE_ADDR + 0x14)) +#define T3MR0 (*(volatile unsigned int *)(TMR3_BASE_ADDR + 0x18)) +#define T3MR1 (*(volatile unsigned int *)(TMR3_BASE_ADDR + 0x1C)) +#define T3MR2 (*(volatile unsigned int *)(TMR3_BASE_ADDR + 0x20)) +#define T3MR3 (*(volatile unsigned int *)(TMR3_BASE_ADDR + 0x24)) +#define T3CCR (*(volatile unsigned int *)(TMR3_BASE_ADDR + 0x28)) +#define T3CR0 (*(volatile unsigned int *)(TMR3_BASE_ADDR + 0x2C)) +#define T3CR1 (*(volatile unsigned int *)(TMR3_BASE_ADDR + 0x30)) +#define T3CR2 (*(volatile unsigned int *)(TMR3_BASE_ADDR + 0x34)) +#define T3CR3 (*(volatile unsigned int *)(TMR3_BASE_ADDR + 0x38)) +#define T3EMR (*(volatile unsigned int *)(TMR3_BASE_ADDR + 0x3C)) +#define T3CTCR (*(volatile unsigned int *)(TMR3_BASE_ADDR + 0x70)) + + +/* Pulse Width Modulator (PWM) */ +#define PWM0_BASE_ADDR 0xE0014000 +#define PWM0IR (*(volatile unsigned int *)(PWM0_BASE_ADDR + 0x00)) +#define PWM0TCR (*(volatile unsigned int *)(PWM0_BASE_ADDR + 0x04)) +#define PWM0TC (*(volatile unsigned int *)(PWM0_BASE_ADDR + 0x08)) +#define PWM0PR (*(volatile unsigned int *)(PWM0_BASE_ADDR + 0x0C)) +#define PWM0PC (*(volatile unsigned int *)(PWM0_BASE_ADDR + 0x10)) +#define PWM0MCR (*(volatile unsigned int *)(PWM0_BASE_ADDR + 0x14)) +#define PWM0MR0 (*(volatile unsigned int *)(PWM0_BASE_ADDR + 0x18)) +#define PWM0MR1 (*(volatile unsigned int *)(PWM0_BASE_ADDR + 0x1C)) +#define PWM0MR2 (*(volatile unsigned int *)(PWM0_BASE_ADDR + 0x20)) +#define PWM0MR3 (*(volatile unsigned int *)(PWM0_BASE_ADDR + 0x24)) +#define PWM0CCR (*(volatile unsigned int *)(PWM0_BASE_ADDR + 0x28)) +#define PWM0CR0 (*(volatile unsigned int *)(PWM0_BASE_ADDR + 0x2C)) +#define PWM0CR1 (*(volatile unsigned int *)(PWM0_BASE_ADDR + 0x30)) +#define PWM0CR2 (*(volatile unsigned int *)(PWM0_BASE_ADDR + 0x34)) +#define PWM0CR3 (*(volatile unsigned int *)(PWM0_BASE_ADDR + 0x38)) +#define PWM0EMR (*(volatile unsigned int *)(PWM0_BASE_ADDR + 0x3C)) +#define PWM0MR4 (*(volatile unsigned int *)(PWM0_BASE_ADDR + 0x40)) +#define PWM0MR5 (*(volatile unsigned int *)(PWM0_BASE_ADDR + 0x44)) +#define PWM0MR6 (*(volatile unsigned int *)(PWM0_BASE_ADDR + 0x48)) +#define PWM0PCR (*(volatile unsigned int *)(PWM0_BASE_ADDR + 0x4C)) +#define PWM0LER (*(volatile unsigned int *)(PWM0_BASE_ADDR + 0x50)) +#define PWM0CTCR (*(volatile unsigned int *)(PWM0_BASE_ADDR + 0x70)) + +#define PWM1_BASE_ADDR 0xE0018000 +#define PWM1IR (*(volatile unsigned int *)(PWM1_BASE_ADDR + 0x00)) +#define PWM1TCR (*(volatile unsigned int *)(PWM1_BASE_ADDR + 0x04)) +#define PWM1TC (*(volatile unsigned int *)(PWM1_BASE_ADDR + 0x08)) +#define PWM1PR (*(volatile unsigned int *)(PWM1_BASE_ADDR + 0x0C)) +#define PWM1PC (*(volatile unsigned int *)(PWM1_BASE_ADDR + 0x10)) +#define PWM1MCR (*(volatile unsigned int *)(PWM1_BASE_ADDR + 0x14)) +#define PWM1MR0 (*(volatile unsigned int *)(PWM1_BASE_ADDR + 0x18)) +#define PWM1MR1 (*(volatile unsigned int *)(PWM1_BASE_ADDR + 0x1C)) +#define PWM1MR2 (*(volatile unsigned int *)(PWM1_BASE_ADDR + 0x20)) +#define PWM1MR3 (*(volatile unsigned int *)(PWM1_BASE_ADDR + 0x24)) +#define PWM1CCR (*(volatile unsigned int *)(PWM1_BASE_ADDR + 0x28)) +#define PWM1CR0 (*(volatile unsigned int *)(PWM1_BASE_ADDR + 0x2C)) +#define PWM1CR1 (*(volatile unsigned int *)(PWM1_BASE_ADDR + 0x30)) +#define PWM1CR2 (*(volatile unsigned int *)(PWM1_BASE_ADDR + 0x34)) +#define PWM1CR3 (*(volatile unsigned int *)(PWM1_BASE_ADDR + 0x38)) +#define PWM1EMR (*(volatile unsigned int *)(PWM1_BASE_ADDR + 0x3C)) +#define PWM1MR4 (*(volatile unsigned int *)(PWM1_BASE_ADDR + 0x40)) +#define PWM1MR5 (*(volatile unsigned int *)(PWM1_BASE_ADDR + 0x44)) +#define PWM1MR6 (*(volatile unsigned int *)(PWM1_BASE_ADDR + 0x48)) +#define PWM1PCR (*(volatile unsigned int *)(PWM1_BASE_ADDR + 0x4C)) +#define PWM1LER (*(volatile unsigned int *)(PWM1_BASE_ADDR + 0x50)) +#define PWM1CTCR (*(volatile unsigned int *)(PWM1_BASE_ADDR + 0x70)) + + +/* Universal Asynchronous Receiver Transmitter 0 (UART0) */ +#define UART0_BASE_ADDR 0xE000C000 +#define U0RBR (*(volatile unsigned int *)(UART0_BASE_ADDR + 0x00)) +#define U0THR (*(volatile unsigned int *)(UART0_BASE_ADDR + 0x00)) +#define U0DLL (*(volatile unsigned int *)(UART0_BASE_ADDR + 0x00)) +#define U0DLM (*(volatile unsigned int *)(UART0_BASE_ADDR + 0x04)) +#define U0IER (*(volatile unsigned int *)(UART0_BASE_ADDR + 0x04)) +#define U0IIR (*(volatile unsigned int *)(UART0_BASE_ADDR + 0x08)) +#define U0FCR (*(volatile unsigned int *)(UART0_BASE_ADDR + 0x08)) +#define U0LCR (*(volatile unsigned int *)(UART0_BASE_ADDR + 0x0C)) +#define U0LSR (*(volatile unsigned int *)(UART0_BASE_ADDR + 0x14)) +#define U0SCR (*(volatile unsigned int *)(UART0_BASE_ADDR + 0x1C)) +#define U0ACR (*(volatile unsigned int *)(UART0_BASE_ADDR + 0x20)) +#define U0ICR (*(volatile unsigned int *)(UART0_BASE_ADDR + 0x24)) +#define U0FDR (*(volatile unsigned int *)(UART0_BASE_ADDR + 0x28)) +#define U0TER (*(volatile unsigned int *)(UART0_BASE_ADDR + 0x30)) + +/* Universal Asynchronous Receiver Transmitter 1 (UART1) */ +#define UART1_BASE_ADDR 0xE0010000 +#define U1RBR (*(volatile unsigned int *)(UART1_BASE_ADDR + 0x00)) +#define U1THR (*(volatile unsigned int *)(UART1_BASE_ADDR + 0x00)) +#define U1DLL (*(volatile unsigned int *)(UART1_BASE_ADDR + 0x00)) +#define U1DLM (*(volatile unsigned int *)(UART1_BASE_ADDR + 0x04)) +#define U1IER (*(volatile unsigned int *)(UART1_BASE_ADDR + 0x04)) +#define U1IIR (*(volatile unsigned int *)(UART1_BASE_ADDR + 0x08)) +#define U1FCR (*(volatile unsigned int *)(UART1_BASE_ADDR + 0x08)) +#define U1LCR (*(volatile unsigned int *)(UART1_BASE_ADDR + 0x0C)) +#define U1MCR (*(volatile unsigned int *)(UART1_BASE_ADDR + 0x10)) +#define U1LSR (*(volatile unsigned int *)(UART1_BASE_ADDR + 0x14)) +#define U1MSR (*(volatile unsigned int *)(UART1_BASE_ADDR + 0x18)) +#define U1SCR (*(volatile unsigned int *)(UART1_BASE_ADDR + 0x1C)) +#define U1ACR (*(volatile unsigned int *)(UART1_BASE_ADDR + 0x20)) +#define U1FDR (*(volatile unsigned int *)(UART1_BASE_ADDR + 0x28)) +#define U1TER (*(volatile unsigned int *)(UART1_BASE_ADDR + 0x30)) + +/* Universal Asynchronous Receiver Transmitter 2 (UART2) */ +#define UART2_BASE_ADDR 0xE0078000 +#define U2RBR (*(volatile unsigned int *)(UART2_BASE_ADDR + 0x00)) +#define U2THR (*(volatile unsigned int *)(UART2_BASE_ADDR + 0x00)) +#define U2DLL (*(volatile unsigned int *)(UART2_BASE_ADDR + 0x00)) +#define U2DLM (*(volatile unsigned int *)(UART2_BASE_ADDR + 0x04)) +#define U2IER (*(volatile unsigned int *)(UART2_BASE_ADDR + 0x04)) +#define U2IIR (*(volatile unsigned int *)(UART2_BASE_ADDR + 0x08)) +#define U2FCR (*(volatile unsigned int *)(UART2_BASE_ADDR + 0x08)) +#define U2LCR (*(volatile unsigned int *)(UART2_BASE_ADDR + 0x0C)) +#define U2LSR (*(volatile unsigned int *)(UART2_BASE_ADDR + 0x14)) +#define U2SCR (*(volatile unsigned int *)(UART2_BASE_ADDR + 0x1C)) +#define U2ACR (*(volatile unsigned int *)(UART2_BASE_ADDR + 0x20)) +#define U2ICR (*(volatile unsigned int *)(UART2_BASE_ADDR + 0x24)) +#define U2FDR (*(volatile unsigned int *)(UART2_BASE_ADDR + 0x28)) +#define U2TER (*(volatile unsigned int *)(UART2_BASE_ADDR + 0x30)) + +/* Universal Asynchronous Receiver Transmitter 3 (UART3) */ +#define UART3_BASE_ADDR 0xE007C000 +#define U3RBR (*(volatile unsigned int *)(UART3_BASE_ADDR + 0x00)) +#define U3THR (*(volatile unsigned int *)(UART3_BASE_ADDR + 0x00)) +#define U3DLL (*(volatile unsigned int *)(UART3_BASE_ADDR + 0x00)) +#define U3DLM (*(volatile unsigned int *)(UART3_BASE_ADDR + 0x04)) +#define U3IER (*(volatile unsigned int *)(UART3_BASE_ADDR + 0x04)) +#define U3IIR (*(volatile unsigned int *)(UART3_BASE_ADDR + 0x08)) +#define U3FCR (*(volatile unsigned int *)(UART3_BASE_ADDR + 0x08)) +#define U3LCR (*(volatile unsigned int *)(UART3_BASE_ADDR + 0x0C)) +#define U3LSR (*(volatile unsigned int *)(UART3_BASE_ADDR + 0x14)) +#define U3SCR (*(volatile unsigned int *)(UART3_BASE_ADDR + 0x1C)) +#define U3ACR (*(volatile unsigned int *)(UART3_BASE_ADDR + 0x20)) +#define U3ICR (*(volatile unsigned int *)(UART3_BASE_ADDR + 0x24)) +#define U3FDR (*(volatile unsigned int *)(UART3_BASE_ADDR + 0x28)) +#define U3TER (*(volatile unsigned int *)(UART3_BASE_ADDR + 0x30)) + +/* I2C Interface 0 */ +#define I2C0_BASE_ADDR 0xE001C000 +#define I20CONSET (*(volatile unsigned int *)(I2C0_BASE_ADDR + 0x00)) +#define I20STAT (*(volatile unsigned int *)(I2C0_BASE_ADDR + 0x04)) +#define I20DAT (*(volatile unsigned int *)(I2C0_BASE_ADDR + 0x08)) +#define I20ADR (*(volatile unsigned int *)(I2C0_BASE_ADDR + 0x0C)) +#define I20SCLH (*(volatile unsigned int *)(I2C0_BASE_ADDR + 0x10)) +#define I20SCLL (*(volatile unsigned int *)(I2C0_BASE_ADDR + 0x14)) +#define I20CONCLR (*(volatile unsigned int *)(I2C0_BASE_ADDR + 0x18)) +//Slightly different naming +#define I2C0CONSET (*(volatile unsigned int *)(I2C0_BASE_ADDR + 0x00)) +#define I2C0STAT (*(volatile unsigned int *)(I2C0_BASE_ADDR + 0x04)) +#define I2C0DAT (*(volatile unsigned int *)(I2C0_BASE_ADDR + 0x08)) +#define I2C0ADR (*(volatile unsigned int *)(I2C0_BASE_ADDR + 0x0C)) +#define I2C0SCLH (*(volatile unsigned int *)(I2C0_BASE_ADDR + 0x10)) +#define I2C0SCLL (*(volatile unsigned int *)(I2C0_BASE_ADDR + 0x14)) +#define I2C0CONCLR (*(volatile unsigned int *)(I2C0_BASE_ADDR + 0x18)) + + +/* I2C Interface 1 */ +#define I2C1_BASE_ADDR 0xE005C000 +#define I21CONSET (*(volatile unsigned int *)(I2C1_BASE_ADDR + 0x00)) +#define I21STAT (*(volatile unsigned int *)(I2C1_BASE_ADDR + 0x04)) +#define I21DAT (*(volatile unsigned int *)(I2C1_BASE_ADDR + 0x08)) +#define I21ADR (*(volatile unsigned int *)(I2C1_BASE_ADDR + 0x0C)) +#define I21SCLH (*(volatile unsigned int *)(I2C1_BASE_ADDR + 0x10)) +#define I21SCLL (*(volatile unsigned int *)(I2C1_BASE_ADDR + 0x14)) +#define I21CONCLR (*(volatile unsigned int *)(I2C1_BASE_ADDR + 0x18)) + +/* I2C Interface 2 */ +#define I2C2_BASE_ADDR 0xE0080000 +#define I22CONSET (*(volatile unsigned int *)(I2C2_BASE_ADDR + 0x00)) +#define I22STAT (*(volatile unsigned int *)(I2C2_BASE_ADDR + 0x04)) +#define I22DAT (*(volatile unsigned int *)(I2C2_BASE_ADDR + 0x08)) +#define I22ADR (*(volatile unsigned int *)(I2C2_BASE_ADDR + 0x0C)) +#define I22SCLH (*(volatile unsigned int *)(I2C2_BASE_ADDR + 0x10)) +#define I22SCLL (*(volatile unsigned int *)(I2C2_BASE_ADDR + 0x14)) +#define I22CONCLR (*(volatile unsigned int *)(I2C2_BASE_ADDR + 0x18)) + +/* SPI0 (Serial Peripheral Interface 0) */ +#define SPI0_BASE_ADDR 0xE0020000 +#define S0SPCR (*(volatile unsigned int *)(SPI0_BASE_ADDR + 0x00)) +#define S0SPSR (*(volatile unsigned int *)(SPI0_BASE_ADDR + 0x04)) +#define S0SPDR (*(volatile unsigned int *)(SPI0_BASE_ADDR + 0x08)) +#define S0SPCCR (*(volatile unsigned int *)(SPI0_BASE_ADDR + 0x0C)) +#define S0SPINT (*(volatile unsigned int *)(SPI0_BASE_ADDR + 0x1C)) + +/* SSP0 Controller */ +#define SSP0_BASE_ADDR 0xE0068000 +#define SSP0CR0 (*(volatile unsigned int *)(SSP0_BASE_ADDR + 0x00)) +#define SSP0CR1 (*(volatile unsigned int *)(SSP0_BASE_ADDR + 0x04)) +#define SSP0DR (*(volatile unsigned int *)(SSP0_BASE_ADDR + 0x08)) +#define SSP0SR (*(volatile unsigned int *)(SSP0_BASE_ADDR + 0x0C)) +#define SSP0CPSR (*(volatile unsigned int *)(SSP0_BASE_ADDR + 0x10)) +#define SSP0IMSC (*(volatile unsigned int *)(SSP0_BASE_ADDR + 0x14)) +#define SSP0RIS (*(volatile unsigned int *)(SSP0_BASE_ADDR + 0x18)) +#define SSP0MIS (*(volatile unsigned int *)(SSP0_BASE_ADDR + 0x1C)) +#define SSP0ICR (*(volatile unsigned int *)(SSP0_BASE_ADDR + 0x20)) +#define SSP0DMACR (*(volatile unsigned int *)(SSP0_BASE_ADDR + 0x24)) + +/* SSP1 Controller */ +#define SSP1_BASE_ADDR 0xE0030000 +#define SSP1CR0 (*(volatile unsigned int *)(SSP1_BASE_ADDR + 0x00)) +#define SSP1CR1 (*(volatile unsigned int *)(SSP1_BASE_ADDR + 0x04)) +#define SSP1DR (*(volatile unsigned int *)(SSP1_BASE_ADDR + 0x08)) +#define SSP1SR (*(volatile unsigned int *)(SSP1_BASE_ADDR + 0x0C)) +#define SSP1CPSR (*(volatile unsigned int *)(SSP1_BASE_ADDR + 0x10)) +#define SSP1IMSC (*(volatile unsigned int *)(SSP1_BASE_ADDR + 0x14)) +#define SSP1RIS (*(volatile unsigned int *)(SSP1_BASE_ADDR + 0x18)) +#define SSP1MIS (*(volatile unsigned int *)(SSP1_BASE_ADDR + 0x1C)) +#define SSP1ICR (*(volatile unsigned int *)(SSP1_BASE_ADDR + 0x20)) +#define SSP1DMACR (*(volatile unsigned int *)(SSP1_BASE_ADDR + 0x24)) + +/* SSP control Register 0. */ +#define SSPCR0_DSS_6 0x5 /* 6 bit transfer */ +#define SSPCR0_DSS_8 0x7 /* 8 bit transfer */ +#define SSPCR0_DSS_16 0xF /* 16 bit transfer */ +#define SSPCR0_SPO_H 0x40 /* Clock Out Polarity High. */ +#define SSPCR0_SPO_L 0x00 /* Clock Out Polarity Low. */ +#define SSPCR0_SPH_N 0x00 /* Clock Out Phase (No phase) */ +#define SSPCR0_SPH_H 0x80 /* Clock Out Phase (Half phase) */ + +/* SSP Status register */ +#define SSPSR_TFE (1 << 0) +#define SSPSR_TNF (1 << 1) +#define SSPSR_RNE (1 << 2) +#define SSPSR_RFF (1 << 3) +#define SSPSR_BSY (1 << 4) + +/* SSP1 CR0 register */ +#define SSPCR0_DSS (1 << 0) +#define SSPCR0_FRF (1 << 4) +#define SSPCR0_SPO (1 << 6) +#define SSPCR0_SPH (1 << 7) +#define SSPCR0_SCR (1 << 8) + +/* SSP1 CR1 register */ +#define SSPCR1_LBM (1 << 0) +#define SSPCR1_SSE (1 << 1) +#define SSPCR1_MS (1 << 2) +#define SSPCR1_SOD (1 << 3) + +#define SSPCR1_LBM (1 << 0) +#define SSPCR1_SSE (1 << 1) +#define SSPCR1_MS (1 << 2) +#define SSPCR1_SOD (1 << 3) + +/* SSP1 Interrupt Mask Set/Clear register */ +#define SSPIMSC_RORIM (1 << 0) +#define SSPIMSC_RTIM (1 << 1) +#define SSPIMSC_RXIM (1 << 2) +#define SSPIMSC_TXIM (1 << 3) + +/* SSP1 Interrupt Status register */ +#define SSPRIS_RORRIS (1 << 0) +#define SSPRIS_RTRIS (1 << 1) +#define SSPRIS_RXRIS (1 << 2) +#define SSPRIS_TXRIS (1 << 3) + +/* SSP1 Masked Interrupt register */ +#define SSPMIS_RORMIS (1 << 0) +#define SSPMIS_RTMIS (1 << 1) +#define SSPMIS_RXMIS (1 << 2) +#define SSPMIS_TXMIS (1 << 3) + +/* SSP1 Interrupt clear register */ +#define SSPICR_RORIC (1 << 0) +#define SSPICR_RTIC (1 << 1) + + +/* Real Time Clock */ +#define RTC_BASE_ADDR 0xE0024000 +#define RTC_ILR (*(volatile unsigned int *)(RTC_BASE_ADDR + 0x00)) +#define RTC_CTC (*(volatile unsigned int *)(RTC_BASE_ADDR + 0x04)) +#define RTC_CCR (*(volatile unsigned int *)(RTC_BASE_ADDR + 0x08)) +#define RTC_CIIR (*(volatile unsigned int *)(RTC_BASE_ADDR + 0x0C)) +#define RTC_AMR (*(volatile unsigned int *)(RTC_BASE_ADDR + 0x10)) +#define RTC_CTIME0 (*(volatile unsigned int *)(RTC_BASE_ADDR + 0x14)) +#define RTC_CTIME1 (*(volatile unsigned int *)(RTC_BASE_ADDR + 0x18)) +#define RTC_CTIME2 (*(volatile unsigned int *)(RTC_BASE_ADDR + 0x1C)) +#define RTC_SEC (*(volatile unsigned int *)(RTC_BASE_ADDR + 0x20)) +#define RTC_MIN (*(volatile unsigned int *)(RTC_BASE_ADDR + 0x24)) +#define RTC_HOUR (*(volatile unsigned int *)(RTC_BASE_ADDR + 0x28)) +#define RTC_DOM (*(volatile unsigned int *)(RTC_BASE_ADDR + 0x2C)) +#define RTC_DOW (*(volatile unsigned int *)(RTC_BASE_ADDR + 0x30)) +#define RTC_DOY (*(volatile unsigned int *)(RTC_BASE_ADDR + 0x34)) +#define RTC_MONTH (*(volatile unsigned int *)(RTC_BASE_ADDR + 0x38)) +#define RTC_YEAR (*(volatile unsigned int *)(RTC_BASE_ADDR + 0x3C)) +#define RTC_CISS (*(volatile unsigned int *)(RTC_BASE_ADDR + 0x40)) +#define RTC_ALSEC (*(volatile unsigned int *)(RTC_BASE_ADDR + 0x60)) +#define RTC_ALMIN (*(volatile unsigned int *)(RTC_BASE_ADDR + 0x64)) +#define RTC_ALHOUR (*(volatile unsigned int *)(RTC_BASE_ADDR + 0x68)) +#define RTC_ALDOM (*(volatile unsigned int *)(RTC_BASE_ADDR + 0x6C)) +#define RTC_ALDOW (*(volatile unsigned int *)(RTC_BASE_ADDR + 0x70)) +#define RTC_ALDOY (*(volatile unsigned int *)(RTC_BASE_ADDR + 0x74)) +#define RTC_ALMON (*(volatile unsigned int *)(RTC_BASE_ADDR + 0x78)) +#define RTC_ALYEAR (*(volatile unsigned int *)(RTC_BASE_ADDR + 0x7C)) +#define RTC_PREINT (*(volatile unsigned int *)(RTC_BASE_ADDR + 0x80)) +#define RTC_PREFRAC (*(volatile unsigned int *)(RTC_BASE_ADDR + 0x84)) + + +/* A/D Converter 0 (AD0) */ +#define AD0_BASE_ADDR 0xE0034000 +#define AD0CR (*(volatile unsigned int *)(AD0_BASE_ADDR + 0x00)) +#define AD0GDR (*(volatile unsigned int *)(AD0_BASE_ADDR + 0x04)) +#define AD0INTEN (*(volatile unsigned int *)(AD0_BASE_ADDR + 0x0C)) +#define AD0DR0 (*(volatile unsigned int *)(AD0_BASE_ADDR + 0x10)) +#define AD0DR1 (*(volatile unsigned int *)(AD0_BASE_ADDR + 0x14)) +#define AD0DR2 (*(volatile unsigned int *)(AD0_BASE_ADDR + 0x18)) +#define AD0DR3 (*(volatile unsigned int *)(AD0_BASE_ADDR + 0x1C)) +#define AD0DR4 (*(volatile unsigned int *)(AD0_BASE_ADDR + 0x20)) +#define AD0DR5 (*(volatile unsigned int *)(AD0_BASE_ADDR + 0x24)) +#define AD0DR6 (*(volatile unsigned int *)(AD0_BASE_ADDR + 0x28)) +#define AD0DR7 (*(volatile unsigned int *)(AD0_BASE_ADDR + 0x2C)) +#define AD0STAT (*(volatile unsigned int *)(AD0_BASE_ADDR + 0x30)) + + +/* D/A Converter */ +#define DAC_BASE_ADDR 0xE006C000 +#define DACR (*(volatile unsigned int *)(DAC_BASE_ADDR + 0x00)) + + +/* Watchdog */ +#define WDG_BASE_ADDR 0xE0000000 +#define WDMOD (*(volatile unsigned int *)(WDG_BASE_ADDR + 0x00)) +#define WDTC (*(volatile unsigned int *)(WDG_BASE_ADDR + 0x04)) +#define WDFEED (*(volatile unsigned int *)(WDG_BASE_ADDR + 0x08)) +#define WDTV (*(volatile unsigned int *)(WDG_BASE_ADDR + 0x0C)) +#define WDCLKSEL (*(volatile unsigned int *)(WDG_BASE_ADDR + 0x10)) + +/* CAN CONTROLLERS AND ACCEPTANCE FILTER */ +#define CAN_ACCEPT_BASE_ADDR 0xE003C000 +#define CAN_AFMR (*(volatile unsigned int *)(CAN_ACCEPT_BASE_ADDR + 0x00)) +#define CAN_SFF_SA (*(volatile unsigned int *)(CAN_ACCEPT_BASE_ADDR + 0x04)) +#define CAN_SFF_GRP_SA (*(volatile unsigned int *)(CAN_ACCEPT_BASE_ADDR + 0x08)) +#define CAN_EFF_SA (*(volatile unsigned int *)(CAN_ACCEPT_BASE_ADDR + 0x0C)) +#define CAN_EFF_GRP_SA (*(volatile unsigned int *)(CAN_ACCEPT_BASE_ADDR + 0x10)) +#define CAN_EOT (*(volatile unsigned int *)(CAN_ACCEPT_BASE_ADDR + 0x14)) +#define CAN_LUT_ERR_ADR (*(volatile unsigned int *)(CAN_ACCEPT_BASE_ADDR + 0x18)) +#define CAN_LUT_ERR (*(volatile unsigned int *)(CAN_ACCEPT_BASE_ADDR + 0x1C)) + +#define CAN_CENTRAL_BASE_ADDR 0xE0040000 +#define CAN_TX_SR (*(volatile unsigned int *)(CAN_CENTRAL_BASE_ADDR + 0x00)) +#define CAN_RX_SR (*(volatile unsigned int *)(CAN_CENTRAL_BASE_ADDR + 0x04)) +#define CAN_MSR (*(volatile unsigned int *)(CAN_CENTRAL_BASE_ADDR + 0x08)) + +#define CAN1_BASE_ADDR 0xE0044000 +#define CAN1MOD (*(volatile unsigned int *)(CAN1_BASE_ADDR + 0x00)) +#define CAN1CMR (*(volatile unsigned int *)(CAN1_BASE_ADDR + 0x04)) +#define CAN1GSR (*(volatile unsigned int *)(CAN1_BASE_ADDR + 0x08)) +#define CAN1ICR (*(volatile unsigned int *)(CAN1_BASE_ADDR + 0x0C)) +#define CAN1IER (*(volatile unsigned int *)(CAN1_BASE_ADDR + 0x10)) +#define CAN1BTR (*(volatile unsigned int *)(CAN1_BASE_ADDR + 0x14)) +#define CAN1EWL (*(volatile unsigned int *)(CAN1_BASE_ADDR + 0x18)) +#define CAN1SR (*(volatile unsigned int *)(CAN1_BASE_ADDR + 0x1C)) +#define CAN1RFS (*(volatile unsigned int *)(CAN1_BASE_ADDR + 0x20)) +#define CAN1RID (*(volatile unsigned int *)(CAN1_BASE_ADDR + 0x24)) +#define CAN1RDA (*(volatile unsigned int *)(CAN1_BASE_ADDR + 0x28)) +#define CAN1RDB (*(volatile unsigned int *)(CAN1_BASE_ADDR + 0x2C)) + +#define CAN1TFI1 (*(volatile unsigned int *)(CAN1_BASE_ADDR + 0x30)) +#define CAN1TID1 (*(volatile unsigned int *)(CAN1_BASE_ADDR + 0x34)) +#define CAN1TDA1 (*(volatile unsigned int *)(CAN1_BASE_ADDR + 0x38)) +#define CAN1TDB1 (*(volatile unsigned int *)(CAN1_BASE_ADDR + 0x3C)) +#define CAN1TFI2 (*(volatile unsigned int *)(CAN1_BASE_ADDR + 0x40)) +#define CAN1TID2 (*(volatile unsigned int *)(CAN1_BASE_ADDR + 0x44)) +#define CAN1TDA2 (*(volatile unsigned int *)(CAN1_BASE_ADDR + 0x48)) +#define CAN1TDB2 (*(volatile unsigned int *)(CAN1_BASE_ADDR + 0x4C)) +#define CAN1TFI3 (*(volatile unsigned int *)(CAN1_BASE_ADDR + 0x50)) +#define CAN1TID3 (*(volatile unsigned int *)(CAN1_BASE_ADDR + 0x54)) +#define CAN1TDA3 (*(volatile unsigned int *)(CAN1_BASE_ADDR + 0x58)) +#define CAN1TDB3 (*(volatile unsigned int *)(CAN1_BASE_ADDR + 0x5C)) + +#define CAN2_BASE_ADDR 0xE0048000 +#define CAN2MOD (*(volatile unsigned int *)(CAN2_BASE_ADDR + 0x00)) +#define CAN2CMR (*(volatile unsigned int *)(CAN2_BASE_ADDR + 0x04)) +#define CAN2GSR (*(volatile unsigned int *)(CAN2_BASE_ADDR + 0x08)) +#define CAN2ICR (*(volatile unsigned int *)(CAN2_BASE_ADDR + 0x0C)) +#define CAN2IER (*(volatile unsigned int *)(CAN2_BASE_ADDR + 0x10)) +#define CAN2BTR (*(volatile unsigned int *)(CAN2_BASE_ADDR + 0x14)) +#define CAN2EWL (*(volatile unsigned int *)(CAN2_BASE_ADDR + 0x18)) +#define CAN2SR (*(volatile unsigned int *)(CAN2_BASE_ADDR + 0x1C)) +#define CAN2RFS (*(volatile unsigned int *)(CAN2_BASE_ADDR + 0x20)) +#define CAN2RID (*(volatile unsigned int *)(CAN2_BASE_ADDR + 0x24)) +#define CAN2RDA (*(volatile unsigned int *)(CAN2_BASE_ADDR + 0x28)) +#define CAN2RDB (*(volatile unsigned int *)(CAN2_BASE_ADDR + 0x2C)) + +#define CAN2TFI1 (*(volatile unsigned int *)(CAN2_BASE_ADDR + 0x30)) +#define CAN2TID1 (*(volatile unsigned int *)(CAN2_BASE_ADDR + 0x34)) +#define CAN2TDA1 (*(volatile unsigned int *)(CAN2_BASE_ADDR + 0x38)) +#define CAN2TDB1 (*(volatile unsigned int *)(CAN2_BASE_ADDR + 0x3C)) +#define CAN2TFI2 (*(volatile unsigned int *)(CAN2_BASE_ADDR + 0x40)) +#define CAN2TID2 (*(volatile unsigned int *)(CAN2_BASE_ADDR + 0x44)) +#define CAN2TDA2 (*(volatile unsigned int *)(CAN2_BASE_ADDR + 0x48)) +#define CAN2TDB2 (*(volatile unsigned int *)(CAN2_BASE_ADDR + 0x4C)) +#define CAN2TFI3 (*(volatile unsigned int *)(CAN2_BASE_ADDR + 0x50)) +#define CAN2TID3 (*(volatile unsigned int *)(CAN2_BASE_ADDR + 0x54)) +#define CAN2TDA3 (*(volatile unsigned int *)(CAN2_BASE_ADDR + 0x58)) +#define CAN2TDB3 (*(volatile unsigned int *)(CAN2_BASE_ADDR + 0x5C)) + + +/* MultiMedia Card Interface(MCI) Controller */ +#define MCI_BASE_ADDR 0xE008C000 +#define MCI_POWER (*(volatile unsigned int *)(MCI_BASE_ADDR + 0x00)) +#define MCI_CLOCK (*(volatile unsigned int *)(MCI_BASE_ADDR + 0x04)) +#define MCI_ARGUMENT (*(volatile unsigned int *)(MCI_BASE_ADDR + 0x08)) +#define MCI_COMMAND (*(volatile unsigned int *)(MCI_BASE_ADDR + 0x0C)) +#define MCI_RESP_CMD (*(volatile unsigned int *)(MCI_BASE_ADDR + 0x10)) +#define MCI_RESP0 (*(volatile unsigned int *)(MCI_BASE_ADDR + 0x14)) +#define MCI_RESP1 (*(volatile unsigned int *)(MCI_BASE_ADDR + 0x18)) +#define MCI_RESP2 (*(volatile unsigned int *)(MCI_BASE_ADDR + 0x1C)) +#define MCI_RESP3 (*(volatile unsigned int *)(MCI_BASE_ADDR + 0x20)) +#define MCI_DATA_TMR (*(volatile unsigned int *)(MCI_BASE_ADDR + 0x24)) +#define MCI_DATA_LEN (*(volatile unsigned int *)(MCI_BASE_ADDR + 0x28)) +#define MCI_DATA_CTRL (*(volatile unsigned int *)(MCI_BASE_ADDR + 0x2C)) +#define MCI_DATA_CNT (*(volatile unsigned int *)(MCI_BASE_ADDR + 0x30)) +#define MCI_STATUS (*(volatile unsigned int *)(MCI_BASE_ADDR + 0x34)) +#define MCI_CLEAR (*(volatile unsigned int *)(MCI_BASE_ADDR + 0x38)) +#define MCI_MASK0 (*(volatile unsigned int *)(MCI_BASE_ADDR + 0x3C)) +#define MCI_MASK1 (*(volatile unsigned int *)(MCI_BASE_ADDR + 0x40)) +#define MCI_FIFO_CNT (*(volatile unsigned int *)(MCI_BASE_ADDR + 0x48)) +#define MCI_FIFO (*(volatile unsigned int *)(MCI_BASE_ADDR + 0x80)) + + +/* I2S Interface Controller (I2S) */ +#define I2S_BASE_ADDR 0xE0088000 +#define I2S_DAO (*(volatile unsigned int *)(I2S_BASE_ADDR + 0x00)) +#define I2S_DAI (*(volatile unsigned int *)(I2S_BASE_ADDR + 0x04)) +#define I2S_TX_FIFO (*(volatile unsigned int *)(I2S_BASE_ADDR + 0x08)) +#define I2S_RX_FIFO (*(volatile unsigned int *)(I2S_BASE_ADDR + 0x0C)) +#define I2S_STATE (*(volatile unsigned int *)(I2S_BASE_ADDR + 0x10)) +#define I2S_DMA1 (*(volatile unsigned int *)(I2S_BASE_ADDR + 0x14)) +#define I2S_DMA2 (*(volatile unsigned int *)(I2S_BASE_ADDR + 0x18)) +#define I2S_IRQ (*(volatile unsigned int *)(I2S_BASE_ADDR + 0x1C)) +#define I2S_TXRATE (*(volatile unsigned int *)(I2S_BASE_ADDR + 0x20)) +#define I2S_RXRATE (*(volatile unsigned int *)(I2S_BASE_ADDR + 0x24)) + + +/* General-purpose DMA Controller */ +#define DMA_BASE_ADDR 0xFFE04000 +#define GPDMA_INT_STAT (*(volatile unsigned int *)(DMA_BASE_ADDR + 0x000)) +#define GPDMA_INT_TCSTAT (*(volatile unsigned int *)(DMA_BASE_ADDR + 0x004)) +#define GPDMA_INT_TCCLR (*(volatile unsigned int *)(DMA_BASE_ADDR + 0x008)) +#define GPDMA_INT_ERR_STAT (*(volatile unsigned int *)(DMA_BASE_ADDR + 0x00C)) +#define GPDMA_INT_ERR_CLR (*(volatile unsigned int *)(DMA_BASE_ADDR + 0x010)) +#define GPDMA_RAW_INT_TCSTAT (*(volatile unsigned int *)(DMA_BASE_ADDR + 0x014)) +#define GPDMA_RAW_INT_ERR_STAT (*(volatile unsigned int *)(DMA_BASE_ADDR + 0x018)) +#define GPDMA_ENABLED_CHNS (*(volatile unsigned int *)(DMA_BASE_ADDR + 0x01C)) +#define GPDMA_SOFT_BREQ (*(volatile unsigned int *)(DMA_BASE_ADDR + 0x020)) +#define GPDMA_SOFT_SREQ (*(volatile unsigned int *)(DMA_BASE_ADDR + 0x024)) +#define GPDMA_SOFT_LBREQ (*(volatile unsigned int *)(DMA_BASE_ADDR + 0x028)) +#define GPDMA_SOFT_LSREQ (*(volatile unsigned int *)(DMA_BASE_ADDR + 0x02C)) +#define GPDMA_CONFIG (*(volatile unsigned int *)(DMA_BASE_ADDR + 0x030)) +#define GPDMA_SYNC (*(volatile unsigned int *)(DMA_BASE_ADDR + 0x034)) + +/* DMA channel 0 registers */ +#define GPDMA_CH0_SRC (*(volatile unsigned int *)(DMA_BASE_ADDR + 0x100)) +#define GPDMA_CH0_DEST (*(volatile unsigned int *)(DMA_BASE_ADDR + 0x104)) +#define GPDMA_CH0_LLI (*(volatile unsigned int *)(DMA_BASE_ADDR + 0x108)) +#define GPDMA_CH0_CTRL (*(volatile unsigned int *)(DMA_BASE_ADDR + 0x10C)) +#define GPDMA_CH0_CFG (*(volatile unsigned int *)(DMA_BASE_ADDR + 0x110)) + +/* DMA channel 1 registers */ +#define GPDMA_CH1_SRC (*(volatile unsigned int *)(DMA_BASE_ADDR + 0x120)) +#define GPDMA_CH1_DEST (*(volatile unsigned int *)(DMA_BASE_ADDR + 0x124)) +#define GPDMA_CH1_LLI (*(volatile unsigned int *)(DMA_BASE_ADDR + 0x128)) +#define GPDMA_CH1_CTRL (*(volatile unsigned int *)(DMA_BASE_ADDR + 0x12C)) +#define GPDMA_CH1_CFG (*(volatile unsigned int *)(DMA_BASE_ADDR + 0x130)) + + +/* USB Controller */ +//#define USB_INT_BASE_ADDR 0xE01FC1C0 +//#define USB_BASE_ADDR 0xFFE0C200 /* USB Base Address */ + +//#define USB_INT_STAT (*(volatile unsigned int *)(USB_INT_BASE_ADDR + 0x00)) + +/* USB Device Interrupt Registers */ +//#define DEV_INT_STAT (*(volatile unsigned int *)(USB_BASE_ADDR + 0x00)) +//#define DEV_INT_EN (*(volatile unsigned int *)(USB_BASE_ADDR + 0x04)) +//#define DEV_INT_CLR (*(volatile unsigned int *)(USB_BASE_ADDR + 0x08)) +//#define DEV_INT_SET (*(volatile unsigned int *)(USB_BASE_ADDR + 0x0C)) +//#define DEV_INT_PRIO (*(volatile unsigned int *)(USB_BASE_ADDR + 0x2C)) + +/* USB Device Endpoint Interrupt Registers */ +//#define EP_INT_STAT (*(volatile unsigned int *)(USB_BASE_ADDR + 0x30)) +//#define EP_INT_EN (*(volatile unsigned int *)(USB_BASE_ADDR + 0x34)) +//#define EP_INT_CLR (*(volatile unsigned int *)(USB_BASE_ADDR + 0x38)) +//#define EP_INT_SET (*(volatile unsigned int *)(USB_BASE_ADDR + 0x3C)) +//#define EP_INT_PRIO (*(volatile unsigned int *)(USB_BASE_ADDR + 0x40)) + +/* USB Device Endpoint Realization Registers */ +//#define REALIZE_EP (*(volatile unsigned int *)(USB_BASE_ADDR + 0x44)) +//#define EP_INDEX (*(volatile unsigned int *)(USB_BASE_ADDR + 0x48)) +//#define MAXPACKET_SIZE (*(volatile unsigned int *)(USB_BASE_ADDR + 0x4C)) + +/* USB Device Command Reagisters */ +//#define CMD_CODE (*(volatile unsigned int *)(USB_BASE_ADDR + 0x10)) +//#define CMD_DATA (*(volatile unsigned int *)(USB_BASE_ADDR + 0x14)) + +/* USB Device Data Transfer Registers */ +//#define RX_DATA (*(volatile unsigned int *)(USB_BASE_ADDR + 0x18)) +//#define TX_DATA (*(volatile unsigned int *)(USB_BASE_ADDR + 0x1C)) +//#define RX_PLENGTH (*(volatile unsigned int *)(USB_BASE_ADDR + 0x20)) +//#define TX_PLENGTH (*(volatile unsigned int *)(USB_BASE_ADDR + 0x24)) +//#define USB_CTRL (*(volatile unsigned int *)(USB_BASE_ADDR + 0x28)) + +/* USB Device DMA Registers */ +//#define DMA_REQ_STAT (*(volatile unsigned int *)(USB_BASE_ADDR + 0x50)) +//#define DMA_REQ_CLR (*(volatile unsigned int *)(USB_BASE_ADDR + 0x54)) +//#define DMA_REQ_SET (*(volatile unsigned int *)(USB_BASE_ADDR + 0x58)) +//#define UDCA_HEAD (*(volatile unsigned int *)(USB_BASE_ADDR + 0x80)) +//#define EP_DMA_STAT (*(volatile unsigned int *)(USB_BASE_ADDR + 0x84)) +//#define EP_DMA_EN (*(volatile unsigned int *)(USB_BASE_ADDR + 0x88)) +//#define EP_DMA_DIS (*(volatile unsigned int *)(USB_BASE_ADDR + 0x8C)) +//#define DMA_INT_STAT (*(volatile unsigned int *)(USB_BASE_ADDR + 0x90)) +//#define DMA_INT_EN (*(volatile unsigned int *)(USB_BASE_ADDR + 0x94)) +//#define EOT_INT_STAT (*(volatile unsigned int *)(USB_BASE_ADDR + 0xA0)) +//#define EOT_INT_CLR (*(volatile unsigned int *)(USB_BASE_ADDR + 0xA4)) +//#define EOT_INT_SET (*(volatile unsigned int *)(USB_BASE_ADDR + 0xA8)) +//#define NDD_REQ_INT_STAT (*(volatile unsigned int *)(USB_BASE_ADDR + 0xAC)) +//#define NDD_REQ_INT_CLR (*(volatile unsigned int *)(USB_BASE_ADDR + 0xB0)) +//#define NDD_REQ_INT_SET (*(volatile unsigned int *)(USB_BASE_ADDR + 0xB4)) +//#define SYS_ERR_INT_STAT (*(volatile unsigned int *)(USB_BASE_ADDR + 0xB8)) +//#define SYS_ERR_INT_CLR (*(volatile unsigned int *)(USB_BASE_ADDR + 0xBC)) +//#define SYS_ERR_INT_SET (*(volatile unsigned int *)(USB_BASE_ADDR + 0xC0)) + +/* USB Controller */ +#define USB_BASE_ADDR 0xFFE0C000 + +/* USBPortSel only available on the LPC2378 */ +#define USBPortSel (*(volatile unsigned int *)(USB_BASE_ADDR + 0x110)) + +/* USB Clock Control Registers */ +#define USBClkCtrl (*(volatile unsigned int *)(USB_BASE_ADDR + 0xFF4)) +#define USBClkSt (*(volatile unsigned int *)(USB_BASE_ADDR + 0xFF8)) + +/* USB Device Interrupt Registers */ +#define USBIntSt (*(volatile unsigned int *)(USB_BASE_ADDR + 0x1C0)) +#define USBDevIntSt (*(volatile unsigned int *)(USB_BASE_ADDR + 0x200)) +#define USBDevIntEn (*(volatile unsigned int *)(USB_BASE_ADDR + 0x204)) +#define USBDevIntClr (*(volatile unsigned int *)(USB_BASE_ADDR + 0x208)) +#define USBDevIntSet (*(volatile unsigned int *)(USB_BASE_ADDR + 0x20C)) +#define USBDevIntPri (*(volatile unsigned int *)(USB_BASE_ADDR + 0x22C)) + +/* USB Device Endpoint Interrupt Registers */ +#define USBEpIntSt (*(volatile unsigned int *)(USB_BASE_ADDR + 0x230)) +#define USBEpIntEn (*(volatile unsigned int *)(USB_BASE_ADDR + 0x234)) +#define USBEpIntClr (*(volatile unsigned int *)(USB_BASE_ADDR + 0x238)) +#define USBEpIntSet (*(volatile unsigned int *)(USB_BASE_ADDR + 0x23C)) +#define USBEpIntPri (*(volatile unsigned int *)(USB_BASE_ADDR + 0x240)) + +/* USB Device Endpoint Realization Registers */ +#define USBReEp (*(volatile unsigned int *)(USB_BASE_ADDR + 0x244)) +#define USBEpInd (*(volatile unsigned int *)(USB_BASE_ADDR + 0x248)) +#define USBMaxPSize (*(volatile unsigned int *)(USB_BASE_ADDR + 0x24C)) + +/* USB Device Data Transfer Registers */ +#define USBRxData (*(volatile unsigned int *)(USB_BASE_ADDR + 0x218)) +#define USBRxPLen (*(volatile unsigned int *)(USB_BASE_ADDR + 0x220)) +#define USBTxData (*(volatile unsigned int *)(USB_BASE_ADDR + 0x21C)) +#define USBTxPLen (*(volatile unsigned int *)(USB_BASE_ADDR + 0x224)) +#define USBCtrl (*(volatile unsigned int *)(USB_BASE_ADDR + 0x228)) + +/* USB SIE Command Reagisters */ +#define USBCmdCode (*(volatile unsigned int *)(USB_BASE_ADDR + 0x210)) +#define USBCmdData (*(volatile unsigned int *)(USB_BASE_ADDR + 0x214)) + +/* USB Device DMA Registers */ +#define USBDMARSt (*(volatile unsigned int *)(USB_BASE_ADDR + 0x250)) +#define USBDMARClr (*(volatile unsigned int *)(USB_BASE_ADDR + 0x254)) +#define USBDMARSet (*(volatile unsigned int *)(USB_BASE_ADDR + 0x258)) +#define USBUDCAH (*(volatile unsigned int *)(USB_BASE_ADDR + 0x280)) +#define USBEpDMASt (*(volatile unsigned int *)(USB_BASE_ADDR + 0x284)) +#define USBEpDMAEn (*(volatile unsigned int *)(USB_BASE_ADDR + 0x288)) +#define USBEpDMADis (*(volatile unsigned int *)(USB_BASE_ADDR + 0x28C)) +#define USBDMAIntSt (*(volatile unsigned int *)(USB_BASE_ADDR + 0x290)) +#define USBDMAIntEn (*(volatile unsigned int *)(USB_BASE_ADDR + 0x294)) +#define USBEoTIntSt (*(volatile unsigned int *)(USB_BASE_ADDR + 0x2A0)) +#define USBEoTIntClr (*(volatile unsigned int *)(USB_BASE_ADDR + 0x2A4)) +#define USBEoTIntSet (*(volatile unsigned int *)(USB_BASE_ADDR + 0x2A8)) +#define USBNDDRIntSt (*(volatile unsigned int *)(USB_BASE_ADDR + 0x2AC)) +#define USBNDDRIntClr (*(volatile unsigned int *)(USB_BASE_ADDR + 0x2B0)) +#define USBNDDRIntSet (*(volatile unsigned int *)(USB_BASE_ADDR + 0x2B4)) +#define USBSysErrIntSt (*(volatile unsigned int *)(USB_BASE_ADDR + 0x2B8)) +#define USBSysErrIntClr (*(volatile unsigned int *)(USB_BASE_ADDR + 0x2BC)) +#define USBSysErrIntSet (*(volatile unsigned int *)(USB_BASE_ADDR + 0x2C0)) + +/* USB Host Controller */ +#define USBHC_BASE_ADDR 0xFFE0C000 +#define HC_REVISION (*(volatile unsigned int *)(USBHC_BASE_ADDR + 0x00)) +#define HC_CONTROL (*(volatile unsigned int *)(USBHC_BASE_ADDR + 0x04)) +#define HC_CMD_STAT (*(volatile unsigned int *)(USBHC_BASE_ADDR + 0x08)) +#define HC_INT_STAT (*(volatile unsigned int *)(USBHC_BASE_ADDR + 0x0C)) +#define HC_INT_EN (*(volatile unsigned int *)(USBHC_BASE_ADDR + 0x10)) +#define HC_INT_DIS (*(volatile unsigned int *)(USBHC_BASE_ADDR + 0x14)) +#define HC_HCCA (*(volatile unsigned int *)(USBHC_BASE_ADDR + 0x18)) +#define HC_PERIOD_CUR_ED (*(volatile unsigned int *)(USBHC_BASE_ADDR + 0x1C)) +#define HC_CTRL_HEAD_ED (*(volatile unsigned int *)(USBHC_BASE_ADDR + 0x20)) +#define HC_CTRL_CUR_ED (*(volatile unsigned int *)(USBHC_BASE_ADDR + 0x24)) +#define HC_BULK_HEAD_ED (*(volatile unsigned int *)(USBHC_BASE_ADDR + 0x28)) +#define HC_BULK_CUR_ED (*(volatile unsigned int *)(USBHC_BASE_ADDR + 0x2C)) +#define HC_DONE_HEAD (*(volatile unsigned int *)(USBHC_BASE_ADDR + 0x30)) +#define HC_FM_INTERVAL (*(volatile unsigned int *)(USBHC_BASE_ADDR + 0x34)) +#define HC_FM_REMAINING (*(volatile unsigned int *)(USBHC_BASE_ADDR + 0x38)) +#define HC_FM_NUMBER (*(volatile unsigned int *)(USBHC_BASE_ADDR + 0x3C)) +#define HC_PERIOD_START (*(volatile unsigned int *)(USBHC_BASE_ADDR + 0x40)) +#define HC_LS_THRHLD (*(volatile unsigned int *)(USBHC_BASE_ADDR + 0x44)) +#define HC_RH_DESCA (*(volatile unsigned int *)(USBHC_BASE_ADDR + 0x48)) +#define HC_RH_DESCB (*(volatile unsigned int *)(USBHC_BASE_ADDR + 0x4C)) +#define HC_RH_STAT (*(volatile unsigned int *)(USBHC_BASE_ADDR + 0x50)) +#define HC_RH_PORT_STAT1 (*(volatile unsigned int *)(USBHC_BASE_ADDR + 0x54)) +#define HC_RH_PORT_STAT2 (*(volatile unsigned int *)(USBHC_BASE_ADDR + 0x58)) + +/* USB OTG Controller */ +#define USBOTG_BASE_ADDR 0xFFE0C100 +#define OTG_INT_STAT (*(volatile unsigned int *)(USBOTG_BASE_ADDR + 0x00)) +#define OTG_INT_EN (*(volatile unsigned int *)(USBOTG_BASE_ADDR + 0x04)) +#define OTG_INT_SET (*(volatile unsigned int *)(USBOTG_BASE_ADDR + 0x08)) +#define OTG_INT_CLR (*(volatile unsigned int *)(USBOTG_BASE_ADDR + 0x0C)) +#define OTG_STAT_CTRL (*(volatile unsigned int *)(USBOTG_BASE_ADDR + 0x10)) +#define OTG_TIMER (*(volatile unsigned int *)(USBOTG_BASE_ADDR + 0x14)) + +#define USBOTG_I2C_BASE_ADDR 0xFFE0C300 +#define OTG_I2C_RX (*(volatile unsigned int *)(USBOTG_I2C_BASE_ADDR + 0x00)) +#define OTG_I2C_TX (*(volatile unsigned int *)(USBOTG_I2C_BASE_ADDR + 0x00)) +#define OTG_I2C_STS (*(volatile unsigned int *)(USBOTG_I2C_BASE_ADDR + 0x04)) +#define OTG_I2C_CTL (*(volatile unsigned int *)(USBOTG_I2C_BASE_ADDR + 0x08)) +#define OTG_I2C_CLKHI (*(volatile unsigned int *)(USBOTG_I2C_BASE_ADDR + 0x0C)) +#define OTG_I2C_CLKLO (*(volatile unsigned int *)(USBOTG_I2C_BASE_ADDR + 0x10)) + +#define USBOTG_CLK_BASE_ADDR 0xFFE0CFF0 +#define OTG_CLK_CTRL (*(volatile unsigned int *)(USBOTG_CLK_BASE_ADDR + 0x04)) +#define OTG_CLK_STAT (*(volatile unsigned int *)(USBOTG_CLK_BASE_ADDR + 0x08)) + + +/* Ethernet MAC (32 bit data bus) -- all registers are RW unless indicated in parentheses */ +#define MAC_BASE_ADDR 0xFFE00000 /* AHB Peripheral # 0 */ +#define MAC_MAC1 (*(volatile unsigned int *)(MAC_BASE_ADDR + 0x000)) /* MAC config reg 1 */ +#define MAC_MAC2 (*(volatile unsigned int *)(MAC_BASE_ADDR + 0x004)) /* MAC config reg 2 */ +#define MAC_IPGT (*(volatile unsigned int *)(MAC_BASE_ADDR + 0x008)) /* b2b InterPacketGap reg */ +#define MAC_IPGR (*(volatile unsigned int *)(MAC_BASE_ADDR + 0x00C)) /* non b2b InterPacketGap reg */ +#define MAC_CLRT (*(volatile unsigned int *)(MAC_BASE_ADDR + 0x010)) /* CoLlision window/ReTry reg */ +#define MAC_MAXF (*(volatile unsigned int *)(MAC_BASE_ADDR + 0x014)) /* MAXimum Frame reg */ +#define MAC_SUPP (*(volatile unsigned int *)(MAC_BASE_ADDR + 0x018)) /* PHY SUPPort reg */ +#define MAC_TEST (*(volatile unsigned int *)(MAC_BASE_ADDR + 0x01C)) /* TEST reg */ +#define MAC_MCFG (*(volatile unsigned int *)(MAC_BASE_ADDR + 0x020)) /* MII Mgmt ConFiG reg */ +#define MAC_MCMD (*(volatile unsigned int *)(MAC_BASE_ADDR + 0x024)) /* MII Mgmt CoMmanD reg */ +#define MAC_MADR (*(volatile unsigned int *)(MAC_BASE_ADDR + 0x028)) /* MII Mgmt ADdRess reg */ +#define MAC_MWTD (*(volatile unsigned int *)(MAC_BASE_ADDR + 0x02C)) /* MII Mgmt WriTe Data reg (WO) */ +#define MAC_MRDD (*(volatile unsigned int *)(MAC_BASE_ADDR + 0x030)) /* MII Mgmt ReaD Data reg (RO) */ +#define MAC_MIND (*(volatile unsigned int *)(MAC_BASE_ADDR + 0x034)) /* MII Mgmt INDicators reg (RO) */ + +#define MAC_SA0 (*(volatile unsigned int *)(MAC_BASE_ADDR + 0x040)) /* Station Address 0 reg */ +#define MAC_SA1 (*(volatile unsigned int *)(MAC_BASE_ADDR + 0x044)) /* Station Address 1 reg */ +#define MAC_SA2 (*(volatile unsigned int *)(MAC_BASE_ADDR + 0x048)) /* Station Address 2 reg */ + +#define MAC_COMMAND (*(volatile unsigned int *)(MAC_BASE_ADDR + 0x100)) /* Command reg */ +#define MAC_STATUS (*(volatile unsigned int *)(MAC_BASE_ADDR + 0x104)) /* Status reg (RO) */ +#define MAC_RXDESCRIPTOR (*(volatile unsigned int *)(MAC_BASE_ADDR + 0x108)) /* Rx descriptor base address reg */ +#define MAC_RXSTATUS (*(volatile unsigned int *)(MAC_BASE_ADDR + 0x10C)) /* Rx status base address reg */ +#define MAC_RXDESCRIPTORNUM (*(volatile unsigned int *)(MAC_BASE_ADDR + 0x110)) /* Rx number of descriptors reg */ +#define MAC_RXPRODUCEINDEX (*(volatile unsigned int *)(MAC_BASE_ADDR + 0x114)) /* Rx produce index reg (RO) */ +#define MAC_RXCONSUMEINDEX (*(volatile unsigned int *)(MAC_BASE_ADDR + 0x118)) /* Rx consume index reg */ +#define MAC_TXDESCRIPTOR (*(volatile unsigned int *)(MAC_BASE_ADDR + 0x11C)) /* Tx descriptor base address reg */ +#define MAC_TXSTATUS (*(volatile unsigned int *)(MAC_BASE_ADDR + 0x120)) /* Tx status base address reg */ +#define MAC_TXDESCRIPTORNUM (*(volatile unsigned int *)(MAC_BASE_ADDR + 0x124)) /* Tx number of descriptors reg */ +#define MAC_TXPRODUCEINDEX (*(volatile unsigned int *)(MAC_BASE_ADDR + 0x128)) /* Tx produce index reg */ +#define MAC_TXCONSUMEINDEX (*(volatile unsigned int *)(MAC_BASE_ADDR + 0x12C)) /* Tx consume index reg (RO) */ + +#define MAC_TSV0 (*(volatile unsigned int *)(MAC_BASE_ADDR + 0x158)) /* Tx status vector 0 reg (RO) */ +#define MAC_TSV1 (*(volatile unsigned int *)(MAC_BASE_ADDR + 0x15C)) /* Tx status vector 1 reg (RO) */ +#define MAC_RSV (*(volatile unsigned int *)(MAC_BASE_ADDR + 0x160)) /* Rx status vector reg (RO) */ + +#define MAC_FLOWCONTROLCNT (*(volatile unsigned int *)(MAC_BASE_ADDR + 0x170)) /* Flow control counter reg */ +#define MAC_FLOWCONTROLSTS (*(volatile unsigned int *)(MAC_BASE_ADDR + 0x174)) /* Flow control status reg */ + +#define MAC_RXFILTERCTRL (*(volatile unsigned int *)(MAC_BASE_ADDR + 0x200)) /* Rx filter ctrl reg */ +#define MAC_RXFILTERWOLSTS (*(volatile unsigned int *)(MAC_BASE_ADDR + 0x204)) /* Rx filter WoL status reg (RO) */ +#define MAC_RXFILTERWOLCLR (*(volatile unsigned int *)(MAC_BASE_ADDR + 0x208)) /* Rx filter WoL clear reg (WO) */ + +#define MAC_HASHFILTERL (*(volatile unsigned int *)(MAC_BASE_ADDR + 0x210)) /* Hash filter LSBs reg */ +#define MAC_HASHFILTERH (*(volatile unsigned int *)(MAC_BASE_ADDR + 0x214)) /* Hash filter MSBs reg */ + +#define MAC_INTSTATUS (*(volatile unsigned int *)(MAC_BASE_ADDR + 0xFE0)) /* Interrupt status reg (RO) */ +#define MAC_INTENABLE (*(volatile unsigned int *)(MAC_BASE_ADDR + 0xFE4)) /* Interrupt enable reg */ +#define MAC_INTCLEAR (*(volatile unsigned int *)(MAC_BASE_ADDR + 0xFE8)) /* Interrupt clear reg (WO) */ +#define MAC_INTSET (*(volatile unsigned int *)(MAC_BASE_ADDR + 0xFEC)) /* Interrupt set reg (WO) */ + +#define MAC_POWERDOWN (*(volatile unsigned int *)(MAC_BASE_ADDR + 0xFF4)) /* Power-down reg */ +#define MAC_MODULEID (*(volatile unsigned int *)(MAC_BASE_ADDR + 0xFFC)) /* Module ID reg (RO) */ + +/* Some bit-mask definitions - mthomas */ + +/* Timers */ +#define TxIR_MR0_Interrupt (1UL<<0) +#define TxIR_MR1_Interrupt (1UL<<1) +#define TxIR_MR2_Interrupt (1UL<<2) +#define TxIR_MR3_Interrupt (1UL<<3) +#define TxIR_CR0_Interrupt (1UL<<4) +#define TxIR_CR1_Interrupt (1UL<<5) +#define TxIR_CR2_Interrupt (1UL<<6) +#define TxIR_CR3_Interrupt (1UL<<7) + +#define TxTCR_Counter_Enable (1UL<<0) +#define TxTCR_Counter_Reset (1UL<<1) + +#define TxMCR_MR0I (1UL<<0) +#define TxMCR_MR0R (1UL<<1) +#define TxMCR_MR0S (1UL<<2) +#define TxMCR_MR1I (1UL<<3) +#define TxMCR_MR1R (1UL<<4) +#define TxMCR_MR1S (1UL<<5) +#define TxMCR_MR2I (1UL<<6) +#define TxMCR_MR2R (1UL<<7) +#define TxMCR_MR2S (1UL<<8) +#define TxMCR_MR3I (1UL<<9) +#define TxMCR_MR3R (1UL<<10) +#define TxMCR_MR3S (1UL<<11) + +/* VIC */ +#define VIC_CHAN_NUM_WDT 0 +#define VIC_CHAN_NUM_UNUSED 1 +#define VIC_CHAN_NUM_ARM_Core_DgbCommRX 2 +#define VIC_CHAN_NUM_ARM_Core_DbgCommTX 3 +#define VIC_CHAN_NUM_Timer0 4 +#define VIC_CHAN_NUM_Timer1 5 +#define VIC_CHAN_NUM_UART0 6 +#define VIC_CHAN_NUM_UART1 7 +#define VIC_CHAN_NUM_PWM1 8 +#define VIC_CHAN_NUM_I2C0 9 +#define VIC_CHAN_NUM_SPI 10 +#define VIC_CHAN_NUM_SSP0 10 +#define VIC_CHAN_NUM_SSP1 11 +#define VIC_CHAN_NUM_PLL 12 +#define VIC_CHAN_NUM_RTC 13 +#define VIC_CHAN_NUM_EINT0 14 +#define VIC_CHAN_NUM_EINT1 15 +#define VIC_CHAN_NUM_EINT2 16 +#define VIC_CHAN_NUM_EINT3 17 +#define VIC_CHAN_NUM_ADC0 18 +#define VIC_CHAN_NUM_I2C1 19 +#define VIC_CHAN_NUM_BOD 20 +#define VIC_CHAN_NUM_Ethernet 21 +#define VIC_CHAN_NUM_USB 22 +#define VIC_CHAN_NUM_CAN 23 +#define VIC_CHAN_NUM_SD_MMC 24 +#define VIC_CHAN_NUM_GP_DMA 25 +#define VIC_CHAN_NUM_Timer2 26 +#define VIC_CHAN_NUM_Timer3 27 +#define VIC_CHAN_NUM_UART2 28 +#define VIC_CHAN_NUM_UART3 29 +#define VIC_CHAN_NUM_I2C2 30 +#define VIC_CHAN_NUM_I2S 31 + +#define VIC_CHAN_TO_MASK(vctm_chan_num__) (1UL<flash + + prog : + { + *(.text) + *(.rodata) + *(.rodata*) + *(.glue_7) + *(.glue_7t) + } >flash + + __end_of_text__ = .; + + .data : + { + __data_beg__ = .; + __data_beg_src__ = __end_of_text__; + *(.data) + __data_end__ = .; + } >ram AT>flash + + .bss : + { + __bss_beg__ = .; + *(.bss) + *(COMMON) + __bss_end__ = .; + } >ram + + .backupram (NOLOAD): + { + __backupram_beg__ = .; + *(.backupram); + __backupram_end__ = .; + } >ram + + + /* Align here to ensure that the .bss section occupies space up to + _end. Align after .bss to ensure correct alignment even if the + .bss section disappears because there are no input sections. */ + . = ALIGN(32 / 8); + + .usbram (NOLOAD): + { + __usbram_beg__ = .; + *(.dmaram) + __usbram_end__ = .; + } >usbram + + .ethram (NOLOAD): + { + __ethram_beg__ = .; + *(.ethram) + __ethram_end__ = .; + } >ethram + + + .rtcram (NOLOAD): + { + __rtcram_beg__ = .; + *(.rtcram) + __rtcram_end__ = .; + } >rtcram + +} + . = ALIGN(32 / 8); + _end = .; + /*_bss_end__ = . ; __bss_end__ = . ; */ + __end__ = . ; + PROVIDE (end = .); + + diff --git a/Tester/SW/inc/sys_config.h b/Tester/SW/inc/sys_config.h new file mode 100644 index 0000000..f5f2f74 --- /dev/null +++ b/Tester/SW/inc/sys_config.h @@ -0,0 +1,202 @@ +/****************************************************************************** + * + * $RCSfile: $ + * $Revision: $ + * + * This module provides information about the project configuration + * Copyright 2004, R O SoftWare + * No guarantees, warrantees, or promises, implied or otherwise. + * May be used for hobby or commercial purposes provided copyright + * notice remains intact. + * + *****************************************************************************/ + + /* modified by Martin Thomas */ + +// 5/2007 mt: adapted to LPC23xx/24xx + +#ifndef SYS_CONFIG_H__ +#define SYS_CONFIG_H__ + +#include "LPC23xx.h" + +/*#include "app_types.h" +//#include "LPC_REGS.h"*/ + +// some handy DEFINES +#ifndef FALSE +#define FALSE 0 +#ifndef TRUE +#define TRUE !FALSE +#endif +#endif + +#ifndef BIT +#define BIT(n) (1L << (n)) +#endif + +#ifndef TSTBIT +#define TSTBIT(a, n) (a & (1L << n) ? TRUE : FALSE) +#endif + +#define HLWORD(hb,lb) ( ((UINT16)(hb)<< 8) | ((UINT16)(lb) & 0x00FF) ) + +#define SW1_PIN FIO0PIN +#define SW1_BIT BIT(29) +#define SW2_PIN SW1_PIN +#define SW2_BIT BIT(18) + +#define LED1_SET FIO0SET +#define LED1_DIR FIO0DIR +#define LED1_CLR FIO0CLR +#define LED1_PIN FIO0PIN +#define LED1_BIT BIT(21) /* MCI PWR */ + +#if 0 +#define LED2_SET FIO1SET +#define LED2_DIR FIO1DIR +#define LED2_CLR FIO1CLR +#define LED2_BIT BIT(26) /* LCD BL */ +#endif + +#define HOST_BAUD_U0 (115200) +#define HOST_BAUD_U1 (115200) + +#define WDOG() + +// PLL setup values are computed within the LPC include file +// It relies upon the following defines +// PLL input is the XTAL at FOSC +// FCCO is FOSC * PLL_MUL * 2 / PLL_DIV +// +#define FOSC (12000000) // Master Oscillator Freq. +#define PLL_MUL (11) // PLL Multiplier +#define PLL_DIV (0) // PLL Divider +#define CCLK_DIV (5) // PLL out -> CPU clock divider +#define FCCO ((FOSC * (PLL_MUL + 1) * 2) / (PLL_DIV + 1)) // PLLclk= 288 Mhz +#define CCLK ( FCCO / (CCLK_DIV + 1) ) // CPU Clock Freq. (48 Mhz) + +// Pheripheral Bus Speed Divider +#define PBSD 4 // MUST BE 1, 2, or 4 +#define PCLK (CCLK / PBSD) // Pheripheal Bus Clock Freq. + + +// The following ist not used in this example: +// Port Bit Definitions & Macros: Description - initial conditions +// Port 0 +#define P00_UNUSED_BIT BIT(0) // P0.00 unused - low output +#define P01_UNUSED_BIT BIT(1) // P0.01 unused - low output +#define P02_UNUSED_BIT BIT(2) // P0.02 unused - low output +#define P03_UNUSED_BIT BIT(3) // P0.03 unused - low output +#define P04_UNUSED_BIT BIT(4) // P0.04 unused - low output +#define P05_UNUSED_BIT BIT(5) // P0.05 unused - low output +#define P06_UNUSED_BIT BIT(6) // P0.06 unused - low output +#define P07_UNUSED_BIT BIT(7) // P0.06 unused - low output +#define P08_UNUSED_BIT BIT(8) // P0.08 unused - low output +#define P09_UNUSED_BIT BIT(9) // P0.09 unused - low output +#define P10_UNUSED_BIT BIT(10) // P0.10 unused - low output +#define P11_UNUSED_BIT BIT(11) // P0.11 unused - low output +#define P12_UNUSED_BIT BIT(12) // P0.12 unused - low output +#define P13_UNUSED_BIT BIT(13) // P0.13 unused - low output +#define P14_UNUSED_BIT BIT(14) // P0.14 unused - low output +#define P15_UNUSED_BIT BIT(15) // P0.15 unused - low output +#define P16_UNUSED_BIT BIT(16) // P0.16 unused - low output +#define P17_UNUSED_BIT BIT(17) // P0.17 unused - low output +#define P18_UNUSED_BIT BIT(18) // P0.18 unused - low output +#define P19_UNUSED_BIT BIT(19) // P0.19 unused - low output +#define P20_UNUSED_BIT BIT(20) // P0.20 unused - low output +#define P21_UNUSED_BIT BIT(21) // P0.21 unused - low output +#define P22_UNUSED_BIT BIT(22) // P0.22 unused - low output +#define P23_UNUSED_BIT BIT(23) // P0.23 unused - low output +#define P24_UNUSED_BIT BIT(24) // P0.24 unused - low output +#define P25_UNUSED_BIT BIT(25) // P0.25 unused - low output +#define P26_UNUSED_BIT BIT(26) // P0.26 unused - low output +#define P27_UNUSED_BIT BIT(27) // P0.27 unused - low output +#define P28_UNUSED_BIT BIT(28) // P0.28 unused - low output +#define P29_UNUSED_BIT BIT(29) // P0.29 unused - low output +#define P30_UNUSED_BIT BIT(30) // P0.30 unused - low output +#define P31_UNUSED_BIT BIT(31) // P0.31 unused - low output + +// Port 1 +// Port Bit Definitions & Macros: Description - initial conditions +#define P1_00_UNUSED_BIT BIT(0) // P1_0.00 unused - low output +#define P1_01_UNUSED_BIT BIT(1) // P1_0.01 unused - low output +#define P1_02_UNUSED_BIT BIT(2) // P1_0.02 unused - low output +#define P1_03_UNUSED_BIT BIT(3) // P1_0.03 unused - low output +#define P1_04_UNUSED_BIT BIT(4) // P1_0.04 unused - low output +#define P1_05_UNUSED_BIT BIT(5) // P1_0.05 unused - low output +#define P1_06_UNUSED_BIT BIT(6) // P1_0.06 unused - low output +#define P1_07_UNUSED_BIT BIT(7) // P1_0.06 unused - low output +#define P1_08_UNUSED_BIT BIT(8) // P1_0.08 unused - low output +#define P1_09_UNUSED_BIT BIT(9) // P1_0.09 unused - low output +#define P1_10_UNUSED_BIT BIT(10) // P1_0.10 unused - low output +#define P1_11_UNUSED_BIT BIT(11) // P1_0.11 unused - low output +#define P1_12_UNUSED_BIT BIT(12) // P1_0.12 unused - low output +#define P1_13_UNUSED_BIT BIT(13) // P1_0.13 unused - low output +#define P1_14_UNUSED_BIT BIT(14) // P1_0.14 unused - low output +#define P1_15_UNUSED_BIT BIT(15) // P1_0.15 unused - low output +#define P1_16_UNUSED_BIT BIT(16) // P1_0.16 unused - low output +#define P1_17_UNUSED_BIT BIT(17) // P1_0.17 unused - low output +#define P1_18_UNUSED_BIT BIT(18) // P1_0.18 unused - low output +#define P1_19_UNUSED_BIT BIT(19) // P1_0.19 unused - low output +#define P1_20_UNUSED_BIT BIT(20) // P1_0.20 unused - low output +#define P1_21_UNUSED_BIT BIT(21) // P1_0.21 unused - low output +#define P1_22_UNUSED_BIT BIT(22) // P1_0.22 unused - low output +#define P1_23_UNUSED_BIT BIT(23) // P1_0.23 unused - low output +#define P1_24_UNUSED_BIT BIT(24) // P1_0.24 unused - low output +#define P1_25_UNUSED_BIT BIT(25) // P1_0.25 unused - low output +#define P1_26_UNUSED_BIT BIT(26) // P1_0.26 unused - low output +#define P1_27_UNUSED_BIT BIT(27) // P1_0.27 unused - low output +#define P1_28_UNUSED_BIT BIT(28) // P1_0.28 unused - low output +#define P1_29_UNUSED_BIT BIT(29) // P1_0.29 unused - low output +#define P1_30_UNUSED_BIT BIT(30) // P1_0.30 unused - low output +#define P1_31_UNUSED_BIT BIT(31) // P1_0.31 unused - low output + + +#define PIO_INPUT_BITS (uint32_t) ( \ + 0 ) + +#define PIO_ZERO_BITS (uint32_t) ( \ + P00_UNUSED_BIT | \ + P01_UNUSED_BIT | \ + P02_UNUSED_BIT | \ + P03_UNUSED_BIT | \ + P04_UNUSED_BIT | \ + P05_UNUSED_BIT | \ + P06_UNUSED_BIT | \ + P07_UNUSED_BIT | \ + P08_UNUSED_BIT | \ + P09_UNUSED_BIT | \ + P10_UNUSED_BIT | \ + P11_UNUSED_BIT | \ + P12_UNUSED_BIT | \ + P13_UNUSED_BIT | \ + P14_UNUSED_BIT | \ + P15_UNUSED_BIT | \ + P16_UNUSED_BIT | \ + P16_UNUSED_BIT | \ + P17_UNUSED_BIT | \ + P18_UNUSED_BIT | \ + P19_UNUSED_BIT | \ + P20_UNUSED_BIT | \ + P21_UNUSED_BIT | \ + P22_UNUSED_BIT | \ + P23_UNUSED_BIT | \ + P24_UNUSED_BIT | \ + P25_UNUSED_BIT | \ + P26_UNUSED_BIT | \ + P27_UNUSED_BIT | \ + P28_UNUSED_BIT | \ + P29_UNUSED_BIT | \ + P30_UNUSED_BIT | \ + P31_UNUSED_BIT | \ + 0 ) + +#define PIO_ONE_BITS (uint32_t) ( \ + 0 ) + +#define PIO_OUTPUT_BITS (uint32_t) ( \ + PIO_ZERO_BITS | \ + PIO_ONE_BITS ) + +#endif diff --git a/Tester/SW/inc/types.h b/Tester/SW/inc/types.h new file mode 100644 index 0000000..b5c0444 --- /dev/null +++ b/Tester/SW/inc/types.h @@ -0,0 +1,108 @@ +/* --------------------------------------------------------------------------- + * types.h - v0.1 (c) 2007 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: Contains definitions of native types. + * --------------------------------------------------------------------------- + * Version(s): 0.1, 10-09-2007, Marcel Mulder. + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef __TYPES_H__ +#define __TYPES_H__ +/** \file types.h + \brief Contains the native types of LPC2378 +*/ +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ +#define UINT8 unsigned char +#define UINT16 unsigned short +#define UINT32 unsigned int + + +typedef unsigned long long UINT64; // Unsigned 64 bit quantity + + +#define pUINT8 unsigned char * +#define pUINT16 unsigned short * +#define pUINT32 unsigned int * + + +#define INT8 char +#define INT16 short +#define INT32 int + + +#define pINT8 char * +#define pINT16 short * +#define pINT32 int * + + +#ifndef BIT +#define BIT(n) (1L << (n)) +#endif + +#ifndef NULL +#define NULL (0) +#endif + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ +#ifdef fsasfd +typedef enum +{ + FALSE = 0, /**< Definition of false*/ + TRUE +} BOOLEAN; +#endif + +#ifndef FALSE +#define FALSE (1 == 0) +#endif + +#ifndef TRUE +#define TRUE (1==1) +#endif + +#define BOOLEAN char + + +typedef enum +{ + ERROR = 0, /**< Definition for ERROR*/ + OK +} RESULT; + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ + +#endif /* __TYPES_H__ */ diff --git a/Tester/SW/lib/BusProtocol/.cproject b/Tester/SW/lib/BusProtocol/.cproject new file mode 100644 index 0000000..864a446 --- /dev/null +++ b/Tester/SW/lib/BusProtocol/.cproject @@ -0,0 +1,607 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tester/SW/lib/BusProtocol/.project b/Tester/SW/lib/BusProtocol/.project new file mode 100644 index 0000000..87fb733 --- /dev/null +++ b/Tester/SW/lib/BusProtocol/.project @@ -0,0 +1,84 @@ + + + BusProtocol + + + Drivers + FreeRTOS + inc + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + org.eclipse.cdt.make.core.cleanBuildTarget + clean + + + org.eclipse.cdt.make.core.enableCleanBuild + true + + + org.eclipse.cdt.make.core.append_environment + true + + + ?name? + + + + org.eclipse.cdt.make.core.stopOnError + true + + + org.eclipse.cdt.make.core.buildCommand + make + + + org.eclipse.cdt.make.core.contents + org.eclipse.cdt.make.core.activeConfigSettings + + + org.eclipse.cdt.make.core.buildLocation + ${workspace_loc:/BusProtocol/Debug} + + + org.eclipse.cdt.make.core.useDefaultBuildCmd + true + + + org.eclipse.cdt.make.core.enableFullBuild + true + + + org.eclipse.cdt.make.core.enableAutoBuild + false + + + org.eclipse.cdt.make.core.fullBuildTarget + all + + + org.eclipse.cdt.make.core.buildArguments + + + + org.eclipse.cdt.make.core.autoBuildTarget + all + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.core.cnature + + diff --git a/Tester/SW/lib/BusProtocol/BpMessageFormat.c b/Tester/SW/lib/BusProtocol/BpMessageFormat.c new file mode 100644 index 0000000..4d27f62 --- /dev/null +++ b/Tester/SW/lib/BusProtocol/BpMessageFormat.c @@ -0,0 +1,131 @@ +/* --------------------------------------------------------------------------- + * BpMessageFormat.c - v0.1 (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Jan 29, 2008, FSc + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "BpMessageFormat.h" +#include "Crc.h" + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ + + +/** \brief Calculates the CRC over payload etc... and sets unique start byte + * + * \param msg Message over which the CRC should be calculated + */ +void bpmsgEncodeMessage( t_bpmsg_message * msg ) +{ + UINT16 crc; + + crc = crcCalc( &msg->payloadSize, 1, 0); + crc = crcCalc( msg->payload, msg->payloadSize, crc); + + msg->crc = crc; +} + + +void bpmsgAdd16bit(UINT8 *payloadlocation, UINT16 data) +{ + UINT8 index = 0; + + payloadlocation[index] = (UINT8)(data >> 8); + index++; + payloadlocation[index] = (UINT8)(data & 0x00FF); +} + + +void bpmsgAdd32bit(UINT8 *payloadlocation, UINT32 data) +{ + UINT8 index = 0; + + payloadlocation[index] = (UINT8)(data >> 24); + index++; + payloadlocation[index] = (UINT8)(data >> 16); + index++; + payloadlocation[index] = (UINT8)(data >> 8); + index++; + payloadlocation[index] = (UINT8)(data & 0xFF); + +} + +UINT8 bpmsgGet8bit(UINT8 *payload, UINT8 *payloadIndex) +{ + UINT8 result; + + result = (UINT8)payload[*payloadIndex]; + (*payloadIndex)++; + + return result; +} + + +UINT16 bpmsgGet16bit(UINT8 *payload, UINT8 *payloadIndex) +{ + UINT16 result; + + result = ((UINT16)payload[*payloadIndex]) << 8; + (*payloadIndex)++; + result += ((UINT16)payload[*payloadIndex] & 0x00FF); + (*payloadIndex)++; + + return result; +} + + +UINT32 bpmsgGet32bit(UINT8 *payload, UINT8 *payloadIndex) +{ + UINT32 result; + + result = ((UINT32)payload[*payloadIndex]) << 24; + (*payloadIndex)++; + result += ((UINT32)payload[*payloadIndex]) << 16; + (*payloadIndex)++; + result += ((UINT32)payload[*payloadIndex]) << 8; + (*payloadIndex)++; + result += ((UINT32)payload[*payloadIndex] & 0x000000FF); + (*payloadIndex)++; + + return result; +} + diff --git a/Tester/SW/lib/BusProtocol/BpMessageFormat.h b/Tester/SW/lib/BusProtocol/BpMessageFormat.h new file mode 100644 index 0000000..c87aa6f --- /dev/null +++ b/Tester/SW/lib/BusProtocol/BpMessageFormat.h @@ -0,0 +1,102 @@ +/* --------------------------------------------------------------------------- + * BpMessageFormat.h - v0.1 (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Jan 29, 2008, FSc + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef __BPMESSAGEFORMAT_H__ +#define __BPMESSAGEFORMAT_H__ +/** \file BpMessageFormat.h + \brief +*/ + +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ +#include "types.h" + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ +#define BPMSG_STARTBYTE (0xAA) + +#define BPMSG_MSGID_PASSTURN (0x00) +#define BPMSG_MSGID_RESETCLIENT (0x01) +#define BPMSG_MSGID_GIVEELECTRONICSTATUS (0x02) +#define BPMSG_MSGID_SETDACVALUE (0x03) +#define BPMSG_MSGID_SETDIGITALOUTVALUE (0x04) +#define BPMSG_MSGID_SETADCMODE (0x05) +#define BPMSG_MSGID_SETALLDIGITALOUT (0x06) +#define BPMSG_MSGID_SETALLDACVALUES (0x07) +#define BPMSG_MSGID_SETALLDOUTPUT (0x08) +#define BPMSG_MSGID_CALLRPC (0x10) +#define BPMSG_MSGID_GIVERPCRESULTS (0x11) + +#define BPMSG_BROADCAST_ID (0xFF) +#define BPMSG_MASTER_DEVID (0x01) +#define BPMSG_STATUS_FINISHEDSENDING (0xC0) +#define BPMSG_STATUS_BUSYSENDING (0x40) +#define BPMSG_DACMODE_VOLTAGE (0x00) +#define BPMSG_DACMODE_CURRENT (0x01) +#define BPMSG_ADCMODE_VOLTAGE (0x00) +#define BPMSG_ADCMODE_CURRENT (0x01) +#define BPMSG_RPC_ERRORRESULT (0xFF) + +#define BPMSG_UINT32_SIZE (4) +#define BPMSG_UINT16_SIZE (2) +#define BPMSG_UINT8_SIZE (1) + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ +typedef struct t_BPMSG_MESSAGE { + UINT8 uniqueStartByte; + UINT8 senderId; + UINT8 targetId; + UINT8 packetNr; + UINT8 status; + UINT8 messageId; + UINT8 payloadSize; + UINT8 *payload; + UINT16 crc; +} t_bpmsg_message; + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ + +/** \brief Calculates the CRC over payload and sets unique start byte */ +void bpmsgEncodeMessage( t_bpmsg_message * msg ); +void bpmsgAdd16bit(UINT8 *payloadlocation, UINT16 data); +void bpmsgAdd32bit(UINT8 *payloadlocation, UINT32 data); +UINT8 bpmsgGet8bit(UINT8 *payload, UINT8 *payloadIndex); +UINT16 bpmsgGet16bit(UINT8 *payload, UINT8 *payloadIndex); +UINT32 bpmsgGet32bit(UINT8 *payload, UINT8 *payloadIndex); + +#endif /* __BPMESSAGEFORMAT_H__ */ diff --git a/Tester/SW/lib/BusProtocol/BusProtocol.c b/Tester/SW/lib/BusProtocol/BusProtocol.c new file mode 100644 index 0000000..c163112 --- /dev/null +++ b/Tester/SW/lib/BusProtocol/BusProtocol.c @@ -0,0 +1,685 @@ +/* --------------------------------------------------------------------------- + * BusProtocol.c - v0.1 (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Jan 28, 2008, FSc + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +#include +#include + +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "types.h" +#include "BusProtocol.h" +#include "ProtocolThread.h" +#include "MessageHandlerQueue.h" +#include "RemoteProcedureCalls.h" +#include "RpcResults.h" +#include "bus.h" +#include "serial.h" +#include "ElecStatusCache.h" +#include "mem_mod.h" + +#include "FreeRTOS.h" + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ +typedef struct t_BP_ADMIN { + UINT8 deviceId; + UINT8 rpcRequestNr; + int rpcHandle; + int rpcrHandle; + int bpthreadHandle; + int messageHandlerHandle; +} t_bp_admin; + +memman *bpMessagePool; + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ +static void WriteElectricStatusCallback( int handle, BOOLEAN isDigital, UINT8 device, UINT8 channel, UINT16 value ); + +/** \brief Initialises the BusProtocol + * + * \param bus The bus to communicate on + * \param deviceId the bus identity for this device + * \retval the handle for the BusProtocol-driver (0 = unsuccesfull) + */ +int bpInit( t_bus_devices recvBus, t_bus_devices sendBus, UINT8 deviceId, UINT8 highestDeviceId, UINT8 inputQueueSize ) +{ + t_bp_admin *newBusProtocol = (t_bp_admin *)pvPortMalloc( sizeof(t_bp_admin)); + + if (newBusProtocol != NULL) + { + // Fill administration + newBusProtocol->deviceId = deviceId; + newBusProtocol->rpcRequestNr = 0; + newBusProtocol->rpcHandle = rpcInit(); + newBusProtocol->rpcrHandle = rpcrInit(); + newBusProtocol->messageHandlerHandle = mhqInit(); + + // Allocate payload queue + bpMessagePool = Memmod_Create( inputQueueSize, 64); // Make sure size is dividable by 4 + + // Register RPC Callback + mhqAdd( newBusProtocol->messageHandlerHandle, BPMSG_MSGID_CALLRPC, rpcRequestHandler, newBusProtocol->rpcHandle ); + + // Register RPC-result Callback + mhqAdd( newBusProtocol->messageHandlerHandle, BPMSG_MSGID_GIVERPCRESULTS, rpcrRequestHandler, newBusProtocol->rpcrHandle ); + + // Register Write electronic status callbac ) + bpecAttachWriteCallback(newBusProtocol, WriteElectricStatusCallback); + + // Open bus + busInit(recvBus); + if (recvBus != sendBus) + { + busInit(sendBus); + } + + // Create & start thread to poll bus + newBusProtocol->bpthreadHandle = bpthreadStart( recvBus, sendBus, deviceId, highestDeviceId, (int)newBusProtocol, newBusProtocol->messageHandlerHandle ); + } + + return (int)newBusProtocol; +} + +/** \brief Closes the active BusProtocol + * + * \post Protocol on this handle cannot be used anymore + * \param handle The handle for the BusProtocol (received with bpInit()) + */ +void bpDeinit( int handle ) +{ + // Stop & Destroy the bus poll thread + rpcDeinit( ((t_bp_admin *)handle)->rpcHandle ); + rpcrDeinit( ((t_bp_admin *)handle)->rpcrHandle ); + bpthreadStop( ((t_bp_admin *)handle)->bpthreadHandle ); + + // Free BusProtocol-administration + vPortFree( (void *)handle ); +} + + +/** \brief Indicates whether a message a device is received in the last 10 seconds + * Only used by the master + */ +BOOLEAN bpDeviceIsDetected( int handle, UINT8 deviceId ) +{ + return bpthreadDeviceIsDetected(((t_bp_admin *)handle)->bpthreadHandle, deviceId); +} + + +/** \brief Sends message to pass turn (Nothing to send) + * + * \param handle The handle for the BusProtocol (received with bpInit()) + */ +void bpSendPassTurn( int handle ) +{ + t_bpmsg_message sendPassTurnMessage; + + BP_DEBUG_OUT('p');BP_DEBUG_OUT('>'); + + // Create new message + sendPassTurnMessage.uniqueStartByte = BPMSG_STARTBYTE; + sendPassTurnMessage.senderId = ((t_bp_admin *)handle)->deviceId; + sendPassTurnMessage.targetId = BPMSG_BROADCAST_ID; + sendPassTurnMessage.packetNr = 0; // packetNr filled at transmitting time + sendPassTurnMessage.status = 0; // Clear status (filled by ProtocolThread) + sendPassTurnMessage.messageId = BPMSG_MSGID_PASSTURN; + sendPassTurnMessage.payloadSize = 0; + sendPassTurnMessage.payload = NULL; + + // Calculate CRC + bpmsgEncodeMessage(&sendPassTurnMessage); + + bpthreadAddMessage(((t_bp_admin *)handle)->bpthreadHandle, &sendPassTurnMessage); +} + +/** \brief Sends message to reset another bus device + * + * \param handle The handle for the BusProtocol (received with bpInit()) + * \param deviceId Identity of targeted bus device (0xFF = all devices) + */ +void bpSendResetClient( int handle, UINT8 deviceId ) +{ + t_bpmsg_message sendResetClientMessage; + + // Create new message + sendResetClientMessage.uniqueStartByte = BPMSG_STARTBYTE; + sendResetClientMessage.senderId = ((t_bp_admin *)handle)->deviceId; + sendResetClientMessage.targetId = deviceId; + sendResetClientMessage.packetNr = 0; // packetNr filled at transmitting time + sendResetClientMessage.status = 0; // Clear status (filled by ProtocolThread) + sendResetClientMessage.messageId = BPMSG_MSGID_RESETCLIENT; + sendResetClientMessage.payloadSize = 0; + sendResetClientMessage.payload = NULL; + + // Calculate CRC + bpmsgEncodeMessage(&sendResetClientMessage); + + bpthreadAddMessage(((t_bp_admin *)handle)->bpthreadHandle, &sendResetClientMessage); +} + +/** \brief Sends message with all electronic information (DAC's, ADC's and digital I/O) + * + * Broadcasts the electronic status of the device + * + * \param handle The handle for the BusProtocol (received with bpInit()) + * \param nrOfAdcValues Number of ADC-values included in the message + * \param adcValues Pointer to a UINT16 array + * \param nrOfDacValues Number of DAC-values included in the message + * \param dacValues Pointer to a UINT16 array + * \param nrOfDiValues Number of digital input values included in the message + * \param diValues Digital input channel values (8 channels per byte) + * \param nrOfDoValues Number of digital output values inculded in the message + * \param doValues Digital output channel values (8 channels per byte) + */ +void bpSendGiveElectronicStatus( int handle, + UINT8 nrOfAdcValues, + UINT16 *adcValues, + UINT8 nrOfDacValues, + UINT16 *dacValues, + UINT8 nrOfDiValues, + UINT8 *diValues, + UINT8 nrOfDoValues, + UINT8 *doValues + ) +{ + t_bpmsg_message sendGiveElectronicStatusMessage; + UINT8 *payload; + UINT16 payloadSize; + UINT8 payloadIndex = 0; + UINT8 index; + + // Determine payload size + payloadSize = BPMSG_UINT8_SIZE; + payloadSize += nrOfAdcValues * BPMSG_UINT16_SIZE; + payloadSize += BPMSG_UINT8_SIZE; + payloadSize += nrOfDacValues * BPMSG_UINT16_SIZE; + payloadSize += BPMSG_UINT8_SIZE; + payloadSize += nrOfDiValues * BPMSG_UINT8_SIZE; + payloadSize += BPMSG_UINT8_SIZE; + payloadSize += nrOfDoValues * BPMSG_UINT8_SIZE; + + payload = (UINT8 *)Memmod_Alloc( bpMessagePool ); + if (payload == 0) return; + + // Create new message + sendGiveElectronicStatusMessage.uniqueStartByte = BPMSG_STARTBYTE; + sendGiveElectronicStatusMessage.senderId = ((t_bp_admin *)handle)->deviceId; + sendGiveElectronicStatusMessage.targetId = BPMSG_BROADCAST_ID; + sendGiveElectronicStatusMessage.packetNr = 0; // packetNr filled at transmitting time + sendGiveElectronicStatusMessage.status = 0; // Clear status (filled by ProtocolThread) + sendGiveElectronicStatusMessage.messageId = BPMSG_MSGID_GIVEELECTRONICSTATUS; + sendGiveElectronicStatusMessage.payloadSize = payloadSize; + sendGiveElectronicStatusMessage.payload = payload; + + // Fill Payload + payload[payloadIndex] = nrOfAdcValues; + payloadIndex += BPMSG_UINT8_SIZE; + for (index = 0; index < nrOfAdcValues; index++) + { + bpmsgAdd16bit( &payload[payloadIndex], adcValues[index]); + payloadIndex += BPMSG_UINT16_SIZE; + } + + payload[payloadIndex] = nrOfDacValues; + payloadIndex += BPMSG_UINT8_SIZE; + for (index = 0; index < nrOfDacValues; index++) + { + bpmsgAdd16bit( &payload[payloadIndex], dacValues[index]); + payloadIndex += BPMSG_UINT16_SIZE; + } + + payload[payloadIndex] = nrOfDiValues; + payloadIndex += BPMSG_UINT8_SIZE; + for (index = 0; index < nrOfDiValues; index++) + { + payload[payloadIndex] = diValues[index]; + payloadIndex += BPMSG_UINT8_SIZE; + } + + payload[payloadIndex] = nrOfDoValues; + payloadIndex += BPMSG_UINT8_SIZE; + for (index = 0; index < nrOfDoValues; index++) + { + payload[payloadIndex] = doValues[index]; + payloadIndex += BPMSG_UINT8_SIZE; + } + + // Calculate CRC + bpmsgEncodeMessage(&sendGiveElectronicStatusMessage); + + bpthreadAddMessage(((t_bp_admin *)handle)->bpthreadHandle, &sendGiveElectronicStatusMessage); +} + +/** \brief Sends message to set a DAC on another bus device + * + * \param handle The handle for the BusProtocol (received with bpInit()) + * \param deviceId Identity of targeted bus device + * \param channelNr Number of the DAC-channel + * \param dacMode Voltage (0) / Ampere (<> 0) + * \param davValue New DAC value (voltage: 0-10000mV, ampere: 0-20000uA) + */ +void bpSendSetDacValue( int handle, UINT8 deviceId, UINT8 channelNr, UINT8 dacMode, UINT16 dacValue ) +{ + t_bpmsg_message sendSetDacMessage; + UINT8 *payload = (UINT8 *) Memmod_Alloc( bpMessagePool ); + if (payload == 0) return; + + BP_DEBUG_OUT('a'); BP_DEBUG_OUT('>'); + + // Create new message + sendSetDacMessage.uniqueStartByte = BPMSG_STARTBYTE; + sendSetDacMessage.senderId = ((t_bp_admin *)handle)->deviceId; + sendSetDacMessage.targetId = deviceId; + sendSetDacMessage.packetNr = 0; // packetNr filled at transmitting time + sendSetDacMessage.status = 0; // Clear status (filled by ProtocolThread) + sendSetDacMessage.messageId = BPMSG_MSGID_SETDACVALUE; + sendSetDacMessage.payloadSize = 4; + sendSetDacMessage.payload = payload; + + // Fill Payload + payload[0] = channelNr; + payload[1] = dacMode; + bpmsgAdd16bit( &payload[2], dacValue); + + // Calculate CRC + bpmsgEncodeMessage(&sendSetDacMessage); + + bpthreadAddMessage(((t_bp_admin *)handle)->bpthreadHandle, &sendSetDacMessage); +} + +/** \brief Sends message to set the values of all DAC's on another bus device + * + * \param handle The handle for the BusProtocol (received with bpInit()) + * \param deviceId Identity of targeted bus device + * \param davValue pointer to array with 4 DAC value, i.e. DAC-value position 0 for Channel 0 etc... (voltage: 0-10000mV, ampere: 0-20000uA) + */ +void bpSendSetAllDacValues( int handle, UINT8 deviceId, UINT16 *dacValue ) +{ + t_bpmsg_message sendSetDacMessage; + UINT8 *payload = (UINT8 *) Memmod_Alloc( bpMessagePool ); + if (payload == 0) return; + + BP_DEBUG_OUT('a'); BP_DEBUG_OUT('>'); + + // Create new message + sendSetDacMessage.uniqueStartByte = BPMSG_STARTBYTE; + sendSetDacMessage.senderId = ((t_bp_admin *)handle)->deviceId; + sendSetDacMessage.targetId = deviceId; + sendSetDacMessage.packetNr = 0; // packetNr filled at transmitting time + sendSetDacMessage.status = 0; // Clear status (filled by ProtocolThread) + sendSetDacMessage.messageId = BPMSG_MSGID_SETALLDACVALUES; + sendSetDacMessage.payloadSize = 4 * 2; + sendSetDacMessage.payload = payload; + + // Fill Payload + bpmsgAdd16bit( &payload[0], dacValue[0]); + bpmsgAdd16bit( &payload[2], dacValue[1]); + bpmsgAdd16bit( &payload[4], dacValue[2]); + bpmsgAdd16bit( &payload[6], dacValue[3]); + + // Calculate CRC + bpmsgEncodeMessage(&sendSetDacMessage); + + bpthreadAddMessage(((t_bp_admin *)handle)->bpthreadHandle, &sendSetDacMessage); +} + + +/** \brief Sends message to set a digital out on another bus device + * + * \param handle The handle for the BusProtocol (received with bpInit()) + * \param bitNr Number of the digital output pin + * \param value Low-level (0) or High-level (<> 0) + */ +void bpSendSetDigitalOutValue( int handle, UINT8 deviceId, UINT8 bitNr, UINT8 value ) +{ + t_bpmsg_message sendSetDoMessage; + UINT8 *payload = (UINT8 *)Memmod_Alloc( bpMessagePool ); + if (payload == 0) return; + + BP_DEBUG_OUT('d'); BP_DEBUG_OUT('>'); + + // Create new message + sendSetDoMessage.uniqueStartByte = BPMSG_STARTBYTE; + sendSetDoMessage.senderId = ((t_bp_admin *)handle)->deviceId; + sendSetDoMessage.targetId = deviceId; + sendSetDoMessage.packetNr = 0; // packetNr filled at transmitting time + sendSetDoMessage.status = 0; // Clear status (filled by ProtocolThread) + sendSetDoMessage.messageId = BPMSG_MSGID_SETDIGITALOUTVALUE; + sendSetDoMessage.payloadSize = 2; + sendSetDoMessage.payload = payload; + + // Fill Payload + payload[0] = bitNr; + payload[1] = value; + + // Calculate CRC + bpmsgEncodeMessage(&sendSetDoMessage); + + bpthreadAddMessage(((t_bp_admin *)handle)->bpthreadHandle, &sendSetDoMessage); +} + +/** \brief Sends message to set all digital out ports at once on another bus device + * + * \param handle The handle for the BusProtocol (received with bpInit()) + * \param deviceId The ID of the other bus device + * \param bits All bitsNumber of the digital output pin + */ +void bpSendSetAllDigitalOut( int handle, UINT8 deviceId, UINT8 bits) +{ + t_bpmsg_message sendSetDoMessage; + UINT8 *payload = (UINT8 *)Memmod_Alloc( bpMessagePool ); + if (payload == 0) return; + + BP_DEBUG_OUT('d'); BP_DEBUG_OUT('>'); + + // Create new message + sendSetDoMessage.uniqueStartByte = BPMSG_STARTBYTE; + sendSetDoMessage.senderId = ((t_bp_admin *)handle)->deviceId; + sendSetDoMessage.targetId = deviceId; + sendSetDoMessage.packetNr = 0; // packetNr filled at transmitting time + sendSetDoMessage.status = 0; // Clear status (filled by ProtocolThread) + sendSetDoMessage.messageId = BPMSG_MSGID_SETALLDIGITALOUT; + sendSetDoMessage.payloadSize = 1; + sendSetDoMessage.payload = payload; + + // Fill Payload + payload[0] = bits; + + // Calculate CRC + bpmsgEncodeMessage(&sendSetDoMessage); + + bpthreadAddMessage(((t_bp_admin *)handle)->bpthreadHandle, &sendSetDoMessage); +} + +/** \brief Sends message to set all outputs (analogue & digital) on another bus device +* +* \param handle The handle for the BusProtocol (received with bpInit()) +* \param deviceId Identity of targeted bus device +* \param bits All bitsNumber of the digital output pin +* \param davValue pointer to array with 4 DAC value, i.e. DAC-value position 0 for Channel 0 etc... (voltage: 0-10000mV, ampere: 0-20000uA) +*/ +void bpSendSetAllOutput( int handle, UINT8 deviceId, UINT8 bits, UINT16 *dacValue ) +{ + t_bpmsg_message sendSetAllOutpuntMessage; + UINT8 *payload = (UINT8 *) Memmod_Alloc( bpMessagePool ); + if (payload == 0) return; + + BP_DEBUG_OUT('a'); BP_DEBUG_OUT('o'); BP_DEBUG_OUT('>'); + + // Create new message + sendSetAllOutpuntMessage.uniqueStartByte = BPMSG_STARTBYTE; + sendSetAllOutpuntMessage.senderId = ((t_bp_admin *)handle)->deviceId; + sendSetAllOutpuntMessage.targetId = deviceId; + sendSetAllOutpuntMessage.packetNr = 0; // packetNr filled at transmitting time + sendSetAllOutpuntMessage.status = 0; // Clear status (filled by ProtocolThread) + sendSetAllOutpuntMessage.messageId = BPMSG_MSGID_SETALLDOUTPUT; + sendSetAllOutpuntMessage.payloadSize = (4 * 2) + 1; + sendSetAllOutpuntMessage.payload = payload; + + // Fill Payload + payload[0] = bits; + bpmsgAdd16bit( &payload[1], dacValue[0]); + bpmsgAdd16bit( &payload[3], dacValue[1]); + bpmsgAdd16bit( &payload[5], dacValue[2]); + bpmsgAdd16bit( &payload[7], dacValue[3]); + + // Calculate CRC + bpmsgEncodeMessage(&sendSetAllOutpuntMessage); + + bpthreadAddMessage(((t_bp_admin *)handle)->bpthreadHandle, &sendSetAllOutpuntMessage); +} + + +/** \brief Sends message to call an Remote Procedure Call on an other bus device + * + * Request to execute a procedure on another device + * + * \param handle The handle for the BusProtocol (received with bpInit()) + * \param deviceId Identity of targeted bus device + * \param functionId Identity of the RPC-function + * \param nrOfParams Number of parameters for the RPC-function + * \param params Pointer to an array of 32-bit integers + */ +void bpSendCallRpc( int handle, UINT8 deviceId, UINT8 functionId, UINT8 nrOfParams, INT32 *params ) +{ + t_bpmsg_message sendCallRpcMessage; + UINT8 *payload; + UINT8 payloadSize; + UINT8 payloadIndex = 0; + UINT8 index; + + BP_DEBUG_OUT('c'); BP_DEBUG_OUT('>'); + + // Determine payload size + payloadSize = 3 * BPMSG_UINT8_SIZE; + payloadSize += nrOfParams * BPMSG_UINT32_SIZE; + + payload = (UINT8 *)Memmod_Alloc( bpMessagePool ); + if (payload == 0) return; + + // Create new message + sendCallRpcMessage.uniqueStartByte = BPMSG_STARTBYTE; + sendCallRpcMessage.senderId = ((t_bp_admin *)handle)->deviceId; + sendCallRpcMessage.targetId = deviceId; + sendCallRpcMessage.packetNr = 0; // packetNr filled at transmitting time + sendCallRpcMessage.status = 0; // Clear status (filled by ProtocolThread) + sendCallRpcMessage.messageId = BPMSG_MSGID_CALLRPC; + sendCallRpcMessage.payloadSize = payloadSize; + sendCallRpcMessage.payload = payload; + + // Fill Payload + payload[payloadIndex] = ((t_bp_admin *)handle)->rpcRequestNr; + ((t_bp_admin *)handle)->rpcRequestNr++; + payloadIndex += BPMSG_UINT8_SIZE; + + payload[payloadIndex] = functionId; + payloadIndex += BPMSG_UINT8_SIZE; + + payload[payloadIndex] = nrOfParams; + payloadIndex += BPMSG_UINT8_SIZE; + + for (index = 0; index < nrOfParams; index++) + { + bpmsgAdd32bit( payload + payloadIndex, (UINT32)params[index]); + payloadIndex += BPMSG_UINT32_SIZE; + } + + if (payloadIndex >= 54) + { + serWrite(1, sizeof("Message too large"), "Message too large"); + } + + // Calculate CRC + bpmsgEncodeMessage(&sendCallRpcMessage); + + bpthreadAddMessage(((t_bp_admin *)handle)->bpthreadHandle, &sendCallRpcMessage); +} + +/** \brief Sends message to give result on issued RPC-function + * + * \param handle The handle for the BusProtocol (received with bpInit()) + * \param nrOfResults Number of results to be send + * \param results Pointer to array with results. + */ +void bpSendRpcResult( int handle, UINT8 deviceId, UINT8 functionId, UINT8 requestNr, UINT8 nrOfResults, INT32 *results ) +{ + t_bpmsg_message sendCallRpcResultMessage; + UINT8 *payload; + UINT8 payloadSize; + UINT8 payloadIndex = 0; + UINT8 index; + + BP_DEBUG_OUT('r'); BP_DEBUG_OUT('>'); + + // Determine payload size + payloadSize = 3 * BPMSG_UINT8_SIZE; + payloadSize += nrOfResults * BPMSG_UINT32_SIZE; + + payload = (UINT8 *)Memmod_Alloc( bpMessagePool ); + if (payload == 0) return; + + // Create new message + sendCallRpcResultMessage.uniqueStartByte = BPMSG_STARTBYTE; + sendCallRpcResultMessage.senderId = ((t_bp_admin *)handle)->deviceId; + sendCallRpcResultMessage.targetId = deviceId; + sendCallRpcResultMessage.packetNr = 0; // packetNr filled at transmitting time + sendCallRpcResultMessage.status = 0; // Clear status (filled by ProtocolThread) + sendCallRpcResultMessage.messageId = BPMSG_MSGID_GIVERPCRESULTS; + sendCallRpcResultMessage.payloadSize = payloadSize; + sendCallRpcResultMessage.payload = payload; + + // Fill Payload + payload[payloadIndex] = requestNr; + payloadIndex += BPMSG_UINT8_SIZE; + + payload[payloadIndex] = functionId; + payloadIndex += BPMSG_UINT8_SIZE; + + payload[payloadIndex] = nrOfResults; + payloadIndex += BPMSG_UINT8_SIZE; + + for (index = 0; index < nrOfResults; index++) + { + bpmsgAdd32bit( &payload[payloadIndex], (UINT32)results[index]); + payloadIndex += BPMSG_UINT32_SIZE; + } + + // Calculate CRC + bpmsgEncodeMessage(&sendCallRpcResultMessage); + + bpthreadAddMessage(((t_bp_admin *)handle)->bpthreadHandle, &sendCallRpcResultMessage); +} + + +/** \brief Attachs a callback, which is called when it is the device its turn to send data on the bus + * + * \param handle The handle for the BusProtocol (received with bpInit()) + * \param onMyTurnCallback pointer to the callback function + */ +void bpAttachOnMyTurn( int handle, t_bp_myturn_callback onMyTurnCallback ) +{ + t_bp_admin *bpAdmin = (t_bp_admin *)handle; + + bpthreadAttachMyTurn( bpAdmin->bpthreadHandle, onMyTurnCallback); +} + +/** \brief Detaches the above callback + * + * \param handle The handle for the BusProtocol (received with bpInit()) + * \param onMyTurnCallback pointer to the callback function + */ +void bpDetachOnMyTurn( int handle, t_bp_myturn_callback onMyTurnCallback ) +{ + t_bp_admin *bpAdmin = (t_bp_admin *)handle; + + bpthreadDetachMyTurn( bpAdmin->bpthreadHandle, onMyTurnCallback); +} + +/** \brief Attachs a RPC-function, which can be called by another bus device + * + * \param handle The handle for the BusProtocol (received with bpInit()) + * \param functionId The identity of the RPC-function + * \param functionPointer Pointer to actual RPC-function + * \param nrOfParams Number of parameters, required by RPC + */ +void bpAttachRpc( int handle, UINT8 functionId, char * functionName, t_rpc_remote_procedure_call functionPointer, UINT8 nrOfParams ) +{ + t_bp_admin *bpAdmin = (t_bp_admin *)handle; + + rpcAdd( bpAdmin->rpcHandle, functionId, functionName, functionPointer, nrOfParams); +} + +/** \brief Detaches the above RPC-function + * + * \post RPC-function is not supported anymore + * \param handle The handle for the BusProtocol (received with bpInit()) + * \param functionId Identity of the detached RPC-function + */ +void bpDetachRpc( int handle, UINT8 functionId ) +{ + t_bp_admin *bpAdmin = (t_bp_admin *)handle; + + rpcRemove( bpAdmin->rpcHandle, functionId ); +} + +/** \brief Attachs a "RPC result"-function, which is a result of a requeste RPC-call on another bus device + * + * \param handle The handle for the BusProtocol (returned by bpInit()) + * \param functionId The functionId on which the result should be catched + * \param functionPointer The funtion which must be called when a RPC-result is received. + */ +void bpAttachRpcResult( int handle, UINT8 functionId, t_bp_rpcresult_callback functionPointer, UINT8 nrOfResults ) +{ + t_bp_admin *bpAdmin = (t_bp_admin *)handle; + + rpcrAdd( bpAdmin->rpcrHandle, functionId, functionPointer, nrOfResults); +} + +/** \brief Detaches the above "RPC result"-function + * + * \param handle The handle for the BusProtocol (returned by bpInit()) + * \param functionId The functionId on which the result should be catched + */ +void bpDetachRpcResult( int handle, UINT8 functionId ) +{ + t_bp_admin *bpAdmin = (t_bp_admin *)handle; + + rpcrRemove( bpAdmin->rpcrHandle, functionId ); +} + +t_rpc_entity *bpLookupRpcEntry( int handle, UINT8 functionId ) +{ + t_bp_admin *bpAdmin = (t_bp_admin *)handle; + + return rpcLookupEntry( bpAdmin->rpcHandle, functionId ); +} + + +void WriteElectricStatusCallback( int handle, BOOLEAN isDigital, UINT8 device, UINT8 channel, UINT16 value ) +{ + if (isDigital) + { + bpSendSetDigitalOutValue( handle, device, channel, (BOOLEAN)value ) ; + } + else + { + bpSendSetDacValue( handle, device, channel, 0, value ); + } +} diff --git a/Tester/SW/lib/BusProtocol/BusProtocol.h b/Tester/SW/lib/BusProtocol/BusProtocol.h new file mode 100644 index 0000000..6941f91 --- /dev/null +++ b/Tester/SW/lib/BusProtocol/BusProtocol.h @@ -0,0 +1,141 @@ +/* --------------------------------------------------------------------------- + * BusProtocol.h - v0.1 (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Jan 28, 2008, FSc + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef __BUSPROTOCOL_H__ +#define __BUSPROTOCOL_H__ +/** \file BusProtocol.h + \brief Implementation of BusProtocol +*/ + +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ +#include "types.h" +#include "bus.h" +#include "RemoteProcedureCalls.h" +#include "BpMessageFormat.h" + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ +#define MASTER_DEVICE_ID (1) +#define MAX_PAYLOAD_SIZE (50) +#define BP_DEBUG_OUT(a) /* serPut( COM2, a) */ + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ +typedef void (*t_bp_myturn_callback)(void); +typedef void (*t_bp_rpcresult_callback)( UINT8 requestNr, UINT8 nrOfResults, UINT32 *results ); +typedef void (*t_bp_messagehandler)(t_bpmsg_message *receivedMessage, int ownHandler ); + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ + +/** \brief Initialises the BusProtocol */ +int bpInit( t_bus_devices recvBus, t_bus_devices sendBus, UINT8 deviceId, UINT8 highestDeviceId, UINT8 inputQueueSize ); + +/** \brief Closes the active BusProtocol */ +void bpDeinit( int handle ); + +/** \brief Indicates whether a message a device is received in the last 10 seconds + * Only used by the master + */ +BOOLEAN bpDeviceIsDetected( int handle, UINT8 deviceId ); + +/** \brief Sends message to pass turn (Nothing to send) */ +void bpSendPassTurn( int handle ); + +/** \brief Sends message to reset another bus device */ +void bpSendResetClient( int handle, UINT8 deviceId ); + +/** \brief Sends message with all electronic information (DAC's, ADC's and digital I/O) */ +void bpSendGiveElectronicStatus( int handle, + UINT8 nrOfAdcValues, + UINT16 *adcValues, + UINT8 nrOfDacValues, + UINT16 *dacValues, + UINT8 nrOfDiValues, + UINT8 *diValues, + UINT8 nrOfDoValues, + UINT8 *doValues + ); + +/** \brief Sends message to set a DAC on another bus device */ +void bpSendSetDacValue( int handle, UINT8 deviceId, UINT8 channelNr, UINT8 dacMode, UINT16 dacValue ); + +/** \brief Sends message to set the values of all DAC's on another bus device */ +void bpSendSetAllDacValues( int handle, UINT8 deviceId, UINT16 *dacValue ); + +/** \brief Sends message to set a digital out on another bus device */ +void bpSendSetDigitalOutValue( int handle, UINT8 deviceId, UINT8 bitNr, UINT8 value ); + +/** \brief Sends message to set all digital out ports at once on another bus device */ +void bpSendSetAllDigitalOut( int handle, UINT8 deviceId, UINT8 bits); + +/** \brief Sends message to set all outputs (analogue & digital) on another bus device */ +void bpSendSetAllOutput( int handle, UINT8 deviceId, UINT8 bits, UINT16 *dacValue); + +/** \brief Sends message to call an Remote Procedure Call on an other bus device */ +void bpSendCallRpc( int handle, UINT8 deviceId, UINT8 functionId, UINT8 nrOfParams, INT32 *params ); + +/** \brief Attachs a callback, which is called when it is the device its turn to send data on the bus */ +void bpAttachOnMyTurn( int handle, t_bp_myturn_callback onMyTurnCallback ); + +/** \brief Detaches the above callback */ +void bpDetachOnMyTurn( int handle, t_bp_myturn_callback onMyTurnCallback ); + +/** \brief Attach callback on receiving a specific message */ +void bpAttachMessageHandler( int handle, UINT8 messageId, t_bp_messagehandler messageHandler); + +/** \brief Attach callback on receiving a specific message */ +void bpDetachMessageHandler( int handle, UINT8 messageId, t_bp_messagehandler messageHandler); + +/** \brief Attachs a RPC-function, which can be called by another bus device */ +void bpAttachRpc( int handle, UINT8 functionId, char * functionName, t_rpc_remote_procedure_call functionPointer, UINT8 nrOfParams ); + +/** \brief Detaches the above RPC-function */ +void bpDetachRpc( int handle, UINT8 functionId ); + +/** \brief Attachs a "RPC result"-function, which is a result of a requeste RPC-call on another bus device */ +void bpAttachRpcResult( int handle, UINT8 functionId, t_bp_rpcresult_callback functionPointer, UINT8 nrOfResult ); + +/** \brief Detaches the above "RPC result"-function */ +void bpDetachRpcResult( int handle, UINT8 functionId ); + +t_rpc_entity *bpLookupRpcEntry( int handle, UINT8 functionId ); + +/** \brief Sends message to give result on issued RPC-function */ +void bpSendRpcResult( int handle, UINT8 deviceId, UINT8 functionId, UINT8 requestNr, UINT8 nrOfResults, INT32 *results ); + +#endif /* __BUSPROTOCOL_H__ */ diff --git a/Tester/SW/lib/BusProtocol/Crc.c b/Tester/SW/lib/BusProtocol/Crc.c new file mode 100644 index 0000000..1db20c2 --- /dev/null +++ b/Tester/SW/lib/BusProtocol/Crc.c @@ -0,0 +1,123 @@ +/* --------------------------------------------------------------------------- + * Crc.c - v0.1 (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Jan 31, 2008, FSc + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "crc.h" + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ +const UINT16 CRC_table[256] = +{ + 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7, + 0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF, + 0x1231, 0x0210, 0x3273, 0x2252, 0x52B5, 0x4294, 0x72F7, 0x62D6, + 0x9339, 0x8318, 0xB37B, 0xA35A, 0xD3BD, 0xC39C, 0xF3FF, 0xE3DE, + 0x2462, 0x3443, 0x0420, 0x1401, 0x64E6, 0x74C7, 0x44A4, 0x5485, + 0xA56A, 0xB54B, 0x8528, 0x9509, 0xE5EE, 0xF5CF, 0xC5AC, 0xD58D, + 0x3653, 0x2672, 0x1611, 0x0630, 0x76D7, 0x66F6, 0x5695, 0x46B4, + 0xB75B, 0xA77A, 0x9719, 0x8738, 0xF7DF, 0xE7FE, 0xD79D, 0xC7BC, + 0x48C4, 0x58E5, 0x6886, 0x78A7, 0x0840, 0x1861, 0x2802, 0x3823, + 0xC9CC, 0xD9ED, 0xE98E, 0xF9AF, 0x8948, 0x9969, 0xA90A, 0xB92B, + 0x5AF5, 0x4AD4, 0x7AB7, 0x6A96, 0x1A71, 0x0A50, 0x3A33, 0x2A12, + 0xDBFD, 0xCBDC, 0xFBBF, 0xEB9E, 0x9B79, 0x8B58, 0xBB3B, 0xAB1A, + 0x6CA6, 0x7C87, 0x4CE4, 0x5CC5, 0x2C22, 0x3C03, 0x0C60, 0x1C41, + 0xEDAE, 0xFD8F, 0xCDEC, 0xDDCD, 0xAD2A, 0xBD0B, 0x8D68, 0x9D49, + 0x7E97, 0x6EB6, 0x5ED5, 0x4EF4, 0x3E13, 0x2E32, 0x1E51, 0x0E70, + 0xFF9F, 0xEFBE, 0xDFDD, 0xCFFC, 0xBF1B, 0xAF3A, 0x9F59, 0x8F78, + 0x9188, 0x81A9, 0xB1CA, 0xA1EB, 0xD10C, 0xC12D, 0xF14E, 0xE16F, + 0x1080, 0x00A1, 0x30C2, 0x20E3, 0x5004, 0x4025, 0x7046, 0x6067, + 0x83B9, 0x9398, 0xA3FB, 0xB3DA, 0xC33D, 0xD31C, 0xE37F, 0xF35E, + 0x02B1, 0x1290, 0x22F3, 0x32D2, 0x4235, 0x5214, 0x6277, 0x7256, + 0xB5EA, 0xA5CB, 0x95A8, 0x8589, 0xF56E, 0xE54F, 0xD52C, 0xC50D, + 0x34E2, 0x24C3, 0x14A0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405, + 0xA7DB, 0xB7FA, 0x8799, 0x97B8, 0xE75F, 0xF77E, 0xC71D, 0xD73C, + 0x26D3, 0x36F2, 0x0691, 0x16B0, 0x6657, 0x7676, 0x4615, 0x5634, + 0xD94C, 0xC96D, 0xF90E, 0xE92F, 0x99C8, 0x89E9, 0xB98A, 0xA9AB, + 0x5844, 0x4865, 0x7806, 0x6827, 0x18C0, 0x08E1, 0x3882, 0x28A3, + 0xCB7D, 0xDB5C, 0xEB3F, 0xFB1E, 0x8BF9, 0x9BD8, 0xABBB, 0xBB9A, + 0x4A75, 0x5A54, 0x6A37, 0x7A16, 0x0AF1, 0x1AD0, 0x2AB3, 0x3A92, + 0xFD2E, 0xED0F, 0xDD6C, 0xCD4D, 0xBDAA, 0xAD8B, 0x9DE8, 0x8DC9, + 0x7C26, 0x6C07, 0x5C64, 0x4C45, 0x3CA2, 0x2C83, 0x1CE0, 0x0CC1, + 0xEF1F, 0xFF3E, 0xCF5D, 0xDF7C, 0xAF9B, 0xBFBA, 0x8FD9, 0x9FF8, + 0x6E17, 0x7E36, 0x4E55, 0x5E74, 0x2E93, 0x3EB2, 0x0ED1, 0x1EF0 +}; + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ + +/*! +* \brief Calculate 16 bit CRC +* +* a function to calculate an serial 16 bit CRC +* according to the CCITT V.024 standard +* To short down the calculation time of the serial CRC +* a hash table is used. +* This CRC is a fast (with hash table) and good CRC for +* data transfer and integrity test of data storage. It can effectively +* can detect errors by data transfer. 16 Bit is good for data blocks from +* 0 - 4 KByte with a residual risk for non detection of 10E-8 per transfer. +* (Multiply this with the error factor of the transmit line) +* +* The polynoom of CRC-16-CCIT = x^16 + x^12 + x^5 + 1 +* +* \param data Build the crc from this data block +* \param length Length of the data block +* \param feed Initial CRC value (take 0 by default) +*/ +UINT16 crcCalc(UINT8 * data, UINT32 length, UINT16 feed) +{ + unsigned short crc = feed; + unsigned char index; + unsigned int count; + + for(count=0; count> 8); + crc = crc & 0x00FF; + crc = (crc << 8); + crc &= 0xFF00; + crc = crc ^ CRC_table[index] ^ (*data & 0x00FF); + data++; + } + + return crc; +} + diff --git a/Tester/SW/lib/BusProtocol/Crc.h b/Tester/SW/lib/BusProtocol/Crc.h new file mode 100644 index 0000000..e398859 --- /dev/null +++ b/Tester/SW/lib/BusProtocol/Crc.h @@ -0,0 +1,59 @@ +/* --------------------------------------------------------------------------- + * Crc.h - v0.1 (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Jan 31, 2008, FSc + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef __CRC_H__ +#define __CRC_H__ +/** \file Crc.h + \brief +*/ + +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ +#include "types.h" + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ + +UINT16 crcCalc(UINT8 * pData, UINT32 length, UINT16 feed); + +#endif /* __CRC_H__ */ + diff --git a/Tester/SW/lib/BusProtocol/MessageHandlerQueue.c b/Tester/SW/lib/BusProtocol/MessageHandlerQueue.c new file mode 100644 index 0000000..07c304c --- /dev/null +++ b/Tester/SW/lib/BusProtocol/MessageHandlerQueue.c @@ -0,0 +1,204 @@ +/* --------------------------------------------------------------------------- + * MessageHandlerQueue.c - v0.1 (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Jan 30, 2008, FSc + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "MessageHandlerQueue.h" + +#include "FreeRTOS.h" +#include "task.h" + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ + +typedef struct t_mhq_ENTITY +{ + UINT8 messageId; + t_bp_messagehandler messageHandler; + int ownHandle; + struct t_mhq_ENTITY *next; + struct t_mhq_ENTITY *previous; +} t_mhq_entity; + +typedef struct t_mhq_ADMIN +{ + struct t_mhq_ENTITY *head; + struct t_mhq_ENTITY *tail; +} t_mhq_admin; + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ +static t_mhq_entity *lookupMhqEntry(int handle, UINT8 messageId); + + +int mhqInit() +{ + t_mhq_admin *newAdmin = (t_mhq_admin *)pvPortMalloc( sizeof(t_mhq_admin) ); + + newAdmin->head = NULL; + + return (int)newAdmin; +} + +void mhqDeinit(int handle) +{ + t_mhq_entity *iterator = ((t_mhq_admin *)handle)->head; + + while (iterator != NULL) + { + t_mhq_entity *nextItem = iterator->next; + vPortFree( iterator ); + iterator = nextItem; + } + + vPortFree( (t_mhq_admin *)handle ); +} + +void mhqAdd(int handle, UINT8 messageId, t_bp_messagehandler messageHandler, int ownHandle) +{ + t_mhq_admin *theAdmin = (t_mhq_admin *)handle; + t_mhq_entity *newEntry = (t_mhq_entity *)pvPortMalloc( sizeof(t_mhq_entity) ); + + // fill entry + newEntry->messageId = messageId; + newEntry->messageHandler = messageHandler; + newEntry->ownHandle = ownHandle; + newEntry->next = NULL; + newEntry->previous = NULL; + + taskENTER_CRITICAL(); + { + // Add to linked list + if (theAdmin->head != NULL) + { + theAdmin->tail->next = newEntry; + newEntry->previous = theAdmin->tail; + theAdmin->tail = newEntry; + } + else + { + theAdmin->head = newEntry; + theAdmin->tail = newEntry; + } + } + taskEXIT_CRITICAL(); +} + +void mhqRemove(int handle, UINT8 messageId, t_bp_messagehandler messageHandler) +{ + t_mhq_entity *entry = lookupMhqEntry(handle, messageId); + t_mhq_admin *theAdmin = (t_mhq_admin *)handle; + + taskENTER_CRITICAL(); + { + if (entry != NULL) + { + // rebuild linked list + if (entry->next != NULL) + { + entry->next->previous = entry->previous; + } + else + { + theAdmin->tail = entry->previous; + } + + if (entry->previous != NULL) + { + entry->previous->next = entry->next; + } + else + { + theAdmin->head = entry->next; + } + + // remove entry + vPortFree( entry ); + } + } + taskEXIT_CRITICAL(); +} + +RESULT mhqExecute(int handle, UINT8 messageId, t_bpmsg_message *message) +{ + t_mhq_entity *item = lookupMhqEntry(handle, messageId); + + if (item != NULL) + { + item->messageHandler( message, item->ownHandle ); + + return OK; + } + else + { + return ERROR; + } +} + + +t_mhq_entity *lookupMhqEntry(int handle, UINT8 messageId) +{ + t_mhq_admin *theAdmin = (t_mhq_admin *)handle; + t_mhq_entity *result = NULL; + t_mhq_entity *iterator; + + taskENTER_CRITICAL(); + { + iterator = theAdmin->head; + while ((result == NULL) && (iterator != NULL)) + { + if (iterator->messageId == messageId) + { + result = iterator; + } + else + { + iterator = iterator->next; + } + } + } + taskEXIT_CRITICAL(); + + return result; +} + + + + diff --git a/Tester/SW/lib/BusProtocol/MessageHandlerQueue.h b/Tester/SW/lib/BusProtocol/MessageHandlerQueue.h new file mode 100644 index 0000000..0817a64 --- /dev/null +++ b/Tester/SW/lib/BusProtocol/MessageHandlerQueue.h @@ -0,0 +1,65 @@ +/* --------------------------------------------------------------------------- + * MessageHandlerQueue.h - v0.1 (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Jan 30, 2008, FSc + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef __MESSAGEHANDLERQUEUE_H__ +#define __MESSAGEHANDLERQUEUE_H__ +/** \file MessageHandlerQueue.h + \brief Contains a list of message handlers +*/ + +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ +#include "BusProtocol.h" +#include "BpMessageFormat.h" + + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ + +int mhqInit(); +void mhqAdd(int handle, UINT8 messageId, t_bp_messagehandler messageHandler, int ownHandle); +void mhqRemove(int handle, UINT8 messageId, t_bp_messagehandler messageHandler); +RESULT mhqExecute(int handle, UINT8 messageId, t_bpmsg_message *message); + + +#endif /* __MESSAGEHANDLERQUEUE_H__ */ + diff --git a/Tester/SW/lib/BusProtocol/MessageQueue.c b/Tester/SW/lib/BusProtocol/MessageQueue.c new file mode 100644 index 0000000..483b60e --- /dev/null +++ b/Tester/SW/lib/BusProtocol/MessageQueue.c @@ -0,0 +1,124 @@ +/* --------------------------------------------------------------------------- + * MessageQueue.c - v0.1 (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Jan 29, 2008, FSc + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +#include +#include + + +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "MessageQueue.h" + +#include "FreeRTOS.h" +#include "task.h" + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ + + t_mq_messagequeue *mqInit() + { + t_mq_messagequeue *newMessageQueue = (t_mq_messagequeue *)pvPortMalloc( sizeof(t_mq_messagequeue) ); + + newMessageQueue->count = 0; + newMessageQueue->head = 0; + newMessageQueue->tail = 0; + + return newMessageQueue; + } + +RESULT mqAdd( t_mq_messagequeue *queue, t_bpmsg_message *message) +{ + RESULT result = OK; + + taskENTER_CRITICAL(); + { + if(queue->count >= TX_QUEUE_SIZE) + { + result = ERROR; + } + else + { + memcpy( &(queue->messages[queue->tail]), message, sizeof(t_bpmsg_message) ); + queue->count++; + queue->tail = (queue->tail + 1) % TX_QUEUE_SIZE; + } + } + taskEXIT_CRITICAL(); + + return result; +} + +RESULT mqGet( t_mq_messagequeue *queue, t_bpmsg_message *message) +{ + RESULT result = OK; + + taskENTER_CRITICAL(); + { + if(queue->count > 0) + { + memcpy( message, &(queue->messages[queue->head]), sizeof(t_bpmsg_message) ); + queue->head = (queue->head + 1) % TX_QUEUE_SIZE; + queue->count--; + } + else + { + result = ERROR; + } + } + taskEXIT_CRITICAL(); + + return result; +} + +BOOLEAN mqEmpty( t_mq_messagequeue *queue ) +{ + UINT8 count; + + taskENTER_CRITICAL(); + { + count = queue->count; + } + taskEXIT_CRITICAL(); + + return ( count == 0 ? TRUE : FALSE); +} + diff --git a/Tester/SW/lib/BusProtocol/MessageQueue.h b/Tester/SW/lib/BusProtocol/MessageQueue.h new file mode 100644 index 0000000..48b5b2c --- /dev/null +++ b/Tester/SW/lib/BusProtocol/MessageQueue.h @@ -0,0 +1,72 @@ +/* --------------------------------------------------------------------------- + * MessageQueue.h - v0.1 (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Jan 29, 2008, FSc + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef __MESSAGEQUEUE_H__ +#define __MESSAGEQUEUE_H__ +/** \file MessageQueue.h + \brief +*/ + +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ +#include "types.h" +#include "BpMessageFormat.h" + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ +#define TX_QUEUE_SIZE (20) + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ +typedef struct t_mq_MESSAGEQUEUE +{ + t_bpmsg_message messages[TX_QUEUE_SIZE]; + UINT8 head; + UINT8 tail; + UINT8 count; +} t_mq_messagequeue; + + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ +t_mq_messagequeue *mqInit(); +RESULT mqAdd( t_mq_messagequeue *queue, t_bpmsg_message *message); +RESULT mqGet( t_mq_messagequeue *queue, t_bpmsg_message *message); +BOOLEAN mqEmpty( t_mq_messagequeue *queue ); + + +#endif /* __MESSAGEQUEUE_H__ */ + diff --git a/Tester/SW/lib/BusProtocol/ProtocolThread.c b/Tester/SW/lib/BusProtocol/ProtocolThread.c new file mode 100644 index 0000000..fa976cd --- /dev/null +++ b/Tester/SW/lib/BusProtocol/ProtocolThread.c @@ -0,0 +1,1060 @@ +/* --------------------------------------------------------------------------- + * ProtocolThread.c - v0.1 (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Jan 29, 2008, FSc + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +#include + +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "LPC23xx.h" +#include "types.h" +#include "BusProtocol.h" +#include "ProtocolThread.h" +#include "bus.h" +#include "MessageQueue.h" +#include "MessageHandlerQueue.h" +#include "BpMessageFormat.h" +#include "serial.h" +#include "crc.h" +#include "ElecStatusCache.h" +#include "mem_mod.h" + +#include "adc.h" +#include "dac.h" +#include "dio.h" +#include "watchdog.h" + +/* FreeRTOS includes */ +#include "FreeRTOS.h" +#include "Task.h" +#include "Queue.h" + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ +#define TX_QUEUE_SIZE (20) +#define MAX_TX_MESSAGES (12) /**< Maximum number of message to be send in 1 turn */ +#define THREAD_NAME_BUS1 "Bus1Pb" +#define THREAD_NAME_BUS2 "Bus2Pb" +#define MESSAGE_THREAD_NAME_BUS1 "Bus1MsgH" +#define MESSAGE_THREAD_NAME_BUS2 "Bus2MsgH" +#define MAX_NR_CHANNELS (32) + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ +typedef enum +{ + IDLE, + SENDER_ID, + TARGET_ID, + PACKET_NR, + STATUS, + MESSAGE_ID, + PAYLOAD_SIZE, + PAYLOAD, + CRC +} t_bpthread_decodestatus; + + +typedef struct t_BPTHREAD_ADMIN { + t_bus_devices recvBus; + t_bus_devices sendBus; + UINT8 deviceId; + UINT8 highestDeviceId; + int busProtocolHandle; + int messageHandlerHandle; + t_bp_myturn_callback myTurnCallback; + xTaskHandle threadHandle; + xTaskHandle threadMessageHandle; + t_mq_messagequeue *messageQueue; + xQueueHandle messageHandlerQueue; + UINT8 lastReceivedPacketNr; + UINT8 lastReceivedSenderId; + t_bpthread_decodestatus decodeStatus; + t_bpmsg_message rxMessage; + BOOLEAN rxStartByteDetected; + UINT8 rxFillIdx; + UINT16 rxCrc; + UINT16 cyclusTimeout; + UINT32 cyclusEndTick; + UINT16 messageTimeout; + UINT32 messageEndTick; + UINT16 backoffTime; + portTickType *timestampLastRecvMsgDevices; +} t_bpthread_admin; + +extern memman *bpMessagePool; +memman *bpRecvMessagePool; + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ +static void protocolThread( void *pvParameters ); +static void messageHandlerThread( void *pvParameters ); +static t_bpmsg_message *decodeByte( t_bpthread_admin *threadAdmin, UINT8 byte ); +static void handleMessage(t_bpthread_admin *threadAdmin, t_bpmsg_message *message); +static void detectMyTurn(t_bpthread_admin *threadAdmin, t_bpmsg_message *message); +static void doMyTurnActions(t_bpthread_admin *threadAdmin); +static void checkTimeouts(t_bpthread_admin *threadAdmin); +static void resetMessageTimeout(t_bpthread_admin *threadAdmin); +static void resetCyclusTimeout(t_bpthread_admin *threadAdmin); +static void sendMessage( t_bus_devices bus, t_bpmsg_message *message ); +static UINT32 calcEndTick( UINT16 timeoutPeriod ); +static BOOLEAN hasTimeoutPast( UINT32 endTick ); +static BOOLEAN ignoreFirstStartByte(t_bpthread_admin *threadAdmin, UINT8 byte); +static void putOnLine( t_bus_devices bus, UINT8 dataLength, UINT8 *data); +static void DecodeAndCacheElectronicStatus(t_bpmsg_message *message); +static void DecodeAndSetDacValue( t_bpmsg_message *message ); +static void DecodeAndSetAllDacValues( t_bpmsg_message *message ); +static void DecodeAndSetDigitalOut( t_bpmsg_message *message ); +static void DecodeAndSetAllDigitalOut( t_bpmsg_message *message ); +static void DecodeAndSetAllOutput( t_bpmsg_message *message ); +static void SendLocalElectronicStatus(t_bpthread_admin *threadAdmin); +static void secureSlave(); + +static int bpthreadMessageReceived = 0; +static int bpthreadMessageSend = 0; +static int bpthreadBadCrcMessage = 0; +static int bpthreadDecodeError = 0; +static UINT16 bpthreadArrayAdcValue[MAX_NR_CHANNELS]; +static UINT16 bpthreadArrayDacValue[MAX_NR_CHANNELS]; +static BOOLEAN bpthreadArrayDoValue[MAX_NR_CHANNELS]; +static BOOLEAN bpthreadArrayDiValue[MAX_NR_CHANNELS]; + +/** \brief Starts the protocol handling thread + * + * \param bus The communicaiton bus + * \param deviceId Identifier for this device + * \param highestDeviceId The highest deviceId on the bus (only required for master device (deviceId = 0x01)) + * \param bpHandle Handle of busprotocol + * \parma mhqHandle Handle of MessageHandlerQueue + */ +int bpthreadStart(t_bus_devices recvBus, t_bus_devices sendBus, UINT8 deviceId, UINT8 highestDeviceId, int bpHandle, int mhqHandle) +{ + t_bpthread_admin *newAdmin = (t_bpthread_admin *)pvPortMalloc( sizeof(t_bpthread_admin) ); + signed portCHAR *threadName; + signed portCHAR *messageHandlerThreadName; + int i; + + /* init administration */ + newAdmin->recvBus = recvBus; + newAdmin->sendBus = sendBus; + newAdmin->deviceId = deviceId; + newAdmin->highestDeviceId = highestDeviceId; + newAdmin->busProtocolHandle = bpHandle; + newAdmin->myTurnCallback = NULL; + newAdmin->messageQueue = mqInit(); + newAdmin->decodeStatus = IDLE; + newAdmin->lastReceivedSenderId = 0; + newAdmin->lastReceivedPacketNr = 0; + newAdmin->rxStartByteDetected = FALSE; + newAdmin->rxMessage.payload = NULL; + newAdmin->messageHandlerHandle = mhqHandle; + newAdmin->messageTimeout = 50; //was 50; /// \TODO tune timeouts + newAdmin->cyclusTimeout = 500; // was 500; + newAdmin->backoffTime = 5; // Was 5 + newAdmin->messageHandlerQueue = xQueueCreate( 25, sizeof(t_bpmsg_message)); + newAdmin->timestampLastRecvMsgDevices = (portTickType *)pvPortMalloc( sizeof(portTickType) * highestDeviceId ); + + // Reset buffer + for (i =0; i < highestDeviceId; i++) + { + newAdmin->timestampLastRecvMsgDevices[i] = xTaskGetTickCount(); + } + + bpRecvMessagePool = Memmod_Create(8,64); // Make sure size is dividable by 4 + + if (recvBus == BUS1) + { + threadName = (signed portCHAR *)THREAD_NAME_BUS1; + messageHandlerThreadName = (signed portCHAR *)MESSAGE_THREAD_NAME_BUS1; + } + else + { + threadName = (signed portCHAR *)THREAD_NAME_BUS2; + messageHandlerThreadName = (signed portCHAR *)MESSAGE_THREAD_NAME_BUS2; + } + + xTaskCreate( protocolThread, threadName, configMINIMAL_STACK_SIZE + 100, newAdmin, tskIDLE_PRIORITY + 3, &(newAdmin->threadHandle) ); + xTaskCreate( messageHandlerThread, messageHandlerThreadName, configMINIMAL_STACK_SIZE + 400, newAdmin, tskIDLE_PRIORITY + 2, &(newAdmin->threadMessageHandle) ); + + return (int)newAdmin; +} + +/** \brief Stops the protocol handling thread + * + * \note this function is never tested (reconsider implementation) + * \post handle is not valid anymore + * \param handle Handle to the protocol thread + */ +void bpthreadStop( int handle ) +{ + vTaskDelete( ((t_bpthread_admin *)handle)->threadHandle ); + vTaskDelete( ((t_bpthread_admin *)handle)->threadMessageHandle ); + + vPortFree( (void *)handle ); +} + +/** \brief Add a message to the tx-queue. Message will be send when its this device its turn */ +void bpthreadAddMessage( int handle, t_bpmsg_message *message ) +{ + t_bpthread_admin *theAdmin = (t_bpthread_admin *)handle; + mqAdd( theAdmin->messageQueue, message ); +} + +/** \brief Indicates whether a message a device is received in the last 10 seconds + * Only used by the master + */ +BOOLEAN bpthreadDeviceIsDetected( int handle, UINT8 deviceId ) +{ + t_bpthread_admin *theAdmin = (t_bpthread_admin *)handle; + portTickType currentTimeout; + BOOLEAN retval; + + // if difference is larger than 10 seconds return FALSE + currentTimeout = xTaskGetTickCount() - theAdmin->timestampLastRecvMsgDevices[deviceId - 1]; + if (currentTimeout < 0) + { + currentTimeout = LONG_MAX - theAdmin->timestampLastRecvMsgDevices[deviceId] + xTaskGetTickCount(); + } + + if (currentTimeout > 10000) // Timeout larger than 10 seconds + { + retval = FALSE; + } + else + { + retval = TRUE; + } + + return retval; +} + + +/** \brief Attaches a callback function to MyTurn-event, which notifies when it is this device its turn + * + * \param handle Handle to the protocol thread + * \param callback Pointer to callback-function + */ +void bpthreadAttachMyTurn( int handle, t_bp_myturn_callback callback) +{ + t_bpthread_admin *theAdmin = (t_bpthread_admin *)handle; + + theAdmin->myTurnCallback = callback; +} + +/** \brief Detaches the callback function to MyTurn-event + * + * \param handle Handle to the protocol thread + * \param callback Pointer to callback-function + */ +void bpthreadDetachMyTurn( int handle, t_bp_myturn_callback callback) +{ + t_bpthread_admin *theAdmin = (t_bpthread_admin *)handle; + + theAdmin->myTurnCallback = NULL; +} + +/** \brief The thread which handles the in & output on the bus. + * + * \param pvParameters Pointer to parameters + */ +void protocolThread( void *pvParameters ) +{ + t_bpthread_admin *threadAdmin = (t_bpthread_admin *)pvParameters; + t_bpmsg_message *rxMessage; + UINT8 rxByte; + + if (threadAdmin->deviceId == MASTER_DEVICE_ID) + { + /* This is the master so start sending messages */ + doMyTurnActions( threadAdmin ); + + resetMessageTimeout( threadAdmin ); + resetCyclusTimeout( threadAdmin ); + } + else + { + resetMessageTimeout( threadAdmin ); + } + + for (;;) + { + // Read all bytes received on bus + while (busGet( threadAdmin->recvBus, &rxByte ) == TRUE) + { + rxMessage = decodeByte( threadAdmin, rxByte ); + if (rxMessage != NULL) + { + bpthreadMessageReceived++; + threadAdmin->lastReceivedSenderId = rxMessage->senderId; + + // Complete message is received, handle message + handleMessage( threadAdmin, rxMessage ); + resetMessageTimeout( threadAdmin ); + if (rxMessage->status == BPMSG_STATUS_FINISHEDSENDING ) + { + detectMyTurn( threadAdmin, rxMessage ); + } + } + } + + // Verify timeouts + checkTimeouts( threadAdmin ); + + vTaskDelay( 5 ); // 5 milliseconden sleep + } +} + +t_bpmsg_message *decodeByte( t_bpthread_admin *threadAdmin, UINT8 byte ) +{ + switch (threadAdmin->decodeStatus) + { + case(IDLE): + if (byte == BPMSG_STARTBYTE) + { + threadAdmin->decodeStatus = SENDER_ID; + } + else + { + bpthreadDecodeError++; + } + break; + case(SENDER_ID): + if (byte != BPMSG_STARTBYTE) /* 0xAA is not allowed as SENDER_ID, must be a START BYTE */ + { + threadAdmin->rxMessage.senderId = byte; + threadAdmin->decodeStatus = TARGET_ID; + } + else + { + bpthreadDecodeError++; + } + break; + case(TARGET_ID): + if (byte != BPMSG_STARTBYTE) /* 0xAA is not allowed as SENDER_ID, must be a START BYTE */ + { + threadAdmin->rxMessage.targetId = byte; + threadAdmin->decodeStatus = PACKET_NR; + } + else + { + bpthreadDecodeError++; + threadAdmin->decodeStatus = SENDER_ID; + } + break; + case(PACKET_NR): + if (byte != BPMSG_STARTBYTE) /* 0xAA is not allowed as PACKET_NR, must be a START BYTE */ + { + threadAdmin->rxMessage.packetNr = byte; + threadAdmin->decodeStatus = STATUS; + } + else + { + bpthreadDecodeError++; + threadAdmin->decodeStatus = SENDER_ID; + } + break; + case(STATUS): + if ( (byte & 0x40) == 0x40) /* bit 6 must be high */ + { + threadAdmin->rxMessage.status = byte; + threadAdmin->decodeStatus = MESSAGE_ID; + } + else + { + bpthreadDecodeError++; + threadAdmin->decodeStatus = IDLE; + } + break; + case(MESSAGE_ID): + if (byte != BPMSG_STARTBYTE) /* 0xAA is not allowed as PACKET_NR, must be a START BYTE */ + { + threadAdmin->rxMessage.messageId = byte; + threadAdmin->decodeStatus = PAYLOAD_SIZE; + threadAdmin->rxStartByteDetected = FALSE; + } + else + { + bpthreadDecodeError++; + threadAdmin->decodeStatus = SENDER_ID; + } + break; + case(PAYLOAD_SIZE): + if (!ignoreFirstStartByte(threadAdmin, byte )) + { + threadAdmin->rxCrc = crcCalc(&byte, 1, 0); + threadAdmin->rxMessage.payloadSize = byte; + if (byte > 0) + { + threadAdmin->decodeStatus = PAYLOAD; + threadAdmin->rxMessage.payload = (UINT8 *)Memmod_Alloc(bpRecvMessagePool); + threadAdmin->rxFillIdx = 0; + } + else + { + threadAdmin->decodeStatus = CRC; + threadAdmin->rxMessage.payload = NULL; + } + } + break; + case(PAYLOAD): + if (!ignoreFirstStartByte(threadAdmin, byte )) + { + threadAdmin->rxCrc = crcCalc(&byte, 1, threadAdmin->rxCrc); + threadAdmin->rxMessage.payload[threadAdmin->rxFillIdx] = byte; + threadAdmin->rxFillIdx++; + } + + if (threadAdmin->rxFillIdx == threadAdmin->rxMessage.payloadSize) + { + threadAdmin->rxFillIdx = 0; + threadAdmin->decodeStatus = CRC; + } + break; + case(CRC): + if (!ignoreFirstStartByte(threadAdmin, byte) ) + { + if (threadAdmin->rxFillIdx == 0) + { + threadAdmin->rxMessage.crc = ((UINT16)byte) << 8; + } + else + { + threadAdmin->rxMessage.crc |= (UINT16)byte; + } + threadAdmin->rxFillIdx++; + } + + if (threadAdmin->rxFillIdx == 2) + { + threadAdmin->rxFillIdx = 0; + threadAdmin->decodeStatus = IDLE; + + if (threadAdmin->rxCrc == threadAdmin->rxMessage.crc) + { + return &(threadAdmin->rxMessage); + } + else + { + if (threadAdmin->rxMessage.payload != NULL) + { + Memmod_Free( bpRecvMessagePool, threadAdmin->rxMessage.payload ); + threadAdmin->rxMessage.payload = NULL; + } + + bpthreadBadCrcMessage++; + } + } + break; + } + + return NULL; +} + + +void handleMessage(t_bpthread_admin *threadAdmin, t_bpmsg_message *message) +{ + // Record packet nr. + threadAdmin->lastReceivedPacketNr = message->packetNr; + + // Reset Device detected timeout + if ((message->senderId > 0) && (message->senderId <= threadAdmin->highestDeviceId)) // Safety first + { + threadAdmin->timestampLastRecvMsgDevices[message->senderId - 1] = xTaskGetTickCount(); + } + + // is message ment for this device + if ( (message->targetId == BPMSG_BROADCAST_ID) + || (message->targetId == threadAdmin->deviceId) + ) + { + // Add to queue + xQueueSendToBack( threadAdmin->messageHandlerQueue, message, 100); + + // Make sure the payload isn't freed + //message->payload = NULL; + } + else + { + // Delete message stuff + if (message->payload != NULL) + { + Memmod_Free( bpRecvMessagePool, message->payload ); + message->payload = NULL; + } + } +} + +void detectMyTurn(t_bpthread_admin *threadAdmin, t_bpmsg_message *message) +{ + BOOLEAN isMyTurn = FALSE; + + if ((message->status & BPMSG_STATUS_FINISHEDSENDING) == BPMSG_STATUS_FINISHEDSENDING) + { + if (threadAdmin->deviceId == BPMSG_MASTER_DEVID) + { + if (message->senderId == threadAdmin->highestDeviceId) + { + resetCyclusTimeout( threadAdmin ); + isMyTurn = TRUE; + } + } + else + { + if ( (message->senderId + 1) == threadAdmin->deviceId) + { + isMyTurn = TRUE; + } + } + } + + if (isMyTurn == TRUE) + { + doMyTurnActions(threadAdmin); + } +} + +void checkTimeouts( t_bpthread_admin *threadAdmin ) +{ + if (threadAdmin->deviceId == MASTER_DEVICE_ID) + { + if (hasTimeoutPast( threadAdmin->cyclusEndTick ) == TRUE) + { + BP_DEBUG_OUT( 't'); BP_DEBUG_OUT( 'c'); + resetCyclusTimeout( threadAdmin ); + doMyTurnActions( threadAdmin ); + } + } + else + { + // If slave device than check if master is seen in the last 10 seconds + if (bpthreadDeviceIsDetected( (int)threadAdmin, MASTER_DEVICE_ID ) == FALSE) + { + // Put slave in save mode and reset device + secureSlave(); + } + } + + // Can safely do test again, cause above actions have reset this + // timeout in doMyTurnActions. + if (hasTimeoutPast( threadAdmin->messageEndTick ) == TRUE) + { + resetMessageTimeout( threadAdmin ); + + // Test if it is possible my turn + if ((threadAdmin->lastReceivedSenderId + 1) == threadAdmin->deviceId) + { + BP_DEBUG_OUT('t'); BP_DEBUG_OUT('m'); + doMyTurnActions( threadAdmin ); + } + else + { + if ( (threadAdmin->deviceId == MASTER_DEVICE_ID) + && (threadAdmin->lastReceivedSenderId == threadAdmin->highestDeviceId) + ) + { + BP_DEBUG_OUT('t'); BP_DEBUG_OUT('m'); + resetCyclusTimeout( threadAdmin ); + doMyTurnActions( threadAdmin ); + } + else + { + threadAdmin->lastReceivedSenderId++; + } + } + } +} + +void doMyTurnActions(t_bpthread_admin *threadAdmin) +{ + int nrOfMessagesSend = 0; + t_bpmsg_message message; + UINT16 multipleTimeout; + + // Backoff for some time + vTaskDelay( threadAdmin->backoffTime ); + + /* Notify MyTurn-event listeners */ + if (threadAdmin->myTurnCallback != NULL) + { + // If MyTurn is handled by application -> then application is responsible for send give electronicStatus + threadAdmin->myTurnCallback(); + + /* Sending electronic status message */ + SendLocalElectronicStatus(threadAdmin); + } + else + { + //if (mqEmpty(threadAdmin->messageQueue) == TRUE) + SendLocalElectronicStatus(threadAdmin); + } + + // Send MAX messages on the bus + while ( (nrOfMessagesSend < MAX_TX_MESSAGES) + && (mqEmpty(threadAdmin->messageQueue) == FALSE) + ) + { + if (mqGet(threadAdmin->messageQueue, &message) != ERROR) + { + // If last message in a row then set status LAST_MESSAGE + if ( (mqEmpty(threadAdmin->messageQueue) == TRUE ) + || ((nrOfMessagesSend + 1)>= MAX_TX_MESSAGES) + ) + { + message.status = BPMSG_STATUS_FINISHEDSENDING; + } + else + { + message.status = BPMSG_STATUS_BUSYSENDING; + } + + // Fill packetNr + threadAdmin->lastReceivedPacketNr++; + if (threadAdmin->lastReceivedPacketNr == BPMSG_STARTBYTE) threadAdmin->lastReceivedPacketNr++; // 0xAA cannot be used as packetNr + message.packetNr = threadAdmin->lastReceivedPacketNr; + + sendMessage( threadAdmin->sendBus, &message ); + nrOfMessagesSend++; + + // Throw payload away (dynamic part of message) + if (message.payload != NULL) + { + Memmod_Free( bpMessagePool, message.payload ); + } + } + } + + threadAdmin->lastReceivedSenderId = threadAdmin->deviceId; + + // Reset message timeout multiple times + multipleTimeout = nrOfMessagesSend * threadAdmin->messageTimeout; + threadAdmin->messageEndTick = calcEndTick( multipleTimeout ); +} + +void resetMessageTimeout(t_bpthread_admin *threadAdmin) +{ + threadAdmin->messageEndTick = calcEndTick( threadAdmin->messageTimeout); +} + +void resetCyclusTimeout(t_bpthread_admin *threadAdmin) +{ + threadAdmin->cyclusEndTick = calcEndTick( threadAdmin->cyclusTimeout); +} + +void LogByte( UINT8 byte ) +{ + char output[3] = " ,"; + char nibble; + + nibble = ((byte & 0xF0)>> 4); + if (nibble < 10) + { + output[0] = '0'+ nibble; + } + else + { + output[0] = 'A' + (nibble - 10); + } + + nibble = (byte & 0x0F); + if (nibble < 10) + { + output[1] = '0'+ nibble; + } + else + { + output[1] = 'A' + (nibble - 10); + } + + serWrite( COM2, 3, output); +} + +void sendMessage( t_bus_devices bus, t_bpmsg_message *message ) +{ + bpthreadMessageSend++; + UINT8 crcByte; + + // Put message on the bus + busPut( bus, message->uniqueStartByte); + busPut( bus, message->senderId); + busPut( bus, message->targetId); + busPut( bus, message->packetNr); + busPut( bus, message->status); + busPut( bus, message->messageId); + putOnLine( bus, 1, &(message->payloadSize)); + putOnLine( bus, message->payloadSize, message->payload ); + crcByte = (UINT8)(message->crc >> 8); + putOnLine( bus, 1, &crcByte); + crcByte = (UINT8)message->crc; + putOnLine( bus, 1, &crcByte); +} + +void putOnLine( t_bus_devices bus, UINT8 dataLength, UINT8 *data) +{ + int index; + + for (index = 0; index < dataLength; index++) + { + if (data[index] == BPMSG_STARTBYTE) + { + // Write double AA + busPut( bus, BPMSG_STARTBYTE); + busPut( bus, BPMSG_STARTBYTE); + } + else + { + busPut( bus, data[index]); + } + } +} + +UINT32 calcEndTick( UINT16 timeoutPeriod ) +{ + UINT32 result = xTaskGetTickCount() + timeoutPeriod; + + return result; +} + +BOOLEAN hasTimeoutPast( UINT32 endTick ) +{ + UINT32 nowTick = xTaskGetTickCount(); + + if (nowTick >= endTick) + { + if ((nowTick - endTick) > 0x0000FFFF) + { + // the endTick has gone through 0 point, nowTick is at end of range + return FALSE; + } + else + { + // nowTick passed endTick. + return TRUE; + } + } + else + { + if ((endTick - nowTick) > 0x0000FFFF) + { + + // the endTick was at end of range, nowTick has gone through 0 point + return TRUE; + } + else + { + // nowTick still has to pass endTick + return FALSE; + } + } +} + +BOOLEAN ignoreFirstStartByte(t_bpthread_admin *threadAdmin, UINT8 byte) +{ + if (threadAdmin->rxStartByteDetected == FALSE) + { + if (byte == BPMSG_STARTBYTE) + { + threadAdmin->rxStartByteDetected = TRUE; + } + else + { + threadAdmin->rxStartByteDetected = FALSE; + } + } + else + { + if (byte == BPMSG_STARTBYTE) + { + // Correctly received the second StartByte + threadAdmin->rxStartByteDetected = FALSE; + } + else + { + // Expected a second StartByte but didn't => ERROR + threadAdmin->rxStartByteDetected = TRUE; + threadAdmin->decodeStatus = IDLE; + } + } + + return threadAdmin->rxStartByteDetected; +} + +void messageHandlerThread( void *pvParameters ) +{ + t_bpthread_admin *threadAdmin = (t_bpthread_admin *)pvParameters; + t_bpmsg_message message; + + for (;;) + { + if (xQueueReceive(threadAdmin->messageHandlerQueue, &message, 200)) + { + // If "Give Electronic status"-update then store in bpec of driver + if (message.messageId == BPMSG_MSGID_GIVEELECTRONICSTATUS) + { + DecodeAndCacheElectronicStatus( &message ); + } + + // If "Give Electronic status"-update then store in bpec of driver + if (message.messageId == BPMSG_MSGID_SETDACVALUE) + { + DecodeAndSetDacValue( &message ); + } + + if (message.messageId == BPMSG_MSGID_SETDIGITALOUTVALUE) + { + DecodeAndSetDigitalOut( &message ); + } + + if (message.messageId == BPMSG_MSGID_SETALLDIGITALOUT) + { + DecodeAndSetAllDigitalOut( &message ); + } + + if (message.messageId == BPMSG_MSGID_SETALLDACVALUES) + { + DecodeAndSetAllDacValues( &message ); + } + + if (message.messageId == BPMSG_MSGID_SETALLDOUTPUT) + { + DecodeAndSetAllOutput( &message ); + } + + // Lookup message and execute handler + mhqExecute( threadAdmin->messageHandlerHandle, message.messageId, &message ); + + if (message.payload != NULL) + { + Memmod_Free( bpRecvMessagePool, message.payload ); + } + } + } + vTaskDelay(20); +} + +void DecodeAndCacheElectronicStatus(t_bpmsg_message *message) +{ + UINT8 index; + UINT8 arraySize; + UINT8 payloadIndex = 0; + + BP_DEBUG_OUT( 'e'); BP_DEBUG_OUT( '<'); + + // Decode ADC-values + arraySize = message->payload[payloadIndex++]; + for (index = 0; index < arraySize; index++) + { + bpthreadArrayAdcValue[index] = bpmsgGet16bit( message->payload, &payloadIndex); + } + bpecSetAdcReadCache( message->senderId, bpthreadArrayAdcValue, arraySize); + + // Decode DAC-values + arraySize = message->payload[payloadIndex++]; + for (index = 0; index < arraySize; index++) + { + bpthreadArrayDacValue[index] = bpmsgGet16bit( message->payload, &payloadIndex); + } + bpecSetDacReadBackCache( message->senderId, bpthreadArrayDacValue, arraySize); + + // Decode DIO input-values + arraySize = message->payload[payloadIndex++]; + for (index = 0; index < arraySize; index++) + { + bpthreadArrayDiValue[index] = bpmsgGet8bit( message->payload, &payloadIndex); + } + bpecSetDioReadCache( message->senderId, bpthreadArrayDiValue, arraySize); + + // Decode DIO output-values + arraySize = message->payload[payloadIndex++]; + for (index = 0; index < arraySize; index++) + { + bpthreadArrayDoValue[index] = bpmsgGet8bit( message->payload, &payloadIndex); + } + bpecSetDioReadBackCache( message->senderId, bpthreadArrayDoValue, arraySize); +} + +void DecodeAndSetDacValue( t_bpmsg_message *message ) +{ + UINT8 channelId; + UINT16 dacValue; + UINT8 payloadIndex = 0; + + BP_DEBUG_OUT( 'a'); BP_DEBUG_OUT( '<'); + + channelId = message->payload[payloadIndex++]; + payloadIndex++; // Ignore dacMode + dacValue = bpmsgGet16bit( message->payload, &payloadIndex); + + // Set the Dac value + dacWrite( 0, channelId, dacValue ); +} + +void DecodeAndSetAllDacValues( t_bpmsg_message *message ) +{ + UINT8 i; + UINT16 dacValue; + UINT8 payloadIndex = 0; + + BP_DEBUG_OUT( 'a'); BP_DEBUG_OUT( 'a'); BP_DEBUG_OUT( '<'); + + for (i=0; i< 4; i++) + { + dacValue = bpmsgGet16bit( message->payload, &payloadIndex); + + // Set the Dac value + dacWrite( 0, i, dacValue ); + } +} + +void DecodeAndSetDigitalOut( t_bpmsg_message *message ) +{ + UINT8 channelId = 0xFF; + BOOLEAN doValue = FALSE; + UINT8 payloadIndex = 0; + + BP_DEBUG_OUT( 'd'); BP_DEBUG_OUT( '<'); + + channelId = bpmsgGet8bit( message->payload, &payloadIndex); + doValue = bpmsgGet8bit( message->payload, &payloadIndex); + + // Set the Dac value + dioWrite( 0, channelId, doValue ); +} + +void DecodeAndSetAllDigitalOut( t_bpmsg_message *message ) +{ + UINT8 doValue = FALSE; + UINT8 payloadIndex = 0; + UINT8 i; + + BP_DEBUG_OUT( 'd'); BP_DEBUG_OUT( 'a'); BP_DEBUG_OUT( '<'); + + doValue = bpmsgGet8bit( message->payload, &payloadIndex); + + // Set the Dac value + for (i = 0; i < 8; i++) + { + dioWrite( 0, i, doValue & 0x01 ); + doValue = doValue >> 1; + } +} + +void DecodeAndSetAllOutput( t_bpmsg_message *message ) +{ + UINT8 doValue = FALSE; + UINT16 dacValue; + UINT8 payloadIndex = 0; + UINT8 i; + + BP_DEBUG_OUT( 'a'); BP_DEBUG_OUT( 'o'); BP_DEBUG_OUT( '<'); + + doValue = bpmsgGet8bit( message->payload, &payloadIndex); + + // Set the Dac value + for (i = 0; i < 8; i++) + { + dioWrite( 0, i, doValue & 0x01 ); + doValue = doValue >> 1; + } + + for (i=0; i< 4; i++) + { + dacValue = bpmsgGet16bit( message->payload, &payloadIndex); + + // Set the Dac value + dacWrite( 0, i, dacValue ); + } +} + + +void SendLocalElectronicStatus(t_bpthread_admin *threadAdmin) +{ + int i; + + BP_DEBUG_OUT( 'e'); BP_DEBUG_OUT( '>'); + + // Assemble information + for (i = 0; i < maxADC_Channels; i++ ) + { + bpthreadArrayAdcValue[i] = adcRead( 0, i ); + } + + for (i = 0; i < maxDAC_Channels; i++ ) + { + bpthreadArrayDacValue[i] = dacReadBack( 0, i ); + } + + for (i = 0; i < maxDI_Channels; i++ ) + { + bpthreadArrayDiValue[i] = dioRead( 0, i ); + } + + for (i = 0; i < maxDO_Channels; i++ ) + { + bpthreadArrayDoValue[i] = dioReadBack( 0, i ); + } + + // Send message + bpSendGiveElectronicStatus( threadAdmin->busProtocolHandle, + maxADC_Channels, + bpthreadArrayAdcValue, + maxDAC_Channels, + bpthreadArrayDacValue, + maxDI_Channels, + (UINT8 *)bpthreadArrayDiValue, + maxDO_Channels, + (UINT8 *)bpthreadArrayDoValue + ); +} + +void secureSlave() +{ + int i; + + // Put slave is save mode by setting all outputs to zero + // and reset the CPU + for (i = 0; i < maxDO_Channels; i++ ) + { + dioWrite( 0, i, FALSE ); + } + + for (i = 0; i < maxDAC_Channels; i++ ) + { + dacWrite( 0, i, 0 ); + } + + DISABLE_INTERRUPTS(); + + watchdogEnable( 1 ); // force watchdog reset +} diff --git a/Tester/SW/lib/BusProtocol/ProtocolThread.h b/Tester/SW/lib/BusProtocol/ProtocolThread.h new file mode 100644 index 0000000..05d84e1 --- /dev/null +++ b/Tester/SW/lib/BusProtocol/ProtocolThread.h @@ -0,0 +1,80 @@ +/* --------------------------------------------------------------------------- + * ProtocolThread.h - v0.1 (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Jan 29, 2008, FSc + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef __PROTOCOLTHREAD_H__ +#define __PROTOCOLTHREAD_H__ +/** \file ProtocolThread.h + \brief Thread which handles the messaging of the protocol. +*/ + +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ +#include "bus.h" +#include "BpMessageFormat.h" +#include "BusProtocol.h" + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ + + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ +/** \brief Starts the protocol handling thread */ +int bpthreadStart( t_bus_devices recvBus, t_bus_devices sendBus, UINT8 deviceId, UINT8 highestDeviceId, int bpHandle, int mhqHandle ); + +/** \brief Stops the protocol handling thread */ +void bpthreadStop( int handle ); + +/** \brief Indicates whether a message a device is received in the last 10 seconds + * Only used by the master + */ +BOOLEAN bpthreadDeviceIsDetected( int handle, UINT8 deviceId ); + +/** \brief Add a message to the tx-queue. Message will be send when its this device its turn */ +void bpthreadAddMessage( int handle, t_bpmsg_message *message ); + +/** \brief Attaches a callback function to MyTurn-event, which notifies when it is this device its turn */ +void bpthreadAttachMyTurn( int handle, t_bp_myturn_callback callback); + +/** \brief Detaches the callback function to MyTurn-event */ +void bpthreadDetachMyTurn( int handle, t_bp_myturn_callback callback); + + +#endif /* __PROTOCOLTHREAD_H__ */ + diff --git a/Tester/SW/lib/BusProtocol/RemoteProcedureCalls.c b/Tester/SW/lib/BusProtocol/RemoteProcedureCalls.c new file mode 100644 index 0000000..55a956e --- /dev/null +++ b/Tester/SW/lib/BusProtocol/RemoteProcedureCalls.c @@ -0,0 +1,301 @@ +/* --------------------------------------------------------------------------- + * RemoteProcedureCalls.c - v0.1 (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Jan 29, 2008, FSc + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +#include + + +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "types.h" +#include "RemoteProcedureCalls.h" +#include "serial.h" +#include "BusProtocol.h" + +#include "FreeRTOS.h" +#include "queue.h" +#include "mem_mod.h" + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ + +#define RPC_DISPATCH_QUEUE_SIZE (10) + + +extern memman *bpMessagePool; + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ +//static t_rpc_entity *lookupRpcEntry( int handle, UINT8 functionId ); + + +/** \brief Initialises a Remote Procedure Call administration + * + * \returns Handle to Remote Procedure Call administration (0 = failure) + */ +int rpcInit() +{ + t_rpc_admin *newAdmin = (t_rpc_admin *)pvPortMalloc( sizeof(t_rpc_admin) ); + if (newAdmin != NULL) + { + newAdmin->firstEntry = NULL; + newAdmin->lastEntry = NULL; + } + + return (int)newAdmin; +} + +/** \brief Deinitialises the Remote Procedure Call administration + * + * \param handle Handle to RPC-adminstration + */ +void rpcDeinit( int handle ) +{ + t_rpc_admin *theAdmin = (t_rpc_admin *)handle; + + // Remove whole list + if (theAdmin->firstEntry != NULL) + { + t_rpc_entity *entry = theAdmin->firstEntry; + + while (entry != NULL) + { + t_rpc_entity *nextEntry = entry->next; + + vPortFree( entry ); + + entry = nextEntry; + } + } + + // Remove admin + vPortFree( (void *)handle ); +} + +/** \brief Adds a Remote Procedure Call to the administration + * + * \param handle Handle to RPC-administration + * \param functionId Identifier for RPC + * \param nrOfParams Nr of parameters required by RPC-function + */ +void rpcAdd( int handle, UINT8 functionId, char * functionName, t_rpc_remote_procedure_call funcptr, UINT8 nrOfParams ) +{ + t_rpc_entity *newEntry = (t_rpc_entity *)pvPortMalloc( sizeof(t_rpc_entity) ); + t_rpc_admin *theAdmin = (t_rpc_admin *)handle; + + // fill entry + newEntry->functionId = functionId; + newEntry->functionName = functionName; + newEntry->rpcFunction = funcptr; + newEntry->nrOfParams = nrOfParams; + newEntry->next = NULL; + newEntry->previous = NULL; + + // Add to linked list + if (theAdmin->firstEntry != NULL) + { + theAdmin->lastEntry->next = newEntry; + newEntry->previous = theAdmin->lastEntry; + theAdmin->lastEntry = newEntry; + } + else + { + theAdmin->firstEntry = newEntry; + theAdmin->lastEntry = newEntry; + } +} + +/** \brief Removes a Remote Procedure Call to the administration + * + * \param handle Handle to RPC-administration + * \param functionId Identifier for RPC-function + */ +void rpcRemove( int handle, UINT8 functionId ) +{ + t_rpc_entity *entry = rpcLookupEntry(handle, functionId); + t_rpc_admin *theAdmin = (t_rpc_admin *)handle; + + if (entry != NULL) + { + // rebuild linked list + if (entry->next != NULL) + { + entry->next->previous = entry->previous; + } + else + { + theAdmin->lastEntry = entry->previous; + } + + if (entry->previous != NULL) + { + entry->previous->next = entry->next; + } + else + { + theAdmin->firstEntry = entry->next; + } + + // remove entry + vPortFree( entry ); + } + +} + +/** \brief Looks up a Remote Procedure Call to the administration + * + * \param handle Handle to RPC-administration + * \param functionId Identifier for RPC-function + * \retval Pointer to RPC-function (NULL when not found) + */ +t_rpc_remote_procedure_call rpcLookup( int handle, UINT8 functionId ) +{ + t_rpc_remote_procedure_call result = NULL; + t_rpc_entity *entry = rpcLookupEntry(handle, functionId); + + if (entry != NULL) + { + result = entry->rpcFunction; + } + + return result; +} + +/** \brief Executes a Remote Procedure Call + * + * \param handle Handle to RPC-administration + * \param nrOfParams Nr of parameters in params-array + * \param params Pointer to array with all parameters + * \retval OK RPC request is send + * \retval ERROR Unable to send RPC request + */ +RESULT rpcExecute( int handle, UINT8 functionId, UINT8 nrOfParams, const UINT32 *params ) +{ + t_rpc_entity *entry = rpcLookupEntry(handle, functionId); + if (entry != NULL) + { + // Dispatch function to rpcThread + // execute function + //result = entry->rpcFunction; + return OK; + } + else + { + return ERROR; + } +} + + +t_rpc_entity *rpcLookupEntry( int handle, UINT8 functionId ) +{ + t_rpc_admin *theAdmin = (t_rpc_admin *)handle; + t_rpc_entity *result = NULL; + t_rpc_entity *iterator; + + iterator = theAdmin->firstEntry; + while ((result == NULL) && (iterator != NULL)) + { + if (iterator->functionId == functionId) + { + result = iterator; + } + else + { + iterator = iterator->next; + } + } + + return result; +} + + +void rpcRequestHandler(t_bpmsg_message *msg, int ownHandler) +{ + UINT8 index = 0; + UINT8 count; + UINT8 targetId, senderId, requestNr, functionId, nrOfParams; + UINT32 *params; + t_rpc_entity *rpcEntry; + + // Decode message + targetId = msg->targetId; + senderId = msg->senderId; + requestNr = bpmsgGet8bit( msg->payload, &index); + functionId = bpmsgGet8bit( msg->payload, &index); + nrOfParams = bpmsgGet8bit( msg->payload, &index); + + BP_DEBUG_OUT('{'); + BP_DEBUG_OUT('a' + functionId); + + // Allocate an array for the params + if (nrOfParams > 0) + { + params = (UINT32 *)Memmod_Alloc( bpMessagePool ); + if (params != NULL) + { + for (count = 0; count < nrOfParams; count++) + { + params[count] = bpmsgGet32bit(msg->payload, &index); + } + } + else + { + // Error already indicated by heap_2.c + return; + } + } + else + { + params = NULL; + } + + // Call RPC-function + rpcEntry = rpcLookupEntry(ownHandler, functionId); + if (rpcEntry != NULL) + { + BP_DEBUG_OUT('a' + functionId); + // execute function + rpcEntry->rpcFunction( senderId, targetId, requestNr, functionId, nrOfParams, params ); + } + + if (params != NULL) + { + Memmod_Free( bpMessagePool, params ); + } +} + diff --git a/Tester/SW/lib/BusProtocol/RemoteProcedureCalls.h b/Tester/SW/lib/BusProtocol/RemoteProcedureCalls.h new file mode 100644 index 0000000..b720b2d --- /dev/null +++ b/Tester/SW/lib/BusProtocol/RemoteProcedureCalls.h @@ -0,0 +1,96 @@ +/* --------------------------------------------------------------------------- + * RemoteProcedureCalls.h - v0.1 (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: Holds supported Remote Procedure Calls + * --------------------------------------------------------------------------- + * Version(s): 0.1, Jan 29, 2008, FSc + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef __REMOTEPROCEDURECALLS_H__ +#define __REMOTEPROCEDURECALLS_H__ +/** \file RemoteProcedureCalls.h + \brief +*/ + +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ +#include "BpMessageFormat.h" + + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ + +typedef void (*t_rpc_remote_procedure_call)( UINT8 senderId, UINT8 targetId, UINT8 requestNr, UINT8 functionId, UINT8 nrOfParams, UINT32 *params ); + +typedef struct t_RPC_ENTITY { + UINT8 functionId; + char * functionName; + UINT8 nrOfParams; + t_rpc_remote_procedure_call rpcFunction; + struct t_RPC_ENTITY *next; + struct t_RPC_ENTITY *previous; +} t_rpc_entity; + +typedef struct t_RPC_ADMIN { + t_rpc_entity *firstEntry; + t_rpc_entity *lastEntry; +} t_rpc_admin; + + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ +/** \brief Initialises a Remote Procedure Call administration */ +int rpcInit(); + +/** \brief Deinitialises the Remote Procedure Call administration */ +void rpcDeinit( int handle ); + +/** \brief Adds a Remote Procedure Call to the administration */ +void rpcAdd( int handle, UINT8 functionId, char * functionName, t_rpc_remote_procedure_call funcptr, UINT8 nrOfParams ); + +/** \brief Removes a Remote Procedure Call to the administration */ +void rpcRemove( int handle, UINT8 functionId ); + +/** \brief Looks up a Remote Procedure Call to the administration */ +t_rpc_remote_procedure_call rpcLookup( int handle, UINT8 functionId ); + +/** \brief Executes a Remote Procedure Call */ +RESULT rpcExecute( int handle, UINT8 functionId, UINT8 nrOfParams, const UINT32 *params ); + +t_rpc_entity *rpcLookupEntry( int handle, UINT8 functionId ); + +/** \brief Message handler for RPC-requests */ +void rpcRequestHandler(t_bpmsg_message *msg, int ownHandler); + +#endif /* __REMOTEPROCEDURECALLS_H__ */ diff --git a/Tester/SW/lib/BusProtocol/RpcResults.c b/Tester/SW/lib/BusProtocol/RpcResults.c new file mode 100644 index 0000000..b9efe96 --- /dev/null +++ b/Tester/SW/lib/BusProtocol/RpcResults.c @@ -0,0 +1,288 @@ +/* --------------------------------------------------------------------------- + * RemoteProcedureCalls.c - v0.1 (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Jan 29, 2008, FSc + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +#include + + +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "types.h" +#include "RpcResults.h" +#include "serial.h" +#include "BusProtocol.h" +#include "mem_mod.h" + +#include "FreeRTOS.h" +#include "queue.h" + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ + +#define RPCR_DISPATCH_QUEUE_SIZE (10) + +typedef struct t_RPCR_ENTITY { + UINT8 functionId; + UINT8 nrOfParams; + t_bp_rpcresult_callback rpcrFunction; + struct t_RPCR_ENTITY *next; + struct t_RPCR_ENTITY *previous; +} t_rpcr_entity; + +typedef struct t_RPCR_ADMIN { + t_rpcr_entity *firstEntry; + t_rpcr_entity *lastEntry; +} t_rpcr_admin; + +extern memman *bpMessagePool; + + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ +static t_rpcr_entity *lookupRpcrEntry( int handle, UINT8 functionId ); + + +/** \brief Initialises a Remote Procedure Call administration + * + * \returns Handle to Remote Procedure Call administration (0 = failure) + */ +int rpcrInit() +{ + t_rpcr_admin *newAdmin = (t_rpcr_admin *)pvPortMalloc( sizeof(t_rpcr_admin) ); + if (newAdmin != NULL) + { + newAdmin->firstEntry = NULL; + newAdmin->lastEntry = NULL; + } + + return (int)newAdmin; +} + +/** \brief Deinitialises the Remote Procedure Call administration + * + * \param handle Handle to RPC-adminstration + */ +void rpcrDeinit( int handle ) +{ + t_rpcr_admin *theAdmin = (t_rpcr_admin *)handle; + + // Remove whole list + if (theAdmin->firstEntry != NULL) + { + t_rpcr_entity *entry = theAdmin->firstEntry; + + while (entry != NULL) + { + t_rpcr_entity *nextEntry = entry->next; + + vPortFree( entry ); + + entry = nextEntry; + } + } + + // Remove admin + vPortFree( (void *)handle ); +} + +/** \brief Adds a Remote Procedure Call to the administration + * + * \param handle Handle to RPC-administration + * \param functionId Identifier for RPC + * \param nrOfParams Nr of parameters required by RPC-function + */ +void rpcrAdd( int handle, UINT8 functionId, t_bp_rpcresult_callback funcptr, UINT8 nrOfParams ) +{ + t_rpcr_entity *newEntry = (t_rpcr_entity *)pvPortMalloc( sizeof(t_rpcr_entity) ); + t_rpcr_admin *theAdmin = (t_rpcr_admin *)handle; + + // fill entry + newEntry->functionId = functionId; + newEntry->rpcrFunction = funcptr; + newEntry->nrOfParams = nrOfParams; + newEntry->next = NULL; + newEntry->previous = NULL; + + // Add to linked list + if (theAdmin->firstEntry != NULL) + { + theAdmin->lastEntry->next = newEntry; + newEntry->previous = theAdmin->lastEntry; + theAdmin->lastEntry = newEntry; + } + else + { + theAdmin->firstEntry = newEntry; + theAdmin->lastEntry = newEntry; + } +} + +/** \brief Removes a Remote Procedure Call to the administration + * + * \param handle Handle to RPC-administration + * \param functionId Identifier for RPC-function + */ +void rpcrRemove( int handle, UINT8 functionId ) +{ + t_rpcr_entity *entry = lookupRpcrEntry(handle, functionId); + t_rpcr_admin *theAdmin = (t_rpcr_admin *)handle; + + if (entry != NULL) + { + // rebuild linked list + if (entry->next != NULL) + { + entry->next->previous = entry->previous; + } + else + { + theAdmin->lastEntry = entry->previous; + } + + if (entry->previous != NULL) + { + entry->previous->next = entry->next; + } + else + { + theAdmin->firstEntry = entry->next; + } + + // remove entry + vPortFree( entry ); + } + +} + +/** \brief Looks up a Remote Procedure Call to the administration + * + * \param handle Handle to RPC-administration + * \param functionId Identifier for RPC-function + * \retval Pointer to RPC-function (NULL when not found) + */ +t_bp_rpcresult_callback rpcrLookup( int handle, UINT8 functionId ) +{ + t_bp_rpcresult_callback result = NULL; + t_rpcr_entity *entry = lookupRpcrEntry(handle, functionId); + + if (entry != NULL) + { + result = entry->rpcrFunction; + } + + return result; +} + + +t_rpcr_entity *lookupRpcrEntry( int handle, UINT8 functionId ) +{ + t_rpcr_admin *theAdmin = (t_rpcr_admin *)handle; + t_rpcr_entity *result = NULL; + t_rpcr_entity *iterator; + + iterator = theAdmin->firstEntry; + while ((result == NULL) && (iterator != NULL)) + { + if (iterator->functionId == functionId) + { + result = iterator; + } + else + { + iterator = iterator->next; + } + } + + return result; +} + + +void rpcrRequestHandler(t_bpmsg_message *msg, int ownHandler) +{ + UINT8 index = 0; + UINT8 count; + UINT8 targetId, senderId, requestNr, functionId, nrOfResults; + UINT32 *results; + t_rpcr_entity *rpcrEntry; + + BP_DEBUG_OUT( '!'); + + // Decode message + targetId = msg->targetId; + senderId = msg->senderId; + requestNr = bpmsgGet8bit( msg->payload, &index); + functionId = bpmsgGet8bit( msg->payload, &index); + nrOfResults = bpmsgGet8bit( msg->payload, &index); + + // Allocate an array for the params + if (nrOfResults > 0) + { + results = (UINT32 *)Memmod_Alloc( bpMessagePool ); + if (results != NULL) + { + for (count = 0; count < nrOfResults; count++) + { + results[count] = bpmsgGet32bit(msg->payload, &index); + } + } + else + { + // Error already indicated by heap_2.c + return; + } + } + else + { + results = NULL; + } + + // Call RPC-function + rpcrEntry = lookupRpcrEntry(ownHandler, functionId); + if (rpcrEntry != NULL) + { + // execute function + BP_DEBUG_OUT('#'); + rpcrEntry->rpcrFunction( requestNr, nrOfResults, results ); + } + + if (results != NULL) + { + Memmod_Free( bpMessagePool, results ); + } +} + diff --git a/Tester/SW/lib/BusProtocol/RpcResults.h b/Tester/SW/lib/BusProtocol/RpcResults.h new file mode 100644 index 0000000..e1ee7c2 --- /dev/null +++ b/Tester/SW/lib/BusProtocol/RpcResults.h @@ -0,0 +1,76 @@ +/* --------------------------------------------------------------------------- + * RpcResults.h - v0.1 (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: Holds supported Remote Procedure Calls + * --------------------------------------------------------------------------- + * Version(s): 0.1, Jan 29, 2008, FSc + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef __RPCRESULTS_H__ +#define __RPCRESULTS_H__ +/** \file RpcResults.h + \brief +*/ + +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ +#include "BusProtocol.h" +#include "BpMessageFormat.h" + + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ + + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ +/** \brief Initialises a Remote Procedure Call-Result administration */ +int rpcrInit(); + +/** \brief Deinitialises the Remote Procedure Call-Result administration */ +void rpcrDeinit( int handle ); + +/** \brief Adds a RPC-result handler to the administration */ +void rpcrAdd( int handle, UINT8 functionId, t_bp_rpcresult_callback funcptr, UINT8 nrOfParams); + +/** \brief Removes a RPC-result handler to the administration */ +void rpcrRemove( int handle, UINT8 functionId ); + +/** \brief Looks up a RPC-result handler to the administration */ +t_bp_rpcresult_callback rpcrLookup( int handle, UINT8 functionId ); + +/** \brief Message handler for RPC-requests */ +void rpcrRequestHandler(t_bpmsg_message *msg, int ownHandler); + +#endif /* __RPCRESULTS_H__ */ diff --git a/Tester/SW/lib/BusProtocol/mem_mod.c b/Tester/SW/lib/BusProtocol/mem_mod.c new file mode 100644 index 0000000..1aef9af --- /dev/null +++ b/Tester/SW/lib/BusProtocol/mem_mod.c @@ -0,0 +1,90 @@ + +#include "mem_mod.h" + +/* FreeRTOS includes */ +#include "FreeRTOS.h" +#include "Task.h" +#include "Queue.h" + +extern void serWrite ( + int device, + short length, /**< Lengh of data in bytes */ + char * data /**< Pointer to data */ +); + +void Memmod_Init(memman *me,unsigned char buf_count,unsigned short buf_size) +{ + unsigned char *buffer; + unsigned short i; + me->count = buf_count; + me->size = buf_size; + buffer = pvPortMalloc(buf_count*buf_size); + me->buffer = buffer; + me->free_index = buf_count; + me->freelist = pvPortMalloc(buf_count*sizeof(link_item)); + for(i=0;ifreelist[i].data = buffer; + buffer = buffer+buf_size; + } +} + +unsigned char* Memmod_GetBuffer(memman *me) +{ + return me->buffer; +} + +memman *Memmod_Create(unsigned char buf_count,unsigned short buf_size) +{ + memman *new_item; + new_item = (memman *)pvPortMalloc(sizeof(memman)); + Memmod_Init(new_item,buf_count,buf_size); + return new_item; +} + +void *Memmod_Alloc(memman *me) +{ + unsigned char index; + void *retval; + + taskENTER_CRITICAL(); + { + index = me->free_index; + if(index > 0) + { + index--; + me->free_index=index; + retval = me->freelist[index].data; + } + else + { + retval = 0; + } + } + taskEXIT_CRITICAL(); + + if (retval == 0) + { + serWrite(1, sizeof("buffer error"), "buffer error"); + } + + return retval; +} + +void Memmod_Free(memman *me,void *buffer) +{ + unsigned char index; + + taskENTER_CRITICAL(); + { + index = me->free_index; + if(index < me->count) + { + me->freelist[index].data = buffer; + index++; + me->free_index=index; + } + } + taskEXIT_CRITICAL(); + +} diff --git a/Tester/SW/lib/BusProtocol/mem_mod.h b/Tester/SW/lib/BusProtocol/mem_mod.h new file mode 100644 index 0000000..fa57d7f --- /dev/null +++ b/Tester/SW/lib/BusProtocol/mem_mod.h @@ -0,0 +1,32 @@ +#ifndef _MEM_MODH +#define _MEM_MODH + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct link_item +{ + void *data; +} link_item; + +typedef struct +{ + unsigned char count; + unsigned char size; + unsigned char free_index; + void *buffer; + link_item *freelist; +} memman; + +void Memmod_Init(memman *me,unsigned char buf_count,unsigned short buf_size); +memman *Memmod_Create(unsigned char buf_count,unsigned short buf_size); +unsigned char* Memmod_GetBuffer(memman *me); +void *Memmod_Alloc(memman *me); +void Memmod_Free(memman *me,void *buffer); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/Tester/SW/lib/Drivers/.cproject b/Tester/SW/lib/Drivers/.cproject new file mode 100644 index 0000000..bab259c --- /dev/null +++ b/Tester/SW/lib/Drivers/.cproject @@ -0,0 +1,554 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tester/SW/lib/Drivers/.project b/Tester/SW/lib/Drivers/.project new file mode 100644 index 0000000..16c3c1c --- /dev/null +++ b/Tester/SW/lib/Drivers/.project @@ -0,0 +1,84 @@ + + + Drivers + + + FreeRTOS + inc + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + org.eclipse.cdt.make.core.cleanBuildTarget + clean + + + org.eclipse.cdt.make.core.enableCleanBuild + true + + + org.eclipse.cdt.make.core.append_environment + true + + + ?name? + + + + org.eclipse.cdt.make.core.stopOnError + true + + + org.eclipse.cdt.make.core.buildCommand + make + + + org.eclipse.cdt.make.core.contents + org.eclipse.cdt.make.core.activeConfigSettings + + + org.eclipse.cdt.make.core.buildLocation + ${workspace_loc:/Drivers/Debug} + + + org.eclipse.cdt.make.core.useDefaultBuildCmd + true + + + org.eclipse.cdt.make.core.enableFullBuild + true + + + org.eclipse.cdt.make.core.enableAutoBuild + false + + + org.eclipse.cdt.make.core.fullBuildTarget + all + + + org.eclipse.cdt.make.core.buildArguments + + + + org.eclipse.cdt.make.core.autoBuildTarget + all + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.core.cnature + org.eclipse.cdt.core.ccnature + + diff --git a/Tester/SW/lib/Drivers/API.txt b/Tester/SW/lib/Drivers/API.txt new file mode 100644 index 0000000..e670f57 --- /dev/null +++ b/Tester/SW/lib/Drivers/API.txt @@ -0,0 +1,20 @@ +All: +UINT8 device [0..255] 0 = Self + 1..32 = Remote +ADC: +UINT8 channel [0..255] 0..7 = valid + 8..255 = future use +if mode == VOLTAGE UINT16 value [0..10000] mV +if mode == CURRENT UINT16 value [0..20000] uA + +DAC: +UINT8 channel [0..255] 0..3 = valid + 4..255 = future use +if mode == VOLTAGE UINT16 value [0..10000] mV +if mode == CURRENT UINT16 value [0..20000] uA + +serial: +Baudrate: B1200, B9600, B19200, B38400, B57600, B115200 +Mode: UART_8N1, UART_7N1, UART_8N2, UART_7N2, UART_8E1, UART_7E1, UART_8E2, UART_7E2, UART_8O1, UART_7O1, UART_8O2, UART_7O2 +FMode: UART_FIFO_OFF, UART_FIFO_1, UART_FIFO_4, UART_FIFO_8, UART_FIFO_14 + diff --git a/Tester/SW/lib/Drivers/Bootloader.c b/Tester/SW/lib/Drivers/Bootloader.c new file mode 100644 index 0000000..3ffed0a --- /dev/null +++ b/Tester/SW/lib/Drivers/Bootloader.c @@ -0,0 +1,88 @@ +/* --------------------------------------------------------------------------- + * Bootloader.c - v0.1 (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: Activates the bootloader. + * --------------------------------------------------------------------------- + * Version(s): 0.1, Feb 21, 2008, FSc + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "types.h" +#include "sys_config.h" +#include "Bootloader.h" +#include "watchdog.h" + + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ +typedef void (*t_bootloader_startup)(void); +#define BOOTMODE_ADDR 0x4000005C + + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ + +//* \brief Jumps to bootloader +void blActivateBootloader() +{ + // Set direction pin for storing + *((UINT32 *)BOOTMODE_ADDR) = STAY_IN_BOOTLOADER; + + DISABLE_INTERRUPTS(); + + watchdogEnable( 1 ); // force watchdog reset +} + + +t_bl_bootmodes blGetBootmode() +{ + if ( *((UINT32 *)BOOTMODE_ADDR) == (UINT32)STAY_IN_BOOTLOADER) + { + return STAY_IN_BOOTLOADER; + } + else + { + return CONTINUE_APPLICATION; + } +} + +void blResetBootmode() +{ + *((UINT32 *)BOOTMODE_ADDR) = CONTINUE_APPLICATION; + +} + + diff --git a/Tester/SW/lib/Drivers/Bootloader.h b/Tester/SW/lib/Drivers/Bootloader.h new file mode 100644 index 0000000..32bdce8 --- /dev/null +++ b/Tester/SW/lib/Drivers/Bootloader.h @@ -0,0 +1,65 @@ +/* --------------------------------------------------------------------------- + * Bootloader.h - v0.1 (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Feb 21, 2008, FSc + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef __BOOTLOADER_H__ +#define __BOOTLOADER_H__ +/** \file Bootloader.h + \brief Activates the bootloader +*/ + +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ +typedef enum { STAY_IN_BOOTLOADER = 0xABCDEF01, CONTINUE_APPLICATION = 0 } t_bl_bootmodes; + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ + +/** \brief Sets the bootmode to STAY_IN_BOOTLOADER and activates the bootloader */ +void blActivateBootloader(); + +/** \brief Returns the bootmode */ +t_bl_bootmodes blGetBootmode(); + +/** \brief Sets bootmode to default status (CONTINUE APPLICATION) */ +void blResetBootmode(); + +#endif /* __BOOTLOADER_H__ */ diff --git a/Tester/SW/lib/Drivers/Doxyfile b/Tester/SW/lib/Drivers/Doxyfile new file mode 100644 index 0000000..e3459a5 --- /dev/null +++ b/Tester/SW/lib/Drivers/Doxyfile @@ -0,0 +1,267 @@ +# Doxyfile 1.5.3 + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- +DOXYFILE_ENCODING = UTF-8 +PROJECT_NAME = "Landustrie IO controller API " +PROJECT_NUMBER = V0.1 +OUTPUT_DIRECTORY = P:/LAN_2636/SW/API/Doxygen +CREATE_SUBDIRS = NO +OUTPUT_LANGUAGE = English +BRIEF_MEMBER_DESC = YES +REPEAT_BRIEF = YES +ABBREVIATE_BRIEF = "The $name class " \ + "The $name widget " \ + "The $name file " \ + is \ + provides \ + specifies \ + contains \ + represents \ + a \ + an \ + the +ALWAYS_DETAILED_SEC = NO +INLINE_INHERITED_MEMB = NO +FULL_PATH_NAMES = YES +STRIP_FROM_PATH = C:/Tools/doxygen/bin/ +STRIP_FROM_INC_PATH = +SHORT_NAMES = NO +JAVADOC_AUTOBRIEF = NO +QT_AUTOBRIEF = NO +MULTILINE_CPP_IS_BRIEF = NO +DETAILS_AT_TOP = NO +INHERIT_DOCS = YES +SEPARATE_MEMBER_PAGES = NO +TAB_SIZE = 8 +ALIASES = +OPTIMIZE_OUTPUT_FOR_C = YES +OPTIMIZE_OUTPUT_JAVA = NO +BUILTIN_STL_SUPPORT = NO +CPP_CLI_SUPPORT = NO +DISTRIBUTE_GROUP_DOC = NO +SUBGROUPING = YES +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- +EXTRACT_ALL = YES +EXTRACT_PRIVATE = YES +EXTRACT_STATIC = YES +EXTRACT_LOCAL_CLASSES = YES +EXTRACT_LOCAL_METHODS = NO +EXTRACT_ANON_NSPACES = NO +HIDE_UNDOC_MEMBERS = NO +HIDE_UNDOC_CLASSES = NO +HIDE_FRIEND_COMPOUNDS = NO +HIDE_IN_BODY_DOCS = NO +INTERNAL_DOCS = NO +CASE_SENSE_NAMES = NO +HIDE_SCOPE_NAMES = NO +SHOW_INCLUDE_FILES = YES +INLINE_INFO = YES +SORT_MEMBER_DOCS = YES +SORT_BRIEF_DOCS = NO +SORT_BY_SCOPE_NAME = NO +GENERATE_TODOLIST = YES +GENERATE_TESTLIST = YES +GENERATE_BUGLIST = YES +GENERATE_DEPRECATEDLIST= YES +ENABLED_SECTIONS = +MAX_INITIALIZER_LINES = 30 +SHOW_USED_FILES = YES +SHOW_DIRECTORIES = NO +FILE_VERSION_FILTER = +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- +QUIET = NO +WARNINGS = YES +WARN_IF_UNDOCUMENTED = YES +WARN_IF_DOC_ERROR = YES +WARN_NO_PARAMDOC = NO +WARN_FORMAT = "$file:$line: $text " +WARN_LOGFILE = +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- +INPUT = P:/LAN_2636/SW/API +INPUT_ENCODING = UTF-8 +FILE_PATTERNS = *.c \ + *.cc \ + *.cxx \ + *.cpp \ + *.c++ \ + *.d \ + *.java \ + *.ii \ + *.ixx \ + *.ipp \ + *.i++ \ + *.inl \ + *.h \ + *.hh \ + *.hxx \ + *.hpp \ + *.h++ \ + *.idl \ + *.odl \ + *.cs \ + *.php \ + *.php3 \ + *.inc \ + *.m \ + *.mm \ + *.dox \ + *.py +RECURSIVE = NO +EXCLUDE = +EXCLUDE_SYMLINKS = NO +EXCLUDE_PATTERNS = +EXCLUDE_SYMBOLS = +EXAMPLE_PATH = +EXAMPLE_PATTERNS = * +EXAMPLE_RECURSIVE = NO +IMAGE_PATH = +INPUT_FILTER = +FILTER_PATTERNS = +FILTER_SOURCE_FILES = NO +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- +SOURCE_BROWSER = YES +INLINE_SOURCES = NO +STRIP_CODE_COMMENTS = YES +REFERENCED_BY_RELATION = YES +REFERENCES_RELATION = YES +REFERENCES_LINK_SOURCE = YES +USE_HTAGS = NO +VERBATIM_HEADERS = YES +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- +ALPHABETICAL_INDEX = YES +COLS_IN_ALPHA_INDEX = 5 +IGNORE_PREFIX = +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- +GENERATE_HTML = YES +HTML_OUTPUT = html +HTML_FILE_EXTENSION = .html +HTML_HEADER = +HTML_FOOTER = +HTML_STYLESHEET = +HTML_ALIGN_MEMBERS = YES +GENERATE_HTMLHELP = NO +HTML_DYNAMIC_SECTIONS = NO +CHM_FILE = +HHC_LOCATION = +GENERATE_CHI = NO +BINARY_TOC = NO +TOC_EXPAND = NO +DISABLE_INDEX = NO +ENUM_VALUES_PER_LINE = 4 +GENERATE_TREEVIEW = NO +TREEVIEW_WIDTH = 250 +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- +GENERATE_LATEX = YES +LATEX_OUTPUT = latex +LATEX_CMD_NAME = latex +MAKEINDEX_CMD_NAME = makeindex +COMPACT_LATEX = NO +PAPER_TYPE = a4wide +EXTRA_PACKAGES = +LATEX_HEADER = +PDF_HYPERLINKS = YES +USE_PDFLATEX = YES +LATEX_BATCHMODE = NO +LATEX_HIDE_INDICES = NO +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- +GENERATE_RTF = NO +RTF_OUTPUT = rtf +COMPACT_RTF = NO +RTF_HYPERLINKS = NO +RTF_STYLESHEET_FILE = +RTF_EXTENSIONS_FILE = +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- +GENERATE_MAN = NO +MAN_OUTPUT = man +MAN_EXTENSION = .3 +MAN_LINKS = NO +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- +GENERATE_XML = NO +XML_OUTPUT = xml +XML_SCHEMA = +XML_DTD = +XML_PROGRAMLISTING = YES +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- +GENERATE_AUTOGEN_DEF = NO +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- +GENERATE_PERLMOD = NO +PERLMOD_LATEX = NO +PERLMOD_PRETTY = YES +PERLMOD_MAKEVAR_PREFIX = +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- +ENABLE_PREPROCESSING = YES +MACRO_EXPANSION = NO +EXPAND_ONLY_PREDEF = NO +SEARCH_INCLUDES = YES +INCLUDE_PATH = +INCLUDE_FILE_PATTERNS = +PREDEFINED = +EXPAND_AS_DEFINED = +SKIP_FUNCTION_MACROS = YES +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- +TAGFILES = +GENERATE_TAGFILE = +ALLEXTERNALS = NO +EXTERNAL_GROUPS = YES +PERL_PATH = /usr/bin/perl +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- +CLASS_DIAGRAMS = NO +MSCGEN_PATH = +HIDE_UNDOC_RELATIONS = YES +HAVE_DOT = YES +CLASS_GRAPH = YES +COLLABORATION_GRAPH = YES +GROUP_GRAPHS = YES +UML_LOOK = NO +TEMPLATE_RELATIONS = NO +INCLUDE_GRAPH = YES +INCLUDED_BY_GRAPH = YES +CALL_GRAPH = NO +CALLER_GRAPH = NO +GRAPHICAL_HIERARCHY = YES +DIRECTORY_GRAPH = YES +DOT_IMAGE_FORMAT = png +DOT_PATH = +DOTFILE_DIRS = +DOT_GRAPH_MAX_NODES = 50 +MAX_DOT_GRAPH_DEPTH = 1000 +DOT_TRANSPARENT = NO +DOT_MULTI_TARGETS = NO +GENERATE_LEGEND = YES +DOT_CLEANUP = YES +#--------------------------------------------------------------------------- +# Configuration::additions related to the search engine +#--------------------------------------------------------------------------- +SEARCHENGINE = NO diff --git a/Tester/SW/lib/Drivers/ElecStatusCache.c b/Tester/SW/lib/Drivers/ElecStatusCache.c new file mode 100644 index 0000000..850d74f --- /dev/null +++ b/Tester/SW/lib/Drivers/ElecStatusCache.c @@ -0,0 +1,271 @@ +/* --------------------------------------------------------------------------- + * BusProtocol.c - v0.1 (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Jan 28, 2008, FSc + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +#include +#include +#include + +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "types.h" +#include "ElecStatusCache.h" + +#include "FreeRTOS.h" + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ +#define MAX_NR_DEVICES 20 +#define CACHE_NOT_USED 0xFF + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ + + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ +static UINT16 *bpecAdcReadCache[MAX_NR_DEVICES]; +static UINT8 bpecAdcReadCacheSize[MAX_NR_DEVICES]; +static UINT16 *bpecDacReadBackCache[MAX_NR_DEVICES]; +static UINT8 bpecDacReadBackCacheSize[MAX_NR_DEVICES]; +static BOOLEAN *bpecDioReadCache[MAX_NR_DEVICES]; +static UINT8 bpecDioReadCacheSize[MAX_NR_DEVICES]; +static BOOLEAN *bpecDioReadBackCache[MAX_NR_DEVICES]; +static UINT8 bpecDioReadBackCacheSize[MAX_NR_DEVICES]; +static t_bpec_write_callback bpecWriteCallback; +static int bpecBusProtocolHandle; + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ + +void bpecInit() +{ + int i; + + bpecWriteCallback = NULL; + bpecBusProtocolHandle = -1; + + // Empty the administration + for (i = 0; i < MAX_NR_DEVICES; i++) + { + bpecAdcReadCache[i] = NULL; + bpecAdcReadCacheSize[i] = CACHE_NOT_USED; + bpecDacReadBackCache[i] = NULL; + bpecDacReadBackCacheSize[i] = CACHE_NOT_USED; + bpecDioReadCache[i] = NULL; + bpecDioReadCacheSize[i] = CACHE_NOT_USED; + bpecDioReadBackCache[i] = NULL; + bpecDioReadBackCacheSize[i] = CACHE_NOT_USED; + } +} + +void bpecAttachWriteCallback(int busProtocolHandle, t_bpec_write_callback callback) +{ + bpecBusProtocolHandle = busProtocolHandle; + bpecWriteCallback = callback; +} + +void bpecDetachWriteCallback() +{ + bpecBusProtocolHandle = -1; + bpecWriteCallback = NULL; +} + +void bpecWriteDacValue( UINT8 device, UINT8 channel, UINT16 dacValue ) +{ + if (bpecWriteCallback != NULL) + { + bpecWriteCallback( bpecBusProtocolHandle, FALSE, device, channel, dacValue ); + } +} + +void bpecWriteDioValue( UINT8 device, UINT8 channel, BOOLEAN doValue ) +{ + if (bpecWriteCallback != NULL) + { + bpecWriteCallback( bpecBusProtocolHandle, TRUE, device, channel, (UINT16)doValue ); + } +} + +void bpecSetAdcReadCache( UINT8 device, UINT16 adcValues[], UINT8 nrOfAdcValues) +{ + static int NrOfAllocs = 0; + if (bpecAdcReadCacheSize[device] != nrOfAdcValues) + { + if (bpecAdcReadCacheSize[device] == CACHE_NOT_USED) + { + NrOfAllocs++; + bpecAdcReadCache[device] = pvPortMalloc( nrOfAdcValues * sizeof(UINT16) ); + if (bpecAdcReadCache[device] != NULL) + { + bpecAdcReadCacheSize[device] = nrOfAdcValues; + memcpy(bpecAdcReadCache[device], adcValues, nrOfAdcValues * sizeof(UINT16)); + } /* else Failure */ + } + /* else Failure */ + } + else + { + memcpy(bpecAdcReadCache[device], adcValues, nrOfAdcValues * sizeof(UINT16)); + } +} + +void bpecSetDioReadCache( UINT8 device, BOOLEAN dioValues[], UINT8 nrOfDioValues) +{ + if (bpecDioReadCacheSize[device] != nrOfDioValues) + { + if (bpecDioReadCacheSize[device] == CACHE_NOT_USED) + { + bpecDioReadCache[device] = pvPortMalloc( nrOfDioValues * sizeof(BOOLEAN) ); + if (bpecDioReadCache[device] != NULL) + { + bpecDioReadCacheSize[device] = nrOfDioValues; + memcpy(bpecDioReadCache[device], dioValues, nrOfDioValues * sizeof(BOOLEAN)); + } /* else Failure */ + } + /* else Failure */ + } + else + { + memcpy(bpecDioReadCache[device], dioValues, nrOfDioValues * sizeof(BOOLEAN)); + } +} + +void bpecSetDioReadBackCache( UINT8 device, BOOLEAN dioValues[], UINT8 nrOfDioValues) +{ + static int NrOfWritings = 0; + static int LastSetDevice = 0; + static int LastSetNrOfDioValues = 0; + NrOfWritings++; + LastSetDevice = device; + LastSetNrOfDioValues = nrOfDioValues; + + if (bpecDioReadBackCacheSize[device] != nrOfDioValues) + { + if (bpecDioReadBackCacheSize[device] == CACHE_NOT_USED) + { + bpecDioReadBackCache[device] = pvPortMalloc( nrOfDioValues * sizeof(BOOLEAN) ); + if (bpecDioReadBackCache[device] != NULL) + { + bpecDioReadBackCacheSize[device] = nrOfDioValues; + memcpy(bpecDioReadBackCache[device], dioValues, nrOfDioValues * sizeof(BOOLEAN)); + } /* else Failure */ + } + /* else Failure */ + } + else + { + memcpy(bpecDioReadBackCache[device], dioValues, nrOfDioValues * sizeof(BOOLEAN)); + } + +} + +void bpecSetDacReadBackCache( UINT8 device, UINT16 dacValues[], UINT8 nrOfDacValues) +{ + if (bpecDacReadBackCacheSize[device] != nrOfDacValues) + { + if (bpecDacReadBackCacheSize[device] == CACHE_NOT_USED) + { + bpecDacReadBackCache[device] = pvPortMalloc( nrOfDacValues * sizeof(UINT16) ); + if (bpecDacReadBackCache[device] != NULL) + { + bpecDacReadBackCacheSize[device] = nrOfDacValues; + memcpy(bpecDacReadBackCache[device], dacValues, nrOfDacValues * sizeof(UINT16)); + } /* else Failure */ + } + /* else Failure */ + } + else + { + memcpy(bpecDacReadBackCache[device], dacValues, nrOfDacValues * sizeof(UINT16)); + } +} + +UINT16 bpecAdcRead( UINT8 device, UINT8 channel ) +{ + UINT16 result = 0; + + if (bpecAdcReadCacheSize[device] != CACHE_NOT_USED) + { + if (channel < bpecAdcReadCacheSize[device]) + { + result = (bpecAdcReadCache[device])[channel]; + } + } + + return result; +} + +BOOLEAN bpecDioRead( UINT8 device, UINT8 channel ) +{ + BOOLEAN result = FALSE; + + if (bpecDioReadCacheSize[device] != CACHE_NOT_USED) + { + if (channel < bpecDioReadCacheSize[device]) + { + result = (bpecDioReadCache[device])[channel]; + } + } + + return result; +} + +BOOLEAN bpecDioReadBack( UINT8 device, UINT8 channel ) +{ + BOOLEAN result = FALSE; + + if (bpecDioReadBackCacheSize[device] != CACHE_NOT_USED) + { + if (channel < bpecDioReadBackCacheSize[device]) + { + result = (bpecDioReadBackCache[device])[channel]; + } + } + + return result; +} + +UINT16 bpecDacReadBack( UINT8 device, UINT8 channel ) +{ + UINT16 result = 0; + + if (bpecDacReadBackCacheSize[device] != CACHE_NOT_USED) + { + if (channel < bpecDacReadBackCacheSize[device]) + { + result = (bpecDacReadBackCache[device])[channel]; + } + } + + return result; +} diff --git a/Tester/SW/lib/Drivers/ElecStatusCache.h b/Tester/SW/lib/Drivers/ElecStatusCache.h new file mode 100644 index 0000000..65cb24e --- /dev/null +++ b/Tester/SW/lib/Drivers/ElecStatusCache.h @@ -0,0 +1,71 @@ +/* --------------------------------------------------------------------------- + * ElecStatusCache.h - v0.1 (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: Stores all electronic status of other IO-controllers + * --------------------------------------------------------------------------- + * Version(s): 0.1, Jan 29, 2008, FSc + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef __ELECSTATUSCACHE_H__ +#define __ELECSTATUSCACHE_H__ +/** \file ElecStatusCache.h + \brief +*/ + +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ +//#include "BpMessageFormat.h" + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ +typedef void (*t_bpec_write_callback)( int handle, BOOLEAN isDigital, UINT8 device, UINT8 channel, UINT16 value ); + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ + +void bpecInit(); +void bpecAttachWriteCallback(int busProtocolHandle, t_bpec_write_callback callback); +void bpecDetachWriteCallback(); +void bpecWriteDacValue( UINT8 device, UINT8 channel, UINT16 dacValue ); +void bpecWriteDioValue( UINT8 device, UINT8 channel, BOOLEAN doValue ); +void bpecSetAdcReadCache( UINT8 device, UINT16 adcValues[], UINT8 nrOfAdcValues); +void bpecSetDioReadCache( UINT8 device, BOOLEAN dioValues[], UINT8 nrOfDioValues); +void bpecSetDioReadBackCache( UINT8 device, BOOLEAN dioValues[], UINT8 nrOfDioValues); +void bpecSetDacReadBackCache( UINT8 device, UINT16 dacValues[], UINT8 nrOfDacValues); +UINT16 bpecAdcRead( UINT8 device, UINT8 channel ); +BOOLEAN bpecDioRead( UINT8 device, UINT8 channel ); +BOOLEAN bpecDioReadBack( UINT8 device, UINT8 channel ); +UINT16 bpecDacReadBack( UINT8 device, UINT8 channel ); + +#endif /* __ELECSTATUSCACHE_H__ */ diff --git a/Tester/SW/lib/Drivers/InternalFlash.c b/Tester/SW/lib/Drivers/InternalFlash.c new file mode 100644 index 0000000..6f4685b --- /dev/null +++ b/Tester/SW/lib/Drivers/InternalFlash.c @@ -0,0 +1,217 @@ +/* --------------------------------------------------------------------------- + * InternalFlash.c - v0.1 (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Feb 11, 2008, FSc + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "types.h" +#include "sys_config.h" +#include "InternalFlash.h" +#include "leds.h" +#include "sys_config.h" + + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ +#define IAP_LOCATION 0x7ffffff1 + +#define IAP_PREPARE_CMD (50) +#define IAP_COPY_RAM2FLASH_CMD (51) +#define IAP_ERASE_SECTORS_CMD (52) +#define IAP_BLANK_CHECK_SECTORS_CMD (53) +#define IAP_READ_PART_ID_CMD (54) +#define IAP_READ_BOOTCODE_V_CMD (55) +#define IAP_COMPARE_CMD (56) +#define IAP_REINVOKE_ISP_CMD (57) + + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ +static unsigned int command[5]; +static unsigned int result[2]; + +typedef void (*IAP)(unsigned int [],unsigned int[]); +IAP iap_entry; + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ + +/** \brief Initialises the internal flash module */ +void iflashInit() +{ + iap_entry=(IAP) IAP_LOCATION; +} + +/** \brief Prepares the flash for erasing and programming (must be called before these actions) + * + * This command must be executed before executing "Copy RAM to flash" or "Erase + * Sector(s)" command. Successful execution of the "Copy RAM to flash" or "Erase + * Sector(s)" command causes relevant sectors to be protected again. The boot + * sector can not be prepared by this command. To prepare a single sector use the + * same "Start" and "End" sector numbers + * + * \param beginSector Start sector number (0-27) + * \param endSector End Sector Number (should be greater than or equal to start sector number). + * \retval CMD_SUCCESS prepare was succesfull + * \retval BUSY + * \retval INVALID_SECTOR + */ +iflashresult iflashPrepare(UINT8 beginSector, UINT8 endSector) +{ + // Build command + command[0] = IAP_PREPARE_CMD; + command[1] = beginSector; + command[2] = endSector; + + //DISABLE_INTERRUPTS(); + + iap_entry (command, result); + + //ENABLE_INTERRUPTS(); + + // readout result + + return result[0]; + //return CMD_SUCCESS; +} + +/** \brief Erases one sector on the internal flash + * + * \param sector Sector nr to be erased (0-27) + * \retval CMD_SUCCESS + * \retval BUSY + * \retval SECTOR_NOT_PREPARED_FOR_WRITE_OPERATION + * \retval INVALID_SECTOR + */ +iflashresult iflashErase( UINT8 sector ) +{ + // Build command + command[0] = IAP_ERASE_SECTORS_CMD; + command[1] = sector; // start sector + command[2] = sector; // end sector + command[3] = CCLK/1000; // Clock frequency in kHz + + DISABLE_INTERRUPTS(); + + iap_entry (command, result); + + ENABLE_INTERRUPTS(); + + return result[0]; +} + + +/** \brief Programs some data on the flash + * + * \param address Addres on flash to which the data must be programmed + * \param dataLength Nr of bytes in data array (Should be 256 | 512 | 1024 | 4096.) + * \param data The data-array that should be programmed + * \retval CMD_SUCCESS + * \retval SRC_ADDR_ERROR (Address not a word boundary) + * \retval DST_ADDR_ERROR (Address not on correct boundary) + * \retval SRC_ADDR_NOT_MAPPED + * \retval DST_ADDR_NOT_MAPPED + * \retval COUNT_ERROR (Byte count is not 256 | 512 | 1024 | 4096) + * \retval SECTOR_NOT_PREPARED_FOR_WRITE_OPERATION + * \retval BUSY + */ +iflashresult iflashProgram( UINT32 address, UINT16 dataLength, UINT8 *data) +{ + // Build command + command[0] = IAP_COPY_RAM2FLASH_CMD; + command[1] = address; // flash address + command[2] = (UINT32)data; // RAM address + command[3] = dataLength; // Nr of bytes Should be 256 | 512 | 1024 | 4096. + command[4] = CCLK/1000; // Clock frequency in kHz + + DISABLE_INTERRUPTS(); + + iap_entry (command, result); + + ENABLE_INTERRUPTS(); + + return result[0]; +} + +/** \brief Compares the data with the data on the internal flash on location "address" + * + * \param address Addres on flash to which the data must be programmed + * \param dataLength Number of bytes to be compared; should be a multiple of 4. + * \param data The data-array that should be programmed + * \retval CMD_SUCCESS + * \retval COMPARE_ERROR + * \retval COUNT_ERROR (Byte count is not a multiple of 4) + * \retval ADDR_ERROR + * \retval ADDR_NOT_MAPPED + */ +iflashresult iflashVerify( UINT32 address, UINT16 dataLength, UINT8 *data) +{ + // Build command + command[0] = IAP_COMPARE_CMD; + command[1] = address; // flash address + command[2] = (UINT32)data; // RAM address + command[3] = dataLength; + + iap_entry (command, result); + + return result[0]; +} + +/** \brief This command is used to read the part identification number. + * + * \retval the Part identification number + */ +UINT32 iflashReadPartId() +{ + // Build command + command[0] = IAP_READ_PART_ID_CMD; + + iap_entry (command, result); + + return result[1]; +} + +/** \brief This command is used to read the boot code version number. */ +UINT32 iflashReadBootcodeVersionNr() +{ + // Build command + command[0] = IAP_READ_BOOTCODE_V_CMD; + + iap_entry (command, result); + + return result[1]; +} + diff --git a/Tester/SW/lib/Drivers/InternalFlash.h b/Tester/SW/lib/Drivers/InternalFlash.h new file mode 100644 index 0000000..80fb313 --- /dev/null +++ b/Tester/SW/lib/Drivers/InternalFlash.h @@ -0,0 +1,92 @@ +/* --------------------------------------------------------------------------- + * InternalFlash.h - v0.1 (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Feb 11, 2008, FSc + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef __INTERNALFLASH_H__ +#define __INTERNALFLASH_H__ +/** \file InternalFlash.h + \brief +*/ + +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ +typedef enum +{ + CMD_SUCCESS = 0, + INVALID_COMMAND = 1, + SRC_ADDR_ERROR = 2, + DST_ADDR_ERROR = 3, + SRC_ADDR_NOT_MAPPED = 4, + DST_ADDR_NOT_MAPPED = 5, + COUNT_ERROR = 6, + INVALID_SECTOR = 7, + SECTOR_NOT_BLANK = 8, + SECTOR_NOT_PREPARED_FOR_WRITE_OPERATION = 9, + COMPARE_ERROR = 10, + BUSY = 11 +} iflashresult; + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ + +/** \brief Initialises the internal flash module */ +void iflashInit(); + +/** \brief Prepares the flash for erasing and programming (must be called before these actions) */ +iflashresult iflashPrepare(UINT8 beginSector, UINT8 endSector); + +/** \brief Erases one sector on the internal flash */ +iflashresult iflashErase( UINT8 sector ); + +/** \brief Programs some data on the flash */ +iflashresult iflashProgram( UINT32 address, UINT16 dataLength, UINT8 *data); + +/** \brief Compares the data with the data on the internal flash on location "address" */ +iflashresult iflashVerify( UINT32 address, UINT16 dataLength, UINT8 *data); + +/** \brief This command is used to read the part identification number. */ +UINT32 iflashReadPartId(); + +/** \brief This command is used to read the boot code version number. */ +UINT32 iflashReadBootcodeVersionNr(); + + +#endif /* __INTERNALFLASH_H__ */ diff --git a/Tester/SW/lib/Drivers/LPC_REGS.h b/Tester/SW/lib/Drivers/LPC_REGS.h new file mode 100644 index 0000000..efc955a --- /dev/null +++ b/Tester/SW/lib/Drivers/LPC_REGS.h @@ -0,0 +1,7 @@ +#ifndef LPC_REGS_H__ +#define LPC_REGS_H__ + +#include "LPC23xx.h" +#include "LPC_UTIL_DEFS.h" + +#endif diff --git a/Tester/SW/lib/Drivers/LPC_UTIL_DEFS.h b/Tester/SW/lib/Drivers/LPC_UTIL_DEFS.h new file mode 100644 index 0000000..7746f94 --- /dev/null +++ b/Tester/SW/lib/Drivers/LPC_UTIL_DEFS.h @@ -0,0 +1,237 @@ +/* "ripped from the R O Software example and extended by mthomas */ + +#ifndef LPC_UTILDEFS_H +#define LPC_UTILDEFS_H + +/////////////////////////////////////////////////////////////////////////////// +// CLKSRC defines +#define CLKSRC_INT_RC (0x00) +#define CLKSRC_MAIN_OSC (0x01) +#define CLKSRC_MIN_RTC (0x02) + +/////////////////////////////////////////////////////////////////////////////// +// SCS defines +#define SCS_GPIOM (1UL<<0) +#define SCS_EMC_RST_DIS (1UL<<1) +#define SCS_MCIPWR (1UL<<3) +#define SCS_OSCRANGE (1UL<<4) +#define SCS_OSCEN (1UL<<5) +#define SCS_OSCSTAT (1UL<<6) + +/////////////////////////////////////////////////////////////////////////////// +// MAM defines +#define MAMCR_OFF 0 +#define MAMCR_PART 1 +#define MAMCR_FULL 2 + +#define MAMTIM_CYCLES (((CCLK) + 19999999) / 20000000) + +/////////////////////////////////////////////////////////////////////////////// +// MEMMAP defines +#define MEMMAP_BBLK 0 // Interrupt Vectors in Boot Block +#define MEMMAP_FLASH 1 // Interrupt Vectors in Flash +#define MEMMAP_SRAM 2 // Interrupt Vectors in SRAM + + +/////////////////////////////////////////////////////////////////////////////// +// VPBDIV defines & computations +#define VPBDIV_VALUE (PBSD & 0x03) // VPBDIV value + +/////////////////////////////////////////////////////////////////////////////// +// SCS defines - mthomas +#define GPIO0M (1 << 0) +#define GPIO1M (1 << 1) + +/////////////////////////////////////////////////////////////////////////////// +// UART defines + +#define U0_TX_PINSEL_REG PINSEL0 +#define U0_TX_PINSEL (1UL<<4) /* PINSEL0 Value for UART0 TX */ +#define U0_TX_PINMASK (3UL<<4) /* PINSEL0 Mask for UART0 RX */ +#define U0_RX_PINSEL_REG PINSEL0 +#define U0_RX_PINSEL (1UL<<6) /* PINSEL0 Value for UART0 TX */ +#define U0_RX_PINMASK (3UL<<6) /* PINSEL0 Mask for UART0 RX */ + +#define U1_TX_PINSEL_REG PINSEL4 +#define U1_TX_PINSEL (2UL<<0) /* PINSEL4 Value for UART1 TX */ +#define U1_TX_PINMASK (3UL<<0) /* PINSEL4 Mask for UART1 RX */ +#define U1_RX_PINSEL_REG PINSEL4 +#define U1_RX_PINSEL (2UL<<2) /* PINSEL4 Value for UART1 TX */ +#define U1_RX_PINMASK (3UL<<2) /* PINSEL4 Mask for UART1 RX */ +#define U1_CTS_PINSEL_REG PINSEL4 +#define U1_CTS_PINSEL (2UL<<4) /* PINSEL4 Value for UART1 TX */ +#define U1_CTS_PINMASK (3UL<<4) /* PINSEL4 Mask for UART1 RX */ +#define U1_RTS_PINSEL_REG PINSEL4 +#define U1_RTS_PINSEL (2UL<<14) /* PINSEL4 Value for UART1 TX */ +#define U1_RTS_PINMASK (3UL<<14) /* PINSEL4 Mask for UART1 RX */ + +// Interrupt Enable Register bit definitions +#define UIER_RBR (1UL << 0) // (UIER_ERBFI) Enable Receive Data Available Interrupt +#define UIER_THRE (1UL << 1) // (UIER_ETBEI) Enable Transmit Holding Register Empty Interrupt +#define UIER_RX_LINE_STAT (1UL << 2) // (UIER_ELSI) Enable Receive Line Status Interrupt +#define UIER_MODEM_STAT_INT_EN (1UL<<3) // (UIER_EDSSI) +#define UIER_CTS_INT_ENT (1UL << 7) +#define UIER_ABTOIntEn (1UL << 8) +#define UIER_ABE0IntEn (1UL << 9) + +// Interrupt ID Register bit definitions +#define UIIR_NO_INT (1 << 0) // NO INTERRUPTS PENDING if set +#define UIIR_MS_INT (0 << 1) // MODEM Status +#define UIIR_THRE_INT (1 << 1) // Transmit Holding Register Empty +#define UIIR_RDA_INT (2 << 1) // Receive Data Available +#define UIIR_RLS_INT (3 << 1) // Receive Line Status +#define UIIR_CTI_INT (6 << 1) // Character Timeout Indicator +#define UIIR_ID_MASK 0x0E +#define UIIR_FIFO_ENABLE (1<<6) +#define UIIR_ABEOInt (1<<8) +#define UIIR_ABTOInt (1<<9) + +// FIFO Control Register bit definitions +#define UFCR_FIFO_ENABLE (1 << 0) // FIFO Enable +#define UFCR_RX_FIFO_RESET (1 << 1) // Reset Receive FIFO +#define UFCR_TX_FIFO_RESET (1 << 2) // Reset Transmit FIFO +#define UFCR_FIFO_TRIG1 (0 << 6) // Trigger @ 1 character in FIFO +#define UFCR_FIFO_TRIG4 (1 << 6) // Trigger @ 4 characters in FIFO +#define UFCR_FIFO_TRIG8 (2 << 6) // Trigger @ 8 characters in FIFO +#define UFCR_FIFO_TRIG14 (3 << 6) // Trigger @ 14 characters in FIFO + +// Line Control Register bit definitions +#define ULCR_CHAR_5 (0 << 0) // 5-bit character length +#define ULCR_CHAR_6 (1 << 0) // 6-bit character length +#define ULCR_CHAR_7 (2 << 0) // 7-bit character length +#define ULCR_CHAR_8 (3 << 0) // 8-bit character length +#define ULCR_STOP_1 (0 << 2) // 1 stop bit +#define ULCR_STOP_2 (1 << 2) // 2 stop bits +#define ULCR_PAR_NO (0 << 3) // No Parity +#define ULCR_PAR_ODD (1 << 3) // Odd Parity +#define ULCR_PAR_EVEN (3 << 3) // Even Parity +#define ULCR_PAR_MARK (5 << 3) // MARK "1" Parity +#define ULCR_PAR_SPACE (7 << 3) // SPACE "0" Paruty +#define ULCR_BREAK_ENABLE (1 << 6) // Output BREAK line condition +#define ULCR_DLAB_ENABLE (1 << 7) // Enable Divisor Latch Access + +// Modem Control Register bit definitions +#define UMCR_DTR (1 << 0) // Data Terminal Ready +#define UMCR_RTS (1 << 1) // Request To Send +#define UMCR_LB (1 << 4) // Loopback +#define UMCR_RTS_EN (1 << 6) // Automatic RTS enable +#define UMCR_CTS_EN (1 << 7) // Automatic CTS enable + +// Line Status Register bit definitions +#define ULSR_RDR (1 << 0) // Receive Data Ready +#define ULSR_OE (1 << 1) // Overrun Error +#define ULSR_PE (1 << 2) // Parity Error +#define ULSR_FE (1 << 3) // Framing Error +#define ULSR_BI (1 << 4) // Break Interrupt +#define ULSR_THRE (1 << 5) // Transmit Holding Register Empty +#define ULSR_TEMT (1 << 6) // Transmitter Empty +#define ULSR_RXFE (1 << 7) // Error in Receive FIFO +#define ULSR_ERR_MASK 0x1E + +// Modem Status Register bit definitions +#define UMSR_DCTS (1 << 0) // Delta Clear To Send +#define UMSR_DDSR (1 << 1) // Delta Data Set Ready +#define UMSR_TERI (1 << 2) // Trailing Edge Ring Indicator +#define UMSR_DDCD (1 << 3) // Delta Data Carrier Detect +#define UMSR_CTS (1 << 4) // Clear To Send +#define UMSR_DSR (1 << 5) // Data Set Ready +#define UMSR_RI (1 << 6) // Ring Indicator +#define UMSR_DCD (1 << 7) // Data Carrier Detect + +/////////////////////////////////////////////////////////////////////////////// +// TIMER defines + +// Timer Interrupt Register Bit Definitions +#define TIR_MR0I (1 << 0) // Interrupt flag for match channel 0 +#define TIR_MR1I (1 << 1) // Interrupt flag for match channel 1 +#define TIR_MR2I (1 << 2) // Interrupt flag for match channel 2 +#define TIR_MR3I (1 << 3) // Interrupt flag for match channel 3 +#define TIR_CR0I (1 << 4) // Interrupt flag for capture channel 0 event +#define TIR_CR1I (1 << 5) // Interrupt flag for capture channel 1 event +#define TIR_CR2I (1 << 6) // Interrupt flag for capture channel 2 event +#define TIR_CR3I (1 << 7) // Interrupt flag for capture channel 3 event + +// PWM Interrupt Register Bit Definitions +#define PWMIR_MR0I (1 << 0) // Interrupt flag for match channel 0 +#define PWMIR_MR1I (1 << 1) // Interrupt flag for match channel 1 +#define PWMIR_MR2I (1 << 2) // Interrupt flag for match channel 2 +#define PWMIR_MR3I (1 << 3) // Interrupt flag for match channel 3 +#define PWMIR_MR4I (1 << 8) // Interrupt flag for match channel 4 +#define PWMIR_MR5I (1 << 9) // Interrupt flag for match channel 5 +#define PWMIR_MR6I (1 << 10) // Interrupt flag for match channel 6 +#define PWMIR_MASK (0x070F) + +// Timer Control Register Bit Definitions +#define TCR_ENABLE (1 << 0) +#define TCR_RESET (1 << 1) + +// PWM Control Register Bit Definitions +#define PWMCR_ENABLE (1 << 0) +#define PWMCR_RESET (1 << 1) + +// Timer Match Control Register Bit Definitions +#define TMCR_MR0_I (1 << 0) // Enable Interrupt when MR0 matches TC +#define TMCR_MR0_R (1 << 1) // Enable Reset of TC upon MR0 match +#define TMCR_MR0_S (1 << 2) // Enable Stop of TC upon MR0 match +#define TMCR_MR1_I (1 << 3) // Enable Interrupt when MR1 matches TC +#define TMCR_MR1_R (1 << 4) // Enable Reset of TC upon MR1 match +#define TMCR_MR1_S (1 << 5) // Enable Stop of TC upon MR1 match +#define TMCR_MR2_I (1 << 6) // Enable Interrupt when MR2 matches TC +#define TMCR_MR2_R (1 << 7) // Enable Reset of TC upon MR2 match +#define TMCR_MR2_S (1 << 8) // Enable Stop of TC upon MR2 match +#define TMCR_MR3_I (1 << 9) // Enable Interrupt when MR3 matches TC +#define TMCR_MR3_R (1 << 10) // Enable Reset of TC upon MR3 match +#define TMCR_MR3_S (1 << 11) // Enable Stop of TC upon MR3 match + +// Timer Capture Control Register Bit Definitions +#define TCCR_CR0_R (1 << 0) // Enable Rising edge on CAPn.0 will load TC to CR0 +#define TCCR_CR0_F (1 << 1) // Enable Falling edge on CAPn.0 will load TC to CR0 +#define TCCR_CR0_I (1 << 2) // Enable Interrupt on load of CR0 +#define TCCR_CR1_R (1 << 3) // Enable Rising edge on CAPn.1 will load TC to CR1 +#define TCCR_CR1_F (1 << 4) // Enable Falling edge on CAPn.1 will load TC to CR1 +#define TCCR_CR1_I (1 << 5) // Enable Interrupt on load of CR1 +#define TCCR_CR2_R (1 << 6) // Enable Rising edge on CAPn.2 will load TC to CR2 +#define TCCR_CR2_F (1 << 7) // Enable Falling edge on CAPn.2 will load TC to CR2 +#define TCCR_CR2_I (1 << 8) // Enable Interrupt on load of CR2 +#define TCCR_CR3_R (1 << 9) // Enable Rising edge on CAPn.3 will load TC to CR3 +#define TCCR_CR3_F (1 << 10) // Enable Falling edge on CAPn.3 will load TC to CR3 +#define TCCR_CR3_I (1 << 11) // Enable Interrupt on load of CR3 + +#if 0 +/////////////////////////////////////////////////////////////////////////////// +// VIC defines + +// VIC Channel Assignments +#define VIC_WDT 0 +#define VIC_TIMER0 4 +#define VIC_TIMER1 5 +#define VIC_UART0 6 +#define VIC_UART1 7 +#define VIC_PWM 8 +#define VIC_PWM0 8 +#define VIC_I2C 9 +#define VIC_SPI 10 +#define VIC_SPI0 10 +#define VIC_SPI1 11 +#define VIC_PLL 12 +#define VIC_RTC 13 +#define VIC_EINT0 14 +#define VIC_EINT1 15 +#define VIC_EINT2 16 +#define VIC_EINT3 17 +#define VIC_ADC 18 + +// Vector Control Register bit definitions +#define VIC_ENABLE (1 << 5) + +// Convert Channel Number to Bit Value +#define VIC_BIT(chan) (1L << (chan)) + +#endif + +#define VECT_ADDR_INDEX 0x100 +#define VECT_CNTL_INDEX 0x200 +#define VECT_PRIO_INDEX 0x200 + +#endif + diff --git a/Tester/SW/lib/Drivers/SerOut.c b/Tester/SW/lib/Drivers/SerOut.c new file mode 100644 index 0000000..90f5313 --- /dev/null +++ b/Tester/SW/lib/Drivers/SerOut.c @@ -0,0 +1,198 @@ +/* --------------------------------------------------------------------------- + * FILENAME.c (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * Contains a Function so send Messages on COM1/COM2 to a Terminal. + * Contains some handy Functions to convert different DataTypes to Strings + * + * --------------------------------------------------------------------------- + * Version(s): 0.1, Feb 11, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +#include +#include + +#include "lpc23xx.h" +#include "types.h" + +/* FreeRTOS includes */ +#include "FreeRTOS.h" +#include "Task.h" +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "SerOut.h" +#include "serial.h" +#include "logging.h" +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ + +extern UINT32 interruptcounter; +extern UINT32 switchcounter; + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ +char CustomMessage[40]; +char BoolRestoStrMessage[40]; +char D_array[40]; +char F_array[40]; +char H_array[40]; +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ + +void sendString(t_serial_devices ComPort, BOOLEAN newline, + Messagetype_t urgency, char * DefMessage, char * Devider, + char * CstmMessage) +{ + BOOLEAN allowPrintout = TRUE; + + switch (urgency) + { + case importantMessage: + if (block_ImportantMessage == TRUE) + { + allowPrintout = FALSE; + } + break; + case headerMessage: + if (block_HeaderMessage == TRUE) + { + allowPrintout = FALSE; + } + break; + case resultMessage: + if (block_ResultMessage == TRUE) + { + allowPrintout = FALSE; + } + break; + case noteMessage: + if (block_NoteMessage == TRUE) + { + allowPrintout = FALSE; + } + break; + case testMessage: + if (block_TestMessage == TRUE) + { + allowPrintout = FALSE; + } + break; + case menuMessage: + if (block_MenuMessage == TRUE) + { + allowPrintout = FALSE; + } + break; + default: + ; + } + + if ((allowPrintout == TRUE) || (LogFlag == TRUE)) + { + + if ((allowPrintout == TRUE) && (newline == TRUE)) + { + serWrite(ComPort, strlen("\n\r"), (UINT8 *)"\n\r"); + } + + strcpy(CustomMessage, DefMessage); /* Copy first Message to String */ + strcat(CustomMessage, Devider); /* Copy second Message to String*/ + strcat(CustomMessage, CstmMessage); /* Copy third Message to String */ + + if ((urgency == menuMessage)&& (block_MenuMessage == TRUE)) + { + /* Do nothing */ + } + else + { + writeLog(LogOutput, ComPort, urgency, CustomMessage); + } + + if (allowPrintout == TRUE) + { + /* Send built String to defined COM */ + serWrite(ComPort, strlen(CustomMessage), (UINT8 *) CustomMessage); + } + + } +} + +void debugPrint(char * Message) +{ + serWrite(SerOutPort, strlen(Message), (UINT8 *)Message); +} + + +char * BooltoStr (BOOLEAN var) +{ + if (var == TRUE) /* If BOOLEAN Variable is TRUE */ + { + strcpy(BoolRestoStrMessage, "HIGH/TRUE"); + } + else /* If BOOLEAN Variable is FALSE */ + { + strcpy(BoolRestoStrMessage, " LOW/FALSE "); + } + return BoolRestoStrMessage; /* Return built String */ +} + + +char * BoolRestoStr(BOOLEAN Result) +{ + if (Result == TRUE) /* If BOOLEAN Variable is TRUE */ + { + strcpy(BoolRestoStrMessage, "PASSED "); /* Copy "PASSED" to String */ + } + else /* If BOOLEAN Variable is FALSE */ + { + strcpy(BoolRestoStrMessage, " FAILED "); /* Copy "FAILED"to String */ + } + return BoolRestoStrMessage; /* Return built String */ +} + +char * ItoDStr(UINT32 IntValue) +{ + sprintf(D_array, "%i", IntValue); /* Convert INT-Value to DEZ-String */ + return D_array; /* Return DEZ-String */ +} + +char * FtoDStr(float IntValue) +{ + sprintf(F_array, "%f", IntValue); /* Convert INT-Value to DEZ-String */ + return F_array; /* Return FLOAT-String */ +} + +char * ItoHStr(UINT32 IntValue) +{ + sprintf(H_array, "%X", IntValue); /* Convert INT-Value to HEX-String */ + return H_array; /* Return HEX-String */ +} + diff --git a/Tester/SW/lib/Drivers/SerOut.h b/Tester/SW/lib/Drivers/SerOut.h new file mode 100644 index 0000000..7e64296 --- /dev/null +++ b/Tester/SW/lib/Drivers/SerOut.h @@ -0,0 +1,166 @@ +/* --------------------------------------------------------------------------- + * FILENAME.h (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * Headerfile for SerOut.c + * --------------------------------------------------------------------------- + * Version(s): 0.1, Feb 11, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef SEROUT_H_ +#define SEROUT_H_ + +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ +#include "lpc23xx.h" +#include "types.h" + + +/* FreeRTOS includes */ +#include "FreeRTOS.h" +#include "Task.h" +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ +#include "serial.h" +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ +/*predefines for sendString Function */ +#define StartMessage "\nBegin Test: " +#define EndMessage "End Test: " +#define NewLine "\n\r" +#define f_tab "\t" +#define s_tab "\t\t" +#define f_lines "\t---- " +#define s_lines "\t\t---- " +#define tabdevider "\t/\t" +#define devider " / " +#define Dummy "" + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ +typedef enum _Messagetype_t + { + importantMessage = 0, + headerMessage, + resultMessage, + noteMessage, + testMessage, + menuMessage + } Messagetype_t; +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ +BOOLEAN block_ImportantMessage; +BOOLEAN block_HeaderMessage; +BOOLEAN block_ResultMessage; +BOOLEAN block_NoteMessage; +BOOLEAN block_TestMessage; +BOOLEAN block_MenuMessage; +BOOLEAN block_SpinningWheel; +BOOLEAN GotoNewLine; + +/* Message in- and output */ +t_serial_devices SerOutPort; /* General used COM-Port */ +t_serial_devices MenuPort; /* Port for the Prompt-menu */ + +// \note help + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function: sendString + * + * Function to send a String on COM1 or COM2 + * + * Parameters: t_serial_devices ComPort, - defines the COM-Port to use + * BOOLEAN newline, - write to a newline or not + * char * DefMessage, - First Message to send + * char * Devider, - second Message to send + * char * CstmMessage - third Message to send + * Return: void + * --------------------------------------------------------------------------- + */ +void sendString (t_serial_devices ComPort, + BOOLEAN newline, + Messagetype_t urgency, + char * DefMessage, + char * Devider, + char * CstmMessage); + + +/* --------------------------------------------------------------------------- + * Function: debugPrint + * + * Function for a fast and easy stringOut method + * + * Parameters: char * Message - Message to send + * Return: void + * --------------------------------------------------------------------------- + */ +void debugPrint (char * Message); + + +/* --------------------------------------------------------------------------- + * Function: BooltoStr / BoolRestoStr + * + * Functions to convert a certain BOOLEAN-Value wether to "high" / "passed" or + * "low" / "failed" String. + * + * Parameters: BOOLEAN Result - the Value to be converted + * + * Return: char * - converted String + * --------------------------------------------------------------------------- + */ +char * BooltoStr (BOOLEAN var); +char * BoolRestoStr (BOOLEAN Result); + +/* --------------------------------------------------------------------------- + * Function: ItoDStr + * + * Function to convert a certain INT-Value to a dezimal formated String + * + * Parameters: UINT16 IntValue - the Value to be converted + * + * Return: char * - converted String + * --------------------------------------------------------------------------- + */ +char * ItoDStr (UINT32 IntValue); +char * FtoDStr (float IntValue); + +/* --------------------------------------------------------------------------- + * Function: ItoHStr + * + * Function to convert a certain INT-Value to a hexadezimal formated String + * + * Parameters: UINT16 IntValue - the Value to be converted + * + * Return: char * - converted String + * --------------------------------------------------------------------------- + */ +char * ItoHStr (UINT32 IntValue); + + + +#endif /*SEROUT_H_*/ diff --git a/Tester/SW/lib/Drivers/adc.c b/Tester/SW/lib/Drivers/adc.c new file mode 100644 index 0000000..97c2764 --- /dev/null +++ b/Tester/SW/lib/Drivers/adc.c @@ -0,0 +1,303 @@ +/* --------------------------------------------------------------------------- + * adc.c - v0.1 (c) 2007 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: ADC-driver (MCP3208-CI/SL) + * --------------------------------------------------------------------------- + * Version(s): 0.1, 28-11-2007, fvds. + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +#include "LPC23xx.h" +#include "types.h" + +/* FreeRTOS includes */ +#include "FreeRTOS.h" +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "adc.h" +#include "ssp0.h" +#include "ElecStatusCache.h" +#include "calibrateaio.h" +#include "sys_config.h" +#include "dio.h" + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ +#define ADC_CS_DIR_REG FIO1DIR +#define ADC_CS_SET_REG FIO1SET +#define ADC_CS_CLR_REG FIO1CLR +#define ADC_CS_BIT BIT( 25 ) +#define ADC_CS_DISABLE (ADC_CS_SET_REG = ADC_CS_BIT) +#define ADC_CS_ENABLE (ADC_CS_CLR_REG = ADC_CS_BIT) + +// \MARK NEW PINSETTINGS FOR TESTER (2) +#if (PINSET_TESTER == 2) +#define ADC_CV_DIR_REG FIO3DIR +#define ADC_CV_PIN_REG FIO3PIN +#define ADC_CV_SET_REG FIO3SET +#define ADC_CV_CLR_REG FIO3CLR +#else +#define ADC_CV_DIR_REG_P1 FIO1DIR +#define ADC_CV_DIR_REG_P2 FIO2DIR +#define ADC_CV_PIN_REG_P1 FIO1PIN +#define ADC_CV_PIN_REG_P2 FIO2PIN +#define ADC_CV_SET_REG_P1 FIO1SET +#define ADC_CV_SET_REG_P2 FIO2SET +#define ADC_CV_CLR_REG_P1 FIO1CLR +#define ADC_CV_CLR_REG_P2 FIO2CLR +#endif + +// \MARK NEW PINSETTINGS FOR TESTER (2) +#if (PINSET_TESTER == 2) +#define CURRENT_VOLTAGE_BITS (0x000000FF) +#else +#define CURRENT_VOLTAGE_BITS_P1 (0x3C000000) +#define CURRENT_VOLTAGE_BITS_P2 (0x00000078) +#endif + +// \MARK NEW PINSETTINGS FOR TESTER (2) +#if (PINSET_TESTER == 2) +#define ADC_MUX_DIR FIO3DIR +#define ADC_MUX_SET FIO3SET +#define ADC_MUX_CLR FIO3CLR + +#define ADC_MUX_BIT BIT(23) +#define ADC_MUX_EN (ADC_MUX_SET = ADC_MUX_BIT) +#define ADC_MUX_DS (ADC_MUX_CLR = ADC_MUX_BIT) +#endif + +#define spiWrite ssp0Write +#define spiRead ssp0Read +#define spiWriteBuffer ssp0WriteBuffer +#define spiReadBuffer ssp0ReadBuffer +#define spiTakeBus ssp0TakeBus +#define spiReleaseBus ssp0ReleaseBus + +#define ADC_START_CMD (0x04) +#define ADC_SINGLE_ENDED (0x02) +#define ADC_DIFFERENTIAL (0x00) + + + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ +UINT16 InputVoltageCorrection[8]; +UINT16 InputCurrentCorrection[8]; + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ + +void adcInit (void) +{ +// \MARK NEW PINSETTINGS FOR TESTER (2) +#if (PINSET_TESTER == 2) + /* TESTER Pins like IO_CTRL REV_B */ + ADC_CV_DIR_REG |= CURRENT_VOLTAGE_BITS; +#else + ADC_CV_DIR_REG_P1 |= CURRENT_VOLTAGE_BITS_P1; + ADC_CV_DIR_REG_P2 |= CURRENT_VOLTAGE_BITS_P2; +#endif +#if (PINSET_TESTER == 2) + /* TESTER Pins like IO_CTRL REV_B */ + ADC_CV_SET_REG = CURRENT_VOLTAGE_BITS; // Default all bits to current +#else + ADC_CV_SET_REG_P1 = CURRENT_VOLTAGE_BITS_P1; + ADC_CV_SET_REG_P2 = CURRENT_VOLTAGE_BITS_P2; +#endif + + ADC_CS_DIR_REG |= ADC_CS_BIT; + ADC_CS_DISABLE; + + loadCorrectionValue(InputVoltageCorrection, VoltageInput); + loadCorrectionValue(InputCurrentCorrection, CurrentInput); + +// \MARK NEW PINSETTINGS FOR TESTER (2) +#if (PINSET_TESTER == 2) + ADC_MUX_DIR |= ADC_MUX_BIT; +#endif + +} + + + +void adc_MuxEn (BOOLEAN mode) +{ +// \MARK NEW PINSETTINGS FOR TESTER (2) +#if (PINSET_TESTER == 2) + if (mode == TRUE) + { + ADC_MUX_EN; /* Set MUX to ExtensionBoard */ + } + else + { + ADC_MUX_DS; /* Set MUX to MainBoard */ + } +#endif +} + +BOOLEAN adc_MuxRB (void) +{ +// \MARK NEW PINSETTINGS FOR TESTER (2) +#if (PINSET_TESTER == 2) + if (ADC_MUX_SET & ADC_MUX_BIT) + { + /* Mux is switched to ExtensionBoard */ + return (TRUE); + } + else + { + /* Mux is switched to MainBoard */ + return (FALSE); + } +#endif +} + + +/** \brief Select input mode (Voltage or Current) of a certain channel. */ +void adcMode ( + UINT8 channel, /**< 0..7 = valid, 8..255 = future use */ + t_adc_mode mode +) +{ +#if (PINSET_TESTER == 2) + /* TESTER Pins like IO_CTRL REV_B */ + if (channel >= maxADC_Channels ) return; // Channel doesn't exist + + if (mode == adcVOLTAGE) + { + ADC_CV_CLR_REG = BIT( channel ); + } + else + { + ADC_CV_SET_REG = BIT( channel ); + } +#else + if (channel >= maxADC_Channels ) return; // Channel doesn't exist + + if (mode == adcVOLTAGE) + { + if (channel <= 3) + { + ADC_CV_CLR_REG_P1 = BIT (26 + channel); + } + else + { + ADC_CV_CLR_REG_P2 = BIT (channel - 1); + } + } + else + { + if (channel <= 3) + { + ADC_CV_SET_REG_P1 = BIT (26 + channel); + } + else + { + ADC_CV_SET_REG_P2 = BIT (channel - 1); + } + } +#endif +} + +/** \brief Read analog value in mV or uA depending on adcMode + \retval value VOLTAGE: 0..10000[mV], CURRENT: 0..20000[uA] */ +UINT16 adcRead ( + UINT8 device, /**< 0 = Self, 1..32 = Remote device */ + UINT8 channel /**< 0..7 = valid, 8..255 = future use */ +) +{ + UINT8 spiAdcCommand[3]; + UINT8 spiAdcResponse[3]; + UINT16 adcResult; + UINT32 range; + UINT32 measuredValue; + + if (device > 0) + { + measuredValue = bpecAdcRead(device, channel); + } + else + { + + if (channel >= maxADC_Channels) return 0; + + spiAdcCommand[0] = (ADC_START_CMD | ADC_SINGLE_ENDED); + spiAdcCommand[0] |= (channel >> 2) & 0x01; + spiAdcCommand[1] = (channel << 6); + spiAdcCommand[2] = 0; + + spiTakeBus(); + { + ADC_CS_ENABLE; + + spiWriteBuffer( spiAdcCommand, 3 ); + spiReadBuffer( spiAdcResponse, 3 ); + + ADC_CS_DISABLE; + } + spiReleaseBus(); + + adcResult = (UINT16)(spiAdcResponse[1] & 0x0F) << 8; + adcResult |= (UINT16)spiAdcResponse[2]; + + // Convert ADC value (0-4096) to measured value + // Determin range Voltage = 10000 & Ampere = 20000 +#if (PINSET_TESTER == 2) + /* TESTER Pins like IO_CTRL REV_B */ + if ((ADC_CV_PIN_REG & BIT( channel )) == 0) +#else + if ((((ADC_CV_PIN_REG_P1 & BIT (26 + channel)) == 0) && (channel <= 3)) + || (((ADC_CV_PIN_REG_P2 & BIT (channel - 1)) == 0) && (channel >= 4))) +#endif + { + range = 10000; + measuredValue = (adcResult * range) / InputVoltageCorrection[channel]; + } + else + { + range = 20000; + measuredValue = (adcResult * range) / InputCurrentCorrection[channel]; + } + } + + return (UINT16)measuredValue; +} + +void adcModeAll (t_adc_mode mode) +{ + adcMode (0, mode); + adcMode (1, mode); + adcMode (2, mode); + adcMode (3, mode); + adcMode (4, mode); + adcMode (5, mode); + adcMode (6, mode); + adcMode (7, mode); +} diff --git a/Tester/SW/lib/Drivers/adc.h b/Tester/SW/lib/Drivers/adc.h new file mode 100644 index 0000000..8e0cfdb --- /dev/null +++ b/Tester/SW/lib/Drivers/adc.h @@ -0,0 +1,90 @@ +/* --------------------------------------------------------------------------- + * adc.h - v0.1 (c) 2007 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: Analog to digital signal interface. + * --------------------------------------------------------------------------- + * Version(s): 0.1, 10-09-2007, Marcel Mulder. + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef __ADC_H__ +#define __ADC_H__ +/** \file adc.h + \brief Analog to digital signal interface. +*/ + +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ +#include "lpc23xx.h" +#include "types.h" + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ +/** Maximum number of real analog channels*/ +#define maxADC_Channels (8) +#define maxADC_VOLTAGE (10000) +#define maxADC_CURRENT (20000) + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ +typedef enum +{ + adcVOLTAGE, /**< Voltage mode 0 to 10V */ + adcCURRENT /**< Current mode 0 to 20mA */ +} t_adc_mode; + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ +/** \brief Initialize ADC.*/ +void adcInit (void); + +// \MARK NEW PINSETTINGS FOR TESTER (2) + +void adc_MuxEn (BOOLEAN mode); + +BOOLEAN adc_MuxRB (void); + + +/** \brief Select input mode (Voltage or Current) of a certain channel. */ +void adcMode ( + UINT8 channel, /**< 0..7 = valid, 8..255 = future use */ + t_adc_mode mode +); + +/** \brief Read analog value in mV or uA depending on adcMode + \retval value VOLTAGE: 0..10000[mV], CURRENT: 0..20000[uA] */ +UINT16 adcRead ( + UINT8 device, /**< 0 = Self, 1..32 = Remote device */ + UINT8 channel /**< 0..7 = valid, 8..255 = future use */ +); + +void adcModeAll (t_adc_mode mode); + +#endif /* __ADC_H__ */ diff --git a/Tester/SW/lib/Drivers/app_types.h b/Tester/SW/lib/Drivers/app_types.h new file mode 100644 index 0000000..0da4c56 --- /dev/null +++ b/Tester/SW/lib/Drivers/app_types.h @@ -0,0 +1,19 @@ +/****************************************************************************** + * + * $RCSfile: $ + * $Revision: $ + * + * This module defines some regularly used typedefs + * + *****************************************************************************/ + +#ifndef APP_TYPES_H__ +#define APP_TYPES_H__ + +/* typedefs are here */ +#include +#include /* NULL */ + +typedef enum {false, true} boolean; + +#endif diff --git a/Tester/SW/lib/Drivers/armVIC.c b/Tester/SW/lib/Drivers/armVIC.c new file mode 100644 index 0000000..f83b8a6 --- /dev/null +++ b/Tester/SW/lib/Drivers/armVIC.c @@ -0,0 +1,85 @@ +/****************************************************************************** + * + * $RCSfile: $ + * $Revision: $ + * + * This module provides the interface routines for setting up and + * controlling the various interrupt modes present on the ARM processor. + * Copyright 2004, R O SoftWare + * No guarantees, warrantees, or promises, implied or otherwise. + * May be used for hobby or commercial purposes provided copyright + * notice remains intact. + * + *****************************************************************************/ +#include "app_types.h" +#include "armVIC.h" + +#define IRQ_MASK 0x00000080 +#define FIQ_MASK 0x00000040 +#define INT_MASK (IRQ_MASK | FIQ_MASK) + +static inline unsigned __get_cpsr(void) +{ + unsigned long retval; + asm volatile (" mrs %0, cpsr" : "=r" (retval) : /* no inputs */ ); + return retval; +} + +static inline void __set_cpsr(unsigned val) +{ + asm volatile (" msr cpsr, %0" : /* no outputs */ : "r" (val) ); +} + +unsigned disableIRQ(void) +{ + unsigned _cpsr; + + _cpsr = __get_cpsr(); + __set_cpsr(_cpsr | IRQ_MASK); + return _cpsr; +} + +unsigned restoreIRQ(unsigned oldCPSR) +{ + unsigned _cpsr; + + _cpsr = __get_cpsr(); + __set_cpsr((_cpsr & ~IRQ_MASK) | (oldCPSR & IRQ_MASK)); + return _cpsr; +} + +unsigned enableIRQ(void) +{ + unsigned _cpsr; + + _cpsr = __get_cpsr(); + __set_cpsr(_cpsr & ~IRQ_MASK); + return _cpsr; +} + +unsigned disableFIQ(void) +{ + unsigned _cpsr; + + _cpsr = __get_cpsr(); + __set_cpsr(_cpsr | FIQ_MASK); + return _cpsr; +} + +unsigned restoreFIQ(unsigned oldCPSR) +{ + unsigned _cpsr; + + _cpsr = __get_cpsr(); + __set_cpsr((_cpsr & ~FIQ_MASK) | (oldCPSR & FIQ_MASK)); + return _cpsr; +} + +unsigned enableFIQ(void) +{ + unsigned _cpsr; + + _cpsr = __get_cpsr(); + __set_cpsr(_cpsr & ~FIQ_MASK); + return _cpsr; +} diff --git a/Tester/SW/lib/Drivers/armVIC.h b/Tester/SW/lib/Drivers/armVIC.h new file mode 100644 index 0000000..7402679 --- /dev/null +++ b/Tester/SW/lib/Drivers/armVIC.h @@ -0,0 +1,157 @@ +/****************************************************************************** + * + * $RCSfile: $ + * $Revision: $ + * + * This module provides the interface definitions for setting up and + * controlling the various interrupt modes present on the ARM processor. + * Copyright 2004, R O SoftWare + * No guarantees, warrantees, or promises, implied or otherwise. + * May be used for hobby or commercial purposes provided copyright + * notice remains intact. + * + *****************************************************************************/ +#ifndef INC_ARM_VIC_H +#define INC_ARM_VIC_H + +/****************************************************************************** + * + * MACRO Name: ISR_ENTRY() + * + * Description: + * This MACRO is used upon entry to an ISR. The current version of + * the gcc compiler for ARM does not produce correct code for + * interrupt routines to operate properly with THUMB code. The MACRO + * performs the following steps: + * + * 1 - Adjust address at which execution should resume after servicing + * ISR to compensate for IRQ entry + * 2 - Save the non-banked registers r0-r12 and lr onto the IRQ stack. + * 3 - Get the status of the interrupted program is in SPSR. + * 4 - Push it onto the IRQ stack as well. + * + *****************************************************************************/ +#define ISR_ENTRY() asm volatile(" sub lr, lr,#4\n" \ + " stmfd sp!,{r0-r12,lr}\n" \ + " mrs r1, spsr\n" \ + " stmfd sp!,{r1}") + +/****************************************************************************** + * + * MACRO Name: ISR_EXIT() + * + * Description: + * This MACRO is used to exit an ISR. The current version of the gcc + * compiler for ARM does not produce correct code for interrupt + * routines to operate properly with THUMB code. The MACRO performs + * the following steps: + * + * 1 - Recover SPSR value from stack + * 2 - and restore its value + * 3 - Pop the return address & the saved general registers from + * the IRQ stack & return + * + *****************************************************************************/ +#define ISR_EXIT() asm volatile(" ldmfd sp!,{r1}\n" \ + " msr spsr_c,r1\n" \ + " ldmfd sp!,{r0-r12,pc}^") + +/****************************************************************************** + * + * Function Name: disableIRQ() + * + * Description: + * This function sets the IRQ disable bit in the status register + * + * Calling Sequence: + * void + * + * Returns: + * previous value of CPSR + * + *****************************************************************************/ +unsigned disableIRQ(void); + +/****************************************************************************** + * + * Function Name: enableIRQ() + * + * Description: + * This function clears the IRQ disable bit in the status register + * + * Calling Sequence: + * void + * + * Returns: + * previous value of CPSR + * + *****************************************************************************/ +unsigned enableIRQ(void); + +/****************************************************************************** + * + * Function Name: restoreIRQ() + * + * Description: + * This function restores the IRQ disable bit in the status register + * to the value contained within passed oldCPSR + * + * Calling Sequence: + * void + * + * Returns: + * previous value of CPSR + * + *****************************************************************************/ +unsigned restoreIRQ(unsigned oldCPSR); + +/****************************************************************************** + * + * Function Name: disableFIQ() + * + * Description: + * This function sets the FIQ disable bit in the status register + * + * Calling Sequence: + * void + * + * Returns: + * previous value of CPSR + * + *****************************************************************************/ +unsigned disableFIQ(void); + +/****************************************************************************** + * + * Function Name: enableFIQ() + * + * Description: + * This function clears the FIQ disable bit in the status register + * + * Calling Sequence: + * void + * + * Returns: + * previous value of CPSR + * + *****************************************************************************/ +unsigned enableFIQ(void); + +/****************************************************************************** + * + * Function Name: restoreIRQ() + * + * Description: + * This function restores the FIQ disable bit in the status register + * to the value contained within passed oldCPSR + * + * Calling Sequence: + * void + * + * Returns: + * previous value of CPSR + * + *****************************************************************************/ +unsigned restoreFIQ(unsigned oldCPSR); + +#endif diff --git a/Tester/SW/lib/Drivers/bus.c b/Tester/SW/lib/Drivers/bus.c new file mode 100644 index 0000000..ae94549 --- /dev/null +++ b/Tester/SW/lib/Drivers/bus.c @@ -0,0 +1,317 @@ +/* --------------------------------------------------------------------------- + * bus.c - v0.1 (c) 2007 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: RS-485 bus driver + * --------------------------------------------------------------------------- + * Version(s): 0.1, 28-11-2007, fvds. + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +#include +#include + + +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "LPC23xx.h" +#include "types.h" +#include "bus.h" +#include "armVIC.h" +#include "uart2.h" +#include "uart3.h" + + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ +#define NR_OF_BUSPORTS 2 + +// \MARK NEW PINSETTINGS FOR TESTER (2) +// \TODO WATCH OUT PATCHES FOR UART2 +#if (PINSET_TESTER == 2) +#define UB2_DE_PINSEL_REG PINSEL2 +#define UB2_DE_PINSEL (0UL<<4) /* PINSEL8 Value for GPIO (P2.2) */ +#define UB2_DE_PINMASK (3UL<<4) /* PINSEL8 Mask for GPIO (P2.2) */ +#define UB2_RE_PINSEL_REG PINSEL2 +#define UB2_RE_PINSEL (0UL<<6) /* PINSEL8 Value for GPIO (P2.3) */ +#define UB2_RE_PINMASK (3UL<<6) /* PINSEL8 Mask for GPIO (P2.3) */ +#define UB3_DE_PINSEL_REG PINSEL2 +#define UB3_DE_PINSEL (0UL<<10) /* PINSEL8 Value for GPIO (P2.5) */ +#define UB3_DE_PINMASK (3UL<<10) /* PINSEL8 Mask for GPIO (P2.5) */ +#define UB3_RE_PINSEL_REG PINSEL2 +#define UB3_RE_PINSEL (0UL<<12) /* PINSEL8 Value for GPIO (P2.6) */ +#define UB3_RE_PINMASK (3UL<<12) /* PINSEL8 Mask for GPIO (P2.6) */ +#else +#define UB2_DE_PINSEL_REG PINSEL3 +#define UB2_DE_PINSEL (0UL<<0) /* PINSEL3 Value for GPIO */ +#define UB2_DE_PINMASK (3UL<<0) /* PINSEL3 Mask for GPIO */ +#define UB2_RE_PINSEL_REG PINSEL3 +#define UB2_RE_PINSEL (0UL<<2) /* PINSEL3 Value for GPIO */ +#define UB2_RE_PINMASK (3UL<<2) /* PINSEL3 Mask for GPIO */ +#define UB3_DE_PINSEL_REG PINSEL3 +#define UB3_DE_PINSEL (0UL<<4) /* PINSEL3 Value for GPIO */ +#define UB3_DE_PINMASK (3UL<<4) /* PINSEL3 Mask for GPIO */ +#define UB3_RE_PINSEL_REG PINSEL3 +#define UB3_RE_PINSEL (0UL<<6) /* PINSEL3 Value for GPIO */ +#define UB3_RE_PINMASK (3UL<<6) /* PINSEL3 Mask for GPIO */ +#endif + +// \MARK NEW PINSETTINGS FOR TESTER (2) +#if (PINSET_TESTER == 2) +#define UB2_REN_DE_DIR_REG FIO2DIR +#define UB2_REN_DE_SET_REG FIO2SET +#define UB2_REN_DE_CLR_REG FIO2CLR +#else +#define UB2_REN_DE_DIR_REG FIO1DIR +#define UB2_REN_DE_SET_REG FIO1SET +#define UB2_REN_DE_CLR_REG FIO1CLR +#endif +// \MARK NEW PINSETTINGS FOR TESTER (2) +#if (PINSET_TESTER == 2) +#define UB2_REN_BIT BIT(3) +#define UB2_DE_BIT BIT(2) +#else +#define UB2_REN_BIT BIT(17) +#define UB2_DE_BIT BIT(16) +#endif +#define UB2_REN_DE_BITS (UB2_REN_BIT | UB2_DE_BIT) +#define UB2_TX_MODE (UB2_REN_DE_SET_REG = UB2_REN_DE_BITS) +#define UB2_RX_MODE (UB2_REN_DE_CLR_REG = UB2_REN_DE_BITS) +#define UB2_LOOPBACK_MODE +// \MARK NEW PINSETTINGS FOR TESTER (2) +#if (PINSET_TESTER == 2) +#define UB3_REN_DE_DIR_REG FIO2DIR +#define UB3_REN_DE_SET_REG FIO2SET +#define UB3_REN_DE_CLR_REG FIO2CLR +#else +#define UB3_REN_DE_DIR_REG FIO1DIR +#define UB3_REN_DE_SET_REG FIO1SET +#define UB3_REN_DE_CLR_REG FIO1CLR +#endif +// \MARK NEW PINSETTINGS FOR TESTER (2) +#if (PINSET_TESTER == 2) +#define UB3_REN_BIT BIT(6) +#define UB3_DE_BIT BIT(5) +#else +#define UB3_REN_BIT BIT(19) +#define UB3_DE_BIT BIT(18) +#endif +#define UB3_REN_DE_BITS (UB3_REN_BIT | UB3_DE_BIT) +#define UB3_TX_MODE (UB3_REN_DE_SET_REG = UB3_REN_DE_BITS) +#define UB3_RX_MODE (UB3_REN_DE_CLR_REG = UB3_REN_DE_BITS) +#define UB3_LOOPBACK_MODE + + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ + +void onUart2TxFinished(); +void onUart3TxFinished(); + + +/** \brief Initialize of serial interface.*/ +void busInit ( + t_bus_devices device +) +{ + SCS |= (1UL<<0); // set GPIOM in SCS for fast IO + + switch( device ) + { + case(BUS1): + // set EN/DE pins for BUS0 + UB2_DE_PINSEL_REG = ( UB2_DE_PINSEL_REG & ~UB2_DE_PINMASK ) | UB2_DE_PINSEL; + UB2_RE_PINSEL_REG = ( UB2_RE_PINSEL_REG & ~UB2_RE_PINMASK ) | UB2_RE_PINSEL; + + // set EN/DE pin as output and in Receive mode + UB2_REN_DE_DIR_REG |= UB2_REN_DE_BITS; + UB2_RX_MODE; + uart2Init( B38400, UART_8N1, UART_FIFO_8 ); // \TODO BAUDRATE + uart2SubscribeTxFinished( onUart2TxFinished ); + + break; + case(BUS2): + // set EN/DE pins for BUS1 + UB3_DE_PINSEL_REG = ( UB3_DE_PINSEL_REG & ~UB3_DE_PINMASK ) | UB3_DE_PINSEL; + UB3_RE_PINSEL_REG = ( UB3_RE_PINSEL_REG & ~UB3_RE_PINMASK ) | UB3_RE_PINSEL; + + // set EN/DE pin as output and in Receive mode + UB3_REN_DE_DIR_REG |= UB3_REN_DE_BITS; + UB3_RX_MODE; + + uart3Init( B38400, UART_8N1, UART_FIFO_8 ); // \TODO BAUDRATE + uart3SubscribeTxFinished( onUart3TxFinished ); + + break; + } + +} + +/** \brief Write data of a certain length to a serial port.*/ +void busWrite ( + t_bus_devices device, + UINT16 length, /**< Lengh of data in bytes */ + UINT8 *data /**< Pointer to data */ +) +{ + switch( device ) + { + case(BUS1): + UB2_TX_MODE; + uart2Write( (char *)data, length); + break; + + case(BUS2): + UB3_TX_MODE; + uart3Write( (char *)data, length); + break; + } +} + +/** \brief Reads data from serial port. + \retval Length of received data in bytes*/ +UINT16 busRead ( + t_bus_devices device, + UINT8 * data /**< Pointer to data */ +) +{ + UINT16 bytesReceived = 0; + BOOLEAN receivedSomething; + do + { + receivedSomething = busGet( device, &(data[bytesReceived])); + if (receivedSomething) + bytesReceived++; + } while(receivedSomething); + + return bytesReceived; +} + +/** \brief Get byte from serial port. + \retval bool Returns true if there was data */ +BOOLEAN busGet( + t_bus_devices device, + UINT8 * byte /**< Pointer to byte to return data*/ +) +{ + int receivedChar = -1; + + switch( device ) + { + case(BUS1): + receivedChar = uart2Getch(); + break; + case(BUS2): + receivedChar = uart3Getch(); + break; + } + + if (receivedChar >= 0) + { + *byte = (UINT8)receivedChar; + return TRUE; + } + else + { + return FALSE; + } +} + +/** \brief Send byte to serial port. */ +void busPut( + t_bus_devices device, + UINT8 value /**< Byte to send*/ +) +{ + switch( device ) + { + case(BUS1): + UB2_TX_MODE; + uart2Putch( value ); + break; + case(BUS2): + UB3_TX_MODE; + uart3Putch( value ); + break; + } + +} + +/** \brief Flush serial port buffers. */ +void busFlush( + t_bus_devices device +) +{ + switch( device ) + { + case(BUS1): + uart2TxFlush( ); + break; + case(BUS2): + uart3TxFlush( ); + break; + } + +} + +/** \brief Check if receive buffers is empty. + \retval bool Returns true if recieve buffer is empty */ +BOOLEAN busEmpty( + t_bus_devices device +) +{ + switch( device ) + { + case(BUS1): + return (uart2RxEmpty( ) != 0); + break; + case(BUS2): + return (uart3RxEmpty( ) != 0); + break; + } + + return FALSE; +} + + +void onUart2TxFinished() +{ + // After all characters are send, put back in Receiver mode + UB2_RX_MODE; +} + +void onUart3TxFinished() +{ + // After all characters are send, put back in Receiver mode + UB3_RX_MODE; +} + diff --git a/Tester/SW/lib/Drivers/bus.h b/Tester/SW/lib/Drivers/bus.h new file mode 100644 index 0000000..a1a9021 --- /dev/null +++ b/Tester/SW/lib/Drivers/bus.h @@ -0,0 +1,106 @@ +/* --------------------------------------------------------------------------- + * bus.h - v0.1 (c) 2007 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: RS485 interface. + * --------------------------------------------------------------------------- + * Version(s): 0.1, 10-09-2007, Marcel Mulder. + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef __BUS_H__ +#define __BUS_H__ + +/** \file bus.h + \brief RS485 (UART) interface. +*/ +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ +#include "lpc23xx.h" +#include "types.h" +#include "uart.h" + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ +typedef enum +{ + BUS1, /**< First RS485 port*/ + BUS2 /**< Second RS485 port*/ +} t_bus_devices; + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ +/** \brief Initialize of serial bus interface.*/ +void busInit ( + t_bus_devices device +); + +/** \brief Write data of a certain length to a serial bus.*/ +void busWrite ( + t_bus_devices device, + UINT16 length, /**< Lengh of data in bytes */ + UINT8 * data /**< Pointer to data */ +); + +/** \brief Reads data from serial bus. + \retval Lengt of received data in bytes*/ +UINT16 busRead ( + t_bus_devices device, + UINT8 * data /**< Pointer to data */ +); + +/** \brief Get byte from serial bus. + \retval bool Returns true if there was data */ +BOOLEAN busGet( + t_bus_devices device, + UINT8 * byte /**< Pointer to byte to return data*/ +); + +/** \brief Send byte to serial bus. */ +void busPut( + t_bus_devices device, + UINT8 value /**< Byte to send*/ +); + +/** \brief Flush serial bus buffers. */ +void busFlush( + t_bus_devices device +); + +/** \brief Check if receive buffers is empty. + \retval bool Returns true if recieve buffer is empty +*/ +BOOLEAN busEmpty( + t_bus_devices device +); + +#endif /* __BUS_H__ */ diff --git a/Tester/SW/lib/Drivers/calibrateaio.c b/Tester/SW/lib/Drivers/calibrateaio.c new file mode 100644 index 0000000..d7ae062 --- /dev/null +++ b/Tester/SW/lib/Drivers/calibrateaio.c @@ -0,0 +1,769 @@ +/* --------------------------------------------------------------------------- + * calibrateaio.c (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Mei 22, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ + + +/* APPLICATION NOTES: + * Voltage Input Calibration: All Inputs need to be connected to the defined, + * preset Voltage Value (e.g. 10 V). + * + * Voltage Output Calibration: Output 0-3 need to be connected to own Inputs + * 0-3. + * + * Current Input Calibration: All Inputs need to be connected to the defined, + * preset Current Value (e.g. 20 mA per channel) + * + * Current Output Calibration: Output 0-3 need to be connected to own Inputs + * 0-3. All other Connections must be removed. + */ + + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +#include + +#include "lpc23xx.h" +#include "types.h" + +/* FreeRTOS includes */ +#include "FreeRTOS.h" +#include "Task.h" +#include "semphr.h" +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "calibrateaio.h" +#include "adc.h" +#include "dac.h" +#include "dio.h" +#include "eeprom.h" +#include "ssp0.h" +#include "BusProtocol.h" +#include "serial.h" +#include "SerOut.h" + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ +#define NumberOfOutputChannels maxDAC_Channels /* See dac.h */ +#define NumberOfInputChannels maxADC_Channels /* See adc.h */ + +#define MaximumCurrent 20000 /* Maximum driveable Current */ +#define MaximumVoltage 10000 /* Maximum driveable Voltage */ + +/* Addresses, where correction factors are stored in the EEPROM */ +#define VI_Address 0x00 /* Adress of Voltage Input Factor */ +#define CI_Address 0x10 /* Adress of Current Input Factor */ +#define VO_Address 0x20 /* Adress of Voltage Output Factor */ +// \MARK NEW PINSETTINGS FOR TESTER (2) +#if (PINSET_TESTER == 2) +#define CO_Address 0x30 /* Adress of Current Output Factor */ +#else +#define CO_Address 0x28 /* Adress of Current Output Factor */ +#endif + +#define VI_ByteLength 0x10 /* Length of VI Entry in Bytes */ +#define CI_ByteLength 0x10 /* Length of CI Entry in Bytes */ +// \MARK NEW PINSETTINGS FOR TESTER (2) +#if (PINSET_TESTER == 2) +#define VO_ByteLength 0x10 /* Length of VO Entry in Bytes */ +#define CO_ByteLength 0x10 /* Length of CO Entry in Bytes */ +#else +#define VO_ByteLength 0x08 /* Length of VO Entry in Bytes */ +#define CO_ByteLength 0x08 /* Length of CO Entry in Bytes */ +#endif + +// \MARK NEW PINSETTINGS FOR TESTER (2) +#if (PINSET_TESTER == 2) +#define ident_VoltageInput 0x40 /* Stat of Volt. Input Calibration */ +#define ident_VoltageOutput 0x41 /* Stat of Volt. Output Calibration */ +#define ident_CurrentInput 0x42 /* Stat of Curr. Input Calibration */ +#define ident_CurrentOutput 0x43 /* Stat of Curr. Output Calibration */ +#else +#define ident_VoltageInput 0x30 /* Stat of Volt. Input Calibration */ +#define ident_VoltageOutput 0x31 /* Stat of Volt. Output Calibration */ +#define ident_CurrentInput 0x32 /* Stat of Curr. Input Calibration */ +#define ident_CurrentOutput 0x33 /* Stat of Curr. Output Calibration */ +#endif + +#define DAC_CHANNEL_A (0x8000) +#define DAC_CHANNEL_B (0x0000) + + +#define spiWriteBuffer ssp0WriteBuffer +#define spiReadBuffer ssp0ReadBuffer + + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ +/* External Arrays where system stores calibration values for temporary use */ +extern UINT16 OutputVoltageCorrection[NumberOfOutputChannels]; +extern UINT16 OutputCurrentCorrection[NumberOfOutputChannels]; +extern UINT16 InputVoltageCorrection[NumberOfInputChannels]; +extern UINT16 InputCurrentCorrection[NumberOfInputChannels]; + + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ + + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ + +void killStats (void) +{ + eepromWrite(ident_VoltageInput, 0x00); /* Write 0x00 to EEPROM Adress */ + eepromWrite(ident_VoltageOutput, 0x00); + eepromWrite(ident_CurrentInput, 0x00); + eepromWrite(ident_CurrentOutput, 0x00); +} + +void defaultStats (void) +{ + eepromWrite(ident_VoltageInput, ident_default); /* Write DEFAULT Value */ + eepromWrite(ident_VoltageOutput, ident_default); + eepromWrite(ident_CurrentInput, ident_default); + eepromWrite(ident_CurrentOutput, ident_default); +} + +void calibratedStats (void) +{ + eepromWrite(ident_VoltageInput, ident_calibrated); /* Write CALIBRATED */ + eepromWrite(ident_VoltageOutput, ident_calibrated); + eepromWrite(ident_CurrentInput, ident_calibrated); + eepromWrite(ident_CurrentOutput, ident_calibrated); +} + + +void calibrationInit (void) +{ + UINT8 volin; + UINT8 volout; + UINT8 curin; + UINT8 curout; + + /* Readout Stats from EEPROM */ + eepromRead(ident_VoltageInput, &volin); + eepromRead(ident_VoltageOutput, &volout); + eepromRead(ident_CurrentInput, &curin); + eepromRead(ident_CurrentOutput, &curout); + + /* If a Stat is not defined, delete the Values and reset them to DEFAULT*/ + if ((volin != ident_default) && (volin != ident_calibrated)) + { + deleteCorrectionValue(VoltageInput); + loadCorrectionValue_defaultTarget(VoltageInput); + } + if ((volout != ident_default) && (volout != ident_calibrated)) + { + deleteCorrectionValue(VoltageOutput); + loadCorrectionValue_defaultTarget(VoltageOutput); + } + if ((curin != ident_default) && (curin != ident_calibrated)) + { + deleteCorrectionValue(CurrentInput); + loadCorrectionValue_defaultTarget(CurrentInput); + } + if ((curout != ident_default) && (curout != ident_calibrated)) + { + deleteCorrectionValue(CurrentOutput); + loadCorrectionValue_defaultTarget(CurrentOutput); + } + +} + +UINT8 returnCalibrationStatus (daadCorrection_t correctionType) +{ + UINT8 readback; + + /* read corresponding Stats from EEPROM */ + switch (correctionType) + { + case VoltageInput: eepromRead(ident_VoltageInput, &readback); + break; + case VoltageOutput: eepromRead(ident_VoltageOutput, &readback); + break; + case CurrentInput: eepromRead(ident_CurrentInput, &readback); + break; + case CurrentOutput: eepromRead(ident_CurrentOutput, &readback); + break; + } + + return (readback); /* Return read Value to Caller */ +} + + +UINT8 showLocalCalibrationStatus (INT32 correctionType) +{ + UINT8 readback; + + readback = returnCalibrationStatus (correctionType); + + if (readback & ident_default) + { + sendString (SerOutPort, FALSE, importantMessage, + "Values are in DEFAULT Mode", Dummy, Dummy); + } + else if (readback & ident_calibrated) + { + sendString (SerOutPort, FALSE, importantMessage, + "Values are in CALIBRATED Mode", Dummy, Dummy); + } + else + { + sendString (SerOutPort, FALSE, importantMessage, + "NO VALID VALUES IN EEPROM", Dummy, Dummy); + } + + return (readback); +} + + + +/* Calibration of Analogue Inputs in Voltage Mode: + * Attach Voltage Supply with Calibration Value (recommended: 10,000 V) to + * the Input(s) you want to calibrate. Software will read out the real, + * digital Value from the ADC and uses this as Point of Calibration. Value + * will be stored in EEPROM (Adresses see above). + */ + +void calibrateVoltageInput(void) +{ + /* Local Variable Declaration */ + UINT32 adcResult; + UINT32 loopcnt; + UINT16 VoltageInputCorrection[8]; + UINT8 spiAdcCommand[3]; + UINT8 spiAdcResponse[3]; + + /* Delete/Reset old Calibration Values */ + deleteCorrectionValue (VoltageInput); + /* Load default Calibration Values from EEPROM */ + loadCorrectionValue(InputVoltageCorrection, VoltageInput); + + adcModeAll (adcVOLTAGE); /* Set ADC to Mode VOLTAGE */ + + loopcnt = 0; + + do /* Do single for every Input */ + { + /* Reset readback Variables */ + adcResult = 0; + spiAdcResponse[0] = 0; + spiAdcResponse[1] = 0; + spiAdcResponse[2] = 0; + + /* Build SPI Command */ + spiAdcCommand[0] = 0x06; + spiAdcCommand[0] |= (loopcnt >> 2) & 0x01; + spiAdcCommand[1] = (loopcnt << 6); + spiAdcCommand[2] = 0; + + FIO1CLR = BIT( 25 ); /* Enable Chipselect of ADC */ + + spiWriteBuffer( spiAdcCommand, 3 ); /* send Command */ + spiReadBuffer( spiAdcResponse, 3 ); /* receive Response */ + + FIO1SET = BIT( 25 ); /* Disbale Chipselect of ADC */ + + /* Build 12 Bit Result out of 8 and 4 Bit readBack */ + adcResult = (UINT16)(spiAdcResponse[1] & 0x0F) << 8; + adcResult |= (UINT16)spiAdcResponse[2]; + + + /* Store result in Array for Voltage Input Correction */ + VoltageInputCorrection[loopcnt] = adcResult; + + loopcnt++; + } while (loopcnt < NumberOfInputChannels); + + + /* Save Correction Values to EEPROM */ + saveCorrectionValue(VoltageInputCorrection, VoltageInput); + /* Load new Calibration Values from EEPROM */ + loadCorrectionValue(InputVoltageCorrection, VoltageInput); +} + + +/* Calibration of Analogue Outputs in Voltage Mode: + * Attach the Output you want to calibrate to its corresponding Input + * (e.g. Output 1 to Input 1). Software will set up In- and Outputs + * automatically. The Correction Value will be calculated and stored in + * the EEPROM (Adresses see above). + */ +void calibrateVoltageOutput (void) +{ + UINT16 spiCommand; + UINT16 channel = 0; + UINT16 value = 0xF80; + UINT16 readVoltage; + UINT16 VoltageOutputCorrection[4]; + BOOLEAN leaveloop = FALSE; + + /* Delete/Reset old Calibration Values */ + deleteCorrectionValue (VoltageOutput); + /* Load default Calibration Values from EEPROM */ + loadCorrectionValue(OutputVoltageCorrection, VoltageOutput); + + + dacModeAll (dacVOLTAGE); /* Set Output Types to Voltage */ + adcModeAll (dacVOLTAGE); /* Set Input Types to Voltage */ + vTaskDelay (100); + + do /* Single for every Channel */ + { + do /* As long as false channel Result */ + { + /* Build and send SPI Command */ + spiCommand = 0x3000; + spiCommand |= ((channel & 0x01) == + 0x01 ? DAC_CHANNEL_B : DAC_CHANNEL_A); + spiCommand |= (UINT16) value; + WriteDacCommand( spiCommand, (channel >> 1)); + + vTaskDelay (50); + + readVoltage = adcRead (0, channel); + + /* Is Result exactly 10000? + * If so, wait for 1 Second and test again. If no change, Result + * is OK and Correction Value is stored. If not, test further + */ + if (readVoltage == 10000) + { + vTaskDelay (1000); + if ((readVoltage = adcRead (0, channel)) == 10000) + { + VoltageOutputCorrection[channel] = value; + leaveloop = TRUE; + } + } + + /* If Readback is too: + * LOW: increase Output and try again + * HIGH: decrease Output and try again + */ + else if (readVoltage > 10000) + { + value -= 0x01; + } + else if (readVoltage < 10000) + { + value += 0x01; + } + + } while (leaveloop == FALSE); + + /* Reset loop Values for next Channel */ + leaveloop = FALSE; + value = 0xF80; + channel++; + } while (channel < NumberOfOutputChannels); + + /* Save Correction Values to EEPROM */ + saveCorrectionValue(VoltageOutputCorrection, VoltageOutput); + /* Load new Calibration Values from EEPROM */ + loadCorrectionValue(OutputVoltageCorrection, VoltageOutput); +} + +/* Calibration of Analogue Inputs in Current Mode: + * Attach Current Supply with Calibration Value (recommended: 20,000 mA) to + * the first Input you want to calibrate. Software will read out the real, + * digital Value from the ADC and uses this as Point of Calibration. Continue + * with the next channel when software prompts to press enter. + * Value will be stored in EEPROM (Adresses see above). + * NEVER CONNECT MORE THAN ONE CHANNEL TO CURRENT SUPPLY ONCE + */ +void calibrateCurrentInput (void) +{ + UINT32 channel = 0; + UINT16 adcResult; + UINT16 CurrentInputCorrection[8]; + UINT8 buffer; + UINT8 spiAdcCommand[3]; + UINT8 spiAdcResponse[3]; + BOOLEAN receive; + + /* Delete/Reset old Calibration Values */ + deleteCorrectionValue (CurrentInput); + /* Load default Calibration Values from EEPROM */ + loadCorrectionValue(InputCurrentCorrection, CurrentInput); + + + adcModeAll (adcCURRENT); /* Set ADC Mode to CURRENT */ + vTaskDelay (100); + + + do /* Single for every Channel */ + { + /* Just for Testing!!! */ + receive = FALSE; + buffer = 0; + sendString (SerOutPort, TRUE, importantMessage, + "Press ENTER to continue with Channel ", ItoDStr (channel), Dummy); + do /* do-while loop for String input */ + { + vTaskDelay (10); + receive = serGet(MenuPort, &buffer); + } while ((buffer != 13) && (buffer != 32)); + + + /* Reset readback Variables */ + adcResult = 0x00; + spiAdcResponse[0] = 0; + spiAdcResponse[1] = 0; + spiAdcResponse[2] = 0; + + /* Build SPI Command */ + spiAdcCommand[0] = 0x06; + spiAdcCommand[0] |= (channel >> 2) & 0x01; + spiAdcCommand[1] = (channel << 6); + spiAdcCommand[2] = 0; + + FIO1CLR = BIT( 25 ); /* ADC chipselect enable */ + + spiWriteBuffer( spiAdcCommand, 3 ); /* Send SPI Command */ + spiReadBuffer( spiAdcResponse, 3 ); /* Receive Response */ + + FIO1SET = BIT( 25 ); /* ADC Chipselect disable */ + + /* Build 12 Bit Result out of 8 and 4 Bit readBack */ + adcResult = (UINT16)(spiAdcResponse[1] & 0x0F) << 8; + adcResult |= (UINT16)spiAdcResponse[2]; + + + /* Store Value to Array */ + CurrentInputCorrection[channel] = adcResult; + + channel++; /* Test next Channel */ + } while (channel < 8); + + /* Save Correction Values to EEPROM */ + saveCorrectionValue(CurrentInputCorrection, CurrentInput); + /* Load new Calibration Values from EEPROM */ + loadCorrectionValue(InputCurrentCorrection, CurrentInput); +} + +/* Connect Analogue Outputs to the corresponding analogue Inputs. Software + * will prevent of double-usage of channels. + * Values will be stored in EEPROM automatically + */ +void calibrateCurrentOutput (void) +{ + UINT16 spiCommand; + UINT16 channel = 0; + UINT16 value = 0xF80; + UINT16 readCurrent; + UINT16 CurrentOutputCorrection[4]; + BOOLEAN leaveloop = FALSE; + + /* Delete/Reset old Calibration Values */ + deleteCorrectionValue (CurrentOutput); + /* Load default Calibration Values from EEPROM */ + loadCorrectionValue(OutputCurrentCorrection, CurrentOutput); + + + dacModeAll (dacCURRENT); /* Set Output Types to Voltage */ + + adcMode(0, adcCURRENT); + adcMode(1, adcCURRENT); + adcMode(2, adcCURRENT); + adcMode(3, adcCURRENT); + adcMode(4, adcVOLTAGE); + adcMode(5, adcVOLTAGE); + adcMode(6, adcVOLTAGE); + adcMode(7, adcVOLTAGE); + + vTaskDelay (100); + + do /* Single for every Channel */ + { + do /* As long as false channel Result */ + { + /* Build and send SPI Command */ + spiCommand = 0x3000; + spiCommand |= ((channel & 0x01) == + 0x01 ? DAC_CHANNEL_B : DAC_CHANNEL_A); + spiCommand |= (UINT16) value; + WriteDacCommand( spiCommand, (channel >> 1)); + + vTaskDelay (50); + + readCurrent = adcRead (0, channel); + + /* Is Result exactly 20000? + * If so, wait for 1 Second and test again. If no change, Result + * is OK and Correction Value is stored. If not, test further + */ + + if (readCurrent == 20000) + { + vTaskDelay (1000); + if ((readCurrent = adcRead (0, channel)) == 20000) + { + CurrentOutputCorrection[channel] = value; + leaveloop = TRUE; + } + } + + /* If Readback is too: + * LOW: increase Output and try again + * HIGH: decrease Output and try again + */ + else if (readCurrent > 20000) + { + value -= 0x01; + } + else if (readCurrent < 20000) + { + value += 0x01; + } + + } while (leaveloop == FALSE); + + /* Reset loop Values for next Channel */ + leaveloop = FALSE; + value = 0xF80; + channel++; + } while (channel < NumberOfOutputChannels); + + /* Save Correction Values to EEPROM */ + saveCorrectionValue(CurrentOutputCorrection, CurrentOutput); + /* Load new Calibration Values from EEPROM */ + loadCorrectionValue(OutputCurrentCorrection, CurrentOutput); +} + + +void saveCorrectionValue(pUINT16 CorrectionValueArray, + daadCorrection_t correctionType) +{ + UINT32 loopcnt = 0; + UINT8 sendBuffer[16]; + + switch (correctionType) + { + case VoltageInput: /* Voltage Input Correction */ + while (loopcnt < NumberOfInputChannels) + { + /* Build 8Bit Array out of 16Bit Array */ + sendBuffer [2*loopcnt] = (CorrectionValueArray[loopcnt] + & 0x00FF); + sendBuffer [2*loopcnt+1] = ((CorrectionValueArray[loopcnt] + & 0xFF00) >> 8); + loopcnt++; + } + /* Send built Array to EEPROM with specific Address and Length */ + eepromWriteBuffer(VI_Address, sendBuffer, VI_ByteLength); + eepromWrite(ident_VoltageInput, ident_calibrated); + break; + + case VoltageOutput: /* Voltage Output Correction */ + while (loopcnt < NumberOfOutputChannels) + { + sendBuffer [2*loopcnt] = (CorrectionValueArray[loopcnt] + & 0x00FF); + sendBuffer [2*loopcnt+1] = ((CorrectionValueArray[loopcnt] + & 0xFF00) >> 8); + loopcnt++; + } + + eepromWriteBuffer(VO_Address, sendBuffer, VO_ByteLength); + eepromWrite(ident_VoltageOutput, ident_calibrated); + break; + + case CurrentInput: /* Current Input Correction */ + while (loopcnt < NumberOfInputChannels) + { + sendBuffer [2*loopcnt] = (CorrectionValueArray[loopcnt] + & 0x00FF); + sendBuffer [2*loopcnt+1] = ((CorrectionValueArray[loopcnt] + & 0xFF00) >> 8); + loopcnt++; + } + + eepromWriteBuffer(CI_Address, sendBuffer, CI_ByteLength); + eepromWrite(ident_CurrentInput, ident_calibrated); + break; + + case CurrentOutput: /* Current Output Correction */ + while (loopcnt < NumberOfOutputChannels) + { + sendBuffer [2*loopcnt] = (CorrectionValueArray[loopcnt] + & 0x00FF); + sendBuffer [2*loopcnt+1] = ((CorrectionValueArray[loopcnt] + & 0xFF00) >> 8); + loopcnt++; + } + + eepromWriteBuffer(CO_Address, sendBuffer, CO_ByteLength); + eepromWrite(ident_CurrentOutput, ident_calibrated); + break; + } + +} + +void loadCorrectionValue_defaultTarget (daadCorrection_t correctionType) +{ + UINT32 loopcnt = 0; + UINT8 receiveArray[16]; + + switch (correctionType) + { + case VoltageInput: /* Voltage Input Correction */ + /* Read EEPROM entry on specific Address and Length */ + eepromReadBuffer(VI_Address, receiveArray, VI_ByteLength); + + /* Build 16 Bit Array out of 8 Bit Array */ + while (loopcnt < NumberOfInputChannels) + { + InputVoltageCorrection[loopcnt] = (receiveArray[2*loopcnt]&0xFF) + | ((receiveArray[2*loopcnt+1]&0xFF) << 8); + loopcnt++; + } + break; + + case VoltageOutput: /* Voltage Output Correction */ + eepromReadBuffer(VO_Address, receiveArray, VO_ByteLength); + while (loopcnt < NumberOfOutputChannels) + { + OutputVoltageCorrection[loopcnt] = (receiveArray[2*loopcnt]&0xFF) + | ((receiveArray[2*loopcnt+1]&0xFF) << 8); + loopcnt++; + } + break; + + case CurrentInput: /* Current Input Correction */ + eepromReadBuffer(CI_Address, receiveArray, CI_ByteLength); + while (loopcnt < NumberOfInputChannels) + { + InputCurrentCorrection[loopcnt] = (receiveArray[2*loopcnt]&0xFF) + | ((receiveArray[2*loopcnt+1]&0xFF) << 8); + loopcnt++; + } + break; + + case CurrentOutput: /* Current Output Correction */ + eepromReadBuffer(CO_Address, receiveArray, CO_ByteLength); + while (loopcnt < NumberOfOutputChannels) + { + OutputCurrentCorrection[loopcnt] = (receiveArray[2*loopcnt]&0xFF) + | ((receiveArray[2*loopcnt+1]&0xFF) << 8); + loopcnt++; + } + break; + } + +} + +void loadCorrectionValue(pUINT16 CorrectionValueArray, + daadCorrection_t correctionType) +{ + UINT32 loopcnt = 0; + UINT8 receiveArray[16]; + + switch (correctionType) + { + case VoltageInput: /* Voltage Input Correction */ + /* Read EEPROM entry on specific Address and Length */ + eepromReadBuffer(VI_Address, receiveArray, VI_ByteLength); + + /* Build 16 Bit Array out of 8 Bit Array */ + while (loopcnt < NumberOfInputChannels) + { + CorrectionValueArray[loopcnt] = (receiveArray[2*loopcnt]&0xFF) + | ((receiveArray[2*loopcnt+1]&0xFF) << 8); + loopcnt++; + } + break; + + case VoltageOutput: /* Voltage Output Correction */ + eepromReadBuffer(VO_Address, receiveArray, VO_ByteLength); + while (loopcnt < NumberOfOutputChannels) + { + CorrectionValueArray[loopcnt] = (receiveArray[2*loopcnt]&0xFF) + | ((receiveArray[2*loopcnt+1]&0xFF) << 8); + loopcnt++; + } + break; + + case CurrentInput: /* Current Input Correction */ + eepromReadBuffer(CI_Address, receiveArray, CI_ByteLength); + while (loopcnt < NumberOfInputChannels) + { + CorrectionValueArray[loopcnt] = (receiveArray[2*loopcnt]&0xFF) + | ((receiveArray[2*loopcnt+1]&0xFF) << 8); + loopcnt++; + } + break; + + case CurrentOutput: /* Current Output Correction */ + eepromReadBuffer(CO_Address, receiveArray, CO_ByteLength); + while (loopcnt < NumberOfOutputChannels) + { + CorrectionValueArray[loopcnt] = (receiveArray[2*loopcnt]&0xFF) + | ((receiveArray[2*loopcnt+1]&0xFF) << 8); + loopcnt++; + } + break; + } + +} + + +void deleteCorrectionValue (daadCorrection_t correctionType) +{ + UINT32 loopcnt; + UINT8 emptyBuffer[16]; + + /* Build NULL-Array */ + for (loopcnt = 0; loopcnt < NumberOfInputChannels; loopcnt++) + { + emptyBuffer[2*loopcnt] = 0xFF; + emptyBuffer[2*loopcnt+1] = 0x0F; + } + + switch (correctionType) + { + case VoltageInput: + eepromWriteBuffer (VI_Address, emptyBuffer, VI_ByteLength); + eepromWrite(ident_VoltageInput, ident_default); + break; + case VoltageOutput: + eepromWriteBuffer (VO_Address, emptyBuffer, VO_ByteLength); + eepromWrite(ident_VoltageOutput, ident_default); + break; + case CurrentInput: + eepromWriteBuffer (CI_Address, emptyBuffer, CI_ByteLength); + eepromWrite(ident_CurrentInput, ident_default); + break; + case CurrentOutput: + eepromWriteBuffer (CO_Address, emptyBuffer, CO_ByteLength); + eepromWrite(ident_CurrentOutput, ident_default); + break; + } +} diff --git a/Tester/SW/lib/Drivers/calibrateaio.h b/Tester/SW/lib/Drivers/calibrateaio.h new file mode 100644 index 0000000..586dc22 --- /dev/null +++ b/Tester/SW/lib/Drivers/calibrateaio.h @@ -0,0 +1,245 @@ +/* --------------------------------------------------------------------------- + * calibrateaio.h (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: Digital inputs/outputs interface. + * --------------------------------------------------------------------------- + * Version(s): 0.1, Mei 22, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef CALIBRATEAIO_H_ +#define CALIBRATEAIO_H_ +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ +#include "lpc23xx.h" +#include "types.h" +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ +#define ident_calibrated 0x55 +#define ident_default 0xAA + +#define maxCAL_types (4) +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ +typedef enum _daadCorrection_t + { + VoltageInput = 0, + VoltageOutput = 1, + CurrentInput = 2, + CurrentOutput = 3 + + } daadCorrection_t; +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function: killStats + * + * Function deletes all calibration Stats in EEPROM + * + * Parameters: void + * + * Return: void + * --------------------------------------------------------------------------- + */ +void killStats (void); + + +/* --------------------------------------------------------------------------- + * Function: defaultStats + * + * Function resets all calibration Stats in EEPROM to default + * + * Parameters: void + * + * Return: void + * --------------------------------------------------------------------------- + */ +void defaultStats (void); + + +/* --------------------------------------------------------------------------- + * Function: calibratedStats + * + * Function sets all calibration stats in EEPROM to "CALIBRATED" + * + * Parameters: void + * + * Return: void + * --------------------------------------------------------------------------- + */ +void calibratedStats (void); + + +/* --------------------------------------------------------------------------- + * Function: calibrationInit + * + * Initialisation of Calibration status. + * Function should be called in bootup sequence. It reads all four calibration + * Stats from the EEPROM. If a Stat is neither set to DEFAULT nor to + * CALIBRATED, the INIT-Function will automatically reset the corresponding + * Calibration Values in EEPROM to DEFAULT (0x0FFF). + * + * Parameters: void + * + * Return: void + * --------------------------------------------------------------------------- + */ +void calibrationInit (void); + + +/* --------------------------------------------------------------------------- + * Function: returnCalibrationStatus + * + * Function sets all calibration stats in EEPROM to "CALIBRATED" + * + * Parameters: void + * + * Return: void + * --------------------------------------------------------------------------- + */ +UINT8 returnCalibrationStatus (daadCorrection_t correctionType); +UINT8 showLocalCalibrationStatus (INT32 correctionType); + +/* --------------------------------------------------------------------------- + * Function: calibrateVoltageInput + * + * function to calibrate the Voltage Input. + * Appliance hints: see Function in calibrateaio.c + * + * Parameters: void + * + * Return: void + * --------------------------------------------------------------------------- + */ +void calibrateVoltageInput (void); + + +/* --------------------------------------------------------------------------- + * Function: calibrateVoltageOutput + * + * function to calibrate the Voltage Output. + * Appliance hints: see Function in calibrateaio.c + * + * Parameters: void + * + * Return: void + * --------------------------------------------------------------------------- + */ +void calibrateVoltageOutput (void); + + +/* --------------------------------------------------------------------------- + * Function: calibrateCurrentInput + * + * function to calibrate the Current Input. + * Appliance hints: see Function in calibrateaio.c + * + * Parameters: void + * + * Return: void + * --------------------------------------------------------------------------- + */ +void calibrateCurrentInput (void); + + +/* --------------------------------------------------------------------------- + * Function: calibrateCurrentOutput + * + * function to calibrate the Current Output. + * Appliance hints: see Function in calibrateaio.c + * + * Parameters: void + * + * Return: void + * --------------------------------------------------------------------------- + */ +void calibrateCurrentOutput (void); + + +/* --------------------------------------------------------------------------- + * Function: saveCorrectionValue + * + * Function to save Corection Values to the EEPROM. The Storage Addresses are + * mentioned in calibrateaio.c (Makro definitions). Storage Addresses and + * Lengths depend on the type of Correction Values (given in correctionType). + * + * Parameters: pUINT16 CorrectionValueArray - Pointer to Value Array + * daadCorrection_t correctionType - Type of Calibration + * + * Return: void + * --------------------------------------------------------------------------- + */ +void saveCorrectionValue (pUINT16 CorrectionValueArray, + daadCorrection_t correctionType); + + +/* --------------------------------------------------------------------------- + * Function: loadCorrectionValue_defaultTarget / loadCorrectionValue + * + * Function to load Corection Values from EEPROM into the temporary work + * Array. + * The Read Addresses are mentioned in calibrateaio.c (Makro definitions). + * Read Addresses and Lengths depend on the type of Correction Values (given + * in correctionType). + * loadCorrectionValue_defaultTarget will load the Values to the default + * Target Arrays, which are defined in adc.c and dac.c + * + * Parameters: pUINT16 CorrectionValueArray - Pointer to Value Array + * daadCorrection_t correctionType - Type of Calibration + * + * Return: void + * --------------------------------------------------------------------------- + */ +void loadCorrectionValue_defaultTarget (daadCorrection_t correctionType); +void loadCorrectionValue(pUINT16 CorrectionValueArray, + daadCorrection_t correctionType); + + +/* --------------------------------------------------------------------------- + * Function: deleteCorrectionValue + * + * Function to delete the previous Calibration Values in EEPROM on the + * Address and Length depending on the Type (given in correctionType). + * Because the adc/dac Drivers multiplicate with the correction Values, they + * are not written to Zero but to 0xFFF, which results then in a + * calculation with 1. + * This function only overwrites the Values in EEPROM. The default Values then + * must be loaded with loadCorrectionValue(). + * + * Parameters: daadCorrection_t correctionType - Type of Calibration Values + * + * Return: void + * --------------------------------------------------------------------------- + */ +void deleteCorrectionValue (daadCorrection_t correctionType); + + + +#endif /*CALIBRATEAIO_H_*/ diff --git a/Tester/SW/lib/Drivers/can.c b/Tester/SW/lib/Drivers/can.c new file mode 100644 index 0000000..2517a32 --- /dev/null +++ b/Tester/SW/lib/Drivers/can.c @@ -0,0 +1,460 @@ +/* --------------------------------------------------------------------------- + * can.c (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Feb 11, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +/* Hardware Includes */ +#include "LPC23xx.h" +#include "types.h" + +/* FreeRTOS includes */ +#include "FreeRTOS.h" +#include "Task.h" +#include "queue.h" +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "can.h" +#include "SerOut.h" +#include "armVIC.h" +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ +#define CAN_PORT 2 +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ +static UINT32 debugVar = 0; +static UINT32 debugCnt = 0; +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ +UINT16 volatile gCANFilter = 0; /* Number of global set filters */ + +CAN_MSG volatile gCANList[MAX_FILTERS]; /* CAN message list */ +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ + + +UINT16 CANInit (UINT32 can_btr) +{ + + PCONP |= (1 << 14); /* power on CAN2 */ + + + /* Enable Pins for CAN interface */ + /* Set P0.4 to function 10 (RD2) */ + PINSEL0 &=~(1 << 8); /* Clear Bit 8 in PINSEL0 */ + PINSEL0 |= (1 << 9); /* set bit 9 in PINSEL0 */ + /* Set P0.5 to function 10 (TD2) */ + PINSEL0 &=~(1 << 10); /* Clear bit 10 in PINSEL0 */ + PINSEL0 |= (1 << 11); /* Set bit 11 in PINSEL0 */ + + gCANFilter = 0; /* Reset previous Filters */ +// CAN_AFMR = 0x00000001L; /* Switch off Aceptance Filter */ + + CAN2MOD = 0x00000001; /* Set Mode to Reset (Bit 0) */ + CAN2IER = 0x00000000; /* Disable all CAN2 Interrupts */ + CAN2GSR = 0x00000000; /* Clear all status bits */ + CAN2BTR = can_btr; /* Set bus timing */ + + /* Set Address of CAN ISR to Vectored Interrupt Address 23 */ + VICVectAddr23 = (unsigned long) CAN_IRS_Handler; + VICVectCntl23 = 1; /* Set a low interrupt priority */ + VICIntEnable |= (1 << 23); /* Enable CAN interrupt */ + +// CAN2IER = 0x00000081; /* Enable all RX and Err IRQs */ + CAN2IER = 0x00000001; /* Enable all RX IRQs */ + CAN2MOD = 0x00000000; /* Set Mode to Normal (Bit 0) */ + + return (TRUE); +} + + +UINT16 CANSetFilter (UINT32 CANID) +{ + UINT32 loopcnt = 0; + UINT32 regbuffer = 0; + UINT32 buf0; + UINT32 buf1; + UINT32 ID_lower; + UINT32 ID_upper; + UINT32 *pAddr; + + CAN_AFMR = 0x00000001L; /* Switch off Acceptance filter */ + + if (gCANFilter == 0) + { + /* First filter set - Init Entry of position Zero */ + /* Make first array entry for CAN device 1 + * This is necessary due to the following sort algorithm + */ + gCANList[0].Dat1 = 0x000037FFL; + } + + if (gCANFilter >= MAX_FILTERS) + { + /* If Array index exceeds the limit, return with error */ + return (FALSE); + } + + CANID &= 0x000007FFL; /* Mask the 11-bit ID */ + CANID |= ((CAN_PORT - 1) << 13); /* Add PORT# to ID */ + + /* Filters must be sorted by interface, then by priority */ + + /* Algorithm to sort new entry into excisting array */ + while (loopcnt < gCANFilter) /* Look through all entries */ + { + if ((gCANList[loopcnt].Dat1 & 0x0000FFFFL)> CANID) + { + /* Found position to insert new entry */ + break; + } + loopcnt++; + } + + buf0 = gCANList[loopcnt].Dat1; /* Buffer old array entry */ + gCANList[loopcnt].Dat1 = CANID; /* Insert the new entry */ + + /* move all remaining entries one position up */ + gCANFilter++; /* Increase Filter counter */ + while (loopcnt < gCANFilter) + { + loopcnt++; + buf1 = gCANList[loopcnt].Dat1; + gCANList[loopcnt].Dat1 = buf0; + buf0 = buf1; + } + + + CAN_SFF_SA = regbuffer; /* Set Std Frame Start Address */ + /* Set pointer to the Filter RAM base Address */ + pAddr = ( UINT32 *) ACCEPTANCE_FILTER_RAM_BASE; + + for (loopcnt = 0; loopcnt < ((gCANFilter + 1) / 2); loopcnt++) + { + ID_lower = gCANList[loopcnt * 2].Dat1 & 0x0000FFFFL; + ID_upper = gCANList[loopcnt * 2 + 1].Dat1 & 0x0000FFFFL; +// candata = (ID_lower << 16) + ID_upper; // \TODO IS THIS WORKING? +// *pAddr = candata; + *pAddr = (ID_lower << 16) + ID_upper; + regbuffer += 4; + pAddr++; + } + + /* regbuffer points to the End of the Table */ + + CAN_SFF_GRP_SA = regbuffer; /* Set Std Group Start Address */ + + // Set pointer for Extended Frame Individual + // Extended Frame Start Address Register + CAN_EFF_SA = regbuffer; /* Set Extd. Frame Start Address*/ + + CAN_EFF_GRP_SA = regbuffer; /* Set Extd. Group Start Address*/ + + CAN_EOT = regbuffer; /* Set End of Table */ + + CAN_AFMR = 0; /* enable Acception Filter */ + + return (TRUE); +} + + + +UINT16 CANPushMessage (CAN_MSG *pTransmitBuf) + { + UINT32 *pAddr; + UINT32 *pCandata; + UINT8 TXBufOffset; + + pAddr = (UINT32 *) &CAN2SR; // CANSR + + /* Check if one of the three transmit buffers are available, use first */ + if (!(*pAddr & 0x00000004L)) + { + /* First Buffer is not available */ + if (!(*pAddr & 0x00000400L)) + { + /* Second Buffer is not available */ + if (!(*pAddr & 0x00040000L)) + { + /* Third Buffer is not available -> No Buffer available */ + return (FALSE); /* Abort transmission, Error */ + } + else + { + /* Third Buffer is available, set Buffer offset */ + TXBufOffset = 0x08; + } + } + else + { + /* Second Buffer is available, set Buffer offset */ + TXBufOffset = 0x04; + } + } + else + { + /* First Buffer is available, set Buffer offset */ + TXBufOffset = 0x00; + } + + /* Write Data to Transmit Frame Information Register */ + pAddr = (UINT32 *) &CAN2TFI1 + TXBufOffset; /* Set pointer to CAN2TFIx */ // \TODO WATCH HERE (had offset)!!! + *pAddr = (pTransmitBuf->Dat1 & 0x000F0000L); + + /* Write CAN ID to Transmit Identifier Register */ + pAddr++; /* Increase pointer to CAN2TIDx */ + *pAddr = pTransmitBuf->Dat1 & 0x000007FFL; + + /* Write first four Bytes to Transmit Data Register A */ + pCandata = (UINT32 *) &(pTransmitBuf->DatA); /* Get first 4 bytes */ + pAddr++; /* Set pointer to DataA register*/ + *pAddr = *pCandata; /* Write first 4 bytes to DataA */ + + /* Write second four Bytes to Transmit Data Register B */ + pCandata++; /* Get second four bytes */ + pAddr++; /* Point to DataB register */ + *pAddr = *pCandata; /* Write second 4 Bytes to DataB*/ + + + /* Write Transmission Request to CAN2 Command Register + * This Action is depending on the chosen transmission buffer (1-3) + * Two bits must be written - Bit (0): (TR) Transmission Request + * Bit (5|6|7): (STBx) Select Buffer (1|2|3) + */ + if (TXBufOffset == 0x00) + { + /* First buffer was chosen. Write TR and STB1 */ + CAN2CMR = 0x21; + } + else if (TXBufOffset == 0x04) + { + /* Second buffer was chosen. Write TR and STB2 */ + CAN2CMR = 0x41; + } + else if (TXBufOffset == 0x08) + { + /* Third buffer was chosen. Write TR and STB3 */ + CAN2CMR = 0x81; + } + else + { + /* No Buffer was chosen, return with error (should not come here) */ + return (FALSE); + } + + return (TRUE); +} + + +UINT16 CANPullMessage (CAN_MSG *pReceiveBuf) +{ + UINT32 loopcnt = 0; + UINT32 *pSrc; + UINT32 *pDst; + UINT32 match; + + + /* Initialise Source and Destination Pointer */ + pSrc = (UINT32 *) &(gCANList[0].Dat1); + pDst = (UINT32 *) &(pReceiveBuf->Dat1); + + /* Prepare match value for CAN interface */ + match = CAN_PORT << 13; + match |= 0x03000000L; /* Semaphore bits are 11b */ + + while (loopcnt < gCANFilter) + { + /* Scan for every set Filter */ + if ((*pSrc & 0x0300E000L) == match) + { + /* A new Message is detected in Source Array */ + *pSrc &= 0xFCFFFFFFL; /* clear Semaphore */ + + *pDst = *pSrc; /* Copy Dat1 from SRC to DST */ + + pSrc++; /* Set SRC-Pointer to SRC.DataA */ + pDst++; /* Set DST-Pointer to DST.DataA */ + + *pDst = *pSrc; /* Copy DatA from SRC to DST */ + + pSrc++; /* Set SRC-Pointer to SRC.DataB */ + pDst++; /* Set DST-Pointer to DST.DataB */ + + *pDst = *pSrc; /* Copy DatB from SRC to DST */ + + pSrc -= 2; // Reset SRC-Pointer to Dat1 */ + pDst -= 2; // Reset DST-Pointer to Dat1 */ + + if ((*pSrc & 0x03000000L) == 0) + { + /* If actual SRC was updated while reading, return to caller + * This is to prevent of ignoring the message that came in while + * reading, which would not be noticed if the message counter + * will be increased like the loop will do in the next step + */ + return (TRUE); + } + } + loopcnt++; /* Go to next Message in Buffer */ + pSrc += 3; /* Increase SRC-Pointer to next */ + } + return (FALSE); /* Return False if no Message in*/ +} + + +void CAN_IRS_Handler() +{ + UINT32 CANStatus; + + ISR_ENTRY(); + CANStatus = CAN_RX_SR; + if (CANStatus & (1 << 8)) + { + /* A received Message is available in CAN1 controller */ + CAN_CANISR_Rx1(); + } + if (CANStatus & (1 << 9)) + { + /* A received Message is available in CAN2 controller */ + CAN_CANISR_Rx2(); + } + +/* Error Interrupts are currently disabled due to purpose of CAN driver */ + if (CAN_MSR & (1 << 1)) + { + /* At least one Error-Counter of CAN2 has reached the limit */ + CAN_CANISR_Err(); + } + if (CAN1GSR & (1 << 6 )) + { + /* The error count includes both TX and RX */ + } + if (CAN2GSR & (1 << 6 )) + { + /* The error count includes both TX and RX */ + } + if (CAN2ICR & (1 << 7)) + { + /* Error-on-Bus Interrupt detected */ + CAN_ERRORBUS(); + } + + VICVectAddr = 0; /* Acknowledge Interrupt */ + + ISR_EXIT(); +} + + +void CAN_CANISR_Rx1 (void) +{ +UINT32 buf; +UINT32 *pDest; + + if (!(CAN1RFS & 0xC0000400L)) + { // 11-bit ID, no RTR, matched a filter + + // initialize destination pointer + // filter number is in lower 10 bits of C1RFS + pDest = (UINT32 *) &(gCANList[(CAN1RFS & 0x000003FFL)].Dat1); + + // calculate contents for first entry into CAN list + buf = CAN1RFS & 0xC00F0000L; // mask FF, RTR and DLC + buf |= 0x01002000L; // set semaphore to 01b and CAN port to 1 + buf |= CAN1RID & 0x000007FFL; // get CAN message ID + + // now copy entire message to CAN list + *pDest = buf; + pDest++; // set to gCANList[(C1RFS & 0x000003FFL)].DatA + *pDest = CAN1RDA; + pDest++; // set to gCANList[(C1RFS & 0x000003FFL)].DatB + *pDest = CAN1RDB; + + // now set the sempahore to complete + buf |= 0x03000000L; // set semaphore to 11b + pDest -= 2; // set to gCANList[(C1RFS & 0x000003FFL)].Dat1 + *pDest = buf; + } + + CAN1CMR = 0x04; // release receive buffer +} + + +void CAN_CANISR_Rx2(void) +{ + UINT32 buf; + UINT32 *pDest; + + debugVar = 0x00000001; + + if (!(CAN2RFS & 0xC0000400L)) + { + /* 11-bit ID, no RTR */ + debugVar = 0x00000011; + /* initialize Destination Pointer */ + /* Filter Nmber is in bit 0-9 of CAN2RFS */ + pDest = (UINT32 *) &(gCANList[(CAN2RFS & 0x000003FFL)].Dat1); +// pDest = (UINT32 *) &(gCANList[(1)].Dat1); + + /* Calculate contents for first entry into CAN list */ + buf = CAN2RFS & 0xC00F0000L; /* Mask FF, RTR and DLC */ + buf |= 0x01004000L; /* set sema to 01b and port to 2*/ + buf |= CAN2RID & 0x000007FFL; /* get CAN message ID */ + + /* Copy entire message to CAN list */ + *pDest = buf; /* Copy Dat1 to DST */ + pDest++; /* Set Pointer to DataA */ + *pDest = CAN2RDA; /* copy DataA */ + pDest++; /* Set Pointer to DataB */ + *pDest = CAN2RDB; /* Copy DataB */ + + + buf |= 0x03000000L; /* semaphore to 11b (complete) */ + pDest -= 2; /* Set back to Dat1 */ + *pDest = buf; /* update semaphore in DST */ + } + + debugCnt++; + CAN2CMR = 0x04; /* Release Receive Buffer */ +} + + +void CAN_CANISR_Err (void) +{ + +} + +void CAN_ERRORBUS (void) +{ + volatile UINT32 regRead; + + regRead = CAN2ICR; + + debugPrint("released"); +} diff --git a/Tester/SW/lib/Drivers/can.h b/Tester/SW/lib/Drivers/can.h new file mode 100644 index 0000000..83cced9 --- /dev/null +++ b/Tester/SW/lib/Drivers/can.h @@ -0,0 +1,110 @@ +/* --------------------------------------------------------------------------- + * can.h (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Feb 11, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef CAN_H_ +#define CAN_H_ +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ +/* Hardware Includes */ +#include "LPC23xx.h" +#include "types.h" + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ + +// Maximum number of total FullCAN Filters for ALL CAN interfaces +#define MAX_FILTERS 20 + +// Define CAN SFR address bases +#define CAN_REG_BASE (0xE0000000) +#define ACCEPTANCE_FILTER_RAM_BASE (CAN_REG_BASE + 0x00038000) +#define ACCEPTANCE_FILTER_REGISTER_BASE (CAN_REG_BASE + 0x0003C000) +#define CENTRAL_CAN_REGISTER_BASE (CAN_REG_BASE + 0x00040000) + +// Common CAN bit rates +#define CANBitrate50_12MHz 0x001C000E +#define CANBitrate125k_12MHz 0x001C0005 +#define CANBitrate250k_12MHz 0x001C0002 + +// CAN Interrupt Service Routines +void CAN_IRS_Handler (void) __attribute__ ((naked, interrupt("IRQ"))); +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ +// Type definition to hold a FullCAN message +// Compatible to FullCAN Mode Stored Messages in LPC User Manual +typedef struct +{ + UINT32 Dat1; // Bits 0..10: CAN Message ID + // Bits 13..15: CAN interface number (1..4) + // Bits 16..19: DLC - Data Length Counter + // Bits 24..25: Semaphore bits + UINT32 DatA; // CAN Message Data Bytes 0-3 + UINT32 DatB; // CAN Message Data Bytes 4-7 +} CAN_MSG; +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ + + +UINT16 CANInit ( + UINT32 can_btr /* CAN Baud Rate setting */ + ); + + +UINT16 CANSetFilter + ( + UINT32 CANID // 11-bit CAN message identifier + ); + + + +UINT16 CANPushMessage ( + CAN_MSG *pTransmitBuf // Source pointer to a CAN message + ); + + +UINT16 CANPullMessage ( + CAN_MSG *pReceiveBuf // Destination pointer to a CAN message + ); + + +void CAN_CANISR_Rx1 (void); +void CAN_CANISR_Rx2 (void); +void CAN_CANISR_Err (void); +void CAN_ERRORBUS (void); + + + +#endif /*CAN_H_*/ diff --git a/Tester/SW/lib/Drivers/dac.c b/Tester/SW/lib/Drivers/dac.c new file mode 100644 index 0000000..f99584f --- /dev/null +++ b/Tester/SW/lib/Drivers/dac.c @@ -0,0 +1,416 @@ +/* --------------------------------------------------------------------------- + * dac.c - v0.1 (c) 2007 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: ADC-driver + * --------------------------------------------------------------------------- + * Version(s): 0.1, 28-11-2007, fvds. + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +#include "LPC23xx.h" +#include "types.h" + +/* FreeRTOS includes */ +#include "FreeRTOS.h" +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "dac.h" +#include "sys_config.h" +#include "ssp0.h" +#include "dio.h" +#include "calibrateaio.h" +#include "ElecStatusCache.h" + + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ +#define DAC_CS_DIR_REG FIO1DIR +#define DAC_CS_SET_REG FIO1SET +#define DAC_CS_CLR_REG FIO1CLR +#define DAC1_CS_BIT BIT( 21 ) +#define DAC2_CS_BIT BIT( 22 ) +// \MARK NEW PINSETTINGS FOR TESTER (2) +#if (PINSET_TESTER == 2) +#define DAC3_CS_BIT BIT( 19) +#endif + +// \MARK NEW PINSETTINGS FOR TESTER (2) +#if (PINSET_TESTER == 2) +#define DACS_CS_BITS (DAC1_CS_BIT | DAC2_CS_BIT | DAC3_CS_BIT) +#else +#define DACS_CS_BITS (DAC1_CS_BIT | DAC2_CS_BIT) +#endif + +#define DAC1_CS_DISABLE (DAC_CS_SET_REG = DAC1_CS_BIT) +#define DAC1_CS_ENABLE (DAC_CS_CLR_REG = DAC1_CS_BIT) +#define DAC2_CS_DISABLE (DAC_CS_SET_REG = DAC2_CS_BIT) +#define DAC2_CS_ENABLE (DAC_CS_CLR_REG = DAC2_CS_BIT) +// \MARK NEW PINSETTINGS FOR TESTER (2) +#if (PINSET_TESTER == 2) +#define DAC3_CS_DISABLE (DAC_CS_SET_REG = DAC3_CS_BIT) +#define DAC3_CS_ENABLE (DAC_CS_CLR_REG = DAC3_CS_BIT) +#endif + +// \MARK NEW PINSETTINGS FOR TESTER (2) +#if (PINSET_TESTER == 2) +#define DAC_CV_DIR_REG FIO4DIR +#define DAC_CV_SET_REG FIO4SET +#define DAC_CV_CLR_REG FIO4CLR +#else +#define DAC_CV_DIR_REG FIO3DIR +#define DAC_CV_SET_REG FIO3SET +#define DAC_CV_CLR_REG FIO3CLR +#endif + +// \MARK NEW PINSETTINGS FOR TESTER (2) +#if (PINSET_TESTER == 2) +#define CURRENT_VOLTAGE_BITS (0x0000003F) +#else +#define CURRENT_VOLTAGE_BITS (0x07800000) +#endif + +// \MARK NEW PINSETTINGS FOR TESTER (2) +#if (PINSET_TESTER == 2) +#define DAC_MUX_DIR FIO3DIR +#define DAC_MUX_SET FIO3SET +#define DAC_MUX_CLR FIO3CLR + +#define DAC_MUX_BIT BIT(24) +#define DAC_MUX_EN (DAC_MUX_SET = DAC_MUX_BIT) +#define DAC_MUX_DS (DAC_MUX_CLR = DAC_MUX_BIT) +#endif + +#define spiWrite ssp0Write +#define spiRead ssp0Read +#define spiWriteBuffer ssp0WriteBuffer +#define spiReadBuffer ssp0ReadBuffer +#define spiTakeBus ssp0TakeBus +#define spiReleaseBus ssp0ReleaseBus + + +#define DAC_CHANNEL_A (0x8000) +#define DAC_CHANNEL_B (0x0000) + +#define DAC_OUTPUT_BUFFERED (0x4000) +#define DAC_OUTPUT_UNBUFFERED (0x0000) +#define DAC_OUTPUT_GAIN_1x (0x2000) +#define DAC_OUTPUT_GAIN_2x (0x0000) +#define DAC_SHDN_OPDC (0x1000) +#define DAC_SHDN_DISABLED (0x0000) +#define DAC_MAX_SETTING (4095) +#define DAC_MAX_CURRENT (20000) +#define DAC_MAX_VOLTAGE (10000) + + + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ +UINT16 OutputVoltageCorrection[maxDAC_Channels]; +UINT16 OutputCurrentCorrection[maxDAC_Channels]; +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ + +// \MARK NEW PINSETTINGS FOR TESTER (2) +#if (PINSET_TESTER == 2) +t_dac_mode channelModes[maxDAC_Channels] = +{ + dacCURRENT, + dacCURRENT, + dacCURRENT, + dacCURRENT, + dacCURRENT, + dacCURRENT +}; + +UINT16 channelSetting[maxDAC_Channels] = +{ + 0, + 0, + 0, + 0, + 0, + 0 +}; +#else +t_dac_mode channelModes[maxDAC_Channels] = +{ + dacCURRENT, + dacCURRENT, + dacCURRENT, + dacCURRENT +}; + +UINT16 channelSetting[maxDAC_Channels] = +{ + 0, + 0, + 0, + 0 +}; +#endif + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ + + + +void dacInit (void) +{ + DAC_CV_DIR_REG |= CURRENT_VOLTAGE_BITS; + DAC_CV_CLR_REG = CURRENT_VOLTAGE_BITS; // Default all bits to current + DAC_CS_DIR_REG |= DACS_CS_BITS; + DAC1_CS_DISABLE; + DAC2_CS_DISABLE; +// \MARK NEW PINSETTINGS FOR TESTER (2) +#if (PINSET_TESTER == 2) + DAC3_CS_DISABLE; + DAC_MUX_DIR |= DAC_MUX_BIT; +#endif + + loadCorrectionValue(OutputVoltageCorrection, VoltageOutput); + loadCorrectionValue(OutputCurrentCorrection, CurrentOutput); + + +} + + +void dac_MuxEn (BOOLEAN mode) +{ +// \MARK NEW PINSETTINGS FOR TESTER (2) +#if (PINSET_TESTER == 2) + if (mode == TRUE) + { + DAC_MUX_EN; /* Set MUX to ExtensionBoard */ + } + else + { + DAC_MUX_DS; /* Set MUX to MainBoard */ + } +#endif +} + +BOOLEAN dac_MuxRB (void) +{ +// \MARK NEW PINSETTINGS FOR TESTER (2) +#if (PINSET_TESTER == 2) + if (DAC_MUX_SET & DAC_MUX_BIT) + { + /* Mux is switched to ExtensionBoard */ + return (TRUE); + } + else + { + /* Mux is switched to MainBoard */ + return (FALSE); + } +#endif +} + + + +/** \brief Select output mode (Voltage or Current) of a certain channel. */ +void dacMode ( + UINT8 channel, /*< 0..5 = valid */ + t_dac_mode mode +) +{ + UINT32 channelMask; + + if (channel >= maxDAC_Channels ) return; // Channel doesn't exist + + channelModes[channel] = mode; +// \MARK NEW PINSETTINGS FOR TESTER (2) +#if (PINSET_TESTER == 2) + channelMask = BIT( (UINT32)(channel) ); /* channel bit + offset */ +#else + channelMask = BIT( (UINT32)(channel + 23) ); /* channel bit + offset */ +#endif + if (mode == dacVOLTAGE) + { + DAC_CV_SET_REG = channelMask; + } + else + { + DAC_CV_CLR_REG = channelMask; + } + +} + +/** \brief Write analog value in mV or uA depending on dacMode */ +void dacWrite( + UINT8 device, /**< 0 = Self, valid */ + UINT8 channel, /**< 0..5 = valid */ + UINT16 value /*< VOLTAGE: 0..10000[mV], CURRENT: 0..20000[uA] */ +) +{ + UINT16 spiCommand; + UINT32 dacSetting; + UINT32 divideValue; + + if (device == 0) + { + + if (channel >= maxDAC_Channels ) return; // Channel doesn't exist + + channelSetting[ channel] = value; + + // Assemble DAC command + spiCommand = DAC_OUTPUT_UNBUFFERED | DAC_OUTPUT_GAIN_1x | DAC_SHDN_OPDC; + spiCommand |= ( (channel & 0x01) == 0x01 ? DAC_CHANNEL_B : DAC_CHANNEL_A); + divideValue = (channelModes[channel] == dacVOLTAGE ? DAC_MAX_VOLTAGE : DAC_MAX_CURRENT); + +// dacSetting = ((UINT32)value * DAC_MAX_SETTING) / divideValue; + + if (channelModes[channel] == dacVOLTAGE) + { + dacSetting = (UINT32)value * OutputVoltageCorrection[channel] / divideValue; + } + else + { + dacSetting = (UINT32)value * OutputCurrentCorrection[channel] / divideValue; + } + + if (dacSetting > DAC_MAX_SETTING) return; + + spiCommand |= (UINT16) dacSetting; + + /* devide channel by 2 on send the SPI command with WriteDacCommand + * channel 0-1: dac0 + * channel 2-3: dac1 + * channel 4-5: dac2 */ + WriteDacCommand( spiCommand, (channel >> 1)); + } + else + { + bpecWriteDacValue(device, channel, value); + } +} + + +UINT16 dacReadBack ( + UINT8 device, /**< 0 = Self, 1..32 = Remote device */ + UINT8 channel /**< 0..3 = valid, 8..255 = future use */ +) +{ + if (device == 0) + { + if (channel >= maxDAC_Channels ) return 0; // Channel doesn't exist) + + return channelSetting[ channel ]; + } + else + { + return bpecDacReadBack(device, channel); + } +} + + +void WriteDacCommand( UINT16 spiCommand, UINT8 dacNr ) +{ + UINT8 spiCommandArray[2]; + UINT8 spiResponse[2]; + + spiTakeBus(); + { + // dacNr 0: DAC 0 + // dacNr 1: DAC 1 + // dacNr 2: DAC 2 + // Enable correct ChipSelect + switch (dacNr) + { + case 0: + DAC1_CS_ENABLE; + break; + case 1: + DAC2_CS_ENABLE; + break; +// \MARK NEW PINSETTINGS FOR TESTER (2) +#if (PINSET_TESTER == 2) + case 2: DAC3_CS_ENABLE; + break; +#endif + } + +// if (dacNr == 0) +// { +// DAC1_CS_ENABLE; +// } else +// { +// DAC2_CS_ENABLE; +// } + + spiCommandArray[0] = (spiCommand >> 8) & 0xFF; + spiCommandArray[1] = spiCommand & 0xFF; + + spiWriteBuffer( spiCommandArray, 2); + spiReadBuffer( spiResponse, 2 ); + + // dacNr 0: DAC 0 + // dacNr 1: DAC 1 + // dacNr 2: DAC 2 + // Enable correct ChipSelect + switch (dacNr) + { + case 0: + DAC1_CS_DISABLE; + break; + case 1: + DAC2_CS_DISABLE; + break; +// \MARK NEW PINSETTINGS FOR TESTER (2) +#if (PINSET_TESTER == 2) + case 2: + DAC3_CS_DISABLE; + break; +#endif + } + +// if (dacNr == 0) +// { +// DAC1_CS_DISABLE; +// } else +// { +// DAC2_CS_DISABLE; +// } + } + spiReleaseBus(); +} + +void dacModeAll (t_dac_mode mode) +{ + dacMode(0, mode); + dacMode(1, mode); + dacMode(2, mode); + dacMode(3, mode); +// \MARK NEW PINSETTINGS FOR TESTER (2) +#if (PINSET_TESTER == 2) + dacMode(4, mode); + dacMode(5, mode); +#endif + + +} diff --git a/Tester/SW/lib/Drivers/dac.h b/Tester/SW/lib/Drivers/dac.h new file mode 100644 index 0000000..84834ef --- /dev/null +++ b/Tester/SW/lib/Drivers/dac.h @@ -0,0 +1,103 @@ +/* --------------------------------------------------------------------------- + * dac.h - v0.1 (c) 2007 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: Digital to analog signal interface. + * --------------------------------------------------------------------------- + * Version(s): 0.1, 10-09-2007, Marcel Mulder. + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef __DAC_H__ +#define __DAC_H__ +/** \file dac.h + \brief Digital to analog signal interface. +*/ + +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ +#include "lpc23xx.h" +#include "types.h" + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ +/** Maximum number of real analog channels*/ +// \MARK NEW PINSETTINGS FOR TESTER (2) +#if (PINSET_TESTER == 2) +#define maxDAC_Channels 6 +#else +#define maxDAC_Channels 4 +#endif +#define maxDAC_VOLTAGE (10000) +#define maxDAC_CURRENT (20000) + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ +typedef enum +{ + dacVOLTAGE, /**< Voltage mode 0 to 10V */ + dacCURRENT /**< Current mode 0 to 20mA */ +} t_dac_mode; + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ +/** \brief Initialize DAC.*/ +void dacInit (void); + + +void dac_MuxEn (BOOLEAN mode); + +BOOLEAN dac_MuxRB (void); + + +/** \brief Select input mode (Voltage or Current) of a certain channel. */ +void dacMode( + UINT8 channel, /**< 0..3 = valid, 8..255 = future use */ + t_dac_mode mode +); + +/** \brief Write analog value in mV or uA depending on dacMode */ +void dacWrite( + UINT8 device, /**< 0 = Self, 1..32 = Remote device */ + UINT8 channel, /**< 0..3 = valid, 8..255 = future use */ + UINT16 value /**< VOLTAGE: 0..10000[mV], CURRENT: 0..20000[uA] */ +); + +/** \brief Read analog value in mV or uA depending on dacMode + \retval value VOLTAGE: 0..10000[mV], CURRENT: 0..20000[uA] */ +UINT16 dacReadBack ( + UINT8 device, /**< 0 = Self, 1..32 = Remote device */ + UINT8 channel /**< 0..3 = valid, 8..255 = future use */ +); + +void WriteDacCommand( UINT16 spiCommand, UINT8 dacNr ); + +void dacModeAll (t_dac_mode mode); + +#endif /* __DAC_H__ */ diff --git a/Tester/SW/lib/Drivers/dio.c b/Tester/SW/lib/Drivers/dio.c new file mode 100644 index 0000000..9ce8bf0 --- /dev/null +++ b/Tester/SW/lib/Drivers/dio.c @@ -0,0 +1,716 @@ +/* --------------------------------------------------------------------------- + * dio.c - v0.1 (c) 2007 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: Digital inputs/outputs interface. + * --------------------------------------------------------------------------- + * Version(s): 0.1, 28-11-2007, fvds. + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +/* Compiler includes */ +#include +#include + +/* Hardware Includes */ +#include "LPC23xx.h" +#include "types.h" + +/* FreeRTOS includes */ +#include "FreeRTOS.h" +#include "Task.h" +#include "queue.h" +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "dio.h" +#include "dioISR.h" +#include "armVIC.h" +#include "ElecStatusCache.h" + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ +#define PORT0_BASE_ADDR FIO_BASE_ADDR +#define PORT1_BASE_ADDR (FIO_BASE_ADDR + 0x20) +#define PORT2_BASE_ADDR (FIO_BASE_ADDR + 0x40) +#define PORT3_BASE_ADDR (FIO_BASE_ADDR + 0x60) +#define PORT4_BASE_ADDR (FIO_BASE_ADDR + 0x80) + +#define DIR_OFFSET (0x00) +#define MASK_OFFSET (0x10) +#define PIN_OFFSET (0x14) +#define SET_OFFSET (0x18) +#define CLR_OFFSET (0x1C) + +// \MARK NEW PINSETTINGS FOR TESTER (2) +#if (PINSET_TESTER == 2) +#define DIO_MUX_DIR FIO3DIR +#define DIO_MUX_SET FIO3SET +#define DIO_MUX_CLR FIO3CLR + +#define DIN_MUX_BIT BIT(25) +#define DIN_MUX_SET (DIO_MUX_SET = DIN_MUX_BIT) +#define DIN_MUX_CLR (DIO_MUX_CLR = DIN_MUX_BIT) + + +#define DOUT_MUX_BIT BIT(26) +#define DOUT_MUX_SET (DIO_MUX_SET = DOUT_MUX_BIT) +#define DOUT_MUX_CLR (DIO_MUX_CLR = DOUT_MUX_BIT) +#endif + +#define DISPATCH_TASK_PRIO (tskIDLE_PRIORITY + 5) +#define DISPATCH_QUEUE_SIZE 10 + +#define Int_queue_time 3 /* In Miliseconds */ + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ + + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ +portTickType dechatterStopTime[maxDI_Channels]; /* Contains tickcount Value, where*/ + /* dechattering timeout occours */ + +UINT8 dechatterLockFlag[maxDI_Channels] = /* Channel Lock Flag */ + { + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + }; + +UINT32 dechatterTime[maxDI_Channels] = /* TimeDelay until dechatter timeout*/ + { + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10 + }; + +// \MARK NEW PINSETTINGS FOR TESTER (2) +#if (PINSET_TESTER == 2) +t_output outputPins[maxDO_Channels] = + { + { PORT4_BASE_ADDR, BIT(8) }, // DOUT0 + { PORT4_BASE_ADDR, BIT(9) }, // DOUT1 + { PORT4_BASE_ADDR, BIT(10) }, // DOUT2 + { PORT4_BASE_ADDR, BIT(11) }, // DOUT3 + { PORT4_BASE_ADDR, BIT(12) }, // DOUT4 + { PORT4_BASE_ADDR, BIT(13) }, // DOUT5 + { PORT4_BASE_ADDR, BIT(14) }, // DOUT6 + { PORT4_BASE_ADDR, BIT(15) } // DOUT7 + }; +#else +t_output outputPins[maxDO_Channels] = + { + { PORT1_BASE_ADDR, BIT(0) }, // DOUT0 + { PORT1_BASE_ADDR, BIT(1) }, // DOUT1 + { PORT1_BASE_ADDR, BIT(4) }, // DOUT2 + { PORT1_BASE_ADDR, BIT(8) }, // DOUT3 + { PORT1_BASE_ADDR, BIT(9) }, // DOUT4 + { PORT1_BASE_ADDR, BIT(10) }, // DOUT5 + { PORT1_BASE_ADDR, BIT(14) }, // DOUT6 + { PORT1_BASE_ADDR, BIT(15) } // DOUT7 + }; +#endif + +t_input inputPins[maxDI_Channels] = + { + { PORT0_BASE_ADDR, BIT(15), NULL }, // DIN0 + { PORT0_BASE_ADDR, BIT(16), NULL }, // DIN1 + { PORT0_BASE_ADDR, BIT(17), NULL }, // DIN2 + { PORT0_BASE_ADDR, BIT(18), NULL }, // DIN3 + { PORT0_BASE_ADDR, BIT(24), NULL }, // DIN4 + { PORT0_BASE_ADDR, BIT(25), NULL }, // DIN5 + { PORT0_BASE_ADDR, BIT(26), NULL }, // DIN6 + { PORT0_BASE_ADDR, BIT(27), NULL }, // DIN7 + { PORT0_BASE_ADDR, BIT(28), NULL }, // DIN8 + { PORT0_BASE_ADDR, BIT(29), NULL }, // DIN9 + { PORT0_BASE_ADDR, BIT(30), NULL } // DIN10 + }; + +BOOLEAN dioActive = FALSE; +xQueueHandle dispatchedIsrQueue= 0; + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ +static void setMaskDirRegisters(void); +static void enableChannelInterrupt(UINT8 channel); +static void disableChannelInterrupt(UINT8 channel); +static void isrDispatchTask(void *pvParameters); +static BOOLEAN hasTimeoutPast( UINT32 endTick ); +static void startDechatterInput (UINT8 ChannelNumber, t_di_mode Edge); +static void endDechatterInput (void); +static void callAllCallbacks(t_callbackListItem *pCallbackList, t_di_mode detectedEdge); + + + +void dioInit(void) +{ + SCS |= (1UL<<0); /* GPIOM in SCS to fast IO */ + + setMaskDirRegisters(); /* Init channel Registers */ + dioActive= TRUE; /* Set global dioAcitve */ + + /* Create queue and Task for ISR-displatching */ + dispatchedIsrQueue = xQueueCreate( DISPATCH_QUEUE_SIZE, sizeof(t_IsrDispatchQueueItem)); + xTaskCreate(isrDispatchTask, ( signed portCHAR * ) "dioIsrDispatcher", + configMINIMAL_STACK_SIZE, NULL, DISPATCH_TASK_PRIO, NULL); + + /* Enable GPIO interrupt */ + portENTER_CRITICAL(); + { + VICIntSelect &= ~(VIC_CHAN_TO_MASK(VIC_CHAN_NUM_EINT3)); + VICIntEnClr = VIC_CHAN_TO_MASK(VIC_CHAN_NUM_EINT3); + VICVectAddr17 = (void *)gpioISR; + VICVectCntl7 = 0x01; + VICIntEnable = VIC_CHAN_TO_MASK(VIC_CHAN_NUM_EINT3); + } + portEXIT_CRITICAL(); + +// \MARK NEW PINSETTINGS FOR TESTER (2) +#if (PINSET_TESTER == 2) + /* Init both MUX lines as Outputs */ + DIO_MUX_DIR |= (DIN_MUX_BIT | DOUT_MUX_BIT); +#endif + + +} + + +void dio_inMuxEn (BOOLEAN mode) +{ +// \MARK NEW PINSETTINGS FOR TESTER (2) +#if (PINSET_TESTER == 2) + if (mode == TRUE) + { + DIN_MUX_SET; + } + else + { + DIN_MUX_CLR; + } +#endif +} + +void dio_outMuxEn (BOOLEAN mode) +{ +// \MARK NEW PINSETTINGS FOR TESTER (2) +#if (PINSET_TESTER == 2) + if (mode == TRUE) + { + DOUT_MUX_SET; + } + else + { + DOUT_MUX_CLR; + } +#endif +} + +BOOLEAN dio_inMuxRB (void) +{ +// \MARK NEW PINSETTINGS FOR TESTER (2) +#if (PINSET_TESTER == 2) + if (DIO_MUX_SET & DIN_MUX_BIT) + { + /* MUX of digital input is switched to Extension Board */ + return (TRUE); + } + else + { + /* MUX of digital input is switched to Main Board */ + return (FALSE); + } +#endif +} + +BOOLEAN dio_outMuxRB (void) +{ +// \MARK NEW PINSETTINGS FOR TESTER (2) +#if (PINSET_TESTER == 2) + if (DIO_MUX_SET & DOUT_MUX_BIT) + { + /* MUX of digital input is switched to Extension Board */ + return (TRUE); + } + else + { + /* MUX of digital input is switched to Main Board */ + return (FALSE); + } +#endif +} + + + +RESULT dioRegisterCallback (t_dio_callbackfunc pFunc, UINT8 channel, t_di_mode mode) +{ + RESULT result = OK; + + disableChannelInterrupt(channel); + + // Create item + t_callbackListItem *newCallbackListItem = + (t_callbackListItem *) pvPortMalloc(sizeof(t_callbackListItem)); + if (newCallbackListItem == NULL) + { + result = ERROR; + } else + { + if (inputPins[channel].pCallbackList == NULL) + { + enableChannelInterrupt(channel); + } + + // Fill list item + newCallbackListItem->pCallback = pFunc; + newCallbackListItem->mode = mode; + + // Add to front of list + newCallbackListItem->next = inputPins[channel].pCallbackList; + inputPins[channel].pCallbackList = newCallbackListItem; + } + + enableChannelInterrupt(channel); + + return result; +} + +/** \brief Remove register callback function for digital input + * \retval OK Callback was removed succesfully + * \retval ERROR Failed to remove Callback-function from channel + */ +RESULT dioRemoveCallback(t_dio_callbackfunc pFunc, UINT8 channel) +{ + RESULT result = OK; + + disableChannelInterrupt(channel); + + // Check if channel has callback list + if (inputPins[channel].pCallbackList == NULL) + { + result = ERROR; + } else + { + BOOLEAN callbackFound = FALSE; + t_callbackListItem * previousItem= NULL; + t_callbackListItem * currentItem = inputPins[channel].pCallbackList; + + // Find callbackfunc + while ((!callbackFound) && (currentItem != NULL)) + { + callbackFound = (currentItem->pCallback == pFunc); + + if (!callbackFound) + { + previousItem = currentItem; + currentItem = currentItem->next; + } + } + + if (callbackFound) + { + if (previousItem == NULL) + { + // Remove first item from list + inputPins[channel].pCallbackList = currentItem->next; + } else + { + // Remove list item + previousItem->next = currentItem->next; + } + vPortFree(currentItem); // Release resources of listitem + } else + { + result = FALSE; + } + } + + if (inputPins[channel].pCallbackList != NULL) + { + enableChannelInterrupt(channel); + } + + return result; +} + +/** \brief Read digital input.*/ +BOOLEAN dioRead(UINT8 device, /**< 0 = Self, 1..32 = Remote device */ + UINT8 channel /**< 0..10 = valid, 11..255 = future use */ +) + { + BOOLEAN Result; + volatile UINT32 *gpioRegister; + + if (device == 0) + { + gpioRegister = (UINT32 *)(inputPins[channel].portBaseAddr + PIN_OFFSET); + + // device is now ignored, future implementation + + // Get result + if (*gpioRegister & inputPins[channel].pinMask) + { + Result = FALSE; + } else + { + Result = TRUE; + } + } + else + { + Result = bpecDioRead( device, channel ); + } + + return Result; + } + +/** \brief Readback digital outputs.*/ +BOOLEAN dioReadBack(UINT8 device, /**< 0 = Self, 1..32 = Remote device */ + UINT8 channel /**< 0..7 = valid, 8..255 = future use */ +) + { + BOOLEAN Result; + volatile UINT32 *gpioRegister; + + if (device == 0) + { + gpioRegister = (UINT32 *)(outputPins[channel].portBaseAddr + PIN_OFFSET); + + // device is now ignored, future implementation + + // Get result + // NOTE: Input signal is inverted + if (*gpioRegister & outputPins[channel].pinMask) + { + Result = TRUE; + } else + { + Result = FALSE; + } + } + else + { + Result = bpecDioReadBack( device, channel ); + } + + return Result; + } + +/** \brief Write digital outputs.*/ +void dioWrite(UINT8 device, /**< 0 = Self, 1..32 = Remote device */ +UINT8 channel, /**< 0..7 = valid, 8..255 = future use */ +BOOLEAN data) +{ + volatile UINT32 *gpioRegister; + + if (device == 0) + { + if (data == TRUE) + { + gpioRegister = (UINT32 *)(outputPins[channel].portBaseAddr + + SET_OFFSET); + *gpioRegister = outputPins[channel].pinMask; + } + else + { + gpioRegister = (UINT32 *)(outputPins[channel].portBaseAddr + + CLR_OFFSET); + *gpioRegister = outputPins[channel].pinMask; + } + } else + { + bpecWriteDioValue(device, channel, data); + } +} + +void setMaskDirRegisters() +{ + int i; + volatile UINT32 *gpioRegister; + + for (i=0; i< maxDO_Channels; i++) + { + // Clear bit in mask Register + gpioRegister = (UINT32 *)(outputPins[i].portBaseAddr + MASK_OFFSET); + *gpioRegister &= ~(outputPins[i].pinMask); + + // Set direction bit to output + gpioRegister = (UINT32 *)(outputPins[i].portBaseAddr + DIR_OFFSET); + *gpioRegister |= outputPins[i].pinMask; + } + + for (i=0; i< maxDI_Channels; i++) + { + // Clear bit in maskRegister + gpioRegister = (UINT32 *)(inputPins[i].portBaseAddr + MASK_OFFSET); + *gpioRegister &= ~(inputPins[i].pinMask); + + // Set direction bit to input + gpioRegister = (UINT32 *)(inputPins[i].portBaseAddr + DIR_OFFSET); + *gpioRegister &= ~(inputPins[i].pinMask); + + // Reset callback functions + inputPins[i].pCallbackList = NULL; + } +} + +void enableChannelInterrupt(UINT8 channel) +{ + if (inputPins[channel].portBaseAddr == PORT0_BASE_ADDR) + { + IO0_INT_CLR = inputPins[channel].pinMask; + IO0_INT_EN_R |= inputPins[channel].pinMask; + IO0_INT_EN_F |= inputPins[channel].pinMask; + } + else + { + IO2_INT_CLR = inputPins[channel].pinMask; + IO2_INT_EN_R |= inputPins[channel].pinMask; + IO2_INT_EN_F |= inputPins[channel].pinMask; + } +} + +void disableChannelInterrupt(UINT8 channel) +{ + if (inputPins[channel].portBaseAddr == PORT0_BASE_ADDR) + { + IO0_INT_EN_R &= ~BIT(inputPins[channel].pinMask); + IO0_INT_EN_F &= ~BIT(inputPins[channel].pinMask); + } + else + { + IO2_INT_EN_R &= ~BIT(inputPins[channel].pinMask); + IO2_INT_EN_F &= ~BIT(inputPins[channel].pinMask); + } +} + +void isrDispatchTask(void *pvParameters) +{ + t_IsrDispatchQueueItem dispatchItem; + UINT32 channelcnt; + + do /* As long as active */ + { + /* If an Input Interrupt occures, enter if Statement */ + if (xQueueReceive(dispatchedIsrQueue, &dispatchItem, Int_queue_time)) + { + /* Check for each single Channel, which one is active */ + for (channelcnt=0; channelcnt < maxDI_Channels; channelcnt++) + { + /* Go further if CallBack exists for corresponding Channel */ + if (inputPins[channelcnt].pCallbackList != NULL) + { + /* Check if this bit is active */ + int portIndex = (inputPins[channelcnt].portBaseAddr + == PORT0_BASE_ADDR ? 0 : 1); + + /* Check if Interrupt occured from a RISING EDGE */ + if (dispatchItem.riseInterrupts[ portIndex ] + & inputPins[channelcnt].pinMask) + { /* Rising Edge Interrupt detected */ + if (dechatterTime[channelcnt] == 0) + { /* If dechatterTime is set to ZERO */ + /* call Callback directly */ + callAllCallbacks( + inputPins[channelcnt].pCallbackList, + RISING_EDGE); + } + else /* If there is a dechattering Time */ + { /* Start dechattering the Input */ + startDechatterInput(channelcnt, RISING_EDGE); + } + } + + /* Check if Interrupt occured from a FALLING EDGE */ + if (dispatchItem.fallInterrupts[ portIndex ] + & inputPins[channelcnt].pinMask) + { /* Falling Edge Interrupt detected */ + if (dechatterTime[channelcnt] == 0) + { /* If dechatterTime is set to ZERO */ + /* call Callback directly */ + callAllCallbacks( + inputPins[channelcnt].pCallbackList, + FALLING_EDGE); + } + else /* if there is a dechattering Time */ + { /* Start dechattering the Input */ + startDechatterInput(channelcnt, FALLING_EDGE); + } + } + } /* EndIf CallBack exists Check */ + } /* End of FOR Loop */ + } /* End Check for occuring Interrupt */ + + + endDechatterInput(); /* Call dechatter monitor Function */ + + } while (dioActive == TRUE); +} + + +void startDechatterInput(UINT8 ChannelNumber, t_di_mode Edge) +{ + + /* If corresponding Channel is currently not monitored */ + if (dechatterLockFlag[ChannelNumber] == 0) + { + /* Set dechatter Timer */ + dechatterStopTime[ChannelNumber] = xTaskGetTickCount() + + dechatterTime[ChannelNumber]; + /* Handle type of detected Edge in channel Lock Flag */ + switch (Edge) + { + case RISING_EDGE: + dechatterLockFlag[ChannelNumber] = 1; + break; + case FALLING_EDGE: + dechatterLockFlag[ChannelNumber] = 2; + break; +// case BOTH_EDGES: + default: + break; + } + } + + /* If come here, an already monitored Channel causes a new Interrupt + * (which means, within the Timer a new Edge occured) + * This is a chatter! + * Reload the Timer! + */ + else + { + dechatterStopTime[ChannelNumber] = xTaskGetTickCount() + + dechatterTime[ChannelNumber]; + } + +} +void endDechatterInput(void) +{ + UINT32 channelcnt; + + /* Check every single Channel */ + for (channelcnt = 0; channelcnt < maxDI_Channels; channelcnt++) + { + /* If Timeout for corresponding channel occured */ + if (hasTimeoutPast( dechatterStopTime[channelcnt]) ) + { + /* Switch corresponding to the former detected Edge */ + switch (dechatterLockFlag[channelcnt]) + { + case 1: /* a Rising Edge was dechattered */ + /* Is Input still High? If Yes, channel is dechattered */ + if (dioRead(0, channelcnt) == TRUE) + { /* Call Callback Functions */ + callAllCallbacks(inputPins[channelcnt].pCallbackList, + RISING_EDGE); + } + dechatterLockFlag[channelcnt] = 0; /* release Lock Flag */ + break; + + case 2: /* a Falling Edge was dechattered */ + /* Is Input still Low? If Yes, channel is dechattered */ + if (dioRead(0, channelcnt) == FALSE) + { /* Call Callback Functions */ + callAllCallbacks(inputPins[channelcnt].pCallbackList, + FALLING_EDGE); + } + dechatterLockFlag[channelcnt] = 0; + break; + } + } + } +} + +void callAllCallbacks(t_callbackListItem *pCallbackList, t_di_mode detectedEdge) +{ + while (pCallbackList != NULL) + { + if ( (pCallbackList->mode == detectedEdge) || (pCallbackList->mode + == BOTH_EDGES)) + { + // Call the callback + pCallbackList->pCallback(); + } + + // Check next item + pCallbackList = pCallbackList->next; + } +} + +void dioSetDechatterTime(UINT8 channel, UINT32 time) +{ + dechatterTime[channel] = time; +} + + +BOOLEAN hasTimeoutPast( UINT32 endTick ) +{ + UINT32 nowTick = xTaskGetTickCount(); + + if (nowTick >= endTick) + { + if ((nowTick - endTick) > 0x0000FFFF) + { + // the endTick has gone through 0 point, nowTick is at end of range + return FALSE; + } + else + { + // nowTick passed endTick. + return TRUE; + } + } + else + { + if ((endTick - nowTick) > 0x0000FFFF) + { + + // the endTick was at end of range, nowTick has gone through 0 point + return TRUE; + } + else + { + // nowTick still has to pass endTick + return FALSE; + } + } +} diff --git a/Tester/SW/lib/Drivers/dio.h b/Tester/SW/lib/Drivers/dio.h new file mode 100644 index 0000000..1e3a010 --- /dev/null +++ b/Tester/SW/lib/Drivers/dio.h @@ -0,0 +1,136 @@ +/* --------------------------------------------------------------------------- + * dio.h - v0.1 (c) 2007 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: Digital inputs/outputs interface. + * --------------------------------------------------------------------------- + * Version(s): 0.1, 10-09-2007, Marcel Mulder. + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef __DIO_H__ +#define __DIO_H__ +/** \file dio.h + \brief Digital inputs/outputs interface. +*/ +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ +#include "lpc23xx.h" +#include "types.h" + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ +/** Maximum number of digital inputs*/ +//const UINT8 maxDI_Channels = 11; +#define maxDI_Channels (11) +/** Maximum number of digital outputs*/ +//const UINT8 maxDO_Channels = 8; +#define maxDO_Channels (8) + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ +typedef void (*t_dio_callbackfunc)(void); + +typedef enum +{ + RISING_EDGE, /**< Generates interrupt on rising edge*/ + FALLING_EDGE, /**< Generates interrupt on falling edge*/ + BOTH_EDGES /**< Generates interrupt on both edges*/ +} t_di_mode; + +typedef struct t_OUTPUT { + UINT32 portBaseAddr; + UINT32 pinMask; +} t_output; + +typedef struct t_CALLBACKLISTITEM { + t_dio_callbackfunc pCallback; + t_di_mode mode; + struct t_CALLBACKLISTITEM *next; +} t_callbackListItem; + +typedef struct t_INPUT { + UINT32 portBaseAddr; + UINT32 pinMask; + t_callbackListItem *pCallbackList; +} t_input; + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ +/** \brief Initialize DIO.*/ +void dioInit (void); + +void dio_inMuxEn (BOOLEAN mode); + +void dio_outMuxEn (BOOLEAN mode); + +BOOLEAN dio_inMuxRB (void); + +BOOLEAN dio_outMuxRB (void); + + +/** \brief Register callback function digital input events defined in mode + (rising, falling edge or both) */ +RESULT dioRegisterCallback( + t_dio_callbackfunc pFunc, /**< Function pointer to callback function */ + UINT8 channel, /**< 0..10 = valid, 11..255 = future use */ + t_di_mode mode +); + +/** \brief Remove register callback function for digital input*/ +RESULT dioRemoveCallback( + t_dio_callbackfunc pFunc, + UINT8 channel +); + +/** \brief Read digital input.*/ +BOOLEAN dioRead ( + UINT8 device, /**< 0 = Self, 1..32 = Remote device */ + UINT8 channel /**< 0..10 = valid, 11..255 = future use */ +); + +/** \brief Readback digital outputs.*/ +BOOLEAN dioReadBack ( + UINT8 device, /**< 0 = Self, 1..32 = Remote device */ + UINT8 channel /**< 0..7 = valid, 8..255 = future use */ +); + +/** \brief Write digital outputs.*/ +void dioWrite ( + UINT8 device, /**< 0 = Self, 1..32 = Remote device */ + UINT8 channel, /**< 0..7 = valid, 8..255 = future use */ + BOOLEAN data +); + +void dioSetDechatterTime( + UINT8 channel, + UINT32 time +); + +#endif /* __DIO_H__ */ diff --git a/Tester/SW/lib/Drivers/dioISR.c b/Tester/SW/lib/Drivers/dioISR.c new file mode 100644 index 0000000..5c1d623 --- /dev/null +++ b/Tester/SW/lib/Drivers/dioISR.c @@ -0,0 +1,102 @@ +/* --------------------------------------------------------------------------- + * dio.c - v0.1 (c) 2007 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: Digital inputs/outputs interface. + * --------------------------------------------------------------------------- + * Version(s): 0.1, 28-11-2007, fvds. + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +#include +#include + + +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "LPC23xx.h" +#include "types.h" +#include "dio.h" +#include "dioISR.h" +#include "armVIC.h" + +/* FreeRTOS includes */ +#include "FreeRTOS.h" +#include "Task.h" +#include "queue.h" + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ +extern xQueueHandle dispatchedIsrQueue; +t_IsrDispatchQueueItem dispatchItem; + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ +volatile UINT32 receivedInts = 0; + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ +static void GpioHandler( void ); + + +void gpioISR() +{ + /* Save the context of the interrupted task. */ + portSAVE_CONTEXT(); + { + /* Call the handler to do the work. This must be a separate function to + the wrapper to ensure the correct stack frame is set up. */ + GpioHandler(); + } + /* Restore the context of whichever task is going to run once the interrupt + completes. */ + portRESTORE_CONTEXT(); +} + + +void GpioHandler( void ) +{ + receivedInts++; + + // Check flags + // -=NOTE=- Because input signal is inverted; the rising and + // falling signal are switched. + dispatchItem.riseInterrupts[0] = IO0_INT_STAT_F; + dispatchItem.fallInterrupts[0] = IO0_INT_STAT_R; + dispatchItem.riseInterrupts[1] = IO2_INT_STAT_R; + dispatchItem.fallInterrupts[1] = IO2_INT_STAT_F; + + xQueueSendToBackFromISR( dispatchedIsrQueue, &dispatchItem, pdFALSE ); + + IO0_INT_CLR = 0xFFFFFFFF; + IO2_INT_CLR = 0xFFFFFFFF; + + VICVectAddr = 0x00000000; // clear this interrupt from the VIC +} + diff --git a/Tester/SW/lib/Drivers/dioISR.h b/Tester/SW/lib/Drivers/dioISR.h new file mode 100644 index 0000000..1090916 --- /dev/null +++ b/Tester/SW/lib/Drivers/dioISR.h @@ -0,0 +1,61 @@ +/* --------------------------------------------------------------------------- + * dio.h - v0.1 (c) 2007 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: Digital inputs/outputs interface. + * --------------------------------------------------------------------------- + * Version(s): 0.1, 10-09-2007, Marcel Mulder. + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef __DIOISR_H__ +#define __DIOISR_H__ +/** \file dio.h + \brief Digital inputs/outputs interface. +*/ +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ +#include "lpc23xx.h" +#include "types.h" + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ +typedef struct t_ISRDISPATCHQUEUEITEM { + UINT32 riseInterrupts[2]; + UINT32 fallInterrupts[2]; +} t_IsrDispatchQueueItem; + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ +void gpioISR(void) __attribute__ ((naked)); + +#endif /* __DIOISR_H__ */ diff --git a/Tester/SW/lib/Drivers/eeprom.c b/Tester/SW/lib/Drivers/eeprom.c new file mode 100644 index 0000000..0581a88 --- /dev/null +++ b/Tester/SW/lib/Drivers/eeprom.c @@ -0,0 +1,385 @@ +/* --------------------------------------------------------------------------- + * eeporm.c - v0.1 (c) 2007 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: EEPROM-driver + * --------------------------------------------------------------------------- + * Version(s): 0.1, 28-11-2007, fvds. + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "LPC23xx.h" +#include "types.h" +#include "sys_config.h" +#include "ssp1.h" +#include "eeprom.h" +#include "armVIC.h" + +/* FreeRTOS includes */ +#include "FreeRTOS.h" +#include "task.h" + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ +#define EEPROM_CS_DIR_REG FIO0DIR +#define EEPROM_CS_SET_REG FIO0SET +#define EEPROM_CS_CLR_REG FIO0CLR +#define EEPROM_CS_BIT BIT( 6 ) +#define EEPROM_CS_DISABLE (EEPROM_CS_SET_REG = EEPROM_CS_BIT) +#define EEPROM_CS_ENABLE (EEPROM_CS_CLR_REG = EEPROM_CS_BIT) +#define EEPROM_PAGE_SIZE (128) + +#define SPICMD_WRITE_STATUS 0x01 +#define SPICMD_WRITE 0x02 +#define SPICMD_READ 0x03 +#define SPICMD_WRITE_DISABLE 0x04 +#define SPICMD_READ_STATUS 0x05 +#define SPICMD_WRITE_ENABLE 0x06 + +#define SPICMD_STATUS_WIP 0x01 +#define SPICMD_STATUS_WEL 0x02 +#define SPICMD_STATUS_BP0 0x04 +#define SPICMD_STATUS_BP1 0x08 +#define SPICMD_STATUS_WPEN 0x80 + +#define spiWrite ssp1Write +#define spiRead ssp1Read +#define spiWriteBuffer ssp1WriteBuffer +#define spiReadBuffer ssp1ReadBuffer +#define spiTakeBus ssp1TakeBus +#define spiReleaseBus ssp1ReleaseBus + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ +//extern UINT16 adres_var[]; +UINT16 adres_var[MAX_VARSINEEPROM]; // t.b.v. aantal variabelen in EEPROM JHi 12-03-2008 + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ +static void DisableWriteProtection(void); +static void WaitForEndOfWrite(void); +static void WaitForEndOfWrite(void); +static void WriteDataByte(UINT16 address, UINT8 dataOut); +static void WriteDataArray(UINT16 address, UINT8 *buffer, UINT16 size); +static void ReadDataByte(UINT16 address, UINT8 *dataOut); +static void ReadDataArray(UINT16 address, UINT8 *buffer, UINT16 size); +static void WriteEnable(void); +static UINT8 GetStatus(void); + + +void eepromInit() +{ + // Setup ChipSelect line + SCS |= (1UL<<0); // set GPIOM in SCS for fast IO + EEPROM_CS_DIR_REG |= EEPROM_CS_BIT; + EEPROM_CS_DISABLE; +} + +RESULT eepromRead(UINT16 address, UINT8 *byte) +{ + WaitForEndOfWrite(); + + ReadDataByte(address, byte); + + return OK; +} + +RESULT eepromWrite(UINT16 address, UINT8 byte) +{ + WaitForEndOfWrite(); + + WriteEnable(); + + //EEPROM_DELAY; + + WriteDataByte( address, byte ); + + //EEPROM_WRITE_DELAY; + //EEPROM_Status |= C25LCXX_STATUS_WIP; // indicate we started a write action + + return OK; + +} + +RESULT eepromWriteBuffer(UINT16 address, UINT8 *buffer, UINT16 bufferSize) +{ + // Split up in page boundaries, if necessary + while (bufferSize > 0) + { + UINT16 length; + UINT16 endAddress; + + // Calculate length + if (bufferSize >= EEPROM_PAGE_SIZE) + { + endAddress = address + EEPROM_PAGE_SIZE; + } + else + { + endAddress = address + bufferSize; + } + + // Check if buffer overflows a page + if (((endAddress - 1) / EEPROM_PAGE_SIZE) == (address / EEPROM_PAGE_SIZE)) + { + // buffer doesn't exceed page + length = endAddress - address; + } + else + { + // buffer exceeds page + length = endAddress - (endAddress % EEPROM_PAGE_SIZE) - address; + } + + WaitForEndOfWrite(); + WriteEnable(); + WriteDataArray( address, buffer, length ); + + bufferSize = bufferSize - length; + address = address + length; + buffer = buffer + length; + } + + return OK; +} + +RESULT eepromReadBuffer(UINT16 address, UINT8 *buffer, UINT16 bufferSize) +{ + WaitForEndOfWrite(); + + while (bufferSize > 0) + { + int length = EEPROM_PAGE_SIZE; + if (bufferSize < EEPROM_PAGE_SIZE) + { + length = bufferSize; + } + + ReadDataArray( address, buffer, length ); + + bufferSize -= length; + address = address + length; + buffer = buffer + length; + + if (bufferSize > 0) vTaskDelay(3); + } + + return OK; +} + +RESULT eepromWriteVar(int variableId, void *parameter ) +{ + UINT16 address = adres_var[variableId]; + UINT16 length = adres_var[variableId + 1] - address; + + return eepromWriteBuffer( address, parameter, length ); +} + + +RESULT eepromReadVar(int variableId, void *parameter ) +{ + UINT16 address = adres_var[variableId]; + UINT16 length = adres_var[variableId + 1] - address; + + return eepromReadBuffer( address, parameter, length ); +} + +void DisableWriteProtection() +{ + WriteEnable(); +} + +UINT8 +GetStatus() +{ + UINT8 spiCommand[2]; + static UINT8 status; + + spiCommand[0] = SPICMD_READ_STATUS; + spiCommand[1] = 0x00; + + spiTakeBus(); + { + EEPROM_CS_ENABLE; + + spiWriteBuffer( spiCommand, 2 ); + spiReadBuffer( spiCommand, 2 ); + + EEPROM_CS_DISABLE; + } + spiReleaseBus(); + + status = spiCommand[1]; + + return spiCommand[1]; // lsb of word +} + +void WaitForEndOfWrite(void) +{ + UINT8 eepromStatus = GetStatus(); + + while ((eepromStatus & SPICMD_STATUS_WIP) != 0x00) + { + eepromStatus = GetStatus(); + } +} + +void WriteEnable() +{ + UINT8 spiCommand[1]; + + spiCommand[0] = SPICMD_WRITE_ENABLE; + + spiTakeBus(); + { + EEPROM_CS_ENABLE; + + spiWriteBuffer( spiCommand, 1 ); + spiReadBuffer( spiCommand, 1 ); + + EEPROM_CS_DISABLE; + } + spiReleaseBus(); +} + + +void WriteDataByte(UINT16 address, UINT8 dataOut) +{ + UINT8 spiCommand[4]; + UINT8 spiResponse[4]; + + spiCommand[0] = SPICMD_WRITE; + spiCommand[1] = ((address >> 8) & 0xFF); + spiCommand[2] = address & 0xFF; + spiCommand[3] = dataOut; + + spiTakeBus(); + { + EEPROM_CS_ENABLE; + + spiWriteBuffer( spiCommand, 4 ); + spiReadBuffer( spiResponse, 4 ); + + EEPROM_CS_DISABLE; + } + spiReleaseBus(); + +} + +void ReadDataByte(UINT16 address, UINT8 *byte) +{ + UINT8 spiCommand[4]; + UINT8 spiResponse[4]; + + spiCommand[0] = SPICMD_READ; + spiCommand[1] = ((address >> 8) & 0x00FF); + spiCommand[2] = (address & 0x00FF); + spiCommand[3] = 0x00; + + spiTakeBus(); + { + EEPROM_CS_ENABLE; + + spiWriteBuffer( spiCommand, 4 ); + spiReadBuffer( spiResponse, 4 ); + + EEPROM_CS_DISABLE; + } + spiReleaseBus(); + + *byte = (UINT8)spiResponse[3]; +} + +void WriteDataArray(UINT16 address, UINT8 *buffer, UINT16 size) +{ + UINT8 spiCommand[3]; + UINT8 spiResponse[3]; + UINT8 dummyResponse; + UINT16 index; + + spiTakeBus(); + { + EEPROM_CS_ENABLE; + + spiCommand[0] = SPICMD_WRITE; + spiCommand[1] = ((address >> 8) & 0xFF); + spiCommand[2] = address & 0xFF; + + // Write command + address + spiWriteBuffer( spiCommand, 3 ); + spiWriteBuffer( buffer, size ); + spiReadBuffer( spiResponse, 3 ); + for (index = 0; index < size; index++) + { + spiRead( &dummyResponse ); + } + + + EEPROM_CS_DISABLE; + } + spiReleaseBus(); +} + +void ReadDataArray(UINT16 address, UINT8 *buffer, UINT16 size) +{ + UINT8 spiCommand[3]; + UINT8 spiResponse[3]; + UINT16 index; + + spiCommand[0] = SPICMD_READ; + spiCommand[1] = ((address >> 8) & 0x00FF); + spiCommand[2] = (address & 0x00FF); + + // Fill buffer with zero's + for (index = 0; index < size; index++) + { + buffer[index] = 0x00; + } + + spiTakeBus(); + { + EEPROM_CS_ENABLE; + + spiWriteBuffer( spiCommand, 3 ); + spiWriteBuffer( buffer, size ); + spiReadBuffer( spiResponse, 3 ); + + for (index = 0; index < size; index++) + { + spiRead( buffer ); + buffer++; + } + + EEPROM_CS_DISABLE; + } + spiReleaseBus(); +} diff --git a/Tester/SW/lib/Drivers/eeprom.h b/Tester/SW/lib/Drivers/eeprom.h new file mode 100644 index 0000000..2e34a91 --- /dev/null +++ b/Tester/SW/lib/Drivers/eeprom.h @@ -0,0 +1,67 @@ +/* --------------------------------------------------------------------------- + * eeprom.h - v0.1 (c) 2007 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: EEPROM interface + * --------------------------------------------------------------------------- + * Version(s): 0.1, 10-09-2007, Marcel Mulder. + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef __EEPROM_H__ +#define __EEPROM_H__ +/** \file eeprom.h + \brief EEPROM interface (tested on m95512) +*/ +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ +#include "lpc23xx.h" +#include "types.h" + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ +#define eepromSIZE (2^16) // 64 kBytes = 512 kBit = 2^16 +#define MAX_VARSINEEPROM 300 // Let op max. aantal vaiabelen in eeprom + // JHi 12-03-2008 + + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ +void eepromInit( void ); +RESULT eepromWrite( UINT16 address, UINT8 byte ); +RESULT eepromRead( UINT16 address, UINT8 *byte ); +RESULT eepromWriteBuffer( UINT16 address, UINT8 *buffer, UINT16 bufferSize ); +RESULT eepromReadBuffer( UINT16 address, UINT8 *buffer, UINT16 bufferSize ); +RESULT eepromWriteVar(int variableId, void *parameter ); +RESULT eepromReadVar(int variableId, void *parameter ); + +#endif /* __EEPROM_H__ */ diff --git a/Tester/SW/lib/Drivers/ethernet/LPC23xx_enet.c b/Tester/SW/lib/Drivers/ethernet/LPC23xx_enet.c new file mode 100644 index 0000000..3713e0e --- /dev/null +++ b/Tester/SW/lib/Drivers/ethernet/LPC23xx_enet.c @@ -0,0 +1,460 @@ +/************************************************************************* + * + * Used with ICCARM and AARM. + * + * (c) Copyright IAR Systems 2006 + * + * File name : LPC23xx_enet.c + * Description : MAC/DMA Controller with DMA (ENET) driver + * + * History : + * 1. Date : December 14, 2006 + * Author : Stanimir Bonev + * Description : Create + * + * $Revision: 1.1.2.3 $ + **************************************************************************/ + +#define __no_init /* Dummy for __no_init */ + +#include "LPC23xx.h" +#include "types.h" +#include "LPC23xx_enet.h" + +//#pragma segment="EMAC_DMA_RAM" + +//#pragma location="EMAC_DMA_RAM" +//#pragma data_alignment=4 +__no_init EnetDmaRxDesc_t EnetDmaRx[ENET_DMA_DESC_NUMB]__attribute__ ((section (".ethram"))) __attribute__((aligned (4))); +//#pragma location="EMAC_DMA_RAM" +//#pragma data_alignment=8 +__no_init EnetDmaRxStatus_t EnetDmaRxSta[ENET_DMA_DESC_NUMB]__attribute__ ((section (".ethram"))) __attribute__((aligned (8))); +//#pragma location="EMAC_DMA_RAM" +//#pragma data_alignment=4 +__no_init Int8U RxBuff0[EMAC_MAX_PACKET_SIZE]__attribute__ ((section (".ethram"))) __attribute__((aligned (4))); +//#pragma location="EMAC_DMA_RAM" +//#pragma data_alignment=4 +__no_init Int8U RxBuff1[EMAC_MAX_PACKET_SIZE]__attribute__ ((section (".ethram"))) __attribute__((aligned (4))); + + +//#pragma location="EMAC_DMA_RAM" +//#pragma data_alignment=4 +__no_init EnetDmaTxDesc_t EnetDmaTx[ENET_DMA_DESC_NUMB]__attribute__ ((section (".ethram"))) __attribute__((aligned (4))); +//#pragma location="EMAC_DMA_RAM" +//#pragma data_alignment=4 +__no_init EnetDmaTxStatus_t EnetDmaTxSta[ENET_DMA_DESC_NUMB]__attribute__ ((section (".ethram"))) __attribute__((aligned (4))); +//#pragma location="EMAC_DMA_RAM" +//#pragma data_alignment=4 +__no_init Int8U TxBuff0[EMAC_MAX_PACKET_SIZE]__attribute__ ((section (".ethram"))) __attribute__((aligned (4))); +//#pragma location="EMAC_DMA_RAM" +//#pragma data_alignment=4 +__no_init Int8U TxBuff1[EMAC_MAX_PACKET_SIZE]__attribute__ ((section (".ethram"))) __attribute__((aligned (4))); + +static Int8U PhyAddr; + +/************************************************************************* + * Function Name: + * Parameters: None + * + * Return: Boolean + * + * Description: Init MAC/DMA Controller + * + *************************************************************************/ +Boolean tapdev_init(void) +{ +Int32U Reg,to,i; + + // Pins assignment + PINMODE2 = 0xA02A220A; // P1[0,1,4,6,8,9,10,14,15] disable pu/pd + PINMODE3 = 0x0000000A; // P1[17:16] disable pu/pd + PINSEL2 = 0x50151105; // selects P1[0,1,4,6,8,9,10,14,15] + PINSEL3 = 0x00000005; // selects P1[17:16] + // clk enable +// PCONP_bit.PCENET = 1; + PCONP |= (1 << 30); /* Set Bit 30 (eth) in PCONP */ +// POWERDOWN_bit.POWERDOWN = 0; + MAC_POWERDOWN &=~(1 << 31); /* Clear Bit 31(powerdown) */ + // Reset entire MAC + MAC_MAC1 = 0x0000CF00; /* Reset entire MAC */ + MAC_COMMAND = 0x0038; /* Reset all control registers */ + MAC_MAC1 = 0; /* Clear entire MAC */ +// COMMAND_bit.RMII = 1; + MAC_COMMAND |= (1 << 9); /* Set Bit 9 (RMII) in CMD */ + MAC_SUPP = 0; /* Clear PHY support register */ + MAC_TEST = 0; /* Clear test register */ + + // write the station address registers + MAC_SA0 = (UIP_ETHADDR1<<8) | UIP_ETHADDR0; + MAC_SA1 = (UIP_ETHADDR3<<8) | UIP_ETHADDR2; + MAC_SA2 = (UIP_ETHADDR5<<8) | UIP_ETHADDR4; + + MAC_MAXF = 0x600; /* Set maximum Frame */ + MAC_MCFG = 0x8018; /* clk/20 */ + MAC_MCMD = 0; /* Clear MCommand register */ + + // MIIM init +// MCFG_bit.RSTMIIMGMT = 0; + MAC_MCFG &=~(1 << 15); /* Clear RSTMIIMGMT Bit */ + + // descriptors init +// MAC1_bit.RSTMCSTX = 1; + MAC_MAC1 |= (1 << 9); /* Set Bit 9 (RSTMCSTX) in MAC1 */ +// COMMAND_bit.TXENABLE = 0; + MAC_COMMAND &=~(1 << 1); /* Clear Bit 1 (TXENABLE) */ +// MAC1_bit.RSTTX = 1; + MAC_MAC1 |= (1 << 8); /* Set Bit 8 (RSTTX) in MAC1 */ +// COMMAND_bit.TXRESET = 1; + MAC_COMMAND |= (1 << 4); /* Set Bit 4 (TXRESET) in MCMD */ +// MAC1_bit.RSTMCSTX = 0; + MAC_MAC1 &=~(1 << 9); /* Clear Bit 9 (RSTMCSTX) */ +// MAC1_bit.RSTTX = 0; + MAC_MAC1 &=~(1 << 8); /* Clear Bit 8 (RSTTX) in MAC1 */ + +// MAC1_bit.RE = 0; + MAC_MAC1 &=~(1 << 0); /* Clear Bit 0 (RE) in MAC1 */ +// MAC1_bit.RSTMCSRX = 1; + MAC_MAC1 |= (1 << 11); /* Set Bit 11 (RSTMCSRX) in MAC1*/ +// COMMAND_bit.RXENABLE = 0; + MAC_COMMAND &=~(1 << 0); /* Clear Bit 0 (RXENABLE) */ +// MAC1_bit.RSTRX = 1; + MAC_MAC1 |= (1 << 10); /* Set Bit 10 (RSTRX) in MAC1 */ +// COMMAND_bit.RXRESET = 1; + MAC_COMMAND |= (1 << 5); /* Set Bit 5 (RXRESET) in MCMD */ +// MAC1_bit.RSTMCSRX = 0; + MAC_MAC1 &=~(1 << 11); /* Clear Bit 11 (RSTMCSRX) */ +// MAC1_bit.RSTRX = 0; + MAC_MAC1 &=~(1 << 10); /* Clear Bit 10 (RSTRX) */ + + MAC_RXDESCRIPTORNUM = ENET_DMA_DESC_NUMB-1; + MAC_TXDESCRIPTORNUM = ENET_DMA_DESC_NUMB-1; +// COMMAND_bit.PASSRUNTFRAME = 1; + MAC_COMMAND |= (1 << 6); /* Set Bit 6 (PASSRUNTFRAME) */ +// COMMAND_bit.PASSRXFILTER = 1; + MAC_COMMAND |= (1 << 7); /* Set Bit 7 (PASSRXFILTER) */ +// MAC1_bit.PARF = 1; + MAC_MAC1 |= (1 << 1); /* Set bit 1 (PARF) in MAC1 */ + MAC_MAC2 = 0x30; /* Set CRCEN & PADCRCEN in MAC2 */ + +// CLRT_bit.RM = 0xF; +// CLRT_bit.CW = 0x37; + MAC_CLRT = 0x0000370F; /* Set RM (0xF) and CW (0x3700) */ + +// IPGR_bit.IPGR2 = 0x12; +// IPGR_bit.IPGR1 = 0x0c; + MAC_IPGR = 0x00000C12; /*Set IPGR2(0x12) & IPGR1(0xC00)*/ + + MAC_IPGT = 0x12; /* Set IPGT register */ +// MAC2_bit.FD = COMMAND_bit.FULLDUPLEX = 0; + MAC_MAC2 &=~(1 << 0); /* Clear Bit 0 (FD) in MAC2 */ + MAC_COMMAND &=~(1 << 10); /* Clear Bit 10 (FULLDUPLEX) */ +// SUPP_bit.SPEED = 0; + MAC_SUPP &=~(1 << 8); /* Clear Bit 8 (SPEED) in SUPP */ + + + /* find PHY address */ + for(PhyAddr = 1; PhyAddr < 32; ++PhyAddr) + { + /* See Micrel PHY KS8721 Users Manual for more details */ + if((ENET_MIIReadRegister(PhyAddr, PHY_PHYIDR1) & 0xFFFF) != 0x0022) + { + continue; + } + + if ((ENET_MIIReadRegister(PhyAddr, PHY_PHYIDR2) & 0xFFFF) == 0x1619) + { + break; + } + } + + if(PhyAddr == 32) + { + return(FALSE); + } + + printf("PHY Address - %d\r\n",PhyAddr); + + ENET_MIIWriteRegister(PhyAddr,PHY_BMCR,BMCR_RESET); + + to = PHY_TO; + + while(to) + { + Reg = ENET_MIIReadRegister(PhyAddr,PHY_BMCR); + + if(!(Reg & BMCR_RESET)) + { + break; + } + } + + if(!to) + { + return(FALSE); + } + +#ifdef TRACE_PHY + Reg = ENET_MIIReadRegister(PhyAddr,0); + printf("PHY_BMCR(0) - 0x%04X\n\r",Reg); + Reg = ENET_MIIReadRegister(PhyAddr,1); + printf("PHY_BMSR(1) - 0x%04X\n\r",Reg); + Reg = ENET_MIIReadRegister(PhyAddr,0x4); + printf("PHY_ANAR(4) - 0x%04X\n\r",Reg); + Reg = ENET_MIIReadRegister(PhyAddr,0x5); + printf("PHY_ANLPAR(5) - 0x%04X\n\r",Reg); + Reg = ENET_MIIReadRegister(PhyAddr,0x6); + printf("PHY_ANER(6) - 0x%04X\n\r",Reg); + Reg = ENET_MIIReadRegister(PhyAddr,0x1f); + printf("PHY_100PHY(1F) - 0x%04X\n\r",Reg); +#endif // TRACE_PHY + + if(ENET_MIIReadRegister(PhyAddr,PHY_BMSR ) & BMSR_NOPREAM) + { + // PHY support preamble suppression + MAC_MCFG |= 1 << 1; + } + +#if AUTO_NEGOTIATION_ENA != 0 + // PHY interrupt init, clear and enable + // Set Auto-Negotiation Advertisement + ENET_MIIWriteRegister(PhyAddr,PHY_ANAR, 1 | ANAR_10BT | ANAR_10BT_FULL | ANAR_100BT | ANAR_100BT_FULL); + // Enable Auto-Negotiation + Reg = BMCR_AN | BMCR_RE_AN; +#else + + Reg = 0; + + if(FIX_DUPLEX == FULL_DUPLEX) + { + Reg |= BMCR_DUPLEX; + } + + if(FIX_SPEED == SPEED_100) + { + Reg |= BMCR_SPEED_100; + } + +#endif + + ENET_MIIWriteRegister(PhyAddr,PHY_BMCR,Reg); + + to = PHY_TO; + + while(to) + { + --to; + if(ENET_MIIReadRegister(PhyAddr,PHY_BMSR) & BMSR_LINK_ESTABLISHED) + { + break; + } + } + + if(!to) + { + return(FALSE); + } + +#ifdef TRACE_PHY + Reg = ENET_MIIReadRegister(PhyAddr,0); + printf("PHY_BMCR(0) - 0x%04X\n\r",Reg); + Reg = ENET_MIIReadRegister(PhyAddr,1); + printf("PHY_BMSR(1) - 0x%04X\n\r",Reg); + Reg = ENET_MIIReadRegister(PhyAddr,0x4); + printf("PHY_ANAR(4) - 0x%04X\n\r",Reg); + Reg = ENET_MIIReadRegister(PhyAddr,0x5); + printf("PHY_ANLPAR(5) - 0x%04X\n\r",Reg); + Reg = ENET_MIIReadRegister(PhyAddr,0x6); + printf("PHY_ANER(6) - 0x%04X\n\r",Reg); + Reg = ENET_MIIReadRegister(PhyAddr,0x1f); + printf("PHY_100PHY(1F) - 0x%04X\n\r",Reg); +#endif // TRACE_PHY + + Reg = ENET_MIIReadRegister(PhyAddr,PHY_100PHY) & PHYCR_MODE; + + switch(Reg) + { + case 0x04: // 10 BASE T Half-duplex + printf("10 BASE T Half-duplex\r\n"); + Reg = 0; + break; + case 0x08: // 100 BASE TX Half-duplex + printf("100 BASE TX Half-duplex\r\n"); + Reg = BMCR_SPEED_100; +// SUPP_bit.SPEED = 1; + MAC_SUPP |= (1 << 8); /* Set Bit 8 (SPEED) in SUPP */ + break; + case 0x14: // 10 BASE T Full-duplex + printf("10 BASE T Full-duplex\r\n"); + Reg = BMCR_DUPLEX; + MAC_IPGT = 0x15; +// MAC2_bit.FD = COMMAND_bit.FULLDUPLEX = 1; + MAC_MAC2 |= (1 << 0); /* Set Bit 0 (FD) in MAC2 */ + MAC_COMMAND |= (1 << 10); /* Set Bit 10 (FULLDUPLEX) */ + break; + case 0x18: // 100 BASE TX Full-duplex + printf("100 BASE TX Full-duplex\r\n"); + Reg = BMCR_SPEED_100 | BMCR_DUPLEX; + MAC_IPGT = 0x15; +// MAC2_bit.FD = COMMAND_bit.FULLDUPLEX = 1; + MAC_MAC2 |= (1 << 0); /* Set Bit 0 (FD) in MAC2 */ + MAC_COMMAND |= (1 << 10); /* Set Bit 10 (FULLDUPLEX) */ +// SUPP_bit.SPEED = 1; + MAC_SUPP |= (1 << 8); /* Set Bit 8 (SPEED) in SUPP */ + break; + default: + return(FALSE); + } + + // Disable Auto-Negotiation and update speed and duplex settings + ENET_MIIWriteRegister(PhyAddr,PHY_BMCR,Reg); + + to = PHY_TO; + + while(to) + { + --to; + if(ENET_MIIReadRegister(PhyAddr,PHY_BMSR) & BMSR_LINK_ESTABLISHED) + { + break; + } + } + + if(!to) + { + return(FALSE); + } + + for( i = 0; i < ENET_DMA_DESC_NUMB; ++i) + { + EnetDmaRx[i].EnetRxCtrl.Size = EMAC_MAX_PACKET_SIZE-1; + EnetDmaRx[i].EnetRxCtrl.Intr = 1; + EnetDmaRxSta[i].Data[0] = EnetDmaRxSta[i].Data[1] = 0; + + EnetDmaTx[i].EnetTxCtrl.Data = (1<<31) | (1<<30) | (1<<29) | (1<<28) | (1<<26) | (EMAC_MAX_PACKET_SIZE-1); + EnetDmaTxSta[i].Data = 0; + + } + + EnetDmaRx[0].pBuffer = (pInt32U)RxBuff0; + EnetDmaRx[1].pBuffer = (pInt32U)RxBuff1; + EnetDmaTx[0].pBuffer = (pInt32U)TxBuff0; + EnetDmaTx[1].pBuffer = (pInt32U)TxBuff1; + MAC_RXCONSUMEINDEX = 0; + MAC_TXPRODUCEINDEX = 0; + MAC_TXDESCRIPTOR = (Int32U)EnetDmaTx; + MAC_TXSTATUS = (Int32U)EnetDmaTxSta; + MAC_RXDESCRIPTOR = (Int32U)EnetDmaRx; + MAC_RXSTATUS = (Int32U)EnetDmaRxSta; + +// COMMAND_bit.RXENABLE = 1; + MAC_COMMAND |= (1 << 0); /* Set Bit 0 (RXENABLE) in CMD */ +// MAC1_bit.RE = 1; + MAC_MAC1 |= (1 << 0); /* Set Bit 0 (RE) in MAC1 */ +// COMMAND_bit.TXENABLE = 1; + MAC_COMMAND |= (1 << 1); /* Set Bit 1 (TXENABLE) in CMD */ + + return(TRUE); +} + +/************************************************************************* + * Function Name: tapdev_read + * Parameters: + * Return: + * + * Description: Read data for MAC/DMA Controller + * + *************************************************************************/ +Int32U tapdev_read(void * pPacket) +{ +Int32U Indx = MAC_RXCONSUMEINDEX; +Int32U Size = EMAC_MAX_PACKET_SIZE; + if(Indx == MAC_RXPRODUCEINDEX) + { + return(0); + } + Size = MIN(Size,(EnetDmaRxSta[Indx].RxSize+1)); + memcpy(pPacket,EnetDmaRx[Indx].pBuffer,Size); + if(++Indx > MAC_RXDESCRIPTORNUM) + { + Indx = 0; + } + MAC_RXCONSUMEINDEX = Indx; + return(Size); +} + +/************************************************************************* + * Function Name: tapdev_send + * Parameters: + * Return: Boolean + * + * Description: Send data to MAC/DMA Controller + * + *************************************************************************/ +Boolean tapdev_send(void *pPacket, Int32U size) +{ +Int32U Indx, IndxHold = MAC_TXPRODUCEINDEX + 1; + if(size == 0) + { + return(TRUE); + } + if(IndxHold > MAC_TXDESCRIPTORNUM) + { + IndxHold = 0; + } + if(IndxHold == MAC_TXCONSUMEINDEX) + { + return(FALSE); + } + Indx = MAC_TXPRODUCEINDEX; + size = MIN(size,EMAC_MAX_PACKET_SIZE); + memcpy(EnetDmaTx[Indx].pBuffer,pPacket,size); + EnetDmaTx[Indx].EnetTxCtrl.Size = size - 1; + MAC_TXPRODUCEINDEX = IndxHold; + + return(TRUE); +} + +/************************************************************************* + * Function Name: ENET_MIIWriteRegister + * Parameters: Int8U DevId, Int8U RegAddr, Int32U Value + * Return: none + * + * Description: Writes a value on the PHY registers + * + *************************************************************************/ +static void ENET_MIIWriteRegister (Int8U DevId, Int8U RegAddr, Int32U Value) +{ + MAC_MCMD = 0; /* set read operation */ +// MADR_bit.PHY_ADDR = DevId; + + MAC_MADR = MAC_MADR & 0xFFFFE0E0; /* Reset PHY_ADDR and REG_ADDR */ + MAC_MADR |= (DevId << 8) | (RegAddr << 0); /* Set PHY_ADDR and REG_ADDR */ // \TODO is this working?? + + MAC_MWTD = Value; +// while(MIND_bit.BUSY); + while (MAC_MIND & (1 << 0)); // \TODO is this working?? +} + +/************************************************************************* + * Function Name: ENET_MIIReadRegister + * Parameters: Int8U DevId, Int8U RegAddr, Int32U Value + * Return: Int32U + * + * Description: Read a value from the PHY registers + * + *************************************************************************/ +static Int32U ENET_MIIReadRegister (Int8U DevId, Int8U RegAddr) +{ + MAC_MCMD = 0; +// MADR_bit.PHY_ADDR = DevId; // set the MII Physical address +// MADR_bit.REGADDR = RegAddr; // set the MII register address + MAC_MADR = MAC_MADR & 0xFFFFE0E0; /* Reset PHY_ADDR and REG_ADDR */ + MAC_MADR |= (DevId << 8) | (RegAddr << 0); /* Set PHY_ADDR and REG_ADDR */ // \TODO is this working?? + + MAC_MCMD = 1; // set read operation +// while(MIND_bit.BUSY | MIND_bit.NOT_VALID); + while (MAC_MIND & (5 << 0)); // \TODO is this working?? + return(MAC_MRDD); +} + + diff --git a/Tester/SW/lib/Drivers/ethernet/LPC23xx_enet.h b/Tester/SW/lib/Drivers/ethernet/LPC23xx_enet.h new file mode 100644 index 0000000..c082949 --- /dev/null +++ b/Tester/SW/lib/Drivers/ethernet/LPC23xx_enet.h @@ -0,0 +1,314 @@ +/************************************************************************* + * + * Used with ICCARM and AARM. + * + * (c) Copyright IAR Systems 2006 + * + * File name : LPC23xx_enet.h + * Description : MAC/DMA Controller with DMA (ENET) driver include file + * + * History : + * 1. Date : December 14, 2006 + * Author : Stanimir Bonev + * Description : Create + * + * $Revision: 1.1.2.3 $ + **************************************************************************/ +#include + +#ifndef __LPC23XX_ENET_H +#define __LPC23XX_ENET_H + + +#define EMAC_MAX_PACKET_SIZE (UIP_CONF_BUFFER_SIZE + 16) +#define ENET_DMA_DESC_NUMB 2 +#define ENET_OK (1) +#define ENET_NOK (0) + +#define AUTO_NEGOTIATION_ENA 0 // Enable PHY Auto-negotiation + +#define PHY_TO 666666 // ~10sec + +// KS8721B1 +#define PHY_BMCR 0x0000 +#define PHY_BMSR 0x0001 +#define PHY_PHYIDR1 0x0002 +#define PHY_PHYIDR2 0x0003 +#define PHY_ANAR 0x0004 +#define PHY_ANLPAR 0x0005 +#define PHY_ANLPARNP 0x0005 +#define PHY_ANER 0x0006 +#define PHY_ANNPTR 0x0007 +#define PHY_LPNPA 0x0008 + +#define PHY_RECR 0x0015 +#define PHY_INTCTRL 0x001B +#define PHY_100PHY 0x001F + +/* BMCR bitmap */ +#define BMCR_RESET 0x8000 +#define BMCR_LOOPBACK 0x4000 +#define BMCR_SPEED_100 0x2000 +#define BMCR_AN 0x1000 +#define BMCR_POWERDOWN 0x0800 +#define BMCR_ISOLATE 0x0400 +#define BMCR_RE_AN 0x0200 +#define BMCR_DUPLEX 0x0100 + +/* BMSR bitmap */ +#define BMSR_100BE_T4 0x8000 +#define BMSR_100TX_FULL 0x4000 +#define BMSR_100TX_HALF 0x2000 +#define BMSR_10BE_FULL 0x1000 +#define BMSR_10BE_HALF 0x0800 +#define BMSR_NOPREAM 0x0040 +#define BMSR_AUTO_DONE 0x0020 +#define BMSR_REMOTE_FAULT 0x0010 +#define BMSR_NO_AUTO 0x0008 +#define BMSR_LINK_ESTABLISHED 0x0004 + +/* PHY_ANAR bitmap */ +#define ANAR_NEXT_PAGE 0x8000 +#define ANAR_REMOTE_FAULT 0x2000 +#define ANAR_PAUSE 0x0400 +#define ANAR_100BE_T4 0x0200 +#define ANAR_100BT_FULL 0x0100 +#define ANAR_100BT 0x0080 +#define ANAR_10BT_FULL 0x0040 +#define ANAR_10BT 0x0020 +#define ANAR_SELECTOR 0x001F + +/* ANLPAR bitmap */ +#define ANLPAR_NEXT_PAGE 0x8000 +#define ANLPAR_ACKN 0x4000 +#define ANLPAR_REMOTE_FAULT 0x2000 +#define ANLPAR_PAUSE 0x0C00 +#define ANLPAR_100BE_T4 0x0200 +#define ANLPAR_100BT_FULL 0x0100 +#define ANLPAR_100BT 0x0080 +#define ANLPAR_10BT_FULL 0x0040 +#define ANLPAR_10BT 0x0020 +#define ANLPAR_SELECTOR 0x001F + +/* PHY_100PHY setting */ +#define PHYCR_MDIX_DIS 0x2000 +#define PHYCR_ENR_DET 0x1000 +#define PHYCR_FORCE_LINK 0x0800 +#define PHYCR_POWER_SAVING 0x0400 +#define PHYCR_INTR_LEVEL 0x0200 +#define PHYCR_JABBER_ENA 0x0100 +#define PHYCR_PAUSE_ENA 0x0080 +#define PHYCR_PHY_ISO 0x0040 +#define PHYCR_MODE 0x001C +#define PHYCR_SQE_TST_ENA 0x0002 +#define PHYCR_SCRAM_DIS 0x0001 + +#define SPEED_100 1 +#define SPEED_10 0 +#define FULL_DUPLEX 1 +#define HALF_DUPLEX 0 + +#define FIX_SPEED SPEED_100 +#define FIX_DUPLEX FULL_DUPLEX + +typedef union _EnetRxCR_t +{ + Int32U Data; + struct { + Int32U DMA_XFERCOUNT :12; + Int32U CONT_EN : 1; + Int32U : 1; + Int32U NXT_EN : 1; + Int32U DLY_EN : 1; + Int32U : 1; + Int32U ENTRY_TRIG : 5; + Int32U ADDR_WRAP :10; + }; +} EnetRxCR_t, * pEnetRxCR_t; + +typedef union _EnetRxSR_t +{ + Int32U Data; + struct { + Int32U FrameLength :11; + Int32U : 1; + Int32U Overlength : 1; + Int32U FalseCarrier : 1; + Int32U WatchdogTO : 1; + Int32U RuntFrame : 1; + Int32U Valid : 1; + Int32U LateCollision : 1; + Int32U FrameType : 1; + Int32U MIIError : 1; + Int32U ExtraBits : 1; + Int32U CRCError : 1; + Int32U OneLevelVLAN : 1; + Int32U TwoLevelVLAN : 1; + Int32U LengthError : 1; + Int32U ControlFrame : 1; + Int32U UnsupportedFrame: 1; + Int32U MulticastFrame : 1; + Int32U BroadcastFrame : 1; + Int32U FilteringFail : 1; + Int32U PacketFilter : 1; + Int32U FrameAbort : 1; + }; +} EnetRxSR_t, * pEnetRxSR_t; + +typedef union _EnetTxSR_t +{ + Int32U Data; + struct { + Int32U FrameAborted : 1; + Int32U : 1; + Int32U NoCarrier : 1; + Int32U LossOfCarrier : 1; + Int32U ExcessiveDef : 1; + Int32U LateCollision : 1; + Int32U ExcessiveColl : 1; + Int32U UnderRun : 1; + Int32U Deferred : 1; + Int32U LateCollisionObs: 1; + Int32U CollisionCount : 4; + Int32U : 2; + Int32U Valid : 1; + Int32U : 1; + Int32U ByteCounter :13; + Int32U PacketRetry : 1; + }; +} EnetTxSR_t, * pEnetTxSR_t; + + +typedef union _EnetTxCtrl_t +{ + Int32U Data; + struct + { + Int32U Size : 11; + Int32U : 15; + Int32U Override : 1; + Int32U Huge : 1; + Int32U Pad : 1; + Int32U CRC : 1; + Int32U Last : 1; + Int32U Intr : 1; + }; +} EnetTxCtrl_t, *pEnetTxCtrl_t; + +typedef struct _EnetDmaTxDesc_t +{ + pInt32U pBuffer; + EnetTxCtrl_t EnetTxCtrl; +} EnetDmaTxDesc_t, * pEnetDmaTxDesc_t; + +typedef union _EnetDmaTxStatus_t +{ + Int32U Data; + struct + { + Int32U :21; + Int32U CollisionCount : 4; + Int32U Defer : 1; + Int32U ExcessiveDefer : 1; + Int32U ExcessiveCollision : 1; + Int32U LateCollision : 1; + Int32U Underrun : 1; + Int32U NoDescriptor : 1; + Int32U Error : 1; + }; +} EnetDmaTxStatus_t, * pEnetDmaTxStatus_t; + +typedef struct _EnetRxCtrl_t +{ + Int32U Size : 11; + Int32U : 20; + Int32U Intr : 1; +} EnetRxCtrl_t, *pEnetRxCtrl_t; + +typedef struct _EnetDmaRxDesc_t +{ + pInt32U pBuffer; + EnetRxCtrl_t EnetRxCtrl; +} EnetDmaRxDesc_t, * pEnetDmaRxDesc_t; + +typedef union _EnetDmaRxStatus_t +{ + Int32U Data[2]; + struct + { + Int32U RxSize :11; + Int32U : 7; + Int32U ControlFrame : 1; + Int32U VLAN : 1; + Int32U FailFilter : 1; + Int32U Multicast : 1; + Int32U Broadcast : 1; + Int32U CRCError : 1; + Int32U SymbolError : 1; + Int32U LengthError : 1; + Int32U RangeError : 1; + Int32U AlignmentError : 1; + Int32U Overrun : 1; + Int32U NoDescriptor : 1; + Int32U LastFlag : 1; + Int32U Error : 1; + Int32U SAHashCRC : 8; + Int32U : 8; + Int32U DAHashCRC : 8; + Int32U : 8; + }; +} EnetDmaRxStatus_t, * pEnetDmaRxStatus_t; + +/************************************************************************* + * Function Name: + * Parameters: None + * + * Return: None + * + * Description: Init MAC/DMA Controller + * + *************************************************************************/ +Boolean tapdev_init(void); + +/************************************************************************* + * Function Name: tapdev_read + * Parameters: + * Return: + * + * Description: Read data for MAC/DMA Controller + * + *************************************************************************/ +Int32U tapdev_read(void * pPacket); + +/************************************************************************* + * Function Name: tapdev_send + * Parameters: + * Return: Boolean + * + * Description: Send data to MAC/DMA Controller + * + *************************************************************************/ +Boolean tapdev_send (void *pPacket, Int32U size); + +/************************************************************************* + * Function Name: ENET_MIIWriteRegister + * Parameters: Int8U DevId, Int8U RegAddr, Int32U Value + * Return: none + * + * Description: Writes a value on the PHY registers + * + *************************************************************************/ +static void ENET_MIIWriteRegister (Int8U DevId, Int8U RegAddr, Int32U Value); + +/************************************************************************* + * Function Name: ENET_MIIReadRegister + * Parameters: Int8U DevId, Int8U RegAddr, Int32U Value + * Return: Int32U + * + * Description: Read a value from the PHY registers + * + *************************************************************************/ +static Int32U ENET_MIIReadRegister (Int8U DevId, Int8U RegAddr); + +#endif // __LPC23XX_ENET_H + diff --git a/Tester/SW/lib/Drivers/ethernet/arm_comm.h b/Tester/SW/lib/Drivers/ethernet/arm_comm.h new file mode 100644 index 0000000..7851ced --- /dev/null +++ b/Tester/SW/lib/Drivers/ethernet/arm_comm.h @@ -0,0 +1,94 @@ +/*************************************************************************** + ** + ** Common definition for IAR EW ARM + ** + ** Used with ARM IAR C/C++ Compiler and Assembler. + ** + ** (c) Copyright IAR Systems 2006 + ** + ** $Revision: 1.4 $ + ** + ***************************************************************************/ +#ifndef __ARM_COMM_DEF_H +#define __ARM_COMM_DEF_H + +#define MHZ *1000000l +#define KHZ *1000l +#define HZ *1l + +#ifndef FALSE +#define FALSE (1 == 0) +#endif + +#ifndef TRUE +#define TRUE (1==1) +#endif + +#ifndef NULL +#define NULL ((void*)0) +#endif + +typedef double Flo64; // Double precision floating point +typedef double * pFlo64; +typedef float Flo32; // Single precision floating point +typedef float * pFlo32; +typedef signed long long Int64S; // Signed 64 bit quantity +typedef signed long long * pInt64S; +typedef unsigned long long Int64U; // Unsigned 64 bit quantity +typedef unsigned long long * pInt64U; +typedef signed int Int32S; // Signed 32 bit quantity +typedef signed int * pInt32S; +typedef unsigned int Int32U; // Unsigned 32 bit quantity +typedef unsigned int * pInt32U; +typedef signed short Int16S; // Signed 16 bit quantity +typedef signed short * pInt16S; +typedef unsigned short Int16U; // Unsigned 16 bit quantity +typedef unsigned short * pInt16U; +typedef signed char Int8S; // Signed 8 bit quantity +typedef signed char * pInt8S; +typedef unsigned char Int8U; // Unsigned 8 bit quantity +typedef unsigned char * pInt8U; +typedef unsigned char Boolean; // Boolean +typedef unsigned char * pBoolean; + +#define MAX(a, b) (((a) > (b)) ? (a) : (b)) +#define MIN(a, b) (((a) < (b)) ? (a) : (b)) +#define _2BL(a) (Int8U)(a),(Int8U)(a>>8) +#define _2BB(a) (Int8U)(a>>8),(Int8U)(a), +#define _3BL(a) (Int8U)(a),(Int8U)(a>>8),(Int8U)(a>>16) +#define _3BB(a) (Int8U)(a>>16),(Int8U)(a>>8),(Int8U)(a) +#define _4BL(a) (Int8U)(a),(Int8U)(a>>8),(Int8U)(a>>16),(Int8U)(a>>24) +#define _4BB(a) (Int8U)(a>>24),(Int8U)(a>>16),(Int8U)(a>>8),(Int8U)(a) + +typedef void * (*CommUserFpnt_t)(void *); +typedef void (*VoidFpnt_t)(void); + +// Atomic exchange of data between a memory cell and a register +// return value of the memory cell +//inline Int32U AtomicExchange (Int32U State, pInt32U Flag) +//{ +// asm("swp r0, r0, [r1]"); +// return(State); +//} + +#define LongToBin(n) (((n >> 21) & 0x80) | \ + ((n >> 18) & 0x40) | \ + ((n >> 15) & 0x20) | \ + ((n >> 12) & 0x10) | \ + ((n >> 9) & 0x08) | \ + ((n >> 6) & 0x04) | \ + ((n >> 3) & 0x02) | \ + ((n ) & 0x01)) + +#define __BIN(n) LongToBin(0x##n##l) + +#define BIN8(n) __BIN(n) +#define BIN(n) __BIN(n) +#define BIN16(b1,b2) (( __BIN(b1) << 8) + \ + __BIN(b2)) +#define BIN32(b1,b2,b3,b4) ((((u32_t)__BIN(b1)) << 24ul) + \ + (((u32_t)__BIN(b2)) << 16ul) + \ + (((u32_t)__BIN(b3)) << 8ul) + \ + (u32_t)__BIN(b4)) + +#endif // __ARM_COMM_DEF_H diff --git a/Tester/SW/lib/Drivers/ethernet/board.h b/Tester/SW/lib/Drivers/ethernet/board.h new file mode 100644 index 0000000..35a0b05 --- /dev/null +++ b/Tester/SW/lib/Drivers/ethernet/board.h @@ -0,0 +1,293 @@ +/*************************************************************************** + ** + ** This file defines the board specific definition + ** + ** Used with ARM IAR C/C++ Compiler and Assembler. + ** + ** (c) Copyright IAR Systems 2005 + ** + ** $Revision: 1.4 $ + ** + ***************************************************************************/ +#include "arm_comm.h" + +#ifndef __BOARD_H +#define __BOARD_H + +#define I_RC_OSC_FREQ (4000000) +#define MAIN_OSC_FREQ (12000000) +#define RTC_OSC_FREQ (32768UL) + +#if defined(IAR_LPC_2378_SK) + +// USB Link LED +#define USB_LINK_LED_MASK (1UL<<13) +#define USB_LINK_LED_DIR IO0DIR +#define USB_LINK_LED_FDIR FIO0DIR +#define USB_LINK_LED_SET IO0SET +#define USB_LINK_LED_FSET FIO0SET +#define USB_LINK_LED_CLR IO0CLR +#define USB_LINK_LED_FCLR FIO0CLR +#define USB_LINK_LED_IO IO0PIN +#define USB_LINK_LED_FIO FIO0PIN + +// LCD Backlight +#define LCD_BL_MASK (1UL<<26) +#define LCD_BL_DIR IO1DIR +#define LCD_BL_FDIR FIO1DIR +#define LCD_BL_SET IO1SET +#define LCD_BL_FSET FIO1SET +#define LCD_BL_CLR IO1CLR +#define LCD_BL_FCLR FIO1CLR +#define LCD_BL_IO IO1PIN +#define LCD_BL_FIO FIO1PIN +// LCD Reset +#define LCD_RST_MASK (1UL<<25) +#define LCD_RST_FDIR FIO3DIR +#define LCD_RST_FSET FIO3SET +#define LCD_RST_FCLR FIO3CLR +#define LCD_RST_FIO FIO3PIN +// LCD CS +#define LCD_CS_MASK (1UL<<21) +#define LCD_CS_DIR IO1DIR +#define LCD_CS_FDIR FIO1DIR +#define LCD_CS_SET IO1SET +#define LCD_CS_FSET FIO1SET +#define LCD_CS_CLR IO1CLR +#define LCD_CS_FCLR FIO1CLR +#define LCD_CS_IO IO1PIN +#define LCD_CS_FIO FIO1PIN + +// Buttons +#define B1_MASK (1UL<<29) +#define B1_DIR IO0DIR +#define B1_FDIR FIO0DIR +#define B1_IO IO0PIN +#define B1_FIO FIO0PIN + +#define B2_MASK (1UL<<18) +#define B2_DIR IO0DIR +#define B2_FDIR FIO0DIR +#define B2_IO IO0PIN +#define B2_FIO FIO0PIN + +// Joystick +#define JS_RIGHT_MASK (1UL << 22) +#define JS_LEFT_MASK (1UL << 27) +#define JS_UP_MASK (1UL << 18) +#define JS_DOWN_MASK (1UL << 19) +#define JS_CENTER_MASK (1UL << 25) +#define JS_DIR IO1DIR +#define JS_FDIR FIO1DIR +#define JS_IO IO1PIN +#define JS_FIO FIO1PIN + +// MMC/SD card switches +// Card present +#define MMC_CP_MASK (1UL << 17) +#define MMC_CP_DIR IO0DIR +#define MMC_CP_FDIR FIO0DIR +#define MMC_CP_IO IO0PIN +#define MMC_CP_FIO FIO0PIN +#define MMC_CP_MODE PINMODE1_bit.P0_17 + +// Card write protect +#define MMC_WP_MASK (1UL << 29) +#define MMC_WP_DIR IO1DIR +#define MMC_WP_FDIR FIO1DIR +#define MMC_WP_IO IO1PIN +#define MMC_WP_FIO FIO1PIN +#define MMC_WP_MODE PINMODE3_bit.P1_29 + +//MMA +#define X_CHANNEL 1 +#define X_CHANNEL_SEL PINSEL1_bit.P0_24 +#define Y_CHANNEL 0 +#define Y_CHANNEL_SEL PINSEL1_bit.P0_23 +#define Z_CHANNEL 6 +#define Z_CHANNEL_SEL PINSEL0_bit.P0_12 + +// Analog trim +#define ANALOG_TRIM_CHANNEL 5 +#define ANALOG_TRIM_CHANNEL_SEL PINSEL3_bit.P1_31 + +// MIC Input +#define MIC_IN_CHANNEL 3 +#define MIC_IN_CHANNEL_SEL PINMODE1_bit.P0_25 + +// Check for board revision. +// The board with PHY routing mistake have 4.7k resistor on port P0.21 and +// internal pull-up can't set logical 1. +// To fix routing mistake U4's pin 9 must be swaped with pin 22 and add pull +// down 1k resistor on a pin 9. +#define BOARD_BUG_CTRL PINMODE1_bit.P0_21 +#define BOARD_BUG_FDATA FIO0PIN_bit.P0_21 +#define BOARD_BUG_DATA IO0PIN_bit.P0_21 + +#elif defined(IAR_LPC_P2378_SK) + +// USB Link LED +#define USB_LINK_LED_MASK (1UL<<13) +#define USB_LINK_LED_DIR IO0DIR +#define USB_LINK_LED_FDIR FIO0DIR +#define USB_LINK_LED_SET IO0SET +#define USB_LINK_LED_FSET FIO0SET +#define USB_LINK_LED_CLR IO0CLR +#define USB_LINK_LED_FCLR FIO0CLR +#define USB_LINK_LED_IO IO0PIN +#define USB_LINK_LED_FIO FIO0PIN + +// Status LED +#define STATUS_LED_MASK (1UL<<19) +#define STATUS_LED_DIR IO1DIR +#define STATUS_LED_FDIR FIO1DIR +#define STATUS_LED_SET IO1SET +#define STATUS_LED_FSET FIO1SET +#define STATUS_LED_CLR IO1CLR +#define STATUS_LED_FCLR FIO1CLR +#define STATUS_LED_IO IO1PIN +#define STATUS_LED_FIO FIO1PIN + +// Buttons +#define B1_MASK (1UL<<30) +#define B1_DIR IO0DIR +#define B1_FDIR FIO0DIR +#define B1_IO IO0PIN +#define B1_FIO FIO0PIN + +#define B2_MASK (1UL<<6) +#define B2_DIR IO0DIR +#define B2_FDIR FIO0DIR +#define B2_IO IO0PIN +#define B2_FIO FIO0PIN + +// MMC/SD card switches +// Card present +#define MMC_CP_MASK (1UL << 29) +#define MMC_CP_DIR IO0DIR +#define MMC_CP_FDIR FIO0DIR +#define MMC_CP_IO IO0PIN +#define MMC_CP_FIO FIO0PIN +#define MMC_CP_MODE PINMODE1_bit.P0_29 + +// Card write protect +#define MMC_WP_MASK (1UL << 28) +#define MMC_WP_DIR IO1DIR +#define MMC_WP_FDIR FIO1DIR +#define MMC_WP_IO IO1PIN +#define MMC_WP_FIO FIO1PIN +#define MMC_WP_MODE PINMODE3_bit.P1_28 + +// Check for board revision. +// The board with PHY routing mistake have 4.7k resistor on port P0.21 and +// internal pull-up can't set logical 1. +// To fix routing mistake U4's pin 9 must be swaped with pin 22 and add pull +// down 1k resistor on a pin 9. +#define BOARD_BUG_CTRL PINMODE1_bit.P0_21 +#define BOARD_BUG_FDATA FIO0PIN_bit.P0_21 +#define BOARD_BUG_DATA IO0PIN_bit.P0_21 + +#else +//#error define type of the board +#endif + +// PCLK offset +#define WDT_PCLK_OFFSET 0 +#define TIMER0_PCLK_OFFSET 2 +#define TIMER1_PCLK_OFFSET 4 +#define UART0_PCLK_OFFSET 6 +#define UART1_PCLK_OFFSET 8 +#define PWM0_PCLK_OFFSET 10 +#define PWM1_PCLK_OFFSET 12 +#define I2C0_PCLK_OFFSET 14 +#define SPI_PCLK_OFFSET 16 +#define RTC_PCLK_OFFSET 18 +#define SSP1_PCLK_OFFSET 20 +#define DAC_PCLK_OFFSET 22 +#define ADC_PCLK_OFFSET 24 +#define CAN1_PCLK_OFFSET 26 +#define CAN2_PCLK_OFFSET 28 +#define ACF_PCLK_OFFSET 30 +#define BAT_RAM_PCLK_OFFSET 32 +#define GPIO_PCLK_OFFSET 34 +#define PCB_PCLK_OFFSET 36 +#define I2C1_PCLK_OFFSET 38 +//#define 40 +#define SSP0_PCLK_OFFSET 42 +#define TIMER2_PCLK_OFFSET 44 +#define TIMER3_PCLK_OFFSET 46 +#define UART2_PCLK_OFFSET 48 +#define UART3_PCLK_OFFSET 50 +#define I2C2_PCLK_OFFSET 52 +#define I2S_PCLK_OFFSET 54 +#define MCI_PCLK_OFFSET 56 +//#define 58 +#define PCLK_PCLK_OFFSET 60 +//#define 62 + +#define IRQ_FLAG 0x80 +#define FIQ_FLAG 0x40 + +/************************************************************************* + * Function Name: restore_IRQ + * Parameters: unsigned long IFlag + * Return: void + * Description: Restore I flag state + * + *************************************************************************/ +//inline +//void restore_IRQ(unsigned long IFlag) +//{ +//unsigned long tmp; +// tmp=__get_CPSR(); +// __set_CPSR(tmp & (IFlag | ~IRQ_FLAG)); +//} + + /************************************************************************* + * Function Name: disable_IRQ + * Parameters: + * Return: unsigned long + * Description: Disable IRQ and return previous state state of flags I + * + *************************************************************************/ +//inline +//unsigned long disable_IRQ(void) +//{ +//unsigned long tmp; +// tmp=__get_CPSR(); +// __set_CPSR(tmp | IRQ_FLAG); +// return tmp & IRQ_FLAG; +//} + + /************************************************************************* + * Function Name: restore_interrupts + * Parameters: unsigned long IFlag + * Return: void + * Description: Restore F,I flag state + * + *************************************************************************/ +//inline +//void restore_interrupts(unsigned long IFlag) +//{ +//unsigned long tmp; +// tmp=__get_CPSR(); +// __set_CPSR(tmp & (IFlag | ~(IRQ_FLAG | FIQ_FLAG))); +//} + + /************************************************************************* + * Function Name: disable_interrupts + * Parameters: + * Return: unsigned long + * Description: Disable interrupts and return previous state state of flags I + * + *************************************************************************/ +//inline +//unsigned long disable_interrupts(void) +//{ +//unsigned long tmp; +// tmp=__get_CPSR(); +// __set_CPSR(tmp | IRQ_FLAG | FIQ_FLAG); +// return tmp; +//} + +#endif /* __BOARD_H */ diff --git a/Tester/SW/lib/Drivers/ethernet/clock-arch.c b/Tester/SW/lib/Drivers/ethernet/clock-arch.c new file mode 100644 index 0000000..3be29e2 --- /dev/null +++ b/Tester/SW/lib/Drivers/ethernet/clock-arch.c @@ -0,0 +1,98 @@ +/************************************************************************* + * + * Used with ICCARM and AARM. + * + * (c) Copyright IAR Systems 2006 + * + * File name : clock-arch.c + * Description : Implementation of architecture-specific clock functionality + * + * History : + * 1. Date : October 4, 2006 + * Author : Stanimir Bonev + * Description : Create + * + * $Revision: 1.1.2.3 $ +**************************************************************************/ +#include "LPC23xx.h" + +#include "clock-arch.h" +#include "ethernet.h" + +volatile clock_time_t Ticks; + +/************************************************************************* + * Function Name: Tim0Handler + * Parameters: none + * + * Return: none + * + * Description: Timer 0 interrupt handler + * + *************************************************************************/ +static +void Timer1IntrHandler (void) +{ + ++Ticks; +// T0IR_bit.MR0INT = 1; + T1IR |= (1 << 1); + VICIRQStatus = 0; +} + +/************************************************************************* + * Function Name: clock_init + * Parameters: Int32U IntrPriority + * + * Return: none + * + * Description: Timer init + * + *************************************************************************/ +void clock_init(Int32U IntrPriority) +{ + Ticks = 0; + + // Init Time0 +// PCONP_bit.PCTIM0 = 1; + PCONP |= (1 << 2); /* Enable Timer 1 CLK */ +// T0TCR_bit.CE = 0; + T1TCR &=~(1 << 0); /* Disable Counter 1 */ +// T0TCR_bit.CR = 1; + T1TCR |= (1 << 1); /* Reset Counter 1 */ +// T0TCR_bit.CR = 0; + T1TCR &=~(1 << 1); /* Relase Reset on Counter 1 */ +// T0CTCR_bit.CTM = 0; + T1CTCR &=~(1 << 0) &~(1 << 1); /* Mode: every rising PCLK edge */ + +// T0MCR_bit.MR0I = 1; + T1MCR |= (1 << 3); /* Enable Interrupt on MR1 */ +// T0MCR_bit.MR0R = 1; + T1MCR |= (1 << 4); /* Enable reset on MR1 */ +// T0MCR_bit.MR0S = 0; + T1MCR &=~(1 << 5); /* Disable stop on MR1 */ + + T1PR = 0; /* set timer 1 period */ + + T1MR0 = SYS_GetFpclk(TIMER0_PCLK_OFFSET)/(TICK_PER_SEC); + // init timer 0 interrupt +// T0IR_bit.MR0INT = 1; + T1IR |= (1 << 1); /* clear pending interrupt */ + VIC_SetVectoredIRQ(Timer1IntrHandler,IntrPriority,VIC_CHAN_NUM_Timer1); + VICIntEnable |= 1UL << VIC_CHAN_NUM_Timer1; +// T0TCR_bit.CE = 1; + T1TCR |= (1 << 0); /* Enable Counter */ +} + +/************************************************************************* + * Function Name: clock_init + * Parameters: none + * + * Return: none + * + * Description: The current clock time, measured in system ticks + * + *************************************************************************/ +clock_time_t clock_time(void) +{ + return(Ticks); +} diff --git a/Tester/SW/lib/Drivers/ethernet/clock-arch.h b/Tester/SW/lib/Drivers/ethernet/clock-arch.h new file mode 100644 index 0000000..0416c72 --- /dev/null +++ b/Tester/SW/lib/Drivers/ethernet/clock-arch.h @@ -0,0 +1,67 @@ +/************************************************************************* + * + * Used with ICCARM and AARM. + * + * (c) Copyright IAR Systems 2006 + * + * File name : clock-arch.h + * Description : Implementation of architecture-specific clock + * functionality include file + * + * History : + * 1. Date : October 4, 2006 + * Author : Stanimir Bonev + * Description : Create + * + * $Revision: 1.1.2.3 $ +**************************************************************************/ +#include "includes.h" + +#ifndef __CLOCK_ARCH_H__ +#define __CLOCK_ARCH_H__ + +#define TICK_PER_SEC 100 + +typedef Int32U clock_time_t; + +#define CLOCK_CONF_SECOND TICK_PER_SEC + +extern Int32U SYS_GetFpclk(Int32U Periphery); +extern void VIC_SetVectoredIRQ(void(*pIRQSub)(), unsigned int Priority, + unsigned int VicIntSource); + +/************************************************************************* + * Function Name: Tim0Handler + * Parameters: none + * + * Return: none + * + * Description: Timer 0 interrupt handler + * + *************************************************************************/ +static +void Timer1IntrHandler (void); + +/************************************************************************* + * Function Name: clock_init + * Parameters: Int32U IntrPriority + * + * Return: none + * + * Description: Timer init + * + *************************************************************************/ +//void clock_init(Int32U IntrPriority); + +/************************************************************************* + * Function Name: clock_init + * Parameters: none + * + * Return: none + * + * Description: The current clock time, measured in system ticks + * + *************************************************************************/ +clock_time_t clock_time(void); + +#endif /* __CLOCK_ARCH_H__ */ diff --git a/Tester/SW/lib/Drivers/ethernet/clock.h b/Tester/SW/lib/Drivers/ethernet/clock.h new file mode 100644 index 0000000..7110ea9 --- /dev/null +++ b/Tester/SW/lib/Drivers/ethernet/clock.h @@ -0,0 +1,88 @@ +/** + * \defgroup clock Clock interface + * + * The clock interface is the interface between the \ref timer "timer library" + * and the platform specific clock functionality. The clock + * interface must be implemented for each platform that uses the \ref + * timer "timer library". + * + * The clock interface does only one this: it measures time. The clock + * interface provides a macro, CLOCK_SECOND, which corresponds to one + * second of system time. + * + * \sa \ref timer "Timer library" + * + * @{ + */ + +/* + * Copyright (c) 2004, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of the uIP TCP/IP stack + * + * Author: Adam Dunkels + * + * $Id: clock.h,v 1.1.2.3 2006/12/04 18:52:39 fredrikh Exp $ + */ +#ifndef __CLOCK_H__ +#define __CLOCK_H__ + +#include "clock-arch.h" + +/** + * Initialize the clock library. + * + * This function initializes the clock library and should be called + * from the main() function of the system. + * + */ +//void clock_init(Int32U IntrPriority); + +/** + * Get the current clock time. + * + * This function returns the current system clock time. + * + * \return The current clock time, measured in system ticks. + */ +clock_time_t clock_time(void); + +/** + * A second, measured in system clock time. + * + * \hideinitializer + */ +#ifdef CLOCK_CONF_SECOND +#define CLOCK_SECOND CLOCK_CONF_SECOND +#else +#define CLOCK_SECOND (clock_time_t)32 +#endif + +#endif /* __CLOCK_H__ */ + +/** @} */ diff --git a/Tester/SW/lib/Drivers/ethernet/ethernet.c b/Tester/SW/lib/Drivers/ethernet/ethernet.c new file mode 100644 index 0000000..6222efe --- /dev/null +++ b/Tester/SW/lib/Drivers/ethernet/ethernet.c @@ -0,0 +1,349 @@ +/************************************************************************* + * + * Used with ICCARM and AARM. + * + * (c) Copyright IAR Systems 2007 + * + * File name : main.c + * Description : Main module + * + * History : + * 1. Date : February 3, 2007 + * Author : Stanimir Bonev + * Description : Create + * + * This example project shows how to use the IAR Embedded Workbench for ARM + * to develop code for the IAR LPC-2378-SK board. + * It implements WEB server. + * The default IP address is: + * 192.168.0.100 + * The physical MAC address is (defined in uipopt.h): + * 00-ff-ff-ff-ff-ff + * + * Jumpers: + * PWR_SEL - depending of power source + * RST_E - unfilled + * ISP_E - unfilled + * + * Note: + * After power-up the controller get clock from internal RC oscillator that + * is unstable and may fail with J-Link auto detect, therefore adaptive clocking + * should always be used. The adaptive clock can be select from menu: + * Project->Options..., section Debugger->J-Link/J-Trace JTAG Speed - Adaptive. + * + ************************************************************************** + * Copyright (c) 2001-2003, Adam Dunkels. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This file is part of the uIP TCP/IP stack. + * + ************************************************************************** + * + * $Revision: 1.0 $ + * + **************************************************************************/ +#include "LPC23xx.h" +#include "types.h" + +#include "includes.h" + +#define BUF ((struct uip_eth_hdr *)&uip_buf[0]) + + + + +/************************************************************************* + * Function Name: VIC_SetVectoredIRQ + * Parameters: void(*pIRQSub)() + * unsigned int VicIrqSlot + * unsigned int VicIntSouce + * + * Return: void + * + * Description: Init vectored interrupts + * + *************************************************************************/ +void VIC_SetVectoredIRQ(void(*pIRQSub)(), unsigned int Priority, + unsigned int VicIntSource) +{ +unsigned long volatile *pReg; + // load base address of vectored address registers + pReg = &VICVectAddr0; + // Set Address of callback function to corresponding Slot + *(pReg+VicIntSource) = (unsigned long)pIRQSub; + // load base address of ctrl registers + pReg = &VICVectCntl0; + // Set source channel and enable the slot + *(pReg+VicIntSource) = Priority; + // Clear FIQ select bit + VICIntSelect &= ~(1 << VicIntSource); +} + +/************************************************************************* + * Function Name: GpioInit + * Parameters: void + * Return: void + * + * Description: Reset all GPIO pins to default: primary function + * + *************************************************************************/ +void GpioInit(void) +{ + // Set to inputs + IODIR0 = \ + IODIR1 = \ + FIO0DIR = \ + FIO1DIR = \ + FIO2DIR = \ + FIO3DIR = \ + FIO4DIR = 0; + + // Enable Fast GPIO0,1 +// SCS_bit.GPIOM = 1; + SCS |= (1 << 0); + + // clear mask registers + FIO0MASK =\ + FIO1MASK =\ + FIO2MASK =\ + FIO3MASK =\ + FIO4MASK = 0; + + // Reset all GPIO pins to default primary function + PINSEL0 =\ + PINSEL1 =\ + PINSEL2 =\ + PINSEL3 =\ + PINSEL4 =\ + PINSEL5 =\ + PINSEL6 =\ + PINSEL7 =\ + PINSEL8 =\ + PINSEL9 =\ + PINSEL10= 0; +} + +/************************************************************************* + * Function Name: SYS_GetFsclk + * Parameters: none + * Return: Int32U + * + * Description: return Sclk [Hz] + * + *************************************************************************/ +Int32U SYS_GetFsclk(void) +{ +Int32U Mul = 1, Div = 1, Osc, Fsclk; +// if(PLLSTAT_bit.PLLC) + if (PLLSTAT & (1 << 25)) // \TODO is this working?? + { + // when PLL is connected +// Mul = PLLSTAT_bit.MSEL + 1; + Mul = (PLLSTAT & 0x00007FFF) + 1; // \TODO is this working?? +// Div = PLLSTAT_bit.NSEL + 1; + Div = (PLLSTAT & 0x00FF0000) + 1; // \TODO is this working?? + + } + + // Find clk source +// switch(CLKSRCSEL_bit.CLKSRC) + switch (CLKSRCSEL | 0x00000003) // \TODO is this working?? + { + case 0: + Osc = I_RC_OSC_FREQ; + break; + case 1: + Osc = MAIN_OSC_FREQ; + break; + case 2: + Osc = RTC_OSC_FREQ; + break; + default: + Osc = 0; + } + // Calculate system frequency + Fsclk = Osc*Mul*2; + Fsclk /= Div*(CCLKCFG+1); + return(Fsclk); +} + +/************************************************************************* + * Function Name: SYS_GetFpclk + * Parameters: Int32U Periphery + * Return: Int32U + * + * Description: return Pclk [Hz] + * + *************************************************************************/ +Int32U SYS_GetFpclk(Int32U Periphery) +{ +Int32U Fpclk; +pInt32U pReg = (pInt32U)((Periphery < 32)?&PCLKSEL0:&PCLKSEL1); + + Periphery &= 0x1F; // %32 + Fpclk = SYS_GetFsclk(); + // find peripheral appropriate periphery divider + switch((*pReg >> Periphery) & 3) + { + case 0: + Fpclk /= 4; + break; + case 1: + break; + case 2: + Fpclk /= 2; + break; + default: + Fpclk /= 8; + } + return(Fpclk); +} + +/************************************************************************* + * Function Name: Dly100us + * Parameters: void *arg + * Return: void + * + * Description: Delay [100us] + * + *************************************************************************/ +//void Dly100us(void *arg) +//{ +//volatile Int32U Dly = (Int32U)arg, Dly100; +// for(;Dly;Dly--) +// for(Dly100 = 350; Dly100; Dly100--); +//} + +/************************************************************************* + * Function Name: main + * Parameters: none + * + * Return: none + * + * Description: main + * + *************************************************************************/ +void ethInit(void) +{ +unsigned int i; +uip_ipaddr_t ipaddr; +struct timer periodic_timer, arp_timer; + + // Init GPIO + GpioInit(); + + + timer_set(&periodic_timer, CLOCK_SECOND / 2); + timer_set(&arp_timer, CLOCK_SECOND * 10); + + // Initialize the ethernet device driver + while(!tapdev_init()); + + ENABLE_INTERRUPTS(); + + + + // uIP web server + // Initialize the uIP TCP/IP stack. + uip_init(); + + uip_ipaddr(ipaddr, 192,168,1,82); + uip_sethostaddr(ipaddr); + uip_ipaddr(ipaddr, 192,168,1,2); + uip_setdraddr(ipaddr); + uip_ipaddr(ipaddr, 255,255,255,0); + uip_setnetmask(ipaddr); + + // Initialize the HTTP server. + httpd_init(); + + while(1) + { + uip_len = tapdev_read(uip_buf); + if(uip_len > 0) + { + if(BUF->type == htons(UIP_ETHTYPE_IP)) + { + uip_arp_ipin(); + uip_input(); + /* If the above function invocation resulted in data that + should be sent out on the network, the global variable + uip_len is set to a value > 0. */ + if(uip_len > 0) + { + uip_arp_out(); + tapdev_send(uip_buf,uip_len); + } + } + else if(BUF->type == htons(UIP_ETHTYPE_ARP)) + { + uip_arp_arpin(); + /* If the above function invocation resulted in data that + should be sent out on the network, the global variable + uip_len is set to a value > 0. */ + if(uip_len > 0) + { + tapdev_send(uip_buf,uip_len); + } + } + } + else if(timer_expired(&periodic_timer)) + { + timer_reset(&periodic_timer); + for(i = 0; i < UIP_CONNS; i++) + { + uip_periodic(i); + /* If the above function invocation resulted in data that + should be sent out on the network, the global variable + uip_len is set to a value > 0. */ + if(uip_len > 0) + { + uip_arp_out(); + tapdev_send(uip_buf,uip_len); + } + } +#if UIP_UDP + for(i = 0; i < UIP_UDP_CONNS; i++) { + uip_udp_periodic(i); + /* If the above function invocation resulted in data that + should be sent out on the network, the global variable + uip_len is set to a value > 0. */ + if(uip_len > 0) { + uip_arp_out(); + tapdev_send(); + } + } +#endif /* UIP_UDP */ + /* Call the ARP timer function every 10 seconds. */ + if(timer_expired(&arp_timer)) + { + timer_reset(&arp_timer); + uip_arp_timer(); + } + } + } +} diff --git a/Tester/SW/lib/Drivers/ethernet/ethernet.h b/Tester/SW/lib/Drivers/ethernet/ethernet.h new file mode 100644 index 0000000..347037a --- /dev/null +++ b/Tester/SW/lib/Drivers/ethernet/ethernet.h @@ -0,0 +1,58 @@ +/* --------------------------------------------------------------------------- + * ethernet.h (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Nov 11, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ + +void VIC_SetVectoredIRQ(void(*pIRQSub)(), unsigned int Priority, + unsigned int VicIntSource); + +void ethInit (void); + +#ifndef ETHERNET_H_ +#define ETHERNET_H_ + +#endif /*ETHERNET_H_*/ diff --git a/Tester/SW/lib/Drivers/ethernet/httpd/http-strings.c b/Tester/SW/lib/Drivers/ethernet/httpd/http-strings.c new file mode 100644 index 0000000..0952244 --- /dev/null +++ b/Tester/SW/lib/Drivers/ethernet/httpd/http-strings.c @@ -0,0 +1,102 @@ +const char http_http[8] = +/* "http://" */ +{0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, }; +const char http_200[5] = +/* "200 " */ +{0x32, 0x30, 0x30, 0x20, }; +const char http_301[5] = +/* "301 " */ +{0x33, 0x30, 0x31, 0x20, }; +const char http_302[5] = +/* "302 " */ +{0x33, 0x30, 0x32, 0x20, }; +const char http_get[5] = +/* "GET " */ +{0x47, 0x45, 0x54, 0x20, }; +const char http_10[9] = +/* "HTTP/1.0" */ +{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, }; +const char http_11[9] = +/* "HTTP/1.1" */ +{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x31, }; +const char http_content_type[15] = +/* "content-type: " */ +{0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, }; +const char http_texthtml[10] = +/* "text/html" */ +{0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, }; +const char http_location[11] = +/* "location: " */ +{0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, }; +const char http_host[7] = +/* "host: " */ +{0x68, 0x6f, 0x73, 0x74, 0x3a, 0x20, }; +const char http_crnl[3] = +/* "\r\n" */ +{0xd, 0xa, }; +const char http_index_html[12] = +/* "/index.html" */ +{0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x6c, }; +const char http_404_html[10] = +/* "/404.html" */ +{0x2f, 0x34, 0x30, 0x34, 0x2e, 0x68, 0x74, 0x6d, 0x6c, }; +const char http_referer[9] = +/* "Referer:" */ +{0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x72, 0x3a, }; +const char http_header_200[84] = +/* "HTTP/1.0 200 OK\r\nServer: uIP/1.0 http://www.sics.se/~adam/uip/\r\nConnection: close\r\n" */ +{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32, 0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x3a, 0x20, 0x75, 0x49, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x69, 0x63, 0x73, 0x2e, 0x73, 0x65, 0x2f, 0x7e, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x75, 0x69, 0x70, 0x2f, 0xd, 0xa, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0xd, 0xa, }; +const char http_header_404[91] = +/* "HTTP/1.0 404 Not found\r\nServer: uIP/1.0 http://www.sics.se/~adam/uip/\r\nConnection: close\r\n" */ +{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x34, 0x30, 0x34, 0x20, 0x4e, 0x6f, 0x74, 0x20, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0xd, 0xa, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x3a, 0x20, 0x75, 0x49, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x69, 0x63, 0x73, 0x2e, 0x73, 0x65, 0x2f, 0x7e, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x75, 0x69, 0x70, 0x2f, 0xd, 0xa, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0xd, 0xa, }; +const char http_content_type_plain[29] = +/* "Content-type: text/plain\r\n\r\n" */ +{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x70, 0x6c, 0x61, 0x69, 0x6e, 0xd, 0xa, 0xd, 0xa, }; +const char http_content_type_html[28] = +/* "Content-type: text/html\r\n\r\n" */ +{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0xd, 0xa, 0xd, 0xa, }; +const char http_content_type_css [27] = +/* "Content-type: text/css\r\n\r\n" */ +{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x63, 0x73, 0x73, 0xd, 0xa, 0xd, 0xa, }; +const char http_content_type_text[28] = +/* "Content-type: text/text\r\n\r\n" */ +{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x74, 0x65, 0x78, 0x74, 0xd, 0xa, 0xd, 0xa, }; +const char http_content_type_png [28] = +/* "Content-type: image/png\r\n\r\n" */ +{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x70, 0x6e, 0x67, 0xd, 0xa, 0xd, 0xa, }; +const char http_content_type_gif [28] = +/* "Content-type: image/gif\r\n\r\n" */ +{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x67, 0x69, 0x66, 0xd, 0xa, 0xd, 0xa, }; +const char http_content_type_jpg [29] = +/* "Content-type: image/jpeg\r\n\r\n" */ +{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x6a, 0x70, 0x65, 0x67, 0xd, 0xa, 0xd, 0xa, }; +const char http_content_type_binary[43] = +/* "Content-type: application/octet-stream\r\n\r\n" */ +{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x6f, 0x63, 0x74, 0x65, 0x74, 0x2d, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0xd, 0xa, 0xd, 0xa, }; +const char http_html[6] = +/* ".html" */ +{0x2e, 0x68, 0x74, 0x6d, 0x6c, }; +const char http_shtml[7] = +/* ".shtml" */ +{0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, }; +const char http_htm[5] = +/* ".htm" */ +{0x2e, 0x68, 0x74, 0x6d, }; +const char http_css[5] = +/* ".css" */ +{0x2e, 0x63, 0x73, 0x73, }; +const char http_png[5] = +/* ".png" */ +{0x2e, 0x70, 0x6e, 0x67, }; +const char http_gif[5] = +/* ".gif" */ +{0x2e, 0x67, 0x69, 0x66, }; +const char http_jpg[5] = +/* ".jpg" */ +{0x2e, 0x6a, 0x70, 0x67, }; +const char http_text[5] = +/* ".txt" */ +{0x2e, 0x74, 0x78, 0x74, }; +const char http_txt[5] = +/* ".txt" */ +{0x2e, 0x74, 0x78, 0x74, }; diff --git a/Tester/SW/lib/Drivers/ethernet/httpd/http-strings.h b/Tester/SW/lib/Drivers/ethernet/httpd/http-strings.h new file mode 100644 index 0000000..acbe7e1 --- /dev/null +++ b/Tester/SW/lib/Drivers/ethernet/httpd/http-strings.h @@ -0,0 +1,34 @@ +extern const char http_http[8]; +extern const char http_200[5]; +extern const char http_301[5]; +extern const char http_302[5]; +extern const char http_get[5]; +extern const char http_10[9]; +extern const char http_11[9]; +extern const char http_content_type[15]; +extern const char http_texthtml[10]; +extern const char http_location[11]; +extern const char http_host[7]; +extern const char http_crnl[3]; +extern const char http_index_html[12]; +extern const char http_404_html[10]; +extern const char http_referer[9]; +extern const char http_header_200[84]; +extern const char http_header_404[91]; +extern const char http_content_type_plain[29]; +extern const char http_content_type_html[28]; +extern const char http_content_type_css [27]; +extern const char http_content_type_text[28]; +extern const char http_content_type_png [28]; +extern const char http_content_type_gif [28]; +extern const char http_content_type_jpg [29]; +extern const char http_content_type_binary[43]; +extern const char http_html[6]; +extern const char http_shtml[7]; +extern const char http_htm[5]; +extern const char http_css[5]; +extern const char http_png[5]; +extern const char http_gif[5]; +extern const char http_jpg[5]; +extern const char http_text[5]; +extern const char http_txt[5]; diff --git a/Tester/SW/lib/Drivers/ethernet/httpd/httpd-cgi.c b/Tester/SW/lib/Drivers/ethernet/httpd/httpd-cgi.c new file mode 100644 index 0000000..57d38c6 --- /dev/null +++ b/Tester/SW/lib/Drivers/ethernet/httpd/httpd-cgi.c @@ -0,0 +1,203 @@ +/** + * \addtogroup httpd + * @{ + */ + +/** + * \file + * Web server script interface + * \author + * Adam Dunkels + * + */ + +/* + * Copyright (c) 2001-2006, Adam Dunkels. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This file is part of the uIP TCP/IP stack. + * + * $Id: httpd-cgi.c,v 1.1.2.3 2006/12/04 18:52:39 fredrikh Exp $ + * + */ + +#include "uip.h" +#include "psock.h" +#include "httpd.h" +#include "httpd-cgi.h" +#include "httpd-fs.h" + +#include +#include + +HTTPD_CGI_CALL(file, "file-stats", file_stats); +HTTPD_CGI_CALL(tcp, "tcp-connections", tcp_stats); +HTTPD_CGI_CALL(net, "net-stats", net_stats); + +static const struct httpd_cgi_call *calls[] = { &file, &tcp, &net, NULL }; + +/*---------------------------------------------------------------------------*/ +static +PT_THREAD(nullfunction(struct httpd_state *s, char *ptr)) +{ + PSOCK_BEGIN(&s->sout); + PSOCK_END(&s->sout); +} +/*---------------------------------------------------------------------------*/ +httpd_cgifunction +httpd_cgi(char *name) +{ + const struct httpd_cgi_call **f; + + /* Find the matching name in the table, return the function. */ + for(f = calls; *f != NULL; ++f) { + if(strncmp((*f)->name, name, strlen((*f)->name)) == 0) { + return (*f)->function; + } + } + return nullfunction; +} +/*---------------------------------------------------------------------------*/ +static unsigned short +generate_file_stats(void *arg) +{ + char *f = (char *)arg; + return snprintf((char *)uip_appdata, UIP_APPDATA_SIZE, "%5u", httpd_fs_count(f)); +} +/*---------------------------------------------------------------------------*/ +static +PT_THREAD(file_stats(struct httpd_state *s, char *ptr)) +{ + PSOCK_BEGIN(&s->sout); + + PSOCK_GENERATOR_SEND(&s->sout, generate_file_stats, strchr(ptr, ' ') + 1); + + PSOCK_END(&s->sout); +} +/*---------------------------------------------------------------------------*/ +static const char closed[] = /* "CLOSED",*/ +{0x43, 0x4c, 0x4f, 0x53, 0x45, 0x44, 0}; +static const char syn_rcvd[] = /* "SYN-RCVD",*/ +{0x53, 0x59, 0x4e, 0x2d, 0x52, 0x43, 0x56, + 0x44, 0}; +static const char syn_sent[] = /* "SYN-SENT",*/ +{0x53, 0x59, 0x4e, 0x2d, 0x53, 0x45, 0x4e, + 0x54, 0}; +static const char established[] = /* "ESTABLISHED",*/ +{0x45, 0x53, 0x54, 0x41, 0x42, 0x4c, 0x49, 0x53, 0x48, + 0x45, 0x44, 0}; +static const char fin_wait_1[] = /* "FIN-WAIT-1",*/ +{0x46, 0x49, 0x4e, 0x2d, 0x57, 0x41, 0x49, + 0x54, 0x2d, 0x31, 0}; +static const char fin_wait_2[] = /* "FIN-WAIT-2",*/ +{0x46, 0x49, 0x4e, 0x2d, 0x57, 0x41, 0x49, + 0x54, 0x2d, 0x32, 0}; +static const char closing[] = /* "CLOSING",*/ +{0x43, 0x4c, 0x4f, 0x53, 0x49, + 0x4e, 0x47, 0}; +static const char time_wait[] = /* "TIME-WAIT,"*/ +{0x54, 0x49, 0x4d, 0x45, 0x2d, 0x57, 0x41, + 0x49, 0x54, 0}; +static const char last_ack[] = /* "LAST-ACK"*/ +{0x4c, 0x41, 0x53, 0x54, 0x2d, 0x41, 0x43, + 0x4b, 0}; + +static const char *states[] = { + closed, + syn_rcvd, + syn_sent, + established, + fin_wait_1, + fin_wait_2, + closing, + time_wait, + last_ack}; + + +static unsigned short +generate_tcp_stats(void *arg) +{ + struct uip_conn *conn; + struct httpd_state *s = (struct httpd_state *)arg; + + conn = &uip_conns[s->count]; + return snprintf((char *)uip_appdata, UIP_APPDATA_SIZE, + "%d%u.%u.%u.%u:%u%s%u%u%c %c\r\n", + htons(conn->lport), + htons(conn->ripaddr[0]) >> 8, + htons(conn->ripaddr[0]) & 0xff, + htons(conn->ripaddr[1]) >> 8, + htons(conn->ripaddr[1]) & 0xff, + htons(conn->rport), + states[conn->tcpstateflags & UIP_TS_MASK], + conn->nrtx, + conn->timer, + (uip_outstanding(conn))? '*':' ', + (uip_stopped(conn))? '!':' '); +} +/*---------------------------------------------------------------------------*/ +static +PT_THREAD(tcp_stats(struct httpd_state *s, char *ptr)) +{ + + PSOCK_BEGIN(&s->sout); + + for(s->count = 0; s->count < UIP_CONNS; ++s->count) { + if((uip_conns[s->count].tcpstateflags & UIP_TS_MASK) != UIP_CLOSED) { + PSOCK_GENERATOR_SEND(&s->sout, generate_tcp_stats, s); + } + } + + PSOCK_END(&s->sout); +} +/*---------------------------------------------------------------------------*/ +static unsigned short +generate_net_stats(void *arg) +{ + struct httpd_state *s = (struct httpd_state *)arg; + return snprintf((char *)uip_appdata, UIP_APPDATA_SIZE, + "%5u\n", ((uip_stats_t *)&uip_stat)[s->count]); +} + +static +PT_THREAD(net_stats(struct httpd_state *s, char *ptr)) +{ + PSOCK_BEGIN(&s->sout); + +#if UIP_STATISTICS + + for(s->count = 0; s->count < sizeof(uip_stat) / sizeof(uip_stats_t); + ++s->count) { + PSOCK_GENERATOR_SEND(&s->sout, generate_net_stats, s); + } + +#endif /* UIP_STATISTICS */ + + PSOCK_END(&s->sout); +} +/*---------------------------------------------------------------------------*/ +/** @} */ diff --git a/Tester/SW/lib/Drivers/ethernet/httpd/httpd-cgi.h b/Tester/SW/lib/Drivers/ethernet/httpd/httpd-cgi.h new file mode 100644 index 0000000..c5d4801 --- /dev/null +++ b/Tester/SW/lib/Drivers/ethernet/httpd/httpd-cgi.h @@ -0,0 +1,84 @@ +/** + * \addtogroup httpd + * @{ + */ + +/** + * \file + * Web server script interface header file + * \author + * Adam Dunkels + * + */ + + + +/* + * Copyright (c) 2001, Adam Dunkels. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This file is part of the uIP TCP/IP stack. + * + * $Id: httpd-cgi.h,v 1.1.2.3 2006/12/04 18:52:39 fredrikh Exp $ + * + */ + +#ifndef __HTTPD_CGI_H__ +#define __HTTPD_CGI_H__ + +#include "psock.h" +#include "httpd.h" + +typedef PT_THREAD((* httpd_cgifunction)(struct httpd_state *, char *)); + +httpd_cgifunction httpd_cgi(char *name); + +struct httpd_cgi_call { + const char *name; + const httpd_cgifunction function; +}; + +/** + * \brief HTTPD CGI function declaration + * \param name The C variable name of the function + * \param str The string name of the function, used in the script file + * \param function A pointer to the function that implements it + * + * This macro is used for declaring a HTTPD CGI + * function. This function is then added to the list of + * HTTPD CGI functions with the httpd_cgi_add() function. + * + * \hideinitializer + */ +#define HTTPD_CGI_CALL(name, str, function) \ +static PT_THREAD(function(struct httpd_state *, char *)); \ +static const struct httpd_cgi_call name = {str, function} + +void httpd_cgi_init(void); +#endif /* __HTTPD_CGI_H__ */ + +/** @} */ diff --git a/Tester/SW/lib/Drivers/ethernet/httpd/httpd-fs.c b/Tester/SW/lib/Drivers/ethernet/httpd/httpd-fs.c new file mode 100644 index 0000000..7f0257a --- /dev/null +++ b/Tester/SW/lib/Drivers/ethernet/httpd/httpd-fs.c @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2001, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + * $Id: httpd-fs.c,v 1.1.2.3 2006/12/04 18:52:39 fredrikh Exp $ + */ + +#include "httpd.h" +#include "httpd-fs.h" +#include "httpd-fsdata.h" + +#ifndef NULL +#define NULL 0 +#endif /* NULL */ + +#include "httpd-fsdata.c" + +#if HTTPD_FS_STATISTICS +static u16_t count[HTTPD_FS_NUMFILES]; +#endif /* HTTPD_FS_STATISTICS */ + +/*-----------------------------------------------------------------------------------*/ +static u8_t +httpd_fs_strcmp(const char *str1, const char *str2) +{ + u8_t i; + i = 0; + loop: + + if(str2[i] == 0 || + str1[i] == '\r' || + str1[i] == '\n') { + return 0; + } + + if(str1[i] != str2[i]) { + return 1; + } + + + ++i; + goto loop; +} +/*-----------------------------------------------------------------------------------*/ +int +httpd_fs_open(const char *name, struct httpd_fs_file *file) +{ +#if HTTPD_FS_STATISTICS + u16_t i = 0; +#endif /* HTTPD_FS_STATISTICS */ + struct httpd_fsdata_file_noconst *f; + + for(f = (struct httpd_fsdata_file_noconst *)HTTPD_FS_ROOT; + f != NULL; + f = (struct httpd_fsdata_file_noconst *)f->next) { + + if(httpd_fs_strcmp(name, f->name) == 0) { + file->data = f->data; + file->len = f->len; +#if HTTPD_FS_STATISTICS + ++count[i]; +#endif /* HTTPD_FS_STATISTICS */ + return 1; + } +#if HTTPD_FS_STATISTICS + ++i; +#endif /* HTTPD_FS_STATISTICS */ + + } + return 0; +} +/*-----------------------------------------------------------------------------------*/ +void +httpd_fs_init(void) +{ +#if HTTPD_FS_STATISTICS + u16_t i; + for(i = 0; i < HTTPD_FS_NUMFILES; i++) { + count[i] = 0; + } +#endif /* HTTPD_FS_STATISTICS */ +} +/*-----------------------------------------------------------------------------------*/ +#if HTTPD_FS_STATISTICS +u16_t httpd_fs_count +(char *name) +{ + struct httpd_fsdata_file_noconst *f; + u16_t i; + + i = 0; + for(f = (struct httpd_fsdata_file_noconst *)HTTPD_FS_ROOT; + f != NULL; + f = (struct httpd_fsdata_file_noconst *)f->next) { + + if(httpd_fs_strcmp(name, f->name) == 0) { + return count[i]; + } + ++i; + } + return 0; +} +#endif /* HTTPD_FS_STATISTICS */ +/*-----------------------------------------------------------------------------------*/ diff --git a/Tester/SW/lib/Drivers/ethernet/httpd/httpd-fs.h b/Tester/SW/lib/Drivers/ethernet/httpd/httpd-fs.h new file mode 100644 index 0000000..3409747 --- /dev/null +++ b/Tester/SW/lib/Drivers/ethernet/httpd/httpd-fs.h @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2001, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + * $Id: httpd-fs.h,v 1.1.2.3 2006/12/04 18:52:39 fredrikh Exp $ + */ +#ifndef __HTTPD_FS_H__ +#define __HTTPD_FS_H__ + +#define HTTPD_FS_STATISTICS 1 + +struct httpd_fs_file { + char *data; + int len; +}; + +/* file must be allocated by caller and will be filled in + by the function. */ +int httpd_fs_open(const char *name, struct httpd_fs_file *file); + +#ifdef HTTPD_FS_STATISTICS +#if HTTPD_FS_STATISTICS == 1 +u16_t httpd_fs_count(char *name); +#endif /* HTTPD_FS_STATISTICS */ +#endif /* HTTPD_FS_STATISTICS */ + +void httpd_fs_init(void); + +#endif /* __HTTPD_FS_H__ */ diff --git a/Tester/SW/lib/Drivers/ethernet/httpd/httpd-fs/404.html b/Tester/SW/lib/Drivers/ethernet/httpd/httpd-fs/404.html new file mode 100644 index 0000000..43e7f4c --- /dev/null +++ b/Tester/SW/lib/Drivers/ethernet/httpd/httpd-fs/404.html @@ -0,0 +1,8 @@ + + +
+

404 - file not found

+

Go here instead.

+
+ + \ No newline at end of file diff --git a/Tester/SW/lib/Drivers/ethernet/httpd/httpd-fs/fade.png b/Tester/SW/lib/Drivers/ethernet/httpd/httpd-fs/fade.png new file mode 100644 index 0000000..a9e69f7 Binary files /dev/null and b/Tester/SW/lib/Drivers/ethernet/httpd/httpd-fs/fade.png differ diff --git a/Tester/SW/lib/Drivers/ethernet/httpd/httpd-fs/files.shtml b/Tester/SW/lib/Drivers/ethernet/httpd/httpd-fs/files.shtml new file mode 100644 index 0000000..361cc1d --- /dev/null +++ b/Tester/SW/lib/Drivers/ethernet/httpd/httpd-fs/files.shtml @@ -0,0 +1,35 @@ +%!: /header.html +

File statistics

+
+ + + + + + + + + + + + + + + +
/index.html%! file-stats /index.html +
/files.shtml%! file-stats /files.shtml +
/tcp.shtml%! file-stats /tcp.shtml +
/stats.shtml%! file-stats /stats.shtml +
/style.css%! file-stats /style.css +
/404.html%! file-stats /404.html +
/fade.png%! file-stats /fade.png +
+
+%!: /footer.html diff --git a/Tester/SW/lib/Drivers/ethernet/httpd/httpd-fs/footer.html b/Tester/SW/lib/Drivers/ethernet/httpd/httpd-fs/footer.html new file mode 100644 index 0000000..290832d --- /dev/null +++ b/Tester/SW/lib/Drivers/ethernet/httpd/httpd-fs/footer.html @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/Tester/SW/lib/Drivers/ethernet/httpd/httpd-fs/header.html b/Tester/SW/lib/Drivers/ethernet/httpd/httpd-fs/header.html new file mode 100644 index 0000000..0c3c4ef --- /dev/null +++ b/Tester/SW/lib/Drivers/ethernet/httpd/httpd-fs/header.html @@ -0,0 +1,18 @@ + + + + Welcome to the uIP web server! + + + + + + +
diff --git a/Tester/SW/lib/Drivers/ethernet/httpd/httpd-fs/index.html b/Tester/SW/lib/Drivers/ethernet/httpd/httpd-fs/index.html new file mode 100644 index 0000000..7af64c8 --- /dev/null +++ b/Tester/SW/lib/Drivers/ethernet/httpd/httpd-fs/index.html @@ -0,0 +1,29 @@ + + + + Welcome to the uIP web server! + + + + + + +
+

+ These web pages are served by a small web server running on top of + the uIP embedded TCP/IP + stack. +

+

+ Click on the links above for web server statistics. +

+ + + diff --git a/Tester/SW/lib/Drivers/ethernet/httpd/httpd-fs/processes.shtml b/Tester/SW/lib/Drivers/ethernet/httpd/httpd-fs/processes.shtml new file mode 100644 index 0000000..be857f9 --- /dev/null +++ b/Tester/SW/lib/Drivers/ethernet/httpd/httpd-fs/processes.shtml @@ -0,0 +1,5 @@ +%!: /header.html +

System processes


+ +%! processes +%!: /footer.html \ No newline at end of file diff --git a/Tester/SW/lib/Drivers/ethernet/httpd/httpd-fs/stats.shtml b/Tester/SW/lib/Drivers/ethernet/httpd/httpd-fs/stats.shtml new file mode 100644 index 0000000..7eb381a --- /dev/null +++ b/Tester/SW/lib/Drivers/ethernet/httpd/httpd-fs/stats.shtml @@ -0,0 +1,31 @@ +%!: /header.html +

Network statistics

+
+
IDNamePriorityPoll handlerEvent handlerProcstate
+
+IP           Packets received
+             Packets sent
+	     Packets dropped
+IP errors    IP version/header length
+             IP length, high byte
+             IP length, low byte
+             IP fragments
+             Header checksum
+             Wrong protocol
+ICMP	     Packets received
+             Packets sent
+             Packets dropped
+             Type errors
+TCP          Packets received
+             Packets sent
+             Packets dropped
+             Checksum errors
+             Data packets without ACKs
+             Resets
+             Retransmissions
+	     No connection avaliable
+	     Connection attempts to closed ports
+
%! net-stats
+
+ +%!: /footer.html diff --git a/Tester/SW/lib/Drivers/ethernet/httpd/httpd-fs/style.css b/Tester/SW/lib/Drivers/ethernet/httpd/httpd-fs/style.css new file mode 100644 index 0000000..089fe84 --- /dev/null +++ b/Tester/SW/lib/Drivers/ethernet/httpd/httpd-fs/style.css @@ -0,0 +1,92 @@ +h1 +{ + text-align: center; + font-size:14pt; + font-family:arial,helvetica; + font-weight:bold; + padding:10px; +} + +body +{ + + background-color: #fffeec; + color:black; + + font-size:8pt; + font-family:arial,helvetica; +} + +.menu +{ + margin: 4px; + width:60%; + + padding:2px; + + border: solid 1px; + background-color: #fffcd2; + text-align:left; + + font-size:9pt; + font-family:arial,helvetica; +} + +div.menubox +{ + width: 25%; + border: 0; + float: left; +text-align: center; +} + +.contentblock +{ + margin: 4px; + width:60%; + + padding:2px; + + border: 1px dotted; + background-color: white; + + font-size:8pt; + font-family:arial,helvetica; + +} + +p.intro +{ + margin-left:20px; + margin-right:20px; + + font-size:10pt; +/* font-weight:bold; */ + font-family:arial,helvetica; +} + +p.clink +{ + font-size:12pt; + font-family:courier,monospace; + text-align:center; +} + +p.clink9 +{ + font-size:9pt; + font-family:courier,monospace; + text-align:center; +} + + +p +{ + padding-left:10px; +} + +p.right +{ + text-align:right; +} + diff --git a/Tester/SW/lib/Drivers/ethernet/httpd/httpd-fs/tcp.shtml b/Tester/SW/lib/Drivers/ethernet/httpd/httpd-fs/tcp.shtml new file mode 100644 index 0000000..2404aed --- /dev/null +++ b/Tester/SW/lib/Drivers/ethernet/httpd/httpd-fs/tcp.shtml @@ -0,0 +1,5 @@ +%!: /header.html +

Current connections


+ +%! tcp-connections +%!: /footer.html \ No newline at end of file diff --git a/Tester/SW/lib/Drivers/ethernet/httpd/httpd-fsdata.c b/Tester/SW/lib/Drivers/ethernet/httpd/httpd-fsdata.c new file mode 100644 index 0000000..5e6387b --- /dev/null +++ b/Tester/SW/lib/Drivers/ethernet/httpd/httpd-fsdata.c @@ -0,0 +1,637 @@ +#include "LPC23xx.h" +#include "types.h" + +#include "httpd-fsdata.h" + + + +static const unsigned char data_processes_shtml[] = { + /* /processes.shtml */ + 0x2f, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x65, 0x73, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0, + 0x25, 0x21, 0x3a, 0x20, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x65, + 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0xa, 0x3c, 0x68, 0x31, + 0x3e, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x20, 0x70, 0x72, + 0x6f, 0x63, 0x65, 0x73, 0x73, 0x65, 0x73, 0x3c, 0x2f, 0x68, + 0x31, 0x3e, 0x3c, 0x62, 0x72, 0x3e, 0x3c, 0x74, 0x61, 0x62, + 0x6c, 0x65, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3d, 0x22, + 0x31, 0x30, 0x30, 0x25, 0x22, 0x3e, 0xa, 0x3c, 0x74, 0x72, + 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x49, 0x44, 0x3c, 0x2f, 0x74, + 0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x4e, 0x61, 0x6d, 0x65, + 0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x50, + 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x3c, 0x2f, 0x74, + 0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x50, 0x6f, 0x6c, 0x6c, + 0x20, 0x68, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x3c, 0x2f, + 0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x45, 0x76, 0x65, + 0x6e, 0x74, 0x20, 0x68, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, + 0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x50, + 0x72, 0x6f, 0x63, 0x73, 0x74, 0x61, 0x74, 0x65, 0x3c, 0x2f, + 0x74, 0x68, 0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 0xa, 0x25, + 0x21, 0x20, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x65, + 0x73, 0xa, 0x25, 0x21, 0x3a, 0x20, 0x2f, 0x66, 0x6f, 0x6f, + 0x74, 0x65, 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0}; + +static const unsigned char data_404_html[] = { + /* /404.html */ + 0x2f, 0x34, 0x30, 0x34, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0, + 0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0xa, 0x20, 0x20, 0x3c, + 0x62, 0x6f, 0x64, 0x79, 0x20, 0x62, 0x67, 0x63, 0x6f, 0x6c, + 0x6f, 0x72, 0x3d, 0x22, 0x77, 0x68, 0x69, 0x74, 0x65, 0x22, + 0x3e, 0xa, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x63, 0x65, 0x6e, + 0x74, 0x65, 0x72, 0x3e, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x3c, 0x68, 0x31, 0x3e, 0x34, 0x30, 0x34, 0x20, 0x2d, + 0x20, 0x66, 0x69, 0x6c, 0x65, 0x20, 0x6e, 0x6f, 0x74, 0x20, + 0x66, 0x6f, 0x75, 0x6e, 0x64, 0x3c, 0x2f, 0x68, 0x31, 0x3e, + 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x68, 0x33, + 0x3e, 0x47, 0x6f, 0x20, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, + 0x66, 0x3d, 0x22, 0x2f, 0x22, 0x3e, 0x68, 0x65, 0x72, 0x65, + 0x3c, 0x2f, 0x61, 0x3e, 0x20, 0x69, 0x6e, 0x73, 0x74, 0x65, + 0x61, 0x64, 0x2e, 0x3c, 0x2f, 0x68, 0x33, 0x3e, 0xa, 0x20, + 0x20, 0x20, 0x20, 0x3c, 0x2f, 0x63, 0x65, 0x6e, 0x74, 0x65, + 0x72, 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x2f, 0x62, 0x6f, 0x64, + 0x79, 0x3e, 0xa, 0x3c, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x3e, +0}; + +static const unsigned char data_files_shtml[] = { + /* /files.shtml */ + 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0, + 0x25, 0x21, 0x3a, 0x20, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x65, + 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0xa, 0x3c, 0x68, 0x31, + 0x3e, 0x46, 0x69, 0x6c, 0x65, 0x20, 0x73, 0x74, 0x61, 0x74, + 0x69, 0x73, 0x74, 0x69, 0x63, 0x73, 0x3c, 0x2f, 0x68, 0x31, + 0x3e, 0xa, 0x3c, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3e, + 0xa, 0x3c, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x77, 0x69, + 0x64, 0x74, 0x68, 0x3d, 0x22, 0x33, 0x30, 0x30, 0x22, 0x3e, + 0xa, 0x3c, 0x74, 0x72, 0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c, + 0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x69, + 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0x22, + 0x3e, 0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, + 0x6d, 0x6c, 0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x74, 0x64, + 0x3e, 0xa, 0x3c, 0x74, 0x64, 0x3e, 0x25, 0x21, 0x20, 0x66, + 0x69, 0x6c, 0x65, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x73, 0x20, + 0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, + 0x6c, 0xa, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x74, 0x64, + 0x3e, 0x3c, 0x69, 0x6d, 0x67, 0x20, 0x73, 0x72, 0x63, 0x3d, + 0x22, 0x2f, 0x66, 0x61, 0x64, 0x65, 0x2e, 0x70, 0x6e, 0x67, + 0x22, 0x20, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x3d, 0x31, + 0x30, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3d, 0x25, 0x21, + 0x20, 0x66, 0x69, 0x6c, 0x65, 0x2d, 0x73, 0x74, 0x61, 0x74, + 0x73, 0x20, 0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, + 0x74, 0x6d, 0x6c, 0xa, 0x3e, 0x20, 0x3c, 0x2f, 0x74, 0x64, + 0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 0xa, 0x3c, 0x74, 0x72, + 0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x61, 0x20, 0x68, 0x72, + 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x73, + 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x2f, 0x66, + 0x69, 0x6c, 0x65, 0x73, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, + 0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0xa, + 0x3c, 0x74, 0x64, 0x3e, 0x25, 0x21, 0x20, 0x66, 0x69, 0x6c, + 0x65, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x73, 0x20, 0x2f, 0x66, + 0x69, 0x6c, 0x65, 0x73, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, + 0xa, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x74, 0x64, 0x3e, + 0x3c, 0x69, 0x6d, 0x67, 0x20, 0x73, 0x72, 0x63, 0x3d, 0x22, + 0x2f, 0x66, 0x61, 0x64, 0x65, 0x2e, 0x70, 0x6e, 0x67, 0x22, + 0x20, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x3d, 0x31, 0x30, + 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3d, 0x25, 0x21, 0x20, + 0x66, 0x69, 0x6c, 0x65, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x73, + 0x20, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x2e, 0x73, 0x68, + 0x74, 0x6d, 0x6c, 0xa, 0x3e, 0x20, 0x3c, 0x2f, 0x74, 0x64, + 0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 0xa, 0x3c, 0x74, 0x72, + 0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x61, 0x20, 0x68, 0x72, + 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x74, 0x63, 0x70, 0x2e, 0x73, + 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x2f, 0x74, 0x63, 0x70, + 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0x3c, 0x2f, 0x61, 0x3e, + 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0xa, 0x3c, 0x74, 0x64, 0x3e, + 0x25, 0x21, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x2d, 0x73, 0x74, + 0x61, 0x74, 0x73, 0x20, 0x2f, 0x74, 0x63, 0x70, 0x2e, 0x73, + 0x68, 0x74, 0x6d, 0x6c, 0xa, 0x3c, 0x2f, 0x74, 0x64, 0x3e, + 0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x69, 0x6d, 0x67, 0x20, 0x73, + 0x72, 0x63, 0x3d, 0x22, 0x2f, 0x66, 0x61, 0x64, 0x65, 0x2e, + 0x70, 0x6e, 0x67, 0x22, 0x20, 0x68, 0x65, 0x69, 0x67, 0x68, + 0x74, 0x3d, 0x31, 0x30, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, + 0x3d, 0x25, 0x21, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x2d, 0x73, + 0x74, 0x61, 0x74, 0x73, 0x20, 0x2f, 0x74, 0x63, 0x70, 0x2e, + 0x73, 0x68, 0x74, 0x6d, 0x6c, 0xa, 0x3e, 0x20, 0x3c, 0x2f, + 0x74, 0x64, 0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 0xa, 0x3c, + 0x74, 0x72, 0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x61, 0x20, + 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x73, 0x74, 0x61, + 0x74, 0x73, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, + 0x2f, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x73, 0x68, 0x74, + 0x6d, 0x6c, 0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x74, 0x64, + 0x3e, 0xa, 0x3c, 0x74, 0x64, 0x3e, 0x25, 0x21, 0x20, 0x66, + 0x69, 0x6c, 0x65, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x73, 0x20, + 0x2f, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x73, 0x68, 0x74, + 0x6d, 0x6c, 0xa, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x74, + 0x64, 0x3e, 0x3c, 0x69, 0x6d, 0x67, 0x20, 0x73, 0x72, 0x63, + 0x3d, 0x22, 0x2f, 0x66, 0x61, 0x64, 0x65, 0x2e, 0x70, 0x6e, + 0x67, 0x22, 0x20, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x3d, + 0x31, 0x30, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3d, 0x25, + 0x21, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x2d, 0x73, 0x74, 0x61, + 0x74, 0x73, 0x20, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, + 0x73, 0x68, 0x74, 0x6d, 0x6c, 0xa, 0x3e, 0x20, 0x3c, 0x2f, + 0x74, 0x64, 0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 0xa, 0x3c, + 0x74, 0x72, 0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x61, 0x20, + 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x73, 0x74, 0x79, + 0x6c, 0x65, 0x2e, 0x63, 0x73, 0x73, 0x22, 0x3e, 0x2f, 0x73, + 0x74, 0x79, 0x6c, 0x65, 0x2e, 0x63, 0x73, 0x73, 0x3c, 0x2f, + 0x61, 0x3e, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0xa, 0x3c, 0x74, + 0x64, 0x3e, 0x25, 0x21, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x2d, + 0x73, 0x74, 0x61, 0x74, 0x73, 0x20, 0x2f, 0x73, 0x74, 0x79, + 0x6c, 0x65, 0x2e, 0x63, 0x73, 0x73, 0xa, 0x3c, 0x2f, 0x74, + 0x64, 0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x69, 0x6d, 0x67, + 0x20, 0x73, 0x72, 0x63, 0x3d, 0x22, 0x2f, 0x66, 0x61, 0x64, + 0x65, 0x2e, 0x70, 0x6e, 0x67, 0x22, 0x20, 0x68, 0x65, 0x69, + 0x67, 0x68, 0x74, 0x3d, 0x31, 0x30, 0x20, 0x77, 0x69, 0x64, + 0x74, 0x68, 0x3d, 0x25, 0x21, 0x20, 0x66, 0x69, 0x6c, 0x65, + 0x2d, 0x73, 0x74, 0x61, 0x74, 0x73, 0x20, 0x2f, 0x73, 0x74, + 0x79, 0x6c, 0x65, 0x2e, 0x63, 0x73, 0x73, 0xa, 0x3e, 0x20, + 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, + 0xa, 0x3c, 0x74, 0x72, 0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c, + 0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x34, + 0x30, 0x34, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x2f, + 0x34, 0x30, 0x34, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0x3c, 0x2f, + 0x61, 0x3e, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0xa, 0x3c, 0x74, + 0x64, 0x3e, 0x25, 0x21, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x2d, + 0x73, 0x74, 0x61, 0x74, 0x73, 0x20, 0x2f, 0x34, 0x30, 0x34, + 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0xa, 0x3c, 0x2f, 0x74, 0x64, + 0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x69, 0x6d, 0x67, 0x20, + 0x73, 0x72, 0x63, 0x3d, 0x22, 0x2f, 0x66, 0x61, 0x64, 0x65, + 0x2e, 0x70, 0x6e, 0x67, 0x22, 0x20, 0x68, 0x65, 0x69, 0x67, + 0x68, 0x74, 0x3d, 0x31, 0x30, 0x20, 0x77, 0x69, 0x64, 0x74, + 0x68, 0x3d, 0x25, 0x21, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x2d, + 0x73, 0x74, 0x61, 0x74, 0x73, 0x20, 0x2f, 0x34, 0x30, 0x34, + 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0xa, 0x3e, 0x20, 0x3c, 0x2f, + 0x74, 0x64, 0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 0xa, 0x3c, + 0x74, 0x72, 0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x61, 0x20, + 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x66, 0x61, 0x64, + 0x65, 0x2e, 0x70, 0x6e, 0x67, 0x22, 0x3e, 0x2f, 0x66, 0x61, + 0x64, 0x65, 0x2e, 0x70, 0x6e, 0x67, 0x3c, 0x2f, 0x61, 0x3e, + 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0xa, 0x3c, 0x74, 0x64, 0x3e, + 0x25, 0x21, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x2d, 0x73, 0x74, + 0x61, 0x74, 0x73, 0x20, 0x2f, 0x66, 0x61, 0x64, 0x65, 0x2e, + 0x70, 0x6e, 0x67, 0xa, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, + 0x74, 0x64, 0x3e, 0x3c, 0x69, 0x6d, 0x67, 0x20, 0x73, 0x72, + 0x63, 0x3d, 0x22, 0x2f, 0x66, 0x61, 0x64, 0x65, 0x2e, 0x70, + 0x6e, 0x67, 0x22, 0x20, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, + 0x3d, 0x31, 0x30, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3d, + 0x25, 0x21, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x2d, 0x73, 0x74, + 0x61, 0x74, 0x73, 0x20, 0x2f, 0x66, 0x61, 0x64, 0x65, 0x2e, + 0x70, 0x6e, 0x67, 0xa, 0x3e, 0x20, 0x3c, 0x2f, 0x74, 0x64, + 0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 0xa, 0x3c, 0x2f, 0x74, + 0x61, 0x62, 0x6c, 0x65, 0x3e, 0xa, 0x3c, 0x2f, 0x63, 0x65, + 0x6e, 0x74, 0x65, 0x72, 0x3e, 0xa, 0x25, 0x21, 0x3a, 0x20, + 0x2f, 0x66, 0x6f, 0x6f, 0x74, 0x65, 0x72, 0x2e, 0x68, 0x74, + 0x6d, 0x6c, 0xa, 0}; + +static const unsigned char data_footer_html[] = { + /* /footer.html */ + 0x2f, 0x66, 0x6f, 0x6f, 0x74, 0x65, 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0, + 0x20, 0x20, 0x3c, 0x2f, 0x62, 0x6f, 0x64, 0x79, 0x3e, 0xa, + 0x3c, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0}; + +static const unsigned char data_header_html[] = { + /* /header.html */ + 0x2f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0, + 0x3c, 0x21, 0x44, 0x4f, 0x43, 0x54, 0x59, 0x50, 0x45, 0x20, + 0x48, 0x54, 0x4d, 0x4c, 0x20, 0x50, 0x55, 0x42, 0x4c, 0x49, + 0x43, 0x20, 0x22, 0x2d, 0x2f, 0x2f, 0x57, 0x33, 0x43, 0x2f, + 0x2f, 0x44, 0x54, 0x44, 0x20, 0x48, 0x54, 0x4d, 0x4c, 0x20, + 0x34, 0x2e, 0x30, 0x31, 0x20, 0x54, 0x72, 0x61, 0x6e, 0x73, + 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x2f, 0x2f, 0x45, + 0x4e, 0x22, 0x20, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, + 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x77, 0x33, 0x2e, 0x6f, 0x72, + 0x67, 0x2f, 0x54, 0x52, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x34, + 0x2f, 0x6c, 0x6f, 0x6f, 0x73, 0x65, 0x2e, 0x64, 0x74, 0x64, + 0x22, 0x3e, 0xa, 0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0xa, + 0x20, 0x20, 0x3c, 0x68, 0x65, 0x61, 0x64, 0x3e, 0xa, 0x20, + 0x20, 0x20, 0x20, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, + 0x57, 0x65, 0x6c, 0x63, 0x6f, 0x6d, 0x65, 0x20, 0x74, 0x6f, + 0x20, 0x74, 0x68, 0x65, 0x20, 0x75, 0x49, 0x50, 0x20, 0x77, + 0x65, 0x62, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x21, + 0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0xa, 0x20, + 0x20, 0x20, 0x20, 0x3c, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x72, + 0x65, 0x6c, 0x3d, 0x22, 0x73, 0x74, 0x79, 0x6c, 0x65, 0x73, + 0x68, 0x65, 0x65, 0x74, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, + 0x3d, 0x22, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x63, 0x73, 0x73, + 0x22, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x73, 0x74, + 0x79, 0x6c, 0x65, 0x2e, 0x63, 0x73, 0x73, 0x22, 0x3e, 0x20, + 0x20, 0xa, 0x20, 0x20, 0x3c, 0x2f, 0x68, 0x65, 0x61, 0x64, + 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x62, 0x6f, 0x64, 0x79, 0x20, + 0x62, 0x67, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3d, 0x22, 0x23, + 0x66, 0x66, 0x66, 0x65, 0x65, 0x63, 0x22, 0x20, 0x74, 0x65, + 0x78, 0x74, 0x3d, 0x22, 0x62, 0x6c, 0x61, 0x63, 0x6b, 0x22, + 0x3e, 0xa, 0xa, 0x20, 0x20, 0x3c, 0x64, 0x69, 0x76, 0x20, + 0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x6d, 0x65, 0x6e, + 0x75, 0x22, 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x64, 0x69, 0x76, + 0x20, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x6d, 0x65, + 0x6e, 0x75, 0x62, 0x6f, 0x78, 0x22, 0x3e, 0x3c, 0x61, 0x20, + 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x22, 0x3e, 0x46, + 0x72, 0x6f, 0x6e, 0x74, 0x20, 0x70, 0x61, 0x67, 0x65, 0x3c, + 0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e, 0xa, + 0x20, 0x20, 0x3c, 0x64, 0x69, 0x76, 0x20, 0x63, 0x6c, 0x61, + 0x73, 0x73, 0x3d, 0x22, 0x6d, 0x65, 0x6e, 0x75, 0x62, 0x6f, + 0x78, 0x22, 0x3e, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66, + 0x3d, 0x22, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x2e, 0x73, 0x68, + 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x46, 0x69, 0x6c, 0x65, 0x20, + 0x73, 0x74, 0x61, 0x74, 0x69, 0x73, 0x74, 0x69, 0x63, 0x73, + 0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e, + 0xa, 0x20, 0x20, 0x3c, 0x64, 0x69, 0x76, 0x20, 0x63, 0x6c, + 0x61, 0x73, 0x73, 0x3d, 0x22, 0x6d, 0x65, 0x6e, 0x75, 0x62, + 0x6f, 0x78, 0x22, 0x3e, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, + 0x66, 0x3d, 0x22, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x73, + 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x4e, 0x65, 0x74, 0x77, + 0x6f, 0x72, 0x6b, 0x20, 0x73, 0x74, 0x61, 0x74, 0x69, 0x73, + 0x74, 0x69, 0x63, 0x73, 0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x2f, + 0x64, 0x69, 0x76, 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x64, 0x69, + 0x76, 0x20, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x6d, + 0x65, 0x6e, 0x75, 0x62, 0x6f, 0x78, 0x22, 0x3e, 0x3c, 0x61, + 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x74, 0x63, 0x70, + 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x4e, 0x65, + 0x74, 0x77, 0x6f, 0x72, 0x6b, 0xa, 0x20, 0x20, 0x63, 0x6f, + 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x3c, + 0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e, 0xa, + 0x20, 0x20, 0x3c, 0x62, 0x72, 0x3e, 0xa, 0x20, 0x20, 0x3c, + 0x2f, 0x64, 0x69, 0x76, 0x3e, 0xa, 0x20, 0x20, 0xa, 0x20, + 0x20, 0x3c, 0x64, 0x69, 0x76, 0x20, 0x63, 0x6c, 0x61, 0x73, + 0x73, 0x3d, 0x22, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, + 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x3e, 0xa, 0}; + +static const unsigned char data_index_html[] = { + /* /index.html */ + 0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0, + 0x3c, 0x21, 0x44, 0x4f, 0x43, 0x54, 0x59, 0x50, 0x45, 0x20, + 0x48, 0x54, 0x4d, 0x4c, 0x20, 0x50, 0x55, 0x42, 0x4c, 0x49, + 0x43, 0x20, 0x22, 0x2d, 0x2f, 0x2f, 0x57, 0x33, 0x43, 0x2f, + 0x2f, 0x44, 0x54, 0x44, 0x20, 0x48, 0x54, 0x4d, 0x4c, 0x20, + 0x34, 0x2e, 0x30, 0x31, 0x20, 0x54, 0x72, 0x61, 0x6e, 0x73, + 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x2f, 0x2f, 0x45, + 0x4e, 0x22, 0x20, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, + 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x77, 0x33, 0x2e, 0x6f, 0x72, + 0x67, 0x2f, 0x54, 0x52, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x34, + 0x2f, 0x6c, 0x6f, 0x6f, 0x73, 0x65, 0x2e, 0x64, 0x74, 0x64, + 0x22, 0x3e, 0xa, 0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0xa, + 0x20, 0x20, 0x3c, 0x68, 0x65, 0x61, 0x64, 0x3e, 0xa, 0x20, + 0x20, 0x20, 0x20, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, + 0x57, 0x65, 0x6c, 0x63, 0x6f, 0x6d, 0x65, 0x20, 0x74, 0x6f, + 0x20, 0x74, 0x68, 0x65, 0x20, 0x75, 0x49, 0x50, 0x20, 0x77, + 0x65, 0x62, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x21, + 0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0xa, 0x20, + 0x20, 0x20, 0x20, 0x3c, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x72, + 0x65, 0x6c, 0x3d, 0x22, 0x73, 0x74, 0x79, 0x6c, 0x65, 0x73, + 0x68, 0x65, 0x65, 0x74, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, + 0x3d, 0x22, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x63, 0x73, 0x73, + 0x22, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x73, 0x74, + 0x79, 0x6c, 0x65, 0x2e, 0x63, 0x73, 0x73, 0x22, 0x3e, 0x20, + 0x20, 0xa, 0x20, 0x20, 0x3c, 0x2f, 0x68, 0x65, 0x61, 0x64, + 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x62, 0x6f, 0x64, 0x79, 0x20, + 0x62, 0x67, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3d, 0x22, 0x23, + 0x66, 0x66, 0x66, 0x65, 0x65, 0x63, 0x22, 0x20, 0x74, 0x65, + 0x78, 0x74, 0x3d, 0x22, 0x62, 0x6c, 0x61, 0x63, 0x6b, 0x22, + 0x3e, 0xa, 0xa, 0x20, 0x20, 0x3c, 0x64, 0x69, 0x76, 0x20, + 0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x6d, 0x65, 0x6e, + 0x75, 0x22, 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x64, 0x69, 0x76, + 0x20, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x6d, 0x65, + 0x6e, 0x75, 0x62, 0x6f, 0x78, 0x22, 0x3e, 0x3c, 0x61, 0x20, + 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x22, 0x3e, 0x46, + 0x72, 0x6f, 0x6e, 0x74, 0x20, 0x70, 0x61, 0x67, 0x65, 0x3c, + 0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e, 0xa, + 0x20, 0x20, 0x3c, 0x64, 0x69, 0x76, 0x20, 0x63, 0x6c, 0x61, + 0x73, 0x73, 0x3d, 0x22, 0x6d, 0x65, 0x6e, 0x75, 0x62, 0x6f, + 0x78, 0x22, 0x3e, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66, + 0x3d, 0x22, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x2e, 0x73, 0x68, + 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x46, 0x69, 0x6c, 0x65, 0x20, + 0x73, 0x74, 0x61, 0x74, 0x69, 0x73, 0x74, 0x69, 0x63, 0x73, + 0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e, + 0xa, 0x20, 0x20, 0x3c, 0x64, 0x69, 0x76, 0x20, 0x63, 0x6c, + 0x61, 0x73, 0x73, 0x3d, 0x22, 0x6d, 0x65, 0x6e, 0x75, 0x62, + 0x6f, 0x78, 0x22, 0x3e, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, + 0x66, 0x3d, 0x22, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x73, + 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x4e, 0x65, 0x74, 0x77, + 0x6f, 0x72, 0x6b, 0x20, 0x73, 0x74, 0x61, 0x74, 0x69, 0x73, + 0x74, 0x69, 0x63, 0x73, 0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x2f, + 0x64, 0x69, 0x76, 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x64, 0x69, + 0x76, 0x20, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x6d, + 0x65, 0x6e, 0x75, 0x62, 0x6f, 0x78, 0x22, 0x3e, 0x3c, 0x61, + 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x74, 0x63, 0x70, + 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x4e, 0x65, + 0x74, 0x77, 0x6f, 0x72, 0x6b, 0xa, 0x20, 0x20, 0x63, 0x6f, + 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x3c, + 0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e, 0xa, + 0x20, 0x20, 0x3c, 0x62, 0x72, 0x3e, 0xa, 0x20, 0x20, 0x3c, + 0x2f, 0x64, 0x69, 0x76, 0x3e, 0xa, 0xa, 0x20, 0x20, 0x3c, + 0x64, 0x69, 0x76, 0x20, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, + 0x22, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x62, 0x6c, + 0x6f, 0x63, 0x6b, 0x22, 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x70, + 0x3e, 0xa, 0x20, 0x20, 0x54, 0x68, 0x65, 0x73, 0x65, 0x20, + 0x77, 0x65, 0x62, 0x20, 0x70, 0x61, 0x67, 0x65, 0x73, 0x20, + 0x61, 0x72, 0x65, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 0x64, + 0x20, 0x62, 0x79, 0x20, 0x61, 0x20, 0x73, 0x6d, 0x61, 0x6c, + 0x6c, 0x20, 0x77, 0x65, 0x62, 0x20, 0x73, 0x65, 0x72, 0x76, + 0x65, 0x72, 0x20, 0x72, 0x75, 0x6e, 0x6e, 0x69, 0x6e, 0x67, + 0x20, 0x6f, 0x6e, 0x20, 0x74, 0x6f, 0x70, 0x20, 0x6f, 0x66, + 0xa, 0x20, 0x20, 0x74, 0x68, 0x65, 0x20, 0x3c, 0x61, 0x20, + 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, + 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x69, 0x63, + 0x73, 0x2e, 0x73, 0x65, 0x2f, 0x7e, 0x61, 0x64, 0x61, 0x6d, + 0x2f, 0x75, 0x69, 0x70, 0x2f, 0x22, 0x3e, 0x75, 0x49, 0x50, + 0x20, 0x65, 0x6d, 0x62, 0x65, 0x64, 0x64, 0x65, 0x64, 0x20, + 0x54, 0x43, 0x50, 0x2f, 0x49, 0x50, 0xa, 0x20, 0x20, 0x73, + 0x74, 0x61, 0x63, 0x6b, 0x3c, 0x2f, 0x61, 0x3e, 0x2e, 0xa, + 0x20, 0x20, 0x3c, 0x2f, 0x70, 0x3e, 0xa, 0x20, 0x20, 0x3c, + 0x70, 0x3e, 0xa, 0x20, 0x20, 0x43, 0x6c, 0x69, 0x63, 0x6b, + 0x20, 0x6f, 0x6e, 0x20, 0x74, 0x68, 0x65, 0x20, 0x6c, 0x69, + 0x6e, 0x6b, 0x73, 0x20, 0x61, 0x62, 0x6f, 0x76, 0x65, 0x20, + 0x66, 0x6f, 0x72, 0x20, 0x77, 0x65, 0x62, 0x20, 0x73, 0x65, + 0x72, 0x76, 0x65, 0x72, 0x20, 0x73, 0x74, 0x61, 0x74, 0x69, + 0x73, 0x74, 0x69, 0x63, 0x73, 0x2e, 0xa, 0x20, 0x20, 0x3c, + 0x2f, 0x70, 0x3e, 0xa, 0xa, 0x20, 0x20, 0x3c, 0x2f, 0x62, + 0x6f, 0x64, 0x79, 0x3e, 0xa, 0x3c, 0x2f, 0x68, 0x74, 0x6d, + 0x6c, 0x3e, 0xa, 0}; + +static const unsigned char data_style_css[] = { + /* /style.css */ + 0x2f, 0x73, 0x74, 0x79, 0x6c, 0x65, 0x2e, 0x63, 0x73, 0x73, 0, + 0x68, 0x31, 0x20, 0xa, 0x7b, 0xa, 0x20, 0x20, 0x74, 0x65, + 0x78, 0x74, 0x2d, 0x61, 0x6c, 0x69, 0x67, 0x6e, 0x3a, 0x20, + 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3b, 0xa, 0x20, 0x20, + 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, + 0x31, 0x34, 0x70, 0x74, 0x3b, 0xa, 0x20, 0x20, 0x66, 0x6f, + 0x6e, 0x74, 0x2d, 0x66, 0x61, 0x6d, 0x69, 0x6c, 0x79, 0x3a, + 0x61, 0x72, 0x69, 0x61, 0x6c, 0x2c, 0x68, 0x65, 0x6c, 0x76, + 0x65, 0x74, 0x69, 0x63, 0x61, 0x3b, 0xa, 0x20, 0x20, 0x66, + 0x6f, 0x6e, 0x74, 0x2d, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, + 0x3a, 0x62, 0x6f, 0x6c, 0x64, 0x3b, 0xa, 0x20, 0x20, 0x70, + 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x3a, 0x31, 0x30, 0x70, + 0x78, 0x3b, 0x20, 0xa, 0x7d, 0xa, 0xa, 0x62, 0x6f, 0x64, + 0x79, 0xa, 0x7b, 0xa, 0xa, 0x20, 0x20, 0x62, 0x61, 0x63, + 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x2d, 0x63, 0x6f, + 0x6c, 0x6f, 0x72, 0x3a, 0x20, 0x23, 0x66, 0x66, 0x66, 0x65, + 0x65, 0x63, 0x3b, 0xa, 0x20, 0x20, 0x63, 0x6f, 0x6c, 0x6f, + 0x72, 0x3a, 0x62, 0x6c, 0x61, 0x63, 0x6b, 0x3b, 0xa, 0xa, + 0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, + 0x65, 0x3a, 0x38, 0x70, 0x74, 0x3b, 0xa, 0x20, 0x20, 0x66, + 0x6f, 0x6e, 0x74, 0x2d, 0x66, 0x61, 0x6d, 0x69, 0x6c, 0x79, + 0x3a, 0x61, 0x72, 0x69, 0x61, 0x6c, 0x2c, 0x68, 0x65, 0x6c, + 0x76, 0x65, 0x74, 0x69, 0x63, 0x61, 0x3b, 0xa, 0x7d, 0xa, + 0xa, 0x2e, 0x6d, 0x65, 0x6e, 0x75, 0xa, 0x7b, 0xa, 0x20, + 0x20, 0x6d, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x3a, 0x20, 0x34, + 0x70, 0x78, 0x3b, 0xa, 0x20, 0x20, 0x77, 0x69, 0x64, 0x74, + 0x68, 0x3a, 0x36, 0x30, 0x25, 0x3b, 0xa, 0xa, 0x20, 0x20, + 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x3a, 0x32, 0x70, + 0x78, 0x3b, 0xa, 0x9, 0xa, 0x20, 0x20, 0x62, 0x6f, 0x72, + 0x64, 0x65, 0x72, 0x3a, 0x20, 0x73, 0x6f, 0x6c, 0x69, 0x64, + 0x20, 0x31, 0x70, 0x78, 0x3b, 0xa, 0x20, 0x20, 0x62, 0x61, + 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x2d, 0x63, + 0x6f, 0x6c, 0x6f, 0x72, 0x3a, 0x20, 0x23, 0x66, 0x66, 0x66, + 0x63, 0x64, 0x32, 0x3b, 0xa, 0x20, 0x20, 0x74, 0x65, 0x78, + 0x74, 0x2d, 0x61, 0x6c, 0x69, 0x67, 0x6e, 0x3a, 0x6c, 0x65, + 0x66, 0x74, 0x3b, 0xa, 0x20, 0x20, 0xa, 0x20, 0x20, 0x66, + 0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x39, + 0x70, 0x74, 0x3b, 0xa, 0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, + 0x2d, 0x66, 0x61, 0x6d, 0x69, 0x6c, 0x79, 0x3a, 0x61, 0x72, + 0x69, 0x61, 0x6c, 0x2c, 0x68, 0x65, 0x6c, 0x76, 0x65, 0x74, + 0x69, 0x63, 0x61, 0x3b, 0x20, 0x20, 0xa, 0x7d, 0xa, 0xa, + 0x64, 0x69, 0x76, 0x2e, 0x6d, 0x65, 0x6e, 0x75, 0x62, 0x6f, + 0x78, 0xa, 0x7b, 0xa, 0x20, 0x20, 0x77, 0x69, 0x64, 0x74, + 0x68, 0x3a, 0x20, 0x32, 0x35, 0x25, 0x3b, 0xa, 0x20, 0x20, + 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x3a, 0x20, 0x30, 0x3b, + 0xa, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x3a, 0x20, + 0x6c, 0x65, 0x66, 0x74, 0x3b, 0xa, 0x74, 0x65, 0x78, 0x74, + 0x2d, 0x61, 0x6c, 0x69, 0x67, 0x6e, 0x3a, 0x20, 0x63, 0x65, + 0x6e, 0x74, 0x65, 0x72, 0x3b, 0xa, 0x7d, 0xa, 0xa, 0x2e, + 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x62, 0x6c, 0x6f, + 0x63, 0x6b, 0xa, 0x7b, 0x20, 0x20, 0xa, 0x20, 0x20, 0x6d, + 0x61, 0x72, 0x67, 0x69, 0x6e, 0x3a, 0x20, 0x34, 0x70, 0x78, + 0x3b, 0xa, 0x20, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3a, + 0x36, 0x30, 0x25, 0x3b, 0xa, 0xa, 0x20, 0x20, 0x70, 0x61, + 0x64, 0x64, 0x69, 0x6e, 0x67, 0x3a, 0x32, 0x70, 0x78, 0x3b, + 0xa, 0xa, 0x20, 0x20, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, + 0x3a, 0x20, 0x31, 0x70, 0x78, 0x20, 0x64, 0x6f, 0x74, 0x74, + 0x65, 0x64, 0x3b, 0xa, 0x20, 0x20, 0x62, 0x61, 0x63, 0x6b, + 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x2d, 0x63, 0x6f, 0x6c, + 0x6f, 0x72, 0x3a, 0x20, 0x77, 0x68, 0x69, 0x74, 0x65, 0x3b, + 0xa, 0xa, 0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, + 0x69, 0x7a, 0x65, 0x3a, 0x38, 0x70, 0x74, 0x3b, 0xa, 0x20, + 0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x66, 0x61, 0x6d, 0x69, + 0x6c, 0x79, 0x3a, 0x61, 0x72, 0x69, 0x61, 0x6c, 0x2c, 0x68, + 0x65, 0x6c, 0x76, 0x65, 0x74, 0x69, 0x63, 0x61, 0x3b, 0x20, + 0x20, 0xa, 0xa, 0x7d, 0xa, 0xa, 0x70, 0x2e, 0x69, 0x6e, + 0x74, 0x72, 0x6f, 0xa, 0x7b, 0xa, 0x20, 0x20, 0x6d, 0x61, + 0x72, 0x67, 0x69, 0x6e, 0x2d, 0x6c, 0x65, 0x66, 0x74, 0x3a, + 0x32, 0x30, 0x70, 0x78, 0x3b, 0xa, 0x20, 0x20, 0x6d, 0x61, + 0x72, 0x67, 0x69, 0x6e, 0x2d, 0x72, 0x69, 0x67, 0x68, 0x74, + 0x3a, 0x32, 0x30, 0x70, 0x78, 0x3b, 0xa, 0xa, 0x20, 0x20, + 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, + 0x31, 0x30, 0x70, 0x74, 0x3b, 0xa, 0x2f, 0x2a, 0x20, 0x20, + 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x77, 0x65, 0x69, 0x67, 0x68, + 0x74, 0x3a, 0x62, 0x6f, 0x6c, 0x64, 0x3b, 0x20, 0x2a, 0x2f, + 0xa, 0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x66, 0x61, + 0x6d, 0x69, 0x6c, 0x79, 0x3a, 0x61, 0x72, 0x69, 0x61, 0x6c, + 0x2c, 0x68, 0x65, 0x6c, 0x76, 0x65, 0x74, 0x69, 0x63, 0x61, + 0x3b, 0x20, 0x20, 0xa, 0x7d, 0xa, 0xa, 0x70, 0x2e, 0x63, + 0x6c, 0x69, 0x6e, 0x6b, 0xa, 0x7b, 0xa, 0x20, 0x20, 0x66, + 0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x31, + 0x32, 0x70, 0x74, 0x3b, 0xa, 0x20, 0x20, 0x66, 0x6f, 0x6e, + 0x74, 0x2d, 0x66, 0x61, 0x6d, 0x69, 0x6c, 0x79, 0x3a, 0x63, + 0x6f, 0x75, 0x72, 0x69, 0x65, 0x72, 0x2c, 0x6d, 0x6f, 0x6e, + 0x6f, 0x73, 0x70, 0x61, 0x63, 0x65, 0x3b, 0x20, 0x20, 0xa, + 0x20, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2d, 0x61, 0x6c, 0x69, + 0x67, 0x6e, 0x3a, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3b, + 0xa, 0x7d, 0xa, 0xa, 0x70, 0x2e, 0x63, 0x6c, 0x69, 0x6e, + 0x6b, 0x39, 0xa, 0x7b, 0xa, 0x20, 0x20, 0x66, 0x6f, 0x6e, + 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x39, 0x70, 0x74, + 0x3b, 0xa, 0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x66, + 0x61, 0x6d, 0x69, 0x6c, 0x79, 0x3a, 0x63, 0x6f, 0x75, 0x72, + 0x69, 0x65, 0x72, 0x2c, 0x6d, 0x6f, 0x6e, 0x6f, 0x73, 0x70, + 0x61, 0x63, 0x65, 0x3b, 0x20, 0x20, 0xa, 0x20, 0x20, 0x74, + 0x65, 0x78, 0x74, 0x2d, 0x61, 0x6c, 0x69, 0x67, 0x6e, 0x3a, + 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3b, 0xa, 0x7d, 0xa, + 0xa, 0xa, 0x70, 0xa, 0x7b, 0xa, 0x20, 0x20, 0x70, 0x61, + 0x64, 0x64, 0x69, 0x6e, 0x67, 0x2d, 0x6c, 0x65, 0x66, 0x74, + 0x3a, 0x31, 0x30, 0x70, 0x78, 0x3b, 0xa, 0x7d, 0xa, 0xa, + 0x70, 0x2e, 0x72, 0x69, 0x67, 0x68, 0x74, 0xa, 0x7b, 0xa, + 0x20, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2d, 0x61, 0x6c, 0x69, + 0x67, 0x6e, 0x3a, 0x72, 0x69, 0x67, 0x68, 0x74, 0x3b, 0x20, + 0xa, 0x7d, 0xa, 0xa, 0}; + +static const unsigned char data_tcp_shtml[] = { + /* /tcp.shtml */ + 0x2f, 0x74, 0x63, 0x70, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0, + 0x25, 0x21, 0x3a, 0x20, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x65, + 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0xa, 0x3c, 0x68, 0x31, + 0x3e, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x20, 0x63, + 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, + 0x3c, 0x2f, 0x68, 0x31, 0x3e, 0x3c, 0x62, 0x72, 0x3e, 0x3c, + 0x74, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x77, 0x69, 0x64, 0x74, + 0x68, 0x3d, 0x22, 0x31, 0x30, 0x30, 0x25, 0x22, 0x3e, 0xa, + 0x3c, 0x74, 0x72, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x4c, 0x6f, + 0x63, 0x61, 0x6c, 0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74, + 0x68, 0x3e, 0x52, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x3c, 0x2f, + 0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x53, 0x74, 0x61, + 0x74, 0x65, 0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, + 0x3e, 0x52, 0x65, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x6d, 0x69, + 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x3c, 0x2f, 0x74, 0x68, + 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x54, 0x69, 0x6d, 0x65, 0x72, + 0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x46, + 0x6c, 0x61, 0x67, 0x73, 0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, + 0x2f, 0x74, 0x72, 0x3e, 0xa, 0x25, 0x21, 0x20, 0x74, 0x63, + 0x70, 0x2d, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0xa, 0x25, 0x21, 0x3a, 0x20, 0x2f, 0x66, + 0x6f, 0x6f, 0x74, 0x65, 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, +0}; + +static const unsigned char data_fade_png[] = { + /* /fade.png */ + 0x2f, 0x66, 0x61, 0x64, 0x65, 0x2e, 0x70, 0x6e, 0x67, 0, + 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 00, 00, + 00, 0xd, 0x49, 0x48, 0x44, 0x52, 00, 00, 00, 0x4, + 00, 00, 00, 0xa, 0x8, 0x2, 00, 00, 00, 0x1c, + 0x99, 0x68, 0x59, 00, 00, 00, 0x9, 0x70, 0x48, 0x59, + 0x73, 00, 00, 0xb, 0x13, 00, 00, 0xb, 0x13, 0x1, + 00, 0x9a, 0x9c, 0x18, 00, 00, 00, 0x7, 0x74, 0x49, + 0x4d, 0x45, 0x7, 0xd6, 0x6, 0x8, 0x14, 0x1b, 0x39, 0xaf, + 0x5b, 0xc0, 0xe3, 00, 00, 00, 0x1d, 0x74, 0x45, 0x58, + 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 00, 0x43, + 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, + 0x68, 0x20, 0x54, 0x68, 0x65, 0x20, 0x47, 0x49, 0x4d, 0x50, + 0xef, 0x64, 0x25, 0x6e, 00, 00, 00, 0x3a, 0x49, 0x44, + 0x41, 0x54, 0x8, 0xd7, 0x75, 0x8c, 0x31, 0x12, 00, 0x10, + 0x10, 0xc4, 0x2e, 0x37, 0x9e, 0x40, 0x65, 0xfd, 0xff, 0x83, + 0xf4, 0xa, 0x1c, 0x8d, 0x54, 0x9b, 0xc9, 0xcc, 0x9a, 0x3d, + 0x90, 0x73, 0x71, 0x67, 0x91, 0xd4, 0x74, 0x36, 0xa9, 0x55, + 0x1, 0xf8, 0x29, 0x58, 0xc8, 0xbf, 0x48, 0xc4, 0x81, 0x74, + 0xb, 0xa3, 0xf, 0x7c, 0xdb, 0x4, 0xe8, 0x40, 0x5, 0xdf, + 0xa1, 0xf3, 0xfc, 0x73, 00, 00, 00, 00, 0x49, 0x45, + 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82, 0}; + +static const unsigned char data_stats_shtml[] = { + /* /stats.shtml */ + 0x2f, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0, + 0x25, 0x21, 0x3a, 0x20, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x65, + 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0xa, 0x3c, 0x68, 0x31, + 0x3e, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x20, 0x73, + 0x74, 0x61, 0x74, 0x69, 0x73, 0x74, 0x69, 0x63, 0x73, 0x3c, + 0x2f, 0x68, 0x31, 0x3e, 0xa, 0x3c, 0x63, 0x65, 0x6e, 0x74, + 0x65, 0x72, 0x3e, 0xa, 0x3c, 0x74, 0x61, 0x62, 0x6c, 0x65, + 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3d, 0x22, 0x33, 0x30, + 0x30, 0x22, 0x20, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x3d, + 0x22, 0x30, 0x22, 0x3e, 0xa, 0x3c, 0x74, 0x72, 0x3e, 0x3c, + 0x74, 0x64, 0x3e, 0x3c, 0x70, 0x72, 0x65, 0x3e, 0xa, 0x49, + 0x50, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x73, 0x20, + 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0xa, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x73, 0x20, + 0x73, 0x65, 0x6e, 0x74, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x73, 0x20, 0x64, + 0x72, 0x6f, 0x70, 0x70, 0x65, 0x64, 0xa, 0x49, 0x50, 0x20, + 0x65, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x20, 0x20, 0x20, 0x20, + 0x49, 0x50, 0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, + 0x2f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x20, 0x6c, 0x65, + 0x6e, 0x67, 0x74, 0x68, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x49, 0x50, + 0x20, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x2c, 0x20, 0x68, + 0x69, 0x67, 0x68, 0x20, 0x62, 0x79, 0x74, 0x65, 0xa, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x49, 0x50, 0x20, 0x6c, 0x65, 0x6e, 0x67, 0x74, + 0x68, 0x2c, 0x20, 0x6c, 0x6f, 0x77, 0x20, 0x62, 0x79, 0x74, + 0x65, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x49, 0x50, 0x20, 0x66, 0x72, + 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0xa, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x20, 0x63, 0x68, + 0x65, 0x63, 0x6b, 0x73, 0x75, 0x6d, 0xa, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x57, 0x72, 0x6f, 0x6e, 0x67, 0x20, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x63, 0x6f, 0x6c, 0xa, 0x49, 0x43, 0x4d, 0x50, 0x9, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x50, 0x61, 0x63, 0x6b, 0x65, + 0x74, 0x73, 0x20, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, + 0x64, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x50, 0x61, 0x63, 0x6b, 0x65, + 0x74, 0x73, 0x20, 0x73, 0x65, 0x6e, 0x74, 0xa, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x73, 0x20, 0x64, + 0x72, 0x6f, 0x70, 0x70, 0x65, 0x64, 0xa, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x54, 0x79, 0x70, 0x65, 0x20, 0x65, 0x72, 0x72, 0x6f, 0x72, + 0x73, 0xa, 0x54, 0x43, 0x50, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x50, 0x61, 0x63, 0x6b, 0x65, + 0x74, 0x73, 0x20, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, + 0x64, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x50, 0x61, 0x63, 0x6b, 0x65, + 0x74, 0x73, 0x20, 0x73, 0x65, 0x6e, 0x74, 0xa, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x73, 0x20, 0x64, + 0x72, 0x6f, 0x70, 0x70, 0x65, 0x64, 0xa, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x43, 0x68, 0x65, 0x63, 0x6b, 0x73, 0x75, 0x6d, 0x20, 0x65, + 0x72, 0x72, 0x6f, 0x72, 0x73, 0xa, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x44, + 0x61, 0x74, 0x61, 0x20, 0x70, 0x61, 0x63, 0x6b, 0x65, 0x74, + 0x73, 0x20, 0x77, 0x69, 0x74, 0x68, 0x6f, 0x75, 0x74, 0x20, + 0x41, 0x43, 0x4b, 0x73, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x52, 0x65, + 0x73, 0x65, 0x74, 0x73, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x52, 0x65, + 0x74, 0x72, 0x61, 0x6e, 0x73, 0x6d, 0x69, 0x73, 0x73, 0x69, + 0x6f, 0x6e, 0x73, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x4e, 0x6f, 0x20, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, + 0x69, 0x6f, 0x6e, 0x20, 0x61, 0x76, 0x61, 0x6c, 0x69, 0x61, + 0x62, 0x6c, 0x65, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, + 0x20, 0x61, 0x74, 0x74, 0x65, 0x6d, 0x70, 0x74, 0x73, 0x20, + 0x74, 0x6f, 0x20, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0x64, 0x20, + 0x70, 0x6f, 0x72, 0x74, 0x73, 0xa, 0x3c, 0x2f, 0x70, 0x72, + 0x65, 0x3e, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x74, 0x64, + 0x3e, 0x3c, 0x70, 0x72, 0x65, 0x3e, 0x25, 0x21, 0x20, 0x6e, + 0x65, 0x74, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x73, 0xa, 0x3c, + 0x2f, 0x70, 0x72, 0x65, 0x3e, 0x3c, 0x2f, 0x74, 0x61, 0x62, + 0x6c, 0x65, 0x3e, 0xa, 0x3c, 0x2f, 0x63, 0x65, 0x6e, 0x74, + 0x65, 0x72, 0x3e, 0xa, 0x25, 0x21, 0x3a, 0x20, 0x2f, 0x66, + 0x6f, 0x6f, 0x74, 0x65, 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, + 0xa, 0}; +/* +const struct httpd_fsdata_file file_processes_shtml[] = {{NULL, data_processes_shtml, data_processes_shtml + 17, sizeof(data_processes_shtml) - 17}}; + +const struct httpd_fsdata_file file_404_html[] = {{file_processes_shtml, data_404_html, data_404_html + 10, sizeof(data_404_html) - 10}}; + +const struct httpd_fsdata_file file_files_shtml[] = {{file_404_html, data_files_shtml, data_files_shtml + 13, sizeof(data_files_shtml) - 13}}; + +const struct httpd_fsdata_file file_footer_html[] = {{file_files_shtml, data_footer_html, data_footer_html + 13, sizeof(data_footer_html) - 13}}; + +const struct httpd_fsdata_file file_header_html[] = {{file_footer_html, data_header_html, data_header_html + 13, sizeof(data_header_html) - 13}}; + +const struct httpd_fsdata_file file_index_html[] = {{file_header_html, data_index_html, data_index_html + 12, sizeof(data_index_html) - 12}}; + +const struct httpd_fsdata_file file_style_css[] = {{file_index_html, data_style_css, data_style_css + 11, sizeof(data_style_css) - 11}}; + +const struct httpd_fsdata_file file_tcp_shtml[] = {{file_style_css, data_tcp_shtml, data_tcp_shtml + 11, sizeof(data_tcp_shtml) - 11}}; + +const struct httpd_fsdata_file file_fade_png[] = {{file_tcp_shtml, data_fade_png, data_fade_png + 10, sizeof(data_fade_png) - 10}}; + +const struct httpd_fsdata_file file_stats_shtml[] = {{file_fade_png, data_stats_shtml, data_stats_shtml + 13, sizeof(data_stats_shtml) - 13}}; + +#define HTTPD_FS_ROOT file_stats_shtml +*/ + +const struct httpd_fsdata_file file_processes_shtml = {NULL, (char const*)data_processes_shtml, (char const*)data_processes_shtml + 17, sizeof(data_processes_shtml) - 17}; + +const struct httpd_fsdata_file file_404_html = {&file_processes_shtml, (char const*)data_404_html, (char const*)data_404_html + 10, sizeof(data_404_html) - 10}; + +const struct httpd_fsdata_file file_files_shtml = {&file_404_html, (char const*)data_files_shtml, (char const*)data_files_shtml + 13, sizeof(data_files_shtml) - 13}; + +const struct httpd_fsdata_file file_footer_html = {&file_files_shtml, (char const*)data_footer_html, (char const*)data_footer_html + 13, sizeof(data_footer_html) - 13}; + +const struct httpd_fsdata_file file_header_html = {&file_footer_html, (char const*)data_header_html, (char const*)data_header_html + 13, sizeof(data_header_html) - 13}; + +const struct httpd_fsdata_file file_index_html = {&file_header_html, (char const*)data_index_html, (char const*)data_index_html + 12, sizeof(data_index_html) - 12}; + +const struct httpd_fsdata_file file_style_css = {&file_index_html, (char const*)data_style_css, (char const*)data_style_css + 11, sizeof(data_style_css) - 11}; + +const struct httpd_fsdata_file file_tcp_shtml = {&file_style_css, (char const*)data_tcp_shtml, (char const*)data_tcp_shtml + 11, sizeof(data_tcp_shtml) - 11}; + +const struct httpd_fsdata_file file_fade_png = {&file_tcp_shtml, (char const*)data_fade_png, (char const*)data_fade_png + 10, sizeof(data_fade_png) - 10}; + +const struct httpd_fsdata_file file_stats_shtml = {&file_fade_png, (char const*)data_stats_shtml, (char const*)data_stats_shtml + 13, sizeof(data_stats_shtml) - 13}; + +#define HTTPD_FS_ROOT &file_stats_shtml + +#define HTTPD_FS_NUMFILES 10 diff --git a/Tester/SW/lib/Drivers/ethernet/httpd/httpd-fsdata.h b/Tester/SW/lib/Drivers/ethernet/httpd/httpd-fsdata.h new file mode 100644 index 0000000..33fcd79 --- /dev/null +++ b/Tester/SW/lib/Drivers/ethernet/httpd/httpd-fsdata.h @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2001, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + * $Id: httpd-fsdata.h,v 1.1.2.3 2006/12/04 18:52:39 fredrikh Exp $ + */ +#ifndef __HTTPD_FSDATA_H__ +#define __HTTPD_FSDATA_H__ + +#include "uip.h" + +struct httpd_fsdata_file { + const struct httpd_fsdata_file *next; + const char *name; + const char *data; + const int len; +#ifdef HTTPD_FS_STATISTICS +#if HTTPD_FS_STATISTICS == 1 + u16_t count; +#endif /* HTTPD_FS_STATISTICS */ +#endif /* HTTPD_FS_STATISTICS */ +}; + +struct httpd_fsdata_file_noconst { + struct httpd_fsdata_file *next; + char *name; + char *data; + int len; +#ifdef HTTPD_FS_STATISTICS +#if HTTPD_FS_STATISTICS == 1 + u16_t count; +#endif /* HTTPD_FS_STATISTICS */ +#endif /* HTTPD_FS_STATISTICS */ +}; + +#endif /* __HTTPD_FSDATA_H__ */ diff --git a/Tester/SW/lib/Drivers/ethernet/httpd/httpd.c b/Tester/SW/lib/Drivers/ethernet/httpd/httpd.c new file mode 100644 index 0000000..1ad8635 --- /dev/null +++ b/Tester/SW/lib/Drivers/ethernet/httpd/httpd.c @@ -0,0 +1,338 @@ +/** + * \addtogroup apps + * @{ + */ + +/** + * \defgroup httpd Web server + * @{ + * The uIP web server is a very simplistic implementation of an HTTP + * server. It can serve web pages and files from a read-only ROM + * filesystem, and provides a very small scripting language. + + */ + +/** + * \file + * Web server + * \author + * Adam Dunkels + */ + + +/* + * Copyright (c) 2004, Adam Dunkels. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of the uIP TCP/IP stack. + * + * Author: Adam Dunkels + * + * $Id: httpd.c,v 1.1.2.3 2006/12/04 18:52:39 fredrikh Exp $ + */ + +#include "uip.h" +#include "httpd.h" +#include "httpd-fs.h" +#include "httpd-cgi.h" +#include "http-strings.h" + +#include + +#define STATE_WAITING 0 +#define STATE_OUTPUT 1 + +#define ISO_nl 0x0a +#define ISO_space 0x20 +#define ISO_bang 0x21 +#define ISO_percent 0x25 +#define ISO_period 0x2e +#define ISO_slash 0x2f +#define ISO_colon 0x3a + + +/*---------------------------------------------------------------------------*/ +static unsigned short +generate_part_of_file(void *state) +{ + struct httpd_state *s = (struct httpd_state *)state; + + if(s->file.len > uip_mss()) { + s->len = uip_mss(); + } else { + s->len = s->file.len; + } + memcpy(uip_appdata, s->file.data, s->len); + + return s->len; +} +/*---------------------------------------------------------------------------*/ +static +PT_THREAD(send_file(struct httpd_state *s)) +{ + PSOCK_BEGIN(&s->sout); + + do { + PSOCK_GENERATOR_SEND(&s->sout, generate_part_of_file, s); + s->file.len -= s->len; + s->file.data += s->len; + } while(s->file.len > 0); + + PSOCK_END(&s->sout); +} +/*---------------------------------------------------------------------------*/ +static +PT_THREAD(send_part_of_file(struct httpd_state *s)) +{ + PSOCK_BEGIN(&s->sout); + + PSOCK_SEND(&s->sout, s->file.data, s->len); + + PSOCK_END(&s->sout); +} +/*---------------------------------------------------------------------------*/ +static void +next_scriptstate(struct httpd_state *s) +{ + char *p; + p = strchr(s->scriptptr, ISO_nl) + 1; + s->scriptlen -= (unsigned short)(p - s->scriptptr); + s->scriptptr = p; +} +/*---------------------------------------------------------------------------*/ +static +PT_THREAD(handle_script(struct httpd_state *s)) +{ + char *ptr; + + PT_BEGIN(&s->scriptpt); + + + while(s->file.len > 0) { + + /* Check if we should start executing a script. */ + if(*s->file.data == ISO_percent && + *(s->file.data + 1) == ISO_bang) { + s->scriptptr = s->file.data + 3; + s->scriptlen = s->file.len - 3; + if(*(s->scriptptr - 1) == ISO_colon) { + httpd_fs_open(s->scriptptr + 1, &s->file); + PT_WAIT_THREAD(&s->scriptpt, send_file(s)); + } else { + PT_WAIT_THREAD(&s->scriptpt, + httpd_cgi(s->scriptptr)(s, s->scriptptr)); + } + next_scriptstate(s); + + /* The script is over, so we reset the pointers and continue + sending the rest of the file. */ + s->file.data = s->scriptptr; + s->file.len = s->scriptlen; + } else { + /* See if we find the start of script marker in the block of HTML + to be sent. */ + + if(s->file.len > uip_mss()) { + s->len = uip_mss(); + } else { + s->len = s->file.len; + } + + if(*s->file.data == ISO_percent) { + ptr = strchr(s->file.data + 1, ISO_percent); + } else { + ptr = strchr(s->file.data, ISO_percent); + } + if(ptr != NULL && + ptr != s->file.data) { + s->len = (int)(ptr - s->file.data); + if(s->len >= uip_mss()) { + s->len = uip_mss(); + } + } + PT_WAIT_THREAD(&s->scriptpt, send_part_of_file(s)); + s->file.data += s->len; + s->file.len -= s->len; + + } + } + + PT_END(&s->scriptpt); +} +/*---------------------------------------------------------------------------*/ +static +PT_THREAD(send_headers(struct httpd_state *s, const char *statushdr)) +{ + char *ptr; + + PSOCK_BEGIN(&s->sout); + + PSOCK_SEND_STR(&s->sout, statushdr); + + ptr = strrchr(s->filename, ISO_period); + if(ptr == NULL) { + PSOCK_SEND_STR(&s->sout, http_content_type_binary); + } else if(strncmp(http_html, ptr, 5) == 0 || + strncmp(http_shtml, ptr, 6) == 0) { + PSOCK_SEND_STR(&s->sout, http_content_type_html); + } else if(strncmp(http_css, ptr, 4) == 0) { + PSOCK_SEND_STR(&s->sout, http_content_type_css); + } else if(strncmp(http_png, ptr, 4) == 0) { + PSOCK_SEND_STR(&s->sout, http_content_type_png); + } else if(strncmp(http_gif, ptr, 4) == 0) { + PSOCK_SEND_STR(&s->sout, http_content_type_gif); + } else if(strncmp(http_jpg, ptr, 4) == 0) { + PSOCK_SEND_STR(&s->sout, http_content_type_jpg); + } else { + PSOCK_SEND_STR(&s->sout, http_content_type_plain); + } + PSOCK_END(&s->sout); +} +/*---------------------------------------------------------------------------*/ +static +PT_THREAD(handle_output(struct httpd_state *s)) +{ + char *ptr; + + PT_BEGIN(&s->outputpt); + + if(!httpd_fs_open(s->filename, &s->file)) { + httpd_fs_open(http_404_html, &s->file); + strcpy(s->filename, http_404_html); + PT_WAIT_THREAD(&s->outputpt, + send_headers(s, + http_header_404)); + PT_WAIT_THREAD(&s->outputpt, + send_file(s)); + } else { + PT_WAIT_THREAD(&s->outputpt, + send_headers(s, + http_header_200)); + ptr = strchr(s->filename, ISO_period); + if(ptr != NULL && strncmp(ptr, http_shtml, 6) == 0) { + PT_INIT(&s->scriptpt); + PT_WAIT_THREAD(&s->outputpt, handle_script(s)); + } else { + PT_WAIT_THREAD(&s->outputpt, + send_file(s)); + } + } + PSOCK_CLOSE(&s->sout); + PT_END(&s->outputpt); +} +/*---------------------------------------------------------------------------*/ +static +PT_THREAD(handle_input(struct httpd_state *s)) +{ + PSOCK_BEGIN(&s->sin); + + PSOCK_READTO(&s->sin, ISO_space); + + + if(strncmp(s->inputbuf, http_get, 4) != 0) { + PSOCK_CLOSE_EXIT(&s->sin); + } + PSOCK_READTO(&s->sin, ISO_space); + + if(s->inputbuf[0] != ISO_slash) { + PSOCK_CLOSE_EXIT(&s->sin); + } + + if(s->inputbuf[1] == ISO_space) { + strncpy(s->filename, http_index_html, sizeof(s->filename)); + } else { + s->inputbuf[PSOCK_DATALEN(&s->sin) - 1] = 0; + strncpy(s->filename, &s->inputbuf[0], sizeof(s->filename)); + } + + /* httpd_log_file(uip_conn->ripaddr, s->filename);*/ + + s->state = STATE_OUTPUT; + + while(1) { + PSOCK_READTO(&s->sin, ISO_nl); + + if(strncmp(s->inputbuf, http_referer, 8) == 0) { + s->inputbuf[PSOCK_DATALEN(&s->sin) - 2] = 0; + /* httpd_log(&s->inputbuf[9]);*/ + } + } + + PSOCK_END(&s->sin); +} +/*---------------------------------------------------------------------------*/ +static void +handle_connection(struct httpd_state *s) +{ + handle_input(s); + if(s->state == STATE_OUTPUT) { + handle_output(s); + } +} +/*---------------------------------------------------------------------------*/ +void +httpd_appcall(void) +{ + struct httpd_state *s = (struct httpd_state *)&(uip_conn->appstate); + + if(uip_closed() || uip_aborted() || uip_timedout()) { + } else if(uip_connected()) { + PSOCK_INIT(&s->sin, s->inputbuf, sizeof(s->inputbuf) - 1); + PSOCK_INIT(&s->sout, s->inputbuf, sizeof(s->inputbuf) - 1); + PT_INIT(&s->outputpt); + s->state = STATE_WAITING; + /* timer_set(&s->timer, CLOCK_SECOND * 100);*/ + s->timer = 0; + handle_connection(s); + } else if(s != NULL) { + if(uip_poll()) { + ++s->timer; + if(s->timer >= 20) { + uip_abort(); + } + } else { + s->timer = 0; + } + handle_connection(s); + } else { + uip_abort(); + } +} +/*---------------------------------------------------------------------------*/ +/** + * \brief Initialize the web server + * + * This function initializes the web server and should be + * called at system boot-up. + */ +void +httpd_init(void) +{ + uip_listen(HTONS(80)); +} +/*---------------------------------------------------------------------------*/ +/** @} */ diff --git a/Tester/SW/lib/Drivers/ethernet/httpd/httpd.h b/Tester/SW/lib/Drivers/ethernet/httpd/httpd.h new file mode 100644 index 0000000..c5fe2a9 --- /dev/null +++ b/Tester/SW/lib/Drivers/ethernet/httpd/httpd.h @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2001-2005, Adam Dunkels. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This file is part of the uIP TCP/IP stack. + * + * $Id: httpd.h,v 1.1.2.3 2006/12/04 18:52:39 fredrikh Exp $ + * + */ + +#ifndef __HTTPD_H__ +#define __HTTPD_H__ + +#include "psock.h" +#include "httpd-fs.h" + +struct httpd_state { + unsigned char timer; + struct psock sin, sout; + struct pt outputpt, scriptpt; + char inputbuf[50]; + char filename[20]; + char state; + struct httpd_fs_file file; + int len; + char *scriptptr; + int scriptlen; + + unsigned short count; +}; + +void httpd_init(void); +void httpd_appcall(void); + +void httpd_log(char *msg); +void httpd_log_file(u16_t *requester, char *file); + +#endif /* __HTTPD_H__ */ diff --git a/Tester/SW/lib/Drivers/ethernet/httpd/webserver.h b/Tester/SW/lib/Drivers/ethernet/httpd/webserver.h new file mode 100644 index 0000000..5820d0a --- /dev/null +++ b/Tester/SW/lib/Drivers/ethernet/httpd/webserver.h @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2002, Adam Dunkels. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This file is part of the uIP TCP/IP stack + * + * $Id: webserver.h,v 1.1.2.3 2006/12/04 18:52:39 fredrikh Exp $ + * + */ +#ifndef __WEBSERVER_H__ +#define __WEBSERVER_H__ + +#include "httpd.h" + +typedef struct httpd_state uip_tcp_appstate_t; +/* UIP_APPCALL: the name of the application function. This function + must return void and take no arguments (i.e., C type "void + appfunc(void)"). */ +#ifndef UIP_APPCALL +#define UIP_APPCALL httpd_appcall +#endif + + +#endif /* __WEBSERVER_H__ */ diff --git a/Tester/SW/lib/Drivers/ethernet/includes.h b/Tester/SW/lib/Drivers/ethernet/includes.h new file mode 100644 index 0000000..2f86bb4 --- /dev/null +++ b/Tester/SW/lib/Drivers/ethernet/includes.h @@ -0,0 +1,42 @@ +/*************************************************************************** + ** + ** + ** Master include file + ** + ** Used with ARM IAR C/C++ Compiler + ** + ** (c) Copyright IAR Systems 2007 + ** + ** $Revision: 1.0 $ + ** + ***************************************************************************/ + +#ifndef __INCLUDES_H +#define __INCLUDES_H + + + +#include +#include +#include +#include +#include +#include +#include + +#include "arm_comm.h" +#include "board.h" + +#include "lpc23xx_enet.h" + +#include "clock-arch.h" + +#include "timer.h" +#include "uip-conf.h" +#include "uipopt.h" +#include "uip_arp.h" +#include "uip.h" + +#include "httpd.h" + +#endif // __INCLUDES_H diff --git a/Tester/SW/lib/Drivers/ethernet/lc-addrlabels.h b/Tester/SW/lib/Drivers/ethernet/lc-addrlabels.h new file mode 100644 index 0000000..fdc45c4 --- /dev/null +++ b/Tester/SW/lib/Drivers/ethernet/lc-addrlabels.h @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2004-2005, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of the uIP TCP/IP stack + * + * Author: Adam Dunkels + * + * $Id: lc-addrlabels.h,v 1.1.2.3 2006/12/04 18:52:39 fredrikh Exp $ + */ + +/** + * \addtogroup lc + * @{ + */ + +/** + * \file + * Implementation of local continuations based on the "Labels as + * values" feature of gcc + * \author + * Adam Dunkels + * + * This implementation of local continuations is based on a special + * feature of the GCC C compiler called "labels as values". This + * feature allows assigning pointers with the address of the code + * corresponding to a particular C label. + * + * For more information, see the GCC documentation: + * http://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html + * + * Thanks to dividuum for finding the nice local scope label + * implementation. + */ + +#ifndef __LC_ADDRLABELS_H__ +#define __LC_ADDRLABELS_H__ + +/** \hideinitializer */ +typedef void * lc_t; + +#define LC_INIT(s) s = NULL + + +#define LC_RESUME(s) \ + do { \ + if(s != NULL) { \ + goto *s; \ + } \ + } while(0) + +#define LC_SET(s) \ + do { ({ __label__ resume; resume: (s) = &&resume; }); }while(0) + +#define LC_END(s) + +#endif /* __LC_ADDRLABELS_H__ */ + +/** @} */ diff --git a/Tester/SW/lib/Drivers/ethernet/lc-switch.h b/Tester/SW/lib/Drivers/ethernet/lc-switch.h new file mode 100644 index 0000000..f101b77 --- /dev/null +++ b/Tester/SW/lib/Drivers/ethernet/lc-switch.h @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2004-2005, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of the uIP TCP/IP stack + * + * Author: Adam Dunkels + * + * $Id: lc-switch.h,v 1.1.2.3 2006/12/04 18:52:39 fredrikh Exp $ + */ + +/** + * \addtogroup lc + * @{ + */ + +/** + * \file + * Implementation of local continuations based on switch() statment + * \author Adam Dunkels + * + * This implementation of local continuations uses the C switch() + * statement to resume execution of a function somewhere inside the + * function's body. The implementation is based on the fact that + * switch() statements are able to jump directly into the bodies of + * control structures such as if() or while() statmenets. + * + * This implementation borrows heavily from Simon Tatham's coroutines + * implementation in C: + * http://www.chiark.greenend.org.uk/~sgtatham/coroutines.html + */ + +#ifndef __LC_SWITCH_H__ +#define __LC_SWTICH_H__ + +/* WARNING! lc implementation using switch() does not work if an + LC_SET() is done within another switch() statement! */ + +/** \hideinitializer */ +typedef unsigned short lc_t; + +#define LC_INIT(s) s = 0; + +#define LC_RESUME(s) switch(s) { case 0: + +#define LC_SET(s) s = __LINE__; case __LINE__: + +#define LC_END(s) } + +#endif /* __LC_SWITCH_H__ */ + +/** @} */ diff --git a/Tester/SW/lib/Drivers/ethernet/lc.h b/Tester/SW/lib/Drivers/ethernet/lc.h new file mode 100644 index 0000000..d2e667b --- /dev/null +++ b/Tester/SW/lib/Drivers/ethernet/lc.h @@ -0,0 +1,131 @@ +/* + * Copyright (c) 2004-2005, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of the uIP TCP/IP stack + * + * Author: Adam Dunkels + * + * $Id: lc.h,v 1.1.2.3 2006/12/04 18:52:39 fredrikh Exp $ + */ + +/** + * \addtogroup pt + * @{ + */ + +/** + * \defgroup lc Local continuations + * @{ + * + * Local continuations form the basis for implementing protothreads. A + * local continuation can be set in a specific function to + * capture the state of the function. After a local continuation has + * been set can be resumed in order to restore the state of the + * function at the point where the local continuation was set. + * + * + */ + +/** + * \file lc.h + * Local continuations + * \author + * Adam Dunkels + * + */ + +#ifdef DOXYGEN +/** + * Initialize a local continuation. + * + * This operation initializes the local continuation, thereby + * unsetting any previously set continuation state. + * + * \hideinitializer + */ +#define LC_INIT(lc) + +/** + * Set a local continuation. + * + * The set operation saves the state of the function at the point + * where the operation is executed. As far as the set operation is + * concerned, the state of the function does not include the + * call-stack or local (automatic) variables, but only the program + * counter and such CPU registers that needs to be saved. + * + * \hideinitializer + */ +#define LC_SET(lc) + +/** + * Resume a local continuation. + * + * The resume operation resumes a previously set local continuation, thus + * restoring the state in which the function was when the local + * continuation was set. If the local continuation has not been + * previously set, the resume operation does nothing. + * + * \hideinitializer + */ +#define LC_RESUME(lc) + +/** + * Mark the end of local continuation usage. + * + * The end operation signifies that local continuations should not be + * used any more in the function. This operation is not needed for + * most implementations of local continuation, but is required by a + * few implementations. + * + * \hideinitializer + */ +#define LC_END(lc) + +/** + * \var typedef lc_t; + * + * The local continuation type. + * + * \hideinitializer + */ +#endif /* DOXYGEN */ + +#ifndef __LC_H__ +#define __LC_H__ + +#ifdef LC_CONF_INCLUDE +#include LC_CONF_INCLUDE +#else +#include "lc-switch.h" +#endif /* LC_CONF_INCLUDE */ + +#endif /* __LC_H__ */ + +/** @} */ +/** @} */ diff --git a/Tester/SW/lib/Drivers/ethernet/psock.c b/Tester/SW/lib/Drivers/ethernet/psock.c new file mode 100644 index 0000000..2833dbe --- /dev/null +++ b/Tester/SW/lib/Drivers/ethernet/psock.c @@ -0,0 +1,338 @@ +/* + * Copyright (c) 2004, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of the uIP TCP/IP stack + * + * Author: Adam Dunkels + * + * $Id: psock.c,v 1.1.2.3 2006/12/04 18:52:39 fredrikh Exp $ + */ + +#include +#include + +#include "uipopt.h" +#include "psock.h" +#include "uip.h" + +#define STATE_NONE 0 +#define STATE_ACKED 1 +#define STATE_READ 2 +#define STATE_BLOCKED_NEWDATA 3 +#define STATE_BLOCKED_CLOSE 4 +#define STATE_BLOCKED_SEND 5 +#define STATE_DATA_SENT 6 + +/* + * Return value of the buffering functions that indicates that a + * buffer was not filled by incoming data. + * + */ +#define BUF_NOT_FULL 0 +#define BUF_NOT_FOUND 0 + +/* + * Return value of the buffering functions that indicates that a + * buffer was completely filled by incoming data. + * + */ +#define BUF_FULL 1 + +/* + * Return value of the buffering functions that indicates that an + * end-marker byte was found. + * + */ +#define BUF_FOUND 2 + +/*---------------------------------------------------------------------------*/ +static void +buf_setup(struct psock_buf *buf, + u8_t *bufptr, u16_t bufsize) +{ + buf->ptr = bufptr; + buf->left = bufsize; +} +/*---------------------------------------------------------------------------*/ +static u8_t +buf_bufdata(struct psock_buf *buf, u16_t len, + u8_t **dataptr, u16_t *datalen) +{ + if(*datalen < buf->left) { + memcpy(buf->ptr, *dataptr, *datalen); + buf->ptr += *datalen; + buf->left -= *datalen; + *dataptr += *datalen; + *datalen = 0; + return BUF_NOT_FULL; + } else if(*datalen == buf->left) { + memcpy(buf->ptr, *dataptr, *datalen); + buf->ptr += *datalen; + buf->left = 0; + *dataptr += *datalen; + *datalen = 0; + return BUF_FULL; + } else { + memcpy(buf->ptr, *dataptr, buf->left); + buf->ptr += buf->left; + *datalen -= buf->left; + *dataptr += buf->left; + buf->left = 0; + return BUF_FULL; + } +} +/*---------------------------------------------------------------------------*/ +static u8_t +buf_bufto(register struct psock_buf *buf, u8_t endmarker, + register u8_t **dataptr, register u16_t *datalen) +{ + u8_t c; + while(buf->left > 0 && *datalen > 0) { + c = *buf->ptr = **dataptr; + ++*dataptr; + ++buf->ptr; + --*datalen; + --buf->left; + + if(c == endmarker) { + return BUF_FOUND; + } + } + + if(*datalen == 0) { + return BUF_NOT_FOUND; + } + + while(*datalen > 0) { + c = **dataptr; + --*datalen; + ++*dataptr; + + if(c == endmarker) { + return BUF_FOUND | BUF_FULL; + } + } + + return BUF_FULL; +} +/*---------------------------------------------------------------------------*/ +static char +send_data(register struct psock *s) +{ + if(s->state != STATE_DATA_SENT || uip_rexmit()) { + if(s->sendlen > uip_mss()) { + uip_send(s->sendptr, uip_mss()); + } else { + uip_send(s->sendptr, s->sendlen); + } + s->state = STATE_DATA_SENT; + return 1; + } + return 0; +} +/*---------------------------------------------------------------------------*/ +static char +data_acked(register struct psock *s) +{ + if(s->state == STATE_DATA_SENT && uip_acked()) { + if(s->sendlen > uip_mss()) { + s->sendlen -= uip_mss(); + s->sendptr += uip_mss(); + } else { + s->sendptr += s->sendlen; + s->sendlen = 0; + } + s->state = STATE_ACKED; + return 1; + } + return 0; +} +/*---------------------------------------------------------------------------*/ +PT_THREAD(psock_send(register struct psock *s, const char *buf, + unsigned int len)) +{ + PT_BEGIN(&s->psockpt); + + /* If there is no data to send, we exit immediately. */ + if(len == 0) { + PT_EXIT(&s->psockpt); + } + + /* Save the length of and a pointer to the data that is to be + sent. */ + s->sendptr = (u8_t *)buf; + s->sendlen = len; + + s->state = STATE_NONE; + + /* We loop here until all data is sent. The s->sendlen variable is + updated by the data_sent() function. */ + while(s->sendlen > 0) { + + /* + * The condition for this PT_WAIT_UNTIL is a little tricky: the + * protothread will wait here until all data has been acknowledged + * (data_acked() returns true) and until all data has been sent + * (send_data() returns true). The two functions data_acked() and + * send_data() must be called in succession to ensure that all + * data is sent. Therefore the & operator is used instead of the + * && operator, which would cause only the data_acked() function + * to be called when it returns false. + */ + PT_WAIT_UNTIL(&s->psockpt, data_acked(s) & send_data(s)); + } + + s->state = STATE_NONE; + + PT_END(&s->psockpt); +} +/*---------------------------------------------------------------------------*/ +PT_THREAD(psock_generator_send(register struct psock *s, + unsigned short (*generate)(void *), void *arg)) +{ + PT_BEGIN(&s->psockpt); + + /* Ensure that there is a generator function to call. */ + if(generate == NULL) { + PT_EXIT(&s->psockpt); + } + + /* Call the generator function to generate the data in the + uip_appdata buffer. */ + s->sendlen = generate(arg); + s->sendptr = uip_appdata; + + s->state = STATE_NONE; + do { + /* Call the generator function again if we are called to perform a + retransmission. */ + if(uip_rexmit()) { + generate(arg); + } + /* Wait until all data is sent and acknowledged. */ + PT_WAIT_UNTIL(&s->psockpt, data_acked(s) & send_data(s)); + } while(s->sendlen > 0); + + s->state = STATE_NONE; + + PT_END(&s->psockpt); +} +/*---------------------------------------------------------------------------*/ +u16_t +psock_datalen(struct psock *psock) +{ + return psock->bufsize - psock->buf.left; +} +/*---------------------------------------------------------------------------*/ +char +psock_newdata(struct psock *s) +{ + if(s->readlen > 0) { + /* There is data in the uip_appdata buffer that has not yet been + read with the PSOCK_READ functions. */ + return 1; + } else if(s->state == STATE_READ) { + /* All data in uip_appdata buffer already consumed. */ + s->state = STATE_BLOCKED_NEWDATA; + return 0; + } else if(uip_newdata()) { + /* There is new data that has not been consumed. */ + return 1; + } else { + /* There is no new data. */ + return 0; + } +} +/*---------------------------------------------------------------------------*/ +PT_THREAD(psock_readto(register struct psock *psock, unsigned char c)) +{ + PT_BEGIN(&psock->psockpt); + + buf_setup(&psock->buf, (u8_t *)psock->bufptr, psock->bufsize); + + /* XXX: Should add buf_checkmarker() before do{} loop, if + incoming data has been handled while waiting for a write. */ + + do { + if(psock->readlen == 0) { + PT_WAIT_UNTIL(&psock->psockpt, psock_newdata(psock)); + psock->state = STATE_READ; + psock->readptr = (u8_t *)uip_appdata; + psock->readlen = uip_datalen(); + } + } while((buf_bufto(&psock->buf, c, + &psock->readptr, + &psock->readlen) & BUF_FOUND) == 0); + + if(psock_datalen(psock) == 0) { + psock->state = STATE_NONE; + PT_RESTART(&psock->psockpt); + } + PT_END(&psock->psockpt); +} +/*---------------------------------------------------------------------------*/ +PT_THREAD(psock_readbuf(register struct psock *psock)) +{ + PT_BEGIN(&psock->psockpt); + + buf_setup(&psock->buf, (u8_t *)psock->bufptr, psock->bufsize); + + /* XXX: Should add buf_checkmarker() before do{} loop, if + incoming data has been handled while waiting for a write. */ + + do { + if(psock->readlen == 0) { + PT_WAIT_UNTIL(&psock->psockpt, psock_newdata(psock)); + printf("Waited for newdata\n"); + psock->state = STATE_READ; + psock->readptr = (u8_t *)uip_appdata; + psock->readlen = uip_datalen(); + } + } while(buf_bufdata(&psock->buf, psock->bufsize, + &psock->readptr, + &psock->readlen) != BUF_FULL); + + if(psock_datalen(psock) == 0) { + psock->state = STATE_NONE; + PT_RESTART(&psock->psockpt); + } + PT_END(&psock->psockpt); +} +/*---------------------------------------------------------------------------*/ +void +psock_init(register struct psock *psock, char *buffer, unsigned int buffersize) +{ + psock->state = STATE_NONE; + psock->readlen = 0; + psock->bufptr = buffer; + psock->bufsize = buffersize; + buf_setup(&psock->buf, (u8_t *)buffer, buffersize); + PT_INIT(&psock->pt); + PT_INIT(&psock->psockpt); +} +/*---------------------------------------------------------------------------*/ diff --git a/Tester/SW/lib/Drivers/ethernet/psock.h b/Tester/SW/lib/Drivers/ethernet/psock.h new file mode 100644 index 0000000..5652852 --- /dev/null +++ b/Tester/SW/lib/Drivers/ethernet/psock.h @@ -0,0 +1,380 @@ +/* + * Copyright (c) 2004, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of the uIP TCP/IP stack + * + * Author: Adam Dunkels + * + * $Id: psock.h,v 1.1.2.3 2006/12/04 18:52:39 fredrikh Exp $ + */ + +/** + * \defgroup psock Protosockets library + * @{ + * + * The protosocket library provides an interface to the uIP stack that is + * similar to the traditional BSD socket interface. Unlike programs + * written for the ordinary uIP event-driven interface, programs + * written with the protosocket library are executed in a sequential + * fashion and does not have to be implemented as explicit state + * machines. + * + * Protosockets only work with TCP connections. + * + * The protosocket library uses \ref pt protothreads to provide + * sequential control flow. This makes the protosockets lightweight in + * terms of memory, but also means that protosockets inherits the + * functional limitations of protothreads. Each protosocket lives only + * within a single function. Automatic variables (stack variables) are + * not retained across a protosocket library function call. + * + * \note Because the protosocket library uses protothreads, local + * variables will not always be saved across a call to a protosocket + * library function. It is therefore advised that local variables are + * used with extreme care. + * + * The protosocket library provides functions for sending data without + * having to deal with retransmissions and acknowledgements, as well + * as functions for reading data without having to deal with data + * being split across more than one TCP segment. + * + * Because each protosocket runs as a protothread, the protosocket has to be + * started with a call to PSOCK_BEGIN() at the start of the function + * in which the protosocket is used. Similarly, the protosocket protothread can + * be terminated by a call to PSOCK_EXIT(). + * + */ + +/** + * \file + * Protosocket library header file + * \author + * Adam Dunkels + * + */ + +#ifndef __PSOCK_H__ +#define __PSOCK_H__ + +#include "uipopt.h" +#include "pt.h" + + /* + * The structure that holds the state of a buffer. + * + * This structure holds the state of a uIP buffer. The structure has + * no user-visible elements, but is used through the functions + * provided by the library. + * + */ +struct psock_buf { + u8_t *ptr; + unsigned short left; +}; + +/** + * The representation of a protosocket. + * + * The protosocket structrure is an opaque structure with no user-visible + * elements. + */ +struct psock { + struct pt pt, psockpt; /* Protothreads - one that's using the psock + functions, and one that runs inside the + psock functions. */ + const u8_t *sendptr; /* Pointer to the next data to be sent. */ + u8_t *readptr; /* Pointer to the next data to be read. */ + + char *bufptr; /* Pointer to the buffer used for buffering + incoming data. */ + + u16_t sendlen; /* The number of bytes left to be sent. */ + u16_t readlen; /* The number of bytes left to be read. */ + + struct psock_buf buf; /* The structure holding the state of the + input buffer. */ + unsigned int bufsize; /* The size of the input buffer. */ + + unsigned char state; /* The state of the protosocket. */ +}; + +void psock_init(struct psock *psock, char *buffer, unsigned int buffersize); +/** + * Initialize a protosocket. + * + * This macro initializes a protosocket and must be called before the + * protosocket is used. The initialization also specifies the input buffer + * for the protosocket. + * + * \param psock (struct psock *) A pointer to the protosocket to be + * initialized + * + * \param buffer (char *) A pointer to the input buffer for the + * protosocket. + * + * \param buffersize (unsigned int) The size of the input buffer. + * + * \hideinitializer + */ +#define PSOCK_INIT(psock, buffer, buffersize) \ + psock_init(psock, buffer, buffersize) + +/** + * Start the protosocket protothread in a function. + * + * This macro starts the protothread associated with the protosocket and + * must come before other protosocket calls in the function it is used. + * + * \param psock (struct psock *) A pointer to the protosocket to be + * started. + * + * \hideinitializer + */ +#define PSOCK_BEGIN(psock) PT_BEGIN(&((psock)->pt)) + +PT_THREAD(psock_send(struct psock *psock, const char *buf, unsigned int len)); +/** + * Send data. + * + * This macro sends data over a protosocket. The protosocket protothread blocks + * until all data has been sent and is known to have been received by + * the remote end of the TCP connection. + * + * \param psock (struct psock *) A pointer to the protosocket over which + * data is to be sent. + * + * \param data (char *) A pointer to the data that is to be sent. + * + * \param datalen (unsigned int) The length of the data that is to be + * sent. + * + * \hideinitializer + */ +#define PSOCK_SEND(psock, data, datalen) \ + PT_WAIT_THREAD(&((psock)->pt), psock_send(psock, data, datalen)) + +/** + * \brief Send a null-terminated string. + * \param psock Pointer to the protosocket. + * \param str The string to be sent. + * + * This function sends a null-terminated string over the + * protosocket. + * + * \hideinitializer + */ +#define PSOCK_SEND_STR(psock, str) \ + PT_WAIT_THREAD(&((psock)->pt), psock_send(psock, str, strlen(str))) + +PT_THREAD(psock_generator_send(struct psock *psock, + unsigned short (*f)(void *), void *arg)); + +/** + * \brief Generate data with a function and send it + * \param psock Pointer to the protosocket. + * \param generator Pointer to the generator function + * \param arg Argument to the generator function + * + * This function generates data and sends it over the + * protosocket. This can be used to dynamically generate + * data for a transmission, instead of generating the data + * in a buffer beforehand. This function reduces the need for + * buffer memory. The generator function is implemented by + * the application, and a pointer to the function is given + * as an argument with the call to PSOCK_GENERATOR_SEND(). + * + * The generator function should place the generated data + * directly in the uip_appdata buffer, and return the + * length of the generated data. The generator function is + * called by the protosocket layer when the data first is + * sent, and once for every retransmission that is needed. + * + * \hideinitializer + */ +#define PSOCK_GENERATOR_SEND(psock, generator, arg) \ + PT_WAIT_THREAD(&((psock)->pt), \ + psock_generator_send(psock, generator, arg)) + + +/** + * Close a protosocket. + * + * This macro closes a protosocket and can only be called from within the + * protothread in which the protosocket lives. + * + * \param psock (struct psock *) A pointer to the protosocket that is to + * be closed. + * + * \hideinitializer + */ +#define PSOCK_CLOSE(psock) uip_close() + +PT_THREAD(psock_readbuf(struct psock *psock)); +/** + * Read data until the buffer is full. + * + * This macro will block waiting for data and read the data into the + * input buffer specified with the call to PSOCK_INIT(). Data is read + * until the buffer is full.. + * + * \param psock (struct psock *) A pointer to the protosocket from which + * data should be read. + * + * \hideinitializer + */ +#define PSOCK_READBUF(psock) \ + PT_WAIT_THREAD(&((psock)->pt), psock_readbuf(psock)) + +PT_THREAD(psock_readto(struct psock *psock, unsigned char c)); +/** + * Read data up to a specified character. + * + * This macro will block waiting for data and read the data into the + * input buffer specified with the call to PSOCK_INIT(). Data is only + * read until the specifieed character appears in the data stream. + * + * \param psock (struct psock *) A pointer to the protosocket from which + * data should be read. + * + * \param c (char) The character at which to stop reading. + * + * \hideinitializer + */ +#define PSOCK_READTO(psock, c) \ + PT_WAIT_THREAD(&((psock)->pt), psock_readto(psock, c)) + +/** + * The length of the data that was previously read. + * + * This macro returns the length of the data that was previously read + * using PSOCK_READTO() or PSOCK_READ(). + * + * \param psock (struct psock *) A pointer to the protosocket holding the data. + * + * \hideinitializer + */ +#define PSOCK_DATALEN(psock) psock_datalen(psock) + +u16_t psock_datalen(struct psock *psock); + +/** + * Exit the protosocket's protothread. + * + * This macro terminates the protothread of the protosocket and should + * almost always be used in conjunction with PSOCK_CLOSE(). + * + * \sa PSOCK_CLOSE_EXIT() + * + * \param psock (struct psock *) A pointer to the protosocket. + * + * \hideinitializer + */ +#define PSOCK_EXIT(psock) PT_EXIT(&((psock)->pt)) + +/** + * Close a protosocket and exit the protosocket's protothread. + * + * This macro closes a protosocket and exits the protosocket's protothread. + * + * \param psock (struct psock *) A pointer to the protosocket. + * + * \hideinitializer + */ +#define PSOCK_CLOSE_EXIT(psock) \ + do { \ + PSOCK_CLOSE(psock); \ + PSOCK_EXIT(psock); \ + } while(0) + +/** + * Declare the end of a protosocket's protothread. + * + * This macro is used for declaring that the protosocket's protothread + * ends. It must always be used together with a matching PSOCK_BEGIN() + * macro. + * + * \param psock (struct psock *) A pointer to the protosocket. + * + * \hideinitializer + */ +#define PSOCK_END(psock) PT_END(&((psock)->pt)) + +char psock_newdata(struct psock *s); + +/** + * Check if new data has arrived on a protosocket. + * + * This macro is used in conjunction with the PSOCK_WAIT_UNTIL() + * macro to check if data has arrived on a protosocket. + * + * \param psock (struct psock *) A pointer to the protosocket. + * + * \hideinitializer + */ +#define PSOCK_NEWDATA(psock) psock_newdata(psock) + +/** + * Wait until a condition is true. + * + * This macro blocks the protothread until the specified condition is + * true. The macro PSOCK_NEWDATA() can be used to check if new data + * arrives when the protosocket is waiting. + * + * Typically, this macro is used as follows: + * + \code + PT_THREAD(thread(struct psock *s, struct timer *t)) + { + PSOCK_BEGIN(s); + + PSOCK_WAIT_UNTIL(s, PSOCK_NEWADATA(s) || timer_expired(t)); + + if(PSOCK_NEWDATA(s)) { + PSOCK_READTO(s, '\n'); + } else { + handle_timed_out(s); + } + + PSOCK_END(s); + } + \endcode + * + * \param psock (struct psock *) A pointer to the protosocket. + * \param condition The condition to wait for. + * + * \hideinitializer + */ +#define PSOCK_WAIT_UNTIL(psock, condition) \ + PT_WAIT_UNTIL(&((psock)->pt), (condition)); + +#define PSOCK_WAIT_THREAD(psock, condition) \ + PT_WAIT_THREAD(&((psock)->pt), (condition)) + +#endif /* __PSOCK_H__ */ + +/** @} */ diff --git a/Tester/SW/lib/Drivers/ethernet/pt.h b/Tester/SW/lib/Drivers/ethernet/pt.h new file mode 100644 index 0000000..db19064 --- /dev/null +++ b/Tester/SW/lib/Drivers/ethernet/pt.h @@ -0,0 +1,323 @@ +/* + * Copyright (c) 2004-2005, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of the uIP TCP/IP stack + * + * Author: Adam Dunkels + * + * $Id: pt.h,v 1.1.2.3 2006/12/04 18:52:39 fredrikh Exp $ + */ + +/** + * \addtogroup pt + * @{ + */ + +/** + * \file + * Protothreads implementation. + * \author + * Adam Dunkels + * + */ + +#ifndef __PT_H__ +#define __PT_H__ + +#include "lc.h" + +struct pt { + lc_t lc; +}; + +#define PT_WAITING 0 +#define PT_EXITED 1 +#define PT_ENDED 2 +#define PT_YIELDED 3 + +/** + * \name Initialization + * @{ + */ + +/** + * Initialize a protothread. + * + * Initializes a protothread. Initialization must be done prior to + * starting to execute the protothread. + * + * \param pt A pointer to the protothread control structure. + * + * \sa PT_SPAWN() + * + * \hideinitializer + */ +#define PT_INIT(pt) LC_INIT((pt)->lc) + +/** @} */ + +/** + * \name Declaration and definition + * @{ + */ + +/** + * Declaration of a protothread. + * + * This macro is used to declare a protothread. All protothreads must + * be declared with this macro. + * + * \param name_args The name and arguments of the C function + * implementing the protothread. + * + * \hideinitializer + */ +#define PT_THREAD(name_args) char name_args + +/** + * Declare the start of a protothread inside the C function + * implementing the protothread. + * + * This macro is used to declare the starting point of a + * protothread. It should be placed at the start of the function in + * which the protothread runs. All C statements above the PT_BEGIN() + * invokation will be executed each time the protothread is scheduled. + * + * \param pt A pointer to the protothread control structure. + * + * \hideinitializer + */ +#define PT_BEGIN(pt) { volatile char PT_YIELD_FLAG = 1; LC_RESUME((pt)->lc) + +/** + * Declare the end of a protothread. + * + * This macro is used for declaring that a protothread ends. It must + * always be used together with a matching PT_BEGIN() macro. + * + * \param pt A pointer to the protothread control structure. + * + * \hideinitializer + */ +#define PT_END(pt) LC_END((pt)->lc); PT_YIELD_FLAG = 0; \ + PT_INIT(pt); return PT_ENDED; } + +/** @} */ + +/** + * \name Blocked wait + * @{ + */ + +/** + * Block and wait until condition is true. + * + * This macro blocks the protothread until the specified condition is + * true. + * + * \param pt A pointer to the protothread control structure. + * \param condition The condition. + * + * \hideinitializer + */ +#define PT_WAIT_UNTIL(pt, condition) \ + do { \ + LC_SET((pt)->lc); \ + if(!(condition)) { \ + return PT_WAITING; \ + } \ + } while(0) + +/** + * Block and wait while condition is true. + * + * This function blocks and waits while condition is true. See + * PT_WAIT_UNTIL(). + * + * \param pt A pointer to the protothread control structure. + * \param cond The condition. + * + * \hideinitializer + */ +#define PT_WAIT_WHILE(pt, cond) PT_WAIT_UNTIL((pt), !(cond)) + +/** @} */ + +/** + * \name Hierarchical protothreads + * @{ + */ + +/** + * Block and wait until a child protothread completes. + * + * This macro schedules a child protothread. The current protothread + * will block until the child protothread completes. + * + * \note The child protothread must be manually initialized with the + * PT_INIT() function before this function is used. + * + * \param pt A pointer to the protothread control structure. + * \param thread The child protothread with arguments + * + * \sa PT_SPAWN() + * + * \hideinitializer + */ +#define PT_WAIT_THREAD(pt, thread) PT_WAIT_WHILE((pt), PT_SCHEDULE(thread)) + +/** + * Spawn a child protothread and wait until it exits. + * + * This macro spawns a child protothread and waits until it exits. The + * macro can only be used within a protothread. + * + * \param pt A pointer to the protothread control structure. + * \param child A pointer to the child protothread's control structure. + * \param thread The child protothread with arguments + * + * \hideinitializer + */ +#define PT_SPAWN(pt, child, thread) \ + do { \ + PT_INIT((child)); \ + PT_WAIT_THREAD((pt), (thread)); \ + } while(0) + +/** @} */ + +/** + * \name Exiting and restarting + * @{ + */ + +/** + * Restart the protothread. + * + * This macro will block and cause the running protothread to restart + * its execution at the place of the PT_BEGIN() call. + * + * \param pt A pointer to the protothread control structure. + * + * \hideinitializer + */ +#define PT_RESTART(pt) \ + do { \ + PT_INIT(pt); \ + return PT_WAITING; \ + } while(0) + +/** + * Exit the protothread. + * + * This macro causes the protothread to exit. If the protothread was + * spawned by another protothread, the parent protothread will become + * unblocked and can continue to run. + * + * \param pt A pointer to the protothread control structure. + * + * \hideinitializer + */ +#define PT_EXIT(pt) \ + do { \ + PT_INIT(pt); \ + return PT_EXITED; \ + } while(0) + +/** @} */ + +/** + * \name Calling a protothread + * @{ + */ + +/** + * Schedule a protothread. + * + * This function shedules a protothread. The return value of the + * function is non-zero if the protothread is running or zero if the + * protothread has exited. + * + * \param f The call to the C function implementing the protothread to + * be scheduled + * + * \hideinitializer + */ +#define PT_SCHEDULE(f) ((f) == PT_WAITING) + +/** @} */ + +/** + * \name Yielding from a protothread + * @{ + */ + +/** + * Yield from the current protothread. + * + * This function will yield the protothread, thereby allowing other + * processing to take place in the system. + * + * \param pt A pointer to the protothread control structure. + * + * \hideinitializer + */ +#define PT_YIELD(pt) \ + do { \ + PT_YIELD_FLAG = 0; \ + LC_SET((pt)->lc); \ + if(PT_YIELD_FLAG == 0) { \ + return PT_YIELDED; \ + } \ + } while(0) + +/** + * \brief Yield from the protothread until a condition occurs. + * \param pt A pointer to the protothread control structure. + * \param cond The condition. + * + * This function will yield the protothread, until the + * specified condition evaluates to true. + * + * + * \hideinitializer + */ +#define PT_YIELD_UNTIL(pt, cond) \ + do { \ + PT_YIELD_FLAG = 0; \ + LC_SET((pt)->lc); \ + if((PT_YIELD_FLAG == 0) || !(cond)) { \ + return PT_YIELDED; \ + } \ + } while(0) + +/** @} */ + +#endif /* __PT_H__ */ + +/** @} */ diff --git a/Tester/SW/lib/Drivers/ethernet/timer.c b/Tester/SW/lib/Drivers/ethernet/timer.c new file mode 100644 index 0000000..db977f7 --- /dev/null +++ b/Tester/SW/lib/Drivers/ethernet/timer.c @@ -0,0 +1,127 @@ +/** + * \addtogroup timer + * @{ + */ + +/** + * \file + * Timer library implementation. + * \author + * Adam Dunkels + */ + +/* + * Copyright (c) 2004, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of the uIP TCP/IP stack + * + * Author: Adam Dunkels + * + * $Id: timer.c,v 1.1.2.3 2006/12/04 18:52:39 fredrikh Exp $ + */ + +#include "clock.h" +#include "timer.h" + +/*---------------------------------------------------------------------------*/ +/** + * Set a timer. + * + * This function is used to set a timer for a time sometime in the + * future. The function timer_expired() will evaluate to true after + * the timer has expired. + * + * \param t A pointer to the timer + * \param interval The interval before the timer expires. + * + */ +void +timer_set(struct timer *t, clock_time_t interval) +{ + t->interval = interval; + t->start = clock_time(); +} +/*---------------------------------------------------------------------------*/ +/** + * Reset the timer with the same interval. + * + * This function resets the timer with the same interval that was + * given to the timer_set() function. The start point of the interval + * is the exact time that the timer last expired. Therefore, this + * function will cause the timer to be stable over time, unlike the + * timer_rester() function. + * + * \param t A pointer to the timer. + * + * \sa timer_restart() + */ +void +timer_reset(struct timer *t) +{ + t->start += t->interval; +} +/*---------------------------------------------------------------------------*/ +/** + * Restart the timer from the current point in time + * + * This function restarts a timer with the same interval that was + * given to the timer_set() function. The timer will start at the + * current time. + * + * \note A periodic timer will drift if this function is used to reset + * it. For preioric timers, use the timer_reset() function instead. + * + * \param t A pointer to the timer. + * + * \sa timer_reset() + */ +void +timer_restart(struct timer *t) +{ + t->start = clock_time(); +} +/*---------------------------------------------------------------------------*/ +/** + * Check if a timer has expired. + * + * This function tests if a timer has expired and returns true or + * false depending on its status. + * + * \param t A pointer to the timer + * + * \return Non-zero if the timer has expired, zero otherwise. + * + */ +int +timer_expired(struct timer *t) +{ + return (clock_time_t)(clock_time() - t->start) >= (clock_time_t)t->interval; +} +/*---------------------------------------------------------------------------*/ + +/** @} */ diff --git a/Tester/SW/lib/Drivers/ethernet/timer.h b/Tester/SW/lib/Drivers/ethernet/timer.h new file mode 100644 index 0000000..d723937 --- /dev/null +++ b/Tester/SW/lib/Drivers/ethernet/timer.h @@ -0,0 +1,86 @@ +/** + * \defgroup timer Timer library + * + * The timer library provides functions for setting, resetting and + * restarting timers, and for checking if a timer has expired. An + * application must "manually" check if its timers have expired; this + * is not done automatically. + * + * A timer is declared as a \c struct \c timer and all access to the + * timer is made by a pointer to the declared timer. + * + * \note The timer library uses the \ref clock "Clock library" to + * measure time. Intervals should be specified in the format used by + * the clock library. + * + * @{ + */ + + +/** + * \file + * Timer library header file. + * \author + * Adam Dunkels + */ + +/* + * Copyright (c) 2004, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of the uIP TCP/IP stack + * + * Author: Adam Dunkels + * + * $Id: timer.h,v 1.1.2.3 2006/12/04 18:52:39 fredrikh Exp $ + */ +#ifndef __TIMER_H__ +#define __TIMER_H__ + +#include "clock.h" + +/** + * A timer. + * + * This structure is used for declaring a timer. The timer must be set + * with timer_set() before it can be used. + * + * \hideinitializer + */ +struct timer { + clock_time_t start; + clock_time_t interval; +}; + +void timer_set(struct timer *t, clock_time_t interval); +void timer_reset(struct timer *t); +void timer_restart(struct timer *t); +int timer_expired(struct timer *t); + +#endif /* __TIMER_H__ */ + +/** @} */ diff --git a/Tester/SW/lib/Drivers/ethernet/uip-conf.h b/Tester/SW/lib/Drivers/ethernet/uip-conf.h new file mode 100644 index 0000000..f831a1d --- /dev/null +++ b/Tester/SW/lib/Drivers/ethernet/uip-conf.h @@ -0,0 +1,157 @@ +/** + * \addtogroup uipopt + * @{ + */ + +/** + * \name Project-specific configuration options + * @{ + * + * uIP has a number of configuration options that can be overridden + * for each project. These are kept in a project-specific uip-conf.h + * file and all configuration names have the prefix UIP_CONF. + */ + +/* + * Copyright (c) 2006, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of the uIP TCP/IP stack + * + * $Id: uip-conf.h,v 1.1.2.3 2006/12/04 18:52:39 fredrikh Exp $ + */ + +/** + * \file + * An example uIP configuration file + * \author + * Adam Dunkels + */ + +#ifndef __UIP_CONF_H__ +#define __UIP_CONF_H__ + +#include + +/** + * 8 bit datatype + * + * This typedef defines the 8-bit type used throughout uIP. + * + * \hideinitializer + */ +typedef uint8_t u8_t; + +/** + * 16 bit datatype + * + * This typedef defines the 16-bit type used throughout uIP. + * + * \hideinitializer + */ +typedef uint16_t u16_t; + +/** + * Statistics datatype + * + * This typedef defines the dataype used for keeping statistics in + * uIP. + * + * \hideinitializer + */ +typedef unsigned short uip_stats_t; + +/** + * Maximum number of TCP connections. + * + * \hideinitializer + */ +#define UIP_CONF_MAX_CONNECTIONS 40 + +/** + * Maximum number of listening TCP ports. + * + * \hideinitializer + */ +#define UIP_CONF_MAX_LISTENPORTS 40 + +/** + * uIP buffer size. + * + * \hideinitializer + */ +#define UIP_CONF_BUFFER_SIZE 1520 + +/** + * CPU byte order. + * + * \hideinitializer + */ +#define UIP_CONF_BYTE_ORDER LITTLE_ENDIAN + +/** + * Logging on or off + * + * \hideinitializer + */ +#define UIP_CONF_LOGGING 0 + +/** + * UDP support on or off + * + * \hideinitializer + */ +#define UIP_CONF_UDP 0 + +/** + * UDP checksums on or off + * + * \hideinitializer + */ +#define UIP_CONF_UDP_CHECKSUMS 1 + +/** + * uIP statistics on or off + * + * \hideinitializer + */ +#define UIP_CONF_STATISTICS 1 + +/* Here we include the header file for the application(s) we use in + our project. */ +/*#include "smtp.h"*/ +/*#include "hello-world.h"*/ +/*#include "telnetd.h"*/ +#include "webserver.h" +/*#include "dhcpc.h"*/ +/*#include "resolv.h"*/ +/*#include "webclient.h"*/ + +#endif /* __UIP_CONF_H__ */ + +/** @} */ +/** @} */ diff --git a/Tester/SW/lib/Drivers/ethernet/uip.c b/Tester/SW/lib/Drivers/ethernet/uip.c new file mode 100644 index 0000000..0f56b02 --- /dev/null +++ b/Tester/SW/lib/Drivers/ethernet/uip.c @@ -0,0 +1,1898 @@ +#define DEBUG_PRINTF(...) /*printf(__VA_ARGS__)*/ + +/** + * \defgroup uip The uIP TCP/IP stack + * @{ + * + * uIP is an implementation of the TCP/IP protocol stack intended for + * small 8-bit and 16-bit microcontrollers. + * + * uIP provides the necessary protocols for Internet communication, + * with a very small code footprint and RAM requirements - the uIP + * code size is on the order of a few kilobytes and RAM usage is on + * the order of a few hundred bytes. + */ + +/** + * \file + * The uIP TCP/IP stack code. + * \author Adam Dunkels + */ + +/* + * Copyright (c) 2001-2003, Adam Dunkels. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This file is part of the uIP TCP/IP stack. + * + * $Id: uip.c,v 1.1.2.3 2006/12/04 18:52:39 fredrikh Exp $ + * + */ + +/* + * uIP is a small implementation of the IP, UDP and TCP protocols (as + * well as some basic ICMP stuff). The implementation couples the IP, + * UDP, TCP and the application layers very tightly. To keep the size + * of the compiled code down, this code frequently uses the goto + * statement. While it would be possible to break the uip_process() + * function into many smaller functions, this would increase the code + * size because of the overhead of parameter passing and the fact that + * the optimier would not be as efficient. + * + * The principle is that we have a small buffer, called the uip_buf, + * in which the device driver puts an incoming packet. The TCP/IP + * stack parses the headers in the packet, and calls the + * application. If the remote host has sent data to the application, + * this data is present in the uip_buf and the application read the + * data from there. It is up to the application to put this data into + * a byte stream if needed. The application will not be fed with data + * that is out of sequence. + * + * If the application whishes to send data to the peer, it should put + * its data into the uip_buf. The uip_appdata pointer points to the + * first available byte. The TCP/IP stack will calculate the + * checksums, and fill in the necessary header fields and finally send + * the packet back to the peer. +*/ + +#include "uip.h" +#include "uipopt.h" +#include "uip_arch.h" + +#if UIP_CONF_IPV6 +#include "uip-neighbor.h" +#endif /* UIP_CONF_IPV6 */ + +#include + +/*---------------------------------------------------------------------------*/ +/* Variable definitions. */ + + +/* The IP address of this host. If it is defined to be fixed (by + setting UIP_FIXEDADDR to 1 in uipopt.h), the address is set + here. Otherwise, the address */ +#if UIP_FIXEDADDR > 0 +const uip_ipaddr_t uip_hostaddr = + {HTONS((UIP_IPADDR0 << 8) | UIP_IPADDR1), + HTONS((UIP_IPADDR2 << 8) | UIP_IPADDR3)}; +const uip_ipaddr_t uip_draddr = + {HTONS((UIP_DRIPADDR0 << 8) | UIP_DRIPADDR1), + HTONS((UIP_DRIPADDR2 << 8) | UIP_DRIPADDR3)}; +const uip_ipaddr_t uip_netmask = + {HTONS((UIP_NETMASK0 << 8) | UIP_NETMASK1), + HTONS((UIP_NETMASK2 << 8) | UIP_NETMASK3)}; +#else +uip_ipaddr_t uip_hostaddr, uip_draddr, uip_netmask; +#endif /* UIP_FIXEDADDR */ + +static const uip_ipaddr_t all_ones_addr = +#if UIP_CONF_IPV6 + {0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff}; +#else /* UIP_CONF_IPV6 */ + {0xffff,0xffff}; +#endif /* UIP_CONF_IPV6 */ +static const uip_ipaddr_t all_zeroes_addr = +#if UIP_CONF_IPV6 + {0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000}; +#else /* UIP_CONF_IPV6 */ + {0x0000,0x0000}; +#endif /* UIP_CONF_IPV6 */ + + +#if UIP_FIXEDETHADDR +const struct uip_eth_addr uip_ethaddr = {{UIP_ETHADDR0, + UIP_ETHADDR1, + UIP_ETHADDR2, + UIP_ETHADDR3, + UIP_ETHADDR4, + UIP_ETHADDR5}}; +#else +struct uip_eth_addr uip_ethaddr = {{0,0,0,0,0,0}}; +#endif + +#ifndef UIP_CONF_EXTERNAL_BUFFER +//#pragma data_alignment=4 +u8_t uip_buf[UIP_BUFSIZE + 2]__attribute__ ((aligned(4))); /* The packet buffer that contains + incoming packets. */ +#endif /* UIP_CONF_EXTERNAL_BUFFER */ + +void *uip_appdata; /* The uip_appdata pointer points to + application data. */ +void *uip_sappdata; /* The uip_appdata pointer points to + the application data which is to + be sent. */ +#if UIP_URGDATA > 0 +void *uip_urgdata; /* The uip_urgdata pointer points to + urgent data (out-of-band data), if + present. */ +u16_t uip_urglen, uip_surglen; +#endif /* UIP_URGDATA > 0 */ + +u16_t uip_len, uip_slen; + /* The uip_len is either 8 or 16 bits, + depending on the maximum packet + size. */ + +u8_t uip_flags; /* The uip_flags variable is used for + communication between the TCP/IP stack + and the application program. */ +struct uip_conn *uip_conn; /* uip_conn always points to the current + connection. */ + +struct uip_conn uip_conns[UIP_CONNS]; + /* The uip_conns array holds all TCP + connections. */ +u16_t uip_listenports[UIP_LISTENPORTS]; + /* The uip_listenports list all currently + listning ports. */ +#if UIP_UDP +struct uip_udp_conn *uip_udp_conn; +struct uip_udp_conn uip_udp_conns[UIP_UDP_CONNS]; +#endif /* UIP_UDP */ + +static u16_t ipid; /* Ths ipid variable is an increasing + number that is used for the IP ID + field. */ + +void uip_setipid(u16_t id) { ipid = id; } + +static u8_t iss[4]; /* The iss variable is used for the TCP + initial sequence number. */ + +#if UIP_ACTIVE_OPEN +static u16_t lastport; /* Keeps track of the last port used for + a new connection. */ +#endif /* UIP_ACTIVE_OPEN */ + +/* Temporary variables. */ +u8_t uip_acc32[4]; +static u8_t c, opt; +static u16_t tmp16; + +/* Structures and definitions. */ +#define TCP_FIN 0x01 +#define TCP_SYN 0x02 +#define TCP_RST 0x04 +#define TCP_PSH 0x08 +#define TCP_ACK 0x10 +#define TCP_URG 0x20 +#define TCP_CTL 0x3f + +#define TCP_OPT_END 0 /* End of TCP options list */ +#define TCP_OPT_NOOP 1 /* "No-operation" TCP option */ +#define TCP_OPT_MSS 2 /* Maximum segment size TCP option */ + +#define TCP_OPT_MSS_LEN 4 /* Length of TCP MSS option. */ + +#define ICMP_ECHO_REPLY 0 +#define ICMP_ECHO 8 + +#define ICMP6_ECHO_REPLY 129 +#define ICMP6_ECHO 128 +#define ICMP6_NEIGHBOR_SOLICITATION 135 +#define ICMP6_NEIGHBOR_ADVERTISEMENT 136 + +#define ICMP6_FLAG_S (1 << 6) + +#define ICMP6_OPTION_SOURCE_LINK_ADDRESS 1 +#define ICMP6_OPTION_TARGET_LINK_ADDRESS 2 + + +/* Macros. */ +#define BUF ((struct uip_tcpip_hdr *)&uip_buf[UIP_LLH_LEN]) +#define FBUF ((struct uip_tcpip_hdr *)&uip_reassbuf[0]) +#define ICMPBUF ((struct uip_icmpip_hdr *)&uip_buf[UIP_LLH_LEN]) +#define UDPBUF ((struct uip_udpip_hdr *)&uip_buf[UIP_LLH_LEN]) + + +#if UIP_STATISTICS == 1 +struct uip_stats uip_stat; +#define UIP_STAT(s) s +#else +#define UIP_STAT(s) +#endif /* UIP_STATISTICS == 1 */ + +#if UIP_LOGGING == 1 +#include +void uip_log(char *msg); +#define UIP_LOG(m) uip_log(m) +#else +#define UIP_LOG(m) +#endif /* UIP_LOGGING == 1 */ + +#if ! UIP_ARCH_ADD32 +void +uip_add32(u8_t *op32, u16_t op16) +{ + uip_acc32[3] = op32[3] + (op16 & 0xff); + uip_acc32[2] = op32[2] + (op16 >> 8); + uip_acc32[1] = op32[1]; + uip_acc32[0] = op32[0]; + + if(uip_acc32[2] < (op16 >> 8)) { + ++uip_acc32[1]; + if(uip_acc32[1] == 0) { + ++uip_acc32[0]; + } + } + + + if(uip_acc32[3] < (op16 & 0xff)) { + ++uip_acc32[2]; + if(uip_acc32[2] == 0) { + ++uip_acc32[1]; + if(uip_acc32[1] == 0) { + ++uip_acc32[0]; + } + } + } +} + +#endif /* UIP_ARCH_ADD32 */ + +#if ! UIP_ARCH_CHKSUM +/*---------------------------------------------------------------------------*/ +static u16_t +chksum(u16_t sum, const u8_t *data, u16_t len) +{ + u16_t t; + const u8_t *dataptr; + const u8_t *last_byte; + + dataptr = data; + last_byte = data + len - 1; + + while(dataptr < last_byte) { /* At least two more bytes */ + t = (dataptr[0] << 8) + dataptr[1]; + sum += t; + if(sum < t) { + sum++; /* carry */ + } + dataptr += 2; + } + + if(dataptr == last_byte) { + t = (dataptr[0] << 8) + 0; + sum += t; + if(sum < t) { + sum++; /* carry */ + } + } + + /* Return sum in host byte order. */ + return sum; +} +/*---------------------------------------------------------------------------*/ +u16_t +uip_chksum(u16_t *data, u16_t len) +{ + return htons(chksum(0, (u8_t *)data, len)); +} +/*---------------------------------------------------------------------------*/ +#ifndef UIP_ARCH_IPCHKSUM +u16_t +uip_ipchksum(void) +{ + u16_t sum; + + sum = chksum(0, &uip_buf[UIP_LLH_LEN], UIP_IPH_LEN); + DEBUG_PRINTF("uip_ipchksum: sum 0x%04x\n", sum); + return (sum == 0) ? 0xffff : htons(sum); +} +#endif +/*---------------------------------------------------------------------------*/ +static u16_t +upper_layer_chksum(u8_t proto) +{ + u16_t upper_layer_len; + u16_t sum; + +#if UIP_CONF_IPV6 + upper_layer_len = (((u16_t)(BUF->len[0]) << 8) + BUF->len[1]); +#else /* UIP_CONF_IPV6 */ + upper_layer_len = (((u16_t)(BUF->len[0]) << 8) + BUF->len[1]) - UIP_IPH_LEN; +#endif /* UIP_CONF_IPV6 */ + + /* First sum pseudoheader. */ + + /* IP protocol and length fields. This addition cannot carry. */ + sum = upper_layer_len + proto; + /* Sum IP source and destination addresses. */ + sum = chksum(sum, (u8_t *)&BUF->srcipaddr[0], 2 * sizeof(uip_ipaddr_t)); + + /* Sum TCP header and data. */ + sum = chksum(sum, &uip_buf[UIP_IPH_LEN + UIP_LLH_LEN], + upper_layer_len); + + return (sum == 0) ? 0xffff : htons(sum); +} +/*---------------------------------------------------------------------------*/ +#if UIP_CONF_IPV6 +u16_t +uip_icmp6chksum(void) +{ + return upper_layer_chksum(UIP_PROTO_ICMP6); + +} +#endif /* UIP_CONF_IPV6 */ +/*---------------------------------------------------------------------------*/ +u16_t +uip_tcpchksum(void) +{ + return upper_layer_chksum(UIP_PROTO_TCP); +} +/*---------------------------------------------------------------------------*/ +#if UIP_UDP_CHECKSUMS +u16_t +uip_udpchksum(void) +{ + return upper_layer_chksum(UIP_PROTO_UDP); +} +#endif /* UIP_UDP_CHECKSUMS */ +#endif /* UIP_ARCH_CHKSUM */ +/*---------------------------------------------------------------------------*/ +void +uip_init(void) +{ + for(c = 0; c < UIP_LISTENPORTS; ++c) { + uip_listenports[c] = 0; + } + for(c = 0; c < UIP_CONNS; ++c) { + uip_conns[c].tcpstateflags = UIP_CLOSED; + } +#if UIP_ACTIVE_OPEN + lastport = 1024; +#endif /* UIP_ACTIVE_OPEN */ + +#if UIP_UDP + for(c = 0; c < UIP_UDP_CONNS; ++c) { + uip_udp_conns[c].lport = 0; + } +#endif /* UIP_UDP */ + + + /* IPv4 initialization. */ +#if UIP_FIXEDADDR == 0 + /* uip_hostaddr[0] = uip_hostaddr[1] = 0;*/ +#endif /* UIP_FIXEDADDR */ + +} +/*---------------------------------------------------------------------------*/ +#if UIP_ACTIVE_OPEN +struct uip_conn * +uip_connect(uip_ipaddr_t *ripaddr, u16_t rport) +{ + register struct uip_conn *conn, *cconn; + + /* Find an unused local port. */ + again: + ++lastport; + + if(lastport >= 32000) { + lastport = 4096; + } + + /* Check if this port is already in use, and if so try to find + another one. */ + for(c = 0; c < UIP_CONNS; ++c) { + conn = &uip_conns[c]; + if(conn->tcpstateflags != UIP_CLOSED && + conn->lport == htons(lastport)) { + goto again; + } + } + + conn = 0; + for(c = 0; c < UIP_CONNS; ++c) { + cconn = &uip_conns[c]; + if(cconn->tcpstateflags == UIP_CLOSED) { + conn = cconn; + break; + } + if(cconn->tcpstateflags == UIP_TIME_WAIT) { + if(conn == 0 || + cconn->timer > conn->timer) { + conn = cconn; + } + } + } + + if(conn == 0) { + return 0; + } + + conn->tcpstateflags = UIP_SYN_SENT; + + conn->snd_nxt[0] = iss[0]; + conn->snd_nxt[1] = iss[1]; + conn->snd_nxt[2] = iss[2]; + conn->snd_nxt[3] = iss[3]; + + conn->initialmss = conn->mss = UIP_TCP_MSS; + + conn->len = 1; /* TCP length of the SYN is one. */ + conn->nrtx = 0; + conn->timer = 1; /* Send the SYN next time around. */ + conn->rto = UIP_RTO; + conn->sa = 0; + conn->sv = 16; /* Initial value of the RTT variance. */ + conn->lport = htons(lastport); + conn->rport = rport; + uip_ipaddr_copy(&conn->ripaddr, ripaddr); + + return conn; +} +#endif /* UIP_ACTIVE_OPEN */ +/*---------------------------------------------------------------------------*/ +#if UIP_UDP +struct uip_udp_conn * +uip_udp_new(uip_ipaddr_t *ripaddr, u16_t rport) +{ + register struct uip_udp_conn *conn; + + /* Find an unused local port. */ + again: + ++lastport; + + if(lastport >= 32000) { + lastport = 4096; + } + + for(c = 0; c < UIP_UDP_CONNS; ++c) { + if(uip_udp_conns[c].lport == htons(lastport)) { + goto again; + } + } + + + conn = 0; + for(c = 0; c < UIP_UDP_CONNS; ++c) { + if(uip_udp_conns[c].lport == 0) { + conn = &uip_udp_conns[c]; + break; + } + } + + if(conn == 0) { + return 0; + } + + conn->lport = HTONS(lastport); + conn->rport = rport; + if(ripaddr == NULL) { + memset(conn->ripaddr, 0, sizeof(uip_ipaddr_t)); + } else { + uip_ipaddr_copy(&conn->ripaddr, ripaddr); + } + conn->ttl = UIP_TTL; + + return conn; +} +#endif /* UIP_UDP */ +/*---------------------------------------------------------------------------*/ +void +uip_unlisten(u16_t port) +{ + for(c = 0; c < UIP_LISTENPORTS; ++c) { + if(uip_listenports[c] == port) { + uip_listenports[c] = 0; + return; + } + } +} +/*---------------------------------------------------------------------------*/ +void +uip_listen(u16_t port) +{ + for(c = 0; c < UIP_LISTENPORTS; ++c) { + if(uip_listenports[c] == 0) { + uip_listenports[c] = port; + return; + } + } +} +/*---------------------------------------------------------------------------*/ +/* XXX: IP fragment reassembly: not well-tested. */ + +#if UIP_REASSEMBLY && !UIP_CONF_IPV6 +#define UIP_REASS_BUFSIZE (UIP_BUFSIZE - UIP_LLH_LEN) +static u8_t uip_reassbuf[UIP_REASS_BUFSIZE]; +static u8_t uip_reassbitmap[UIP_REASS_BUFSIZE / (8 * 8)]; +static const u8_t bitmap_bits[8] = {0xff, 0x7f, 0x3f, 0x1f, + 0x0f, 0x07, 0x03, 0x01}; +static u16_t uip_reasslen; +static u8_t uip_reassflags; +#define UIP_REASS_FLAG_LASTFRAG 0x01 +static u8_t uip_reasstmr; + +#define IP_MF 0x20 + +static u8_t +uip_reass(void) +{ + u16_t offset, len; + u16_t i; + + /* If ip_reasstmr is zero, no packet is present in the buffer, so we + write the IP header of the fragment into the reassembly + buffer. The timer is updated with the maximum age. */ + if(uip_reasstmr == 0) { + memcpy(uip_reassbuf, &BUF->vhl, UIP_IPH_LEN); + uip_reasstmr = UIP_REASS_MAXAGE; + uip_reassflags = 0; + /* Clear the bitmap. */ + memset(uip_reassbitmap, 0, sizeof(uip_reassbitmap)); + } + + /* Check if the incoming fragment matches the one currently present + in the reasembly buffer. If so, we proceed with copying the + fragment into the buffer. */ + if(BUF->srcipaddr[0] == FBUF->srcipaddr[0] && + BUF->srcipaddr[1] == FBUF->srcipaddr[1] && + BUF->destipaddr[0] == FBUF->destipaddr[0] && + BUF->destipaddr[1] == FBUF->destipaddr[1] && + BUF->ipid[0] == FBUF->ipid[0] && + BUF->ipid[1] == FBUF->ipid[1]) { + + len = (BUF->len[0] << 8) + BUF->len[1] - (BUF->vhl & 0x0f) * 4; + offset = (((BUF->ipoffset[0] & 0x3f) << 8) + BUF->ipoffset[1]) * 8; + + /* If the offset or the offset + fragment length overflows the + reassembly buffer, we discard the entire packet. */ + if(offset > UIP_REASS_BUFSIZE || + offset + len > UIP_REASS_BUFSIZE) { + uip_reasstmr = 0; + goto nullreturn; + } + + /* Copy the fragment into the reassembly buffer, at the right + offset. */ + memcpy(&uip_reassbuf[UIP_IPH_LEN + offset], + (char *)BUF + (int)((BUF->vhl & 0x0f) * 4), + len); + + /* Update the bitmap. */ + if(offset / (8 * 8) == (offset + len) / (8 * 8)) { + /* If the two endpoints are in the same byte, we only update + that byte. */ + + uip_reassbitmap[offset / (8 * 8)] |= + bitmap_bits[(offset / 8 ) & 7] & + ~bitmap_bits[((offset + len) / 8 ) & 7]; + } else { + /* If the two endpoints are in different bytes, we update the + bytes in the endpoints and fill the stuff inbetween with + 0xff. */ + uip_reassbitmap[offset / (8 * 8)] |= + bitmap_bits[(offset / 8 ) & 7]; + for(i = 1 + offset / (8 * 8); i < (offset + len) / (8 * 8); ++i) { + uip_reassbitmap[i] = 0xff; + } + uip_reassbitmap[(offset + len) / (8 * 8)] |= + ~bitmap_bits[((offset + len) / 8 ) & 7]; + } + + /* If this fragment has the More Fragments flag set to zero, we + know that this is the last fragment, so we can calculate the + size of the entire packet. We also set the + IP_REASS_FLAG_LASTFRAG flag to indicate that we have received + the final fragment. */ + + if((BUF->ipoffset[0] & IP_MF) == 0) { + uip_reassflags |= UIP_REASS_FLAG_LASTFRAG; + uip_reasslen = offset + len; + } + + /* Finally, we check if we have a full packet in the buffer. We do + this by checking if we have the last fragment and if all bits + in the bitmap are set. */ + if(uip_reassflags & UIP_REASS_FLAG_LASTFRAG) { + /* Check all bytes up to and including all but the last byte in + the bitmap. */ + for(i = 0; i < uip_reasslen / (8 * 8) - 1; ++i) { + if(uip_reassbitmap[i] != 0xff) { + goto nullreturn; + } + } + /* Check the last byte in the bitmap. It should contain just the + right amount of bits. */ + if(uip_reassbitmap[uip_reasslen / (8 * 8)] != + (u8_t)~bitmap_bits[uip_reasslen / 8 & 7]) { + goto nullreturn; + } + + /* If we have come this far, we have a full packet in the + buffer, so we allocate a pbuf and copy the packet into it. We + also reset the timer. */ + uip_reasstmr = 0; + memcpy(BUF, FBUF, uip_reasslen); + + /* Pretend to be a "normal" (i.e., not fragmented) IP packet + from now on. */ + BUF->ipoffset[0] = BUF->ipoffset[1] = 0; + BUF->len[0] = uip_reasslen >> 8; + BUF->len[1] = uip_reasslen & 0xff; + BUF->ipchksum = 0; + BUF->ipchksum = ~(uip_ipchksum()); + + return uip_reasslen; + } + } + + nullreturn: + return 0; +} +#endif /* UIP_REASSEMBLY */ +/*---------------------------------------------------------------------------*/ +static void +uip_add_rcv_nxt(u16_t n) +{ + uip_add32(uip_conn->rcv_nxt, n); + uip_conn->rcv_nxt[0] = uip_acc32[0]; + uip_conn->rcv_nxt[1] = uip_acc32[1]; + uip_conn->rcv_nxt[2] = uip_acc32[2]; + uip_conn->rcv_nxt[3] = uip_acc32[3]; +} +/*---------------------------------------------------------------------------*/ +void +uip_process(u8_t flag) +{ + register struct uip_conn *uip_connr = uip_conn; + +#if UIP_UDP + if(flag == UIP_UDP_SEND_CONN) { + goto udp_send; + } +#endif /* UIP_UDP */ + + uip_sappdata = uip_appdata = &uip_buf[UIP_IPTCPH_LEN + UIP_LLH_LEN]; + + /* Check if we were invoked because of a poll request for a + particular connection. */ + if(flag == UIP_POLL_REQUEST) { + if((uip_connr->tcpstateflags & UIP_TS_MASK) == UIP_ESTABLISHED && + !uip_outstanding(uip_connr)) { + uip_flags = UIP_POLL; + UIP_APPCALL(); + goto appsend; + } + goto drop; + + /* Check if we were invoked because of the perodic timer fireing. */ + } else if(flag == UIP_TIMER) { +#if UIP_REASSEMBLY + if(uip_reasstmr != 0) { + --uip_reasstmr; + } +#endif /* UIP_REASSEMBLY */ + /* Increase the initial sequence number. */ + if(++iss[3] == 0) { + if(++iss[2] == 0) { + if(++iss[1] == 0) { + ++iss[0]; + } + } + } + + /* Reset the length variables. */ + uip_len = 0; + uip_slen = 0; + + /* Check if the connection is in a state in which we simply wait + for the connection to time out. If so, we increase the + connection's timer and remove the connection if it times + out. */ + if(uip_connr->tcpstateflags == UIP_TIME_WAIT || + uip_connr->tcpstateflags == UIP_FIN_WAIT_2) { + ++(uip_connr->timer); + if(uip_connr->timer == UIP_TIME_WAIT_TIMEOUT) { + uip_connr->tcpstateflags = UIP_CLOSED; + } + } else if(uip_connr->tcpstateflags != UIP_CLOSED) { + /* If the connection has outstanding data, we increase the + connection's timer and see if it has reached the RTO value + in which case we retransmit. */ + if(uip_outstanding(uip_connr)) { + if(uip_connr->timer-- == 0) { + if(uip_connr->nrtx == UIP_MAXRTX || + ((uip_connr->tcpstateflags == UIP_SYN_SENT || + uip_connr->tcpstateflags == UIP_SYN_RCVD) && + uip_connr->nrtx == UIP_MAXSYNRTX)) { + uip_connr->tcpstateflags = UIP_CLOSED; + + /* We call UIP_APPCALL() with uip_flags set to + UIP_TIMEDOUT to inform the application that the + connection has timed out. */ + uip_flags = UIP_TIMEDOUT; + UIP_APPCALL(); + + /* We also send a reset packet to the remote host. */ + BUF->flags = TCP_RST | TCP_ACK; + goto tcp_send_nodata; + } + + /* Exponential backoff. */ + uip_connr->timer = UIP_RTO << (uip_connr->nrtx > 4? + 4: + uip_connr->nrtx); + ++(uip_connr->nrtx); + + /* Ok, so we need to retransmit. We do this differently + depending on which state we are in. In ESTABLISHED, we + call upon the application so that it may prepare the + data for the retransmit. In SYN_RCVD, we resend the + SYNACK that we sent earlier and in LAST_ACK we have to + retransmit our FINACK. */ + UIP_STAT(++uip_stat.tcp.rexmit); + switch(uip_connr->tcpstateflags & UIP_TS_MASK) { + case UIP_SYN_RCVD: + /* In the SYN_RCVD state, we should retransmit our + SYNACK. */ + goto tcp_send_synack; + +#if UIP_ACTIVE_OPEN + case UIP_SYN_SENT: + /* In the SYN_SENT state, we retransmit out SYN. */ + BUF->flags = 0; + goto tcp_send_syn; +#endif /* UIP_ACTIVE_OPEN */ + + case UIP_ESTABLISHED: + /* In the ESTABLISHED state, we call upon the application + to do the actual retransmit after which we jump into + the code for sending out the packet (the apprexmit + label). */ + uip_flags = UIP_REXMIT; + UIP_APPCALL(); + goto apprexmit; + + case UIP_FIN_WAIT_1: + case UIP_CLOSING: + case UIP_LAST_ACK: + /* In all these states we should retransmit a FINACK. */ + goto tcp_send_finack; + + } + } + } else if((uip_connr->tcpstateflags & UIP_TS_MASK) == UIP_ESTABLISHED) { + /* If there was no need for a retransmission, we poll the + application for new data. */ + uip_flags = UIP_POLL; + UIP_APPCALL(); + goto appsend; + } + } + goto drop; + } +#if UIP_UDP + if(flag == UIP_UDP_TIMER) { + if(uip_udp_conn->lport != 0) { + uip_conn = NULL; + uip_sappdata = uip_appdata = &uip_buf[UIP_LLH_LEN + UIP_IPUDPH_LEN]; + uip_len = uip_slen = 0; + uip_flags = UIP_POLL; + UIP_UDP_APPCALL(); + goto udp_send; + } else { + goto drop; + } + } +#endif + + /* This is where the input processing starts. */ + UIP_STAT(++uip_stat.ip.recv); + + /* Start of IP input header processing code. */ + +#if UIP_CONF_IPV6 + /* Check validity of the IP header. */ + if((BUF->vtc & 0xf0) != 0x60) { /* IP version and header length. */ + UIP_STAT(++uip_stat.ip.drop); + UIP_STAT(++uip_stat.ip.vhlerr); + UIP_LOG("ipv6: invalid version."); + goto drop; + } +#else /* UIP_CONF_IPV6 */ + /* Check validity of the IP header. */ + if(BUF->vhl != 0x45) { /* IP version and header length. */ + UIP_STAT(++uip_stat.ip.drop); + UIP_STAT(++uip_stat.ip.vhlerr); + UIP_LOG("ip: invalid version or header length."); + goto drop; + } +#endif /* UIP_CONF_IPV6 */ + + /* Check the size of the packet. If the size reported to us in + uip_len is smaller the size reported in the IP header, we assume + that the packet has been corrupted in transit. If the size of + uip_len is larger than the size reported in the IP packet header, + the packet has been padded and we set uip_len to the correct + value.. */ + + if((BUF->len[0] << 8) + BUF->len[1] <= uip_len) { + uip_len = (BUF->len[0] << 8) + BUF->len[1]; +#if UIP_CONF_IPV6 + uip_len += 40; /* The length reported in the IPv6 header is the + length of the payload that follows the + header. However, uIP uses the uip_len variable + for holding the size of the entire packet, + including the IP header. For IPv4 this is not a + problem as the length field in the IPv4 header + contains the length of the entire packet. But + for IPv6 we need to add the size of the IPv6 + header (40 bytes). */ +#endif /* UIP_CONF_IPV6 */ + } else { + UIP_LOG("ip: packet shorter than reported in IP header."); + goto drop; + } + +#if !UIP_CONF_IPV6 + /* Check the fragment flag. */ + if((BUF->ipoffset[0] & 0x3f) != 0 || + BUF->ipoffset[1] != 0) { +#if UIP_REASSEMBLY + uip_len = uip_reass(); + if(uip_len == 0) { + goto drop; + } +#else /* UIP_REASSEMBLY */ + UIP_STAT(++uip_stat.ip.drop); + UIP_STAT(++uip_stat.ip.fragerr); + UIP_LOG("ip: fragment dropped."); + goto drop; +#endif /* UIP_REASSEMBLY */ + } +#endif /* UIP_CONF_IPV6 */ + + if(uip_ipaddr_cmp(uip_hostaddr, all_zeroes_addr)) { + /* If we are configured to use ping IP address configuration and + hasn't been assigned an IP address yet, we accept all ICMP + packets. */ +#if UIP_PINGADDRCONF && !UIP_CONF_IPV6 + if(BUF->proto == UIP_PROTO_ICMP) { + UIP_LOG("ip: possible ping config packet received."); + goto icmp_input; + } else { + UIP_LOG("ip: packet dropped since no address assigned."); + goto drop; + } +#endif /* UIP_PINGADDRCONF */ + + } else { + /* If IP broadcast support is configured, we check for a broadcast + UDP packet, which may be destined to us. */ +#if UIP_BROADCAST + DEBUG_PRINTF("UDP IP checksum 0x%04x\n", uip_ipchksum()); + if(BUF->proto == UIP_PROTO_UDP && + uip_ipaddr_cmp(BUF->destipaddr, all_ones_addr) + /*&& + uip_ipchksum() == 0xffff*/) { + goto udp_input; + } +#endif /* UIP_BROADCAST */ + + /* Check if the packet is destined for our IP address. */ +#if !UIP_CONF_IPV6 + if(!uip_ipaddr_cmp(BUF->destipaddr, uip_hostaddr)) { + UIP_STAT(++uip_stat.ip.drop); + goto drop; + } +#else /* UIP_CONF_IPV6 */ + /* For IPv6, packet reception is a little trickier as we need to + make sure that we listen to certain multicast addresses (all + hosts multicast address, and the solicited-node multicast + address) as well. However, we will cheat here and accept all + multicast packets that are sent to the ff02::/16 addresses. */ + if(!uip_ipaddr_cmp(BUF->destipaddr, uip_hostaddr) && + BUF->destipaddr[0] != HTONS(0xff02)) { + UIP_STAT(++uip_stat.ip.drop); + goto drop; + } +#endif /* UIP_CONF_IPV6 */ + } + +#if !UIP_CONF_IPV6 + if(uip_ipchksum() != 0xffff) { /* Compute and check the IP header + checksum. */ + UIP_STAT(++uip_stat.ip.drop); + UIP_STAT(++uip_stat.ip.chkerr); + UIP_LOG("ip: bad checksum."); + goto drop; + } +#endif /* UIP_CONF_IPV6 */ + + if(BUF->proto == UIP_PROTO_TCP) { /* Check for TCP packet. If so, + proceed with TCP input + processing. */ + goto tcp_input; + } + +#if UIP_UDP + if(BUF->proto == UIP_PROTO_UDP) { + goto udp_input; + } +#endif /* UIP_UDP */ + +#if !UIP_CONF_IPV6 + /* ICMPv4 processing code follows. */ + if(BUF->proto != UIP_PROTO_ICMP) { /* We only allow ICMP packets from + here. */ + UIP_STAT(++uip_stat.ip.drop); + UIP_STAT(++uip_stat.ip.protoerr); + UIP_LOG("ip: neither tcp nor icmp."); + goto drop; + } + +#if UIP_PINGADDRCONF + icmp_input: +#endif /* UIP_PINGADDRCONF */ + UIP_STAT(++uip_stat.icmp.recv); + + /* ICMP echo (i.e., ping) processing. This is simple, we only change + the ICMP type from ECHO to ECHO_REPLY and adjust the ICMP + checksum before we return the packet. */ + if(ICMPBUF->type != ICMP_ECHO) { + UIP_STAT(++uip_stat.icmp.drop); + UIP_STAT(++uip_stat.icmp.typeerr); + UIP_LOG("icmp: not icmp echo."); + goto drop; + } + + /* If we are configured to use ping IP address assignment, we use + the destination IP address of this ping packet and assign it to + ourself. */ +#if UIP_PINGADDRCONF + if((uip_hostaddr[0] | uip_hostaddr[1]) == 0) { + uip_hostaddr[0] = BUF->destipaddr[0]; + uip_hostaddr[1] = BUF->destipaddr[1]; + } +#endif /* UIP_PINGADDRCONF */ + + ICMPBUF->type = ICMP_ECHO_REPLY; + + if(ICMPBUF->icmpchksum >= HTONS(0xffff - (ICMP_ECHO << 8))) { + ICMPBUF->icmpchksum += HTONS(ICMP_ECHO << 8) + 1; + } else { + ICMPBUF->icmpchksum += HTONS(ICMP_ECHO << 8); + } + + /* Swap IP addresses. */ + uip_ipaddr_copy(BUF->destipaddr, BUF->srcipaddr); + uip_ipaddr_copy(BUF->srcipaddr, uip_hostaddr); + + UIP_STAT(++uip_stat.icmp.sent); + goto send; + + /* End of IPv4 input header processing code. */ +#else /* !UIP_CONF_IPV6 */ + + /* This is IPv6 ICMPv6 processing code. */ + DEBUG_PRINTF("icmp6_input: length %d\n", uip_len); + + if(BUF->proto != UIP_PROTO_ICMP6) { /* We only allow ICMPv6 packets from + here. */ + UIP_STAT(++uip_stat.ip.drop); + UIP_STAT(++uip_stat.ip.protoerr); + UIP_LOG("ip: neither tcp nor icmp6."); + goto drop; + } + + UIP_STAT(++uip_stat.icmp.recv); + + /* If we get a neighbor solicitation for our address we should send + a neighbor advertisement message back. */ + if(ICMPBUF->type == ICMP6_NEIGHBOR_SOLICITATION) { + if(uip_ipaddr_cmp(ICMPBUF->icmp6data, uip_hostaddr)) { + + if(ICMPBUF->options[0] == ICMP6_OPTION_SOURCE_LINK_ADDRESS) { + /* Save the sender's address in our neighbor list. */ + uip_neighbor_add(ICMPBUF->srcipaddr, &(ICMPBUF->options[2])); + } + + /* We should now send a neighbor advertisement back to where the + neighbor solicication came from. */ + ICMPBUF->type = ICMP6_NEIGHBOR_ADVERTISEMENT; + ICMPBUF->flags = ICMP6_FLAG_S; /* Solicited flag. */ + + ICMPBUF->reserved1 = ICMPBUF->reserved2 = ICMPBUF->reserved3 = 0; + + uip_ipaddr_copy(ICMPBUF->destipaddr, ICMPBUF->srcipaddr); + uip_ipaddr_copy(ICMPBUF->srcipaddr, uip_hostaddr); + ICMPBUF->options[0] = ICMP6_OPTION_TARGET_LINK_ADDRESS; + ICMPBUF->options[1] = 1; /* Options length, 1 = 8 bytes. */ + memcpy(&(ICMPBUF->options[2]), &uip_ethaddr, sizeof(uip_ethaddr)); + ICMPBUF->icmpchksum = 0; + ICMPBUF->icmpchksum = ~uip_icmp6chksum(); + goto send; + + } + goto drop; + } else if(ICMPBUF->type == ICMP6_ECHO) { + /* ICMP echo (i.e., ping) processing. This is simple, we only + change the ICMP type from ECHO to ECHO_REPLY and update the + ICMP checksum before we return the packet. */ + + ICMPBUF->type = ICMP6_ECHO_REPLY; + + uip_ipaddr_copy(BUF->destipaddr, BUF->srcipaddr); + uip_ipaddr_copy(BUF->srcipaddr, uip_hostaddr); + ICMPBUF->icmpchksum = 0; + ICMPBUF->icmpchksum = ~uip_icmp6chksum(); + + UIP_STAT(++uip_stat.icmp.sent); + goto send; + } else { + DEBUG_PRINTF("Unknown icmp6 message type %d\n", ICMPBUF->type); + UIP_STAT(++uip_stat.icmp.drop); + UIP_STAT(++uip_stat.icmp.typeerr); + UIP_LOG("icmp: unknown ICMP message."); + goto drop; + } + + /* End of IPv6 ICMP processing. */ + +#endif /* !UIP_CONF_IPV6 */ + +#if UIP_UDP + /* UDP input processing. */ + udp_input: + /* UDP processing is really just a hack. We don't do anything to the + UDP/IP headers, but let the UDP application do all the hard + work. If the application sets uip_slen, it has a packet to + send. */ +#if UIP_UDP_CHECKSUMS + uip_len = uip_len - UIP_IPUDPH_LEN; + uip_appdata = &uip_buf[UIP_LLH_LEN + UIP_IPUDPH_LEN]; + if(UDPBUF->udpchksum != 0 && uip_udpchksum() != 0xffff) { + UIP_STAT(++uip_stat.udp.drop); + UIP_STAT(++uip_stat.udp.chkerr); + UIP_LOG("udp: bad checksum."); + goto drop; + } +#else /* UIP_UDP_CHECKSUMS */ + uip_len = uip_len - UIP_IPUDPH_LEN; +#endif /* UIP_UDP_CHECKSUMS */ + + /* Demultiplex this UDP packet between the UDP "connections". */ + for(uip_udp_conn = &uip_udp_conns[0]; + uip_udp_conn < &uip_udp_conns[UIP_UDP_CONNS]; + ++uip_udp_conn) { + /* If the local UDP port is non-zero, the connection is considered + to be used. If so, the local port number is checked against the + destination port number in the received packet. If the two port + numbers match, the remote port number is checked if the + connection is bound to a remote port. Finally, if the + connection is bound to a remote IP address, the source IP + address of the packet is checked. */ + if(uip_udp_conn->lport != 0 && + UDPBUF->destport == uip_udp_conn->lport && + (uip_udp_conn->rport == 0 || + UDPBUF->srcport == uip_udp_conn->rport) && + (uip_ipaddr_cmp(uip_udp_conn->ripaddr, all_zeroes_addr) || + uip_ipaddr_cmp(uip_udp_conn->ripaddr, all_ones_addr) || + uip_ipaddr_cmp(BUF->srcipaddr, uip_udp_conn->ripaddr))) { + goto udp_found; + } + } + UIP_LOG("udp: no matching connection found"); + goto drop; + + udp_found: + uip_conn = NULL; + uip_flags = UIP_NEWDATA; + uip_sappdata = uip_appdata = &uip_buf[UIP_LLH_LEN + UIP_IPUDPH_LEN]; + uip_slen = 0; + UIP_UDP_APPCALL(); + udp_send: + if(uip_slen == 0) { + goto drop; + } + uip_len = uip_slen + UIP_IPUDPH_LEN; + +#if UIP_CONF_IPV6 + /* For IPv6, the IP length field does not include the IPv6 IP header + length. */ + BUF->len[0] = ((uip_len - UIP_IPH_LEN) >> 8); + BUF->len[1] = ((uip_len - UIP_IPH_LEN) & 0xff); +#else /* UIP_CONF_IPV6 */ + BUF->len[0] = (uip_len >> 8); + BUF->len[1] = (uip_len & 0xff); +#endif /* UIP_CONF_IPV6 */ + + BUF->ttl = uip_udp_conn->ttl; + BUF->proto = UIP_PROTO_UDP; + + UDPBUF->udplen = HTONS(uip_slen + UIP_UDPH_LEN); + UDPBUF->udpchksum = 0; + + BUF->srcport = uip_udp_conn->lport; + BUF->destport = uip_udp_conn->rport; + + uip_ipaddr_copy(BUF->srcipaddr, uip_hostaddr); + uip_ipaddr_copy(BUF->destipaddr, uip_udp_conn->ripaddr); + + uip_appdata = &uip_buf[UIP_LLH_LEN + UIP_IPTCPH_LEN]; + +#if UIP_UDP_CHECKSUMS + /* Calculate UDP checksum. */ + UDPBUF->udpchksum = ~(uip_udpchksum()); + if(UDPBUF->udpchksum == 0) { + UDPBUF->udpchksum = 0xffff; + } +#endif /* UIP_UDP_CHECKSUMS */ + + goto ip_send_nolen; +#endif /* UIP_UDP */ + + /* TCP input processing. */ + tcp_input: + UIP_STAT(++uip_stat.tcp.recv); + + /* Start of TCP input header processing code. */ + + if(uip_tcpchksum() != 0xffff) { /* Compute and check the TCP + checksum. */ + UIP_STAT(++uip_stat.tcp.drop); + UIP_STAT(++uip_stat.tcp.chkerr); + UIP_LOG("tcp: bad checksum."); + goto drop; + } + + + /* Demultiplex this segment. */ + /* First check any active connections. */ + for(uip_connr = &uip_conns[0]; uip_connr <= &uip_conns[UIP_CONNS - 1]; + ++uip_connr) { + if(uip_connr->tcpstateflags != UIP_CLOSED && + BUF->destport == uip_connr->lport && + BUF->srcport == uip_connr->rport && + uip_ipaddr_cmp(BUF->srcipaddr, uip_connr->ripaddr)) { + goto found; + } + } + + /* If we didn't find and active connection that expected the packet, + either this packet is an old duplicate, or this is a SYN packet + destined for a connection in LISTEN. If the SYN flag isn't set, + it is an old packet and we send a RST. */ + if((BUF->flags & TCP_CTL) != TCP_SYN) { + goto reset; + } + + tmp16 = BUF->destport; + /* Next, check listening connections. */ + for(c = 0; c < UIP_LISTENPORTS; ++c) { + if(tmp16 == uip_listenports[c]) + goto found_listen; + } + + /* No matching connection found, so we send a RST packet. */ + UIP_STAT(++uip_stat.tcp.synrst); + reset: + + /* We do not send resets in response to resets. */ + if(BUF->flags & TCP_RST) { + goto drop; + } + + UIP_STAT(++uip_stat.tcp.rst); + + BUF->flags = TCP_RST | TCP_ACK; + uip_len = UIP_IPTCPH_LEN; + BUF->tcpoffset = 5 << 4; + + /* Flip the seqno and ackno fields in the TCP header. */ + c = BUF->seqno[3]; + BUF->seqno[3] = BUF->ackno[3]; + BUF->ackno[3] = c; + + c = BUF->seqno[2]; + BUF->seqno[2] = BUF->ackno[2]; + BUF->ackno[2] = c; + + c = BUF->seqno[1]; + BUF->seqno[1] = BUF->ackno[1]; + BUF->ackno[1] = c; + + c = BUF->seqno[0]; + BUF->seqno[0] = BUF->ackno[0]; + BUF->ackno[0] = c; + + /* We also have to increase the sequence number we are + acknowledging. If the least significant byte overflowed, we need + to propagate the carry to the other bytes as well. */ + if(++BUF->ackno[3] == 0) { + if(++BUF->ackno[2] == 0) { + if(++BUF->ackno[1] == 0) { + ++BUF->ackno[0]; + } + } + } + + /* Swap port numbers. */ + tmp16 = BUF->srcport; + BUF->srcport = BUF->destport; + BUF->destport = tmp16; + + /* Swap IP addresses. */ + uip_ipaddr_copy(BUF->destipaddr, BUF->srcipaddr); + uip_ipaddr_copy(BUF->srcipaddr, uip_hostaddr); + + /* And send out the RST packet! */ + goto tcp_send_noconn; + + /* This label will be jumped to if we matched the incoming packet + with a connection in LISTEN. In that case, we should create a new + connection and send a SYNACK in return. */ + found_listen: + /* First we check if there are any connections avaliable. Unused + connections are kept in the same table as used connections, but + unused ones have the tcpstate set to CLOSED. Also, connections in + TIME_WAIT are kept track of and we'll use the oldest one if no + CLOSED connections are found. Thanks to Eddie C. Dost for a very + nice algorithm for the TIME_WAIT search. */ + uip_connr = 0; + for(c = 0; c < UIP_CONNS; ++c) { + if(uip_conns[c].tcpstateflags == UIP_CLOSED) { + uip_connr = &uip_conns[c]; + break; + } + if(uip_conns[c].tcpstateflags == UIP_TIME_WAIT) { + if(uip_connr == 0 || + uip_conns[c].timer > uip_connr->timer) { + uip_connr = &uip_conns[c]; + } + } + } + + if(uip_connr == 0) { + /* All connections are used already, we drop packet and hope that + the remote end will retransmit the packet at a time when we + have more spare connections. */ + UIP_STAT(++uip_stat.tcp.syndrop); + UIP_LOG("tcp: found no unused connections."); + goto drop; + } + uip_conn = uip_connr; + + /* Fill in the necessary fields for the new connection. */ + uip_connr->rto = uip_connr->timer = UIP_RTO; + uip_connr->sa = 0; + uip_connr->sv = 4; + uip_connr->nrtx = 0; + uip_connr->lport = BUF->destport; + uip_connr->rport = BUF->srcport; + uip_ipaddr_copy(uip_connr->ripaddr, BUF->srcipaddr); + uip_connr->tcpstateflags = UIP_SYN_RCVD; + + uip_connr->snd_nxt[0] = iss[0]; + uip_connr->snd_nxt[1] = iss[1]; + uip_connr->snd_nxt[2] = iss[2]; + uip_connr->snd_nxt[3] = iss[3]; + uip_connr->len = 1; + + /* rcv_nxt should be the seqno from the incoming packet + 1. */ + uip_connr->rcv_nxt[3] = BUF->seqno[3]; + uip_connr->rcv_nxt[2] = BUF->seqno[2]; + uip_connr->rcv_nxt[1] = BUF->seqno[1]; + uip_connr->rcv_nxt[0] = BUF->seqno[0]; + uip_add_rcv_nxt(1); + + /* Parse the TCP MSS option, if present. */ + if((BUF->tcpoffset & 0xf0) > 0x50) { + for(c = 0; c < ((BUF->tcpoffset >> 4) - 5) << 2 ;) { + opt = uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + c]; + if(opt == TCP_OPT_END) { + /* End of options. */ + break; + } else if(opt == TCP_OPT_NOOP) { + ++c; + /* NOP option. */ + } else if(opt == TCP_OPT_MSS && + uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + 1 + c] == TCP_OPT_MSS_LEN) { + /* An MSS option with the right option length. */ + tmp16 = ((u16_t)uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + 2 + c] << 8) | + (u16_t)uip_buf[UIP_IPTCPH_LEN + UIP_LLH_LEN + 3 + c]; + uip_connr->initialmss = uip_connr->mss = + tmp16 > UIP_TCP_MSS? UIP_TCP_MSS: tmp16; + + /* And we are done processing options. */ + break; + } else { + /* All other options have a length field, so that we easily + can skip past them. */ + if(uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + 1 + c] == 0) { + /* If the length field is zero, the options are malformed + and we don't process them further. */ + break; + } + c += uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + 1 + c]; + } + } + } + + /* Our response will be a SYNACK. */ +#if UIP_ACTIVE_OPEN + tcp_send_synack: + BUF->flags = TCP_ACK; + + tcp_send_syn: + BUF->flags |= TCP_SYN; +#else /* UIP_ACTIVE_OPEN */ + tcp_send_synack: + BUF->flags = TCP_SYN | TCP_ACK; +#endif /* UIP_ACTIVE_OPEN */ + + /* We send out the TCP Maximum Segment Size option with our + SYNACK. */ + BUF->optdata[0] = TCP_OPT_MSS; + BUF->optdata[1] = TCP_OPT_MSS_LEN; + BUF->optdata[2] = (UIP_TCP_MSS) / 256; + BUF->optdata[3] = (UIP_TCP_MSS) & 255; + uip_len = UIP_IPTCPH_LEN + TCP_OPT_MSS_LEN; + BUF->tcpoffset = ((UIP_TCPH_LEN + TCP_OPT_MSS_LEN) / 4) << 4; + goto tcp_send; + + /* This label will be jumped to if we found an active connection. */ + found: + uip_conn = uip_connr; + uip_flags = 0; + /* We do a very naive form of TCP reset processing; we just accept + any RST and kill our connection. We should in fact check if the + sequence number of this reset is wihtin our advertised window + before we accept the reset. */ + if(BUF->flags & TCP_RST) { + uip_connr->tcpstateflags = UIP_CLOSED; + UIP_LOG("tcp: got reset, aborting connection."); + uip_flags = UIP_ABORT; + UIP_APPCALL(); + goto drop; + } + /* Calculated the length of the data, if the application has sent + any data to us. */ + c = (BUF->tcpoffset >> 4) << 2; + /* uip_len will contain the length of the actual TCP data. This is + calculated by subtracing the length of the TCP header (in + c) and the length of the IP header (20 bytes). */ + uip_len = uip_len - c - UIP_IPH_LEN; + + /* First, check if the sequence number of the incoming packet is + what we're expecting next. If not, we send out an ACK with the + correct numbers in. */ + if(!(((uip_connr->tcpstateflags & UIP_TS_MASK) == UIP_SYN_SENT) && + ((BUF->flags & TCP_CTL) == (TCP_SYN | TCP_ACK)))) { + if((uip_len > 0 || ((BUF->flags & (TCP_SYN | TCP_FIN)) != 0)) && + (BUF->seqno[0] != uip_connr->rcv_nxt[0] || + BUF->seqno[1] != uip_connr->rcv_nxt[1] || + BUF->seqno[2] != uip_connr->rcv_nxt[2] || + BUF->seqno[3] != uip_connr->rcv_nxt[3])) { + goto tcp_send_ack; + } + } + + /* Next, check if the incoming segment acknowledges any outstanding + data. If so, we update the sequence number, reset the length of + the outstanding data, calculate RTT estimations, and reset the + retransmission timer. */ + if((BUF->flags & TCP_ACK) && uip_outstanding(uip_connr)) { + uip_add32(uip_connr->snd_nxt, uip_connr->len); + + if(BUF->ackno[0] == uip_acc32[0] && + BUF->ackno[1] == uip_acc32[1] && + BUF->ackno[2] == uip_acc32[2] && + BUF->ackno[3] == uip_acc32[3]) { + /* Update sequence number. */ + uip_connr->snd_nxt[0] = uip_acc32[0]; + uip_connr->snd_nxt[1] = uip_acc32[1]; + uip_connr->snd_nxt[2] = uip_acc32[2]; + uip_connr->snd_nxt[3] = uip_acc32[3]; + + + /* Do RTT estimation, unless we have done retransmissions. */ + if(uip_connr->nrtx == 0) { + signed char m; + m = uip_connr->rto - uip_connr->timer; + /* This is taken directly from VJs original code in his paper */ + m = m - (uip_connr->sa >> 3); + uip_connr->sa += m; + if(m < 0) { + m = -m; + } + m = m - (uip_connr->sv >> 2); + uip_connr->sv += m; + uip_connr->rto = (uip_connr->sa >> 3) + uip_connr->sv; + + } + /* Set the acknowledged flag. */ + uip_flags = UIP_ACKDATA; + /* Reset the retransmission timer. */ + uip_connr->timer = uip_connr->rto; + + /* Reset length of outstanding data. */ + uip_connr->len = 0; + } + + } + + /* Do different things depending on in what state the connection is. */ + switch(uip_connr->tcpstateflags & UIP_TS_MASK) { + /* CLOSED and LISTEN are not handled here. CLOSE_WAIT is not + implemented, since we force the application to close when the + peer sends a FIN (hence the application goes directly from + ESTABLISHED to LAST_ACK). */ + case UIP_SYN_RCVD: + /* In SYN_RCVD we have sent out a SYNACK in response to a SYN, and + we are waiting for an ACK that acknowledges the data we sent + out the last time. Therefore, we want to have the UIP_ACKDATA + flag set. If so, we enter the ESTABLISHED state. */ + if(uip_flags & UIP_ACKDATA) { + uip_connr->tcpstateflags = UIP_ESTABLISHED; + uip_flags = UIP_CONNECTED; + uip_connr->len = 0; + if(uip_len > 0) { + uip_flags |= UIP_NEWDATA; + uip_add_rcv_nxt(uip_len); + } + uip_slen = 0; + UIP_APPCALL(); + goto appsend; + } + goto drop; +#if UIP_ACTIVE_OPEN + case UIP_SYN_SENT: + /* In SYN_SENT, we wait for a SYNACK that is sent in response to + our SYN. The rcv_nxt is set to sequence number in the SYNACK + plus one, and we send an ACK. We move into the ESTABLISHED + state. */ + if((uip_flags & UIP_ACKDATA) && + (BUF->flags & TCP_CTL) == (TCP_SYN | TCP_ACK)) { + + /* Parse the TCP MSS option, if present. */ + if((BUF->tcpoffset & 0xf0) > 0x50) { + for(c = 0; c < ((BUF->tcpoffset >> 4) - 5) << 2 ;) { + opt = uip_buf[UIP_IPTCPH_LEN + UIP_LLH_LEN + c]; + if(opt == TCP_OPT_END) { + /* End of options. */ + break; + } else if(opt == TCP_OPT_NOOP) { + ++c; + /* NOP option. */ + } else if(opt == TCP_OPT_MSS && + uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + 1 + c] == TCP_OPT_MSS_LEN) { + /* An MSS option with the right option length. */ + tmp16 = (uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + 2 + c] << 8) | + uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + 3 + c]; + uip_connr->initialmss = + uip_connr->mss = tmp16 > UIP_TCP_MSS? UIP_TCP_MSS: tmp16; + + /* And we are done processing options. */ + break; + } else { + /* All other options have a length field, so that we easily + can skip past them. */ + if(uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + 1 + c] == 0) { + /* If the length field is zero, the options are malformed + and we don't process them further. */ + break; + } + c += uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + 1 + c]; + } + } + } + uip_connr->tcpstateflags = UIP_ESTABLISHED; + uip_connr->rcv_nxt[0] = BUF->seqno[0]; + uip_connr->rcv_nxt[1] = BUF->seqno[1]; + uip_connr->rcv_nxt[2] = BUF->seqno[2]; + uip_connr->rcv_nxt[3] = BUF->seqno[3]; + uip_add_rcv_nxt(1); + uip_flags = UIP_CONNECTED | UIP_NEWDATA; + uip_connr->len = 0; + uip_len = 0; + uip_slen = 0; + UIP_APPCALL(); + goto appsend; + } + /* Inform the application that the connection failed */ + uip_flags = UIP_ABORT; + UIP_APPCALL(); + /* The connection is closed after we send the RST */ + uip_conn->tcpstateflags = UIP_CLOSED; + goto reset; +#endif /* UIP_ACTIVE_OPEN */ + + case UIP_ESTABLISHED: + /* In the ESTABLISHED state, we call upon the application to feed + data into the uip_buf. If the UIP_ACKDATA flag is set, the + application should put new data into the buffer, otherwise we are + retransmitting an old segment, and the application should put that + data into the buffer. + + If the incoming packet is a FIN, we should close the connection on + this side as well, and we send out a FIN and enter the LAST_ACK + state. We require that there is no outstanding data; otherwise the + sequence numbers will be screwed up. */ + + if(BUF->flags & TCP_FIN && !(uip_connr->tcpstateflags & UIP_STOPPED)) { + if(uip_outstanding(uip_connr)) { + goto drop; + } + uip_add_rcv_nxt(1 + uip_len); + uip_flags |= UIP_CLOSE; + if(uip_len > 0) { + uip_flags |= UIP_NEWDATA; + } + UIP_APPCALL(); + uip_connr->len = 1; + uip_connr->tcpstateflags = UIP_LAST_ACK; + uip_connr->nrtx = 0; + tcp_send_finack: + BUF->flags = TCP_FIN | TCP_ACK; + goto tcp_send_nodata; + } + + /* Check the URG flag. If this is set, the segment carries urgent + data that we must pass to the application. */ + if((BUF->flags & TCP_URG) != 0) { +#if UIP_URGDATA > 0 + uip_urglen = (BUF->urgp[0] << 8) | BUF->urgp[1]; + if(uip_urglen > uip_len) { + /* There is more urgent data in the next segment to come. */ + uip_urglen = uip_len; + } + uip_add_rcv_nxt(uip_urglen); + uip_len -= uip_urglen; + uip_urgdata = uip_appdata; + uip_appdata += uip_urglen; + } else { + uip_urglen = 0; +#else /* UIP_URGDATA > 0 */ + uip_appdata = ((char *)uip_appdata) + ((BUF->urgp[0] << 8) | BUF->urgp[1]); + uip_len -= (BUF->urgp[0] << 8) | BUF->urgp[1]; +#endif /* UIP_URGDATA > 0 */ + } + + /* If uip_len > 0 we have TCP data in the packet, and we flag this + by setting the UIP_NEWDATA flag and update the sequence number + we acknowledge. If the application has stopped the dataflow + using uip_stop(), we must not accept any data packets from the + remote host. */ + if(uip_len > 0 && !(uip_connr->tcpstateflags & UIP_STOPPED)) { + uip_flags |= UIP_NEWDATA; + uip_add_rcv_nxt(uip_len); + } + + /* Check if the available buffer space advertised by the other end + is smaller than the initial MSS for this connection. If so, we + set the current MSS to the window size to ensure that the + application does not send more data than the other end can + handle. + + If the remote host advertises a zero window, we set the MSS to + the initial MSS so that the application will send an entire MSS + of data. This data will not be acknowledged by the receiver, + and the application will retransmit it. This is called the + "persistent timer" and uses the retransmission mechanim. + */ + tmp16 = ((u16_t)BUF->wnd[0] << 8) + (u16_t)BUF->wnd[1]; + if(tmp16 > uip_connr->initialmss || + tmp16 == 0) { + tmp16 = uip_connr->initialmss; + } + uip_connr->mss = tmp16; + + /* If this packet constitutes an ACK for outstanding data (flagged + by the UIP_ACKDATA flag, we should call the application since it + might want to send more data. If the incoming packet had data + from the peer (as flagged by the UIP_NEWDATA flag), the + application must also be notified. + + When the application is called, the global variable uip_len + contains the length of the incoming data. The application can + access the incoming data through the global pointer + uip_appdata, which usually points UIP_IPTCPH_LEN + UIP_LLH_LEN + bytes into the uip_buf array. + + If the application wishes to send any data, this data should be + put into the uip_appdata and the length of the data should be + put into uip_len. If the application don't have any data to + send, uip_len must be set to 0. */ + if(uip_flags & (UIP_NEWDATA | UIP_ACKDATA)) { + uip_slen = 0; + UIP_APPCALL(); + + appsend: + + if(uip_flags & UIP_ABORT) { + uip_slen = 0; + uip_connr->tcpstateflags = UIP_CLOSED; + BUF->flags = TCP_RST | TCP_ACK; + goto tcp_send_nodata; + } + + if(uip_flags & UIP_CLOSE) { + uip_slen = 0; + uip_connr->len = 1; + uip_connr->tcpstateflags = UIP_FIN_WAIT_1; + uip_connr->nrtx = 0; + BUF->flags = TCP_FIN | TCP_ACK; + goto tcp_send_nodata; + } + + /* If uip_slen > 0, the application has data to be sent. */ + if(uip_slen > 0) { + + /* If the connection has acknowledged data, the contents of + the ->len variable should be discarded. */ + if((uip_flags & UIP_ACKDATA) != 0) { + uip_connr->len = 0; + } + + /* If the ->len variable is non-zero the connection has + already data in transit and cannot send anymore right + now. */ + if(uip_connr->len == 0) { + + /* The application cannot send more than what is allowed by + the mss (the minumum of the MSS and the available + window). */ + if(uip_slen > uip_connr->mss) { + uip_slen = uip_connr->mss; + } + + /* Remember how much data we send out now so that we know + when everything has been acknowledged. */ + uip_connr->len = uip_slen; + } else { + + /* If the application already had unacknowledged data, we + make sure that the application does not send (i.e., + retransmit) out more than it previously sent out. */ + uip_slen = uip_connr->len; + } + } + uip_connr->nrtx = 0; + apprexmit: + uip_appdata = uip_sappdata; + + /* If the application has data to be sent, or if the incoming + packet had new data in it, we must send out a packet. */ + if(uip_slen > 0 && uip_connr->len > 0) { + /* Add the length of the IP and TCP headers. */ + uip_len = uip_connr->len + UIP_TCPIP_HLEN; + /* We always set the ACK flag in response packets. */ + BUF->flags = TCP_ACK | TCP_PSH; + /* Send the packet. */ + goto tcp_send_noopts; + } + /* If there is no data to send, just send out a pure ACK if + there is newdata. */ + if(uip_flags & UIP_NEWDATA) { + uip_len = UIP_TCPIP_HLEN; + BUF->flags = TCP_ACK; + goto tcp_send_noopts; + } + } + goto drop; + case UIP_LAST_ACK: + /* We can close this connection if the peer has acknowledged our + FIN. This is indicated by the UIP_ACKDATA flag. */ + if(uip_flags & UIP_ACKDATA) { + uip_connr->tcpstateflags = UIP_CLOSED; + uip_flags = UIP_CLOSE; + UIP_APPCALL(); + } + break; + + case UIP_FIN_WAIT_1: + /* The application has closed the connection, but the remote host + hasn't closed its end yet. Thus we do nothing but wait for a + FIN from the other side. */ + if(uip_len > 0) { + uip_add_rcv_nxt(uip_len); + } + if(BUF->flags & TCP_FIN) { + if(uip_flags & UIP_ACKDATA) { + uip_connr->tcpstateflags = UIP_TIME_WAIT; + uip_connr->timer = 0; + uip_connr->len = 0; + } else { + uip_connr->tcpstateflags = UIP_CLOSING; + } + uip_add_rcv_nxt(1); + uip_flags = UIP_CLOSE; + UIP_APPCALL(); + goto tcp_send_ack; + } else if(uip_flags & UIP_ACKDATA) { + uip_connr->tcpstateflags = UIP_FIN_WAIT_2; + uip_connr->len = 0; + goto drop; + } + if(uip_len > 0) { + goto tcp_send_ack; + } + goto drop; + + case UIP_FIN_WAIT_2: + if(uip_len > 0) { + uip_add_rcv_nxt(uip_len); + } + if(BUF->flags & TCP_FIN) { + uip_connr->tcpstateflags = UIP_TIME_WAIT; + uip_connr->timer = 0; + uip_add_rcv_nxt(1); + uip_flags = UIP_CLOSE; + UIP_APPCALL(); + goto tcp_send_ack; + } + if(uip_len > 0) { + goto tcp_send_ack; + } + goto drop; + + case UIP_TIME_WAIT: + goto tcp_send_ack; + + case UIP_CLOSING: + if(uip_flags & UIP_ACKDATA) { + uip_connr->tcpstateflags = UIP_TIME_WAIT; + uip_connr->timer = 0; + } + } + goto drop; + + + /* We jump here when we are ready to send the packet, and just want + to set the appropriate TCP sequence numbers in the TCP header. */ + tcp_send_ack: + BUF->flags = TCP_ACK; + tcp_send_nodata: + uip_len = UIP_IPTCPH_LEN; + tcp_send_noopts: + BUF->tcpoffset = (UIP_TCPH_LEN / 4) << 4; + tcp_send: + /* We're done with the input processing. We are now ready to send a + reply. Our job is to fill in all the fields of the TCP and IP + headers before calculating the checksum and finally send the + packet. */ + BUF->ackno[0] = uip_connr->rcv_nxt[0]; + BUF->ackno[1] = uip_connr->rcv_nxt[1]; + BUF->ackno[2] = uip_connr->rcv_nxt[2]; + BUF->ackno[3] = uip_connr->rcv_nxt[3]; + + BUF->seqno[0] = uip_connr->snd_nxt[0]; + BUF->seqno[1] = uip_connr->snd_nxt[1]; + BUF->seqno[2] = uip_connr->snd_nxt[2]; + BUF->seqno[3] = uip_connr->snd_nxt[3]; + + BUF->proto = UIP_PROTO_TCP; + + BUF->srcport = uip_connr->lport; + BUF->destport = uip_connr->rport; + + uip_ipaddr_copy(BUF->srcipaddr, uip_hostaddr); + uip_ipaddr_copy(BUF->destipaddr, uip_connr->ripaddr); + + if(uip_connr->tcpstateflags & UIP_STOPPED) { + /* If the connection has issued uip_stop(), we advertise a zero + window so that the remote host will stop sending data. */ + BUF->wnd[0] = BUF->wnd[1] = 0; + } else { + BUF->wnd[0] = ((UIP_RECEIVE_WINDOW) >> 8); + BUF->wnd[1] = ((UIP_RECEIVE_WINDOW) & 0xff); + } + + tcp_send_noconn: + BUF->ttl = UIP_TTL; +#if UIP_CONF_IPV6 + /* For IPv6, the IP length field does not include the IPv6 IP header + length. */ + BUF->len[0] = ((uip_len - UIP_IPH_LEN) >> 8); + BUF->len[1] = ((uip_len - UIP_IPH_LEN) & 0xff); +#else /* UIP_CONF_IPV6 */ + BUF->len[0] = (uip_len >> 8); + BUF->len[1] = (uip_len & 0xff); +#endif /* UIP_CONF_IPV6 */ + + BUF->urgp[0] = BUF->urgp[1] = 0; + + /* Calculate TCP checksum. */ + BUF->tcpchksum = 0; + BUF->tcpchksum = ~(uip_tcpchksum()); + + ip_send_nolen: + +#if UIP_CONF_IPV6 + BUF->vtc = 0x60; + BUF->tcflow = 0x00; + BUF->flow = 0x00; +#else /* UIP_CONF_IPV6 */ + BUF->vhl = 0x45; + BUF->tos = 0; + BUF->ipoffset[0] = BUF->ipoffset[1] = 0; + ++ipid; + BUF->ipid[0] = ipid >> 8; + BUF->ipid[1] = ipid & 0xff; + /* Calculate IP checksum. */ + BUF->ipchksum = 0; + BUF->ipchksum = ~(uip_ipchksum()); + DEBUG_PRINTF("uip ip_send_nolen: chkecum 0x%04x\n", uip_ipchksum()); +#endif /* UIP_CONF_IPV6 */ + + UIP_STAT(++uip_stat.tcp.sent); + send: + DEBUG_PRINTF("Sending packet with length %d (%d)\n", uip_len, + (BUF->len[0] << 8) | BUF->len[1]); + + UIP_STAT(++uip_stat.ip.sent); + /* Return and let the caller do the actual transmission. */ + uip_flags = 0; + return; + drop: + uip_len = 0; + uip_flags = 0; + return; +} +/*---------------------------------------------------------------------------*/ +u16_t +htons(u16_t val) +{ + return HTONS(val); +} +/*---------------------------------------------------------------------------*/ +void +uip_send(const void *data, int len) +{ + if(len > 0) { + uip_slen = len; + if(data != uip_sappdata) { + memcpy(uip_sappdata, (data), uip_slen); + } + } +} +/** @} */ diff --git a/Tester/SW/lib/Drivers/ethernet/uip.h b/Tester/SW/lib/Drivers/ethernet/uip.h new file mode 100644 index 0000000..b70efc8 --- /dev/null +++ b/Tester/SW/lib/Drivers/ethernet/uip.h @@ -0,0 +1,1600 @@ +/** + * \addtogroup uip + * @{ + */ + +/** + * \file + * Header file for the uIP TCP/IP stack. + * \author Adam Dunkels + * + * The uIP TCP/IP stack header file contains definitions for a number + * of C macros that are used by uIP programs as well as internal uIP + * structures, TCP/IP header structures and function declarations. + * + */ + + +/* + * Copyright (c) 2001-2003, Adam Dunkels. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This file is part of the uIP TCP/IP stack. + * + * $Id: uip.h,v 1.1.2.3 2006/12/04 18:52:39 fredrikh Exp $ + * + */ + +#ifndef __UIP_H__ +#define __UIP_H__ + +#include "uipopt.h" + +/** + * Repressentation of an IP address. + * + */ +typedef u16_t uip_ip4addr_t[2]; +typedef u16_t uip_ip6addr_t[8]; +#if UIP_CONF_IPV6 +typedef uip_ip6addr_t uip_ipaddr_t; +#else /* UIP_CONF_IPV6 */ +typedef uip_ip4addr_t uip_ipaddr_t; +#endif /* UIP_CONF_IPV6 */ + +/*---------------------------------------------------------------------------*/ +/* First, the functions that should be called from the + * system. Initialization, the periodic timer and incoming packets are + * handled by the following three functions. + */ + +/** + * \defgroup uipconffunc uIP configuration functions + * @{ + * + * The uIP configuration functions are used for setting run-time + * parameters in uIP such as IP addresses. + */ + +/** + * Set the IP address of this host. + * + * The IP address is represented as a 4-byte array where the first + * octet of the IP address is put in the first member of the 4-byte + * array. + * + * Example: + \code + + uip_ipaddr_t addr; + + uip_ipaddr(&addr, 192,168,1,2); + uip_sethostaddr(&addr); + + \endcode + * \param addr A pointer to an IP address of type uip_ipaddr_t; + * + * \sa uip_ipaddr() + * + * \hideinitializer + */ +#define uip_sethostaddr(addr) uip_ipaddr_copy(uip_hostaddr, (addr)) + +/** + * Get the IP address of this host. + * + * The IP address is represented as a 4-byte array where the first + * octet of the IP address is put in the first member of the 4-byte + * array. + * + * Example: + \code + uip_ipaddr_t hostaddr; + + uip_gethostaddr(&hostaddr); + \endcode + * \param addr A pointer to a uip_ipaddr_t variable that will be + * filled in with the currently configured IP address. + * + * \hideinitializer + */ +#define uip_gethostaddr(addr) uip_ipaddr_copy((addr), uip_hostaddr) + +/** + * Set the default router's IP address. + * + * \param addr A pointer to a uip_ipaddr_t variable containing the IP + * address of the default router. + * + * \sa uip_ipaddr() + * + * \hideinitializer + */ +#define uip_setdraddr(addr) uip_ipaddr_copy(uip_draddr, (addr)) + +/** + * Set the netmask. + * + * \param addr A pointer to a uip_ipaddr_t variable containing the IP + * address of the netmask. + * + * \sa uip_ipaddr() + * + * \hideinitializer + */ +#define uip_setnetmask(addr) uip_ipaddr_copy(uip_netmask, (addr)) + + +/** + * Get the default router's IP address. + * + * \param addr A pointer to a uip_ipaddr_t variable that will be + * filled in with the IP address of the default router. + * + * \hideinitializer + */ +#define uip_getdraddr(addr) uip_ipaddr_copy((addr), uip_draddr) + +/** + * Get the netmask. + * + * \param addr A pointer to a uip_ipaddr_t variable that will be + * filled in with the value of the netmask. + * + * \hideinitializer + */ +#define uip_getnetmask(addr) uip_ipaddr_copy((addr), uip_netmask) + +/** @} */ + +/** + * \defgroup uipinit uIP initialization functions + * @{ + * + * The uIP initialization functions are used for booting uIP. + */ + +/** + * uIP initialization function. + * + * This function should be called at boot up to initilize the uIP + * TCP/IP stack. + */ +void uip_init(void); + +/** + * uIP initialization function. + * + * This function may be used at boot time to set the initial ip_id. + */ +void uip_setipid(u16_t id); + +/** @} */ + +/** + * \defgroup uipdevfunc uIP device driver functions + * @{ + * + * These functions are used by a network device driver for interacting + * with uIP. + */ + +/** + * Process an incoming packet. + * + * This function should be called when the device driver has received + * a packet from the network. The packet from the device driver must + * be present in the uip_buf buffer, and the length of the packet + * should be placed in the uip_len variable. + * + * When the function returns, there may be an outbound packet placed + * in the uip_buf packet buffer. If so, the uip_len variable is set to + * the length of the packet. If no packet is to be sent out, the + * uip_len variable is set to 0. + * + * The usual way of calling the function is presented by the source + * code below. + \code + uip_len = devicedriver_poll(); + if(uip_len > 0) { + uip_input(); + if(uip_len > 0) { + devicedriver_send(); + } + } + \endcode + * + * \note If you are writing a uIP device driver that needs ARP + * (Address Resolution Protocol), e.g., when running uIP over + * Ethernet, you will need to call the uIP ARP code before calling + * this function: + \code + #define BUF ((struct uip_eth_hdr *)&uip_buf[0]) + uip_len = ethernet_devicedrver_poll(); + if(uip_len > 0) { + if(BUF->type == HTONS(UIP_ETHTYPE_IP)) { + uip_arp_ipin(); + uip_input(); + if(uip_len > 0) { + uip_arp_out(); + ethernet_devicedriver_send(); + } + } else if(BUF->type == HTONS(UIP_ETHTYPE_ARP)) { + uip_arp_arpin(); + if(uip_len > 0) { + ethernet_devicedriver_send(); + } + } + \endcode + * + * \hideinitializer + */ +#define uip_input() uip_process(UIP_DATA) + +/** + * Periodic processing for a connection identified by its number. + * + * This function does the necessary periodic processing (timers, + * polling) for a uIP TCP conneciton, and should be called when the + * periodic uIP timer goes off. It should be called for every + * connection, regardless of whether they are open of closed. + * + * When the function returns, it may have an outbound packet waiting + * for service in the uIP packet buffer, and if so the uip_len + * variable is set to a value larger than zero. The device driver + * should be called to send out the packet. + * + * The ususal way of calling the function is through a for() loop like + * this: + \code + for(i = 0; i < UIP_CONNS; ++i) { + uip_periodic(i); + if(uip_len > 0) { + devicedriver_send(); + } + } + \endcode + * + * \note If you are writing a uIP device driver that needs ARP + * (Address Resolution Protocol), e.g., when running uIP over + * Ethernet, you will need to call the uip_arp_out() function before + * calling the device driver: + \code + for(i = 0; i < UIP_CONNS; ++i) { + uip_periodic(i); + if(uip_len > 0) { + uip_arp_out(); + ethernet_devicedriver_send(); + } + } + \endcode + * + * \param conn The number of the connection which is to be periodically polled. + * + * \hideinitializer + */ +#define uip_periodic(conn) do { uip_conn = &uip_conns[conn]; \ + uip_process(UIP_TIMER); } while (0) + +/** + * + * + */ +#define uip_conn_active(conn) (uip_conns[conn].tcpstateflags != UIP_CLOSED) + +/** + * Perform periodic processing for a connection identified by a pointer + * to its structure. + * + * Same as uip_periodic() but takes a pointer to the actual uip_conn + * struct instead of an integer as its argument. This function can be + * used to force periodic processing of a specific connection. + * + * \param conn A pointer to the uip_conn struct for the connection to + * be processed. + * + * \hideinitializer + */ +#define uip_periodic_conn(conn) do { uip_conn = conn; \ + uip_process(UIP_TIMER); } while (0) + +/** + * Reuqest that a particular connection should be polled. + * + * Similar to uip_periodic_conn() but does not perform any timer + * processing. The application is polled for new data. + * + * \param conn A pointer to the uip_conn struct for the connection to + * be processed. + * + * \hideinitializer + */ +#define uip_poll_conn(conn) do { uip_conn = conn; \ + uip_process(UIP_POLL_REQUEST); } while (0) + + +#if UIP_UDP +/** + * Periodic processing for a UDP connection identified by its number. + * + * This function is essentially the same as uip_periodic(), but for + * UDP connections. It is called in a similar fashion as the + * uip_periodic() function: + \code + for(i = 0; i < UIP_UDP_CONNS; i++) { + uip_udp_periodic(i); + if(uip_len > 0) { + devicedriver_send(); + } + } + \endcode + * + * \note As for the uip_periodic() function, special care has to be + * taken when using uIP together with ARP and Ethernet: + \code + for(i = 0; i < UIP_UDP_CONNS; i++) { + uip_udp_periodic(i); + if(uip_len > 0) { + uip_arp_out(); + ethernet_devicedriver_send(); + } + } + \endcode + * + * \param conn The number of the UDP connection to be processed. + * + * \hideinitializer + */ +#define uip_udp_periodic(conn) do { uip_udp_conn = &uip_udp_conns[conn]; \ + uip_process(UIP_UDP_TIMER); } while (0) + +/** + * Periodic processing for a UDP connection identified by a pointer to + * its structure. + * + * Same as uip_udp_periodic() but takes a pointer to the actual + * uip_conn struct instead of an integer as its argument. This + * function can be used to force periodic processing of a specific + * connection. + * + * \param conn A pointer to the uip_udp_conn struct for the connection + * to be processed. + * + * \hideinitializer + */ +#define uip_udp_periodic_conn(conn) do { uip_udp_conn = conn; \ + uip_process(UIP_UDP_TIMER); } while (0) + + +#endif /* UIP_UDP */ + +/** + * The uIP packet buffer. + * + * The uip_buf array is used to hold incoming and outgoing + * packets. The device driver should place incoming data into this + * buffer. When sending data, the device driver should read the link + * level headers and the TCP/IP headers from this buffer. The size of + * the link level headers is configured by the UIP_LLH_LEN define. + * + * \note The application data need not be placed in this buffer, so + * the device driver must read it from the place pointed to by the + * uip_appdata pointer as illustrated by the following example: + \code + void + devicedriver_send(void) + { + hwsend(&uip_buf[0], UIP_LLH_LEN); + if(uip_len <= UIP_LLH_LEN + UIP_TCPIP_HLEN) { + hwsend(&uip_buf[UIP_LLH_LEN], uip_len - UIP_LLH_LEN); + } else { + hwsend(&uip_buf[UIP_LLH_LEN], UIP_TCPIP_HLEN); + hwsend(uip_appdata, uip_len - UIP_TCPIP_HLEN - UIP_LLH_LEN); + } + } + \endcode + */ +extern u8_t uip_buf[UIP_BUFSIZE+2]; + +/** @} */ + +/*---------------------------------------------------------------------------*/ +/* Functions that are used by the uIP application program. Opening and + * closing connections, sending and receiving data, etc. is all + * handled by the functions below. +*/ +/** + * \defgroup uipappfunc uIP application functions + * @{ + * + * Functions used by an application running of top of uIP. + */ + +/** + * Start listening to the specified port. + * + * \note Since this function expects the port number in network byte + * order, a conversion using HTONS() or htons() is necessary. + * + \code + uip_listen(HTONS(80)); + \endcode + * + * \param port A 16-bit port number in network byte order. + */ +void uip_listen(u16_t port); + +/** + * Stop listening to the specified port. + * + * \note Since this function expects the port number in network byte + * order, a conversion using HTONS() or htons() is necessary. + * + \code + uip_unlisten(HTONS(80)); + \endcode + * + * \param port A 16-bit port number in network byte order. + */ +void uip_unlisten(u16_t port); + +/** + * Connect to a remote host using TCP. + * + * This function is used to start a new connection to the specified + * port on the specied host. It allocates a new connection identifier, + * sets the connection to the SYN_SENT state and sets the + * retransmission timer to 0. This will cause a TCP SYN segment to be + * sent out the next time this connection is periodically processed, + * which usually is done within 0.5 seconds after the call to + * uip_connect(). + * + * \note This function is avaliable only if support for active open + * has been configured by defining UIP_ACTIVE_OPEN to 1 in uipopt.h. + * + * \note Since this function requires the port number to be in network + * byte order, a conversion using HTONS() or htons() is necessary. + * + \code + uip_ipaddr_t ipaddr; + + uip_ipaddr(&ipaddr, 192,168,1,2); + uip_connect(&ipaddr, HTONS(80)); + \endcode + * + * \param ripaddr The IP address of the remote hot. + * + * \param port A 16-bit port number in network byte order. + * + * \return A pointer to the uIP connection identifier for the new connection, + * or NULL if no connection could be allocated. + * + */ +struct uip_conn *uip_connect(uip_ipaddr_t *ripaddr, u16_t port); + + + +/** + * \internal + * + * Check if a connection has outstanding (i.e., unacknowledged) data. + * + * \param conn A pointer to the uip_conn structure for the connection. + * + * \hideinitializer + */ +#define uip_outstanding(conn) ((conn)->len) + +/** + * Send data on the current connection. + * + * This function is used to send out a single segment of TCP + * data. Only applications that have been invoked by uIP for event + * processing can send data. + * + * The amount of data that actually is sent out after a call to this + * funcion is determined by the maximum amount of data TCP allows. uIP + * will automatically crop the data so that only the appropriate + * amount of data is sent. The function uip_mss() can be used to query + * uIP for the amount of data that actually will be sent. + * + * \note This function does not guarantee that the sent data will + * arrive at the destination. If the data is lost in the network, the + * application will be invoked with the uip_rexmit() event being + * set. The application will then have to resend the data using this + * function. + * + * \param data A pointer to the data which is to be sent. + * + * \param len The maximum amount of data bytes to be sent. + * + * \hideinitializer + */ +void uip_send(const void *data, int len); + +/** + * The length of any incoming data that is currently avaliable (if avaliable) + * in the uip_appdata buffer. + * + * The test function uip_data() must first be used to check if there + * is any data available at all. + * + * \hideinitializer + */ +/*void uip_datalen(void);*/ +#define uip_datalen() uip_len + +/** + * The length of any out-of-band data (urgent data) that has arrived + * on the connection. + * + * \note The configuration parameter UIP_URGDATA must be set for this + * function to be enabled. + * + * \hideinitializer + */ +#define uip_urgdatalen() uip_urglen + +/** + * Close the current connection. + * + * This function will close the current connection in a nice way. + * + * \hideinitializer + */ +#define uip_close() (uip_flags = UIP_CLOSE) + +/** + * Abort the current connection. + * + * This function will abort (reset) the current connection, and is + * usually used when an error has occured that prevents using the + * uip_close() function. + * + * \hideinitializer + */ +#define uip_abort() (uip_flags = UIP_ABORT) + +/** + * Tell the sending host to stop sending data. + * + * This function will close our receiver's window so that we stop + * receiving data for the current connection. + * + * \hideinitializer + */ +#define uip_stop() (uip_conn->tcpstateflags |= UIP_STOPPED) + +/** + * Find out if the current connection has been previously stopped with + * uip_stop(). + * + * \hideinitializer + */ +#define uip_stopped(conn) ((conn)->tcpstateflags & UIP_STOPPED) + +/** + * Restart the current connection, if is has previously been stopped + * with uip_stop(). + * + * This function will open the receiver's window again so that we + * start receiving data for the current connection. + * + * \hideinitializer + */ +#define uip_restart() do { uip_flags |= UIP_NEWDATA; \ + uip_conn->tcpstateflags &= ~UIP_STOPPED; \ + } while(0) + + +/* uIP tests that can be made to determine in what state the current + connection is, and what the application function should do. */ + +/** + * Is the current connection a UDP connection? + * + * This function checks whether the current connection is a UDP connection. + * + * \hideinitializer + * + */ +#define uip_udpconnection() (uip_conn == NULL) + +/** + * Is new incoming data available? + * + * Will reduce to non-zero if there is new data for the application + * present at the uip_appdata pointer. The size of the data is + * avaliable through the uip_len variable. + * + * \hideinitializer + */ +#define uip_newdata() (uip_flags & UIP_NEWDATA) + +/** + * Has previously sent data been acknowledged? + * + * Will reduce to non-zero if the previously sent data has been + * acknowledged by the remote host. This means that the application + * can send new data. + * + * \hideinitializer + */ +#define uip_acked() (uip_flags & UIP_ACKDATA) + +/** + * Has the connection just been connected? + * + * Reduces to non-zero if the current connection has been connected to + * a remote host. This will happen both if the connection has been + * actively opened (with uip_connect()) or passively opened (with + * uip_listen()). + * + * \hideinitializer + */ +#define uip_connected() (uip_flags & UIP_CONNECTED) + +/** + * Has the connection been closed by the other end? + * + * Is non-zero if the connection has been closed by the remote + * host. The application may then do the necessary clean-ups. + * + * \hideinitializer + */ +#define uip_closed() (uip_flags & UIP_CLOSE) + +/** + * Has the connection been aborted by the other end? + * + * Non-zero if the current connection has been aborted (reset) by the + * remote host. + * + * \hideinitializer + */ +#define uip_aborted() (uip_flags & UIP_ABORT) + +/** + * Has the connection timed out? + * + * Non-zero if the current connection has been aborted due to too many + * retransmissions. + * + * \hideinitializer + */ +#define uip_timedout() (uip_flags & UIP_TIMEDOUT) + +/** + * Do we need to retransmit previously data? + * + * Reduces to non-zero if the previously sent data has been lost in + * the network, and the application should retransmit it. The + * application should send the exact same data as it did the last + * time, using the uip_send() function. + * + * \hideinitializer + */ +#define uip_rexmit() (uip_flags & UIP_REXMIT) + +/** + * Is the connection being polled by uIP? + * + * Is non-zero if the reason the application is invoked is that the + * current connection has been idle for a while and should be + * polled. + * + * The polling event can be used for sending data without having to + * wait for the remote host to send data. + * + * \hideinitializer + */ +#define uip_poll() (uip_flags & UIP_POLL) + +/** + * Get the initial maxium segment size (MSS) of the current + * connection. + * + * \hideinitializer + */ +#define uip_initialmss() (uip_conn->initialmss) + +/** + * Get the current maxium segment size that can be sent on the current + * connection. + * + * The current maxiumum segment size that can be sent on the + * connection is computed from the receiver's window and the MSS of + * the connection (which also is available by calling + * uip_initialmss()). + * + * \hideinitializer + */ +#define uip_mss() (uip_conn->mss) + +/** + * Set up a new UDP connection. + * + * This function sets up a new UDP connection. The function will + * automatically allocate an unused local port for the new + * connection. However, another port can be chosen by using the + * uip_udp_bind() call, after the uip_udp_new() function has been + * called. + * + * Example: + \code + uip_ipaddr_t addr; + struct uip_udp_conn *c; + + uip_ipaddr(&addr, 192,168,2,1); + c = uip_udp_new(&addr, HTONS(12345)); + if(c != NULL) { + uip_udp_bind(c, HTONS(12344)); + } + \endcode + * \param ripaddr The IP address of the remote host. + * + * \param rport The remote port number in network byte order. + * + * \return The uip_udp_conn structure for the new connection or NULL + * if no connection could be allocated. + */ +struct uip_udp_conn *uip_udp_new(uip_ipaddr_t *ripaddr, u16_t rport); + +/** + * Removed a UDP connection. + * + * \param conn A pointer to the uip_udp_conn structure for the connection. + * + * \hideinitializer + */ +#define uip_udp_remove(conn) (conn)->lport = 0 + +/** + * Bind a UDP connection to a local port. + * + * \param conn A pointer to the uip_udp_conn structure for the + * connection. + * + * \param port The local port number, in network byte order. + * + * \hideinitializer + */ +#define uip_udp_bind(conn, port) (conn)->lport = port + +/** + * Send a UDP datagram of length len on the current connection. + * + * This function can only be called in response to a UDP event (poll + * or newdata). The data must be present in the uip_buf buffer, at the + * place pointed to by the uip_appdata pointer. + * + * \param len The length of the data in the uip_buf buffer. + * + * \hideinitializer + */ +#define uip_udp_send(len) uip_send((char *)uip_appdata, len) + +/** @} */ + +/* uIP convenience and converting functions. */ + +/** + * \defgroup uipconvfunc uIP conversion functions + * @{ + * + * These functions can be used for converting between different data + * formats used by uIP. + */ + +/** + * Construct an IP address from four bytes. + * + * This function constructs an IP address of the type that uIP handles + * internally from four bytes. The function is handy for specifying IP + * addresses to use with e.g. the uip_connect() function. + * + * Example: + \code + uip_ipaddr_t ipaddr; + struct uip_conn *c; + + uip_ipaddr(&ipaddr, 192,168,1,2); + c = uip_connect(&ipaddr, HTONS(80)); + \endcode + * + * \param addr A pointer to a uip_ipaddr_t variable that will be + * filled in with the IP address. + * + * \param addr0 The first octet of the IP address. + * \param addr1 The second octet of the IP address. + * \param addr2 The third octet of the IP address. + * \param addr3 The forth octet of the IP address. + * + * \hideinitializer + */ +#define uip_ipaddr(addr, addr0,addr1,addr2,addr3) do { \ + ((u16_t *)(addr))[0] = HTONS(((addr0) << 8) | (addr1)); \ + ((u16_t *)(addr))[1] = HTONS(((addr2) << 8) | (addr3)); \ + } while(0) + +/** + * Construct an IPv6 address from eight 16-bit words. + * + * This function constructs an IPv6 address. + * + * \hideinitializer + */ +#define uip_ip6addr(addr, addr0,addr1,addr2,addr3,addr4,addr5,addr6,addr7) do { \ + ((u16_t *)(addr))[0] = HTONS((addr0)); \ + ((u16_t *)(addr))[1] = HTONS((addr1)); \ + ((u16_t *)(addr))[2] = HTONS((addr2)); \ + ((u16_t *)(addr))[3] = HTONS((addr3)); \ + ((u16_t *)(addr))[4] = HTONS((addr4)); \ + ((u16_t *)(addr))[5] = HTONS((addr5)); \ + ((u16_t *)(addr))[6] = HTONS((addr6)); \ + ((u16_t *)(addr))[7] = HTONS((addr7)); \ + } while(0) + +/** + * Copy an IP address to another IP address. + * + * Copies an IP address from one place to another. + * + * Example: + \code + uip_ipaddr_t ipaddr1, ipaddr2; + + uip_ipaddr(&ipaddr1, 192,16,1,2); + uip_ipaddr_copy(&ipaddr2, &ipaddr1); + \endcode + * + * \param dest The destination for the copy. + * \param src The source from where to copy. + * + * \hideinitializer + */ +#if !UIP_CONF_IPV6 +#define uip_ipaddr_copy(dest, src) do { \ + ((u16_t *)dest)[0] = ((u16_t *)src)[0]; \ + ((u16_t *)dest)[1] = ((u16_t *)src)[1]; \ + } while(0) +#else /* !UIP_CONF_IPV6 */ +#define uip_ipaddr_copy(dest, src) memcpy(dest, src, sizeof(uip_ip6addr_t)) +#endif /* !UIP_CONF_IPV6 */ + +/** + * Compare two IP addresses + * + * Compares two IP addresses. + * + * Example: + \code + uip_ipaddr_t ipaddr1, ipaddr2; + + uip_ipaddr(&ipaddr1, 192,16,1,2); + if(uip_ipaddr_cmp(&ipaddr2, &ipaddr1)) { + printf("They are the same"); + } + \endcode + * + * \param addr1 The first IP address. + * \param addr2 The second IP address. + * + * \hideinitializer + */ +#if !UIP_CONF_IPV6 +#define uip_ipaddr_cmp(addr1, addr2) (((u16_t *)addr1)[0] == ((u16_t *)addr2)[0] && \ + ((u16_t *)addr1)[1] == ((u16_t *)addr2)[1]) +#else /* !UIP_CONF_IPV6 */ +#define uip_ipaddr_cmp(addr1, addr2) (memcmp(addr1, addr2, sizeof(uip_ip6addr_t)) == 0) +#endif /* !UIP_CONF_IPV6 */ + +/** + * Compare two IP addresses with netmasks + * + * Compares two IP addresses with netmasks. The masks are used to mask + * out the bits that are to be compared. + * + * Example: + \code + uip_ipaddr_t ipaddr1, ipaddr2, mask; + + uip_ipaddr(&mask, 255,255,255,0); + uip_ipaddr(&ipaddr1, 192,16,1,2); + uip_ipaddr(&ipaddr2, 192,16,1,3); + if(uip_ipaddr_maskcmp(&ipaddr1, &ipaddr2, &mask)) { + printf("They are the same"); + } + \endcode + * + * \param addr1 The first IP address. + * \param addr2 The second IP address. + * \param mask The netmask. + * + * \hideinitializer + */ +#define uip_ipaddr_maskcmp(addr1, addr2, mask) \ + (((((u16_t *)addr1)[0] & ((u16_t *)mask)[0]) == \ + (((u16_t *)addr2)[0] & ((u16_t *)mask)[0])) && \ + ((((u16_t *)addr1)[1] & ((u16_t *)mask)[1]) == \ + (((u16_t *)addr2)[1] & ((u16_t *)mask)[1]))) + + +/** + * Mask out the network part of an IP address. + * + * Masks out the network part of an IP address, given the address and + * the netmask. + * + * Example: + \code + uip_ipaddr_t ipaddr1, ipaddr2, netmask; + + uip_ipaddr(&ipaddr1, 192,16,1,2); + uip_ipaddr(&netmask, 255,255,255,0); + uip_ipaddr_mask(&ipaddr2, &ipaddr1, &netmask); + \endcode + * + * In the example above, the variable "ipaddr2" will contain the IP + * address 192.168.1.0. + * + * \param dest Where the result is to be placed. + * \param src The IP address. + * \param mask The netmask. + * + * \hideinitializer + */ +#define uip_ipaddr_mask(dest, src, mask) do { \ + ((u16_t *)dest)[0] = ((u16_t *)src)[0] & ((u16_t *)mask)[0]; \ + ((u16_t *)dest)[1] = ((u16_t *)src)[1] & ((u16_t *)mask)[1]; \ + } while(0) + +/** + * Pick the first octet of an IP address. + * + * Picks out the first octet of an IP address. + * + * Example: + \code + uip_ipaddr_t ipaddr; + u8_t octet; + + uip_ipaddr(&ipaddr, 1,2,3,4); + octet = uip_ipaddr1(&ipaddr); + \endcode + * + * In the example above, the variable "octet" will contain the value 1. + * + * \hideinitializer + */ +#define uip_ipaddr1(addr) (htons(((u16_t *)(addr))[0]) >> 8) + +/** + * Pick the second octet of an IP address. + * + * Picks out the second octet of an IP address. + * + * Example: + \code + uip_ipaddr_t ipaddr; + u8_t octet; + + uip_ipaddr(&ipaddr, 1,2,3,4); + octet = uip_ipaddr2(&ipaddr); + \endcode + * + * In the example above, the variable "octet" will contain the value 2. + * + * \hideinitializer + */ +#define uip_ipaddr2(addr) (htons(((u16_t *)(addr))[0]) & 0xff) + +/** + * Pick the third octet of an IP address. + * + * Picks out the third octet of an IP address. + * + * Example: + \code + uip_ipaddr_t ipaddr; + u8_t octet; + + uip_ipaddr(&ipaddr, 1,2,3,4); + octet = uip_ipaddr3(&ipaddr); + \endcode + * + * In the example above, the variable "octet" will contain the value 3. + * + * \hideinitializer + */ +#define uip_ipaddr3(addr) (htons(((u16_t *)(addr))[1]) >> 8) + +/** + * Pick the fourth octet of an IP address. + * + * Picks out the fourth octet of an IP address. + * + * Example: + \code + uip_ipaddr_t ipaddr; + u8_t octet; + + uip_ipaddr(&ipaddr, 1,2,3,4); + octet = uip_ipaddr4(&ipaddr); + \endcode + * + * In the example above, the variable "octet" will contain the value 4. + * + * \hideinitializer + */ +#define uip_ipaddr4(addr) (htons(((u16_t *)(addr))[1]) & 0xff) + +/** + * Convert 16-bit quantity from host byte order to network byte order. + * + * This macro is primarily used for converting constants from host + * byte order to network byte order. For converting variables to + * network byte order, use the htons() function instead. + * + * \hideinitializer + */ +#ifndef HTONS +# if UIP_BYTE_ORDER == UIP_BIG_ENDIAN +# define HTONS(n) (n) +# else /* UIP_BYTE_ORDER == UIP_BIG_ENDIAN */ +# define HTONS(n) (u16_t)((((u16_t) (n)) << 8) | (((u16_t) (n)) >> 8)) +# endif /* UIP_BYTE_ORDER == UIP_BIG_ENDIAN */ +#else +#error "HTONS already defined!" +#endif /* HTONS */ + +/** + * Convert 16-bit quantity from host byte order to network byte order. + * + * This function is primarily used for converting variables from host + * byte order to network byte order. For converting constants to + * network byte order, use the HTONS() macro instead. + */ +#ifndef htons +u16_t htons(u16_t val); +#endif /* htons */ +#ifndef ntohs +#define ntohs htons +#endif + +/** @} */ + +/** + * Pointer to the application data in the packet buffer. + * + * This pointer points to the application data when the application is + * called. If the application wishes to send data, the application may + * use this space to write the data into before calling uip_send(). + */ +extern void *uip_appdata; + +#if UIP_URGDATA > 0 +/* u8_t *uip_urgdata: + * + * This pointer points to any urgent data that has been received. Only + * present if compiled with support for urgent data (UIP_URGDATA). + */ +extern void *uip_urgdata; +#endif /* UIP_URGDATA > 0 */ + + +/** + * \defgroup uipdrivervars Variables used in uIP device drivers + * @{ + * + * uIP has a few global variables that are used in device drivers for + * uIP. + */ + +/** + * The length of the packet in the uip_buf buffer. + * + * The global variable uip_len holds the length of the packet in the + * uip_buf buffer. + * + * When the network device driver calls the uIP input function, + * uip_len should be set to the length of the packet in the uip_buf + * buffer. + * + * When sending packets, the device driver should use the contents of + * the uip_len variable to determine the length of the outgoing + * packet. + * + */ +extern u16_t uip_len; + +/** @} */ + +#if UIP_URGDATA > 0 +extern u16_t uip_urglen, uip_surglen; +#endif /* UIP_URGDATA > 0 */ + + +/** + * Representation of a uIP TCP connection. + * + * The uip_conn structure is used for identifying a connection. All + * but one field in the structure are to be considered read-only by an + * application. The only exception is the appstate field whos purpose + * is to let the application store application-specific state (e.g., + * file pointers) for the connection. The type of this field is + * configured in the "uipopt.h" header file. + */ +struct uip_conn { + uip_ipaddr_t ripaddr; /**< The IP address of the remote host. */ + + u16_t lport; /**< The local TCP port, in network byte order. */ + u16_t rport; /**< The local remote TCP port, in network byte + order. */ + + u8_t rcv_nxt[4]; /**< The sequence number that we expect to + receive next. */ + u8_t snd_nxt[4]; /**< The sequence number that was last sent by + us. */ + u16_t len; /**< Length of the data that was previously sent. */ + u16_t mss; /**< Current maximum segment size for the + connection. */ + u16_t initialmss; /**< Initial maximum segment size for the + connection. */ + u8_t sa; /**< Retransmission time-out calculation state + variable. */ + u8_t sv; /**< Retransmission time-out calculation state + variable. */ + u8_t rto; /**< Retransmission time-out. */ + u8_t tcpstateflags; /**< TCP state and flags. */ + u8_t timer; /**< The retransmission timer. */ + u8_t nrtx; /**< The number of retransmissions for the last + segment sent. */ + + /** The application state. */ + uip_tcp_appstate_t appstate; +}; + + +/** + * Pointer to the current TCP connection. + * + * The uip_conn pointer can be used to access the current TCP + * connection. + */ +extern struct uip_conn *uip_conn; +/* The array containing all uIP connections. */ +extern struct uip_conn uip_conns[UIP_CONNS]; +/** + * \addtogroup uiparch + * @{ + */ + +/** + * 4-byte array used for the 32-bit sequence number calculations. + */ +extern u8_t uip_acc32[4]; + +/** @} */ + + +#if UIP_UDP +/** + * Representation of a uIP UDP connection. + */ +struct uip_udp_conn { + uip_ipaddr_t ripaddr; /**< The IP address of the remote peer. */ + u16_t lport; /**< The local port number in network byte order. */ + u16_t rport; /**< The remote port number in network byte order. */ + u8_t ttl; /**< Default time-to-live. */ + + /** The application state. */ + uip_udp_appstate_t appstate; +}; + +/** + * The current UDP connection. + */ +extern struct uip_udp_conn *uip_udp_conn; +extern struct uip_udp_conn uip_udp_conns[UIP_UDP_CONNS]; +#endif /* UIP_UDP */ + +/** + * The structure holding the TCP/IP statistics that are gathered if + * UIP_STATISTICS is set to 1. + * + */ +struct uip_stats { + struct { + uip_stats_t recv; /**< Number of received packets at the IP + layer. */ + uip_stats_t sent; /**< Number of sent packets at the IP + layer. */ + uip_stats_t drop; /**< Number of dropped packets at the IP + layer. */ + uip_stats_t vhlerr; /**< Number of packets dropped due to wrong + IP version or header length. */ + uip_stats_t hblenerr; /**< Number of packets dropped due to wrong + IP length, high byte. */ + uip_stats_t lblenerr; /**< Number of packets dropped due to wrong + IP length, low byte. */ + uip_stats_t fragerr; /**< Number of packets dropped since they + were IP fragments. */ + uip_stats_t chkerr; /**< Number of packets dropped due to IP + checksum errors. */ + uip_stats_t protoerr; /**< Number of packets dropped since they + were neither ICMP, UDP nor TCP. */ + } ip; /**< IP statistics. */ + struct { + uip_stats_t recv; /**< Number of received ICMP packets. */ + uip_stats_t sent; /**< Number of sent ICMP packets. */ + uip_stats_t drop; /**< Number of dropped ICMP packets. */ + uip_stats_t typeerr; /**< Number of ICMP packets with a wrong + type. */ + } icmp; /**< ICMP statistics. */ + struct { + uip_stats_t recv; /**< Number of recived TCP segments. */ + uip_stats_t sent; /**< Number of sent TCP segments. */ + uip_stats_t drop; /**< Number of dropped TCP segments. */ + uip_stats_t chkerr; /**< Number of TCP segments with a bad + checksum. */ + uip_stats_t ackerr; /**< Number of TCP segments with a bad ACK + number. */ + uip_stats_t rst; /**< Number of recevied TCP RST (reset) segments. */ + uip_stats_t rexmit; /**< Number of retransmitted TCP segments. */ + uip_stats_t syndrop; /**< Number of dropped SYNs due to too few + connections was avaliable. */ + uip_stats_t synrst; /**< Number of SYNs for closed ports, + triggering a RST. */ + } tcp; /**< TCP statistics. */ +#if UIP_UDP + struct { + uip_stats_t recv; /**< Number of recived UDP segments. */ + uip_stats_t sent; /**< Number of sent UDP segments. */ + uip_stats_t drop; /**< Number of dropped UDP segments. */ + uip_stats_t chkerr; /**< Number of UDP segments with a bad + checksum. */ + } udp; /**< UDP statistics. */ +#endif /* UIP_UDP */ +}; + +/** + * The uIP TCP/IP statistics. + * + * This is the variable in which the uIP TCP/IP statistics are gathered. + */ +extern struct uip_stats uip_stat; + + +/*---------------------------------------------------------------------------*/ +/* All the stuff below this point is internal to uIP and should not be + * used directly by an application or by a device driver. + */ +/*---------------------------------------------------------------------------*/ +/* u8_t uip_flags: + * + * When the application is called, uip_flags will contain the flags + * that are defined in this file. Please read below for more + * infomation. + */ +extern u8_t uip_flags; + +/* The following flags may be set in the global variable uip_flags + before calling the application callback. The UIP_ACKDATA, + UIP_NEWDATA, and UIP_CLOSE flags may both be set at the same time, + whereas the others are mutualy exclusive. Note that these flags + should *NOT* be accessed directly, but only through the uIP + functions/macros. */ + +#define UIP_ACKDATA 1 /* Signifies that the outstanding data was + acked and the application should send + out new data instead of retransmitting + the last data. */ +#define UIP_NEWDATA 2 /* Flags the fact that the peer has sent + us new data. */ +#define UIP_REXMIT 4 /* Tells the application to retransmit the + data that was last sent. */ +#define UIP_POLL 8 /* Used for polling the application, to + check if the application has data that + it wants to send. */ +#define UIP_CLOSE 16 /* The remote host has closed the + connection, thus the connection has + gone away. Or the application signals + that it wants to close the + connection. */ +#define UIP_ABORT 32 /* The remote host has aborted the + connection, thus the connection has + gone away. Or the application signals + that it wants to abort the + connection. */ +#define UIP_CONNECTED 64 /* We have got a connection from a remote + host and have set up a new connection + for it, or an active connection has + been successfully established. */ + +#define UIP_TIMEDOUT 128 /* The connection has been aborted due to + too many retransmissions. */ + +/* uip_process(flag): + * + * The actual uIP function which does all the work. + */ +void uip_process(u8_t flag); + +/* The following flags are passed as an argument to the uip_process() + function. They are used to distinguish between the two cases where + uip_process() is called. It can be called either because we have + incoming data that should be processed, or because the periodic + timer has fired. These values are never used directly, but only in + the macrose defined in this file. */ + +#define UIP_DATA 1 /* Tells uIP that there is incoming + data in the uip_buf buffer. The + length of the data is stored in the + global variable uip_len. */ +#define UIP_TIMER 2 /* Tells uIP that the periodic timer + has fired. */ +#define UIP_POLL_REQUEST 3 /* Tells uIP that a connection should + be polled. */ +#define UIP_UDP_SEND_CONN 4 /* Tells uIP that a UDP datagram + should be constructed in the + uip_buf buffer. */ +#if UIP_UDP +#define UIP_UDP_TIMER 5 +#endif /* UIP_UDP */ + +/* The TCP states used in the uip_conn->tcpstateflags. */ +#define UIP_CLOSED 0 +#define UIP_SYN_RCVD 1 +#define UIP_SYN_SENT 2 +#define UIP_ESTABLISHED 3 +#define UIP_FIN_WAIT_1 4 +#define UIP_FIN_WAIT_2 5 +#define UIP_CLOSING 6 +#define UIP_TIME_WAIT 7 +#define UIP_LAST_ACK 8 +#define UIP_TS_MASK 15 + +#define UIP_STOPPED 16 + +/* The TCP and IP headers. */ +struct uip_tcpip_hdr { +#if UIP_CONF_IPV6 + /* IPv6 header. */ + u8_t vtc, + tcflow; + u16_t flow; + u8_t len[2]; + u8_t proto, ttl; + uip_ip6addr_t srcipaddr, destipaddr; +#else /* UIP_CONF_IPV6 */ + /* IPv4 header. */ + u8_t vhl, + tos, + len[2], + ipid[2], + ipoffset[2], + ttl, + proto; + u16_t ipchksum; + u16_t srcipaddr[2], + destipaddr[2]; +#endif /* UIP_CONF_IPV6 */ + + /* TCP header. */ + u16_t srcport, + destport; + u8_t seqno[4], + ackno[4], + tcpoffset, + flags, + wnd[2]; + u16_t tcpchksum; + u8_t urgp[2]; + u8_t optdata[4]; +}; + +/* The ICMP and IP headers. */ +struct uip_icmpip_hdr { +#if UIP_CONF_IPV6 + /* IPv6 header. */ + u8_t vtc, + tcf; + u16_t flow; + u8_t len[2]; + u8_t proto, ttl; + uip_ip6addr_t srcipaddr, destipaddr; +#else /* UIP_CONF_IPV6 */ + /* IPv4 header. */ + u8_t vhl, + tos, + len[2], + ipid[2], + ipoffset[2], + ttl, + proto; + u16_t ipchksum; + u16_t srcipaddr[2], + destipaddr[2]; +#endif /* UIP_CONF_IPV6 */ + + /* ICMP (echo) header. */ + u8_t type, icode; + u16_t icmpchksum; +#if !UIP_CONF_IPV6 + u16_t id, seqno; +#else /* !UIP_CONF_IPV6 */ + u8_t flags, reserved1, reserved2, reserved3; + u8_t icmp6data[16]; + u8_t options[1]; +#endif /* !UIP_CONF_IPV6 */ +}; + + +/* The UDP and IP headers. */ +struct uip_udpip_hdr { +#if UIP_CONF_IPV6 + /* IPv6 header. */ + u8_t vtc, + tcf; + u16_t flow; + u8_t len[2]; + u8_t proto, ttl; + uip_ip6addr_t srcipaddr, destipaddr; +#else /* UIP_CONF_IPV6 */ + /* IP header. */ + u8_t vhl, + tos, + len[2], + ipid[2], + ipoffset[2], + ttl, + proto; + u16_t ipchksum; + u16_t srcipaddr[2], + destipaddr[2]; +#endif /* UIP_CONF_IPV6 */ + + /* UDP header. */ + u16_t srcport, + destport; + u16_t udplen; + u16_t udpchksum; +}; + + + +/** + * The buffer size available for user data in the \ref uip_buf buffer. + * + * This macro holds the available size for user data in the \ref + * uip_buf buffer. The macro is intended to be used for checking + * bounds of available user data. + * + * Example: + \code + snprintf(uip_appdata, UIP_APPDATA_SIZE, "%u\n", i); + \endcode + * + * \hideinitializer + */ +#define UIP_APPDATA_SIZE (UIP_BUFSIZE - UIP_LLH_LEN - UIP_TCPIP_HLEN) + + +#define UIP_PROTO_ICMP 1 +#define UIP_PROTO_TCP 6 +#define UIP_PROTO_UDP 17 +#define UIP_PROTO_ICMP6 58 + +/* Header sizes. */ +#if UIP_CONF_IPV6 +#define UIP_IPH_LEN 40 +#else /* UIP_CONF_IPV6 */ +#define UIP_IPH_LEN 20 /* Size of IP header */ +#endif /* UIP_CONF_IPV6 */ +#define UIP_UDPH_LEN 8 /* Size of UDP header */ +#define UIP_TCPH_LEN 20 /* Size of TCP header */ +#define UIP_IPUDPH_LEN (UIP_UDPH_LEN + UIP_IPH_LEN) /* Size of IP + + UDP + header */ +#define UIP_IPTCPH_LEN (UIP_TCPH_LEN + UIP_IPH_LEN) /* Size of IP + + TCP + header */ +#define UIP_TCPIP_HLEN UIP_IPTCPH_LEN + + +#if UIP_FIXEDADDR +extern const uip_ipaddr_t uip_hostaddr, uip_netmask, uip_draddr; +#else /* UIP_FIXEDADDR */ +extern uip_ipaddr_t uip_hostaddr, uip_netmask, uip_draddr; +#endif /* UIP_FIXEDADDR */ + + + +/** + * Representation of a 48-bit Ethernet address. + */ +struct uip_eth_addr { + u8_t addr[6]; +}; + +/** + * Calculate the Internet checksum over a buffer. + * + * The Internet checksum is the one's complement of the one's + * complement sum of all 16-bit words in the buffer. + * + * See RFC1071. + * + * \param buf A pointer to the buffer over which the checksum is to be + * computed. + * + * \param len The length of the buffer over which the checksum is to + * be computed. + * + * \return The Internet checksum of the buffer. + */ +u16_t uip_chksum(u16_t *buf, u16_t len); + +/** + * Calculate the IP header checksum of the packet header in uip_buf. + * + * The IP header checksum is the Internet checksum of the 20 bytes of + * the IP header. + * + * \return The IP header checksum of the IP header in the uip_buf + * buffer. + */ +u16_t uip_ipchksum(void); + +/** + * Calculate the TCP checksum of the packet in uip_buf and uip_appdata. + * + * The TCP checksum is the Internet checksum of data contents of the + * TCP segment, and a pseudo-header as defined in RFC793. + * + * \return The TCP checksum of the TCP segment in uip_buf and pointed + * to by uip_appdata. + */ +u16_t uip_tcpchksum(void); + +/** + * Calculate the UDP checksum of the packet in uip_buf and uip_appdata. + * + * The UDP checksum is the Internet checksum of data contents of the + * UDP segment, and a pseudo-header as defined in RFC768. + * + * \return The UDP checksum of the UDP segment in uip_buf and pointed + * to by uip_appdata. + */ +u16_t uip_udpchksum(void); + + +#endif /* __UIP_H__ */ + + +/** @} */ diff --git a/Tester/SW/lib/Drivers/ethernet/uip_arch.h b/Tester/SW/lib/Drivers/ethernet/uip_arch.h new file mode 100644 index 0000000..8331b01 --- /dev/null +++ b/Tester/SW/lib/Drivers/ethernet/uip_arch.h @@ -0,0 +1,138 @@ +/** + * \addtogroup uip + * {@ + */ + +/** + * \defgroup uiparch Architecture specific uIP functions + * @{ + * + * The functions in the architecture specific module implement the IP + * check sum and 32-bit additions. + * + * The IP checksum calculation is the most computationally expensive + * operation in the TCP/IP stack and it therefore pays off to + * implement this in efficient assembler. The purpose of the uip-arch + * module is to let the checksum functions to be implemented in + * architecture specific assembler. + * + */ + +/** + * \file + * Declarations of architecture specific functions. + * \author Adam Dunkels + */ + +/* + * Copyright (c) 2001, Adam Dunkels. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This file is part of the uIP TCP/IP stack. + * + * $Id: uip_arch.h,v 1.1.2.3 2006/12/04 18:52:39 fredrikh Exp $ + * + */ + +#ifndef __UIP_ARCH_H__ +#define __UIP_ARCH_H__ + +#include "uip.h" + +/** + * Carry out a 32-bit addition. + * + * Because not all architectures for which uIP is intended has native + * 32-bit arithmetic, uIP uses an external C function for doing the + * required 32-bit additions in the TCP protocol processing. This + * function should add the two arguments and place the result in the + * global variable uip_acc32. + * + * \note The 32-bit integer pointed to by the op32 parameter and the + * result in the uip_acc32 variable are in network byte order (big + * endian). + * + * \param op32 A pointer to a 4-byte array representing a 32-bit + * integer in network byte order (big endian). + * + * \param op16 A 16-bit integer in host byte order. + */ +void uip_add32(u8_t *op32, u16_t op16); + +/** + * Calculate the Internet checksum over a buffer. + * + * The Internet checksum is the one's complement of the one's + * complement sum of all 16-bit words in the buffer. + * + * See RFC1071. + * + * \note This function is not called in the current version of uIP, + * but future versions might make use of it. + * + * \param buf A pointer to the buffer over which the checksum is to be + * computed. + * + * \param len The length of the buffer over which the checksum is to + * be computed. + * + * \return The Internet checksum of the buffer. + */ +u16_t uip_chksum(u16_t *buf, u16_t len); + +/** + * Calculate the IP header checksum of the packet header in uip_buf. + * + * The IP header checksum is the Internet checksum of the 20 bytes of + * the IP header. + * + * \return The IP header checksum of the IP header in the uip_buf + * buffer. + */ +u16_t uip_ipchksum(void); + +/** + * Calculate the TCP checksum of the packet in uip_buf and uip_appdata. + * + * The TCP checksum is the Internet checksum of data contents of the + * TCP segment, and a pseudo-header as defined in RFC793. + * + * \note The uip_appdata pointer that points to the packet data may + * point anywhere in memory, so it is not possible to simply calculate + * the Internet checksum of the contents of the uip_buf buffer. + * + * \return The TCP checksum of the TCP segment in uip_buf and pointed + * to by uip_appdata. + */ +u16_t uip_tcpchksum(void); + +u16_t uip_udpchksum(void); + +/** @} */ +/** @} */ + +#endif /* __UIP_ARCH_H__ */ diff --git a/Tester/SW/lib/Drivers/ethernet/uip_arp.c b/Tester/SW/lib/Drivers/ethernet/uip_arp.c new file mode 100644 index 0000000..bb43180 --- /dev/null +++ b/Tester/SW/lib/Drivers/ethernet/uip_arp.c @@ -0,0 +1,423 @@ +/** + * \addtogroup uip + * @{ + */ + +/** + * \defgroup uiparp uIP Address Resolution Protocol + * @{ + * + * The Address Resolution Protocol ARP is used for mapping between IP + * addresses and link level addresses such as the Ethernet MAC + * addresses. ARP uses broadcast queries to ask for the link level + * address of a known IP address and the host which is configured with + * the IP address for which the query was meant, will respond with its + * link level address. + * + * \note This ARP implementation only supports Ethernet. + */ + +/** + * \file + * Implementation of the ARP Address Resolution Protocol. + * \author Adam Dunkels + * + */ + +/* + * Copyright (c) 2001-2003, Adam Dunkels. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This file is part of the uIP TCP/IP stack. + * + * $Id: uip_arp.c,v 1.1.2.3 2006/12/04 18:52:39 fredrikh Exp $ + * + */ + + +#include "uip_arp.h" + +#include + +struct arp_hdr { + struct uip_eth_hdr ethhdr; + u16_t hwtype; + u16_t protocol; + u8_t hwlen; + u8_t protolen; + u16_t opcode; + struct uip_eth_addr shwaddr; + u16_t sipaddr[2]; + struct uip_eth_addr dhwaddr; + u16_t dipaddr[2]; +}; + +struct ethip_hdr { + struct uip_eth_hdr ethhdr; + /* IP header. */ + u8_t vhl, + tos, + len[2], + ipid[2], + ipoffset[2], + ttl, + proto; + u16_t ipchksum; + u16_t srcipaddr[2], + destipaddr[2]; +}; + +#define ARP_REQUEST 1 +#define ARP_REPLY 2 + +#define ARP_HWTYPE_ETH 1 + +struct arp_entry { + u16_t ipaddr[2]; + struct uip_eth_addr ethaddr; + u8_t time; +}; + +static const struct uip_eth_addr broadcast_ethaddr = + {{0xff,0xff,0xff,0xff,0xff,0xff}}; +static const u16_t broadcast_ipaddr[2] = {0xffff,0xffff}; + +static struct arp_entry arp_table[UIP_ARPTAB_SIZE]; +static u16_t ipaddr[2]; +static u8_t i, c; + +static u8_t arptime; +static u8_t tmpage; + +#define BUF ((struct arp_hdr *)&uip_buf[0]) +#define IPBUF ((struct ethip_hdr *)&uip_buf[0]) +/*-----------------------------------------------------------------------------------*/ +/** + * Initialize the ARP module. + * + */ +/*-----------------------------------------------------------------------------------*/ +void +uip_arp_init(void) +{ + for(i = 0; i < UIP_ARPTAB_SIZE; ++i) { + memset(arp_table[i].ipaddr, 0, 4); + } +} +/*-----------------------------------------------------------------------------------*/ +/** + * Periodic ARP processing function. + * + * This function performs periodic timer processing in the ARP module + * and should be called at regular intervals. The recommended interval + * is 10 seconds between the calls. + * + */ +/*-----------------------------------------------------------------------------------*/ +void +uip_arp_timer(void) +{ + struct arp_entry *tabptr; + + ++arptime; + for(i = 0; i < UIP_ARPTAB_SIZE; ++i) { + tabptr = &arp_table[i]; + if((tabptr->ipaddr[0] | tabptr->ipaddr[1]) != 0 && + arptime - tabptr->time >= UIP_ARP_MAXAGE) { + memset(tabptr->ipaddr, 0, 4); + } + } + +} +/*-----------------------------------------------------------------------------------*/ +static void +uip_arp_update(u16_t *ipaddr, struct uip_eth_addr *ethaddr) +{ + register struct arp_entry *tabptr; + /* Walk through the ARP mapping table and try to find an entry to + update. If none is found, the IP -> MAC address mapping is + inserted in the ARP table. */ + for(i = 0; i < UIP_ARPTAB_SIZE; ++i) { + + tabptr = &arp_table[i]; + /* Only check those entries that are actually in use. */ + if(tabptr->ipaddr[0] != 0 && + tabptr->ipaddr[1] != 0) { + + /* Check if the source IP address of the incoming packet matches + the IP address in this ARP table entry. */ + if(ipaddr[0] == tabptr->ipaddr[0] && + ipaddr[1] == tabptr->ipaddr[1]) { + + /* An old entry found, update this and return. */ + memcpy(tabptr->ethaddr.addr, ethaddr->addr, 6); + tabptr->time = arptime; + + return; + } + } + } + + /* If we get here, no existing ARP table entry was found, so we + create one. */ + + /* First, we try to find an unused entry in the ARP table. */ + for(i = 0; i < UIP_ARPTAB_SIZE; ++i) { + tabptr = &arp_table[i]; + if(tabptr->ipaddr[0] == 0 && + tabptr->ipaddr[1] == 0) { + break; + } + } + + /* If no unused entry is found, we try to find the oldest entry and + throw it away. */ + if(i == UIP_ARPTAB_SIZE) { + tmpage = 0; + c = 0; + for(i = 0; i < UIP_ARPTAB_SIZE; ++i) { + tabptr = &arp_table[i]; + if(arptime - tabptr->time > tmpage) { + tmpage = arptime - tabptr->time; + c = i; + } + } + i = c; + tabptr = &arp_table[i]; + } + + /* Now, i is the ARP table entry which we will fill with the new + information. */ + memcpy(tabptr->ipaddr, ipaddr, 4); + memcpy(tabptr->ethaddr.addr, ethaddr->addr, 6); + tabptr->time = arptime; +} +/*-----------------------------------------------------------------------------------*/ +/** + * ARP processing for incoming IP packets + * + * This function should be called by the device driver when an IP + * packet has been received. The function will check if the address is + * in the ARP cache, and if so the ARP cache entry will be + * refreshed. If no ARP cache entry was found, a new one is created. + * + * This function expects an IP packet with a prepended Ethernet header + * in the uip_buf[] buffer, and the length of the packet in the global + * variable uip_len. + */ +/*-----------------------------------------------------------------------------------*/ +#if 0 +void +uip_arp_ipin(void) +{ + uip_len -= sizeof(struct uip_eth_hdr); + + /* Only insert/update an entry if the source IP address of the + incoming IP packet comes from a host on the local network. */ + if((IPBUF->srcipaddr[0] & uip_netmask[0]) != + (uip_hostaddr[0] & uip_netmask[0])) { + return; + } + if((IPBUF->srcipaddr[1] & uip_netmask[1]) != + (uip_hostaddr[1] & uip_netmask[1])) { + return; + } + uip_arp_update(IPBUF->srcipaddr, &(IPBUF->ethhdr.src)); + + return; +} +#endif /* 0 */ +/*-----------------------------------------------------------------------------------*/ +/** + * ARP processing for incoming ARP packets. + * + * This function should be called by the device driver when an ARP + * packet has been received. The function will act differently + * depending on the ARP packet type: if it is a reply for a request + * that we previously sent out, the ARP cache will be filled in with + * the values from the ARP reply. If the incoming ARP packet is an ARP + * request for our IP address, an ARP reply packet is created and put + * into the uip_buf[] buffer. + * + * When the function returns, the value of the global variable uip_len + * indicates whether the device driver should send out a packet or + * not. If uip_len is zero, no packet should be sent. If uip_len is + * non-zero, it contains the length of the outbound packet that is + * present in the uip_buf[] buffer. + * + * This function expects an ARP packet with a prepended Ethernet + * header in the uip_buf[] buffer, and the length of the packet in the + * global variable uip_len. + */ +/*-----------------------------------------------------------------------------------*/ +void +uip_arp_arpin(void) +{ + + if(uip_len < sizeof(struct arp_hdr)) { + uip_len = 0; + return; + } + uip_len = 0; + + switch(BUF->opcode) { + case HTONS(ARP_REQUEST): + /* ARP request. If it asked for our address, we send out a + reply. */ + if(uip_ipaddr_cmp(BUF->dipaddr, uip_hostaddr)) { + /* First, we register the one who made the request in our ARP + table, since it is likely that we will do more communication + with this host in the future. */ + uip_arp_update(BUF->sipaddr, &BUF->shwaddr); + + /* The reply opcode is 2. */ + BUF->opcode = HTONS(2); + + memcpy(BUF->dhwaddr.addr, BUF->shwaddr.addr, 6); + memcpy(BUF->shwaddr.addr, uip_ethaddr.addr, 6); + memcpy(BUF->ethhdr.src.addr, uip_ethaddr.addr, 6); + memcpy(BUF->ethhdr.dest.addr, BUF->dhwaddr.addr, 6); + + BUF->dipaddr[0] = BUF->sipaddr[0]; + BUF->dipaddr[1] = BUF->sipaddr[1]; + BUF->sipaddr[0] = uip_hostaddr[0]; + BUF->sipaddr[1] = uip_hostaddr[1]; + + BUF->ethhdr.type = HTONS(UIP_ETHTYPE_ARP); + uip_len = sizeof(struct arp_hdr); + } + break; + case HTONS(ARP_REPLY): + /* ARP reply. We insert or update the ARP table if it was meant + for us. */ + if(uip_ipaddr_cmp(BUF->dipaddr, uip_hostaddr)) { + uip_arp_update(BUF->sipaddr, &BUF->shwaddr); + } + break; + } + + return; +} +/*-----------------------------------------------------------------------------------*/ +/** + * Prepend Ethernet header to an outbound IP packet and see if we need + * to send out an ARP request. + * + * This function should be called before sending out an IP packet. The + * function checks the destination IP address of the IP packet to see + * what Ethernet MAC address that should be used as a destination MAC + * address on the Ethernet. + * + * If the destination IP address is in the local network (determined + * by logical ANDing of netmask and our IP address), the function + * checks the ARP cache to see if an entry for the destination IP + * address is found. If so, an Ethernet header is prepended and the + * function returns. If no ARP cache entry is found for the + * destination IP address, the packet in the uip_buf[] is replaced by + * an ARP request packet for the IP address. The IP packet is dropped + * and it is assumed that they higher level protocols (e.g., TCP) + * eventually will retransmit the dropped packet. + * + * If the destination IP address is not on the local network, the IP + * address of the default router is used instead. + * + * When the function returns, a packet is present in the uip_buf[] + * buffer, and the length of the packet is in the global variable + * uip_len. + */ +/*-----------------------------------------------------------------------------------*/ +void +uip_arp_out(void) +{ + struct arp_entry *tabptr; + + /* Find the destination IP address in the ARP table and construct + the Ethernet header. If the destination IP addres isn't on the + local network, we use the default router's IP address instead. + + If not ARP table entry is found, we overwrite the original IP + packet with an ARP request for the IP address. */ + + /* First check if destination is a local broadcast. */ + if(uip_ipaddr_cmp(IPBUF->destipaddr, broadcast_ipaddr)) { + memcpy(IPBUF->ethhdr.dest.addr, broadcast_ethaddr.addr, 6); + } else { + /* Check if the destination address is on the local network. */ + if(!uip_ipaddr_maskcmp(IPBUF->destipaddr, uip_hostaddr, uip_netmask)) { + /* Destination address was not on the local network, so we need to + use the default router's IP address instead of the destination + address when determining the MAC address. */ + uip_ipaddr_copy(ipaddr, uip_draddr); + } else { + /* Else, we use the destination IP address. */ + uip_ipaddr_copy(ipaddr, IPBUF->destipaddr); + } + + for(i = 0; i < UIP_ARPTAB_SIZE; ++i) { + tabptr = &arp_table[i]; + if(uip_ipaddr_cmp(ipaddr, tabptr->ipaddr)) { + break; + } + } + + if(i == UIP_ARPTAB_SIZE) { + /* The destination address was not in our ARP table, so we + overwrite the IP packet with an ARP request. */ + + memset(BUF->ethhdr.dest.addr, 0xff, 6); + memset(BUF->dhwaddr.addr, 0x00, 6); + memcpy(BUF->ethhdr.src.addr, uip_ethaddr.addr, 6); + memcpy(BUF->shwaddr.addr, uip_ethaddr.addr, 6); + + uip_ipaddr_copy(BUF->dipaddr, ipaddr); + uip_ipaddr_copy(BUF->sipaddr, uip_hostaddr); + BUF->opcode = HTONS(ARP_REQUEST); /* ARP request. */ + BUF->hwtype = HTONS(ARP_HWTYPE_ETH); + BUF->protocol = HTONS(UIP_ETHTYPE_IP); + BUF->hwlen = 6; + BUF->protolen = 4; + BUF->ethhdr.type = HTONS(UIP_ETHTYPE_ARP); + + uip_appdata = &uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN]; + + uip_len = sizeof(struct arp_hdr); + return; + } + + /* Build an ethernet header. */ + memcpy(IPBUF->ethhdr.dest.addr, tabptr->ethaddr.addr, 6); + } + memcpy(IPBUF->ethhdr.src.addr, uip_ethaddr.addr, 6); + + IPBUF->ethhdr.type = HTONS(UIP_ETHTYPE_IP); + + uip_len += sizeof(struct uip_eth_hdr); +} +/*-----------------------------------------------------------------------------------*/ + +/** @} */ +/** @} */ diff --git a/Tester/SW/lib/Drivers/ethernet/uip_arp.h b/Tester/SW/lib/Drivers/ethernet/uip_arp.h new file mode 100644 index 0000000..d1cb2b9 --- /dev/null +++ b/Tester/SW/lib/Drivers/ethernet/uip_arp.h @@ -0,0 +1,149 @@ +/** + * \addtogroup uip + * @{ + */ + +/** + * \addtogroup uiparp + * @{ + */ + +/** + * \file + * Macros and definitions for the ARP module. + * \author Adam Dunkels + */ + + +/* + * Copyright (c) 2001-2003, Adam Dunkels. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This file is part of the uIP TCP/IP stack. + * + * $Id: uip_arp.h,v 1.1.2.3 2006/12/04 18:52:39 fredrikh Exp $ + * + */ + +#ifndef __UIP_ARP_H__ +#define __UIP_ARP_H__ + +#include "uip.h" + +#if UIP_FIXEDETHADDR +extern const struct uip_eth_addr uip_ethaddr; +#else +extern struct uip_eth_addr uip_ethaddr; +#endif + +/** + * The Ethernet header. + */ +struct uip_eth_hdr { + struct uip_eth_addr dest; + struct uip_eth_addr src; + u16_t type; +}; + +#define UIP_ETHTYPE_ARP 0x0806 +#define UIP_ETHTYPE_IP 0x0800 +#define UIP_ETHTYPE_IP6 0x86dd + + +/* The uip_arp_init() function must be called before any of the other + ARP functions. */ +void uip_arp_init(void); + +/* The uip_arp_ipin() function should be called whenever an IP packet + arrives from the Ethernet. This function refreshes the ARP table or + inserts a new mapping if none exists. The function assumes that an + IP packet with an Ethernet header is present in the uip_buf buffer + and that the length of the packet is in the uip_len variable. */ +/*void uip_arp_ipin(void);*/ +#define uip_arp_ipin() + +/* The uip_arp_arpin() should be called when an ARP packet is received + by the Ethernet driver. This function also assumes that the + Ethernet frame is present in the uip_buf buffer. When the + uip_arp_arpin() function returns, the contents of the uip_buf + buffer should be sent out on the Ethernet if the uip_len variable + is > 0. */ +void uip_arp_arpin(void); + +/* The uip_arp_out() function should be called when an IP packet + should be sent out on the Ethernet. This function creates an + Ethernet header before the IP header in the uip_buf buffer. The + Ethernet header will have the correct Ethernet MAC destination + address filled in if an ARP table entry for the destination IP + address (or the IP address of the default router) is present. If no + such table entry is found, the IP packet is overwritten with an ARP + request and we rely on TCP to retransmit the packet that was + overwritten. In any case, the uip_len variable holds the length of + the Ethernet frame that should be transmitted. */ +void uip_arp_out(void); + +/* The uip_arp_timer() function should be called every ten seconds. It + is responsible for flushing old entries in the ARP table. */ +void uip_arp_timer(void); + +/** @} */ + +/** + * \addtogroup uipconffunc + * @{ + */ + + +/** + * Specifiy the Ethernet MAC address. + * + * The ARP code needs to know the MAC address of the Ethernet card in + * order to be able to respond to ARP queries and to generate working + * Ethernet headers. + * + * \note This macro only specifies the Ethernet MAC address to the ARP + * code. It cannot be used to change the MAC address of the Ethernet + * card. + * + * \param eaddr A pointer to a struct uip_eth_addr containing the + * Ethernet MAC address of the Ethernet card. + * + * \hideinitializer + */ +#if UIP_FIXEDETHADDR == 0 +#define uip_setethaddr(eaddr) do {uip_ethaddr.addr[0] = eaddr.addr[0]; \ + uip_ethaddr.addr[1] = eaddr.addr[1];\ + uip_ethaddr.addr[2] = eaddr.addr[2];\ + uip_ethaddr.addr[3] = eaddr.addr[3];\ + uip_ethaddr.addr[4] = eaddr.addr[4];\ + uip_ethaddr.addr[5] = eaddr.addr[5];} while(0) +#endif + +/** @} */ +/** @} */ + +#endif /* __UIP_ARP_H__ */ diff --git a/Tester/SW/lib/Drivers/ethernet/uiplib.c b/Tester/SW/lib/Drivers/ethernet/uiplib.c new file mode 100644 index 0000000..2185a32 --- /dev/null +++ b/Tester/SW/lib/Drivers/ethernet/uiplib.c @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2004, Adam Dunkels and the Swedish Institute of + * Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This file is part of the uIP TCP/IP stack + * + * $Id: uiplib.c,v 1.1.2.3 2006/12/04 18:52:39 fredrikh Exp $ + * + */ + + +#include "uip.h" +#include "uiplib.h" + + +/*-----------------------------------------------------------------------------------*/ +unsigned char +uiplib_ipaddrconv(char *addrstr, unsigned char *ipaddr) +{ + unsigned char tmp; + char c; + unsigned char i, j; + + tmp = 0; + + for(i = 0; i < 4; ++i) { + j = 0; + do { + c = *addrstr; + ++j; + if(j > 4) { + return 0; + } + if(c == '.' || c == 0) { + *ipaddr = tmp; + ++ipaddr; + tmp = 0; + } else if(c >= '0' && c <= '9') { + tmp = (tmp * 10) + (c - '0'); + } else { + return 0; + } + ++addrstr; + } while(c != '.' && c != 0); + } + return 1; +} + +/*-----------------------------------------------------------------------------------*/ diff --git a/Tester/SW/lib/Drivers/ethernet/uiplib.h b/Tester/SW/lib/Drivers/ethernet/uiplib.h new file mode 100644 index 0000000..4360e8d --- /dev/null +++ b/Tester/SW/lib/Drivers/ethernet/uiplib.h @@ -0,0 +1,71 @@ +/** + * \file + * Various uIP library functions. + * \author + * Adam Dunkels + * + */ + +/* + * Copyright (c) 2002, Adam Dunkels. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This file is part of the uIP TCP/IP stack + * + * $Id: uiplib.h,v 1.1.2.3 2006/12/04 18:52:39 fredrikh Exp $ + * + */ +#ifndef __UIPLIB_H__ +#define __UIPLIB_H__ + +/** + * \addtogroup uipconvfunc + * @{ + */ + +/** + * Convert a textual representation of an IP address to a numerical representation. + * + * This function takes a textual representation of an IP address in + * the form a.b.c.d and converts it into a 4-byte array that can be + * used by other uIP functions. + * + * \param addrstr A pointer to a string containing the IP address in + * textual form. + * + * \param addr A pointer to a 4-byte array that will be filled in with + * the numerical representation of the address. + * + * \retval 0 If the IP address could not be parsed. + * \retval Non-zero If the IP address was parsed. + */ +unsigned char uiplib_ipaddrconv(char *addrstr, unsigned char *addr); + +/** @} */ + +#endif /* __UIPLIB_H__ */ diff --git a/Tester/SW/lib/Drivers/ethernet/uipopt.h b/Tester/SW/lib/Drivers/ethernet/uipopt.h new file mode 100644 index 0000000..aebd377 --- /dev/null +++ b/Tester/SW/lib/Drivers/ethernet/uipopt.h @@ -0,0 +1,559 @@ +/** + * \defgroup uipopt Configuration options for uIP + * @{ + * + * uIP is configured using the per-project configuration file + * uipopt.h. This file contains all compile-time options for uIP and + * should be tweaked to match each specific project. The uIP + * distribution contains a documented example "uipopt.h" that can be + * copied and modified for each project. + * + * \note Most of the configuration options in the uipopt.h should not + * be changed, but rather the per-project uip-conf.h file. + */ + +/** + * \file + * Configuration options for uIP. + * \author Adam Dunkels + * + * This file is used for tweaking various configuration options for + * uIP. You should make a copy of this file into one of your project's + * directories instead of editing this example "uipopt.h" file that + * comes with the uIP distribution. + */ + +/* + * Copyright (c) 2001-2003, Adam Dunkels. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This file is part of the uIP TCP/IP stack. + * + * $Id: uipopt.h,v 1.1.2.3 2006/12/04 18:52:39 fredrikh Exp $ + * + */ + +#ifndef __UIPOPT_H__ +#define __UIPOPT_H__ + +#ifndef UIP_LITTLE_ENDIAN +#define UIP_LITTLE_ENDIAN 3412 +#endif /* UIP_LITTLE_ENDIAN */ +#ifndef UIP_BIG_ENDIAN +#define UIP_BIG_ENDIAN 1234 +#endif /* UIP_BIG_ENDIAN */ + +#include "uip-conf.h" + +/*------------------------------------------------------------------------------*/ + +/** + * \name Static configuration options + * @{ + * + * These configuration options can be used for setting the IP address + * settings statically, but only if UIP_FIXEDADDR is set to 1. The + * configuration options for a specific node includes IP address, + * netmask and default router as well as the Ethernet address. The + * netmask, default router and Ethernet address are appliciable only + * if uIP should be run over Ethernet. + * + * All of these should be changed to suit your project. +*/ + +/** + * Determines if uIP should use a fixed IP address or not. + * + * If uIP should use a fixed IP address, the settings are set in the + * uipopt.h file. If not, the macros uip_sethostaddr(), + * uip_setdraddr() and uip_setnetmask() should be used instead. + * + * \hideinitializer + */ +#define UIP_FIXEDADDR 0 + +/** + * Ping IP address asignment. + * + * uIP uses a "ping" packets for setting its own IP address if this + * option is set. If so, uIP will start with an empty IP address and + * the destination IP address of the first incoming "ping" (ICMP echo) + * packet will be used for setting the hosts IP address. + * + * \note This works only if UIP_FIXEDADDR is 0. + * + * \hideinitializer + */ +#ifdef UIP_CONF_PINGADDRCONF +#define UIP_PINGADDRCONF UIP_CONF_PINGADDRCONF +#else /* UIP_CONF_PINGADDRCONF */ +#define UIP_PINGADDRCONF 0 +#endif /* UIP_CONF_PINGADDRCONF */ + + +/** + * Specifies if the uIP ARP module should be compiled with a fixed + * Ethernet MAC address or not. + * + * If this configuration option is 0, the macro uip_setethaddr() can + * be used to specify the Ethernet address at run-time. + * + * \hideinitializer + */ +#define UIP_FIXEDETHADDR 1 + +#define UIP_ETHADDR0 0x00 /**< The first octet of the Ethernet + address if UIP_FIXEDETHADDR is + 1. \hideinitializer */ +#define UIP_ETHADDR1 0xFF /**< The second octet of the Ethernet + address if UIP_FIXEDETHADDR is + 1. \hideinitializer */ +#define UIP_ETHADDR2 0xFF /**< The third octet of the Ethernet + address if UIP_FIXEDETHADDR is + 1. \hideinitializer */ +#define UIP_ETHADDR3 0xFF /**< The fourth octet of the Ethernet + address if UIP_FIXEDETHADDR is + 1. \hideinitializer */ +#define UIP_ETHADDR4 0xFF /**< The fifth octet of the Ethernet + address if UIP_FIXEDETHADDR is + 1. \hideinitializer */ +#define UIP_ETHADDR5 0xFF /**< The sixth octet of the Ethernet + address if UIP_FIXEDETHADDR is + 1. \hideinitializer */ + + +/** @} */ +/*------------------------------------------------------------------------------*/ +/** + * \name IP configuration options + * @{ + * + */ +/** + * The IP TTL (time to live) of IP packets sent by uIP. + * + * This should normally not be changed. + */ +#define UIP_TTL 64 + +/** + * Turn on support for IP packet reassembly. + * + * uIP supports reassembly of fragmented IP packets. This features + * requires an additonal amount of RAM to hold the reassembly buffer + * and the reassembly code size is approximately 700 bytes. The + * reassembly buffer is of the same size as the uip_buf buffer + * (configured by UIP_BUFSIZE). + * + * \note IP packet reassembly is not heavily tested. + * + * \hideinitializer + */ +#define UIP_REASSEMBLY 0 + +/** + * The maximum time an IP fragment should wait in the reassembly + * buffer before it is dropped. + * + */ +#define UIP_REASS_MAXAGE 40 + +/** @} */ + +/*------------------------------------------------------------------------------*/ +/** + * \name UDP configuration options + * @{ + */ + +/** + * Toggles wether UDP support should be compiled in or not. + * + * \hideinitializer + */ +#ifdef UIP_CONF_UDP +#define UIP_UDP UIP_CONF_UDP +#else /* UIP_CONF_UDP */ +#define UIP_UDP 0 +#endif /* UIP_CONF_UDP */ + +/** + * Toggles if UDP checksums should be used or not. + * + * \note Support for UDP checksums is currently not included in uIP, + * so this option has no function. + * + * \hideinitializer + */ +#ifdef UIP_CONF_UDP_CHECKSUMS +#define UIP_UDP_CHECKSUMS UIP_CONF_UDP_CHECKSUMS +#else +#define UIP_UDP_CHECKSUMS 0 +#endif + +/** + * The maximum amount of concurrent UDP connections. + * + * \hideinitializer + */ +#ifdef UIP_CONF_UDP_CONNS +#define UIP_UDP_CONNS UIP_CONF_UDP_CONNS +#else /* UIP_CONF_UDP_CONNS */ +#define UIP_UDP_CONNS 10 +#endif /* UIP_CONF_UDP_CONNS */ + +/** + * The name of the function that should be called when UDP datagrams arrive. + * + * \hideinitializer + */ + + +/** @} */ +/*------------------------------------------------------------------------------*/ +/** + * \name TCP configuration options + * @{ + */ + +/** + * Determines if support for opening connections from uIP should be + * compiled in. + * + * If the applications that are running on top of uIP for this project + * do not need to open outgoing TCP connections, this configration + * option can be turned off to reduce the code size of uIP. + * + * \hideinitializer + */ +#define UIP_ACTIVE_OPEN 1 + +/** + * The maximum number of simultaneously open TCP connections. + * + * Since the TCP connections are statically allocated, turning this + * configuration knob down results in less RAM used. Each TCP + * connection requires approximatly 30 bytes of memory. + * + * \hideinitializer + */ +#ifndef UIP_CONF_MAX_CONNECTIONS +#define UIP_CONNS 10 +#else /* UIP_CONF_MAX_CONNECTIONS */ +#define UIP_CONNS UIP_CONF_MAX_CONNECTIONS +#endif /* UIP_CONF_MAX_CONNECTIONS */ + + +/** + * The maximum number of simultaneously listening TCP ports. + * + * Each listening TCP port requires 2 bytes of memory. + * + * \hideinitializer + */ +#ifndef UIP_CONF_MAX_LISTENPORTS +#define UIP_LISTENPORTS 20 +#else /* UIP_CONF_MAX_LISTENPORTS */ +#define UIP_LISTENPORTS UIP_CONF_MAX_LISTENPORTS +#endif /* UIP_CONF_MAX_LISTENPORTS */ + +/** + * Determines if support for TCP urgent data notification should be + * compiled in. + * + * Urgent data (out-of-band data) is a rarely used TCP feature that + * very seldom would be required. + * + * \hideinitializer + */ +#define UIP_URGDATA 0 + +/** + * The initial retransmission timeout counted in timer pulses. + * + * This should not be changed. + */ +#define UIP_RTO 3 + +/** + * The maximum number of times a segment should be retransmitted + * before the connection should be aborted. + * + * This should not be changed. + */ +#define UIP_MAXRTX 8 + +/** + * The maximum number of times a SYN segment should be retransmitted + * before a connection request should be deemed to have been + * unsuccessful. + * + * This should not need to be changed. + */ +#define UIP_MAXSYNRTX 5 + +/** + * The TCP maximum segment size. + * + * This is should not be to set to more than + * UIP_BUFSIZE - UIP_LLH_LEN - UIP_TCPIP_HLEN. + */ +#define UIP_TCP_MSS (UIP_BUFSIZE - UIP_LLH_LEN - UIP_TCPIP_HLEN) + +/** + * The size of the advertised receiver's window. + * + * Should be set low (i.e., to the size of the uip_buf buffer) is the + * application is slow to process incoming data, or high (32768 bytes) + * if the application processes data quickly. + * + * \hideinitializer + */ +#ifndef UIP_CONF_RECEIVE_WINDOW +#define UIP_RECEIVE_WINDOW UIP_TCP_MSS +#else +#define UIP_RECEIVE_WINDOW UIP_CONF_RECEIVE_WINDOW +#endif + +/** + * How long a connection should stay in the TIME_WAIT state. + * + * This configiration option has no real implication, and it should be + * left untouched. + */ +#define UIP_TIME_WAIT_TIMEOUT 120 + + +/** @} */ +/*------------------------------------------------------------------------------*/ +/** + * \name ARP configuration options + * @{ + */ + +/** + * The size of the ARP table. + * + * This option should be set to a larger value if this uIP node will + * have many connections from the local network. + * + * \hideinitializer + */ +#ifdef UIP_CONF_ARPTAB_SIZE +#define UIP_ARPTAB_SIZE UIP_CONF_ARPTAB_SIZE +#else +#define UIP_ARPTAB_SIZE 8 +#endif + +/** + * The maxium age of ARP table entries measured in 10ths of seconds. + * + * An UIP_ARP_MAXAGE of 120 corresponds to 20 minutes (BSD + * default). + */ +#define UIP_ARP_MAXAGE 120 + +/** @} */ + +/*------------------------------------------------------------------------------*/ + +/** + * \name General configuration options + * @{ + */ + +/** + * The size of the uIP packet buffer. + * + * The uIP packet buffer should not be smaller than 60 bytes, and does + * not need to be larger than 1500 bytes. Lower size results in lower + * TCP throughput, larger size results in higher TCP throughput. + * + * \hideinitializer + */ +#ifndef UIP_CONF_BUFFER_SIZE +#define UIP_BUFSIZE 1520 +#else /* UIP_CONF_BUFFER_SIZE */ +#define UIP_BUFSIZE UIP_CONF_BUFFER_SIZE +#endif /* UIP_CONF_BUFFER_SIZE */ + + +/** + * Determines if statistics support should be compiled in. + * + * The statistics is useful for debugging and to show the user. + * + * \hideinitializer + */ +#ifndef UIP_CONF_STATISTICS +#define UIP_STATISTICS 0 +#else /* UIP_CONF_STATISTICS */ +#define UIP_STATISTICS UIP_CONF_STATISTICS +#endif /* UIP_CONF_STATISTICS */ + +/** + * Determines if logging of certain events should be compiled in. + * + * This is useful mostly for debugging. The function uip_log() + * must be implemented to suit the architecture of the project, if + * logging is turned on. + * + * \hideinitializer + */ +#ifndef UIP_CONF_LOGGING +#define UIP_LOGGING 0 +#else /* UIP_CONF_LOGGING */ +#define UIP_LOGGING UIP_CONF_LOGGING +#endif /* UIP_CONF_LOGGING */ + +/** + * Broadcast support. + * + * This flag configures IP broadcast support. This is useful only + * together with UDP. + * + * \hideinitializer + * + */ +#ifndef UIP_CONF_BROADCAST +#define UIP_BROADCAST 0 +#else /* UIP_CONF_BROADCAST */ +#define UIP_BROADCAST UIP_CONF_BROADCAST +#endif /* UIP_CONF_BROADCAST */ + +/** + * Print out a uIP log message. + * + * This function must be implemented by the module that uses uIP, and + * is called by uIP whenever a log message is generated. + */ +void uip_log(char *msg); + +/** + * The link level header length. + * + * This is the offset into the uip_buf where the IP header can be + * found. For Ethernet, this should be set to 14. For SLIP, this + * should be set to 0. + * + * \hideinitializer + */ +#ifdef UIP_CONF_LLH_LEN +#define UIP_LLH_LEN UIP_CONF_LLH_LEN +#else /* UIP_CONF_LLH_LEN */ +#define UIP_LLH_LEN 14 +#endif /* UIP_CONF_LLH_LEN */ + +/** @} */ +/*------------------------------------------------------------------------------*/ +/** + * \name CPU architecture configuration + * @{ + * + * The CPU architecture configuration is where the endianess of the + * CPU on which uIP is to be run is specified. Most CPUs today are + * little endian, and the most notable exception are the Motorolas + * which are big endian. The BYTE_ORDER macro should be changed to + * reflect the CPU architecture on which uIP is to be run. + */ + +/** + * The byte order of the CPU architecture on which uIP is to be run. + * + * This option can be either BIG_ENDIAN (Motorola byte order) or + * LITTLE_ENDIAN (Intel byte order). + * + * \hideinitializer + */ +#ifdef UIP_CONF_BYTE_ORDER +#define UIP_BYTE_ORDER UIP_CONF_BYTE_ORDER +#else /* UIP_CONF_BYTE_ORDER */ +#define UIP_BYTE_ORDER UIP_LITTLE_ENDIAN +#endif /* UIP_CONF_BYTE_ORDER */ + +/** @} */ +/*------------------------------------------------------------------------------*/ + +/** + * \name Appication specific configurations + * @{ + * + * An uIP application is implemented using a single application + * function that is called by uIP whenever a TCP/IP event occurs. The + * name of this function must be registered with uIP at compile time + * using the UIP_APPCALL definition. + * + * uIP applications can store the application state within the + * uip_conn structure by specifying the type of the application + * structure by typedef:ing the type uip_tcp_appstate_t and uip_udp_appstate_t. + * + * The file containing the definitions must be included in the + * uipopt.h file. + * + * The following example illustrates how this can look. + \code + +void httpd_appcall(void); +#define UIP_APPCALL httpd_appcall + +struct httpd_state { + u8_t state; + u16_t count; + char *dataptr; + char *script; +}; +typedef struct httpd_state uip_tcp_appstate_t + \endcode + */ + +/** + * \var #define UIP_APPCALL + * + * The name of the application function that uIP should call in + * response to TCP/IP events. + * + */ + +/** + * \var typedef uip_tcp_appstate_t + * + * The type of the application state that is to be stored in the + * uip_conn structure. This usually is typedef:ed to a struct holding + * application state information. + */ + +/** + * \var typedef uip_udp_appstate_t + * + * The type of the application state that is to be stored in the + * uip_conn structure. This usually is typedef:ed to a struct holding + * application state information. + */ +/** @} */ +/** @} */ + +#endif /* __UIPOPT_H__ */ diff --git a/Tester/SW/lib/Drivers/irq.c b/Tester/SW/lib/Drivers/irq.c new file mode 100644 index 0000000..ea3bc2e --- /dev/null +++ b/Tester/SW/lib/Drivers/irq.c @@ -0,0 +1,78 @@ +/***************************************************************************** + * irq.c: Interrupt handler C file for NXP LPC230x Family Microprocessors + * + * Copyright(C) 2006, NXP Semiconductor + * All rights reserved. + * + * History + * 2006.07.13 ver 1.00 Prelimnary version, first Release + * +******************************************************************************/ +#include "LPC23xx.h" +#include "types.h" +#include "irq.h" + +/* Initialize the interrupt controller */ +/****************************************************************************** +** Function name: init_VIC +** +** Descriptions: Initialize VIC interrupt controller. +** parameters: None +** Returned value: None +** +******************************************************************************/ +void init_VIC(void) +{ +UINT32 i = 0; +UINT32 *vect_addr, *vect_cntl; + + /* initialize VIC*/ + VICIntEnClr = 0xffffffff; + VICVectAddr = 0; + VICIntSelect = 0; + + /* set all the vector and vector control register to 0 */ + for ( i = 0; i < VIC_SIZE; i++ ) + { + vect_addr = (UINT32 *)(VIC_BASE_ADDR + VECT_ADDR_INDEX + i*4); + vect_cntl = (UINT32 *)(VIC_BASE_ADDR + VECT_CNTL_INDEX + i*4); + *vect_addr = 0x0; + *vect_cntl = 0xF; + } + return; +} + +/****************************************************************************** +** Function name: install_irq +** +** Descriptions: Install interrupt handler +** parameters: Interrupt number, interrupt handler address, +** interrupt priority +** Returned value: true or false, return false if IntNum is out of range +** +******************************************************************************/ +BOOLEAN install_irq( UINT32 IntNumber, void *HandlerAddr, UINT32 Priority ) +{ +UINT32 *vect_addr; +UINT32 *vect_cntl; + + VICIntEnClr = 1 << IntNumber; /* Disable Interrupt */ + if ( IntNumber >= VIC_SIZE ) + { + return ( FALSE ); + } + else + { + /* find first un-assigned VIC address for the handler */ + vect_addr = (UINT32 *)(VIC_BASE_ADDR + VECT_ADDR_INDEX + IntNumber*4); + vect_cntl = (UINT32 *)(VIC_BASE_ADDR + VECT_CNTL_INDEX + IntNumber*4); + *vect_addr = (UINT32)HandlerAddr; /* set interrupt vector */ + *vect_cntl = Priority; + VICIntEnable = 1 << IntNumber; /* Enable Interrupt */ + return( TRUE ); + } +} + +/****************************************************************************** +** End Of File +******************************************************************************/ diff --git a/Tester/SW/lib/Drivers/irq.h b/Tester/SW/lib/Drivers/irq.h new file mode 100644 index 0000000..fa5d9f4 --- /dev/null +++ b/Tester/SW/lib/Drivers/irq.h @@ -0,0 +1,73 @@ +/****************************************************************************** + * irq.h: Interrupt related Header file for NXP LPC230x Family + * Microprocessors + * + * Copyright(C) 2006, NXP Semiconductor + * All rights reserved. + * + * History + * 2006.09.01 ver 1.00 Prelimnary version, first Release + * +******************************************************************************/ +#ifndef __IRQ_H +#define __IRQ_H + +#define I_Bit 0x80 +#define F_Bit 0x40 + +#define SYS32Mode 0x1F +#define IRQ32Mode 0x12 +#define FIQ32Mode 0x11 + +#define HIGHEST_PRIORITY 0x01 +#define LOWEST_PRIORITY 0x0F + +#define WDT_INT 0 +#define SWI_INT 1 +#define ARM_CORE0_INT 2 +#define ARM_CORE1_INT 3 +#define TIMER0_INT 4 +#define TIMER1_INT 5 +#define UART0_INT 6 +#define UART1_INT 7 +#define PWM0_1_INT 8 +#define I2C0_INT 9 +#define SPI0_INT 10 /* SPI and SSP0 share VIC slot */ +#define SSP0_INT 10 +#define SSP1_INT 11 +#define PLL_INT 12 +#define RTC_INT 13 +#define EINT0_INT 14 +#define EINT1_INT 15 +#define EINT2_INT 16 +#define EINT3_INT 17 +#define ADC0_INT 18 +#define I2C1_INT 19 +#define BOD_INT 20 +#define EMAC_INT 21 +#define USB_INT 22 +#define CAN_INT 23 +#define MCI_INT 24 +#define GPDMA_INT 25 +#define TIMER2_INT 26 +#define TIMER3_INT 27 +#define UART2_INT 28 +#define UART3_INT 29 +#define I2C2_INT 30 +#define I2S_INT 31 + +#define VIC_SIZE 32 + +//#define VIC_BASE_ADDR ((unsigned int)&VICIRQSTATUS) + +#define VECT_ADDR_INDEX 0x100 +#define VECT_CNTL_INDEX 0x200 + +void init_VIC( void ); +BOOLEAN install_irq( UINT32 IntNumber, void *HandlerAddr, UINT32 Priority ); + +#endif /* end __IRQ_H */ + +/****************************************************************************** +** End Of File +******************************************************************************/ diff --git a/Tester/SW/lib/Drivers/leds.c b/Tester/SW/lib/Drivers/leds.c new file mode 100644 index 0000000..49f4787 --- /dev/null +++ b/Tester/SW/lib/Drivers/leds.c @@ -0,0 +1,121 @@ +/* --------------------------------------------------------------------------- + * dio.c - v0.1 (c) 2007 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: Digital inputs/outputs interface. + * --------------------------------------------------------------------------- + * Version(s): 0.1, 28-11-2007, fvds. + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +#include +#include + +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "LPC23xx.h" +#include "types.h" +#include "leds.h" + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ +#define LED0_MASK 0x00000010 +#define LED1_MASK 0x00000020 +#define LEDS_MASK (LED0_MASK | LED1_MASK) + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ +void ledInit() +{ + SCS |= (1UL<<0); + // set GPIOM in SCS for fast IO + + // Set pin 4 & 5 of port 4 as output + FIO0DIR |= LEDS_MASK; + + // Turn LED's off + FIO0CLR = LEDS_MASK; +} + +void ledSet(t_led_ids ledId, BOOLEAN on) +{ + UINT32 ledMask; + + ledMask = (ledId == LED0 ? LED0_MASK : LED1_MASK); + + if (on == TRUE) + { + FIO0SET = ledMask; + } + else + { + FIO0CLR = ledMask; + } + +} + +BOOLEAN ledGet( t_led_ids ledId ) + { + UINT32 ledMask; + + ledMask = (ledId == LED0 ? LED0_MASK : LED1_MASK); + + + if (FIO0PIN & ledMask) + + { + return TRUE; + } + else + { + return FALSE; + } + } + +void ledToggle(t_led_ids ledId) +{ + UINT32 ledMask; + + ledMask = (ledId == LED0 ? LED0_MASK : LED1_MASK); + if (FIO0PIN & ledMask) + { + FIO0CLR = ledMask; + // Turn off led + } + else + { + FIO0SET = ledMask; + // Turn on led + } + +} + diff --git a/Tester/SW/lib/Drivers/leds.h b/Tester/SW/lib/Drivers/leds.h new file mode 100644 index 0000000..a40aa3b --- /dev/null +++ b/Tester/SW/lib/Drivers/leds.h @@ -0,0 +1,76 @@ +/* --------------------------------------------------------------------------- + * leds.h - v0.1 (c) 2007 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: LED-driver interface. + * --------------------------------------------------------------------------- + * Version(s): 0.1, 10-09-2007, Marcel Mulder. + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef __LEDS_H__ +#define __LEDS_H__ + +/** \file leds.h + \brief LED driver interface. +*/ + +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ +#include "lpc23xx.h" +#include "types.h" + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ +typedef enum +{ + LED0, /**< First LED */ + LED1 /**< Second LED*/ +} t_led_ids; + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ +/** \brief Initialize of leds interface.*/ +void ledInit( void ); + +/** \brief Sets the status of a LED.*/ +void ledSet( t_led_ids ledId, BOOLEAN on ); + +/** \brief Returns the status of a LED.*/ +BOOLEAN ledGet( t_led_ids ledId ); + +/** \brief Toggles the status of a LED.*/ +void ledToggle( t_led_ids ledId ); + + +#endif /* __LEDS_H__ */ diff --git a/Tester/SW/lib/Drivers/logging.c b/Tester/SW/lib/Drivers/logging.c new file mode 100644 index 0000000..8812779 --- /dev/null +++ b/Tester/SW/lib/Drivers/logging.c @@ -0,0 +1,217 @@ +/* --------------------------------------------------------------------------- + * logging.c (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: log driver + * --------------------------------------------------------------------------- + * Version(s): 0.1, Nov 28, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +/* Compiler includes */ +#include "string.h" + +#include "LPC23xx.h" +#include "types.h" + +/* FreeRTOS includes */ +#include "FreeRTOS.h" +#include "task.h" +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "logging.h" +#include "serial.h" +#include "SerOut.h" + +#include "fat_public.h" +#include "fat_intern.h" +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ +char returndate[12]; +char returntime[9]; +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ + +void enableLog (void) +{ + LogFlag = TRUE; +} + + +void disableLog (void) +{ + LogFlag = FALSE; +} + + +void startLog (UINT32 serialnumber) +{ + char fileName[13]; + char fileExt[4] = ".txt"; + + sprintf (fileName, "%i", serialnumber); /* Convert INT-Value to DEZ-String */ + strncat (fileName, fileExt, 4); + debugPrint ("\n\r"); + debugPrint (fileName); + + FAT_StatusOut (f_open (&log_file, fileName, (FA_READ | FA_WRITE | FA_CREATE_ALWAYS))); +} + + +void stopLog (void) +{ + FAT_StatusOut (f_sync (&log_file)); + FAT_StatusOut (f_close (&log_file)); +} + + +void writeLog (t_logSource source, t_serial_devices ComPort, Messagetype_t urgency, char * Message) +{ + UINT32 bytes_written; + UINT32 string_length; + char WriteBuffer[512]; + + if (LogFlag == TRUE) + { + + if (ComPort == COM1) + { + strcpy(WriteBuffer, "\nSerial Port: COM1\t"); + } + else if (ComPort == COM2) + { + strcpy(WriteBuffer, "\nSerial Port: COM2\t"); + } + + if (source == LogInput) + { + strcat(WriteBuffer, "Direction: Input\t"); + } + else if (source == LogOutput) + { + strcat(WriteBuffer, "Direction: Output\t"); + } + + switch (urgency) + { + case importantMessage: + strcat(WriteBuffer, "Urgency: important Message\t"); + break; + case headerMessage: + strcat(WriteBuffer, "Urgency: header Message\t\t"); + break; + case resultMessage: + strcat(WriteBuffer, "Urgency: result Message\t\t"); + break; + case noteMessage: + strcat(WriteBuffer, "Urgency: note Message\t\t"); + break; + case testMessage: + strcat(WriteBuffer, "Urgency: test Message\t\t"); + break; + case menuMessage: + strcat(WriteBuffer, "Urgency: menu Message\t\t"); + break; + default: + ; + } + +// strcat(WriteBuffer, "\n"); + strcat(WriteBuffer, Message); + + string_length = strlen(WriteBuffer); + + f_write(&log_file, &WriteBuffer, string_length, &bytes_written); + } +} + + +void listLog (char* path) +{ + UINT32 loopcnt; + DIR directory; + FILINFO fileinfo; + + if (f_opendir(&directory, path) == FR_OK) + { + loopcnt = strlen(path); + + sendString (SerOutPort, TRUE, importantMessage, + "Content of ", path, ":\n\r"); + + while ((f_readdir(&directory, &fileinfo) == FR_OK) && fileinfo.fname[0]) + { + sendString (SerOutPort, TRUE, importantMessage, + f_tab, &fileinfo.fname[0], Dummy); + sendString (SerOutPort, FALSE, importantMessage, + f_tab, ItoDStr (fileinfo.fsize), Dummy); + sendString (SerOutPort, FALSE, importantMessage, + f_tab, formatFiledate (fileinfo.fdate), Dummy); + sendString (SerOutPort, FALSE, importantMessage, + f_tab, formatFiletime (fileinfo.ftime), Dummy); + } + } +} + + +char * formatFiledate (UINT16 date) +{ + char date_devider = '-'; + + strcpy (returndate, ItoDStr (date & 0x0000001F)); + returndate[2] = date_devider; + + strcat (returndate, ItoDStr ((date & 0x000001E0) >> 5)); + returndate[5] = date_devider; + + strcat (returndate, ItoDStr (1980 + ((date & 0x0000FE00) >> 9))); + returndate[10] = '\0'; + + return (returndate); +} + + +char * formatFiletime (UINT16 time) +{ + char date_devider = ':'; + + strcpy (returntime, ItoDStr ((time & 0x0000F800) >> 11)); + returntime[2] = date_devider; + + strcat (returntime, ItoDStr ((time & 0x000007E0) >> 5)); + returntime[5] = date_devider; + + strcat (returntime, ItoDStr (2 * (time & 0x0000001F))); + returntime[8] = '\0'; + + return (returntime); +} diff --git a/Tester/SW/lib/Drivers/logging.h b/Tester/SW/lib/Drivers/logging.h new file mode 100644 index 0000000..2b39a36 --- /dev/null +++ b/Tester/SW/lib/Drivers/logging.h @@ -0,0 +1,74 @@ +/* --------------------------------------------------------------------------- + * logging.h (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Nov 28, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef LOGGING_H_ +#define LOGGING_H_ +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ +#include "LPC23xx.h" +#include "types.h" + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ +#include "serial.h" +#include "SerOut.h" + +#include "fat_public.h" +#include "fat_intern.h" +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ +typedef enum _t_logSource + { + LogInput = 0, + LogOutput = 1 + } t_logSource; +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ +BOOLEAN LogFlag; +FATFS SD_CARD; +FIL log_file; +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ + +void enableLog (void); +void disableLog (void); +void startLog (UINT32 serialnumber); +void stopLog (void); +void writeLog (t_logSource source, t_serial_devices ComPort, Messagetype_t urgency, char * Message); +void listLog (char* path); + +char * formatFiledate (UINT16 date); +char * formatFiletime (UINT16 date); + + +#endif /*LOGGING_H_*/ diff --git a/Tester/SW/lib/Drivers/mem.h b/Tester/SW/lib/Drivers/mem.h new file mode 100644 index 0000000..ebaa754 --- /dev/null +++ b/Tester/SW/lib/Drivers/mem.h @@ -0,0 +1,89 @@ +/* --------------------------------------------------------------------------- + * mem.h - v0.1 (c) 2007 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: Non-volatile memory interface. + * --------------------------------------------------------------------------- + * Version(s): 0.1, 10-09-2007, Marcel Mulder. + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef __MEM_H__ +#define __MEM_H__ + +/** \file mem.h + \brief Non-volatile memory interface. +*/ + +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ +#include "lpc23xx.h" +#include "types.h" + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ +typedef enum +{ + SEEPROM, /**< Serial (SPI) EEPROM*/ + SFLASH, /**< Serial (SPI) FLASH*/ + IFLASH, /**< Internal FLASH*/ + ISRAM /**< Internal battery backupped SRAM*/ +} t_mem_devices; + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ +/** \brief Initialize non-volatile memory interface.*/ +void memInit (void); + +/** \brief Read from non-volatile memory. + \retval len Length of data + \retval data Pointer to data + \retval bool True if succesfull +*/ +BOOLEAN memRead ( + t_mem_devices memDevices, + UINT32 addr, /**< Address of memory device*/ + UINT16 * len, /**< Pointer to length of data*/ + UINT8 * data /**< Pointer to data*/ +); + +/** \brief Write to non-volatile memory. + \retval bool True if succesfull +*/ +BOOLEAN memWrite ( + t_mem_devices memDevices, + UINT32 addr, /**< Address of memory device*/ + UINT16 len, /**< Length of data*/ + UINT8 * data /**< Pointer to data*/ +); + +#endif /* __MEM_H__ */ diff --git a/Tester/SW/lib/Drivers/mmc.c b/Tester/SW/lib/Drivers/mmc.c new file mode 100644 index 0000000..c21f958 --- /dev/null +++ b/Tester/SW/lib/Drivers/mmc.c @@ -0,0 +1,810 @@ +/* --------------------------------------------------------------------------- + * mmc.c (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Apr 22, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +/* Compiler Includes */ +#include +#include + +#include "LPC23xx.h" +#include "types.h" +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "mmc.h" +#include "mmc_transfer.h" +#include "dio.h" +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ +#define MMC_GLOBAL + +#define __no_init + +#define CSD_GET_TRAN_SPEED_EXP() (MmcSdCsd[ 0]&0x07) +#define CSD_GET_TRAN_SPEED_MANT() ((MmcSdCsd[ 0]&0xF8)>>3 ) +#define CSD_GET_NSAC() (MmcSdCsd[ 1] ) +#define CSD_GET_TAAC_EXP() (MmcSdCsd[ 2]&0x7) +#define CSD_GET_TAAC_MANT() ((MmcSdCsd[ 2]&0xF8)>>3 ) +#define CSD_GET_R2W_FACTOR() ((MmcSdCsd[15]&0x1C)>>2 ) +#define CSD_GET_READ_BL_LEN() (MmcSdCsd[ 6]&0x0F) +#define CSD_GET_C_SIZE() (((MmcSdCsd[ 5]&0x03)<<10) + (MmcSdCsd[4]<<2) + ((MmcSdCsd[11]&0xc0)>>6)) +#define CSD_GET_C_SIZE_MULT() (((MmcSdCsd[10]&0x03)<<1 ) +((MmcSdCsd[9]&0x80)>>7)) +#define CSD_GET_PERM_WRITE_PROTECT() ((MmcSdCsd[13]&0x20)>>5 ) +#define CSD_GET_TMP_WRITE_PROTECT() ((MmcSdCsd[13]&0x10)>>4 ) + +volatile UINT32 i; + + +#define SpcInquiryRemovableMedium 0x80 +#define SpcInquiryStandartVersion 5 +#define SizeOfInquiryDescMmcDsk 36 + +const UINT32 MmcTransfExp[] = + { 10000UL, 100000UL, 1000000UL, 10000000UL, 0UL, 0UL, 0UL, 0UL, +}; + +const UINT32 MmmcAccessTime [] = + { 1UL, 10UL, 100UL, 1000UL, 10000UL, 100000UL, 1000000UL, 10000000UL, +}; + +const UINT32 MmcCsdMant[] = + { 0UL, 10UL, 12UL, 13UL, 15UL, 20UL, 25UL, 30UL, 35UL, 40UL, 45UL, 50UL, + 55UL, 60UL, 70UL, 80UL, +}; + +const MmcCommads_t MmcCmd[CMD_END] = + { /* {TxData, Arg, Resp} */ + { 0x00, MmcNoArg, MmcNoResp }, /* CMD0 */ + { 0x01, MmcOcr, MmcR3 }, /* CMD1 */ + { 0x02, MmcNoArg, MmcR2 }, /* CMD2 */ + { 0x03, MmcRelAddr, MmcR1 }, /* CMD3 */ + { 0x07, MmcRelAddr, MmcR1 }, /* CMD7 */ + { 0x09, MmcRelAddr, MmcR2 }, /* CMD9 */ + { 0x0A, MmcRelAddr, MmcR2 }, /* CMD10 */ + { 0x0C, MmcNoArg, MmcR1b }, /* CMD12 */ + { 0x0D, MmcRelAddr, MmcR1 }, /* CMD13 */ + { 0x10, MmcBlockLen, MmcR1 }, /* CMD16 */ + { 0x11, MmcDataAdd, MmcR1 }, /* CMD17 */ + { 0x12, MmcDataAdd, MmcR1 }, /* CMD18 */ + { 0x18, MmcDataAdd, MmcR1 }, /* CMD24 */ + { 0x19, MmcDataAdd, MmcR1 }, /* CMD25 */ + { 0x1B, MmcOcr, MmcR1 }, /* CMD27 */ + { 0x1C, MmcDataAdd, MmcR1b }, /* CMD28 */ + { 0x1D, MmcDataAdd, MmcR1b }, /* CMD29 */ + { 0x1E, MmcDataAdd, MmcR1 }, /* CMD30 */ + { 0x20, MmcDataAdd, MmcR1 }, /* CMD32 */ + { 0x21, MmcDataAdd, MmcR1 }, /* CMD33 */ + { 0x22, MmcDataAdd, MmcR1 }, /* CMD34 */ + { 0x23, MmcDataAdd, MmcR1 }, /* CMD35 */ + { 0x24, MmcDataAdd, MmcR1 }, /* CMD36 */ + { 0x25, MmcDataAdd, MmcR1 }, /* CMD37 */ + { 0x26, MmcNoArg, MmcR1b }, /* CMD38 */ + { 0x2A, MmcNoArg, MmcR1b }, /* CMD42 */ + { 0x37, MmcRelAddr, MmcR1 }, /* CMD55 */ + { 0x38, MmcNoArg, MmcR1 }, /* CMD56 */ + { 0x06, MmcDataAdd, MmcR1 }, /* ACMD46 */ + { 0x29, MmcDataAdd, MmcR3 }, /* ACMD41 */ +}; + +const UINT8 MmcDskInquiry[]__attribute__((aligned (4)))= + { + SbcDirectAccess, /* 0 PERIPHERAL QUALIFIER AND DEVICE*/ + SpcInquiryRemovableMedium, /* 1 RMB */ + SpcInquiryStandartVersion, /* 2 VERSION */ + 0x02, /* 3 NORMACA HISUP RESPONSE FORMAT */ + 36-4, /* 4 ADDITIONAL LENGTH (n-4) */ + 0x00, /* 5 SCCS */ + /* for parallel SCSI only */ + 0x00, /* 6 BQUE ENCSERV VS MULTIP MCHNGR Obsolete Obsolete ADDR16 */ + 0x00, /* 7 RELADR Obsolete WBUS16† SYNC† LINKED Obsolete CMDQUE VS*/ + 'I','A','R',' ','S','y','s','.', /* 8 - 15 VENDOR IDENTIFICATION */ + /* 16 - 31 PRODUCT IDENTIFICATION */ + 'L','P','C','2','3','7','8',' ','S','t','o','r','a','g','e',' ', + '1','.','0','0', /* 32 - 35 PRODUCT REVISION LEVEL */ + }; + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ +static UINT32 CardRCA; +UINT32 MmcLastError; +UINT32 dlycnt; +UINT32 Tnac; +UINT32 Twr; + +UINT8 MmcSdCsd[16]__attribute__ ((aligned (4))); +static BOOLEAN bMmcPermWriteProtect; +BOOLEAN bMmcChanged; + +DiskCtrlBlk_t MmcDskCtrlBlk; +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ + +/* Function returns TRUE if Card is inserted, FALSE if Card is removed */ +inline BOOLEAN MmcPresent(void) +{ + return (!(MMC_CP_FIO & MMC_CP_MASK)); +} + + +/* Function returns TRUE is WriteProtection is activated, FALSE if + * Protection is off. If no Card is inserted, Function will also return + * TRUE. This results from the physical Switch Connection (See Datasheet). + * Usage of this Function only makes Sense with previous TRUE-Return + * from MmcPresent. + */ +inline BOOLEAN MmcWriteProtect(void) +{ + if (!(MMC_WP_FIO & MMC_WP_MASK)) + { + return (FALSE); + } + else + { + return (TRUE); + } +} + +UINT32 MmcSetClockFreq (UINT32 Frequency) + { + UINT32 Pclk = SYS_GetFPclk(MCI_PCLK_OFFSET); + UINT32 Div; + Frequency <<= 1; + + for(Div = 1; Div <= 256; ++Div) + { + if((Frequency * Div)> Pclk) + { + break; + } + } + MCI_CLOCK = ((Div - 1) & 0xFF); /* Set Clock Devider (Bit 0-7) */ + for(dlycnt = 10; dlycnt > 0;dlycnt--); + MCI_CLOCK |= (1 << 8); /* enable Clock (Bit 8) */ + for(dlycnt = 10; dlycnt > 0;dlycnt--); + MCI_CLOCK |= (1 << 9); /* Set PowerSave (Bit 9) */ + for(dlycnt = 10; dlycnt > 0;dlycnt--); + + return(Pclk/(Div<<1)); /* Return real frequency */ + } + +void MmcInit(void) +{ + UINT32 i; + + MMC_CP_DIR &= ~MMC_CP_MASK; /* Set CP to Input */ + MMC_CP_MODE &=~(1 << 24); /* Neither PullUp nor PullDown */ + MMC_CP_MODE |= (1 << 25); + + MMC_WP_DIR &= ~MMC_WP_MASK; /* Set WP to Input */ + MMC_WP_MODE &=~(1 << 22); /* Neither PullUp nor PullDown */ + MMC_WP_MODE |= (1 << 23); + + + PCLKSEL1 |= (1 << 24); /* set divider to /1 (Bit 24&25) */ + PCLKSEL1 &=~(1 << 25); + + PCONP |= 0x30000000; /* Set Power up */ + + PINSEL1 &=~(1 << 6); /* Assign Pin 0.19 (Bit 6&7) */ + PINSEL1 |= (1 << 7); + PINSEL1 &=~(1 << 8); /* Assign Pin 0.20 (Bit 8&9) */ + PINSEL1 |= (1 << 9); + PINSEL1 &=~(1 << 10); /* Assign Pin 0.21 (Bit 10&11) */ + PINSEL1 |= (1 << 11); + PINSEL1 &=~(1 << 12); /* Assign Pin 0.22 (Bit 12&13) */ + PINSEL1 |= (1 << 13); + PINSEL4 &=~(1 << 22); /* Assign Pin 2.11 (Bit 22&23) */ + PINSEL4 |= (1 << 23); + PINSEL4 &=~(1 << 24); /* Assign Pin 2.12 (Bit 24&25) */ + PINSEL4 |= (1 << 25); + PINSEL4 &=~(1 << 26); /* Assign Pin 2.13 (Bit 26&27) */ + PINSEL4 |= (1 << 27); + + + PINMODE1 &=~(1 << 6) & ~(1 << 7); /* Set PullUp Pin 0.19 (Bit 6&7) */ + PINMODE1 &=~(1 << 8) & ~(1 << 9); /* Set PullUp Pin 0.20 (Bit 8&9) */ + PINMODE1 &=~(1 << 10) & ~(1 << 11); /* Set PullUp Pin 0.21 (Bit 10&11) */ + PINMODE1 &=~(1 << 12) & ~(1 << 13); /* Set PullUp Pin 0.22 (Bit 12&13) */ + + + MCI_COMMAND = 0; /* Clear MCI Command Register */ + MCI_DATA_CTRL = 0; /* Clear MCI Data Control Register */ + MCI_CLEAR = 0x7FF; /* Clear all pending interrupts. */ + + /* Power up, switch on VCC for the Flash Card - Wait shortly */ + MCI_POWER = 0x02; + for (i = 0; i < 50000; i++); + + + MCI_POWER |= 0x01; /* Power on the Flash Card. */ + for (i = 0; i < 50000; i++); /* Wait shortly */ + + MmcPowerDown(); + + GPDMA_SYNC = 0; /* DMA sync enable */ + GPDMA_INT_ERR_CLR = 3; /* Clear DMA Error Interrupts */ + GPDMA_INT_TCCLR = 3; /* Clear DMA Interrupts */ + +} + +void MmcPowerDown(void) +{ + SCS |= (1 << 3); /* Init Power State (Bit 3) */ + MCI_POWER = 0; + for(dlycnt = 10; dlycnt > 0;dlycnt--); + MCI_MASK0 = 0; /* Disable all interrupts for now */ + MCI_MASK1 = 0; + MCI_COMMAND = 0; + for(dlycnt = 10; dlycnt > 0;dlycnt--); + MCI_DATA_CTRL = 0; + for(dlycnt = 10; dlycnt > 0;dlycnt--); + MCI_CLEAR = 0x7FF; + + MCI_CLOCK &=~(1 << 11); /* clear all pending interrupts */ + for(dlycnt = 10; dlycnt > 0;dlycnt--); + + MmcSetClockFreq(IdentificationModeClock); /* ClkFreq Ident Mode< 400kHz */ +} + + +MmcState_t MmcSendCmd(MmcSpiCmdInd_t ComdInd, pUINT32 pArg) +{ + UINT32 Status; + union + { + UINT32 Data; + struct + { + UINT32 CMDINDEX : 6; + UINT32 RESPONSE : 1; + UINT32 LONGRSP : 1; + UINT32 INTERRUPT : 1; + UINT32 PENDING : 1; + UINT32 ENABLE : 1; + UINT32 :21; + }; + } Command; + + /* The Command engine has to be Disabled when modifying the Argument + * of the Peripheral + */ + while ((MCI_STATUS << 11) == TRUE) /* While a Command is in Progress */ + { + MCI_COMMAND = 0; /* Clear MCI Command Register */ + for(dlycnt = 10; dlycnt > 0;dlycnt--); + } + Command.Data = 0; + + /* Copy Command-specific Index-Argument from MmcCmd LookUp Table to + * Command struct + */ + Command.CMDINDEX = MmcCmd[ComdInd].TxData; + if (pArg != NULL) /* Set Command Response depending on*/ + { /* asked Argument */ + switch (MmcCmd[ComdInd].Resp) + { + case MmcR2: + Command.LONGRSP = 1; + case MmcR1: + case MmcR1b: + case MmcR3: + Command.RESPONSE = 1; + case MmcNoResp:; + } + } + Command.ENABLE = 1; + + if (MmcCmd[ComdInd].Arg != MmcNoArg) /* If Argument exists */ + { + MCI_ARGUMENT = *pArg; /* Copy Argument to MCI Argument Reg*/ + } + else + { + MCI_ARGUMENT = 0; + } + + MCI_COMMAND = Command.Data; /* Send Command to Card */ + for(dlycnt = 10; dlycnt > 0;dlycnt--); + while ((Status = MCI_STATUS & 0x000000C5) == 0);/* Wait command respond */ + + MCI_CLEAR = Status; /* Clear actual Status */ + + if (Status & (1UL << 2)) /* If Command TimeOut occourses */ + { + MCI_COMMAND = 0; /* reset Command Register */ + for(dlycnt = 10; dlycnt > 0;dlycnt--); + return (MmcNoResponse); /* Return with Error Message */ + } + if (Status & (1UL << 0)) /* Command CRC Error */ + { + switch (MCI_COMMAND & 0x3F) /* Ignore CRC Error for following */ + { /* Commands */ + case 1: /* CMD1 */ + case 41: /* ACMD42 */ + case 12: /* CMD12 */ + MCI_COMMAND = 0; + for(dlycnt = 10; dlycnt > 0;dlycnt--); + MCI_ARGUMENT = 0xFFFFFFFF; + break; + default: /* No CRC Error Ignoring */ + MCI_COMMAND = 0; + for(dlycnt = 10; dlycnt > 0;dlycnt--); + return (MmcCardError); + } + } + + if (pArg != NULL) + { + switch (MmcCmd[ComdInd].Resp) /* Handle Command Response */ + { + case MmcNoResp: + break; + case MmcR3: + *pArg = MCI_RESP0; + break; + case MmcR2: + *pArg++ = MCI_RESP0; + *pArg++ = MCI_RESP1; + *pArg++ = MCI_RESP2; + *pArg++ = MCI_RESP3; + break; + default: + if (MmcCmd[ComdInd].TxData != (MCI_RESP_CMD & 0x3F)) /* Bit 0-5*/ + { + return (MmcCardError); + } + *pArg = MCI_RESP0; + } + } + MCI_COMMAND = 0; + for(dlycnt = 10; dlycnt > 0;dlycnt--); + return (MmcOk); +} + +UINT32 Status; +MmcState_t MmcInitMedia(void) +{ + UINT32 i; + UINT32 res; + UINT32 loopcnt; + volatile UINT32 Dly; + UINT8 MmcSdCid[16]; + BOOLEAN CardDetected = FALSE; + + Tnac = 1; + if (MmcPresent() == FALSE) /* If no Card inserted */ + { + if (MCI_POWER & 0x3) /* Is Power up? */ + { + MmcPowerDown(); /* Set to power down state */ + } + return (MmcNoPresent); /* Return with Error Message */ + } + + MmcPowerDown(); /* Power Down */ + MmcDly_1ms(100); + + MCI_POWER &=~(1 << 0); /* power up (Bit 1) */ + MCI_POWER |= (1 << 1); + for(dlycnt = 10; dlycnt > 0;dlycnt--); + while ((MCI_POWER & 0x3) != 0x2); + + MCI_POWER |= (1 << 0); /* power reserved (Bit 0) */ + MCI_POWER &=~(1 << 1); + MmcDly_1ms(100); + MCI_POWER &=~(1 << 6); /* Disable OpenDrain Mode */ + for(dlycnt = 10; dlycnt > 0;dlycnt--); + + MCI_POWER = 0x02; /* Power up (Bit 1) */ + for (loopcnt = 0; loopcnt < 50000; loopcnt++); + + MCI_POWER |= 0x01; /* Power on the Flash Card */ + for (loopcnt = 0; loopcnt < 50000; loopcnt++); + + if (MmcSendCmd(CMD0, NULL) != MmcOk) /* Send Cmd0, Reset Card */ + { + return (MmcNoResponse); + } + + MCI_POWER |= 0x40; /* Set OpenDrain output control */ + + MmcDskCtrlBlk.DiskType = DiskMMC; /* Determinate Card type SD or MMC */ + for (i=100; i; --i) /* Try detecting several Times */ + { + MCI_POWER &=~(1 << 6); /* Disable OpenDrain Mode */ + for(dlycnt = 10; dlycnt > 0;dlycnt--); + res = 0; + if (((Status = MmcSendCmd(CMD55, &res)) == MmcOk) && (res & 0x100)) + { /* Send Notification for ACMD41 */ + res = OcrReg; + if ((MmcSendCmd(ACMD41, &res) == MmcOk) && (res & 0x80000000)) + /* Activates Init Process (only SD) */ + { /* Gets here when SD Card detected */ + CardDetected = TRUE; + MmcDskCtrlBlk.DiskType = DiskSD; + break; + } + } + else /* If Cmd55 fails */ + { + MCI_POWER |= (1 << 6); /* enable OpenDrain Mode */ + for(dlycnt = 10; dlycnt > 0;dlycnt--); + res = OcrReg; + if (MmcSendCmd(CMD1, &res) == MmcOk && (res & 0x80000000)) + /* CMD1 for MMC Init sequence */ + { /* Gets here when MMC Card detected */ + CardDetected = TRUE; + break; + } + } + MmcDly_1ms(50); + } /* end Card Detection */ + + if (CardDetected == FALSE) /* If no Card recognized */ + { + return (MmcNoResponse); /* Return with Error Message */ + } + if (MmcSendCmd(CMD2, (pUINT32)MmcSdCid) != MmcOk) /* Read CID from Card */ + { + return (MmcNoResponse); /* Return with Error Message */ + } + + /* Set address */ + CardRCA = (MmcDskCtrlBlk.DiskType == DiskMMC) ? 0x00010000 : 0x00000000; + if (MmcSendCmd(CMD3, &CardRCA) != MmcOk) + { + return (MmcNoResponse); + } + if (MmcDskCtrlBlk.DiskType == DiskSD) + { + CardRCA &= 0xFFFF0000; + } + else + { + CardRCA = 0x00010000; + } + + MCI_POWER &=~(1 << 6); /* Disable OpenDrain Mode */ + for(dlycnt = 10; dlycnt > 0;dlycnt--); + + + /* Read Card specific Data from Card */ + MmcSdCsd[0] = 0; + MmcSdCsd[1] = 0; + MmcSdCsd[2] = CardRCA >> 16; + MmcSdCsd[3] = CardRCA >> 24; + if (MmcSendCmd(CMD9, (pUINT32)MmcSdCsd) != MmcOk) + { + return (MmcNoResponse); + } + + MmcCsdImplemet(); /* Implement CSD data */ + + res = CardRCA; + if (MmcSendCmd(CMD7, &res) != MmcOk) /* Select Card */ + { + return (MmcNoResponse); + } + res = CardRCA; + if (MmcOk != MmcSendCmd(CMD13, &res)) /* Send Card Status Register */ + { + return (MmcNoResponse); + } else if (!(res & READY_FOR_DATA) || ((res & CURRENT_STATE) + != CARD_TRAN)) + { + return (MmcCardError); + } + + if (MmcDskCtrlBlk.DiskType == DiskSD) + { + MCI_CLOCK |= (1 << 11); /* Use wide bus for SD */ + for (loopcnt = 0; loopcnt < 100; loopcnt++); + + res = CardRCA; + if (((Status = MmcSendCmd(CMD55, &res)) != MmcOk) || !(res & 0x100)) + /* Send Notification for ACMD6 */ + { + return (MmcCardError); + } + + res = 2; + if (MmcSendCmd(ACMD6, &res) != MmcOk) /* Set bus width 4bits */ + { + return (MmcCardError); + } + } + + res = MmcDskCtrlBlk.BlockSize; + if (MmcSendCmd(CMD16, &res)) /* Set Block size */ + { + return (MmcNoResponse); + } + + return (MmcOk); +} + +UINT32 Tets; +void MmcCsdImplemet(void) +{ + UINT32 Freq; + UINT64 Tmp; + // Calculate SPI max clock + Freq = MmcTransfExp[CSD_GET_TRAN_SPEED_EXP()] * MmcCsdMant[CSD_GET_TRAN_SPEED_MANT()]; + Freq = MmcSetClockFreq(Freq); + if (MmcDskCtrlBlk.DiskType == DiskMMC) + { + // Calculate Time outs for MMC cards + Tmp = MmmcAccessTime[CSD_GET_TAAC_EXP()] * MmcCsdMant[CSD_GET_TAAC_MANT()]; + Tmp /= 10000; // us + // Freq [Hz], Tmp[1 us], *10 + Tmp = (Freq*Tmp)/100000LL; + // NSAC*100*10 + Tmp += 1000*CSD_GET_NSAC(); + // Max time out + Tnac = Tmp; + Twr = Tmp * (1<CapacityListLength = sizeof(Mmc3FormatCapDescriptor_t); + if (MmcDskCtrlBlk.DiskStatus != DiskCommandPass) + { + pFormatCapacity->MaximumDescriptor.DescriptorType = FormattedMedia; + pFormatCapacity->MaximumDescriptor.BlockLength[0] = (MmcDskCtrlBlk.BlockSize >> 16) & 0xFF; + pFormatCapacity->MaximumDescriptor.BlockLength[1] = (MmcDskCtrlBlk.BlockSize >> 8) & 0xFF; + pFormatCapacity->MaximumDescriptor.BlockLength[2] = (MmcDskCtrlBlk.BlockSize ) & 0xFF; + pFormatCapacity->MaximumDescriptor.NumberofBlocks[0] = (MmcDskCtrlBlk.BlockNumb >> 24) & 0xFF; + pFormatCapacity->MaximumDescriptor.NumberofBlocks[1] = (MmcDskCtrlBlk.BlockNumb >> 16) & 0xFF; + pFormatCapacity->MaximumDescriptor.NumberofBlocks[2] = (MmcDskCtrlBlk.BlockNumb >> 8) & 0xFF; + pFormatCapacity->MaximumDescriptor.NumberofBlocks[3] = (MmcDskCtrlBlk.BlockNumb ) & 0xFF; + } + else + { + pFormatCapacity->MaximumDescriptor.DescriptorType = NoMediaPresent; + pFormatCapacity->MaximumDescriptor.BlockLength[0] = (2048 >> 16) & 0xFF; + pFormatCapacity->MaximumDescriptor.BlockLength[1] = (2048 >> 8) & 0xFF; + pFormatCapacity->MaximumDescriptor.BlockLength[2] = (2048 ) & 0xFF; + pFormatCapacity->MaximumDescriptor.NumberofBlocks[0] = (0xFFFFFFFF >> 24) & 0xFF; + pFormatCapacity->MaximumDescriptor.NumberofBlocks[1] = (0xFFFFFFFF >> 16) & 0xFF; + pFormatCapacity->MaximumDescriptor.NumberofBlocks[2] = (0xFFFFFFFF >> 8) & 0xFF; + pFormatCapacity->MaximumDescriptor.NumberofBlocks[3] = (0xFFFFFFFF ) & 0xFF; + } + return(sizeof(Mmc3FormatCapResponse_t)); + } + return(0); + } +#endif + +pDiskCtrlBlk_t MmcGetDiskCtrlBkl(void) +{ + return (&MmcDskCtrlBlk); +} + +UINT32 SYS_GetFSclk(void) + { + UINT32 Mul = 1, Div = 1, Osc, Fsclk; + if (PLLSTAT & (1 << 25)) + { + // when PLL is connected + Mul = (PLLSTAT & 0x7FFF) +1; + Div = ((PLLSTAT >> 16) & 0xFF) +1; + } + + // Find clk source + switch (CLKSRCSEL & 0x3) + { + case 0: + Osc = I_RC_OSC_FREQ; + break; + case 1: + Osc = MAIN_OSC_FREQ; + break; + case 2: + Osc = RTC_OSC_FREQ; + break; + default: + Osc = 0; + } + // Calculate system frequency + Fsclk = Osc*Mul*2; + Fsclk /= Div*(CCLKCFG+1); + return (Fsclk); + } + +UINT32 SYS_GetFPclk(UINT32 Periphery) + { + UINT32 Fpclk; + pUINT32 pReg = (pUINT32)((Periphery < 32) ? &PCLKSEL0 : &PCLKSEL1); + + Periphery &= 0x1F; // %32 + Fpclk = SYS_GetFSclk(); + // find peripheral appropriate periphery divider + switch ((*pReg >> Periphery) & 3) + { + case 0: + Fpclk /= 4; + break; + case 1: + break; + case 2: + Fpclk /= 2; + break; + default: + Fpclk /= 8; + } + return (Fpclk); + } + +void Dly100us(void *arg) +{ + volatile UINT32 Dly = (UINT32)arg, Dly100; + for (; Dly; Dly--) + for (Dly100 = 500; Dly100; Dly100--) + ; +} + diff --git a/Tester/SW/lib/Drivers/mmc.h b/Tester/SW/lib/Drivers/mmc.h new file mode 100644 index 0000000..555d0a2 --- /dev/null +++ b/Tester/SW/lib/Drivers/mmc.h @@ -0,0 +1,533 @@ +/* --------------------------------------------------------------------------- + * mmc.h (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Apr 22, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef __MMC_H +#define __MMC_H + +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ +#include "LPC23xx.h" +#include "types.h" +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ +#ifdef MMC_GLOBAL +#define MMC_EXTERN +#else +#define MMC_EXTERN extern +#endif + +extern void Dly100us(void *arg); + +#define MMC_DISK_INFO +#define MMC_DISK_LUN 0 + +/* Hardware depends definitions */ +#define IdentificationModeClock 400000 +#define PC_PCSPI1 (1<<10) +#define PC_PCSPI0 (1<<8) + +#define RTC_OSC_FREQ (32768UL) + +#define RD_TIME_OUT 100LL /* SD Max. Block Read Access Time */ +#define WR_TIME_OUT 250LL /* SD Max. Block Write Access Time */ + +#define OcrReg 0x00FF8000 + +/* Card Status register */ +#define READY_FOR_DATA (1UL << 8) +#define CURRENT_STATE (0xFUL << 9) +#define ERASE_RESET (1UL << 13) +#define CARD_ECC_DISABLED (1UL << 14) +#define WP_ERASE_SKIP (1UL << 15) +#define CID_CSD_OVERWRITE (1UL << 16) +#define ERROR (1UL << 17) +#define ILLEGAL_COMMAND (1UL << 22) +#define COM_CRC_ERROR (1UL << 23) +#define WP_VIOLATION (1UL << 26) +#define ERASE_PARAM (1UL << 27) +#define ERASE_SEQ_ERROR (1UL << 28) +#define BLOCK_LEN_ERROR (1UL << 29) +#define ADDRESS_ERROR (1UL << 30) +#define OUT_OF_RANGE (1UL << 31) + +/* Card states */ +#define CARD_IDLE (0UL << 9) +#define CARD_READY (1UL << 9) +#define CARD_IDENT (2UL << 9) +#define CARD_STBY (3UL << 9) +#define CARD_TRAN (4UL << 9) +#define CARD_DATA (5UL << 9) +#define CARD_RCV (6UL << 9) +#define CARD_PRG (7UL << 9) +#define CARD_DIS (8UL << 9) + +#define MmcDly_1ms(Delay) Dly100us((void*)(10 * Delay)) + + +/* WORKAROUND + * As long as MCI_CP and MCI_WP are swapped, right PinMapping + * is done here. + * After Hardware Update, simply use commented PinMasks instead + * of the corrected ones. + */ + +// MMC/SD card switches +// Card present +// \MARK NEW PINSETTINGS FOR TESTER (2) and IO_CTRL (1) +#if ((PINSET_TESTER == 1) || (PINSET_TESTER == 2)) +#define MMC_CP_MASK (1UL << 4) +#define MMC_CP_DIR FIO0PIN1 +#define MMC_CP_FDIR FIO0DIR +#define MMC_CP_IO FIO0PIN1 +#define MMC_CP_FIO FIO0PIN1 +#define MMC_CP_MODE PINMODE1 /* Bit 12&13 */ +#else +/* Pin 87 (P0.17) */ +#define MMC_CP_MASK (1UL << 1) +#define MMC_CP_DIR FIO0PIN2 +#define MMC_CP_FDIR FIO0DIR +#define MMC_CP_IO FIO0PIN2 +#define MMC_CP_FIO FIO0PIN2 +#define MMC_CP_MODE PINMODE1 +#endif + + +// Card write protect +// \MARK NEW PINSETTINGS FOR TESTER (2) and IO_CTRL (1) +#if ((PINSET_TESTER == 1) || (PINSET_TESTER == 2)) +#define MMC_WP_MASK (1UL << 3) +#define MMC_WP_DIR FIO0DIR +#define MMC_WP_FDIR FIO0DIR +#define MMC_WP_IO FIO0PIN1 +#define MMC_WP_FIO FIO0PIN1 +#define MMC_WP_MODE PINMODE1 /* Bit 13&14 */ +#else +/* Pin 64 (P1.29) */ +#define MMC_WP_MASK (1UL << 5) +#define MMC_WP_DIR FIO1DIR3 +#define MMC_WP_FDIR FIO1DIR +#define MMC_WP_IO FIO1PIN3 +#define MMC_WP_FIO FIO1PIN3 +#define MMC_WP_MODE PINMODE3 +#endif + + +#define DMA_MMCSD 4 /* MMC/SD */ + +#define MCI_PCLK_OFFSET 56 + +#define I_RC_OSC_FREQ (4000000) +#define MAIN_OSC_FREQ (12000000) +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ + +typedef enum _DiskStatusCode_t +{ + DiskCommandPass = 0, DiskNotReady, DiskNotPresent, + DiskParametersError, DiskMiscompareError, DiskChanged, + DiskUknowError, +} DiskStatusCode_t; + +typedef enum _DiskIoRequest_t +{ + DiskWrite = 0, DiskRead, DiskVerify, +} DiskIoRequest_t; + +typedef enum _DiskInfoType_t +{ + DiskInquiry = 0, DiskFormatCapacity, +} DiskInfoType_t; + +typedef enum _DiskType_t +{ + DiskMMC, DiskSD, DiskUnknow, +} DiskType_t; + +typedef struct _DiskCtrlBlk_t +{ + UINT32 BlockNumb; + UINT32 BlockSize; + DiskStatusCode_t DiskStatus; + DiskType_t DiskType; + BOOLEAN WriteProtect; + BOOLEAN MediaChanged; +} DiskCtrlBlk_t, *pDiskCtrlBlk_t; + +typedef enum _MmcState_t + { + MmcOk = 0, + MmcNoPresent = 1, + MmcNoResponse = 2 , + MmcCardError = 3, + MmcMiscompare = 4, + MmcDmaError = 5, + MmcProtect = 6 + } MmcState_t; + +typedef enum _MmcSpiCmdInd_t + { + CMD0 = 0, /* Resets the MultiMediaCard */ + CMD1, /* Activates card’s init process */ + CMD2, /* Asks all cards to send its card identification (CID) */ + CMD3, /* Set relative address */ + CMD7, /* Select/deselect card the card is selected by its own */ + /* relative address and deselected by other address. */ + /* address 0 deselects all */ + CMD9, /* Asks the card to send its card-specific data (CSD) */ + CMD10, /* Asks the card to send its card identification (CID) */ + CMD12, /* Stop transmission on multiple block read */ + CMD13, /* Asks the selected card to send its status register */ + CMD16, /* Selects a block length (in bytes) for all following */ + /* block commands (read and write) */ + CMD17, /* Read block of size selected in SET_BLOCKLEN command */ + CMD18, /* Continuously transfers data blocks from card to host */ + /* until interrupted by a Stop command or the requested */ + /* number of data blocks transmitted */ + CMD24, /* Write block of size selected in SET_BLOCKLEN command */ + CMD25, /* Continuously writes blocks of data until ‘Stop Tran’ */ + /* Token or the requested number of blocks received */ + CMD27, /* Programming of the programmable bits of the CSD */ + CMD28, /* If the card has write protection features, this */ + /* command sets the write protection bit of the */ + /* addressed group. The properties of write protection */ + /* are coded in the card specific data (WP_GRP_SIZE). */ + CMD29, /* If the card has write protection features, this */ + /* command clears protection bit of the addressed group */ + CMD30, /* If the card has write protection features, this */ + /* command asks the card to send the status of the write*/ + /* protection bits */ + CMD32, /* Sets the address of first sector of the erase group */ + CMD33, /* Sets the address of the last sector in a continuous */ + /* range within selected erase group, or the address */ + /* of a single sector to be selected for erase */ + CMD34, /* Removes one previously selected sector from the */ + /* erase selection */ + CMD35, /* Sets the address of the first erase group within a */ + /* range to be selected for erase */ + CMD36, /* Sets the address of the last erase group within a */ + /* continuous range to be selected for erase */ + CMD37, /* Removes one previously selected erase group from the */ + /* erase selection. */ + CMD38, /* Erases all previously selected sectors */ + CMD42, /* Used to set/reset the password or lock/unlock the */ + /* card. The size of the Data Block is defined by the */ + /* ET_BLOCK_LEN command */ + CMD55, /* Notifies the card that the next command is an */ + /* application specific command (Non standard command) */ + CMD56, /* Used either to transfer a Data Block to the card or */ + /* to get a Data Block from the card for general */ + /* purpose/application specific commands. The size */ + /* of Data Block is defined with SET_BLOCK_LEN command */ + ACMD6, /* Defines data bus width (’00’=1bit or’10’=4 bits bus) */ + /* (Only for SD) */ + ACMD41, /* Activates card initialization process (Only for SD) */ + CMD_END /* End of commands index */ + } MmcSpiCmdInd_t; + +typedef enum _MmcAgmType_t + { + MmcNoArg = 0, + MmcBlockLen, + MmcDataAdd, + MmcRelAddr, + MmcOcr + } MmcAgmType_t; + +typedef enum _MmcRespType_t + { + MmcNoResp = 0, + MmcR1, + MmcR1b, + MmcR2, + MmcR3 + } MmcRespType_t; + +typedef struct _MmcCommads_t + { + UINT8 TxData; + MmcAgmType_t Arg; + MmcRespType_t Resp; + } MmcCommads_t; + +typedef union _DataCtrl_t + { + UINT32 Data; + struct + { + UINT32 ENABLE : 1; + UINT32 DIRECTION : 1; + UINT32 MODE : 1; + UINT32 DMAENABLE : 1; + UINT32 BLOCKSIZE : 4; + UINT32 :24; + }; + } DataCtrl_t, *pDataCtrl_t; + +typedef struct _Mmc3FormatCapDescriptor_t + { + UINT8 NumberofBlocks[4]; + struct + { + UINT8 DescriptorType : 2; + UINT8 FormatType : 6; + }; + UINT8 BlockLength[3]; + } Mmc3FormatCapDescriptor_t, *pMmc3FormatCapDescriptor_t; + +typedef struct _Mmc3FormatCapResponse_t + { + UINT8 Reserved0; + UINT8 Reserved1; + UINT8 Reserved2; + UINT8 CapacityListLength; + Mmc3FormatCapDescriptor_t MaximumDescriptor; + } Mmc3FormatCapResponse_t, * pMmc3FormatCapResponse_t; + +typedef enum _SpcPeripheralDeviceType_t + { + SbcDirectAccess = 0, SscSequentialAccess,SSCPrinter,SpcProcessor, + ScbWriteOnce,Mmc2CDROM,Scsi2Scanner,SbcOpticalMemory, + SmcMediumChanger,Scsi2Communications,DefinedByASCIT8_1,DefinedByASCIT8_2, + Scc2StorageArrayController,SesEnclosureServices,RbcSimplifiedDirectAccess, + OcrwOpticalCardReader,BridgingExpanders,OsdObjectBasedStorage, UnknowType = 0x1F, + } SpcPeripheralDeviceType_t; + +typedef enum _FormatCapacityDescType_t + { + UnformattedMedia = 1, FormattedMedia, NoMediaPresent, + } FormatCapacityDescType_t; + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ + +extern UINT32 SYS_GetFpclk(UINT32 Periphery); + +/* --------------------------------------------------------------------------- + * Function: MmcPresent + * + * checks if a Card is inserted. + * + * Parameters: void + * + * Return: BOOLEAN - true if Card is inserted, false if not + * --------------------------------------------------------------------------- + */ +inline BOOLEAN MmcPresent(void); + +/* --------------------------------------------------------------------------- + * Function: MmcWriteProtect + * + * checks if inserted Card is write protected. + * + * Parameters: void + * + * Return: BOOLEAN - true if Card is protected, false if not + * --------------------------------------------------------------------------- + */ +inline BOOLEAN MmcWriteProtect(void); + +/* --------------------------------------------------------------------------- + * Function: MmcSetClockFreq + * + * Sets SPI Clock Frequency + * + * Parameters: UINT32 - Frequency + * + * Return: UINT32 + * --------------------------------------------------------------------------- + */ +UINT32 MmcSetClockFreq(UINT32 Frequency); + +/* --------------------------------------------------------------------------- + * Function: MmcInit + * + * Initialises the MMC Interface and sets it to SPI Mode. Sets Card Present + * and WriteProtect Pins. + * + * Parameters: void + * + * Return: void + * --------------------------------------------------------------------------- + */ +void MmcInit(void); + +/* --------------------------------------------------------------------------- + * Function: MmcPowerDown + * + * Sets to PowerDown state + * + * Parameters: void + * + * Return: void + * --------------------------------------------------------------------------- + */ +void MmcPowerDown(void); + +/* --------------------------------------------------------------------------- + * Function: MmcSendCmd + * + * Implements and sends a Command to MMC + * + * Parameters: MmcSpiCmdInd_t ComdInd - specific Command + * UINT32 Arg - Command Argument + * + * Return: MmcState_t - Response from Card + * --------------------------------------------------------------------------- + */ +MmcState_t MmcSendCmd(MmcSpiCmdInd_t ComdInd, pUINT32 pArg); + +/* --------------------------------------------------------------------------- + * Function: MmcInitMedia + * + * Detects and initialises a connected MMC + * + * Parameters: void + * + * Return: MmcState_t - Response from Card + * --------------------------------------------------------------------------- + */ +MmcState_t MmcInitMedia(void); + +/* --------------------------------------------------------------------------- + * Function: MmcCsdImplement + * + * Implement Data from CSD + * + * Parameters: void + * + * Return: void + * --------------------------------------------------------------------------- + */ +void MmcCsdImplemet(void); + +/* --------------------------------------------------------------------------- + * Function: MmcVerify + * + * Verifies a MMC + * + * Parameters: const UINT8 * pData - Pointer to Data + * UINT32 Add - Address of Data + * UINT32 Length - Length of Data + * + * Return: MmcState_t - Response from Card + * --------------------------------------------------------------------------- + */ +inline MmcState_t MmcVerify(const UINT8 * pData, UINT32 Add, + UINT32 Length); + +/* --------------------------------------------------------------------------- + * Function: MmcGetLastError + * + * Returns last occured ERROR + * + * Parameters: void + * + * Return: UINT32 - Last occured Error + * --------------------------------------------------------------------------- + */ +UINT32 MmcGetLastError(void); + +/* --------------------------------------------------------------------------- + * Function: MmcStatusUpdate + * + * Updates the status of SD/MMC Card + * + * Parameters: void + * + * Return: void + * --------------------------------------------------------------------------- + */ +void MmcStatusUpdate(void); + +/* --------------------------------------------------------------------------- + * Function: MmcDiskInit + * + * Initialises MMC/SD Disk + * + * Parameters: void + * + * Return: void + * --------------------------------------------------------------------------- + */ +void MmcDiskInit(void); + +#ifdef MMC_DISK_INFO +/* --------------------------------------------------------------------------- + * Function: MmcDiskInfo + * + * Returns Pointer to Info Structure of inserted Disk + * + * Parameters: pUINT8 pData - Pointer to Data + * DiskInfoType_t DiskInfoType - Info Type + * + * Return: UINT32 + * --------------------------------------------------------------------------- + */ +UINT32 MmcDiskInfo(pUINT8 pData, DiskInfoType_t DiskInfoType); +#endif // MMC_DISK_INFO +/* --------------------------------------------------------------------------- + * Function: MmcGetDiskCtrlBkl + * + * Returns Pointer to Control Block Structure + * + * Parameters: void + * + * Return: pDiskCtrlBlock_t - Pointer to Control Block + * --------------------------------------------------------------------------- + */ +pDiskCtrlBlk_t MmcGetDiskCtrlBkl(void); + + +UINT32 SYS_GetFSclk(void); + + +UINT32 SYS_GetFPclk(UINT32 Periphery); + +/************************************************************************* + * Function Name: Dly100us + * Parameters: void *arg + * Return: void + * + * Description: Delay [100us] + * + *************************************************************************/ +void Dly100us(void *arg); + + + +#endif // __MMC_H + + diff --git a/Tester/SW/lib/Drivers/mmc_transfer.c b/Tester/SW/lib/Drivers/mmc_transfer.c new file mode 100644 index 0000000..f58ce81 --- /dev/null +++ b/Tester/SW/lib/Drivers/mmc_transfer.c @@ -0,0 +1,307 @@ +/* --------------------------------------------------------------------------- + * mmc_transfer.c (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, May 08, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +#include + +#include "LPC23xx.h" +#include "types.h" +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "mmc_transfer.h" +#include "mmc.h" +#include "dio.h" +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ +#define Card_Page_Size 512 +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ +extern UINT32 Tnac; +extern UINT32 Twr; +extern DiskCtrlBlk_t MmcDskCtrlBlk; + +UINT32 dlycnt; +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ +UINT8 ReadFromCard[512] __attribute__ ((section (".dmaram"))); +UINT8 WriteToCard[512] __attribute__ ((section (".dmaram"))); +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ + +MmcState_t CardRead (pUINT8 pData, UINT32 Address, UINT32 Length) +{ + UINT32 ArrayIndex = 0; + UINT32 loopcnt; + MmcState_t Status = MmcOk; + + for (loopcnt = 0; loopcnt < Card_Page_Size; loopcnt++)/* Prepare Buffer */ + { + ReadFromCard[loopcnt] = 0; /* Set all Positions to Zero */ + } + + /* Error or Wrong Argument Handle Block */ + if (MmcPresent() == FALSE) /* Check if Card is present */ + { + return (MmcNoPresent); /* Return NoCardPresent State */ + } + if (checkLength(Length) == FALSE) /* Check Read Length for validity */ + { + return (MmcMiscompare); /* Return WrongLength State */ + } + + Address = ((Address / Card_Page_Size) * Card_Page_Size); + /* Calculate first Address of Page */ + + do /* Loop to handle multible Reads */ + { + Status = MmcReadBlock((pUINT8)ReadFromCard, Address); + /* Read 512 from Card */ + memcpy (&(pData[ArrayIndex]), ReadFromCard, Card_Page_Size); + /* Copy read Content to User Buffer */ + + /* Recalculate Loop Values */ + Length -= Card_Page_Size; + Address += Card_Page_Size; + ArrayIndex += Card_Page_Size; + } while (Length > 0); + + return (Status); +} + + +MmcState_t CardWrite (pUINT8 pData, UINT32 Address, UINT32 Length) +{ + UINT32 ArrayIndex = 0; + UINT32 loopcnt; + MmcState_t Status = MmcOk; + + for (loopcnt = 0; loopcnt < Card_Page_Size; loopcnt++)/* Prepare Buffer */ + { + WriteToCard[loopcnt] = 0; /* Set all Positions to Zero */ + } + + /* Error or Wrong Argument Handle Block */ + if (MmcPresent() == FALSE) /* Check if Card is Present */ + { + return (MmcNoPresent); /* Return NoCardPresent State */ + } + if (MmcWriteProtect() == TRUE) /* Check if Card is Writeprotected */ + { + return (MmcProtect); /* Return WriteProtect State */ + } + if (checkLength(Length) == FALSE) /* Check Read Length for validity */ + { + return (MmcMiscompare); /* Return WrongLength State */ + } + if (Address < 0x200) /* Defend Master Boot Sector */ + { + return (MmcCardError); /* Return Error State */ + } + + + Address = ((Address / Card_Page_Size) * Card_Page_Size); + /* Calculate first Address of Page */ + + do + { + memcpy (WriteToCard, &(pData[ArrayIndex]), Card_Page_Size); + /* Copy 512Bytes in send-Buffer */ + Status = MmcWriteBlock((pUINT8)WriteToCard, Address); + /* Write 512 Bytes to Card */ + + /* Recalculate Loop Values */ + Length -= Card_Page_Size; + Address += Card_Page_Size; + ArrayIndex += Card_Page_Size; + } while (Length > 0); + + return (Status); +} + + +inline BOOLEAN checkLength (UINT32 Length) +{ + if (Length == 0) + { + return (FALSE); + } + /* Check data length - Must be divisible of Card Block Size */ + if ((Length % MmcDskCtrlBlk.BlockSize) != 0) + { + return (FALSE); + } + return (TRUE); +} + + +inline MmcState_t MmcReadBlock(pUINT8 pData, UINT32 Add) +{ + UINT32 Data; + MmcState_t Status = MmcOk; + + PCONP |= (1 << 29); /* Turn on MCI Power */ + MCI_DATA_TMR = Tnac; /* Set Read Timeout */ + MCI_CLEAR = 0x000007FF; /* Clear all Interrupt Flags */ + + /* General Purpose DMA (GPDMA) Control Settings for Reading */ + GPDMA_CONFIG = 0x00; /* Disable DMA */ + GPDMA_CH0_LLI = 0; /* No link List available */ + GPDMA_CH0_CTRL = 0x00; /* Reset DMA Control Block */ + GPDMA_CH0_SRC = (UINT32)&MCI_FIFO; /* Set MCI FIFO as Source Adress */ + + GPDMA_CH0_CTRL = (Card_Page_Size & 0x0FFF) /* 512 Byte Transfer Size */ + | (0x04 << 12) /* 32 Bit Source Burst Size */ + | (0x04 << 15) /* 32 Bit Destination Burst Size */ + | (0x02 << 18) /* 32 Bit Source width size */ + | (0x00 << 21) /* 8 Bit Destination width size */ + | (1 << 27) /* Destination index increment */ + | (1U << 31); /* Terminal count interrupt */ + + MCI_DATA_LEN = MmcDskCtrlBlk.BlockSize; /* Set Transfer Blocksize */ Data = Add; /* Hand over Adress */ Status = MmcSendCmd(CMD17, &Data); /* Send Write Command to Card */ + + if (MmcOk != Status) /* If Command Response is not OK: */ { return (Status); /* return Status and exit Function */ } if (!(Data & READY_FOR_DATA) ||((Data & CURRENT_STATE) != CARD_TRAN)) { /* Check Command Response */ MmcSendCmd(CMD12, NULL); return (MmcCardError); } GPDMA_CH0_DEST = (UINT32)pData; /* Set DMA Destination Adress */ + /* DMA Channel Configuration Block */ GPDMA_CH0_CFG = 0x00; /* Reset DMA Channel Configuration */ GPDMA_CH0_CFG = (0x10000) | (0x04 << 1) /* Source Device is Peripheral */ | (0x00 << 6) /* Destination Device is Memory */ | (0x06 << 11); /* Peripheral to Memory Mode */ + GPDMA_INT_TCCLR = 0x01; /* Clear all Terminal Interrupts */ GPDMA_CONFIG = 0x01; /* enable GPDMA after setup Channel */ while ((GPDMA_CONFIG & 0x01)!= 0x01); /* Poll Enable bit until set */ GPDMA_CH0_CFG |= (1 << 0); /* enable DMA Channel */ MCI_DATA_CTRL = (0x0001) /* Data Transfer enable */ | (0x01 << 1) /* From Card to Controller */ | (0x00 << 2) /* Block Data Transfer */ | (0x01 << 3) /* DMA enabled */ | (0x09 << 4); /* BlockSize 2^9 = 512 Byte */ for(dlycnt = 10; dlycnt > 0; dlycnt--); + while (MCI_STATUS & (1 << 13)); /* Poll RxActive until read finish */ GPDMA_CH0_CFG &=~(1 << 0); /* Disable DMA channel */ MCI_DATA_CTRL = 0; /* Reset Data Control Register */ for(dlycnt = 10; dlycnt > 0; dlycnt--); /* Interrupt Handling Block */ if (GPDMA_RAW_INT_ERR_STAT & (1 << 0)) /* Channel requests Interrupt */ { GPDMA_INT_ERR_CLR |= (1 << 0); /* clear Flag, terminate transfer */ return (MmcDmaError); } + /* Error Handling Block */ if (MCI_STATUS & (1 << 3)) /* Timeout Error */ { MCI_CLEAR = 1UL << 3; /* Clear Timeout Bit */ return (MmcNoResponse); /* Return with Error Message */ } if (MCI_STATUS & (1 << 9)) /* StartBit not detected in Wide */ { /* Bus Mode on every four Lines */ MCI_CLEAR = 1UL << 9; /* Clear StartBitError bit */ return (MmcCardError); /* Return with Error Message */ } if (MCI_STATUS & (1 << 1)) /* DATA CRC Error */ { MCI_CLEAR = 1UL << 1; /* Clear Data CRC Error Bit */ return (MmcCardError); /* Return with Error Message */ } if (MCI_STATUS & (1 << 5)) /* Read FIFO Overrun Error */ { MCI_CLEAR = 1UL << 5; /* Clean FIFO Overrun Error Bit */ return (MmcCardError); /* Return with Error Message */ } + MCI_CLEAR = (1UL << 8) /* Clear DATA END and DATA BLOCK END*/ + | (1UL << 10); + return (Status); +} + + +inline MmcState_t MmcWriteBlock(const UINT8 * pData, UINT32 Add) +{ + UINT32 Data; + + + MmcState_t Status = MmcOk; + + PCONP |= (1 << 29); /* Turn on MCI Power */ + MCI_DATA_TMR = Twr; /* Set write Timeout */ + MCI_CLEAR = 0x000007FF; /* Clear all related flags */ + + /* General Purpose DMA (GPDMA) Control Settings for Writing */ + GPDMA_CONFIG = 0x00; /* Disable DMA */ + GPDMA_CH0_LLI = 0; /* No link List */ + GPDMA_CH0_CTRL = 0x00; /* Reset DMA Control Block */ + GPDMA_CH0_DEST = (UINT32)&MCI_FIFO; /* Set MCI FIFO as Destination */ + + GPDMA_CH0_CTRL = (Card_Page_Size & 0x0FFF) /* 512 Byte Transfer Size */ + | (0x04 << 12) /* 32 Bit Source Burst Size */ + | (0x04 << 15) /* 32 Bit Destination Burst Size */ + | (0x00 << 18) /* 8 bit Source width Size */ + | (0x02 << 21) /* 32 Bit Destination width Size */ + | (1 << 26) /* Source index increment */ + | (1U << 31); /* Terminal count interrupt enable */ + + + MCI_DATA_LEN = MmcDskCtrlBlk.BlockSize; /* Set Transfer Blocksize */ + Data = Add; /* Hand over Adress */ + Status = MmcSendCmd(CMD24, &Data); /* Send Write Command */ + + if (MmcOk != Status) /* If Command Response is NOT OK */ + { + return (Status); /* Return with Error Message */ + } + + if (!(Data & READY_FOR_DATA) + || ((Data & CURRENT_STATE) != CARD_TRAN)) + { /* Check Command Response */ + MmcSendCmd(CMD12, NULL); + return (MmcCardError); + } + + GPDMA_CH0_SRC = (UINT32)pData; /* Set DMA Source address */ + + /* DMA Channel Configuration Block */ + GPDMA_CH0_CFG = 0x00; /* Reset DMA Channel Configuration */ + GPDMA_CH0_CFG = (0x10000) + | (0x00 << 1) /* Source Device is Memory */ + | (0x04 << 6) /* Destination is Peripheral */ + | (0x05 << 11); /* Memory to Peripheral Mode */ + + GPDMA_INT_TCCLR = 0x01; /* Clear all Terminal Interrupts */ + GPDMA_CONFIG = 0x01; /* Enable GPDMA after Setup Channel */ + while ((GPDMA_CONFIG & 0x01)!= 0x01); /* Poll Enable Bit */ + GPDMA_CH0_CFG |= (1 << 0); /* enable DMA Channel */ + + MCI_DATA_CTRL = (0x0001) /* Data Transfer enable */ + | (0x00 << 1) /* From Controller to Card */ + | (0x00 << 2) /* Block Data Transfer */ + | (0x01 << 3) /* DMA enabled */ + | (0x09 << 4); /* BlockSize 2^9 = 512 Byte */ + + for(dlycnt = 10; dlycnt > 0; dlycnt--); + + while (MCI_STATUS & (1 << 12)); /* Poll TxActive until write finish */ + + GPDMA_CH0_CFG &=~(1 << 0); /* Disable DMA Channel */ + + /* Interrupt Handle Block */ + if (GPDMA_RAW_INT_ERR_STAT & (1 << 0)) /* Channel requests Interrupt */ + { + GPDMA_INT_ERR_CLR |= (1 << 0); /* clear Flag, terminate transfer */ + return (MmcDmaError); + } + + MCI_DATA_CTRL = 0; /* Reset DATA Control Register */ + for(dlycnt = 10; dlycnt > 0; dlycnt--); + + /* Error Handling Block */ + if (MCI_STATUS & (1 << 3)) /* Timeout Error */ + { + MCI_CLEAR = 1UL << 3; /* Clear Timeout Bit */ + return (MmcNoResponse); /* Return with Error Message */ + } + if (MCI_STATUS & (1 << 9)) /* StartBit not detected in Wide */ + { /* Bus Mode on every four Lines */ + MCI_CLEAR = 1UL << 9; /* Clear StartBitError bit */ + return (MmcCardError); /* Return with Error Message */ + } + if (MCI_STATUS & (1 << 1)) /* DATA CRC Error */ + { + MCI_CLEAR = 1UL << 1; /* Clear Data CRC Error Bit */ + return (MmcCardError); /* Return with Error Message */ + } + if (MCI_STATUS & (1 << 4)) /* Write FIFO Underrun Error */ + { + MCI_CLEAR = 1UL << 4; /* Clean FIFO Underrun Error Bit */ + return (MmcCardError); /* Return with Error Message */ + } + + MCI_CLEAR = (1UL << 8) /* Clear DATA END and DATA BLOCK END*/ + | (1UL << 10); + + return (Status); +} + diff --git a/Tester/SW/lib/Drivers/mmc_transfer.h b/Tester/SW/lib/Drivers/mmc_transfer.h new file mode 100644 index 0000000..5003d12 --- /dev/null +++ b/Tester/SW/lib/Drivers/mmc_transfer.h @@ -0,0 +1,122 @@ +/* --------------------------------------------------------------------------- + * mmc_transfer.h (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: Digital inputs/outputs interface. + * --------------------------------------------------------------------------- + * Version(s): 0.1, May 08, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef MMC_TRANSFER_H_ +#define MMC_TRANSFER_H_ +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ +#include "LPC23xx.h" +#include "types.h" +#include "mmc.h" +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function: CardRead + * + * Reads user defined blocks and lengths from memory card + * + * Parameters: pUINT8 pData - Data to read to + * UINT32 Add - Address to read from + * UINT32 Length - Length of Data to be read + * + * Return: MmcState_t - Response from Card + * --------------------------------------------------------------------------- + */ +MmcState_t CardRead (pUINT8 pData, UINT32 Address, UINT32 Length); + + +/* --------------------------------------------------------------------------- + * Function: CardWrite + * + * Writes user defined blocks and lengths to memory card + * + * Parameters: pUINT8 pData - Data to write + * UINT32 Add - Address to write to + * UINT32 Length - Length of Data to be written + * + * Return: MmcState_t - Response from Card + * --------------------------------------------------------------------------- + */ +MmcState_t CardWrite (pUINT8 pData, UINT32 Address, UINT32 Length); + +/* --------------------------------------------------------------------------- + * Function: checkLength + * + * Functions checks asked read/write length for valid length-value, which is + * a multible from cards blocksize. + * + * Parameters: UINT32 Length - Length of Block to read or write + * + * Return: BOOLEAN - TRUE if length fits, FALSE if not + * --------------------------------------------------------------------------- + */ +inline BOOLEAN checkLength (UINT32 Length); + +/* --------------------------------------------------------------------------- + * Function: MmcReadBlock + * + * Reads from a MMC + * + * Parameters: pUINT8 pData - Pointer to where Content is read + * UINT32 Add - Address to read from + * + * Return: MmcState_t - Response from Card + * --------------------------------------------------------------------------- + */ +inline MmcState_t MmcReadBlock(pUINT8 pData, UINT32 Add); + +/* --------------------------------------------------------------------------- + * Function: MmcWriteBlock + * + * Writes to a MMC + * + * Parameters: const UINT8 * pData - Data to write + * UINT32 Add - Address to write to + * + * Return: MmcState_t - Response from Card + * --------------------------------------------------------------------------- + */ +inline MmcState_t MmcWriteBlock(const UINT8 * pData, UINT32 Add); + + +#endif /*MMC_TRANSFER_H_*/ diff --git a/Tester/SW/lib/Drivers/power.c b/Tester/SW/lib/Drivers/power.c new file mode 100644 index 0000000..2d2afb0 --- /dev/null +++ b/Tester/SW/lib/Drivers/power.c @@ -0,0 +1,173 @@ +/* --------------------------------------------------------------------------- + * power.c - v0.1 (c) 2007 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: Checks for power supply + * --------------------------------------------------------------------------- + * Version(s): 0.1, 28-11-2007, fvds. + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +#include +#include + + +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "LPC23xx.h" +#include "types.h" +#include "power.h" + +/* FreeRTOS includes */ +#include "FreeRTOS.h" + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ +#define ADC_INTERRUPT_FLAG 1 /* 1 is interrupt driven, 0 is polling */ + +#define ADC_OFFSET 0x10 +#define ADC_INDEX 4 + +#define ADC_DONE 0x80000000 +#define ADC_OVERRUN 0x40000000 +#define ADC_ADINT 0x00010000 + +#define ADC_NUM 8 /* for LPC23xx */ +#define ADC_CLK 1000000 /* set to 1Mhz */ + +#define VCC_DIVIDER_R1 22000 +#define VCC_DIVIDER_R2 19100 +#define VCC_DIVIDER_CORR ((VCC_DIVIDER_R2 * 1000) / (VCC_DIVIDER_R1 + VCC_DIVIDER_R2)) +#define V24_DIVIDER_R1 33000 +#define V24_DIVIDER_R2 3300 +#define V24_DIVIDER_CORR ((V24_DIVIDER_R2 * 1000) / (V24_DIVIDER_R1 + V24_DIVIDER_R2)) + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ +static UINT16 ADC0Read( UINT8 channelNum ); +static UINT16 Convert2mV( UINT32 dataRegistry ); + + +void powerInit() +{ + /* Enable CLOCK into ADC controller */ + PCONP |= (1 << 12); + + /* all the related pins are set to ADC inputs, AD0.0, 4 and 5 */ + PINSEL1 &= ~0x0000C000; /* P0.23, A0.0, function 01 */ + PINSEL1 |= 0x00004000; + PINSEL3 |= 0xC0000000; /* P1.31, A0.5, function 11 */ + + AD0CR = ( 0x21 << 0 ) | /* SEL=1,select channel 0,4 and 5 on ADC0 */ + ( 0 << 8 ) | /* CLKDIV = Fpclk / 1000000 - 1 => 2.4 MHz */ + ( 1 << 16 ) | /* BURST = 0, no BURST, software controlled */ + ( 0 << 17 ) | /* CLKS = 0, 11 clocks/10 bits */ + ( 1 << 21 ) | /* PDN = 1, normal operation */ + ( 0 << 22 ) | /* TEST1:0 = 00 */ + ( 0 << 24 ) | /* START = 0 A/D conversion stops */ + ( 0 << 27 ); /* EDGE = 0 (CAP/MAT singal falling,trigger A/D conversion) */ +} + +UINT16 powerVccVoltage() +{ + UINT32 adcDataRegister; + UINT32 voltage; + + adcDataRegister = AD0DR5; + voltage = Convert2mV( adcDataRegister ); + + // Correct voltage divider + voltage = (voltage * 1000)/VCC_DIVIDER_CORR; + + return voltage; +} + +UINT16 powerV24Voltage() +{ + UINT32 adcDataRegister; + UINT32 voltage; + + adcDataRegister = AD0DR0; + voltage = Convert2mV( adcDataRegister ); + + // Correct voltage divider + voltage = (voltage * 1000)/V24_DIVIDER_CORR; + + return voltage; +} + + +UINT16 Convert2mV( UINT32 dataRegister ) +{ + UINT32 pwrDummy; + dataRegister = dataRegister >> 6; + dataRegister = dataRegister & 0x03FF; + + // Convert ADC value to voltage (0..1024 -> 0.. 3300 mV) + dataRegister = (dataRegister * 3300) / (1024); + pwrDummy = dataRegister; + + return (UINT16)dataRegister; +} + +UINT16 ADC0Read( UINT8 channelNum ) +{ + UINT16 regVal, ADC_Data; + + /* channel number is 0 through 7 */ + if ( channelNum >= ADC_NUM ) + { + channelNum = 0; /* reset channel number to 0 */ + } + AD0CR &= 0xFFFFFF00; + AD0CR |= (1 << 24) | (1 << channelNum); + /* switch channel,start A/D convert */ + + while ( 1 ) /* wait until end of A/D convert */ + { + regVal = *(volatile unsigned long *)(AD0_BASE_ADDR + ADC_OFFSET + ADC_INDEX * channelNum); + /* read result of A/D conversion */ + if ( regVal & ADC_DONE ) + { + break; + } + } + + AD0CR &= 0xF8FFFFFF; /* stop ADC now */ + if ( regVal & ADC_OVERRUN ) /* save data when it's not overrun, otherwise, return zero */ + { + return ( 0 ); + } + ADC_Data = ( regVal >> 6 ) & 0x3FF; + return ( ADC_Data ); /* return A/D conversion value */ +} + diff --git a/Tester/SW/lib/Drivers/power.h b/Tester/SW/lib/Drivers/power.h new file mode 100644 index 0000000..c51e7ac --- /dev/null +++ b/Tester/SW/lib/Drivers/power.h @@ -0,0 +1,60 @@ +/* --------------------------------------------------------------------------- + * power.h - v0.1 (c) 2007 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: Power supply checks + * --------------------------------------------------------------------------- + * Version(s): 0.1, 10-09-2007, Marcel Mulder. + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef __POWER_H__ +#define __POWER_H__ +/** \file power.h + \brief Checks voltage on power supplies +*/ +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ +#include "lpc23xx.h" +#include "types.h" + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ + + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ +void powerInit( void ); +UINT16 powerVccVoltage( void ); +UINT16 powerV24Voltage( void ); + +#endif /* __POWER_H__ */ diff --git a/Tester/SW/lib/Drivers/relay.c b/Tester/SW/lib/Drivers/relay.c new file mode 100644 index 0000000..bf6c743 --- /dev/null +++ b/Tester/SW/lib/Drivers/relay.c @@ -0,0 +1,122 @@ +/* --------------------------------------------------------------------------- + * relay.c (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Nov 10, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +/* Hardware Includes */ +#include "LPC23xx.h" +#include "types.h" + +/* FreeRTOS includes */ +#include "FreeRTOS.h" +#include "Task.h" +#include "queue.h" +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "relay.h" +#include "dio.h" +#include "ElecStatusCache.h" +//#include "dioISR.h" +//#include "armVIC.h" + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ +#define PORT0_BASE_ADDR (FIO_BASE_ADDR) /* Fast IO Base Address */ +#define PORT1_BASE_ADDR (FIO_BASE_ADDR + 0x20) /* Offset for Port2 */ + +#define DIR_OFFSET (0x00) /* Offset of 32Bit DID register */ +#define MASK_OFFSET (0x10) /* Offset of 32bit MASK register*/ +#define PIN_OFFSET (0x14) /* Offset of 32Bit PIN register */ +#define SET_OFFSET (0x18) /* Offset of 32Bit SET register */ +#define CLR_OFFSET (0x1C) /* Offset of 32Bit CLR register */ + +#define RLY_CHANNELS 6 +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ +t_input rly_inputPins[RLY_CHANNELS] = + { + { PORT1_BASE_ADDR, BIT(26), NULL }, /* Relay Input 0 */ + { PORT1_BASE_ADDR, BIT(27), NULL }, /* Relay Input 1 */ + { PORT1_BASE_ADDR, BIT(28), NULL }, /* Relay Input 2 */ + { PORT1_BASE_ADDR, BIT(29), NULL }, /* Relay Input 3 */ + { PORT1_BASE_ADDR, BIT(30), NULL }, /* Relay Input 4 */ + { PORT1_BASE_ADDR, BIT(31), NULL }, /* Relay Input 5 */ + + }; +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ + +void rlyInit(void) +{ + UINT8 loopcnt; + volatile UINT32 *gpioRegister; + + SCS |= (1UL<<0); /* GPIOM in SCS to fast IO */ + + /* Set registers for all Inputs in right Mode */ + for (loopcnt=0; loopcnt < RLY_CHANNELS; loopcnt++) + { + /* Clear MASK register of corresponding Input */ + gpioRegister = (UINT32 *)(rly_inputPins[loopcnt].portBaseAddr + MASK_OFFSET); + *gpioRegister &= ~(rly_inputPins[loopcnt].pinMask); + + /* Set corresponding channel to direction INPUT */ + gpioRegister = (UINT32 *)(rly_inputPins[loopcnt].portBaseAddr + DIR_OFFSET); + *gpioRegister &= ~(rly_inputPins[loopcnt].pinMask); + } + +} + +BOOLEAN rlyRead(UINT8 device, UINT8 channel) + { + BOOLEAN Result; + volatile UINT32 *gpioRegister; + + /* Set pointer to corresponding channel register */ + gpioRegister = (UINT32 *)(rly_inputPins[channel].portBaseAddr + PIN_OFFSET); + + /* Receive Result from Register (Inputs are LOW-active) */ + if (*gpioRegister & rly_inputPins[channel].pinMask) + { + /* Received a HIGH state, so INPUT is LOW or FALSE */ + Result = FALSE; + } + else + { + /* Received a LOW state, so INPUT is HIGH or TRUE */ + Result = TRUE; + } + + return Result; + } diff --git a/Tester/SW/lib/Drivers/relay.h b/Tester/SW/lib/Drivers/relay.h new file mode 100644 index 0000000..95a3c3d --- /dev/null +++ b/Tester/SW/lib/Drivers/relay.h @@ -0,0 +1,58 @@ +/* --------------------------------------------------------------------------- + * relay.h (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Nov 10, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef RELAY_H_ +#define RELAY_H_ +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ + +/* Hardware Includes */ +#include "LPC23xx.h" +#include "types.h" +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ + +void rlyInit(void); + +BOOLEAN rlyRead(UINT8 device, UINT8 channel); + +#endif /*RELAY_H_*/ diff --git a/Tester/SW/lib/Drivers/rtc.c b/Tester/SW/lib/Drivers/rtc.c new file mode 100644 index 0000000..3a08567 --- /dev/null +++ b/Tester/SW/lib/Drivers/rtc.c @@ -0,0 +1,163 @@ +/* --------------------------------------------------------------------------- + * rtc.c - v0.1 (c) 2007 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: Real time clock functionality + * --------------------------------------------------------------------------- + * Version(s): 0.1, 28-11-2007, fvds. + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +#include "LPC23xx.h" +#include "types.h" + +/* FreeRTOS includes */ +#include "FreeRTOS.h" +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "rtc.h" +#include "dio.h" + +#include "BusProtocol.h" +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ +#define IMSEC 0x00000001 +#define IMMIN 0x00000002 +#define IMHOUR 0x00000004 +#define IMDOM 0x00000008 +#define IMDOW 0x00000010 +#define IMDOY 0x00000020 +#define IMMON 0x00000040 +#define IMYEAR 0x00000080 + +#define AMRSEC 0x00000001 /* Alarm mask for Seconds */ +#define AMRMIN 0x00000002 /* Alarm mask for Minutes */ +#define AMRHOUR 0x00000004 /* Alarm mask for Hours */ +#define AMRDOM 0x00000008 /* Alarm mask for Day of Month */ +#define AMRDOW 0x00000010 /* Alarm mask for Day of Week */ +#define AMRDOY 0x00000020 /* Alarm mask for Day of Year */ +#define AMRMON 0x00000040 /* Alarm mask for Month */ +#define AMRYEAR 0x00000080 /* Alarm mask for Year */ + +#define PREINT_RTC 0x000001C8 /* Prescaler value, integer portion, PCLK = 15Mhz */ +#define PREFRAC_RTC 0x000061C0 /* Prescaler value, fraction portion,PCLK = 15Mhz */ +#define ILR_RTCCIF 0x01 +#define ILR_RTCALF 0x02 + +#define CCR_CLKEN 0x01 +#define CCR_CTCRST 0x02 +#define CCR_CLKSRC 0x10 + + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ +extern UINT32 interruptcounter; +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ +void rtcISR (void) __attribute__ ((naked)); + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ +/** \brief Initialize RTC interface.*/ +void rtcInit(void) +{ + /*--- Initialize registers ---*/ + RTC_AMR = 0; + RTC_CIIR = 0; + //RTC_CCR = 0; + //RTC_PREINT = PREINT_RTC; + //RTC_PREFRAC = PREFRAC_RTC; + + RTC_CCR = (CCR_CLKEN | CCR_CLKSRC); + + + /* Enable RTC interrupt and register it to the VIC */ + //portENTER_CRITICAL(); + // { + // VICIntSelect &= ~(VIC_CHAN_TO_MASK(VIC_CHAN_NUM_RTC)); + // VICIntEnClr = VIC_CHAN_TO_MASK(VIC_CHAN_NUM_RTC); + // VICVectAddr13 = (void *)rtcISR; + // VICVectCntl3 = 0x06; + // VICIntEnable = VIC_CHAN_TO_MASK(VIC_CHAN_NUM_RTC); + // } + //portEXIT_CRITICAL(); + + //RTC_CIIR |= 0x01; /* Enable Interrupt every Second */ + //RTC_CISS = 0x80; /* Enable SubSecond Interrupt (488u)*/ + +} + +/** \brief Read real time clock.*/ +void rtcRead(t_rtc * time) +{ + time->sec = RTC_SEC; + time->min = RTC_MIN; + time->hour = RTC_HOUR; + time->day = RTC_DOM; + time->dom = RTC_DOM; + time->dow = RTC_DOW; + time->doy = RTC_DOY; + time->mon = RTC_MONTH; + time->year = RTC_YEAR; +} + +/** \brief Write to real time clock.*/ +void rtcWrite(t_rtc * time) +{ + RTC_SEC = time->sec; + RTC_MIN = time->min; + RTC_HOUR = time->hour; + RTC_DOM = time->day; + RTC_DOW = time->dow; + RTC_DOY = time->doy; + RTC_MONTH = time->mon; + RTC_YEAR = time->year; +} +// Alarms + + +/* RTC INTERRUPT SERVICE ROUTINE */ +void rtcISR () +{ + portSAVE_CONTEXT(); /* Save context of interrupted task */ + { + + if (RTC_ILR & 0x01) /* Check for Seconds Interrupt */ + { + RTC_ILR = 0x1; /* Clear Seconds Interrupt */ + } + if (RTC_ILR & 0x04) /* Check for SubSecond Interrupt */ + { + RTC_ILR = 0x4; /* Clear SubSeconds Interrupt */ + } + + VICVectAddr = 0x00000000; /* clear Interrupts from the VIC */ + } + /* Restore the context of whichever task is going to run once the interrupt + * completes. + */ + portRESTORE_CONTEXT(); +} diff --git a/Tester/SW/lib/Drivers/rtc.h b/Tester/SW/lib/Drivers/rtc.h new file mode 100644 index 0000000..68e7463 --- /dev/null +++ b/Tester/SW/lib/Drivers/rtc.h @@ -0,0 +1,83 @@ +/* --------------------------------------------------------------------------- + * rtc.h - v0.1 (c) 2007 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: Real Time Clock interface. + * --------------------------------------------------------------------------- + * Version(s): 0.1, 10-09-2007, Marcel Mulder. + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef __RTC_H__ +#define __RTC_H__ +/** \file rtc.h + \brief Real Time Clock interface. +*/ + +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ +#include "lpc23xx.h" +#include "types.h" + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ +typedef struct t_RTC { + UINT8 sec; /**< Seconds */ + UINT8 min; /**< Minutes */ + UINT8 hour; /**< Hours */ + UINT8 day; /**< Day */ + UINT8 dow; /**< Day of week (0..7) */ + UINT8 mon; /**< Month */ + UINT8 dom; /**< Day of month */ + UINT16 year; /**< Year */ + UINT16 doy; /**< Day of year */ +} t_rtc; + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ +/** \brief Initialize logging interface.*/ +void rtcInit (void); + +/** \brief Read real time clock.*/ +void rtcRead ( + t_rtc * time +); + +/** \brief Write to real time clock.*/ +void rtcWrite ( + t_rtc * time +); +// Alarms + + + +#endif /* __RTC_H__ */ diff --git a/Tester/SW/lib/Drivers/serial.c b/Tester/SW/lib/Drivers/serial.c new file mode 100644 index 0000000..9cc821c --- /dev/null +++ b/Tester/SW/lib/Drivers/serial.c @@ -0,0 +1,236 @@ +/* --------------------------------------------------------------------------- + * serial.c - v0.1 (c) 2007 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: Serial port interface. + * --------------------------------------------------------------------------- + * Version(s): 0.1, 28-11-2007, fvds. + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +#include +#include + + +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "LPC23xx.h" +#include "types.h" +#include "serial.h" +#include "armVIC.h" +#include "uart.h" + +/* FreeRTOS includes */ + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ +#define NR_OF_COMPORTS 2 + + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ + + +/** \brief Initialize of serial interface.*/ +void serInit ( + t_serial_devices device, + UINT16 baudrate, /**< baudrate: B1200, B9600, B19200, B38400, B57600, B115200*/ + UINT8 mode, /**< mode: UART_8N1, UART_7N1, UART_8N2, UART_7N2, UART_8E1, + UART_7E1, UART_8E2, UART_7E2, UART_8O1, UART_7O1, + UART_8O2, UART_7O2 */ + UINT8 fmode /**< fmode: UART_FIFO_OFF, UART_FIFO_1, UART_FIFO_4, UART_FIFO_8, + UART_FIFO_14*/ +) +{ + switch( device ) + { + case(COM1): + uart0Init( baudrate, mode, fmode ); + break; + case(COM2): + uart1Init( baudrate, mode, fmode ); + + // Enable Handshake lines as well + U1_CTS_PINSEL_REG = ( U1_CTS_PINSEL_REG & ~U1_CTS_PINMASK ) | U1_CTS_PINSEL; + U1_RTS_PINSEL_REG = ( U1_RTS_PINSEL_REG & ~U1_RTS_PINMASK ) | U1_RTS_PINSEL; + + break; + } + +} + +/** \brief Write data of a certain length to a serial port.*/ +void serWrite ( + t_serial_devices device, + UINT16 length, /**< Lengh of data in bytes */ + UINT8 * data /**< Pointer to data */ +) +{ + switch( device ) + { + case(COM1): + uart0Write( (char *)data, length); + break; + case(COM2): + uart1Write( (char *)data, length); + break; + } +} + +/** \brief Reads data from serial port. + \retval Lengt of received data in bytes*/ +UINT16 serRead ( + t_serial_devices device, + UINT8 * data /**< Pointer to data */ +) +{ + UINT16 bytesReceived = 0; + BOOLEAN receivedSomething; + + do + { + receivedSomething = serGet( device, &(data[bytesReceived])); + if (receivedSomething) + bytesReceived++; + } while(receivedSomething); + + return bytesReceived; +} + +/** \brief Get byte from serial port. + \retval bool Returns true if there was data */ +BOOLEAN serGet( + t_serial_devices device, + UINT8 * byte /**< Pointer to byte to return data*/ +) +{ + int receivedChar = -1; + + switch( device ) + { + case(COM1): + receivedChar = uart0Getch(); + break; + case(COM2): + receivedChar = uart1Getch(); + break; + } + + if (receivedChar >= 0) + { + *byte = (UINT8)receivedChar; + return TRUE; + } + else + { + return FALSE; + } +} + +/** \brief Send byte to serial port. */ +void serPut( + t_serial_devices device, + UINT8 value /**< Byte to send*/ +) +{ + switch( device ) + { + case(COM1): + uart0Putch( value ); + break; + case(COM2): + uart1Putch( value ); + break; + } + +} + +/** \brief Flush serial port buffers. */ +void serFlush( + t_serial_devices device +) +{ + switch( device ) + { + case(COM1): + uart0TxFlush( ); + break; + case(COM2): + uart1TxFlush( ); + break; + } + +} + +/** \brief Check if receive buffers is empty. + \retval bool Returns true if recieve buffer is empty */ +BOOLEAN serEmpty( + t_serial_devices device +) +{ + switch( device ) + { + case(COM1): + return (uart0RxEmpty( ) != 0); + break; + case(COM2): + return (uart1RxEmpty( ) != 0); + break; + } + + return FALSE; +} + + +RESULT serSetModemControl( + t_serial_devices device, + BOOLEAN enable +) +{ + if (device == COM2) + { + if (enable == TRUE) + { + U1MCR |= (UMCR_RTS_EN | UMCR_CTS_EN); + } + else + { + U1MCR &= ~(UMCR_RTS_EN | UMCR_CTS_EN); + } + + return OK; + } + else + { + return ERROR; + } +} diff --git a/Tester/SW/lib/Drivers/serial.h b/Tester/SW/lib/Drivers/serial.h new file mode 100644 index 0000000..66f5386 --- /dev/null +++ b/Tester/SW/lib/Drivers/serial.h @@ -0,0 +1,125 @@ +/* --------------------------------------------------------------------------- + * serial.h - v0.1 (c) 2007 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: RS232 interface. + * --------------------------------------------------------------------------- + * Version(s): 0.1, 10-09-2007, Marcel Mulder. + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef __SERIAL_H__ +#define __SERIAL_H__ + +/** \file serial.h + \brief RS232 (UART) interface. +*/ + +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ +#include "sys_config.h" +#include "lpc23xx.h" +#include "types.h" +#include "uart.h" + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ +typedef enum +{ + COM1, /**< First RS232 port*/ + COM2 /**< Second RS232 port*/ +} t_serial_devices; + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ +/** \brief Initialize of serial interface.*/ +void serInit ( + t_serial_devices device, + UINT16 baudrate, /**< baudrate: B1200, B9600, B19200, B38400, B57600, B115200*/ + UINT8 mode, /**< mode: UART_8N1, UART_7N1, UART_8N2, UART_7N2, UART_8E1, + UART_7E1, UART_8E2, UART_7E2, UART_8O1, UART_7O1, + UART_8O2, UART_7O2 */ + UINT8 fmode /**< fmode: UART_FIFO_OFF, UART_FIFO_1, UART_FIFO_4, UART_FIFO_8, + UART_FIFO_14*/ +); + +/** \brief Write data of a certain length to a serial port.*/ +void serWrite ( + t_serial_devices device, + UINT16 length, /**< Lengh of data in bytes */ + UINT8 * data /**< Pointer to data */ +); + +/** \brief Reads data from serial port. + \retval Lengt of received data in bytes*/ +UINT16 serRead ( + t_serial_devices device, + UINT8 * data /**< Pointer to data */ +); + +/** \brief Get byte from serial port. + \retval bool Returns true if there was data */ +BOOLEAN serGet( + t_serial_devices device, + UINT8 * byte /**< Pointer to byte to return data*/ +); + +/** \brief Send byte to serial port. */ +void serPut( + t_serial_devices device, + UINT8 value /**< Byte to send*/ +); + +/** \brief Flush serial port buffers. */ +void serFlush( + t_serial_devices device +); + +/** \brief Check if receive buffers is empty. + \retval bool Returns true if recieve buffer is empty */ +BOOLEAN serEmpty( + t_serial_devices device +); + +/** \brief Enables handshaking to use serial-port with an external modem + * When enabled the CTS/RTS lines are used for communication with external modem. + * The ModemControl is only supported by COM2 + * \retval OK Modem control was altered succesfull + * \retval ERROR Modem control couldn't be altered (COM1 doesn't support modem control + */ +RESULT serSetModemControl( + t_serial_devices device, /**< COM1 or COM2 */ + BOOLEAN enable /**< Enable/disable modem control */ +); + +#endif /* __SERIAL_H__ */ diff --git a/Tester/SW/lib/Drivers/spi0.c b/Tester/SW/lib/Drivers/spi0.c new file mode 100644 index 0000000..59dcd1e --- /dev/null +++ b/Tester/SW/lib/Drivers/spi0.c @@ -0,0 +1,180 @@ +/* --------------------------------------------------------------------------- + * spi0.c - v1.0 (c) 2006 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AA Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: SPI 0 driver + * --------------------------------------------------------------------------- + * Version(s): 1.0, 07-12-2006, Jos Pasop. + * Creation. + * --------------------------------------------------------------------------- + */ +#define DEBUG + +#include "types.h" +#include "lpc23xx.h" +#include "armVic.h" +#include "spi0.h" + +#ifdef DEBUG +#include "uart.h" +#include "gpio.h" +#endif +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions. + * --------------------------------------------------------------------------- + */ +#define SPI_SPCR_BIT_ENABLE(b) (b<<2) +#define SPI_SPCR_CPHA(b) (b<<3) +#define SPI_SPCR_CPOL(b) (b<<4) +#define SPI_SPCR_MSTR(b) (b<<5) +#define SPI_SPCR_LSBF(b) (b<<6) +#define SPI_SPCR_SPIE(b) (b<<7) +#define SPI_SPCR_BITS(b) (b<<8) + +#define SPI_SPSR_ABRT (1<<3) +#define SPI_SPSR_MODF (1<<4) +#define SPI_SPSR_ROVR (1<<5) +#define SPI_SPSR_WCOL (1<<6) +#define SPI_SPSR_SPIF (1<<7) + +#define DISABLE_SPI0_IRQ {SPI_SPCR &= ~(SPI_SPCR_SPIE(1))} +#define ENABLE_SPI0_IRQ {SPI_SPCR |= (SPI_SPCR_SPIE(1))} + +/* --------------------------------------------------------------------------- + * Global variable definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local variable definitions. + * --------------------------------------------------------------------------- + */ + + +/* --------------------------------------------------------------------------- + * Local function declarations. + * --------------------------------------------------------------------------- + */ +VOID __attribute__ ((interrupt("IRQ"))) spi0Isr (VOID); + +/* --------------------------------------------------------------------------- + * spi0Init -- SPI0 initialize. + * + * This function initializes SPI0 to operate at slave at 1.2Mhz and sets up + * the VIC to for SPI0 interrupt service routine + * + * Global variables: commState, commStateSubI + * --------------------------------------------------------------------------- + */ +VOID +spi0Init + ( + VOID + ) + { +#ifdef DEBUG + /* Used to toggle the led to be able to check isr interrupt rate. */ + PCB_PINSEL1 &= ~0x3; /* set P0.16 (LED) as GPIO */ + GPIO_FIO0DIR |= LED; /* set P0.16 as output */ + GPIO_FIO0MASK &= ~LED; /* enable P0.16 */ +#endif + + // OTTO + //spi0TxBuf [0] = 0xD; + //spi0TxBuf [1] = 0x1234; + + /* Initialize pin connect block. */ + PCB_PINSEL0 &= ~0xFF00; /* clear the SPI0 fields */ + PCB_PINSEL0 |= 0x5500; /* configure the SPI0 pins */ + + S0SPCR = 0; +#if 0 + /* Set SPI0 clock rate. 1.2Mhz @ 48Mhz PCLK. */ + SPI_SPCCR = 40; +#endif + S0SPCR = + SPI_SPCR_BIT_ENABLE (0) | /* 1 -> enable n of bits selection */ + SPI_SPCR_CPHA (1) | /* 1 -> data sampled on 2nd edge */ + /* of sck */ + SPI_SPCR_CPOL (0) | /* 1 -> active low clock polarity */ + SPI_SPCR_MSTR (1) | /* 1 -> master mode */ + SPI_SPCR_LSBF (0) | /* 1 -> LSB shifted out first */ + SPI_SPCR_SPIE (0) | /* 0 -> hardware interrupt disabled*/ + SPI_SPCR_BITS (16); /* 7 < n < 16 -> n of bits, */ + /* 0->16 bits */ + + /* Initialize the SPI0 interrupt vector. */ + //VICVectAddr2 = (UINT32) spi0Isr; /* address of the ISR */ + //VICIntSelect &= ~VIC_BIT (VIC_SPI0); /* select SPI0 as IRQ */ + //VICVectCntl2 = VIC_IRQ_SLOT_EN | VIC_SPI0; /* priority 4 interrupt */ + //VICIntEnable = VIC_BIT (VIC_SPI0); /* enable SPI0 interrupt */ + } + + +VOID spi0Enable (VOID) +{ + // ? +} + +VOID spi0Disable (VOID) +{ + // ? +} + +RESULT spi0Write (UINT16 data) +{ + /* Check if SPI controller is disabled */ + + S0SPDR = data; /* write data */ + if ((S0SPSR & SPI_SPSR_WCOL) == SPI_SPSR_WCOL) return ERROR; /* Write collision */ + + return OK; +} + +RESULT spi0WriteRead (UINT16 *data) +{ + volatile int DummyRead; + + /* Check if SPI controller is disabled */ + + DummyRead = S0SPSR; /* For resetting status */ + S0SPDR = *data; /* write data */ + if ((S0SPSR & SPI_SPSR_WCOL) == SPI_SPSR_WCOL) return ERROR; /* Write collision */ + + while ((S0SPSR & SPI_SPSR_SPIF) == 0); /* wait if transmit is completed */ + + *data = S0SPDR; /* read data */ + + if ((S0SPSR & SPI_SPSR_ROVR) == SPI_SPSR_ROVR) return ERROR; /* Read overrun */ + + return OK; +} + +INT16 spi0Read (UINT16 * pData) +{ + volatile int DummyRead; + + /* Check if SPI controller is disabled */ + + DummyRead = S0SPSR; /* For resetting status */ + while ((S0SPSR & SPI_SPSR_SPIF) == 0); /* wait if transmit is completed */ + *data = S0SPDR; /* read data */ + if ((S0SPSR & SPI_SPSR_ROVR) == SPI_SPSR_ROVR) return ERROR; /* Read overrun */ + + return ERR_NONE; + +} + diff --git a/Tester/SW/lib/Drivers/spi0.h b/Tester/SW/lib/Drivers/spi0.h new file mode 100644 index 0000000..5d08afb --- /dev/null +++ b/Tester/SW/lib/Drivers/spi0.h @@ -0,0 +1,60 @@ +/* --------------------------------------------------------------------------- + * spi0.h - v1.0 (c) 2006 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AA Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: SPI 0 driver + * --------------------------------------------------------------------------- + * Version(s): 1.0, 07-12-2006, Jos Pasop. + * Creation. + * --------------------------------------------------------------------------- + */ + +#ifndef __SPI0_H__ +#define __SPI0_H__ + +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ +void spi0Init (void); +void spi0Enable (void); +void spi0Disable (void); +INT16 spi0Write (UINT16 data); +INT16 spi0Read (UINT16 * pData); + + +#endif /* __SPI0_H__ */ diff --git a/Tester/SW/lib/Drivers/ssp0.c b/Tester/SW/lib/Drivers/ssp0.c new file mode 100644 index 0000000..ba14ba6 --- /dev/null +++ b/Tester/SW/lib/Drivers/ssp0.c @@ -0,0 +1,287 @@ +/* --------------------------------------------------------------------------- + * spi1.c - v1.0 (c) 2006 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AA Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: spi1 driver. + * --------------------------------------------------------------------------- + * Version(s): 1.0, 27-10-2006, Jos Pasop. + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ +#include "types.h" +#include "lpc23xx.h" +#include "irq.h" +#include "ssp0.h" +#include "ssp0ISR.h" + +/* FreeRTOS includes */ +#include "FreeRTOS.h" +#include "Task.h" +#include "queue.h" +#include "semphr.h" + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions. + * --------------------------------------------------------------------------- + */ + +#define SSP0_DISPATCH_QUEUE_SIZE 64 + +#define SSP_CR0 SSP0CR0 +#define SSP_CR1 SSP0CR1 +#define SSP_CPSR SSP0CPSR +#define SSP_SR SSP0SR +#define SSP_DR SSP0DR +#define SSP_IMSC SSP0IMSC + + +/* Functions. */ +#define SPI_RXIM_ENABLE SSP1IMSC |= SSPIMSC_RXIM +#define SPI_RXIM_DISABLE SSP1IMSC &= ~SSPIMSC_RXIM +#define SPI_TXIM_ENABLE SSP1IMSC |= SSPIMSC_TXIM +#define SPI_TXIM_DISABLE SSP1IMSC &= ~SSPIMSC_TXIM + + + +/* --------------------------------------------------------------------------- + * Global variable definitions. + * --------------------------------------------------------------------------- + */ +xQueueHandle ssp0DispatchedIsrQueue; +xSemaphoreHandle ssp0BusMutex; + + +/* --------------------------------------------------------------------------- + * Local variable definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local function declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * ssp1Init -- SPI1 controller init. + * + * This function initialises the SPI1 controller. + * SPI1 is configured as master for the A/D converters (ADS8344). + * The SPI clock is used to clock the conversion. + * Each conversion takes 24 clk pulses. For a 50kHz throughput the SPI clock + * should be set at 24 * 50kHz = 1,2 MHz. + * + * Global variables: -- + * --------------------------------------------------------------------------- + */ +void +ssp0Init + ( + void + ) +{ + // Create queue and task for ISR-dispatching + ssp0DispatchedIsrQueue = xQueueCreate( SSP0_DISPATCH_QUEUE_SIZE, sizeof(UINT8)); + ssp0BusMutex = xSemaphoreCreateMutex(); + + + /* enable clock to SSP0 for security reason. By default, it's enabled already */ + PCONP |= (1 << 10); + + /* Configure PIN connect block */ + /* port 1 bits 7, 8, 9, 6 are SSP port SCK0, MISO0, MOSI0 */ + /* set SSEL to GPIO pin that you will have the totoal freedom to set/reset + the SPI chip-select pin */ + //PINSEL3 &= ~0x000FC000; // Clear de pin selection for SSP1 + PINSEL3 |= 0x0003C300; + + /* Control register 0. + * DSS = 16 bit tranfer + * FRF = SPI + * CPOL = 0 + * CPHA = 0 + * SCR = 0 + */ + SSP_CR0 = SSPCR0_DSS_8 | SSPCR0_SPO_L | SSPCR0_SPH_N; + + /* Control register 1. + * LBM = 0 + * SSE = 0 + * MS = 0 (master) + * SOD = 0 + */ + SSP_CR1 = 0x0; + + /* SSP Clock Prescale register. */ + SSP_CPSR = 10; /* 12 MHz / 10 = 1,2 Mhz (ADC highest speed) */ + + // Enable SSP0 interrupt + install_irq( VIC_CHAN_NUM_SSP0, (void *)ssp0ISR, HIGHEST_PRIORITY); + + SSP_IMSC = (SSPIMSC_RORIM) | (SSPIMSC_RTIM) | (SSPIMSC_RXIM); +} + +/* --------------------------------------------------------------------------- + * ssp1Enable -- SPI1 enable. + * + * This function enables the SSP controller + * + * Global variables: -- + * --------------------------------------------------------------------------- + */ +void +ssp0Enable + ( + void + ) +{ + SSP_CR1 |= SSPCR1_SSE; +} + +/* --------------------------------------------------------------------------- + * ssp1Disable -- SPI1 disable. + * + * This function disables the SSP controller + * + * Global variables: -- + * --------------------------------------------------------------------------- + */ +void +ssp0Disable + ( + void + ) +{ + SSP_CR1 &= ~SSPCR1_SSE; +} + + +void ssp0TakeBus(void) +{ + xSemaphoreTake( ssp0BusMutex, portMAX_DELAY ); +} + + +void ssp0ReleaseBus(void) +{ + xSemaphoreGive( ssp0BusMutex ); +} + + + +/* --------------------------------------------------------------------------- + * ssp1Write -- SPI1 write bit. + * + * This function sends bit data through the SPI bus. + * If the SPI bus is disabled ERROR is returned. Otherwise OK. + * + * Global variables: -- + * --------------------------------------------------------------------------- + */ +RESULT +ssp0Write + ( + UINT8 data + ) +{ + if ((SSP_CR1 & SSPCR1_SSE) == 0) + { + return ERROR; /* SPI controller is disabled */ + } + + + while ((SSP_SR & SSPSR_TNF) == 0); /* wait if transmit FIFO is full */ + + SSP_DR = data; /* write data */ + + return OK; +} + +/* --------------------------------------------------------------------------- + * ssp1Read -- SPI1 read. + * + * This function reads 16 bit data from the SPI bus. + * If no data is available ERROR is returned. Otherwise OK. + * + * Global variables: -- + * --------------------------------------------------------------------------- + */ +RESULT +ssp0Read + ( + UINT8 * pData + ) +{ + UINT16 dispatchItem; + + if (xQueueReceive(ssp0DispatchedIsrQueue, &dispatchItem, 200)) + { + *pData = (UINT8)dispatchItem; + } + + return OK; +} + +void ssp0WriteBuffer( UINT8 *buffer, UINT16 length ) +{ + UINT16 i; + for ( i = 0; i < length; i++ ) + { + /* as long as TNF bit is set (TxFIFO is not full), I can always transmit */ + while ( !(SSP_SR & SSPSR_TNF) ); + + SSP_DR = *buffer; + buffer++; + /* Wait until the Busy bit is cleared */ + while ( SSP_SR & SSPSR_BSY ); + } + return; +} + +void ssp0ReadBuffer( UINT8 *buffer, UINT16 length ) +{ + UINT16 i; + UINT8 dispatchItem; + + for ( i = 0; i < length; i++ ) + { + if (xQueueReceive(ssp0DispatchedIsrQueue, &dispatchItem, 200)) + { + *buffer = dispatchItem; + buffer++; + } + } + + return; +} + +void ssp0Loopback( BOOLEAN enable ) +{ + if (enable == TRUE) + { + SSP_CR1 |= SSPCR1_LBM; + } + else + { + SSP_CR1 &= ~SSPCR1_LBM; + } +} + + diff --git a/Tester/SW/lib/Drivers/ssp0.h b/Tester/SW/lib/Drivers/ssp0.h new file mode 100644 index 0000000..f72ddc9 --- /dev/null +++ b/Tester/SW/lib/Drivers/ssp0.h @@ -0,0 +1,67 @@ +/* --------------------------------------------------------------------------- + * ssp0.h - v1.0 (c) 2006 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AA Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: ssp0 driver interface description. + * --------------------------------------------------------------------------- + * Version(s): 1.0, 30-10-2006, Jos Pasop. + * Creation. + * --------------------------------------------------------------------------- + */ + +#ifndef __SSP0_H__ +#define __SSP0_H__ + +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ +#include "lpc23xx.h" + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ +#define SSP0_RX_BUFFER_SIZE 128 // UART0 receive buffer size +#define SSP0_TX_BUFFER_SIZE 128 // UART0 transmit buffer size + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ + + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ +void ssp0Init (void); +void ssp0Enable (void); +void ssp0Disable (void); +void ssp0TakeBus(void); +void ssp0ReleaseBus(void); +RESULT ssp0Write (UINT8 data); +RESULT ssp0Read (UINT8 * pData); +void ssp0WriteBuffer( UINT8 *buffer, UINT16 length ); +void ssp0ReadBuffer( UINT8 *buffer, UINT16 length ); +void ssp0Loopback( BOOLEAN enable ); + +#endif /* __SSP0_H__ */ diff --git a/Tester/SW/lib/Drivers/ssp0ISR.c b/Tester/SW/lib/Drivers/ssp0ISR.c new file mode 100644 index 0000000..596bd48 --- /dev/null +++ b/Tester/SW/lib/Drivers/ssp0ISR.c @@ -0,0 +1,126 @@ +/* --------------------------------------------------------------------------- + * ssp0ISR.c - v0.1 (c) 2007 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: Interrupt service routine for SSP0 + * --------------------------------------------------------------------------- + * Version(s): 0.1, 28-11-2007, fvds. + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +#include +#include + + +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "LPC23xx.h" +#include "types.h" + +#include "ssp0ISR.h" +//#include "armVIC.h" + +/* FreeRTOS includes */ +#include "FreeRTOS.h" +#include "Task.h" +#include "queue.h" + + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ +extern xQueueHandle ssp0DispatchedIsrQueue; + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ +/* statistics of all the interrupts */ +static volatile UINT32 interruptRxStat = 0; +static volatile UINT32 interruptOverRunStat = 0; +static volatile UINT32 interruptRxTimeoutStat = 0; +static UINT8 receivedByte; + + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ +static void ssp0Handler( void ); + + +void ssp0ISR( void ) +{ + /* Save the context of the interrupted task. */ + portSAVE_CONTEXT(); + { + ssp0Handler(); + } + /* Restore the context of whichever task is going to run once the interrupt + completes. */ + portRESTORE_CONTEXT(); +} + +void ssp0Handler( void ) +{ + UINT32 regValue; + + regValue = SSP0MIS; + if ( regValue & SSPMIS_RORMIS ) /* Receive overrun interrupt */ + { + interruptOverRunStat++; + SSP0ICR = SSPICR_RORIC; /* clear interrupt */ + } + + if ( regValue & SSPMIS_RTMIS ) /* Receive timeout interrupt */ + { + interruptRxTimeoutStat++; + + while ( SSP0SR & SSPSR_RNE ) // While not empty + { + receivedByte = SSP0DR; + xQueueSendToBackFromISR( ssp0DispatchedIsrQueue, &receivedByte, pdFALSE ); + } + + SSP0ICR = SSPICR_RTIC; /* clear interrupt */ + } + + /* please be aware that, in main and ISR, CurrentRxIndex and CurrentTxIndex + are shared as global variables. It may create some race condition that main + and ISR manipulate these variables at the same time. SSPSR_BSY checking (polling) + in both main and ISR could prevent this kind of race condition */ + if ( regValue & SSPMIS_RXMIS ) /* Rx at least half full */ + { + interruptRxStat++; /* receive until it's empty */ + + while ( SSP0SR & SSPSR_RNE ) // While not empty + { + receivedByte = SSP0DR; + xQueueSendToBackFromISR( ssp0DispatchedIsrQueue, &receivedByte, pdFALSE ); + } + } + + VICVectAddr = 0; /* Acknowledge Interrupt */ +} + diff --git a/Tester/SW/lib/Drivers/ssp0ISR.h b/Tester/SW/lib/Drivers/ssp0ISR.h new file mode 100644 index 0000000..06f420d --- /dev/null +++ b/Tester/SW/lib/Drivers/ssp0ISR.h @@ -0,0 +1,56 @@ +/* --------------------------------------------------------------------------- + * ssp0ISR.h - v1.0 (c) 2006 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AA Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: Default Interrupt service Routine of SSP0. + * --------------------------------------------------------------------------- + * Version(s): 1.0, 30-10-2006, Jos Pasop. + * Creation. + * --------------------------------------------------------------------------- + */ + +#ifndef __SSP0ISR_H__ +#define __SSP0ISR_H__ + +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ +#include "lpc23xx.h" + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ + + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ +void ssp0ISR (void) __attribute__ ((naked)); + +#endif /* __SSP0ISR_H__ */ diff --git a/Tester/SW/lib/Drivers/ssp1.c b/Tester/SW/lib/Drivers/ssp1.c new file mode 100644 index 0000000..ec09527 --- /dev/null +++ b/Tester/SW/lib/Drivers/ssp1.c @@ -0,0 +1,297 @@ +/* --------------------------------------------------------------------------- + * ssp1.c - v1.0 (c) 2006 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AA Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: ssp1 driver. + * --------------------------------------------------------------------------- + * Version(s): 1.0, 27-10-2006, Jos Pasop. + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ +#include "types.h" +#include "lpc23xx.h" +#include "irq.h" +#include "ssp1.h" +#include "ssp1ISR.h" + +/* FreeRTOS includes */ +#include "FreeRTOS.h" +#include "Task.h" +#include "queue.h" +#include "semphr.h" + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions. + * --------------------------------------------------------------------------- + */ + +#define SSP1_DISPATCH_QUEUE_SIZE 150 + +#define SSP_CR0 SSP1CR0 +#define SSP_CR1 SSP1CR1 +#define SSP_CPSR SSP1CPSR +#define SSP_SR SSP1SR +#define SSP_DR SSP1DR +#define SSP_IMSC SSP1IMSC + + +/* Functions. */ +#define SPI_RXIM_ENABLE SSP1IMSC |= SSPIMSC_RXIM +#define SPI_RXIM_DISABLE SSP1IMSC &= ~SSPIMSC_RXIM +#define SPI_TXIM_ENABLE SSP1IMSC |= SSPIMSC_TXIM +#define SPI_TXIM_DISABLE SSP1IMSC &= ~SSPIMSC_TXIM + + + +/* --------------------------------------------------------------------------- + * Global variable definitions. + * --------------------------------------------------------------------------- + */ +xQueueHandle ssp1DispatchedIsrQueue; +xSemaphoreHandle ssp1BusMutex; + +/* --------------------------------------------------------------------------- + * Local variable definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local function declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * ssp1Init -- SPI1 controller init. + * + * This function initialises the SPI1 controller. + * SPI1 is configured as master for the A/D converters (ADS8344). + * The SPI clock is used to clock the conversion. + * Each conversion takes 24 clk pulses. For a 50kHz throughput the SPI clock + * should be set at 24 * 50kHz = 1,2 MHz. + * + * Global variables: -- + * --------------------------------------------------------------------------- + */ +void +ssp1Init + ( + void + ) +{ + // Create queue and task for ISR-dispatching + ssp1DispatchedIsrQueue = xQueueCreate( SSP1_DISPATCH_QUEUE_SIZE, sizeof(UINT8)); + ssp1BusMutex = xSemaphoreCreateMutex(); + + + /* enable clock to SSP1 for security reason. By default, it's enabled already */ + PCONP |= (1 << 10); + + /* Configure PIN connect block */ + /* port 1 bits 7, 8, 9, 6 are SSP port SCK1, MISO1, MOSI1 */ + /* set SSEL to GPIO pin that you will have the totoal freedom to set/reset + the SPI chip-select pin */ + PINSEL0 &= ~0x000FC000; // Clear de pin selection for SSP1 + PINSEL0 |= 0x000A8000; + + + /* Control register 0. + * DSS = 16 bit tranfer + * FRF = SPI + * CPOL = 0 + * CPHA = 0 + * SCR = 0 + */ + SSP_CR0 = SSPCR0_DSS_8 | SSPCR0_SPO_L | SSPCR0_SPH_N; + + /* Control register 1. + * LBM = 0 + * SSE = 0 + * MS = 0 (master) + * SOD = 0 + */ + SSP_CR1 = 0x0; + + /* SSP Clock Prescale register. */ + SSP_CPSR = 4; /* 12 MHz / 4 EEPROM max 5 MHz */ + + // Enable SSP1 interrupt + install_irq( VIC_CHAN_NUM_SSP1, (void *)ssp1ISR, HIGHEST_PRIORITY ); + + SSP_IMSC = (SSPIMSC_RORIM) | (SSPIMSC_RTIM) | (SSPIMSC_RXIM); + + +} + +/* --------------------------------------------------------------------------- + * ssp1Enable -- SPI1 enable. + * + * This function enables the SSP controller + * + * Global variables: -- + * --------------------------------------------------------------------------- + */ +void +ssp1Enable + ( + void + ) +{ + SSP_CR1 |= SSPCR1_SSE; +} + +/* --------------------------------------------------------------------------- + * ssp1Disable -- SPI1 disable. + * + * This function disables the SSP controller + * + * Global variables: -- + * --------------------------------------------------------------------------- + */ +void +ssp1Disable + ( + void + ) +{ + SSP_CR1 &= ~SSPCR1_SSE; +} + + +void ssp1TakeBus(void) +{ + xSemaphoreTake( ssp1BusMutex, portMAX_DELAY ); +} + + +void ssp1ReleaseBus(void) +{ + xSemaphoreGive( ssp1BusMutex ); +} + + +/* --------------------------------------------------------------------------- + * ssp1Write -- SPI1 write bit. + * + * This function sends bit data through the SPI bus. + * If the SPI bus is disabled ERROR is returned. Otherwise OK. + * + * Global variables: -- + * --------------------------------------------------------------------------- + */ +RESULT +ssp1Write + ( + UINT8 data + ) +{ + if ((SSP_CR1 & SSPCR1_SSE) == 0) + { + return ERROR; /* SPI controller is disabled */ + } + + + while ((SSP_SR & SSPSR_TNF) == 0); /* wait if transmit FIFO is full */ + + SSP_DR = data; /* write data */ + + return OK; +} + +//BOOLEAN +//ssp1TransmitBufferFull +//( +//) + + +/* --------------------------------------------------------------------------- + * ssp1Read -- SPI1 read. + * + * This function reads 16 bit data from the SPI bus. + * If no data is available ERROR is returned. Otherwise OK. + * + * Global variables: -- + * --------------------------------------------------------------------------- + */ +RESULT +ssp1Read + ( + UINT8 * pData + ) +{ + UINT16 dispatchItem; + + if (xQueueReceive(ssp1DispatchedIsrQueue, &dispatchItem, 200)) + { + *pData = (UINT8)dispatchItem; + return OK; + } + else + { + return ERROR; + } +} + +void ssp1WriteBuffer( UINT8 *buffer, UINT16 length ) +{ + UINT16 i; + for ( i = 0; i < length; i++ ) + { + /* as long as TNF bit is set (TxFIFO is not full), I can always transmit */ + while ( !(SSP_SR & SSPSR_TNF) ); + + SSP_DR = *buffer; + buffer++; + /* Wait until the Busy bit is cleared `(Busy if 1)*/ + while ( (SSP_SR & SSPSR_BSY) ); + } + return; +} + +void ssp1ReadBuffer( UINT8 *buffer, UINT16 length ) +{ + UINT16 i; + UINT8 dispatchItem; + + for ( i = 0; i < length; i++ ) + { + if (xQueueReceive(ssp1DispatchedIsrQueue, &dispatchItem, 200)) + { + *buffer = dispatchItem; + buffer++; + } + } + + return; +} + +void ssp1Loopback( BOOLEAN enable ) +{ + if (enable == TRUE) + { + SSP_CR1 |= SSPCR1_LBM; + } + else + { + SSP_CR1 &= ~SSPCR1_LBM; + } +} + + diff --git a/Tester/SW/lib/Drivers/ssp1.h b/Tester/SW/lib/Drivers/ssp1.h new file mode 100644 index 0000000..380a919 --- /dev/null +++ b/Tester/SW/lib/Drivers/ssp1.h @@ -0,0 +1,64 @@ +/* --------------------------------------------------------------------------- + * ssp1.h - v1.0 (c) 2006 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AA Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: spi1 driver interface description. + * --------------------------------------------------------------------------- + * Version(s): 1.0, 30-10-2006, Jos Pasop. + * Creation. + * --------------------------------------------------------------------------- + */ + +#ifndef __SSP1_H__ +#define __SSP1_H__ + +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ +#include "lpc23xx.h" + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ +void ssp1Init (void); +void ssp1Enable (void); +void ssp1Disable (void); +void ssp1TakeBus(void); +void ssp1ReleaseBus(void); +RESULT ssp1Write (UINT8 data); +RESULT ssp1Read (UINT8 * pData); +void ssp1WriteBuffer( UINT8 *buffer, UINT16 length ); +void ssp1ReadBuffer( UINT8 *buffer, UINT16 length ); +void ssp1Loopback( BOOLEAN enable ); + +#endif /* __SSP1_H__ */ diff --git a/Tester/SW/lib/Drivers/ssp1ISR.c b/Tester/SW/lib/Drivers/ssp1ISR.c new file mode 100644 index 0000000..5f16b35 --- /dev/null +++ b/Tester/SW/lib/Drivers/ssp1ISR.c @@ -0,0 +1,126 @@ +/* --------------------------------------------------------------------------- + * ssp0ISR.c - v0.1 (c) 2007 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: Interrupt service routine for SSP0 + * --------------------------------------------------------------------------- + * Version(s): 0.1, 28-11-2007, fvds. + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +#include +#include + + +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "LPC23xx.h" +#include "types.h" + +#include "ssp1ISR.h" +//#include "armVIC.h" + +/* FreeRTOS includes */ +#include "FreeRTOS.h" +#include "Task.h" +#include "queue.h" + + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ +extern xQueueHandle ssp1DispatchedIsrQueue; + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ +/* statistics of all the interrupts */ +static volatile UINT32 interruptRxStat = 0; +static volatile UINT32 interruptOverRunStat = 0; +static volatile UINT32 interruptRxTimeoutStat = 0; +static UINT8 receivedByte; + + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ +static void ssp1Handler( void ); + + +void ssp1ISR( void ) +{ + /* Save the context of the interrupted task. */ + portSAVE_CONTEXT(); + { + ssp1Handler(); + } + /* Restore the context of whichever task is going to run once the interrupt + completes. */ + portRESTORE_CONTEXT(); +} + +void ssp1Handler( void ) +{ + UINT32 regValue; + + regValue = SSP1MIS; + if ( regValue & SSPMIS_RORMIS ) /* Receive overrun interrupt */ + { + interruptOverRunStat++; + SSP1ICR = SSPICR_RORIC; /* clear interrupt */ + } + + if ( regValue & SSPMIS_RTMIS ) /* Receive timeout interrupt */ + { + interruptRxTimeoutStat++; + + while ( SSP1SR & SSPSR_RNE ) // While not empty + { + receivedByte = SSP1DR; + xQueueSendToBackFromISR( ssp1DispatchedIsrQueue, &receivedByte, pdFALSE ); + } + + SSP1ICR = SSPICR_RTIC; /* clear interrupt */ + } + + /* please be aware that, in main and ISR, CurrentRxIndex and CurrentTxIndex + are shared as global variables. It may create some race condition that main + and ISR manipulate these variables at the same time. SSPSR_BSY checking (polling) + in both main and ISR could prevent this kind of race condition */ + if ( regValue & SSPMIS_RXMIS ) /* Rx at least half full */ + { + interruptRxStat++; /* receive until it's empty */ + + while ( SSP1SR & SSPSR_RNE ) // While not empty + { + receivedByte = SSP1DR; + xQueueSendToBackFromISR( ssp1DispatchedIsrQueue, &receivedByte, pdFALSE ); + } + } + + VICVectAddr = 0; /* Acknowledge Interrupt */ +} + diff --git a/Tester/SW/lib/Drivers/ssp1ISR.h b/Tester/SW/lib/Drivers/ssp1ISR.h new file mode 100644 index 0000000..73971b9 --- /dev/null +++ b/Tester/SW/lib/Drivers/ssp1ISR.h @@ -0,0 +1,56 @@ +/* --------------------------------------------------------------------------- + * ssp1ISR.h - v1.0 (c) 2006 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AA Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: Default Interrupt service Routine of SSP1. + * --------------------------------------------------------------------------- + * Version(s): 1.0, 30-10-2006, Jos Pasop. + * Creation. + * --------------------------------------------------------------------------- + */ + +#ifndef __SSP1ISR_H__ +#define __SSP1ISR_H__ + +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ +#include "lpc23xx.h" + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ + + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ +void ssp1ISR (void) __attribute__ ((naked)); + +#endif /* __SSP1ISR_H__ */ diff --git a/Tester/SW/lib/Drivers/uart.c b/Tester/SW/lib/Drivers/uart.c new file mode 100644 index 0000000..6da1791 --- /dev/null +++ b/Tester/SW/lib/Drivers/uart.c @@ -0,0 +1,619 @@ +/****************************************************************************** + * + * $RCSfile: $ + * $Revision: $ + * + * This module provides interface routines to the LPC ARM UARTs. + * Copyright 2004, R O SoftWare + * No guarantees, warrantees, or promises, implied or otherwise. + * May be used for hobby or commercial purposes provided copyright + * notice remains intact. + * + * Modified by Martin Thomas for LPC23xx 24xx + *****************************************************************************/ +#include "app_types.h" +#include "LPC_REGS.h" +#include "sys_config.h" + +#include "uart.h" + +#ifndef USHRT_MAX +#define USHRT_MAX 16 +#endif + +#include "armVIC.h" +#include "uartISR.h" + +uint8_t uart0_rx_buffer[UART0_RX_BUFFER_SIZE]; +uint16_t uart0_rx_insert_idx, uart0_rx_extract_idx; +uint8_t uart0_tx_buffer[UART0_TX_BUFFER_SIZE]; +uint16_t uart0_tx_insert_idx, uart0_tx_extract_idx; +int uart0_tx_running; + +uint8_t uart1_rx_buffer[UART1_RX_BUFFER_SIZE]; +uint16_t uart1_rx_insert_idx, uart1_rx_extract_idx; +uint8_t uart1_tx_buffer[UART1_TX_BUFFER_SIZE]; +uint16_t uart1_tx_insert_idx, uart1_tx_extract_idx; +int uart1_tx_running; + + +/****************************************************************************** + * + * Function Name: uart0Init() + * + * Description: + * This function initializes the UART for async mode + * + * Calling Sequence: + * baudrate divisor - use UART_BAUD macro + * mode - see typical modes (uart.h) + * fmode - see typical fmodes (uart.h) + * + * Returns: + * void + * + * NOTE: uart0Init(UART_BAUD(9600), UART_8N1, UART_FIFO_8); + * + *****************************************************************************/ +void uart0Init(uint16_t baud, uint8_t mode, uint8_t fmode) +{ + // set port pins for UART0 + // mthomas PINSEL0 = (PINSEL0 & ~U0_PINMASK) | U0_PINSEL; + // set port pins for UART0 + // PINSEL0 = (PINSEL0 & ~U0_PINMASK) | U0_PINSEL; + U0_TX_PINSEL_REG = ( U0_TX_PINSEL_REG & ~U0_TX_PINMASK ) | U0_TX_PINSEL; + U0_RX_PINSEL_REG = ( U0_RX_PINSEL_REG & ~U0_RX_PINMASK ) | U0_RX_PINSEL; + + // Set CLOCK for UART0 device (4x) +// PCLKSEL0 = 0x00000040; + + // Set CLOCK for UART0 device (/2) + PCLKSEL0 &= 0xFFFFFF7F; + PCLKSEL0 |= 0x00000080; + + U0IER = 0x00; // disable all interrupts + U0IIR; // clear interrupt ID + U0RBR; // clear receive register + U0LSR; // clear line status register + + // set the baudrate + U0LCR = ULCR_DLAB_ENABLE; // select divisor latches + U0DLL = (uint8_t)baud; // set for baud low byte + U0DLM = (uint8_t)(baud >> 8); // set for baud high byte + + // set the number of characters and other + // user specified operating parameters + U0LCR = (mode & ~ULCR_DLAB_ENABLE); + U0FCR = fmode; + + // initialize the interrupt vector + VICIntSelect &= ~VIC_CHAN_TO_MASK(VIC_CHAN_NUM_UART0); + VICIntEnClr = VIC_CHAN_TO_MASK(VIC_CHAN_NUM_UART0); + VICVectAddr6 = (uint32_t)uart0ISR; + VICVectPriority6 = 0xF; + VICIntEnable = VIC_CHAN_TO_MASK(VIC_CHAN_NUM_UART0); + + // initialize the transmit data queue + uart0_tx_extract_idx = uart0_tx_insert_idx = 0; + uart0_tx_running = 0; + + // initialize the receive data queue + uart0_rx_extract_idx = uart0_rx_insert_idx = 0; + + // enable receiver interrupts + U0IER = UIER_RBR; +} + +/****************************************************************************** + * + * Function Name: uart0Putch() + * + * Description: + * This function puts a character into the UART output queue for + * transmission. + * + * Calling Sequence: + * character to be transmitted + * + * Returns: + * ch on success, -1 on error (queue full) + * + *****************************************************************************/ +int uart0Putch(int ch) +{ + uint16_t temp; + unsigned cpsr; + + temp = (uart0_tx_insert_idx + 1) % UART0_TX_BUFFER_SIZE; + + if (temp == uart0_tx_extract_idx) + return -1; // no room + + cpsr = disableIRQ(); // disable global interrupts + U0IER &= ~UIER_THRE; // disable TX interrupts + restoreIRQ(cpsr); // restore global interrupts + + // check if in process of sending data + if (uart0_tx_running) + { + // add to queue + uart0_tx_buffer[uart0_tx_insert_idx] = (uint8_t)ch; + uart0_tx_insert_idx = temp; + } + else + { + // set running flag and write to output register + uart0_tx_running = 1; + U0THR = (uint8_t)ch; + } + + cpsr = disableIRQ(); // disable global interrupts + U0IER |= UIER_THRE; // enable TX interrupts + restoreIRQ(cpsr); // restore global interrupts + + return (uint8_t)ch; +} + +/****************************************************************************** + * + * Function Name: uart0Space() + * + * Description: + * This function gets the available space in the transmit queue + * + * Calling Sequence: + * void + * + * Returns: + * available space in the transmit queue + * + *****************************************************************************/ +uint16_t uart0Space(void) +{ + int space; + + if ((space = (uart0_tx_extract_idx - uart0_tx_insert_idx)) <= 0) + space += UART0_TX_BUFFER_SIZE; + + return (uint16_t)(space - 1); +} + +/****************************************************************************** + * + * Function Name: uart0Puts() + * + * Description: + * This function writes a NULL terminated 'string' to the UART output + * queue, returning a pointer to the next character to be written. + * + * Calling Sequence: + * address of the string + * + * Returns: + * a pointer to the next character to be written + * (\0 if full string is written) + * + *****************************************************************************/ +const char *uart0Puts(const char *string) +{ + register char ch; + + while ((ch = *string) && (uart0Putch(ch) >= 0)) + string++; + + return string; +} + +/****************************************************************************** + * + * Function Name: uart0Write() + * + * Description: + * This function writes 'count' characters from 'buffer' to the UART + * output queue. + * + * Calling Sequence: + * + * + * Returns: + * 0 on success, -1 if insufficient room, -2 on error + * NOTE: if insufficient room, no characters are written. + * + *****************************************************************************/ +int uart0Write(const char *buffer, uint16_t count) +{ + if (count > uart0Space()) + return -1; + + while (count && (uart0Putch(*buffer++) >= 0)) + count--; + + return (count ? -2 : 0); +} + +/****************************************************************************** + * + * Function Name: uart0TxEmpty() + * + * Description: + * This function returns the status of the UART transmit data + * registers. + * + * Calling Sequence: + * void + * + * Returns: + * FALSE - either the tx holding or shift register is not empty + * !FALSE - if both the tx holding & shift registers are empty + * + *****************************************************************************/ +int uart0TxEmpty(void) +{ + return (U0LSR & (ULSR_THRE | ULSR_TEMT)) == (ULSR_THRE | ULSR_TEMT); +} + +int uart0RxEmpty(void) +{ + if (uart0_rx_insert_idx == uart0_rx_extract_idx) // check if character is available + { + return 1; + } + else + { + return 0; + } + +} +/****************************************************************************** + * + * Function Name: uart0TxFlush() + * + * Description: + * This function removes all characters from the UART transmit queue + * (without transmitting them). + * + * Calling Sequence: + * void + * + * Returns: + * void + * + *****************************************************************************/ +void uart0TxFlush(void) +{ + unsigned cpsr; + + U0FCR |= UFCR_TX_FIFO_RESET; // clear the TX fifo + + // "Empty" the transmit buffer. + cpsr = disableIRQ(); // disable global interrupts + U0IER &= ~UIER_THRE; // disable TX interrupts + restoreIRQ(cpsr); // restore global interrupts + uart0_tx_insert_idx = uart0_tx_extract_idx = 0; +} + +/****************************************************************************** + * + * Function Name: uart0Getch() + * + * Description: + * This function gets a character from the UART receive queue + * + * Calling Sequence: + * void + * + * Returns: + * character on success, -1 if no character is available + * + *****************************************************************************/ +int uart0Getch(void) +{ + uint8_t ch; + + if (uart0_rx_insert_idx == uart0_rx_extract_idx) // check if character is available + return -1; + + ch = uart0_rx_buffer[uart0_rx_extract_idx++]; // get character, bump pointer + uart0_rx_extract_idx %= UART0_RX_BUFFER_SIZE; // limit the pointer + return ch; +} + + +/****************************************************************************** + * + * Function Name: uart1Init() + * + * Description: + * This function initializes the UART for async mode + * + * Calling Sequence: + * baudrate divisor - use UART_BAUD macro + * mode - see typical modes (uart.h) + * fmode - see typical fmodes (uart.h) + * + * Returns: + * void + * + * NOTE: uart1Init(UART_BAUD(9600), UART_8N1, UART_FIFO_8); + * + *****************************************************************************/ +void uart1Init(uint16_t baud, uint8_t mode, uint8_t fmode) +{ + // set port pins for UART1 + // mthomas PINSEL0 = (PINSEL0 & ~U1_PINMASK) | U1_PINSEL; + U1_TX_PINSEL_REG = ( U1_TX_PINSEL_REG & ~U1_TX_PINMASK ) | U1_TX_PINSEL; + U1_RX_PINSEL_REG = ( U1_RX_PINSEL_REG & ~U1_RX_PINMASK ) | U1_RX_PINSEL; + + U1IER = 0x00; // disable all interrupts + U1IIR; // clear interrupt ID + U1RBR; // clear receive register + U1LSR; // clear line status register + + // Set CLOCK for UART1 device (4x) + //PCLKSEL0 = 0x00000100; + + // Set CLOCK for UART1 device (div 2) + PCLKSEL0 &= 0xFFFFFCFF; + PCLKSEL0 |= 0x00000200; + + // set the baudrate + U1LCR = ULCR_DLAB_ENABLE; // select divisor latches + U1DLL = (uint8_t)baud; // set for baud low byte + U1DLM = (uint8_t)(baud >> 8); // set for baud high byte + + // set the number of characters and other + // user specified operating parameters + U1LCR = (mode & ~ULCR_DLAB_ENABLE); + U1FCR = fmode; + + // initialize the interrupt vector + VICIntSelect &= ~VIC_CHAN_TO_MASK(VIC_CHAN_NUM_UART1); + VICIntEnClr = VIC_CHAN_TO_MASK(VIC_CHAN_NUM_UART1); + VICVectAddr7 = (uint32_t)uart1ISR; + VICVectPriority7 = 0x0F; + VICIntEnable = VIC_CHAN_TO_MASK(VIC_CHAN_NUM_UART1); + + uart1_tx_extract_idx = uart1_tx_insert_idx = 0; + uart1_tx_running = 0; + + // initialize data queues + uart1_rx_extract_idx = uart1_rx_insert_idx = 0; + + // enable receiver interrupts + U1IER |= UIER_RBR; +} + +/****************************************************************************** + * + * Function Name: uart1Putch() + * + * Description: + * This function puts a character into the UART output queue for + * transmission. + * + * Calling Sequence: + * ch - character to be transmitted + * + * Returns: + * ch on success, -1 on error (queue full) + * + *****************************************************************************/ +int uart1Putch(int ch) +{ + uint16_t temp; + unsigned cpsr; + + temp = (uart1_tx_insert_idx + 1) % UART1_TX_BUFFER_SIZE; + + if (temp == uart1_tx_extract_idx) + return -1; // no room + + cpsr = disableIRQ(); // disable global interrupts + U1IER &= ~UIER_THRE; // disable TX interrupts + restoreIRQ(cpsr); // restore global interrupts + + // check if in process of sending data + if (uart1_tx_running) + { + // add to queue + uart1_tx_buffer[uart1_tx_insert_idx] = (uint8_t)ch; + uart1_tx_insert_idx = temp; + } + else + { + // set running flag and write to output register + uart1_tx_running = 1; + U1THR = (uint8_t)ch; + } + + cpsr = disableIRQ(); // disable global interrupts + U1IER |= UIER_THRE; // enable TX interrupts + restoreIRQ(cpsr); // restore global interrupts + + return (uint8_t)ch; +} + +int uart1Putch_block(int ch) +{ + while ( !uart1Space() ) { + ; // wait for space available + } + return uart1Putch(ch); +} + +/****************************************************************************** + * + * Function Name: uart1Space() + * + * Description: + * This function gets the available space in the transmit queue + * + * Calling Sequence: + * void + * + * Returns: + * available space in the transmit queue + * + *****************************************************************************/ +uint16_t uart1Space(void) +{ + int space; + + if ((space = (uart1_tx_extract_idx - uart1_tx_insert_idx)) <= 0) + space += UART1_TX_BUFFER_SIZE; + + return (uint16_t)(space - 1); +} + +/****************************************************************************** + * + * Function Name: uart1Puts() + * + * Description: + * This function writes a NULL terminated 'string' to the UART output + * queue, returning a pointer to the next character to be written. + * + * Calling Sequence: + * address of the string + * + * Returns: + * a pointer to the next character to be written + * (\0 if full string is written) + * + *****************************************************************************/ +const char *uart1Puts(const char *string) +{ + register char ch; + + while ((ch = *string) && (uart1Putch(ch) >= 0)) + string++; + + return string; +} + +const char *uart1Puts_block(const char *string) +{ + register char ch; + + while ((ch = *string) && (uart1Putch_block(ch) >= 0)) + string++; + + return string; +} + +/****************************************************************************** + * + * Function Name: uart1Write() + * + * Description: + * This function writes 'count' characters from 'buffer' to the UART + * output queue. + * + * Calling Sequence: + * + * + * Returns: + * 0 on success, -1 if insufficient room, -2 on error + * NOTE: if insufficient room, no characters are written. + * + *****************************************************************************/ +int uart1Write(const char *buffer, uint16_t count) +{ + if (count > uart1Space()) + return -1; + + while (count && (uart1Putch(*buffer++) >= 0)) + count--; + + return (count ? -2 : 0); +} + +/****************************************************************************** + * + * Function Name: uart1TxEmpty() + * + * Description: + * This function returns the status of the UART transmit data + * registers. + * + * Calling Sequence: + * void + * + * Returns: + * FALSE - either the tx holding or shift register is not empty + * !FALSE - if both the tx holding & shift registers are empty + * + *****************************************************************************/ +int uart1TxEmpty(void) +{ + return (U1LSR & (ULSR_THRE | ULSR_TEMT)) == (ULSR_THRE | ULSR_TEMT); +} + +int uart1RxEmpty(void) +{ + if (uart1_rx_insert_idx == uart1_rx_extract_idx) // check if character is available + { + return 1; + } + else + { + return 0; + } + +} + + +/****************************************************************************** + * + * Function Name: uart1TxFlush() + * + * Description: + * This function removes all characters from the UART transmit queue + * (without transmitting them). + * + * Calling Sequence: + * void + * + * Returns: + * void + * + *****************************************************************************/ +void uart1TxFlush(void) +{ + unsigned cpsr; + + U1FCR |= UFCR_TX_FIFO_RESET; // clear the TX fifo + + // "Empty" the transmit buffer. + cpsr = disableIRQ(); // disable global interrupts + U1IER &= ~UIER_THRE; // disable TX interrupts + restoreIRQ(cpsr); // restore global interrupts + uart1_tx_insert_idx = uart1_tx_extract_idx = 0; +} + +/****************************************************************************** + * + * Function Name: uart1Getch() + * + * Description: + * This function gets a character from the UART receive queue + * + * Calling Sequence: + * void + * + * Returns: + * character on success, -1 if no character is available + * + *****************************************************************************/ +int uart1Getch(void) +{ + uint8_t ch; + + if (uart1_rx_insert_idx == uart1_rx_extract_idx) // check if character is available + return -1; + + ch = uart1_rx_buffer[uart1_rx_extract_idx++]; // get character, bump pointer + uart1_rx_extract_idx %= UART1_RX_BUFFER_SIZE; // limit the pointer + return ch; +} + diff --git a/Tester/SW/lib/Drivers/uart.h b/Tester/SW/lib/Drivers/uart.h new file mode 100644 index 0000000..3a3cbaf --- /dev/null +++ b/Tester/SW/lib/Drivers/uart.h @@ -0,0 +1,400 @@ +/****************************************************************************** + * + * $RCSfile: $ + * $Revision: $ + * + * This module provides the interface definitions for for uart.c + * Copyright 2004, R O SoftWare + * No guarantees, warrantees, or promises, implied or otherwise. + * May be used for hobby or commercial purposes provided copyright + * notice remains intact. + * + *****************************************************************************/ +#ifndef INC_UART_H +#define INC_UART_H + +#include "sys_config.h" +#include "app_types.h" +#include "LPC_REGS.h" + + +/////////////////////////////////////////////////////////////////////////////// +// code is optimized for power of 2 buffer sizes (16, 32, 64, 128, ...) +// NOTE: the buffers are only used if the respective interrupt mode is +// enabled +#define UART0_RX_BUFFER_SIZE 256 // UART0 receive buffer size +#define UART0_TX_BUFFER_SIZE 256 // UART0 transmit buffer size +#define UART1_RX_BUFFER_SIZE 128 // UART1 receive buffer size +#define UART1_TX_BUFFER_SIZE 256 // UART1 transmit buffer size + +/////////////////////////////////////////////////////////////////////////////// +// use the following macros to determine the 'baud' parameter values +// for uart0Init() and uart1Init() +// CAUTION - 'baud' SHOULD ALWAYS BE A CONSTANT or +// a lot of code will be generated. +#define UART_PCLK_DIV (2) // PCLKSEL0 is changed to div 2 is changed for UART for supporting 115k +#define UART_BAUD(baud) (uint16_t)(((CCLK / UART_PCLK_DIV) / ((baud) * 16.0)) + 0.5) + + +/////////////////////////////////////////////////////////////////////////////// +// Definitions for typical UART 'baud' settings +#define B1200 UART_BAUD(1200) +#define B2400 UART_BAUD(2400) +#define B4800 UART_BAUD(4800) +#define B9600 UART_BAUD(9600) +#define B19200 UART_BAUD(19200) +#define B38400 UART_BAUD(38400) +#define B57600 UART_BAUD(57600) +#define B115200 UART_BAUD(115200) + +/////////////////////////////////////////////////////////////////////////////// +// Definitions for typical UART 'mode' settings +#define UART_8N1 (uint8_t)(ULCR_CHAR_8 + ULCR_PAR_NO + ULCR_STOP_1) +#define UART_7N1 (uint8_t)(ULCR_CHAR_7 + ULCR_PAR_NO + ULCR_STOP_1) +#define UART_8N2 (uint8_t)(ULCR_CHAR_8 + ULCR_PAR_NO + ULCR_STOP_2) +#define UART_7N2 (uint8_t)(ULCR_CHAR_7 + ULCR_PAR_NO + ULCR_STOP_2) +#define UART_8E1 (uint8_t)(ULCR_CHAR_8 + ULCR_PAR_EVEN + ULCR_STOP_1) +#define UART_7E1 (uint8_t)(ULCR_CHAR_7 + ULCR_PAR_EVEN + ULCR_STOP_1) +#define UART_8E2 (uint8_t)(ULCR_CHAR_8 + ULCR_PAR_EVEN + ULCR_STOP_2) +#define UART_7E2 (uint8_t)(ULCR_CHAR_7 + ULCR_PAR_EVEN + ULCR_STOP_2) +#define UART_8O1 (uint8_t)(ULCR_CHAR_8 + ULCR_PAR_ODD + ULCR_STOP_1) +#define UART_7O1 (uint8_t)(ULCR_CHAR_7 + ULCR_PAR_ODD + ULCR_STOP_1) +#define UART_8O2 (uint8_t)(ULCR_CHAR_8 + ULCR_PAR_ODD + ULCR_STOP_2) +#define UART_7O2 (uint8_t)(ULCR_CHAR_7 + ULCR_PAR_ODD + ULCR_STOP_2) + +/////////////////////////////////////////////////////////////////////////////// +// Definitions for typical UART 'fmode' settings +#define UART_FIFO_OFF (0x00) +#define UART_FIFO_1 (uint8_t)(UFCR_FIFO_ENABLE + UFCR_FIFO_TRIG1) +#define UART_FIFO_4 (uint8_t)(UFCR_FIFO_ENABLE + UFCR_FIFO_TRIG4) +#define UART_FIFO_8 (uint8_t)(UFCR_FIFO_ENABLE + UFCR_FIFO_TRIG8) +#define UART_FIFO_14 (uint8_t)(UFCR_FIFO_ENABLE + UFCR_FIFO_TRIG14) + + +/////////////////////////////////////////////////////////////////////////////// + +/****************************************************************************** + * + * Function Name: uart0Init() + * + * Description: + * This function initializes the UART for async mode + * + * Calling Sequence: + * baudrate divisor - use UART0_BAUD macro + * mode - see typical modes (above) + * fmode - see typical fmodes (above) + * + * Returns: + * void + * + * NOTE: uart0Init(UART_BAUD(9600), UART_8N1, UART_FIFO_8); + * + *****************************************************************************/ +void uart0Init(uint16_t baud, uint8_t mode, uint8_t fmode); + +/****************************************************************************** + * + * Function Name: uart0Putch() + * + * Description: + * This function puts a character into the UART output queue for + * transmission. + * + * Calling Sequence: + * character to be transmitted + * + * Returns: + * ch on success, -1 on error (queue full) + * + *****************************************************************************/ +int uart0Putch(int ch); +// same but blocking when no space available (mthomas) +int uart0Putch_block(int ch); + +/****************************************************************************** + * + * Function Name: uart0Space() + * + * Description: + * This function gets the available space in the transmit queue + * + * Calling Sequence: + * void + * + * Returns: + * available space in the transmit queue + * + *****************************************************************************/ +uint16_t uart0Space(void); + +/****************************************************************************** + * + * Function Name: uart0Puts() + * + * Description: + * This function writes a NULL terminated 'string' to the UART output + * queue, returning a pointer to the next character to be written. + * + * Calling Sequence: + * address of the string + * + * Returns: + * a pointer to the next character to be written + * (\0 if full string is written) + * + *****************************************************************************/ +const char *uart0Puts(const char *string); +// same but blocking when no space available (mthomas) +const char *uart0Puts_block(const char *string); + +/****************************************************************************** + * + * Function Name: uart0Write() + * + * Description: + * This function writes 'count' characters from 'buffer' to the UART + * output queue. + * + * Calling Sequence: + * + * + * Returns: + * 0 on success, -1 if insufficient room, -2 on error + * NOTE: if insufficient room, no characters are written. + * + *****************************************************************************/ +int uart0Write(const char *buffer, uint16_t count); + +/****************************************************************************** + * + * Function Name: uart0TxEmpty() + * + * Description: + * This function returns the status of the UART transmit data + * registers. + * + * Calling Sequence: + * void + * + * Returns: + * FALSE - either the tx holding or shift register is not empty + * !FALSE - if both the tx holding & shift registers are empty + * + *****************************************************************************/ +int uart0TxEmpty(void); + +/****************************************************************************** + * + * Function Name: uart0RxEmpty() + * + * Description: + * This function checks the imput buffers + * + * Calling Sequence: + * void + * + * Returns: + * FALSE - either the tx holding or shift register is not empty + * !FALSE - if both the tx holding & shift registers are empty + * + *****************************************************************************/ +int uart0RxEmpty(void); + + +/****************************************************************************** + * + * Function Name: uart0TxFlush() + * + * Description: + * This function removes all characters from the UART transmit queue + * (without transmitting them). + * + * Calling Sequence: + * void + * + * Returns: + * void + * + *****************************************************************************/ +void uart0TxFlush(void); + +/****************************************************************************** + * + * Function Name: uart0Getch() + * + * Description: + * This function gets a character from the UART receive queue + * + * Calling Sequence: + * void + * + * Returns: + * character on success, -1 if no character is available + * + *****************************************************************************/ +int uart0Getch(void); + +/****************************************************************************** + * + * Function Name: uart1Init() + * + * Description: + * This function initializes the UART for async mode + * + * Calling Sequence: + * baudrate divisor - use UART_BAUD macro + * mode - see typical modes (above) + * fmode - see typical fmodes (above) + * + * Returns: + * void + * + * NOTE: uart1Init(UART_BAUD(9600), UART_8N1, UART_FIFO_8); + * + *****************************************************************************/ +void uart1Init(uint16_t baud, uint8_t mode, uint8_t fmode); + +/****************************************************************************** + * + * Function Name: uart1Putch() + * + * Description: + * This function puts a character into the UART output queue for + * transmission. + * + * Calling Sequence: + * character to be transmitted + * + * Returns: + * ch on success, -1 on error (queue full) + * + *****************************************************************************/ +int uart1Putch(int ch); +// same but blocking when no space available (mthomas) +int uart1Putch_block(int ch); + +/****************************************************************************** + * + * Function Name: uart1Space() + * + * Description: + * This function gets the available space in the transmit queue + * + * Calling Sequence: + * void + * + * Returns: + * available space in the transmit queue + * + *****************************************************************************/ +uint16_t uart1Space(void); + +/****************************************************************************** + * + * Function Name: uart1Puts() + * + * Description: + * This function writes a NULL terminated 'string' to the UART output + * queue, returning a pointer to the next character to be written. + * + * Calling Sequence: + * address of the string + * + * Returns: + * a pointer to the next character to be written + * (\0 if full string is written) + * + *****************************************************************************/ +const char *uart1Puts(const char *string); +// same but blocking when no space available (mthomas) +const char *uart1Puts_block(const char *string); + +/****************************************************************************** + * + * Function Name: uart1Write() + * + * Description: + * This function writes 'count' characters from 'buffer' to the UART + * output queue. + * + * Calling Sequence: + * + * + * Returns: + * 0 on success, -1 if insufficient room, -2 on error + * NOTE: if insufficient room, no characters are written. + * + *****************************************************************************/ +int uart1Write(const char *buffer, uint16_t count); + +/****************************************************************************** + * + * Function Name: uart1TxEmpty() + * + * Description: + * This function returns the status of the UART transmit data + * registers. + * + * Calling Sequence: + * void + * + * Returns: + * FALSE - either the tx holding or shift register is not empty + * !FALSE - if both the tx holding & shift registers are empty + * + *****************************************************************************/ +int uart1TxEmpty(void); + +/****************************************************************************** + * + * Function Name: uart1RxEmpty() + * + * Description: + * This function checks the imput buffers + * + * Calling Sequence: + * void + * + * Returns: + * FALSE - either the tx holding or shift register is not empty + * !FALSE - if both the tx holding & shift registers are empty + * + *****************************************************************************/ +int uart1RxEmpty(void); + + +/****************************************************************************** + * + * Function Name: uart1TxFlush() + * + * Description: + * This function removes all characters from the UART transmit queue + * (without transmitting them). + * + * Calling Sequence: + * void + * + * Returns: + * void + * + *****************************************************************************/ +void uart1TxFlush(void); + +/****************************************************************************** + * + * Function Name: uart1Getch() + * + * Description: + * This function gets a character from the UART receive queue + * + * Calling Sequence: + * void + * + * Returns: + * character on success, -1 if no character is available + * + *****************************************************************************/ +int uart1Getch(void); + +#endif diff --git a/Tester/SW/lib/Drivers/uart2.c b/Tester/SW/lib/Drivers/uart2.c new file mode 100644 index 0000000..71ee8a6 --- /dev/null +++ b/Tester/SW/lib/Drivers/uart2.c @@ -0,0 +1,331 @@ +/****************************************************************************** + * + * $RCSfile: $ + * $Revision: $ + * + * This module provides interface routines to the LPC ARM UARTs. + * Copyright 2004, R O SoftWare + * No guarantees, warrantees, or promises, implied or otherwise. + * May be used for hobby or commercial purposes provided copyright + * notice remains intact. + * + * Modified by Martin Thomas for LPC23xx 24xx + *****************************************************************************/ +#include "app_types.h" +#include "LPC_REGS.h" +#include "sys_config.h" + +#include "uart2.h" + +#ifndef USHRT_MAX +#define USHRT_MAX 16 +#endif + +#include "armVIC.h" +#include "uart2ISR.h" + +#define U2_TX_PINSEL_REG PINSEL4 +#define U2_TX_PINSEL (2UL<<16) /* PINSEL4 Value for UART2 TX */ +#define U2_TX_PINMASK (3UL<<16) /* PINSEL4 Mask for UART2 RX */ +#define U2_RX_PINSEL_REG PINSEL4 +#define U2_RX_PINSEL (2UL<<18) /* PINSEL4 Value for UART2 TX */ +#define U2_RX_PINMASK (3UL<<18) /* PINSEL4 Mask for UART2 RX */ + +uint8_t uart2_rx_buffer[UART2_RX_BUFFER_SIZE]; +uint16_t uart2_rx_insert_idx, uart2_rx_extract_idx; +uint8_t uart2_tx_buffer[UART2_TX_BUFFER_SIZE]; +uint16_t uart2_tx_insert_idx, uart2_tx_extract_idx; +int uart2_tx_running; +t_uart2_txcomplete uart2_tx_complete_callback; + +void uart2TxFinished(void); + +void uart2Init(uint16_t baud, uint8_t mode, uint8_t fmode) +{ + PCONP |= BIT( 24 ); // power on UART2 + + // set port pins for UART2 + // mthomas PINSEL0 = (PINSEL0 & ~U0_PINMASK) | U0_PINSEL; + // set port pins for UART2 + // PINSEL0 = (PINSEL0 & ~U0_PINMASK) | U0_PINSEL; + U2_TX_PINSEL_REG = ( U2_TX_PINSEL_REG & ~U2_TX_PINMASK ) | U2_TX_PINSEL; + U2_RX_PINSEL_REG = ( U2_RX_PINSEL_REG & ~U2_RX_PINMASK ) | U2_RX_PINSEL; + + U2IER = 0x00; // disable all interrupts + U2IIR; // clear interrupt ID + U2RBR; // clear receive register + U2LSR; // clear line status register + + // Set CLOCK for UART2 device (4x) + //PCLKSEL1 = 0x00010000; + + // Set CLOCK for UART2 device (div 2) + PCLKSEL1 &= 0xFFFDFFFF; + PCLKSEL1 |= 0x00020000; + + // Preset callback function to none + uart2_tx_complete_callback = 0; + + // set the baudrate + U2LCR = ULCR_DLAB_ENABLE; // select divisor latches + U2DLL = (uint8_t)baud; // set for baud low byte + U2DLM = (uint8_t)(baud >> 8); // set for baud high byte + + // set the number of characters and other + // user specified operating parameters + U2LCR = (mode & ~ULCR_DLAB_ENABLE); + U2FCR = fmode; + + // initialize the interrupt vector + VICIntSelect &= ~VIC_CHAN_TO_MASK(VIC_CHAN_NUM_UART2); + VICIntEnClr = VIC_CHAN_TO_MASK(VIC_CHAN_NUM_UART2); + VICVectAddr28 = (uint32_t)uart2ISR; + VICVectPriority28 = 0xF; + VICIntEnable = VIC_CHAN_TO_MASK(VIC_CHAN_NUM_UART2); + + // initialize the transmit data queue + uart2_tx_extract_idx = uart2_tx_insert_idx = 0; + uart2_tx_running = 0; + + // initialize the receive data queue + uart2_rx_extract_idx = uart2_rx_insert_idx = 0; + + // enable receiver interrupts + U2IER = UIER_RBR; +} + +/****************************************************************************** + * + * Function Name: uart2Putch() + * + * Description: + * This function puts a character into the UART output queue for + * transmission. + * + * Calling Sequence: + * character to be transmitted + * + * Returns: + * ch on success, -1 on error (queue full) + * + *****************************************************************************/ +int uart2Putch(int ch) +{ + uint16_t temp; + unsigned cpsr; + + temp = (uart2_tx_insert_idx + 1) % UART2_TX_BUFFER_SIZE; + + if (temp == uart2_tx_extract_idx) + return -1; // no room + + cpsr = disableIRQ(); // disable global interrupts + U2IER &= ~UIER_THRE; // disable TX interrupts + restoreIRQ(cpsr); // restore global interrupts + + // check if in process of sending data + if (uart2_tx_running) + { + // add to queue + uart2_tx_buffer[uart2_tx_insert_idx] = (uint8_t)ch; + uart2_tx_insert_idx = temp; + } + else + { + // set running flag and write to output register + uart2_tx_running = 1; + U2THR = (uint8_t)ch; + } + + cpsr = disableIRQ(); // disable global interrupts + U2IER |= UIER_THRE; // enable TX interrupts + restoreIRQ(cpsr); // restore global interrupts + + return (uint8_t)ch; +} + +/****************************************************************************** + * + * Function Name: uart2Space() + * + * Description: + * This function gets the available space in the transmit queue + * + * Calling Sequence: + * void + * + * Returns: + * available space in the transmit queue + * + *****************************************************************************/ +uint16_t uart2Space(void) +{ + int space; + + if ((space = (uart2_tx_extract_idx - uart2_tx_insert_idx)) <= 0) + space += UART2_TX_BUFFER_SIZE; + + return (uint16_t)(space - 1); +} + +/****************************************************************************** + * + * Function Name: uart2Puts() + * + * Description: + * This function writes a NULL terminated 'string' to the UART output + * queue, returning a pointer to the next character to be written. + * + * Calling Sequence: + * address of the string + * + * Returns: + * a pointer to the next character to be written + * (\0 if full string is written) + * + *****************************************************************************/ +const char *uart2Puts(const char *string) +{ + register char ch; + + while ((ch = *string) && (uart2Putch(ch) >= 0)) + string++; + + return string; +} + +/****************************************************************************** + * + * Function Name: uart2Write() + * + * Description: + * This function writes 'count' characters from 'buffer' to the UART + * output queue. + * + * Calling Sequence: + * + * + * Returns: + * 0 on success, -1 if insufficient room, -2 on error + * NOTE: if insufficient room, no characters are written. + * + *****************************************************************************/ +int uart2Write(const char *buffer, uint16_t count) +{ + if (count > uart2Space()) + return -1; + + while (count && (uart2Putch(*buffer++) >= 0)) + count--; + + return (count ? -2 : 0); +} + +/****************************************************************************** + * + * Function Name: uart2TxEmpty() + * + * Description: + * This function returns the status of the UART transmit data + * registers. + * + * Calling Sequence: + * void + * + * Returns: + * FALSE - either the tx holding or shift register is not empty + * !FALSE - if both the tx holding & shift registers are empty + * + *****************************************************************************/ +int uart2TxEmpty(void) +{ + return (U2LSR & (ULSR_THRE | ULSR_TEMT)) == (ULSR_THRE | ULSR_TEMT); +} + +int uart2RxEmpty(void) +{ + if (uart2_rx_insert_idx == uart2_rx_extract_idx) // check if character is available + { + return 1; + } + else + { + return 0; + } +} + + +/****************************************************************************** + * + * Function Name: uart2TxFlush() + * + * Description: + * This function removes all characters from the UART transmit queue + * (without transmitting them). + * + * Calling Sequence: + * void + * + * Returns: + * void + * + *****************************************************************************/ +void uart2TxFlush(void) +{ + unsigned cpsr; + + U2FCR |= UFCR_TX_FIFO_RESET; // clear the TX fifo + + // "Empty" the transmit buffer. + cpsr = disableIRQ(); // disable global interrupts + U2IER &= ~UIER_THRE; // disable TX interrupts + restoreIRQ(cpsr); // restore global interrupts + uart2_tx_insert_idx = uart2_tx_extract_idx = 0; +} + +/****************************************************************************** + * + * Function Name: uart2Getch() + * + * Description: + * This function gets a character from the UART receive queue + * + * Calling Sequence: + * void + * + * Returns: + * character on success, -1 if no character is available + * + *****************************************************************************/ +int uart2Getch(void) +{ + uint8_t ch; + + if (uart2_rx_insert_idx == uart2_rx_extract_idx) // check if character is available + return -1; + + ch = uart2_rx_buffer[uart2_rx_extract_idx++]; // get character, bump pointer + uart2_rx_extract_idx %= UART2_RX_BUFFER_SIZE; // limit the pointer + return ch; +} + +void uart2SubscribeTxFinished( t_uart2_txcomplete callback ) +{ + uart2_tx_complete_callback = callback; +} + +void uart2UnsubsribeTxFinished( t_uart2_txcomplete callback ) +{ + uart2_tx_complete_callback = 0; +} + + +void uart2TxFinished(void) +{ + if (uart2_tx_complete_callback != 0) + { + uart2_tx_complete_callback(); + } +} + + diff --git a/Tester/SW/lib/Drivers/uart2.h b/Tester/SW/lib/Drivers/uart2.h new file mode 100644 index 0000000..e4089ae --- /dev/null +++ b/Tester/SW/lib/Drivers/uart2.h @@ -0,0 +1,77 @@ +/* --------------------------------------------------------------------------- + * uart2.h - v0.1 (c) 2007 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: UART2-driver + * --------------------------------------------------------------------------- + * Version(s): 0.1, 10-09-2007, Marcel Mulder. + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef __UART2_H__ +#define __UART2_H__ +/** \file uart2.h + \brief UART2 +*/ + +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ +#include "app_types.h" +#include "sys_config.h" +#include "LPC_REGS.h" +#include "uart.h" + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ +#define UART2_RX_BUFFER_SIZE 256 // UART2 receive buffer size org. 128 +#define UART2_TX_BUFFER_SIZE 256 // UART2 transmit buffer size + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ +typedef void (*t_uart2_txcomplete)(void); + + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ +void uart2Init(uint16_t baud, uint8_t mode, uint8_t fmode); +int uart2Putch(int ch); +int uart2Putch_block(int ch); +uint16_t uart2Space(void); +const char *uart2Puts(const char *string); +const char *uart2Puts_block(const char *string); +int uart2Write(const char *buffer, uint16_t count); +int uart2TxEmpty(void); +int uart2RxEmpty(void); +void uart2TxFlush(void); +int uart2Getch(void); +void uart2SubscribeTxFinished( t_uart2_txcomplete callback ); +void uart2UnsubsribeTxFinished( t_uart2_txcomplete callback ); + + +#endif /* __UART2_H__ */ diff --git a/Tester/SW/lib/Drivers/uart2ISR.c b/Tester/SW/lib/Drivers/uart2ISR.c new file mode 100644 index 0000000..4d1c4ed --- /dev/null +++ b/Tester/SW/lib/Drivers/uart2ISR.c @@ -0,0 +1,108 @@ +/****************************************************************************** + * + * $RCSfile: $ + * $Revision: $ + * + * This module implements the ISRs for the UARTs on the LPC ARMs. + * Copyright 2004, R O SoftWare + * No guarantees, warrantees, or promises, implied or otherwise. + * May be used for hobby or commercial purposes provided copyright + * notice remains intact. + * + * Modified by Martin Thomas for LPC23xx 24xx + *****************************************************************************/ +#include "app_types.h" +#include "LPC_REGS.h" + +#include "uart2.h" +#include "uart2ISR.h" +#include "armVIC.h" + +extern uint8_t uart2_rx_buffer[UART2_RX_BUFFER_SIZE]; +extern uint16_t uart2_rx_insert_idx, uart2_rx_extract_idx; +extern uint8_t uart2_tx_buffer[UART2_TX_BUFFER_SIZE]; +extern uint16_t uart2_tx_insert_idx, uart2_tx_extract_idx; +extern int uart2_tx_running; + +extern int uart2TxFinished(void); + +/****************************************************************************** + * + * Function Name: uart2ISR() + * + * Description: + * This function implements the ISR for UART2. + * + * Calling Sequence: + * void + * + * Returns: + * void + * + *****************************************************************************/ +void uart2ISR(void) +{ + uint8_t iid; + + // perform proper ISR entry so thumb-interwork works properly + ISR_ENTRY(); + + // loop until not more interrupt sources + while (((iid = U2IIR) & UIIR_NO_INT) == 0) + { + // identify & process the highest priority interrupt + switch (iid & UIIR_ID_MASK) + { + case UIIR_RLS_INT: // Receive Line Status + U2LSR; // read LSR to clear + break; + + case UIIR_CTI_INT: // Character Timeout Indicator + case UIIR_RDA_INT: // Receive Data Available + do + { + uint16_t temp; + + // calc next insert index & store character + temp = (uart2_rx_insert_idx + 1) % UART2_RX_BUFFER_SIZE; + uart2_rx_buffer[uart2_rx_insert_idx] = U2RBR; + + // check for more room in queue + if (temp != uart2_rx_extract_idx) + uart2_rx_insert_idx = temp; // update insert index + } + while (U2LSR & ULSR_RDR); + + break; + + case UIIR_THRE_INT: // Transmit Holding Register Empty + while (U2LSR & ULSR_THRE) + { + // check if more data to send + if (uart2_tx_insert_idx != uart2_tx_extract_idx) + { + U2THR = uart2_tx_buffer[uart2_tx_extract_idx++]; + uart2_tx_extract_idx %= UART2_TX_BUFFER_SIZE; + } + else + { + // All data is send (acknownledge this to bus driver) + uart2TxFinished(); + uart2_tx_running = 0; // clear running flag + break; + } + } + + break; + + default: // Unknown + U2LSR; + U2RBR; + break; + } + } + + VICVectAddr = 0x00000000; // clear this interrupt from the VIC + ISR_EXIT(); // recover registers and return +} + diff --git a/Tester/SW/lib/Drivers/uart2ISR.h b/Tester/SW/lib/Drivers/uart2ISR.h new file mode 100644 index 0000000..01ca178 --- /dev/null +++ b/Tester/SW/lib/Drivers/uart2ISR.h @@ -0,0 +1,20 @@ +/****************************************************************************** + * + * $RCSfile: $ + * $Revision: $ + * + * This module provides the interface definitions for uartISR.c + * Copyright 2004, R O SoftWare + * No guarantees, warrantees, or promises, implied or otherwise. + * May be used for hobby or commercial purposes provided copyright + * notice remains intact. + * + *****************************************************************************/ +#ifndef INC_UART2_ISR_H +#define INC_UART2_ISR_H + +#include "uart.h" + +void uart2ISR(void) __attribute__((naked)); + +#endif diff --git a/Tester/SW/lib/Drivers/uart3.c b/Tester/SW/lib/Drivers/uart3.c new file mode 100644 index 0000000..3df0990 --- /dev/null +++ b/Tester/SW/lib/Drivers/uart3.c @@ -0,0 +1,332 @@ +/****************************************************************************** + * + * $RCSfile: $ + * $Revision: $ + * + * This module provides interface routines to the LPC ARM UARTs. + * Copyright 2004, R O SoftWare + * No guarantees, warrantees, or promises, implied or otherwise. + * May be used for hobby or commercial purposes provided copyright + * notice remains intact. + * + * Modified by Martin Thomas for LPC23xx 24xx + *****************************************************************************/ +#include "app_types.h" +#include "LPC_REGS.h" +#include "sys_config.h" + +#include "uart3.h" + +#ifndef USHRT_MAX +#define USHRT_MAX 16 +#endif + +#include "armVIC.h" +#include "uart3ISR.h" + +#define U3_TX_PINSEL_REG PINSEL0 +#define U3_TX_PINSEL (2UL<<0) /* PINSEL4 Value for UART3 TX */ +#define U3_TX_PINMASK (3UL<<0) /* PINSEL4 Mask for UART3 RX */ +#define U3_RX_PINSEL_REG PINSEL0 +#define U3_RX_PINSEL (2UL<<2) /* PINSEL4 Value for UART3 TX */ +#define U3_RX_PINMASK (3UL<<2) /* PINSEL4 Mask for UART3 RX */ + +uint8_t uart3_rx_buffer[UART3_RX_BUFFER_SIZE]; +uint16_t uart3_rx_insert_idx, uart3_rx_extract_idx; +uint8_t uart3_tx_buffer[UART3_TX_BUFFER_SIZE]; +uint16_t uart3_tx_insert_idx, uart3_tx_extract_idx; +int uart3_tx_running; +t_uart3_txcomplete uart3_tx_complete_callback; + + +void uart3TxFinished(void); + +void uart3Init(uint16_t baud, uint8_t mode, uint8_t fmode) +{ + PCONP |= BIT( 25 ); // power on UART3 + + // set port pins for UART3 + // mthomas PINSEL0 = (PINSEL0 & ~U0_PINMASK) | U0_PINSEL; + // set port pins for UART3 + // PINSEL0 = (PINSEL0 & ~U0_PINMASK) | U0_PINSEL; + U3_TX_PINSEL_REG = ( U3_TX_PINSEL_REG & ~U3_TX_PINMASK ) | U3_TX_PINSEL; + U3_RX_PINSEL_REG = ( U3_RX_PINSEL_REG & ~U3_RX_PINMASK ) | U3_RX_PINSEL; + + U3IER = 0x00; // disable all interrupts + U3IIR; // clear interrupt ID + U3RBR; // clear receive register + U3LSR; // clear line status register + + // Set CLOCK for UART3 device (4x) + //PCLKSEL1 = 0x00040000; + + // Set CLOCK for UART3 device (4x) + PCLKSEL1 &= 0xFFF7FFFF; + PCLKSEL1 |= 0x00080000; + + // Preset callback function + uart3_tx_complete_callback = 0; + + // set the baudrate + U3LCR = ULCR_DLAB_ENABLE; // select divisor latches + U3DLL = (uint8_t)baud; // set for baud low byte + U3DLM = (uint8_t)(baud >> 8); // set for baud high byte + + // set the number of characters and other + // user specified operating parameters + U3LCR = (mode & ~ULCR_DLAB_ENABLE); + U3FCR = fmode; + + // initialize the interrupt vector + VICIntSelect &= ~VIC_CHAN_TO_MASK(VIC_CHAN_NUM_UART3); + VICIntEnClr = VIC_CHAN_TO_MASK(VIC_CHAN_NUM_UART3); + VICVectAddr29 = (uint32_t)uart3ISR; + VICVectPriority29 = 0xF; + VICIntEnable = VIC_CHAN_TO_MASK(VIC_CHAN_NUM_UART3); + + // initialize the transmit data queue + uart3_tx_extract_idx = uart3_tx_insert_idx = 0; + uart3_tx_running = 0; + + // initialize the receive data queue + uart3_rx_extract_idx = uart3_rx_insert_idx = 0; + + // enable receiver interrupts + U3IER = UIER_RBR; +} + +/****************************************************************************** + * + * Function Name: uart3Putch() + * + * Description: + * This function puts a character into the UART output queue for + * transmission. + * + * Calling Sequence: + * character to be transmitted + * + * Returns: + * ch on success, -1 on error (queue full) + * + *****************************************************************************/ +int uart3Putch(int ch) +{ + uint16_t temp; + unsigned cpsr; + + temp = (uart3_tx_insert_idx + 1) % UART3_TX_BUFFER_SIZE; + + if (temp == uart3_tx_extract_idx) + return -1; // no room + + cpsr = disableIRQ(); // disable global interrupts + U3IER &= ~UIER_THRE; // disable TX interrupts + restoreIRQ(cpsr); // restore global interrupts + + // check if in process of sending data + if (uart3_tx_running) + { + // add to queue + uart3_tx_buffer[uart3_tx_insert_idx] = (uint8_t)ch; + uart3_tx_insert_idx = temp; + } + else + { + // set running flag and write to output register + uart3_tx_running = 1; + U3THR = (uint8_t)ch; + } + + cpsr = disableIRQ(); // disable global interrupts + U3IER |= UIER_THRE; // enable TX interrupts + restoreIRQ(cpsr); // restore global interrupts + + return (uint8_t)ch; +} + +/****************************************************************************** + * + * Function Name: uart3Space() + * + * Description: + * This function gets the available space in the transmit queue + * + * Calling Sequence: + * void + * + * Returns: + * available space in the transmit queue + * + *****************************************************************************/ +uint16_t uart3Space(void) +{ + int space; + + if ((space = (uart3_tx_extract_idx - uart3_tx_insert_idx)) <= 0) + space += UART3_TX_BUFFER_SIZE; + + return (uint16_t)(space - 1); +} + +/****************************************************************************** + * + * Function Name: uart3Puts() + * + * Description: + * This function writes a NULL terminated 'string' to the UART output + * queue, returning a pointer to the next character to be written. + * + * Calling Sequence: + * address of the string + * + * Returns: + * a pointer to the next character to be written + * (\0 if full string is written) + * + *****************************************************************************/ +const char *uart3Puts(const char *string) +{ + register char ch; + + while ((ch = *string) && (uart3Putch(ch) >= 0)) + string++; + + return string; +} + +/****************************************************************************** + * + * Function Name: uart3Write() + * + * Description: + * This function writes 'count' characters from 'buffer' to the UART + * output queue. + * + * Calling Sequence: + * + * + * Returns: + * 0 on success, -1 if insufficient room, -2 on error + * NOTE: if insufficient room, no characters are written. + * + *****************************************************************************/ +int uart3Write(const char *buffer, uint16_t count) +{ + if (count > uart3Space()) + return -1; + + while (count && (uart3Putch(*buffer++) >= 0)) + count--; + + return (count ? -2 : 0); +} + +/****************************************************************************** + * + * Function Name: uart3TxEmpty() + * + * Description: + * This function returns the status of the UART transmit data + * registers. + * + * Calling Sequence: + * void + * + * Returns: + * FALSE - either the tx holding or shift register is not empty + * !FALSE - if both the tx holding & shift registers are empty + * + *****************************************************************************/ +int uart3TxEmpty(void) +{ + return (U3LSR & (ULSR_THRE | ULSR_TEMT)) == (ULSR_THRE | ULSR_TEMT); +} + + +int uart3RxEmpty(void) +{ + if (uart3_rx_insert_idx == uart3_rx_extract_idx) // check if character is available + { + return 1; + } + else + { + return 0; + } +} + +/****************************************************************************** + * + * Function Name: uart3TxFlush() + * + * Description: + * This function removes all characters from the UART transmit queue + * (without transmitting them). + * + * Calling Sequence: + * void + * + * Returns: + * void + * + *****************************************************************************/ +void uart3TxFlush(void) +{ + unsigned cpsr; + + U3FCR |= UFCR_TX_FIFO_RESET; // clear the TX fifo + + // "Empty" the transmit buffer. + cpsr = disableIRQ(); // disable global interrupts + U3IER &= ~UIER_THRE; // disable TX interrupts + restoreIRQ(cpsr); // restore global interrupts + uart3_tx_insert_idx = uart3_tx_extract_idx = 0; +} + +/****************************************************************************** + * + * Function Name: uart3Getch() + * + * Description: + * This function gets a character from the UART receive queue + * + * Calling Sequence: + * void + * + * Returns: + * character on success, -1 if no character is available + * + *****************************************************************************/ +int uart3Getch(void) +{ + uint8_t ch; + + if (uart3_rx_insert_idx == uart3_rx_extract_idx) // check if character is available + return -1; + + ch = uart3_rx_buffer[uart3_rx_extract_idx++]; // get character, bump pointer + uart3_rx_extract_idx %= UART3_RX_BUFFER_SIZE; // limit the pointer + return ch; +} + +void uart3SubscribeTxFinished( t_uart3_txcomplete callback ) +{ + uart3_tx_complete_callback = callback; +} + +void uart3UnsubsribeTxFinished( t_uart3_txcomplete callback ) +{ + uart3_tx_complete_callback = 0; +} + + +void uart3TxFinished(void) +{ + if (uart3_tx_complete_callback != 0) + { + uart3_tx_complete_callback(); + } +} + + diff --git a/Tester/SW/lib/Drivers/uart3.h b/Tester/SW/lib/Drivers/uart3.h new file mode 100644 index 0000000..063586e --- /dev/null +++ b/Tester/SW/lib/Drivers/uart3.h @@ -0,0 +1,76 @@ +/* --------------------------------------------------------------------------- + * uart3.h - v0.1 (c) 2007 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: UART3-driver + * --------------------------------------------------------------------------- + * Version(s): 0.1, 10-09-2007, Marcel Mulder. + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef __UART3_H__ +#define __UART3_H__ +/** \file uart3.h + \brief UART3 +*/ + +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ +#include "app_types.h" +#include "sys_config.h" +#include "LPC_REGS.h" +#include "uart.h" + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ +#define UART3_RX_BUFFER_SIZE 256 // UART3 receive buffer size +#define UART3_TX_BUFFER_SIZE 256 // UART3 transmit buffer size + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ +typedef void (*t_uart3_txcomplete)(void); + + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ +void uart3Init(uint16_t baud, uint8_t mode, uint8_t fmode); +int uart3Putch(int ch); +int uart3Putch_block(int ch); +uint16_t uart3Space(void); +const char *uart3Puts(const char *string); +const char *uart3Puts_block(const char *string); +int uart3Write(const char *buffer, uint16_t count); +int uart3TxEmpty(void); +int uart3RxEmpty(void); +void uart3TxFlush(void); +int uart3Getch(void); +void uart3SubscribeTxFinished( t_uart3_txcomplete callback ); +void uart3UnsubsribeTxFinished( t_uart3_txcomplete callback ); + +#endif /* __UART3_H__ */ diff --git a/Tester/SW/lib/Drivers/uart3ISR.c b/Tester/SW/lib/Drivers/uart3ISR.c new file mode 100644 index 0000000..46adf08 --- /dev/null +++ b/Tester/SW/lib/Drivers/uart3ISR.c @@ -0,0 +1,112 @@ +/****************************************************************************** + * + * $RCSfile: $ + * $Revision: $ + * + * This module implements the ISRs for the UARTs on the LPC ARMs. + * Copyright 2004, R O SoftWare + * No guarantees, warrantees, or promises, implied or otherwise. + * May be used for hobby or commercial purposes provided copyright + * notice remains intact. + * + * Modified by Martin Thomas for LPC23xx 24xx + *****************************************************************************/ +#include "app_types.h" +#include "LPC_REGS.h" + +#include "uart3.h" +#include "uart3ISR.h" +#include "armVIC.h" + +extern uint8_t uart3_rx_buffer[UART3_RX_BUFFER_SIZE]; +extern uint16_t uart3_rx_insert_idx, uart3_rx_extract_idx; +extern uint8_t uart3_tx_buffer[UART3_TX_BUFFER_SIZE]; +extern uint16_t uart3_tx_insert_idx, uart3_tx_extract_idx; +extern int uart3_tx_running; + +extern int uart3TxFinished(void); + +int uart3ReceivedCount = 0; + +/****************************************************************************** + * + * Function Name: uart3ISR() + * + * Description: + * This function implements the ISR for UART3. + * + * Calling Sequence: + * void + * + * Returns: + * void + * + *****************************************************************************/ +void uart3ISR(void) +{ + uint8_t iid; + + // perform proper ISR entry so thumb-interwork works properly + ISR_ENTRY(); + + // loop until not more interrupt sources + while (((iid = U3IIR) & UIIR_NO_INT) == 0) + { + // identify & process the highest priority interrupt + switch (iid & UIIR_ID_MASK) + { + case UIIR_RLS_INT: // Receive Line Status + U3LSR; // read LSR to clear + break; + + case UIIR_CTI_INT: // Character Timeout Indicator + case UIIR_RDA_INT: // Receive Data Available + do + { + uint16_t temp; + + uart3ReceivedCount++; + + // calc next insert index & store character + temp = (uart3_rx_insert_idx + 1) % UART3_RX_BUFFER_SIZE; + uart3_rx_buffer[uart3_rx_insert_idx] = U3RBR; + + // check for more room in queue + if (temp != uart3_rx_extract_idx) + uart3_rx_insert_idx = temp; // update insert index + } + while (U3LSR & ULSR_RDR); + + break; + + case UIIR_THRE_INT: // Transmit Holding Register Empty + while (U3LSR & ULSR_THRE) + { + // check if more data to send + if (uart3_tx_insert_idx != uart3_tx_extract_idx) + { + U3THR = uart3_tx_buffer[uart3_tx_extract_idx++]; + uart3_tx_extract_idx %= UART3_TX_BUFFER_SIZE; + } + else + { + // All data is send (acknownledge this to bus driver) + uart3TxFinished(); + uart3_tx_running = 0; // clear running flag + break; + } + } + + break; + + default: // Unknown + U3LSR; + U3RBR; + break; + } + } + + VICVectAddr = 0x00000000; // clear this interrupt from the VIC + ISR_EXIT(); // recover registers and return +} + diff --git a/Tester/SW/lib/Drivers/uart3ISR.h b/Tester/SW/lib/Drivers/uart3ISR.h new file mode 100644 index 0000000..c2bcb4c --- /dev/null +++ b/Tester/SW/lib/Drivers/uart3ISR.h @@ -0,0 +1,20 @@ +/****************************************************************************** + * + * $RCSfile: $ + * $Revision: $ + * + * This module provides the interface definitions for uartISR.c + * Copyright 2004, R O SoftWare + * No guarantees, warrantees, or promises, implied or otherwise. + * May be used for hobby or commercial purposes provided copyright + * notice remains intact. + * + *****************************************************************************/ +#ifndef INC_UART3_ISR_H +#define INC_UART3_ISR_H + +#include "uart.h" + +void uart3ISR(void) __attribute__((naked)); + +#endif diff --git a/Tester/SW/lib/Drivers/uartISR.c b/Tester/SW/lib/Drivers/uartISR.c new file mode 100644 index 0000000..953d5c2 --- /dev/null +++ b/Tester/SW/lib/Drivers/uartISR.c @@ -0,0 +1,194 @@ +/****************************************************************************** + * + * $RCSfile: $ + * $Revision: $ + * + * This module implements the ISRs for the UARTs on the LPC ARMs. + * Copyright 2004, R O SoftWare + * No guarantees, warrantees, or promises, implied or otherwise. + * May be used for hobby or commercial purposes provided copyright + * notice remains intact. + * + * Modified by Martin Thomas for LPC23xx 24xx + *****************************************************************************/ +#include "app_types.h" +#include "LPC_REGS.h" + +#include "uart.h" +#include "uartISR.h" +#include "armVIC.h" + +extern uint8_t uart0_rx_buffer[UART0_RX_BUFFER_SIZE]; +extern uint16_t uart0_rx_insert_idx, uart0_rx_extract_idx; +extern uint8_t uart0_tx_buffer[UART0_TX_BUFFER_SIZE]; +extern uint16_t uart0_tx_insert_idx, uart0_tx_extract_idx; +extern int uart0_tx_running; + +/****************************************************************************** + * + * Function Name: uart0ISR() + * + * Description: + * This function implements the ISR for UART0. + * + * Calling Sequence: + * void + * + * Returns: + * void + * + *****************************************************************************/ +void uart0ISR(void) +{ + uint8_t iid; + + // perform proper ISR entry so thumb-interwork works properly + ISR_ENTRY(); + + // loop until not more interrupt sources + while (((iid = U0IIR) & UIIR_NO_INT) == 0) + { + // identify & process the highest priority interrupt + switch (iid & UIIR_ID_MASK) + { + case UIIR_RLS_INT: // Receive Line Status + U0LSR; // read LSR to clear + break; + + case UIIR_CTI_INT: // Character Timeout Indicator + case UIIR_RDA_INT: // Receive Data Available + do + { + uint16_t temp; + + // calc next insert index & store character + temp = (uart0_rx_insert_idx + 1) % UART0_RX_BUFFER_SIZE; + uart0_rx_buffer[uart0_rx_insert_idx] = U0RBR; + + // check for more room in queue + if (temp != uart0_rx_extract_idx) + uart0_rx_insert_idx = temp; // update insert index + } + while (U0LSR & ULSR_RDR); + + break; + + case UIIR_THRE_INT: // Transmit Holding Register Empty + while (U0LSR & ULSR_THRE) + { + // check if more data to send + if (uart0_tx_insert_idx != uart0_tx_extract_idx) + { + U0THR = uart0_tx_buffer[uart0_tx_extract_idx++]; + uart0_tx_extract_idx %= UART0_TX_BUFFER_SIZE; + } + else + { + // no + uart0_tx_running = 0; // clear running flag + break; + } + } + + break; + + default: // Unknown + U0LSR; + U0RBR; + break; + } + } + + VICVectAddr = 0x00000000; // clear this interrupt from the VIC + ISR_EXIT(); // recover registers and return +} + + +extern uint8_t uart1_rx_buffer[UART1_RX_BUFFER_SIZE]; +extern uint16_t uart1_rx_insert_idx, uart1_rx_extract_idx; +extern uint8_t uart1_tx_buffer[UART1_TX_BUFFER_SIZE]; +extern uint16_t uart1_tx_insert_idx, uart1_tx_extract_idx; +extern int uart1_tx_running; + +/****************************************************************************** + * + * Function Name: uart1ISR() + * + * Description: + * This function implements the ISR for UART1. + * + * Calling Sequence: + * void + * + * Returns: + * void + * + *****************************************************************************/ +void uart1ISR(void) +{ + uint8_t iid; + + // perform proper ISR entry so thumb-interwork works properly + ISR_ENTRY(); + + // loop until not more interrupt sources + while (((iid = U1IIR) & UIIR_NO_INT) == 0) + { + // identify & process the highest priority interrupt + switch (iid & UIIR_ID_MASK) + { + case UIIR_RLS_INT: // Receive Line Status + U1LSR; // read LSR to clear + break; + + case UIIR_CTI_INT: // Character Timeout Indicator + case UIIR_RDA_INT: // Receive Data Available + do + { + uint16_t temp; + + // calc next insert index & store character + temp = (uart1_rx_insert_idx + 1) % UART1_RX_BUFFER_SIZE; + uart1_rx_buffer[uart1_rx_insert_idx] = U1RBR; + + // check for more room in queue + if (temp != uart1_rx_extract_idx) + uart1_rx_insert_idx = temp; // update insert index + } + while (U1LSR & ULSR_RDR); + + break; + case UIIR_THRE_INT: // Transmit Holding Register Empty + while (U1LSR & ULSR_THRE) + { + // check if more data to send + if (uart1_tx_insert_idx != uart1_tx_extract_idx) + { + U1THR = uart1_tx_buffer[uart1_tx_extract_idx++]; + uart1_tx_extract_idx %= UART1_TX_BUFFER_SIZE; + } + else + { + // no + uart1_tx_running = 0; // clear running flag + break; + } + } + + break; + + case UIIR_MS_INT: // MODEM Status + U1MSR; // read MSR to clear + break; + + default: // Unknown + U1LSR; + U1RBR; + U1MSR; + break; + } + } + + VICVectAddr = 0x00000000; // clear this interrupt from the VIC + ISR_EXIT(); // recover registers and return +} diff --git a/Tester/SW/lib/Drivers/uartISR.h b/Tester/SW/lib/Drivers/uartISR.h new file mode 100644 index 0000000..aa71897 --- /dev/null +++ b/Tester/SW/lib/Drivers/uartISR.h @@ -0,0 +1,21 @@ +/****************************************************************************** + * + * $RCSfile: $ + * $Revision: $ + * + * This module provides the interface definitions for uartISR.c + * Copyright 2004, R O SoftWare + * No guarantees, warrantees, or promises, implied or otherwise. + * May be used for hobby or commercial purposes provided copyright + * notice remains intact. + * + *****************************************************************************/ +#ifndef INC_UART_ISR_H +#define INC_UART_ISR_H + +#include "uart.h" + +void uart0ISR(void) __attribute__((naked)); +void uart1ISR(void) __attribute__((naked)); + +#endif diff --git a/Tester/SW/lib/Drivers/watchdog.c b/Tester/SW/lib/Drivers/watchdog.c new file mode 100644 index 0000000..8221a59 --- /dev/null +++ b/Tester/SW/lib/Drivers/watchdog.c @@ -0,0 +1,105 @@ +/* --------------------------------------------------------------------------- + * watchdog.c - v0.1 (c) 2007 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: Watchdog funcitonality + * --------------------------------------------------------------------------- + * Version(s): 0.1, 28-11-2007, fvds. + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "LPC23xx.h" +#include "types.h" +#include "watchdog.h" + +/* FreeRTOS includes */ +#include "FreeRTOS.h" + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ +#define WD_CLKSRC_APB (0x01) +#define WD_CLKSRC_IRC_OSC (0x00) +#define WD_EN (0x01) +#define WD_RESET (0x02) +#define WD_WTOF (0x04) + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ +static INT16 WtofStatus = -1; + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ + +/** \brief Enable the watchdog */ +void watchdogEnable( + UINT16 resetTime /**< Time in ms till watchdog will reset target when not fed in meantime */ + ) +{ + UINT32 prescaleFeedValue; + + // Make sure the WD_WTOF is stored + watchdogCausedReset(); + + // Internal RC oscilator runs on 4 Mhz, the prescale is calculated by: + // 1 resetTime + // ------------ * 4 * prescaleFeedValue = (-----------) (seconden) + // 4.000.000 1000 + // + // + prescaleFeedValue = resetTime * 1000; + WDTC = prescaleFeedValue; /* once WDEN is set, the WDT will start after feeding */ + WDMOD = WD_EN | WD_RESET; + + WDFEED = 0xAA; /* Feeding sequence */ + WDFEED = 0x55; +} + + +/** \brief Feed the watchdog in order to prevent a reset */ +void watchdogFeed() +{ + WDFEED = 0xAA; /* Feeding sequence */ + WDFEED = 0x55; +} + +BOOLEAN watchdogCausedReset() +{ + if ( WtofStatus < 0) + { + WtofStatus = ((WDMOD & WD_WTOF) == WD_WTOF ? 1 : 0); + + // Clear bit + WDMOD &= ~WD_WTOF; + } + + return (WtofStatus == 1 ? TRUE : FALSE); +} diff --git a/Tester/SW/lib/Drivers/watchdog.h b/Tester/SW/lib/Drivers/watchdog.h new file mode 100644 index 0000000..8ab7898 --- /dev/null +++ b/Tester/SW/lib/Drivers/watchdog.h @@ -0,0 +1,71 @@ +/* --------------------------------------------------------------------------- + * watchdog.h - v0.1 (c) 2007 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: Watchdog interface. + * --------------------------------------------------------------------------- + * Version(s): 0.1, 10-09-2007, Marcel Mulder. + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef __WATCHDOG_H__ +#define __WATCHDOG_H__ + +/** \file watchdog.h + \brief Watchdog functionality. + + Once the watchdog is enable, it cannot be disabled. +*/ + +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ +#include "lpc23xx.h" +#include "types.h" + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ +/** \brief Enable the watchdog */ +void watchdogEnable( + UINT16 resetTime /**< Time in ms till watchdog will reset target when not fed in meantime */ + ); + +/** \brief Feed the watchdog in order to prevent a reset */ +void watchdogFeed( void ); + +/** \brief Indicates whether the CPU is reset by the watchdog */ +BOOLEAN watchdogCausedReset(); + +#endif /* __WATCHDOG_H__ */ diff --git a/Tester/SW/lib/Drivers/webserver/EMAC_ISR.c b/Tester/SW/lib/Drivers/webserver/EMAC_ISR.c new file mode 100644 index 0000000..20561d4 --- /dev/null +++ b/Tester/SW/lib/Drivers/webserver/EMAC_ISR.c @@ -0,0 +1,45 @@ +#include "FreeRTOS.h" +#include "semphr.h" +#include "task.h" + +/* The interrupt entry point. */ +void vEMAC_ISR_Wrapper( void ) __attribute__((naked)); + +/* The handler that does the actual work. */ +void vEMAC_ISR_Handler( void ); + +extern xSemaphoreHandle xEMACSemaphore; + + +void vEMAC_ISR_Handler( void ) +{ +portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE; + + /* Clear the interrupt. */ + MAC_INTCLEAR = 0xffff; + VICVectAddr = 0; + + /* Ensure the uIP task is not blocked as data has arrived. */ + xSemaphoreGiveFromISR( xEMACSemaphore, &xHigherPriorityTaskWoken ); + + if( xHigherPriorityTaskWoken ) + { + /* Giving the semaphore woke a task. */ + portYIELD_FROM_ISR(); + } +} +/*-----------------------------------------------------------*/ + +void vEMAC_ISR_Wrapper( void ) +{ + /* Save the context of the interrupted task. */ + portSAVE_CONTEXT(); + + /* Call the handler. This must be a separate function unless you can + guarantee that no stack will be used. */ + vEMAC_ISR_Handler(); + + /* Restore the context of whichever task is going to run next. */ + portRESTORE_CONTEXT(); +} + diff --git a/Tester/SW/lib/Drivers/webserver/clock-arch.h b/Tester/SW/lib/Drivers/webserver/clock-arch.h new file mode 100644 index 0000000..cde657b --- /dev/null +++ b/Tester/SW/lib/Drivers/webserver/clock-arch.h @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2006, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of the uIP TCP/IP stack + * + * $Id: clock-arch.h,v 1.2 2006/06/12 08:00:31 adam Exp $ + */ + +#ifndef __CLOCK_ARCH_H__ +#define __CLOCK_ARCH_H__ + +#include "FreeRTOS.h" + +typedef unsigned long clock_time_t; +#define CLOCK_CONF_SECOND configTICK_RATE_HZ + +#endif /* __CLOCK_ARCH_H__ */ diff --git a/Tester/SW/lib/Drivers/webserver/emac.c b/Tester/SW/lib/Drivers/webserver/emac.c new file mode 100644 index 0000000..11225c7 --- /dev/null +++ b/Tester/SW/lib/Drivers/webserver/emac.c @@ -0,0 +1,413 @@ +/****************************************************************** + ***** ***** + ***** Name: cs8900.c ***** + ***** Ver.: 1.0 ***** + ***** Date: 07/05/2001 ***** + ***** Auth: Andreas Dannenberg ***** + ***** HTWK Leipzig ***** + ***** university of applied sciences ***** + ***** Germany ***** + ***** Func: ethernet packet-driver for use with LAN- ***** + ***** controller CS8900 from Crystal/Cirrus Logic ***** + ***** ***** + ***** Keil: Module modified for use with Philips ***** + ***** LPC2378 EMAC Ethernet controller ***** + ***** ***** + ******************************************************************/ + +/* Adapted from file originally written by Andreas Dannenberg. Supplied with permission. */ + +#include "FreeRTOS.h" +#include "semphr.h" +#include "task.h" +#include "emac.h" + +#include "FreeRTOSConfig.h" + +/* The semaphore used to wake the uIP task when data arives. */ +xSemaphoreHandle xEMACSemaphore = NULL; + +static unsigned short *rptr; +static unsigned short *tptr; + +// easyWEB internal function +// help function to swap the byte order of a WORD + +static unsigned short SwapBytes(unsigned short Data) +{ + return (Data >> 8) | (Data << 8); +} + +// Keil: function added to write PHY +void write_PHY (int PhyReg, int Value) +{ + unsigned int tout; + + MAC_MADR = DP83848C_DEF_ADR | PhyReg; + MAC_MWTD = Value; + + /* Wait utill operation completed */ + tout = 0; + for (tout = 0; tout < MII_WR_TOUT; tout++) { + if ((MAC_MIND & MIND_BUSY) == 0) { + break; + } + } +} + + +// Keil: function added to read PHY +unsigned short read_PHY (unsigned char PhyReg) +{ + unsigned int tout; + + MAC_MADR = DP83848C_DEF_ADR | PhyReg; + MAC_MCMD = MCMD_READ; + + /* Wait until operation completed */ + tout = 0; + for (tout = 0; tout < MII_RD_TOUT; tout++) { + if ((MAC_MIND & MIND_BUSY) == 0) { + break; + } + } + MAC_MCMD = 0; + return (MAC_MRDD); +} + + +// Keil: function added to initialize Rx Descriptors +void rx_descr_init (void) +{ + unsigned int i; + + for (i = 0; i < NUM_RX_FRAG; i++) { + RX_DESC_PACKET(i) = RX_BUF(i); + RX_DESC_CTRL(i) = RCTRL_INT | (ETH_FRAG_SIZE-1); + RX_STAT_INFO(i) = 0; + RX_STAT_HASHCRC(i) = 0; + } + + /* Set EMAC Receive Descriptor Registers. */ + MAC_RXDESCRIPTOR = RX_DESC_BASE; + MAC_RXSTATUS = RX_STAT_BASE; + MAC_RXDESCRIPTORNUM = NUM_RX_FRAG-1; + + /* Rx Descriptors Point to 0 */ + MAC_RXCONSUMEINDEX = 0; +} + + +// Keil: function added to initialize Tx Descriptors +void tx_descr_init (void) { + unsigned int i; + + for (i = 0; i < NUM_TX_FRAG; i++) { + TX_DESC_PACKET(i) = TX_BUF(i); + TX_DESC_CTRL(i) = 0; + TX_STAT_INFO(i) = 0; + } + + /* Set EMAC Transmit Descriptor Registers. */ + MAC_TXDESCRIPTOR = TX_DESC_BASE; + MAC_TXSTATUS = TX_STAT_BASE; + MAC_TXDESCRIPTORNUM = NUM_TX_FRAG-1; + + /* Tx Descriptors Point to 0 */ + MAC_TXPRODUCEINDEX = 0; +} + + +// configure port-pins for use with LAN-controller, +// reset it and send the configuration-sequence + +portBASE_TYPE Init_EMAC(void) +{ +portBASE_TYPE xReturn = pdPASS; + +// Keil: function modified to access the EMAC +// Initializes the EMAC ethernet controller + volatile unsigned int regv,tout,id1,id2; + + /* Enable P1 Ethernet Pins. */ + PINSEL2 = configPINSEL2_VALUE; + PINSEL3 = (PINSEL3 & ~0x0000000F) | 0x00000005; + + /* Power Up the EMAC controller. */ + PCONP |= 0x40000000; + vTaskDelay( 1 ); + + /* Reset all EMAC internal modules. */ + MAC_MAC1 = MAC1_RES_TX | MAC1_RES_MCS_TX | MAC1_RES_RX | MAC1_RES_MCS_RX | MAC1_SIM_RES | MAC1_SOFT_RES; + MAC_COMMAND = CR_REG_RES | CR_TX_RES | CR_RX_RES; + + /* A short delay after reset. */ + vTaskDelay( 1 ); + + /* Initialize MAC control registers. */ + MAC_MAC1 = MAC1_PASS_ALL; + MAC_MAC2 = MAC2_CRC_EN | MAC2_PAD_EN; + MAC_MAXF = ETH_MAX_FLEN; + MAC_CLRT = CLRT_DEF; + MAC_IPGR = IPGR_DEF; + + /* Enable Reduced MII interface. */ + MAC_COMMAND = CR_RMII | CR_PASS_RUNT_FRM; + + /* Reset Reduced MII Logic. */ + MAC_SUPP = SUPP_RES_RMII; + MAC_SUPP = 0; + + /* Put the DP83848C in reset mode */ + write_PHY (PHY_REG_BMCR, 0x8000); + write_PHY (PHY_REG_BMCR, 0x8000); + + /* Wait for hardware reset to end. */ + for (tout = 0; tout < 100; tout++) { + vTaskDelay( 10 ); + regv = read_PHY (PHY_REG_BMCR); + if (!(regv & 0x8000)) { + /* Reset complete */ + break; + } + } + + /* Check if this is a DP83848C PHY. */ + id1 = read_PHY (PHY_REG_IDR1); + id2 = read_PHY (PHY_REG_IDR2); + if (((id1 << 16) | (id2 & 0xFFF0)) == DP83848C_ID) { + /* Configure the PHY device */ + + /* Use autonegotiation about the link speed. */ + write_PHY (PHY_REG_BMCR, PHY_AUTO_NEG); + /* Wait to complete Auto_Negotiation. */ + for (tout = 0; tout < 10; tout++) { + vTaskDelay( 100 ); + regv = read_PHY (PHY_REG_BMSR); + if (regv & 0x0020) { + /* Autonegotiation Complete. */ + break; + } + } + } + else + { + xReturn = pdFAIL; + } + + /* Check the link status. */ + if( xReturn == pdPASS ) + { + xReturn = pdFAIL; + for (tout = 0; tout < 10; tout++) { + vTaskDelay( 100 ); + regv = read_PHY (PHY_REG_STS); + if (regv & 0x0001) { + /* Link is on. */ + xReturn = pdPASS; + break; + } + } + } + + if( xReturn == pdPASS ) + { + /* Configure Full/Half Duplex mode. */ + if (regv & 0x0004) { + /* Full duplex is enabled. */ + MAC_MAC2 |= MAC2_FULL_DUP; + MAC_COMMAND |= CR_FULL_DUP; + MAC_IPGT = IPGT_FULL_DUP; + } + else { + /* Half duplex mode. */ + MAC_IPGT = IPGT_HALF_DUP; + } + + /* Configure 100MBit/10MBit mode. */ + if (regv & 0x0002) { + /* 10MBit mode. */ + MAC_SUPP = 0; + } + else { + /* 100MBit mode. */ + MAC_SUPP = SUPP_SPEED; + } + + /* Set the Ethernet MAC Address registers */ + MAC_SA0 = (emacETHADDR0 << 8) | emacETHADDR1; + MAC_SA1 = (emacETHADDR2 << 8) | emacETHADDR3; + MAC_SA2 = (emacETHADDR4 << 8) | emacETHADDR5; + + /* Initialize Tx and Rx DMA Descriptors */ + rx_descr_init (); + tx_descr_init (); + + /* Receive Broadcast and Perfect Match Packets */ + MAC_RXFILTERCTRL = RFC_UCAST_EN | RFC_BCAST_EN | RFC_PERFECT_EN; + + /* Create the semaphore used ot wake the uIP task. */ + vSemaphoreCreateBinary( xEMACSemaphore ); + + /* Reset all interrupts */ + MAC_INTCLEAR = 0xFFFF; + + /* Enable receive and transmit mode of MAC Ethernet core */ + MAC_COMMAND |= (CR_RX_EN | CR_TX_EN); + MAC_MAC1 |= MAC1_REC_EN; + } + + return xReturn; +} + + +// reads a word in little-endian byte order from RX_BUFFER + +unsigned short ReadFrame_EMAC(void) +{ + return (*rptr++); +} + +// reads a word in big-endian byte order from RX_FRAME_PORT +// (useful to avoid permanent byte-swapping while reading +// TCP/IP-data) + +unsigned short ReadFrameBE_EMAC(void) +{ + unsigned short ReturnValue; + + ReturnValue = SwapBytes (*rptr++); + return (ReturnValue); +} + + +// copies bytes from frame port to MCU-memory +// NOTES: * an odd number of byte may only be transfered +// if the frame is read to the end! +// * MCU-memory MUST start at word-boundary + +void CopyFromFrame_EMAC(void *Dest, unsigned short Size) +{ + unsigned short * piDest; // Keil: Pointer added to correct expression + + piDest = Dest; // Keil: Line added + while (Size > 1) { + *piDest++ = ReadFrame_EMAC(); + Size -= 2; + } + + if (Size) { // check for leftover byte... + *(unsigned char *)piDest = (char)ReadFrame_EMAC();// the LAN-Controller will return 0 + } // for the highbyte +} + +// does a dummy read on frame-I/O-port +// NOTE: only an even number of bytes is read! + +void DummyReadFrame_EMAC(unsigned short Size) // discards an EVEN number of bytes +{ // from RX-fifo + while (Size > 1) { + ReadFrame_EMAC(); + Size -= 2; + } +} + +// Reads the length of the received ethernet frame and checks if the +// destination address is a broadcast message or not +// returns the frame length +unsigned short StartReadFrame(void) { + unsigned short RxLen; + unsigned int idx; + + idx = MAC_RXCONSUMEINDEX; + RxLen = (RX_STAT_INFO(idx) & RINFO_SIZE) - 3; + rptr = (unsigned short *)RX_DESC_PACKET(idx); + return(RxLen); +} + +void EndReadFrame(void) { + unsigned int idx; + + /* DMA free packet. */ + idx = MAC_RXCONSUMEINDEX; + + if (++idx == NUM_RX_FRAG) + idx = 0; + + MAC_RXCONSUMEINDEX = idx; +} + +unsigned int CheckFrameReceived(void) { // Packet received ? + + if (MAC_RXPRODUCEINDEX != MAC_RXCONSUMEINDEX) // more packets received ? + return(1); + else + return(0); +} + +unsigned int uiGetEMACRxData( unsigned char *ucBuffer ) +{ +unsigned int uiLen = 0; + + if( MAC_RXPRODUCEINDEX != MAC_RXCONSUMEINDEX ) + { + uiLen = StartReadFrame(); + CopyFromFrame_EMAC( ucBuffer, uiLen ); + EndReadFrame(); + } + + return uiLen; +} + +// requests space in EMAC memory for storing an outgoing frame + +void RequestSend(void) +{ + unsigned int idx; + + idx = MAC_TXPRODUCEINDEX; + tptr = (unsigned short *)TX_DESC_PACKET(idx); +} + +// check if ethernet controller is ready to accept the +// frame we want to send + +unsigned int Rdy4Tx(void) +{ + return (1); // the ethernet controller transmits much faster +} // than the CPU can load its buffers + + +// writes a word in little-endian byte order to TX_BUFFER +void WriteFrame_EMAC(unsigned short Data) +{ + *tptr++ = Data; +} + +// copies bytes from MCU-memory to frame port +// NOTES: * an odd number of byte may only be transfered +// if the frame is written to the end! +// * MCU-memory MUST start at word-boundary + +void CopyToFrame_EMAC(void *Source, unsigned int Size) +{ + unsigned short * piSource; + + piSource = Source; + Size = (Size + 1) & 0xFFFE; // round Size up to next even number + while (Size > 0) { + WriteFrame_EMAC(*piSource++); + Size -= 2; + } +} + +void DoSend_EMAC(unsigned short FrameSize) +{ + unsigned int idx; + + idx = MAC_TXPRODUCEINDEX; + TX_DESC_CTRL(idx) = FrameSize | TCTRL_LAST; + if (++idx == NUM_TX_FRAG) idx = 0; + MAC_TXPRODUCEINDEX = idx; +} + diff --git a/Tester/SW/lib/Drivers/webserver/emac.h b/Tester/SW/lib/Drivers/webserver/emac.h new file mode 100644 index 0000000..c363421 --- /dev/null +++ b/Tester/SW/lib/Drivers/webserver/emac.h @@ -0,0 +1,322 @@ +/*---------------------------------------------------------------------------- + * LPC2378 Ethernet Definitions + *---------------------------------------------------------------------------- + * Name: EMAC.H + * Purpose: Philips LPC2378 EMAC hardware definitions + *---------------------------------------------------------------------------- + * Copyright (c) 2006 KEIL - An ARM Company. All rights reserved. + *---------------------------------------------------------------------------*/ +#ifndef __EMAC_H +#define __EMAC_H + +/* MAC address definition. The MAC address must be unique on the network. */ +#define emacETHADDR0 0 +#define emacETHADDR1 0xbd +#define emacETHADDR2 0x33 +#define emacETHADDR3 0x02 +#define emacETHADDR4 0x64 +#define emacETHADDR5 0x24 + + +/* EMAC Memory Buffer configuration for 16K Ethernet RAM. */ +#define NUM_RX_FRAG 4 /* Num.of RX Fragments 4*1536= 6.0kB */ +#define NUM_TX_FRAG 2 /* Num.of TX Fragments 2*1536= 3.0kB */ +#define ETH_FRAG_SIZE 1536 /* Packet Fragment size 1536 Bytes */ + +#define ETH_MAX_FLEN 1536 /* Max. Ethernet Frame Size */ + +/* EMAC variables located in 16K Ethernet SRAM */ +#define RX_DESC_BASE 0x7FE00000 +#define RX_STAT_BASE (RX_DESC_BASE + NUM_RX_FRAG*8) +#define TX_DESC_BASE (RX_STAT_BASE + NUM_RX_FRAG*8) +#define TX_STAT_BASE (TX_DESC_BASE + NUM_TX_FRAG*8) +#define RX_BUF_BASE (TX_STAT_BASE + NUM_TX_FRAG*4) +#define TX_BUF_BASE (RX_BUF_BASE + NUM_RX_FRAG*ETH_FRAG_SIZE) + +/* RX and TX descriptor and status definitions. */ +#define RX_DESC_PACKET(i) (*(unsigned int *)(RX_DESC_BASE + 8*i)) +#define RX_DESC_CTRL(i) (*(unsigned int *)(RX_DESC_BASE+4 + 8*i)) +#define RX_STAT_INFO(i) (*(unsigned int *)(RX_STAT_BASE + 8*i)) +#define RX_STAT_HASHCRC(i) (*(unsigned int *)(RX_STAT_BASE+4 + 8*i)) +#define TX_DESC_PACKET(i) (*(unsigned int *)(TX_DESC_BASE + 8*i)) +#define TX_DESC_CTRL(i) (*(unsigned int *)(TX_DESC_BASE+4 + 8*i)) +#define TX_STAT_INFO(i) (*(unsigned int *)(TX_STAT_BASE + 4*i)) +#define RX_BUF(i) (RX_BUF_BASE + ETH_FRAG_SIZE*i) +#define TX_BUF(i) (TX_BUF_BASE + ETH_FRAG_SIZE*i) + +/* MAC Configuration Register 1 */ +#define MAC1_REC_EN 0x00000001 /* Receive Enable */ +#define MAC1_PASS_ALL 0x00000002 /* Pass All Receive Frames */ +#define MAC1_RX_FLOWC 0x00000004 /* RX Flow Control */ +#define MAC1_TX_FLOWC 0x00000008 /* TX Flow Control */ +#define MAC1_LOOPB 0x00000010 /* Loop Back Mode */ +#define MAC1_RES_TX 0x00000100 /* Reset TX Logic */ +#define MAC1_RES_MCS_TX 0x00000200 /* Reset MAC TX Control Sublayer */ +#define MAC1_RES_RX 0x00000400 /* Reset RX Logic */ +#define MAC1_RES_MCS_RX 0x00000800 /* Reset MAC RX Control Sublayer */ +#define MAC1_SIM_RES 0x00004000 /* Simulation Reset */ +#define MAC1_SOFT_RES 0x00008000 /* Soft Reset MAC */ + +/* MAC Configuration Register 2 */ +#define MAC2_FULL_DUP 0x00000001 /* Full Duplex Mode */ +#define MAC2_FRM_LEN_CHK 0x00000002 /* Frame Length Checking */ +#define MAC2_HUGE_FRM_EN 0x00000004 /* Huge Frame Enable */ +#define MAC2_DLY_CRC 0x00000008 /* Delayed CRC Mode */ +#define MAC2_CRC_EN 0x00000010 /* Append CRC to every Frame */ +#define MAC2_PAD_EN 0x00000020 /* Pad all Short Frames */ +#define MAC2_VLAN_PAD_EN 0x00000040 /* VLAN Pad Enable */ +#define MAC2_ADET_PAD_EN 0x00000080 /* Auto Detect Pad Enable */ +#define MAC2_PPREAM_ENF 0x00000100 /* Pure Preamble Enforcement */ +#define MAC2_LPREAM_ENF 0x00000200 /* Long Preamble Enforcement */ +#undef MAC2_NO_BACKOFF /* Remove compiler warning. */ +#define MAC2_NO_BACKOFF 0x00001000 /* No Backoff Algorithm */ +#define MAC2_BACK_PRESSURE 0x00002000 /* Backoff Presurre / No Backoff */ +#define MAC2_EXCESS_DEF 0x00004000 /* Excess Defer */ + +/* Back-to-Back Inter-Packet-Gap Register */ +#define IPGT_FULL_DUP 0x00000015 /* Recommended value for Full Duplex */ +#define IPGT_HALF_DUP 0x00000012 /* Recommended value for Half Duplex */ + +/* Non Back-to-Back Inter-Packet-Gap Register */ +#define IPGR_DEF 0x00000012 /* Recommended value */ + +/* Collision Window/Retry Register */ +#define CLRT_DEF 0x0000370F /* Default value */ + +/* PHY Support Register */ +#undef SUPP_SPEED /* Remove compiler warning. */ +#define SUPP_SPEED 0x00000100 /* Reduced MII Logic Current Speed */ +#define SUPP_RES_RMII 0x00000800 /* Reset Reduced MII Logic */ + +/* Test Register */ +#define TEST_SHCUT_PQUANTA 0x00000001 /* Shortcut Pause Quanta */ +#define TEST_TST_PAUSE 0x00000002 /* Test Pause */ +#define TEST_TST_BACKP 0x00000004 /* Test Back Pressure */ + +/* MII Management Configuration Register */ +#define MCFG_SCAN_INC 0x00000001 /* Scan Increment PHY Address */ +#define MCFG_SUPP_PREAM 0x00000002 /* Suppress Preamble */ +#define MCFG_CLK_SEL 0x0000001C /* Clock Select Mask */ +#define MCFG_RES_MII 0x00008000 /* Reset MII Management Hardware */ + +/* MII Management Command Register */ +#undef MCMD_READ /* Remove compiler warning. */ +#define MCMD_READ 0x00000001 /* MII Read */ +#undef MCMD_SCAN /* Remove compiler warning. */ +#define MCMD_SCAN 0x00000002 /* MII Scan continuously */ + +#define MII_WR_TOUT 0x00050000 /* MII Write timeout count */ +#define MII_RD_TOUT 0x00050000 /* MII Read timeout count */ + +/* MII Management Address Register */ +#define MADR_REG_ADR 0x0000001F /* MII Register Address Mask */ +#define MADR_PHY_ADR 0x00001F00 /* PHY Address Mask */ + +/* MII Management Indicators Register */ +#undef MIND_BUSY /* Remove compiler warning. */ +#define MIND_BUSY 0x00000001 /* MII is Busy */ +#define MIND_SCAN 0x00000002 /* MII Scanning in Progress */ +#define MIND_NOT_VAL 0x00000004 /* MII Read Data not valid */ +#define MIND_MII_LINK_FAIL 0x00000008 /* MII Link Failed */ + +/* Command Register */ +#define CR_RX_EN 0x00000001 /* Enable Receive */ +#define CR_TX_EN 0x00000002 /* Enable Transmit */ +#define CR_REG_RES 0x00000008 /* Reset Host Registers */ +#define CR_TX_RES 0x00000010 /* Reset Transmit Datapath */ +#define CR_RX_RES 0x00000020 /* Reset Receive Datapath */ +#define CR_PASS_RUNT_FRM 0x00000040 /* Pass Runt Frames */ +#define CR_PASS_RX_FILT 0x00000080 /* Pass RX Filter */ +#define CR_TX_FLOW_CTRL 0x00000100 /* TX Flow Control */ +#define CR_RMII 0x00000200 /* Reduced MII Interface */ +#define CR_FULL_DUP 0x00000400 /* Full Duplex */ + +/* Status Register */ +#define SR_RX_EN 0x00000001 /* Enable Receive */ +#define SR_TX_EN 0x00000002 /* Enable Transmit */ + +/* Transmit Status Vector 0 Register */ +#define TSV0_CRC_ERR 0x00000001 /* CRC error */ +#define TSV0_LEN_CHKERR 0x00000002 /* Length Check Error */ +#define TSV0_LEN_OUTRNG 0x00000004 /* Length Out of Range */ +#define TSV0_DONE 0x00000008 /* Tramsmission Completed */ +#define TSV0_MCAST 0x00000010 /* Multicast Destination */ +#define TSV0_BCAST 0x00000020 /* Broadcast Destination */ +#define TSV0_PKT_DEFER 0x00000040 /* Packet Deferred */ +#define TSV0_EXC_DEFER 0x00000080 /* Excessive Packet Deferral */ +#define TSV0_EXC_COLL 0x00000100 /* Excessive Collision */ +#define TSV0_LATE_COLL 0x00000200 /* Late Collision Occured */ +#define TSV0_GIANT 0x00000400 /* Giant Frame */ +#define TSV0_UNDERRUN 0x00000800 /* Buffer Underrun */ +#define TSV0_BYTES 0x0FFFF000 /* Total Bytes Transferred */ +#define TSV0_CTRL_FRAME 0x10000000 /* Control Frame */ +#define TSV0_PAUSE 0x20000000 /* Pause Frame */ +#define TSV0_BACK_PRESS 0x40000000 /* Backpressure Method Applied */ +#define TSV0_VLAN 0x80000000 /* VLAN Frame */ + +/* Transmit Status Vector 1 Register */ +#define TSV1_BYTE_CNT 0x0000FFFF /* Transmit Byte Count */ +#define TSV1_COLL_CNT 0x000F0000 /* Transmit Collision Count */ + +/* Receive Status Vector Register */ +#define RSV_BYTE_CNT 0x0000FFFF /* Receive Byte Count */ +#define RSV_PKT_IGNORED 0x00010000 /* Packet Previously Ignored */ +#define RSV_RXDV_SEEN 0x00020000 /* RXDV Event Previously Seen */ +#define RSV_CARR_SEEN 0x00040000 /* Carrier Event Previously Seen */ +#define RSV_REC_CODEV 0x00080000 /* Receive Code Violation */ +#define RSV_CRC_ERR 0x00100000 /* CRC Error */ +#define RSV_LEN_CHKERR 0x00200000 /* Length Check Error */ +#define RSV_LEN_OUTRNG 0x00400000 /* Length Out of Range */ +#define RSV_REC_OK 0x00800000 /* Frame Received OK */ +#define RSV_MCAST 0x01000000 /* Multicast Frame */ +#define RSV_BCAST 0x02000000 /* Broadcast Frame */ +#define RSV_DRIB_NIBB 0x04000000 /* Dribble Nibble */ +#define RSV_CTRL_FRAME 0x08000000 /* Control Frame */ +#define RSV_PAUSE 0x10000000 /* Pause Frame */ +#define RSV_UNSUPP_OPC 0x20000000 /* Unsupported Opcode */ +#define RSV_VLAN 0x40000000 /* VLAN Frame */ + +/* Flow Control Counter Register */ +#define FCC_MIRR_CNT 0x0000FFFF /* Mirror Counter */ +#define FCC_PAUSE_TIM 0xFFFF0000 /* Pause Timer */ + +/* Flow Control Status Register */ +#define FCS_MIRR_CNT 0x0000FFFF /* Mirror Counter Current */ + +/* Receive Filter Control Register */ +#define RFC_UCAST_EN 0x00000001 /* Accept Unicast Frames Enable */ +#define RFC_BCAST_EN 0x00000002 /* Accept Broadcast Frames Enable */ +#define RFC_MCAST_EN 0x00000004 /* Accept Multicast Frames Enable */ +#define RFC_UCAST_HASH_EN 0x00000008 /* Accept Unicast Hash Filter Frames */ +#define RFC_MCAST_HASH_EN 0x00000010 /* Accept Multicast Hash Filter Fram.*/ +#define RFC_PERFECT_EN 0x00000020 /* Accept Perfect Match Enable */ +#define RFC_MAGP_WOL_EN 0x00001000 /* Magic Packet Filter WoL Enable */ +#define RFC_PFILT_WOL_EN 0x00002000 /* Perfect Filter WoL Enable */ + +/* Receive Filter WoL Status/Clear Registers */ +#define WOL_UCAST 0x00000001 /* Unicast Frame caused WoL */ +#define WOL_BCAST 0x00000002 /* Broadcast Frame caused WoL */ +#define WOL_MCAST 0x00000004 /* Multicast Frame caused WoL */ +#define WOL_UCAST_HASH 0x00000008 /* Unicast Hash Filter Frame WoL */ +#define WOL_MCAST_HASH 0x00000010 /* Multicast Hash Filter Frame WoL */ +#define WOL_PERFECT 0x00000020 /* Perfect Filter WoL */ +#define WOL_RX_FILTER 0x00000080 /* RX Filter caused WoL */ +#define WOL_MAG_PACKET 0x00000100 /* Magic Packet Filter caused WoL */ + +/* Interrupt Status/Enable/Clear/Set Registers */ +#define INT_RX_OVERRUN 0x00000001 /* Overrun Error in RX Queue */ +#define INT_RX_ERR 0x00000002 /* Receive Error */ +#define INT_RX_FIN 0x00000004 /* RX Finished Process Descriptors */ +#define INT_RX_DONE 0x00000008 /* Receive Done */ +#define INT_TX_UNDERRUN 0x00000010 /* Transmit Underrun */ +#define INT_TX_ERR 0x00000020 /* Transmit Error */ +#define INT_TX_FIN 0x00000040 /* TX Finished Process Descriptors */ +#define INT_TX_DONE 0x00000080 /* Transmit Done */ +#define INT_SOFT_INT 0x00001000 /* Software Triggered Interrupt */ +#define INT_WAKEUP 0x00002000 /* Wakeup Event Interrupt */ + +/* Power Down Register */ +#define PD_POWER_DOWN 0x80000000 /* Power Down MAC */ + +/* RX Descriptor Control Word */ +#define RCTRL_SIZE 0x000007FF /* Buffer size mask */ +#define RCTRL_INT 0x80000000 /* Generate RxDone Interrupt */ + +/* RX Status Hash CRC Word */ +#define RHASH_SA 0x000001FF /* Hash CRC for Source Address */ +#define RHASH_DA 0x001FF000 /* Hash CRC for Destination Address */ + +/* RX Status Information Word */ +#define RINFO_SIZE 0x000007FF /* Data size in bytes */ +#define RINFO_CTRL_FRAME 0x00040000 /* Control Frame */ +#define RINFO_VLAN 0x00080000 /* VLAN Frame */ +#define RINFO_FAIL_FILT 0x00100000 /* RX Filter Failed */ +#define RINFO_MCAST 0x00200000 /* Multicast Frame */ +#define RINFO_BCAST 0x00400000 /* Broadcast Frame */ +#define RINFO_CRC_ERR 0x00800000 /* CRC Error in Frame */ +#define RINFO_SYM_ERR 0x01000000 /* Symbol Error from PHY */ +#define RINFO_LEN_ERR 0x02000000 /* Length Error */ +#define RINFO_RANGE_ERR 0x04000000 /* Range Error (exceeded max. size) */ +#define RINFO_ALIGN_ERR 0x08000000 /* Alignment Error */ +#define RINFO_OVERRUN 0x10000000 /* Receive overrun */ +#define RINFO_NO_DESCR 0x20000000 /* No new Descriptor available */ +#define RINFO_LAST_FLAG 0x40000000 /* Last Fragment in Frame */ +#define RINFO_ERR 0x80000000 /* Error Occured (OR of all errors) */ + +#define RINFO_ERR_MASK (RINFO_FAIL_FILT | RINFO_CRC_ERR | RINFO_SYM_ERR | \ + RINFO_LEN_ERR | RINFO_ALIGN_ERR | RINFO_OVERRUN) + +/* TX Descriptor Control Word */ +#define TCTRL_SIZE 0x000007FF /* Size of data buffer in bytes */ +#define TCTRL_OVERRIDE 0x04000000 /* Override Default MAC Registers */ +#define TCTRL_HUGE 0x08000000 /* Enable Huge Frame */ +#define TCTRL_PAD 0x10000000 /* Pad short Frames to 64 bytes */ +#define TCTRL_CRC 0x20000000 /* Append a hardware CRC to Frame */ +#define TCTRL_LAST 0x40000000 /* Last Descriptor for TX Frame */ +#define TCTRL_INT 0x80000000 /* Generate TxDone Interrupt */ + +/* TX Status Information Word */ +#define TINFO_COL_CNT 0x01E00000 /* Collision Count */ +#define TINFO_DEFER 0x02000000 /* Packet Deferred (not an error) */ +#define TINFO_EXCESS_DEF 0x04000000 /* Excessive Deferral */ +#define TINFO_EXCESS_COL 0x08000000 /* Excessive Collision */ +#define TINFO_LATE_COL 0x10000000 /* Late Collision Occured */ +#define TINFO_UNDERRUN 0x20000000 /* Transmit Underrun */ +#define TINFO_NO_DESCR 0x40000000 /* No new Descriptor available */ +#define TINFO_ERR 0x80000000 /* Error Occured (OR of all errors) */ + +/* DP83848C PHY Registers */ +#define PHY_REG_BMCR 0x00 /* Basic Mode Control Register */ +#define PHY_REG_BMSR 0x01 /* Basic Mode Status Register */ +#define PHY_REG_IDR1 0x02 /* PHY Identifier 1 */ +#define PHY_REG_IDR2 0x03 /* PHY Identifier 2 */ +#define PHY_REG_ANAR 0x04 /* Auto-Negotiation Advertisement */ +#define PHY_REG_ANLPAR 0x05 /* Auto-Neg. Link Partner Abitily */ +#define PHY_REG_ANER 0x06 /* Auto-Neg. Expansion Register */ +#define PHY_REG_ANNPTR 0x07 /* Auto-Neg. Next Page TX */ + +/* PHY Extended Registers */ +#define PHY_REG_STS 0x10 /* Status Register */ +#define PHY_REG_MICR 0x11 /* MII Interrupt Control Register */ +#define PHY_REG_MISR 0x12 /* MII Interrupt Status Register */ +#define PHY_REG_FCSCR 0x14 /* False Carrier Sense Counter */ +#define PHY_REG_RECR 0x15 /* Receive Error Counter */ +#define PHY_REG_PCSR 0x16 /* PCS Sublayer Config. and Status */ +#define PHY_REG_RBR 0x17 /* RMII and Bypass Register */ +#define PHY_REG_LEDCR 0x18 /* LED Direct Control Register */ +#define PHY_REG_PHYCR 0x19 /* PHY Control Register */ +#define PHY_REG_10BTSCR 0x1A /* 10Base-T Status/Control Register */ +#define PHY_REG_CDCTRL1 0x1B /* CD Test Control and BIST Extens. */ +#define PHY_REG_EDCR 0x1D /* Energy Detect Control Register */ + +#define PHY_FULLD_100M 0x2100 /* Full Duplex 100Mbit */ +#define PHY_HALFD_100M 0x2000 /* Half Duplex 100Mbit */ +#define PHY_FULLD_10M 0x0100 /* Full Duplex 10Mbit */ +#define PHY_HALFD_10M 0x0000 /* Half Duplex 10MBit */ +#define PHY_AUTO_NEG 0x3000 /* Select Auto Negotiation */ + +#define DP83848C_DEF_ADR 0x0100 /* Default PHY device address */ +#define DP83848C_ID 0x20005C90 /* PHY Identifier */ + +// prototypes +portBASE_TYPE Init_EMAC(void); +unsigned short ReadFrameBE_EMAC(void); +void CopyToFrame_EMAC(void *Source, unsigned int Size); +void CopyFromFrame_EMAC(void *Dest, unsigned short Size); +void DummyReadFrame_EMAC(unsigned short Size); +unsigned short StartReadFrame(void); +void EndReadFrame(void); +unsigned int CheckFrameReceived(void); +void RequestSend(void); +unsigned int Rdy4Tx(void); +void DoSend_EMAC(unsigned short FrameSize); +void vEMACWaitForInput( void ); +unsigned int uiGetEMACRxData( unsigned char *ucBuffer ); + + +#endif + +/*---------------------------------------------------------------------------- + * end of file + *---------------------------------------------------------------------------*/ + diff --git a/Tester/SW/lib/Drivers/webserver/http-strings b/Tester/SW/lib/Drivers/webserver/http-strings new file mode 100644 index 0000000..0d3c30c --- /dev/null +++ b/Tester/SW/lib/Drivers/webserver/http-strings @@ -0,0 +1,35 @@ +http_http "http://" +http_200 "200 " +http_301 "301 " +http_302 "302 " +http_get "GET " +http_10 "HTTP/1.0" +http_11 "HTTP/1.1" +http_content_type "content-type: " +http_texthtml "text/html" +http_location "location: " +http_host "host: " +http_crnl "\r\n" +http_index_html "/index.html" +http_404_html "/404.html" +http_referer "Referer:" +http_header_200 "HTTP/1.0 200 OK\r\nServer: uIP/1.0 http://www.sics.se/~adam/uip/\r\nConnection: close\r\n" +http_header_404 "HTTP/1.0 404 Not found\r\nServer: uIP/1.0 http://www.sics.se/~adam/uip/\r\nConnection: close\r\n" +http_content_type_plain "Content-type: text/plain\r\n\r\n" +http_content_type_html "Content-type: text/html\r\n\r\n" +http_content_type_css "Content-type: text/css\r\n\r\n" +http_content_type_text "Content-type: text/text\r\n\r\n" +http_content_type_png "Content-type: image/png\r\n\r\n" +http_content_type_gif "Content-type: image/gif\r\n\r\n" +http_content_type_jpg "Content-type: image/jpeg\r\n\r\n" +http_content_type_binary "Content-type: application/octet-stream\r\n\r\n" +http_html ".html" +http_shtml ".shtml" +http_htm ".htm" +http_css ".css" +http_png ".png" +http_gif ".gif" +http_jpg ".jpg" +http_text ".txt" +http_txt ".txt" + diff --git a/Tester/SW/lib/Drivers/webserver/http-strings.c b/Tester/SW/lib/Drivers/webserver/http-strings.c new file mode 100644 index 0000000..ef7a41c --- /dev/null +++ b/Tester/SW/lib/Drivers/webserver/http-strings.c @@ -0,0 +1,102 @@ +const char http_http[8] = +/* "http://" */ +{0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, }; +const char http_200[5] = +/* "200 " */ +{0x32, 0x30, 0x30, 0x20, }; +const char http_301[5] = +/* "301 " */ +{0x33, 0x30, 0x31, 0x20, }; +const char http_302[5] = +/* "302 " */ +{0x33, 0x30, 0x32, 0x20, }; +const char http_get[5] = +/* "GET " */ +{0x47, 0x45, 0x54, 0x20, }; +const char http_10[9] = +/* "HTTP/1.0" */ +{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, }; +const char http_11[9] = +/* "HTTP/1.1" */ +{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x31, }; +const char http_content_type[15] = +/* "content-type: " */ +{0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, }; +const char http_texthtml[10] = +/* "text/html" */ +{0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, }; +const char http_location[11] = +/* "location: " */ +{0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, }; +const char http_host[7] = +/* "host: " */ +{0x68, 0x6f, 0x73, 0x74, 0x3a, 0x20, }; +const char http_crnl[3] = +/* "\r\n" */ +{0xd, 0xa, }; +const char http_index_html[12] = +/* "/index.html" */ +{0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x6c, }; +const char http_404_html[10] = +/* "/404.html" */ +{0x2f, 0x34, 0x30, 0x34, 0x2e, 0x68, 0x74, 0x6d, 0x6c, }; +const char http_referer[9] = +/* "Referer:" */ +{0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x72, 0x3a, }; +const char http_header_200[84] = +/* "HTTP/1.0 200 OK\r\nServer: uIP/1.0 http://www.sics.se/~adam/uip/\r\nConnection: close\r\n" */ +{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32, 0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x3a, 0x20, 0x75, 0x49, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x69, 0x63, 0x73, 0x2e, 0x73, 0x65, 0x2f, 0x7e, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x75, 0x69, 0x70, 0x2f, 0xd, 0xa, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0xd, 0xa, }; +const char http_header_404[91] = +/* "HTTP/1.0 404 Not found\r\nServer: uIP/1.0 http://www.sics.se/~adam/uip/\r\nConnection: close\r\n" */ +{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x34, 0x30, 0x34, 0x20, 0x4e, 0x6f, 0x74, 0x20, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0xd, 0xa, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x3a, 0x20, 0x75, 0x49, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x69, 0x63, 0x73, 0x2e, 0x73, 0x65, 0x2f, 0x7e, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x75, 0x69, 0x70, 0x2f, 0xd, 0xa, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0xd, 0xa, }; +const char http_content_type_plain[29] = +/* "Content-type: text/plain\r\n\r\n" */ +{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x70, 0x6c, 0x61, 0x69, 0x6e, 0xd, 0xa, 0xd, 0xa, }; +const char http_content_type_html[28] = +/* "Content-type: text/html\r\n\r\n" */ +{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0xd, 0xa, 0xd, 0xa, }; +const char http_content_type_css [27] = +/* "Content-type: text/css\r\n\r\n" */ +{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x63, 0x73, 0x73, 0xd, 0xa, 0xd, 0xa, }; +const char http_content_type_text[28] = +/* "Content-type: text/text\r\n\r\n" */ +{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x74, 0x65, 0x78, 0x74, 0xd, 0xa, 0xd, 0xa, }; +const char http_content_type_png [28] = +/* "Content-type: image/png\r\n\r\n" */ +{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x70, 0x6e, 0x67, 0xd, 0xa, 0xd, 0xa, }; +const char http_content_type_gif [28] = +/* "Content-type: image/gif\r\n\r\n" */ +{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x67, 0x69, 0x66, 0xd, 0xa, 0xd, 0xa, }; +const char http_content_type_jpg [29] = +/* "Content-type: image/jpeg\r\n\r\n" */ +{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x6a, 0x70, 0x65, 0x67, 0xd, 0xa, 0xd, 0xa, }; +const char http_content_type_binary[43] = +/* "Content-type: application/octet-stream\r\n\r\n" */ +{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x6f, 0x63, 0x74, 0x65, 0x74, 0x2d, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0xd, 0xa, 0xd, 0xa, }; +const char http_html[6] = +/* ".html" */ +{0x2e, 0x68, 0x74, 0x6d, 0x6c, }; +const char http_shtml[7] = +/* ".shtml" */ +{0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, }; +const char http_htm[5] = +/* ".htm" */ +{0x2e, 0x68, 0x74, 0x6d, }; +const char http_css[5] = +/* ".css" */ +{0x2e, 0x63, 0x73, 0x73, }; +const char http_png[5] = +/* ".png" */ +{0x2e, 0x70, 0x6e, 0x67, }; +const char http_gif[5] = +/* ".gif" */ +{0x2e, 0x67, 0x69, 0x66, }; +const char http_jpg[5] = +/* ".jpg" */ +{0x2e, 0x6a, 0x70, 0x67, }; +const char http_text[5] = +/* ".txt" */ +{0x2e, 0x74, 0x78, 0x74, }; +const char http_txt[5] = +/* ".txt" */ +{0x2e, 0x74, 0x78, 0x74, }; diff --git a/Tester/SW/lib/Drivers/webserver/http-strings.h b/Tester/SW/lib/Drivers/webserver/http-strings.h new file mode 100644 index 0000000..acbe7e1 --- /dev/null +++ b/Tester/SW/lib/Drivers/webserver/http-strings.h @@ -0,0 +1,34 @@ +extern const char http_http[8]; +extern const char http_200[5]; +extern const char http_301[5]; +extern const char http_302[5]; +extern const char http_get[5]; +extern const char http_10[9]; +extern const char http_11[9]; +extern const char http_content_type[15]; +extern const char http_texthtml[10]; +extern const char http_location[11]; +extern const char http_host[7]; +extern const char http_crnl[3]; +extern const char http_index_html[12]; +extern const char http_404_html[10]; +extern const char http_referer[9]; +extern const char http_header_200[84]; +extern const char http_header_404[91]; +extern const char http_content_type_plain[29]; +extern const char http_content_type_html[28]; +extern const char http_content_type_css [27]; +extern const char http_content_type_text[28]; +extern const char http_content_type_png [28]; +extern const char http_content_type_gif [28]; +extern const char http_content_type_jpg [29]; +extern const char http_content_type_binary[43]; +extern const char http_html[6]; +extern const char http_shtml[7]; +extern const char http_htm[5]; +extern const char http_css[5]; +extern const char http_png[5]; +extern const char http_gif[5]; +extern const char http_jpg[5]; +extern const char http_text[5]; +extern const char http_txt[5]; diff --git a/Tester/SW/lib/Drivers/webserver/httpd-cgi.c b/Tester/SW/lib/Drivers/webserver/httpd-cgi.c new file mode 100644 index 0000000..19f7a63 --- /dev/null +++ b/Tester/SW/lib/Drivers/webserver/httpd-cgi.c @@ -0,0 +1,276 @@ +/** + * \addtogroup httpd + * @{ + */ + +/** + * \file + * Web server script interface + * \author + * Adam Dunkels + * + */ + +/* + * Copyright (c) 2001-2006, Adam Dunkels. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This file is part of the uIP TCP/IP stack. + * + * $Id: httpd-cgi.c,v 1.2 2006/06/11 21:46:37 adam Exp $ + * + */ + +#include "uip.h" +#include "psock.h" +#include "httpd.h" +#include "httpd-cgi.h" +#include "httpd-fs.h" + +#include +#include + +HTTPD_CGI_CALL(file, "file-stats", file_stats); +HTTPD_CGI_CALL(tcp, "tcp-connections", tcp_stats); +HTTPD_CGI_CALL(net, "net-stats", net_stats); +HTTPD_CGI_CALL(rtos, "rtos-stats", rtos_stats ); +HTTPD_CGI_CALL(io, "led-io", led_io ); + + +static const struct httpd_cgi_call *calls[] = { &file, &tcp, &net, &rtos, &io, NULL }; + +/*---------------------------------------------------------------------------*/ +static +PT_THREAD(nullfunction(struct httpd_state *s, char *ptr)) +{ + PSOCK_BEGIN(&s->sout); + PSOCK_END(&s->sout); +} +/*---------------------------------------------------------------------------*/ +httpd_cgifunction +httpd_cgi(char *name) +{ + const struct httpd_cgi_call **f; + + /* Find the matching name in the table, return the function. */ + for(f = calls; *f != NULL; ++f) { + if(strncmp((*f)->name, name, strlen((*f)->name)) == 0) { + return (*f)->function; + } + } + return nullfunction; +} +/*---------------------------------------------------------------------------*/ +static unsigned short +generate_file_stats(void *arg) +{ + char *f = (char *)arg; + return snprintf((char *)uip_appdata, UIP_APPDATA_SIZE, "%5u", httpd_fs_count(f)); +} +/*---------------------------------------------------------------------------*/ +static +PT_THREAD(file_stats(struct httpd_state *s, char *ptr)) +{ + PSOCK_BEGIN(&s->sout); + + PSOCK_GENERATOR_SEND(&s->sout, generate_file_stats, strchr(ptr, ' ') + 1); + + PSOCK_END(&s->sout); +} +/*---------------------------------------------------------------------------*/ +static const char closed[] = /* "CLOSED",*/ +{0x43, 0x4c, 0x4f, 0x53, 0x45, 0x44, 0}; +static const char syn_rcvd[] = /* "SYN-RCVD",*/ +{0x53, 0x59, 0x4e, 0x2d, 0x52, 0x43, 0x56, + 0x44, 0}; +static const char syn_sent[] = /* "SYN-SENT",*/ +{0x53, 0x59, 0x4e, 0x2d, 0x53, 0x45, 0x4e, + 0x54, 0}; +static const char established[] = /* "ESTABLISHED",*/ +{0x45, 0x53, 0x54, 0x41, 0x42, 0x4c, 0x49, 0x53, 0x48, + 0x45, 0x44, 0}; +static const char fin_wait_1[] = /* "FIN-WAIT-1",*/ +{0x46, 0x49, 0x4e, 0x2d, 0x57, 0x41, 0x49, + 0x54, 0x2d, 0x31, 0}; +static const char fin_wait_2[] = /* "FIN-WAIT-2",*/ +{0x46, 0x49, 0x4e, 0x2d, 0x57, 0x41, 0x49, + 0x54, 0x2d, 0x32, 0}; +static const char closing[] = /* "CLOSING",*/ +{0x43, 0x4c, 0x4f, 0x53, 0x49, + 0x4e, 0x47, 0}; +static const char time_wait[] = /* "TIME-WAIT,"*/ +{0x54, 0x49, 0x4d, 0x45, 0x2d, 0x57, 0x41, + 0x49, 0x54, 0}; +static const char last_ack[] = /* "LAST-ACK"*/ +{0x4c, 0x41, 0x53, 0x54, 0x2d, 0x41, 0x43, + 0x4b, 0}; + +static const char *states[] = { + closed, + syn_rcvd, + syn_sent, + established, + fin_wait_1, + fin_wait_2, + closing, + time_wait, + last_ack}; + + +static unsigned short +generate_tcp_stats(void *arg) +{ + struct uip_conn *conn; + struct httpd_state *s = (struct httpd_state *)arg; + + conn = &uip_conns[s->count]; + return snprintf((char *)uip_appdata, UIP_APPDATA_SIZE, + "\r\n", + htons(conn->lport), + htons(conn->ripaddr[0]) >> 8, + htons(conn->ripaddr[0]) & 0xff, + htons(conn->ripaddr[1]) >> 8, + htons(conn->ripaddr[1]) & 0xff, + htons(conn->rport), + states[conn->tcpstateflags & UIP_TS_MASK], + conn->nrtx, + conn->timer, + (uip_outstanding(conn))? '*':' ', + (uip_stopped(conn))? '!':' '); +} +/*---------------------------------------------------------------------------*/ +static +PT_THREAD(tcp_stats(struct httpd_state *s, char *ptr)) +{ + + PSOCK_BEGIN(&s->sout); + + for(s->count = 0; s->count < UIP_CONNS; ++s->count) { + if((uip_conns[s->count].tcpstateflags & UIP_TS_MASK) != UIP_CLOSED) { + PSOCK_GENERATOR_SEND(&s->sout, generate_tcp_stats, s); + } + } + + PSOCK_END(&s->sout); +} +/*---------------------------------------------------------------------------*/ +static unsigned short +generate_net_stats(void *arg) +{ + struct httpd_state *s = (struct httpd_state *)arg; + return snprintf((char *)uip_appdata, UIP_APPDATA_SIZE, + "%5u\n", ((uip_stats_t *)&uip_stat)[s->count]); +} + +static +PT_THREAD(net_stats(struct httpd_state *s, char *ptr)) +{ + PSOCK_BEGIN(&s->sout); + +#if UIP_STATISTICS + + for(s->count = 0; s->count < sizeof(uip_stat) / sizeof(uip_stats_t); + ++s->count) { + PSOCK_GENERATOR_SEND(&s->sout, generate_net_stats, s); + } + +#endif /* UIP_STATISTICS */ + + PSOCK_END(&s->sout); +} +/*---------------------------------------------------------------------------*/ + +extern void vTaskList( signed char *pcWriteBuffer ); +static char cCountBuf[ 32 ]; +long lRefreshCount = 0; +static unsigned short +generate_rtos_stats(void *arg) +{ + lRefreshCount++; + sprintf( cCountBuf, "


Refresh count = %ld", lRefreshCount ); + vTaskList( uip_appdata ); + strcat( uip_appdata, cCountBuf ); + + return strlen( uip_appdata ); +} +/*---------------------------------------------------------------------------*/ + + +static +PT_THREAD(rtos_stats(struct httpd_state *s, char *ptr)) +{ + PSOCK_BEGIN(&s->sout); + PSOCK_GENERATOR_SEND(&s->sout, generate_rtos_stats, NULL); + PSOCK_END(&s->sout); +} +/*---------------------------------------------------------------------------*/ + +char *pcStatus[ 3 ]; +unsigned long ulString; +extern unsigned long uxParTextGetLED( unsigned long uxLED ); + +static unsigned short generate_io_state( void *arg ) +{ +// for( ulString = 0; ulString < 4; ulString++ ) +// { +// if( uxParTextGetLED( ulString + 5 ) ) +// { +// pcStatus[ ulString ] = "checked"; +// } +// else +// { +// pcStatus[ ulString ] = ""; +// } +// } + + sprintf( uip_appdata, + "LED 2.5,"\ + "LED 2.6,"\ + "LED 2.7"\ + "

"\ + "", + pcStatus[ 0 ], + pcStatus[ 1 ], + pcStatus[ 2 ] ); + + return strlen( uip_appdata ); +} + +static PT_THREAD(led_io(struct httpd_state *s, char *ptr)) +{ + PSOCK_BEGIN(&s->sout); + PSOCK_GENERATOR_SEND(&s->sout, generate_io_state, NULL); + PSOCK_END(&s->sout); +} + +/** @} */ + + + + + + diff --git a/Tester/SW/lib/Drivers/webserver/httpd-cgi.h b/Tester/SW/lib/Drivers/webserver/httpd-cgi.h new file mode 100644 index 0000000..7ae9283 --- /dev/null +++ b/Tester/SW/lib/Drivers/webserver/httpd-cgi.h @@ -0,0 +1,84 @@ +/** + * \addtogroup httpd + * @{ + */ + +/** + * \file + * Web server script interface header file + * \author + * Adam Dunkels + * + */ + + + +/* + * Copyright (c) 2001, Adam Dunkels. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This file is part of the uIP TCP/IP stack. + * + * $Id: httpd-cgi.h,v 1.2 2006/06/11 21:46:38 adam Exp $ + * + */ + +#ifndef __HTTPD_CGI_H__ +#define __HTTPD_CGI_H__ + +#include "psock.h" +#include "httpd.h" + +typedef PT_THREAD((* httpd_cgifunction)(struct httpd_state *, char *)); + +httpd_cgifunction httpd_cgi(char *name); + +struct httpd_cgi_call { + const char *name; + const httpd_cgifunction function; +}; + +/** + * \brief HTTPD CGI function declaration + * \param name The C variable name of the function + * \param str The string name of the function, used in the script file + * \param function A pointer to the function that implements it + * + * This macro is used for declaring a HTTPD CGI + * function. This function is then added to the list of + * HTTPD CGI functions with the httpd_cgi_add() function. + * + * \hideinitializer + */ +#define HTTPD_CGI_CALL(name, str, function) \ +static PT_THREAD(function(struct httpd_state *, char *)); \ +static const struct httpd_cgi_call name = {str, function} + +void httpd_cgi_init(void); +#endif /* __HTTPD_CGI_H__ */ + +/** @} */ diff --git a/Tester/SW/lib/Drivers/webserver/httpd-fs.c b/Tester/SW/lib/Drivers/webserver/httpd-fs.c new file mode 100644 index 0000000..dc4aef0 --- /dev/null +++ b/Tester/SW/lib/Drivers/webserver/httpd-fs.c @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2001, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + * $Id: httpd-fs.c,v 1.1 2006/06/07 09:13:08 adam Exp $ + */ + +#include "httpd.h" +#include "httpd-fs.h" +#include "httpd-fsdata.h" + +#ifndef NULL +#define NULL 0 +#endif /* NULL */ + +#include "httpd-fsdata.c" + +#if HTTPD_FS_STATISTICS +static u16_t count[HTTPD_FS_NUMFILES]; +#endif /* HTTPD_FS_STATISTICS */ + +/*-----------------------------------------------------------------------------------*/ +static u8_t +httpd_fs_strcmp(const char *str1, const char *str2) +{ + u8_t i; + i = 0; + loop: + + if(str2[i] == 0 || + str1[i] == '\r' || + str1[i] == '\n') { + return 0; + } + + if(str1[i] != str2[i]) { + return 1; + } + + + ++i; + goto loop; +} +/*-----------------------------------------------------------------------------------*/ +int +httpd_fs_open(const char *name, struct httpd_fs_file *file) +{ +#if HTTPD_FS_STATISTICS + u16_t i = 0; +#endif /* HTTPD_FS_STATISTICS */ + struct httpd_fsdata_file_noconst *f; + + for(f = (struct httpd_fsdata_file_noconst *)HTTPD_FS_ROOT; + f != NULL; + f = (struct httpd_fsdata_file_noconst *)f->next) { + + if(httpd_fs_strcmp(name, f->name) == 0) { + file->data = f->data; + file->len = f->len; +#if HTTPD_FS_STATISTICS + ++count[i]; +#endif /* HTTPD_FS_STATISTICS */ + return 1; + } +#if HTTPD_FS_STATISTICS + ++i; +#endif /* HTTPD_FS_STATISTICS */ + + } + return 0; +} +/*-----------------------------------------------------------------------------------*/ +void +httpd_fs_init(void) +{ +#if HTTPD_FS_STATISTICS + u16_t i; + for(i = 0; i < HTTPD_FS_NUMFILES; i++) { + count[i] = 0; + } +#endif /* HTTPD_FS_STATISTICS */ +} +/*-----------------------------------------------------------------------------------*/ +#if HTTPD_FS_STATISTICS +u16_t httpd_fs_count +(char *name) +{ + struct httpd_fsdata_file_noconst *f; + u16_t i; + + i = 0; + for(f = (struct httpd_fsdata_file_noconst *)HTTPD_FS_ROOT; + f != NULL; + f = (struct httpd_fsdata_file_noconst *)f->next) { + + if(httpd_fs_strcmp(name, f->name) == 0) { + return count[i]; + } + ++i; + } + return 0; +} +#endif /* HTTPD_FS_STATISTICS */ +/*-----------------------------------------------------------------------------------*/ diff --git a/Tester/SW/lib/Drivers/webserver/httpd-fs.h b/Tester/SW/lib/Drivers/webserver/httpd-fs.h new file mode 100644 index 0000000..b594eea --- /dev/null +++ b/Tester/SW/lib/Drivers/webserver/httpd-fs.h @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2001, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + * $Id: httpd-fs.h,v 1.1 2006/06/07 09:13:08 adam Exp $ + */ +#ifndef __HTTPD_FS_H__ +#define __HTTPD_FS_H__ + +#define HTTPD_FS_STATISTICS 1 + +struct httpd_fs_file { + char *data; + int len; +}; + +/* file must be allocated by caller and will be filled in + by the function. */ +int httpd_fs_open(const char *name, struct httpd_fs_file *file); + +#ifdef HTTPD_FS_STATISTICS +#if HTTPD_FS_STATISTICS == 1 +u16_t httpd_fs_count(char *name); +#endif /* HTTPD_FS_STATISTICS */ +#endif /* HTTPD_FS_STATISTICS */ + +void httpd_fs_init(void); + +#endif /* __HTTPD_FS_H__ */ diff --git a/Tester/SW/lib/Drivers/webserver/httpd-fs/404.html b/Tester/SW/lib/Drivers/webserver/httpd-fs/404.html new file mode 100644 index 0000000..43e7f4c --- /dev/null +++ b/Tester/SW/lib/Drivers/webserver/httpd-fs/404.html @@ -0,0 +1,8 @@ + + +

+

404 - file not found

+

Go here instead.

+
+ + \ No newline at end of file diff --git a/Tester/SW/lib/Drivers/webserver/httpd-fs/index.html b/Tester/SW/lib/Drivers/webserver/httpd-fs/index.html new file mode 100644 index 0000000..1d3bbee --- /dev/null +++ b/Tester/SW/lib/Drivers/webserver/httpd-fs/index.html @@ -0,0 +1,13 @@ + + + + FreeRTOS.org uIP WEB server demo + + + +Loading index.shtml. Click here if not automatically redirected. + + + + + diff --git a/Tester/SW/lib/Drivers/webserver/httpd-fs/index.shtml b/Tester/SW/lib/Drivers/webserver/httpd-fs/index.shtml new file mode 100644 index 0000000..0ce405b --- /dev/null +++ b/Tester/SW/lib/Drivers/webserver/httpd-fs/index.shtml @@ -0,0 +1,20 @@ + + + + FreeRTOS.org uIP WEB server demo + + + +RTOS Stats | TCP Stats | Connections | FreeRTOS.org Homepage | IO +

+


+

+

Task statistics

+Page will refresh evey 2 seconds.

+

Task          State  Priority  Stack	#
************************************************
+%! rtos-stats +
+
+ + + diff --git a/Tester/SW/lib/Drivers/webserver/httpd-fs/io.shtml b/Tester/SW/lib/Drivers/webserver/httpd-fs/io.shtml new file mode 100644 index 0000000..0ffdbff --- /dev/null +++ b/Tester/SW/lib/Drivers/webserver/httpd-fs/io.shtml @@ -0,0 +1,28 @@ + + + + FreeRTOS.org uIP WEB server demo + + + +RTOS Stats | TCP Stats | Connections | FreeRTOS.org Homepage | IO +

+


+LED and LCD IO
+ +

+ +Use the check boxes to select the LED's to turn on or off, enter text to display on the LCD, then click "Update IO". + + +

+
+%! led-io +

+ + +

+ + + + diff --git a/Tester/SW/lib/Drivers/webserver/httpd-fs/stats.shtml b/Tester/SW/lib/Drivers/webserver/httpd-fs/stats.shtml new file mode 100644 index 0000000..d762f40 --- /dev/null +++ b/Tester/SW/lib/Drivers/webserver/httpd-fs/stats.shtml @@ -0,0 +1,41 @@ + + + + FreeRTOS.org uIP WEB server demo + + + +RTOS Stats | TCP Stats | Connections | FreeRTOS.org Homepage | IO +

+


+

+

Network statistics

+
LocalRemoteStateRetransmissionsTimerFlags
%d%u.%u.%u.%u:%u%s%u%u%c %c
+
+IP           Packets dropped
+             Packets received
+             Packets sent
+IP errors    IP version/header length
+             IP length, high byte
+             IP length, low byte
+             IP fragments
+             Header checksum
+             Wrong protocol
+ICMP	     Packets dropped
+             Packets received
+             Packets sent
+             Type errors
+TCP          Packets dropped
+             Packets received
+             Packets sent
+             Checksum errors
+             Data packets without ACKs
+             Resets
+             Retransmissions
+	     No connection avaliable
+	     Connection attempts to closed ports
+
%! net-stats
+
+ + + diff --git a/Tester/SW/lib/Drivers/webserver/httpd-fs/tcp.shtml b/Tester/SW/lib/Drivers/webserver/httpd-fs/tcp.shtml new file mode 100644 index 0000000..654d61f --- /dev/null +++ b/Tester/SW/lib/Drivers/webserver/httpd-fs/tcp.shtml @@ -0,0 +1,21 @@ + + + + FreeRTOS.org uIP WEB server demo + + + +RTOS Stats | TCP Stats | Connections | FreeRTOS.org Homepage | IO +

+


+
+

Network connections

+

+ + +%! tcp-connections + + + + + diff --git a/Tester/SW/lib/Drivers/webserver/httpd-fsdata.c b/Tester/SW/lib/Drivers/webserver/httpd-fsdata.c new file mode 100644 index 0000000..4160704 --- /dev/null +++ b/Tester/SW/lib/Drivers/webserver/httpd-fsdata.c @@ -0,0 +1,476 @@ +#include "LPC23xx.h" +#include "types.h" + +#include "httpd-fsdata.h" + + +static const unsigned char data_404_html[] = { + /* /404.html */ + 0x2f, 0x34, 0x30, 0x34, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0, + 0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0xd, 0xa, 0x20, 0x20, + 0x3c, 0x62, 0x6f, 0x64, 0x79, 0x20, 0x62, 0x67, 0x63, 0x6f, + 0x6c, 0x6f, 0x72, 0x3d, 0x22, 0x77, 0x68, 0x69, 0x74, 0x65, + 0x22, 0x3e, 0xd, 0xa, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x63, + 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3e, 0xd, 0xa, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x3c, 0x68, 0x31, 0x3e, 0x34, 0x30, + 0x34, 0x20, 0x2d, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x20, 0x6e, + 0x6f, 0x74, 0x20, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0x3c, 0x2f, + 0x68, 0x31, 0x3e, 0xd, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x3c, 0x68, 0x33, 0x3e, 0x47, 0x6f, 0x20, 0x3c, 0x61, + 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x22, 0x3e, + 0x68, 0x65, 0x72, 0x65, 0x3c, 0x2f, 0x61, 0x3e, 0x20, 0x69, + 0x6e, 0x73, 0x74, 0x65, 0x61, 0x64, 0x2e, 0x3c, 0x2f, 0x68, + 0x33, 0x3e, 0xd, 0xa, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x2f, + 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3e, 0xd, 0xa, 0x20, + 0x20, 0x3c, 0x2f, 0x62, 0x6f, 0x64, 0x79, 0x3e, 0xd, 0xa, + 0x3c, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0}; + +static const unsigned char data_index_html[] = { + /* /index.html */ + 0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0, + 0x3c, 0x21, 0x44, 0x4f, 0x43, 0x54, 0x59, 0x50, 0x45, 0x20, + 0x48, 0x54, 0x4d, 0x4c, 0x20, 0x50, 0x55, 0x42, 0x4c, 0x49, + 0x43, 0x20, 0x22, 0x2d, 0x2f, 0x2f, 0x57, 0x33, 0x43, 0x2f, + 0x2f, 0x44, 0x54, 0x44, 0x20, 0x48, 0x54, 0x4d, 0x4c, 0x20, + 0x34, 0x2e, 0x30, 0x31, 0x20, 0x54, 0x72, 0x61, 0x6e, 0x73, + 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x2f, 0x2f, 0x45, + 0x4e, 0x22, 0x20, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, + 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x77, 0x33, 0x2e, 0x6f, 0x72, + 0x67, 0x2f, 0x54, 0x52, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x34, + 0x2f, 0x6c, 0x6f, 0x6f, 0x73, 0x65, 0x2e, 0x64, 0x74, 0x64, + 0x22, 0x3e, 0xd, 0xa, 0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e, + 0xd, 0xa, 0x20, 0x20, 0x3c, 0x68, 0x65, 0x61, 0x64, 0x3e, + 0xd, 0xa, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x74, 0x69, 0x74, + 0x6c, 0x65, 0x3e, 0x46, 0x72, 0x65, 0x65, 0x52, 0x54, 0x4f, + 0x53, 0x2e, 0x6f, 0x72, 0x67, 0x20, 0x75, 0x49, 0x50, 0x20, + 0x57, 0x45, 0x42, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, + 0x20, 0x64, 0x65, 0x6d, 0x6f, 0x3c, 0x2f, 0x74, 0x69, 0x74, + 0x6c, 0x65, 0x3e, 0xd, 0xa, 0x20, 0x20, 0x3c, 0x2f, 0x68, + 0x65, 0x61, 0x64, 0x3e, 0xd, 0xa, 0x20, 0x20, 0x3c, 0x42, + 0x4f, 0x44, 0x59, 0x20, 0x6f, 0x6e, 0x4c, 0x6f, 0x61, 0x64, + 0x3d, 0x22, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x2e, 0x73, + 0x65, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x28, + 0x26, 0x71, 0x75, 0x6f, 0x74, 0x3b, 0x6c, 0x6f, 0x63, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x68, 0x72, 0x65, 0x66, 0x3d, + 0x27, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x73, 0x68, 0x74, + 0x6d, 0x6c, 0x27, 0x26, 0x71, 0x75, 0x6f, 0x74, 0x3b, 0x2c, + 0x31, 0x30, 0x30, 0x29, 0x22, 0x62, 0x67, 0x63, 0x6f, 0x6c, + 0x6f, 0x72, 0x3d, 0x22, 0x23, 0x43, 0x43, 0x43, 0x43, 0x66, + 0x66, 0x22, 0x3e, 0xd, 0xa, 0x3c, 0x66, 0x6f, 0x6e, 0x74, + 0x20, 0x66, 0x61, 0x63, 0x65, 0x3d, 0x22, 0x61, 0x72, 0x69, + 0x61, 0x6c, 0x22, 0x3e, 0xd, 0xa, 0x4c, 0x6f, 0x61, 0x64, + 0x69, 0x6e, 0x67, 0x20, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, + 0x73, 0x68, 0x74, 0x6d, 0x6c, 0x2e, 0x20, 0x20, 0x43, 0x6c, + 0x69, 0x63, 0x6b, 0x20, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, + 0x66, 0x3d, 0x22, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x73, + 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x68, 0x65, 0x72, 0x65, + 0x3c, 0x2f, 0x61, 0x3e, 0x20, 0x69, 0x66, 0x20, 0x6e, 0x6f, + 0x74, 0x20, 0x61, 0x75, 0x74, 0x6f, 0x6d, 0x61, 0x74, 0x69, + 0x63, 0x61, 0x6c, 0x6c, 0x79, 0x20, 0x72, 0x65, 0x64, 0x69, + 0x72, 0x65, 0x63, 0x74, 0x65, 0x64, 0x2e, 0xd, 0xa, 0x3c, + 0x2f, 0x66, 0x6f, 0x6e, 0x74, 0x3e, 0xd, 0xa, 0x3c, 0x2f, + 0x66, 0x6f, 0x6e, 0x74, 0x3e, 0xd, 0xa, 0x3c, 0x2f, 0x62, + 0x6f, 0x64, 0x79, 0x3e, 0xd, 0xa, 0x3c, 0x2f, 0x68, 0x74, + 0x6d, 0x6c, 0x3e, 0xd, 0xa, 0xd, 0xa, 0}; + +static const unsigned char data_index_shtml[] = { + /* /index.shtml */ + 0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0, + 0x3c, 0x21, 0x44, 0x4f, 0x43, 0x54, 0x59, 0x50, 0x45, 0x20, + 0x48, 0x54, 0x4d, 0x4c, 0x20, 0x50, 0x55, 0x42, 0x4c, 0x49, + 0x43, 0x20, 0x22, 0x2d, 0x2f, 0x2f, 0x57, 0x33, 0x43, 0x2f, + 0x2f, 0x44, 0x54, 0x44, 0x20, 0x48, 0x54, 0x4d, 0x4c, 0x20, + 0x34, 0x2e, 0x30, 0x31, 0x20, 0x54, 0x72, 0x61, 0x6e, 0x73, + 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x2f, 0x2f, 0x45, + 0x4e, 0x22, 0x20, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, + 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x77, 0x33, 0x2e, 0x6f, 0x72, + 0x67, 0x2f, 0x54, 0x52, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x34, + 0x2f, 0x6c, 0x6f, 0x6f, 0x73, 0x65, 0x2e, 0x64, 0x74, 0x64, + 0x22, 0x3e, 0xd, 0xa, 0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e, + 0xd, 0xa, 0x20, 0x20, 0x3c, 0x68, 0x65, 0x61, 0x64, 0x3e, + 0xd, 0xa, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x74, 0x69, 0x74, + 0x6c, 0x65, 0x3e, 0x46, 0x72, 0x65, 0x65, 0x52, 0x54, 0x4f, + 0x53, 0x2e, 0x6f, 0x72, 0x67, 0x20, 0x75, 0x49, 0x50, 0x20, + 0x57, 0x45, 0x42, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, + 0x20, 0x64, 0x65, 0x6d, 0x6f, 0x3c, 0x2f, 0x74, 0x69, 0x74, + 0x6c, 0x65, 0x3e, 0xd, 0xa, 0x20, 0x20, 0x3c, 0x2f, 0x68, + 0x65, 0x61, 0x64, 0x3e, 0xd, 0xa, 0x20, 0x20, 0x3c, 0x42, + 0x4f, 0x44, 0x59, 0x20, 0x6f, 0x6e, 0x4c, 0x6f, 0x61, 0x64, + 0x3d, 0x22, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x2e, 0x73, + 0x65, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x28, + 0x26, 0x71, 0x75, 0x6f, 0x74, 0x3b, 0x6c, 0x6f, 0x63, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x68, 0x72, 0x65, 0x66, 0x3d, + 0x27, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x73, 0x68, 0x74, + 0x6d, 0x6c, 0x27, 0x26, 0x71, 0x75, 0x6f, 0x74, 0x3b, 0x2c, + 0x32, 0x30, 0x30, 0x30, 0x29, 0x22, 0x62, 0x67, 0x63, 0x6f, + 0x6c, 0x6f, 0x72, 0x3d, 0x22, 0x23, 0x43, 0x43, 0x43, 0x43, + 0x66, 0x66, 0x22, 0x3e, 0xd, 0xa, 0x3c, 0x66, 0x6f, 0x6e, + 0x74, 0x20, 0x66, 0x61, 0x63, 0x65, 0x3d, 0x22, 0x61, 0x72, + 0x69, 0x61, 0x6c, 0x22, 0x3e, 0xd, 0xa, 0x3c, 0x61, 0x20, + 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x69, 0x6e, 0x64, 0x65, + 0x78, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x52, + 0x54, 0x4f, 0x53, 0x20, 0x53, 0x74, 0x61, 0x74, 0x73, 0x3c, + 0x2f, 0x61, 0x3e, 0x20, 0x3c, 0x62, 0x3e, 0x7c, 0x3c, 0x2f, + 0x62, 0x3e, 0x20, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66, + 0x3d, 0x22, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x73, 0x68, + 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x54, 0x43, 0x50, 0x20, 0x53, + 0x74, 0x61, 0x74, 0x73, 0x3c, 0x2f, 0x61, 0x3e, 0x20, 0x3c, + 0x62, 0x3e, 0x7c, 0x3c, 0x2f, 0x62, 0x3e, 0x20, 0x3c, 0x61, + 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x74, 0x63, 0x70, + 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x43, 0x6f, + 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x3c, + 0x2f, 0x61, 0x3e, 0x20, 0x3c, 0x62, 0x3e, 0x7c, 0x3c, 0x2f, + 0x62, 0x3e, 0x20, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66, + 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, + 0x77, 0x77, 0x2e, 0x66, 0x72, 0x65, 0x65, 0x72, 0x74, 0x6f, + 0x73, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x22, 0x3e, 0x46, 0x72, + 0x65, 0x65, 0x52, 0x54, 0x4f, 0x53, 0x2e, 0x6f, 0x72, 0x67, + 0x20, 0x48, 0x6f, 0x6d, 0x65, 0x70, 0x61, 0x67, 0x65, 0x3c, + 0x2f, 0x61, 0x3e, 0x20, 0x3c, 0x62, 0x3e, 0x7c, 0x3c, 0x2f, + 0x62, 0x3e, 0x20, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66, + 0x3d, 0x22, 0x69, 0x6f, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, + 0x22, 0x3e, 0x49, 0x4f, 0x3c, 0x2f, 0x61, 0x3e, 0xd, 0xa, + 0x3c, 0x62, 0x72, 0x3e, 0x3c, 0x70, 0x3e, 0xd, 0xa, 0x3c, + 0x68, 0x72, 0x3e, 0xd, 0xa, 0x3c, 0x62, 0x72, 0x3e, 0x3c, + 0x70, 0x3e, 0xd, 0xa, 0x3c, 0x68, 0x32, 0x3e, 0x54, 0x61, + 0x73, 0x6b, 0x20, 0x73, 0x74, 0x61, 0x74, 0x69, 0x73, 0x74, + 0x69, 0x63, 0x73, 0x3c, 0x2f, 0x68, 0x32, 0x3e, 0xd, 0xa, + 0x50, 0x61, 0x67, 0x65, 0x20, 0x77, 0x69, 0x6c, 0x6c, 0x20, + 0x72, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x20, 0x65, 0x76, + 0x65, 0x79, 0x20, 0x32, 0x20, 0x73, 0x65, 0x63, 0x6f, 0x6e, + 0x64, 0x73, 0x2e, 0x3c, 0x70, 0x3e, 0xd, 0xa, 0x3c, 0x66, + 0x6f, 0x6e, 0x74, 0x20, 0x66, 0x61, 0x63, 0x65, 0x3d, 0x22, + 0x63, 0x6f, 0x75, 0x72, 0x69, 0x65, 0x72, 0x22, 0x3e, 0x3c, + 0x70, 0x72, 0x65, 0x3e, 0x54, 0x61, 0x73, 0x6b, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x53, 0x74, + 0x61, 0x74, 0x65, 0x20, 0x20, 0x50, 0x72, 0x69, 0x6f, 0x72, + 0x69, 0x74, 0x79, 0x20, 0x20, 0x53, 0x74, 0x61, 0x63, 0x6b, + 0x9, 0x23, 0x3c, 0x62, 0x72, 0x3e, 0x2a, 0x2a, 0x2a, 0x2a, + 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, + 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, + 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, + 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, + 0x2a, 0x2a, 0x2a, 0x2a, 0x3c, 0x62, 0x72, 0x3e, 0xd, 0xa, + 0x25, 0x21, 0x20, 0x72, 0x74, 0x6f, 0x73, 0x2d, 0x73, 0x74, + 0x61, 0x74, 0x73, 0xd, 0xa, 0x3c, 0x2f, 0x70, 0x72, 0x65, + 0x3e, 0x3c, 0x2f, 0x66, 0x6f, 0x6e, 0x74, 0x3e, 0xd, 0xa, + 0x3c, 0x2f, 0x66, 0x6f, 0x6e, 0x74, 0x3e, 0xd, 0xa, 0x3c, + 0x2f, 0x62, 0x6f, 0x64, 0x79, 0x3e, 0xd, 0xa, 0x3c, 0x2f, + 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0xd, 0xa, 0xd, 0xa, 0}; + +static const unsigned char data_io_shtml[] = { + /* /io.shtml */ + 0x2f, 0x69, 0x6f, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0, + 0x3c, 0x21, 0x44, 0x4f, 0x43, 0x54, 0x59, 0x50, 0x45, 0x20, + 0x48, 0x54, 0x4d, 0x4c, 0x20, 0x50, 0x55, 0x42, 0x4c, 0x49, + 0x43, 0x20, 0x22, 0x2d, 0x2f, 0x2f, 0x57, 0x33, 0x43, 0x2f, + 0x2f, 0x44, 0x54, 0x44, 0x20, 0x48, 0x54, 0x4d, 0x4c, 0x20, + 0x34, 0x2e, 0x30, 0x31, 0x20, 0x54, 0x72, 0x61, 0x6e, 0x73, + 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x2f, 0x2f, 0x45, + 0x4e, 0x22, 0x20, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, + 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x77, 0x33, 0x2e, 0x6f, 0x72, + 0x67, 0x2f, 0x54, 0x52, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x34, + 0x2f, 0x6c, 0x6f, 0x6f, 0x73, 0x65, 0x2e, 0x64, 0x74, 0x64, + 0x22, 0x3e, 0xd, 0xa, 0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e, + 0xd, 0xa, 0x20, 0x20, 0x3c, 0x68, 0x65, 0x61, 0x64, 0x3e, + 0xd, 0xa, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x74, 0x69, 0x74, + 0x6c, 0x65, 0x3e, 0x46, 0x72, 0x65, 0x65, 0x52, 0x54, 0x4f, + 0x53, 0x2e, 0x6f, 0x72, 0x67, 0x20, 0x75, 0x49, 0x50, 0x20, + 0x57, 0x45, 0x42, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, + 0x20, 0x64, 0x65, 0x6d, 0x6f, 0x3c, 0x2f, 0x74, 0x69, 0x74, + 0x6c, 0x65, 0x3e, 0xd, 0xa, 0x20, 0x20, 0x3c, 0x2f, 0x68, + 0x65, 0x61, 0x64, 0x3e, 0xd, 0xa, 0x20, 0x20, 0x3c, 0x42, + 0x4f, 0x44, 0x59, 0x20, 0x62, 0x67, 0x63, 0x6f, 0x6c, 0x6f, + 0x72, 0x3d, 0x22, 0x23, 0x43, 0x43, 0x43, 0x43, 0x66, 0x66, + 0x22, 0x3e, 0xd, 0xa, 0x3c, 0x66, 0x6f, 0x6e, 0x74, 0x20, + 0x66, 0x61, 0x63, 0x65, 0x3d, 0x22, 0x61, 0x72, 0x69, 0x61, + 0x6c, 0x22, 0x3e, 0xd, 0xa, 0x3c, 0x61, 0x20, 0x68, 0x72, + 0x65, 0x66, 0x3d, 0x22, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, + 0x73, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x52, 0x54, 0x4f, + 0x53, 0x20, 0x53, 0x74, 0x61, 0x74, 0x73, 0x3c, 0x2f, 0x61, + 0x3e, 0x20, 0x3c, 0x62, 0x3e, 0x7c, 0x3c, 0x2f, 0x62, 0x3e, + 0x20, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, + 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x73, 0x68, 0x74, 0x6d, + 0x6c, 0x22, 0x3e, 0x54, 0x43, 0x50, 0x20, 0x53, 0x74, 0x61, + 0x74, 0x73, 0x3c, 0x2f, 0x61, 0x3e, 0x20, 0x3c, 0x62, 0x3e, + 0x7c, 0x3c, 0x2f, 0x62, 0x3e, 0x20, 0x3c, 0x61, 0x20, 0x68, + 0x72, 0x65, 0x66, 0x3d, 0x22, 0x74, 0x63, 0x70, 0x2e, 0x73, + 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x43, 0x6f, 0x6e, 0x6e, + 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x3c, 0x2f, 0x61, + 0x3e, 0x20, 0x3c, 0x62, 0x3e, 0x7c, 0x3c, 0x2f, 0x62, 0x3e, + 0x20, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, + 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, + 0x2e, 0x66, 0x72, 0x65, 0x65, 0x72, 0x74, 0x6f, 0x73, 0x2e, + 0x6f, 0x72, 0x67, 0x2f, 0x22, 0x3e, 0x46, 0x72, 0x65, 0x65, + 0x52, 0x54, 0x4f, 0x53, 0x2e, 0x6f, 0x72, 0x67, 0x20, 0x48, + 0x6f, 0x6d, 0x65, 0x70, 0x61, 0x67, 0x65, 0x3c, 0x2f, 0x61, + 0x3e, 0x20, 0x3c, 0x62, 0x3e, 0x7c, 0x3c, 0x2f, 0x62, 0x3e, + 0x20, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, + 0x69, 0x6f, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, + 0x49, 0x4f, 0x3c, 0x2f, 0x61, 0x3e, 0xd, 0xa, 0x3c, 0x62, + 0x72, 0x3e, 0x3c, 0x70, 0x3e, 0xd, 0xa, 0x3c, 0x68, 0x72, + 0x3e, 0xd, 0xa, 0x3c, 0x62, 0x3e, 0x4c, 0x45, 0x44, 0x20, + 0x61, 0x6e, 0x64, 0x20, 0x4c, 0x43, 0x44, 0x20, 0x49, 0x4f, + 0x3c, 0x2f, 0x62, 0x3e, 0x3c, 0x62, 0x72, 0x3e, 0xd, 0xa, + 0xd, 0xa, 0x3c, 0x70, 0x3e, 0xd, 0xa, 0xd, 0xa, 0x55, + 0x73, 0x65, 0x20, 0x74, 0x68, 0x65, 0x20, 0x63, 0x68, 0x65, + 0x63, 0x6b, 0x20, 0x62, 0x6f, 0x78, 0x65, 0x73, 0x20, 0x74, + 0x6f, 0x20, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x20, 0x74, + 0x68, 0x65, 0x20, 0x4c, 0x45, 0x44, 0x27, 0x73, 0x20, 0x74, + 0x6f, 0x20, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x6f, 0x6e, 0x20, + 0x6f, 0x72, 0x20, 0x6f, 0x66, 0x66, 0x2c, 0x20, 0x65, 0x6e, + 0x74, 0x65, 0x72, 0x20, 0x74, 0x65, 0x78, 0x74, 0x20, 0x74, + 0x6f, 0x20, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x20, + 0x6f, 0x6e, 0x20, 0x74, 0x68, 0x65, 0x20, 0x4c, 0x43, 0x44, + 0x2c, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x20, 0x63, 0x6c, 0x69, + 0x63, 0x6b, 0x20, 0x22, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, + 0x20, 0x49, 0x4f, 0x22, 0x2e, 0xd, 0xa, 0xd, 0xa, 0xd, + 0xa, 0x3c, 0x70, 0x3e, 0xd, 0xa, 0x3c, 0x66, 0x6f, 0x72, + 0x6d, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x61, 0x46, + 0x6f, 0x72, 0x6d, 0x22, 0x20, 0x61, 0x63, 0x74, 0x69, 0x6f, + 0x6e, 0x3d, 0x22, 0x2f, 0x69, 0x6f, 0x2e, 0x73, 0x68, 0x74, + 0x6d, 0x6c, 0x22, 0x20, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, + 0x3d, 0x22, 0x67, 0x65, 0x74, 0x22, 0x3e, 0xd, 0xa, 0x25, + 0x21, 0x20, 0x6c, 0x65, 0x64, 0x2d, 0x69, 0x6f, 0xd, 0xa, + 0x3c, 0x70, 0x3e, 0xd, 0xa, 0x3c, 0x69, 0x6e, 0x70, 0x75, + 0x74, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x73, 0x75, + 0x62, 0x6d, 0x69, 0x74, 0x22, 0x20, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x3d, 0x22, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x20, + 0x49, 0x4f, 0x22, 0x3e, 0xd, 0xa, 0x3c, 0x2f, 0x66, 0x6f, + 0x72, 0x6d, 0x3e, 0xd, 0xa, 0x3c, 0x62, 0x72, 0x3e, 0x3c, + 0x70, 0x3e, 0xd, 0xa, 0x3c, 0x2f, 0x66, 0x6f, 0x6e, 0x74, + 0x3e, 0xd, 0xa, 0x3c, 0x2f, 0x62, 0x6f, 0x64, 0x79, 0x3e, + 0xd, 0xa, 0x3c, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0xd, + 0xa, 0xd, 0xa, 0}; + +static const unsigned char data_stats_shtml[] = { + /* /stats.shtml */ + 0x2f, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0, + 0x3c, 0x21, 0x44, 0x4f, 0x43, 0x54, 0x59, 0x50, 0x45, 0x20, + 0x48, 0x54, 0x4d, 0x4c, 0x20, 0x50, 0x55, 0x42, 0x4c, 0x49, + 0x43, 0x20, 0x22, 0x2d, 0x2f, 0x2f, 0x57, 0x33, 0x43, 0x2f, + 0x2f, 0x44, 0x54, 0x44, 0x20, 0x48, 0x54, 0x4d, 0x4c, 0x20, + 0x34, 0x2e, 0x30, 0x31, 0x20, 0x54, 0x72, 0x61, 0x6e, 0x73, + 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x2f, 0x2f, 0x45, + 0x4e, 0x22, 0x20, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, + 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x77, 0x33, 0x2e, 0x6f, 0x72, + 0x67, 0x2f, 0x54, 0x52, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x34, + 0x2f, 0x6c, 0x6f, 0x6f, 0x73, 0x65, 0x2e, 0x64, 0x74, 0x64, + 0x22, 0x3e, 0xd, 0xa, 0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e, + 0xd, 0xa, 0x20, 0x20, 0x3c, 0x68, 0x65, 0x61, 0x64, 0x3e, + 0xd, 0xa, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x74, 0x69, 0x74, + 0x6c, 0x65, 0x3e, 0x46, 0x72, 0x65, 0x65, 0x52, 0x54, 0x4f, + 0x53, 0x2e, 0x6f, 0x72, 0x67, 0x20, 0x75, 0x49, 0x50, 0x20, + 0x57, 0x45, 0x42, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, + 0x20, 0x64, 0x65, 0x6d, 0x6f, 0x3c, 0x2f, 0x74, 0x69, 0x74, + 0x6c, 0x65, 0x3e, 0xd, 0xa, 0x20, 0x20, 0x3c, 0x2f, 0x68, + 0x65, 0x61, 0x64, 0x3e, 0xd, 0xa, 0x20, 0x20, 0x3c, 0x42, + 0x4f, 0x44, 0x59, 0x20, 0x62, 0x67, 0x63, 0x6f, 0x6c, 0x6f, + 0x72, 0x3d, 0x22, 0x23, 0x43, 0x43, 0x43, 0x43, 0x66, 0x66, + 0x22, 0x3e, 0xd, 0xa, 0x3c, 0x66, 0x6f, 0x6e, 0x74, 0x20, + 0x66, 0x61, 0x63, 0x65, 0x3d, 0x22, 0x61, 0x72, 0x69, 0x61, + 0x6c, 0x22, 0x3e, 0xd, 0xa, 0x3c, 0x61, 0x20, 0x68, 0x72, + 0x65, 0x66, 0x3d, 0x22, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, + 0x73, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x52, 0x54, 0x4f, + 0x53, 0x20, 0x53, 0x74, 0x61, 0x74, 0x73, 0x3c, 0x2f, 0x61, + 0x3e, 0x20, 0x3c, 0x62, 0x3e, 0x7c, 0x3c, 0x2f, 0x62, 0x3e, + 0x20, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, + 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x73, 0x68, 0x74, 0x6d, + 0x6c, 0x22, 0x3e, 0x54, 0x43, 0x50, 0x20, 0x53, 0x74, 0x61, + 0x74, 0x73, 0x3c, 0x2f, 0x61, 0x3e, 0x20, 0x3c, 0x62, 0x3e, + 0x7c, 0x3c, 0x2f, 0x62, 0x3e, 0x20, 0x3c, 0x61, 0x20, 0x68, + 0x72, 0x65, 0x66, 0x3d, 0x22, 0x74, 0x63, 0x70, 0x2e, 0x73, + 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x43, 0x6f, 0x6e, 0x6e, + 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x3c, 0x2f, 0x61, + 0x3e, 0x20, 0x3c, 0x62, 0x3e, 0x7c, 0x3c, 0x2f, 0x62, 0x3e, + 0x20, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, + 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, + 0x2e, 0x66, 0x72, 0x65, 0x65, 0x72, 0x74, 0x6f, 0x73, 0x2e, + 0x6f, 0x72, 0x67, 0x2f, 0x22, 0x3e, 0x46, 0x72, 0x65, 0x65, + 0x52, 0x54, 0x4f, 0x53, 0x2e, 0x6f, 0x72, 0x67, 0x20, 0x48, + 0x6f, 0x6d, 0x65, 0x70, 0x61, 0x67, 0x65, 0x3c, 0x2f, 0x61, + 0x3e, 0x20, 0x3c, 0x62, 0x3e, 0x7c, 0x3c, 0x2f, 0x62, 0x3e, + 0x20, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, + 0x69, 0x6f, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, + 0x49, 0x4f, 0x3c, 0x2f, 0x61, 0x3e, 0xd, 0xa, 0x3c, 0x62, + 0x72, 0x3e, 0x3c, 0x70, 0x3e, 0xd, 0xa, 0x3c, 0x68, 0x72, + 0x3e, 0xd, 0xa, 0x3c, 0x62, 0x72, 0x3e, 0x3c, 0x70, 0x3e, + 0xd, 0xa, 0x3c, 0x68, 0x32, 0x3e, 0x4e, 0x65, 0x74, 0x77, + 0x6f, 0x72, 0x6b, 0x20, 0x73, 0x74, 0x61, 0x74, 0x69, 0x73, + 0x74, 0x69, 0x63, 0x73, 0x3c, 0x2f, 0x68, 0x32, 0x3e, 0xd, + 0xa, 0x3c, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x77, 0x69, + 0x64, 0x74, 0x68, 0x3d, 0x22, 0x33, 0x30, 0x30, 0x22, 0x20, + 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x3d, 0x22, 0x30, 0x22, + 0x3e, 0xd, 0xa, 0x3c, 0x74, 0x72, 0x3e, 0x3c, 0x74, 0x64, + 0x20, 0x61, 0x6c, 0x69, 0x67, 0x6e, 0x3d, 0x22, 0x6c, 0x65, + 0x66, 0x74, 0x22, 0x3e, 0x3c, 0x66, 0x6f, 0x6e, 0x74, 0x20, + 0x66, 0x61, 0x63, 0x65, 0x3d, 0x22, 0x63, 0x6f, 0x75, 0x72, + 0x69, 0x65, 0x72, 0x22, 0x3e, 0x3c, 0x70, 0x72, 0x65, 0x3e, + 0xd, 0xa, 0x49, 0x50, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x50, 0x61, 0x63, 0x6b, 0x65, + 0x74, 0x73, 0x20, 0x64, 0x72, 0x6f, 0x70, 0x70, 0x65, 0x64, + 0xd, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x50, 0x61, 0x63, 0x6b, 0x65, + 0x74, 0x73, 0x20, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, + 0x64, 0xd, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x50, 0x61, 0x63, 0x6b, + 0x65, 0x74, 0x73, 0x20, 0x73, 0x65, 0x6e, 0x74, 0xd, 0xa, + 0x49, 0x50, 0x20, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x20, + 0x20, 0x20, 0x20, 0x49, 0x50, 0x20, 0x76, 0x65, 0x72, 0x73, + 0x69, 0x6f, 0x6e, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, + 0x20, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0xd, 0xa, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x49, 0x50, 0x20, 0x6c, 0x65, 0x6e, 0x67, 0x74, + 0x68, 0x2c, 0x20, 0x68, 0x69, 0x67, 0x68, 0x20, 0x62, 0x79, + 0x74, 0x65, 0xd, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x49, 0x50, 0x20, + 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x2c, 0x20, 0x6c, 0x6f, + 0x77, 0x20, 0x62, 0x79, 0x74, 0x65, 0xd, 0xa, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x49, 0x50, 0x20, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, + 0x6e, 0x74, 0x73, 0xd, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x48, 0x65, + 0x61, 0x64, 0x65, 0x72, 0x20, 0x63, 0x68, 0x65, 0x63, 0x6b, + 0x73, 0x75, 0x6d, 0xd, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x57, 0x72, + 0x6f, 0x6e, 0x67, 0x20, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, + 0x6f, 0x6c, 0xd, 0xa, 0x49, 0x43, 0x4d, 0x50, 0x9, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, + 0x73, 0x20, 0x64, 0x72, 0x6f, 0x70, 0x70, 0x65, 0x64, 0xd, + 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, + 0x73, 0x20, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, + 0xd, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x50, 0x61, 0x63, 0x6b, 0x65, + 0x74, 0x73, 0x20, 0x73, 0x65, 0x6e, 0x74, 0xd, 0xa, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x54, 0x79, 0x70, 0x65, 0x20, 0x65, 0x72, 0x72, + 0x6f, 0x72, 0x73, 0xd, 0xa, 0x54, 0x43, 0x50, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x50, 0x61, + 0x63, 0x6b, 0x65, 0x74, 0x73, 0x20, 0x64, 0x72, 0x6f, 0x70, + 0x70, 0x65, 0x64, 0xd, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x50, 0x61, + 0x63, 0x6b, 0x65, 0x74, 0x73, 0x20, 0x72, 0x65, 0x63, 0x65, + 0x69, 0x76, 0x65, 0x64, 0xd, 0xa, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x50, + 0x61, 0x63, 0x6b, 0x65, 0x74, 0x73, 0x20, 0x73, 0x65, 0x6e, + 0x74, 0xd, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x43, 0x68, 0x65, 0x63, + 0x6b, 0x73, 0x75, 0x6d, 0x20, 0x65, 0x72, 0x72, 0x6f, 0x72, + 0x73, 0xd, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x44, 0x61, 0x74, 0x61, + 0x20, 0x70, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x73, 0x20, 0x77, + 0x69, 0x74, 0x68, 0x6f, 0x75, 0x74, 0x20, 0x41, 0x43, 0x4b, + 0x73, 0xd, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x52, 0x65, 0x73, 0x65, + 0x74, 0x73, 0xd, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x52, 0x65, 0x74, + 0x72, 0x61, 0x6e, 0x73, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, + 0x6e, 0x73, 0xd, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x4e, 0x6f, 0x20, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, + 0x69, 0x6f, 0x6e, 0x20, 0x61, 0x76, 0x61, 0x6c, 0x69, 0x61, + 0x62, 0x6c, 0x65, 0xd, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, + 0x6e, 0x20, 0x61, 0x74, 0x74, 0x65, 0x6d, 0x70, 0x74, 0x73, + 0x20, 0x74, 0x6f, 0x20, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0x64, + 0x20, 0x70, 0x6f, 0x72, 0x74, 0x73, 0xd, 0xa, 0x3c, 0x2f, + 0x70, 0x72, 0x65, 0x3e, 0x3c, 0x2f, 0x66, 0x6f, 0x6e, 0x74, + 0x3e, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x74, 0x64, 0x3e, + 0x3c, 0x70, 0x72, 0x65, 0x3e, 0x25, 0x21, 0x20, 0x6e, 0x65, + 0x74, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x73, 0xd, 0xa, 0x3c, + 0x2f, 0x70, 0x72, 0x65, 0x3e, 0x3c, 0x2f, 0x74, 0x61, 0x62, + 0x6c, 0x65, 0x3e, 0xd, 0xa, 0x3c, 0x2f, 0x66, 0x6f, 0x6e, + 0x74, 0x3e, 0xd, 0xa, 0x3c, 0x2f, 0x62, 0x6f, 0x64, 0x79, + 0x3e, 0xd, 0xa, 0x3c, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x3e, + 0xd, 0xa, 0}; + +static const unsigned char data_tcp_shtml[] = { + /* /tcp.shtml */ + 0x2f, 0x74, 0x63, 0x70, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0, + 0x3c, 0x21, 0x44, 0x4f, 0x43, 0x54, 0x59, 0x50, 0x45, 0x20, + 0x48, 0x54, 0x4d, 0x4c, 0x20, 0x50, 0x55, 0x42, 0x4c, 0x49, + 0x43, 0x20, 0x22, 0x2d, 0x2f, 0x2f, 0x57, 0x33, 0x43, 0x2f, + 0x2f, 0x44, 0x54, 0x44, 0x20, 0x48, 0x54, 0x4d, 0x4c, 0x20, + 0x34, 0x2e, 0x30, 0x31, 0x20, 0x54, 0x72, 0x61, 0x6e, 0x73, + 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x2f, 0x2f, 0x45, + 0x4e, 0x22, 0x20, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, + 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x77, 0x33, 0x2e, 0x6f, 0x72, + 0x67, 0x2f, 0x54, 0x52, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x34, + 0x2f, 0x6c, 0x6f, 0x6f, 0x73, 0x65, 0x2e, 0x64, 0x74, 0x64, + 0x22, 0x3e, 0xd, 0xa, 0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e, + 0xd, 0xa, 0x20, 0x20, 0x3c, 0x68, 0x65, 0x61, 0x64, 0x3e, + 0xd, 0xa, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x74, 0x69, 0x74, + 0x6c, 0x65, 0x3e, 0x46, 0x72, 0x65, 0x65, 0x52, 0x54, 0x4f, + 0x53, 0x2e, 0x6f, 0x72, 0x67, 0x20, 0x75, 0x49, 0x50, 0x20, + 0x57, 0x45, 0x42, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, + 0x20, 0x64, 0x65, 0x6d, 0x6f, 0x3c, 0x2f, 0x74, 0x69, 0x74, + 0x6c, 0x65, 0x3e, 0xd, 0xa, 0x20, 0x20, 0x3c, 0x2f, 0x68, + 0x65, 0x61, 0x64, 0x3e, 0xd, 0xa, 0x20, 0x20, 0x3c, 0x42, + 0x4f, 0x44, 0x59, 0x20, 0x62, 0x67, 0x63, 0x6f, 0x6c, 0x6f, + 0x72, 0x3d, 0x22, 0x23, 0x43, 0x43, 0x43, 0x43, 0x66, 0x66, + 0x22, 0x3e, 0xd, 0xa, 0x3c, 0x66, 0x6f, 0x6e, 0x74, 0x20, + 0x66, 0x61, 0x63, 0x65, 0x3d, 0x22, 0x61, 0x72, 0x69, 0x61, + 0x6c, 0x22, 0x3e, 0xd, 0xa, 0x3c, 0x61, 0x20, 0x68, 0x72, + 0x65, 0x66, 0x3d, 0x22, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, + 0x73, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x52, 0x54, 0x4f, + 0x53, 0x20, 0x53, 0x74, 0x61, 0x74, 0x73, 0x3c, 0x2f, 0x61, + 0x3e, 0x20, 0x3c, 0x62, 0x3e, 0x7c, 0x3c, 0x2f, 0x62, 0x3e, + 0x20, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, + 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x73, 0x68, 0x74, 0x6d, + 0x6c, 0x22, 0x3e, 0x54, 0x43, 0x50, 0x20, 0x53, 0x74, 0x61, + 0x74, 0x73, 0x3c, 0x2f, 0x61, 0x3e, 0x20, 0x3c, 0x62, 0x3e, + 0x7c, 0x3c, 0x2f, 0x62, 0x3e, 0x20, 0x3c, 0x61, 0x20, 0x68, + 0x72, 0x65, 0x66, 0x3d, 0x22, 0x74, 0x63, 0x70, 0x2e, 0x73, + 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x43, 0x6f, 0x6e, 0x6e, + 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x3c, 0x2f, 0x61, + 0x3e, 0x20, 0x3c, 0x62, 0x3e, 0x7c, 0x3c, 0x2f, 0x62, 0x3e, + 0x20, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, + 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, + 0x2e, 0x66, 0x72, 0x65, 0x65, 0x72, 0x74, 0x6f, 0x73, 0x2e, + 0x6f, 0x72, 0x67, 0x2f, 0x22, 0x3e, 0x46, 0x72, 0x65, 0x65, + 0x52, 0x54, 0x4f, 0x53, 0x2e, 0x6f, 0x72, 0x67, 0x20, 0x48, + 0x6f, 0x6d, 0x65, 0x70, 0x61, 0x67, 0x65, 0x3c, 0x2f, 0x61, + 0x3e, 0x20, 0x3c, 0x62, 0x3e, 0x7c, 0x3c, 0x2f, 0x62, 0x3e, + 0x20, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, + 0x69, 0x6f, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, + 0x49, 0x4f, 0x3c, 0x2f, 0x61, 0x3e, 0xd, 0xa, 0x3c, 0x62, + 0x72, 0x3e, 0x3c, 0x70, 0x3e, 0xd, 0xa, 0x3c, 0x68, 0x72, + 0x3e, 0xd, 0xa, 0x3c, 0x62, 0x72, 0x3e, 0xd, 0xa, 0x3c, + 0x68, 0x32, 0x3e, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, + 0x20, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, + 0x6e, 0x73, 0x3c, 0x2f, 0x68, 0x32, 0x3e, 0xd, 0xa, 0x3c, + 0x70, 0x3e, 0xd, 0xa, 0x3c, 0x74, 0x61, 0x62, 0x6c, 0x65, + 0x3e, 0xd, 0xa, 0x3c, 0x74, 0x72, 0x3e, 0x3c, 0x74, 0x68, + 0x3e, 0x4c, 0x6f, 0x63, 0x61, 0x6c, 0x3c, 0x2f, 0x74, 0x68, + 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x52, 0x65, 0x6d, 0x6f, 0x74, + 0x65, 0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, + 0x53, 0x74, 0x61, 0x74, 0x65, 0x3c, 0x2f, 0x74, 0x68, 0x3e, + 0x3c, 0x74, 0x68, 0x3e, 0x52, 0x65, 0x74, 0x72, 0x61, 0x6e, + 0x73, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x3c, + 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x54, 0x69, + 0x6d, 0x65, 0x72, 0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74, + 0x68, 0x3e, 0x46, 0x6c, 0x61, 0x67, 0x73, 0x3c, 0x2f, 0x74, + 0x68, 0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 0xd, 0xa, 0x25, + 0x21, 0x20, 0x74, 0x63, 0x70, 0x2d, 0x63, 0x6f, 0x6e, 0x6e, + 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0xd, 0xa, 0x3c, + 0x2f, 0x70, 0x72, 0x65, 0x3e, 0x3c, 0x2f, 0x66, 0x6f, 0x6e, + 0x74, 0x3e, 0xd, 0xa, 0x3c, 0x2f, 0x66, 0x6f, 0x6e, 0x74, + 0x3e, 0xd, 0xa, 0x3c, 0x2f, 0x62, 0x6f, 0x64, 0x79, 0x3e, + 0xd, 0xa, 0x3c, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0xd, + 0xa, 0xd, 0xa, 0}; + +const struct httpd_fsdata_file file_404_html[] = {{NULL, data_404_html, data_404_html + 10, sizeof(data_404_html) - 10}}; + +const struct httpd_fsdata_file file_index_html[] = {{file_404_html, data_index_html, data_index_html + 12, sizeof(data_index_html) - 12}}; + +const struct httpd_fsdata_file file_index_shtml[] = {{file_index_html, data_index_shtml, data_index_shtml + 13, sizeof(data_index_shtml) - 13}}; + +const struct httpd_fsdata_file file_io_shtml[] = {{file_index_shtml, data_io_shtml, data_io_shtml + 10, sizeof(data_io_shtml) - 10}}; + +const struct httpd_fsdata_file file_stats_shtml[] = {{file_io_shtml, data_stats_shtml, data_stats_shtml + 13, sizeof(data_stats_shtml) - 13}}; + +const struct httpd_fsdata_file file_tcp_shtml[] = {{file_stats_shtml, data_tcp_shtml, data_tcp_shtml + 11, sizeof(data_tcp_shtml) - 11}}; + +#define HTTPD_FS_ROOT file_tcp_shtml + +#define HTTPD_FS_NUMFILES 6 diff --git a/Tester/SW/lib/Drivers/webserver/httpd-fsdata.h b/Tester/SW/lib/Drivers/webserver/httpd-fsdata.h new file mode 100644 index 0000000..52d35c2 --- /dev/null +++ b/Tester/SW/lib/Drivers/webserver/httpd-fsdata.h @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2001, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + * $Id: httpd-fsdata.h,v 1.1 2006/06/07 09:13:08 adam Exp $ + */ +#ifndef __HTTPD_FSDATA_H__ +#define __HTTPD_FSDATA_H__ + +#include "uip.h" + +struct httpd_fsdata_file { + const struct httpd_fsdata_file *next; + const char *name; + const char *data; + const int len; +#ifdef HTTPD_FS_STATISTICS +#if HTTPD_FS_STATISTICS == 1 + u16_t count; +#endif /* HTTPD_FS_STATISTICS */ +#endif /* HTTPD_FS_STATISTICS */ +}; + +struct httpd_fsdata_file_noconst { + struct httpd_fsdata_file *next; + char *name; + char *data; + int len; +#ifdef HTTPD_FS_STATISTICS +#if HTTPD_FS_STATISTICS == 1 + u16_t count; +#endif /* HTTPD_FS_STATISTICS */ +#endif /* HTTPD_FS_STATISTICS */ +}; + +#endif /* __HTTPD_FSDATA_H__ */ diff --git a/Tester/SW/lib/Drivers/webserver/httpd.c b/Tester/SW/lib/Drivers/webserver/httpd.c new file mode 100644 index 0000000..644cf16 --- /dev/null +++ b/Tester/SW/lib/Drivers/webserver/httpd.c @@ -0,0 +1,346 @@ +/** + * \addtogroup apps + * @{ + */ + +/** + * \defgroup httpd Web server + * @{ + * The uIP web server is a very simplistic implementation of an HTTP + * server. It can serve web pages and files from a read-only ROM + * filesystem, and provides a very small scripting language. + + */ + +/** + * \file + * Web server + * \author + * Adam Dunkels + */ + + +/* + * Copyright (c) 2004, Adam Dunkels. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of the uIP TCP/IP stack. + * + * Author: Adam Dunkels + * + * $Id: httpd.c,v 1.2 2006/06/11 21:46:38 adam Exp $ + */ + +#include "uip.h" +#include "httpd.h" +#include "httpd-fs.h" +#include "httpd-cgi.h" +#include "http-strings.h" + +#include + +#define STATE_WAITING 0 +#define STATE_OUTPUT 1 + +#define ISO_nl 0x0a +#define ISO_space 0x20 +#define ISO_bang 0x21 +#define ISO_percent 0x25 +#define ISO_period 0x2e +#define ISO_slash 0x2f +#define ISO_colon 0x3a + + +/*---------------------------------------------------------------------------*/ +static unsigned short +generate_part_of_file(void *state) +{ + struct httpd_state *s = (struct httpd_state *)state; + + if(s->file.len > uip_mss()) { + s->len = uip_mss(); + } else { + s->len = s->file.len; + } + memcpy(uip_appdata, s->file.data, s->len); + + return s->len; +} +/*---------------------------------------------------------------------------*/ +static +PT_THREAD(send_file(struct httpd_state *s)) +{ + PSOCK_BEGIN(&s->sout); + + do { + PSOCK_GENERATOR_SEND(&s->sout, generate_part_of_file, s); + s->file.len -= s->len; + s->file.data += s->len; + } while(s->file.len > 0); + + PSOCK_END(&s->sout); +} +/*---------------------------------------------------------------------------*/ +static +PT_THREAD(send_part_of_file(struct httpd_state *s)) +{ + PSOCK_BEGIN(&s->sout); + + PSOCK_SEND(&s->sout, s->file.data, s->len); + + PSOCK_END(&s->sout); +} +/*---------------------------------------------------------------------------*/ +static void +next_scriptstate(struct httpd_state *s) +{ + char *p; + p = strchr(s->scriptptr, ISO_nl) + 1; + s->scriptlen -= (unsigned short)(p - s->scriptptr); + s->scriptptr = p; +} +/*---------------------------------------------------------------------------*/ +static +PT_THREAD(handle_script(struct httpd_state *s)) +{ + char *ptr; + + PT_BEGIN(&s->scriptpt); + + + while(s->file.len > 0) { + + /* Check if we should start executing a script. */ + if(*s->file.data == ISO_percent && + *(s->file.data + 1) == ISO_bang) { + s->scriptptr = s->file.data + 3; + s->scriptlen = s->file.len - 3; + if(*(s->scriptptr - 1) == ISO_colon) { + httpd_fs_open(s->scriptptr + 1, &s->file); + PT_WAIT_THREAD(&s->scriptpt, send_file(s)); + } else { + PT_WAIT_THREAD(&s->scriptpt, + httpd_cgi(s->scriptptr)(s, s->scriptptr)); + } + next_scriptstate(s); + + /* The script is over, so we reset the pointers and continue + sending the rest of the file. */ + s->file.data = s->scriptptr; + s->file.len = s->scriptlen; + } else { + /* See if we find the start of script marker in the block of HTML + to be sent. */ + + if(s->file.len > uip_mss()) { + s->len = uip_mss(); + } else { + s->len = s->file.len; + } + + if(*s->file.data == ISO_percent) { + ptr = strchr(s->file.data + 1, ISO_percent); + } else { + ptr = strchr(s->file.data, ISO_percent); + } + if(ptr != NULL && + ptr != s->file.data) { + s->len = (int)(ptr - s->file.data); + if(s->len >= uip_mss()) { + s->len = uip_mss(); + } + } + PT_WAIT_THREAD(&s->scriptpt, send_part_of_file(s)); + s->file.data += s->len; + s->file.len -= s->len; + + } + } + + PT_END(&s->scriptpt); +} +/*---------------------------------------------------------------------------*/ +static +PT_THREAD(send_headers(struct httpd_state *s, const char *statushdr)) +{ + char *ptr; + + PSOCK_BEGIN(&s->sout); + + PSOCK_SEND_STR(&s->sout, statushdr); + + ptr = strrchr(s->filename, ISO_period); + if(ptr == NULL) { + PSOCK_SEND_STR(&s->sout, http_content_type_binary); + } else if(strncmp(http_html, ptr, 5) == 0 || + strncmp(http_shtml, ptr, 6) == 0) { + PSOCK_SEND_STR(&s->sout, http_content_type_html); + } else if(strncmp(http_css, ptr, 4) == 0) { + PSOCK_SEND_STR(&s->sout, http_content_type_css); + } else if(strncmp(http_png, ptr, 4) == 0) { + PSOCK_SEND_STR(&s->sout, http_content_type_png); + } else if(strncmp(http_gif, ptr, 4) == 0) { + PSOCK_SEND_STR(&s->sout, http_content_type_gif); + } else if(strncmp(http_jpg, ptr, 4) == 0) { + PSOCK_SEND_STR(&s->sout, http_content_type_jpg); + } else { + PSOCK_SEND_STR(&s->sout, http_content_type_plain); + } + PSOCK_END(&s->sout); +} +/*---------------------------------------------------------------------------*/ +static +PT_THREAD(handle_output(struct httpd_state *s)) +{ + char *ptr; + + PT_BEGIN(&s->outputpt); + + if(!httpd_fs_open(s->filename, &s->file)) { + httpd_fs_open(http_404_html, &s->file); + strcpy(s->filename, http_404_html); + PT_WAIT_THREAD(&s->outputpt, + send_headers(s, + http_header_404)); + PT_WAIT_THREAD(&s->outputpt, + send_file(s)); + } else { + PT_WAIT_THREAD(&s->outputpt, + send_headers(s, + http_header_200)); + ptr = strchr(s->filename, ISO_period); + if(ptr != NULL && strncmp(ptr, http_shtml, 6) == 0) { + PT_INIT(&s->scriptpt); + PT_WAIT_THREAD(&s->outputpt, handle_script(s)); + } else { + PT_WAIT_THREAD(&s->outputpt, + send_file(s)); + } + } + PSOCK_CLOSE(&s->sout); + PT_END(&s->outputpt); +} +/*---------------------------------------------------------------------------*/ +static +PT_THREAD(handle_input(struct httpd_state *s)) +{ + PSOCK_BEGIN(&s->sin); + + PSOCK_READTO(&s->sin, ISO_space); + + + if(strncmp(s->inputbuf, http_get, 4) != 0) { + PSOCK_CLOSE_EXIT(&s->sin); + } + PSOCK_READTO(&s->sin, ISO_space); + + if(s->inputbuf[0] != ISO_slash) { + PSOCK_CLOSE_EXIT(&s->sin); + } + + if(s->inputbuf[1] == ISO_space) { + strncpy(s->filename, http_index_html, sizeof(s->filename)); + } else { + + s->inputbuf[PSOCK_DATALEN(&s->sin) - 1] = 0; + + /* Process any form input being sent to the server. */ + { + extern void vApplicationProcessFormInput( char *pcInputString, long xInputLength ); + vApplicationProcessFormInput( s->inputbuf, PSOCK_DATALEN(&s->sin) ); + } + + strncpy(s->filename, &s->inputbuf[0], sizeof(s->filename)); + } + + /* httpd_log_file(uip_conn->ripaddr, s->filename);*/ + + s->state = STATE_OUTPUT; + + while(1) { + PSOCK_READTO(&s->sin, ISO_nl); + + if(strncmp(s->inputbuf, http_referer, 8) == 0) { + s->inputbuf[PSOCK_DATALEN(&s->sin) - 2] = 0; + /* httpd_log(&s->inputbuf[9]);*/ + } + } + + PSOCK_END(&s->sin); +} +/*---------------------------------------------------------------------------*/ +static void +handle_connection(struct httpd_state *s) +{ + handle_input(s); + if(s->state == STATE_OUTPUT) { + handle_output(s); + } +} +/*---------------------------------------------------------------------------*/ +void +httpd_appcall(void) +{ + struct httpd_state *s = (struct httpd_state *)&(uip_conn->appstate); + + if(uip_closed() || uip_aborted() || uip_timedout()) { + } else if(uip_connected()) { + PSOCK_INIT(&s->sin, s->inputbuf, sizeof(s->inputbuf) - 1); + PSOCK_INIT(&s->sout, s->inputbuf, sizeof(s->inputbuf) - 1); + PT_INIT(&s->outputpt); + s->state = STATE_WAITING; + /* timer_set(&s->timer, CLOCK_SECOND * 100);*/ + s->timer = 0; + handle_connection(s); + } else if(s != NULL) { + if(uip_poll()) { + ++s->timer; + if(s->timer >= 20) { + uip_abort(); + } + } else { + s->timer = 0; + } + handle_connection(s); + } else { + uip_abort(); + } +} +/*---------------------------------------------------------------------------*/ +/** + * \brief Initialize the web server + * + * This function initializes the web server and should be + * called at system boot-up. + */ +void +httpd_init(void) +{ + uip_listen(HTONS(80)); +} +/*---------------------------------------------------------------------------*/ +/** @} */ diff --git a/Tester/SW/lib/Drivers/webserver/httpd.h b/Tester/SW/lib/Drivers/webserver/httpd.h new file mode 100644 index 0000000..7f7a666 --- /dev/null +++ b/Tester/SW/lib/Drivers/webserver/httpd.h @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2001-2005, Adam Dunkels. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This file is part of the uIP TCP/IP stack. + * + * $Id: httpd.h,v 1.2 2006/06/11 21:46:38 adam Exp $ + * + */ + +#ifndef __HTTPD_H__ +#define __HTTPD_H__ + +#include "psock.h" +#include "httpd-fs.h" + +struct httpd_state { + unsigned char timer; + struct psock sin, sout; + struct pt outputpt, scriptpt; + char inputbuf[50]; + char filename[20]; + char state; + struct httpd_fs_file file; + int len; + char *scriptptr; + int scriptlen; + + unsigned short count; +}; + +void httpd_init(void); +void httpd_appcall(void); + +void httpd_log(char *msg); +void httpd_log_file(u16_t *requester, char *file); + +#endif /* __HTTPD_H__ */ diff --git a/Tester/SW/lib/Drivers/webserver/makefsdata b/Tester/SW/lib/Drivers/webserver/makefsdata new file mode 100644 index 0000000..8d2715a --- /dev/null +++ b/Tester/SW/lib/Drivers/webserver/makefsdata @@ -0,0 +1,78 @@ +#!/usr/bin/perl + +open(OUTPUT, "> httpd-fsdata.c"); + +chdir("httpd-fs"); + +opendir(DIR, "."); +@files = grep { !/^\./ && !/(CVS|~)/ } readdir(DIR); +closedir(DIR); + +foreach $file (@files) { + + if(-d $file && $file !~ /^\./) { + print "Processing directory $file\n"; + opendir(DIR, $file); + @newfiles = grep { !/^\./ && !/(CVS|~)/ } readdir(DIR); + closedir(DIR); + printf "Adding files @newfiles\n"; + @files = (@files, map { $_ = "$file/$_" } @newfiles); + next; + } +} + +foreach $file (@files) { + if(-f $file) { + + print "Adding file $file\n"; + + open(FILE, $file) || die "Could not open file $file\n"; + + $file =~ s-^-/-; + $fvar = $file; + $fvar =~ s-/-_-g; + $fvar =~ s-\.-_-g; + # for AVR, add PROGMEM here + print(OUTPUT "static const unsigned char data".$fvar."[] = {\n"); + print(OUTPUT "\t/* $file */\n\t"); + for($j = 0; $j < length($file); $j++) { + printf(OUTPUT "%#02x, ", unpack("C", substr($file, $j, 1))); + } + printf(OUTPUT "0,\n"); + + + $i = 0; + while(read(FILE, $data, 1)) { + if($i == 0) { + print(OUTPUT "\t"); + } + printf(OUTPUT "%#02x, ", unpack("C", $data)); + $i++; + if($i == 10) { + print(OUTPUT "\n"); + $i = 0; + } + } + print(OUTPUT "0};\n\n"); + close(FILE); + push(@fvars, $fvar); + push(@pfiles, $file); + } +} + +for($i = 0; $i < @fvars; $i++) { + $file = $pfiles[$i]; + $fvar = $fvars[$i]; + + if($i == 0) { + $prevfile = "NULL"; + } else { + $prevfile = "file" . $fvars[$i - 1]; + } + print(OUTPUT "const struct httpd_fsdata_file file".$fvar."[] = {{$prevfile, data$fvar, "); + print(OUTPUT "data$fvar + ". (length($file) + 1) .", "); + print(OUTPUT "sizeof(data$fvar) - ". (length($file) + 1) ."}};\n\n"); +} + +print(OUTPUT "#define HTTPD_FS_ROOT file$fvars[$i - 1]\n\n"); +print(OUTPUT "#define HTTPD_FS_NUMFILES $i\n"); diff --git a/Tester/SW/lib/Drivers/webserver/makestrings b/Tester/SW/lib/Drivers/webserver/makestrings new file mode 100644 index 0000000..8a13c6d --- /dev/null +++ b/Tester/SW/lib/Drivers/webserver/makestrings @@ -0,0 +1,40 @@ +#!/usr/bin/perl + + +sub stringify { + my $name = shift(@_); + open(OUTPUTC, "> $name.c"); + open(OUTPUTH, "> $name.h"); + + open(FILE, "$name"); + + while() { + if(/(.+) "(.+)"/) { + $var = $1; + $data = $2; + + $datan = $data; + $datan =~ s/\\r/\r/g; + $datan =~ s/\\n/\n/g; + $datan =~ s/\\01/\01/g; + $datan =~ s/\\0/\0/g; + + printf(OUTPUTC "const char $var\[%d] = \n", length($datan) + 1); + printf(OUTPUTC "/* \"$data\" */\n"); + printf(OUTPUTC "{"); + for($j = 0; $j < length($datan); $j++) { + printf(OUTPUTC "%#02x, ", unpack("C", substr($datan, $j, 1))); + } + printf(OUTPUTC "};\n"); + + printf(OUTPUTH "extern const char $var\[%d];\n", length($datan) + 1); + + } + } + close(OUTPUTC); + close(OUTPUTH); +} +stringify("http-strings"); + +exit 0; + diff --git a/Tester/SW/lib/Drivers/webserver/uIP_Task.c b/Tester/SW/lib/Drivers/webserver/uIP_Task.c new file mode 100644 index 0000000..f870234 --- /dev/null +++ b/Tester/SW/lib/Drivers/webserver/uIP_Task.c @@ -0,0 +1,317 @@ +/* + FreeRTOS.org V5.1.0 - Copyright (C) 2003-2008 Richard Barry. + + This file is part of the FreeRTOS.org distribution. + + FreeRTOS.org is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + FreeRTOS.org is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with FreeRTOS.org; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + A special exception to the GPL can be applied should you wish to distribute + a combined work that includes FreeRTOS.org, without being obliged to provide + the source code for any proprietary components. See the licensing section + of http://www.FreeRTOS.org for full details of how and when the exception + can be applied. + + *************************************************************************** + See http://www.FreeRTOS.org for documentation, latest information, license + and contact details. Please ensure to read the configuration and relevant + port sections of the online documentation. + *************************************************************************** +*/ +/* Standard includes. */ +#include + +/* Scheduler includes. */ +#include "FreeRTOS.h" +#include "task.h" +#include "semphr.h" + +/* uip includes. */ +#include "uip.h" +#include "uip_arp.h" +#include "httpd.h" +#include "timer.h" +#include "clock-arch.h" + +/* Demo includes. */ +#include "emac.h" + +/*-----------------------------------------------------------*/ + +/* MAC address configuration. */ +#define uipMAC_ADDR0 0x00 +#define uipMAC_ADDR1 0x12 +#define uipMAC_ADDR2 0x13 +#define uipMAC_ADDR3 0x10 +#define uipMAC_ADDR4 0x15 +#define uipMAC_ADDR5 0x11 + +/* IP address configuration. */ +#define uipIP_ADDR0 172 +#define uipIP_ADDR1 25 +#define uipIP_ADDR2 218 +#define uipIP_ADDR3 16 + +/* How long to wait before attempting to connect the MAC again. */ +#define uipINIT_WAIT 100 + +/* Shortcut to the header within the Rx buffer. */ +#define xHeader ((struct uip_eth_hdr *) &uip_buf[ 0 ]) + +/* Standard constant. */ +#define uipTOTAL_FRAME_HEADER_SIZE 54 + +/*-----------------------------------------------------------*/ + +/* + * Send the uIP buffer to the MAC. + */ +static void prvENET_Send(void); + +/* + * Setup the MAC address in the MAC itself, and in the uIP stack. + */ +static void prvSetMACAddress( void ); + +/* + * Port functions required by the uIP stack. + */ +void clock_init( void ); +clock_time_t clock_time( void ); + +/*-----------------------------------------------------------*/ + +/* The semaphore used by the ISR to wake the uIP task. */ +extern xSemaphoreHandle xEMACSemaphore; + +/*-----------------------------------------------------------*/ + +void clock_init(void) +{ + /* This is done when the scheduler starts. */ +} +/*-----------------------------------------------------------*/ + +clock_time_t clock_time( void ) +{ + return xTaskGetTickCount(); +} +/*-----------------------------------------------------------*/ + +void vuIP_Task( void *pvParameters ) +{ +portBASE_TYPE i; +uip_ipaddr_t xIPAddr; +struct timer periodic_timer, arp_timer; +extern void ( vEMAC_ISR_Wrapper )( void ); + + /* Create the semaphore used by the ISR to wake this task. */ + vSemaphoreCreateBinary( xEMACSemaphore ); + + /* Initialise the uIP stack. */ + timer_set( &periodic_timer, configTICK_RATE_HZ / 2 ); + timer_set( &arp_timer, configTICK_RATE_HZ * 10 ); + uip_init(); + uip_ipaddr( xIPAddr, uipIP_ADDR0, uipIP_ADDR1, uipIP_ADDR2, uipIP_ADDR3 ); + uip_sethostaddr( xIPAddr ); + httpd_init(); + + /* Initialise the MAC. */ + while( Init_EMAC() != pdPASS ) + { + vTaskDelay( uipINIT_WAIT ); + } + + portENTER_CRITICAL(); + { + MAC_INTENABLE = INT_RX_DONE; + VICIntEnable |= 0x00200000; + VICVectAddr21 = ( portLONG ) vEMAC_ISR_Wrapper; + prvSetMACAddress(); + } + portEXIT_CRITICAL(); + + + for( ;; ) + { + /* Is there received data ready to be processed? */ + uip_len = uiGetEMACRxData( uip_buf ); + + if( uip_len > 0 ) + { + /* Standard uIP loop taken from the uIP manual. */ + if( xHeader->type == htons( UIP_ETHTYPE_IP ) ) + { + uip_arp_ipin(); + uip_input(); + + /* If the above function invocation resulted in data that + should be sent out on the network, the global variable + uip_len is set to a value > 0. */ + if( uip_len > 0 ) + { + uip_arp_out(); + prvENET_Send(); + } + } + else if( xHeader->type == htons( UIP_ETHTYPE_ARP ) ) + { + uip_arp_arpin(); + + /* If the above function invocation resulted in data that + should be sent out on the network, the global variable + uip_len is set to a value > 0. */ + if( uip_len > 0 ) + { + prvENET_Send(); + } + } + } + else + { + if( timer_expired( &periodic_timer ) ) + { + timer_reset( &periodic_timer ); + for( i = 0; i < UIP_CONNS; i++ ) + { + uip_periodic( i ); + + /* If the above function invocation resulted in data that + should be sent out on the network, the global variable + uip_len is set to a value > 0. */ + if( uip_len > 0 ) + { + uip_arp_out(); + prvENET_Send(); + } + } + + /* Call the ARP timer function every 10 seconds. */ + if( timer_expired( &arp_timer ) ) + { + timer_reset( &arp_timer ); + uip_arp_timer(); + } + } + else + { + /* We did not receive a packet, and there was no periodic + processing to perform. Block for a fixed period. If a packet + is received during this period we will be woken by the ISR + giving us the Semaphore. */ + xSemaphoreTake( xEMACSemaphore, configTICK_RATE_HZ / 2 ); + } + } + } +} +/*-----------------------------------------------------------*/ + +static void prvENET_Send(void) +{ + RequestSend(); + + /* Copy the header into the Tx buffer. */ + CopyToFrame_EMAC( uip_buf, uipTOTAL_FRAME_HEADER_SIZE ); + if( uip_len > uipTOTAL_FRAME_HEADER_SIZE ) + { + CopyToFrame_EMAC( uip_appdata, ( uip_len - uipTOTAL_FRAME_HEADER_SIZE ) ); + } + + DoSend_EMAC( uip_len ); +} +/*-----------------------------------------------------------*/ + +static void prvSetMACAddress( void ) +{ +struct uip_eth_addr xAddr; + + /* Configure the MAC address in the uIP stack. */ + xAddr.addr[ 0 ] = uipMAC_ADDR0; + xAddr.addr[ 1 ] = uipMAC_ADDR1; + xAddr.addr[ 2 ] = uipMAC_ADDR2; + xAddr.addr[ 3 ] = uipMAC_ADDR3; + xAddr.addr[ 4 ] = uipMAC_ADDR4; + xAddr.addr[ 5 ] = uipMAC_ADDR5; +// uip_setethaddr( xAddr ); +} +/*-----------------------------------------------------------*/ + +void vApplicationProcessFormInput( portCHAR *pcInputString, portBASE_TYPE xInputLength ) +{ +char *c, *pcText; +static portCHAR cMessageForDisplay[ 32 ]; +extern xQueueHandle xLCDQueue; +xLCDMessage xLCDMessage; + + /* Process the form input sent by the IO page of the served HTML. */ + + c = strstr( pcInputString, "?" ); + if( c ) + { + /* Turn LED's on or off in accordance with the check box status. */ + if( strstr( c, "LED0=1" ) != NULL ) + { +// vParTestSetLED( 5, 0 ); + } + else + { +// vParTestSetLED( 5, 1 ); + } + + if( strstr( c, "LED1=1" ) != NULL ) + { +// vParTestSetLED( 6, 0 ); + } + else + { +// vParTestSetLED( 6, 1 ); + } + + if( strstr( c, "LED2=1" ) != NULL ) + { +// vParTestSetLED( 7, 0 ); + } + else + { +// vParTestSetLED( 7, 1 ); + } + + /* Find the start of the text to be displayed on the LCD. */ + pcText = strstr( c, "LCD=" ); + pcText += strlen( "LCD=" ); + + /* Terminate the file name for further processing within uIP. */ + *c = 0x00; + + /* Terminate the LCD string. */ + c = strstr( pcText, " " ); + if( c != NULL ) + { + *c = 0x00; + } + + /* Add required spaces. */ + while( ( c = strstr( pcText, "+" ) ) != NULL ) + { + *c = ' '; + } + +// /* Write the message to the LCD. */ +// strcpy( cMessageForDisplay, pcText ); +// xLCDMessage.xColumn = 0; +// xLCDMessage.pcMessage = cMessageForDisplay; +// xQueueSend( xLCDQueue, &xLCDMessage, portMAX_DELAY ); + } +} + diff --git a/Tester/SW/lib/Drivers/webserver/uip-conf.h b/Tester/SW/lib/Drivers/webserver/uip-conf.h new file mode 100644 index 0000000..3e6f7f3 --- /dev/null +++ b/Tester/SW/lib/Drivers/webserver/uip-conf.h @@ -0,0 +1,157 @@ +/** + * \addtogroup uipopt + * @{ + */ + +/** + * \name Project-specific configuration options + * @{ + * + * uIP has a number of configuration options that can be overridden + * for each project. These are kept in a project-specific uip-conf.h + * file and all configuration names have the prefix UIP_CONF. + */ + +/* + * Copyright (c) 2006, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of the uIP TCP/IP stack + * + * $Id: uip-conf.h,v 1.6 2006/06/12 08:00:31 adam Exp $ + */ + +/** + * \file + * An example uIP configuration file + * \author + * Adam Dunkels + */ + +#ifndef __UIP_CONF_H__ +#define __UIP_CONF_H__ + +#include + +/** + * 8 bit datatype + * + * This typedef defines the 8-bit type used throughout uIP. + * + * \hideinitializer + */ +typedef uint8_t u8_t; + +/** + * 16 bit datatype + * + * This typedef defines the 16-bit type used throughout uIP. + * + * \hideinitializer + */ +typedef uint16_t u16_t; + +/** + * Statistics datatype + * + * This typedef defines the dataype used for keeping statistics in + * uIP. + * + * \hideinitializer + */ +typedef unsigned short uip_stats_t; + +/** + * Maximum number of TCP connections. + * + * \hideinitializer + */ +#define UIP_CONF_MAX_CONNECTIONS 40 + +/** + * Maximum number of listening TCP ports. + * + * \hideinitializer + */ +#define UIP_CONF_MAX_LISTENPORTS 40 + +/** + * uIP buffer size. + * + * \hideinitializer + */ +#define UIP_CONF_BUFFER_SIZE 1480 + +/** + * CPU byte order. + * + * \hideinitializer + */ +#define UIP_CONF_BYTE_ORDER LITTLE_ENDIAN + +/** + * Logging on or off + * + * \hideinitializer + */ +#define UIP_CONF_LOGGING 0 + +/** + * UDP support on or off + * + * \hideinitializer + */ +#define UIP_CONF_UDP 0 + +/** + * UDP checksums on or off + * + * \hideinitializer + */ +#define UIP_CONF_UDP_CHECKSUMS 1 + +/** + * uIP statistics on or off + * + * \hideinitializer + */ +#define UIP_CONF_STATISTICS 1 + +/* Here we include the header file for the application(s) we use in + our project. */ +/*#include "smtp.h"*/ +/*#include "hello-world.h"*/ +/*#include "telnetd.h"*/ +#include "webserver.h" +/*#include "dhcpc.h"*/ +/*#include "resolv.h"*/ +/*#include "webclient.h"*/ + +#endif /* __UIP_CONF_H__ */ + +/** @} */ +/** @} */ diff --git a/Tester/SW/lib/Drivers/webserver/webserver.h b/Tester/SW/lib/Drivers/webserver/webserver.h new file mode 100644 index 0000000..1acb290 --- /dev/null +++ b/Tester/SW/lib/Drivers/webserver/webserver.h @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2002, Adam Dunkels. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This file is part of the uIP TCP/IP stack + * + * $Id: webserver.h,v 1.2 2006/06/11 21:46:38 adam Exp $ + * + */ +#ifndef __WEBSERVER_H__ +#define __WEBSERVER_H__ + +#include "httpd.h" + +typedef struct httpd_state uip_tcp_appstate_t; +/* UIP_APPCALL: the name of the application function. This function + must return void and take no arguments (i.e., C type "void + appfunc(void)"). */ +#ifndef UIP_APPCALL +#define UIP_APPCALL httpd_appcall +#endif + + +#endif /* __WEBSERVER_H__ */ diff --git a/Tester/SW/lib/FreeRTOS/Source/.cproject b/Tester/SW/lib/FreeRTOS/Source/.cproject new file mode 100644 index 0000000..86465e3 --- /dev/null +++ b/Tester/SW/lib/FreeRTOS/Source/.cproject @@ -0,0 +1,618 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tester/SW/lib/FreeRTOS/Source/.project b/Tester/SW/lib/FreeRTOS/Source/.project new file mode 100644 index 0000000..a2a33f4 --- /dev/null +++ b/Tester/SW/lib/FreeRTOS/Source/.project @@ -0,0 +1,82 @@ + + + FreeRTOS + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + org.eclipse.cdt.make.core.cleanBuildTarget + clean + + + org.eclipse.cdt.make.core.enableCleanBuild + true + + + ?name? + + + + org.eclipse.cdt.make.core.append_environment + true + + + org.eclipse.cdt.make.core.stopOnError + true + + + org.eclipse.cdt.make.core.buildCommand + make + + + org.eclipse.cdt.make.core.contents + org.eclipse.cdt.make.core.activeConfigSettings + + + org.eclipse.cdt.make.core.buildLocation + ${workspace_loc:/FreeRTOS/Debug} + + + org.eclipse.cdt.make.core.useDefaultBuildCmd + true + + + org.eclipse.cdt.make.core.enableAutoBuild + false + + + org.eclipse.cdt.make.core.enableFullBuild + true + + + org.eclipse.cdt.make.core.buildArguments + + + + org.eclipse.cdt.make.core.fullBuildTarget + all + + + org.eclipse.cdt.make.core.autoBuildTarget + all + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.core.cnature + org.eclipse.cdt.core.ccnature + + diff --git a/Tester/SW/lib/FreeRTOS/Source/croutine.c b/Tester/SW/lib/FreeRTOS/Source/croutine.c new file mode 100644 index 0000000..88dceff --- /dev/null +++ b/Tester/SW/lib/FreeRTOS/Source/croutine.c @@ -0,0 +1,346 @@ +/* + FreeRTOS.org V4.6.1 - Copyright (C) 2003-2007 Richard Barry. + + This file is part of the FreeRTOS.org distribution. + + FreeRTOS.org is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + FreeRTOS.org is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with FreeRTOS.org; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + A special exception to the GPL can be applied should you wish to distribute + a combined work that includes FreeRTOS.org, without being obliged to provide + the source code for any proprietary components. See the licensing section + of http://www.FreeRTOS.org for full details of how and when the exception + can be applied. + + *************************************************************************** + See http://www.FreeRTOS.org for documentation, latest information, license + and contact details. Please ensure to read the configuration and relevant + port sections of the online documentation. + + Also see http://www.SafeRTOS.com a version that has been certified for use + in safety critical systems, plus commercial licensing, development and + support options. + *************************************************************************** +*/ + +#include "FreeRTOS.h" +#include "task.h" +#include "croutine.h" + +/* Lists for ready and blocked co-routines. --------------------*/ +static xList pxReadyCoRoutineLists[ configMAX_CO_ROUTINE_PRIORITIES ]; /*< Prioritised ready co-routines. */ +static xList xDelayedCoRoutineList1; /*< Delayed co-routines. */ +static xList xDelayedCoRoutineList2; /*< Delayed co-routines (two lists are used - one for delays that have overflowed the current tick count. */ +static xList * pxDelayedCoRoutineList; /*< Points to the delayed co-routine list currently being used. */ +static xList * pxOverflowDelayedCoRoutineList; /*< Points to the delayed co-routine list currently being used to hold co-routines that have overflowed the current tick count. */ +static xList xPendingReadyList; /*< Holds co-routines that have been readied by an external event. They cannot be added directly to the ready lists as the ready lists cannot be accessed by interrupts. */ + +/* Other file private variables. --------------------------------*/ +corCRCB * pxCurrentCoRoutine = NULL; +static unsigned portBASE_TYPE uxTopCoRoutineReadyPriority = 0; +static portTickType xCoRoutineTickCount = 0; + +/* The initial state of the co-routine when it is created. */ +#define corINITIAL_STATE ( 0 ) + +/* + * Place the co-routine represented by pxCRCB into the appropriate ready queue + * for the priority. It is inserted at the end of the list. + * + * This macro accesses the co-routine ready lists and therefore must not be + * used from within an ISR. + */ +#define prvAddCoRoutineToReadyQueue( pxCRCB ) \ +{ \ + if( pxCRCB->uxPriority > uxTopCoRoutineReadyPriority ) \ + { \ + uxTopCoRoutineReadyPriority = pxCRCB->uxPriority; \ + } \ + vListInsertEnd( ( xList * ) &( pxReadyCoRoutineLists[ pxCRCB->uxPriority ] ), &( pxCRCB->xGenericListItem ) ); \ +} + +/* + * Utility to ready all the lists used by the scheduler. This is called + * automatically upon the creation of the first co-routine. + */ +static void prvInitialiseCoRoutineLists( void ); + +/* + * Co-routines that are readied by an interrupt cannot be placed directly into + * the ready lists (there is no mutual exclusion). Instead they are placed in + * in the pending ready list in order that they can later be moved to the ready + * list by the co-routine scheduler. + */ +static inline void prvCheckPendingReadyList( void ); + +/* + * Macro that looks at the list of co-routines that are currently delayed to + * see if any require waking. + * + * Co-routines are stored in the queue in the order of their wake time - + * meaning once one co-routine has been found whose timer has not expired + * we need not look any further down the list. + */ +static inline void prvCheckDelayedList( void ); + +/*-----------------------------------------------------------*/ + +signed portBASE_TYPE xCoRoutineCreate( crCOROUTINE_CODE pxCoRoutineCode, unsigned portBASE_TYPE uxPriority, unsigned portBASE_TYPE uxIndex ) +{ +signed portBASE_TYPE xReturn; +corCRCB *pxCoRoutine; + + /* Allocate the memory that will store the co-routine control block. */ + pxCoRoutine = ( corCRCB * ) pvPortMalloc( sizeof( corCRCB ) ); + if( pxCoRoutine ) + { + /* If pxCurrentCoRoutine is NULL then this is the first co-routine to + be created and the co-routine data structures need initialising. */ + if( pxCurrentCoRoutine == NULL ) + { + pxCurrentCoRoutine = pxCoRoutine; + prvInitialiseCoRoutineLists(); + } + + /* Check the priority is within limits. */ + if( uxPriority >= configMAX_CO_ROUTINE_PRIORITIES ) + { + uxPriority = configMAX_CO_ROUTINE_PRIORITIES - 1; + } + + /* Fill out the co-routine control block from the function parameters. */ + pxCoRoutine->uxState = corINITIAL_STATE; + pxCoRoutine->uxPriority = uxPriority; + pxCoRoutine->uxIndex = uxIndex; + pxCoRoutine->pxCoRoutineFunction = pxCoRoutineCode; + + /* Initialise all the other co-routine control block parameters. */ + vListInitialiseItem( &( pxCoRoutine->xGenericListItem ) ); + vListInitialiseItem( &( pxCoRoutine->xEventListItem ) ); + + /* Set the co-routine control block as a link back from the xListItem. + This is so we can get back to the containing CRCB from a generic item + in a list. */ + listSET_LIST_ITEM_OWNER( &( pxCoRoutine->xGenericListItem ), pxCoRoutine ); + listSET_LIST_ITEM_OWNER( &( pxCoRoutine->xEventListItem ), pxCoRoutine ); + + /* Event lists are always in priority order. */ + listSET_LIST_ITEM_VALUE( &( pxCoRoutine->xEventListItem ), configMAX_PRIORITIES - ( portTickType ) uxPriority ); + + /* Now the co-routine has been initialised it can be added to the ready + list at the correct priority. */ + prvAddCoRoutineToReadyQueue( pxCoRoutine ); + + xReturn = pdPASS; + } + else + { + xReturn = errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY; + } + + return xReturn; +} +/*-----------------------------------------------------------*/ + +void vCoRoutineAddToDelayedList( portTickType xTicksToDelay, xList *pxEventList ) +{ +portTickType xTimeToWake; + + /* Calculate the time to wake - this may overflow but this is + not a problem. */ + xTimeToWake = xCoRoutineTickCount + xTicksToDelay; + + /* We must remove ourselves from the ready list before adding + ourselves to the blocked list as the same list item is used for + both lists. */ + vListRemove( ( xListItem * ) &( pxCurrentCoRoutine->xGenericListItem ) ); + + /* The list item will be inserted in wake time order. */ + listSET_LIST_ITEM_VALUE( &( pxCurrentCoRoutine->xGenericListItem ), xTimeToWake ); + + if( xTimeToWake < xCoRoutineTickCount ) + { + /* Wake time has overflowed. Place this item in the + overflow list. */ + vListInsert( ( xList * ) pxOverflowDelayedCoRoutineList, ( xListItem * ) &( pxCurrentCoRoutine->xGenericListItem ) ); + } + else + { + /* The wake time has not overflowed, so we can use the + current block list. */ + vListInsert( ( xList * ) pxDelayedCoRoutineList, ( xListItem * ) &( pxCurrentCoRoutine->xGenericListItem ) ); + } + + if( pxEventList ) + { + /* Also add the co-routine to an event list. If this is done then the + function must be called with interrupts disabled. */ + vListInsert( pxEventList, &( pxCurrentCoRoutine->xEventListItem ) ); + } +} +/*-----------------------------------------------------------*/ + +static inline void prvCheckPendingReadyList( void ) +{ + /* Are there any co-routines waiting to get moved to the ready list? These + are co-routines that have been readied by an ISR. The ISR cannot access + the ready lists itself. */ + while( !listLIST_IS_EMPTY( &xPendingReadyList ) ) + { + corCRCB *pxUnblockedCRCB; + + /* The pending ready list can be accessed by an ISR. */ + portDISABLE_INTERRUPTS(); + { + pxUnblockedCRCB = ( corCRCB * ) listGET_OWNER_OF_HEAD_ENTRY( (&xPendingReadyList) ); + vListRemove( &( pxUnblockedCRCB->xEventListItem ) ); + } + portENABLE_INTERRUPTS(); + + vListRemove( &( pxUnblockedCRCB->xGenericListItem ) ); + prvAddCoRoutineToReadyQueue( pxUnblockedCRCB ); + } +} +/*-----------------------------------------------------------*/ + +static inline void prvCheckDelayedList( void ) +{ +static portTickType xLastTickCount, xPassedTicks; +corCRCB *pxCRCB; + + xPassedTicks = xTaskGetTickCount() - xLastTickCount; + while( xPassedTicks ) + { + xCoRoutineTickCount++; + xPassedTicks--; + + /* If the tick count has overflowed we need to swap the ready lists. */ + if( xCoRoutineTickCount == 0 ) + { + xList * pxTemp; + + /* Tick count has overflowed so we need to swap the delay lists. If there are + any items in pxDelayedCoRoutineList here then there is an error! */ + pxTemp = pxDelayedCoRoutineList; + pxDelayedCoRoutineList = pxOverflowDelayedCoRoutineList; + pxOverflowDelayedCoRoutineList = pxTemp; + } + + /* See if this tick has made a timeout expire. */ + while( ( pxCRCB = ( corCRCB * ) listGET_OWNER_OF_HEAD_ENTRY( pxDelayedCoRoutineList ) ) != NULL ) + { + if( xCoRoutineTickCount < listGET_LIST_ITEM_VALUE( &( pxCRCB->xGenericListItem ) ) ) + { + /* Timeout not yet expired. */ + break; + } + + portDISABLE_INTERRUPTS(); + { + /* The event could have occurred just before this critical + section. If this is the case then the generic list item will + have been moved to the pending ready list and the following + line is still valid. Also the pvContainer parameter will have + been set to NULL so the following lines are also valid. */ + vListRemove( &( pxCRCB->xGenericListItem ) ); + + /* Is the co-routine waiting on an event also? */ + if( pxCRCB->xEventListItem.pvContainer ) + { + vListRemove( &( pxCRCB->xEventListItem ) ); + } + } + portENABLE_INTERRUPTS(); + + prvAddCoRoutineToReadyQueue( pxCRCB ); + } + } + + xLastTickCount = xCoRoutineTickCount; +} +/*-----------------------------------------------------------*/ + +void vCoRoutineSchedule( void ) +{ + /* See if any co-routines readied by events need moving to the ready lists. */ + prvCheckPendingReadyList(); + + /* See if any delayed co-routines have timed out. */ + prvCheckDelayedList(); + + /* Find the highest priority queue that contains ready co-routines. */ + while( listLIST_IS_EMPTY( &( pxReadyCoRoutineLists[ uxTopCoRoutineReadyPriority ] ) ) ) + { + if( uxTopCoRoutineReadyPriority == 0 ) + { + /* No more co-routines to check. */ + return; + } + --uxTopCoRoutineReadyPriority; + } + + /* listGET_OWNER_OF_NEXT_ENTRY walks through the list, so the co-routines + of the same priority get an equal share of the processor time. */ + listGET_OWNER_OF_NEXT_ENTRY( pxCurrentCoRoutine, &( pxReadyCoRoutineLists[ uxTopCoRoutineReadyPriority ] ) ); + + /* Call the co-routine. */ + ( pxCurrentCoRoutine->pxCoRoutineFunction )( pxCurrentCoRoutine, pxCurrentCoRoutine->uxIndex ); + + return; +} +/*-----------------------------------------------------------*/ + +static void prvInitialiseCoRoutineLists( void ) +{ +unsigned portBASE_TYPE uxPriority; + + for( uxPriority = 0; uxPriority < configMAX_CO_ROUTINE_PRIORITIES; uxPriority++ ) + { + vListInitialise( ( xList * ) &( pxReadyCoRoutineLists[ uxPriority ] ) ); + } + + vListInitialise( ( xList * ) &xDelayedCoRoutineList1 ); + vListInitialise( ( xList * ) &xDelayedCoRoutineList2 ); + vListInitialise( ( xList * ) &xPendingReadyList ); + + /* Start with pxDelayedCoRoutineList using list1 and the + pxOverflowDelayedCoRoutineList using list2. */ + pxDelayedCoRoutineList = &xDelayedCoRoutineList1; + pxOverflowDelayedCoRoutineList = &xDelayedCoRoutineList2; +} +/*-----------------------------------------------------------*/ + +signed portBASE_TYPE xCoRoutineRemoveFromEventList( const xList *pxEventList ) +{ +corCRCB *pxUnblockedCRCB; +signed portBASE_TYPE xReturn; + + /* This function is called from within an interrupt. It can only access + event lists and the pending ready list. */ + pxUnblockedCRCB = ( corCRCB * ) listGET_OWNER_OF_HEAD_ENTRY( pxEventList ); + vListRemove( &( pxUnblockedCRCB->xEventListItem ) ); + vListInsertEnd( ( xList * ) &( xPendingReadyList ), &( pxUnblockedCRCB->xEventListItem ) ); + + if( pxUnblockedCRCB->uxPriority >= pxCurrentCoRoutine->uxPriority ) + { + xReturn = pdTRUE; + } + else + { + xReturn = pdFALSE; + } + + return xReturn; +} + diff --git a/Tester/SW/lib/FreeRTOS/Source/include/FreeRTOS.h b/Tester/SW/lib/FreeRTOS/Source/include/FreeRTOS.h new file mode 100644 index 0000000..a30631f --- /dev/null +++ b/Tester/SW/lib/FreeRTOS/Source/include/FreeRTOS.h @@ -0,0 +1,135 @@ +/* + FreeRTOS.org V4.6.1 - Copyright (C) 2003-2007 Richard Barry. + + This file is part of the FreeRTOS.org distribution. + + FreeRTOS.org is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + FreeRTOS.org is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with FreeRTOS.org; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + A special exception to the GPL can be applied should you wish to distribute + a combined work that includes FreeRTOS.org, without being obliged to provide + the source code for any proprietary components. See the licensing section + of http://www.FreeRTOS.org for full details of how and when the exception + can be applied. + + *************************************************************************** + See http://www.FreeRTOS.org for documentation, latest information, license + and contact details. Please ensure to read the configuration and relevant + port sections of the online documentation. + + Also see http://www.SafeRTOS.com a version that has been certified for use + in safety critical systems, plus commercial licensing, development and + support options. + *************************************************************************** +*/ + +#ifndef INC_FREERTOS_H +#define INC_FREERTOS_H + + +/* + * Include the generic headers required for the FreeRTOS port being used. + */ +#include + +/* Basic FreeRTOS definitions. */ +#include "projdefs.h" + +/* Application specific configuration options. */ +#include "FreeRTOSConfig.h" + +/* Definitions specific to the port being used. */ +#include "portable.h" + +// Memory allocation of RTOS is used in application +void *pvPortMalloc( size_t xWantedSize ); +void vPortFree( void *pv ); + + + + + + + + +/* + * Check all the required application specific macros have been defined. + * These macros are application specific and (as downloaded) are defined + * within FreeRTOSConfig.h. + */ + +#ifndef configUSE_PREEMPTION + #error Missing definition: configUSE_PREEMPTION should be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. +#endif + +#ifndef configUSE_IDLE_HOOK + #error Missing definition: configUSE_IDLE_HOOK should be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. +#endif + +#ifndef configUSE_TICK_HOOK + #error Missing definition: configUSE_TICK_HOOK should be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. +#endif + +#ifndef configUSE_CO_ROUTINES + #error Missing definition: configUSE_CO_ROUTINES should be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. +#endif + +#ifndef INCLUDE_vTaskPrioritySet + #error Missing definition: INCLUDE_vTaskPrioritySet should be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. +#endif + +#ifndef INCLUDE_uxTaskPriorityGet + #error Missing definition: INCLUDE_uxTaskPriorityGet should be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. +#endif + +#ifndef INCLUDE_vTaskDelete + #error Missing definition: INCLUDE_vTaskDelete should be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. +#endif + +#ifndef INCLUDE_vTaskCleanUpResources + #error Missing definition: INCLUDE_vTaskCleanUpResources should be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. +#endif + +#ifndef INCLUDE_vTaskSuspend + #error Missing definition: INCLUDE_vTaskSuspend should be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. +#endif + +#ifndef INCLUDE_vTaskDelayUntil + #error Missing definition: INCLUDE_vTaskDelayUntil should be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. +#endif + +#ifndef INCLUDE_vTaskDelay + #error Missing definition: INCLUDE_vTaskDelay should be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. +#endif + +#ifndef configUSE_16_BIT_TICKS + #error Missing definition: configUSE_16_BIT_TICKS should be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. +#endif + +#ifndef configUSE_MUTEXES + #define configUSE_MUTEXES 0 +#endif + +#if ( configUSE_MUTEXES == 1 ) + /* xTaskGetCurrentTaskHandle is used by the priority inheritance mechanism + within the mutex implementation so must be available if mutexes are used. */ + #undef INCLUDE_xTaskGetCurrentTaskHandle + #define INCLUDE_xTaskGetCurrentTaskHandle 1 +#else + #ifndef INCLUDE_xTaskGetCurrentTaskHandle + #define INCLUDE_xTaskGetCurrentTaskHandle 0 + #endif +#endif + +#endif /* INC_FREERTOS_H */ diff --git a/Tester/SW/lib/FreeRTOS/Source/include/croutine.h b/Tester/SW/lib/FreeRTOS/Source/include/croutine.h new file mode 100644 index 0000000..5c4a4b3 --- /dev/null +++ b/Tester/SW/lib/FreeRTOS/Source/include/croutine.h @@ -0,0 +1,724 @@ +/* + FreeRTOS.org V4.6.1 - Copyright (C) 2003-2007 Richard Barry. + + This file is part of the FreeRTOS.org distribution. + + FreeRTOS.org is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + FreeRTOS.org is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with FreeRTOS.org; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + A special exception to the GPL can be applied should you wish to distribute + a combined work that includes FreeRTOS.org, without being obliged to provide + the source code for any proprietary components. See the licensing section + of http://www.FreeRTOS.org for full details of how and when the exception + can be applied. + + *************************************************************************** + See http://www.FreeRTOS.org for documentation, latest information, license + and contact details. Please ensure to read the configuration and relevant + port sections of the online documentation. + + Also see http://www.SafeRTOS.com a version that has been certified for use + in safety critical systems, plus commercial licensing, development and + support options. + *************************************************************************** +*/ +#ifndef CO_ROUTINE_H +#define CO_ROUTINE_H + +#include "list.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Used to hide the implementation of the co-routine control block. The +control block structure however has to be included in the header due to +the macro implementation of the co-routine functionality. */ +typedef void * xCoRoutineHandle; + +/* Defines the prototype to which co-routine functions must conform. */ +typedef void (*crCOROUTINE_CODE)( xCoRoutineHandle, unsigned portBASE_TYPE ); + +typedef struct corCoRoutineControlBlock +{ + crCOROUTINE_CODE pxCoRoutineFunction; + xListItem xGenericListItem; /*< List item used to place the CRCB in ready and blocked queues. */ + xListItem xEventListItem; /*< List item used to place the CRCB in event lists. */ + unsigned portBASE_TYPE uxPriority; /*< The priority of the co-routine in relation to other co-routines. */ + unsigned portBASE_TYPE uxIndex; /*< Used to distinguish between co-routines when multiple co-routines use the same co-routine function. */ + unsigned portSHORT uxState; /*< Used internally by the co-routine implementation. */ +} corCRCB; /* Co-routine control block. Note must be identical in size down to uxPriority with tskTCB. */ + +/** + * croutine. h + *
+ portBASE_TYPE xCoRoutineCreate(
+                                 crCOROUTINE_CODE pxCoRoutineCode,
+                                 unsigned portBASE_TYPE uxPriority,
+                                 unsigned portBASE_TYPE uxIndex
+                               );
+ * + * Create a new co-routine and add it to the list of co-routines that are + * ready to run. + * + * @param pxCoRoutineCode Pointer to the co-routine function. Co-routine + * functions require special syntax - see the co-routine section of the WEB + * documentation for more information. + * + * @param uxPriority The priority with respect to other co-routines at which + * the co-routine will run. + * + * @param uxIndex Used to distinguish between different co-routines that + * execute the same function. See the example below and the co-routine section + * of the WEB documentation for further information. + * + * @return pdPASS if the co-routine was successfully created and added to a ready + * list, otherwise an error code defined with ProjDefs.h. + * + * Example usage: +
+ // Co-routine to be created.
+ void vFlashCoRoutine( xCoRoutineHandle xHandle, unsigned portBASE_TYPE uxIndex )
+ {
+ // Variables in co-routines must be declared static if they must maintain value across a blocking call.
+ // This may not be necessary for const variables.
+ static const char cLedToFlash[ 2 ] = { 5, 6 };
+ static const portTickType xTimeToDelay[ 2 ] = { 200, 400 };
+
+     // Must start every co-routine with a call to crSTART();
+     crSTART( xHandle );
+
+     for( ;; )
+     {
+         // This co-routine just delays for a fixed period, then toggles
+         // an LED.  Two co-routines are created using this function, so
+         // the uxIndex parameter is used to tell the co-routine which
+         // LED to flash and how long to delay.  This assumes xQueue has
+         // already been created.
+         vParTestToggleLED( cLedToFlash[ uxIndex ] );
+         crDELAY( xHandle, uxFlashRates[ uxIndex ] );
+     }
+
+     // Must end every co-routine with a call to crEND();
+     crEND();
+ }
+
+ // Function that creates two co-routines.
+ void vOtherFunction( void )
+ {
+ unsigned char ucParameterToPass;
+ xTaskHandle xHandle;
+		
+     // Create two co-routines at priority 0.  The first is given index 0
+     // so (from the code above) toggles LED 5 every 200 ticks.  The second
+     // is given index 1 so toggles LED 6 every 400 ticks.
+     for( uxIndex = 0; uxIndex < 2; uxIndex++ )
+     {
+         xCoRoutineCreate( vFlashCoRoutine, 0, uxIndex );
+     }
+ }
+   
+ * \defgroup xCoRoutineCreate xCoRoutineCreate + * \ingroup Tasks + */ +signed portBASE_TYPE xCoRoutineCreate( crCOROUTINE_CODE pxCoRoutineCode, unsigned portBASE_TYPE uxPriority, unsigned portBASE_TYPE uxIndex ); + + +/** + * croutine. h + *
+ void vCoRoutineSchedule( void );
+ * + * Run a co-routine. + * + * vCoRoutineSchedule() executes the highest priority co-routine that is able + * to run. The co-routine will execute until it either blocks, yields or is + * preempted by a task. Co-routines execute cooperatively so one + * co-routine cannot be preempted by another, but can be preempted by a task. + * + * If an application comprises of both tasks and co-routines then + * vCoRoutineSchedule should be called from the idle task (in an idle task + * hook). + * + * Example usage: +
+ // This idle task hook will schedule a co-routine each time it is called.
+ // The rest of the idle task will execute between co-routine calls.
+ void vApplicationIdleHook( void )
+ {
+	vCoRoutineSchedule();
+ }
+
+ // Alternatively, if you do not require any other part of the idle task to
+ // execute, the idle task hook can call vCoRoutineScheduler() within an
+ // infinite loop.
+ void vApplicationIdleHook( void )
+ {
+    for( ;; )
+    {
+        vCoRoutineSchedule();
+    }
+ }
+ 
+ * \defgroup vCoRoutineSchedule vCoRoutineSchedule + * \ingroup Tasks + */ +void vCoRoutineSchedule( void ); + +/** + * croutine. h + *
+ crSTART( xCoRoutineHandle xHandle );
+ * + * This macro MUST always be called at the start of a co-routine function. + * + * Example usage: +
+ // Co-routine to be created.
+ void vACoRoutine( xCoRoutineHandle xHandle, unsigned portBASE_TYPE uxIndex )
+ {
+ // Variables in co-routines must be declared static if they must maintain value across a blocking call.
+ static portLONG ulAVariable;
+
+     // Must start every co-routine with a call to crSTART();
+     crSTART( xHandle );
+
+     for( ;; )
+     {
+          // Co-routine functionality goes here.
+     }
+
+     // Must end every co-routine with a call to crEND();
+     crEND();
+ }
+ * \defgroup crSTART crSTART + * \ingroup Tasks + */ +#define crSTART( pxCRCB ) switch( ( ( corCRCB * )pxCRCB )->uxState ) { case 0: + +/** + * croutine. h + *
+ crEND();
+ * + * This macro MUST always be called at the end of a co-routine function. + * + * Example usage: +
+ // Co-routine to be created.
+ void vACoRoutine( xCoRoutineHandle xHandle, unsigned portBASE_TYPE uxIndex )
+ {
+ // Variables in co-routines must be declared static if they must maintain value across a blocking call.
+ static portLONG ulAVariable;
+
+     // Must start every co-routine with a call to crSTART();
+     crSTART( xHandle );
+
+     for( ;; )
+     {
+          // Co-routine functionality goes here.
+     }
+
+     // Must end every co-routine with a call to crEND();
+     crEND();
+ }
+ * \defgroup crSTART crSTART + * \ingroup Tasks + */ +#define crEND() } + +/* + * These macros are intended for internal use by the co-routine implementation + * only. The macros should not be used directly by application writers. + */ +#define crSET_STATE0( xHandle ) ( ( corCRCB * )xHandle)->uxState = (__LINE__ * 2); return; case (__LINE__ * 2): +#define crSET_STATE1( xHandle ) ( ( corCRCB * )xHandle)->uxState = ((__LINE__ * 2)+1); return; case ((__LINE__ * 2)+1): + +/** + * croutine. h + *
+ crDELAY( xCoRoutineHandle xHandle, portTickType xTicksToDelay );
+ * + * Delay a co-routine for a fixed period of time. + * + * crDELAY can only be called from the co-routine function itself - not + * from within a function called by the co-routine function. This is because + * co-routines do not maintain their own stack. + * + * @param xHandle The handle of the co-routine to delay. This is the xHandle + * parameter of the co-routine function. + * + * @param xTickToDelay The number of ticks that the co-routine should delay + * for. The actual amount of time this equates to is defined by + * configTICK_RATE_HZ (set in FreeRTOSConfig.h). The constant portTICK_RATE_MS + * can be used to convert ticks to milliseconds. + * + * Example usage: +
+ // Co-routine to be created.
+ void vACoRoutine( xCoRoutineHandle xHandle, unsigned portBASE_TYPE uxIndex )
+ {
+ // Variables in co-routines must be declared static if they must maintain value across a blocking call.
+ // This may not be necessary for const variables.
+ // We are to delay for 200ms.
+ static const xTickType xDelayTime = 200 / portTICK_RATE_MS;
+
+     // Must start every co-routine with a call to crSTART();
+     crSTART( xHandle );
+
+     for( ;; )
+     {
+        // Delay for 200ms.
+        crDELAY( xHandle, xDelayTime );
+
+        // Do something here.
+     }
+
+     // Must end every co-routine with a call to crEND();
+     crEND();
+ }
+ * \defgroup crDELAY crDELAY + * \ingroup Tasks + */ +#define crDELAY( xHandle, xTicksToDelay ) \ + if( xTicksToDelay > 0 ) \ + { \ + vCoRoutineAddToDelayedList( xTicksToDelay, NULL ); \ + } \ + crSET_STATE0( xHandle ); + +/** + *
+ crQUEUE_SEND(
+                  xCoRoutineHandle xHandle,
+                  xQueueHandle pxQueue,
+                  void *pvItemToQueue,
+                  portTickType xTicksToWait,
+                  portBASE_TYPE *pxResult
+             )
+ * + * The macro's crQUEUE_SEND() and crQUEUE_RECEIVE() are the co-routine + * equivalent to the xQueueSend() and xQueueReceive() functions used by tasks. + * + * crQUEUE_SEND and crQUEUE_RECEIVE can only be used from a co-routine whereas + * xQueueSend() and xQueueReceive() can only be used from tasks. + * + * crQUEUE_SEND can only be called from the co-routine function itself - not + * from within a function called by the co-routine function. This is because + * co-routines do not maintain their own stack. + * + * See the co-routine section of the WEB documentation for information on + * passing data between tasks and co-routines and between ISR's and + * co-routines. + * + * @param xHandle The handle of the calling co-routine. This is the xHandle + * parameter of the co-routine function. + * + * @param pxQueue The handle of the queue on which the data will be posted. + * The handle is obtained as the return value when the queue is created using + * the xQueueCreate() API function. + * + * @param pvItemToQueue A pointer to the data being posted onto the queue. + * The number of bytes of each queued item is specified when the queue is + * created. This number of bytes is copied from pvItemToQueue into the queue + * itself. + * + * @param xTickToDelay The number of ticks that the co-routine should block + * to wait for space to become available on the queue, should space not be + * available immediately. The actual amount of time this equates to is defined + * by configTICK_RATE_HZ (set in FreeRTOSConfig.h). The constant + * portTICK_RATE_MS can be used to convert ticks to milliseconds (see example + * below). + * + * @param pxResult The variable pointed to by pxResult will be set to pdPASS if + * data was successfully posted onto the queue, otherwise it will be set to an + * error defined within ProjDefs.h. + * + * Example usage: +
+ // Co-routine function that blocks for a fixed period then posts a number onto
+ // a queue.
+ static void prvCoRoutineFlashTask( xCoRoutineHandle xHandle, unsigned portBASE_TYPE uxIndex )
+ {
+ // Variables in co-routines must be declared static if they must maintain value across a blocking call.
+ static portBASE_TYPE xNumberToPost = 0;
+ static portBASE_TYPE xResult;
+
+    // Co-routines must begin with a call to crSTART().
+    crSTART( xHandle );
+
+    for( ;; )
+    {
+        // This assumes the queue has already been created.
+        crQUEUE_SEND( xHandle, xCoRoutineQueue, &xNumberToPost, NO_DELAY, &xResult );
+
+        if( xResult != pdPASS )
+        {
+            // The message was not posted!
+        }
+
+        // Increment the number to be posted onto the queue.
+        xNumberToPost++;
+
+        // Delay for 100 ticks.
+        crDELAY( xHandle, 100 );
+    }
+
+    // Co-routines must end with a call to crEND().
+    crEND();
+ }
+ * \defgroup crQUEUE_SEND crQUEUE_SEND + * \ingroup Tasks + */ +#define crQUEUE_SEND( xHandle, pxQueue, pvItemToQueue, xTicksToWait, pxResult ) \ +{ \ + *pxResult = xQueueCRSend( pxQueue, pvItemToQueue, xTicksToWait ); \ + if( *pxResult == errQUEUE_BLOCKED ) \ + { \ + crSET_STATE0( xHandle ); \ + *pxResult = xQueueCRSend( pxQueue, pvItemToQueue, 0 ); \ + } \ + if( *pxResult == errQUEUE_YIELD ) \ + { \ + crSET_STATE1( xHandle ); \ + *pxResult = pdPASS; \ + } \ +} + +/** + * croutine. h + *
+  crQUEUE_RECEIVE(
+                     xCoRoutineHandle xHandle,
+                     xQueueHandle pxQueue,
+                     void *pvBuffer,
+                     portTickType xTicksToWait,
+                     portBASE_TYPE *pxResult
+                 )
+ * + * The macro's crQUEUE_SEND() and crQUEUE_RECEIVE() are the co-routine + * equivalent to the xQueueSend() and xQueueReceive() functions used by tasks. + * + * crQUEUE_SEND and crQUEUE_RECEIVE can only be used from a co-routine whereas + * xQueueSend() and xQueueReceive() can only be used from tasks. + * + * crQUEUE_RECEIVE can only be called from the co-routine function itself - not + * from within a function called by the co-routine function. This is because + * co-routines do not maintain their own stack. + * + * See the co-routine section of the WEB documentation for information on + * passing data between tasks and co-routines and between ISR's and + * co-routines. + * + * @param xHandle The handle of the calling co-routine. This is the xHandle + * parameter of the co-routine function. + * + * @param pxQueue The handle of the queue from which the data will be received. + * The handle is obtained as the return value when the queue is created using + * the xQueueCreate() API function. + * + * @param pvBuffer The buffer into which the received item is to be copied. + * The number of bytes of each queued item is specified when the queue is + * created. This number of bytes is copied into pvBuffer. + * + * @param xTickToDelay The number of ticks that the co-routine should block + * to wait for data to become available from the queue, should data not be + * available immediately. The actual amount of time this equates to is defined + * by configTICK_RATE_HZ (set in FreeRTOSConfig.h). The constant + * portTICK_RATE_MS can be used to convert ticks to milliseconds (see the + * crQUEUE_SEND example). + * + * @param pxResult The variable pointed to by pxResult will be set to pdPASS if + * data was successfully retrieved from the queue, otherwise it will be set to + * an error code as defined within ProjDefs.h. + * + * Example usage: +
+ // A co-routine receives the number of an LED to flash from a queue.  It
+ // blocks on the queue until the number is received.
+ static void prvCoRoutineFlashWorkTask( xCoRoutineHandle xHandle, unsigned portBASE_TYPE uxIndex )
+ {
+ // Variables in co-routines must be declared static if they must maintain value across a blocking call.
+ static portBASE_TYPE xResult;
+ static unsigned portBASE_TYPE uxLEDToFlash;
+
+    // All co-routines must start with a call to crSTART().
+    crSTART( xHandle );
+
+    for( ;; )
+    {
+        // Wait for data to become available on the queue.
+        crQUEUE_RECEIVE( xHandle, xCoRoutineQueue, &uxLEDToFlash, portMAX_DELAY, &xResult );
+
+        if( xResult == pdPASS )
+        {
+            // We received the LED to flash - flash it!
+            vParTestToggleLED( uxLEDToFlash );
+        }
+    }
+
+    crEND();
+ }
+ * \defgroup crQUEUE_RECEIVE crQUEUE_RECEIVE + * \ingroup Tasks + */ +#define crQUEUE_RECEIVE( xHandle, pxQueue, pvBuffer, xTicksToWait, pxResult ) \ +{ \ + *pxResult = xQueueCRReceive( pxQueue, pvBuffer, xTicksToWait ); \ + if( *pxResult == errQUEUE_BLOCKED ) \ + { \ + crSET_STATE0( xHandle ); \ + *pxResult = xQueueCRReceive( pxQueue, pvBuffer, 0 ); \ + } \ + if( *pxResult == errQUEUE_YIELD ) \ + { \ + crSET_STATE1( xHandle ); \ + *pxResult = pdPASS; \ + } \ +} + +/** + * croutine. h + *
+  crQUEUE_SEND_FROM_ISR(
+                            xQueueHandle pxQueue,
+                            void *pvItemToQueue,
+                            portBASE_TYPE xCoRoutinePreviouslyWoken
+                       )
+ * + * The macro's crQUEUE_SEND_FROM_ISR() and crQUEUE_RECEIVE_FROM_ISR() are the + * co-routine equivalent to the xQueueSendFromISR() and xQueueReceiveFromISR() + * functions used by tasks. + * + * crQUEUE_SEND_FROM_ISR() and crQUEUE_RECEIVE_FROM_ISR() can only be used to + * pass data between a co-routine and and ISR, whereas xQueueSendFromISR() and + * xQueueReceiveFromISR() can only be used to pass data between a task and and + * ISR. + * + * crQUEUE_SEND_FROM_ISR can only be called from an ISR to send data to a queue + * that is being used from within a co-routine. + * + * See the co-routine section of the WEB documentation for information on + * passing data between tasks and co-routines and between ISR's and + * co-routines. + * + * @param xQueue The handle to the queue on which the item is to be posted. + * + * @param pvItemToQueue A pointer to the item that is to be placed on the + * queue. The size of the items the queue will hold was defined when the + * queue was created, so this many bytes will be copied from pvItemToQueue + * into the queue storage area. + * + * @param xCoRoutinePreviouslyWoken This is included so an ISR can post onto + * the same queue multiple times from a single interrupt. The first call + * should always pass in pdFALSE. Subsequent calls should pass in + * the value returned from the previous call. + * + * @return pdTRUE if a co-routine was woken by posting onto the queue. This is + * used by the ISR to determine if a context switch may be required following + * the ISR. + * + * Example usage: +
+ // A co-routine that blocks on a queue waiting for characters to be received.
+ static void vReceivingCoRoutine( xCoRoutineHandle xHandle, unsigned portBASE_TYPE uxIndex )
+ {
+ portCHAR cRxedChar;
+ portBASE_TYPE xResult;
+
+     // All co-routines must start with a call to crSTART().
+     crSTART( xHandle );
+
+     for( ;; )
+     {
+         // Wait for data to become available on the queue.  This assumes the
+         // queue xCommsRxQueue has already been created!
+         crQUEUE_RECEIVE( xHandle, xCommsRxQueue, &uxLEDToFlash, portMAX_DELAY, &xResult );
+
+         // Was a character received?
+         if( xResult == pdPASS )
+         {
+             // Process the character here.
+         }
+     }
+
+     // All co-routines must end with a call to crEND().
+     crEND();
+ }
+
+ // An ISR that uses a queue to send characters received on a serial port to
+ // a co-routine.
+ void vUART_ISR( void )
+ {
+ portCHAR cRxedChar;
+ portBASE_TYPE xCRWokenByPost = pdFALSE;
+
+     // We loop around reading characters until there are none left in the UART.
+     while( UART_RX_REG_NOT_EMPTY() )
+     {
+         // Obtain the character from the UART.
+         cRxedChar = UART_RX_REG;
+
+         // Post the character onto a queue.  xCRWokenByPost will be pdFALSE
+         // the first time around the loop.  If the post causes a co-routine
+         // to be woken (unblocked) then xCRWokenByPost will be set to pdTRUE.
+         // In this manner we can ensure that if more than one co-routine is
+         // blocked on the queue only one is woken by this ISR no matter how
+         // many characters are posted to the queue.
+         xCRWokenByPost = crQUEUE_SEND_FROM_ISR( xCommsRxQueue, &cRxedChar, xCRWokenByPost );
+     }
+ }
+ * \defgroup crQUEUE_SEND_FROM_ISR crQUEUE_SEND_FROM_ISR + * \ingroup Tasks + */ +#define crQUEUE_SEND_FROM_ISR( pxQueue, pvItemToQueue, xCoRoutinePreviouslyWoken ) xQueueCRSendFromISR( pxQueue, pvItemToQueue, xCoRoutinePreviouslyWoken ) + + +/** + * croutine. h + *
+  crQUEUE_SEND_FROM_ISR(
+                            xQueueHandle pxQueue,
+                            void *pvBuffer,
+                            portBASE_TYPE * pxCoRoutineWoken
+                       )
+ * + * The macro's crQUEUE_SEND_FROM_ISR() and crQUEUE_RECEIVE_FROM_ISR() are the + * co-routine equivalent to the xQueueSendFromISR() and xQueueReceiveFromISR() + * functions used by tasks. + * + * crQUEUE_SEND_FROM_ISR() and crQUEUE_RECEIVE_FROM_ISR() can only be used to + * pass data between a co-routine and and ISR, whereas xQueueSendFromISR() and + * xQueueReceiveFromISR() can only be used to pass data between a task and and + * ISR. + * + * crQUEUE_RECEIVE_FROM_ISR can only be called from an ISR to receive data + * from a queue that is being used from within a co-routine (a co-routine + * posted to the queue). + * + * See the co-routine section of the WEB documentation for information on + * passing data between tasks and co-routines and between ISR's and + * co-routines. + * + * @param xQueue The handle to the queue on which the item is to be posted. + * + * @param pvBuffer A pointer to a buffer into which the received item will be + * placed. The size of the items the queue will hold was defined when the + * queue was created, so this many bytes will be copied from the queue into + * pvBuffer. + * + * @param pxCoRoutineWoken A co-routine may be blocked waiting for space to become + * available on the queue. If crQUEUE_RECEIVE_FROM_ISR causes such a + * co-routine to unblock *pxCoRoutineWoken will get set to pdTRUE, otherwise + * *pxCoRoutineWoken will remain unchanged. + * + * @return pdTRUE an item was successfully received from the queue, otherwise + * pdFALSE. + * + * Example usage: +
+ // A co-routine that posts a character to a queue then blocks for a fixed
+ // period.  The character is incremented each time.
+ static void vSendingCoRoutine( xCoRoutineHandle xHandle, unsigned portBASE_TYPE uxIndex )
+ {
+ // cChar holds its value while this co-routine is blocked and must therefore
+ // be declared static.
+ static portCHAR cCharToTx = 'a';
+ portBASE_TYPE xResult;
+
+     // All co-routines must start with a call to crSTART().
+     crSTART( xHandle );
+
+     for( ;; )
+     {
+         // Send the next character to the queue.
+         crQUEUE_SEND( xHandle, xCoRoutineQueue, &cCharToTx, NO_DELAY, &xResult );
+
+         if( xResult == pdPASS )
+         {
+             // The character was successfully posted to the queue.
+         }
+		 else
+		 {
+			// Could not post the character to the queue.
+		 }
+
+         // Enable the UART Tx interrupt to cause an interrupt in this
+		 // hypothetical UART.  The interrupt will obtain the character
+		 // from the queue and send it.
+		 ENABLE_RX_INTERRUPT();
+
+		 // Increment to the next character then block for a fixed period.
+		 // cCharToTx will maintain its value across the delay as it is
+		 // declared static.
+		 cCharToTx++;
+		 if( cCharToTx > 'x' )
+		 {
+			cCharToTx = 'a';
+		 }
+		 crDELAY( 100 );
+     }
+
+     // All co-routines must end with a call to crEND().
+     crEND();
+ }
+
+ // An ISR that uses a queue to receive characters to send on a UART.
+ void vUART_ISR( void )
+ {
+ portCHAR cCharToTx;
+ portBASE_TYPE xCRWokenByPost = pdFALSE;
+
+     while( UART_TX_REG_EMPTY() )
+     {
+         // Are there any characters in the queue waiting to be sent?
+		 // xCRWokenByPost will automatically be set to pdTRUE if a co-routine
+		 // is woken by the post - ensuring that only a single co-routine is
+		 // woken no matter how many times we go around this loop.
+         if( crQUEUE_RECEIVE_FROM_ISR( pxQueue, &cCharToTx, &xCRWokenByPost ) )
+		 {
+			 SEND_CHARACTER( cCharToTx );
+		 }
+     }
+ }
+ * \defgroup crQUEUE_RECEIVE_FROM_ISR crQUEUE_RECEIVE_FROM_ISR + * \ingroup Tasks + */ +#define crQUEUE_RECEIVE_FROM_ISR( pxQueue, pvBuffer, pxCoRoutineWoken ) xQueueCRReceiveFromISR( pxQueue, pvBuffer, pxCoRoutineWoken ) + +/* + * This function is intended for internal use by the co-routine macros only. + * The macro nature of the co-routine implementation requires that the + * prototype appears here. The function should not be used by application + * writers. + * + * Removes the current co-routine from its ready list and places it in the + * appropriate delayed list. + */ +void vCoRoutineAddToDelayedList( portTickType xTicksToDelay, xList *pxEventList ); + +/* + * This function is intended for internal use by the queue implementation only. + * The function should not be used by application writers. + * + * Removes the highest priority co-routine from the event list and places it in + * the pending ready list. + */ +signed portBASE_TYPE xCoRoutineRemoveFromEventList( const xList *pxEventList ); + +#ifdef __cplusplus +} +#endif + +#endif /* CO_ROUTINE_H */ diff --git a/Tester/SW/lib/FreeRTOS/Source/include/list.h b/Tester/SW/lib/FreeRTOS/Source/include/list.h new file mode 100644 index 0000000..e4f63fe --- /dev/null +++ b/Tester/SW/lib/FreeRTOS/Source/include/list.h @@ -0,0 +1,288 @@ +/* + FreeRTOS.org V4.6.1 - Copyright (C) 2003-2007 Richard Barry. + + This file is part of the FreeRTOS.org distribution. + + FreeRTOS.org is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + FreeRTOS.org is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with FreeRTOS.org; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + A special exception to the GPL can be applied should you wish to distribute + a combined work that includes FreeRTOS.org, without being obliged to provide + the source code for any proprietary components. See the licensing section + of http://www.FreeRTOS.org for full details of how and when the exception + can be applied. + + *************************************************************************** + See http://www.FreeRTOS.org for documentation, latest information, license + and contact details. Please ensure to read the configuration and relevant + port sections of the online documentation. + + Also see http://www.SafeRTOS.com a version that has been certified for use + in safety critical systems, plus commercial licensing, development and + support options. + *************************************************************************** +*/ + +/* + * This is the list implementation used by the scheduler. While it is tailored + * heavily for the schedulers needs, it is also available for use by + * application code. + * + * xLists can only store pointers to xListItems. Each xListItem contains a + * numeric value (xItemValue). Most of the time the lists are sorted in + * descending item value order. + * + * Lists are created already containing one list item. The value of this + * item is the maximum possible that can be stored, it is therefore always at + * the end of the list and acts as a marker. The list member pxHead always + * points to this marker - even though it is at the tail of the list. This + * is because the tail contains a wrap back pointer to the true head of + * the list. + * + * In addition to it's value, each list item contains a pointer to the next + * item in the list (pxNext), a pointer to the list it is in (pxContainer) + * and a pointer to back to the object that contains it. These later two + * pointers are included for efficiency of list manipulation. There is + * effectively a two way link between the object containing the list item and + * the list item itself. + * + * + * \page ListIntroduction List Implementation + * \ingroup FreeRTOSIntro + */ + +/* + Changes from V4.3.1 + + + Included local const within listGET_OWNER_OF_NEXT_ENTRY() to assist + compiler with optimisation. Thanks B.R. +*/ + +#ifndef LIST_H +#define LIST_H + +#ifdef __cplusplus +extern "C" { +#endif +/* + * Definition of the only type of object that a list can contain. + */ +struct xLIST_ITEM +{ + portTickType xItemValue; /*< The value being listed. In most cases this is used to sort the list in descending order. */ + volatile struct xLIST_ITEM * pxNext; /*< Pointer to the next xListItem in the list. */ + volatile struct xLIST_ITEM * pxPrevious;/*< Pointer to the previous xListItem in the list. */ + void * pvOwner; /*< Pointer to the object (normally a TCB) that contains the list item. There is therefore a two way link between the object containing the list item and the list item itself. */ + void * pvContainer; /*< Pointer to the list in which this list item is placed (if any). */ +}; +typedef struct xLIST_ITEM xListItem; /* For some reason lint wants this as two separate definitions. */ + +struct xMINI_LIST_ITEM +{ + portTickType xItemValue; + volatile struct xLIST_ITEM *pxNext; + volatile struct xLIST_ITEM *pxPrevious; +}; +typedef struct xMINI_LIST_ITEM xMiniListItem; + +/* + * Definition of the type of queue used by the scheduler. + */ +typedef struct xLIST +{ + volatile unsigned portBASE_TYPE uxNumberOfItems; + volatile xListItem * pxIndex; /*< Used to walk through the list. Points to the last item returned by a call to pvListGetOwnerOfNextEntry (). */ + volatile xMiniListItem xListEnd; /*< List item that contains the maximum possible item value meaning it is always at the end of the list and is therefore used as a marker. */ +} xList; + +/* + * Access macro to set the owner of a list item. The owner of a list item + * is the object (usually a TCB) that contains the list item. + * + * \page listSET_LIST_ITEM_OWNER listSET_LIST_ITEM_OWNER + * \ingroup LinkedList + */ +#define listSET_LIST_ITEM_OWNER( pxListItem, pxOwner ) ( pxListItem )->pvOwner = ( void * ) pxOwner + +/* + * Access macro to set the value of the list item. In most cases the value is + * used to sort the list in descending order. + * + * \page listSET_LIST_ITEM_VALUE listSET_LIST_ITEM_VALUE + * \ingroup LinkedList + */ +#define listSET_LIST_ITEM_VALUE( pxListItem, xValue ) ( pxListItem )->xItemValue = xValue + +/* + * Access macro the retrieve the value of the list item. The value can + * represent anything - for example a the priority of a task, or the time at + * which a task should be unblocked. + * + * \page listGET_LIST_ITEM_VALUE listGET_LIST_ITEM_VALUE + * \ingroup LinkedList + */ +#define listGET_LIST_ITEM_VALUE( pxListItem ) ( ( pxListItem )->xItemValue ) + +/* + * Access macro to determine if a list contains any items. The macro will + * only have the value true if the list is empty. + * + * \page listLIST_IS_EMPTY listLIST_IS_EMPTY + * \ingroup LinkedList + */ +#define listLIST_IS_EMPTY( pxList ) ( ( pxList )->uxNumberOfItems == ( unsigned portBASE_TYPE ) 0 ) + +/* + * Access macro to return the number of items in the list. + */ +#define listCURRENT_LIST_LENGTH( pxList ) ( ( pxList )->uxNumberOfItems ) + +/* + * Access function to obtain the owner of the next entry in a list. + * + * The list member pxIndex is used to walk through a list. Calling + * listGET_OWNER_OF_NEXT_ENTRY increments pxIndex to the next item in the list + * and returns that entries pxOwner parameter. Using multiple calls to this + * function it is therefore possible to move through every item contained in + * a list. + * + * The pxOwner parameter of a list item is a pointer to the object that owns + * the list item. In the scheduler this is normally a task control block. + * The pxOwner parameter effectively creates a two way link between the list + * item and its owner. + * + * @param pxList The list from which the next item owner is to be returned. + * + * \page listGET_OWNER_OF_NEXT_ENTRY listGET_OWNER_OF_NEXT_ENTRY + * \ingroup LinkedList + */ +#define listGET_OWNER_OF_NEXT_ENTRY( pxTCB, pxList ) \ +{ \ +xList * const pxConstList = pxList; \ + /* Increment the index to the next item and return the item, ensuring */ \ + /* we don't return the marker used at the end of the list. */ \ + ( pxConstList )->pxIndex = ( pxConstList )->pxIndex->pxNext; \ + if( ( pxConstList )->pxIndex == ( xListItem * ) &( ( pxConstList )->xListEnd ) ) \ + { \ + ( pxConstList )->pxIndex = ( pxConstList )->pxIndex->pxNext; \ + } \ + pxTCB = ( pxConstList )->pxIndex->pvOwner; \ +} + + +/* + * Access function to obtain the owner of the first entry in a list. Lists + * are normally sorted in ascending item value order. + * + * This function returns the pxOwner member of the first item in the list. + * The pxOwner parameter of a list item is a pointer to the object that owns + * the list item. In the scheduler this is normally a task control block. + * The pxOwner parameter effectively creates a two way link between the list + * item and its owner. + * + * @param pxList The list from which the owner of the head item is to be + * returned. + * + * \page listGET_OWNER_OF_HEAD_ENTRY listGET_OWNER_OF_HEAD_ENTRY + * \ingroup LinkedList + */ +#define listGET_OWNER_OF_HEAD_ENTRY( pxList ) ( ( pxList->uxNumberOfItems != ( unsigned portBASE_TYPE ) 0 ) ? ( (&( pxList->xListEnd ))->pxNext->pvOwner ) : ( NULL ) ) + +/* + * Check to see if a list item is within a list. The list item maintains a + * "container" pointer that points to the list it is in. All this macro does + * is check to see if the container and the list match. + * + * @param pxList The list we want to know if the list item is within. + * @param pxListItem The list item we want to know if is in the list. + * @return pdTRUE is the list item is in the list, otherwise pdFALSE. + * pointer against + */ +#define listIS_CONTAINED_WITHIN( pxList, pxListItem ) ( ( pxListItem )->pvContainer == ( void * ) pxList ) + +/* + * Must be called before a list is used! This initialises all the members + * of the list structure and inserts the xListEnd item into the list as a + * marker to the back of the list. + * + * @param pxList Pointer to the list being initialised. + * + * \page vListInitialise vListInitialise + * \ingroup LinkedList + */ +void vListInitialise( xList *pxList ); + +/* + * Must be called before a list item is used. This sets the list container to + * null so the item does not think that it is already contained in a list. + * + * @param pxItem Pointer to the list item being initialised. + * + * \page vListInitialiseItem vListInitialiseItem + * \ingroup LinkedList + */ +void vListInitialiseItem( xListItem *pxItem ); + +/* + * Insert a list item into a list. The item will be inserted into the list in + * a position determined by its item value (descending item value order). + * + * @param pxList The list into which the item is to be inserted. + * + * @param pxNewListItem The item to that is to be placed in the list. + * + * \page vListInsert vListInsert + * \ingroup LinkedList + */ +void vListInsert( xList *pxList, xListItem *pxNewListItem ); + +/* + * Insert a list item into a list. The item will be inserted in a position + * such that it will be the last item within the list returned by multiple + * calls to listGET_OWNER_OF_NEXT_ENTRY. + * + * The list member pvIndex is used to walk through a list. Calling + * listGET_OWNER_OF_NEXT_ENTRY increments pvIndex to the next item in the list. + * Placing an item in a list using vListInsertEnd effectively places the item + * in the list position pointed to by pvIndex. This means that every other + * item within the list will be returned by listGET_OWNER_OF_NEXT_ENTRY before + * the pvIndex parameter again points to the item being inserted. + * + * @param pxList The list into which the item is to be inserted. + * + * @param pxNewListItem The list item to be inserted into the list. + * + * \page vListInsertEnd vListInsertEnd + * \ingroup LinkedList + */ +void vListInsertEnd( xList *pxList, xListItem *pxNewListItem ); + +/* + * Remove an item from a list. The list item has a pointer to the list that + * it is in, so only the list item need be passed into the function. + * + * @param vListRemove The item to be removed. The item will remove itself from + * the list pointed to by it's pxContainer parameter. + * + * \page vListRemove vListRemove + * \ingroup LinkedList + */ +void vListRemove( xListItem *pxItemToRemove ); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/Tester/SW/lib/FreeRTOS/Source/include/portable.h b/Tester/SW/lib/FreeRTOS/Source/include/portable.h new file mode 100644 index 0000000..6c45fdf --- /dev/null +++ b/Tester/SW/lib/FreeRTOS/Source/include/portable.h @@ -0,0 +1,249 @@ +/* + FreeRTOS.org V4.6.1 - Copyright (C) 2003-2007 Richard Barry. + + This file is part of the FreeRTOS.org distribution. + + FreeRTOS.org is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + FreeRTOS.org is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with FreeRTOS.org; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + A special exception to the GPL can be applied should you wish to distribute + a combined work that includes FreeRTOS.org, without being obliged to provide + the source code for any proprietary components. See the licensing section + of http:www.FreeRTOS.org for full details of how and when the exception + can be applied. + + *************************************************************************** + See http:www.FreeRTOS.org for documentation, latest information, license + and contact details. Please ensure to read the configuration and relevant + port sections of the online documentation. + + Also see http://www.SafeRTOS.com a version that has been certified for use + in safety critical systems, plus commercial licensing, development and + support options. + *************************************************************************** +*/ + +/*----------------------------------------------------------- + * Portable layer API. Each function must be defined for each port. + *----------------------------------------------------------*/ + +#ifndef PORTABLE_H +#define PORTABLE_H + +/* Include the macro file relevant to the port being used. */ + +#ifdef OPEN_WATCOM_INDUSTRIAL_PC_PORT + #include "..\..\source\portable\owatcom\16bitdos\pc\portmacro.h" + typedef void ( __interrupt __far *pxISR )(); +#endif + +#ifdef OPEN_WATCOM_FLASH_LITE_186_PORT + #include "..\..\source\portable\owatcom\16bitdos\flsh186\portmacro.h" + typedef void ( __interrupt __far *pxISR )(); +#endif + +#ifdef GCC_MEGA_AVR + #include "../portable/GCC/ATMega323/portmacro.h" +#endif + +#ifdef IAR_MEGA_AVR + #include "../portable/IAR/ATMega323/portmacro.h" +#endif + +#ifdef MPLAB_PIC24_PORT + #include "..\..\Source\portable\MPLAB\PIC24_dsPIC\portmacro.h" +#endif + +#ifdef MPLAB_DSPIC_PORT + #include "..\..\Source\portable\MPLAB\PIC24_dsPIC\portmacro.h" +#endif + +#ifdef MPLAB_PIC18F_PORT + #include "..\..\source\portable\MPLAB\PIC18F\portmacro.h" +#endif + +#ifdef MPLAB_PIC32MX_PORT + #include "..\..\Source\portable\MPLAB\PIC32MX\portmacro.h" +#endif + +#ifdef _FEDPICC + #include "libFreeRTOS/Include/portmacro.h" +#endif + +#ifdef SDCC_CYGNAL + #include "../../Source/portable/SDCC/Cygnal/portmacro.h" +#endif + +#ifdef GCC_ARM7 + #include "../../Source/portable/GCC/ARM7_LPC2000/portmacro.h" +#endif + +#ifdef GCC_ARM7_ECLIPSE + #include "portmacro.h" +#endif + +#ifdef ROWLEY_LPC23xx + #include "../../Source/portable/GCC/ARM7_LPC23xx/portmacro.h" +#endif + +#ifdef GCC_MSP430 + #include "../../Source/portable/GCC/MSP430F449/portmacro.h" +#endif + +#ifdef ROWLEY_MSP430 + #include "../../Source/portable/Rowley/MSP430F449/portmacro.h" +#endif + +#ifdef KEIL_ARM7 + #include "..\..\Source\portable\Keil\ARM7\portmacro.h" +#endif + +#ifdef SAM7_GCC + #include "../../Source/portable/GCC/ARM7_AT91SAM7S/portmacro.h" +#endif + +#ifdef SAM7_IAR + #include "..\..\Source\portable\IAR\AtmelSAM7S64\portmacro.h" +#endif + +#ifdef LPC2000_IAR + #include "..\..\Source\portable\IAR\LPC2000\portmacro.h" +#endif + +#ifdef STR71X_IAR + #include "..\..\Source\portable\IAR\STR71x\portmacro.h" +#endif + +#ifdef STR75X_IAR + #include "..\..\Source\portable\IAR\STR75x\portmacro.h" +#endif + +#ifdef STR75X_GCC + #include "..\..\Source\portable\GCC\STR75x\portmacro.h" +#endif + +#ifdef STR91X_IAR + #include "..\..\Source\portable\IAR\STR91x\portmacro.h" +#endif + +#ifdef GCC_H8S + #include "../../Source/portable/GCC/H8S2329/portmacro.h" +#endif + +#ifdef GCC_AT91FR40008 + #include "../../Source/portable/GCC/ARM7_AT91FR40008/portmacro.h" +#endif + +#ifdef RVDS_ARMCM3_LM3S102 + #include "../../Source/portable/RVDS/ARM_CM3/portmacro.h" +#endif + +#ifdef GCC_ARMCM3_LM3S102 + #include "../../Source/portable/GCC/ARM_CM3/portmacro.h" +#endif + +#ifdef IAR_ARM_CM3 + #include "../../Source/portable/IAR/ARM_CM3/portmacro.h" +#endif + +#ifdef IAR_ARMCM3_LM + #include "../../Source/portable/IAR/ARM_CM3/portmacro.h" +#endif + +#ifdef HCS12_CODE_WARRIOR + #include "../../Source/portable/CodeWarrior/HCS12/portmacro.h" +#endif + +#ifdef MICROBLAZE_GCC + #include "../../Source/portable/GCC/MicroBlaze/portmacro.h" +#endif + +#ifdef TERN_EE + #include "..\..\Source\portable\Paradigm\Tern_EE\small\portmacro.h" +#endif + +#ifdef GCC_HCS12 + #include "../../Source/portable/GCC/HCS12/portmacro.h" +#endif + +#ifdef GCC_MCF5235 + #include "../../Source/portable/GCC/MCF5235/portmacro.h" +#endif + +#ifdef BCC_INDUSTRIAL_PC_PORT + /* A short file name has to be used in place of the normal + FreeRTOSConfig.h when using the Borland compiler. */ + #include "frconfig.h" + #include "..\portable\BCC\16BitDOS\PC\prtmacro.h" + typedef void ( __interrupt __far *pxISR )(); +#endif + +#ifdef BCC_FLASH_LITE_186_PORT + /* A short file name has to be used in place of the normal + FreeRTOSConfig.h when using the Borland compiler. */ + #include "frconfig.h" + #include "..\portable\BCC\16BitDOS\flsh186\prtmacro.h" + typedef void ( __interrupt __far *pxISR )(); +#endif + +#ifdef __GNUC__ + #ifdef __AVR32_AVR32A__ + #include "portmacro.h" + #endif +#endif + +#ifdef __ICCAVR32__ + #ifdef __CORE__ + #if __CORE__ == __AVR32A__ + #include "portmacro.h" + #endif + #endif +#endif + +#ifdef __cplusplus +extern "C" { +#endif +/* + * Setup the stack of a new task so it is ready to be placed under the + * scheduler control. The registers have to be placed on the stack in + * the order that the port expects to find them. + */ +portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE pxCode, void *pvParameters ); + +/* + * Map to the memory management routines required for the port. + */ +void *pvPortMalloc( size_t xSize ); +void vPortFree( void *pv ); +void vPortInitialiseBlocks( void ); + +/* + * Setup the hardware ready for the scheduler to take control. This generally + * sets up a tick interrupt and sets timers for the correct tick frequency. + */ +portBASE_TYPE xPortStartScheduler( void ); + +/* + * Undo any hardware/ISR setup that was performed by xPortStartScheduler() so + * the hardware is left in its original condition after the scheduler stops + * executing. + */ +void vPortEndScheduler( void ); + +#ifdef __cplusplus +} +#endif + +#endif /* PORTABLE_H */ + diff --git a/Tester/SW/lib/FreeRTOS/Source/include/projdefs.h b/Tester/SW/lib/FreeRTOS/Source/include/projdefs.h new file mode 100644 index 0000000..bd42b32 --- /dev/null +++ b/Tester/SW/lib/FreeRTOS/Source/include/projdefs.h @@ -0,0 +1,60 @@ +/* + FreeRTOS.org V4.6.1 - Copyright (C) 2003-2007 Richard Barry. + + This file is part of the FreeRTOS.org distribution. + + FreeRTOS.org is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + FreeRTOS.org is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with FreeRTOS.org; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + A special exception to the GPL can be applied should you wish to distribute + a combined work that includes FreeRTOS.org, without being obliged to provide + the source code for any proprietary components. See the licensing section + of http://www.FreeRTOS.org for full details of how and when the exception + can be applied. + + *************************************************************************** + See http://www.FreeRTOS.org for documentation, latest information, license + and contact details. Please ensure to read the configuration and relevant + port sections of the online documentation. + + Also see http://www.SafeRTOS.com a version that has been certified for use + in safety critical systems, plus commercial licensing, development and + support options. + *************************************************************************** +*/ + +#ifndef PROJDEFS_H +#define PROJDEFS_H + +/* Defines to prototype to which task functions must conform. */ +typedef void (*pdTASK_CODE)( void * ); + +#define pdTRUE ( 1 ) +#define pdFALSE ( 0 ) + +#define pdPASS ( 1 ) +#define pdFAIL ( 0 ) +#define errQUEUE_EMPTY ( 0 ) +#define errQUEUE_FULL ( 0 ) + +/* Error definitions. */ +#define errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY ( -1 ) +#define errNO_TASK_TO_RUN ( -2 ) +#define errQUEUE_BLOCKED ( -4 ) +#define errQUEUE_YIELD ( -5 ) + +#endif /* PROJDEFS_H */ + + + diff --git a/Tester/SW/lib/FreeRTOS/Source/include/queue.h b/Tester/SW/lib/FreeRTOS/Source/include/queue.h new file mode 100644 index 0000000..482ccc3 --- /dev/null +++ b/Tester/SW/lib/FreeRTOS/Source/include/queue.h @@ -0,0 +1,1188 @@ +/* + FreeRTOS.org V4.6.1 - Copyright (C) 2003-2007 Richard Barry. + + This file is part of the FreeRTOS.org distribution. + + FreeRTOS.org is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + FreeRTOS.org is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with FreeRTOS.org; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + A special exception to the GPL can be applied should you wish to distribute + a combined work that includes FreeRTOS.org, without being obliged to provide + the source code for any proprietary components. See the licensing section + of http://www.FreeRTOS.org for full details of how and when the exception + can be applied. + + *************************************************************************** + See http://www.FreeRTOS.org for documentation, latest information, license + and contact details. Please ensure to read the configuration and relevant + port sections of the online documentation. + + Also see http://www.SafeRTOS.com a version that has been certified for use + in safety critical systems, plus commercial licensing, development and + support options. + *************************************************************************** +*/ + +#ifndef QUEUE_H +#define QUEUE_H + +#ifdef __cplusplus +extern "C" { +#endif +typedef void * xQueueHandle; + +/* For internal use only. */ +#define queueSEND_TO_BACK ( 0 ) +#define queueSEND_TO_FRONT ( 1 ) + + +/** + * queue. h + *
+ xQueueHandle xQueueCreate(
+                              unsigned portBASE_TYPE uxQueueLength,
+                              unsigned portBASE_TYPE uxItemSize
+                          );
+ * 
+ * + * Creates a new queue instance. This allocates the storage required by the + * new queue and returns a handle for the queue. + * + * @param uxQueueLength The maximum number of items that the queue can contain. + * + * @param uxItemSize The number of bytes each item in the queue will require. + * Items are queued by copy, not by reference, so this is the number of bytes + * that will be copied for each posted item. Each item on the queue must be + * the same size. + * + * @return If the queue is successfully create then a handle to the newly + * created queue is returned. If the queue cannot be created then 0 is + * returned. + * + * Example usage: +
+ struct AMessage
+ {
+    portCHAR ucMessageID;
+    portCHAR ucData[ 20 ];
+ };
+
+ void vATask( void *pvParameters )
+ {
+ xQueueHandle xQueue1, xQueue2;
+
+    // Create a queue capable of containing 10 unsigned long values.
+    xQueue1 = xQueueCreate( 10, sizeof( unsigned portLONG ) );
+    if( xQueue1 == 0 )
+    {
+        // Queue was not created and must not be used.
+    }
+
+    // Create a queue capable of containing 10 pointers to AMessage structures.
+    // These should be passed by pointer as they contain a lot of data.
+    xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );
+    if( xQueue2 == 0 )
+    {
+        // Queue was not created and must not be used.
+    }
+
+    // ... Rest of task code.
+ }
+ 
+ * \defgroup xQueueCreate xQueueCreate + * \ingroup QueueManagement + */ +xQueueHandle xQueueCreate( unsigned portBASE_TYPE uxQueueLength, unsigned portBASE_TYPE uxItemSize ); + +/** + * queue. h + *
+ portBASE_TYPE xQueueSendToToFront(
+                                   xQueueHandle xQueue,
+                                   const void * pvItemToQueue,
+                                   portTickType xTicksToWait
+                               );
+ * 
+ * + * This is a macro that calls xQueueGenericSend(). + * + * Post an item to the front of a queue. The item is queued by copy, not by + * reference. This function must not be called from an interrupt service + * routine. See xQueueSendFromISR () for an alternative which may be used + * in an ISR. + * + * @param xQueue The handle to the queue on which the item is to be posted. + * + * @param pvItemToQueue A pointer to the item that is to be placed on the + * queue. The size of the items the queue will hold was defined when the + * queue was created, so this many bytes will be copied from pvItemToQueue + * into the queue storage area. + * + * @param xTicksToWait The maximum amount of time the task should block + * waiting for space to become available on the queue, should it already + * be full. The call will return immediately if this is set to 0. The + * time is defined in tick periods so the constant portTICK_RATE_MS + * should be used to convert to real time if this is required. + * + * @return pdTRUE if the item was successfully posted, otherwise errQUEUE_FULL. + * + * Example usage: +
+ struct AMessage
+ {
+    portCHAR ucMessageID;
+    portCHAR ucData[ 20 ];
+ } xMessage;
+
+ unsigned portLONG ulVar = 10UL;
+
+ void vATask( void *pvParameters )
+ {
+ xQueueHandle xQueue1, xQueue2;
+ struct AMessage *pxMessage;
+
+    // Create a queue capable of containing 10 unsigned long values.
+    xQueue1 = xQueueCreate( 10, sizeof( unsigned portLONG ) );
+
+    // Create a queue capable of containing 10 pointers to AMessage structures.
+    // These should be passed by pointer as they contain a lot of data.
+    xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );
+
+    // ...
+
+    if( xQueue1 != 0 )
+    {
+        // Send an unsigned long.  Wait for 10 ticks for space to become
+        // available if necessary.
+        if( xQueueSendToFront( xQueue1, ( void * ) &ulVar, ( portTickType ) 10 ) != pdPASS )
+        {
+            // Failed to post the message, even after 10 ticks.
+        }
+    }
+
+    if( xQueue2 != 0 )
+    {
+        // Send a pointer to a struct AMessage object.  Don't block if the
+        // queue is already full.
+        pxMessage = & xMessage;
+        xQueueSendToFront( xQueue2, ( void * ) &pxMessage, ( portTickType ) 0 );
+    }
+
+	// ... Rest of task code.
+ }
+ 
+ * \defgroup xQueueSend xQueueSend + * \ingroup QueueManagement + */ +#define xQueueSendToFront( xQueue, pvItemToQueue, xTicksToWait ) xQueueGenericSend( xQueue, pvItemToQueue, xTicksToWait, queueSEND_TO_FRONT ) + +/** + * queue. h + *
+ portBASE_TYPE xQueueSendToBack(
+                                   xQueueHandle xQueue,
+                                   const void * pvItemToQueue,
+                                   portTickType xTicksToWait
+                               );
+ * 
+ * + * This is a macro that calls xQueueGenericSend(). + * + * Post an item to the back of a queue. The item is queued by copy, not by + * reference. This function must not be called from an interrupt service + * routine. See xQueueSendFromISR () for an alternative which may be used + * in an ISR. + * + * @param xQueue The handle to the queue on which the item is to be posted. + * + * @param pvItemToQueue A pointer to the item that is to be placed on the + * queue. The size of the items the queue will hold was defined when the + * queue was created, so this many bytes will be copied from pvItemToQueue + * into the queue storage area. + * + * @param xTicksToWait The maximum amount of time the task should block + * waiting for space to become available on the queue, should it already + * be full. The call will return immediately if this is set to 0. The + * time is defined in tick periods so the constant portTICK_RATE_MS + * should be used to convert to real time if this is required. + * + * @return pdTRUE if the item was successfully posted, otherwise errQUEUE_FULL. + * + * Example usage: +
+ struct AMessage
+ {
+    portCHAR ucMessageID;
+    portCHAR ucData[ 20 ];
+ } xMessage;
+
+ unsigned portLONG ulVar = 10UL;
+
+ void vATask( void *pvParameters )
+ {
+ xQueueHandle xQueue1, xQueue2;
+ struct AMessage *pxMessage;
+
+    // Create a queue capable of containing 10 unsigned long values.
+    xQueue1 = xQueueCreate( 10, sizeof( unsigned portLONG ) );
+
+    // Create a queue capable of containing 10 pointers to AMessage structures.
+    // These should be passed by pointer as they contain a lot of data.
+    xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );
+
+    // ...
+
+    if( xQueue1 != 0 )
+    {
+        // Send an unsigned long.  Wait for 10 ticks for space to become
+        // available if necessary.
+        if( xQueueSendToBack( xQueue1, ( void * ) &ulVar, ( portTickType ) 10 ) != pdPASS )
+        {
+            // Failed to post the message, even after 10 ticks.
+        }
+    }
+
+    if( xQueue2 != 0 )
+    {
+        // Send a pointer to a struct AMessage object.  Don't block if the
+        // queue is already full.
+        pxMessage = & xMessage;
+        xQueueSendToBack( xQueue2, ( void * ) &pxMessage, ( portTickType ) 0 );
+    }
+
+	// ... Rest of task code.
+ }
+ 
+ * \defgroup xQueueSend xQueueSend + * \ingroup QueueManagement + */ +#define xQueueSendToBack( xQueue, pvItemToQueue, xTicksToWait ) xQueueGenericSend( xQueue, pvItemToQueue, xTicksToWait, queueSEND_TO_BACK ) + +/** + * queue. h + *
+ portBASE_TYPE xQueueSend(
+                              xQueueHandle xQueue,
+                              const void * pvItemToQueue,
+                              portTickType xTicksToWait
+                         );
+ * 
+ * + * This is a macro that calls xQueueGenericSend(). It is included for + * backward compatibility with versions of FreeRTOS.org that did not + * include the xQueueSendToFront() and xQueueSendToBack() macros. It is + * equivalent to xQueueSendToBack(). + * + * Post an item on a queue. The item is queued by copy, not by reference. + * This function must not be called from an interrupt service routine. + * See xQueueSendFromISR () for an alternative which may be used in an ISR. + * + * @param xQueue The handle to the queue on which the item is to be posted. + * + * @param pvItemToQueue A pointer to the item that is to be placed on the + * queue. The size of the items the queue will hold was defined when the + * queue was created, so this many bytes will be copied from pvItemToQueue + * into the queue storage area. + * + * @param xTicksToWait The maximum amount of time the task should block + * waiting for space to become available on the queue, should it already + * be full. The call will return immediately if this is set to 0. The + * time is defined in tick periods so the constant portTICK_RATE_MS + * should be used to convert to real time if this is required. + * + * @return pdTRUE if the item was successfully posted, otherwise errQUEUE_FULL. + * + * Example usage: +
+ struct AMessage
+ {
+    portCHAR ucMessageID;
+    portCHAR ucData[ 20 ];
+ } xMessage;
+
+ unsigned portLONG ulVar = 10UL;
+
+ void vATask( void *pvParameters )
+ {
+ xQueueHandle xQueue1, xQueue2;
+ struct AMessage *pxMessage;
+
+    // Create a queue capable of containing 10 unsigned long values.
+    xQueue1 = xQueueCreate( 10, sizeof( unsigned portLONG ) );
+
+    // Create a queue capable of containing 10 pointers to AMessage structures.
+    // These should be passed by pointer as they contain a lot of data.
+    xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );
+
+    // ...
+
+    if( xQueue1 != 0 )
+    {
+        // Send an unsigned long.  Wait for 10 ticks for space to become
+        // available if necessary.
+        if( xQueueSend( xQueue1, ( void * ) &ulVar, ( portTickType ) 10 ) != pdPASS )
+        {
+            // Failed to post the message, even after 10 ticks.
+        }
+    }
+
+    if( xQueue2 != 0 )
+    {
+        // Send a pointer to a struct AMessage object.  Don't block if the
+        // queue is already full.
+        pxMessage = & xMessage;
+        xQueueSend( xQueue2, ( void * ) &pxMessage, ( portTickType ) 0 );
+    }
+
+	// ... Rest of task code.
+ }
+ 
+ * \defgroup xQueueSend xQueueSend + * \ingroup QueueManagement + */ +#define xQueueSend( xQueue, pvItemToQueue, xTicksToWait ) xQueueGenericSend( xQueue, pvItemToQueue, xTicksToWait, queueSEND_TO_BACK ) + + +/** + * queue. h + *
+ portBASE_TYPE xQueueGenericSend(
+									xQueueHandle xQueue,
+									const void * pvItemToQueue,
+									portTickType xTicksToWait
+									portBASE_TYPE xCopyPosition
+								);
+ * 
+ * + * It is preferred that the macros xQueueSend(), xQueueSendToFront() and + * xQueueSendToBack() are used in place of calling this function directly. + * + * Post an item on a queue. The item is queued by copy, not by reference. + * This function must not be called from an interrupt service routine. + * See xQueueSendFromISR () for an alternative which may be used in an ISR. + * + * @param xQueue The handle to the queue on which the item is to be posted. + * + * @param pvItemToQueue A pointer to the item that is to be placed on the + * queue. The size of the items the queue will hold was defined when the + * queue was created, so this many bytes will be copied from pvItemToQueue + * into the queue storage area. + * + * @param xTicksToWait The maximum amount of time the task should block + * waiting for space to become available on the queue, should it already + * be full. The call will return immediately if this is set to 0. The + * time is defined in tick periods so the constant portTICK_RATE_MS + * should be used to convert to real time if this is required. + * + * @param xCopyPosition Can take the value queueSEND_TO_BACK to place the + * item at the back of the queue, or queueSEND_TO_FRONT to place the item + * at the front of the queue (for high priority messages). + * + * @return pdTRUE if the item was successfully posted, otherwise errQUEUE_FULL. + * + * Example usage: +
+ struct AMessage
+ {
+    portCHAR ucMessageID;
+    portCHAR ucData[ 20 ];
+ } xMessage;
+
+ unsigned portLONG ulVar = 10UL;
+
+ void vATask( void *pvParameters )
+ {
+ xQueueHandle xQueue1, xQueue2;
+ struct AMessage *pxMessage;
+
+    // Create a queue capable of containing 10 unsigned long values.
+    xQueue1 = xQueueCreate( 10, sizeof( unsigned portLONG ) );
+
+    // Create a queue capable of containing 10 pointers to AMessage structures.
+    // These should be passed by pointer as they contain a lot of data.
+    xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );
+
+    // ...
+
+    if( xQueue1 != 0 )
+    {
+        // Send an unsigned long.  Wait for 10 ticks for space to become
+        // available if necessary.
+        if( xQueueGenericSend( xQueue1, ( void * ) &ulVar, ( portTickType ) 10, queueSEND_TO_BACK ) != pdPASS )
+        {
+            // Failed to post the message, even after 10 ticks.
+        }
+    }
+
+    if( xQueue2 != 0 )
+    {
+        // Send a pointer to a struct AMessage object.  Don't block if the
+        // queue is already full.
+        pxMessage = & xMessage;
+        xQueueGenericSend( xQueue2, ( void * ) &pxMessage, ( portTickType ) 0, queueSEND_TO_BACK );
+    }
+
+	// ... Rest of task code.
+ }
+ 
+ * \defgroup xQueueSend xQueueSend + * \ingroup QueueManagement + */ +signed portBASE_TYPE xQueueGenericSend( xQueueHandle xQueue, const void * const pvItemToQueue, portTickType xTicksToWait, portBASE_TYPE xCopyPosition ); + +/** + * queue. h + *
+ portBASE_TYPE xQueuePeek(
+                             xQueueHandle xQueue,
+                             void *pvBuffer,
+                             portTickType xTicksToWait
+                         );
+ * + * This is a macro that calls the xQueueGenericReceive() function. + * + * Receive an item from a queue without removing the item from the queue. + * The item is received by copy so a buffer of adequate size must be + * provided. The number of bytes copied into the buffer was defined when + * the queue was created. + * + * Successfully received items remain on the queue so will be returned again + * by the next call, or a call to xQueueReceive(). + * + * This macro must not be used in an interrupt service routine. + * + * @param pxQueue The handle to the queue from which the item is to be + * received. + * + * @param pvBuffer Pointer to the buffer into which the received item will + * be copied. + * + * @param xTicksToWait The maximum amount of time the task should block + * waiting for an item to receive should the queue be empty at the time + * of the call. The time is defined in tick periods so the constant + * portTICK_RATE_MS should be used to convert to real time if this is required. + * + * @return pdTRUE if an item was successfully received from the queue, + * otherwise pdFALSE. + * + * Example usage: +
+ struct AMessage
+ {
+    portCHAR ucMessageID;
+    portCHAR ucData[ 20 ];
+ } xMessage;
+
+ xQueueHandle xQueue;
+
+ // Task to create a queue and post a value.
+ void vATask( void *pvParameters )
+ {
+ struct AMessage *pxMessage;
+
+    // Create a queue capable of containing 10 pointers to AMessage structures.
+    // These should be passed by pointer as they contain a lot of data.
+    xQueue = xQueueCreate( 10, sizeof( struct AMessage * ) );
+    if( xQueue == 0 )
+    {
+        // Failed to create the queue.
+    }
+
+    // ...
+
+    // Send a pointer to a struct AMessage object.  Don't block if the
+    // queue is already full.
+    pxMessage = & xMessage;
+    xQueueSend( xQueue, ( void * ) &pxMessage, ( portTickType ) 0 );
+
+	// ... Rest of task code.
+ }
+
+ // Task to peek the data from the queue.
+ void vADifferentTask( void *pvParameters )
+ {
+ struct AMessage *pxRxedMessage;
+
+    if( xQueue != 0 )
+    {
+        // Peek a message on the created queue.  Block for 10 ticks if a
+        // message is not immediately available.
+        if( xQueuePeek( xQueue, &( pxRxedMessage ), ( portTickType ) 10 ) )
+        {
+            // pcRxedMessage now points to the struct AMessage variable posted
+            // by vATask, but the item still remains on the queue.
+        }
+    }
+
+	// ... Rest of task code.
+ }
+ 
+ * \defgroup xQueueReceive xQueueReceive + * \ingroup QueueManagement + */ +#define xQueuePeek( xQueue, pvBuffer, xTicksToWait ) xQueueGenericReceive( xQueue, pvBuffer, xTicksToWait, pdTRUE ) + +/** + * queue. h + *
+ portBASE_TYPE xQueueReceive(
+                                 xQueueHandle xQueue,
+                                 void *pvBuffer,
+                                 portTickType xTicksToWait
+                            );
+ * + * This is a macro that calls the xQueueGenericReceive() function. + * + * Receive an item from a queue. The item is received by copy so a buffer of + * adequate size must be provided. The number of bytes copied into the buffer + * was defined when the queue was created. + * + * Successfully received items are removed from the queue. + * + * This function must not be used in an interrupt service routine. See + * xQueueReceiveFromISR for an alternative that can. + * + * @param pxQueue The handle to the queue from which the item is to be + * received. + * + * @param pvBuffer Pointer to the buffer into which the received item will + * be copied. + * + * @param xTicksToWait The maximum amount of time the task should block + * waiting for an item to receive should the queue be empty at the time + * of the call. The time is defined in tick periods so the constant + * portTICK_RATE_MS should be used to convert to real time if this is required. + * + * @return pdTRUE if an item was successfully received from the queue, + * otherwise pdFALSE. + * + * Example usage: +
+ struct AMessage
+ {
+    portCHAR ucMessageID;
+    portCHAR ucData[ 20 ];
+ } xMessage;
+
+ xQueueHandle xQueue;
+
+ // Task to create a queue and post a value.
+ void vATask( void *pvParameters )
+ {
+ struct AMessage *pxMessage;
+
+    // Create a queue capable of containing 10 pointers to AMessage structures.
+    // These should be passed by pointer as they contain a lot of data.
+    xQueue = xQueueCreate( 10, sizeof( struct AMessage * ) );
+    if( xQueue == 0 )
+    {
+        // Failed to create the queue.
+    }
+
+    // ...
+
+    // Send a pointer to a struct AMessage object.  Don't block if the
+    // queue is already full.
+    pxMessage = & xMessage;
+    xQueueSend( xQueue, ( void * ) &pxMessage, ( portTickType ) 0 );
+
+	// ... Rest of task code.
+ }
+
+ // Task to receive from the queue.
+ void vADifferentTask( void *pvParameters )
+ {
+ struct AMessage *pxRxedMessage;
+
+    if( xQueue != 0 )
+    {
+        // Receive a message on the created queue.  Block for 10 ticks if a
+        // message is not immediately available.
+        if( xQueueReceive( xQueue, &( pxRxedMessage ), ( portTickType ) 10 ) )
+        {
+            // pcRxedMessage now points to the struct AMessage variable posted
+            // by vATask.
+        }
+    }
+
+	// ... Rest of task code.
+ }
+ 
+ * \defgroup xQueueReceive xQueueReceive + * \ingroup QueueManagement + */ +#define xQueueReceive( xQueue, pvBuffer, xTicksToWait ) xQueueGenericReceive( xQueue, pvBuffer, xTicksToWait, pdFALSE ) + + +/** + * queue. h + *
+ portBASE_TYPE xQueueGenericReceive(
+                                       xQueueHandle xQueue,
+                                       void *pvBuffer,
+                                       portTickType xTicksToWait
+                                       portBASE_TYPE xJustPeek
+                                    );
+ * + * It is preferred that the macro xQueueReceive() be used rather than calling + * this function directly. + * + * Receive an item from a queue. The item is received by copy so a buffer of + * adequate size must be provided. The number of bytes copied into the buffer + * was defined when the queue was created. + * + * This function must not be used in an interrupt service routine. See + * xQueueReceiveFromISR for an alternative that can. + * + * @param pxQueue The handle to the queue from which the item is to be + * received. + * + * @param pvBuffer Pointer to the buffer into which the received item will + * be copied. + * + * @param xTicksToWait The maximum amount of time the task should block + * waiting for an item to receive should the queue be empty at the time + * of the call. The time is defined in tick periods so the constant + * portTICK_RATE_MS should be used to convert to real time if this is required. + * + * @param xJustPeek When set to true, the item received from the queue is not + * actually removed from the queue - meaning a subsequent call to + * xQueueReceive() will return the same item. When set to false, the item + * being received from the queue is also removed from the queue. + * + * @return pdTRUE if an item was successfully received from the queue, + * otherwise pdFALSE. + * + * Example usage: +
+ struct AMessage
+ {
+    portCHAR ucMessageID;
+    portCHAR ucData[ 20 ];
+ } xMessage;
+
+ xQueueHandle xQueue;
+
+ // Task to create a queue and post a value.
+ void vATask( void *pvParameters )
+ {
+ struct AMessage *pxMessage;
+
+    // Create a queue capable of containing 10 pointers to AMessage structures.
+    // These should be passed by pointer as they contain a lot of data.
+    xQueue = xQueueCreate( 10, sizeof( struct AMessage * ) );
+    if( xQueue == 0 )
+    {
+        // Failed to create the queue.
+    }
+
+    // ...
+
+    // Send a pointer to a struct AMessage object.  Don't block if the
+    // queue is already full.
+    pxMessage = & xMessage;
+    xQueueSend( xQueue, ( void * ) &pxMessage, ( portTickType ) 0 );
+
+	// ... Rest of task code.
+ }
+
+ // Task to receive from the queue.
+ void vADifferentTask( void *pvParameters )
+ {
+ struct AMessage *pxRxedMessage;
+
+    if( xQueue != 0 )
+    {
+        // Receive a message on the created queue.  Block for 10 ticks if a
+        // message is not immediately available.
+        if( xQueueGenericReceive( xQueue, &( pxRxedMessage ), ( portTickType ) 10 ) )
+        {
+            // pcRxedMessage now points to the struct AMessage variable posted
+            // by vATask.
+        }
+    }
+
+	// ... Rest of task code.
+ }
+ 
+ * \defgroup xQueueReceive xQueueReceive + * \ingroup QueueManagement + */ +signed portBASE_TYPE xQueueGenericReceive( xQueueHandle xQueue, const void * const pvBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeek ); + +/** + * queue. h + *
unsigned portBASE_TYPE uxQueueMessagesWaiting( const xQueueHandle xQueue );
+ * + * Return the number of messages stored in a queue. + * + * @param xQueue A handle to the queue being queried. + * + * @return The number of messages available in the queue. + * + * \page uxQueueMessagesWaiting uxQueueMessagesWaiting + * \ingroup QueueManagement + */ +unsigned portBASE_TYPE uxQueueMessagesWaiting( const xQueueHandle xQueue ); + +/** + * queue. h + *
void vQueueDelete( xQueueHandle xQueue );
+ * + * Delete a queue - freeing all the memory allocated for storing of items + * placed on the queue. + * + * @param xQueue A handle to the queue to be deleted. + * + * \page vQueueDelete vQueueDelete + * \ingroup QueueManagement + */ +void vQueueDelete( xQueueHandle xQueue ); + +/** + * queue. h + *
+ portBASE_TYPE xQueueSendToFrontFromISR(
+                                         xQueueHandle pxQueue,
+                                         const void *pvItemToQueue,
+                                         portBASE_TYPE xTaskPreviouslyWoken
+                                      );
+ 
+ * + * This is a macro that calls xQueueGenericSendFromISR(). + * + * Post an item to the front of a queue. It is safe to use this macro from + * within an interrupt service routine. + * + * Items are queued by copy not reference so it is preferable to only + * queue small items, especially when called from an ISR. In most cases + * it would be preferable to store a pointer to the item being queued. + * + * @param xQueue The handle to the queue on which the item is to be posted. + * + * @param pvItemToQueue A pointer to the item that is to be placed on the + * queue. The size of the items the queue will hold was defined when the + * queue was created, so this many bytes will be copied from pvItemToQueue + * into the queue storage area. + * + * @param cTaskPreviouslyWoken This is included so an ISR can post onto + * the same queue multiple times from a single interrupt. The first call + * should always pass in pdFALSE. Subsequent calls should pass in + * the value returned from the previous call. See the file serial .c in the + * PC port for a good example of this mechanism. + * + * @return pdTRUE if a task was woken by posting onto the queue. This is + * used by the ISR to determine if a context switch may be required following + * the ISR. + * + * Example usage for buffered IO (where the ISR can obtain more than one value + * per call): +
+ void vBufferISR( void )
+ {
+ portCHAR cIn;
+ portBASE_TYPE xTaskWokenByPost;
+
+    // We have not woken a task at the start of the ISR.
+    cTaskWokenByPost = pdFALSE;
+
+    // Loop until the buffer is empty.
+    do
+    {
+        // Obtain a byte from the buffer.
+        cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );						
+
+        // Post the byte.  The first time round the loop cTaskWokenByPost
+        // will be pdFALSE.  If the queue send causes a task to wake we do
+        // not want the task to run until we have finished the ISR, so
+        // xQueueSendFromISR does not cause a context switch.  Also we
+        // don't want subsequent posts to wake any other tasks, so we store
+        // the return value back into cTaskWokenByPost so xQueueSendFromISR
+        // knows not to wake any task the next iteration of the loop.
+        xTaskWokenByPost = xQueueSendToFrontFromISR( xRxQueue, &cIn, cTaskWokenByPost );
+
+    } while( portINPUT_BYTE( BUFFER_COUNT ) );
+
+    // Now the buffer is empty we can switch context if necessary.
+    if( cTaskWokenByPost )
+    {
+        taskYIELD ();
+    }
+ }
+ 
+ * + * \defgroup xQueueSendFromISR xQueueSendFromISR + * \ingroup QueueManagement + */ +#define xQueueSendToFrontFromISR( pxQueue, pvItemToQueue, xTaskPreviouslyWoken ) xQueueGenericSendFromISR( pxQueue, pvItemToQueue, xTaskPreviouslyWoken, queueSEND_TO_FRONT ) + + +/** + * queue. h + *
+ portBASE_TYPE xQueueSendToBackFromISR(
+                                         xQueueHandle pxQueue,
+                                         const void *pvItemToQueue,
+                                         portBASE_TYPE xTaskPreviouslyWoken
+                                      );
+ 
+ * + * This is a macro that calls xQueueGenericSendFromISR(). + * + * Post an item to the back of a queue. It is safe to use this macro from + * within an interrupt service routine. + * + * Items are queued by copy not reference so it is preferable to only + * queue small items, especially when called from an ISR. In most cases + * it would be preferable to store a pointer to the item being queued. + * + * @param xQueue The handle to the queue on which the item is to be posted. + * + * @param pvItemToQueue A pointer to the item that is to be placed on the + * queue. The size of the items the queue will hold was defined when the + * queue was created, so this many bytes will be copied from pvItemToQueue + * into the queue storage area. + * + * @param cTaskPreviouslyWoken This is included so an ISR can post onto + * the same queue multiple times from a single interrupt. The first call + * should always pass in pdFALSE. Subsequent calls should pass in + * the value returned from the previous call. See the file serial .c in the + * PC port for a good example of this mechanism. + * + * @return pdTRUE if a task was woken by posting onto the queue. This is + * used by the ISR to determine if a context switch may be required following + * the ISR. + * + * Example usage for buffered IO (where the ISR can obtain more than one value + * per call): +
+ void vBufferISR( void )
+ {
+ portCHAR cIn;
+ portBASE_TYPE xTaskWokenByPost;
+
+    // We have not woken a task at the start of the ISR.
+    cTaskWokenByPost = pdFALSE;
+
+    // Loop until the buffer is empty.
+    do
+    {
+        // Obtain a byte from the buffer.
+        cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );						
+
+        // Post the byte.  The first time round the loop cTaskWokenByPost
+        // will be pdFALSE.  If the queue send causes a task to wake we do
+        // not want the task to run until we have finished the ISR, so
+        // xQueueSendFromISR does not cause a context switch.  Also we
+        // don't want subsequent posts to wake any other tasks, so we store
+        // the return value back into cTaskWokenByPost so xQueueSendFromISR
+        // knows not to wake any task the next iteration of the loop.
+        xTaskWokenByPost = xQueueSendToBackFromISR( xRxQueue, &cIn, cTaskWokenByPost );
+
+    } while( portINPUT_BYTE( BUFFER_COUNT ) );
+
+    // Now the buffer is empty we can switch context if necessary.
+    if( cTaskWokenByPost )
+    {
+        taskYIELD ();
+    }
+ }
+ 
+ * + * \defgroup xQueueSendFromISR xQueueSendFromISR + * \ingroup QueueManagement + */ +#define xQueueSendToBackFromISR( pxQueue, pvItemToQueue, xTaskPreviouslyWoken ) xQueueGenericSendFromISR( pxQueue, pvItemToQueue, xTaskPreviouslyWoken, queueSEND_TO_BACK ) + + +/** + * queue. h + *
+ portBASE_TYPE xQueueSendFromISR(
+                                     xQueueHandle pxQueue,
+                                     const void *pvItemToQueue,
+                                     portBASE_TYPE xTaskPreviouslyWoken
+                                );
+ 
+ * + * This is a macro that calls xQueueGenericSendFromISR(). It is included + * for backward compatibility with versions of FreeRTOS.org that did not + * include the xQueueSendToBackFromISR() and xQueueSendToFrontFromISR() + * macros. + * + * Post an item to the back of a queue. It is safe to use this function from + * within an interrupt service routine. + * + * Items are queued by copy not reference so it is preferable to only + * queue small items, especially when called from an ISR. In most cases + * it would be preferable to store a pointer to the item being queued. + * + * @param xQueue The handle to the queue on which the item is to be posted. + * + * @param pvItemToQueue A pointer to the item that is to be placed on the + * queue. The size of the items the queue will hold was defined when the + * queue was created, so this many bytes will be copied from pvItemToQueue + * into the queue storage area. + * + * @param cTaskPreviouslyWoken This is included so an ISR can post onto + * the same queue multiple times from a single interrupt. The first call + * should always pass in pdFALSE. Subsequent calls should pass in + * the value returned from the previous call. See the file serial .c in the + * PC port for a good example of this mechanism. + * + * @return pdTRUE if a task was woken by posting onto the queue. This is + * used by the ISR to determine if a context switch may be required following + * the ISR. + * + * Example usage for buffered IO (where the ISR can obtain more than one value + * per call): +
+ void vBufferISR( void )
+ {
+ portCHAR cIn;
+ portBASE_TYPE xTaskWokenByPost;
+
+    // We have not woken a task at the start of the ISR.
+    cTaskWokenByPost = pdFALSE;
+
+    // Loop until the buffer is empty.
+    do
+    {
+        // Obtain a byte from the buffer.
+        cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );						
+
+        // Post the byte.  The first time round the loop cTaskWokenByPost
+        // will be pdFALSE.  If the queue send causes a task to wake we do
+        // not want the task to run until we have finished the ISR, so
+        // xQueueSendFromISR does not cause a context switch.  Also we
+        // don't want subsequent posts to wake any other tasks, so we store
+        // the return value back into cTaskWokenByPost so xQueueSendFromISR
+        // knows not to wake any task the next iteration of the loop.
+        xTaskWokenByPost = xQueueSendFromISR( xRxQueue, &cIn, cTaskWokenByPost );
+
+    } while( portINPUT_BYTE( BUFFER_COUNT ) );
+
+    // Now the buffer is empty we can switch context if necessary.
+    if( cTaskWokenByPost )
+    {
+        taskYIELD ();
+    }
+ }
+ 
+ * + * \defgroup xQueueSendFromISR xQueueSendFromISR + * \ingroup QueueManagement + */ +#define xQueueSendFromISR( pxQueue, pvItemToQueue, xTaskPreviouslyWoken ) xQueueGenericSendFromISR( pxQueue, pvItemToQueue, xTaskPreviouslyWoken, queueSEND_TO_BACK ) + +/** + * queue. h + *
+ portBASE_TYPE xQueueGenericSendFromISR(
+                                           xQueueHandle pxQueue,
+                                           const void *pvItemToQueue,
+                                           portBASE_TYPE xTaskPreviouslyWoken
+										   portBASE_TYPE xCopyPosition
+                                       );
+ 
+ * + * It is preferred that the macros xQueueSendFromISR(), + * xQueueSendToFrontFromISR() and xQueueSendToBackFromISR() be used in place + * of calling this function directly. + * + * Post an item on a queue. It is safe to use this function from within an + * interrupt service routine. + * + * Items are queued by copy not reference so it is preferable to only + * queue small items, especially when called from an ISR. In most cases + * it would be preferable to store a pointer to the item being queued. + * + * @param xQueue The handle to the queue on which the item is to be posted. + * + * @param pvItemToQueue A pointer to the item that is to be placed on the + * queue. The size of the items the queue will hold was defined when the + * queue was created, so this many bytes will be copied from pvItemToQueue + * into the queue storage area. + * + * @param cTaskPreviouslyWoken This is included so an ISR can post onto + * the same queue multiple times from a single interrupt. The first call + * should always pass in pdFALSE. Subsequent calls should pass in + * the value returned from the previous call. See the file serial .c in the + * PC port for a good example of this mechanism. + * + * @param xCopyPosition Can take the value queueSEND_TO_BACK to place the + * item at the back of the queue, or queueSEND_TO_FRONT to place the item + * at the front of the queue (for high priority messages). + * + * @return pdTRUE if a task was woken by posting onto the queue. This is + * used by the ISR to determine if a context switch may be required following + * the ISR. + * + * Example usage for buffered IO (where the ISR can obtain more than one value + * per call): +
+ void vBufferISR( void )
+ {
+ portCHAR cIn;
+ portBASE_TYPE xTaskWokenByPost;
+
+    // We have not woken a task at the start of the ISR.
+    cTaskWokenByPost = pdFALSE;
+
+    // Loop until the buffer is empty.
+    do
+    {
+        // Obtain a byte from the buffer.
+        cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );						
+
+        // Post the byte.  The first time round the loop cTaskWokenByPost
+        // will be pdFALSE.  If the queue send causes a task to wake we do
+        // not want the task to run until we have finished the ISR, so
+        // xQueueSendFromISR does not cause a context switch.  Also we
+        // don't want subsequent posts to wake any other tasks, so we store
+        // the return value back into cTaskWokenByPost so xQueueSendFromISR
+        // knows not to wake any task the next iteration of the loop.
+        xTaskWokenByPost = xQueueGenericSendFromISR( xRxQueue, &cIn, cTaskWokenByPost, queueSEND_TO_BACK );
+
+    } while( portINPUT_BYTE( BUFFER_COUNT ) );
+
+    // Now the buffer is empty we can switch context if necessary.
+    if( cTaskWokenByPost )
+    {
+        taskYIELD ();
+    }
+ }
+ 
+ * + * \defgroup xQueueSendFromISR xQueueSendFromISR + * \ingroup QueueManagement + */ +signed portBASE_TYPE xQueueGenericSendFromISR( xQueueHandle pxQueue, const void * const pvItemToQueue, signed portBASE_TYPE xTaskPreviouslyWoken, portBASE_TYPE xCopyPosition ); + +/** + * queue. h + *
+ portBASE_TYPE xQueueReceiveFromISR(
+                                       xQueueHandle pxQueue,
+                                       void *pvBuffer,
+                                       portBASE_TYPE *pxTaskWoken
+                                   );
+ * 
+ * + * Receive an item from a queue. It is safe to use this function from within an + * interrupt service routine. + * + * @param pxQueue The handle to the queue from which the item is to be + * received. + * + * @param pvBuffer Pointer to the buffer into which the received item will + * be copied. + * + * @param pxTaskWoken A task may be blocked waiting for space to become + * available on the queue. If xQueueReceiveFromISR causes such a task to + * unblock *pxTaskWoken will get set to pdTRUE, otherwise *pxTaskWoken will + * remain unchanged. + * + * @return pdTRUE if an item was successfully received from the queue, + * otherwise pdFALSE. + * + * Example usage: +
+
+ xQueueHandle xQueue;
+
+ // Function to create a queue and post some values.
+ void vAFunction( void *pvParameters )
+ {
+ portCHAR cValueToPost;
+ const portTickType xBlockTime = ( portTickType )0xff;
+
+    // Create a queue capable of containing 10 characters.
+    xQueue = xQueueCreate( 10, sizeof( portCHAR ) );
+    if( xQueue == 0 )
+    {
+        // Failed to create the queue.
+    }
+
+    // ...
+
+    // Post some characters that will be used within an ISR.  If the queue
+    // is full then this task will block for xBlockTime ticks.
+    cValueToPost = 'a';
+    xQueueSend( xQueue, ( void * ) &cValueToPost, xBlockTime );
+    cValueToPost = 'b';
+    xQueueSend( xQueue, ( void * ) &cValueToPost, xBlockTime );
+
+    // ... keep posting characters ... this task may block when the queue
+    // becomes full.
+
+    cValueToPost = 'c';
+    xQueueSend( xQueue, ( void * ) &cValueToPost, xBlockTime );
+ }
+
+ // ISR that outputs all the characters received on the queue.
+ void vISR_Routine( void )
+ {
+ portBASE_TYPE xTaskWokenByReceive = pdFALSE;
+ portCHAR cRxedChar;
+
+    while( xQueueReceiveFromISR( xQueue, ( void * ) &cRxedChar, &xTaskWokenByReceive) )
+    {
+        // A character was received.  Output the character now.
+        vOutputCharacter( cRxedChar );
+
+        // If removing the character from the queue woke the task that was
+        // posting onto the queue cTaskWokenByReceive will have been set to
+        // pdTRUE.  No matter how many times this loop iterates only one
+        // task will be woken.
+    }
+
+    if( cTaskWokenByPost != ( portCHAR ) pdFALSE;
+    {
+        taskYIELD ();
+    }
+ }
+ 
+ * \defgroup xQueueReceiveFromISR xQueueReceiveFromISR + * \ingroup QueueManagement + */ +signed portBASE_TYPE xQueueReceiveFromISR( xQueueHandle pxQueue, const void * const pvBuffer, signed portBASE_TYPE *pxTaskWoken ); + + +/* + * The functions defined above are for passing data to and from tasks. The + * functions below are the equivalents for passing data to and from + * co-routines. + * + * These functions are called from the co-routine macro implementation and + * should not be called directly from application code. Instead use the macro + * wrappers defined within croutine.h. + */ +signed portBASE_TYPE xQueueCRSendFromISR( xQueueHandle pxQueue, const void *pvItemToQueue, signed portBASE_TYPE xCoRoutinePreviouslyWoken ); +signed portBASE_TYPE xQueueCRReceiveFromISR( xQueueHandle pxQueue, void *pvBuffer, signed portBASE_TYPE *pxTaskWoken ); +signed portBASE_TYPE xQueueCRSend( xQueueHandle pxQueue, const void *pvItemToQueue, portTickType xTicksToWait ); +signed portBASE_TYPE xQueueCRReceive( xQueueHandle pxQueue, void *pvBuffer, portTickType xTicksToWait ); + +/* + * For internal use only. Use xSemaphoreCreateMutex() instead of calling + * this function directly. + */ +xQueueHandle xQueueCreateMutex( void ); + +#ifdef __cplusplus +} +#endif + +#endif /* QUEUE_H */ + diff --git a/Tester/SW/lib/FreeRTOS/Source/include/semphr.h b/Tester/SW/lib/FreeRTOS/Source/include/semphr.h new file mode 100644 index 0000000..9855ed7 --- /dev/null +++ b/Tester/SW/lib/FreeRTOS/Source/include/semphr.h @@ -0,0 +1,347 @@ +/* + FreeRTOS.org V4.6.1 - Copyright (C) 2003-2007 Richard Barry. + + This file is part of the FreeRTOS.org distribution. + + FreeRTOS.org is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + FreeRTOS.org is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with FreeRTOS.org; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + A special exception to the GPL can be applied should you wish to distribute + a combined work that includes FreeRTOS.org, without being obliged to provide + the source code for any proprietary components. See the licensing section + of http://www.FreeRTOS.org for full details of how and when the exception + can be applied. + + *************************************************************************** + See http://www.FreeRTOS.org for documentation, latest information, license + and contact details. Please ensure to read the configuration and relevant + port sections of the online documentation. + + Also see http://www.SafeRTOS.com a version that has been certified for use + in safety critical systems, plus commercial licensing, development and + support options. + *************************************************************************** +*/ + +#include "queue.h" + +#ifndef SEMAPHORE_H +#define SEMAPHORE_H + +typedef xQueueHandle xSemaphoreHandle; + +#define semBINARY_SEMAPHORE_QUEUE_LENGTH ( ( unsigned portCHAR ) 1 ) +#define semSEMAPHORE_QUEUE_ITEM_LENGTH ( ( unsigned portCHAR ) 0 ) +#define semGIVE_BLOCK_TIME ( ( portTickType ) 0 ) + + +/** + * semphr. h + *
vSemaphoreCreateBinary( xSemaphoreHandle xSemaphore )
+ * + * Macro that implements a semaphore by using the existing queue mechanism. + * The queue length is 1 as this is a binary semaphore. The data size is 0 + * as we don't want to actually store any data - we just want to know if the + * queue is empty or full. + * + * This type of semaphore can be used for pure synchronisation between tasks or + * between an interrupt and a task. The semaphore need not be given back once + * obtained, so one task/interrupt can continuously 'give' the semaphore while + * another continuously 'takes' the semaphore. For this reason this type of + * semaphore does not use a priority inheritance mechanism. For an alternative + * that does use priority inheritance see xSemaphoreCreateMutex(). + * + * @param xSemaphore Handle to the created semaphore. Should be of type xSemaphoreHandle. + * + * Example usage: +
+ xSemaphoreHandle xSemaphore;
+
+ void vATask( void * pvParameters )
+ {
+    // Semaphore cannot be used before a call to vSemaphoreCreateBinary ().
+    // This is a macro so pass the variable in directly.
+    vSemaphoreCreateBinary( xSemaphore );
+
+    if( xSemaphore != NULL )
+    {
+        // The semaphore was created successfully.
+        // The semaphore can now be used.  
+    }
+ }
+ 
+ * \defgroup vSemaphoreCreateBinary vSemaphoreCreateBinary + * \ingroup Semaphores + */ +#define vSemaphoreCreateBinary( xSemaphore ) { \ + xSemaphore = xQueueCreate( ( unsigned portCHAR ) 1, semSEMAPHORE_QUEUE_ITEM_LENGTH ); \ + if( xSemaphore != NULL ) \ + { \ + xSemaphoreGive( xSemaphore ); \ + } \ + } + +/** + * semphr. h + * xSemaphoreTake( + * xSemaphoreHandle xSemaphore, + * portTickType xBlockTime + * ) + * + * Macro to obtain a semaphore. The semaphore must of been created using + * vSemaphoreCreateBinary (). + * + * @param xSemaphore A handle to the semaphore being obtained. This is the + * handle returned by vSemaphoreCreateBinary (); + * + * @param xBlockTime The time in ticks to wait for the semaphore to become + * available. The macro portTICK_RATE_MS can be used to convert this to a + * real time. A block time of zero can be used to poll the semaphore. + * + * @return pdTRUE if the semaphore was obtained. pdFALSE if xBlockTime + * expired without the semaphore becoming available. + * + * Example usage: +
+ xSemaphoreHandle xSemaphore = NULL;
+
+ // A task that creates a semaphore.
+ void vATask( void * pvParameters )
+ {
+    // Create the semaphore to guard a shared resource.
+    vSemaphoreCreateBinary( xSemaphore );
+ }
+
+ // A task that uses the semaphore.
+ void vAnotherTask( void * pvParameters )
+ {
+    // ... Do other things.
+
+    if( xSemaphore != NULL )
+    {
+        // See if we can obtain the semaphore.  If the semaphore is not available
+        // wait 10 ticks to see if it becomes free.	
+        if( xSemaphoreTake( xSemaphore, ( portTickType ) 10 ) == pdTRUE )
+        {
+            // We were able to obtain the semaphore and can now access the
+            // shared resource.
+
+            // ...
+
+            // We have finished accessing the shared resource.  Release the 
+            // semaphore.
+            xSemaphoreGive( xSemaphore );
+        }
+        else
+        {
+            // We could not obtain the semaphore and can therefore not access
+            // the shared resource safely.
+        }
+    }
+ }
+ 
+ * \defgroup xSemaphoreTake xSemaphoreTake + * \ingroup Semaphores + */ +#define xSemaphoreTake( xSemaphore, xBlockTime ) xQueueReceive( ( xQueueHandle ) xSemaphore, NULL, xBlockTime ) + +/** + * semphr. h + *
xSemaphoreGive( xSemaphoreHandle xSemaphore )
+ * + * Macro to release a semaphore. The semaphore must of been created using + * vSemaphoreCreateBinary (), and obtained using sSemaphoreTake (). + * + * This must not be used from an ISR. See xSemaphoreGiveFromISR () for + * an alternative which can be used from an ISR. + * + * @param xSemaphore A handle to the semaphore being released. This is the + * handle returned by vSemaphoreCreateBinary (); + * + * @return pdTRUE if the semaphore was released. pdFALSE if an error occurred. + * Semaphores are implemented using queues. An error can occur if there is + * no space on the queue to post a message - indicating that the + * semaphore was not first obtained correctly. + * + * Example usage: +
+ xSemaphoreHandle xSemaphore = NULL;
+
+ void vATask( void * pvParameters )
+ {
+    // Create the semaphore to guard a shared resource.
+    vSemaphoreCreateBinary( xSemaphore );
+
+    if( xSemaphore != NULL )
+    {
+        if( xSemaphoreGive( xSemaphore ) != pdTRUE )
+        {
+            // We would expect this call to fail because we cannot give
+            // a semaphore without first "taking" it!
+        }
+
+        // Obtain the semaphore - don't block if the semaphore is not
+        // immediately available.
+        if( xSemaphoreTake( xSemaphore, ( portTickType ) 0 ) )
+        {
+            // We now have the semaphore and can access the shared resource.
+
+            // ...
+
+            // We have finished accessing the shared resource so can free the
+            // semaphore.
+            if( xSemaphoreGive( xSemaphore ) != pdTRUE )
+            {
+                // We would not expect this call to fail because we must have
+                // obtained the semaphore to get here.
+            }
+        }
+    }
+ }
+ 
+ * \defgroup xSemaphoreGive xSemaphoreGive + * \ingroup Semaphores + */ +#define xSemaphoreGive( xSemaphore ) xQueueGenericSend( ( xQueueHandle ) xSemaphore, NULL, semGIVE_BLOCK_TIME, queueSEND_TO_BACK ) + +/** + * semphr. h + *
+ xSemaphoreGiveFromISR( 
+                          xSemaphoreHandle xSemaphore, 
+                          portSHORT sTaskPreviouslyWoken 
+                      )
+ * + * Macro to release a semaphore. The semaphore must of been created using + * vSemaphoreCreateBinary (), and obtained using xSemaphoreTake (). + * + * Mutex type semaphores (those created using a call to xSemaphoreCreateMutex()) + * must not be used with this macro. + * + * This macro can be used from an ISR. + * + * @param xSemaphore A handle to the semaphore being released. This is the + * handle returned by vSemaphoreCreateBinary (); + * + * @param sTaskPreviouslyWoken This is included so an ISR can make multiple calls + * to xSemaphoreGiveFromISR () from a single interrupt. The first call + * should always pass in pdFALSE. Subsequent calls should pass in + * the value returned from the previous call. See the file serial .c in the + * PC port for a good example of using xSemaphoreGiveFromISR (). + * + * @return pdTRUE if a task was woken by releasing the semaphore. This is + * used by the ISR to determine if a context switch may be required following + * the ISR. + * + * Example usage: +
+ #define LONG_TIME 0xffff
+ #define TICKS_TO_WAIT	10
+ xSemaphoreHandle xSemaphore = NULL;
+
+ // Repetitive task.
+ void vATask( void * pvParameters )
+ {
+    for( ;; )
+    {
+        // We want this task to run every 10 ticks or a timer.  The semaphore 
+        // was created before this task was started
+
+        // Block waiting for the semaphore to become available.
+        if( xSemaphoreTake( xSemaphore, LONG_TIME ) == pdTRUE )
+        {
+            // It is time to execute.
+
+            // ...
+
+            // We have finished our task.  Return to the top of the loop where
+            // we will block on the semaphore until it is time to execute 
+            // again.
+        }
+    }
+ }
+
+ // Timer ISR
+ void vTimerISR( void * pvParameters )
+ {
+ static unsigned portCHAR ucLocalTickCount = 0;
+
+    // A timer tick has occurred.
+
+    // ... Do other time functions.
+
+    // Is it time for vATask () to run?
+    ucLocalTickCount++;
+    if( ucLocalTickCount >= TICKS_TO_WAIT )
+    {
+        // Unblock the task by releasing the semaphore.
+        xSemaphoreGive( xSemaphore );
+
+        // Reset the count so we release the semaphore again in 10 ticks time.
+        ucLocalTickCount = 0;
+    }
+ }
+ 
+ * \defgroup xSemaphoreGiveFromISR xSemaphoreGiveFromISR + * \ingroup Semaphores + */ +#define xSemaphoreGiveFromISR( xSemaphore, xTaskPreviouslyWoken ) xQueueGenericSendFromISR( ( xQueueHandle ) xSemaphore, NULL, xTaskPreviouslyWoken, queueSEND_TO_BACK ) + +/** + * semphr. h + *
xSemaphoreCreateMutex( xSemaphoreHandle xSemaphore )
+ * + * Macro that implements a mutex semaphore by using the existing queue + * mechanism. + * + * This type of semaphore uses a priority inheritance mechanism so a task + * 'taking' a semaphore MUST ALWAYS 'give' the semaphore back once the + * semaphore it is no longer required. + * + * Mutex type semaphores cannot be used from within interrupt service routines. + * + * See xSemaphoreCreateBinary() for an alternative implemnetation that can be + * used for pure synchronisation (where one task or interrupt always 'gives' the + * semaphore and another always 'takes' the semaphore) and from within interrupt + * service routines. + * + * @param xSemaphore Handle to the created mutex semaphore. Should be of type + * xSemaphoreHandle. + * + * Example usage: +
+ xSemaphoreHandle xSemaphore;
+
+ void vATask( void * pvParameters )
+ {
+    // Semaphore cannot be used before a call to vSemaphoreCreateBinary ().
+    // This is a macro so pass the variable in directly.
+    vSemaphoreCreateMutex( xSemaphore );
+
+    if( xSemaphore != NULL )
+    {
+        // The semaphore was created successfully.
+        // The semaphore can now be used.  
+    }
+ }
+ 
+ * \defgroup vSemaphoreCreateMutex vSemaphoreCreateMutex + * \ingroup Semaphores + */ +#define xSemaphoreCreateMutex() xQueueCreateMutex() + + +#endif /* SEMAPHORE_H */ + + diff --git a/Tester/SW/lib/FreeRTOS/Source/include/task.h b/Tester/SW/lib/FreeRTOS/Source/include/task.h new file mode 100644 index 0000000..31784b9 --- /dev/null +++ b/Tester/SW/lib/FreeRTOS/Source/include/task.h @@ -0,0 +1,989 @@ +/* + FreeRTOS.org V4.6.1 - Copyright (C) 2003-2007 Richard Barry. + + This file is part of the FreeRTOS.org distribution. + + FreeRTOS.org is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + FreeRTOS.org is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with FreeRTOS.org; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + A special exception to the GPL can be applied should you wish to distribute + a combined work that includes FreeRTOS.org, without being obliged to provide + the source code for any proprietary components. See the licensing section + of http://www.FreeRTOS.org for full details of how and when the exception + can be applied. + + *************************************************************************** + See http://www.FreeRTOS.org for documentation, latest information, license + and contact details. Please ensure to read the configuration and relevant + port sections of the online documentation. + + Also see http://www.SafeRTOS.com a version that has been certified for use + in safety critical systems, plus commercial licensing, development and + support options. + *************************************************************************** +*/ + +/* +Changes since V4.3.1: + + + Added xTaskGetSchedulerState() function. +*/ + +#ifndef TASK_H +#define TASK_H + +#include "portable.h" +#include "list.h" + +#ifdef __cplusplus +extern "C" { +#endif +/*----------------------------------------------------------- + * MACROS AND DEFINITIONS + *----------------------------------------------------------*/ + +#define tskKERNEL_VERSION_NUMBER "V4.6.1" + +/** + * task. h + * + * Type by which tasks are referenced. For example, a call to xTaskCreate + * returns (via a pointer parameter) an xTaskHandle variable that can then + * be used as a parameter to vTaskDelete to delete the task. + * + * \page xTaskHandle xTaskHandle + * \ingroup Tasks + */ +typedef void * xTaskHandle; + +/* + * Used internally only. + */ +typedef struct xTIME_OUT +{ + portBASE_TYPE xOverflowCount; + portTickType xTimeOnEntering; +} xTimeOutType; + +/* + * Defines the priority used by the idle task. This must not be modified. + * + * \ingroup TaskUtils + */ +#define tskIDLE_PRIORITY ( ( unsigned portBASE_TYPE ) 0 ) + +/** + * task. h + * + * Macro for forcing a context switch. + * + * \page taskYIELD taskYIELD + * \ingroup SchedulerControl + */ +#define taskYIELD() portYIELD() + +/** + * task. h + * + * Macro to mark the start of a critical code region. Preemptive context + * switches cannot occur when in a critical region. + * + * NOTE: This may alter the stack (depending on the portable implementation) + * so must be used with care! + * + * \page taskENTER_CRITICAL taskENTER_CRITICAL + * \ingroup SchedulerControl + */ +#define taskENTER_CRITICAL() portENTER_CRITICAL() + +/** + * task. h + * + * Macro to mark the end of a critical code region. Preemptive context + * switches cannot occur when in a critical region. + * + * NOTE: This may alter the stack (depending on the portable implementation) + * so must be used with care! + * + * \page taskEXIT_CRITICAL taskEXIT_CRITICAL + * \ingroup SchedulerControl + */ +#define taskEXIT_CRITICAL() portEXIT_CRITICAL() + +/** + * task. h + * + * Macro to disable all maskable interrupts. + * + * \page taskDISABLE_INTERRUPTS taskDISABLE_INTERRUPTS + * \ingroup SchedulerControl + */ +#define taskDISABLE_INTERRUPTS() portDISABLE_INTERRUPTS() + +/** + * task. h + * + * Macro to enable microcontroller interrupts. + * + * \page taskENABLE_INTERRUPTS taskENABLE_INTERRUPTS + * \ingroup SchedulerControl + */ +#define taskENABLE_INTERRUPTS() portENABLE_INTERRUPTS() + +/* Definitions returned by xTaskGetSchedulerState(). */ +#define taskSCHEDULER_NOT_STARTED 0 +#define taskSCHEDULER_RUNNING 1 +#define taskSCHEDULER_SUSPENDED 2 + +/*----------------------------------------------------------- + * TASK CREATION API + *----------------------------------------------------------*/ + +/** + * task. h + *
+ portBASE_TYPE xTaskCreate(
+                              pdTASK_CODE pvTaskCode,
+                              const portCHAR * const pcName,
+                              unsigned portSHORT usStackDepth,
+                              void *pvParameters,
+                              unsigned portBASE_TYPE uxPriority,
+                              xTaskHandle *pvCreatedTask
+                          );
+ * + * Create a new task and add it to the list of tasks that are ready to run. + * + * @param pvTaskCode Pointer to the task entry function. Tasks + * must be implemented to never return (i.e. continuous loop). + * + * @param pcName A descriptive name for the task. This is mainly used to + * facilitate debugging. Max length defined by tskMAX_TASK_NAME_LEN - default + * is 16. + * + * @param usStackDepth The size of the task stack specified as the number of + * variables the stack can hold - not the number of bytes. For example, if + * the stack is 16 bits wide and usStackDepth is defined as 100, 200 bytes + * will be allocated for stack storage. + * + * @param pvParameters Pointer that will be used as the parameter for the task + * being created. + * + * @param uxPriority The priority at which the task should run. + * + * @param pvCreatedTask Used to pass back a handle by which the created task + * can be referenced. + * + * @return pdPASS if the task was successfully created and added to a ready + * list, otherwise an error code defined in the file errors. h + * + * Example usage: +
+ // Task to be created.
+ void vTaskCode( void * pvParameters )
+ {
+     for( ;; )
+     {
+         // Task code goes here.
+     }
+ }
+
+ // Function that creates a task.
+ void vOtherFunction( void )
+ {
+ unsigned char ucParameterToPass;
+ xTaskHandle xHandle;
+		
+     // Create the task, storing the handle.
+     xTaskCreate( vTaskCode, "NAME", STACK_SIZE, &ucParameterToPass, tskIDLE_PRIORITY, &xHandle );
+		
+     // Use the handle to delete the task.
+     vTaskDelete( xHandle );
+ }
+   
+ * \defgroup xTaskCreate xTaskCreate + * \ingroup Tasks + */ +signed portBASE_TYPE xTaskCreate( pdTASK_CODE pvTaskCode, const signed portCHAR * const pcName, unsigned portSHORT usStackDepth, void *pvParameters, unsigned portBASE_TYPE uxPriority, xTaskHandle *pvCreatedTask ); + +/** + * task. h + *
void vTaskDelete( xTaskHandle pxTask );
+ * + * INCLUDE_vTaskDelete must be defined as 1 for this function to be available. + * See the configuration section for more information. + * + * Remove a task from the RTOS real time kernels management. The task being + * deleted will be removed from all ready, blocked, suspended and event lists. + * + * NOTE: The idle task is responsible for freeing the kernel allocated + * memory from tasks that have been deleted. It is therefore important that + * the idle task is not starved of microcontroller processing time if your + * application makes any calls to vTaskDelete (). Memory allocated by the + * task code is not automatically freed, and should be freed before the task + * is deleted. + * + * See the demo application file death.c for sample code that utilises + * vTaskDelete (). + * + * @param pxTask The handle of the task to be deleted. Passing NULL will + * cause the calling task to be deleted. + * + * Example usage: +
+ void vOtherFunction( void )
+ {
+ xTaskHandle xHandle;
+		
+     // Create the task, storing the handle.
+     xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
+		
+     // Use the handle to delete the task.
+     vTaskDelete( xHandle );
+ }
+   
+ * \defgroup vTaskDelete vTaskDelete + * \ingroup Tasks + */ +void vTaskDelete( xTaskHandle pxTask ); + + +/*----------------------------------------------------------- + * TASK CONTROL API + *----------------------------------------------------------*/ + +/** + * task. h + *
void vTaskDelay( portTickType xTicksToDelay );
+ * + * Delay a task for a given number of ticks. The actual time that the + * task remains blocked depends on the tick rate. The constant + * portTICK_RATE_MS can be used to calculate real time from the tick + * rate - with the resolution of one tick period. + * + * INCLUDE_vTaskDelay must be defined as 1 for this function to be available. + * See the configuration section for more information. + * + * @param xTicksToDelay The amount of time, in tick periods, that + * the calling task should block. + * + * Example usage: +
+ // Wait 10 ticks before performing an action.
+ // NOTE:
+ // This is for demonstration only and would be better achieved
+ // using vTaskDelayUntil ().
+ void vTaskFunction( void * pvParameters )
+ {
+ portTickType xDelay, xNextTime;
+
+     // Calc the time at which we want to perform the action
+     // next.
+     xNextTime = xTaskGetTickCount () + ( portTickType ) 10;
+
+     for( ;; )
+     {
+         xDelay = xNextTime - xTaskGetTickCount ();
+         xNextTime += ( portTickType ) 10;
+
+         // Guard against overflow
+         if( xDelay <= ( portTickType ) 10 )
+         {
+             vTaskDelay( xDelay );
+         }
+
+         // Perform action here.
+     }
+ }
+   
+ * \defgroup vTaskDelay vTaskDelay + * \ingroup TaskCtrl + */ +void vTaskDelay( portTickType xTicksToDelay ); + +/** + * task. h + *
void vTaskDelayUntil( portTickType *pxPreviousWakeTime, portTickType xTimeIncrement );
+ * + * INCLUDE_vTaskDelayUntil must be defined as 1 for this function to be available. + * See the configuration section for more information. + * + * Delay a task until a specified time. This function can be used by cyclical + * tasks to ensure a constant execution frequency. + * + * This function differs from vTaskDelay () in one important aspect: vTaskDelay () will + * cause a task to block for the specified number of ticks from the time vTaskDelay () is + * called. It is therefore difficult to use vTaskDelay () by itself to generate a fixed + * execution frequency as the time between a task starting to execute and that task + * calling vTaskDelay () may not be fixed [the task may take a different path though the + * code between calls, or may get interrupted or preempted a different number of times + * each time it executes]. + * + * Whereas vTaskDelay () specifies a wake time relative to the time at which the function + * is called, vTaskDelayUntil () specifies the absolute (exact) time at which it wishes to + * unblock. + * + * The constant portTICK_RATE_MS can be used to calculate real time from the tick + * rate - with the resolution of one tick period. + * + * @param pxPreviousWakeTime Pointer to a variable that holds the time at which the + * task was last unblocked. The variable must be initialised with the current time + * prior to its first use (see the example below). Following this the variable is + * automatically updated within vTaskDelayUntil (). + * + * @param xTimeIncrement The cycle time period. The task will be unblocked at + * time *pxPreviousWakeTime + xTimeIncrement. Calling vTaskDelayUntil with the + * same xTimeIncrement parameter value will cause the task to execute with + * a fixed interface period. + * + * Example usage: +
+ // Perform an action every 10 ticks.
+ void vTaskFunction( void * pvParameters )
+ {
+ portTickType xLastWakeTime;
+ const portTickType xFrequency = 10;
+
+     // Initialise the xLastWakeTime variable with the current time.
+     xLastWakeTime = xTaskGetTickCount ();
+     for( ;; )
+     {
+         // Wait for the next cycle.
+         vTaskDelayUntil( &xLastWakeTime, xFrequency );
+
+         // Perform action here.
+     }
+ }
+   
+ * \defgroup vTaskDelayUntil vTaskDelayUntil + * \ingroup TaskCtrl + */ +void vTaskDelayUntil( portTickType * const pxPreviousWakeTime, portTickType xTimeIncrement ); + +/** + * task. h + *
unsigned portBASE_TYPE uxTaskPriorityGet( xTaskHandle pxTask );
+ * + * INCLUDE_xTaskPriorityGet must be defined as 1 for this function to be available. + * See the configuration section for more information. + * + * Obtain the priority of any task. + * + * @param pxTask Handle of the task to be queried. Passing a NULL + * handle results in the priority of the calling task being returned. + * + * @return The priority of pxTask. + * + * Example usage: +
+ void vAFunction( void )
+ {
+ xTaskHandle xHandle;
+		
+     // Create a task, storing the handle.
+     xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
+		
+     // ...
+
+     // Use the handle to obtain the priority of the created task.
+     // It was created with tskIDLE_PRIORITY, but may have changed
+     // it itself.
+     if( uxTaskPriorityGet( xHandle ) != tskIDLE_PRIORITY )
+     {
+         // The task has changed it's priority.
+     }
+
+     // ...
+
+     // Is our priority higher than the created task?
+     if( uxTaskPriorityGet( xHandle ) < uxTaskPriorityGet( NULL ) )
+     {
+         // Our priority (obtained using NULL handle) is higher.
+     }
+ }
+   
+ * \defgroup uxTaskPriorityGet uxTaskPriorityGet + * \ingroup TaskCtrl + */ +unsigned portBASE_TYPE uxTaskPriorityGet( xTaskHandle pxTask ); + +/** + * task. h + *
void vTaskPrioritySet( xTaskHandle pxTask, unsigned portBASE_TYPE uxNewPriority );
+ * + * INCLUDE_vTaskPrioritySet must be defined as 1 for this function to be available. + * See the configuration section for more information. + * + * Set the priority of any task. + * + * A context switch will occur before the function returns if the priority + * being set is higher than the currently executing task. + * + * @param pxTask Handle to the task for which the priority is being set. + * Passing a NULL handle results in the priority of the calling task being set. + * + * @param uxNewPriority The priority to which the task will be set. + * + * Example usage: +
+ void vAFunction( void )
+ {
+ xTaskHandle xHandle;
+		
+     // Create a task, storing the handle.
+     xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
+
+     // ...
+
+     // Use the handle to raise the priority of the created task.
+     vTaskPrioritySet( xHandle, tskIDLE_PRIORITY + 1 );
+
+     // ...
+
+     // Use a NULL handle to raise our priority to the same value.
+     vTaskPrioritySet( NULL, tskIDLE_PRIORITY + 1 );
+ }
+   
+ * \defgroup vTaskPrioritySet vTaskPrioritySet + * \ingroup TaskCtrl + */ +void vTaskPrioritySet( xTaskHandle pxTask, unsigned portBASE_TYPE uxNewPriority ); + +/** + * task. h + *
void vTaskSuspend( xTaskHandle pxTaskToSuspend );
+ * + * INCLUDE_vTaskSuspend must be defined as 1 for this function to be available. + * See the configuration section for more information. + * + * Suspend any task. When suspended a task will never get any microcontroller + * processing time, no matter what its priority. + * + * Calls to vTaskSuspend are not accumulative - + * i.e. calling vTaskSuspend () twice on the same task still only requires one + * call to vTaskResume () to ready the suspended task. + * + * @param pxTaskToSuspend Handle to the task being suspended. Passing a NULL + * handle will cause the calling task to be suspended. + * + * Example usage: +
+ void vAFunction( void )
+ {
+ xTaskHandle xHandle;
+		
+     // Create a task, storing the handle.
+     xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
+		
+     // ...
+
+     // Use the handle to suspend the created task.
+     vTaskSuspend( xHandle );
+
+     // ...
+		
+     // The created task will not run during this period, unless
+     // another task calls vTaskResume( xHandle ).
+		
+     //...
+		
+
+     // Suspend ourselves.
+     vTaskSuspend( NULL );
+
+     // We cannot get here unless another task calls vTaskResume
+     // with our handle as the parameter.
+ }
+   
+ * \defgroup vTaskSuspend vTaskSuspend + * \ingroup TaskCtrl + */ +void vTaskSuspend( xTaskHandle pxTaskToSuspend ); + +/** + * task. h + *
void vTaskResume( xTaskHandle pxTaskToResume );
+ * + * INCLUDE_vTaskSuspend must be defined as 1 for this function to be available. + * See the configuration section for more information. + * + * Resumes a suspended task. + * + * A task that has been suspended by one of more calls to vTaskSuspend () + * will be made available for running again by a single call to + * vTaskResume (). + * + * @param pxTaskToResume Handle to the task being readied. + * + * Example usage: +
+ void vAFunction( void )
+ {
+ xTaskHandle xHandle;
+		
+     // Create a task, storing the handle.
+     xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
+		
+     // ...
+
+     // Use the handle to suspend the created task.
+     vTaskSuspend( xHandle );
+
+     // ...
+	
+     // The created task will not run during this period, unless
+     // another task calls vTaskResume( xHandle ).
+		
+     //...
+		
+
+     // Resume the suspended task ourselves.
+     vTaskResume( xHandle );
+
+     // The created task will once again get microcontroller processing
+     // time in accordance with it priority within the system.
+ }
+   
+ * \defgroup vTaskResume vTaskResume + * \ingroup TaskCtrl + */ +void vTaskResume( xTaskHandle pxTaskToResume ); + +/** + * task. h + *
void xTaskResumeFromISR( xTaskHandle pxTaskToResume );
+ * + * INCLUDE_xTaskResumeFromISR must be defined as 1 for this function to be + * available. See the configuration section for more information. + * + * An implementation of vTaskResume() that can be called from within an ISR. + * + * A task that has been suspended by one of more calls to vTaskSuspend () + * will be made available for running again by a single call to + * xTaskResumeFromISR (). + * + * @param pxTaskToResume Handle to the task being readied. + * + * \defgroup vTaskResumeFromISR vTaskResumeFromISR + * \ingroup TaskCtrl + */ +portBASE_TYPE xTaskResumeFromISR( xTaskHandle pxTaskToResume ); + +/*----------------------------------------------------------- + * SCHEDULER CONTROL + *----------------------------------------------------------*/ + +/** + * task. h + *
void vTaskStartScheduler( void );
+ * + * Starts the real time kernel tick processing. After calling the kernel + * has control over which tasks are executed and when. This function + * does not return until an executing task calls vTaskEndScheduler (). + * + * At least one task should be created via a call to xTaskCreate () + * before calling vTaskStartScheduler (). The idle task is created + * automatically when the first application task is created. + * + * See the demo application file main.c for an example of creating + * tasks and starting the kernel. + * + * Example usage: +
+ void vAFunction( void )
+ {
+     // Create at least one task before starting the kernel.
+     xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
+
+     // Start the real time kernel with preemption.
+     vTaskStartScheduler ();
+
+     // Will not get here unless a task calls vTaskEndScheduler ()
+ }
+   
+ * + * \defgroup vTaskStartScheduler vTaskStartScheduler + * \ingroup SchedulerControl + */ +void vTaskStartScheduler( void ); + +/** + * task. h + *
void vTaskEndScheduler( void );
+ * + * Stops the real time kernel tick. All created tasks will be automatically + * deleted and multitasking (either preemptive or cooperative) will + * stop. Execution then resumes from the point where vTaskStartScheduler () + * was called, as if vTaskStartScheduler () had just returned. + * + * See the demo application file main. c in the demo/PC directory for an + * example that uses vTaskEndScheduler (). + * + * vTaskEndScheduler () requires an exit function to be defined within the + * portable layer (see vPortEndScheduler () in port. c for the PC port). This + * performs hardware specific operations such as stopping the kernel tick. + * + * vTaskEndScheduler () will cause all of the resources allocated by the + * kernel to be freed - but will not free resources allocated by application + * tasks. + * + * Example usage: +
+ void vTaskCode( void * pvParameters )
+ {
+     for( ;; )
+     {
+         // Task code goes here.
+
+         // At some point we want to end the real time kernel processing
+         // so call ...
+         vTaskEndScheduler ();
+     }
+ }
+
+ void vAFunction( void )
+ {
+     // Create at least one task before starting the kernel.
+     xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
+
+     // Start the real time kernel with preemption.
+     vTaskStartScheduler ();
+
+     // Will only get here when the vTaskCode () task has called
+     // vTaskEndScheduler ().  When we get here we are back to single task
+     // execution.
+ }
+   
+ * + * \defgroup vTaskEndScheduler vTaskEndScheduler + * \ingroup SchedulerControl + */ +void vTaskEndScheduler( void ); + +/** + * task. h + *
void vTaskSuspendAll( void );
+ * + * Suspends all real time kernel activity while keeping interrupts (including the + * kernel tick) enabled. + * + * After calling vTaskSuspendAll () the calling task will continue to execute + * without risk of being swapped out until a call to xTaskResumeAll () has been + * made. + * + * Example usage: +
+ void vTask1( void * pvParameters )
+ {
+     for( ;; )
+     {
+         // Task code goes here.
+
+         // ...
+
+         // At some point the task wants to perform a long operation during
+         // which it does not want to get swapped out.  It cannot use
+         // taskENTER_CRITICAL ()/taskEXIT_CRITICAL () as the length of the
+         // operation may cause interrupts to be missed - including the
+         // ticks.
+
+         // Prevent the real time kernel swapping out the task.
+         vTaskSuspendAll ();
+
+         // Perform the operation here.  There is no need to use critical
+         // sections as we have all the microcontroller processing time.
+         // During this time interrupts will still operate and the kernel
+         // tick count will be maintained.
+
+         // ...
+
+         // The operation is complete.  Restart the kernel.
+         xTaskResumeAll ();
+     }
+ }
+   
+ * \defgroup vTaskSuspendAll vTaskSuspendAll + * \ingroup SchedulerControl + */ +void vTaskSuspendAll( void ); + +/** + * task. h + *
portCHAR xTaskResumeAll( void );
+ * + * Resumes real time kernel activity following a call to vTaskSuspendAll (). + * After a call to vTaskSuspendAll () the kernel will take control of which + * task is executing at any time. + * + * @return If resuming the scheduler caused a context switch then pdTRUE is + * returned, otherwise pdFALSE is returned. + * + * Example usage: +
+ void vTask1( void * pvParameters )
+ {
+     for( ;; )
+     {
+         // Task code goes here.
+
+         // ...
+
+         // At some point the task wants to perform a long operation during
+         // which it does not want to get swapped out.  It cannot use
+         // taskENTER_CRITICAL ()/taskEXIT_CRITICAL () as the length of the
+         // operation may cause interrupts to be missed - including the
+         // ticks.
+
+         // Prevent the real time kernel swapping out the task.
+         vTaskSuspendAll ();
+
+         // Perform the operation here.  There is no need to use critical
+         // sections as we have all the microcontroller processing time.
+         // During this time interrupts will still operate and the real
+         // time kernel tick count will be maintained.
+
+         // ...
+
+         // The operation is complete.  Restart the kernel.  We want to force
+         // a context switch - but there is no point if resuming the scheduler
+         // caused a context switch already.
+         if( !xTaskResumeAll () )
+         {
+              taskYIELD ();
+         }
+     }
+ }
+   
+ * \defgroup xTaskResumeAll xTaskResumeAll + * \ingroup SchedulerControl + */ +signed portBASE_TYPE xTaskResumeAll( void ); + + +/*----------------------------------------------------------- + * TASK UTILITIES + *----------------------------------------------------------*/ + +/** + * task. h + *
volatile portTickType xTaskGetTickCount( void );
+ * + * @return The count of ticks since vTaskStartScheduler was called. + * + * \page xTaskGetTickCount xTaskGetTickCount + * \ingroup TaskUtils + */ +portTickType xTaskGetTickCount( void ); + +/** + * task. h + *
unsigned portSHORT uxTaskGetNumberOfTasks( void );
+ * + * @return The number of tasks that the real time kernel is currently managing. + * This includes all ready, blocked and suspended tasks. A task that + * has been deleted but not yet freed by the idle task will also be + * included in the count. + * + * \page uxTaskGetNumberOfTasks uxTaskGetNumberOfTasks + * \ingroup TaskUtils + */ +unsigned portBASE_TYPE uxTaskGetNumberOfTasks( void ); + +/** + * task. h + *
void vTaskList( portCHAR *pcWriteBuffer );
+ * + * configUSE_TRACE_FACILITY, INCLUDE_vTaskDelete and INCLUDE_vTaskSuspend + * must all be defined as 1 for this function to be available. + * See the configuration section for more information. + * + * NOTE: This function will disable interrupts for its duration. It is + * not intended for normal application runtime use but as a debug aid. + * + * Lists all the current tasks, along with their current state and stack + * usage high water mark. + * + * Tasks are reported as blocked ('B'), ready ('R'), deleted ('D') or + * suspended ('S'). + * + * @param pcWriteBuffer A buffer into which the above mentioned details + * will be written, in ascii form. This buffer is assumed to be large + * enough to contain the generated report. Approximately 40 bytes per + * task should be sufficient. + * + * \page vTaskList vTaskList + * \ingroup TaskUtils + */ +void vTaskList( signed portCHAR *pcWriteBuffer ); + +/** + * task. h + *
void vTaskStartTrace( portCHAR * pcBuffer, unsigned portBASE_TYPE uxBufferSize );
+ * + * Starts a real time kernel activity trace. The trace logs the identity of + * which task is running when. + * + * The trace file is stored in binary format. A separate DOS utility called + * convtrce.exe is used to convert this into a tab delimited text file which + * can be viewed and plotted in a spread sheet. + * + * @param pcBuffer The buffer into which the trace will be written. + * + * @param ulBufferSize The size of pcBuffer in bytes. The trace will continue + * until either the buffer in full, or ulTaskEndTrace () is called. + * + * \page vTaskStartTrace vTaskStartTrace + * \ingroup TaskUtils + */ +void vTaskStartTrace( signed portCHAR * pcBuffer, unsigned portLONG ulBufferSize ); + +/** + * task. h + *
unsigned portLONG ulTaskEndTrace( void );
+ * + * Stops a kernel activity trace. See vTaskStartTrace (). + * + * @return The number of bytes that have been written into the trace buffer. + * + * \page usTaskEndTrace usTaskEndTrace + * \ingroup TaskUtils + */ +unsigned portLONG ulTaskEndTrace( void ); + + +/*----------------------------------------------------------- + * SCHEDULER INTERNALS AVAILABLE FOR PORTING PURPOSES + *----------------------------------------------------------*/ + +/* + * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS ONLY + * INTENDED FOR USE WHEN IMPLEMENTING A PORT OF THE SCHEDULER AND IS + * AN INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER. + * + * Called from the real time kernel tick (either preemptive or cooperative), + * this increments the tick count and checks if any tasks that are blocked + * for a finite period required removing from a blocked list and placing on + * a ready list. + */ +inline void vTaskIncrementTick( void ); + +/* + * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS AN + * INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER. + * + * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED. + * + * Removes the calling task from the ready list and places it both + * on the list of tasks waiting for a particular event, and the + * list of delayed tasks. The task will be removed from both lists + * and replaced on the ready list should either the event occur (and + * there be no higher priority tasks waiting on the same event) or + * the delay period expires. + * + * @param pxEventList The list containing tasks that are blocked waiting + * for the event to occur. + * + * @param xTicksToWait The maximum amount of time that the task should wait + * for the event to occur. This is specified in kernel ticks,the constant + * portTICK_RATE_MS can be used to convert kernel ticks into a real time + * period. + */ +void vTaskPlaceOnEventList( const xList * const pxEventList, portTickType xTicksToWait ); + +/* + * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS AN + * INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER. + * + * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED. + * + * Removes a task from both the specified event list and the list of blocked + * tasks, and places it on a ready queue. + * + * xTaskRemoveFromEventList () will be called if either an event occurs to + * unblock a task, or the block timeout period expires. + * + * @return pdTRUE if the task being removed has a higher priority than the task + * making the call, otherwise pdFALSE. + */ +signed portBASE_TYPE xTaskRemoveFromEventList( const xList * const pxEventList ); + +/* + * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS AN + * INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER. + * + * INCLUDE_vTaskCleanUpResources and INCLUDE_vTaskSuspend must be defined as 1 + * for this function to be available. + * See the configuration section for more information. + * + * Empties the ready and delayed queues of task control blocks, freeing the + * memory allocated for the task control block and task stacks as it goes. + */ +void vTaskCleanUpResources( void ); + +/* + * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS ONLY + * INTENDED FOR USE WHEN IMPLEMENTING A PORT OF THE SCHEDULER AND IS + * AN INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER. + * + * Sets the pointer to the current TCB to the TCB of the highest priority task + * that is ready to run. + */ +inline void vTaskSwitchContext( void ); + +/* + * Return the handle of the calling task. + */ +xTaskHandle xTaskGetCurrentTaskHandle( void ); + +/* + * Capture the current time status for future reference. + */ +void vTaskSetTimeOutState( xTimeOutType * const pxTimeOut ); + +/* + * Compare the time status now with that previously captured to see if the + * timeout has expired. + */ +portBASE_TYPE xTaskCheckForTimeOut( xTimeOutType * const pxTimeOut, portTickType * const pxTicksToWait ); + +/* + * Shortcut used by the queue implementation to prevent unnecessary call to + * taskYIELD(); + */ +void vTaskMissedYield( void ); + +/* + * Returns the scheduler state as taskSCHEDULER_RUNNING, + * taskSCHEDULER_NOT_STARTED or taskSCHEDULER_SUSPENDED. + */ +portBASE_TYPE xTaskGetSchedulerState( void ); + +/* + * Raises the priority of the mutex holder to that of the calling task should + * the mutex holder have a priority less than the calling task. + */ +void vTaskPriorityInherit( xTaskHandle * const pxMutexHolder ); + +/* + * Set the priority of a task back to its proper priority in the case that it + * inherited a higher priority while it was holding a semaphore. + */ +void vTaskPriorityDisinherit( xTaskHandle * const pxMutexHolder ); + +#ifdef __cplusplus +} +#endif +#endif /* TASK_H */ + + + diff --git a/Tester/SW/lib/FreeRTOS/Source/list.c b/Tester/SW/lib/FreeRTOS/Source/list.c new file mode 100644 index 0000000..7f4869f --- /dev/null +++ b/Tester/SW/lib/FreeRTOS/Source/list.c @@ -0,0 +1,205 @@ +/* + FreeRTOS.org V4.6.1 - Copyright (C) 2003-2007 Richard Barry. + + This file is part of the FreeRTOS.org distribution. + + FreeRTOS.org is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + FreeRTOS.org is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with FreeRTOS.org; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + A special exception to the GPL can be applied should you wish to distribute + a combined work that includes FreeRTOS.org, without being obliged to provide + the source code for any proprietary components. See the licensing section + of http://www.FreeRTOS.org for full details of how and when the exception + can be applied. + + *************************************************************************** + See http://www.FreeRTOS.org for documentation, latest information, license + and contact details. Please ensure to read the configuration and relevant + port sections of the online documentation. + + Also see http://www.SafeRTOS.com a version that has been certified for use + in safety critical systems, plus commercial licensing, development and + support options. + *************************************************************************** +*/ + +/* +Changes from V1.2.0 + + + Removed the volatile modifier from the function parameters. This was + only ever included to prevent compiler warnings. Now warnings are + removed by casting parameters where the calls are made. + + + prvListGetOwnerOfNextEntry() and prvListGetOwnerOfHeadEntry() have been + removed from the c file and added as macros to the h file. + + + uxNumberOfItems has been added to the list structure. This removes the + need for a pointer comparison when checking if a list is empty, and so + is slightly faster. + + + Removed the NULL check in vListRemove(). This makes the call faster but + necessitates any application code utilising the list implementation to + ensure NULL pointers are not passed. + +Changes from V2.0.0 + + + Double linked the lists to allow faster removal item removal. + +Changes from V2.6.1 + + + Make use of the new portBASE_TYPE definition where ever appropriate. + +Changes from V3.0.0 + + + API changes as described on the FreeRTOS.org WEB site. + +Changes from V3.2.4 + + + Removed the pxHead member of the xList structure. This always pointed + to the same place so has been removed to free a few bytes of RAM. + + + Introduced the xMiniListItem structure that does not include the + xListItem members that are not required by the xListEnd member of a list. + Again this was done to reduce RAM usage. + + + Changed the volatile definitions of some structure members to clean up + the code where the list structures are used. + +Changes from V4.0.4 + + + Optimised vListInsert() in the case when the wake time is the maximum + tick count value. +*/ + +#include +#include "FreeRTOS.h" +#include "list.h" + +/*----------------------------------------------------------- + * PUBLIC LIST API documented in list.h + *----------------------------------------------------------*/ + +void vListInitialise( xList *pxList ) +{ + /* The list structure contains a list item which is used to mark the + end of the list. To initialise the list the list end is inserted + as the only list entry. */ + pxList->pxIndex = ( xListItem * ) &( pxList->xListEnd ); + + /* The list end value is the highest possible value in the list to + ensure it remains at the end of the list. */ + pxList->xListEnd.xItemValue = portMAX_DELAY; + + /* The list end next and previous pointers point to itself so we know + when the list is empty. */ + pxList->xListEnd.pxNext = ( xListItem * ) &( pxList->xListEnd ); + pxList->xListEnd.pxPrevious = ( xListItem * ) &( pxList->xListEnd ); + + pxList->uxNumberOfItems = 0; +} +/*-----------------------------------------------------------*/ + +void vListInitialiseItem( xListItem *pxItem ) +{ + /* Make sure the list item is not recorded as being on a list. */ + pxItem->pvContainer = NULL; +} +/*-----------------------------------------------------------*/ + +void vListInsertEnd( xList *pxList, xListItem *pxNewListItem ) +{ +volatile xListItem * pxIndex; + + /* Insert a new list item into pxList, but rather than sort the list, + makes the new list item the last item to be removed by a call to + pvListGetOwnerOfNextEntry. This means it has to be the item pointed to by + the pxIndex member. */ + pxIndex = pxList->pxIndex; + + pxNewListItem->pxNext = pxIndex->pxNext; + pxNewListItem->pxPrevious = pxList->pxIndex; + pxIndex->pxNext->pxPrevious = ( volatile xListItem * ) pxNewListItem; + pxIndex->pxNext = ( volatile xListItem * ) pxNewListItem; + pxList->pxIndex = ( volatile xListItem * ) pxNewListItem; + + /* Remember which list the item is in. */ + pxNewListItem->pvContainer = ( void * ) pxList; + + ( pxList->uxNumberOfItems )++; +} +/*-----------------------------------------------------------*/ + +void vListInsert( xList *pxList, xListItem *pxNewListItem ) +{ +volatile xListItem *pxIterator; +portTickType xValueOfInsertion; + + /* Insert the new list item into the list, sorted in ulListItem order. */ + xValueOfInsertion = pxNewListItem->xItemValue; + + /* If the list already contains a list item with the same item value then + the new list item should be placed after it. This ensures that TCB's which + are stored in ready lists (all of which have the same ulListItem value) + get an equal share of the CPU. However, if the xItemValue is the same as + the back marker the iteration loop below will not end. This means we need + to guard against this by checking the value first and modifying the + algorithm slightly if necessary. */ + if( xValueOfInsertion == portMAX_DELAY ) + { + pxIterator = pxList->xListEnd.pxPrevious; + } + else + { + for( pxIterator = ( xListItem * ) &( pxList->xListEnd ); pxIterator->pxNext->xItemValue <= xValueOfInsertion; pxIterator = pxIterator->pxNext ) + { + /* There is nothing to do here, we are just iterating to the + wanted insertion position. */ + } + } + + pxNewListItem->pxNext = pxIterator->pxNext; + pxNewListItem->pxNext->pxPrevious = ( volatile xListItem * ) pxNewListItem; + pxNewListItem->pxPrevious = pxIterator; + pxIterator->pxNext = ( volatile xListItem * ) pxNewListItem; + + /* Remember which list the item is in. This allows fast removal of the + item later. */ + pxNewListItem->pvContainer = ( void * ) pxList; + + ( pxList->uxNumberOfItems )++; +} +/*-----------------------------------------------------------*/ + +void vListRemove( xListItem *pxItemToRemove ) +{ +xList * pxList; + + pxItemToRemove->pxNext->pxPrevious = pxItemToRemove->pxPrevious; + pxItemToRemove->pxPrevious->pxNext = pxItemToRemove->pxNext; + + /* The list item knows which list it is in. Obtain the list from the list + item. */ + pxList = ( xList * ) pxItemToRemove->pvContainer; + + /* Make sure the index is left pointing to a valid item. */ + if( pxList->pxIndex == pxItemToRemove ) + { + pxList->pxIndex = pxItemToRemove->pxPrevious; + } + + pxItemToRemove->pvContainer = NULL; + ( pxList->uxNumberOfItems )--; +} +/*-----------------------------------------------------------*/ + diff --git a/Tester/SW/lib/FreeRTOS/Source/portable/GCC/ARM7_LPC23xx/port.c b/Tester/SW/lib/FreeRTOS/Source/portable/GCC/ARM7_LPC23xx/port.c new file mode 100644 index 0000000..ddb2cab --- /dev/null +++ b/Tester/SW/lib/FreeRTOS/Source/portable/GCC/ARM7_LPC23xx/port.c @@ -0,0 +1,235 @@ +/* + FreeRTOS.org V4.6.1 - Copyright (C) 2003-2007 Richard Barry. + + This file is part of the FreeRTOS.org distribution. + + FreeRTOS.org is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + FreeRTOS.org is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with FreeRTOS.org; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + A special exception to the GPL can be applied should you wish to distribute + a combined work that includes FreeRTOS.org, without being obliged to provide + the source code for any proprietary components. See the licensing section + of http://www.FreeRTOS.org for full details of how and when the exception + can be applied. + + *************************************************************************** + See http://www.FreeRTOS.org for documentation, latest information, license + and contact details. Please ensure to read the configuration and relevant + port sections of the online documentation. + *************************************************************************** +*/ + + +/*----------------------------------------------------------- + * Implementation of functions defined in portable.h for the ARM7 port. + * + * Components that can be compiled to either ARM or THUMB mode are + * contained in this file. The ISR routines, which can only be compiled + * to ARM mode are contained in portISR.c. + *----------------------------------------------------------*/ + + +/* Standard includes. */ +#include + +/* Scheduler includes. */ +#include "FreeRTOS.h" +#include "task.h" + +/* Constants required to setup the task context. */ +#define portINITIAL_SPSR ( ( portSTACK_TYPE ) 0x1f ) /* System mode, ARM mode, interrupts enabled. */ +#define portTHUMB_MODE_BIT ( ( portSTACK_TYPE ) 0x20 ) +#define portINSTRUCTION_SIZE ( ( portSTACK_TYPE ) 4 ) +#define portNO_CRITICAL_SECTION_NESTING ( ( portSTACK_TYPE ) 0 ) + +/* Constants required to setup the tick ISR. */ +#define portENABLE_TIMER ( ( unsigned portCHAR ) 0x01 ) +#define portPRESCALE_VALUE 0x00 +#define portINTERRUPT_ON_MATCH ( ( unsigned portLONG ) 0x01 ) +#define portRESET_COUNT_ON_MATCH ( ( unsigned portLONG ) 0x02 ) + +/* Constants required to setup the VIC for the tick ISR. */ +#define portTIMER_VIC_CHANNEL ( ( unsigned portLONG ) 0x0004 ) +#define portTIMER_VIC_CHANNEL_BIT ( ( unsigned portLONG ) 0x0010 ) +#define portTIMER_VIC_ENABLE ( ( unsigned portLONG ) 0x0020 ) + +/*-----------------------------------------------------------*/ + +/* Setup the timer to generate the tick interrupts. */ +static void prvSetupTimerInterrupt( void ); + +/* + * The scheduler can only be started from ARM mode, so + * vPortISRStartFirstSTask() is defined in portISR.c. + */ +extern void vPortISRStartFirstTask( void ); + +/*-----------------------------------------------------------*/ + +/* + * Initialise the stack of a task to look exactly as if a call to + * portSAVE_CONTEXT had been called. + * + * See header file for description. + */ +portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE pxCode, void *pvParameters ) +{ +portSTACK_TYPE *pxOriginalTOS; + + pxOriginalTOS = pxTopOfStack; + + /* Setup the initial stack of the task. The stack is set exactly as + expected by the portRESTORE_CONTEXT() macro. */ + + /* First on the stack is the return address - which in this case is the + start of the task. The offset is added to make the return address appear + as it would within an IRQ ISR. */ + *pxTopOfStack = ( portSTACK_TYPE ) pxCode + portINSTRUCTION_SIZE; + pxTopOfStack--; + + *pxTopOfStack = ( portSTACK_TYPE ) 0x00000000; /* R14 */ + pxTopOfStack--; + *pxTopOfStack = ( portSTACK_TYPE ) pxOriginalTOS; /* Stack used when task starts goes in R13. */ + pxTopOfStack--; + *pxTopOfStack = ( portSTACK_TYPE ) 0x12121212; /* R12 */ + pxTopOfStack--; + *pxTopOfStack = ( portSTACK_TYPE ) 0x11111111; /* R11 */ + pxTopOfStack--; + *pxTopOfStack = ( portSTACK_TYPE ) 0x10101010; /* R10 */ + pxTopOfStack--; + *pxTopOfStack = ( portSTACK_TYPE ) 0x09090909; /* R9 */ + pxTopOfStack--; + *pxTopOfStack = ( portSTACK_TYPE ) 0x08080808; /* R8 */ + pxTopOfStack--; + *pxTopOfStack = ( portSTACK_TYPE ) 0x07070707; /* R7 */ + pxTopOfStack--; + *pxTopOfStack = ( portSTACK_TYPE ) 0x06060606; /* R6 */ + pxTopOfStack--; + *pxTopOfStack = ( portSTACK_TYPE ) 0x05050505; /* R5 */ + pxTopOfStack--; + *pxTopOfStack = ( portSTACK_TYPE ) 0x04040404; /* R4 */ + pxTopOfStack--; + *pxTopOfStack = ( portSTACK_TYPE ) 0x03030303; /* R3 */ + pxTopOfStack--; + *pxTopOfStack = ( portSTACK_TYPE ) 0x02020202; /* R2 */ + pxTopOfStack--; + *pxTopOfStack = ( portSTACK_TYPE ) 0x01010101; /* R1 */ + pxTopOfStack--; + + /* When the task starts is will expect to find the function parameter in + R0. */ + *pxTopOfStack = ( portSTACK_TYPE ) pvParameters; /* R0 */ + pxTopOfStack--; + + /* The last thing onto the stack is the status register, which is set for + system mode, with interrupts enabled. */ + *pxTopOfStack = ( portSTACK_TYPE ) portINITIAL_SPSR; + + #ifdef THUMB_INTERWORK + { + /* We want the task to start in thumb mode. */ + *pxTopOfStack |= portTHUMB_MODE_BIT; + } + #endif + + pxTopOfStack--; + + /* Some optimisation levels use the stack differently to others. This + means the interrupt flags cannot always be stored on the stack and will + instead be stored in a variable, which is then saved as part of the + tasks context. */ + *pxTopOfStack = portNO_CRITICAL_SECTION_NESTING; + + return pxTopOfStack; +} +/*-----------------------------------------------------------*/ + +portBASE_TYPE xPortStartScheduler( void ) +{ + /* Start the timer that generates the tick ISR. Interrupts are disabled + here already. */ + prvSetupTimerInterrupt(); + + /* Start the first task. */ + vPortISRStartFirstTask(); + + /* Should not get here! */ + return 0; +} +/*-----------------------------------------------------------*/ + +void vPortEndScheduler( void ) +{ + /* It is unlikely that the ARM port will require this function as there + is nothing to return to. */ +} +/*-----------------------------------------------------------*/ + +/* + * Setup the timer 0 to generate the tick interrupts at the required frequency. + */ +static void prvSetupTimerInterrupt( void ) +{ +unsigned portLONG ulCompareMatch; + + PCLKSEL0 = (PCLKSEL0 & (~(0x3<<2))) | (0x01 << 2); + T0TCR = 2; /* Stop and reset the timer */ + T0CTCR = 0; /* Timer mode */ + + /* A 1ms tick does not require the use of the timer prescale. This is + defaulted to zero but can be used if necessary. */ + T0PR = portPRESCALE_VALUE; + + /* Calculate the match value required for our wanted tick rate. */ + ulCompareMatch = configCPU_CLOCK_HZ / configTICK_RATE_HZ; + + /* Protect against divide by zero. Using an if() statement still results + in a warning - hence the #if. */ + #if portPRESCALE_VALUE != 0 + { + ulCompareMatch /= ( portPRESCALE_VALUE + 1 ); + } + #endif + T0MR1 = ulCompareMatch; + + /* Generate tick with timer 0 compare match. */ + T0MCR = (3 << 3); /* Reset timer on match and generate interrupt */ + + /* Setup the VIC for the timer. */ + VICIntEnable = 0x00000010; + + /* The ISR installed depends on whether the preemptive or cooperative + scheduler is being used. */ + #if configUSE_PREEMPTION == 1 + { + extern void ( vPreemptiveTick )( void ); + VICVectAddr4 = ( portLONG ) vPreemptiveTick; + } + #else + { + extern void ( vNonPreemptiveTick )( void ); + VICVectAddr4 = ( portLONG ) vNonPreemptiveTick; + } + #endif + + VICVectCntl4 = 1; + + /* Start the timer - interrupts are disabled when this function is called + so it is okay to do this here. */ + T0TCR = portENABLE_TIMER; +} +/*-----------------------------------------------------------*/ + + + diff --git a/Tester/SW/lib/FreeRTOS/Source/portable/GCC/ARM7_LPC23xx/portISR.c b/Tester/SW/lib/FreeRTOS/Source/portable/GCC/ARM7_LPC23xx/portISR.c new file mode 100644 index 0000000..72002e9 --- /dev/null +++ b/Tester/SW/lib/FreeRTOS/Source/portable/GCC/ARM7_LPC23xx/portISR.c @@ -0,0 +1,217 @@ +/* + FreeRTOS.org V4.6.1 - Copyright (C) 2003-2007 Richard Barry. + + This file is part of the FreeRTOS.org distribution. + + FreeRTOS.org is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + FreeRTOS.org is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with FreeRTOS.org; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + A special exception to the GPL can be applied should you wish to distribute + a combined work that includes FreeRTOS.org, without being obliged to provide + the source code for any proprietary components. See the licensing section + of http://www.FreeRTOS.org for full details of how and when the exception + can be applied. + + *************************************************************************** + See http://www.FreeRTOS.org for documentation, latest information, license + and contact details. Please ensure to read the configuration and relevant + port sections of the online documentation. + *************************************************************************** +*/ + + +/*----------------------------------------------------------- + * Components that can be compiled to either ARM or THUMB mode are + * contained in port.c The ISR routines, which can only be compiled + * to ARM mode, are contained in this file. + *----------------------------------------------------------*/ + +/* Scheduler includes. */ +#include "FreeRTOS.h" +#include "task.h" + +/* Constants required to handle interrupts. */ +#define portTIMER_MATCH_ISR_BIT ( ( unsigned portCHAR ) 0x01 ) +#define portCLEAR_VIC_INTERRUPT ( ( unsigned portLONG ) 0 ) + +/* Constants required to handle critical sections. */ +#define portNO_CRITICAL_NESTING ( ( unsigned portLONG ) 0 ) +volatile unsigned portLONG ulCriticalNesting = 9999UL; + +/*-----------------------------------------------------------*/ + +/* ISR to handle manual context switches (from a call to taskYIELD()). */ +void vPortYieldProcessor( void ) __attribute__((interrupt("SWI"), naked)); + +/* + * The scheduler can only be started from ARM mode, hence the inclusion of this + * function here. + */ +void vPortISRStartFirstTask( void ); +/*-----------------------------------------------------------*/ + +void vPortISRStartFirstTask( void ) +{ + /* Simply start the scheduler. This is included here as it can only be + called from ARM mode. */ + portRESTORE_CONTEXT(); +} +/*-----------------------------------------------------------*/ + +/* + * Called by portYIELD() or taskYIELD() to manually force a context switch. + * + * When a context switch is performed from the task level the saved task + * context is made to look as if it occurred from within the tick ISR. This + * way the same restore context function can be used when restoring the context + * saved from the ISR or that saved from a call to vPortYieldProcessor. + */ +void vPortYieldProcessor( void ) +{ + /* Within an IRQ ISR the link register has an offset from the true return + address, but an SWI ISR does not. Add the offset manually so the same + ISR return code can be used in both cases. */ + asm volatile ( "ADD LR, LR, #4" ); + + /* Perform the context switch. First save the context of the current task. */ + portSAVE_CONTEXT(); + + /* Find the highest priority task that is ready to run. */ + vTaskSwitchContext(); + + /* Restore the context of the new task. */ + portRESTORE_CONTEXT(); +} +/*-----------------------------------------------------------*/ + +/* + * The ISR used for the scheduler tick depends on whether the cooperative or + * the preemptive scheduler is being used. + */ + + +#if configUSE_PREEMPTION == 0 + + /* The cooperative scheduler requires a normal IRQ service routine to + simply increment the system tick. */ + void vNonPreemptiveTick( void ) __attribute__ ((interrupt ("IRQ"))); + void vNonPreemptiveTick( void ) + { + vTaskIncrementTick(); + T0IR = 2; + VICVectAddr = portCLEAR_VIC_INTERRUPT; + } + +#else + + /* The preemptive scheduler is defined as "naked" as the full context is + saved on entry as part of the context switch. */ + void vPreemptiveTick( void ) __attribute__((naked)); + void vPreemptiveTick( void ) + { + /* Save the context of the interrupted task. */ + portSAVE_CONTEXT(); + + /* Increment the RTOS tick count, then look for the highest priority + task that is ready to run. */ + vTaskIncrementTick(); + vTaskSwitchContext(); + + /* Ready for the next interrupt. */ + T0IR = 2; + VICVectAddr = portCLEAR_VIC_INTERRUPT; + + /* Restore the context of the new task. */ + portRESTORE_CONTEXT(); + } + +#endif +/*-----------------------------------------------------------*/ + +/* + * The interrupt management utilities can only be called from ARM mode. When + * THUMB_INTERWORK is defined the utilities are defined as functions here to + * ensure a switch to ARM mode. When THUMB_INTERWORK is not defined then + * the utilities are defined as macros in portmacro.h - as per other ports. + */ +#ifdef THUMB_INTERWORK + + void vPortDisableInterruptsFromThumb( void ) __attribute__ ((naked)); + void vPortEnableInterruptsFromThumb( void ) __attribute__ ((naked)); + + void vPortDisableInterruptsFromThumb( void ) + { + asm volatile ( + "STMDB SP!, {R0} \n\t" /* Push R0. */ + "MRS R0, CPSR \n\t" /* Get CPSR. */ + "ORR R0, R0, #0xC0 \n\t" /* Disable IRQ, FIQ. */ + "MSR CPSR, R0 \n\t" /* Write back modified value. */ + "LDMIA SP!, {R0} \n\t" /* Pop R0. */ + "BX R14" ); /* Return back to thumb. */ + } + + void vPortEnableInterruptsFromThumb( void ) + { + asm volatile ( + "STMDB SP!, {R0} \n\t" /* Push R0. */ + "MRS R0, CPSR \n\t" /* Get CPSR. */ + "BIC R0, R0, #0xC0 \n\t" /* Enable IRQ, FIQ. */ + "MSR CPSR, R0 \n\t" /* Write back modified value. */ + "LDMIA SP!, {R0} \n\t" /* Pop R0. */ + "BX R14" ); /* Return back to thumb. */ + } + +#endif /* THUMB_INTERWORK */ + +/* The code generated by the GCC compiler uses the stack in different ways at +different optimisation levels. The interrupt flags can therefore not always +be saved to the stack. Instead the critical section nesting level is stored +in a variable, which is then saved as part of the stack context. */ +void vPortEnterCritical( void ) +{ + /* Disable interrupts as per portDISABLE_INTERRUPTS(); */ + asm volatile ( + "STMDB SP!, {R0} \n\t" /* Push R0. */ + "MRS R0, CPSR \n\t" /* Get CPSR. */ + "ORR R0, R0, #0xC0 \n\t" /* Disable IRQ, FIQ. */ + "MSR CPSR, R0 \n\t" /* Write back modified value. */ + "LDMIA SP!, {R0}" ); /* Pop R0. */ + + /* Now interrupts are disabled ulCriticalNesting can be accessed + directly. Increment ulCriticalNesting to keep a count of how many times + portENTER_CRITICAL() has been called. */ + ulCriticalNesting++; +} + +void vPortExitCritical( void ) +{ + if( ulCriticalNesting > portNO_CRITICAL_NESTING ) + { + /* Decrement the nesting count as we are leaving a critical section. */ + ulCriticalNesting--; + + /* If the nesting level has reached zero then interrupts should be + re-enabled. */ + if( ulCriticalNesting == portNO_CRITICAL_NESTING ) + { + /* Enable interrupts as per portEXIT_CRITICAL(). */ + asm volatile ( + "STMDB SP!, {R0} \n\t" /* Push R0. */ + "MRS R0, CPSR \n\t" /* Get CPSR. */ + "BIC R0, R0, #0xC0 \n\t" /* Enable IRQ, FIQ. */ + "MSR CPSR, R0 \n\t" /* Write back modified value. */ + "LDMIA SP!, {R0}" ); /* Pop R0. */ + } + } +} diff --git a/Tester/SW/lib/FreeRTOS/Source/portable/GCC/ARM7_LPC23xx/portmacro.h b/Tester/SW/lib/FreeRTOS/Source/portable/GCC/ARM7_LPC23xx/portmacro.h new file mode 100644 index 0000000..1b1f398 --- /dev/null +++ b/Tester/SW/lib/FreeRTOS/Source/portable/GCC/ARM7_LPC23xx/portmacro.h @@ -0,0 +1,250 @@ +/* + FreeRTOS.org V4.6.1 - Copyright (C) 2003-2007 Richard Barry. + + This file is part of the FreeRTOS.org distribution. + + FreeRTOS.org is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + FreeRTOS.org is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with FreeRTOS.org; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + A special exception to the GPL can be applied should you wish to distribute + a combined work that includes FreeRTOS.org, without being obliged to provide + the source code for any proprietary components. See the licensing section + of http://www.FreeRTOS.org for full details of how and when the exception + can be applied. + + *************************************************************************** + See http://www.FreeRTOS.org for documentation, latest information, license + and contact details. Please ensure to read the configuration and relevant + port sections of the online documentation. + *************************************************************************** +*/ + +/* + Changes from V3.2.3 + + + Modified portENTER_SWITCHING_ISR() to allow use with GCC V4.0.1. + + Changes from V3.2.4 + + + Removed the use of the %0 parameter within the assembler macros and + replaced them with hard coded registers. This will ensure the + assembler does not select the link register as the temp register as + was occasionally happening previously. + + + The assembler statements are now included in a single asm block rather + than each line having its own asm block. + + Changes from V4.5.0 + + + Removed the portENTER_SWITCHING_ISR() and portEXIT_SWITCHING_ISR() macros + and replaced them with portYIELD_FROM_ISR() macro. Application code + should now make use of the portSAVE_CONTEXT() and portRESTORE_CONTEXT() + macros as per the V4.5.1 demo code. +*/ + +#ifndef PORTMACRO_H +#define PORTMACRO_H + +#ifdef __cplusplus +extern "C" { +#endif + +/*----------------------------------------------------------- + * Port specific definitions. + * + * The settings in this file configure FreeRTOS correctly for the + * given hardware and compiler. + * + * These settings should not be altered. + *----------------------------------------------------------- + */ + +/* Type definitions. */ +#define portCHAR char +#define portFLOAT float +#define portDOUBLE double +#define portLONG long +#define portSHORT short +#define portSTACK_TYPE unsigned portLONG +#define portBASE_TYPE portLONG + +#if( configUSE_16_BIT_TICKS == 1 ) + typedef unsigned portSHORT portTickType; + #define portMAX_DELAY ( portTickType ) 0xffff +#else + typedef unsigned portLONG portTickType; + #define portMAX_DELAY ( portTickType ) 0xffffffff +#endif +/*-----------------------------------------------------------*/ + +/* Architecture specifics. */ +#define portSTACK_GROWTH ( -1 ) +#define portTICK_RATE_MS ( ( portTickType ) 1000 / configTICK_RATE_HZ ) +#define portBYTE_ALIGNMENT 4 +#define portNOP() asm volatile ( "NOP" ); +/*-----------------------------------------------------------*/ + + +/* Scheduler utilities. */ + +/* + * portRESTORE_CONTEXT, portRESTORE_CONTEXT, portENTER_SWITCHING_ISR + * and portEXIT_SWITCHING_ISR can only be called from ARM mode, but + * are included here for efficiency. An attempt to call one from + * THUMB mode code will result in a compile time error. + */ +// \TODO BIJWERKEN? Er waren problemen bij de CAN ISR, waar ISR_ENTRY in plaats woord gebruikt +#define portRESTORE_CONTEXT() \ +{ \ +extern volatile void * volatile pxCurrentTCB; \ +extern volatile unsigned portLONG ulCriticalNesting; \ + \ + /* Set the LR to the task stack. */ \ + asm volatile ( \ + "LDR R0, =pxCurrentTCB \n\t" \ + "LDR R0, [R0] \n\t" \ + "LDR LR, [R0] \n\t" \ + \ + /* The critical nesting depth is the first item on the stack. */ \ + /* Load it into the ulCriticalNesting variable. */ \ + "LDR R0, =ulCriticalNesting \n\t" \ + "LDMFD LR!, {R1} \n\t" \ + "STR R1, [R0] \n\t" \ + \ + /* Get the SPSR from the stack. */ \ + "LDMFD LR!, {R0} \n\t" \ + "MSR SPSR, R0 \n\t" \ + \ + /* Restore all system mode registers for the task. */ \ + "LDMFD LR, {R0-R14}^ \n\t" \ + "NOP \n\t" \ + \ + /* Restore the return address. */ \ + "LDR LR, [LR, #+60] \n\t" \ + \ + /* And return - correcting the offset in the LR to obtain the */ \ + /* correct address. */ \ + "SUBS PC, LR, #4 \n\t" \ + ); \ + ( void ) ulCriticalNesting; \ + ( void ) pxCurrentTCB; \ +} +/*-----------------------------------------------------------*/ +// \TODO BIJWERKEN? Er waren problemen bij de CAN ISR, waar ISR_EXIT in plaats woord gebruikt +#define portSAVE_CONTEXT() \ +{ \ +extern volatile void * volatile pxCurrentTCB; \ +extern volatile unsigned portLONG ulCriticalNesting; \ + \ + /* Push R0 as we are going to use the register. */ \ + asm volatile ( \ + "STMDB SP!, {R0} \n\t" \ + \ + /* Set R0 to point to the task stack pointer. */ \ + "STMDB SP,{SP}^ \n\t" \ + "NOP \n\t" \ + "SUB SP, SP, #4 \n\t" \ + "LDMIA SP!,{R0} \n\t" \ + \ + /* Push the return address onto the stack. */ \ + "STMDB R0!, {LR} \n\t" \ + \ + /* Now we have saved LR we can use it instead of R0. */ \ + "MOV LR, R0 \n\t" \ + \ + /* Pop R0 so we can save it onto the system mode stack. */ \ + "LDMIA SP!, {R0} \n\t" \ + \ + /* Push all the system mode registers onto the task stack. */ \ + "STMDB LR,{R0-LR}^ \n\t" \ + "NOP \n\t" \ + "SUB LR, LR, #60 \n\t" \ + \ + /* Push the SPSR onto the task stack. */ \ + "MRS R0, SPSR \n\t" \ + "STMDB LR!, {R0} \n\t" \ + \ + "LDR R0, =ulCriticalNesting \n\t" \ + "LDR R0, [R0] \n\t" \ + "STMDB LR!, {R0} \n\t" \ + \ + /* Store the new top of stack for the task. */ \ + "LDR R0, =pxCurrentTCB \n\t" \ + "LDR R0, [R0] \n\t" \ + "STR LR, [R0] \n\t" \ + ); \ + ( void ) ulCriticalNesting; \ + ( void ) pxCurrentTCB; \ +} + + +#define portYIELD_FROM_ISR() vTaskSwitchContext() +#define portYIELD() asm volatile ( "SWI" ) +/*-----------------------------------------------------------*/ + + +/* Critical section management. */ + +/* + * The interrupt management utilities can only be called from ARM mode. When + * THUMB_INTERWORK is defined the utilities are defined as functions in + * portISR.c to ensure a switch to ARM mode. When THUMB_INTERWORK is not + * defined then the utilities are defined as macros here - as per other ports. + */ + +#ifdef THUMB_INTERWORK + + extern void vPortDisableInterruptsFromThumb( void ) __attribute__ ((naked)); + extern void vPortEnableInterruptsFromThumb( void ) __attribute__ ((naked)); + + #define portDISABLE_INTERRUPTS() vPortDisableInterruptsFromThumb() + #define portENABLE_INTERRUPTS() vPortEnableInterruptsFromThumb() + +#else + + #define portDISABLE_INTERRUPTS() \ + asm volatile ( \ + "STMDB SP!, {R0} \n\t" /* Push R0. */ \ + "MRS R0, CPSR \n\t" /* Get CPSR. */ \ + "ORR R0, R0, #0xC0 \n\t" /* Disable IRQ, FIQ. */ \ + "MSR CPSR, R0 \n\t" /* Write back modified value. */ \ + "LDMIA SP!, {R0} " ) /* Pop R0. */ + + #define portENABLE_INTERRUPTS() \ + asm volatile ( \ + "STMDB SP!, {R0} \n\t" /* Push R0. */ \ + "MRS R0, CPSR \n\t" /* Get CPSR. */ \ + "BIC R0, R0, #0xC0 \n\t" /* Enable IRQ, FIQ. */ \ + "MSR CPSR, R0 \n\t" /* Write back modified value. */ \ + "LDMIA SP!, {R0} " ) /* Pop R0. */ + +#endif /* THUMB_INTERWORK */ + +extern void vPortEnterCritical( void ); +extern void vPortExitCritical( void ); + +#define portENTER_CRITICAL() vPortEnterCritical(); +#define portEXIT_CRITICAL() vPortExitCritical(); +/*-----------------------------------------------------------*/ + +/* Task function macros as described on the FreeRTOS.org WEB site. */ +#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters ) +#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters ) + +#ifdef __cplusplus +} +#endif + +#endif /* PORTMACRO_H */ + diff --git a/Tester/SW/lib/FreeRTOS/Source/portable/MemMang/heap_1.c b/Tester/SW/lib/FreeRTOS/Source/portable/MemMang/heap_1.c new file mode 100644 index 0000000..e56717f --- /dev/null +++ b/Tester/SW/lib/FreeRTOS/Source/portable/MemMang/heap_1.c @@ -0,0 +1,141 @@ +/* + FreeRTOS.org V4.6.1 - Copyright (C) 2003-2007 Richard Barry. + + This file is part of the FreeRTOS.org distribution. + + FreeRTOS.org is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + FreeRTOS.org is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with FreeRTOS.org; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + A special exception to the GPL can be applied should you wish to distribute + a combined work that includes FreeRTOS.org, without being obliged to provide + the source code for any proprietary components. See the licensing section + of http://www.FreeRTOS.org for full details of how and when the exception + can be applied. + + *************************************************************************** + See http://www.FreeRTOS.org for documentation, latest information, license + and contact details. Please ensure to read the configuration and relevant + port sections of the online documentation. + + Also see http://www.SafeRTOS.com a version that has been certified for use + in safety critical systems, plus commercial licensing, development and + support options. + *************************************************************************** +*/ + +/* + +Changes between V2.5.1 and V2.5.1 + + + The memory pool has been defined within a struct to ensure correct memory + alignment on 32bit systems. + +Changes between V2.6.1 and V3.0.0 + + + An overflow check has been added to ensure the next free byte variable + does not wrap around. +*/ + + +/* + * The simplest possible implementation of pvPortMalloc(). Note that this + * implementation does NOT allow allocated memory to be freed again. + * + * See heap_2.c and heap_3.c for alternative implementations, and the memory + * management pages of http://www.FreeRTOS.org for more information. + */ +#include +#include "FreeRTOS.h" +#include "task.h" + +/* Setup the correct byte alignment mask for the defined byte alignment. */ + +#if portBYTE_ALIGNMENT == 8 + #define heapBYTE_ALIGNMENT_MASK ( ( size_t ) 0x0007 ) +#endif + +#if portBYTE_ALIGNMENT == 4 + #define heapBYTE_ALIGNMENT_MASK ( ( size_t ) 0x0003 ) +#endif + +#if portBYTE_ALIGNMENT == 2 + #define heapBYTE_ALIGNMENT_MASK ( ( size_t ) 0x0001 ) +#endif + +#if portBYTE_ALIGNMENT == 1 + #define heapBYTE_ALIGNMENT_MASK ( ( size_t ) 0x0000 ) +#endif + +#ifndef heapBYTE_ALIGNMENT_MASK + #error "Invalid portBYTE_ALIGNMENT definition" +#endif + +/* Allocate the memory for the heap. The struct is used to force byte +alignment without using any non-portable code. */ +static struct xRTOS_HEAP +{ + unsigned portLONG ulDummy; + unsigned portCHAR ucHeap[ configTOTAL_HEAP_SIZE ]; +} xHeap; + +static size_t xNextFreeByte = ( size_t ) 0; +/*-----------------------------------------------------------*/ + +void *pvPortMalloc( size_t xWantedSize ) +{ +void *pvReturn = NULL; + + /* Ensure that blocks are always aligned to the required number of bytes. */ + #if portBYTE_ALIGNMENT != 1 + if( xWantedSize & heapBYTE_ALIGNMENT_MASK ) + { + /* Byte alignment required. */ + xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & heapBYTE_ALIGNMENT_MASK ) ); + } + #endif + + vTaskSuspendAll(); + { + /* Check there is enough room left for the allocation. */ + if( ( ( xNextFreeByte + xWantedSize ) < configTOTAL_HEAP_SIZE ) && + ( ( xNextFreeByte + xWantedSize ) > xNextFreeByte ) )/* Check for overflow. */ + { + /* Return the next free byte then increment the index past this + block. */ + pvReturn = &( xHeap.ucHeap[ xNextFreeByte ] ); + xNextFreeByte += xWantedSize; + } + } + xTaskResumeAll(); + + return pvReturn; +} +/*-----------------------------------------------------------*/ + +void vPortFree( void *pv ) +{ + /* Memory cannot be freed using this scheme. See heap_2.c and heap_3.c + for alternative implementations, and the memory management pages of + http://www.FreeRTOS.org for more information. */ + ( void ) pv; +} +/*-----------------------------------------------------------*/ + +void vPortInitialiseBlocks( void ) +{ + /* Only required when static memory is not cleared. */ + xNextFreeByte = ( size_t ) 0; +} + + diff --git a/Tester/SW/lib/FreeRTOS/Source/portable/MemMang/heap_2.c b/Tester/SW/lib/FreeRTOS/Source/portable/MemMang/heap_2.c new file mode 100644 index 0000000..4cf54c8 --- /dev/null +++ b/Tester/SW/lib/FreeRTOS/Source/portable/MemMang/heap_2.c @@ -0,0 +1,287 @@ +/* + FreeRTOS.org V4.6.1 - Copyright (C) 2003-2007 Richard Barry. + + This file is part of the FreeRTOS.org distribution. + + FreeRTOS.org is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + FreeRTOS.org is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with FreeRTOS.org; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + A special exception to the GPL can be applied should you wish to distribute + a combined work that includes FreeRTOS.org, without being obliged to provide + the source code for any proprietary components. See the licensing section + of http://www.FreeRTOS.org for full details of how and when the exception + can be applied. + + *************************************************************************** + See http://www.FreeRTOS.org for documentation, latest information, license + and contact details. Please ensure to read the configuration and relevant + port sections of the online documentation. + + Also see http://www.SafeRTOS.com a version that has been certified for use + in safety critical systems, plus commercial licensing, development and + support options. + *************************************************************************** +*/ + +/* + * A sample implementation of pvPortMalloc() and vPortFree() that permits + * allocated blocks to be freed, but does not combine adjacent free blocks + * into a single larger block. + * + * See heap_1.c and heap_3.c for alternative implementations, and the memory + * management pages of http://www.FreeRTOS.org for more information. + */ +#include + +#include "FreeRTOS.h" +#include "task.h" + +/* Setup the correct byte alignment mask for the defined byte alignment. */ + +#if portBYTE_ALIGNMENT == 8 + #define heapBYTE_ALIGNMENT_MASK ( ( size_t ) 0x0007 ) +#endif + +#if portBYTE_ALIGNMENT == 4 + #define heapBYTE_ALIGNMENT_MASK ( ( size_t ) 0x0003 ) +#endif + +#if portBYTE_ALIGNMENT == 2 + #define heapBYTE_ALIGNMENT_MASK ( ( size_t ) 0x0001 ) +#endif + +#if portBYTE_ALIGNMENT == 1 + #define heapBYTE_ALIGNMENT_MASK ( ( size_t ) 0x0000 ) +#endif + +#ifndef heapBYTE_ALIGNMENT_MASK + #error "Invalid portBYTE_ALIGNMENT definition" +#endif + +/* Allocate the memory for the heap. The struct is used to force byte +alignment without using any non-portable code. */ +static struct xRTOS_HEAP +{ + unsigned portLONG ulDummy; + unsigned portCHAR ucHeap[ configTOTAL_HEAP_SIZE ]; +} xHeap __attribute__ ((section (".ethram"))); // \TODO DID RAM CHANGE HERE +//} xHeap __attribute__ ((section (".bss"))); + + +/* Define the linked list structure. This is used to link free blocks in order +of their size. */ +typedef struct A_BLOCK_LINK +{ + struct A_BLOCK_LINK *pxNextFreeBlock; /*<< The next free block in the list. */ + size_t xBlockSize; /*<< The size of the free block. */ +} xBlockLink; + + +static const unsigned portSHORT heapSTRUCT_SIZE = ( sizeof( xBlockLink ) + ( sizeof( xBlockLink ) % portBYTE_ALIGNMENT ) ); +#define heapMINIMUM_BLOCK_SIZE ( ( size_t ) ( heapSTRUCT_SIZE * 2 ) ) + +/* Create a couple of list links to mark the start and end of the list. */ +static xBlockLink xStart, xEnd; + +/* STATIC FUNCTIONS ARE DEFINED AS MACROS TO MINIMIZE THE FUNCTION CALL DEPTH. */ + +/* + * Insert a block into the list of free blocks - which is ordered by size of + * the block. Small blocks at the start of the list and large blocks at the end + * of the list. + */ +#define prvInsertBlockIntoFreeList( pxBlockToInsert ) \ +{ \ +xBlockLink *pxIterator; \ +size_t xBlockSize; \ + \ + xBlockSize = pxBlockToInsert->xBlockSize; \ + \ + /* Iterate through the list until a block is found that has a larger size */ \ + /* than the block we are inserting. */ \ + for( pxIterator = &xStart; pxIterator->pxNextFreeBlock->xBlockSize < xBlockSize; pxIterator = pxIterator->pxNextFreeBlock ) \ + { \ + /* There is nothing to do here - just iterate to the correct position. */ \ + } \ + \ + /* Update the list to include the block being inserted in the correct */ \ + /* position. */ \ + pxBlockToInsert->pxNextFreeBlock = pxIterator->pxNextFreeBlock; \ + pxIterator->pxNextFreeBlock = pxBlockToInsert; \ +} +/*-----------------------------------------------------------*/ + +#define prvHeapInit() \ +{ \ +xBlockLink *pxFirstFreeBlock; \ + \ + /* xStart is used to hold a pointer to the first item in the list of free */ \ + /* blocks. The void cast is used to prevent compiler warnings. */ \ + xStart.pxNextFreeBlock = ( void * ) xHeap.ucHeap; \ + xStart.xBlockSize = ( size_t ) 0; \ + \ + /* xEnd is used to mark the end of the list of free blocks. */ \ + xEnd.xBlockSize = configTOTAL_HEAP_SIZE; \ + xEnd.pxNextFreeBlock = NULL; \ + \ + /* To start with there is a single free block that is sized to take up the \ + entire heap space. */ \ + pxFirstFreeBlock = ( void * ) xHeap.ucHeap; \ + pxFirstFreeBlock->xBlockSize = configTOTAL_HEAP_SIZE; \ + pxFirstFreeBlock->pxNextFreeBlock = &xEnd; \ +} +/*-----------------------------------------------------------*/ + +extern void serWrite ( + int device, + short length, /**< Lengh of data in bytes */ + char * data /**< Pointer to data */ +); + +//int allocMemorySizes[100]; +int nrOfAllocs = 0; +int totalMemoryAllocs = 0; +int mallocerror = 0; + +void *pvPortMalloc( size_t xWantedSize ) +{ +xBlockLink *pxBlock, *pxPreviousBlock, *pxNewBlockLink; +static portBASE_TYPE xHeapHasBeenInitialised = pdFALSE; +void *pvReturn = NULL; + + nrOfAllocs++; + totalMemoryAllocs+= xWantedSize; + + vTaskSuspendAll(); + { + /* If this is the first call to malloc then the heap will require + initialisation to setup the list of free blocks. */ + if( xHeapHasBeenInitialised == pdFALSE ) + { + prvHeapInit(); + xHeapHasBeenInitialised = pdTRUE; + } + + /* The wanted size is increased so it can contain a xBlockLink + structure in addition to the requested amount of bytes. */ + if( xWantedSize > 0 ) + { + xWantedSize += heapSTRUCT_SIZE; + + /* Ensure that blocks are always aligned to the required number of bytes. */ + if( xWantedSize & heapBYTE_ALIGNMENT_MASK ) + { + /* Byte alignment required. */ + xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & heapBYTE_ALIGNMENT_MASK ) ); + } + } + + if( ( xWantedSize > 0 ) && ( xWantedSize < configTOTAL_HEAP_SIZE ) ) + { + /* Blocks are stored in byte order - traverse the list from the start + (smallest) block until one of adequate size is found. */ + pxPreviousBlock = &xStart; + pxBlock = xStart.pxNextFreeBlock; + while( ( pxBlock->xBlockSize < xWantedSize ) && ( pxBlock->pxNextFreeBlock ) ) + { + pxPreviousBlock = pxBlock; + pxBlock = pxBlock->pxNextFreeBlock; + } + + /* If we found the end marker then a block of adequate size was not found. */ + if( pxBlock != &xEnd ) + { + /* Return the memory space - jumping over the xBlockLink structure + at its start. */ + pvReturn = ( void * ) ( ( ( unsigned portCHAR * ) pxPreviousBlock->pxNextFreeBlock ) + heapSTRUCT_SIZE ); + + /* This block is being returned for use so must be taken our of the + list of free blocks. */ + pxPreviousBlock->pxNextFreeBlock = pxBlock->pxNextFreeBlock; + + /* If the block is larger than required it can be split into two. */ + if( ( pxBlock->xBlockSize - xWantedSize ) > heapMINIMUM_BLOCK_SIZE ) + { + /* This block is to be split into two. Create a new block + following the number of bytes requested. The void cast is + used to prevent byte alignment warnings from the compiler. */ + pxNewBlockLink = ( void * ) ( ( ( unsigned portCHAR * ) pxBlock ) + xWantedSize ); + + /* Calculate the sizes of two blocks split from the single + block. */ + pxNewBlockLink->xBlockSize = pxBlock->xBlockSize - xWantedSize; + pxBlock->xBlockSize = xWantedSize; + + /* Insert the new block into the list of free blocks. */ + prvInsertBlockIntoFreeList( ( pxNewBlockLink ) ); + } + } + } + } + xTaskResumeAll(); + if (pvReturn == 0) + { + mallocerror++; + serWrite(1, sizeof("memory error"), "memory error"); + } + return pvReturn; +} +/*-----------------------------------------------------------*/ + +void vPortFree( void *pv ) +{ +unsigned portCHAR *puc = ( unsigned portCHAR * ) pv; +xBlockLink *pxLink; + + if( pv ) + { + /* The memory being freed will have an xBlockLink structure immediately + before it. */ + puc -= heapSTRUCT_SIZE; + + /* This casting is to keep the compiler from issuing warnings. */ + pxLink = ( void * ) puc; + + nrOfAllocs--; + totalMemoryAllocs -= pxLink->xBlockSize; + + vTaskSuspendAll(); + { + /* Add this block to the list of free blocks. */ + prvInsertBlockIntoFreeList( ( ( xBlockLink * ) pxLink ) ); + } + xTaskResumeAll(); + } +} +/*-----------------------------------------------------------*/ + +int vMemAvail() +{ + int totalMemAvail = 0; + xBlockLink *pxIterator = &xStart; + + vTaskSuspendAll(); + { + while (pxIterator->pxNextFreeBlock != &xEnd) + { + totalMemAvail += pxIterator->pxNextFreeBlock->xBlockSize; + pxIterator = pxIterator->pxNextFreeBlock; + } + } + xTaskResumeAll(); + + return totalMemAvail; +} +/*-----------------------------------------------------------*/ + diff --git a/Tester/SW/lib/FreeRTOS/Source/portable/MemMang/heap_3.c b/Tester/SW/lib/FreeRTOS/Source/portable/MemMang/heap_3.c new file mode 100644 index 0000000..b7d6d02 --- /dev/null +++ b/Tester/SW/lib/FreeRTOS/Source/portable/MemMang/heap_3.c @@ -0,0 +1,83 @@ +/* + FreeRTOS.org V4.6.1 - Copyright (C) 2003-2007 Richard Barry. + + This file is part of the FreeRTOS.org distribution. + + FreeRTOS.org is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + FreeRTOS.org is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with FreeRTOS.org; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + A special exception to the GPL can be applied should you wish to distribute + a combined work that includes FreeRTOS.org, without being obliged to provide + the source code for any proprietary components. See the licensing section + of http://www.FreeRTOS.org for full details of how and when the exception + can be applied. + + *************************************************************************** + See http://www.FreeRTOS.org for documentation, latest information, license + and contact details. Please ensure to read the configuration and relevant + port sections of the online documentation. + + Also see http://www.SafeRTOS.com a version that has been certified for use + in safety critical systems, plus commercial licensing, development and + support options. + *************************************************************************** +*/ + + +/* + * Implementation of pvPortMalloc() and vPortFree() that relies on the + * compilers own malloc() and free() implementations. + * + * This file can only be used if the linker is configured to to generate + * a heap memory area. + * + * See heap_2.c and heap_1.c for alternative implementations, and the memory + * management pages of http://www.FreeRTOS.org for more information. + */ + +#include + +#include "FreeRTOS.h" +#include "task.h" + +/*-----------------------------------------------------------*/ + +void *pvPortMalloc( size_t xWantedSize ) +{ +void *pvReturn; + + vTaskSuspendAll(); + { + pvReturn = malloc( xWantedSize ); + } + xTaskResumeAll(); + + return pvReturn; +} +/*-----------------------------------------------------------*/ + +void vPortFree( void *pv ) +{ + if( pv ) + { + vTaskSuspendAll(); + { + free( pv ); + } + xTaskResumeAll(); + } +} + + + diff --git a/Tester/SW/lib/FreeRTOS/Source/portable/readme.txt b/Tester/SW/lib/FreeRTOS/Source/portable/readme.txt new file mode 100644 index 0000000..a20d687 --- /dev/null +++ b/Tester/SW/lib/FreeRTOS/Source/portable/readme.txt @@ -0,0 +1,19 @@ +Each real time kernel port consists of three files that contain the core kernel +components and are common to every port, and one or more files that are +specific to a particular microcontroller and/or compiler. + + ++ The FreeRTOS/Source/Portable/MemMang directory contains the three sample +memory allocators as described on the http://www.FreeRTOS.org WEB site. + ++ The other directories each contain files specific to a particular +microcontroller or compiler. + + + +For example, if you are interested in the GCC port for the ATMega323 +microcontroller then the port specific files are contained in +FreeRTOS/Source/Portable/GCC/ATMega323 directory. If this is the only +port you are interested in then all the other directories can be +ignored. + diff --git a/Tester/SW/lib/FreeRTOS/Source/queue.c b/Tester/SW/lib/FreeRTOS/Source/queue.c new file mode 100644 index 0000000..e66ef5e --- /dev/null +++ b/Tester/SW/lib/FreeRTOS/Source/queue.c @@ -0,0 +1,1061 @@ +/* + FreeRTOS.org V4.6.1 - Copyright (C) 2003-2007 Richard Barry. + + This file is part of the FreeRTOS.org distribution. + + FreeRTOS.org is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + FreeRTOS.org is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with FreeRTOS.org; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + A special exception to the GPL can be applied should you wish to distribute + a combined work that includes FreeRTOS.org, without being obliged to provide + the source code for any proprietary components. See the licensing section + of http://www.FreeRTOS.org for full details of how and when the exception + can be applied. + + *************************************************************************** + See http://www.FreeRTOS.org for documentation, latest information, license + and contact details. Please ensure to read the configuration and relevant + port sections of the online documentation. + + Also see http://www.SafeRTOS.com a version that has been certified for use + in safety critical systems, plus commercial licensing, development and + support options. + *************************************************************************** +*/ + +/* +Changes from V1.01 + + + More use of 8bit data types. + + Function name prefixes changed where the data type returned has changed. + +Changed from V2.0.0 + + + Added the queue locking mechanism and make more use of the scheduler + suspension feature to minimise the time interrupts have to be disabled + when accessing a queue. + +Changed from V2.2.0 + + + Explicit use of 'signed' qualifier on portCHAR types added. + +Changes from V3.0.0 + + + API changes as described on the FreeRTOS.org WEB site. + +Changes from V3.2.3 + + + Added the queue functions that can be used from co-routines. + +Changes from V4.0.5 + + + Added a loop within xQueueSend() and xQueueReceive() to prevent the + functions exiting when a block time remains and the function has + not completed. + +Changes from V4.1.2: + + + BUG FIX: Removed the call to prvIsQueueEmpty from within xQueueCRReceive + as it exited with interrupts enabled. Thanks Paul Katz. + +Changes from V4.1.3: + + + Modified xQueueSend() and xQueueReceive() to handle the (very unlikely) + case whereby a task unblocking due to a temporal event can remove/send an + item from/to a queue when a higher priority task is still blocked on the + queue. This modification is a result of the SafeRTOS testing. +*/ + +#include +#include +#include "FreeRTOS.h" +#include "task.h" +#include "croutine.h" + +/*----------------------------------------------------------- + * PUBLIC LIST API documented in list.h + *----------------------------------------------------------*/ + +/* Constants used with the cRxLock and cTxLock structure members. */ +#define queueUNLOCKED ( ( signed portBASE_TYPE ) -1 ) +#define queueERRONEOUS_UNBLOCK ( -1 ) + +/* For internal use only. */ +#define queueSEND_TO_BACK ( 0 ) +#define queueSEND_TO_FRONT ( 1 ) + +/* Effectively make a union out of the xQUEUE structure. */ +#define pxMutexHolder pcTail +#define uxQueueType pcHead +#define queueQUEUE_IS_MUTEX NULL + +/* + * Definition of the queue used by the scheduler. + * Items are queued by copy, not reference. + */ +typedef struct QueueDefinition +{ + signed portCHAR *pcHead; /*< Points to the beginning of the queue storage area. */ + signed portCHAR *pcTail; /*< Points to the byte at the end of the queue storage area. Once more byte is allocated than necessary to store the queue items, this is used as a marker. */ + + signed portCHAR *pcWriteTo; /*< Points to the free next place in the storage area. */ + signed portCHAR *pcReadFrom; /*< Points to the last place that a queued item was read from. */ + + xList xTasksWaitingToSend; /*< List of tasks that are blocked waiting to post onto this queue. Stored in priority order. */ + xList xTasksWaitingToReceive; /*< List of tasks that are blocked waiting to read from this queue. Stored in priority order. */ + + unsigned portBASE_TYPE uxMessagesWaiting;/*< The number of items currently in the queue. */ + unsigned portBASE_TYPE uxLength; /*< The length of the queue defined as the number of items it will hold, not the number of bytes. */ + unsigned portBASE_TYPE uxItemSize; /*< The size of each items that the queue will hold. */ + + signed portBASE_TYPE xRxLock; /*< Stores the number of items received from the queue (removed from the queue) while the queue was locked. Set to queueUNLOCKED when the queue is not locked. */ + signed portBASE_TYPE xTxLock; /*< Stores the number of items transmitted to the queue (added to the queue) while the queue was locked. Set to queueUNLOCKED when the queue is not locked. */ +} xQUEUE; +/*-----------------------------------------------------------*/ + +/* + * Inside this file xQueueHandle is a pointer to a xQUEUE structure. + * To keep the definition private the API header file defines it as a + * pointer to void. + */ +typedef xQUEUE * xQueueHandle; + +/* + * Prototypes for public functions are included here so we don't have to + * include the API header file (as it defines xQueueHandle differently). These + * functions are documented in the API header file. + */ +xQueueHandle xQueueCreate( unsigned portBASE_TYPE uxQueueLength, unsigned portBASE_TYPE uxItemSize ); +signed portBASE_TYPE xQueueGenericSend( xQueueHandle xQueue, const void * const pvItemToQueue, portTickType xTicksToWait, portBASE_TYPE xCopyPosition ); +unsigned portBASE_TYPE uxQueueMessagesWaiting( const xQueueHandle pxQueue ); +void vQueueDelete( xQueueHandle xQueue ); +signed portBASE_TYPE xQueueGenericSendFromISR( xQueueHandle pxQueue, const void * const pvItemToQueue, signed portBASE_TYPE xTaskPreviouslyWoken, portBASE_TYPE xCopyPosition ); +signed portBASE_TYPE xQueueGenericReceive( xQueueHandle pxQueue, const void * const pvBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeeking ); +signed portBASE_TYPE xQueueReceiveFromISR( xQueueHandle pxQueue, const void * const pvBuffer, signed portBASE_TYPE *pxTaskWoken ); +xQueueHandle xQueueCreateMutex( void ); + +#if configUSE_CO_ROUTINES == 1 + signed portBASE_TYPE xQueueCRSendFromISR( xQueueHandle pxQueue, const void *pvItemToQueue, signed portBASE_TYPE xCoRoutinePreviouslyWoken ); + signed portBASE_TYPE xQueueCRReceiveFromISR( xQueueHandle pxQueue, void *pvBuffer, signed portBASE_TYPE *pxTaskWoken ); + signed portBASE_TYPE xQueueCRSend( xQueueHandle pxQueue, const void *pvItemToQueue, portTickType xTicksToWait ); + signed portBASE_TYPE xQueueCRReceive( xQueueHandle pxQueue, void *pvBuffer, portTickType xTicksToWait ); +#endif + +/* + * Unlocks a queue locked by a call to prvLockQueue. Locking a queue does not + * prevent an ISR from adding or removing items to the queue, but does prevent + * an ISR from removing tasks from the queue event lists. If an ISR finds a + * queue is locked it will instead increment the appropriate queue lock count + * to indicate that a task may require unblocking. When the queue in unlocked + * these lock counts are inspected, and the appropriate action taken. + */ +static void prvUnlockQueue( xQueueHandle pxQueue ); + +/* + * Uses a critical section to determine if there is any data in a queue. + * + * @return pdTRUE if the queue contains no items, otherwise pdFALSE. + */ +static signed portBASE_TYPE prvIsQueueEmpty( const xQueueHandle pxQueue ); + +/* + * Uses a critical section to determine if there is any space in a queue. + * + * @return pdTRUE if there is no space, otherwise pdFALSE; + */ +static signed portBASE_TYPE prvIsQueueFull( const xQueueHandle pxQueue ); + +/* + * Copies an item into the queue, either at the front of the queue or the + * back of the queue. + */ +static void prvCopyDataToQueue( xQUEUE *pxQueue, const void *pvItemToQueue, portBASE_TYPE xPosition ); + +/* + * Copies an item out of a queue. + */ +static void prvCopyDataFromQueue( xQUEUE * const pxQueue, const void *pvBuffer ); +/*-----------------------------------------------------------*/ + +/* + * Macro to mark a queue as locked. Locking a queue prevents an ISR from + * accessing the queue event lists. + */ +#define prvLockQueue( pxQueue ) \ +{ \ + taskENTER_CRITICAL(); \ + ++( pxQueue->xRxLock ); \ + ++( pxQueue->xTxLock ); \ + taskEXIT_CRITICAL(); \ +} +/*-----------------------------------------------------------*/ + + +/*----------------------------------------------------------- + * PUBLIC QUEUE MANAGEMENT API documented in queue.h + *----------------------------------------------------------*/ + +xQueueHandle xQueueCreate( unsigned portBASE_TYPE uxQueueLength, unsigned portBASE_TYPE uxItemSize ) +{ +xQUEUE *pxNewQueue; +size_t xQueueSizeInBytes; + + /* Allocate the new queue structure. */ + if( uxQueueLength > ( unsigned portBASE_TYPE ) 0 ) + { + pxNewQueue = ( xQUEUE * ) pvPortMalloc( sizeof( xQUEUE ) ); + if( pxNewQueue != NULL ) + { + /* Create the list of pointers to queue items. The queue is one byte + longer than asked for to make wrap checking easier/faster. */ + xQueueSizeInBytes = ( size_t ) ( uxQueueLength * uxItemSize ) + ( size_t ) 1; + + pxNewQueue->pcHead = ( signed portCHAR * ) pvPortMalloc( xQueueSizeInBytes ); + if( pxNewQueue->pcHead != NULL ) + { + /* Initialise the queue members as described above where the + queue type is defined. */ + pxNewQueue->pcTail = pxNewQueue->pcHead + ( uxQueueLength * uxItemSize ); + pxNewQueue->uxMessagesWaiting = 0; + pxNewQueue->pcWriteTo = pxNewQueue->pcHead; + pxNewQueue->pcReadFrom = pxNewQueue->pcHead + ( ( uxQueueLength - 1 ) * uxItemSize ); + pxNewQueue->uxLength = uxQueueLength; + pxNewQueue->uxItemSize = uxItemSize; + pxNewQueue->xRxLock = queueUNLOCKED; + pxNewQueue->xTxLock = queueUNLOCKED; + + /* Likewise ensure the event queues start with the correct state. */ + vListInitialise( &( pxNewQueue->xTasksWaitingToSend ) ); + vListInitialise( &( pxNewQueue->xTasksWaitingToReceive ) ); + + return pxNewQueue; + } + else + { + vPortFree( pxNewQueue ); + } + } + } + + /* Will only reach here if we could not allocate enough memory or no memory + was required. */ + return NULL; +} +/*-----------------------------------------------------------*/ + +#if ( configUSE_MUTEXES == 1 ) + + xQueueHandle xQueueCreateMutex( void ) + { + xQUEUE *pxNewQueue; + + /* Allocate the new queue structure. */ + pxNewQueue = ( xQUEUE * ) pvPortMalloc( sizeof( xQUEUE ) ); + if( pxNewQueue != NULL ) + { + /* Information required for priority inheritance. */ + pxNewQueue->pxMutexHolder = NULL; + pxNewQueue->uxQueueType = queueQUEUE_IS_MUTEX; + + /* Queues used as a mutex no data is actually copied into or out + of the queue. */ + pxNewQueue->pcWriteTo = NULL; + pxNewQueue->pcReadFrom = NULL; + + /* Each mutex has a length of 1 (like a binary semaphore) and + an item size of 0 as nothing is actually copied into or out + of the mutex. */ + pxNewQueue->uxMessagesWaiting = 0; + pxNewQueue->uxLength = 1; + pxNewQueue->uxItemSize = 0; + pxNewQueue->xRxLock = queueUNLOCKED; + pxNewQueue->xTxLock = queueUNLOCKED; + + /* Ensure the event queues start with the correct state. */ + vListInitialise( &( pxNewQueue->xTasksWaitingToSend ) ); + vListInitialise( &( pxNewQueue->xTasksWaitingToReceive ) ); + + /* Start with the semaphore in the expected state. */ + xQueueGenericSend( pxNewQueue, NULL, 0, queueSEND_TO_BACK ); + } + + return pxNewQueue; + } + +#endif /* configUSE_MUTEXES */ +/*-----------------------------------------------------------*/ + +signed portBASE_TYPE xQueueGenericSend( xQueueHandle pxQueue, const void * const pvItemToQueue, portTickType xTicksToWait, portBASE_TYPE xCopyPosition ) +{ +signed portBASE_TYPE xReturn = pdPASS; +xTimeOutType xTimeOut; + + /* Make sure other tasks do not access the queue. */ + vTaskSuspendAll(); + + /* Capture the current time status for future reference. */ + vTaskSetTimeOutState( &xTimeOut ); + + /* It is important that this is the only thread/ISR that modifies the + ready or delayed lists until xTaskResumeAll() is called. Places where + the ready/delayed lists are modified include: + + + vTaskDelay() - Nothing can call vTaskDelay as the scheduler is + suspended, vTaskDelay() cannot be called from an ISR. + + vTaskPrioritySet() - Has a critical section around the access. + + vTaskSwitchContext() - This will not get executed while the scheduler + is suspended. + + prvCheckDelayedTasks() - This will not get executed while the + scheduler is suspended. + + xTaskCreate() - Has a critical section around the access. + + vTaskResume() - Has a critical section around the access. + + xTaskResumeAll() - Has a critical section around the access. + + xTaskRemoveFromEventList - Checks to see if the scheduler is + suspended. If so then the TCB being removed from the event is + removed from the event and added to the xPendingReadyList. + */ + + /* Make sure interrupts do not access the queue event list. */ + prvLockQueue( pxQueue ); + + /* It is important that interrupts to not access the event list of the + queue being modified here. Places where the event list is modified + include: + + + xQueueGenericSendFromISR(). This checks the lock on the queue to see + if it has access. If the queue is locked then the Tx lock count is + incremented to signify that a task waiting for data can be made ready + once the queue lock is removed. If the queue is not locked then + a task can be moved from the event list, but will not be removed + from the delayed list or placed in the ready list until the scheduler + is unlocked. + + + xQueueReceiveFromISR(). As per xQueueGenericSendFromISR(). + */ + + /* If the queue is already full we may have to block. */ + do + { + if( prvIsQueueFull( pxQueue ) ) + { + /* The queue is full - do we want to block or just leave without + posting? */ + if( xTicksToWait > ( portTickType ) 0 ) + { + /* We are going to place ourselves on the xTasksWaitingToSend event + list, and will get woken should the delay expire, or space become + available on the queue. + + As detailed above we do not require mutual exclusion on the event + list as nothing else can modify it or the ready lists while we + have the scheduler suspended and queue locked. + + It is possible that an ISR has removed data from the queue since we + checked if any was available. If this is the case then the data + will have been copied from the queue, and the queue variables + updated, but the event list will not yet have been checked to see if + anything is waiting as the queue is locked. */ + vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToSend ), xTicksToWait ); + + /* Force a context switch now as we are blocked. We can do + this from within a critical section as the task we are + switching to has its own context. When we return here (i.e. we + unblock) we will leave the critical section as normal. + + It is possible that an ISR has caused an event on an unrelated and + unlocked queue. If this was the case then the event list for that + queue will have been updated but the ready lists left unchanged - + instead the readied task will have been added to the pending ready + list. */ + taskENTER_CRITICAL(); + { + /* We can safely unlock the queue and scheduler here as + interrupts are disabled. We must not yield with anything + locked, but we can yield from within a critical section. + + Tasks that have been placed on the pending ready list cannot + be tasks that are waiting for events on this queue. See + in comment xTaskRemoveFromEventList(). */ + prvUnlockQueue( pxQueue ); + + /* Resuming the scheduler may cause a yield. If so then there + is no point yielding again here. */ + if( !xTaskResumeAll() ) + { + taskYIELD(); + } + + /* We want to check to see if the queue is still full + before leaving the critical section. This is to prevent + this task placing an item into the queue due to an + interrupt making space on the queue between critical + sections (when there might be a higher priority task + blocked on the queue that cannot run yet because the + scheduler gets suspended). */ + if( pxQueue->uxMessagesWaiting == pxQueue->uxLength ) + { + /* We unblocked but there is no space in the queue, + we probably timed out. */ + xReturn = errQUEUE_FULL; + } + + /* Before leaving the critical section we have to ensure + exclusive access again. */ + vTaskSuspendAll(); + prvLockQueue( pxQueue ); + } + taskEXIT_CRITICAL(); + } + } + + /* If xReturn is errQUEUE_FULL then we unblocked when the queue + was still full. Don't check it again now as it is possible that + an interrupt has removed an item from the queue since we left the + critical section and we don't want to write to the queue in case + there is a task of higher priority blocked waiting for space to + be available on the queue. If this is the case the higher priority + task will execute when the scheduler is unsupended. */ + if( xReturn != errQUEUE_FULL ) + { + /* When we are here it is possible that we unblocked as space became + available on the queue. It is also possible that an ISR posted to the + queue since we left the critical section, so it may be that again there + is no space. This would only happen if a task and ISR post onto the + same queue. */ + taskENTER_CRITICAL(); + { + if( pxQueue->uxMessagesWaiting < pxQueue->uxLength ) + { + /* There is room in the queue, copy the data into the queue. */ + prvCopyDataToQueue( pxQueue, pvItemToQueue, xCopyPosition ); + xReturn = pdPASS; + + /* Update the TxLock count so prvUnlockQueue knows to check for + tasks waiting for data to become available in the queue. */ + ++( pxQueue->xTxLock ); + } + else + { + xReturn = errQUEUE_FULL; + } + } + taskEXIT_CRITICAL(); + } + + if( xReturn == errQUEUE_FULL ) + { + if( xTicksToWait > 0 ) + { + if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE ) + { + xReturn = queueERRONEOUS_UNBLOCK; + } + } + } + } + while( xReturn == queueERRONEOUS_UNBLOCK ); + + prvUnlockQueue( pxQueue ); + xTaskResumeAll(); + + return xReturn; +} +/*-----------------------------------------------------------*/ + +signed portBASE_TYPE xQueueGenericSendFromISR( xQueueHandle pxQueue, const void * const pvItemToQueue, signed portBASE_TYPE xTaskPreviouslyWoken, portBASE_TYPE xCopyPosition ) +{ + /* Similar to xQueueGenericSend, except we don't block if there is no room + in the queue. Also we don't directly wake a task that was blocked on a + queue read, instead we return a flag to say whether a context switch is + required or not (i.e. has a task with a higher priority than us been woken + by this post). */ + if( pxQueue->uxMessagesWaiting < pxQueue->uxLength ) + { + prvCopyDataToQueue( pxQueue, pvItemToQueue, xCopyPosition ); + + /* If the queue is locked we do not alter the event list. This will + be done when the queue is unlocked later. */ + if( pxQueue->xTxLock == queueUNLOCKED ) + { + /* We only want to wake one task per ISR, so check that a task has + not already been woken. */ + if( !xTaskPreviouslyWoken ) + { + if( !listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) ) + { + if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) + { + /* The task waiting has a higher priority so record that a + context switch is required. */ + return pdTRUE; + } + } + } + } + else + { + /* Increment the lock count so the task that unlocks the queue + knows that data was posted while it was locked. */ + ++( pxQueue->xTxLock ); + } + } + + return xTaskPreviouslyWoken; +} +/*-----------------------------------------------------------*/ + +signed portBASE_TYPE xQueueGenericReceive( xQueueHandle pxQueue, const void * const pvBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeeking ) +{ +signed portBASE_TYPE xReturn = pdTRUE; +xTimeOutType xTimeOut; +signed portCHAR *pcOriginalReadPosition; + + /* This function is very similar to xQueueGenericSend(). See comments + within xQueueGenericSend() for a more detailed explanation. + + Make sure other tasks do not access the queue. */ + vTaskSuspendAll(); + + /* Capture the current time status for future reference. */ + vTaskSetTimeOutState( &xTimeOut ); + + /* Make sure interrupts do not access the queue. */ + prvLockQueue( pxQueue ); + + do + { + /* If there are no messages in the queue we may have to block. */ + if( prvIsQueueEmpty( pxQueue ) ) + { + /* There are no messages in the queue, do we want to block or just + leave with nothing? */ + if( xTicksToWait > ( portTickType ) 0 ) + { + #if ( configUSE_MUTEXES == 1 ) + { + if( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX ) + { + portENTER_CRITICAL(); + vTaskPriorityInherit( ( void * const ) pxQueue->pxMutexHolder ); + portEXIT_CRITICAL(); + } + } + #endif + + vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToReceive ), xTicksToWait ); + taskENTER_CRITICAL(); + { + prvUnlockQueue( pxQueue ); + if( !xTaskResumeAll() ) + { + taskYIELD(); + } + + if( pxQueue->uxMessagesWaiting == ( unsigned portBASE_TYPE ) 0 ) + { + /* We unblocked but the queue is empty. We probably + timed out. */ + xReturn = errQUEUE_EMPTY; + } + + vTaskSuspendAll(); + prvLockQueue( pxQueue ); + } + taskEXIT_CRITICAL(); + } + } + + if( xReturn != errQUEUE_EMPTY ) + { + taskENTER_CRITICAL(); + { + if( pxQueue->uxMessagesWaiting > ( unsigned portBASE_TYPE ) 0 ) + { + /* Remember our read position in case we are just peeking. */ + pcOriginalReadPosition = pxQueue->pcReadFrom; + + prvCopyDataFromQueue( pxQueue, pvBuffer ); + + if( xJustPeeking == pdFALSE ) + { + /* We are actually removing data. */ + --( pxQueue->uxMessagesWaiting ); + + /* Increment the lock count so prvUnlockQueue knows to check for + tasks waiting for space to become available on the queue. */ + ++( pxQueue->xRxLock ); + + #if ( configUSE_MUTEXES == 1 ) + { + if( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX ) + { + /* Record the information required to implement + priority inheritance should it become necessary. */ + pxQueue->pxMutexHolder = xTaskGetCurrentTaskHandle(); + } + } + #endif + } + else + { + /* We are not removing the data, so reset our read + pointer. */ + pxQueue->pcReadFrom = pcOriginalReadPosition; + + /* The data is being left in the queue, so increment the + lock count so prvUnlockQueue knows to check for other + tasks waiting for the data to be available. */ + ++( pxQueue->xTxLock ); + } + + xReturn = pdPASS; + } + else + { + xReturn = errQUEUE_EMPTY; + } + } + taskEXIT_CRITICAL(); + } + + if( xReturn == errQUEUE_EMPTY ) + { + if( xTicksToWait > 0 ) + { + if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE ) + { + xReturn = queueERRONEOUS_UNBLOCK; + } + } + } + } while( xReturn == queueERRONEOUS_UNBLOCK ); + + /* We no longer require exclusive access to the queue. */ + prvUnlockQueue( pxQueue ); + xTaskResumeAll(); + + return xReturn; +} +/*-----------------------------------------------------------*/ + +signed portBASE_TYPE xQueueReceiveFromISR( xQueueHandle pxQueue, const void * const pvBuffer, signed portBASE_TYPE *pxTaskWoken ) +{ +signed portBASE_TYPE xReturn; + + /* We cannot block from an ISR, so check there is data available. */ + if( pxQueue->uxMessagesWaiting > ( unsigned portBASE_TYPE ) 0 ) + { + prvCopyDataFromQueue( pxQueue, pvBuffer ); + --( pxQueue->uxMessagesWaiting ); + + /* If the queue is locked we will not modify the event list. Instead + we update the lock count so the task that unlocks the queue will know + that an ISR has removed data while the queue was locked. */ + if( pxQueue->xRxLock == queueUNLOCKED ) + { + /* We only want to wake one task per ISR, so check that a task has + not already been woken. */ + if( !( *pxTaskWoken ) ) + { + if( !listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) ) + { + if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE ) + { + /* The task waiting has a higher priority than us so + force a context switch. */ + *pxTaskWoken = pdTRUE; + } + } + } + } + else + { + /* Increment the lock count so the task that unlocks the queue + knows that data was removed while it was locked. */ + ++( pxQueue->xRxLock ); + } + + xReturn = pdPASS; + } + else + { + xReturn = pdFAIL; + } + + return xReturn; +} +/*-----------------------------------------------------------*/ + +unsigned portBASE_TYPE uxQueueMessagesWaiting( const xQueueHandle pxQueue ) +{ +unsigned portBASE_TYPE uxReturn; + + taskENTER_CRITICAL(); + uxReturn = pxQueue->uxMessagesWaiting; + taskEXIT_CRITICAL(); + + return uxReturn; +} +/*-----------------------------------------------------------*/ + +void vQueueDelete( xQueueHandle pxQueue ) +{ + vPortFree( pxQueue->pcHead ); + vPortFree( pxQueue ); +} +/*-----------------------------------------------------------*/ + +static void prvCopyDataToQueue( xQUEUE *pxQueue, const void *pvItemToQueue, portBASE_TYPE xPosition ) +{ + if( pxQueue->uxItemSize == 0 ) + { + #if ( configUSE_MUTEXES == 1 ) + { + if( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX ) + { + /* The mutex is no longer being held. */ + vTaskPriorityDisinherit( ( void * const ) pxQueue->pxMutexHolder ); + } + } + #endif + } + else if( xPosition == queueSEND_TO_BACK ) + { + memcpy( ( void * ) pxQueue->pcWriteTo, pvItemToQueue, ( unsigned ) pxQueue->uxItemSize ); + pxQueue->pcWriteTo += pxQueue->uxItemSize; + if( pxQueue->pcWriteTo >= pxQueue->pcTail ) + { + pxQueue->pcWriteTo = pxQueue->pcHead; + } + } + else + { + memcpy( ( void * ) pxQueue->pcReadFrom, pvItemToQueue, ( unsigned ) pxQueue->uxItemSize ); + pxQueue->pcReadFrom -= pxQueue->uxItemSize; + if( pxQueue->pcReadFrom < pxQueue->pcHead ) + { + pxQueue->pcReadFrom = ( pxQueue->pcTail - pxQueue->uxItemSize ); + } + } + + ++( pxQueue->uxMessagesWaiting ); +} +/*-----------------------------------------------------------*/ + +static void prvCopyDataFromQueue( xQUEUE * const pxQueue, const void *pvBuffer ) +{ + if( pxQueue->uxQueueType != queueQUEUE_IS_MUTEX ) + { + pxQueue->pcReadFrom += pxQueue->uxItemSize; + if( pxQueue->pcReadFrom >= pxQueue->pcTail ) + { + pxQueue->pcReadFrom = pxQueue->pcHead; + } + memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->pcReadFrom, ( unsigned ) pxQueue->uxItemSize ); + } +} +/*-----------------------------------------------------------*/ + +static void prvUnlockQueue( xQueueHandle pxQueue ) +{ + /* THIS FUNCTION MUST BE CALLED WITH THE SCHEDULER SUSPENDED. */ + + /* The lock counts contains the number of extra data items placed or + removed from the queue while the queue was locked. When a queue is + locked items can be added or removed, but the event lists cannot be + updated. */ + taskENTER_CRITICAL(); + { + --( pxQueue->xTxLock ); + + /* See if data was added to the queue while it was locked. */ + if( pxQueue->xTxLock > queueUNLOCKED ) + { + pxQueue->xTxLock = queueUNLOCKED; + + /* Data was posted while the queue was locked. Are any tasks + blocked waiting for data to become available? */ + if( !listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) ) + { + /* Tasks that are removed from the event list will get added to + the pending ready list as the scheduler is still suspended. */ + if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) + { + /* The task waiting has a higher priority so record that a + context switch is required. */ + vTaskMissedYield(); + } + } + } + } + taskEXIT_CRITICAL(); + + /* Do the same for the Rx lock. */ + taskENTER_CRITICAL(); + { + --( pxQueue->xRxLock ); + + if( pxQueue->xRxLock > queueUNLOCKED ) + { + pxQueue->xRxLock = queueUNLOCKED; + + if( !listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) ) + { + if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE ) + { + vTaskMissedYield(); + } + } + } + } + taskEXIT_CRITICAL(); +} +/*-----------------------------------------------------------*/ + +static signed portBASE_TYPE prvIsQueueEmpty( const xQueueHandle pxQueue ) +{ +signed portBASE_TYPE xReturn; + + taskENTER_CRITICAL(); + xReturn = ( pxQueue->uxMessagesWaiting == ( unsigned portBASE_TYPE ) 0 ); + taskEXIT_CRITICAL(); + + return xReturn; +} +/*-----------------------------------------------------------*/ + +static signed portBASE_TYPE prvIsQueueFull( const xQueueHandle pxQueue ) +{ +signed portBASE_TYPE xReturn; + + taskENTER_CRITICAL(); + xReturn = ( pxQueue->uxMessagesWaiting == pxQueue->uxLength ); + taskEXIT_CRITICAL(); + + return xReturn; +} +/*-----------------------------------------------------------*/ + +#if configUSE_CO_ROUTINES == 1 +signed portBASE_TYPE xQueueCRSend( xQueueHandle pxQueue, const void *pvItemToQueue, portTickType xTicksToWait ) +{ +signed portBASE_TYPE xReturn; + + /* If the queue is already full we may have to block. A critical section + is required to prevent an interrupt removing something from the queue + between the check to see if the queue is full and blocking on the queue. */ + portDISABLE_INTERRUPTS(); + { + if( prvIsQueueFull( pxQueue ) ) + { + /* The queue is full - do we want to block or just leave without + posting? */ + if( xTicksToWait > ( portTickType ) 0 ) + { + /* As this is called from a coroutine we cannot block directly, but + return indicating that we need to block. */ + vCoRoutineAddToDelayedList( xTicksToWait, &( pxQueue->xTasksWaitingToSend ) ); + portENABLE_INTERRUPTS(); + return errQUEUE_BLOCKED; + } + else + { + portENABLE_INTERRUPTS(); + return errQUEUE_FULL; + } + } + } + portENABLE_INTERRUPTS(); + + portNOP(); + + portDISABLE_INTERRUPTS(); + { + if( pxQueue->uxMessagesWaiting < pxQueue->uxLength ) + { + /* There is room in the queue, copy the data into the queue. */ + prvCopyDataToQueue( pxQueue, pvItemToQueue, queueSEND_TO_BACK ); + xReturn = pdPASS; + + /* Were any co-routines waiting for data to become available? */ + if( !listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) ) + { + /* In this instance the co-routine could be placed directly + into the ready list as we are within a critical section. + Instead the same pending ready list mechanism is used as if + the event were caused from within an interrupt. */ + if( xCoRoutineRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) + { + /* The co-routine waiting has a higher priority so record + that a yield might be appropriate. */ + xReturn = errQUEUE_YIELD; + } + } + } + else + { + xReturn = errQUEUE_FULL; + } + } + portENABLE_INTERRUPTS(); + + return xReturn; +} +#endif +/*-----------------------------------------------------------*/ + +#if configUSE_CO_ROUTINES == 1 +signed portBASE_TYPE xQueueCRReceive( xQueueHandle pxQueue, void *pvBuffer, portTickType xTicksToWait ) +{ +signed portBASE_TYPE xReturn; + + /* If the queue is already empty we may have to block. A critical section + is required to prevent an interrupt adding something to the queue + between the check to see if the queue is empty and blocking on the queue. */ + portDISABLE_INTERRUPTS(); + { + if( pxQueue->uxMessagesWaiting == ( unsigned portBASE_TYPE ) 0 ) + { + /* There are no messages in the queue, do we want to block or just + leave with nothing? */ + if( xTicksToWait > ( portTickType ) 0 ) + { + /* As this is a co-routine we cannot block directly, but return + indicating that we need to block. */ + vCoRoutineAddToDelayedList( xTicksToWait, &( pxQueue->xTasksWaitingToReceive ) ); + portENABLE_INTERRUPTS(); + return errQUEUE_BLOCKED; + } + else + { + portENABLE_INTERRUPTS(); + return errQUEUE_FULL; + } + } + } + portENABLE_INTERRUPTS(); + + portNOP(); + + portDISABLE_INTERRUPTS(); + { + if( pxQueue->uxMessagesWaiting > ( unsigned portBASE_TYPE ) 0 ) + { + /* Data is available from the queue. */ + pxQueue->pcReadFrom += pxQueue->uxItemSize; + if( pxQueue->pcReadFrom >= pxQueue->pcTail ) + { + pxQueue->pcReadFrom = pxQueue->pcHead; + } + --( pxQueue->uxMessagesWaiting ); + memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->pcReadFrom, ( unsigned ) pxQueue->uxItemSize ); + + xReturn = pdPASS; + + /* Were any co-routines waiting for space to become available? */ + if( !listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) ) + { + /* In this instance the co-routine could be placed directly + into the ready list as we are within a critical section. + Instead the same pending ready list mechanism is used as if + the event were caused from within an interrupt. */ + if( xCoRoutineRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE ) + { + xReturn = errQUEUE_YIELD; + } + } + } + else + { + xReturn = pdFAIL; + } + } + portENABLE_INTERRUPTS(); + + return xReturn; +} +#endif +/*-----------------------------------------------------------*/ + + + +#if configUSE_CO_ROUTINES == 1 +signed portBASE_TYPE xQueueCRSendFromISR( xQueueHandle pxQueue, const void *pvItemToQueue, signed portBASE_TYPE xCoRoutinePreviouslyWoken ) +{ + /* Cannot block within an ISR so if there is no space on the queue then + exit without doing anything. */ + if( pxQueue->uxMessagesWaiting < pxQueue->uxLength ) + { + prvCopyDataToQueue( pxQueue, pvItemToQueue, queueSEND_TO_BACK ); + + /* We only want to wake one co-routine per ISR, so check that a + co-routine has not already been woken. */ + if( !xCoRoutinePreviouslyWoken ) + { + if( !listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) ) + { + if( xCoRoutineRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) + { + return pdTRUE; + } + } + } + } + + return xCoRoutinePreviouslyWoken; +} +#endif +/*-----------------------------------------------------------*/ + +#if configUSE_CO_ROUTINES == 1 +signed portBASE_TYPE xQueueCRReceiveFromISR( xQueueHandle pxQueue, void *pvBuffer, signed portBASE_TYPE *pxCoRoutineWoken ) +{ +signed portBASE_TYPE xReturn; + + /* We cannot block from an ISR, so check there is data available. If + not then just leave without doing anything. */ + if( pxQueue->uxMessagesWaiting > ( unsigned portBASE_TYPE ) 0 ) + { + /* Copy the data from the queue. */ + pxQueue->pcReadFrom += pxQueue->uxItemSize; + if( pxQueue->pcReadFrom >= pxQueue->pcTail ) + { + pxQueue->pcReadFrom = pxQueue->pcHead; + } + --( pxQueue->uxMessagesWaiting ); + memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->pcReadFrom, ( unsigned ) pxQueue->uxItemSize ); + + if( !( *pxCoRoutineWoken ) ) + { + if( !listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) ) + { + if( xCoRoutineRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE ) + { + *pxCoRoutineWoken = pdTRUE; + } + } + } + + xReturn = pdPASS; + } + else + { + xReturn = pdFAIL; + } + + return xReturn; +} +#endif +/*-----------------------------------------------------------*/ + diff --git a/Tester/SW/lib/FreeRTOS/Source/readme.txt b/Tester/SW/lib/FreeRTOS/Source/readme.txt new file mode 100644 index 0000000..01a8781 --- /dev/null +++ b/Tester/SW/lib/FreeRTOS/Source/readme.txt @@ -0,0 +1,15 @@ +Each real time kernel port consists of three files that contain the core kernel +components and are common to every port, and one or more files that are +specific to a particular microcontroller and or compiler. + ++ The FreeRTOS/Source directory contains the three files that are common to +every port. The kernel is contained within these three files. + ++ The FreeRTOS/Source/Portable directory contains the files that are specific to +a particular microcontroller and or compiler. + ++ The FreeRTOS/Source/include directory contains the real time kernel header +files. + +See the readme file in the FreeRTOS/Source/Portable directory for more +information. \ No newline at end of file diff --git a/Tester/SW/lib/FreeRTOS/Source/tasks.c b/Tester/SW/lib/FreeRTOS/Source/tasks.c new file mode 100644 index 0000000..fb7476e --- /dev/null +++ b/Tester/SW/lib/FreeRTOS/Source/tasks.c @@ -0,0 +1,2036 @@ +/* + FreeRTOS.org V4.6.1 - Copyright (C) 2003-2007 Richard Barry. + + This file is part of the FreeRTOS.org distribution. + + FreeRTOS.org is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + FreeRTOS.org is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with FreeRTOS.org; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + A special exception to the GPL can be applied should you wish to distribute + a combined work that includes FreeRTOS.org, without being obliged to provide + the source code for any proprietary components. See the licensing section + of http://www.FreeRTOS.org for full details of how and when the exception + can be applied. + + *************************************************************************** + See http://www.FreeRTOS.org for documentation, latest information, license + and contact details. Please ensure to read the configuration and relevant + port sections of the online documentation. + + Also see http://www.SafeRTOS.com a version that has been certified for use + in safety critical systems, plus commercial licensing, development and + support options. + *************************************************************************** +*/ + +/* +Changes from V1.00: + + + Call to portRESTORE_CONTEXT has been removed. The first context + switch is now performed within sPortStartScheduler(). + +Changes from V1.01: + + + More use of 8bit data types. + + Function name prefixes changed where the data type returned has changed. + + configUSE_TRACE_FACILITY is no longer defined by default. + +Changes from V1.2.0 + + + Introduced ucTopReadyPriority. This tracks the highest priority ready + queue that contains a valid TCB and thus makes the context switch + slightly faster. + + + prvAddTaskToReadyQueue() has been made a macro. + +Changes from V1.2.6 + + + Added conditional compilation directives. + + Extended API. + + Rearranged function order. + + Creating a task now causes a context switch if the task being created + has a higher priority than the calling task - assuming the kernel is + running. + + vTaskDelete() now only causes a context switch if the calling task is + the task being deleted. + +Changes from V2.0.0 + + + Allow the type of the tick count to be 16 or 32 bits. + + Introduce xPendingReadyList feature to allow the time interrupts have to + be disabled to be minimised. + + Remove the #if( INCLUDE_vTaskSuspendAll ) statements. vTaskSuspendAll() + is now always included as it is used by the scheduler itself. + +Changes from V2.1.0 + + + Bug fix - pxCurrentTCB is now initialised before the call to + prvInitializeTaskLists(). Previously pxCurrentTCB could be accessed + while null. + +Changed from V2.1.1 + + + Change to where lStackSize is declared within sTaskCreate() to prevent + compiler warnings with 8051 port. + +Changes from V2.2.0 + + + Explicit use of 'signed' qualifier on portCHAR types added. + + Changed odd calculation of initial pxTopOfStack value when + portSTACK_GROWTH < 0. + + Removed pcVersionNumber definition. + +Changes from V2.5.3 + + + cTaskResumeAll() modified to ensure it can be called prior to the task + lists being initialised. + +Changes from V2.5.5 + + + Added API function vTaskDelayUntil(). + + Added INCLUDE_vTaskDelay conditional compilation. + +Changes from V2.6.0 + + + Updated the vWriteTraceToBuffer macro to always be 4 byte aligned so it + can be used on ARM architectures. + + tskMAX_TASK_NAME_LEN definition replaced with the port specific + configMAX_TASK_NAME_LEN definition. + + Removed the call to strcpy when copying across the task name into the + TCB. + + Added ucTasksDeleted variable to prevent vTaskSuspendAll() being called + too often in the idle task. + +Changes between V3.0.0 and V2.6.1 + + + When resuming the scheduler a yield is performed if either a tick has + been missed, or a task is moved from the pending ready list into a ready + list. Previously a yield was not performed on this second condition. + + Introduced the type portBASE_TYPE. This necessitates several API + changes. + + Removed the sUsingPreemption variable. The constant defined in + portmacro.h is now used directly. + + The idle task can now include an optional hook function - and no longer + completes its time slice if other tasks with equal priority to it are + ready to run. + + See the FreeRTOS.org documentation for more information on V2.x.x to + V3.x.x modifications. + +Changes from V3.1.1 + + + Modified vTaskPrioritySet() and vTaskResume() to allow these functions to + be called while the scheduler is suspended. + + Corrected the task ordering within event lists. + +Changes from V3.2.0 + + + Added function xTaskGetCurrentTaskHandle(). + +Changes from V3.2.4 + + + Changed the volatile declarations on some variables to reflect the + changes to the list definitions. + + Changed the order of the TCB definition so there is commonality between + the task control block and a co-routine control block. + + Allow the scheduler to be started even if no tasks other than the idle + task has been created. This allows co-routines to run even when no tasks + have been created. + + The need for a context switch is now signalled if a task woken by an + event has a priority greater or equal to the currently running task. + Previously this was only greater than. + +Changes from V4.0.0 + + + Added the xMissedYield handling. + +Changes from V4.0.1 + + + The function vTaskList() now suspends the scheduler rather than disabling + interrupts during the creation of the task list. + + Allow a task to delete itself by passing in its own handle. Previously + this could only be done by passing in NULL. + + The tick hook function is now called only within a tick isr. Previously + it was also called when the tick function was called during the scheduler + unlocking process. + +Changes from V4.0.3 + + + Extra checks have been placed in vTaskPrioritySet() to avoid unnecessary + yields. + +Changed from V4.0.4 + + + Bug fix: The 'value' of the event list item is updated when the priority + of a task is changed. Previously only the priority of the TCB itself was + changed. + + When resuming a task a check is first made to see if the task is actually + suspended. + + vTaskPrioritySet() and vTaskResume() no longer use the event list item. + This has not been necessary since V4.0.1 when the xMissedYield handling + was added. + + Implement xTaskResumeFromISR(). + +Changes from V4.0.5 + + + Added utility functions and xOverflowCount variable to facilitate the + queue.c changes. + +Changes from V4.1.2 + + + Tasks that block on events with a timeout of portMAX_DELAY are now + blocked indefinitely if configINCLUDE_vTaskSuspend is defined. + Previously portMAX_DELAY was just the longest block time possible. + +Changes from V4.1.3 + + + Very small change made to xTaskCheckForTimeout() as a result of the + SafeRTOS testing. This corrects the case where the function can return an + invalid value - but only in an extremely unlikely scenario. + +Changes since V4.3.1: + + + Added xTaskGetSchedulerState() function. + + Added prvIsTaskSuspended() to take into account the Occurrence of + vTaskResume() or vTaskResumeFromISR() being called passing in the + handle of a task that appears in the Suspended list only because it + is blocked on an event without a timeout being specified. + + Updated xTaskCheckForTimeout() to take into account that tasks blocked + using the Suspended list should never time out. +*/ + +#include +#include +#include + +#include "FreeRTOS.h" +#include "task.h" + +/* + * Macro to define the amount of stack available to the idle task. + */ +#define tskIDLE_STACK_SIZE configMINIMAL_STACK_SIZE + + +/* + * Default a definitions for backwards compatibility with old + * portmacro.h files. + */ +#ifndef configMAX_TASK_NAME_LEN + #define configMAX_TASK_NAME_LEN 16 +#endif + +#ifndef configIDLE_SHOULD_YIELD + #define configIDLE_SHOULD_YIELD 1 +#endif + +#if configMAX_TASK_NAME_LEN < 1 + #undef configMAX_TASK_NAME_LEN + #define configMAX_TASK_NAME_LEN 1 +#endif + +#ifndef INCLUDE_xTaskResumeFromISR + #define INCLUDE_xTaskResumeFromISR 1 +#endif + +#ifndef INCLUDE_xTaskGetSchedulerState + #define INCLUDE_xTaskGetSchedulerState 0 +#endif + +/* + * Task control block. A task control block (TCB) is allocated to each task, + * and stores the context of the task. + */ +typedef struct tskTaskControlBlock +{ + volatile portSTACK_TYPE *pxTopOfStack; /*< Points to the location of the last item placed on the tasks stack. THIS MUST BE THE FIRST MEMBER OF THE STRUCT. */ + xListItem xGenericListItem; /*< List item used to place the TCB in ready and blocked queues. */ + xListItem xEventListItem; /*< List item used to place the TCB in event lists. */ + unsigned portBASE_TYPE uxPriority; /*< The priority of the task where 0 is the lowest priority. */ + portSTACK_TYPE *pxStack; /*< Points to the start of the stack. */ + signed portCHAR pcTaskName[ configMAX_TASK_NAME_LEN ];/*< Descriptive name given to the task when created. Facilitates debugging only. */ + + #if ( configUSE_TRACE_FACILITY == 1 ) + unsigned portBASE_TYPE uxTCBNumber; /*< This is used for tracing the scheduler and making debugging easier only. */ + #endif + + #if ( configUSE_MUTEXES == 1 ) + unsigned portBASE_TYPE uxBasePriority; + #endif + +} tskTCB; + +/*lint -e956 */ + +tskTCB * volatile pxCurrentTCB = NULL; + +/* Lists for ready and blocked tasks. --------------------*/ + +static xList pxReadyTasksLists[ configMAX_PRIORITIES ]; /*< Prioritised ready tasks. */ +static xList xDelayedTaskList1; /*< Delayed tasks. */ +static xList xDelayedTaskList2; /*< Delayed tasks (two lists are used - one for delays that have overflowed the current tick count. */ +static xList * volatile pxDelayedTaskList; /*< Points to the delayed task list currently being used. */ +static xList * volatile pxOverflowDelayedTaskList; /*< Points to the delayed task list currently being used to hold tasks that have overflowed the current tick count. */ +static xList xPendingReadyList; /*< Tasks that have been readied while the scheduler was suspended. They will be moved to the ready queue when the scheduler is resumed. */ + +#if ( INCLUDE_vTaskDelete == 1 ) + + static volatile xList xTasksWaitingTermination; /*< Tasks that have been deleted - but the their memory not yet freed. */ + static volatile unsigned portBASE_TYPE uxTasksDeleted = ( unsigned portBASE_TYPE ) 0; + +#endif + +#if ( INCLUDE_vTaskSuspend == 1 ) + + static xList xSuspendedTaskList; /*< Tasks that are currently suspended. */ + +#endif + +/* File private variables. --------------------------------*/ +static volatile unsigned portBASE_TYPE uxCurrentNumberOfTasks = ( unsigned portBASE_TYPE ) 0; +static volatile portTickType xTickCount = ( portTickType ) 0; +static unsigned portBASE_TYPE uxTopUsedPriority = tskIDLE_PRIORITY; +static volatile unsigned portBASE_TYPE uxTopReadyPriority = tskIDLE_PRIORITY; +static volatile signed portBASE_TYPE xSchedulerRunning = pdFALSE; +static volatile unsigned portBASE_TYPE uxSchedulerSuspended = ( unsigned portBASE_TYPE ) pdFALSE; +static volatile unsigned portBASE_TYPE uxMissedTicks = ( unsigned portBASE_TYPE ) 0; +static volatile portBASE_TYPE xMissedYield = ( portBASE_TYPE ) pdFALSE; +static volatile portBASE_TYPE xNumOfOverflows = ( portBASE_TYPE ) 0; +/* Debugging and trace facilities private variables and macros. ------------*/ + +/* + * The value used to fill the stack of a task when the task is created. This + * is used purely for checking the high water mark for tasks. + */ +#define tskSTACK_FILL_BYTE ( 0xa5 ) + +/* + * Macros used by vListTask to indicate which state a task is in. + */ +#define tskBLOCKED_CHAR ( ( signed portCHAR ) 'B' ) +#define tskREADY_CHAR ( ( signed portCHAR ) 'R' ) +#define tskDELETED_CHAR ( ( signed portCHAR ) 'D' ) +#define tskSUSPENDED_CHAR ( ( signed portCHAR ) 'S' ) + +/* + * Macros and private variables used by the trace facility. + */ +#if ( configUSE_TRACE_FACILITY == 1 ) + + #define tskSIZE_OF_EACH_TRACE_LINE ( ( unsigned portLONG ) ( sizeof( unsigned portLONG ) + sizeof( unsigned portLONG ) ) ) + static volatile signed portCHAR * volatile pcTraceBuffer; + static signed portCHAR *pcTraceBufferStart; + static signed portCHAR *pcTraceBufferEnd; + static signed portBASE_TYPE xTracing = pdFALSE; + +#endif + +/* + * Macro that writes a trace of scheduler activity to a buffer. This trace + * shows which task is running when and is very useful as a debugging tool. + * As this macro is called each context switch it is a good idea to undefine + * it if not using the facility. + */ +#if ( configUSE_TRACE_FACILITY == 1 ) + + #define vWriteTraceToBuffer() \ + { \ + if( xTracing ) \ + { \ + static unsigned portBASE_TYPE uxPreviousTask = 255; \ + \ + if( uxPreviousTask != pxCurrentTCB->uxTCBNumber ) \ + { \ + if( ( pcTraceBuffer + tskSIZE_OF_EACH_TRACE_LINE ) < pcTraceBufferEnd ) \ + { \ + uxPreviousTask = pxCurrentTCB->uxTCBNumber; \ + *( unsigned portLONG * ) pcTraceBuffer = ( unsigned portLONG ) xTickCount; \ + pcTraceBuffer += sizeof( unsigned portLONG ); \ + *( unsigned portLONG * ) pcTraceBuffer = ( unsigned portLONG ) uxPreviousTask; \ + pcTraceBuffer += sizeof( unsigned portLONG ); \ + } \ + else \ + { \ + xTracing = pdFALSE; \ + } \ + } \ + } \ + } + +#else + + #define vWriteTraceToBuffer() + +#endif + + +/* + * Place the task represented by pxTCB into the appropriate ready queue for + * the task. It is inserted at the end of the list. One quirk of this is + * that if the task being inserted is at the same priority as the currently + * executing task, then it will only be rescheduled after the currently + * executing task has been rescheduled. + */ +#define prvAddTaskToReadyQueue( pxTCB ) \ +{ \ + if( pxTCB->uxPriority > uxTopReadyPriority ) \ + { \ + uxTopReadyPriority = pxTCB->uxPriority; \ + } \ + vListInsertEnd( ( xList * ) &( pxReadyTasksLists[ pxTCB->uxPriority ] ), &( pxTCB->xGenericListItem ) ); \ +} + +/* + * Macro that looks at the list of tasks that are currently delayed to see if + * any require waking. + * + * Tasks are stored in the queue in the order of their wake time - meaning + * once one tasks has been found whose timer has not expired we need not look + * any further down the list. + */ +#define prvCheckDelayedTasks() \ +{ \ +register tskTCB *pxTCB; \ + \ + while( ( pxTCB = ( tskTCB * ) listGET_OWNER_OF_HEAD_ENTRY( pxDelayedTaskList ) ) != NULL ) \ + { \ + if( xTickCount < listGET_LIST_ITEM_VALUE( &( pxTCB->xGenericListItem ) ) ) \ + { \ + break; \ + } \ + vListRemove( &( pxTCB->xGenericListItem ) ); \ + /* Is the task waiting on an event also? */ \ + if( pxTCB->xEventListItem.pvContainer ) \ + { \ + vListRemove( &( pxTCB->xEventListItem ) ); \ + } \ + prvAddTaskToReadyQueue( pxTCB ); \ + } \ +} + +/* + * Several functions take an xTaskHandle parameter that can optionally be NULL, + * where NULL is used to indicate that the handle of the currently executing + * task should be used in place of the parameter. This macro simply checks to + * see if the parameter is NULL and returns a pointer to the appropriate TCB. + */ +#define prvGetTCBFromHandle( pxHandle ) ( ( pxHandle == NULL ) ? ( tskTCB * ) pxCurrentTCB : ( tskTCB * ) pxHandle ) + + +/* File private functions. --------------------------------*/ + +/* + * Utility to ready a TCB for a given task. Mainly just copies the parameters + * into the TCB structure. + */ +static void prvInitialiseTCBVariables( tskTCB *pxTCB, const signed portCHAR * const pcName, unsigned portBASE_TYPE uxPriority ); + +/* + * Utility to ready all the lists used by the scheduler. This is called + * automatically upon the creation of the first task. + */ +static void prvInitialiseTaskLists( void ); + +/* + * The idle task, which as all tasks is implemented as a never ending loop. + * The idle task is automatically created and added to the ready lists upon + * creation of the first user task. + * + * The portTASK_FUNCTION_PROTO() macro is used to allow port/compiler specific + * language extensions. The equivalent prototype for this function is: + * + * void prvIdleTask( void *pvParameters ); + * + */ +static portTASK_FUNCTION_PROTO( prvIdleTask, pvParameters ); + +/* + * Utility to free all memory allocated by the scheduler to hold a TCB, + * including the stack pointed to by the TCB. + * + * This does not free memory allocated by the task itself (i.e. memory + * allocated by calls to pvPortMalloc from within the tasks application code). + */ +#if ( ( INCLUDE_vTaskDelete == 1 ) || ( INCLUDE_vTaskCleanUpResources == 1 ) ) + static void prvDeleteTCB( tskTCB *pxTCB ); +#endif + +/* + * Used only by the idle task. This checks to see if anything has been placed + * in the list of tasks waiting to be deleted. If so the task is cleaned up + * and its TCB deleted. + */ +static void prvCheckTasksWaitingTermination( void ); + +/* + * Allocates memory from the heap for a TCB and associated stack. Checks the + * allocation was successful. + */ +static tskTCB *prvAllocateTCBAndStack( unsigned portSHORT usStackDepth ); + +/* + * Called from vTaskList. vListTasks details all the tasks currently under + * control of the scheduler. The tasks may be in one of a number of lists. + * prvListTaskWithinSingleList accepts a list and details the tasks from + * within just that list. + * + * THIS FUNCTION IS INTENDED FOR DEBUGGING ONLY, AND SHOULD NOT BE CALLED FROM + * NORMAL APPLICATION CODE. + */ +#if ( configUSE_TRACE_FACILITY == 1 ) + + static void prvListTaskWithinSingleList( const signed portCHAR *pcWriteBuffer, xList *pxList, signed portCHAR cStatus ); + +#endif + +/* + * When a task is created, the stack of the task is filled with a known value. + * This function determines the 'high water mark' of the task stack by + * determining how much of the stack remains at the original preset value. + */ +#if ( configUSE_TRACE_FACILITY == 1 ) + + unsigned portSHORT usTaskCheckFreeStackSpace( const unsigned portCHAR * pucStackByte ); + +#endif + +/* + * Checks that a task being resumed (unsuspended) is actually in the Suspended + * state. + */ +#if ( INCLUDE_vTaskSuspend == 1 ) + + static portBASE_TYPE prvIsTaskSuspended( const tskTCB * const pxTCB ); + +#endif + +/*lint +e956 */ + + + + + +/*----------------------------------------------------------- + * TASK CREATION API documented in task.h + *----------------------------------------------------------*/ + +signed portBASE_TYPE xTaskCreate( pdTASK_CODE pvTaskCode, const signed portCHAR * const pcName, unsigned portSHORT usStackDepth, void *pvParameters, unsigned portBASE_TYPE uxPriority, xTaskHandle *pxCreatedTask ) +{ +signed portBASE_TYPE xReturn; +tskTCB * pxNewTCB; +#if ( configUSE_TRACE_FACILITY == 1 ) + static unsigned portBASE_TYPE uxTaskNumber = 0; /*lint !e956 Static is deliberate - this is guarded before use. */ +#endif + + /* Allocate the memory required by the TCB and stack for the new task. + checking that the allocation was successful. */ + pxNewTCB = prvAllocateTCBAndStack( usStackDepth ); + + if( pxNewTCB != NULL ) + { + portSTACK_TYPE *pxTopOfStack; + + /* Setup the newly allocated TCB with the initial state of the task. */ + prvInitialiseTCBVariables( pxNewTCB, pcName, uxPriority ); + + /* Calculate the top of stack address. This depends on whether the + stack grows from high memory to low (as per the 80x86) or visa versa. + portSTACK_GROWTH is used to make the result positive or negative as + required by the port. */ + #if portSTACK_GROWTH < 0 + { + pxTopOfStack = pxNewTCB->pxStack + ( usStackDepth - 1 ); + } + #else + { + pxTopOfStack = pxNewTCB->pxStack; + } + #endif + + /* Initialize the TCB stack to look as if the task was already running, + but had been interrupted by the scheduler. The return address is set + to the start of the task function. Once the stack has been initialised + the top of stack variable is updated. */ + pxNewTCB->pxTopOfStack = pxPortInitialiseStack( pxTopOfStack, pvTaskCode, pvParameters ); + + /* We are going to manipulate the task queues to add this task to a + ready list, so must make sure no interrupts occur. */ + portENTER_CRITICAL(); + { + uxCurrentNumberOfTasks++; + if( uxCurrentNumberOfTasks == ( unsigned portBASE_TYPE ) 1 ) + { + /* As this is the first task it must also be the current task. */ + pxCurrentTCB = pxNewTCB; + + /* This is the first task to be created so do the preliminary + initialisation required. We will not recover if this call + fails, but we will report the failure. */ + prvInitialiseTaskLists(); + } + else + { + /* If the scheduler is not already running, make this task the + current task if it is the highest priority task to be created + so far. */ + if( xSchedulerRunning == pdFALSE ) + { + if( pxCurrentTCB->uxPriority <= uxPriority ) + { + pxCurrentTCB = pxNewTCB; + } + } + } + + /* Remember the top priority to make context switching faster. Use + the priority in pxNewTCB as this has been capped to a valid value. */ + if( pxNewTCB->uxPriority > uxTopUsedPriority ) + { + uxTopUsedPriority = pxNewTCB->uxPriority; + } + + #if ( configUSE_TRACE_FACILITY == 1 ) + { + /* Add a counter into the TCB for tracing only. */ + pxNewTCB->uxTCBNumber = uxTaskNumber; + uxTaskNumber++; + } + #endif + + prvAddTaskToReadyQueue( pxNewTCB ); + + xReturn = pdPASS; + } + portEXIT_CRITICAL(); + } + else + { + xReturn = errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY; + } + + if( xReturn == pdPASS ) + { + if( ( void * ) pxCreatedTask != NULL ) + { + /* Pass the TCB out - in an anonymous way. The calling function/ + task can use this as a handle to delete the task later if + required.*/ + *pxCreatedTask = ( xTaskHandle ) pxNewTCB; + } + + if( xSchedulerRunning != pdFALSE ) + { + /* If the created task is of a higher priority than the current task + then it should run now. */ + if( pxCurrentTCB->uxPriority < uxPriority ) + { + taskYIELD(); + } + } + } + + return xReturn; +} +/*-----------------------------------------------------------*/ + +#if ( INCLUDE_vTaskDelete == 1 ) + + void vTaskDelete( xTaskHandle pxTaskToDelete ) + { + tskTCB *pxTCB; + + taskENTER_CRITICAL(); + { + /* Ensure a yield is performed if the current task is being + deleted. */ + if( pxTaskToDelete == pxCurrentTCB ) + { + pxTaskToDelete = NULL; + } + + /* If null is passed in here then we are deleting ourselves. */ + pxTCB = prvGetTCBFromHandle( pxTaskToDelete ); + + /* Remove task from the ready list and place in the termination list. + This will stop the task from be scheduled. The idle task will check + the termination list and free up any memory allocated by the + scheduler for the TCB and stack. */ + vListRemove( &( pxTCB->xGenericListItem ) ); + + /* Is the task waiting on an event also? */ + if( pxTCB->xEventListItem.pvContainer ) + { + vListRemove( &( pxTCB->xEventListItem ) ); + } + + vListInsertEnd( ( xList * ) &xTasksWaitingTermination, &( pxTCB->xGenericListItem ) ); + + /* Increment the ucTasksDeleted variable so the idle task knows + there is a task that has been deleted and that it should therefore + check the xTasksWaitingTermination list. */ + ++uxTasksDeleted; + } + taskEXIT_CRITICAL(); + + /* Force a reschedule if we have just deleted the current task. */ + if( xSchedulerRunning != pdFALSE ) + { + if( ( void * ) pxTaskToDelete == NULL ) + { + taskYIELD(); + } + } + } + +#endif + + + + + + +/*----------------------------------------------------------- + * TASK CONTROL API documented in task.h + *----------------------------------------------------------*/ + +#if ( INCLUDE_vTaskDelayUntil == 1 ) + + void vTaskDelayUntil( portTickType * const pxPreviousWakeTime, portTickType xTimeIncrement ) + { + portTickType xTimeToWake; + portBASE_TYPE xAlreadyYielded, xShouldDelay = pdFALSE; + + vTaskSuspendAll(); + { + /* Generate the tick time at which the task wants to wake. */ + xTimeToWake = *pxPreviousWakeTime + xTimeIncrement; + + if( xTickCount < *pxPreviousWakeTime ) + { + /* The tick count has overflowed since this function was + lasted called. In this case the only time we should ever + actually delay is if the wake time has also overflowed, + and the wake time is greater than the tick time. When this + is the case it is as if neither time had overflowed. */ + if( ( xTimeToWake < *pxPreviousWakeTime ) && ( xTimeToWake > xTickCount ) ) + { + xShouldDelay = pdTRUE; + } + } + else + { + /* The tick time has not overflowed. In this case we will + delay if either the wake time has overflowed, and/or the + tick time is less than the wake time. */ + if( ( xTimeToWake < *pxPreviousWakeTime ) || ( xTimeToWake > xTickCount ) ) + { + xShouldDelay = pdTRUE; + } + } + + /* Update the wake time ready for the next call. */ + *pxPreviousWakeTime = xTimeToWake; + + if( xShouldDelay ) + { + /* We must remove ourselves from the ready list before adding + ourselves to the blocked list as the same list item is used for + both lists. */ + vListRemove( ( xListItem * ) &( pxCurrentTCB->xGenericListItem ) ); + + /* The list item will be inserted in wake time order. */ + listSET_LIST_ITEM_VALUE( &( pxCurrentTCB->xGenericListItem ), xTimeToWake ); + + if( xTimeToWake < xTickCount ) + { + /* Wake time has overflowed. Place this item in the + overflow list. */ + vListInsert( ( xList * ) pxOverflowDelayedTaskList, ( xListItem * ) &( pxCurrentTCB->xGenericListItem ) ); + } + else + { + /* The wake time has not overflowed, so we can use the + current block list. */ + vListInsert( ( xList * ) pxDelayedTaskList, ( xListItem * ) &( pxCurrentTCB->xGenericListItem ) ); + } + } + } + xAlreadyYielded = xTaskResumeAll(); + + /* Force a reschedule if xTaskResumeAll has not already done so, we may + have put ourselves to sleep. */ + if( !xAlreadyYielded ) + { + taskYIELD(); + } + } + +#endif +/*-----------------------------------------------------------*/ + +#if ( INCLUDE_vTaskDelay == 1 ) + + void vTaskDelay( portTickType xTicksToDelay ) + { + portTickType xTimeToWake; + signed portBASE_TYPE xAlreadyYielded = pdFALSE; + + /* A delay time of zero just forces a reschedule. */ + if( xTicksToDelay > ( portTickType ) 0 ) + { + vTaskSuspendAll(); + { + /* A task that is removed from the event list while the + scheduler is suspended will not get placed in the ready + list or removed from the blocked list until the scheduler + is resumed. + + This task cannot be in an event list as it is the currently + executing task. */ + + /* Calculate the time to wake - this may overflow but this is + not a problem. */ + xTimeToWake = xTickCount + xTicksToDelay; + + /* We must remove ourselves from the ready list before adding + ourselves to the blocked list as the same list item is used for + both lists. */ + vListRemove( ( xListItem * ) &( pxCurrentTCB->xGenericListItem ) ); + + /* The list item will be inserted in wake time order. */ + listSET_LIST_ITEM_VALUE( &( pxCurrentTCB->xGenericListItem ), xTimeToWake ); + + if( xTimeToWake < xTickCount ) + { + /* Wake time has overflowed. Place this item in the + overflow list. */ + vListInsert( ( xList * ) pxOverflowDelayedTaskList, ( xListItem * ) &( pxCurrentTCB->xGenericListItem ) ); + } + else + { + /* The wake time has not overflowed, so we can use the + current block list. */ + vListInsert( ( xList * ) pxDelayedTaskList, ( xListItem * ) &( pxCurrentTCB->xGenericListItem ) ); + } + } + xAlreadyYielded = xTaskResumeAll(); + } + + /* Force a reschedule if xTaskResumeAll has not already done so, we may + have put ourselves to sleep. */ + if( !xAlreadyYielded ) + { + taskYIELD(); + } + } + +#endif +/*-----------------------------------------------------------*/ + +#if ( INCLUDE_uxTaskPriorityGet == 1 ) + + unsigned portBASE_TYPE uxTaskPriorityGet( xTaskHandle pxTask ) + { + tskTCB *pxTCB; + unsigned portBASE_TYPE uxReturn; + + taskENTER_CRITICAL(); + { + /* If null is passed in here then we are changing the + priority of the calling function. */ + pxTCB = prvGetTCBFromHandle( pxTask ); + uxReturn = pxTCB->uxPriority; + } + taskEXIT_CRITICAL(); + + return uxReturn; + } + +#endif +/*-----------------------------------------------------------*/ + +#if ( INCLUDE_vTaskPrioritySet == 1 ) + + void vTaskPrioritySet( xTaskHandle pxTask, unsigned portBASE_TYPE uxNewPriority ) + { + tskTCB *pxTCB; + unsigned portBASE_TYPE uxCurrentPriority, xYieldRequired = pdFALSE; + + /* Ensure the new priority is valid. */ + if( uxNewPriority >= configMAX_PRIORITIES ) + { + uxNewPriority = configMAX_PRIORITIES - 1; + } + + taskENTER_CRITICAL(); + { + /* If null is passed in here then we are changing the + priority of the calling function. */ + pxTCB = prvGetTCBFromHandle( pxTask ); + + #if ( configUSE_MUTEXES == 1 ) + { + uxCurrentPriority = pxTCB->uxBasePriority; + } + #else + { + uxCurrentPriority = pxTCB->uxPriority; + } + #endif + + if( uxCurrentPriority != uxNewPriority ) + { + /* The priority change may have readied a task of higher + priority than the calling task. */ + if( uxNewPriority > uxCurrentPriority ) + { + if( pxTask != NULL ) + { + /* The priority of another task is being raised. If we + were raising the priority of the currently running task + there would be no need to switch as it must have already + been the highest priority task. */ + xYieldRequired = pdTRUE; + } + } + else if( pxTask == NULL ) + { + /* Setting our own priority down means there may now be another + task of higher priority that is ready to execute. */ + xYieldRequired = pdTRUE; + } + + + + #if ( configUSE_MUTEXES == 1 ) + { + /* Only change the priority being used if the task is not + currently using an inherited priority. */ + if( pxTCB->uxBasePriority == pxTCB->uxPriority ) + { + pxTCB->uxPriority = uxNewPriority; + } + + /* The base priority gets set whatever. */ + pxTCB->uxBasePriority = uxNewPriority; + } + #else + { + pxTCB->uxPriority = uxNewPriority; + } + #endif + + listSET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ), ( configMAX_PRIORITIES - ( portTickType ) uxNewPriority ) ); + + /* If the task is in the blocked or suspended list we need do + nothing more than change it's priority variable. However, if + the task is in a ready list it needs to be removed and placed + in the queue appropriate to its new priority. */ + if( listIS_CONTAINED_WITHIN( &( pxReadyTasksLists[ uxCurrentPriority ] ), &( pxTCB->xGenericListItem ) ) ) + { + /* The task is currently in its ready list - remove before adding + it to it's new ready list. As we are in a critical section we + can do this even if the scheduler is suspended. */ + vListRemove( &( pxTCB->xGenericListItem ) ); + prvAddTaskToReadyQueue( pxTCB ); + } + + if( xYieldRequired == pdTRUE ) + { + taskYIELD(); + } + } + } + taskEXIT_CRITICAL(); + } + +#endif +/*-----------------------------------------------------------*/ + +#if ( INCLUDE_vTaskSuspend == 1 ) + + void vTaskSuspend( xTaskHandle pxTaskToSuspend ) + { + tskTCB *pxTCB; + + taskENTER_CRITICAL(); + { + /* Ensure a yield is performed if the current task is being + suspended. */ + if( pxTaskToSuspend == pxCurrentTCB ) + { + pxTaskToSuspend = NULL; + } + + /* If null is passed in here then we are suspending ourselves. */ + pxTCB = prvGetTCBFromHandle( pxTaskToSuspend ); + + /* Remove task from the ready/delayed list and place in the suspended list. */ + vListRemove( &( pxTCB->xGenericListItem ) ); + + /* Is the task waiting on an event also? */ + if( pxTCB->xEventListItem.pvContainer ) + { + vListRemove( &( pxTCB->xEventListItem ) ); + } + + vListInsertEnd( ( xList * ) &xSuspendedTaskList, &( pxTCB->xGenericListItem ) ); + } + taskEXIT_CRITICAL(); + + /* We may have just suspended the current task. */ + if( ( void * ) pxTaskToSuspend == NULL ) + { + taskYIELD(); + } + } + +#endif +/*-----------------------------------------------------------*/ + +#if ( INCLUDE_vTaskSuspend == 1 ) + + static portBASE_TYPE prvIsTaskSuspended( const tskTCB * const pxTCB ) + { + portBASE_TYPE xReturn = pdFALSE; + + /* Is the task we are attempting to resume actually in the + suspended list? */ + if( listIS_CONTAINED_WITHIN( &xSuspendedTaskList, &( pxTCB->xGenericListItem ) ) != pdFALSE ) + { + /* Has the task already been resumed from within an ISR? */ + if( listIS_CONTAINED_WITHIN( &xPendingReadyList, &( pxTCB->xEventListItem ) ) != pdTRUE ) + { + /* Is it in the suspended list because it is in the + Suspended state? It is possible to be in the suspended + list because it is blocked on a task with no timeout + specified. */ + if( listIS_CONTAINED_WITHIN( NULL, &( pxTCB->xEventListItem ) ) == pdTRUE ) + { + xReturn = pdTRUE; + } + } + } + + return xReturn; + } + +#endif +/*-----------------------------------------------------------*/ + +#if ( INCLUDE_vTaskSuspend == 1 ) + + void vTaskResume( xTaskHandle pxTaskToResume ) + { + tskTCB *pxTCB; + + /* Remove the task from whichever list it is currently in, and place + it in the ready list. */ + pxTCB = ( tskTCB * ) pxTaskToResume; + + /* The parameter cannot be NULL as it is impossible to resume the + currently executing task. */ + if( pxTCB != NULL ) + { + taskENTER_CRITICAL(); + { + if( prvIsTaskSuspended( pxTCB ) == pdTRUE ) + { + /* As we are in a critical section we can access the ready + lists even if the scheduler is suspended. */ + vListRemove( &( pxTCB->xGenericListItem ) ); + prvAddTaskToReadyQueue( pxTCB ); + + /* We may have just resumed a higher priority task. */ + if( pxTCB->uxPriority >= pxCurrentTCB->uxPriority ) + { + /* This yield may not cause the task just resumed to run, but + will leave the lists in the correct state for the next yield. */ + taskYIELD(); + } + } + } + taskEXIT_CRITICAL(); + } + } + +#endif + +/*-----------------------------------------------------------*/ + +#if ( ( INCLUDE_xTaskResumeFromISR == 1 ) && ( INCLUDE_vTaskSuspend == 1 ) ) + + portBASE_TYPE xTaskResumeFromISR( xTaskHandle pxTaskToResume ) + { + portBASE_TYPE xYieldRequired = pdFALSE; + tskTCB *pxTCB; + + pxTCB = ( tskTCB * ) pxTaskToResume; + + if( prvIsTaskSuspended( pxTCB ) == pdTRUE ) + { + if( uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdFALSE ) + { + xYieldRequired = ( pxTCB->uxPriority >= pxCurrentTCB->uxPriority ); + vListRemove( &( pxTCB->xGenericListItem ) ); + prvAddTaskToReadyQueue( pxTCB ); + } + else + { + /* We cannot access the delayed or ready lists, so will hold this + task pending until the scheduler is resumed, at which point a + yield will be performed if necessary. */ + vListInsertEnd( ( xList * ) &( xPendingReadyList ), &( pxTCB->xEventListItem ) ); + } + } + + return xYieldRequired; + } + +#endif + + + + +/*----------------------------------------------------------- + * PUBLIC SCHEDULER CONTROL documented in task.h + *----------------------------------------------------------*/ + + +void vTaskStartScheduler( void ) +{ +portBASE_TYPE xReturn; + + /* Add the idle task at the lowest priority. */ + xReturn = xTaskCreate( prvIdleTask, ( signed portCHAR * ) "IDLE", tskIDLE_STACK_SIZE, ( void * ) NULL, tskIDLE_PRIORITY, ( xTaskHandle * ) NULL ); + + if( xReturn == pdPASS ) + { + /* Interrupts are turned off here, to ensure a tick does not occur + before or during the call to xPortStartScheduler(). The stacks of + the created tasks contain a status word with interrupts switched on + so interrupts will automatically get re-enabled when the first task + starts to run. + + STEPPING THROUGH HERE USING A DEBUGGER CAN CAUSE BIG PROBLEMS IF THE + DEBUGGER ALLOWS INTERRUPTS TO BE PROCESSED. */ + portDISABLE_INTERRUPTS(); + + xSchedulerRunning = pdTRUE; + xTickCount = ( portTickType ) 0; + + /* Setting up the timer tick is hardware specific and thus in the + portable interface. */ + if( xPortStartScheduler() ) + { + /* Should not reach here as if the scheduler is running the + function will not return. */ + } + else + { + /* Should only reach here if a task calls xTaskEndScheduler(). */ + } + } +} +/*-----------------------------------------------------------*/ + +void vTaskEndScheduler( void ) +{ + /* Stop the scheduler interrupts and call the portable scheduler end + routine so the original ISRs can be restored if necessary. The port + layer must ensure interrupts enable bit is left in the correct state. */ + portDISABLE_INTERRUPTS(); + xSchedulerRunning = pdFALSE; + vPortEndScheduler(); +} +/*----------------------------------------------------------*/ + +void vTaskSuspendAll( void ) +{ + portENTER_CRITICAL(); + ++uxSchedulerSuspended; + portEXIT_CRITICAL(); +} +/*----------------------------------------------------------*/ + +signed portBASE_TYPE xTaskResumeAll( void ) +{ +register tskTCB *pxTCB; +signed portBASE_TYPE xAlreadyYielded = pdFALSE; + + /* It is possible that an ISR caused a task to be removed from an event + list while the scheduler was suspended. If this was the case then the + removed task will have been added to the xPendingReadyList. Once the + scheduler has been resumed it is safe to move all the pending ready + tasks from this list into their appropriate ready list. */ + portENTER_CRITICAL(); + { + --uxSchedulerSuspended; + + if( uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdFALSE ) + { + if( uxCurrentNumberOfTasks > ( unsigned portBASE_TYPE ) 0 ) + { + portBASE_TYPE xYieldRequired = pdFALSE; + + /* Move any readied tasks from the pending list into the + appropriate ready list. */ + while( ( pxTCB = ( tskTCB * ) listGET_OWNER_OF_HEAD_ENTRY( ( ( xList * ) &xPendingReadyList ) ) ) != NULL ) + { + vListRemove( &( pxTCB->xEventListItem ) ); + vListRemove( &( pxTCB->xGenericListItem ) ); + prvAddTaskToReadyQueue( pxTCB ); + + /* If we have moved a task that has a priority higher than + the current task then we should yield. */ + if( pxTCB->uxPriority >= pxCurrentTCB->uxPriority ) + { + xYieldRequired = pdTRUE; + } + } + + /* If any ticks occurred while the scheduler was suspended then + they should be processed now. This ensures the tick count does not + slip, and that any delayed tasks are resumed at the correct time. */ + if( uxMissedTicks > ( unsigned portBASE_TYPE ) 0 ) + { + while( uxMissedTicks > ( unsigned portBASE_TYPE ) 0 ) + { + vTaskIncrementTick(); + --uxMissedTicks; + } + + /* As we have processed some ticks it is appropriate to yield + to ensure the highest priority task that is ready to run is + the task actually running. */ + xYieldRequired = pdTRUE; + } + + if( ( xYieldRequired == pdTRUE ) || ( xMissedYield == pdTRUE ) ) + { + xAlreadyYielded = pdTRUE; + xMissedYield = pdFALSE; + taskYIELD(); + } + } + } + } + portEXIT_CRITICAL(); + + return xAlreadyYielded; +} + + + + + + +/*----------------------------------------------------------- + * PUBLIC TASK UTILITIES documented in task.h + *----------------------------------------------------------*/ + + + +portTickType xTaskGetTickCount( void ) +{ +portTickType xTicks; + + /* Critical section required if running on a 16 bit processor. */ + taskENTER_CRITICAL(); + { + xTicks = xTickCount; + } + taskEXIT_CRITICAL(); + + return xTicks; +} +/*-----------------------------------------------------------*/ + +unsigned portBASE_TYPE uxTaskGetNumberOfTasks( void ) +{ +unsigned portBASE_TYPE uxNumberOfTasks; + + taskENTER_CRITICAL(); + uxNumberOfTasks = uxCurrentNumberOfTasks; + taskEXIT_CRITICAL(); + + return uxNumberOfTasks; +} +/*-----------------------------------------------------------*/ + +#if ( ( configUSE_TRACE_FACILITY == 1 ) && ( INCLUDE_vTaskDelete == 1 ) && ( INCLUDE_vTaskSuspend == 1 ) ) + + void vTaskList( signed portCHAR *pcWriteBuffer ) + { + unsigned portBASE_TYPE uxQueue; + + /* This is a VERY costly function that should be used for debug only. + It leaves interrupts disabled for a LONG time. */ + + vTaskSuspendAll(); + { + /* Run through all the lists that could potentially contain a TCB and + report the task name, state and stack high water mark. */ + + pcWriteBuffer[ 0 ] = ( signed portCHAR ) 0x00; + strcat( ( portCHAR * ) pcWriteBuffer, ( const portCHAR * ) "\r\n" ); + + uxQueue = uxTopUsedPriority + 1; + + do + { + uxQueue--; + + if( !listLIST_IS_EMPTY( &( pxReadyTasksLists[ uxQueue ] ) ) ) + { + prvListTaskWithinSingleList( pcWriteBuffer, ( xList * ) &( pxReadyTasksLists[ uxQueue ] ), tskREADY_CHAR ); + } + }while( uxQueue > ( unsigned portSHORT ) tskIDLE_PRIORITY ); + + if( !listLIST_IS_EMPTY( pxDelayedTaskList ) ) + { + prvListTaskWithinSingleList( pcWriteBuffer, ( xList * ) pxDelayedTaskList, tskBLOCKED_CHAR ); + } + + if( !listLIST_IS_EMPTY( pxOverflowDelayedTaskList ) ) + { + prvListTaskWithinSingleList( pcWriteBuffer, ( xList * ) pxOverflowDelayedTaskList, tskBLOCKED_CHAR ); + } + + if( !listLIST_IS_EMPTY( &xTasksWaitingTermination ) ) + { + prvListTaskWithinSingleList( pcWriteBuffer, ( xList * ) &xTasksWaitingTermination, tskDELETED_CHAR ); + } + + if( !listLIST_IS_EMPTY( &xSuspendedTaskList ) ) + { + prvListTaskWithinSingleList( pcWriteBuffer, ( xList * ) &xSuspendedTaskList, tskSUSPENDED_CHAR ); + } + } + xTaskResumeAll(); + } + +#endif +/*----------------------------------------------------------*/ + +#if ( configUSE_TRACE_FACILITY == 1 ) + + void vTaskStartTrace( signed portCHAR * pcBuffer, unsigned portLONG ulBufferSize ) + { + portENTER_CRITICAL(); + { + pcTraceBuffer = ( volatile signed portCHAR * volatile )pcBuffer; + pcTraceBufferStart = pcBuffer; + pcTraceBufferEnd = pcBuffer + ( ulBufferSize - tskSIZE_OF_EACH_TRACE_LINE ); + xTracing = pdTRUE; + } + portEXIT_CRITICAL(); + } + +#endif +/*----------------------------------------------------------*/ + +#if ( configUSE_TRACE_FACILITY == 1 ) + + unsigned portLONG ulTaskEndTrace( void ) + { + unsigned portLONG ulBufferLength; + + portENTER_CRITICAL(); + xTracing = pdFALSE; + portEXIT_CRITICAL(); + + ulBufferLength = ( unsigned portLONG ) ( pcTraceBuffer - pcTraceBufferStart ); + + return ulBufferLength; + } + +#endif + + + +/*----------------------------------------------------------- + * SCHEDULER INTERNALS AVAILABLE FOR PORTING PURPOSES + * documented in task.h + *----------------------------------------------------------*/ + + +inline void vTaskIncrementTick( void ) +{ + /* Called by the portable layer each time a tick interrupt occurs. + Increments the tick then checks to see if the new tick value will cause any + tasks to be unblocked. */ + if( uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdFALSE ) + { + ++xTickCount; + if( xTickCount == ( portTickType ) 0 ) + { + xList *pxTemp; + + /* Tick count has overflowed so we need to swap the delay lists. + If there are any items in pxDelayedTaskList here then there is + an error! */ + pxTemp = pxDelayedTaskList; + pxDelayedTaskList = pxOverflowDelayedTaskList; + pxOverflowDelayedTaskList = pxTemp; + xNumOfOverflows++; + } + + /* See if this tick has made a timeout expire. */ + prvCheckDelayedTasks(); + } + else + { + ++uxMissedTicks; + + /* The tick hook gets called at regular intervals, even if the + scheduler is locked. */ + #if ( configUSE_TICK_HOOK == 1 ) + { + extern void vApplicationTickHook( void ); + + vApplicationTickHook(); + } + #endif + } + + #if ( configUSE_TICK_HOOK == 1 ) + { + extern void vApplicationTickHook( void ); + + /* Guard against the tick hook being called when the missed tick + count is being unwound (when the scheduler is being unlocked. */ + if( uxMissedTicks == 0 ) + { + vApplicationTickHook(); + } + } + #endif +} +/*-----------------------------------------------------------*/ + +#if ( ( INCLUDE_vTaskCleanUpResources == 1 ) && ( INCLUDE_vTaskSuspend == 1 ) ) + + void vTaskCleanUpResources( void ) + { + unsigned portSHORT usQueue; + volatile tskTCB *pxTCB; + + usQueue = ( unsigned portSHORT ) uxTopUsedPriority + ( unsigned portSHORT ) 1; + + /* Remove any TCB's from the ready queues. */ + do + { + usQueue--; + + while( !listLIST_IS_EMPTY( &( pxReadyTasksLists[ usQueue ] ) ) ) + { + listGET_OWNER_OF_NEXT_ENTRY( pxTCB, &( pxReadyTasksLists[ usQueue ] ) ); + vListRemove( ( xListItem * ) &( pxTCB->xGenericListItem ) ); + + prvDeleteTCB( ( tskTCB * ) pxTCB ); + } + }while( usQueue > ( unsigned portSHORT ) tskIDLE_PRIORITY ); + + /* Remove any TCB's from the delayed queue. */ + while( !listLIST_IS_EMPTY( &xDelayedTaskList1 ) ) + { + listGET_OWNER_OF_NEXT_ENTRY( pxTCB, &xDelayedTaskList1 ); + vListRemove( ( xListItem * ) &( pxTCB->xGenericListItem ) ); + + prvDeleteTCB( ( tskTCB * ) pxTCB ); + } + + /* Remove any TCB's from the overflow delayed queue. */ + while( !listLIST_IS_EMPTY( &xDelayedTaskList2 ) ) + { + listGET_OWNER_OF_NEXT_ENTRY( pxTCB, &xDelayedTaskList2 ); + vListRemove( ( xListItem * ) &( pxTCB->xGenericListItem ) ); + + prvDeleteTCB( ( tskTCB * ) pxTCB ); + } + + while( !listLIST_IS_EMPTY( &xSuspendedTaskList ) ) + { + listGET_OWNER_OF_NEXT_ENTRY( pxTCB, &xSuspendedTaskList ); + vListRemove( ( xListItem * ) &( pxTCB->xGenericListItem ) ); + + prvDeleteTCB( ( tskTCB * ) pxTCB ); + } + } + +#endif +/*-----------------------------------------------------------*/ + +void vTaskSwitchContext( void ) +{ + if( uxSchedulerSuspended != ( unsigned portBASE_TYPE ) pdFALSE ) + { + /* The scheduler is currently suspended - do not allow a context + switch. */ + xMissedYield = pdTRUE; + return; + } + + /* Find the highest priority queue that contains ready tasks. */ + while( listLIST_IS_EMPTY( &( pxReadyTasksLists[ uxTopReadyPriority ] ) ) ) + { + --uxTopReadyPriority; + } + + /* listGET_OWNER_OF_NEXT_ENTRY walks through the list, so the tasks of the + same priority get an equal share of the processor time. */ + listGET_OWNER_OF_NEXT_ENTRY( pxCurrentTCB, &( pxReadyTasksLists[ uxTopReadyPriority ] ) ); + vWriteTraceToBuffer(); +} +/*-----------------------------------------------------------*/ + +void vTaskPlaceOnEventList( const xList * const pxEventList, portTickType xTicksToWait ) +{ +portTickType xTimeToWake; + + /* THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED OR THE + SCHEDULER SUSPENDED. */ + + /* Place the event list item of the TCB in the appropriate event list. + This is placed in the list in priority order so the highest priority task + is the first to be woken by the event. */ + vListInsert( ( xList * ) pxEventList, ( xListItem * ) &( pxCurrentTCB->xEventListItem ) ); + + /* We must remove ourselves from the ready list before adding ourselves + to the blocked list as the same list item is used for both lists. We have + exclusive access to the ready lists as the scheduler is locked. */ + vListRemove( ( xListItem * ) &( pxCurrentTCB->xGenericListItem ) ); + + + #if ( INCLUDE_vTaskSuspend == 1 ) + { + if( xTicksToWait == portMAX_DELAY ) + { + /* Add ourselves to the suspended task list instead of a delayed task + list to ensure we are not woken by a timing event. We will block + indefinitely. */ + vListInsertEnd( ( xList * ) &xSuspendedTaskList, ( xListItem * ) &( pxCurrentTCB->xGenericListItem ) ); + } + else + { + /* Calculate the time at which the task should be woken if the event does + not occur. This may overflow but this doesn't matter. */ + xTimeToWake = xTickCount + xTicksToWait; + + listSET_LIST_ITEM_VALUE( &( pxCurrentTCB->xGenericListItem ), xTimeToWake ); + + if( xTimeToWake < xTickCount ) + { + /* Wake time has overflowed. Place this item in the overflow list. */ + vListInsert( ( xList * ) pxOverflowDelayedTaskList, ( xListItem * ) &( pxCurrentTCB->xGenericListItem ) ); + } + else + { + /* The wake time has not overflowed, so we can use the current block list. */ + vListInsert( ( xList * ) pxDelayedTaskList, ( xListItem * ) &( pxCurrentTCB->xGenericListItem ) ); + } + } + } + #else + { + /* Calculate the time at which the task should be woken if the event does + not occur. This may overflow but this doesn't matter. */ + xTimeToWake = xTickCount + xTicksToWait; + + listSET_LIST_ITEM_VALUE( &( pxCurrentTCB->xGenericListItem ), xTimeToWake ); + + if( xTimeToWake < xTickCount ) + { + /* Wake time has overflowed. Place this item in the overflow list. */ + vListInsert( ( xList * ) pxOverflowDelayedTaskList, ( xListItem * ) &( pxCurrentTCB->xGenericListItem ) ); + } + else + { + /* The wake time has not overflowed, so we can use the current block list. */ + vListInsert( ( xList * ) pxDelayedTaskList, ( xListItem * ) &( pxCurrentTCB->xGenericListItem ) ); + } + } + #endif +} +/*-----------------------------------------------------------*/ + +signed portBASE_TYPE xTaskRemoveFromEventList( const xList * const pxEventList ) +{ +tskTCB *pxUnblockedTCB; +portBASE_TYPE xReturn; + + /* THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED OR THE + SCHEDULER SUSPENDED. It can also be called from within an ISR. */ + + /* The event list is sorted in priority order, so we can remove the + first in the list, remove the TCB from the delayed list, and add + it to the ready list. + + If an event is for a queue that is locked then this function will never + get called - the lock count on the queue will get modified instead. This + means we can always expect exclusive access to the event list here. */ + pxUnblockedTCB = ( tskTCB * ) listGET_OWNER_OF_HEAD_ENTRY( pxEventList ); + vListRemove( &( pxUnblockedTCB->xEventListItem ) ); + + if( uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdFALSE ) + { + vListRemove( &( pxUnblockedTCB->xGenericListItem ) ); + prvAddTaskToReadyQueue( pxUnblockedTCB ); + } + else + { + /* We cannot access the delayed or ready lists, so will hold this + task pending until the scheduler is resumed. */ + vListInsertEnd( ( xList * ) &( xPendingReadyList ), &( pxUnblockedTCB->xEventListItem ) ); + } + + if( pxUnblockedTCB->uxPriority >= pxCurrentTCB->uxPriority ) + { + /* Return true if the task removed from the event list has + a higher priority than the calling task. This allows + the calling task to know if it should force a context + switch now. */ + xReturn = pdTRUE; + } + else + { + xReturn = pdFALSE; + } + + return xReturn; +} +/*-----------------------------------------------------------*/ + +void vTaskSetTimeOutState( xTimeOutType * const pxTimeOut ) +{ + pxTimeOut->xOverflowCount = xNumOfOverflows; + pxTimeOut->xTimeOnEntering = xTickCount; +} +/*-----------------------------------------------------------*/ + +portBASE_TYPE xTaskCheckForTimeOut( xTimeOutType * const pxTimeOut, portTickType * const pxTicksToWait ) +{ +portBASE_TYPE xReturn; + + #if ( INCLUDE_vTaskSuspend == 1 ) + /* If INCLUDE_vTaskSuspend is set to 1 and the block time specified is + the maximum block time then the task should block indefinitely, and + therefore never time out. */ + if( *pxTicksToWait == portMAX_DELAY ) + { + xReturn = pdFALSE; + } + else /* We are not blocking indefinitely, perform the checks below. */ + #endif + + if( ( xNumOfOverflows != pxTimeOut->xOverflowCount ) && ( xTickCount >= pxTimeOut->xTimeOnEntering ) ) + { + /* The tick count is greater than the time at which vTaskSetTimeout() + was called, but has also overflowed since vTaskSetTimeOut() was called. + It must have wrapped all the way around and gone past us again. This + passed since vTaskSetTimeout() was called. */ + xReturn = pdTRUE; + } + else if( ( xTickCount - pxTimeOut->xTimeOnEntering ) < *pxTicksToWait ) + { + /* Not a genuine timeout. Adjust parameters for time remaining. */ + *pxTicksToWait -= ( xTickCount - pxTimeOut->xTimeOnEntering ); + vTaskSetTimeOutState( pxTimeOut ); + xReturn = pdFALSE; + } + else + { + xReturn = pdTRUE; + } + + return xReturn; +} +/*-----------------------------------------------------------*/ + +void vTaskMissedYield( void ) +{ + xMissedYield = pdTRUE; +} + +/* + * ----------------------------------------------------------- + * The Idle task. + * ---------------------------------------------------------- + * + * The portTASK_FUNCTION() macro is used to allow port/compiler specific + * language extensions. The equivalent prototype for this function is: + * + * void prvIdleTask( void *pvParameters ); + * + */ +static portTASK_FUNCTION( prvIdleTask, pvParameters ) +{ + /* Stop warnings. */ + ( void ) pvParameters; + + for( ;; ) + { + /* See if any tasks have been deleted. */ + prvCheckTasksWaitingTermination(); + + #if ( configUSE_PREEMPTION == 0 ) + { + /* If we are not using preemption we keep forcing a task switch to + see if any other task has become available. If we are using + preemption we don't need to do this as any task becoming available + will automatically get the processor anyway. */ + taskYIELD(); + } + #endif + + #if ( ( configUSE_PREEMPTION == 1 ) && ( configIDLE_SHOULD_YIELD == 1 ) ) + { + /* When using preemption tasks of equal priority will be + timesliced. If a task that is sharing the idle priority is ready + to run then the idle task should yield before the end of the + timeslice. + + A critical region is not required here as we are just reading from + the list, and an occasional incorrect value will not matter. If + the ready list at the idle priority contains more than one task + then a task other than the idle task is ready to execute. */ + if( listCURRENT_LIST_LENGTH( &( pxReadyTasksLists[ tskIDLE_PRIORITY ] ) ) > ( unsigned portBASE_TYPE ) 1 ) + { + taskYIELD(); + } + } + #endif + + #if ( configUSE_IDLE_HOOK == 1 ) + { + extern void vApplicationIdleHook( void ); + + /* Call the user defined function from within the idle task. This + allows the application designer to add background functionality + without the overhead of a separate task. + NOTE: vApplicationIdleHook() MUST NOT, UNDER ANY CIRCUMSTANCES, + CALL A FUNCTION THAT MIGHT BLOCK. */ + vApplicationIdleHook(); + } + #endif + } +} /*lint !e715 pvParameters is not accessed but all task functions require the same prototype. */ + + + + + + + +/*----------------------------------------------------------- + * File private functions documented at the top of the file. + *----------------------------------------------------------*/ + + + +static void prvInitialiseTCBVariables( tskTCB *pxTCB, const signed portCHAR * const pcName, unsigned portBASE_TYPE uxPriority ) +{ + /* Store the function name in the TCB. */ + strncpy( ( char * ) pxTCB->pcTaskName, ( const char * ) pcName, ( unsigned portSHORT ) configMAX_TASK_NAME_LEN ); + pxTCB->pcTaskName[ ( unsigned portSHORT ) configMAX_TASK_NAME_LEN - ( unsigned portSHORT ) 1 ] = '\0'; + + /* This is used as an array index so must ensure it's not too large. */ + if( uxPriority >= configMAX_PRIORITIES ) + { + uxPriority = configMAX_PRIORITIES - 1; + } + + pxTCB->uxPriority = uxPriority; + #if ( configUSE_MUTEXES == 1 ) + { + pxTCB->uxBasePriority = uxPriority; + } + #endif + + vListInitialiseItem( &( pxTCB->xGenericListItem ) ); + vListInitialiseItem( &( pxTCB->xEventListItem ) ); + + /* Set the pxTCB as a link back from the xListItem. This is so we can get + back to the containing TCB from a generic item in a list. */ + listSET_LIST_ITEM_OWNER( &( pxTCB->xGenericListItem ), pxTCB ); + + /* Event lists are always in priority order. */ + listSET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ), configMAX_PRIORITIES - ( portTickType ) uxPriority ); + listSET_LIST_ITEM_OWNER( &( pxTCB->xEventListItem ), pxTCB ); +} +/*-----------------------------------------------------------*/ + +static void prvInitialiseTaskLists( void ) +{ +unsigned portBASE_TYPE uxPriority; + + for( uxPriority = 0; uxPriority < configMAX_PRIORITIES; uxPriority++ ) + { + vListInitialise( ( xList * ) &( pxReadyTasksLists[ uxPriority ] ) ); + } + + vListInitialise( ( xList * ) &xDelayedTaskList1 ); + vListInitialise( ( xList * ) &xDelayedTaskList2 ); + vListInitialise( ( xList * ) &xPendingReadyList ); + + #if ( INCLUDE_vTaskDelete == 1 ) + { + vListInitialise( ( xList * ) &xTasksWaitingTermination ); + } + #endif + + #if ( INCLUDE_vTaskSuspend == 1 ) + { + vListInitialise( ( xList * ) &xSuspendedTaskList ); + } + #endif + + /* Start with pxDelayedTaskList using list1 and the pxOverflowDelayedTaskList + using list2. */ + pxDelayedTaskList = &xDelayedTaskList1; + pxOverflowDelayedTaskList = &xDelayedTaskList2; +} +/*-----------------------------------------------------------*/ + +static void prvCheckTasksWaitingTermination( void ) +{ + #if ( INCLUDE_vTaskDelete == 1 ) + { + portBASE_TYPE xListIsEmpty; + + /* ucTasksDeleted is used to prevent vTaskSuspendAll() being called + too often in the idle task. */ + if( uxTasksDeleted > ( unsigned portBASE_TYPE ) 0 ) + { + vTaskSuspendAll(); + xListIsEmpty = listLIST_IS_EMPTY( &xTasksWaitingTermination ); + xTaskResumeAll(); + + if( !xListIsEmpty ) + { + tskTCB *pxTCB; + + portENTER_CRITICAL(); + { + pxTCB = ( tskTCB * ) listGET_OWNER_OF_HEAD_ENTRY( ( ( xList * ) &xTasksWaitingTermination ) ); + vListRemove( &( pxTCB->xGenericListItem ) ); + --uxCurrentNumberOfTasks; + --uxTasksDeleted; + } + portEXIT_CRITICAL(); + + prvDeleteTCB( pxTCB ); + } + } + } + #endif +} +/*-----------------------------------------------------------*/ + +static tskTCB *prvAllocateTCBAndStack( unsigned portSHORT usStackDepth ) +{ +tskTCB *pxNewTCB; + + /* Allocate space for the TCB. Where the memory comes from depends on + the implementation of the port malloc function. */ + pxNewTCB = ( tskTCB * ) pvPortMalloc( sizeof( tskTCB ) ); + + if( pxNewTCB != NULL ) + { + /* Allocate space for the stack used by the task being created. + The base of the stack memory stored in the TCB so the task can + be deleted later if required. */ + pxNewTCB->pxStack = ( portSTACK_TYPE * ) pvPortMalloc( ( ( size_t )usStackDepth ) * sizeof( portSTACK_TYPE ) ); + + if( pxNewTCB->pxStack == NULL ) + { + /* Could not allocate the stack. Delete the allocated TCB. */ + vPortFree( pxNewTCB ); + pxNewTCB = NULL; + } + else + { + /* Just to help debugging. */ + memset( pxNewTCB->pxStack, tskSTACK_FILL_BYTE, usStackDepth * sizeof( portSTACK_TYPE ) ); + } + } + + return pxNewTCB; +} +/*-----------------------------------------------------------*/ + +#if ( configUSE_TRACE_FACILITY == 1 ) + + static void prvListTaskWithinSingleList( const signed portCHAR *pcWriteBuffer, xList *pxList, signed portCHAR cStatus ) + { + volatile tskTCB *pxNextTCB, *pxFirstTCB; + static portCHAR pcStatusString[ 50 ]; + unsigned portSHORT usStackRemaining; + + /* Write the details of all the TCB's in pxList into the buffer. */ + listGET_OWNER_OF_NEXT_ENTRY( pxFirstTCB, pxList ); + do + { + listGET_OWNER_OF_NEXT_ENTRY( pxNextTCB, pxList ); + usStackRemaining = usTaskCheckFreeStackSpace( ( unsigned portCHAR * ) pxNextTCB->pxStack ); + sprintf( pcStatusString, ( portCHAR * ) "%s\t\t%c\t%u\t%u\t%u\r\n", pxNextTCB->pcTaskName, cStatus, ( unsigned int ) pxNextTCB->uxPriority, usStackRemaining, ( unsigned int ) pxNextTCB->uxTCBNumber ); + strcat( ( portCHAR * ) pcWriteBuffer, ( portCHAR * ) pcStatusString ); + + } while( pxNextTCB != pxFirstTCB ); + } + +#endif +/*-----------------------------------------------------------*/ + +#if ( configUSE_TRACE_FACILITY == 1 ) + unsigned portSHORT usTaskCheckFreeStackSpace( const unsigned portCHAR * pucStackByte ) + { + register unsigned portSHORT usCount = 0; + + while( *pucStackByte == tskSTACK_FILL_BYTE ) + { + pucStackByte -= portSTACK_GROWTH; + usCount++; + } + + usCount /= sizeof( portSTACK_TYPE ); + + return usCount; + } +#endif +/*-----------------------------------------------------------*/ + + + +#if ( ( INCLUDE_vTaskDelete == 1 ) || ( INCLUDE_vTaskCleanUpResources == 1 ) ) + + static void prvDeleteTCB( tskTCB *pxTCB ) + { + /* Free up the memory allocated by the scheduler for the task. It is up to + the task to free any memory allocated at the application level. */ + vPortFree( pxTCB->pxStack ); + vPortFree( pxTCB ); + } + +#endif + + +/*-----------------------------------------------------------*/ + +#if ( INCLUDE_xTaskGetCurrentTaskHandle == 1 ) + + xTaskHandle xTaskGetCurrentTaskHandle( void ) + { + xTaskHandle xReturn; + + portENTER_CRITICAL(); + { + xReturn = ( xTaskHandle ) pxCurrentTCB; + } + portEXIT_CRITICAL(); + + return xReturn; + } + +#endif + +/*-----------------------------------------------------------*/ + +#if ( INCLUDE_xTaskGetSchedulerState == 1 ) + + portBASE_TYPE xTaskGetSchedulerState( void ) + { + portBASE_TYPE xReturn; + + if( xSchedulerRunning == pdFALSE ) + { + xReturn = taskSCHEDULER_NOT_STARTED; + } + else + { + if( uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdFALSE ) + { + xReturn = taskSCHEDULER_RUNNING; + } + else + { + xReturn = taskSCHEDULER_SUSPENDED; + } + } + + return xReturn; + } + +#endif + +#if ( configUSE_MUTEXES == 1 ) + + void vTaskPriorityInherit( xTaskHandle * const pxMutexHolder ) + { + tskTCB * const pxTCB = ( tskTCB * ) pxMutexHolder; + + if( pxTCB->uxPriority < pxCurrentTCB->uxPriority ) + { + /* Adjust the mutex holder state to account for its new priority. */ + listSET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ), configMAX_PRIORITIES - ( portTickType ) pxCurrentTCB->uxPriority ); + + /* If the task being modified is in the read state it will need to + be moved in to a new list. */ + if( listIS_CONTAINED_WITHIN( &( pxReadyTasksLists[ pxTCB->uxPriority ] ), &( pxTCB->xGenericListItem ) ) ) + { + vListRemove( &( pxTCB->xGenericListItem ) ); + + /* Inherit the priority before being moved into the new list. */ + pxTCB->uxPriority = pxCurrentTCB->uxPriority; + prvAddTaskToReadyQueue( pxTCB ); + } + else + { + /* Just inherit the priority. */ + pxTCB->uxPriority = pxCurrentTCB->uxPriority; + } + } + } + +#endif + +#if ( configUSE_MUTEXES == 1 ) + + void vTaskPriorityDisinherit( xTaskHandle * const pxMutexHolder ) + { + tskTCB * const pxTCB = ( tskTCB * ) pxMutexHolder; + + if( pxMutexHolder != NULL ) + { + if( pxTCB->uxPriority != pxTCB->uxBasePriority ) + { + /* We must be the running task to be able to give the mutex back. + Remove ourselves from the ready list we currently appear in. */ + vListRemove( &( pxTCB->xGenericListItem ) ); + + /* Disinherit the priority before adding ourselves into the new + ready list. */ + pxTCB->uxPriority = pxTCB->uxBasePriority; + listSET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ), configMAX_PRIORITIES - ( portTickType ) pxTCB->uxPriority ); + prvAddTaskToReadyQueue( pxTCB ); + } + } + } + +#endif + + + + + diff --git a/Tester/SW/lib/MmcFilesystem/.cproject b/Tester/SW/lib/MmcFilesystem/.cproject new file mode 100644 index 0000000..9b53271 --- /dev/null +++ b/Tester/SW/lib/MmcFilesystem/.cproject @@ -0,0 +1,547 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tester/SW/lib/MmcFilesystem/.project b/Tester/SW/lib/MmcFilesystem/.project new file mode 100644 index 0000000..8e1a0be --- /dev/null +++ b/Tester/SW/lib/MmcFilesystem/.project @@ -0,0 +1,84 @@ + + + MmcFilesystem + + + MmcFilesystem + inc + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + org.eclipse.cdt.make.core.cleanBuildTarget + clean + + + org.eclipse.cdt.make.core.enableCleanBuild + true + + + org.eclipse.cdt.make.core.append_environment + true + + + ?name? + + + + org.eclipse.cdt.make.core.stopOnError + true + + + org.eclipse.cdt.make.core.buildCommand + make + + + org.eclipse.cdt.make.core.contents + org.eclipse.cdt.make.core.activeConfigSettings + + + org.eclipse.cdt.make.core.buildLocation + ${workspace_loc:/Drivers/Debug} + + + org.eclipse.cdt.make.core.useDefaultBuildCmd + true + + + org.eclipse.cdt.make.core.enableFullBuild + true + + + org.eclipse.cdt.make.core.enableAutoBuild + false + + + org.eclipse.cdt.make.core.fullBuildTarget + all + + + org.eclipse.cdt.make.core.buildArguments + + + + org.eclipse.cdt.make.core.autoBuildTarget + all + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.core.cnature + org.eclipse.cdt.core.ccnature + + diff --git a/Tester/SW/lib/MmcFilesystem/fat_diskio.c b/Tester/SW/lib/MmcFilesystem/fat_diskio.c new file mode 100644 index 0000000..17008dc --- /dev/null +++ b/Tester/SW/lib/MmcFilesystem/fat_diskio.c @@ -0,0 +1,192 @@ +/* --------------------------------------------------------------------------- + * diskio.c (C)ChaN, 2007 + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * This is a stub disk I/O module that acts as front end of the existing + * disk I/O modules and attach it to FatFs module with common interface. + * + * --------------------------------------------------------------------------- + * Version(s): 0.2, Aug 11, 2008, MMi + * Edited to fit into LAN_2636 Project + * Change disk_write and disk_read functions to work with MMC + * disable multible drive support + * + * 0.1, 2007 ChanN + * Creation + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +#include "LPC23xx.h" +#include "types.h" +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "fat_diskio.h" +#include "rtc.h" +#include "mmc.h" +#include "mmc_transfer.h" + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ +#define ATA 0 +#define MMC 1 +#define USB 2 + +#define PAGESIZE 512 /* Pagesize of Card in Byte */ +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ + +DSTATUS disk_initialize(UINT8 drive) +{ + DSTATUS stat = 0; + + /* Multidevice support disabled, always return "Operation suceeded" */ + switch (drive) + { + case ATA: + return (stat); + + case MMC: + return (stat); + + case USB: + return (stat); + + default: + return (stat); + } + return STA_NOINIT; +} + + +DSTATUS disk_status(UINT8 drive) +{ + DSTATUS stat = 0; + + /* Multidevice support disabled, always return "Operation suceeded" */ + switch (drive) + { + case ATA: + return (stat); + + case MMC: + return (stat); + + case USB: + return (stat); + + default: + return (stat); + } + return STA_NOINIT; +} + + +DRESULT disk_ioctl(UINT8 drive, UINT8 ctrl, void *buffer) +{ + DRESULT res = 0; + + /* Multidevice support disabled, always return "Operation suceeded" */ + switch (drive) + { + case ATA: + return (res); + + case MMC: + return (res); + + case USB: + return (res); + + default: + return (res); + } + return RES_PARERR; +} + + +DRESULT disk_read(UINT8 drive, pUINT8 buffer, UINT32 sector, UINT8 count) +{ + UINT32 readResult = 1; + MmcState_t cardResult; /* returned from the card reading */ + + /* Read MMC/SD card on the desired sector for desired length + * The multiplications are necessary because the File Systems counts in + * sectors whereas the original MMC/SD driver requires the adress offset + */ + cardResult = CardRead(buffer, (sector * PAGESIZE), (count * PAGESIZE)); + + /* Switch corresponding to the read result */ + switch (cardResult) + { + case MmcOk: + /* Enter here, the reading worked without problems */ + readResult = 0; + break; + default: + /* enter here, there were some problems while reading */ + readResult = 1; + break; + } + + return (readResult); +} + + +#if _READONLY == 0 /* defined in diskio.h */ +DRESULT disk_write(UINT8 drive, pUINT8 buffer, UINT32 sector, UINT8 count) +{ + UINT32 writeResult = 1; + MmcState_t cardResult; + + /* Read MMC/SD card on the desired sector for desired length + * The multiplications are necessary because the File Systems counts in + * sectors whereas the original MMC/SD driver requires the adress offset + */ + cardResult = CardWrite(buffer, (sector * PAGESIZE), (count * PAGESIZE)); + + /* Switch corresponding to the read result */ + switch (cardResult) + { + case MmcOk: + /* Enter here, the writing worked without problems */ + writeResult = 0; + break; + default: + /* enter here, there were some problems while writing */ + writeResult = 1; + break; + } + + return (writeResult); +} +#endif /* _READONLY */ + diff --git a/Tester/SW/lib/MmcFilesystem/fat_diskio.h b/Tester/SW/lib/MmcFilesystem/fat_diskio.h new file mode 100644 index 0000000..386f8de --- /dev/null +++ b/Tester/SW/lib/MmcFilesystem/fat_diskio.h @@ -0,0 +1,172 @@ +/* --------------------------------------------------------------------------- + * diskio.h (C)ChaN, 2007 + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: Low level disk interface modlue include file R0.06 + * --------------------------------------------------------------------------- + * Version(s): 0.2, Aug 11, 2008, MMi + * Edited to fit into LAN_2636 Project + * Change disk_write and disk_read functions to work with MMC + * + * 0.1, 2007 ChanN + * Creation + * --------------------------------------------------------------------------- + */ +#ifndef DISKIO_H_ +#define DISKIO_H_ +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ +#include "LPC23xx.h" +#include "types.h" +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ +#define _READONLY 0 /* 1: Read-only mode */ +#define _USE_IOCTL 1 + +/* Disk Status Bits (DSTATUS) */ +#define STA_NOINIT 0x01 /* Drive not initialized */ +#define STA_NODISK 0x02 /* No medium in the drive */ +#define STA_PROTECT 0x04 /* Write protected */ + +/* Generic command */ +#define CTRL_SYNC 0 /* Mandatory for read/write */ +#define GET_SECTOR_COUNT 1 /* Mandatory for only f_mkfs() */ +#define GET_SECTOR_SIZE 2 +#define GET_BLOCK_SIZE 3 /* Mandatory for only f_mkfs() */ +#define CTRL_POWER 4 +#define CTRL_LOCK 5 +#define CTRL_EJECT 6 +/* MMC/SDC command */ +#define MMC_GET_TYPE 10 +#define MMC_GET_CSD 11 +#define MMC_GET_CID 12 +#define MMC_GET_OCR 13 +#define MMC_GET_SDSTAT 14 +/* ATA/CF command */ +#define ATA_GET_REV 20 +#define ATA_GET_MODEL 21 +#define ATA_GET_SN 22 +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ +/* Status of Disk Functions */ +typedef UINT8 DSTATUS; + +/* Results of Disk Functions */ +typedef enum + { + RES_OK = 0, /* 0: Successful */ + RES_ERROR, /* 1: R/W Error */ + RES_WRPRT, /* 2: Write Protected */ + RES_NOTRDY, /* 3: Not Ready */ + RES_PARERR /* 4: Invalid Parameter */ + } DRESULT; +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function: disk_initialize + * + * Function to call initialisations for different devices. This function is + * needed by the filesystem but is deactivated because for this project, no + * multible devices are used. Function always returns "Operation suceeded" + * + * Parameters: UINT8 drive - Device number + * + * Return : DSTATUS - Initialisation status of desired device + * --------------------------------------------------------------------------- + */ + DSTATUS disk_initialize(UINT8 drive); + + +/* --------------------------------------------------------------------------- + * Function: disk_status + * + * Function to call status calls for different devices. This function is + * needed by the filesystem but is deactivated because for this project, no + * multible devices are used. Function always returns "Operation suceeded" + * + * Parameters: UINT8 drive - Device number + * + * Return : DSTATUS - Status of desired device + * --------------------------------------------------------------------------- + */ +DSTATUS disk_status(UINT8 drive); + + +/* --------------------------------------------------------------------------- + * Function: disk_ioctrl + * + * Function to call controllings for different devices. This function is + * needed by the filesystem but is deactivated because for this project, no + * multible devices are used. Function always returns "Operation suceeded" + * + * Parameters: UINT8 drive - Device number + * UINT8 ctrl - A certain command + * void *buff - A function pointer + * + * Return : DRESULT - Initialisation status of desired device + * --------------------------------------------------------------------------- + */ +DRESULT disk_ioctl(UINT8 drive, UINT8 ctrl, void *buff); + + +/* --------------------------------------------------------------------------- + * Function: disk_read + * + * Function to read from the memory card. + * + * Parameters: UINT8 drive - Device number + * pUINT8 buffer - Pointer to position to storage read data + * UINT32 sector - Sector an that reading should be started + * UINT8 count - Number of following sectors to read + * + * Return : DSTATUS - Initialisation status of desired device + * --------------------------------------------------------------------------- + */ +DRESULT disk_read(UINT8 drive, pUINT8 buffer, UINT32 sector, UINT8 count); + + +/* --------------------------------------------------------------------------- + * Function: disk_write + * + * Function to write to the memory card. + * + * Parameters: UINT8 drive - Device number + * pUINT8 buffer - Pointer to position where data is stored + * UINT32 sector - Sector an that writing should be started + * UINT8 count - Number of following sectors to write on + * + * Return : DSTATUS - Initialisation status of desired device + * --------------------------------------------------------------------------- + */ +#if _READONLY == 0 +DRESULT disk_write(UINT8 drive, pUINT8 buffer, UINT32 sector, UINT8 count); +#endif + +#endif /*FAT_TIME_H_*/ diff --git a/Tester/SW/lib/MmcFilesystem/fat_intern.c b/Tester/SW/lib/MmcFilesystem/fat_intern.c new file mode 100644 index 0000000..4933c1f --- /dev/null +++ b/Tester/SW/lib/MmcFilesystem/fat_intern.c @@ -0,0 +1,989 @@ +/* --------------------------------------------------------------------------- + * FAT_intern.c (C)ChaN, 2008 + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: FatFs - FAT file system module R0.06 + * + * The FatFs module is an experimenal project to implement FAT file system to + * cheap microcontrollers. This is a free software and is opened for education, + * research and development under license policy of following trems. + * + * Copyright (C) 2008, ChaN, all right reserved. + * + * The FatFs module is a free software and there is no warranty. + * You can use, modify and/or redistribute it for personal, non-profit or + * commercial use without restriction under your responsibility. + * Redistributions of source code must retain the above copyright notice. + * --------------------------------------------------------------------------- + * Last Change: 0.2, Aug 11, 2008, MMi + * Edited to fit into LAN_2636 Project + * + *---------------------------------------------------------------------------- + * Feb 26,'06 R0.00 Prototype. + * + * Apr 29,'06 R0.01 First stable version. + * + * Jun 01,'06 R0.02 Added FAT12 support. + * Removed unbuffered mode. + * Fixed a problem on small (<32M) patition. + * Jun 10,'06 R0.02a Added a configuration option (_FS_MINIMUM). + * + * Sep 22,'06 R0.03 Added f_rename(). + * Changed option _FS_MINIMUM to _FS_MINIMIZE. + * Dec 11,'06 R0.03a Improved cluster scan algolithm to write files fast. + * Fixed f_mkdir() creates incorrect directory on FAT32. + * + * Feb 04,'07 R0.04 Supported multiple drive system. + * Changed some interfaces for multiple drive system. + * Changed f_mountdrv() to f_mount(). + * Added f_mkfs(). + * Apr 01,'07 R0.04a Supported multiple partitions on a plysical drive. + * Added a capability of extending file size to f_lseek(). + * Added minimization level 3. + * Fixed an endian sensitive code in f_mkfs(). + * May 05,'07 R0.04b Added a configuration option _USE_NTFLAG. + * Added FSInfo support. + * Fixed DBCS name can result FR_INVALID_NAME. + * Fixed short seek (<= csize) collapses the file object. + * + * Aug 25,'07 R0.05 Changed arguments of f_read(), f_write() and f_mkfs(). + * Fixed f_mkfs() on FAT32 creates incorrect FSInfo. + * Fixed f_mkdir() on FAT32 creates incorrect directory. + * Feb 03,'08 R0.05a Added f_truncate() and f_utime(). + * Fixed off by one error at FAT sub-type determination. + * Fixed btr in f_read() can be mistruncated. + * Fixed cached sector is not flushed when create and close + * without write. + * + * Apr 01,'08 R0.06 Added fputc(), fputs(), fprintf() and fgets(). + * Improved performance of f_lseek() on moving to the same + * or following cluster. + *--------------------------------------------------------------------------- + */ + + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +/* Compiler includes */ +#include + +#include "LPC23xx.h" +#include "types.h" + +/* FreeRTOS includes */ +#include "FreeRTOS.h" +#include "task.h" +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "fat_intern.h" /* FatFs declarations */ +#include "fat_public.h" +#include "fat_diskio.h" /* Include file for user provided disk functions */ +#include "fat_time.h" /* Get time from RTC */ + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ +FATFS *FatFs[_DRIVES] = {0,0}; /* Pointer to file system objects */ + /* (logical drives) */ +UINT16 fsid; /* File system mount ID */ +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ + +BOOLEAN move_window (FATFS *fs, UINT32 sector) +{ + UINT32 wsect; + + wsect = fs->winsect; + if (wsect != sector) + { + /* Changed current window */ +#if !_FS_READONLY /* If write-access granted */ + UINT8 n; + if (fs->winflag) + { + /* Write back dirty window if needed */ + if (disk_write(fs->drive, fs->win, wsect, 1) != RES_OK) + return FALSE; + fs->winflag = 0; + if (wsect < (fs->fatbase + fs->sects_fat)) + { + /* In FAT area */ + for (n = fs->n_fats; n >= 2; n--) + { + /* Refrect the change to FAT copy */ + wsect += fs->sects_fat; + disk_write(fs->drive, fs->win, wsect, 1); + } + } + } +#endif + if (sector) + { + if (disk_read(fs->drive, fs->win, sector, 1) != RES_OK) + { + return FALSE; + } + fs->winsect = sector; + } + } + return TRUE; +} + + +#if !_FS_READONLY +FRESULT sync (FATFS *fs) +{ + fs->winflag = 1; + if (!move_window(fs, 0)) + return FR_RW_ERROR; +#if _USE_FSINFO + /* Update FSInfo sector if needed */ + if (fs->fs_type == FS_FAT32 && fs->fsi_flag) + { + fs->winsect = 0; + memset(fs->win, 0, 512); + ST_WORD(&fs->win[BS_55AA], 0xAA55); + ST_DWORD(&fs->win[FSI_LeadSig], 0x41615252); + ST_DWORD(&fs->win[FSI_StrucSig], 0x61417272); + ST_DWORD(&fs->win[FSI_Free_Count], fs->free_clust); + ST_DWORD(&fs->win[FSI_Nxt_Free], fs->last_clust); + disk_write(fs->drive, fs->win, fs->fsi_sector, 1); + fs->fsi_flag = 0; + } +#endif + /* Make sure that no pending write process in the physical drive */ + if (disk_ioctl(fs->drive, CTRL_SYNC, NULL) != RES_OK) + return FR_RW_ERROR; + return FR_OK; +} +#endif + + +UINT32 get_cluster (FATFS *fs, UINT32 clust) +{ + UINT16 wc, bc; + UINT32 fatsect; + + if (clust >= 2 && clust < fs->max_clust) + { + /* Is it a valid cluster number? */ + fatsect = fs->fatbase; + switch (fs->fs_type) + { + case FS_FAT12: + bc = (UINT16)clust * 3 / 2; + if (!move_window(fs, fatsect + (bc / SS(fs)))) + break; + wc = fs->win[bc & (SS(fs) - 1)]; + bc++; + if (!move_window(fs, fatsect + (bc / SS(fs)))) + break; + wc |= (UINT16)fs->win[bc & (SS(fs) - 1)] << 8; + return (clust & 1) ? (wc >> 4) : (wc & 0xFFF); + + case FS_FAT16: + if (!move_window(fs, fatsect + (clust / (SS(fs) / 2)))) + break; + return LD_WORD(&fs->win[((UINT16)clust * 2) & (SS(fs) - 1)]); + + case FS_FAT32: + if (!move_window(fs, fatsect + (clust / (SS(fs) / 4)))) + break; + return LD_DWORD(&fs->win[((UINT16)clust * 4) & (SS(fs) - 1)]) & 0x0FFFFFFF; + } + } + + return 1; /* Out of cluster range, or an error occured */ +} + + +#if !_FS_READONLY +BOOLEAN put_cluster(FATFS *fs, UINT32 clust, UINT32 val) +{ + UINT32 fatsect; + UINT16 bc; + UINT8 *p; + + fatsect = fs->fatbase; + + switch (fs->fs_type) + { + case FS_FAT12: + bc = (UINT16)clust * 3 / 2; + if (!move_window(fs, fatsect + (bc / SS(fs)))) + { + return FALSE; + } + p = &fs->win[bc & (SS(fs) - 1)]; + *p = (clust & 1) ? ((*p & 0x0F) | ((UINT8)val << 4)) : (UINT8)val; + bc++; + fs->winflag = 1; + if (!move_window(fs, fatsect + (bc / SS(fs)))) + { + return FALSE; + } + p = &fs->win[bc & (SS(fs) - 1)]; + *p = (clust & 1) ? (UINT8)(val >> 4) : ((*p & 0xF0) | ((UINT8)(val + >> 8) & 0x0F)); + break; + + case FS_FAT16: + if (!move_window(fs, fatsect + (clust / (SS(fs) / 2)))) + { + return FALSE; + } + ST_WORD(&fs->win[((UINT16)clust * 2) & (SS(fs) - 1)], (UINT16)val); + break; + + case FS_FAT32: + if (!move_window(fs, fatsect + (clust / (SS(fs) / 4)))) + { + return FALSE; + } + ST_DWORD(&fs->win[((UINT16)clust * 4) & (SS(fs) - 1)], val); + break; + + default: + return FALSE; + } + fs->winflag = 1; + return TRUE; +} +#endif /* !_FS_READONLY */ + + +#if !_FS_READONLY +BOOLEAN remove_chain (FATFS *fs, UINT32 clust) +{ + UINT32 nxt; + + while (clust >= 2 && clust < fs->max_clust) + { + nxt = get_cluster(fs, clust); + if (nxt == 1) + { + return FALSE; + } + if (!put_cluster(fs, clust, 0)) + { + return FALSE; + } + if (fs->free_clust != 0xFFFFFFFF) + { + fs->free_clust++; +#if _USE_FSINFO + fs->fsi_flag = 1; +#endif + } + clust = nxt; + } + return TRUE; +} +#endif + + +#if !_FS_READONLY +UINT32 create_chain (FATFS *fs, UINT32 clust) +{ + UINT32 cstat; + UINT32 ncl; + UINT32 scl; + UINT32 mcl = fs->max_clust; + + if (clust == 0) + { + /* Create new chain */ + scl = fs->last_clust; /* Get suggested start point */ + if (scl == 0 || scl >= mcl) + scl = 1; + } + else + { + /* Stretch existing chain */ + cstat = get_cluster(fs, clust); /* Check the cluster status */ + if (cstat < 2) + { + return 1; /* It is an invalid cluster */ + } + if (cstat < mcl) + { + return cstat; /* Is already followed by cluster */ + } + scl = clust; + } + + ncl = scl; /* Start cluster */ + for (;;) + { + ncl++; /* Next cluster */ + if (ncl >= mcl) + { + /* Wrap around */ + ncl = 2; + if (ncl > scl) + return 0; /* No free custer */ + } + cstat = get_cluster(fs, ncl); /* Get the cluster status */ + if (cstat == 0) + { + break; /* Found a free cluster */ + } + if (cstat == 1) + { + return 1; /* Any error occured */ + } + if (ncl == scl) + { + return 0; /* No free custer */ + } + } + + if (!put_cluster(fs, ncl, 0x0FFFFFFF)) + { + return 1; /* Mark the new cluster "in use" */ + } + if (clust != 0 && !put_cluster(fs, clust, ncl)) + { + return 1; /* Link it to previous one if needed*/ + } + fs->last_clust = ncl; /* Update fsinfo */ + if (fs->free_clust != 0xFFFFFFFF) + { + fs->free_clust--; +#if _USE_FSINFO + fs->fsi_flag = 1; +#endif + } + + return ncl; /* Return new cluster number */ +} +#endif /* !_FS_READONLY */ + + +UINT32 clust2sect(FATFS *fs, UINT32 clust) +{ + clust -= 2; + if (clust >= (fs->max_clust - 2)) + { + return 0; /* Invalid cluster number */ + } + + return (clust * fs->csize + fs->database); +} + + +BOOLEAN next_dir_entry(DIR *dj) +{ + UINT32 clust; + UINT16 idx; + + idx = dj->index + 1; + if ((idx & ((SS(dj->fs) - 1) / 32)) == 0) + { + /* Table sector changed? */ + dj->sect++; /* Next sector */ + if (dj->clust == 0) + { + /* In static table */ + if (idx >= dj->fs->n_rootdir) + { + return FALSE; /* Reached to end of table */ + } + } + else + { + /* In dynamic table */ + if (((idx / (SS(dj->fs) / 32)) & (dj->fs->csize - 1)) == 0) + { + /* Cluster changed? */ + clust = get_cluster(dj->fs, dj->clust); /* Get next cluster */ + if (clust < 2 || clust >= dj->fs->max_clust) + { + /* Reached to end of table */ + return FALSE; + } + dj->clust = clust; /* Initialize for new cluster */ + dj->sect = clust2sect(dj->fs, clust); + } + } + } + dj->index = idx; /* Lower bits of dj->index indicates*/ + /* offset in dj->sect */ + return TRUE; +} + + +#if _FS_MINIMIZE <= 1 +void get_fileinfo (FILINFO *finfo, const UINT8 *dir) +{ + UINT8 n; + UINT8 c; + UINT8 a; + char *p; + + p = &finfo->fname[0]; + a = _USE_NTFLAG ? dir[DIR_NTres] : 0; /* NT flag */ + for (n = 0; n < 8; n++) + { + /* Convert file name (body) */ + c = dir[n]; + if (c == ' ') + { + break; + } + if (c == 0x05) + { + c = 0xE5; + } + if (a & 0x08 && c >= 'A' && c <= 'Z') + { + c += 0x20; + } + *p++ = c; + } + if (dir[8] != ' ') + { + /* Convert file name (extension) */ + *p++ = '.'; + for (n = 8; n < 11; n++) + { + c = dir[n]; + if (c == ' ') + { + break; + } + if (a & 0x10 && c >= 'A' && c <= 'Z') + { + c += 0x20; + } + *p++ = c; + } + } + *p = '\0'; + + finfo->fattrib = dir[DIR_Attr]; /* Attribute */ + finfo->fsize = LD_DWORD(&dir[DIR_FileSize]); /* Size */ + finfo->fdate = LD_WORD(&dir[DIR_WrtDate]); /* Date */ + finfo->ftime = LD_WORD(&dir[DIR_WrtTime]); /* Time */ +} +#endif /* _FS_MINIMIZE <= 1 */ + + +char make_dirfile(const char **path, char *dirname) +{ + UINT8 n; + UINT8 t; + UINT8 c; + UINT8 a; + UINT8 b; + + memset(dirname, ' ', 8+3); /* Fill buffer with spaces */ + a = 0; + b = 0x18; /* NT flag */ + n = 0; + t = 8; + for (;;) + { + c = *(*path)++; + if (c == '\0' || c == '/') + { + /* Reached to end of str or directory separator */ + if (n == 0) + { + break; + } + dirname[11] = _USE_NTFLAG ? (a & b) : 0; + return c; + } + if (c <= ' ' || c == 0x7F) + { + break; /* Reject invisible chars */ + } + if (c == '.') + { + if (!(a & 1) && n >= 1 && n <= 8) + { + /* Enter extension part */ + n = 8; + t = 11; + continue; + } + break; + } + if (_USE_SJIS && ((c >= 0x81 && c <= 0x9F) || /* Accept S-JIS code */ + (c >= 0xE0 && c <= 0xFC))) + { + if (n == 0 && c == 0xE5) /* Change heading \xE5 to \x05 */ + { + c = 0x05; + } + a ^= 0x01; + goto md_l2; /* LABEL SEE END OF FUNCTION */ + } + if (c == '"') + { + break; /* Reject " */ + } + if (c <= ')') + { + goto md_l1; /* LABEL SEE END OF FUNCTION */ + } + /* Accept ! # $ % & ' ( ) */ + if (c <= ',') + { + break; /* Reject * + , */ + } + if (c <= '9') + { + goto md_l1; + } + /* Accept - 0-9 */ + if (c <= '?') + { + break; /* Reject : ; < = > ? */ + } + if (!(a & 1)) + { + /* These checks are not applied to S-JIS 2nd byte */ + if (c == '|') + { + break; /* Reject | */ + } + if (c >= '[' && c <= ']') + { + break; /* Reject [ \ ] */ + } + if (_USE_NTFLAG && c >= 'A' && c <= 'Z') + { + (t == 8) ? (b &= 0xF7) : (b &= 0xEF); + } + if (c >= 'a' && c <= 'z') + { + /* Convert to upper case */ + c -= 0x20; + if (_USE_NTFLAG) + { + (t == 8) ? (a |= 0x08) : (a |= 0x10); + } + } + } + /* GOTO LABELS */ + md_l1: a &= 0xFE; + md_l2: if (n >= t) + { + break; + } + dirname[n++] = c; + } + return 1; +} + + +FRESULT trace_path (DIR *dj, char *fn, const char *path, UINT8 **dir) +{ + UINT32 clust; + char ds; + UINT8 *dptr = NULL; + FATFS *fs = dj->fs; + + /* Initialize directory object */ + clust = fs->dirbase; + if (fs->fs_type == FS_FAT32) + { + dj->clust = dj->sclust = clust; + dj->sect = clust2sect(fs, clust); + } + else + { + dj->clust = dj->sclust = 0; + dj->sect = clust; + } + dj->index = 0; + + if (*path == '\0') + { + /* Null path means the root directory */ + *dir = NULL; + return FR_OK; + } + + for (;;) + { + ds = make_dirfile(&path, fn); /* Get a paragraph into fn[] */ + if (ds == 1) + { + return FR_INVALID_NAME; + } + for (;;) + { + if (!move_window(fs, dj->sect)) + { + return FR_RW_ERROR; + } + /* Pointer to the directory entry */ + dptr = &fs->win[(dj->index & ((SS(fs) - 1) / 32)) * 32]; + if (dptr[DIR_Name] == 0) /* Has it reached to end of dir? */ + { + return !ds ? FR_NO_FILE : FR_NO_PATH; + } + if (dptr[DIR_Name] != 0xE5 /* Matched? */ + && !(dptr[DIR_Attr] & AR_VOL) + && !memcmp(&dptr[DIR_Name], fn, 8+3)) + { + break; + } + if (!next_dir_entry(dj)) /* Next directory pointer */ + { + return !ds ? FR_NO_FILE : FR_NO_PATH; + } + } + if (!ds) + { + *dir = dptr; + return FR_OK; + } /* Matched with end of path */ + if (!(dptr[DIR_Attr] & AR_DIR)) + { + return FR_NO_PATH; /* Cannot trace because it is a file*/ + } + /* Get cluster# of the directory */ + clust = ((UINT32)LD_WORD(&dptr[DIR_FstClusHI]) << 16) + | LD_WORD(&dptr[DIR_FstClusLO]); + /* Restart scanning at the new directory */ + dj->clust = dj->sclust = clust; + dj->sect = clust2sect(fs, clust); + dj->index = 2; + } +} + + + +#if !_FS_READONLY +FRESULT reserve_direntry (DIR *dj, UINT8 **dir) +{ + UINT32 clust; + UINT32 sector; + UINT8 c; + UINT8 n; + UINT8 *dptr; + FATFS *fs = dj->fs; + + /* Re-initialize directory object */ + clust = dj->sclust; + if (clust != 0) + { + /* Dyanmic directory table */ + dj->clust = clust; + dj->sect = clust2sect(fs, clust); + } + else + { + /* Static directory table */ + dj->sect = fs->dirbase; + } + dj->index = 0; + + do + { + if (!move_window(fs, dj->sect)) + { + return FR_RW_ERROR; + } + /* Pointer to the directory entry */ + dptr = &fs->win[(dj->index & ((SS(dj->fs) - 1) / 32)) * 32]; + c = dptr[DIR_Name]; + if (c == 0 || c == 0xE5) + { + /* Found an empty entry */ + *dir = dptr; + return FR_OK; + } + } while (next_dir_entry(dj)); /* Next directory pointer */ + /* Reached to end of the directory table */ + + /* Abort when it is a static table or could not stretch dynamic table */ + if (clust == 0 || !(clust = create_chain(fs, dj->clust))) + { + return FR_DENIED; + } + if (clust == 1 || !move_window(fs, 0)) + { + return FR_RW_ERROR; + } + + /* Cleanup the expanded table */ + fs->winsect = sector = clust2sect(fs, clust); + memset(fs->win, 0, SS(fs)); + for (n = fs->csize; n; n--) + { + if (disk_write(fs->drive, fs->win, sector, 1) != RES_OK) + { + return FR_RW_ERROR; + } + sector++; + } + fs->winflag = 1; + *dir = fs->win; + + return FR_OK; +} +#endif + + +UINT8 check_fs (FATFS *fs, UINT32 sect) +{ + + /* Load boot record */ + if (disk_read(fs->drive, fs->win, sect, 1) != RES_OK) + { + return 2; + } + /* Check record signature (always placed at offset 510 even if the sector + * size is >512) + */ + if (LD_WORD(&fs->win[BS_55AA]) != 0xAA55) + { + return 2; + } + + /* Check FAT signature */ + if (!memcmp(&fs->win[BS_FilSysType], "FAT", 3)) + { + return 0; + } + if (!memcmp(&fs->win[BS_FilSysType32], "FAT32", 5) + && !(fs->win[BPB_ExtFlags] & 0x80)) + { + return 0; + } + + return 1; +} + + +FRESULT auto_mount (const char **path, FATFS **rfs, UINT8 chk_wp) +{ + UINT32 bootsect; + UINT32 fatsize; + UINT32 totalsect; + UINT32 maxclust; + UINT8 drv; + UINT8 fmt; + UINT8 *tbl; + DSTATUS stat; + + const char *p = *path; + FATFS *fs; + + /* Get drive number from the path name */ + while (*p == ' ') + { + p++; /* Strip leading spaces */ + } + drv = p[0] - '0'; /* Is there a drive number? */ + if (drv <= 9 && p[1] == ':') + { + p += 2; /* Found drive number, get&strip it */ + } + else + { + drv = 0; /* No drive number is given, use */ + /* drive number 0 as default */ + } + if (*p == '/') + { + p++; /* Strip heading slash */ + } + *path = p; /* Return pointer to the path name */ + + /* Check if the drive number is valid or not */ + if (drv >= _DRIVES) + { + return FR_INVALID_DRIVE; /* Is the drive number valid? */ + } + *rfs = fs = FatFs[drv]; /* Returen pointer to the */ + /* corresponding file system object */ + if (!fs) + { + return FR_NOT_ENABLED; /* Is file system object registered?*/ + } + + if (fs->fs_type) + { + /* If the logical drive has been mounted */ + stat = disk_status(fs->drive); + if (!(stat & STA_NOINIT)) + { + /* and physical drive is kept initialized (has not been changed)*/ +#if !_FS_READONLY + /* Check write protection if needed */ + if (chk_wp && (stat & STA_PROTECT)) + { + return FR_WRITE_PROTECTED; + } +#endif + return FR_OK; /* The file system object is valid */ + } + } + + /* The logical drive must be re-mounted. + * Following code attempts to mount the logical drive + */ + + memset(fs, 0, sizeof(FATFS)); /* Clean-up the file system object */ + fs->drive = LD2PD(drv); /* Bind logical and physical drive */ + stat = disk_initialize(fs->drive); /* Initialize low level I/O layer */ + + if (stat & STA_NOINIT) /* Check if the drive is ready */ + { + return FR_NOT_READY; + } +#if S_MAX_SIZ > 512 /* Get disk sector size if needed */ + if (disk_ioctl(drv,GET_SECTOR_SIZE,&SS(fs)) != RES_OK || SS(fs)> S_MAX_SIZ) + { + return FR_NO_FILESYSTEM; + } +#endif +#if !_FS_READONLY + if (chk_wp && (stat & STA_PROTECT)) /* Check write protection if needed */ + { + return FR_WRITE_PROTECTED; + } +#endif + /* Search FAT partition on the drive */ + fmt = check_fs(fs, bootsect = 0); /* Check sector 0 as an SFD format */ + if (fmt == 1) + { + /* Not an FAT boot record, it may be patitioned */ + /* Check a partition listed in top of the partition table */ + tbl = &fs->win[MBR_Table + LD2PT(drv) * 16]; /* Partition table */ + if (tbl[4]) + { + /* Is the partition existing? */ + bootsect = LD_DWORD(&tbl[8]); /* Partition offset in LBA */ + fmt = check_fs(fs, bootsect); /* Check the partition */ + } + } + /* No valid FAT patition is found */ + if (fmt || LD_WORD(&fs->win[BPB_BytsPerSec]) != SS(fs)) + { + return FR_NO_FILESYSTEM; + } + + /* Initialize the file system object */ + fatsize = LD_WORD(&fs->win[BPB_FATSz16]); /* Number of sectors per FAT */ + if (!fatsize) + { + fatsize = LD_DWORD(&fs->win[BPB_FATSz32]); + } + fs->sects_fat = fatsize; + /* Number of FAT copies */ + fs->n_fats = fs->win[BPB_NumFATs]; + /* (Number of sectors in FAT area) */ + fatsize *= fs->n_fats; + /* FAT start sector (lba) */ + fs->fatbase = bootsect + LD_WORD(&fs->win[BPB_RsvdSecCnt]); + /* Number of sectors per cluster */ + fs->csize = fs->win[BPB_SecPerClus]; + /* Nmuber of root directory entries */ + fs->n_rootdir = LD_WORD(&fs->win[BPB_RootEntCnt]); + /* Number of sectors on the file system */ + totalsect = LD_WORD(&fs->win[BPB_TotSec16]); + if (!totalsect) + { + totalsect = LD_DWORD(&fs->win[BPB_TotSec32]); + } + + /* max_clust = Last cluster# + 1 */ + fs->max_clust = maxclust = (totalsect - LD_WORD(&fs->win[BPB_RsvdSecCnt]) + - fatsize - fs->n_rootdir / (SS(fs)/32) ) / fs->csize + 2; + + fmt = FS_FAT12; /* Determine the FAT sub type */ + if (maxclust >= 0xFF7) + { + fmt = FS_FAT16; + } + if (maxclust >= 0xFFF7) + { + fmt = FS_FAT32; + } + + if (fmt == FS_FAT32) + { + /* Root directory start cluster */ + fs->dirbase = LD_DWORD(&fs->win[BPB_RootClus]); + } + else + { + /* Root directory start sector (lba) */ + fs->dirbase = fs->fatbase + fatsize; + } + + /* Data start sector (lba) */ + fs->database = fs->fatbase + fatsize + fs->n_rootdir / (SS(fs)/32); + +#if !_FS_READONLY + /* Initialize allocation information */ + fs->free_clust = 0xFFFFFFFF; +#if _USE_FSINFO + /* Get fsinfo if needed */ + if (fmt == FS_FAT32) + { + fs->fsi_sector = bootsect + LD_WORD(&fs->win[BPB_FSInfo]); + if (disk_read(fs->drive, fs->win, fs->fsi_sector, 1) == RES_OK && + LD_WORD(&fs->win[BS_55AA]) == 0xAA55 && + LD_DWORD(&fs->win[FSI_LeadSig]) == 0x41615252 && + LD_DWORD(&fs->win[FSI_StrucSig]) == 0x61417272) + { + fs->last_clust = LD_DWORD(&fs->win[FSI_Nxt_Free]); + fs->free_clust = LD_DWORD(&fs->win[FSI_Free_Count]); + } + } +#endif +#endif + + fs->fs_type = fmt; /* FAT syb-type */ + fs->id = ++fsid; /* File system mount ID */ + return FR_OK; +} + + +FRESULT validate (const FATFS *fs, UINT16 id) +{ + if (!fs || !fs->fs_type || fs->id != id) + { + return FR_INVALID_OBJECT; + } + + if (disk_status(fs->drive) & STA_NOINIT) + { + return FR_NOT_READY; + } + + return FR_OK; +} diff --git a/Tester/SW/lib/MmcFilesystem/fat_intern.h b/Tester/SW/lib/MmcFilesystem/fat_intern.h new file mode 100644 index 0000000..3492bf3 --- /dev/null +++ b/Tester/SW/lib/MmcFilesystem/fat_intern.h @@ -0,0 +1,396 @@ +/* --------------------------------------------------------------------------- + * FAT_intern.h (C)ChaN, 2008 + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: FatFs - FAT file system module include file R0.06 + * + * FatFs module is an experimenal project to implement FAT file system to + * cheap microcontrollers. This is a free software and is opened for education, + * research and development under license policy of following trems. + * + * Copyright (C) 2008, ChaN, all right reserved. + * + * The FatFs module is a free software and there is no warranty. + * You can use, modify and/or redistribute it for personal, non-profit or + * commercial use without any restriction under your responsibility. + * Redistributions of source code must retain the above copyright notice. + * --------------------------------------------------------------------------- + */ +/* --------------------------------------------------------------------------- + * Version(s): 0.2, Aug 11, 2008, MMi + * Edited to fit into LAN_2636 Project + * + * 0.1, 2008 ChanN + * Creation + * --------------------------------------------------------------------------- + */ +#ifndef FAT_INTERN_H_ +#define FAT_INTERN_H_ + +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ +#include "LPC23xx.h" +#include "types.h" + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ +/* The _MCU_ENDIAN defines which access method is used to the FAT structure. + * 1: Enable word access. + * 2: Disable word access and use byte-by-byte access instead. + */ +#define _MCU_ENDIAN 2 + +/* Setting _FS_READONLY to 1 defines read only configuration. This removes + * writing functions, f_write, f_sync, f_unlink, f_mkdir, f_chmod, f_rename, + * f_truncate and useless f_getfree. + */ +#define _FS_READONLY 0 + +/* _FS_MINIMIZE option defines minimization level to remove some functions. + * 0: Full function. + * 1: f_stat, f_getfree, f_unlink, f_mkdir, f_chmod, f_truncate and f_rename + * are removed. + * 2: f_opendir and f_readdir are removed in addition to level 1. + * 3: f_lseek is removed in addition to level 2. */ +#define _FS_MINIMIZE 0 + +/* To enable string functions, set _USE_STRFUNC to 1 or 2. */ +#define _USE_STRFUNC 0 + +/* When _USE_MKFS is set to 1 and _FS_READONLY is set to 0, f_mkfs function is + * enabled. + */ +#define _USE_MKFS 0 + +/* Number of logical drives to use. This affects the size of internal table.*/ +#define _DRIVES 2 + +/* When _MULTI_PARTITION is set to 0, each logical drive is bound to same + * physical drive number and can mount only 1st primaly partition. When it is + * set to 1, each logical drive can mount a partition listed in Drives[]. + */ +#define _MULTI_PARTITION 0 + +/* To enable FSInfo support on FAT32 volume, set _USE_FSINFO to 1. */ +#define _USE_FSINFO 0 + +/* When _USE_SJIS is set to 1, Shift-JIS code transparency is enabled, + * otherwise only US-ASCII(7bit) code can be accepted as file/directory name. + */ +#define _USE_SJIS 1 + +/* When _USE_NTFLAG is set to 1, upper/lower case of the file name is enabled. + * Note that the files are always accessed in case insensitive. + */ +#define _USE_NTFLAG 1 + + +/* Definitions corresponds to multiple sector size */ +#define S_MAX_SIZ 512U /* Do not change */ +#if S_MAX_SIZ > 512U +#define SS(fs) ((fs)->s_size) +#else +#define SS(fs) 512U +#endif + +/* Definitions corresponds to multi partition */ +#if _MULTI_PARTITION != 0 /* Multiple partition cfg */ +#define LD2PD(drv) (Drives[drv].pd) /* Get physical drive number */ +#define LD2PT(drv) (Drives[drv].pt) /* Get partition number */ +#else /* Single partition cfg */ +#define LD2PD(drv) (drv) /* Physical drive number is equal */ + /* to logical drive number */ +#define LD2PT(drv) 0 /* Always mounts the 1st partition */ +#endif + +/* String functions enabled */ +#if _USE_STRFUNC +#define feof(fp) ((fp)->fptr == (fp)->fsize) +#define EOF -1 +int fputc (int, FIL*); /* Put a character to the file */ +int fputs (const char*, FIL*); /* Put a string to the file */ +int fprintf (FIL*, const char*, ...); /* Put a formatted string to file */ +char* fgets (char*, int, FIL*); /* Get a string from the file */ +#endif + +/* File access control and file status flags */ +#define FA_OPEN_EXISTING 0x00 /* Open file. Fails if not exist */ +#define FA_READ 0x01 /* Allow reading access */ +#if _FS_READONLY == 0 /* En-/disable writing functions */ +#define FA_WRITE 0x02 /* Allow writing access */ +#define FA_CREATE_NEW 0x04 /* Create file. Fails if exists */ +#define FA_CREATE_ALWAYS 0x08 /* Create file, overwrites if exists*/ +#define FA_OPEN_ALWAYS 0x10 /* Open file, create if not exists */ +#define FA__WRITTEN 0x20 /* "FileChanged" Flag (internal use)*/ +#define FA__DIRTY 0x40 +#endif +#define FA__ERROR 0x80 /* ERROR Flag */ + +/* FAT sub types */ +#define FS_FAT12 1 +#define FS_FAT16 2 +#define FS_FAT32 3 + +/* File attribute bits for directory entry */ +#define AR_RDO 0x01 /* Read only */ +#define AR_HID 0x02 /* Hidden */ +#define AR_SYS 0x04 /* System */ +#define AR_VOL 0x08 /* Volume label */ +#define AR_LFN 0x0F /* LFN entry */ +#define AR_DIR 0x10 /* Directory */ +#define AR_ARC 0x20 /* Archive */ + +/* Offset of FAT structure members */ +#define BS_jmpBoot 0 /* Jump Statement */ +#define BS_OEMName 3 /* OEM Name */ +#define BPB_BytsPerSec 11 /* Bytes per Sector */ +#define BPB_SecPerClus 13 /* Sectors per Cluster */ +#define BPB_RsvdSecCnt 14 /* Number of reserved Sectors */ +#define BPB_NumFATs 16 /* Number of FATs */ +#define BPB_RootEntCnt 17 /* Number of Root entries */ +#define BPB_TotSec16 19 /* Number of total Sectors (FAT16) */ +#define BPB_Media 21 /* Media Descriptor (unnecessary) */ +#define BPB_FATSz16 22 /* Number of Sectors per FAT */ +#define BPB_SecPerTrk 24 /* Sectors per Track */ +#define BPB_NumHeads 26 /* Number of writing-heads */ +#define BPB_HiddSec 28 /* Number of hidden Sectors */ +#define BPB_TotSec32 32 /* Number of total Sectors (FAT32) */ +#define BS_55AA 510 /* MBR ending structure "55AA" */ + +/* Offset of additional FAT12/FAT16 Descriptors */ +#define BS_DrvNum 36 /* Physical BIOS Drive number */ +#define BS_BootSig 38 /* Extended Boot Signature */ +#define BS_VolID 39 /* Volume ID */ +#define BS_VolLab 43 /* Volume Label (not necessary) */ +#define BS_FilSysType 54 /* Filesystem Type */ + +/* Offset of additional FAT32 Descriptors */ +#define BPB_FATSz32 36 /* Number of Sectors per FAT */ +#define BPB_ExtFlags 40 /* Extended FAT Flags */ +#define BPB_FSVer 42 /* FAT32 Version (usually:0x0000) */ +#define BPB_RootClus 44 /* Rootcluster number */ +#define BPB_FSInfo 48 /* FS Information Sector (usually 1)*/ +#define BPB_BkBootSec 50 /* Sectornumber of Bootsector copy */ +#define BS_DrvNum32 64 /* Physical BIOS Drive number */ +#define BS_BootSig32 66 /* Extended Boot Signature */ +#define BS_VolID32 67 /* Volume ID */ +#define BS_VolLab32 71 /* Volume Label (unused) */ +#define BS_FilSysType32 82 /* FAT Version (always FAT32) */ + +/* Offset of additional File System Information */ +#define FSI_LeadSig 0 +#define FSI_StrucSig 484 +#define FSI_Free_Count 488 +#define FSI_Nxt_Free 492 + +#define MBR_Table 446 + +/* Offset of directory or file information in RootDirectory entries */ +#define DIR_Name 0 /* Entry name (8B Name 3B Extension)*/ +#define DIR_Attr 11 /* Attributes */ +#define DIR_NTres 12 /* Used by NT */ +#define DIR_CrtTime 14 /* Creation Time */ +#define DIR_CrtDate 16 /* Creation Date */ +#define DIR_FstClusHI 20 /* First Cluster (High Bytes) */ +#define DIR_WrtTime 22 /* Last written Time */ +#define DIR_WrtDate 24 /* Last written Date */ +#define DIR_FstClusLO 26 /* First Cluster (Low Bytes) */ +#define DIR_FileSize 28 /* File Size */ + + +/* Multi-byte word access macros */ +#if _MCU_ENDIAN == 1 /* Use word access */ +#define LD_WORD(ptr) (UINT16)(*(UINT16*)(UINT8*)(ptr)) +#define LD_DWORD(ptr) (UINT32)(*(UINT32*)(UINT8*)(ptr)) +#define ST_WORD(ptr,val) *(UINT16*)(UINT8*)(ptr)=(UINT16)(val) +#define ST_DWORD(ptr,val) *(UINT32*)(UINT8*)(ptr)=(UINT32)(val) +#elif _MCU_ENDIAN == 2 /* Use byte-by-byte access */ +#define LD_WORD(ptr) (UINT16)(((UINT16)*(volatile UINT8*)((ptr)+1)<<8)|(UINT16)*(volatile UINT8*)(ptr)) +#define LD_DWORD(ptr) (UINT32)(((UINT32)*(volatile UINT8*)((ptr)+3)<<24)|((UINT32)*(volatile UINT8*)((ptr)+2)<<16)|((UINT16)*(volatile UINT8*)((ptr)+1)<<8)|*(volatile UINT8*)(ptr)) +#define ST_WORD(ptr,val) *(volatile UINT8*)(ptr)=(UINT8)(val); *(volatile UINT8*)((ptr)+1)=(UINT8)((UINT16)(val)>>8) +#define ST_DWORD(ptr,val) *(volatile UINT8*)(ptr)=(UINT8)(val); *(volatile UINT8*)((ptr)+1)=(UINT8)((UINT16)(val)>>8); *(volatile UINT8*)((ptr)+2)=(UINT8)((UINT32)(val)>>16); *(volatile UINT8*)((ptr)+3)=(UINT8)((UINT32)(val)>>24) +#else +#error Do not forget to set _MCU_ENDIAN properly! +#endif +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ + +/* File system object structure */ +typedef struct _FATFS + { + UINT16 id; /* File system mount ID */ + UINT16 n_rootdir; /* Number of root directory entries */ + UINT32 winsect; /* Current sector in the win[] */ + UINT32 sects_fat; /* Sectors per FAT */ + UINT32 max_clust; /* Maximum number of cluster + 1 */ + UINT32 fatbase; /* FAT start sector */ + UINT32 dirbase; /* RootDir start sector */ + /* (cluster number for FAT32) */ + UINT32 database; /* Data start sector */ +#if !_FS_READONLY + UINT32 last_clust; /* Last allocated cluster */ + UINT32 free_clust; /* Number of free clusters */ +#if _USE_FSINFO + UINT32 fsi_sector; /* Fsinfo sector */ + UINT8 fsi_flag; /* fsinfo dirty flag */ + /* (1:must be written back) */ + UINT8 pad2; +#endif +#endif + UINT8 fs_type; /* FAT sub type */ + UINT8 csize; /* Number of sectors per cluster */ +#if S_MAX_SIZ > 512U + UINT16 s_size; /* Sector size */ +#endif + UINT8 n_fats; /* Number of FAT copies */ + UINT8 drive; /* Physical drive number */ + UINT8 winflag; /* win[] dirty flag */ + /* (1:must be written back) */ + UINT8 pad1; + UINT8 win[S_MAX_SIZ]; /* Disk access window for FAT */ + } FATFS; + +/* Directory object structure */ +typedef struct _DIR + { + UINT16 id; /* Owner file system mount ID */ + UINT16 index; /* Current index */ + FATFS* fs; /* Pointer to file system object */ + UINT32 sclust; /* Start cluster */ + UINT32 clust; /* Current cluster */ + UINT32 sect; /* Current sector */ + } DIR; + +/* File object structure */ +typedef struct _FIL + { + UINT16 id; /* Owner file system mount ID */ + UINT8 flag; /* File status flags */ + UINT8 csect; /* Sector address in the cluster */ + FATFS* fs; /* Pointer to file system object */ + UINT32 fptr; /* File Read/Write pointer */ + UINT32 fsize; /* File size */ + UINT32 org_clust; /* File start cluster */ + UINT32 curr_clust; /* Current cluster */ + UINT32 curr_sect; /* Current sector */ +#if _FS_READONLY == 0 + UINT32 dir_sect; /* Sector containing directory entry*/ + pUINT8 dir_ptr; /* Pointer to dir entry in window */ +#endif + UINT8 buffer[S_MAX_SIZ]; /* File Read/Write buffer */ + } FIL; + +/* File status structure */ +typedef struct _FILINFO + { + UINT32 fsize; /* Size */ + UINT16 fdate; /* Date */ + UINT16 ftime; /* Time */ + UINT8 fattrib; /* Attribute */ + char fname[8+1+3+1]; /* Name (8.3 format) */ + } FILINFO; + +/* File function return code (FRESULT) */ +typedef enum + { + FR_OK = 0, /* 0 - Operation Suceeded */ + FR_NOT_READY, /* 1 - Device not ready */ + FR_NO_FILE, /* 2 - No file available */ + FR_NO_PATH, /* 3 - No path available */ + FR_INVALID_NAME, /* 4 - Invalid file or dir name */ + FR_INVALID_DRIVE, /* 5 - Invalid drive number */ + FR_DENIED, /* 6 - Access denied */ + FR_EXIST, /* 7 - File or dir already exists */ + FR_RW_ERROR, /* 8 - Read or Write Error */ + FR_WRITE_PROTECTED, /* 9 - Device is write-protected */ + FR_NOT_ENABLED, /* 10 - Device/function not enabled */ + FR_NO_FILESYSTEM, /* 11 - No filesystem available */ + FR_INVALID_OBJECT, /* 12 - Invalid object reference */ + FR_MKFS_ABORTED /* 13 - MKFS function aborted */ + } FRESULT; + + +/* Definitions corresponds to multi partition */ +#if _MULTI_PARTITION != 0 /* Multiple partition cfg */ +typedef struct _PARTITION + { + UINT8 pd; /* Physical drive # (0-255) */ + UINT8 pt; /* Partition # (0-3) */ + } PARTITION; +extern +const PARTITION Drives[]; /* Logical drive number to physical */ +#endif +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ + +BOOLEAN move_window (FATFS *fs, UINT32 sector); + +#if !_FS_READONLY +FRESULT sync (FATFS *fs); +#endif + +UINT32 get_cluster (FATFS *fs, UINT32 clust); + +#if !_FS_READONLY +BOOLEAN put_cluster(FATFS *fs, UINT32 clust, UINT32 val); +#endif + + +#if !_FS_READONLY +BOOLEAN remove_chain (FATFS *fs, UINT32 clust); +#endif + +#if !_FS_READONLY +UINT32 create_chain (FATFS *fs, UINT32 clust); +#endif + +UINT32 clust2sect(FATFS *fs, UINT32 clust); +BOOLEAN next_dir_entry(DIR *dj); + +#if _FS_MINIMIZE <= 1 +void get_fileinfo (FILINFO *finfo, const UINT8 *dir); +#endif + +char make_dirfile(const char **path, char *dirname); +FRESULT trace_path (DIR *dj, char *fn, const char *path, UINT8 **dir); + +#if !_FS_READONLY +FRESULT reserve_direntry (DIR *dj, UINT8 **dir); +#endif + +UINT8 check_fs (FATFS *fs, UINT32 sect); + +FRESULT auto_mount (const char **path, FATFS **rfs, UINT8 chk_wp); + +FRESULT validate (const FATFS *fs, UINT16 id); + + + + +#endif diff --git a/Tester/SW/lib/MmcFilesystem/fat_public.c b/Tester/SW/lib/MmcFilesystem/fat_public.c new file mode 100644 index 0000000..ea63bf1 --- /dev/null +++ b/Tester/SW/lib/MmcFilesystem/fat_public.c @@ -0,0 +1,1705 @@ +/* --------------------------------------------------------------------------- + * FAT_public.c (C)ChaN, 2008 + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * + * + * Description: FatFs - FAT file system module R0.06 + * + * The FatFs module is an experimenal project to implement FAT file system to + * cheap microcontrollers. This is a free software and is opened for education, + * research and development under license policy of following trems. + * + * Copyright (C) 2008, ChaN, all right reserved. + * + * The FatFs module is a free software and there is no warranty. + * You can use, modify and/or redistribute it for personal, non-profit or + * commercial use without restriction under your responsibility. + * Redistributions of source code must retain the above copyright notice. + * --------------------------------------------------------------------------- + * Last Change: 0.2, Aug 11, 2008, MMi + * Edited to fit into LAN_2636 Project + * + *---------------------------------------------------------------------------- + * Feb 26,'06 R0.00 Prototype. + * + * Apr 29,'06 R0.01 First stable version. + * + * Jun 01,'06 R0.02 Added FAT12 support. + * Removed unbuffered mode. + * Fixed a problem on small (<32M) patition. + * Jun 10,'06 R0.02a Added a configuration option (_FS_MINIMUM). + * + * Sep 22,'06 R0.03 Added f_rename(). + * Changed option _FS_MINIMUM to _FS_MINIMIZE. + * Dec 11,'06 R0.03a Improved cluster scan algolithm to write files fast. + * Fixed f_mkdir() creates incorrect directory on FAT32. + * + * Feb 04,'07 R0.04 Supported multiple drive system. + * Changed some interfaces for multiple drive system. + * Changed f_mountdrv() to f_mount(). + * Added f_mkfs(). + * Apr 01,'07 R0.04a Supported multiple partitions on a plysical drive. + * Added a capability of extending file size to f_lseek(). + * Added minimization level 3. + * Fixed an endian sensitive code in f_mkfs(). + * May 05,'07 R0.04b Added a configuration option _USE_NTFLAG. + * Added FSInfo support. + * Fixed DBCS name can result FR_INVALID_NAME. + * Fixed short seek (<= csize) collapses the file object. + * + * Aug 25,'07 R0.05 Changed arguments of f_read(), f_write() and f_mkfs(). + * Fixed f_mkfs() on FAT32 creates incorrect FSInfo. + * Fixed f_mkdir() on FAT32 creates incorrect directory. + * Feb 03,'08 R0.05a Added f_truncate() and f_utime(). + * Fixed off by one error at FAT sub-type determination. + * Fixed btr in f_read() can be mistruncated. + * Fixed cached sector is not flushed when create and close + * without write. + * + * Apr 01,'08 R0.06 Added fputc(), fputs(), fprintf() and fgets(). + * Improved performance of f_lseek() on moving to the same + * or following cluster. + *--------------------------------------------------------------------------- + */ + + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +/* Compiler includes */ +#include + +#include "LPC23xx.h" +#include "types.h" + +/* FreeRTOS includes */ +#include "FreeRTOS.h" +#include "task.h" +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "fat_intern.h" /* FatFs declarations */ +#include "fat_public.h" +#include "fat_diskio.h" /* Include file for user provided disk functions */ +#include "fat_time.h" /* Get time from RTC */ + +#include "dio.h" +#include "SerOut.h" + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ +extern FATFS *FatFs[_DRIVES]; /* Pointer to file system objects */ + /* (logical drives) */ +extern UINT16 fsid; /* File system mount ID */ +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ + + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ + +void FAT_StatusOut (FRESULT result) +{ + switch (result) + { + case FR_OK: + debugPrint ("\n\rOperation suceeded"); + break; + case FR_NOT_READY: + debugPrint ("\n\rNot ready"); + break; + case FR_NO_FILE: + debugPrint ("\n\rNo file"); + break; + case FR_NO_PATH: + debugPrint ("\n\rNo path"); + break; + case FR_INVALID_NAME: + debugPrint ("\n\rInvalid name"); + break; + case FR_INVALID_DRIVE: + debugPrint ("\n\rInvalid drive"); + break; + case FR_DENIED: + debugPrint ("\n\rOperation denied"); + break; + case FR_EXIST: + debugPrint ("\n\rAlready exists"); + break; + case FR_RW_ERROR: + debugPrint ("\n\rOperation error"); + break; + case FR_WRITE_PROTECTED: + debugPrint ("\n\rWrite-protected"); + break; + case FR_NOT_ENABLED: + debugPrint ("\n\rNot enabled"); + break; + case FR_NO_FILESYSTEM: + debugPrint ("\n\rNo filesystem"); + break; + case FR_INVALID_OBJECT: + debugPrint ("\n\rInvalid object"); + break; + case FR_MKFS_ABORTED: + debugPrint ("\n\rOperation aborted"); + break; + } +} + + +FRESULT f_mount(UINT8 drive, FATFS *fs) +{ + + if (drive >= _DRIVES) + { + return FR_INVALID_DRIVE; + } + + if (FatFs[drive]) + { + FatFs[drive]->fs_type = 0; /* Clear old object */ + } + FatFs[drive] = fs; /* Register and clear new object */ + + if (fs) + { + fs->fs_type = 0; + } + return FR_OK; +} + + +FRESULT f_open (FIL *fp, const char *path, UINT8 mode) +{ + char fn[8+3+1]; + UINT32 ps; + UINT32 rs; + UINT8 *dir; + FRESULT res; + DIR dj; + + fp->fs = NULL; /* Clear file object */ +#if !_FS_READONLY + mode &= (FA_READ|FA_WRITE|FA_CREATE_ALWAYS|FA_OPEN_ALWAYS|FA_CREATE_NEW); + res = auto_mount(&path, &dj.fs, (UINT8)(mode & (FA_WRITE|FA_CREATE_ALWAYS + |FA_OPEN_ALWAYS|FA_CREATE_NEW))); +#else + mode &= FA_READ; + res = auto_mount(&path, &dj.fs, 0); +#endif + if (res != FR_OK) + { + return res; + } + res = trace_path(&dj, fn, path, &dir); /* Trace the file path */ + +#if !_FS_READONLY + /* Create or Open a file */ + if (mode & (FA_CREATE_ALWAYS|FA_OPEN_ALWAYS|FA_CREATE_NEW)) + { + if (res != FR_OK) + { + /* No file, create new */ + if (res != FR_NO_FILE) + { + return res; + } + res = reserve_direntry(&dj, &dir); + if (res != FR_OK) + { + return res; + } + memset(dir, 0, 32); /* Initialize new entry with name */ + memcpy(&dir[DIR_Name], fn, 8+3); + dir[DIR_NTres] = fn[11]; + mode |= FA_CREATE_ALWAYS; + } + else + { + /* Any object is already existing */ + if (mode & FA_CREATE_NEW) /* Cannot create new */ + { + return FR_EXIST; + } + /* Cannot overwrite it (R/O or DIR) */ + if (!dir || (dir[DIR_Attr] & (AR_RDO|AR_DIR))) + { + return FR_DENIED; + } + if (mode & FA_CREATE_ALWAYS) + { + /* Resize it to zero if needed */ + rs = ((UINT32)LD_WORD(&dir[DIR_FstClusHI]) << 16) + | LD_WORD(&dir[DIR_FstClusLO]); /* Get start cluster*/ + ST_WORD(&dir[DIR_FstClusHI], 0); /* cluster = 0 */ + ST_WORD(&dir[DIR_FstClusLO], 0); + ST_DWORD(&dir[DIR_FileSize], 0); /* size = 0 */ + dj.fs->winflag = 1; + ps = dj.fs->winsect; /* Remove the cluster chain */ + if (!remove_chain(dj.fs, rs) || !move_window(dj.fs, ps)) + { + return FR_RW_ERROR; + } + dj.fs->last_clust = rs - 1; /* Reuse the cluster hole */ + } + } + if (mode & FA_CREATE_ALWAYS) + { + dir[DIR_Attr] = 0; /* Reset attribute */ + ps = get_fattime(); + ST_DWORD(&dir[DIR_CrtTime], ps); /* Created time */ + dj.fs->winflag = 1; + mode |= FA__WRITTEN; /* Set file changed flag */ + } + } + /* Open an existing file */ + else + { +#endif /* !_FS_READONLY */ + if (res != FR_OK) + { + return res; /* Trace failed */ + } + if (!dir || (dir[DIR_Attr] & AR_DIR)) /* It is a directory */ + { + return FR_NO_FILE; + } +#if !_FS_READONLY + if ((mode & FA_WRITE) && (dir[DIR_Attr] & AR_RDO)) /* R/O violation */ + { + return FR_DENIED; + } + } + fp->dir_sect = dj.fs->winsect; /* Pointer to the directory entry */ + fp->dir_ptr = dir; +#endif + fp->flag = mode; /* File access mode */ + fp->org_clust = /* File start cluster */ + ((UINT32)LD_WORD(&dir[DIR_FstClusHI]) << 16) | LD_WORD(&dir[DIR_FstClusLO]); + fp->fsize = LD_DWORD(&dir[DIR_FileSize]); /* File size */ + fp->fptr = 0; + fp->csect = 255; /* File pointer */ + fp->curr_sect = 0; + fp->fs = dj.fs; + fp->id = dj.fs->id; /* Owner file system object of file */ + + return FR_OK; +} + + +FRESULT f_read(FIL *fp, void *buff, UINT32 btr, UINT32 *br) +{ + UINT32 clust; + UINT32 sect; + UINT32 remain; + UINT32 rcnt; + UINT32 cc; + UINT8 *rbuff = buff; + FRESULT res; + + *br = 0; + res = validate(fp->fs, fp->id); /* Check validity of the object */ + if (res != FR_OK) + { + return res; + } + if (fp->flag & FA__ERROR) + { + return FR_RW_ERROR; /* Check error flag */ + } + if (!(fp->flag & FA_READ)) + { + return FR_DENIED; /* Check access mode */ + } + remain = fp->fsize - fp->fptr; + if (btr > remain) + { + btr = (UINT32)remain; /* Truncate btr by remaining bytes */ + } + + /* Repeat until all data transferred */ + for (; btr; rbuff += rcnt, fp->fptr += rcnt, *br += rcnt, btr -= rcnt) + { + if ((fp->fptr % SS(fp->fs)) == 0) + { + /* On the sector boundary? */ + if (fp->csect >= fp->fs->csize) + { + /* On the cluster boundary? */ + + /* On the top of the file? */ + clust = (fp->fptr == 0) ? + fp->org_clust : get_cluster(fp->fs, fp->curr_clust); + if (clust < 2 || clust >= fp->fs->max_clust) + { + goto fr_error; /* GOTO LABEL AT END OF FUNCTION */ + } + fp->curr_clust = clust; /* Update current cluster */ + fp->csect = 0; /* Reset sector address in cluster */ + } + + /* Get current sector */ + sect = clust2sect(fp->fs, fp->curr_clust) + fp->csect; + cc = btr / SS(fp->fs); /* remaining bytes >= sector size */ + if (cc) + { + /* Read maximum contiguous sectors directly */ + + /* Clip at cluster boundary */ + if (fp->csect + cc > fp->fs->csize) + { + cc = fp->fs->csize - fp->csect; + } + if (disk_read(fp->fs->drive, rbuff, sect, (UINT8)cc) != RES_OK) + { + goto fr_error; + } + fp->csect += (UINT8)cc; /* Next sector address in cluster */ + rcnt = SS(fp->fs) * cc; /* Number of bytes transferred */ + continue; + } + if (sect != fp->curr_sect) + { + /* Is window offset changed? */ +#if !_FS_READONLY + if (fp->flag & FA__DIRTY) + { + /* Write back file I/O buffer if needed */ + if (disk_write(fp->fs->drive, fp->buffer, fp->curr_sect, 1) + != RES_OK) + { + goto fr_error; /* GOTO LABEL AT END OF FUNCTION */ + } + fp->flag &= (UINT8)~FA__DIRTY; + } +#endif + /* Fill file I/O buffer with file data */ + if (disk_read(fp->fs->drive, fp->buffer, sect, 1) != RES_OK) + { + goto fr_error; /* GOTO LABEL AT END OF FUNCTION */ + } + fp->curr_sect = sect; + } + fp->csect++; /* Next sector address in cluster */ + } + + /* Get partial sector from file I/O buffer */ + rcnt = SS(fp->fs) - (fp->fptr % SS(fp->fs)); + if (rcnt > btr) + { + rcnt = btr; + } + memcpy(rbuff, &fp->buffer[fp->fptr % SS(fp->fs)], rcnt); + } + + return FR_OK; + + /* GOTO LABEL */ + /* Abort this file due to an unrecoverable error */ + fr_error: + fp->flag |= FA__ERROR; + return FR_RW_ERROR; +} + + +#if !_FS_READONLY +FRESULT f_write (FIL *fp, const void *buff, UINT32 btw, UINT32 *bw) +{ + UINT32 clust; + UINT32 sect; + UINT32 wcnt; + UINT32 cc; + const UINT8 *wbuff = buff; + FRESULT res; + + + *bw = 0; + res = validate(fp->fs, fp->id); /* Check validity of the object */ + if (res != FR_OK) + { + return res; + } + if (fp->flag & FA__ERROR) + { + return FR_RW_ERROR; /* Check error flag */ + } + if (!(fp->flag & FA_WRITE)) + { + return FR_DENIED; /* Check access mode */ + } + if (fp->fsize + btw < fp->fsize) + { + return FR_OK; /* File size cannot reach 4GB */ + } + + /* Repeat until all data transferred */ + for (; btw; wbuff += wcnt, fp->fptr += wcnt, *bw += wcnt, btw -= wcnt) + { + if ((fp->fptr % SS(fp->fs)) == 0) + { + /* On the sector boundary? */ + if (fp->csect >= fp->fs->csize) + { + /* On the cluster boundary? */ + if (fp->fptr == 0) + { + /* On the top of the file? */ + clust = fp->org_clust; /* Follow from the origin */ + if (clust == 0) /* When there is no cluster chain */ + { + /* Create a new cluster chain */ + fp->org_clust = clust = create_chain(fp->fs, 0); + } + } + else + { + /* Middle or end of the file */ + /* Trace or streach cluster chain */ + clust = create_chain(fp->fs, fp->curr_clust); + } + if (clust == 0) + { + /* Could not allocate a new cluster (disk full) */ + break; + } + if (clust == 1 || clust >= fp->fs->max_clust) + { + goto fw_error; /* GOTO LABEL AT END OF FUNCTION */ + } + fp->curr_clust = clust; /* Update current cluster */ + fp->csect = 0; /* Reset sector address in cluster */ + } + + /* Get current sector */ + sect = clust2sect(fp->fs, fp->curr_clust) + fp->csect; + cc = btw / SS(fp->fs); /* When remaining bytes>=sector size*/ + if (cc) + { + /* Write maximum contiguous sectors directly */ + if (fp->csect + cc > fp->fs->csize) + { + /* Clip at cluster boundary */ + cc = fp->fs->csize - fp->csect; + } + if (disk_write(fp->fs->drive, wbuff, sect, (UINT8)cc) != RES_OK) + { + goto fw_error; /* GOTO LABEL AT END OF FUNCTION */ + } + fp->csect += (UINT8)cc; /* Next sector address in cluster */ + wcnt = SS(fp->fs) * cc; /* Number of bytes transferred */ + continue; + } + if (sect != fp->curr_sect) + { + /* Is window offset changed? */ + if (fp->flag & FA__DIRTY) + { + /* Write back file I/O buffer if needed */ + if (disk_write(fp->fs->drive, fp->buffer, fp->curr_sect, 1) + != RES_OK) + { + goto fw_error; /* GOTO LABEL AT END OF FUNCTION */ + } + fp->flag &= (UINT8)~FA__DIRTY; + } + + /* Fill file I/O buffer with file data */ + if (fp->fptr < fp->fsize && disk_read(fp->fs->drive, + fp->buffer, sect, 1) != RES_OK) + { + goto fw_error; /* GOTO LABEL AT END OF FUNCTION */ + } + fp->curr_sect = sect; + } + fp->csect++; /* Next sector address in cluster */ + } + + /* Put partial sector into file I/O buffer */ + wcnt = SS(fp->fs) - (fp->fptr % SS(fp->fs)); + if (wcnt > btw) + { + wcnt = btw; + } + memcpy(&fp->buffer[fp->fptr % SS(fp->fs)], wbuff, wcnt); + fp->flag |= FA__DIRTY; + } + + if (fp->fptr > fp->fsize) + { + fp->fsize = fp->fptr; /* Update file size if needed */ + } + fp->flag |= FA__WRITTEN; /* Set file changed flag */ + return FR_OK; + + /* GOTO LABEL */ + fw_error: + /* Abort this file due to an unrecoverable error */ + fp->flag |= FA__ERROR; + return FR_RW_ERROR; +} + + +FRESULT f_sync(FIL *fp) +{ + UINT32 tim; + UINT8 *dir; + FRESULT res; + + res = validate(fp->fs, fp->id); /* Check validity of the object */ + if (res == FR_OK) + { + if (fp->flag & FA__WRITTEN) + { + /* Has the file been written? */ + /* Write back data buffer if needed */ + if (fp->flag & FA__DIRTY) + { + if (disk_write(fp->fs->drive, fp->buffer, fp->curr_sect, 1) + != RES_OK) + { + return FR_RW_ERROR; + } + fp->flag &= (UINT8)~FA__DIRTY; + } + /* Update the directory entry */ + if (!move_window(fp->fs, fp->dir_sect)) + { + return FR_RW_ERROR; + } + dir = fp->dir_ptr; + dir[DIR_Attr] |= AR_ARC; /* Set archive bit */ + ST_DWORD(&dir[DIR_FileSize], fp->fsize); /* Update file size */ + ST_WORD(&dir[DIR_FstClusLO], fp->org_clust); /* Update start cl.*/ + ST_WORD(&dir[DIR_FstClusHI], fp->org_clust >> 16); + tim = get_fattime(); + ST_DWORD(&dir[DIR_WrtTime], tim); + fp->flag &= (UINT8)~FA__WRITTEN; + res = sync(fp->fs); + } + } + return res; +} +#endif /* !_FS_READONLY */ + + +FRESULT f_close(FIL *fp) +{ + FRESULT res; + +#if !_FS_READONLY + res = f_sync(fp); +#else + res = validate(fp->fs, fp->id); +#endif + if (res == FR_OK) + fp->fs = NULL; + return res; +} +#if _FS_MINIMIZE <= 2 + + +FRESULT f_lseek(FIL *fp, UINT32 ofs) +{ + UINT32 clust; + UINT32 csize; + UINT32 nsect; + UINT32 ifptr; + FRESULT res; + + + res = validate(fp->fs, fp->id); /* Check validity of the object */ + if (res != FR_OK) + { + return res; + } + if (fp->flag & FA__ERROR) + { + return FR_RW_ERROR; + } + if (ofs > fp->fsize +#if !_FS_READONLY + /* In read-only mode, clip offset with the file size */ + && !(fp->flag & FA_WRITE) +#endif + ) + { + ofs = fp->fsize; + } + + ifptr = fp->fptr; + fp->fptr = 0; + fp->csect = 255; + nsect = 0; + if (ofs > 0) + { + csize = (UINT32)fp->fs->csize * SS(fp->fs); /* Cluster size (byte) */ + if (ifptr > 0 && (ofs - 1) / csize >= (ifptr - 1) / csize) + { + /* When seek to same or following cluster */ + fp->fptr = (ifptr - 1) & ~(csize - 1); /*start at current clstr */ + ofs -= fp->fptr; + clust = fp->curr_clust; + } + else + { + /* When seek to back cluster, */ + clust = fp->org_clust; /* start from the first cluster */ +#if !_FS_READONLY + if (clust == 0) + { + /* If no cluster chain, create a new chain */ + clust = create_chain(fp->fs, 0); + if (clust == 1) + { + goto fk_error; /* GOTO LABEL AT END OF FUNCTION */ + } + fp->org_clust = clust; + } +#endif + fp->curr_clust = clust; + } + if (clust != 0) + { + while (ofs > csize) + { + /* Cluster following loop */ +#if !_FS_READONLY + if (fp->flag & FA_WRITE) + { + /* Check if in write mode or not */ + /* Force streached if in write mode */ + clust = create_chain(fp->fs, clust); + if (clust == 0) + { + /* When disk gets full, clip file size */ + ofs = csize; + break; + } + } + else +#endif + { + /* Follow cluster chain if not in write mode */ + clust = get_cluster(fp->fs, clust); + } + if (clust < 2 || clust >= fp->fs->max_clust) + { + goto fk_error; /* GOTO LABEL AT END OF FUNCTION */ + } + fp->curr_clust = clust; + fp->fptr += csize; + ofs -= csize; + } + fp->fptr += ofs; + fp->csect = (UINT8)(ofs / SS(fp->fs)); /*Sect offset in cluster */ + if (ofs & (SS(fp->fs) - 1)) + { + /* Current sector */ + nsect = clust2sect(fp->fs, clust) + fp->csect; + fp->csect++; + } + } + } + if (nsect && nsect != fp->curr_sect) + { +#if !_FS_READONLY + if (fp->flag & FA__DIRTY) + { + /* Write-back dirty buffer if needed */ + if (disk_write(fp->fs->drive, fp->buffer, fp->curr_sect, 1) + != RES_OK) + { + goto fk_error; /* GOTO LABEL AT END OF FUNCTION */ + } + fp->flag &= (UINT8)~FA__DIRTY; + } +#endif + if (disk_read(fp->fs->drive, fp->buffer, nsect, 1) != RES_OK) + { + goto fk_error; /* GOTO LABEL AT END OF FUNCTION */ + } + fp->curr_sect = nsect; + } + +#if !_FS_READONLY + if (fp->fptr > fp->fsize) + { + /* Set changed flag if the file was extended */ + fp->fsize = fp->fptr; + fp->flag |= FA__WRITTEN; + } +#endif + + return FR_OK; + + /* GOTO LABEL */ + fk_error: + /* Abort this file due to an unrecoverable error */ + fp->flag |= FA__ERROR; + return FR_RW_ERROR; +} +#if _FS_MINIMIZE <= 1 + + +FRESULT f_opendir(DIR *dj, const char *path) +{ + char fn[8+3+1]; + UINT8 *dir; + FRESULT res; + + + res = auto_mount(&path, &dj->fs, 0); + if (res == FR_OK) + { + res = trace_path(dj, fn, path, &dir); /* Trace the directory path */ + if (res == FR_OK) + { + /* Trace completed */ + if (dir) + { + /* It is not the root dir */ + if (dir[DIR_Attr] & AR_DIR) + { + /* The entry is a directory */ + dj->clust = ((UINT32)LD_WORD(&dir[DIR_FstClusHI]) << 16) + | LD_WORD(&dir[DIR_FstClusLO]); + dj->sect = clust2sect(dj->fs, dj->clust); + dj->index = 2; + } + else + { + /* The entry is not a directory */ + res = FR_NO_FILE; + } + } + dj->id = dj->fs->id; + } + } + + return res; +} + + +FRESULT f_readdir(DIR *dj, FILINFO *finfo) +{ + UINT8 *dir; + UINT8 c; + UINT8 res; + + res = validate(dj->fs, dj->id); /* Check validity of the object */ + if (res != FR_OK) + { + return res; + } + + finfo->fname[0] = 0; + while (dj->sect) + { + if (!move_window(dj->fs, dj->sect)) + { + return FR_RW_ERROR; + } + /* pointer to the directory entry */ + dir = &dj->fs->win[(dj->index & ((SS(dj->fs) - 1) >> 5)) * 32]; + c = dir[DIR_Name]; + if (c == 0) + { + break; /* Has it reached to end of dir? */ + } + if (c != 0xE5 && !(dir[DIR_Attr] & AR_VOL)) /* Is it a valid entry? */ + { + get_fileinfo(finfo, dir); + } + if (!next_dir_entry(dj)) + { + dj->sect = 0; /* Next entry */ + } + if (finfo->fname[0]) + { + break; /* Found valid entry */ + } + } + + return FR_OK; +} +#if _FS_MINIMIZE == 0 + + +FRESULT f_stat(const char *path, FILINFO *finfo) +{ + UINT8 *dir; + char fn[8+3+1]; + FRESULT res; + DIR dj; + + + res = auto_mount(&path, &dj.fs, 0); + if (res == FR_OK) + { + res = trace_path(&dj, fn, path, &dir); /* Trace the file path */ + if (res == FR_OK) + { + /* Trace completed */ + if (dir) /* Found an object */ + { + get_fileinfo(finfo, dir); + } + else + { + /* It is root dir */ + res = FR_INVALID_NAME; + } + } + } + + return res; +} +#if !_FS_READONLY + + +FRESULT f_truncate(FIL *fp) +{ + UINT32 ncl; + FRESULT res; + + + res = validate(fp->fs, fp->id); /* Check validity of the object */ + if (res != FR_OK) + { + return res; + } + if (fp->flag & FA__ERROR) + { + return FR_RW_ERROR; /* Check error flag */ + } + if (!(fp->flag & FA_WRITE)) + { + return FR_DENIED; /* Check access mode */ + } + + if (fp->fsize > fp->fptr) + { + fp->fsize = fp->fptr; /* ile size to current R/W point */ + fp->flag |= FA__WRITTEN; + if (fp->fptr == 0) + { + /* When set file size to zero, remove entire cluster chain */ + if (!remove_chain(fp->fs, fp->org_clust)) + { + goto ft_error; + } + fp->org_clust = 0; + } + else + { + /* When truncate a part of the file, remove remaining clusters */ + ncl = get_cluster(fp->fs, fp->curr_clust); + if (ncl < 2) + { + goto ft_error; /* GOTO LABEL AT END OF FUNCTION */ + } + if (ncl < fp->fs->max_clust) + { + if (!put_cluster(fp->fs, fp->curr_clust, 0x0FFFFFFF)) + { + goto ft_error; /* GOTO LABEL AT END OF FUNCTION */ + } + if (!remove_chain(fp->fs, ncl)) + { + goto ft_error; /* GOTO LABEL AT END OF FUNCTION */ + } + } + } + } + + return FR_OK; + + /* GOTO LABEL */ + ft_error: + /* Abort this file due to an unrecoverable error */ + fp->flag |= FA__ERROR; + return FR_RW_ERROR; +} + + +FRESULT f_getfree(const char *drive, UINT32 *nclust, FATFS **fatfs) +{ + UINT32 n; + UINT32 clust; + UINT32 sect; + UINT8 fat; + UINT8 f; + UINT8 *p; + FRESULT res; + + + /* Get drive number */ + res = auto_mount(&drive, fatfs, 0); + if (res != FR_OK) + { + return res; + } + + /* If number of free cluster is valid, return it without cluster scan. */ + if ((*fatfs)->free_clust <= (*fatfs)->max_clust - 2) + { + *nclust = (*fatfs)->free_clust; + return FR_OK; + } + + /* Get number of free clusters */ + fat = (*fatfs)->fs_type; + n = 0; + if (fat == FS_FAT12) + { + clust = 2; + do + { + if ((UINT16)get_cluster(*fatfs, clust) == 0) + { + n++; + } + } while (++clust < (*fatfs)->max_clust); + } + else + { + clust = (*fatfs)->max_clust; + sect = (*fatfs)->fatbase; + f = 0; + p = 0; + do + { + if (!f) + { + if (!move_window(*fatfs, sect++)) + { + return FR_RW_ERROR; + } + p = (*fatfs)->win; + } + if (fat == FS_FAT16) + { + if (LD_WORD(p) == 0) + { + n++; + } + p += 2; + f += 1; + } + else + { + if (LD_DWORD(p) == 0) + { + n++; + } + p += 4; + f += 2; + } + } while (--clust); + } + (*fatfs)->free_clust = n; +#if _USE_FSINFO + if (fat == FS_FAT32) + { + (*fatfs)->fsi_flag = 1; + } +#endif + + *nclust = n; + return FR_OK; +} + + +FRESULT f_unlink(const char *path) +{ + UINT32 dclust; + UINT32 dsect; + char fn[8+3+1]; + UINT8 *dir; + UINT8 *sdir; + FRESULT res; + DIR dj; + + + res = auto_mount(&path, &dj.fs, 1); + if (res != FR_OK) + { + return res; + } + res = trace_path(&dj, fn, path, &dir); /* Trace the file path */ + if (res != FR_OK) + { + return res; /* Trace failed */ + } + if (!dir) + { + return FR_INVALID_NAME; /* It is the root directory */ + } + if (dir[DIR_Attr] & AR_RDO) + { + return FR_DENIED; /* It is a R/O object */ + } + dsect = dj.fs->winsect; + dclust = ((UINT32)LD_WORD(&dir[DIR_FstClusHI]) << 16) + | LD_WORD(&dir[DIR_FstClusLO]); + + if (dir[DIR_Attr] & AR_DIR) + { + /* It is a sub-directory */ + dj.clust = dclust; /* Check if sub-dir is empty or not */ + dj.sect = clust2sect(dj.fs, dclust); + dj.index = 2; + do + { + if (!move_window(dj.fs, dj.sect)) + { + return FR_RW_ERROR; + } + sdir = &dj.fs->win[(dj.index & ((SS(dj.fs) - 1) >> 5)) * 32]; + if (sdir[DIR_Name] == 0) + { + break; + } + if (sdir[DIR_Name] != 0xE5 && !(sdir[DIR_Attr] & AR_VOL)) + { + return FR_DENIED; /* The directory is not empty */ + } + } while (next_dir_entry(&dj)); + } + + if (!move_window(dj.fs, dsect)) + { + return FR_RW_ERROR; /* Mark directory entry 'deleted' */ + } + dir[DIR_Name] = 0xE5; + dj.fs->winflag = 1; + if (!remove_chain(dj.fs, dclust)) + { + return FR_RW_ERROR; /* Remove the cluster chain */ + } + + return sync(dj.fs); +} + + +FRESULT f_mkdir(const char *path) +{ + UINT32 sect; + UINT32 dsect; + UINT32 dclust; + UINT32 pclust; + UINT32 tim; + char fn[8+3+1]; + UINT8 *dir; + UINT8 *fw; + UINT8 n; + FRESULT res; + DIR dj; + + + res = auto_mount(&path, &dj.fs, 1); + if (res != FR_OK) + { + return res; + } + res = trace_path(&dj, fn, path, &dir); /* Trace the file path */ + if (res == FR_OK) + { + return FR_EXIST; /* Any file or directory is existing*/ + } + if (res != FR_NO_FILE) + { + return res; + } + + res = reserve_direntry(&dj, &dir); /* Reserve a directory entry */ + if (res != FR_OK) + { + return res; + } + sect = dj.fs->winsect; + /* Allocate a cluster for new directory table */ + dclust = create_chain(dj.fs, 0); + if (dclust == 1) + { + return FR_RW_ERROR; + } + dsect = clust2sect(dj.fs, dclust); + if (!dsect) + { + return FR_DENIED; + } + if (!move_window(dj.fs, dsect)) + { + return FR_RW_ERROR; + } + + fw = dj.fs->win; + memset(fw, 0, SS(dj.fs)); /* Clear the new directory table */ + for (n = 1; n < dj.fs->csize; n++) + { + if (disk_write(dj.fs->drive, fw, ++dsect, 1) != RES_OK) + { + return FR_RW_ERROR; + } + } + memset(&fw[DIR_Name], ' ', 8+3); /* Create "." entry */ + fw[DIR_Name] = '.'; + fw[DIR_Attr] = AR_DIR; + tim = get_fattime(); + ST_DWORD(&fw[DIR_WrtTime], tim); + memcpy(&fw[32], &fw[0], 32); + fw[33] = '.'; /* Create ".." entry */ + ST_WORD(&fw[ DIR_FstClusLO], dclust); + ST_WORD(&fw[ DIR_FstClusHI], dclust >> 16); + pclust = dj.sclust; + if (dj.fs->fs_type == FS_FAT32 && pclust == dj.fs->dirbase) + { + pclust = 0; + } + ST_WORD(&fw[32+DIR_FstClusLO], pclust); + ST_WORD(&fw[32+DIR_FstClusHI], pclust >> 16); + dj.fs->winflag = 1; + + if (!move_window(dj.fs, sect)) + { + return FR_RW_ERROR; + } + memset(&dir[0], 0, 32); /* Initialize the new entry */ + memcpy(&dir[DIR_Name], fn, 8+3); /* Name */ + dir[DIR_NTres] = fn[11]; + dir[DIR_Attr] = AR_DIR; /* Attribute */ + ST_DWORD(&dir[DIR_WrtTime], tim); /* Crated time */ + ST_WORD(&dir[DIR_FstClusLO], dclust); /* Table start cluster */ + ST_WORD(&dir[DIR_FstClusHI], dclust >> 16); + + return sync(dj.fs); +} + + + +FRESULT f_chmod(const char *path, UINT8 value, UINT8 mask) +{ + char fn[8+3+1]; + UINT8 *dir; + FRESULT res; + DIR dj; + + res = auto_mount(&path, &dj.fs, 1); + if (res == FR_OK) + { + res = trace_path(&dj, fn, path, &dir); /* Trace the file path */ + if (res == FR_OK) + { + /* Trace completed */ + if (!dir) + { + res = FR_INVALID_NAME; /* Root directory */ + } + else + { + mask &= AR_RDO|AR_HID|AR_SYS|AR_ARC; /* Valid attribute mask*/ + /* Apply attribute change */ + dir[DIR_Attr] = (value & mask) | (dir[DIR_Attr] & (UINT8)~mask); + res = sync(dj.fs); + } + } + } + return res; +} + + +FRESULT f_utime(const char *path, const FILINFO *finfo) +{ + char fn[8+3+1]; + UINT8 *dir; + FRESULT res; + DIR dj; + + + res = auto_mount(&path, &dj.fs, 1); + if (res == FR_OK) + { + res = trace_path(&dj, fn, path, &dir); /* Trace the file path */ + if (res == FR_OK) + { + /* Trace completed */ + if (!dir) + { + res = FR_INVALID_NAME; /* Root directory */ + } + else + { + ST_WORD(&dir[DIR_WrtTime], finfo->ftime); + ST_WORD(&dir[DIR_WrtDate], finfo->fdate); + res = sync(dj.fs); + } + } + } + return res; +} + + +FRESULT f_rename(const char *path_old, const char *path_new) +{ + UINT32 sect_old; + char fn[8+3+1]; + UINT8 *dir_old; + UINT8 *dir_new; + UINT8 direntry[32-11]; + FRESULT res; + DIR dj; + + res = auto_mount(&path_old, &dj.fs, 1); + if (res != FR_OK) + { + return res; + } + + res = trace_path(&dj, fn, path_old, &dir_old); /* Check old object */ + if (res != FR_OK) + { + return res; /* The old object is not found */ + } + if (!dir_old) + { + return FR_NO_FILE; + } + sect_old = dj.fs->winsect; /* Save the object information */ + memcpy(direntry, &dir_old[DIR_Attr], 32-11); + + res = trace_path(&dj, fn, path_new, &dir_new); /* Check new object */ + if (res == FR_OK) + { + return FR_EXIST; /*New object name already existing */ + } + if (res != FR_NO_FILE) + { + return res; /* Is there no old name? */ + } + res = reserve_direntry(&dj, &dir_new); /* Reserve a directory entry */ + if (res != FR_OK) + { + return res; + } + + memcpy(&dir_new[DIR_Attr], direntry, 32-11); /* Create new entry */ + memcpy(&dir_new[DIR_Name], fn, 8+3); + dir_new[DIR_NTres] = fn[11]; + dj.fs->winflag = 1; + + if (!move_window(dj.fs, sect_old)) + { + return FR_RW_ERROR; /* Delete old entry */ + } + dir_old[DIR_Name] = 0xE5; + + return sync(dj.fs); +} + +#endif /* !_FS_READONLY */ +#endif /* _FS_MINIMIZE == 0 */ +#endif /* _FS_MINIMIZE <= 1 */ +#endif /* _FS_MINIMIZE <= 2 */ + +#if _USE_MKFS && !_FS_READONLY +/*-----------------------------------------------------------------------*/ +/* Create File System on the Drive */ +/*-----------------------------------------------------------------------*/ +#define N_ROOTDIR 512 /* Multiple of 32 and <= 2048 */ +#define N_FATS 1 /* 1 or 2 */ +#define MAX_SECTOR 64000000UL /* Maximum partition size */ +#define MIN_SECTOR 2000UL /* Minimum partition size */ + +FRESULT f_mkfs ( + UINT8 drv, /* Logical drive number */ + UINT8 partition, /* Partitioning rule 0:FDISK, 1:SFD */ + UINT16 allocsize /* Allocation unit size [bytes] */ +) + { + UINT8 fmt, m, *tbl; + UINT32 b_part, b_fat, b_dir, b_data; /* Area offset (LBA) */ + UINT32 n_part, n_rsv, n_fat, n_dir; /* Area size */ + UINT32 n_clust, n; + FATFS *fs; + DSTATUS stat; + + /* Check validity of the parameters */ + if (drv >= _DRIVES) return FR_INVALID_DRIVE; + if (partition >= 2) return FR_MKFS_ABORTED; + for (n = 512; n <= 32768U && n != allocsize; n <<= 1); + if (n != allocsize) return FR_MKFS_ABORTED; + + /* Check mounted drive and clear work area */ + fs = FatFs[drv]; + if (!fs) return FR_NOT_ENABLED; + fs->fs_type = 0; + drv = LD2PD(drv); + + /* Get disk statics */ + stat = disk_initialize(drv); + if (stat & STA_NOINIT) return FR_NOT_READY; + if (stat & STA_PROTECT) return FR_WRITE_PROTECTED; + if (disk_ioctl(drv, GET_SECTOR_COUNT, &n_part) != RES_OK || n_part < MIN_SECTOR) + return FR_MKFS_ABORTED; + if (n_part> MAX_SECTOR) n_part = MAX_SECTOR; + b_part = (!partition) ? 63 : 0; /* Boot sector */ + n_part -= b_part; +#if S_MAX_SIZ > 512 /* Check disk sector size */ + if (disk_ioctl(drv, GET_SECTOR_SIZE, &SS(fs)) != RES_OK + || SS(fs)> S_MAX_SIZ + || SS(fs)> allocsize) + return FR_MKFS_ABORTED; +#endif + allocsize /= SS(fs); /* Number of sectors per cluster */ + + /* Pre-compute number of clusters and FAT type */ + n_clust = n_part / allocsize; + fmt = FS_FAT12; + if (n_clust >= 0xFF5) fmt = FS_FAT16; + if (n_clust >= 0xFFF5) fmt = FS_FAT32; + + /* Determine offset and size of FAT structure */ + switch (fmt) + { + case FS_FAT12: + n_fat = ((n_clust * 3 + 1) / 2 + 3 + SS(fs) - 1) / SS(fs); + n_rsv = 1 + partition; + n_dir = N_ROOTDIR * 32 / SS(fs); + break; + case FS_FAT16: + n_fat = ((n_clust * 2) + 4 + SS(fs) - 1) / SS(fs); + n_rsv = 1 + partition; + n_dir = N_ROOTDIR * 32 / SS(fs); + break; + default: + n_fat = ((n_clust * 4) + 8 + SS(fs) - 1) / SS(fs); + n_rsv = 33 - partition; + n_dir = 0; + } + b_fat = b_part + n_rsv; /* FATs start sector */ + b_dir = b_fat + n_fat * N_FATS; /* Directory start sector */ + b_data = b_dir + n_dir; /* Data start sector */ + + /* Align data start sector to erase block boundary (for flash memory media) */ + if (disk_ioctl(drv, GET_BLOCK_SIZE, &n) != RES_OK) return FR_MKFS_ABORTED; + n = (b_data + n - 1) & ~(n - 1); + n_fat += (n - b_data) / N_FATS; + /* b_dir and b_data are no longer used below */ + + /* Determine number of cluster and final check of validity of the FAT type */ + n_clust = (n_part - n_rsv - n_fat * N_FATS - n_dir) / allocsize; + if ( (fmt == FS_FAT16 && n_clust < 0xFF5) + || (fmt == FS_FAT32 && n_clust < 0xFFF5)) + return FR_MKFS_ABORTED; + + /* Create partition table if needed */ + if (!partition) + { + UINT32 n_disk = b_part + n_part; + + tbl = &fs->win[MBR_Table]; + ST_DWORD(&tbl[0], 0x00010180); /* Partition start in CHS */ + if (n_disk < 63UL * 255 * 1024) + { /* Partition end in CHS */ + n_disk = n_disk / 63 / 255; + tbl[7] = (UINT8)n_disk; + tbl[6] = (UINT8)((n_disk >> 2) | 63); + } else + { + ST_WORD(&tbl[6], 0xFFFF); + } + tbl[5] = 254; + if (fmt != FS_FAT32) /* System ID */ + tbl[4] = (n_part < 0x10000) ? 0x04 : 0x06; + else + tbl[4] = 0x0c; + ST_DWORD(&tbl[8], 63); /* Partition start in LBA */ + ST_DWORD(&tbl[12], n_part); /* Partition size in LBA */ + ST_WORD(&tbl[64], 0xAA55); /* Signature */ + if (disk_write(drv, fs->win, 0, 1) != RES_OK) + return FR_RW_ERROR; + } + + /* Create boot record */ + tbl = fs->win; /* Clear buffer */ + memset(tbl, 0, SS(fs)); + ST_DWORD(&tbl[BS_jmpBoot], 0x90FEEB); /* Boot code (jmp $, nop) */ + ST_WORD(&tbl[BPB_BytsPerSec], SS(fs)); /* Sector size */ + tbl[BPB_SecPerClus] = (UINT8)allocsize; /* Sectors per cluster */ + ST_WORD(&tbl[BPB_RsvdSecCnt], n_rsv); /* Reserved sectors */ + tbl[BPB_NumFATs] = N_FATS; /* Number of FATs */ + ST_WORD(&tbl[BPB_RootEntCnt], SS(fs) / 32 * n_dir); /* Number of rootdir entries */ + if (n_part < 0x10000) + { /* Number of total sectors */ + ST_WORD(&tbl[BPB_TotSec16], n_part); + } else + { + ST_DWORD(&tbl[BPB_TotSec32], n_part); + } + tbl[BPB_Media] = 0xF8; /* Media descripter */ + ST_WORD(&tbl[BPB_SecPerTrk], 63); /* Number of sectors per track */ + ST_WORD(&tbl[BPB_NumHeads], 255); /* Number of heads */ + ST_DWORD(&tbl[BPB_HiddSec], b_part); /* Hidden sectors */ + n = get_fattime(); /* Use current time as a VSN */ + if (fmt != FS_FAT32) + { + ST_DWORD(&tbl[BS_VolID], n); /* Volume serial number */ + ST_WORD(&tbl[BPB_FATSz16], n_fat); /* Number of secters per FAT */ + tbl[BS_DrvNum] = 0x80; /* Drive number */ + tbl[BS_BootSig] = 0x29; /* Extended boot signature */ + memcpy(&tbl[BS_VolLab], "NO NAME FAT ", 19); /* Volume lavel, FAT signature */ + } else + { + ST_DWORD(&tbl[BS_VolID32], n); /* Volume serial number */ + ST_DWORD(&tbl[BPB_FATSz32], n_fat); /* Number of secters per FAT */ + ST_DWORD(&tbl[BPB_RootClus], 2); /* Root directory cluster (2) */ + ST_WORD(&tbl[BPB_FSInfo], 1); /* FSInfo record (bs+1) */ + ST_WORD(&tbl[BPB_BkBootSec], 6); /* Backup boot record (bs+6) */ + tbl[BS_DrvNum32] = 0x80; /* Drive number */ + tbl[BS_BootSig32] = 0x29; /* Extended boot signature */ + memcpy(&tbl[BS_VolLab32], "NO NAME FAT32 ", 19); /* Volume lavel, FAT signature */ + } + ST_WORD(&tbl[BS_55AA], 0xAA55); /* Signature */ + if (disk_write(drv, tbl, b_part+0, 1) != RES_OK) + return FR_RW_ERROR; + if (fmt == FS_FAT32) + disk_write(drv, tbl, b_part+6, 1); + + /* Initialize FAT area */ + for (m = 0; m < N_FATS; m++) + { + memset(tbl, 0, SS(fs)); /* 1st sector of the FAT */ + if (fmt != FS_FAT32) + { + n = (fmt == FS_FAT12) ? 0x00FFFFF8 : 0xFFFFFFF8; + ST_DWORD(&tbl[0], n); /* Reserve cluster #0-1 (FAT12/16) */ + } else + { + ST_DWORD(&tbl[0], 0xFFFFFFF8); /* Reserve cluster #0-1 (FAT32) */ + ST_DWORD(&tbl[4], 0xFFFFFFFF); + ST_DWORD(&tbl[8], 0x0FFFFFFF); /* Reserve cluster #2 for root dir */ + } + if (disk_write(drv, tbl, b_fat++, 1) != RES_OK) + return FR_RW_ERROR; + memset(tbl, 0, SS(fs)); /* Following FAT entries are filled by zero */ + for (n = 1; n < n_fat; n++) + { + if (disk_write(drv, tbl, b_fat++, 1) != RES_OK) + return FR_RW_ERROR; + } + } + + /* Initialize Root directory */ + m = (UINT8)((fmt == FS_FAT32) ? allocsize : n_dir); + do + { + if (disk_write(drv, tbl, b_fat++, 1) != RES_OK) + return FR_RW_ERROR; + }while (--m); + + /* Create FSInfo record if needed */ + if (fmt == FS_FAT32) + { + ST_WORD(&tbl[BS_55AA], 0xAA55); + ST_DWORD(&tbl[FSI_LeadSig], 0x41615252); + ST_DWORD(&tbl[FSI_StrucSig], 0x61417272); + ST_DWORD(&tbl[FSI_Free_Count], n_clust - 1); + ST_DWORD(&tbl[FSI_Nxt_Free], 0xFFFFFFFF); + disk_write(drv, tbl, b_part+1, 1); + disk_write(drv, tbl, b_part+7, 1); + } + + return (disk_ioctl(drv, CTRL_SYNC, NULL) == RES_OK) ? FR_OK : FR_RW_ERROR; + } + +#endif /* _USE_MKFS && !_FS_READONLY */ + +#if _USE_STRFUNC >= 1 +/*-----------------------------------------------------------------------*/ +/* Get a string from the file */ +/*-----------------------------------------------------------------------*/ +char* fgets ( + char* buff, /* Pointer to the string buffer to read */ + int len, /* Size of string buffer */ + FIL* fil /* Pointer to the file object */ +) + { + int i = 0; + char *p = buff; + UINT rc; + + while (i < len - 1) + { /* Read bytes until buffer gets filled */ + f_read(fil, p, 1, &rc); + if (rc != 1) break; /* Break when no data to read */ +#if _USE_STRFUNC >= 2 + if (*p == '\r') continue; /* Strip '\r' */ +#endif + i++; + if (*p++ == '\n') break; /* Break when reached end of line */ + } + *p = 0; + return i ? buff : 0; /* When no data read (eof or error), return with error. */ + } + +#if !_FS_READONLY +#include +/*-----------------------------------------------------------------------*/ +/* Put a character to the file */ +/*-----------------------------------------------------------------------*/ +int fputc ( + int chr, /* A character to be output */ + FIL* fil /* Ponter to the file object */ +) + { + UINT bw; + char c; + +#if _USE_STRFUNC >= 2 + if (chr == '\n') fputc ('\r', fil); /* LF -> CRLF conversion */ +#endif + if (!fil) + { /* Special value may be used to switch the destination to any other device */ + /* put_console(chr); */ + return chr; + } + c = (char)chr; + f_write(fil, &c, 1, &bw); /* Write a byte to the file */ + return bw ? chr : EOF; /* Return the resulut */ + } + +/*-----------------------------------------------------------------------*/ +/* Put a string to the file */ +/*-----------------------------------------------------------------------*/ +int fputs ( + const char* str, /* Pointer to the string to be output */ + FIL* fil /* Pointer to the file object */ +) + { + int n; + + for (n = 0; *str; str++, n++) + { + if (fputc(*str, fil) == EOF) return EOF; + } + return n; + } + +/*-----------------------------------------------------------------------*/ +/* Put a formatted string to the file */ +/*-----------------------------------------------------------------------*/ +int fprintf ( + FIL* fil, /* Pointer to the file object */ + const char* str, /* Pointer to the format string */ + ... /* Optional arguments... */ +) + { + va_list arp; + UCHAR c, f, r; + ULONG val; + char s[16]; + int i, w, res, cc; + + va_start(arp, str); + + for (cc = res = 0; cc != EOF; res += cc) + { + c = *str++; + if (c == 0) break; /* End of string */ + if (c != '%') + { /* Non escape cahracter */ + cc = fputc(c, fil); + if (cc != EOF) cc = 1; + continue; + } + w = f = 0; + c = *str++; + if (c == '0') + { /* Flag: '0' padding */ + f = 1; c = *str++; + } + while (c >= '0' && c <= '9') + { /* Precision */ + w = w * 10 + (c - '0'); + c = *str++; + } + if (c == 'l') + { /* Prefix: Size is long int */ + f |= 2; c = *str++; + } + if (c == 's') + { /* Type is string */ + cc = fputs(va_arg(arp, char*), fil); + continue; + } + if (c == 'c') + { /* Type is character */ + cc = fputc(va_arg(arp, char), fil); + if (cc != EOF) cc = 1; + continue; + } + r = 0; + if (c == 'd') r = 10; /* Type is signed decimal */ + if (c == 'u') r = 10; /* Type is unsigned decimal */ + if (c == 'X') r = 16; /* Type is unsigned hexdecimal */ + if (r == 0) break; /* Unknown type */ + if (f & 2) + { /* Get the value */ + val = (ULONG)va_arg(arp, long); + } else + { + val = (c == 'd') ? (ULONG)(long)va_arg(arp, int) : (ULONG)va_arg(arp, unsigned int); + } + /* Put numeral string */ + if (c == 'd') + { + if (val >= 0x80000000) + { + val = 0 - val; + f |= 4; + } + } + i = sizeof(s) - 1; s[i] = 0; + do + { + c = (UCHAR)(val % r + '0'); + if (c> '9') c += 7; + s[--i] = c; + val /= r; + }while (i && val); + if (i && (f & 4)) s[--i] = '-'; + w = sizeof(s) - 1 - w; + while (i && i> w) s[--i] = (f & 1) ? '0' : ' '; + cc = fputs(&s[i], fil); + } + + va_end(arp); + return (cc == EOF) ? cc : res; + } + +#endif /* !_FS_READONLY */ +#endif /* _USE_STRFUNC >= 1*/ diff --git a/Tester/SW/lib/MmcFilesystem/fat_public.h b/Tester/SW/lib/MmcFilesystem/fat_public.h new file mode 100644 index 0000000..2d15717 --- /dev/null +++ b/Tester/SW/lib/MmcFilesystem/fat_public.h @@ -0,0 +1,345 @@ +/* --------------------------------------------------------------------------- + * FAT_intern.h (C)ChaN, 2008 + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: FatFs - FAT file system module include file R0.06 + * + * FatFs module is an experimenal project to implement FAT file system to + * cheap microcontrollers. This is a free software and is opened for education, + * research and development under license policy of following trems. + * + * Copyright (C) 2008, ChaN, all right reserved. + * + * The FatFs module is a free software and there is no warranty. + * You can use, modify and/or redistribute it for personal, non-profit or + * commercial use without any restriction under your responsibility. + * Redistributions of source code must retain the above copyright notice. + * --------------------------------------------------------------------------- + */ +/* --------------------------------------------------------------------------- + * Version(s): 0.2, Aug 11, 2008, MMi + * Edited to fit into LAN_2636 Project + * + * 0.1, 2008 ChanN + * Creation + * --------------------------------------------------------------------------- + */ +#ifndef FAT_PUBLIC_H_ +#define FAT_PUBLIC_H_ +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ +#include "LPC23xx.h" +#include "types.h" + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ +#include "fat_intern.h" +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ + +void FAT_StatusOut (FRESULT result); + +/* --------------------------------------------------------------------------- + * Function: f_mount + * + * Function mounts or unmounts a logical drive + * + * Parameters: UINT8 drive - Device number that should be (un)mounted + * FATFS *fs - Pointer to a clean file system structure + * + * Return : FRESULT - Result if mounting was successful or not + * --------------------------------------------------------------------------- + */ +FRESULT f_mount (UINT8 drive, FATFS *fs); + + +/* --------------------------------------------------------------------------- + * Function: f_open + * + * Function opens or creates a file, depending on the rights given by the + * Attributes in mode. The Filename must contain the whole physical path, so + * include every subfolder. If using multible drives, the drivenumber is also + * necessary. Skipping the drivenumber forces the System to use 0 as drive + * number. So in single drive mode, drive number should be 0. + * + * Parameters: FIL *fp - Pointer to a clean file structure + * const char *path - Name of the File ("drive:subdir/file.ext") + * + * Return : FRESULT - Result if opening was successful or not + * --------------------------------------------------------------------------- + */ +FRESULT f_open (FIL *fp, const char *path, UINT8 mode); + + +/* --------------------------------------------------------------------------- + * Function: f_read + * + * Function to read from a file. File needs to be opened before with f_open. + * The file structure of this is then given tp f_read. Data is read to *buff. + * + * Parameters: FIL *fp - Pointer to opened file structure + * void *buff - Array to read to + * UINT32 btr - indicates how much bytes should be read + * UINT32 *br - returns, how much uch bytes are already read + * + * Return : FRESULT - Result if reading was successful or not + * --------------------------------------------------------------------------- + */ +FRESULT f_read (FIL *fp, void *buff, UINT32 btr, UINT32 *br); + + +/* --------------------------------------------------------------------------- + * Function: f_write + * + * Function to write to a file. File needs to be opened before with f_open. + * The file structure of this is then given tp f_write. Data is written from + * *buff. + * + * Parameters: FIL *fp - Pointer to opened file structure + * void *buff - Array to write from + * UINT32 btr - indicates how much bytes should be written + * UINT32 *br - returns, how much uch bytes are already written + * + * Return : FRESULT - Result if writing was successful or not + * --------------------------------------------------------------------------- + */ +FRESULT f_write (FIL *fp, const void *buff, UINT32 btw, UINT32 *bw); + + +/* --------------------------------------------------------------------------- + * Function: f_sync + * + * Function to flush cached data of a written file + * + * Parameters: FIL *fp - Pointer to opened file structure + * + * Return : FRESULT - Result if syncing was successful or not + * --------------------------------------------------------------------------- + */ +FRESULT f_sync(FIL *fp); + + +/* --------------------------------------------------------------------------- + * Function: f_close + * + * Function to close a opened file. The file is then not accessible anymore. + * + * Parameters: FIL *fp - Pointer to opened file structure + * + * Return : FRESULT - Result if closing was successful or not + * --------------------------------------------------------------------------- + */ +FRESULT f_close(FIL *fp); + + +/* --------------------------------------------------------------------------- + * Function: f_lseek + * + * Function to move the file pointer. When creating a file, the pointer is at + * offset 0x00. After writing or reading, the pointer is moved by the number + * of bytes that have been read. + * + * Parameters: FIL *fp - Pointer to opened file structure + * + * Return : FRESULT - Result if seeking was successful or not + * --------------------------------------------------------------------------- + */ +FRESULT f_lseek (FIL *fp, UINT32 ofs); + + +/* --------------------------------------------------------------------------- + * Function: f_opendir + * + * Function to open an already existing directory. Fails, if directory is not + * available or accessible. + * + * Parameters: DIR *dj - Pointer to clean directory structure + * const char *path - Directory name ("dir/subdir/subsubdir") + * + * Return : FRESULT - Result if opening was successful or not + * --------------------------------------------------------------------------- + */ +FRESULT f_opendir (DIR *dj, const char *path); + + +/* --------------------------------------------------------------------------- + * Function: f_readdir + * + * Function to read a directory Item + * + * Parameters: DIR *dj - Pointer to directory structure + * FILINFO *finfo - Pointer to a clean file info structure + * + * Return : FRESULT - Result if reading was successful or not + * --------------------------------------------------------------------------- + */ +FRESULT f_readdir (DIR *dj, FILINFO *finfo); + + +/* --------------------------------------------------------------------------- + * Function: f_stat + * + * Function to get a file status + * + * Parameters: const char* path - Name of the path + * FILINFO *finfo - Pointer to a clean file info structure + * + * Return : FRESULT - Result if reading was successful or not + * --------------------------------------------------------------------------- + */ +FRESULT f_stat(const char* path, FILINFO* finfo); + +/* --------------------------------------------------------------------------- + * Function: f_truncate + * + * Function to truncate/abort + * + * Parameters: FIL *fp - Pointer to a opened file object structure + * + * + * Return : FRESULT - Result if aborting was successful or not + * --------------------------------------------------------------------------- + */ +FRESULT f_truncate(FIL *fp); + + +/* --------------------------------------------------------------------------- + * Function: f_getfree + * + * Function to get free clusters on the drive + * + * Parameters: const char* drive - Number of drive + * UINT32 *nclust - Pointer to store number of free clusters + * FATFS **fats - Pointer to Pointer to file system + * + * + * Return : FRESULT - Result if getting was successful or not + * --------------------------------------------------------------------------- + */ +FRESULT f_getfree (const char *drv, UINT32 *nclust, FATFS **fatfs); + + +/* --------------------------------------------------------------------------- + * Function: f_unlink + * + * Function to delete an existing file or directory. + * NOTE: Directories must be empty before deleting! + * + * Parameters: const char* path - Name of file/directory + * + * Return : FRESULT - Result if deleting was successful or not + * --------------------------------------------------------------------------- + */ +FRESULT f_unlink(const char* path); + + +/* --------------------------------------------------------------------------- + * Function: f_mkdir + * + * Function to create directories. + * Syntax: "dir/subdir/subsubdir" + * + * Parameters: const char* path - Name/Path of directory + * + * Return : FRESULT - Result if creating was successful or not + * --------------------------------------------------------------------------- + */ +FRESULT f_mkdir(const char* path); + +/* --------------------------------------------------------------------------- + * Function: f_chmod + * + * Function to change attributes of files and directories. + * Usage example: + * To set read-only flag, clear archive flag and retain others: + * f_chmod("file.txt", AR_RDO, (AR_RDO | AR_ARC)); + * + * Parameters: const char* path - Name of file/directory + * UINT8 value - The Attribute Bits to SET + * UINT8 mask - All Attribute Bits to CHANGE + * + * Return : FRESULT - Result if changing was successful or not + * --------------------------------------------------------------------------- + */ +FRESULT f_chmod (const char *path, UINT8 value, UINT8 mask); + + +/* --------------------------------------------------------------------------- + * Function: f_utime + * + * Function to change timestamp of file or directory + * + * Parameters: const char* path - Name of file/directory + * const FILINFO *finfo - file info structure with new timestamp + * + * Return : FRESULT - Result if changing was successful or not + * --------------------------------------------------------------------------- + */ +FRESULT f_utime (const char *path, const FILINFO *finfo); + + +/* --------------------------------------------------------------------------- + * Function: f_rename + * + * Function to rename and move a file or directory. + * Usage: To move a file, simply give the complete physical path in path_new + * + * NOTE: The original author mentioned that movies directories to other + * directories seems to collapse the FAT, but all tests with this were + * positive without any problems. If FAT collapses after moving directories, + * refer to here! + * + * Parameters: const char* path_old - Old Name of file/directory + * const char* path_new - New Name of file/directory + * + * Return : FRESULT - Result if moving/renaming was successful or not + * --------------------------------------------------------------------------- + */ +FRESULT f_rename (const char *path_old, const char *path_new); + + +/* --------------------------------------------------------------------------- + * Function: f_mkfs + * + * Function to make/create a file system + * + * NOTE: Is usually unused! + * + * Parameters: UINT8 drv - Drive number + * UINT8 partition - Partition number + * UINT16 allocsize - Allocating unit size in bytes + * + * Return : FRESULT - Result if moving/renaming was successful or not + * --------------------------------------------------------------------------- + */ +FRESULT f_mkfs (UINT8 drv, UINT8 partition, UINT16 allocsize); +#endif /*FAT_PUBLIC_H_*/ diff --git a/Tester/SW/lib/MmcFilesystem/fat_test.c b/Tester/SW/lib/MmcFilesystem/fat_test.c new file mode 100644 index 0000000..2932062 --- /dev/null +++ b/Tester/SW/lib/MmcFilesystem/fat_test.c @@ -0,0 +1,244 @@ +/* --------------------------------------------------------------------------- + * dosfs_test.c (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Jul 29, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +/* Compiler includes */ +#include +#include + +#include "LPC23xx.h" +#include "types.h" + +/* FreeRTOS includes */ +#include "FreeRTOS.h" +#include "task.h" +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "fat_test.h" +#include "fat_intern.h" +#include "fat_public.h" +#include "fat_diskio.h" +#include "mmc.h" +#include "SerOut.h" +#include "serial.h" + +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ +UINT8 ff_Write[0x200]; /* used with MMC Write Function */ +UINT8 ff_Read[0x200]; +UINT8 test_Write[0x200]; +UINT8 test_Read1[0x200]; +UINT8 test_Read2[0x200]; +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ + +void ffTestStart (void) +{ + UINT32 loopcnt; + MmcState_t CardStatus; + + /* Clear Terminal Screen with VT100 Command */ + serWrite(SerOutPort, sizeof("\x1B[2J"), "\x1B[2J"); /*WARNING don't care*/ + + MmcInitMedia(); /* Init Card and give Status */ + + + /* Test that write and Read work */ + CardStatus = disk_write (0, (pUINT8)ff_Write, 3, 1); + + CardStatus = disk_read (0, (pUINT8)ff_Read, 3, 1); + + for (loopcnt = 0; loopcnt < 0x200; loopcnt++) + { + if (ff_Write[loopcnt] != ff_Read[loopcnt]) + { + debugPrint ("\n\rCompare ERROR"); + break; + } + ff_Write[loopcnt] = 0; + ff_Read[loopcnt] = 0; + } + vTaskDelay(1000); + + +/* --------------------------------------------------------------------------- + * BEGINN FAT TEST SEQUENCE + * --------------------------------------------------------------------------- + */ + + + /* Mount SD-Card as virtual drive 0 */ + FATFS volume_object; + debugPrint ("\n\r-----"); + debugPrint ("\n\rMount Volume as Drive 0"); + FAT_StatusOut (f_mount (0, &volume_object)); + + + vTaskDelay (100); + /* FILE ACCESS TESTS + * Open a File. If file does not exist, create it + * Close File + * Delete File + */ + FIL file_1; /* create a blank File structure */ + debugPrint ("\n\r-----"); + debugPrint ("\n\rOpen, Close and Delete a File"); + FAT_StatusOut (f_open (&file_1, "test.fil", (FA_CREATE_ALWAYS))); + FAT_StatusOut (f_close (&file_1)); + FAT_StatusOut (f_unlink ("test.fil")); + + vTaskDelay (100); + /* DIRECTORY ACCESS TESTS + * Create a subdirectory + * Open a File in the subdirectory. If file does not exist, create it + * Sync File + * Leave file opened + */ + debugPrint ("\n\r-----"); + debugPrint ("\n\rCreate subdirs, create file in subdir, sync file, delete subdir"); + FAT_StatusOut (f_mkdir ("subdir")); + FAT_StatusOut (f_mkdir ("deleteme")); + FAT_StatusOut (f_open (&file_1, "subdir/test.dat", (FA_READ | FA_WRITE | FA_CREATE_ALWAYS))); + FAT_StatusOut (f_sync (&file_1)); + FAT_StatusOut (f_unlink ("deleteme")); + + + vTaskDelay (100); + /* FILE READ/WRITE TESTS + * Read MBR from Disc into an Array + * Open a file. If file does not exist, create it with read and write access + * Write MBR from Array in opened/created file + * Write MBR in already opened file from above (test.dat) + * Sync both files + * Set File Pointer for both files to offset 0x00 + * Read both files and compare content with original MBR + * Close both files + * + * Shown with this is that the file system is capable of multifile access + * by usage of the fil information structure. + */ + UINT32 bytes_written; + UINT32 bytes_read; + FIL file_2; /* create a blank File structure */ + debugPrint ("\n\r-----"); + debugPrint ("\n\rOpen, write and read to files"); + disk_read (0, (pUINT8)test_Write, 0, 1); + FAT_StatusOut (f_open (&file_2, "write.txt", (FA_WRITE | FA_READ | FA_CREATE_ALWAYS))); + FAT_StatusOut (f_write (&file_2, &test_Write, 0x200, &bytes_written)); + FAT_StatusOut (f_write (&file_1, &test_Write, 0x200, &bytes_written)); + FAT_StatusOut (f_sync (&file_2)); + FAT_StatusOut (f_sync (&file_1)); + FAT_StatusOut (f_lseek (&file_2, 0x00)); + FAT_StatusOut (f_lseek (&file_1, 0x00)); + FAT_StatusOut (f_read (&file_2, &test_Read1, 0x200, &bytes_read)); + FAT_StatusOut (f_read (&file_1, &test_Read2, 0x200, &bytes_read)); + for (loopcnt = 0; loopcnt < 0x200; loopcnt++) + { + if ((test_Write[loopcnt] != test_Read1[loopcnt]) + || (test_Write[loopcnt] != test_Read2[loopcnt])) + { + /* Strings are not equal */ + debugPrint ("\n\rCompare Error"); + break; + } + } + FAT_StatusOut (f_close (&file_2)); + FAT_StatusOut (f_close (&file_1)); + + vTaskDelay (100); + /* RENAMING FILE AND DIRECTORY + * Create two files and two Directories + * Rename a File + * Rename a Directory + * Move a File + * Move a Directory + * Combine moving with renaming + * Close both files + */ + debugPrint ("\n\r-----"); + debugPrint ("\n\rCreate, Rename and Move each a file and a directory"); + FAT_StatusOut (f_open (&file_1, "rename1.old", (FA_CREATE_ALWAYS))); + FAT_StatusOut (f_open (&file_2, "rename2.old", (FA_CREATE_ALWAYS))); + FAT_StatusOut (f_mkdir ("renameme")); + FAT_StatusOut (f_mkdir ("movehere")); + FAT_StatusOut (f_rename ("rename1.old", "renamed1.new")); + FAT_StatusOut (f_rename ("renameme", "renamed")); + FAT_StatusOut (f_rename ("renamed1.new", "movehere/renamed1.new")); + FAT_StatusOut (f_rename ("renamed", "movehere/renamed")); + FAT_StatusOut (f_rename ("rename2.old", "movehere/renamed2.new")); + FAT_StatusOut (f_close (&file_1)); + FAT_StatusOut (f_close (&file_2)); + + + vTaskDelay (100); + /* CHANGING FILES + * Open a file. If not available, create it + * change Attributes (SET HIDDEN, set READ ONLY, clear ARCHIVE) + */ + debugPrint ("\n\r-----"); + debugPrint ("\n\rChange Attributes"); + FAT_StatusOut (f_open (&file_1, "attr.dat", (FA_READ | FA_WRITE | FA_CREATE_ALWAYS))); + FAT_StatusOut (f_chmod ("attr.dat", (AR_HID | AR_RDO), (AR_HID | AR_RDO | AR_ARC))); + FAT_StatusOut (f_close (&file_1)); + + + vTaskDelay (100); + /* DO A SPEED TEST + * Fill write array with signs + * Open "speed.txt. If file does not exist, create it with write access + * Write Buffer x-Times to the speed.txt + */ + UINT8 character = 48; + debugPrint ("\n\r-----"); + debugPrint ("\n\rSpeed Test"); + for (loopcnt = 0; loopcnt < 0x200; loopcnt++) + { + ff_Write[loopcnt] = character; + } + FAT_StatusOut (f_open (&file_1, "speed.txt", (FA_WRITE | FA_OPEN_ALWAYS))); + + for (loopcnt = 0; loopcnt < 20000; loopcnt++) + { + f_write (&file_1, &ff_Write, 0x200, &bytes_written); + } + FAT_StatusOut (f_close (&file_1)); + + + debugPrint ("\n\rREADY!!!"); +} + diff --git a/Tester/SW/lib/MmcFilesystem/fat_test.h b/Tester/SW/lib/MmcFilesystem/fat_test.h new file mode 100644 index 0000000..fe1a88a --- /dev/null +++ b/Tester/SW/lib/MmcFilesystem/fat_test.h @@ -0,0 +1,56 @@ +/* --------------------------------------------------------------------------- + * dosfs_test.h (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Jul 29, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef DOSFS_TEST_H_ +#define DOSFS_TEST_H_ +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ +#include "LPC23xx.h" +#include "types.h" + +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ +#include "FAT_intern.h" +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ + +void ffTestStart (void); + +#endif /*DOSFS_TEST_H_*/ diff --git a/Tester/SW/lib/MmcFilesystem/fat_time.c b/Tester/SW/lib/MmcFilesystem/fat_time.c new file mode 100644 index 0000000..7f017dd --- /dev/null +++ b/Tester/SW/lib/MmcFilesystem/fat_time.c @@ -0,0 +1,79 @@ +/* --------------------------------------------------------------------------- + * fat_time.c (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Aug 11, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * System include files + * --------------------------------------------------------------------------- + */ +#include "LPC23xx.h" +#include "types.h" +/* --------------------------------------------------------------------------- + * Application include files + * --------------------------------------------------------------------------- + */ +#include "rtc.h" +/* --------------------------------------------------------------------------- + * Local constant and macro definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Global variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local variable definitions + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Local function definitions + * --------------------------------------------------------------------------- + */ + +UINT32 get_fattime (void) +{ + UINT32 complete_time; + UINT16 time; + UINT16 date; + t_rtc rtcReadValue; + + rtcRead (&rtcReadValue); + + + /* Read and calculate time stamps from RTC for the FAT time stamps */ + time =((rtcReadValue.hour << 11) /* Add hours (5 Bits) */ + |(rtcReadValue.min << 5) /* Add minutes (6 Bits) */ + |(rtcReadValue.sec / 2) /* Add seconds (5 Bits) (* 2) */ + ); /* Seconds with resolution of 2 */ + + /* Read and calculate date stamps from RTC for the FAT date stamps */ + date =(((rtcReadValue.year - 1980) << 9) /* Add year (7 Bits) */ + |(rtcReadValue.mon << 5) /* Add month (4 Bits) */ + |(rtcReadValue.day) /* Add day (5 Bits) */ + ); /* Year since in 1980 */ + + + /* Calculate a 32 Bit value used by the FAT system */ + complete_time = ((date << 16) | time); + + return (complete_time); + +} diff --git a/Tester/SW/lib/MmcFilesystem/fat_time.h b/Tester/SW/lib/MmcFilesystem/fat_time.h new file mode 100644 index 0000000..50ab33a --- /dev/null +++ b/Tester/SW/lib/MmcFilesystem/fat_time.h @@ -0,0 +1,64 @@ +/* --------------------------------------------------------------------------- + * fat_time.h (c) 2008 Micro-key bv + * --------------------------------------------------------------------------- + * Micro-key bv + * Industrieweg 28, 9804 TG Noordhorn + * Postbus 92, 9800 AB Zuidhorn + * The Netherlands + * Tel: +31 594 503020 + * Fax: +31 594 505825 + * Email: support@microkey.nl + * Web: www.microkey.nl + * --------------------------------------------------------------------------- + * Description: + * --------------------------------------------------------------------------- + * Version(s): 0.1, Aug 11, 2008, MMi + * Creation. + * --------------------------------------------------------------------------- + */ +#ifndef FAT_TIME_H_ +#define FAT_TIME_H_ +/* --------------------------------------------------------------------------- + * System include files. + * --------------------------------------------------------------------------- + */ +#include "LPC23xx.h" +#include "types.h" +/* --------------------------------------------------------------------------- + * Application include files. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Constant and macro definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Type definitions. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Variable declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function declarations. + * --------------------------------------------------------------------------- + */ + +/* --------------------------------------------------------------------------- + * Function: get_fattime + * + * Function to read time from RTC and format values into needed 32 Bit value + * + * Parameters: void + * + * Return : UINT32 - Time value + * --------------------------------------------------------------------------- + */ +UINT32 get_fattime (void); + +#endif /*FAT_TIME_H_*/
LocalRemoteStateRetransmissionsTimerFlags