This is a port of the mruby/c tutorial Chapter 03 to the mbed environment.

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers hal.h Source File

hal.h

Go to the documentation of this file.
00001 /*! @file
00002   @brief
00003   Realtime multitask monitor for mruby/c
00004   Hardware abstraction layer
00005         for PSoC5LP
00006 
00007   <pre>
00008   Copyright (C) 2016 Kyushu Institute of Technology.
00009   Copyright (C) 2016 Shimane IT Open-Innovation Center.
00010 
00011   This file is distributed under BSD 3-Clause License.
00012   </pre>
00013 */
00014 
00015 #ifndef MRBC_SRC_HAL_H_
00016 #define MRBC_SRC_HAL_H_
00017 
00018 #ifdef __cplusplus
00019 extern "C" {
00020 #endif
00021 
00022 
00023 /* DON'T USE TIMER */
00024 #define MRBC_NO_TIMER 1
00025 
00026 
00027 /***** Feature test switches ************************************************/
00028 /***** System headers *******************************************************/
00029 
00030 
00031 /***** Local headers ********************************************************/
00032 /***** Constant values ******************************************************/
00033 /***** Macros ***************************************************************/
00034 extern void wait_ms(int tm);
00035 
00036 #ifndef MRBC_NO_TIMER
00037 # define hal_init()        ((void)0)
00038 # define hal_enable_irq()  CyGlobalIntEnable
00039 # define hal_disable_irq() CyGlobalIntDisable
00040 # define hal_idle_cpu()    CyPmAltAct(PM_SLEEP_TIME_NONE, \
00041                                       PM_SLEEP_SRC_CTW | PM_SLEEP_SRC_PICU)
00042 
00043 #else // MRBC_NO_TIMER
00044 # define hal_init()        ((void)0)
00045 # define hal_enable_irq()  ((void)0)
00046 # define hal_disable_irq() ((void)0)
00047 # define hal_idle_cpu()    (wait_ms(1), mrbc_tick())
00048 
00049 #endif
00050 
00051 
00052 /***** Typedefs *************************************************************/
00053 /***** Global variables *****************************************************/
00054 /***** Function prototypes **************************************************/
00055 int hal_write(int fd, const void *buf, size_t nbytes);
00056 int hal_flush(int fd);
00057 
00058 
00059 /***** Inline functions *****************************************************/
00060 
00061 
00062 #ifdef __cplusplus
00063 }
00064 #endif
00065 #endif // ifndef MRBC_HAL_H_
00066