Bare Metal Programming Tool Kit
|
bmptk namespace More...
Namespaces | |
namespace | chips |
peripheral chips | |
namespace | graphics |
graphic elements | |
namespace | hardware |
hardware: pins, ports | |
namespace | rtos |
non-preememptive rtos | |
Classes | |
class | output_channel_polled |
interface for a polled output channel More... | |
class | input_channel_polled |
interface for a polled input channel More... | |
class | input_output_channel_polled |
interface for a polled input/output channel More... | |
class | output_channel_polled_buffer |
a buffered output channel More... | |
class | context |
an execution context (used by the RTOS) More... | |
class | time |
time elapsed since some epoch More... | |
class | sr04 |
interface to an SR04 ultrasonic distance sensor More... | |
Enumerations | |
enum | { type_none, type_pin_ad, type_pin_in, type_pin_out, type_pin_in_out, type_pin_oc, type_port_in, type_port_out, type_port_in_out, type_port_oc, type_i2c_bus, type_spi_bus, type_spi_channel } |
bmptk class 'type' identification More... | |
enum | { has_none = 0x0000, has_ad = 0x0001, has_pullup = 0x0002 } |
bmptk class 'features' identification More... | |
enum | { Hz = 1, kHz = 1000, MHz = 1000 * 1000, GHz = 1000 * 1000 * 1000 } |
Constants for Hz, kHz, MHz, GHz. | |
Functions | |
void | fatal_error_detected (const char *msg) |
handle a fatal error | |
void | fatal_error_handler (void f(const char *)) |
set the fatal error handler | |
context * | current_context () |
the current exceuting context | |
unsigned int | heap_free () |
report the number of free bytes on the heap | |
constexpr time | operator* (long long int n, const time rhs) |
multiplying an integer by a time yields a time | |
constexpr time | us (time::us()) |
unit of time : microsecond | |
constexpr time | ms (us *1000) |
unit of time : millisecond | |
constexpr time | s (us *1000 *1000) |
unit of time : microsecond | |
time | current_time () |
void | wait_busy_until (time t) |
busy wait until a moment in time | |
void | wait_until (time t) |
wait until a moment in time | |
void | wait_busy (time t) |
busy wait an amount of time | |
void | wait (time t) |
wait an amount of time | |
Variables | |
const char | version [] = BMPTK_VERSION_STR( BMPTK_VERSION ) |
bmtkp version, determined by Makefile.inc | |
context | main_context |
the context of the main() | |
bmptk namespace
This namespace contains all bmptk declarations (except, of course, the macro's) bmptk namespace This namespace contains all bmptk declarations (except, of course, the macro's)
anonymous enum |
anonymous enum |
context* bmptk::current_context | ( | ) |
the current exceuting context
This function returns thye currently executing context (initially this is of course &main_context).
time bmptk::current_time | ( | ) |
return the current time
This function returns the amount of time elaspsed since some arbitrary epoch.
On most targets the epoch will be the first call to this function.
On most targets this function (and hence all the wait functions that use it) must be called at least once every x time. In practice this will seldom be a problem: applications that use timing tend to do so on a sub-second basis. On an NDS x is 130 seconds.
On windows this function (and hence all timing related functions) returns the time since windows started, with a resolution of 1 ms. 49 Days after windows was last started it will wrap around to 0. Don't blame me, I am just the piano player..
void bmptk::fatal_error_detected | ( | const char * | msg | ) |
handle a fatal error
This function is called by bmptk code when a fatal condition has been detected at run time. The function that is called is determined by fatal_error_handler(). By default this function does nothing, but fatal_error_hander The default is to loop forever (do nothing).
The application could specify a function that makes a attempt to alert the user show the msg. When the user-defined error handler returns the system will loop forever (do nothing).
void bmptk::fatal_error_handler | ( | void | fconst char * | ) |
set the fatal error handler
This function sets the function that is called when fatal_error_detected() is called. When this error hanler fucntion returns the system will loop forever (do nothing).
unsigned int bmptk::heap_free | ( | ) |
report the number of free bytes on the heap
This function will probably not give a meaningfull result on a hosted environment (for instance windows).
constexpr time bmptk::ms | ( | us * | 1000 | ) |
unit of time : millisecond
Unit of time, to be used by methods that require a time argument. For instance, to pass half a second, use
500 * bmptk::ms
constexpr time bmptk::s | ( | us *1000 * | 1000 | ) |
unit of time : microsecond
Units of time, to be are used by methods that require a time argument. For instance, to pass one hour, use
60 * 60 * bmptk::s
constexpr time bmptk::us | ( | time:: | us() | ) |
unit of time : microsecond
Unit of time, to be used by methods that require a time argument. For instance, to pass half a millisecond, use
500 * bmptk::us
void bmptk::wait | ( | time | t | ) |
wait an amount of time
This function waits at leas the requested amount of time before returning.
When this function is used to measure time over multiple calls using wait_until should be considered beacuse it can avoid the 'accumulated error' problem.
By default this function calls wait_busy, but when an RTOS is used it will switch to another task. When the extra delay that might be caused by task switching is not acceptable wait_busy should be used instead.
void bmptk::wait_busy | ( | time | t | ) |
busy wait an amount of time
This function waits the requested amount of time before returning. It uses busy waiting, polling current_time() to check whether the request amount of time has elapsed.
When this function is used to measure time over multiple calls using wait_busy_until should be considered beacuse it can avoid the 'accumulated error' problem.
When task switching (which can result in a longer delay) is not a problem wait() should be used instead, because it does not lock up the other tasks.
void bmptk::wait_busy_until | ( | time | t | ) |
busy wait until a moment in time
This function waits until the specified moment in time. It uses busy waiting, polling current_time().
When task switching (which can result in a longer delay) is not a problem wait_until() or an RTOS time function should be used instead, to avoid locking up the other tasks.
void bmptk::wait_until | ( | time | t | ) |
wait until a moment in time
This function waits until the specified moment in time. It uses busy waiting, polling current_time().
By default this function calls wait_busy_until, but when an RTOS is used it will switch to another task. When the extra delay that might be caused by task switching is not acceptable wait_busy should be used instead.
context bmptk::main_context |
the context of the main()
This context can be used to resume the main, after it has yielded execution to another context.