2018.5.28 PSOC第一枪:基于cypress的蓝牙开发
Cypress-BLE 开发套件可以快速开发 物联网电子产品。
PSOC编程特点:
A 拖放各PSoC 组件到工作区中,以设计原理图
B 完成各组件之间的布线,并配置GPIO
C 使用所包含的组件API 开发和调试固件
一:使用入门:
PSOC Creator :一款 IDE工具,可以直接进行硬件和固件设计,如下图,创建新工程后。我们可以配置电路图,选择需要用的Lib,和设置PSOC。
1. 将组件图标拖放到主要设计工作区中,以进行您的硬件系统设计。
2. 对您的应用固件和PSoC 硬件进行协同设计。
3. 使用配置工具配置各组件
4. 研究包含100 多个组件的库
5. 查看组件数据手册
二:硬件框图
A.>PSOC4 就是PSOC芯片了具体配置查datasheet
B> PSOC5LP是用来配合调试和串口通讯用的 ,还带了很多集成的模数模块,
其他的东西都可以在help文件里面找到。
三:开始项目
扯淡没用,开始项目。
A 原理框图
PSOC的作用就是把很多原来外围电路 配置到IC内部。而Cypress的优势就是把BLE模块集成化,配置蓝牙参数就像填数字,傻瓜操作。
B:Topdesign 顶层设计(就是模块设置咯)
如下图,配置好Pin脚,Uart串口,Ble模块,设置DAC (其他的模块省略)
C 配置引脚
如下图,把需要用到的引脚配置好就行。
D 配置时钟,中断,模拟电路,Flash等,方法同上。
E 写main函数,其他库函数都自动生成了,但功能逻辑函数还是要自己写的,这里编程就和STM32编程一样。
不过PSOC的优势是:所有底层配置都已经ok,只需要加功能性指令。Test功能函数如下,其他函数都是已经配置好了的。
#include "tester.h"
#include "tools.h"
#include "debug.h"
#include "cmd_list.h"
#include "hw.h"
#include "ble_srv_update.h"
#include "ble_srv_list.h"
#include "tasks.h"
tester_t tester; void tester_init(void){
memset((void*)&tester, , sizeof(tester_t));
tester.leds_timeout = ;
} u8 tester_started_get(void){
return tester.started;
} void tester_started_set(u8 started){
tester.started = started;
// If test is finished - disconnect and delete the mac
if(!started){
if(tester.ble_connected){
memset(tester.mac, , );
CyBle_GapDisconnect(cyBle_connHandle.bdHandle);
}
// Just in case - Reset the processor
CySoftwareReset(); tester.update_timeout = ;
tester.board = ;
}
tester.key = ;
tester.state = ;
tester.error_timeout = ;
PIN_11_ON;
} u8 tester_ble_connected_get(void){
return tester.started;
} void tester_ble_connected_set(u8 val){
tester.ble_connected = val;
if(!val) {
tester.ble_paired = val;
tester.update_timeout = ; // If the 0x0E board is disconnected - reset the tester
if((tester.board == 0x0E) && (tester.state == TESTER_STATE_PASSED)){
tester_started_set();
}
DBG_LOG(DEBUG_ACC, "\n\rTESTER: BLE Disconnected ");
} else {
DBG_LOG(DEBUG_ACC, "\n\rTESTER: BLE Connected ");
}
tester.update_timeout = TESTER_UPDATE_TIMEOUT;
} void tester_board_set(u8 val){
tester.board = val;
// We will write and read the characteristic
// on read event - busy will be cleared
ble_srv_update(BLE_SU_TEST_MODE);
tester.state = ;
} u8 tester_board_get(void){
return tester.board;
} void tester_ble_paired_set(u8 val){ if(val){
// Clear busy flag if the cause is waiting for pair
if((!tester.ble_paired) && \
(tester.status & TESTER_FIELD_BUSY)) {
tester.status &=~TESTER_FIELD_BUSY;
}
// Just in case, if disconnection happens, after reconnection
// it will go to the test mode
if(val && tester.board) {
ble_srv_update(BLE_SU_TEST_MODE);
}
DBG_LOG(DEBUG_ACC, "\n\rTESTER: BLE Paired ");
}
tester.ble_paired = val;
tester.error_timeout = ;
} u8 *tester_mac_get(void){
return tester.mac;
} void tester_mac_set(u8 *mac){
if(mac == NULL) return;
// If test is not started - do not connect
if(!tester.started) return;
memcpy(tester.mac, mac, );
} void tester_mac_parse(u8 *data){
u8 sum, sum_rx, i;
if(tester.ble_connected) return;
if(data == NULL) return;
if(data[] != '<') return;
if(data[]!= '>') return; memset((void*)&tester.mac_tmp[], , sizeof(tester.mac_tmp)); for(i=, sum=; i<; i++){
tester.mac_tmp[-i] = (ASCII_HEX_TO_DEC(data[+i*]) << );
tester.mac_tmp[-i]|= ASCII_HEX_TO_DEC(data[+i*]);
sum += tester.mac_tmp[-i];
} sum_rx = (ASCII_HEX_TO_DEC(data[]) << );
sum_rx|= ASCII_HEX_TO_DEC(data[]); if(sum != sum_rx) return; tester_mac_set(tester.mac_tmp);
} void tester_triac_write(u8 idx, u8 state){
if(state > ) return;
if((idx > ) || (!idx)) return; tester.idx_triac = idx;
if(idx == ) tester.outputs.triac_1 = state;
else if(idx == ) tester.outputs.triac_2 = state;
else if(idx == ) tester.outputs.triac_3 = state;
ble_srv_update(BLE_SU_TRIAC);
} void tester_relay_write(u8 idx, u8 state){
if(state > ) return;
if((idx > ) || (!idx)) return; tester.idx_relay = idx;
if(idx == ) tester.outputs.relay_1 = state;
else if(idx == ) tester.outputs.relay_2 = state;
else if(idx == ) tester.outputs.relay_3 = state;
ble_srv_update(BLE_SU_RELAY);
} u8 tester_triac_idx_get(void){
return tester.idx_triac;
} u8 tester_relay_idx_get(void){
return tester.idx_relay;
} u8 tester_triac_state_get(u8 idx){
if(idx == ) return tester.outputs.triac_1;
else if(idx == ) return tester.outputs.triac_2;
else if(idx == ) return tester.outputs.triac_3;
return ;
} u8 tester_relay_state_get(u8 idx){
if(idx == ) return tester.outputs.relay_1;
else if(idx == ) return tester.outputs.relay_2;
else if(idx == ) return tester.outputs.relay_3;
return ;
} void tester_error_set(u8 val){
tester.error = val;
} void tester_key_set(u8 val){
if(tester.key != val) tester.timeout = ; // Speed up on change
tester.key = val;
} void tester_ntc_set(u8 val){
tester.ntc = val;
} void tester_auto_timeout_set(u8 val){
tester.auto_timeout = val;
tester.state |= 0x80;
tester.error_timeout = ;
} void tester_buzzer_timeout_update(void){
if(tester.buzzer_timeout < 0xFFFF) tester.buzzer_timeout++;
} // Tester state machine
void tester_10ms_run(void){
// Wrong states - back to initial state
if(!tester.started){
// If connected but it not supposed to be connected
if(tester.ble_paired){
memset(tester.mac, , );
CyBle_GapDisconnect(cyBle_connHandle.bdHandle);
DBG_LOG(DEBUG_ACC, "\n\rTESTER: BLE paired - disconnecting ");
} else if(tester.ble_connected){
memset(tester.mac, , );
CyBle_GapDisconnect(cyBle_connHandle.bdHandle);
DBG_LOG(DEBUG_ACC, "\n\rTESTER: BLE connected - disconnecting ");
} // Standalone application
// Wait till the button will be released
if(SW2_STATE){
tester.sw_debaunce = ;
while(SW2_STATE){
CyDelay();
if(tester.sw_debaunce < 0xFF) tester.sw_debaunce++;
}
// If the button was pressed more than 60 ms
if(tester.sw_debaunce > ){
// Start EP4114 test
DBG_LOG(DEBUG_ACC, "\n\rTESTER: EP4114 Test starting... ");
tester_started_set();
tester_board_set(0x0E);
}
} // Test is started
} else { // Check if the error happened
if((tester.error_timeout > TESTER_FAIL_TIMEOUT) && (tester.state != TESTER_STATE_FAILED)){
if(tester.ble_paired || (!tester.ble_paired && (tester.error_timeout > TESTER_PAIR_FAIL_TIMEOUT))) {
tester.status |= TESTER_FIELD_ERROR;
tester.status &=~TESTER_FIELD_BUSY;
tester.state = TESTER_STATE_FAILED;
DBG_LOG(DEBUG_ACC, "\n\rTESTER: FAILED ");
tester.error_timeout = ;
}
} // If not paired - tell PC that it is busy
if(!tester.ble_paired) {
tester.status |= TESTER_FIELD_BUSY;
tester.error_timeout++;
} else {
// Busy - all except errors
if(ble_srv_update_busy_get()) {
if(ble_srv_update_ids_get() &~BLE_SU_ERROR) tester.status |= TESTER_FIELD_BUSY;
}
else if(tester.board != 0x0E) tester.status &=~TESTER_FIELD_BUSY; if(tester.error || ((tester.board == 0x0E) && (tester.state == TESTER_STATE_FAILED)))
tester.status |= TESTER_FIELD_ERROR;
else tester.status &=~TESTER_FIELD_ERROR; if(tester.key) tester.status |= TESTER_FIELD_SWITCH;
else tester.status &=~TESTER_FIELD_SWITCH; // Zero cross generator for EP4114
if(tester.board == 0x0E){
if(PIN_9_STATE) PIN_9_OFF;
else PIN_9_ON;
} // EP4114 is automated test
if((tester.board == 0x0E) && (!ble_srv_update_busy_get())){ switch(tester.state){ /* *****************************
* Hi / Lo Level test
********************************/ // ********** PIN 2 test **********
// Turn On
case TESTER_STATE_PIN2_ON_TURN:
tester.status |= TESTER_FIELD_BUSY;
tester.outputs.relay_3 = ;
tester.idx_relay = ;
ble_srv_update(BLE_SU_RELAY);
tester_auto_timeout_set(TESTER_AUTO_TIMEOUT);
break;
// On
case TESTER_STATE_PIN2_ON_TEST:
if(PIN_2_STATE){
tester.state++;
DBG_LOG(DEBUG_ACC, "\n\rTESTER: PIN2: ON OK ");
} else {
// Failed
if(tester.error_timeout == TESTER_FAIL_TIMEOUT)
DBG_LOG(DEBUG_ACC, "\n\rTESTER: PIN2: Failed ");
tester.error_timeout++;
}
break;
// Turn OFF
case TESTER_STATE_PIN2_OFF_TURN:
tester.outputs.relay_3 = ;
tester.idx_relay = ;
ble_srv_update(BLE_SU_RELAY);
tester_auto_timeout_set(TESTER_AUTO_TIMEOUT);
break;
// Off
case TESTER_STATE_PIN2_OFF_TEST:
if(!PIN_2_STATE){
tester.state++;
DBG_LOG(DEBUG_ACC, "\n\rTESTER: PIN2: OFF OK ");
} else {
// Failed
if(tester.error_timeout == TESTER_FAIL_TIMEOUT)
DBG_LOG(DEBUG_ACC, "\n\rTESTER: PIN2: Failed ");
tester.error_timeout++;
}
break; // ********** PIN 3 test **********
// Turn On
case TESTER_STATE_PIN3_ON_TURN:
tester.outputs.triac_1 = ;
tester.idx_triac = ;
ble_srv_update(BLE_SU_TRIAC);
tester_auto_timeout_set(TESTER_AUTO_TIMEOUT);
break;
// On
case TESTER_STATE_PIN3_ON_TEST:
if(PIN_3_STATE){
tester.state++;
DBG_LOG(DEBUG_ACC, "\n\rTESTER: PIN3: ON OK ");
} else {
// Failed
if(tester.error_timeout == TESTER_FAIL_TIMEOUT)
DBG_LOG(DEBUG_ACC, "\n\rTESTER: PIN3: Failed ");
tester.error_timeout++;
}
break;
// Turn Off
case TESTER_STATE_PIN3_OFF_TURN:
tester.outputs.triac_1 = ;
tester.idx_triac = ;
ble_srv_update(BLE_SU_TRIAC);
tester_auto_timeout_set(TESTER_AUTO_TIMEOUT);
break;
// Off
case TESTER_STATE_PIN3_OFF_TEST:
if(!PIN_3_STATE){
tester.state++;
DBG_LOG(DEBUG_ACC, "\n\rTESTER: PIN3: OFF OK ");
} else {
// Failed
if(tester.error_timeout == TESTER_FAIL_TIMEOUT)
DBG_LOG(DEBUG_ACC, "\n\rTESTER: PIN3: Failed ");
tester.error_timeout++;
}
break; // ********** PIN 4 test **********
// Turn On
case TESTER_STATE_PIN4_ON_TURN:
tester.outputs.triac_2 = ;
tester.idx_triac = ;
ble_srv_update(BLE_SU_TRIAC);
tester_auto_timeout_set(TESTER_AUTO_TIMEOUT);
break;
// On
case TESTER_STATE_PIN4_ON_TEST:
if(PIN_4_STATE){
tester.state++;
DBG_LOG(DEBUG_ACC, "\n\rTESTER: PIN4: ON OK ");
} else {
// Failed
if(tester.error_timeout == TESTER_FAIL_TIMEOUT)
DBG_LOG(DEBUG_ACC, "\n\rTESTER: PIN4: Failed ");
tester.error_timeout++;
}
break;
// Turn Off
case TESTER_STATE_PIN4_OFF_TURN:
tester.outputs.triac_2 = ;
tester.idx_triac = ;
ble_srv_update(BLE_SU_TRIAC);
tester_auto_timeout_set(TESTER_AUTO_TIMEOUT);
break;
// Off
case TESTER_STATE_PIN4_OFF_TEST:
if(!PIN_4_STATE){
tester.state++;
DBG_LOG(DEBUG_ACC, "\n\rTESTER: PIN4: OFF OK ");
} else {
// Failed
if(tester.error_timeout == TESTER_FAIL_TIMEOUT)
DBG_LOG(DEBUG_ACC, "\n\rTESTER: PIN4: Failed ");
tester.error_timeout++;
}
break; // ********** PIN 7 test **********
// Turn On
case TESTER_STATE_PIN7_ON_TURN:
tester.outputs.relay_1 = ;
tester.idx_relay = ;
ble_srv_update(BLE_SU_RELAY);
tester_auto_timeout_set(TESTER_AUTO_TIMEOUT);
break;
// On
case TESTER_STATE_PIN7_ON_TEST:
if(PIN_7_STATE){
tester.state++;
DBG_LOG(DEBUG_ACC, "\n\rTESTER: PIN7: ON OK ");
} else {
// Failed
if(tester.error_timeout == TESTER_FAIL_TIMEOUT)
DBG_LOG(DEBUG_ACC, "\n\rTESTER: PIN7: Failed ");
tester.error_timeout++;
}
break;
// Turn Off
case TESTER_STATE_PIN7_OFF_TURN:
tester.outputs.relay_1 = ;
tester.idx_relay = ;
ble_srv_update(BLE_SU_RELAY);
tester_auto_timeout_set(TESTER_AUTO_TIMEOUT);
break;
// Off
case TESTER_STATE_PIN7_OFF_TEST:
if(!PIN_7_STATE){
tester.state++;
DBG_LOG(DEBUG_ACC, "\n\rTESTER: PIN7: OFF OK ");
} else {
// Failed
if(tester.error_timeout == TESTER_FAIL_TIMEOUT)
DBG_LOG(DEBUG_ACC, "\n\rTESTER: PIN7: Failed ");
tester.error_timeout++;
}
break;
// ********** PIN 8 test **********
// Turn On
case TESTER_STATE_PIN8_ON_TURN:
tester.outputs.relay_2 = ;
tester.idx_relay = ;
ble_srv_update(BLE_SU_RELAY);
tester_auto_timeout_set(TESTER_AUTO_TIMEOUT);
break;
// On
case TESTER_STATE_PIN8_ON_TEST:
if(PIN_8_STATE){
tester.state++;
DBG_LOG(DEBUG_ACC, "\n\rTESTER: PIN8: ON OK ");
} else {
// Failed
if(tester.error_timeout == TESTER_FAIL_TIMEOUT)
DBG_LOG(DEBUG_ACC, "\n\rTESTER: PIN8: Failed ");
tester.error_timeout++;
}
break;
// Turn Off
case TESTER_STATE_PIN8_OFF_TURN:
tester.outputs.relay_2 = ;
tester.idx_relay = ;
ble_srv_update(BLE_SU_RELAY);
tester_auto_timeout_set(TESTER_AUTO_TIMEOUT);
break;
// Off
case TESTER_STATE_PIN8_OFF_TEST:
if(!PIN_8_STATE){
tester.state++;
DBG_LOG(DEBUG_ACC, "\n\rTESTER: PIN8: OFF OK ");
} else {
// Failed
if(tester.error_timeout == TESTER_FAIL_TIMEOUT)
DBG_LOG(DEBUG_ACC, "\n\rTESTER: PIN8: Failed ");
tester.error_timeout++;
}
break; /* *****************************
* Advance
********************************/ // PIN 5 - ADC
case TESTER_STATE_PIN5_TEST:
if( ((((info_error_t)tester.error != INFO_ERROR_NTC_ROOM)&& \
((info_error_t)tester.error != INFO_ERR_NTC_ROOM)) ) && \
((tester.ntc > TESTER_NTC_LIM_MIN) && (tester.ntc < TESTER_NTC_LIM_MAX)) ) {
tester.state++;
DBG_LOG(DEBUG_ACC, "\n\rTESTER: PIN5: OK %u %u ", tester.error, tester.ntc);
tester.error_timeout = ;
} else {
if(tester.error_timeout == TESTER_FAIL_TIMEOUT)
DBG_LOG(DEBUG_ACC, "\n\rTESTER: PIN5: Failed %u %u ", tester.error, tester.ntc);
tester.error_timeout++;
}
break; // PIN 9 - Zero cross
case TESTER_STATE_PIN9_TEST:
if((info_error_t)tester.error != INFO_ERR_ZERO_CROSS){
tester.state++;
DBG_LOG(DEBUG_ACC, "\n\rTESTER: PIN9: OK %u ", tester.error);
tester.error_timeout = ;
} else {
if(tester.error_timeout == TESTER_FAIL_TIMEOUT)
DBG_LOG(DEBUG_ACC, "\n\rTESTER: PIN9: Failed %u ", tester.error);
tester.error_timeout++;
}
tester.buzzer_timeout = ;
break; // PIN 10 - Buzzer
// Low
case TESTER_STATE_PIN10_OFF_TEST:
if(tester.buzzer_timeout < ){
while(PIN_10_STATE){
tasks_run_critical();
if(tester.buzzer_timeout > ) break;
}
if(tester.buzzer_timeout < ){
DBG_LOG(DEBUG_ACC, "\n\rTESTER: PIN10: OFF OK ");
tester.state++;
tester.buzzer_timeout = ;
tester.error_timeout = ;
}
} else {
if(tester.error_timeout == TESTER_FAIL_TIMEOUT)
DBG_LOG(DEBUG_ACC, "\n\rTESTER: PIN10: Failed ");
tester.error_timeout++;
}
break;
// High
case TESTER_STATE_PIN10_ON_TEST:
if(tester.buzzer_timeout < ){
while(!PIN_10_STATE){
tasks_run_critical();
if(tester.buzzer_timeout > ) break;
}
if(tester.buzzer_timeout < ){
DBG_LOG(DEBUG_ACC, "\n\rTESTER: PIN10: ON OK ");
tester.state++;
tester.buzzer_timeout = ;
tester.error_timeout = ;
}
} else {
if(tester.error_timeout == TESTER_FAIL_TIMEOUT)
DBG_LOG(DEBUG_ACC, "\n\rTESTER: PIN10: Failed ");
tester.error_timeout++;
}
break; // PIN 11 - Switch
// Turn Off
case TESTER_STATE_PIN11_OFF_TURN:
PIN_11_ON;
tester_auto_timeout_set(TESTER_AUTO_SW_TIMEOUT);
break; // Read the state
case TESTER_STATE_PIN11_OFF_READ:
ble_srv_update(BLE_SU_ERROR);
tester_auto_timeout_set(TESTER_AUTO_TIMEOUT);
break;
// Off
case TESTER_STATE_PIN11_OFF_TEST:
if(tester.key == ){
tester.state++;
DBG_LOG(DEBUG_ACC, "\n\rTESTER: PIN11: OFF OK ");
tester.error_timeout = ;
} else {
if(tester.error_timeout == TESTER_FAIL_TIMEOUT)
DBG_LOG(DEBUG_ACC, "\n\rTESTER: PIN11: Failed ");
tester.error_timeout++;
}
break; // Turn On
case TESTER_STATE_PIN11_ON_TURN:
PIN_11_OFF;
tester_auto_timeout_set(TESTER_AUTO_SW_TIMEOUT);
break; // Read
case TESTER_STATE_PIN11_ON_READ:
ble_srv_update(BLE_SU_ERROR);
tester_auto_timeout_set(TESTER_AUTO_TIMEOUT);
break; // On
case TESTER_STATE_PIN11_ON_TEST:
if(tester.key){
tester.state++;
DBG_LOG(DEBUG_ACC, "\n\rTESTER: PIN11: ON OK ");
tester.error_timeout = ;
PIN_11_ON;
} else {
if(tester.error_timeout == TESTER_FAIL_TIMEOUT)
DBG_LOG(DEBUG_ACC, "\n\rTESTER: PIN11: Failed ");
tester.error_timeout++;
}
break; case TESTER_STATE_CLEAR_BUSY:
tester.status &=~TESTER_FIELD_BUSY;
DBG_LOG(DEBUG_ACC, "\n\rTESTER: PASSED ");
tester.state++;
tester.error_timeout = ;
break; case TESTER_STATE_PASSED:
case TESTER_STATE_FAILED:
// Stay here
break; case (TESTER_STATE_PIN2_ON_TURN|0x80):
case (TESTER_STATE_PIN2_OFF_TURN|0x80):
case (TESTER_STATE_PIN3_ON_TURN|0x80):
case (TESTER_STATE_PIN3_OFF_TURN|0x80):
case (TESTER_STATE_PIN4_ON_TURN|0x80):
case (TESTER_STATE_PIN4_OFF_TURN|0x80):
case (TESTER_STATE_PIN7_ON_TURN|0x80):
case (TESTER_STATE_PIN7_OFF_TURN|0x80):
case (TESTER_STATE_PIN8_ON_TURN|0x80):
case (TESTER_STATE_PIN8_OFF_TURN|0x80):
case (TESTER_STATE_PIN11_OFF_TURN|0x80):
case (TESTER_STATE_PIN11_OFF_READ|0x80):
case (TESTER_STATE_PIN11_ON_TURN|0x80):
case (TESTER_STATE_PIN11_ON_READ|0x80):
if(tester.auto_timeout){
if(!(--tester.auto_timeout)){
tester.state = (tester.state & 0x7F) + ;
}
}
break; default:
tester.state = ;
break;
}
} } } // Tester board to PC UART wirte handling
if(tester.timeout) {
if(!(--tester.timeout)){
// Send that the error or busy no longer exists
if(!(tester.status & (TESTER_FIELD_ERROR | TESTER_FIELD_BUSY))) cmd_status(tester.status, tester.mac);
}
} else {
// If error - send it up to the PC
if(tester.status & (TESTER_FIELD_ERROR | TESTER_FIELD_BUSY)) {
cmd_status(tester.status, tester.mac);
tester.timeout = TESTER_UART_TIMEOUT;
}
} // Error update from the BLE
if(tester.update_timeout) {
if(!(--tester.update_timeout)){
if(tester.ble_paired) ble_srv_list_read_add(BLE_SRV_LIST_TEST);
tester.update_timeout = TESTER_UPDATE_TIMEOUT;
// If no comunication is on going send the status packet
if(!tester.timeout){
//cmd_status(tester.status, tester.mac); // ?
}
}
} // Board LEDs handling
if(tester.started){
// Blue
if(tester.ble_paired){
if(tester.board == 0x0E){
switch(tester.state){
case TESTER_STATE_PASSED:
case TESTER_STATE_CLEAR_BUSY:
LED_RED_OFF;
LED_GREEN_ON;
LED_BLUE_OFF;
break;
case TESTER_STATE_PIN2_ON_TEST:
case TESTER_STATE_PIN2_OFF_TEST:
case TESTER_STATE_PIN3_ON_TEST:
case TESTER_STATE_PIN3_OFF_TEST:
case TESTER_STATE_PIN4_ON_TEST:
case TESTER_STATE_PIN4_OFF_TEST:
case TESTER_STATE_PIN7_ON_TEST:
case TESTER_STATE_PIN7_OFF_TEST:
case TESTER_STATE_PIN8_ON_TEST:
case TESTER_STATE_PIN8_OFF_TEST:
case TESTER_STATE_PIN5_TEST:
case TESTER_STATE_PIN9_TEST:
case TESTER_STATE_PIN11_OFF_TEST:
case TESTER_STATE_PIN11_ON_TEST:
case TESTER_STATE_PIN10_OFF_TEST:
case TESTER_STATE_PIN10_ON_TEST:
LED_RED_ON;
LED_GREEN_OFF;
LED_BLUE_ON;
break;
case (TESTER_STATE_PIN2_ON_TURN):
case (TESTER_STATE_PIN2_OFF_TURN):
case (TESTER_STATE_PIN3_ON_TURN):
case (TESTER_STATE_PIN3_OFF_TURN):
case (TESTER_STATE_PIN4_ON_TURN):
case (TESTER_STATE_PIN4_OFF_TURN):
case (TESTER_STATE_PIN7_ON_TURN):
case (TESTER_STATE_PIN7_OFF_TURN):
case (TESTER_STATE_PIN8_ON_TURN):
case (TESTER_STATE_PIN8_OFF_TURN):
case (TESTER_STATE_PIN11_OFF_TURN):
case (TESTER_STATE_PIN11_OFF_READ):
case (TESTER_STATE_PIN11_ON_TURN):
case (TESTER_STATE_PIN11_ON_READ):
case (TESTER_STATE_PIN2_ON_TURN|0x80):
case (TESTER_STATE_PIN2_OFF_TURN|0x80):
case (TESTER_STATE_PIN3_ON_TURN|0x80):
case (TESTER_STATE_PIN3_OFF_TURN|0x80):
case (TESTER_STATE_PIN4_ON_TURN|0x80):
case (TESTER_STATE_PIN4_OFF_TURN|0x80):
case (TESTER_STATE_PIN7_ON_TURN|0x80):
case (TESTER_STATE_PIN7_OFF_TURN|0x80):
case (TESTER_STATE_PIN8_ON_TURN|0x80):
case (TESTER_STATE_PIN8_OFF_TURN|0x80):
case (TESTER_STATE_PIN11_OFF_TURN|0x80):
case (TESTER_STATE_PIN11_OFF_READ|0x80):
case (TESTER_STATE_PIN11_ON_TURN|0x80):
case (TESTER_STATE_PIN11_ON_READ|0x80):
LED_RED_OFF;
LED_GREEN_OFF;
LED_BLUE_ON;
break;
case TESTER_STATE_FAILED:
default:
LED_RED_ON;
LED_GREEN_OFF;
LED_BLUE_OFF;
break;
}
} else {
LED_RED_OFF;
LED_GREEN_OFF;
LED_BLUE_ON;
}
// Blue Flashing slow
} else if(tester.ble_connected){
if(tester.leds_timeout){
if(!(--tester.leds_timeout)){
tester.leds_timeout = TESTER_LEDS_SLOW_TIMEOUT; if(LED_BLUE_STATE){
LED_RED_OFF;
LED_GREEN_OFF;
LED_BLUE_OFF;
} else {
LED_RED_OFF;
LED_GREEN_OFF;
LED_BLUE_ON;
}
}
}
// Blue Flashing fast
} else {
if(tester.state == TESTER_STATE_FAILED){
LED_RED_ON;
LED_GREEN_OFF;
LED_BLUE_OFF;
} else {
if(tester.leds_timeout){
if(!(--tester.leds_timeout)){
tester.leds_timeout = TESTER_LEDS_FAST_TIMEOUT; if(LED_BLUE_STATE){
LED_RED_OFF;
LED_GREEN_OFF;
LED_BLUE_OFF;
} else {
LED_RED_OFF;
LED_GREEN_OFF;
LED_BLUE_ON;
}
}
}
}
}
// Red
} else {
if(tester.leds_timeout){
if(!(--tester.leds_timeout)){
tester.leds_timeout = TESTER_LEDS_TIMEOUT; if(LED_RED_STATE){
LED_RED_OFF;
LED_GREEN_OFF;
LED_BLUE_OFF;
} else {
LED_RED_ON;
LED_GREEN_OFF;
LED_BLUE_OFF;
}
}
}
}
}
四:调试
这里只测试了BLE输出电平逻辑,LCD ,KEY, Cap sense 等在另一板子上。
4总结
2018.5.28 PSOC第一枪:基于cypress的蓝牙开发的更多相关文章
- Insider Dev Tour(2018.06.28)
时间:2018.06.28地点:北京金茂万丽酒店
- 基于TINY4412的Andorid开发-------简单的LED灯控制【转】
本文转载自:http://www.cnblogs.com/pengdonglin137/p/3857724.html 基于TINY4412的Andorid开发-------简单的LED灯控制 阅读 ...
- 基于OpenDDS应用程序开发(3)订阅端实现
连续的三篇博文演示如何基于OpenDDS开发应用程序,将数据从发布端节点发送到订阅端节点,该示例程序由一个发布者发布数据,一个订阅者订阅数据,使用默认的QoS策略和TCP/IP传输方式. 本文是第三篇 ...
- 基于 SailingEase WinForm Framework 开发优秀的客户端应用程序(目录)
本系统文章将详细阐述客户端应用程序的设计理念,实现方法. 本系列文章以 SailingEase WinForm Framework 为基础进行设计并实现,但其中的设计理念及方法,亦适用于任何类型的客 ...
- [转]基于Starling移动项目开发准备工作
最近自己趁业余时间做的flash小游戏已经开发得差不多了,准备再完善下ui及数值后,投放到国外flash游戏站.期间也萌生想法,想把游戏拓展到手机平台.这两天尝试了下,除去要接入ane接口的工作,小游 ...
- 最新基于adt-bundle-windows-x86的android开发环境筹建
最新基于adt-bundle-windows-x86的android开发环境搭建 某系统要配套做一个android客户端,来一次android开发环境快速搭建,系统Win7,具体步骤如下: 1.下载j ...
- 基于Typecho CMS框架开发大中型应用
基于Typecho CMS框架开发大中型应用 大中型应用暂且定义为:大于等于3个数据表的应用!汗吧! Typecho原本是一款博客系统,其框架体系有别于市面上一般意义MVC框架,主体代码以自创的Wid ...
- Android基于XMPP Smack openfire 开发的聊天室
Android基于XMPP Smack openfire 开发的聊天室(一)[会议服务.聊天室列表.加入] http://blog.csdn.net/lnb333666/article/details ...
- 基于Android 4.4 开发的多窗体系统 开放源代码
Hi, 这是我基于Android 4.4开发的多窗体系统,还有非常多不足,还请多多不吝赐教啊,代码已经所有开源. 视频地址 源代码地址 Done: 1. APP以窗体化显示 在 PhoneWindow ...
随机推荐
- java 性能检测工具 检测死锁等
死锁检测方法 1 JConsole 找到需要查看的进程,打开线程选项卡,点击检测死锁 2 jps查看java进程ID,使用jstack 7412输出信息 3 使用jvisualvm连接java虚拟机 ...
- Oracle Data Provider for .NET的使用(托管与非托管(一))
目录 简单的概述 简单的使用 非托管系统要求 托管驱动系统要求 其它的注意事项 ODP.NET版本说明 安装ODP.NET 安装非托管驱动 非托管驱动绿色配置 简单的概述 ODP.NET的含义是 Or ...
- vue实践---vue不依赖外部资源实现简单多语
vue使用多语,最常见的就是 vue-i18n, 但是如果开发中的多语很少,比如就不到10个多语,这样就没必要引入vue-i18n了, 引入了反正导致代码体积大了,这时候单纯用vue实现多语就是比较好 ...
- c语言三元组
// Triplet.cpp : 定义控制台应用程序的入口点.//#include "stdio.h"#include "stdlib.h"#define OK ...
- tomcat下发布项目,遇到的问题总结
以前一直是在eclipse下启动tomcat,然后访问web项目.今天脑门一热,就想用tomcat的bin目录下的startup.bat来启动tomcat,虽然tomcat的启动很顺利,但是访问网页的 ...
- 数据预处理及sklearn方法实现
1.标准化(中心化) 在许多机器学习执行前,需要对数据集进行标准化处理.因为很对算法假设数据的特征服从标准正态分布.所以如果不对数据标准化,那么算法的效果会很差. 例如,在学习算法的目标函数,都假设数 ...
- poj1408(求线段交点)
求出所有线段的交点,然后利用叉乘求四边形面积即可. // // main.cpp // poj1408 // // Created by 陈加寿 on 15/12/31. // Copyright ( ...
- 详解Maven项目利用java service wrapper将Java程序生成Windows服务
在项目的开发中,有时候需要将Java应用程序打包成Windows服务,我们就直接可以通过windows的服务来启动和关闭java程序了. 本博文将通过有两种方法实现该功能,手动创建法和Maven自动打 ...
- [Oracle]根据字段值全库搜索相关数据表和字段
这个需求比较冷门,但对于在某些特定的情况下,还是会有这样的需要的.好在Oracle实现还比较方便,用存储过程则轻松实现. 查询字符串: create or replace procedure sear ...
- jmeter--基于http+json接口的功能测试
jmeter--基于http+json接口的功能测试 测试项目叫做smile_task,简称sm_task.这是一个基于nodejs超简单的todo list,sm_task没有任何UI界面(纯接口) ...