Hello. I'm using the ConsoleIO component under CPU External Devices->Display in Processor Expert to do terminal IO. Works great! Using printf() and getchar() to create a menu of tests. But now I want to have a while() loop run and have the loop stop on "any key". I have seen functions like uart_getchar_present(TERM_PORT) in other demo code but this function is not available using the ConsoleIO component. So how do I break a while() loop upon a uart character received?
I have another question. How do I access Processor Expert data structures? For example, when trying to figure out how to detect if a keyboard character is received I came across this structure in IO1.h:
/*! Device data structure type */
typedef struct {
uint16_t SerFlag; /*!< Flags for serial communication */
uint16_t InpRecvDataNum; /*!< The counter of received characters */
uint8_t *InpDataPtr; /*!< The buffer pointer for received characters */
uint16_t InpDataNumReq; /*!< The counter of characters to receive by ReceiveBlock() */
uint16_t OutSentDataNum; /*!< The counter of sent characters */
uint8_t *OutDataPtr; /*!< The buffer pointer for data to be transmitted */
uint16_t OutDataNumReq; /*!< The counter of characters to be send by SendBlock() */
LDD_TUserData *UserDataPtr; /*!< Pointer to user data */
} IO1_TDeviceData;
typedef IO1_TDeviceData *IO1_TDeviceDataPtr ; /*!< Pointer to the device data structure. */
Obviously I am not a firmware designer or I would know this stuff. I'm a hardware engineer trying to figure this out.
Seems like if I could read InpRecvDataNum and see if it changes then I would know that a character was received.
Whether or not this is the right approach for the "hit any key" question I would still like to understand how to access the data in this structure. I know that a pointer to this structure is returned by the IO1_init(). And searching on IO1_init I find this (I cut out the code in the middle):
LDD_TDeviceData* IO1_Init(LDD_TUserData *UserDataPtr)
{
/* Allocate device structure */
IO1_TDeviceDataPtr DeviceDataPrv;
blah, blah, blah....
/* Registration of the device structure */
PE_LDD_RegisterDeviceStructure(PE_LDD_COMPONENT_IO1_ID,DeviceDataPrv);
return ((LDD_TDeviceData *)DeviceDataPrv);
}
So LDD_TDeviceData must be a pointer to the data structure right? But the trouble is that there are a whole bunch of these.
Seems like this:
#include "IO1.h"
uint16_t anyData;
anyData = DeviceDataPrv->InpDataNum;
or this
#include "IO1.h"
uint16_t anyData;
anyData = DeviceDataPrv.InpDataNum;
should work but it does not compile. I get an error that DeviceDataPrv is undefined . Any insight to both questions would be greatly appreciated !!
Thanks in advance.
Mark