<div style="background-color: rgb(255, 255, 255); padding-left: 2px;"><div style="color: rgb(0, 0, 0); font-family: "Courier New"; font-size: 10pt; white-space: pre;"><p><span style="color:#7f0055;font-weight:bold;">int</span> <span style="font-weight: bold;">main</span>(<span style="color:#7f0055;font-weight:bold;">void</span>)</p><p>{</p><p> cy_rslt_t result;</p><p> <span style="color:#7f0055;font-weight:bold;">int</span> cnt = 0;</p><p> <span style="color:#7f0055;font-weight:bold;">char</span> buff[64];</p><p> cy_stc_scb_uart_context_t CYBSP_UART_context;</p><p>
</p><p> <span style="color:#3f7f5f;">/* Initialize the device and board peripherals */</span></p><p> result = cybsp_init();</p><p>
</p><p> <span style="color:#3f7f5f;">/* Board </span><span style="color: rgb(63, 127, 95); text-decoration-line: underline; text-decoration-color: rgb(255, 128, 64); text-decoration-style: wavy;">init</span><span style="color:#3f7f5f;"> failed. Stop program execution */</span></p><p> <span style="color:#7f0055;font-weight:bold;">if</span> (result != CY_RSLT_SUCCESS)</p><p> {</p><p> CY_ASSERT(CY_ASSERT_FAILED);</p><p> }</p><p>
</p><p> <span style="color:#3f7f5f;">/* Configure and enable the UART peripheral */</span></p><p> Cy_SCB_UART_Init(CYBSP_UART_HW, &CYBSP_UART_config, &CYBSP_UART_context);</p><p> Cy_SCB_UART_Enable(CYBSP_UART_HW);</p><p>
</p><p> <span style="color:#3f7f5f;">/* Enable global interrupts */</span></p><p> __enable_irq();</p><p>
</p><p> <span style="color:#3f7f5f;">/* Send a string over serial terminal */</span></p><p> Cy_SCB_UART_PutString(CYBSP_UART_HW, <span style="color:#2a00ff;">"Hello world\r\n"</span>);</p><p>
</p><p> <span style="color:#7f0055;font-weight:bold;">for</span>(;;)</p><p> {</p><p> <span style="color:#3f7f5f;">/* Toggle the user LED state */</span></p><p> Cy_GPIO_Inv(CYBSP_USER_LED1_PORT, CYBSP_USER_LED1_PIN);</p><p>
</p><p> <span style="color:#3f7f5f;">/* Wait for 0.5 seconds */</span></p><p> Cy_SysLib_Delay(LED_DELAY_MS);</p><p> cnt++;</p><p> <span style="text-decoration-line: underline; text-decoration-color: rgb(244, 200, 45); text-decoration-style: wavy;">sprintf(buff,(</span><span style="color: rgb(127, 0, 85); font-weight: bold; text-decoration-line: underline; text-decoration-color: rgb(244, 200, 45); text-decoration-style: wavy;">const</span><span style="text-decoration-line: underline; text-decoration-color: rgb(244, 200, 45); text-decoration-style: wavy;"> </span><span style="color: rgb(127, 0, 85); font-weight: bold; text-decoration-line: underline; text-decoration-color: rgb(244, 200, 45); text-decoration-style: wavy;">char</span><span style="text-decoration-line: underline; text-decoration-color: rgb(244, 200, 45); text-decoration-style: wavy;"> *)</span><span style="color: rgb(42, 0, 255); text-decoration-line: underline; text-decoration-color: rgb(244, 200, 45); text-decoration-style: wavy;">"Hello 21ic </span><span style="color: rgb(42, 0, 255); text-decoration-line: underline; text-decoration-color: rgb(255, 128, 64); text-decoration-style: wavy;">cnt</span><span style="color: rgb(42, 0, 255); text-decoration-line: underline; text-decoration-color: rgb(244, 200, 45); text-decoration-style: wavy;">: %d\r\n"</span><span style="text-decoration-line: underline; text-decoration-color: rgb(244, 200, 45); text-decoration-style: wavy;">, cnt);</span></p><p> Cy_SCB_UART_PutString(CYBSP_UART_HW, buff);</p><p> }</p><p>}</p></div></div>