void lib_aci_init(aci_state_t *aci_stat) { uint8_t i; for (i = 0; i < PIPES_ARRAY_SIZE; i++) { aci_stat->pipes_open_bitmap[i] = 0; aci_stat->pipes_closed_bitmap[i] = 0; aci_cmd_params_open_adv_pipe.pipes[i] = 0; } is_request_operation_pending = false; is_indicate_operation_pending = false; is_open_remote_pipe_pending = false; is_close_remote_pipe_pending = false; cur_transaction_cmd = ACI_CMD_INVALID; memorized_rcvd_cmd_opcode = ACI_CMD_INVALID; memorized_transaction_cmd_opcode = ACI_CMD_INVALID; cx_rf_interval = 0; current_slave_latency = 0; request_operation_pipe = 0; indicate_operation_pipe = 0; cur_error_code = 0; p_rcvd_evt = NULL; p_services_pipe_type_map = aci_stat->aci_setup_info.services_pipe_type_mapping; pipe_count = aci_stat->aci_setup_info.number_of_pipes; p_setup_msgs = aci_stat->aci_setup_info.setup_msgs; setup_msgs_count = aci_stat->aci_setup_info.num_setup_msgs; hal_aci_tl_init(); }
void setup(void) { #if defined(__ICCRL78__) /*The Serial monitor is configured as 115 200 bps, 8 data bit, 1 stop bit, no parity and is configured on the systeminit() at CG_systeminit.c This call just initializes the structure needed for sending data using the same functions name as in Arduino */ initializeSerialMonitor(&Serial); #else Serial.begin(115200); //Wait until the serial port is available (useful only for the Leonardo) //As the Leonardo board is not reseted every time you open the Serial Monitor #if defined (__AVR_ATmega32U4__) while(!Serial) {} delay(5000); //5 seconds delay for enabling to see the start up comments on the serial board #elif defined(__PIC32MX__) delay(1000); #endif #endif Serial.println(F("Arduino setup")); /* Tell the ACI library, the MCU to nRF8001 pin connections. The Active pin is optional and can be marked UNUSED */ aci_state.aci_pins.board_name = BOARD_DEFAULT; //See board.h for details REDBEARLAB_SHIELD_V1_1 or BOARD_DEFAULT aci_state.aci_pins.reqn_pin = ACI_REQN; aci_state.aci_pins.rdyn_pin = ACI_RDYN; aci_state.aci_pins.mosi_pin = ACI_MOSI; aci_state.aci_pins.miso_pin = ACI_MISO; aci_state.aci_pins.sck_pin = ACI_SCLK; aci_state.aci_pins.spi_clock_divider = SPI_CLOCK_DIV8;//SPI_CLOCK_DIV8 = 2MHz SPI speed //SPI_CLOCK_DIV16 = 1MHz SPI speed aci_state.aci_pins.reset_pin = ACI_RESET; aci_state.aci_pins.active_pin = UNUSED; aci_state.aci_pins.optional_chip_sel_pin = UNUSED; aci_state.aci_pins.interface_is_interrupt = false; aci_state.aci_pins.interrupt_number = 1; //The second parameter is for turning debug printing on for the ACI Commands and Events so they be printed on the Serial hal_aci_tl_init(&(aci_state.aci_pins),true); Serial.println(F("nRF8001 Reset done")); }
void lib_aci_init(aci_state_t *aci_stat, bool debug) { uint8_t i; for (i = 0; i < PIPES_ARRAY_SIZE; i++) { aci_stat->pipes_open_bitmap[i] = 0; aci_stat->pipes_closed_bitmap[i] = 0; aci_cmd_params_open_adv_pipe.pipes[i] = 0; } hal_aci_tl_init(&aci_stat->aci_pins, debug); lib_aci_board_init(aci_stat); }
int main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer initializeClocks(); InitializeButton(); InitializeLeds(); //This will reset the nRF8001. ACI Device Started Event is generated by the nRF8001 device //as soon as the reset is complete hal_aci_tl_init(); // Reset nRF8001 resetDevice(); _BIS_SR(GIE); begin_BLE(&aci_state); // Main application loop for (;;) { //_BIS_SR(LPM0_bits + GIE); // Enter LPM0 w/interrupt _nop(); // For debugger //Not entirely sure if any of this if statement needs to be here... if(rdynFlag == 1) { rdynFlag = 0; m_rdy_line_handle(); } pollACI(&aci_state, &aci_data, &aci_cmd); state = getState(); if ((getState() == ACI_EVT_CONNECTED) && (!ctr) && lib_aci_is_pipe_available(&aci_state, PIPE_UART_OVER_BTLE_UART_TX_TX)) { //make sure pipe is available //#define UART #ifdef UART write("80 98 37 998", 12, &aci_state, &aci_data, &aci_cmd); #else write(data, 6, &aci_state, &aci_data, &aci_cmd); #endif //lib_aci_get_battery_level(); } ctr++; } }
void lib_aci_init(aci_state_t *aci_stat,E_BLE_INIT_MODE eInitMode) { if(E_BLE_INIT_MODE_PRELATCH!=eInitMode) { uint8_t i; for (i = 0; i < PIPES_ARRAY_SIZE; i++) { aci_stat->pipes_open_bitmap[i] = 0; aci_stat->pipes_closed_bitmap[i] = 0; aci_cmd_params_open_adv_pipe.pipes[i] = 0; } is_request_operation_pending = false; is_indicate_operation_pending = false; is_open_remote_pipe_pending = false; is_close_remote_pipe_pending = false; request_operation_pipe = 0; indicate_operation_pipe = 0; p_services_pipe_type_map = aci_stat->aci_setup_info.services_pipe_type_mapping; p_setup_msgs = aci_stat->aci_setup_info.setup_msgs; } hal_aci_tl_init(&aci_stat->aci_pins,eInitMode); if(E_BLE_INIT_MODE_POR==eInitMode) { lib_aci_board_init(aci_stat); } }
void lib_aci_init(aci_state_t *aci_stat) { uint8_t i; for (i = 0; i < PIPES_ARRAY_SIZE; i++) { aci_stat->pipes_open_bitmap[i] = 0; aci_stat->pipes_closed_bitmap[i] = 0; aci_cmd_params_open_adv_pipe.pipes[i] = 0; } is_request_operation_pending = false; is_indicate_operation_pending = false; is_open_remote_pipe_pending = false; is_close_remote_pipe_pending = false; request_operation_pipe = 0; indicate_operation_pipe = 0; p_services_pipe_type_map = aci_stat->aci_setup_info.services_pipe_type_mapping; p_setup_msgs = aci_stat->aci_setup_info.setup_msgs; hal_aci_tl_init(&aci_stat->aci_pins); lib_aci_board_init(aci_stat); }