/** \mainpage Driver Overview
  *
  * \section section_drv_info Driver Information
  * This Sensor Controller Interface driver has been generated by the Texas Instruments Sensor Controller
  * Studio tool:
  * - <b>Project name</b>:     CC1352P ALS
  * - <b>Project file</b>:     C:/Users/a0219221/Desktop/sensorControllerDemo/cc1352pAls/cc1352pALS.scp
  * - <b>Code prefix</b>:      -
  * - <b>Operating system</b>: TI-RTOS
  * - <b>Tool version</b>:     2.3.0.684
  * - <b>Tool patches</b>:     None
  * - <b>Target chip</b>:      CC1352P1F3, revision -, package QFN48 7x7 RGZ
  * - <b>Created</b>:          2018-12-11 22:29:31.280
  * - <b>Computer</b>:         CNA0219221B
  * - <b>User</b>:             a0219221
  *
  * No user-provided resource definitions were used to generate this driver.
  *
  * No user-provided procedure definitions were used to generate this driver.
  *
  * Do not edit the generated source code files other than temporarily for debug purposes. Any
  * modifications will be overwritten by the Sensor Controller Studio when generating new output.
  *
  * \section section_drv_modules Driver Modules
  * The driver is divided into three modules:
  * - \ref module_scif_generic_interface, providing the API for:
  *     - Initializing and uninitializing the driver
  *     - Task control (for starting, stopping and executing Sensor Controller tasks)
  *     - Task data exchange (for producing input data to and consume output data from Sensor Controller
  *       tasks)
  * - \ref module_scif_driver_setup, containing:
  *     - The AUX RAM image (Sensor Controller code and data)
  *     - I/O mapping information
  *     - Task data structure information
  *     - Driver setup data, to be used in the driver initialization
  *     - Project-specific functionality
  * - \ref module_scif_osal, for flexible OS support:
  *     - Interfaces with the selected operating system
  *
  * It is possible to use output from multiple Sensor Controller Studio projects in one application. Only
  * one driver setup may be active at a time, but it is possible to switch between these setups. When
  * using this option, there is one instance of the \ref module_scif_generic_interface and
  * \ref module_scif_osal modules, and multiple instances of the \ref module_scif_driver_setup module.
  * This requires that:
  * - The outputs must be generated using the same version of Sensor Controller Studio
  * - The outputs must use the same operating system
  * - The outputs must use different source code prefixes (inserted into all globals of the
  *   \ref module_scif_driver_setup)
  *
  *
  * \section section_project_info Project Description
  * Demonstrates use of the bit-banged I2C master interface by sampling the OPT3001 light sensor on the
  * CC2650 SensorTag.
  * 
  * The application is woken if the light sensor output value changes by more than a configurable amount:
  * - If decreasing, the application blinks the red LED on the SensorTag.
  * - If increasing, the application blinks the green LED on the SensorTag.
  * 
  * See the header in the application source file ("main.c" or similar) for further details and
  * instructions. This file is located in the source code output directory.
  *
  *
  * \subsection section_io_mapping I/O Mapping
  * Task I/O functions are mapped to the following pins:
  * - cc1352Pals:
  *     - <b>I2C SCL</b>: DIO22
  *     - <b>I2C SDA</b>: DIO5
  *
  *
  * \section section_task_info Task Description(s)
  * This driver supports the following task(s):
  *
  *
  * \subsection section_task_desc_cc1352pals cc1352Pals
  * Samples the OPT3001 light sensor on the CC2650 SensorTag. This light sensor integrates over longer
  * periods of time to minimize the effect of 50 and 60 Hz noise sources.
  * 
  * Each iteration of the I2C Light Sensor task:
  * - Runs the Execution Code: The light sensor configured for 100 ms integration, and a single
  * measurement is started. The timer based event trigger is enabled (100 ms + margin).
  * - Runs the Event Handler Code: The light sensor value is read and processed.
  * 
  * The light sensor output is converted from floating-point (12-bit mantissa, 4-bit exponent) to
  * fixed-point (16-bit). The system CPU is alerted if the value is above or below configurable
  * thresholds.
  * 
  * Note that OPT3001 implements a timeout for I2C accesses, and will NACK I2C TX operations if a task
  * debugging session halts execution in the middle of an I2C transaction.
  *
  */




/** \addtogroup module_scif_driver_setup Driver Setup
  *
  * \section section_driver_setup_overview Overview
  *
  * This driver setup instance has been generated for:
  * - <b>Project name</b>:     CC1352P ALS
  * - <b>Code prefix</b>:      -
  *
  * The driver setup module contains the generated output from the Sensor Controller Studio project:
  * - Location of task control and scheduling data structures in AUX RAM
  * - The AUX RAM image, and the size the image
  * - Task data structure information (location, size and buffer count)
  * - I/O pin mapping translation table
  * - Task resource initialization and uninitialization functions
  * - Hooks for run-time logging
  *
  * @{
  */
#ifndef SCIF_H
#define SCIF_H

#include <stdint.h>
#include <stdbool.h>
#include "scif_framework.h"
#include "scif_osal_tirtos.h"


/// Target chip name
#define SCIF_TARGET_CHIP_NAME_CC1352P1F3
/// Target chip package
#define SCIF_TARGET_CHIP_PACKAGE_QFN48_7X7_RGZ

/// Number of tasks implemented by this driver
#define SCIF_TASK_COUNT 1

/// cc1352Pals: Task ID
#define SCIF_CC1352PALS_TASK_ID 0


/// cc1352Pals: OPT3001 configuration triggering 100 ms single conversion
#define SCIF_CC1352PALS_ALS_CFG_ONE_SHOT 49680
/// cc1352Pals: OPT3001 configuration at reset (shutdown)
#define SCIF_CC1352PALS_ALS_CFG_RESET 51216
/// cc1352Pals: OPT3001 I2C address
#define SCIF_CC1352PALS_ALS_I2C_ADDR 136
/// cc1352Pals: OPT3001 configuration register
#define SCIF_CC1352PALS_ALS_REG_CFG 1
/// cc1352Pals: OPT3001 result register
#define SCIF_CC1352PALS_ALS_REG_RESULT 0
/// cc1352Pals I/O mapping: I2C SCL
#define SCIF_CC1352PALS_DIO_I2C_SCL 22
/// cc1352Pals I/O mapping: I2C SDA
#define SCIF_CC1352PALS_DIO_I2C_SDA 5


// All shared data structures in AUX RAM need to be packed
#pragma pack(push, 2)


/// cc1352Pals: Task configuration structure
typedef struct {
    uint16_t highThreshold; ///< High alert threshold
    uint16_t lowThreshold;  ///< Low alert threshold
} SCIF_CC1352PALS_CFG_T;


/// cc1352Pals: Task output data structure
typedef struct {
    uint16_t value; ///< Light sensor output value
} SCIF_CC1352PALS_OUTPUT_T;


/// cc1352Pals: Task state structure
typedef struct {
    uint16_t i2cStatus; ///< I2C master status
} SCIF_CC1352PALS_STATE_T;


/// Sensor Controller task data (configuration, input buffer(s), output buffer(s) and internal state)
typedef struct {
    struct {
        SCIF_CC1352PALS_CFG_T cfg;
        SCIF_CC1352PALS_OUTPUT_T output;
        SCIF_CC1352PALS_STATE_T state;
    } cc1352pals;
} SCIF_TASK_DATA_T;

/// Sensor Controller task generic control (located in AUX RAM)
#define scifTaskData    (*((volatile SCIF_TASK_DATA_T*) 0x400E015C))


// Initialized internal driver data, to be used in the call to \ref scifInit()
extern const SCIF_DATA_T scifDriverSetup;


// Restore previous struct packing setting
#pragma pack(pop)


// AUX I/O re-initialization functions
void scifReinitTaskIo(uint32_t bvTaskIds);


// RTC-based tick generation control
void scifStartRtcTicks(uint32_t tickStart, uint32_t tickPeriod);
void scifStartRtcTicksNow(uint32_t tickPeriod);
void scifStopRtcTicks(void);


#endif
//@}


// Generated by CNA0219221B at 2018-12-11 22:29:31.280
