summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 02b4017)
raw | patch | inline | side by side (parent: 02b4017)
author | Borja Martinez <borja.martinez@gmail.com> | |
Fri, 16 Dec 2016 16:35:28 +0000 (17:35 +0100) | ||
committer | Borja Martinez <borja.martinez@gmail.com> | |
Fri, 16 Dec 2016 16:35:28 +0000 (17:35 +0100) |
diff --git a/Basic-Test-Package/CC2650/Test_CC2650_3wSPI_DAC8730/main.c b/Basic-Test-Package/CC2650/Test_CC2650_3wSPI_DAC8730/main.c
index a3594192c94fe90cce12243337ff6e61bc394eff..3d5ed6a3f8fa4587a27ae78f5ff5fef2bb1ea2e4 100644 (file)
/* XDCtools Header files */
#include <xdc/std.h>
#include <xdc/runtime/System.h>
+#include <xdc/runtime/Error.h>
/* BIOS Header files */
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Task.h>
#include <ti/sysbios/knl/Clock.h>
#include <ti/sysbios/knl/Semaphore.h>
+#include <ti/sysbios/knl/Event.h>
/* TI-RTOS Header files */
//#include <ti/drivers/I2C.h>
Char task2Stack[TASKSTACKSIZE];
+
+Event_Handle myEvent;
+Error_Block eb;
+
Semaphore_Struct semStruct;
Semaphore_Handle semHandle;
void buttonCallbackFxn(PIN_Handle handle, PIN_Id pinId) {
- PIN_setOutputValue(ledPinHandle, Board_LED1,1);
- Semaphore_post(semHandle);
- CPUdelay(8000*50);
- PIN_setOutputValue(ledPinHandle, Board_LED1,0);
+ CPUdelay(8000*200);
+
+ Semaphore_post(semHandle);
+ //Event_post(myEvent,Event_Id_02);
+
+}
+
+Void uartFxn(UArg arg0, UArg arg1)
+{
+ char input;
+
+ while (1) {
+ // Blocking Read
+ input=uart_getch();
+ if(input=='g'){
+ //Event_post(myEvent,Event_Id_02);
+ Semaphore_post(semHandle);
+ }
+ Task_sleep((UInt)arg0);
+ }
+
}
+
#define REGSBW 0x1E
#define REGSBR 0x0F
+
+#define EEPSBW 0x5A
#define EEPSBR 0x4B
#define CMRST 0xC3
-#define WENA 0x00
+#define WENA 0x00
+#define VCFG1 0x01
+#define VCFG2 0x01
+
+#define STA1 0x07
+#define STA2 0x08
#define GPVR 0x0C
+#define CFG3 0xA6
+
Void spiFxn(UArg arg0, UArg arg1)
{
int i;
uint8_t k=0;
+ int flagerr=0;
SPI_Handle spi;
SPI_Params spiParams;
SPI_Transaction spiTransaction;
+ UInt events;
SPI_Params_init(&spiParams);
// Slave mode
//Task_sleep((UInt)arg0);
System_printf("Press button:\r\n");
+ PIN_setOutputValue(ledPinHandle, Board_LED0,1);
+ PIN_setOutputValue(ledPinHandle, Board_LED1,1);
+
Semaphore_pend(semHandle, BIOS_WAIT_FOREVER);
+ /* Start test */
+ PIN_setOutputValue(ledPinHandle, Board_LED0,0);
+ PIN_setOutputValue(ledPinHandle, Board_LED1,0);
+
/* Send SPI Reset Command */
spiTransaction.rxBuf = rxBufferPointer;
rxBufferPointer[2]=0;
if (SPI_transfer(spi,&spiTransaction)) {
- System_printf("Rst: %x %x %x\r\n",rxBufferPointer[0],rxBufferPointer[1],rxBufferPointer[2]);
+ if (rxBufferPointer[2] != 0xF0)
+ {
+ Event_post(myEvent, Event_Id_00);
+ flagerr=1;
+ }
+ System_printf("RST: %x %x %x\r\n",rxBufferPointer[0],rxBufferPointer[1],rxBufferPointer[2]);
System_flush();
+ }else{
+ Event_post(myEvent, Event_Id_00);
+ flagerr=1;
+ //Task_exit();
}
for(i=1000;i>0;i--);
spiTransaction.count = 7;
if (SPI_transfer(spi,&spiTransaction)) {
+
+ if (rxBufferPointer[2] != 0xF0)
+ {
+ Event_post(myEvent, Event_Id_00);
+ flagerr=1;
+ }
+
System_printf("IDC: ");
for(i=0;i<7;i++){
System_printf("%x ",rxBufferPointer[i]);
}
System_printf("\r\n");
System_flush();
+ }else{
+ Event_post(myEvent, Event_Id_00);
+ flagerr=1;
+ //Task_exit();
}
+ /* OK! */
+ if(flagerr==0){
+ Event_post(myEvent, Event_Id_01);
+ System_printf("***\r\n");
+ System_flush();
+ }else{
+ System_printf("KO!\r\n");
+ System_flush();
+ }
+
+ System_printf("Press button to continue:\r\n");
+ Semaphore_pend(semHandle, BIOS_WAIT_FOREVER);
while(1){
System_flush();
}
-
/* READ 1 BYTE from EEPROM
txBufferPointer[0]=EEPSBR;
txBufferPointer[1]=0xA0;
*/
Void heartBeatFxn(UArg arg0, UArg arg1)
{
- while (1) {
+
+ UInt events;
+
+ events=Event_pend(myEvent,Event_Id_NONE,Event_Id_00+Event_Id_01,BIOS_WAIT_FOREVER);
+
+ if(events & Event_Id_00){
+ while (1)
+ {
+ Task_sleep((UInt)arg0);
+ PIN_setOutputValue(ledPinHandle, Board_LED1,!PIN_getOutputValue(Board_LED1));
+ }
+ }
+
+ if(events & Event_Id_01){
+ while (1)
+ {
Task_sleep((UInt)arg0);
PIN_setOutputValue(ledPinHandle, Board_LED0,!PIN_getOutputValue(Board_LED0));
- }
+ }
+ }
}
/*
Board_initUART();
// Board_initWatchdog();
+
+ /* Default instance configuration params */
+ Error_init(&eb);
+ myEvent = Event_create(NULL,&eb);
+ if (myEvent == NULL) {
+ System_abort("Event create failed");
+ }
+
+
/* BMH Init UART for System_printf() */
UART_Params uartParams;
UART_Params_init(&uartParams);
System_printf("Uart open\r\n");
+ /* Construct SPI Echo Task thread */
+ Task_Params_init(&taskParams);
+ taskParams.arg0 = 1000000 / Clock_tickPeriod;
+ taskParams.stackSize = TASKSTACKSIZE;
+ taskParams.stack = &task1Stack;
+ Task_construct(&task1Struct, (Task_FuncPtr)spiFxn, &taskParams, NULL);
+
+
/* Construct heartBeat Task thread */
Task_Params_init(&taskParams);
taskParams.arg0 = 500000 / Clock_tickPeriod;
taskParams.stack = &task0Stack;
Task_construct(&task0Struct, (Task_FuncPtr)heartBeatFxn, &taskParams, NULL);
- /* Construct SPI Echo Task thread */
+
+ /* Construct Uart Task thread */
Task_Params_init(&taskParams);
- taskParams.arg0 = 1000000 / Clock_tickPeriod;
+ taskParams.arg0 = 100000 / Clock_tickPeriod;
taskParams.stackSize = TASKSTACKSIZE;
- taskParams.stack = &task1Stack;
- Task_construct(&task1Struct, (Task_FuncPtr)spiFxn, &taskParams, NULL);
+ taskParams.stack = &task2Stack;
+ Task_construct(&task2Struct, (Task_FuncPtr)uartFxn, &taskParams, NULL);
- /* Construct Semaphore */
+
+ /* Construct Semaphore Obtain instance handle */
Semaphore_Params_init(&semParams);
Semaphore_construct(&semStruct,0, &semParams);
-
- /* Obtain instance handle */
semHandle = Semaphore_handle(&semStruct);
+
/* Setup callback for button pins */
buttonPinHandle = PIN_open(&buttonPinState, buttonPinTable);
if(!buttonPinHandle) {
System_abort("Error initializing board LED pins\n");
}
- PIN_setOutputValue(ledPinHandle, Board_LED0, 0);
- PIN_setOutputValue(ledPinHandle, Board_LED1, 0);
+ PIN_setOutputValue(ledPinHandle, Board_LED0, 1);
+ PIN_setOutputValue(ledPinHandle, Board_LED1, 1);
/* Start BIOS */
BIOS_start();
diff --git a/Basic-Test-Package/CC2650/Test_CC2650_3wSPI_Master_MSP432_SlaveIRQ/main.c b/Basic-Test-Package/CC2650/Test_CC2650_3wSPI_Master_MSP432_SlaveIRQ/main.c
index f96d6413fe77a203d952a8ba38f27d98c51aeecb..e758490d52b6d819fbdfe5e8246ee35569a47e0e 100644 (file)
void buttonCallbackFxn(PIN_Handle handle, PIN_Id pinId) {
- /* Wait IRQ from MSP432 line*/
- PIN_setOutputValue(ledPinHandle, Board_LED1,1);
- CPUdelay(8000*100);
- Semaphore_post(semHandle);
- PIN_setOutputValue(ledPinHandle, Board_LED1,0);
+ Semaphore_post(semHandle);
+ PIN_setOutputValue(ledPinHandle, Board_LEDR,1);
}
-
Void echoFxn(UArg arg0, UArg arg1)
{
- uint8_t i=0;
+
uint8_t txBufferPointer[4];
uint8_t rxBufferPointer[4];
SPI_Handle spi;
Semaphore_pend(semHandle, BIOS_WAIT_FOREVER);
- //txBufferPointer[0]=i++;
- //rxBufferPointer[0]=0;
-
txBufferPointer[0]=rxBufferPointer[0];
if (SPI_transfer(spi,&spiTransaction)) {
- System_printf("RxData: %x TxData: %x\r\n",rxBufferPointer[0],txBufferPointer[0]);
+ //System_printf("RxData: %x TxData: %x\r\n",rxBufferPointer[0],txBufferPointer[0]);
+ PIN_setOutputValue(ledPinHandle, Board_LEDR,0);
}
}
* Toggle the Board_LED0. The Task_sleep is determined by arg0 which
* is configured for the heartBeat Task instance.
*/
+
Void heartBeatFxn(UArg arg0, UArg arg1)
{
+
while (1) {
- Task_sleep((UInt)arg0);
+
+ Task_sleep((UInt)arg0-5000/Clock_tickPeriod);
+ PIN_setOutputValue(ledPinHandle, Board_LEDG,1);
+ Task_sleep((UInt)5000/Clock_tickPeriod);
+ PIN_setOutputValue(ledPinHandle, Board_LEDG,0);
+
+ //Task_sleep((UInt)arg0);
//PIN_setOutputValue(ledPinHandle, Board_LED0,!PIN_getOutputValue(Board_LED0));
//PIN_setOutputValue(ledPinHandle, Board_LED1,!PIN_getOutputValue(Board_LED1));
}
/* Construct heartBeat Task thread */
Task_Params_init(&taskParams);
- taskParams.arg0 = 500000 / Clock_tickPeriod;
+ taskParams.arg0 = 2000000 / Clock_tickPeriod;
taskParams.stackSize = TASKSTACKSIZE;
taskParams.stack = &task0Stack;
Task_construct(&task0Struct, (Task_FuncPtr)heartBeatFxn, &taskParams, NULL);
diff --git a/Basic-Test-Package/CC2650/Test_CC2650_3wSPI_Slave_MSP432_Master/main.c b/Basic-Test-Package/CC2650/Test_CC2650_3wSPI_Slave_MSP432_Master/main.c
index 9a6dadfe7a956b864adea8fe2875b78e690895f0..a8f2bee0a3c6aa2fcf9feeb2240f8d957325925e 100644 (file)
if(!spi){
System_printf("SPI did not open");
}
- System_printf("SPI-Slave Open\r\n");
+ System_printf("SPI Slave Mode Open\r\n");
rxBufferPointer[0]='*';
+
while(1) {
spiTransaction.rxBuf= rxBufferPointer;
spiTransaction.txBuf = txBufferPointer;
spiTransaction.count=1;
- PIN_setOutputValue(ledPinHandle, Board_LEDG,!PIN_getOutputValue(Board_LEDG));
+ PIN_setOutputValue(ledPinHandle, Board_LEDR,0);
+
if (SPI_transfer(spi,&spiTransaction)) {
+ PIN_setOutputValue(ledPinHandle, Board_LEDR,1);
+
+ System_printf("RxData: %x\r\n",rxBufferPointer[0]);
+
txBufferPointer[0]=rxBufferPointer[0];
- System_printf("RxData: %x TxData: %x\r\n",rxBufferPointer[0],txBufferPointer[0]);
+ rxBufferPointer[0]=0x55;
}
Void heartBeatFxn(UArg arg0, UArg arg1)
{
while (1) {
- Task_sleep((UInt)arg0);
+
+ Task_sleep((UInt)arg0-5000/Clock_tickPeriod);
+ PIN_setOutputValue(ledPinHandle, Board_LEDG,1);
+ Task_sleep((UInt)5000/Clock_tickPeriod);
+ PIN_setOutputValue(ledPinHandle, Board_LEDG,0);
+
//PIN_setOutputValue(ledPinHandle, Board_LEDG,!PIN_getOutputValue(Board_LEDG));
//PIN_setOutputValue(ledPinHandle, Board_LEDR,!PIN_getOutputValue(Board_LEDR));
}
/* Construct heartBeat Task thread */
Task_Params_init(&taskParams);
- taskParams.arg0 = 200000 / Clock_tickPeriod;
+ taskParams.arg0 = 2000000 / Clock_tickPeriod;
taskParams.stackSize = TASKSTACKSIZE;
taskParams.stack = &task0Stack;
Task_construct(&task0Struct, (Task_FuncPtr)heartBeatFxn, &taskParams, NULL);
diff --git a/Basic-Test-Package/CC2650/Test_CC2650_DebugUART_EchoPC/main.c b/Basic-Test-Package/CC2650/Test_CC2650_DebugUART_EchoPC/main.c
index 4d2d3f5ba454285a7b151386f874343e018e8f34..7f9f337dd55443f7f54b0b3055aa75e9e20244c6 100644 (file)
while (1) {
/* Blocking Read */
UART_read(uart, &input, 1);
- UART_write(uart, &input, 1);
+ /* Echo */
+ UART_write(uart, &input, 1);
}
}
{
while (1) {
Task_sleep((UInt)arg0);
- PIN_setOutputValue(ledPinHandle, Board_LED0,!PIN_getOutputValue(Board_LED0));
- //PIN_setOutputValue(ledPinHandle, Board_LED1,!PIN_getOutputValue(Board_LED1));
+ //PIN_setOutputValue(ledPinHandle, Board_LEDR,!PIN_getOutputValue(Board_LED0));
+ PIN_setOutputValue(ledPinHandle, Board_LEDG,!PIN_getOutputValue(Board_LED1));
}
}
/* Construct heartBeat Task thread */
Task_Params_init(&taskParams);
- taskParams.arg0 = 2000000 / Clock_tickPeriod;
+ taskParams.arg0 = 1000000 / Clock_tickPeriod;
taskParams.stackSize = TASKSTACKSIZE;
taskParams.stack = &task0Stack;
Task_construct(&task0Struct, (Task_FuncPtr)heartBeatFxn, &taskParams, NULL);
diff --git a/Basic-Test-Package/CC2650/Test_CC2650_I2C_Sensors/main.c b/Basic-Test-Package/CC2650/Test_CC2650_I2C_Sensors/main.c
index afb520e338e072d42db8c7b24405f03ec98e8998..6908811d6c0bc76fc27697b536331131b0002a1e 100644 (file)
void buttonCallbackFxn(PIN_Handle handle, PIN_Id pinId) {
- PIN_setOutputValue(ledPinHandle, Board_LED0,0);
- PIN_setOutputValue(ledPinHandle, Board_LED1,0);
- CPUdelay(8000*200);
- PIN_setOutputValue(ledPinHandle, Board_LED0,1);
- PIN_setOutputValue(ledPinHandle, Board_LED1,1);
+ CPUdelay(8000*200);
//Event_post(myEvent,Event_Id_02);
Semaphore_post(semHandle);
if (i2c == NULL) {
System_abort("Error Initializing I2C\r\n");
}
-
System_printf("I2C Initialized\r\n");
- System_printf("Press button:\r\n");
- Semaphore_pend(semHandle, BIOS_WAIT_FOREVER);
+ /* Wait Semaphore */
+ System_printf("Press Button:\r\n");
+
+ PIN_setOutputValue(ledPinHandle, Board_LED0,1);
+ PIN_setOutputValue(ledPinHandle, Board_LED1,1);
+ Semaphore_pend(semHandle, BIOS_WAIT_FOREVER);
/* Start test */
PIN_setOutputValue(ledPinHandle, Board_LED0,0);
Event_post(myEvent, Event_Id_00);
flagerr=1;
}
- System_printf("OPT3001 ID 0x5449: %x\r\n",data);
+ System_printf("OPT3001 Device ID [0x5449]: %x\r\n",data);
}else{
System_printf("OPT3001 I2c Transaction Failed\r\n");
Event_post(myEvent, Event_Id_00);
flagerr=1;
}
//System_printf("HDC1080 Manufactured ID 0x5449: %x\n",data);
- System_printf("HDC1080 Device ID 0x1050: %x\r\n",data);
+ System_printf("HDC1080 Device ID [0x1050]: %x\r\n",data);
}
else{
System_printf("HDC1080 I2c Transaction Failed\r\n");
Event_post(myEvent, Event_Id_00);
flagerr=1;
}
- System_printf("TMP007 Device ID 0x0078: %x\r\n",data);
+ System_printf("TMP007 Device ID [0x0078]: %x\r\n",data);
}else{
System_printf("TMP007 I2c Transaction Failed\r\n");
Event_post(myEvent, Event_Id_00);
Event_post(myEvent, Event_Id_00);
flagerr=1;
}
- System_printf("BMP280 ID 0x58: %x\r\n",data);
+ System_printf("BMP280 Device ID [0x58]: %x\r\n",data);
}else{
System_printf("BMP280 I2c Transaction Failed\r\n");
Event_post(myEvent, Event_Id_00);
Event_post(myEvent, Event_Id_00);
flagerr=1;
}
- System_printf("MPU9250 WHOIAM 0x71: %x\r\n",data);
+ System_printf("MPU9250 WHOIAM [0x71]: %x\r\n",data);
}else{
System_printf("MPU9250 I2c Transaction Failed\r\n");
Event_post(myEvent, Event_Id_00);
Event_post(myEvent, Event_Id_00);
flagerr=1;
}
- System_printf("LISHH12 WHOIAM 0x41: %x\r\n",data);
+ System_printf("LISHH12 WHOIAM [0x41]: %x\r\n",data);
}else{
System_printf("LISHH12 I2c Transaction Failed\r\n");
Event_post(myEvent, Event_Id_00);