J L
/
ringBuffer26
ringBuffer26
Diff: main.cpp
- Revision:
- 0:333434a8611b
- Child:
- 1:0cb065f9d55a
diff -r 000000000000 -r 333434a8611b main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Mar 20 10:54:58 2020 +0000 @@ -0,0 +1,55 @@ + +/* + + ED Motor Controller API + + + Notes: + A robust protocal has been called for, the motor command sent out is to be echoed back with and <ACK> or <NACK> + + In order to compare what was sent to what is echoed back two buffers are required, a TX buffer and an RX buffer, they can then be compared + using memcmp() function + + 19/03/20 Compare of tx and rx buffers can be done + 20/03/20 Migrate code to mbed studio + + + +*/ + +#include "mbed.h" +#include <string> +#include "MotorControl.h" + +DigitalOut led1(LED1); + + + +int main(){ + + led1=0; + + mc_usart.attach(&motMsg_RX_ISR);//start the serial receiver interrupt + mc_usart.printf("ED Motor Controller Commands\r\n"); + + clrRxMsg(rxMsgStore); + + moveMot(1, 1000); + + mc_usart.printf("TX Buffer Contents\r\n"); + + for(unsigned char i=0 ; i <BUFFER_SIZE ; i++) + mc_usart.printf("%c\r\n",mc_Tx_Buffer[i]); + + while(1){ + + if(getMotMsg(rxMsgStore)){//get the message from the receive buffer and store it in local message store + + msgRecFlag = false;//clear the message received flag + + if(memcmp(rxMsgStore,mc_Tx_Buffer,strlen(rxMsgStore)) == 0){ + led1=1; + } + } + } +} \ No newline at end of file