Edison MCU Project
 All Files Functions Typedefs Macros Pages
mcu_api.h
Go to the documentation of this file.
1 /************************************************************************************
2  * Copyright (c) 2015, Intel Corporation
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without modification,
6  * are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice, this
9  * list of conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation and/or
13  * other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18  * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
19  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
20  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
23  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
24  * OF THE POSSIBILITY OF SUCH DAMAGE.
25  ************************************************************************************/
26 
35 #ifndef __MCUAPI_H
36 #define __MCUAPI_H
37 
38 #define DBG_FATAL 1
39 #define DBG_ERROR 2
40 #define DBG_WARNING 3
41 #define DBG_INFO 4
42 #define DBG_DEBUG 5
43 
48 int api_version();
49 
55 int gpio_read(int gpio);
56 
62 void gpio_write(int gpio, int val);
63 
69 void gpio_setup(int gpio, int direction);
70 
71 #define IRQ_NONE 0
72 #define IRQ_HANDLED 1
73 
78 typedef int (*irq_handler_t)(int irq);
79 
87 int gpio_register_interrupt(int gpio, int int_mode, irq_handler_t fn);
88 
96 int uart_setup(unsigned char port, int baudrate);
97 
105 int uart_read(unsigned char port, unsigned char *buf, unsigned char len);
106 
114 int uart_write(unsigned char port, unsigned char *buf, unsigned char len);
115 
124 int pwm_configure(unsigned char port, int duty_ns, int period_ns);
125 
131 int pwm_enable(unsigned char port);
132 
138 int pwm_disable(unsigned char port);
139 
148 int i2c_read(unsigned char addr, unsigned char reg, unsigned char *buf, int len);
149 
158 int i2c_write(unsigned char addr, unsigned char reg, unsigned char *buf, int len);
159 
164 void mcu_sleep(int ticks);
165 
173 int mcu_delay(int delay_us);
174 
181 unsigned long time_ms();
182 
189 unsigned long time_us();
190 
200 int host_send(unsigned char *buf, int length);
201 
208 int host_receive(unsigned char *buf, int length);
209 
215 void debug_print(int level, const char *fmt, ...);
216 
225 int mcu_snprintf(char *buf, unsigned int size, const char *fmt, ...);
226 #endif
int pwm_configure(unsigned char port, int duty_ns, int period_ns)
int uart_write(unsigned char port, unsigned char *buf, unsigned char len)
unsigned long time_ms()
int api_version()
int gpio_register_interrupt(int gpio, int int_mode, irq_handler_t fn)
int(* irq_handler_t)(int irq)
Definition: mcu_api.h:78
int uart_read(unsigned char port, unsigned char *buf, unsigned char len)
int pwm_disable(unsigned char port)
int gpio_read(int gpio)
unsigned long time_us()
int pwm_enable(unsigned char port)
void debug_print(int level, const char *fmt,...)
void mcu_sleep(int ticks)
int mcu_delay(int delay_us)
int i2c_write(unsigned char addr, unsigned char reg, unsigned char *buf, int len)
int i2c_read(unsigned char addr, unsigned char reg, unsigned char *buf, int len)
void gpio_setup(int gpio, int direction)
int host_send(unsigned char *buf, int length)
int host_receive(unsigned char *buf, int length)
void gpio_write(int gpio, int val)
int mcu_snprintf(char *buf, unsigned int size, const char *fmt,...)
int uart_setup(unsigned char port, int baudrate)