USE OF PRINTF() STATEMENT IN MBED USE OF : "platform/mbed_thread.h" library details and its functions DEBUG BASIC USE PRINT FUNCTION NOTE : YOU CAN NOT CALL THIS FUNCTION FROM ISR ,BECAUSE OF MUTEX GUARD CREATED BY : JAYDEEP SHAH -- radhey04ec@gmail.com

Committer:
radhey04ec
Date:
Sun Jul 12 05:05:11 2020 +0000
Revision:
0:79c7d8ebf698
PRINTF() USAGE IN MBED AND RTOS; DETAILS : "platform/mbed_thread.h" library and its functions; ; BASIC PROGRAM for Debug; JAYDEEP SHAH : radhey04ec@gmail.com

Who changed what in which revision?

UserRevisionLine numberNew contents of line
radhey04ec 0:79c7d8ebf698 1 //USE OF PRINTF STATEMENT IN MBED
radhey04ec 0:79c7d8ebf698 2 //PLEASE NOTE : THIS FUNCTION USE 5K TO 10K SPACE IN MEMORY
radhey04ec 0:79c7d8ebf698 3 //AS WELL TAKE 10mS or 1 million instruction time to call and run
radhey04ec 0:79c7d8ebf698 4 //Do not use when space is limited , DO not call from ISR because mutex guard
radhey04ec 0:79c7d8ebf698 5 //Do not use when process complete in micro second
radhey04ec 0:79c7d8ebf698 6
radhey04ec 0:79c7d8ebf698 7 //EASY AND SIMPLE WAY OF DEBUGGING
radhey04ec 0:79c7d8ebf698 8 //USE SERIAL TERMINAL WITH 9600 BAUD RATE 8-N-1 FORMAT
radhey04ec 0:79c7d8ebf698 9
radhey04ec 0:79c7d8ebf698 10 //Created by : JAYDEEP SHAH --radhey04ec@gmail.com
radhey04ec 0:79c7d8ebf698 11
radhey04ec 0:79c7d8ebf698 12
radhey04ec 0:79c7d8ebf698 13 //Library Added :::::
radhey04ec 0:79c7d8ebf698 14
radhey04ec 0:79c7d8ebf698 15 #include "mbed.h"
radhey04ec 0:79c7d8ebf698 16 #include "platform/mbed_thread.h" //MBED THREAD LIBRARY
radhey04ec 0:79c7d8ebf698 17
radhey04ec 0:79c7d8ebf698 18 /* FUNCTIONS INCLUDES IN THIS LIBRARY :
radhey04ec 0:79c7d8ebf698 19
radhey04ec 0:79c7d8ebf698 20 1) void thread_sleep_for(uint32_t millisec);
radhey04ec 0:79c7d8ebf698 21 --> Sleep until a specified time in millisec
radhey04ec 0:79c7d8ebf698 22 The equivalent functionality is accessible in C++ via ThisThread::sleep_until
radhey04ec 0:79c7d8ebf698 23
radhey04ec 0:79c7d8ebf698 24 2)void thread_sleep_until(uint64_t millisec);
radhey04ec 0:79c7d8ebf698 25
radhey04ec 0:79c7d8ebf698 26 */
radhey04ec 0:79c7d8ebf698 27
radhey04ec 0:79c7d8ebf698 28 // Blinking rate in milliseconds
radhey04ec 0:79c7d8ebf698 29 #define BLINKING_RATE_MS 500
radhey04ec 0:79c7d8ebf698 30
radhey04ec 0:79c7d8ebf698 31
radhey04ec 0:79c7d8ebf698 32 int main()
radhey04ec 0:79c7d8ebf698 33 {
radhey04ec 0:79c7d8ebf698 34 // Initialise the digital pin LED1 as an output
radhey04ec 0:79c7d8ebf698 35 DigitalOut led(LED3); //CREATE OBJECT ON BOARD LED
radhey04ec 0:79c7d8ebf698 36
radhey04ec 0:79c7d8ebf698 37 while (true) {
radhey04ec 0:79c7d8ebf698 38 led = !led; //TOGGLE STATE
radhey04ec 0:79c7d8ebf698 39 thread_sleep_for(BLINKING_RATE_MS); //500MS SLEEP THIS THREAD
radhey04ec 0:79c7d8ebf698 40 printf("\n State Toggle \r\n"); //PRINTF STATEMENT CHANGE
radhey04ec 0:79c7d8ebf698 41 }
radhey04ec 0:79c7d8ebf698 42 }