[update] update gpio
This commit is contained in:
+2
@@ -1,3 +1,5 @@
|
||||
#include "application_config/application_config.h"
|
||||
#include "HAL/cc2650_driver/spi_ctrl.h"
|
||||
#include "HAL/ADGS1412x9.h"
|
||||
|
||||
|
||||
|
||||
+2
-1
@@ -12,8 +12,9 @@
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
*/
|
||||
|
||||
#include "HAL/APA102_2020_256_8x4.h"
|
||||
#include "application_config/application_config.h"
|
||||
#include "HAL/cc2650_driver/spi_ctrl.h"
|
||||
#include "HAL/APA102_2020_256_8x4.h"
|
||||
|
||||
#define LED_FRME_FILL_RSVD(_f) (_f)->rsvd = 0x07 // 0x11100000 || bright
|
||||
#define LED_SERIES_D_START 0x00000000
|
||||
|
||||
+2
-3
@@ -12,8 +12,9 @@
|
||||
* |0 0 1 1 D3 D2 D1 D0| DAC data |
|
||||
* +-+-+-+-+--+--+--+--+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
*/
|
||||
#include "HAL/MAX5136x2.h"
|
||||
#include "application_config/application_config.h"
|
||||
#include "HAL/cc2650_driver/spi_ctrl.h"
|
||||
#include "HAL/MAX5136x2.h"
|
||||
|
||||
struct dac_series_data_t {
|
||||
uint8_t control_bits;
|
||||
@@ -26,8 +27,6 @@ static struct dac_series_data_t dac_series_data_g[MAX5136_NUM_MAX] = {0};
|
||||
|
||||
static int __dac_transfer(struct dac_series_data_t *sd)
|
||||
{
|
||||
|
||||
|
||||
spi1_close();
|
||||
spi1_open(SPI_CLK_4M, POL1, PHA0);
|
||||
|
||||
|
||||
+1
-1
@@ -38,8 +38,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "HAL/MCP23008x2.h"
|
||||
#include "HAL/cc2650_driver/i2c_ctrl.h"
|
||||
#include "HAL/MCP23008x2.h"
|
||||
|
||||
#define MCP23008_WT_BIT 0
|
||||
#define MCP23008_RD_BIT 1
|
||||
|
||||
+3
-3
@@ -4,9 +4,9 @@
|
||||
|
||||
#define VERSION_DATE_YEAR 23
|
||||
#define VERSION_DATE_MONTH 3
|
||||
#define VERSION_DATE_DAY 15
|
||||
#define VERSION_DATE_HOUR 18
|
||||
#define VERSION_DATE_MINUTE 3
|
||||
#define VERSION_DATE_DAY 16
|
||||
#define VERSION_DATE_HOUR 12
|
||||
#define VERSION_DATE_MINUTE 43
|
||||
|
||||
// this is NOT the version hash !!
|
||||
// it's the last version hash
|
||||
|
||||
+83
-82
@@ -1256,10 +1256,14 @@ static void initDATBuf();
|
||||
|
||||
#include <ti/drivers/pin/PINCC26XX.h>
|
||||
|
||||
static PIN_Handle eliteCtrlHandle;
|
||||
static PIN_State eliteState;
|
||||
struct gpio_ctx_t {
|
||||
PIN_Handle handle;
|
||||
PIN_State state;
|
||||
};
|
||||
|
||||
const PIN_Config BLE_IO[] = {
|
||||
static struct gpio_ctx_t gpio_ctx;
|
||||
|
||||
const PIN_Config GPIO_IO[] = {
|
||||
E_PIN_ADCA0 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
|
||||
E_PIN_ADCA1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
|
||||
E_PIN_ADCA2 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
|
||||
@@ -1274,35 +1278,32 @@ const PIN_Config BLE_IO[] = {
|
||||
};
|
||||
|
||||
uint8_t gpio_create(void)
|
||||
{
|
||||
//ret=0 -> success
|
||||
// =1 -> already exists
|
||||
// =2 -> open fail
|
||||
{
|
||||
struct gpio_ctx_t ctx = gpio_ctx;
|
||||
|
||||
PIN_Handle *h = &eliteCtrlHandle;
|
||||
PIN_State *s = &eliteState;
|
||||
|
||||
if (*h != NULL)
|
||||
ctx.handle = PIN_open(&(ctx.state), GPIO_IO);
|
||||
if (ctx.handle == NULL)
|
||||
return 1;
|
||||
|
||||
*h = PIN_open(s, BLE_IO);
|
||||
|
||||
if (*h == NULL)
|
||||
return 2;
|
||||
|
||||
/*
|
||||
* ret = 0 : success
|
||||
* = 1 : open fail
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
static uint8_t pin_set(uint8_t pin, uint8_t set_value)
|
||||
uint8_t pin_set(uint8_t pin, uint8_t set_value)
|
||||
{
|
||||
//ret=0 -> success
|
||||
// =2 -> no access
|
||||
uint8_t p = pin;
|
||||
uint8_t v = set_value;
|
||||
|
||||
PIN_Handle *h = &eliteCtrlHandle;
|
||||
|
||||
return (uint8_t)(PIN_setOutputValue(*h, p, v));
|
||||
struct gpio_ctx_t ctx = gpio_ctx;
|
||||
|
||||
/*
|
||||
* ret = 0 : PIN_SUCCESS
|
||||
* = 1 : PIN_ALREADY_ALLOCATED
|
||||
* = 2 : PIN_NO_ACCESS
|
||||
* = 3 : PIN_UNSUPPORTED
|
||||
*/
|
||||
return (uint8_t)(PIN_setOutputValue(ctx.handle, p, v));
|
||||
}
|
||||
|
||||
static void adc_sel_set(uint8_t adc_sel)
|
||||
@@ -1375,12 +1376,12 @@ static void ELITE15_SPI_HOLD() {
|
||||
// PIN_setOutputValue(eliteCtrlHandle, LOAD2, 0);
|
||||
}
|
||||
static void ELITE15_SPI_CLOSE() {
|
||||
PIN_setOutputValue(eliteCtrlHandle, LOAD0, 0);
|
||||
PIN_setOutputValue(eliteCtrlHandle, LOAD1, 0);
|
||||
PIN_setOutputValue(eliteCtrlHandle, LOAD2, 0);
|
||||
// PIN_setOutputValue(eliteCtrlHandle, LOAD0, 0);
|
||||
// PIN_setOutputValue(eliteCtrlHandle, LOAD1, 0);
|
||||
// PIN_setOutputValue(eliteCtrlHandle, LOAD2, 0);
|
||||
|
||||
spi0_close();
|
||||
spi1_close();
|
||||
// spi0_close();
|
||||
// spi1_close();
|
||||
}
|
||||
|
||||
// #include "EliteADC.h"
|
||||
@@ -1440,63 +1441,63 @@ void AutoGainChangeVin(int32_t RealVin);
|
||||
|
||||
static void __ADC_write(uint8_t ADCin, uint8_t *rxbuf, uint8_t *txbuf)
|
||||
{
|
||||
/*
|
||||
* write SPI to get ADC value
|
||||
* This function can only define [15]~[8] through ADCin
|
||||
* [7]~[0] should always be 0b11101011
|
||||
*
|
||||
* [15] : SS, 0 = no effect, 1 = start work, default 0b0
|
||||
* [14]~[12] : MUX[2:0], default 0b000
|
||||
* [11]~[9] : PGA[2:0], default 0b010 = FSR is ±2.048
|
||||
* [8] : mode, 0 = continuous, 1 = one shot, default 0b1 (Power-down and single-shot mode )
|
||||
*
|
||||
* [7]~[5] : data rate, default 0b100 = 128 SPS
|
||||
* [4] : Temperature? default 0b0 = ADC mode
|
||||
* [3] : Pullup enable, default 0b1 = Pullup resistor enabled
|
||||
* [2]~[1] : NOP, default 0b01
|
||||
* [0] : reserved, default 0b1
|
||||
*
|
||||
*/
|
||||
uint8_t *rx = rxbuf;
|
||||
uint8_t *tx = txbuf;
|
||||
// /*
|
||||
// * write SPI to get ADC value
|
||||
// * This function can only define [15]~[8] through ADCin
|
||||
// * [7]~[0] should always be 0b11101011
|
||||
// *
|
||||
// * [15] : SS, 0 = no effect, 1 = start work, default 0b0
|
||||
// * [14]~[12] : MUX[2:0], default 0b000
|
||||
// * [11]~[9] : PGA[2:0], default 0b010 = FSR is ±2.048
|
||||
// * [8] : mode, 0 = continuous, 1 = one shot, default 0b1 (Power-down and single-shot mode )
|
||||
// *
|
||||
// * [7]~[5] : data rate, default 0b100 = 128 SPS
|
||||
// * [4] : Temperature? default 0b0 = ADC mode
|
||||
// * [3] : Pullup enable, default 0b1 = Pullup resistor enabled
|
||||
// * [2]~[1] : NOP, default 0b01
|
||||
// * [0] : reserved, default 0b1
|
||||
// *
|
||||
// */
|
||||
// uint8_t *rx = rxbuf;
|
||||
// uint8_t *tx = txbuf;
|
||||
|
||||
// tx[0] = 0b00000101;
|
||||
for (int i=0; i<SPI_ADC_SIZE; i++) {
|
||||
tx[i] = 0;
|
||||
rx[i] = 0;
|
||||
// // tx[0] = 0b00000101;
|
||||
// for (int i=0; i<SPI_ADC_SIZE; i++) {
|
||||
// tx[i] = 0;
|
||||
// rx[i] = 0;
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
tx[0] = ADCin;
|
||||
tx[1] = 0b11101011;
|
||||
// tx[0] = ADCin;
|
||||
// tx[1] = 0b11101011;
|
||||
|
||||
PIN_setOutputValue(eliteCtrlHandle, LOAD0, 1);
|
||||
PIN_setOutputValue(eliteCtrlHandle, D6, 0); // CS_ADC LOW
|
||||
spi1_write(rx, tx, 2);
|
||||
// PIN_setOutputValue(eliteCtrlHandle, LOAD0, 1);
|
||||
// PIN_setOutputValue(eliteCtrlHandle, D6, 0); // CS_ADC LOW
|
||||
// spi1_write(rx, tx, 2);
|
||||
|
||||
PIN_setOutputValue(eliteCtrlHandle, D6, 1); // CS_ADC HIGH
|
||||
// PIN_setOutputValue(eliteCtrlHandle, D6, 1); // CS_ADC HIGH
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void __ADC_read(uint8_t *rxbuf, uint8_t *txbuf)
|
||||
{
|
||||
/*
|
||||
* read SPI to get ADC value
|
||||
*/
|
||||
uint8_t *rx = rxbuf;
|
||||
uint8_t *tx = txbuf;
|
||||
// /*
|
||||
// * read SPI to get ADC value
|
||||
// */
|
||||
// uint8_t *rx = rxbuf;
|
||||
// uint8_t *tx = txbuf;
|
||||
|
||||
for (int i=0; i<SPI_ADC_SIZE; i++) {
|
||||
tx[i] = 0;
|
||||
rx[i] = 0;
|
||||
// for (int i=0; i<SPI_ADC_SIZE; i++) {
|
||||
// tx[i] = 0;
|
||||
// rx[i] = 0;
|
||||
|
||||
}
|
||||
PIN_setOutputValue(eliteCtrlHandle, LOAD0, 1);
|
||||
PIN_setOutputValue(eliteCtrlHandle, D6, 0); // CS_ADC LOW
|
||||
spi1_write(rx, tx, 2);
|
||||
// }
|
||||
// PIN_setOutputValue(eliteCtrlHandle, LOAD0, 1);
|
||||
// PIN_setOutputValue(eliteCtrlHandle, D6, 0); // CS_ADC LOW
|
||||
// spi1_write(rx, tx, 2);
|
||||
|
||||
PIN_setOutputValue(eliteCtrlHandle, D6, 1); // CS_ADC HIGH
|
||||
// PIN_setOutputValue(eliteCtrlHandle, D6, 1); // CS_ADC HIGH
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2085,20 +2086,20 @@ static bool DACReset;
|
||||
#define DACOUT 0x31
|
||||
|
||||
static uint16_t DAC_outputV(uint16_t voltLV) {
|
||||
uint8_t v1, v2 = 0;
|
||||
v1 = (uint8_t) ((voltLV & 0xFF00) >> 8);
|
||||
v2 = (uint8_t) (voltLV & 0x00FF);
|
||||
// uint8_t v1, v2 = 0;
|
||||
// v1 = (uint8_t) ((voltLV & 0xFF00) >> 8);
|
||||
// v2 = (uint8_t) (voltLV & 0x00FF);
|
||||
|
||||
spi_DACtxbuf[0] = DACOUT;
|
||||
spi_DACtxbuf[1] = v1;
|
||||
spi_DACtxbuf[2] = v2;
|
||||
// spi_DACtxbuf[0] = DACOUT;
|
||||
// spi_DACtxbuf[1] = v1;
|
||||
// spi_DACtxbuf[2] = v2;
|
||||
|
||||
PIN_setOutputValue(eliteCtrlHandle, LOAD0, 1);
|
||||
PIN_setOutputValue(eliteCtrlHandle, D7, 0); // CS_DAC LOW
|
||||
// PIN_setOutputValue(eliteCtrlHandle, LOAD0, 1);
|
||||
// PIN_setOutputValue(eliteCtrlHandle, D7, 0); // CS_DAC LOW
|
||||
|
||||
spi1_write(spi_rxbuf, spi_DACtxbuf, SPI_DAC_SIZE);
|
||||
// spi1_write(spi_rxbuf, spi_DACtxbuf, SPI_DAC_SIZE);
|
||||
|
||||
PIN_setOutputValue(eliteCtrlHandle, D7, 1); // CS_DAC HIGH
|
||||
// PIN_setOutputValue(eliteCtrlHandle, D7, 1); // CS_DAC HIGH
|
||||
|
||||
return voltLV;
|
||||
}
|
||||
|
||||
+9
-13
@@ -48,7 +48,7 @@
|
||||
/*********************************************************************
|
||||
* INCLUDES
|
||||
*/
|
||||
#include "application_config/application_config.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <ti/sysbios/knl/Task.h>
|
||||
@@ -101,12 +101,6 @@
|
||||
#include <xdc/runtime/Types.h>
|
||||
|
||||
|
||||
#include "HAL/cc2650_driver/spi_ctrl.h"
|
||||
#include "HAL/cc2650_driver/i2c_ctrl.h"
|
||||
#include "HAL/APA102_2020_256_8x4.h"
|
||||
#include "HAL/MCP23008x2.h"
|
||||
|
||||
#include "HAL/MAX5136x2.h"
|
||||
static GPTimerCC26XX_Handle gptimer_handle;
|
||||
|
||||
static void elite_gptimer_callback(GPTimerCC26XX_Handle handle, GPTimerCC26XX_IntMask interruptMask);
|
||||
@@ -160,14 +154,15 @@ static void elite_gptimer_callback(GPTimerCC26XX_Handle handle, GPTimerCC26XX_In
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#include "application/BAT_10_app.h"
|
||||
#include "application_config/application_config.h"
|
||||
#include "HAL/cc2650_driver/spi_ctrl.h"
|
||||
#include "HAL/cc2650_driver/i2c_ctrl.h"
|
||||
#include "HAL/APA102_2020_256_8x4.h"
|
||||
#include "HAL/MCP23008x2.h"
|
||||
#include "HAL/MAX5136x2.h"
|
||||
#include "unfinished_code.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static void SimpleBLEPeripheral_performPeriodicTask(void);
|
||||
|
||||
|
||||
@@ -779,7 +774,7 @@ static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1)
|
||||
// Initialize application
|
||||
SimpleBLEPeripheral_init();
|
||||
|
||||
eliteCtrlHandle = PIN_open(&eliteState, BLE_IO);
|
||||
gpio_create();
|
||||
|
||||
Board_initSPI();
|
||||
spi0_open(SPI_CLK_10M, POL0, PHA1); //10M // SPI0 = LED
|
||||
@@ -1348,6 +1343,7 @@ static void SimpleBLEPeripheral_enqueueMsg(uint8_t event, uint8_t state)
|
||||
}
|
||||
}
|
||||
|
||||
#include "application/BAT_10_app_c.h"
|
||||
#include "HAL/cc2650_driver/spi_ctrl_c.h"
|
||||
#include "HAL/cc2650_driver/i2c_ctrl_c.h"
|
||||
#include "HAL/APA102_2020_256_8x4_c.h"
|
||||
|
||||
Reference in New Issue
Block a user