//Uart test #include #include #include "math.h" #define MAX_BLOCKSIZE 32 #define DELTA (0.000001f) //#define DELTA (0.00000000001f) const float testInput[MAX_BLOCKSIZE] = { -1.244916875853235400, -4.793533929171324800, 0.360705030233248850, 0.827929644170887320, -3.299532218312426900, 3.427441903227623800, 3.422401784294607700, -0.108308165334010680, 0.941943896490312180, 0.502609575000365850, -0.537345278736373500, 2.088817392965764500, -1.693168684143455700, 6.283185307179590700, -0.392545884746175080, 0.327893095115825040, 3.070147440456292300, 0.170611405884662230, -0.275275082396073010, -2.395492805446796300, 0.847311163536506600, -3.845517018083148800, 2.055818378415868300, 4.672594161978930800, -1.990923030266425800, 2.469305197656249500, 3.609002606064021000, -4.586736582331667500, -4.147080139136136300, 1.643756718868359500, -1.150866392366494800, 1.985805026477433800 }; void pause(unsigned int a) { unsigned int i; for(i=a;i>0;i--); } void main() { float diff; float a = M_PI_2; int i; int k=0xAA; int blockSize = 32; UART_InitTypeDef UART_InitStructure; UART_InitStructure.BaudRate = 38400; //set baudrate UART_InitStructure.TypeParity = 0x00000000; //parity control type UART_InitStructure.Parity = 0x00000000; //enable parity control UART_InitStructure.FlowControl = 0x00000000; //enable cts/rts UART_InitStructure.Mode = 0x00000003; //rx enable - 1 bit, tx enable - 2 bit (rx + tx en) GPIOB->BPS = 0x00000300; //alternative port function for uart0 uart_init(UART0, &UART_InitStructure); // DM2UART(UART0, 0x00000000, 0x00000800); while(1) { GPIOB->DIR = ((uint32_t)0x60000000); GPIOB->OUT = ((uint32_t)0x60000000); for(i=0; i< blockSize; i++) { pause(400000); diff = (sinf(testInput[i])*sinf(testInput[i]) + cosf(testInput[i])*cosf(testInput[i]) - 1.0f); if(diff >0) if(diff 0.9999999f) // if(sinf(a) > 0.99999999f) // if(sinf(a) > 0.99999994f) // UART_SEND_BYTE(0x12, UART0); // else // UART_SEND_BYTE(0x34, UART0); } }