void mpxlcol_load (FORM* form) { //Wenn noch kein Colorset gespeichert wurde, wird das Default Colorset //Abgespeichert. Sonst wird das COlorset aus dem Speicher geladen. if((BFS_LoadFile(BFS_ID_RGB_Colors, sizeof(struct Colorset), (unsigned char*) &colors)) != sizeof(struct Colorset)) { colors = default_Colorset; BFS_SaveFile(BFS_ID_RGB_Colors, sizeof(struct Colorset), (unsigned char*) &colors); msgbox(50,BC_OKOnly | BC_DefaultButton1,"Defaults geladen"); } pointer = 0; //Controls mit den Werten im Speicher initialisieren. memcpy(((TXTBOX*)form->controls[3])->text,colors.Name[pointer],20); ((TRACKBAR*)form->controls[4])->actval = colors.color[pointer].Red; ((TRACKBAR*)form->controls[5])->actval = colors.color[pointer].Green; ((TRACKBAR*)form->controls[6])->actval = colors.color[pointer].Blue; //und zeichnen control_draw(form->controls[3], 0); control_draw(form->controls[4], 0); control_draw(form->controls[5], 0); control_draw(form->controls[6], 0); //setzen der ersten Farbe im Speicher cc1100_init(); setRGB(colors.color[0]); //Einschalten des LED-Stacks led_state(mpxl_state_on); }
void auto_init(void) { #ifdef MODULE_BOARD_DISPLAY extern void lcd_init(); lcd_init(); DEBUG("DISP OK"); #endif #ifdef MODULE_DISPLAY_PUTCHAR extern void init_display_putchar(); init_display_putchar(); DEBUG("DISP OK"); #endif #ifdef MODULE_HWTIMER DEBUG("Auto init hwtimer module.\n"); hwtimer_init(); #endif #ifdef MODULE_VTIMER DEBUG("Auto init vtimer module.\n"); vtimer_init(); #endif #ifdef MODULE_UART0 DEBUG("Auto init uart0 module.\n"); board_uart0_init(); #endif #ifdef MODULE_RTC DEBUG("Auto init rtc module.\n"); rtc_init(); rtc_enable(); #endif #ifdef MODULE_SHT11 DEBUG("Auto init SHT11 module.\n"); sht11_init(); #endif #ifdef MODULE_GPIOINT DEBUG("Auto init gpioint module.\n"); gpioint_init(); #endif #ifdef MODULE_CC110X DEBUG("Auto init CC1100 module.\n"); cc1100_init(); #endif #ifdef MODULE_LTC4150 DEBUG("Auto init ltc4150 module.\n"); ltc4150_init(); #endif #ifdef MODULE_MCI DEBUG("Auto init mci module.\n"); MCI_initialize(); #endif #ifdef MODULE_PROFILING extern void profiling_init(void); profiling_init(); #endif main(); }
/* Start the transceiver thread */ kernel_pid_t transceiver_start(void) { transceiver_pid = thread_create(transceiver_stack, TRANSCEIVER_STACK_SIZE, THREAD_PRIORITY_MAIN - 3, CREATE_STACKTEST, run, NULL, "Transceiver"); if (transceiver_pid == KERNEL_PID_UNDEF) { puts("Error creating transceiver thread"); } #if (defined(MODULE_CC110X) || defined(MODULE_CC110X_LEGACY)) else if (transceivers & TRANSCEIVER_CC1100) { DEBUG("transceiver: Transceiver started for CC1100\n"); cc110x_init(transceiver_pid); } #endif #ifdef MODULE_CC110X_LEGACY_CSMA else if (transceivers & TRANSCEIVER_CC1100) { DEBUG("transceiver: Transceiver started for CC1100\n"); cc1100_init(); cc1100_set_packet_monitor(cc1100_packet_monitor); } #endif #ifdef MODULE_CC2420 else if (transceivers & TRANSCEIVER_CC2420) { DEBUG("transceiver: Transceiver started for CC2420\n"); cc2420_init(transceiver_pid); } #endif #ifdef MODULE_AT86RF231 else if (transceivers & TRANSCEIVER_AT86RF231) { DEBUG("transceiver: Transceiver started for AT86RF231\n"); at86rf231_init(transceiver_pid); } #endif #ifdef MODULE_MC1322X else if (transceivers & TRANSCEIVER_MC1322X) { maca_init(); } #endif #ifdef MODULE_NATIVENET else if (transceivers & TRANSCEIVER_NATIVE) { nativenet_init(transceiver_pid); } #endif return transceiver_pid; }
// ----------------------------------------------------------------------- void init_feuerwhere_cc1100_radio( void ) { cc1100_init(); cc1100_set_packet_handler( WISELIB_PROTOCOL, protocol_handler );//layer link layer if(cc1100_set_address((radio_address_t)RADIO_NODE_ID)){ printf("cc1100..[OK] set to %d\n", (radio_address_t)RADIO_NODE_ID); //printf("cc1100..[OK]\n"); } for ( int i = 0; i < MAX_REGISTERED_RECEIVERS; i++ ) receivers[i] = feuerwhere_radio_delegate_t(); }
/** * The main function. */ int main( void ) { /* Stop the watchdog timer. */ WDTCTL = WDTPW + WDTHOLD; /* Setup MCLK 8MHz and SMCLK 1MHz */ set_mcu_speed_xt2_mclk_8MHz_smclk_1MHz(); /* Enable Interrupts */ eint(); uart0_init(UART0_CONFIG_1MHZ_115200); uart0_register_callback(char_cb); printf("CC1100 RXTX test program\r\n"); LEDS_INIT(); LEDS_OFF(); cc1100_init(); cc1100_cfg_append_status(CC1100_APPEND_STATUS_ENABLE); cc1100_cfg_crc_autoflush(CC1100_CRC_AUTOFLUSH_DISABLE); cc1100_cfg_white_data(CC1100_DATA_WHITENING_ENABLE); cc1100_cfg_crc_en(CC1100_CRC_CALCULATION_ENABLE); cc1100_cfg_freq_if(0x0C); cc1100_cfg_fs_autocal(CC1100_AUTOCAL_NEVER); cc1100_cfg_mod_format(CC1100_MODULATION_MSK); cc1100_cfg_sync_mode(CC1100_SYNCMODE_30_32); cc1100_cfg_manchester_en(CC1100_MANCHESTER_DISABLE); printf("CC1100 initialized\r\nType 's' to send a message\r\n"); while(1) { // Enter RX LED_RED_ON(); cc1100_cmd_idle(); cc1100_cmd_flush_rx(); cc1100_cmd_calibrate(); cc1100_cmd_rx(); cc1100_cfg_gdo0(CC1100_GDOx_SYNC_WORD); cc1100_gdo0_int_set_falling_edge(); cc1100_gdo0_int_clear(); cc1100_gdo0_int_enable(); cc1100_gdo0_register_callback(rx_ok); // Low Power Mode LPM0; // Check for send flag if (send == 1) { send = 0; LED_RED_OFF(); cc1100_cmd_idle(); cc1100_cmd_flush_tx(); cc1100_cmd_calibrate(); cc1100_gdo0_int_disable(); frameseq ++; length = sprintf((char *)frame, "Hello World #%i", frameseq); printf("Sent : %s \r\n", frame); cc1100_fifo_put(&length, 1); cc1100_fifo_put(frame, length); cc1100_cmd_tx(); // Wait for SYNC word sent while (cc1100_gdo0_read() == 0); // Wait for end of packet while (cc1100_gdo0_read() != 0); } // Check for receive flag if (receive == 1) { receive = 0; uint8_t i; // verify CRC result if ( !(cc1100_status_crc_lqi() & 0x80) ) { continue; } cc1100_fifo_get(&length, 1); if (length > 60) { continue; } cc1100_fifo_get(frame, length+2); uint16_t rssi = (uint16_t)frame[length]; int16_t rssi_d; if (rssi >= 128) rssi_d = (rssi-256)-140; else rssi_d = rssi-140; printf("Frame received with RSSI=%d.%d dBm: ", rssi_d, 5*(rssi_d&0x1)); for (i=0; i<length; i++) { printf("%c",frame[i]); } printf("\r\n"); LED_GREEN_TOGGLE(); } } return 0; }
void mac_init(uint8_t channel) { // initialize the unique serial number chip and set node address accordingly ds2411_init(); node_addr = (((uint16_t)ds2411_id.serial1)<<8) + (ds2411_id.serial0); // seed the random number generator srand(node_addr); // reset callbacks received_cb = 0x0; sent_cb = 0x0; error_cb = 0x0; // initialize the timerB timerB_init(); timerB_start_ACLK_div(1); timerB_register_cb(ALARM_RETRY, check); // configure the radio cc1100_init(); cc1100_cmd_idle(); /* configure the radio behaviour */ cc1100_cfg_append_status(CC1100_APPEND_STATUS_ENABLE); cc1100_cfg_crc_autoflush(CC1100_CRC_AUTOFLUSH_DISABLE); cc1100_cfg_white_data(CC1100_DATA_WHITENING_ENABLE); cc1100_cfg_crc_en(CC1100_CRC_CALCULATION_ENABLE); cc1100_cfg_freq_if(0x0E); cc1100_cfg_fs_autocal(CC1100_AUTOCAL_IDLE_TO_TX_RX); cc1100_cfg_mod_format(CC1100_MODULATION_GFSK); cc1100_cfg_sync_mode(CC1100_SYNCMODE_30_32); cc1100_cfg_manchester_en(CC1100_MANCHESTER_DISABLE); cc1100_cfg_cca_mode(CC1100_CCA_MODE_RSSI_PKT_RX); // freq = 860MHz cc1100_write_reg(CC1100_REG_FREQ2, 0x1F); cc1100_write_reg(CC1100_REG_FREQ1, 0xDA); cc1100_write_reg(CC1100_REG_FREQ0, 0x12); //packet length to 61 cc1100_write_reg(CC1100_REG_PKTLEN, 0x3D); // configure the radio channel cc1100_cfg_chanspc_e(0x2); cc1100_cfg_chanspc_m(0xF8); cc1100_write_reg(CC1100_REG_DEVIATN, 0x47); // rise CCA threshold cc1100_cfg_carrier_sense_abs_thr(5); // set channel bandwidth cc1100_cfg_chanbw_e(1); cc1100_cfg_chanbw_m(3); // set data rate cc1100_cfg_drate_e(0xB); cc1100_cfg_drate_m(0x74); // go to RX after RX and TX cc1100_cfg_rxoff_mode(CC1100_RXOFF_MODE_IDLE); cc1100_cfg_txoff_mode(CC1100_TXOFF_MODE_RX); uint8_t table[1]; table[0] = 0x1E; // -15dBm 13.4mA cc1100_cfg_patable(table, 1); cc1100_cfg_pa_power(0); // set IDLE state, flush everything, and start rx cc1100_cmd_idle(); cc1100_cmd_flush_rx(); cc1100_cmd_flush_tx(); cc1100_cmd_calibrate(); // configure irq cc1100_cfg_gdo0(CC1100_GDOx_SYNC_WORD); cc1100_gdo0_int_set_falling_edge(); cc1100_gdo0_int_clear(); cc1100_gdo0_int_enable(); cc1100_gdo0_register_callback(rx_parse); // start the machine rx_set(); txframe.length = 0; }
void RF_init (void) { cc1100_init(); RFstatus = 0; cc1100Addr = conf[0x09]; }