/** * @brief Main program * @param None * @retval None */ int main() { int i; /*System clock configuration*/ SystemInit(); /* Configure UART2 */ S_UART_Init(115200); conf.scl = I2C_PA_9; conf.sda = I2C_PA_10; I2C_Init(&conf); //============ Write ============== I2C_Write(&conf, 0xa0, &Transmit_Data[0], MAX_SIZE); delay_function(4000); //========= Read ============= //Write memory address I2C_Write(&conf, 0xA0, &Transmit_Data[0], 1); delay_function(4000); //Read data I2C_Read(&conf, 0xA0, &Recv_Data[0], MAX_SIZE - 1); printf("Recv data : "); for(i=0; i<MAX_SIZE - 1; i++) { printf("0x%x ", Recv_Data[i]); } printf("\r\n"); }
void main(void) { WDTCTL = WDTPW + WDTHOLD; P2DIR |= BIT0; for(;;){ P2OUT |= BIT0; delay_function(); P2OUT = 0; delay_function(); delay++; } }
/** * @brief Main program * @param None * @retval None */ int main() { int i; /*System clock configuration*/ SystemInit(); // *(volatile uint32_t *)(0x41001014) = 0x0060100; //clock setting 48MHz /* CLK OUT Set */ // PAD_AFConfig(PAD_PA,GPIO_Pin_2, PAD_AF2); // PAD Config - CLKOUT used 3nd Function /* UART0 and UART1 configuration*/ UART_StructInit(&UART_InitStructure); /* Configure UART1 */ UART_Init(UART1,&UART_InitStructure); conf.scl = I2C_PA_9; conf.sda = I2C_PA_10; I2C_Init(&conf); //============ Write ============== I2C_Write(&conf, 0xa0, &Transmit_Data[0], MAX_SIZE); delay_function(4000); //========= Read ============= //Write memory address I2C_Write(&conf, 0xA0, &Transmit_Data[0], 1); delay_function(4000); //Read data I2C_Read(&conf, 0xA0, &Recv_Data[0], MAX_SIZE - 1); printf("Recv data : "); for(i=0; i<MAX_SIZE - 1; i++) { printf("0x%x ", Recv_Data[i]); } printf("\r\n"); }