/*
 * ________________________________________________________________________________________________________
 * Copyright (c) 2017 InvenSense Inc. All rights reserved.
 *
 * This software, related documentation and any modifications thereto (collectively “Software”) is subject
 * to InvenSense and its licensors' intellectual property rights under U.S. and international copyright
 * and other intellectual property rights laws.
 *
 * InvenSense and its licensors retain all intellectual property and proprietary rights in and to the Software
 * and any use, reproduction, disclosure or distribution of the Software without an express license agreement
 * from InvenSense is strictly prohibited.
 *
 * EXCEPT AS OTHERWISE PROVIDED IN A LICENSE AGREEMENT BETWEEN THE PARTIES, THE SOFTWARE IS
 * PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
 * TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
 * EXCEPT AS OTHERWISE PROVIDED IN A LICENSE AGREEMENT BETWEEN THE PARTIES, IN NO EVENT SHALL
 * INVENSENSE BE LIABLE FOR ANY DIRECT, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
 * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
 * OF THE SOFTWARE.
 * ________________________________________________________________________________________________________
 */
#ifndef _SYSTEM_H_
#define _SYSTEM_H_

#define SERIF_TYPE_I2C 				1					/* 101xx works on I2C interface only, do not change */				

#define USART_TX_DMA_XFER_EN		0
#define BUFFER_SIZE					256

#define MILLISECONDS_PER_SECOND			1000
#define MICROSECONDS_PER_MILLISECOND	1000

/* Macros and defines */
#define CONSOLE_UART_IRQn           FLEXCOM0_IRQn		/* Configuration for console uart IRQ for command handling */
#define console_uart_irq_handler    FLEXCOM0_Handler	/* Configuration for console uart IRQ handler for command handling */

/* Function prototype declarations */
void clear_irq(void);
void configure_console(void);
void timer_create_ringbuffer_timestamp(uint32_t value);
int32_t timer_clear_irq_timestamp(void);
uint64_t timer_get_irq_timestamp_us(void);

void i2c_master_initialize(void);
uint32_t i2c_master_read_register(uint8_t chip_address, uint8_t reg, uint32_t rlen, void * rbuffer);
uint32_t i2c_master_write_register(uint8_t chip_address, uint8_t reg, uint32_t wlen, void * wbuffer);

typedef void (*timer_callback_t)(void *);
void timer_register_callback(timer_callback_t cb_ptr);
void set_pressure_timer(uint32_t new_timer_val);

#endif /* !_SYSTEM_H_ */
