//=============================================================================================== //*---------------------------------------------------------------------------- //* \fn AT91F_TWI_Open //* \brief Initializes TWI device //*---------------------------------------------------------------------------- void AT91F_TWI_Init(void) { TWI_QUEUE = xQueueCreate( 1, sizeof( unsigned int ) ); TWI_NACK_Error = ErrorCreate("TWI Nack"); TWI_TMO_Error = ErrorCreate("TWI TimeOut"); TWI_SEM_Error = ErrorCreate("TWI Access"); TWI_WriteData_Error = ErrorCreate("TWI Write"); TWI_OVRE_Error = ErrorCreate("TWI OVRE"); vSemaphoreCreateBinary( TWI_Semaphore ); while( TWI_QUEUE == 0 ) ; // Queue was not created and must not be used. portENTER_CRITICAL(); { // Configure TWI in master mode AT91F_TWI_Configure (AT91C_BASE_TWI); // Configure TWI PIOs AT91F_PIO_CfgOutput(AT91C_BASE_PIOA, AT91C_PA1_TWCK ); AT91F_PIO_CfgOpendrain(AT91C_BASE_PIOA, // PIO controller base address ((unsigned int) AT91C_PA1_TWCK ) | ((unsigned int) AT91C_PA0_TWD ) ); AT91F_TWI_CfgPIO(); // Configure PMC by enabling TWI clock AT91F_TWI_CfgPMC (); // AT91F_PMC_EnablePeriphClock ( AT91C_BASE_PMC, 1<<AT91C_ID_TWI ) ; // Set TWI Clock Waveform Generator Register AT91F_SetTwiClock(); AT91F_AIC_ConfigureIt ( AT91C_BASE_AIC, AT91C_ID_TWI, TWI_INTERRUPT_LEVEL, AT91C_AIC_SRCTYPE_INT_LEVEL_SENSITIVE, ( void (*)( void ) )AT91_TWI_ISR_ENTRY); AT91F_AIC_EnableIt (AT91C_BASE_AIC, AT91C_ID_TWI); TWI_TransferStatus = FREE; } portEXIT_CRITICAL(); }
/* This example takes awhile to execute. It uses simulated annealing to fit an RBF network to the iris data set. You can see the output from the example here. As you can see, it took 2000 iterations to train to 0.78. You can see that it is able to classify many of the iris species correctly, but not all. This example uses one-of-n encoding for the iris species. Equilateral could have also been used. Iteration #1: Score: 0.500285 Iteration #2: Score: 0.500285 Iteration #3: Score: 0.500285 Iteration #4: Score: 0.500285 Iteration #5: Score: 0.500285 Iteration #6: Score: 0.500285 Iteration #7: Score: 0.500285 Iteration #8: Score: 0.500285 Iteration #9: Score: 0.500285 Iteration #10: Score: 0.500285 Iteration #11: Score: 0.500285 Iteration #12: Score: 0.500285 Iteration #13: Score: 0.500285 Iteration #14: Score: 0.500285 Iteration #15: Score: 0.500285 Iteration #16: Score: 0.500285 Iteration #17: Score: 0.500285 Iteration #18: Score: 0.500285 Iteration #19: Score: 0.500285 Iteration #20: Score: 0.500285 Iteration #21: Score: 0.500285 Iteration #22: Score: 0.500285 Iteration #23: Score: 0.500285 Iteration #24: Score: 0.500285 Iteration #25: Score: 0.500285 Iteration #26: Score: 0.500285 Iteration #27: Score: 0.500285 Iteration #28: Score: 0.500285 Iteration #29: Score: 0.500285 Iteration #30: Score: 0.500285 Iteration #31: Score: 0.500285 Iteration #32: Score: 0.500285 Iteration #33: Score: 0.500285 Iteration #34: Score: 0.500285 Iteration #35: Score: 0.500285 Iteration #36: Score: 0.500285 Iteration #37: Score: 0.500285 Iteration #38: Score: 0.500285 Iteration #39: Score: 0.500285 Iteration #40: Score: 0.500285 Iteration #41: Score: 0.500285 Iteration #42: Score: 0.500285 Iteration #43: Score: 0.500285 Iteration #44: Score: 0.500285 Iteration #45: Score: 0.500285 Iteration #46: Score: 0.500285 Iteration #47: Score: 0.500285 Iteration #48: Score: 0.500285 Iteration #49: Score: 0.500285 Iteration #50: Score: 0.500285 Iteration #51: Score: 0.500285 Iteration #52: Score: 0.500285 Iteration #53: Score: 0.500285 Iteration #54: Score: 0.500285 Iteration #55: Score: 0.500285 Iteration #56: Score: 0.500285 Iteration #57: Score: 0.500285 Iteration #58: Score: 0.500285 Iteration #59: Score: 0.500285 Iteration #60: Score: 0.500285 Iteration #61: Score: 0.500285 Iteration #62: Score: 0.500285 Iteration #63: Score: 0.500285 Iteration #64: Score: 0.500285 Iteration #65: Score: 0.500285 Iteration #66: Score: 0.500285 Iteration #67: Score: 0.500285 Iteration #68: Score: 0.500285 Iteration #69: Score: 0.500285 Iteration #70: Score: 0.500285 Iteration #71: Score: 0.500285 Iteration #72: Score: 0.500285 Iteration #73: Score: 0.500285 Iteration #74: Score: 0.500285 Iteration #75: Score: 0.500285 Iteration #76: Score: 0.500285 Iteration #77: Score: 0.500285 ... Iteration #1951: Score: 0.081008 Iteration #1952: Score: 0.081008 Iteration #1953: Score: 0.081008 Iteration #1954: Score: 0.081008 Iteration #1955: Score: 0.081008 Iteration #1956: Score: 0.081008 Iteration #1957: Score: 0.081008 Iteration #1958: Score: 0.081008 Iteration #1959: Score: 0.080988 Iteration #1960: Score: 0.080988 Iteration #1961: Score: 0.080988 Iteration #1962: Score: 0.080988 Iteration #1963: Score: 0.080988 Iteration #1964: Score: 0.080988 Iteration #1965: Score: 0.080988 Iteration #1966: Score: 0.080988 Iteration #1967: Score: 0.080988 Iteration #1968: Score: 0.080988 Iteration #1969: Score: 0.080988 Iteration #1970: Score: 0.080988 Iteration #1971: Score: 0.080988 Iteration #1972: Score: 0.080789 Iteration #1973: Score: 0.080725 Iteration #1974: Score: 0.080710 Iteration #1975: Score: 0.080710 Iteration #1976: Score: 0.080464 Iteration #1977: Score: 0.080153 Iteration #1978: Score: 0.080153 Iteration #1979: Score: 0.080153 Iteration #1980: Score: 0.080120 Iteration #1981: Score: 0.080021 Iteration #1982: Score: 0.080021 Iteration #1983: Score: 0.080021 Iteration #1984: Score: 0.080021 Iteration #1985: Score: 0.080021 Iteration #1986: Score: 0.080006 Iteration #1987: Score: 0.079343 Iteration #1988: Score: 0.079343 Iteration #1989: Score: 0.079343 Iteration #1990: Score: 0.078997 Iteration #1991: Score: 0.078155 Iteration #1992: Score: 0.078155 Iteration #1993: Score: 0.078155 Iteration #1994: Score: 0.078155 Iteration #1995: Score: 0.077979 Iteration #1996: Score: 0.077960 Iteration #1997: Score: 0.077717 Iteration #1998: Score: 0.077717 Iteration #1999: Score: 0.077640 Iteration #2000: Score: 0.077640 Iteration #2001: Score: 0.077640 [0.22,0.62,0.07,0.04] -> Actual: [Iris-setosa], Ideal: [Iris-setosa] [0.17,0.42,0.07,0.04] -> Actual: [Iris-setosa], Ideal: [Iris-setosa] [0.11,0.50,0.05,0.04] -> Actual: [Iris-setosa], Ideal: [Iris-setosa] [0.08,0.46,0.08,0.04] -> Actual: [Iris-setosa], Ideal: [Iris-setosa] [0.19,0.67,0.07,0.04] -> Actual: [Iris-setosa], Ideal: [Iris-setosa] [0.31,0.79,0.12,0.13] -> Actual: [Iris-setosa], Ideal: [Iris-setosa] [0.08,0.58,0.07,0.08] -> Actual: [Iris-setosa], Ideal: [Iris-setosa] [0.19,0.58,0.08,0.04] -> Actual: [Iris-setosa], Ideal: [Iris-setosa] [0.03,0.37,0.07,0.04] -> Actual: [Iris-setosa], Ideal: [Iris-setosa] [0.17,0.46,0.08,0.00] -> Actual: [Iris-setosa], Ideal: [Iris-setosa] [0.31,0.71,0.08,0.04] -> Actual: [Iris-setosa], Ideal: [Iris-setosa] [0.14,0.58,0.10,0.04] -> Actual: [Iris-setosa], Ideal: [Iris-setosa] [0.14,0.42,0.07,0.00] -> Actual: [Iris-setosa], Ideal: [Iris-setosa] [0.00,0.42,0.02,0.00] -> Actual: [Iris-setosa], Ideal: [Iris-setosa] [0.42,0.83,0.03,0.04] -> Actual: [Iris-setosa], Ideal: [Iris-setosa] [0.39,1.00,0.08,0.13] -> Actual: [Iris-setosa], Ideal: [Iris-setosa] [0.31,0.79,0.05,0.13] -> Actual: [Iris-setosa], Ideal: [Iris-setosa] [0.22,0.62,0.07,0.08] -> Actual: [Iris-setosa], Ideal: [Iris-setosa] [0.39,0.75,0.12,0.08] -> Actual: [Iris-setosa], Ideal: [Iris-setosa] [0.22,0.75,0.08,0.08] -> Actual: [Iris-setosa], Ideal: [Iris-setosa] [0.31,0.58,0.12,0.04] -> Actual: [Iris-setosa], Ideal: [Iris-setosa] [0.22,0.71,0.08,0.13] -> Actual: [Iris-setosa], Ideal: [Iris-setosa] [0.08,0.67,0.00,0.04] -> Actual: [Iris-setosa], Ideal: [Iris-setosa] [0.22,0.54,0.12,0.17] -> Actual: [Iris-setosa], Ideal: [Iris-setosa] [0.14,0.58,0.15,0.04] -> Actual: [Iris-setosa], Ideal: [Iris-setosa] [0.19,0.42,0.10,0.04] -> Actual: [Iris-setosa], Ideal: [Iris-setosa] [0.19,0.58,0.10,0.13] -> Actual: [Iris-setosa], Ideal: [Iris-setosa] [0.25,0.62,0.08,0.04] -> Actual: [Iris-setosa], Ideal: [Iris-setosa] [0.25,0.58,0.07,0.04] -> Actual: [Iris-setosa], Ideal: [Iris-setosa] [0.11,0.50,0.10,0.04] -> Actual: [Iris-setosa], Ideal: [Iris-setosa] [0.14,0.46,0.10,0.04] -> Actual: [Iris-setosa], Ideal: [Iris-setosa] [0.31,0.58,0.08,0.13] -> Actual: [Iris-setosa], Ideal: [Iris-setosa] [0.25,0.87,0.08,0.00] -> Actual: [Iris-setosa], Ideal: [Iris-setosa] [0.33,0.92,0.07,0.04] -> Actual: [Iris-setosa], Ideal: [Iris-setosa] [0.17,0.46,0.08,0.00] -> Actual: [Iris-setosa], Ideal: [Iris-setosa] [0.19,0.50,0.03,0.04] -> Actual: [Iris-setosa], Ideal: [Iris-setosa] [0.33,0.62,0.05,0.04] -> Actual: [Iris-setosa], Ideal: [Iris-setosa] [0.17,0.46,0.08,0.00] -> Actual: [Iris-setosa], Ideal: [Iris-setosa] [0.03,0.42,0.05,0.04] -> Actual: [Iris-setosa], Ideal: [Iris-setosa] [0.22,0.58,0.08,0.04] -> Actual: [Iris-setosa], Ideal: [Iris-setosa] [0.19,0.62,0.05,0.08] -> Actual: [Iris-setosa], Ideal: [Iris-setosa] [0.06,0.12,0.05,0.08] -> Actual: [Iris-versicolor], Ideal: [Iris-setosa] [0.03,0.50,0.05,0.04] -> Actual: [Iris-setosa], Ideal: [Iris-setosa] [0.19,0.62,0.10,0.21] -> Actual: [Iris-setosa], Ideal: [Iris-setosa] [0.22,0.75,0.15,0.13] -> Actual: [Iris-setosa], Ideal: [Iris-setosa] [0.14,0.42,0.07,0.08] -> Actual: [Iris-setosa], Ideal: [Iris-setosa] [0.22,0.75,0.10,0.04] -> Actual: [Iris-setosa], Ideal: [Iris-setosa] [0.08,0.50,0.07,0.04] -> Actual: [Iris-setosa], Ideal: [Iris-setosa] [0.28,0.71,0.08,0.04] -> Actual: [Iris-setosa], Ideal: [Iris-setosa] [0.19,0.54,0.07,0.04] -> Actual: [Iris-setosa], Ideal: [Iris-setosa] [0.75,0.50,0.63,0.54] -> Actual: [Iris-virginica], Ideal: [Iris-versicolor] [0.58,0.50,0.59,0.58] -> Actual: [Iris-virginica], Ideal: [Iris-versicolor] [0.72,0.46,0.66,0.58] -> Actual: [Iris-virginica], Ideal: [Iris-versicolor] [0.33,0.12,0.51,0.50] -> Actual: [Iris-versicolor], Ideal: [Iris-versicolor] [0.61,0.33,0.61,0.58] -> Actual: [Iris-versicolor], Ideal: [Iris-versicolor] [0.39,0.33,0.59,0.50] -> Actual: [Iris-versicolor], Ideal: [Iris-versicolor] [0.56,0.54,0.63,0.62] -> Actual: [Iris-virginica], Ideal: [Iris-versicolor] [0.17,0.17,0.39,0.38] -> Actual: [Iris-versicolor], Ideal: [Iris-versicolor] [0.64,0.37,0.61,0.50] -> Actual: [Iris-versicolor], Ideal: [Iris-versicolor] [0.25,0.29,0.49,0.54] -> Actual: [Iris-versicolor], Ideal: [Iris-versicolor] [0.19,0.00,0.42,0.38] -> Actual: [Iris-versicolor], Ideal: [Iris-versicolor] [0.44,0.42,0.54,0.58] -> Actual: [Iris-versicolor], Ideal: [Iris-versicolor] [0.47,0.08,0.51,0.38] -> Actual: [Iris-versicolor], Ideal: [Iris-versicolor] [0.50,0.37,0.63,0.54] -> Actual: [Iris-versicolor], Ideal: [Iris-versicolor] [0.36,0.37,0.44,0.50] -> Actual: [Iris-versicolor], Ideal: [Iris-versicolor] [0.67,0.46,0.58,0.54] -> Actual: [Iris-virginica], Ideal: [Iris-versicolor] [0.36,0.42,0.59,0.58] -> Actual: [Iris-versicolor], Ideal: [Iris-versicolor] [0.42,0.29,0.53,0.38] -> Actual: [Iris-versicolor], Ideal: [Iris-versicolor] [0.53,0.08,0.59,0.58] -> Actual: [Iris-versicolor], Ideal: [Iris-versicolor] [0.36,0.21,0.49,0.42] -> Actual: [Iris-versicolor], Ideal: [Iris-versicolor] [0.44,0.50,0.64,0.71] -> Actual: [Iris-virginica], Ideal: [Iris-versicolor] [0.50,0.33,0.51,0.50] -> Actual: [Iris-versicolor], Ideal: [Iris-versicolor] [0.56,0.21,0.66,0.58] -> Actual: [Iris-versicolor], Ideal: [Iris-versicolor] [0.50,0.33,0.63,0.46] -> Actual: [Iris-versicolor], Ideal: [Iris-versicolor] [0.58,0.37,0.56,0.50] -> Actual: [Iris-versicolor], Ideal: [Iris-versicolor] [0.64,0.42,0.58,0.54] -> Actual: [Iris-virginica], Ideal: [Iris-versicolor] [0.69,0.33,0.64,0.54] -> Actual: [Iris-virginica], Ideal: [Iris-versicolor] [0.67,0.42,0.68,0.67] -> Actual: [Iris-virginica], Ideal: [Iris-versicolor] [0.47,0.37,0.59,0.58] -> Actual: [Iris-versicolor], Ideal: [Iris-versicolor] [0.39,0.25,0.42,0.38] -> Actual: [Iris-versicolor], Ideal: [Iris-versicolor] [0.33,0.17,0.47,0.42] -> Actual: [Iris-versicolor], Ideal: [Iris-versicolor] [0.33,0.17,0.46,0.38] -> Actual: [Iris-versicolor], Ideal: [Iris-versicolor] [0.42,0.29,0.49,0.46] -> Actual: [Iris-versicolor], Ideal: [Iris-versicolor] [0.47,0.29,0.69,0.62] -> Actual: [Iris-versicolor], Ideal: [Iris-versicolor] [0.31,0.42,0.59,0.58] -> Actual: [Iris-versicolor], Ideal: [Iris-versicolor] [0.47,0.58,0.59,0.62] -> Actual: [Iris-virginica], Ideal: [Iris-versicolor] [0.67,0.46,0.63,0.58] -> Actual: [Iris-virginica], Ideal: [Iris-versicolor] [0.56,0.12,0.58,0.50] -> Actual: [Iris-versicolor], Ideal: [Iris-versicolor] [0.36,0.42,0.53,0.50] -> Actual: [Iris-versicolor], Ideal: [Iris-versicolor] [0.33,0.21,0.51,0.50] -> Actual: [Iris-versicolor], Ideal: [Iris-versicolor] [0.33,0.25,0.58,0.46] -> Actual: [Iris-versicolor], Ideal: [Iris-versicolor] [0.50,0.42,0.61,0.54] -> Actual: [Iris-versicolor], Ideal: [Iris-versicolor] [0.42,0.25,0.51,0.46] -> Actual: [Iris-versicolor], Ideal: [Iris-versicolor] [0.19,0.12,0.39,0.38] -> Actual: [Iris-versicolor], Ideal: [Iris-versicolor] [0.36,0.29,0.54,0.50] -> Actual: [Iris-versicolor], Ideal: [Iris-versicolor] [0.39,0.42,0.54,0.46] -> Actual: [Iris-versicolor], Ideal: [Iris-versicolor] [0.39,0.37,0.54,0.50] -> Actual: [Iris-versicolor], Ideal: [Iris-versicolor] [0.53,0.37,0.56,0.50] -> Actual: [Iris-versicolor], Ideal: [Iris-versicolor] [0.22,0.21,0.34,0.42] -> Actual: [Iris-versicolor], Ideal: [Iris-versicolor] [0.39,0.33,0.53,0.50] -> Actual: [Iris-versicolor], Ideal: [Iris-versicolor] [0.56,0.54,0.85,1.00] -> Actual: [Iris-virginica], Ideal: [Iris-virginica] [0.42,0.29,0.69,0.75] -> Actual: [Iris-virginica], Ideal: [Iris-virginica] [0.78,0.42,0.83,0.83] -> Actual: [Iris-virginica], Ideal: [Iris-virginica] [0.56,0.37,0.78,0.71] -> Actual: [Iris-virginica], Ideal: [Iris-virginica] [0.61,0.42,0.81,0.88] -> Actual: [Iris-virginica], Ideal: [Iris-virginica] [0.92,0.42,0.95,0.83] -> Actual: [Iris-virginica], Ideal: [Iris-virginica] [0.17,0.21,0.59,0.67] -> Actual: [Iris-versicolor], Ideal: [Iris-virginica] [0.83,0.37,0.90,0.71] -> Actual: [Iris-virginica], Ideal: [Iris-virginica] [0.67,0.21,0.81,0.71] -> Actual: [Iris-virginica], Ideal: [Iris-virginica] [0.81,0.67,0.86,1.00] -> Actual: [Iris-virginica], Ideal: [Iris-virginica] [0.61,0.50,0.69,0.79] -> Actual: [Iris-virginica], Ideal: [Iris-virginica] [0.58,0.29,0.73,0.75] -> Actual: [Iris-virginica], Ideal: [Iris-virginica] [0.69,0.42,0.76,0.83] -> Actual: [Iris-virginica], Ideal: [Iris-virginica] [0.39,0.21,0.68,0.79] -> Actual: [Iris-versicolor], Ideal: [Iris-virginica] [0.42,0.33,0.69,0.96] -> Actual: [Iris-virginica], Ideal: [Iris-virginica] [0.58,0.50,0.73,0.92] -> Actual: [Iris-virginica], Ideal: [Iris-virginica] [0.61,0.42,0.76,0.71] -> Actual: [Iris-virginica], Ideal: [Iris-virginica] [0.94,0.75,0.97,0.88] -> Actual: [Iris-virginica], Ideal: [Iris-virginica] [0.94,0.25,1.00,0.92] -> Actual: [Iris-virginica], Ideal: [Iris-virginica] [0.47,0.08,0.68,0.58] -> Actual: [Iris-versicolor], Ideal: [Iris-virginica] [0.72,0.50,0.80,0.92] -> Actual: [Iris-virginica], Ideal: [Iris-virginica] [0.36,0.33,0.66,0.79] -> Actual: [Iris-virginica], Ideal: [Iris-virginica] [0.94,0.33,0.97,0.79] -> Actual: [Iris-virginica], Ideal: [Iris-virginica] [0.56,0.29,0.66,0.71] -> Actual: [Iris-virginica], Ideal: [Iris-virginica] [0.67,0.54,0.80,0.83] -> Actual: [Iris-virginica], Ideal: [Iris-virginica] [0.81,0.50,0.85,0.71] -> Actual: [Iris-virginica], Ideal: [Iris-virginica] [0.53,0.33,0.64,0.71] -> Actual: [Iris-virginica], Ideal: [Iris-virginica] [0.50,0.42,0.66,0.71] -> Actual: [Iris-virginica], Ideal: [Iris-virginica] [0.58,0.33,0.78,0.83] -> Actual: [Iris-virginica], Ideal: [Iris-virginica] [0.81,0.42,0.81,0.62] -> Actual: [Iris-virginica], Ideal: [Iris-virginica] [0.86,0.33,0.86,0.75] -> Actual: [Iris-virginica], Ideal: [Iris-virginica] [1.00,0.75,0.92,0.79] -> Actual: [Iris-virginica], Ideal: [Iris-virginica] [0.58,0.33,0.78,0.88] -> Actual: [Iris-virginica], Ideal: [Iris-virginica] [0.56,0.33,0.69,0.58] -> Actual: [Iris-versicolor], Ideal: [Iris-virginica] [0.50,0.25,0.78,0.54] -> Actual: [Iris-versicolor], Ideal: [Iris-virginica] [0.94,0.42,0.86,0.92] -> Actual: [Iris-virginica], Ideal: [Iris-virginica] [0.56,0.58,0.78,0.96] -> Actual: [Iris-virginica], Ideal: [Iris-virginica] [0.58,0.46,0.76,0.71] -> Actual: [Iris-virginica], Ideal: [Iris-virginica] [0.47,0.42,0.64,0.71] -> Actual: [Iris-virginica], Ideal: [Iris-virginica] [0.72,0.46,0.75,0.83] -> Actual: [Iris-virginica], Ideal: [Iris-virginica] [0.67,0.46,0.78,0.96] -> Actual: [Iris-virginica], Ideal: [Iris-virginica] [0.72,0.46,0.69,0.92] -> Actual: [Iris-virginica], Ideal: [Iris-virginica] [0.42,0.29,0.69,0.75] -> Actual: [Iris-virginica], Ideal: [Iris-virginica] [0.69,0.50,0.83,0.92] -> Actual: [Iris-virginica], Ideal: [Iris-virginica] [0.67,0.54,0.80,1.00] -> Actual: [Iris-virginica], Ideal: [Iris-virginica] [0.67,0.42,0.71,0.92] -> Actual: [Iris-virginica], Ideal: [Iris-virginica] [0.56,0.21,0.68,0.75] -> Actual: [Iris-virginica], Ideal: [Iris-virginica] [0.61,0.42,0.71,0.79] -> Actual: [Iris-virginica], Ideal: [Iris-virginica] [0.53,0.58,0.75,0.92] -> Actual: [Iris-virginica], Ideal: [Iris-virginica] [0.44,0.42,0.69,0.71] -> Actual: [Iris-virginica], Ideal: [Iris-virginica] */ void ExampleAnnealIris(int argIndex, int argc, char **argv) { IRIS_PARAMS *params; NORM_DATA *norm; TRAIN *train; double *x0, *input, *ideal,y[3]; unsigned int size,i; NORM_DATA_ITEM *irisSpecies; char *idealSpecies,*actualSpecies; const int kMax = 2000; params = (IRIS_PARAMS*)calloc(1,sizeof(IRIS_PARAMS)); norm = NormCreate(); params->training = create_iris_training(norm); params->errorCalc = ErrorCreate(TYPE_ERROR_MSE); params->network = RBFNetworkCreate(RBFGaussian,4,5,3); RBFNetworkReset(params->network); size = params->network->ltm_size*sizeof(double); x0 = (double*)calloc(size,1); memcpy(x0,params->network->long_term_memory,size); /* Extract the species definition */ irisSpecies = NormGetColumnItem(norm, 4); train = TrainCreateAnneal(score_function,x0,size,400,0.0001,100,kMax,params); TrainRun(train,kMax,0.01,1); TrainComplete(train,params->network->long_term_memory); /* Perform the evaluation */ for(i=0;i<params->training->recordCount;i++) { input = DataGetInput(params->training,i); ideal = DataGetIdeal(params->training,i); RBFNetworkComputeRegression(params->network, input, y); idealSpecies = DeNormOneOfN(irisSpecies->firstClass,irisSpecies->targetLow,irisSpecies->targetLow,ideal); actualSpecies = DeNormOneOfN(irisSpecies->firstClass,irisSpecies->targetLow,irisSpecies->targetLow,y); printf("[%.2f,%.2f,%.2f,%.2f] -> Actual: [%s], Ideal: [%s]\n", input[0],input[1],input[2],input[3],actualSpecies,idealSpecies); } DataDelete(params->training); ErrorDelete(params->errorCalc); RBFNetworkDelete(params->network); NormDelete(norm); free(params); }
/*************************************************** * Function : GDD_SCREEN_PictureScreenCreate * Parameters : none * Return : none * Description : Creates GOL widgets used in screen - PictureScreen ***************************************************/ void GDD_SCREEN_PictureScreenCreate(void) { GFX_GOL_ObjectListFree(GFX_INDEX_0); GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(248, 252, 248)); GFX_ScreenClear(GFX_INDEX_0); if(defscheme != NULL) free(defscheme); defscheme = GFX_GOL_SchemeCreate(); defscheme->Color0 = GFX_RGBConvert(32, 168, 224); defscheme->Color1 = GFX_RGBConvert(16, 132, 168); defscheme->TextColor0 = GFX_RGBConvert(24, 24, 24); defscheme->TextColor1 = GFX_RGBConvert(248, 252, 248); defscheme->EmbossDkColor = GFX_RGBConvert(248, 204, 0); defscheme->EmbossLtColor = GFX_RGBConvert(24, 116, 184); defscheme->TextColorDisabled = GFX_RGBConvert(128, 128, 128); defscheme->ColorDisabled = GFX_RGBConvert(208, 224, 240); defscheme->CommonBkColor = GFX_RGBConvert(208, 236, 240); defscheme->pFont = (GFX_RESOURCE_HDR*)&Gentium_16; GFX_GOL_WINDOW *pPICTUREWIND; pPICTUREWIND = GFX_GOL_WindowCreate( GFX_INDEX_0, //gfxIndex PICTUREWIND, //name 0, //left 0, //top 319, //right 239, //bottom GFX_GOL_WINDOW_DRAW_STATE, //state (GFX_RESOURCE_HDR*)&bekeband_kicsi, //bitmap (GFX_XCHAR*)PictureScreen_PICTUREWINDtext, //text GFX_ALIGN_CENTER, //align defscheme //scheme ); if(pPICTUREWIND==NULL) { ErrorCreate(0); while(1); //Fatal Error, Check for memory leak or heap size } }
void Usart0_init ( long BaudRate ) { US0_QUEUE = xQueueCreate( 10, sizeof( unsigned int ) ); US0_Error = ErrorCreate("US0_Error"); while( US0_QUEUE == 0 ) ; // Queue was not created and must not be used. portENTER_CRITICAL(); { AT91F_US0_CfgPIO() ; //* Define RXD and TXD as peripheral AT91F_PMC_EnablePeriphClock ( AT91C_BASE_PMC, 1<<AT91C_ID_US0 ) ; // First, enable the clock of the PIOB AT91F_US_Configure (COM0, MCK,AT91C_US_ASYNC_MODE, BaudRate , 0); // Usart Configure AT91F_AIC_ConfigureIt ( AT91C_BASE_AIC, AT91C_ID_US0, USART_INTERRUPT_LEVEL, AT91C_AIC_SRCTYPE_INT_LEVEL_SENSITIVE, ( void (*)( void ) )AT91_US0_ISR_ENTRY); AT91F_AIC_EnableIt (AT91C_BASE_AIC, AT91C_ID_US0); } portEXIT_CRITICAL(); }
//=============================================================================================== void AT91F_USART_OPEN(AT91_USART_ID idPort, long BaudRate, int mode) { portENTER_CRITICAL(); { switch (idPort) { case AT91_USART_COM0_ID: COM0.id = idPort; COM0.hPort = AT91C_BASE_US0; COM0.hError = ErrorCreate("US0_Error"); COM0.hPDC = AT91C_BASE_PDC_US0; AT91F_PDC_Open(COM0.hPDC); // AT91F_US0_CfgPIO(); //* Define RXD and TXD as peripheral AT91F_PIO_CfgPeriph(AT91C_BASE_PIOA, // PIO controller base address (((unsigned int) AT91C_PA5_RXD0) | ((unsigned int) AT91C_PA6_TXD0)), // Peripheral A 0); AT91F_PMC_EnablePeriphClock(AT91C_BASE_PMC, 1 << AT91C_ID_US0); // First, enable the clock of the PIOB AT91F_US_Configure(COM0.hPort, MCK, mode, BaudRate, 0); // Usart Configure AT91F_AIC_ConfigureIt(AT91C_BASE_AIC, AT91C_ID_US0, USART_INTERRUPT_LEVEL, AT91C_AIC_SRCTYPE_INT_HIGH_LEVEL, (void(*)(void)) AT91_US0_ISR_ENTRY); AT91F_AIC_EnableIt(AT91C_BASE_AIC, AT91C_ID_US0); COM0.hRxQueue = xQueueCreate(1, sizeof(int)); while (COM0.hRxQueue == 0) ; // Queue was not created and must not be used. COM0.hTxQueue = xQueueCreate(1, sizeof(int)); while (COM0.hTxQueue == 0) ; // Queue was not created and must not be used. break; case AT91_USART_COM1_ID: COM1.id = idPort; COM1.hPort = AT91C_BASE_US1; COM1.hPDC = AT91C_BASE_PDC_US1; COM1.hError = ErrorCreate("US1_Error"); AT91F_PDC_DisableTx(COM1.hPDC); AT91F_PDC_DisableRx(COM1.hPDC); AT91F_PIO_CfgPeriph(AT91C_BASE_PIOA, // PIO controller base address (((unsigned int) AT91C_PA21_RXD1) | ((unsigned int) AT91C_PA22_TXD1)), // Peripheral A 0); AT91F_PMC_EnablePeriphClock(AT91C_BASE_PMC, 1 << AT91C_ID_US1); // First, enable the clock of the PIOB AT91F_US_Configure(COM1.hPort, MCK, mode, BaudRate, 0); // Usart Configure AT91F_AIC_ConfigureIt(AT91C_BASE_AIC, AT91C_ID_US1, USART_INTERRUPT_LEVEL, AT91C_AIC_SRCTYPE_INT_HIGH_LEVEL, (void(*)(void)) AT91_US1_ISR_ENTRY); AT91F_AIC_EnableIt(AT91C_BASE_AIC, AT91C_ID_US1); COM1.hRxQueue = xQueueCreate(1, sizeof(int)); while (COM1.hRxQueue == 0) ; // Queue was not created and must not be used. COM1.hTxQueue = xQueueCreate(1, sizeof(int)); while (COM1.hTxQueue == 0) ; // Queue was not created and must not be used. break; default: while (1) ;// error port notfound; } } portEXIT_CRITICAL(); }
/*************************************************** * Function : GDD_SCREEN_WelcomeScreenCreate * Parameters : none * Return : none * Description : Creates GOL widgets used in screen - WelcomeScreen ***************************************************/ void GDD_SCREEN_WelcomeScreenCreate(void) { GFX_GOL_ObjectListFree(GFX_INDEX_0); GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(248, 252, 248)); GFX_ScreenClear(GFX_INDEX_0); if(enter_new_s524cheme != NULL) free(enter_new_s524cheme); enter_new_s524cheme = GFX_GOL_SchemeCreate(); enter_new_s524cheme->Color0 = GFX_RGBConvert(32, 168, 224); enter_new_s524cheme->Color1 = GFX_RGBConvert(16, 132, 168); enter_new_s524cheme->TextColor0 = GFX_RGBConvert(24, 24, 24); enter_new_s524cheme->TextColor1 = GFX_RGBConvert(248, 252, 248); enter_new_s524cheme->EmbossDkColor = GFX_RGBConvert(248, 204, 0); enter_new_s524cheme->EmbossLtColor = GFX_RGBConvert(24, 116, 184); enter_new_s524cheme->TextColorDisabled = GFX_RGBConvert(128, 128, 128); enter_new_s524cheme->ColorDisabled = GFX_RGBConvert(208, 224, 240); enter_new_s524cheme->CommonBkColor = GFX_RGBConvert(208, 236, 240); enter_new_s524cheme->pFont = (GFX_RESOURCE_HDR*)&DroidSans_Bold_12; if(defscheme != NULL) free(defscheme); defscheme = GFX_GOL_SchemeCreate(); defscheme->Color0 = GFX_RGBConvert(32, 168, 224); defscheme->Color1 = GFX_RGBConvert(16, 132, 168); defscheme->TextColor0 = GFX_RGBConvert(24, 24, 24); defscheme->TextColor1 = GFX_RGBConvert(248, 252, 248); defscheme->EmbossDkColor = GFX_RGBConvert(248, 204, 0); defscheme->EmbossLtColor = GFX_RGBConvert(24, 116, 184); defscheme->TextColorDisabled = GFX_RGBConvert(128, 128, 128); defscheme->ColorDisabled = GFX_RGBConvert(208, 224, 240); defscheme->CommonBkColor = GFX_RGBConvert(208, 236, 240); defscheme->pFont = (GFX_RESOURCE_HDR*)&Gentium_16; GFX_GOL_WINDOW *pMAIN_WINDOW; pMAIN_WINDOW = GFX_GOL_WindowCreate( GFX_INDEX_0, //gfxIndex MAIN_WINDOW, //name 0, //left 0, //top 319, //right 239, //bottom GFX_GOL_WINDOW_DRAW_STATE, //state NULL, //bitmap (GFX_XCHAR*)WelcomeScreen_MAIN_WINDOWtext, //text GFX_ALIGN_CENTER, //align enter_new_s524cheme //scheme ); if(pMAIN_WINDOW==NULL) { ErrorCreate(0); while(1); //Fatal Error, Check for memory leak or heap size } GFX_GOL_METER *pMTR_2; pMTR_2 = GFX_GOL_MeterCreate( GFX_INDEX_0, //gfxIndex MTR_2, //name 13, //left 45, //top 133, //right 165, //bottom GFX_GOL_METER_DRAW_STATE, //state GFX_GOL_METER_WHOLE_TYPE, //metertype 1, //pos 1, //minval 50, //maxval (GFX_RESOURCE_HDR*)&Gentium_16, //titlefont (GFX_RESOURCE_HDR*)&Gentium_16, //valuefont (GFX_XCHAR*)WelcomeScreen_MTR_2text, //text defscheme //scheme ); if(pMTR_2==NULL) { ErrorCreate(0); while(1); //Fatal Error, Check for memory leak or heap size } }