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总结 

一般MCU的开发流程..而psoc的开发环境里面有很多用户模块,比如I2C SPI... 这些用户模块一般MCU编写的时候,需要自己写时序,写底层代码,而PSOC已经写好了这些函数,只需调用相应的API函数 就可以,省了写这些code的时间.. 这个是最明显的区别,psoc不用操作底层寄存器,除非你需要改变某个设置;你还可以配置芯片内部模块 。
 
缺点:psoc芯片价格昂贵。这一颗Cypress芯片需要 10美金,加上外围产品,成本会比ARm芯片贵很多。 这也是中国很少用PSOC的原因吧。

2018.5.28 PSOC第一枪:基于cypress的蓝牙开发的更多相关文章

  1. Insider Dev Tour(2018.06.28)

    时间:2018.06.28地点:北京金茂万丽酒店

  2. 基于TINY4412的Andorid开发-------简单的LED灯控制【转】

    本文转载自:http://www.cnblogs.com/pengdonglin137/p/3857724.html 基于TINY4412的Andorid开发-------简单的LED灯控制   阅读 ...

  3. 基于OpenDDS应用程序开发(3)订阅端实现

    连续的三篇博文演示如何基于OpenDDS开发应用程序,将数据从发布端节点发送到订阅端节点,该示例程序由一个发布者发布数据,一个订阅者订阅数据,使用默认的QoS策略和TCP/IP传输方式. 本文是第三篇 ...

  4. 基于 SailingEase WinForm Framework 开发优秀的客户端应用程序(目录)

    本系统文章将详细阐述客户端应用程序的设计理念,实现方法. 本系列文章以  SailingEase WinForm Framework 为基础进行设计并实现,但其中的设计理念及方法,亦适用于任何类型的客 ...

  5. [转]基于Starling移动项目开发准备工作

    最近自己趁业余时间做的flash小游戏已经开发得差不多了,准备再完善下ui及数值后,投放到国外flash游戏站.期间也萌生想法,想把游戏拓展到手机平台.这两天尝试了下,除去要接入ane接口的工作,小游 ...

  6. 最新基于adt-bundle-windows-x86的android开发环境筹建

    最新基于adt-bundle-windows-x86的android开发环境搭建 某系统要配套做一个android客户端,来一次android开发环境快速搭建,系统Win7,具体步骤如下: 1.下载j ...

  7. 基于Typecho CMS框架开发大中型应用

    基于Typecho CMS框架开发大中型应用 大中型应用暂且定义为:大于等于3个数据表的应用!汗吧! Typecho原本是一款博客系统,其框架体系有别于市面上一般意义MVC框架,主体代码以自创的Wid ...

  8. Android基于XMPP Smack openfire 开发的聊天室

    Android基于XMPP Smack openfire 开发的聊天室(一)[会议服务.聊天室列表.加入] http://blog.csdn.net/lnb333666/article/details ...

  9. 基于Android 4.4 开发的多窗体系统 开放源代码

    Hi, 这是我基于Android 4.4开发的多窗体系统,还有非常多不足,还请多多不吝赐教啊,代码已经所有开源. 视频地址 源代码地址 Done: 1. APP以窗体化显示 在 PhoneWindow ...

随机推荐

  1. Boost学习总结(一)VS2010环境下编译STLport和Boost

    Boost学习总结(一)VS2010环境下编译STLport和Boost Boost简介 Boost库是一个功能强大.构造精巧.跨平台.开源并且完全免费的C++程序库.1998年,Beman G.Da ...

  2. 向MapReduce转换:通过部分成绩计算矩阵乘法

    代码共分为四部分: <strong><span style="font-size:18px;">/*** * @author YangXin * @info ...

  3. hihoCoder #1312 : 搜索三·启发式搜索(A*, 康托展开)

    原题网址:http://hihocoder.com/problemset/problem/1312 时间限制:10000ms 单点时限:1000ms 内存限制:256MB   描述 在小Ho的手机上有 ...

  4. 核函数 深度学习 统计学习 强化学习 神经网络 xx

  5. Mac标识物理位置算法 import Levenshtein mac列表特征值

    mac 字符串 与 基准字符串的 Levenshtein   距离,考虑  mac信号强度的时序性,60秒内若干次变化 不引入强度 mac字符串的唯一性 如何排序 基准字符串的选取 同一尺度 都按强度 ...

  6. thinkphp将APP_DEBUG常量设置为false后报错的问题

    ThinkPHP 将 APP_DEBUG 常量设置为 false 后出现了下面的问题: Parse error: syntax error, unexpected T_STRING in \www\R ...

  7. 摇一摇js代码

    init(); var SHAKE_THRESHOLD = 3000; var last_update = 0; var x = y = z = last_x = last_y = last_z = ...

  8. Qt状态机框架(状态机就开始异步的运行了,也就是说,它成为了我们应用程序事件循环的一部分了)

    状态机框架 Qt中的状态机框架为我们提供了很多的API和类,使我们能更容易的在自己的应用程序中集成状态动画.这个框架是和Qt的元对象系统机密结合在一起的.比如,各个状态之间的转换是通过信号触发的,状态 ...

  9. 我的Android进阶之旅------>如何将Activity变为半透明的对话框?

    我的Android进阶之旅------>如何将Activity变为半透明的对话框?可以从两个方面来考虑:对话框和半透明. 在定义Activity时指定Theme.Dialog主题就可以将Acti ...

  10. 【足迹C++primer】32、定制操作_1

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/cutter_point/article/details/32066151 定制操作 向算法传递函数 ...