Очень надеюсь что кто-нибудь из Вас работал с Infineon контроллерами. У меня же в наличии XMC1200 контроллер.
Так вот вопрос по программированию периферии данного контроллера:
Как сделать что бы MANCHESTER_SW_0 отправлял одну посылку данных по приему с UART данных, например 0х01?
В нижеприведенном коде посылка отправляется постоянно, при повторной посылки по UART команды 0х01, MANCHESTER_SW_0 перестает пересылать и вообще реагировать
CODE
#include <DAVE.h> //Declarations from DAVE Code Generation (includes SFR declaration)
#include <xmc_uart.h>
#define UART_RX P1_3
#define UART_TX P1_2
uint16_t ReceiveData = 0;
/* Pins configuration */
XMC_GPIO_CONFIG_t uart_tx;
XMC_GPIO_CONFIG_t uart_rx;
/* UART configuration */
const XMC_UART_CH_CONFIG_t uart_config =
{
.data_bits = 8U,
.stop_bits = 1U,
.baudrate = 9600
};
/**
* @brief main() - Application entry point
*
* <b>Details of function</b><br>
* This routine is the application entry point. It is invoked by the device startup code. It is responsible for
* invoking the APP initialization dispatcher routine - DAVE_Init() and hosting the place-holder for user application
* code.
*/
int main(void)
{
DAVE_STATUS_t status;
status = DAVE_Init(); /* Initialization of DAVE APPs */
uart_tx.mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT7;
uart_rx.mode = XMC_GPIO_MODE_INPUT_TRISTATE;
//led.mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL;
/* Configure UART channel */
XMC_UART_CH_Init(XMC_UART0_CH1, &uart_config);
XMC_UART_CH_SetInputSource(XMC_UART0_CH1, XMC_UART_CH_INPUT_RXD,USIC0_C1_DX0_P1_3);
/* Start UART channel */
XMC_UART_CH_Start(XMC_UART0_CH1);
/* Configure pins */
XMC_GPIO_Init(UART_TX, &uart_tx);
XMC_GPIO_Init(UART_RX, &uart_rx);
//NVIC_SetPriority(USIC0_1_IRQn,3U);
//NVIC_EnableIRQ(USIC0_1_IRQn);
if(status != DAVE_STATUS_SUCCESS)
{
/* Placeholder for error handler code. The while loop below can be replaced with an user error handler. */
XMC_DEBUG("DAVE APPs initialization failed\n");
while(1U)
{
}
}
/* Placeholder for user application code. The while loop below can be replaced with user application code. */
uint32_t temp1 = 0;
while(1U)
{
ReceiveData = XMC_UART_CH_GetReceivedData(XMC_UART0_CH1);
if(ReceiveData == 1){
MANCHESTER_SW_0.encoder->data = ReceiveData;
MANCHESTER_SW_Encode(&MANCHESTER_SW_0);
temp1 = MANCHESTER_SW_0.encoder->status;
while(MANCHESTER_SW_0.encoder->status != 1);
}
ReceiveData = 0;
XMC_UART_CH_Transmit(XMC_UART0_CH1, ReceiveData);
ReceiveData = 0;
}
}
#include <xmc_uart.h>
#define UART_RX P1_3
#define UART_TX P1_2
uint16_t ReceiveData = 0;
/* Pins configuration */
XMC_GPIO_CONFIG_t uart_tx;
XMC_GPIO_CONFIG_t uart_rx;
/* UART configuration */
const XMC_UART_CH_CONFIG_t uart_config =
{
.data_bits = 8U,
.stop_bits = 1U,
.baudrate = 9600
};
/**
* @brief main() - Application entry point
*
* <b>Details of function</b><br>
* This routine is the application entry point. It is invoked by the device startup code. It is responsible for
* invoking the APP initialization dispatcher routine - DAVE_Init() and hosting the place-holder for user application
* code.
*/
int main(void)
{
DAVE_STATUS_t status;
status = DAVE_Init(); /* Initialization of DAVE APPs */
uart_tx.mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT7;
uart_rx.mode = XMC_GPIO_MODE_INPUT_TRISTATE;
//led.mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL;
/* Configure UART channel */
XMC_UART_CH_Init(XMC_UART0_CH1, &uart_config);
XMC_UART_CH_SetInputSource(XMC_UART0_CH1, XMC_UART_CH_INPUT_RXD,USIC0_C1_DX0_P1_3);
/* Start UART channel */
XMC_UART_CH_Start(XMC_UART0_CH1);
/* Configure pins */
XMC_GPIO_Init(UART_TX, &uart_tx);
XMC_GPIO_Init(UART_RX, &uart_rx);
//NVIC_SetPriority(USIC0_1_IRQn,3U);
//NVIC_EnableIRQ(USIC0_1_IRQn);
if(status != DAVE_STATUS_SUCCESS)
{
/* Placeholder for error handler code. The while loop below can be replaced with an user error handler. */
XMC_DEBUG("DAVE APPs initialization failed\n");
while(1U)
{
}
}
/* Placeholder for user application code. The while loop below can be replaced with user application code. */
uint32_t temp1 = 0;
while(1U)
{
ReceiveData = XMC_UART_CH_GetReceivedData(XMC_UART0_CH1);
if(ReceiveData == 1){
MANCHESTER_SW_0.encoder->data = ReceiveData;
MANCHESTER_SW_Encode(&MANCHESTER_SW_0);
temp1 = MANCHESTER_SW_0.encoder->status;
while(MANCHESTER_SW_0.encoder->status != 1);
}
ReceiveData = 0;
XMC_UART_CH_Transmit(XMC_UART0_CH1, ReceiveData);
ReceiveData = 0;
}
}