void main(void) { Sys_Init(); //All init function putchar(' '); XBR0_Init(); ADC_Init(); Port_Init(); PCA_Init(); SMB_Init(); //end the init function lcd_clear(); lcd_print("initializing\r\n"); PCA0CP2 = 0xFFFF - MOTOR_NEUT; PCA0CPL0 = 0xFFFF - PW_CENTER; PCA0CPH0 = (0xFFFF - PW_CENTER) >> 8; while (n_Counts < 50); //pause for a second? start_run(); while (1) { while(SS){ // if the slideswitch is off slide_switch_off(); }///end slide switch off while(!SS) //while the slideswitch is on { Heading(); Ranger(); LCD_Print(); //print all values on the lcd printf("\n\r Range:%d Compass:%d PW:%d", range, heading, PW); //print these on the secure crt for data aquisition } } //end of the infinite while loop }//end of the main function
void main(void) { Sys_Init(); //All init function putchar(' '); XBR0_Init(); ADC_Init(); Port_Init(); PCA_Init(); SMB_Init(); //end the init function lcd_clear(); lcd_print("initializing\r\n"); printf("\n\n\n\rinitalizing"); PCA0CP2 = 0xFFFF - MOTOR_NEUT;//set all to neutural PCA0CPL0 = 0xFFFF - PW_CENTER; PCA0CPH0 = (0xFFFF - PW_CENTER) >> 8; pause(); //pause for a second? start_run(); while (1) { while(SS){ // if the slideswitch is off slide_switch_off(); }///end slide switch off while(!SS){ //while the slideswitch is on Heading(); Ranger(); LCD_Print(); //print all values on the lcd printf("\n\rRange:%d Compass:%d dh: %d, mPW: %d, sPW %d, batt:%d, obst: %d", range, heading, desired_heading, MOTOR_PW_AND_STEER_PW, STEER_PW, battery, near_obstical); //print these on the secure crt for data aquisition //printf("\n\r Range:%d Compass:%d dh: %d, mPW: %d, sPW %d, obst: %d", range, heading, desired_heading, MOTOR_PW_AND_STEER_PW, STEER_PW, near_obstical); //print these on the secure crt for data aquisition }//end slide switch on } //end of the infinite while loop }//end of the main function
/******************************************************************************* * @fn userAppInit * * @brief user Application init * * @param void * * @return none */ void userAppInit(void) { OLED_Init(); // 电池状态读初始化I2C SMB_Init(); // 串口初始化 bspUartInit(); // 按键初始化要等系统稳定后,防止外部中断引起系统死机 KEY_Init(); //电池状态检测初始化 chargeDetection_Init(); //OLED_ShowString(40,32, "WiCore"); OLED_Clear(); // Create one-shot clocks for internal periodic events. Util_constructClock(&periodicClock_10ms, userApp_clockHandler, 10, 0, false, USER_10MS_EVT); #ifndef INCLUDE_CLKSTOP systemState.powerOffFlag = 1; Util_startClock(&periodicClock_10ms); #else Util_stopClock(&periodicClock_10ms); #endif }
//******************************************************************** // Main Functions //******************************************************************** void main(void) { //Main function Sys_Init(); // initialize board putchar(' '); //the quotes in this line may not format correctly Port_Init();//Init ports XBR0_Init();//init xbro PCA_Init();//init pca SMB_Init();//init smb printf("\r\n\n\n\nEmbedded Control Electric Compass and Ranger\n"); //print beginning message Calibration();//Run calibration comp_cal(); //Compass calibration Choose_heading(); //Heading choice printf("\r\nheading error"); while(1) { //inf loop, 40 ms it returns the heading if (new_heading){ //enough overflows for a new heading COMPASS STUFF new_heading = 0;//Clear new_heading heading = ReadCompass(); //get compass heading Steering_Servo(); //run steer func }//end if new heading if (new_range) { //if 80 ms has passed new_range=0;//Clear new_range range=ReadRanger();//read ranger start_ping();//start ping counts++;//set up text function Drive_Motor(); //run drive func }//end if new_range if (counts == 3){ //prevoudly output prined every 200 ms, now every 180 ms print_output();//Print data function. Delete this if faster output is desired }//end if counts }//end inf while }//end main
void main(void) { Sys_Init(); putchar(' '); XBR0_Init(); SMB_Init(); PCA_Init(); Drive_Init(); Port_Init(); ADC_Init(); ranger_pd_init(); //fan angle initialization code goes here while(1) { voltage_update(); if(SS) { Range_Update(); //update the range Drive_Motor(ranger_pd()); } else Drive_Motor(PW_NEUT); //if ss is not flipped, put it in neutral } }
void Notify_AP_MHL_TX_Event(unsigned int event, unsigned int event_param, void *param) { if(event != MHL_TX_EVENT_SMB_DATA) HDMI_LOG("%s, event_param: %d\n", MHL_TX_Event_Print(event), event_param); switch(event) { case MHL_TX_EVENT_CONNECTION: break; case MHL_TX_EVENT_DISCONNECTION: { sii_mhl_connected = MHL_TX_EVENT_DISCONNECTION; hdmi_state_callback(HDMI_STATE_NO_DEVICE); reset_av_info(); SMB_Denit(); MHL_Connect_type = MHL_CABLE; } break; case MHL_TX_EVENT_HPD_CLEAR: { sii_mhl_connected= MHL_TX_EVENT_DISCONNECTION; hdmi_state_callback(HDMI_STATE_NO_DEVICE); } break; case MHL_TX_EVENT_HPD_GOT: break; case MHL_TX_EVENT_DEV_CAP_UPDATE: { MHL_Connect_type = MHL_SMB_CABLE; } break; case MHL_TX_EVENT_EDID_UPDATE: { update_av_info_edid(true, event_param, 0); } break; case MHL_TX_EVENT_EDID_DONE: { #ifdef HDCP_ENABLE HDCP_Supported_Info = true; #endif sii_mhl_connected = MHL_TX_EVENT_CALLBACK; hdmi_state_callback(HDMI_STATE_ACTIVE); SMB_Init(); SMB_HandShake_Init(); } break; case MHL_TX_EVENT_SMB_DATA: { //SMARTBOOK: get write burst command SMB_Write_Data((uint8_t *)param); } break; default: return ; } return ; }
void main(void) { // initialize board Sys_Init(); putchar(' '); //the quotes in this line may not format correctly Port_Init(); PCA_Init(); SMB_Init(); Interrupt_Init(); printf("Starting\n\r"); //print beginning message printf("Embedded Control Drive Motor Control\r\n"); // Initialize motor in neutral and wait for 1 second MOTOR_PW = PW_NEUT; motorPW = 0xFFFF-MOTOR_PW; PCA0CPL2 = motorPW; PCA0CPH2 = motorPW>>8; printf("Pulse Width = %d\r\n",MOTOR_PW); c = 0; while (c < 50); //wait 1 second in neutral printf("end wait \r\n"); //Main Functionality while (1) { if (!SS1) { // If the slide switch is active, set PW to center PW = PWCENTER; PCA0CP0 = 0xFFFF - PW; // Update comparator with new PW value while (!SS1); // Wait... } else if (take_heading) { // Otherwise take a new heading reading = Read_Compass(); // Get current heading printf("%d\n\r", reading); Steering_Servo(reading); // Change PW based on current heading PCA0CP0 = 0xFFFF - PW; // Update comparator with new PW value } if (getRange) { getRange = 0; // Reset 80 ms flag range_val = read_ranger(); // Read the distance from the ranger printf("Range: %d cm \r\n", range_val); printf("Pulse Width: %d \r\n", MOTOR_PW); // Start a new ping Data[0] = 0x51; // write 0x51 to reg 0 of the ranger: i2c_write_data(addr, 0, Data, 1); // write one byte of data to reg 0 at addr } if (SS0) Drive_Motor(range_val); else Drive_Motor(45); // Hold the motor in neutral if the slide switch is off } }
int Valid_User(char *USERNAME, char *PASSWORD, char *SERVER, char *BACKUP, char *DOMAIN) { int pass_is_precrypted_p = 0; char *SMB_Prots[] = { /* "PC NETWORK PROGRAM 1.0", */ /* "MICROSOFT NETWORKS 1.03", */ /* "MICROSOFT NETWORKS 3.0", */ "LANMAN1.0", "LM1.2X002", "Samba", /* "NT LM 0.12", */ /* "NT LANMAN 1.0", */ NULL}; SMB_Handle_Type con; SMB_Init(); con = SMB_Connect_Server(NULL, SERVER, DOMAIN); if (con == NULL) { /* Error ... */ con = SMB_Connect_Server(NULL, BACKUP, DOMAIN); if (con == NULL) { return (NTV_SERVER_ERROR); } } if (SMB_Negotiate(con, SMB_Prots) < 0) { /* An error */ SMB_Discon(con, 0); return (NTV_PROTOCOL_ERROR); } /* Test for a server in share level mode do not authenticate against it */ if (con->Security == 0) { SMB_Discon(con, 0); return (NTV_PROTOCOL_ERROR); } if (SMB_Logon_Server(con, USERNAME, PASSWORD, DOMAIN, pass_is_precrypted_p) < 0) { SMB_Discon(con, 0); return (NTV_LOGON_ERROR); } SMB_Discon(con, 0); return (NTV_NO_ERROR); }
/******************************************************************************* * Function Name : SystemInit * Description : 系统初始化. * Input : None * Output : None * Return : None *******************************************************************************/ extern void SystemInit2(void) { prvSetupHardware(); GPIO_Configuration(); NVIC_Configuration(); //SysTick_Config(MsTimeTick); USART1_Init(); MainQInit(); #if defined (INCLUDE_BUZZER) BuzzerInit(); BuzzerBeep(4); #endif #ifdef INCLUDE_OLED12832 OLED_Init(); #else SMB_Init(); #endif #ifdef INCLUDE_IWDG IWDGInit(); #endif }
void * NTLM_Connect(char *SERVER, char *BACKUP, char *DOMAIN, char *nonce) { char *SMB_Prots[] = { /* "PC NETWORK PROGRAM 1.0", */ /* "MICROSOFT NETWORKS 1.03", */ /* "MICROSOFT NETWORKS 3.0", */ "LANMAN1.0", "LM1.2X002", "Samba", /* "NT LM 0.12", */ /* "NT LANMAN 1.0", */ NULL}; SMB_Handle_Type con; SMB_Init(); con = SMB_Connect_Server(NULL, SERVER, DOMAIN); if (con == NULL) { /* Error ... */ con = SMB_Connect_Server(NULL, BACKUP, DOMAIN); if (con == NULL) { return (NULL); } } if (SMB_Negotiate(con, SMB_Prots) < 0) { /* An error */ SMB_Discon(con, 0); return (NULL); } /* Test for a server in share level mode do not authenticate against it */ if (con->Security == 0) { SMB_Discon(con, 0); return (NULL); } memcpy(nonce, con->Encrypt_Key, 8); return (con); }
main(int argc, char *argv[]) { void *con, *tree; extern char *optarg; extern int optind; int opt, error, SMB_Error, err_class, err_code, pwlen, tries = 0; char server[80], service[80], service_name[160], password[80], username[80]; char old_password[80], err_string[1024]; server[0] = 0; strncpy(service, "IPC$", sizeof(service) - 1); service_name[0] = 0; username[0] = 0; password[0] = 0; old_password[0] = 0; while ((opt = getopt(argc, argv, "s:u:l:v")) != EOF) { switch (opt) { case 's': strcpy(service, optarg); break; case 'u': /* Pick up the user name */ strncpy(username, optarg, sizeof(username) - 1); break; case 'l': /* pick up password len */ pwlen = atoi(optarg); break; case 'v': /* Verbose? */ verbose = TRUE; break; default: usage(); exit(1); break; } } if (optind < argc) { /* Some more parameters, assume is the server */ strncpy(server, argv[optind], sizeof(server) - 1); optind++; } else { strcpy(server, "nemesis"); } if (verbose == TRUE) { /* Print out all we know */ fprintf(stderr, "Finding password for User: %s, on server: %s\n", username, server); fprintf(stderr, "with a pwlen = %i\n", pwlen); } SMB_Init(); /* Initialize things ... */ /* We connect to the server and negotiate */ con = SMB_Connect_Server(NULL, server); if (con == NULL) { /* Error processing */ fprintf(stderr, "Unable to connect to server %s ...\n", server); if (SMB_Get_Last_Error() == SMBlibE_Remote) { SMB_Error = SMB_Get_Last_SMB_Err(); SMB_Get_SMB_Error_Msg(SMBlib_Error_Class(SMB_Error), SMBlib_Error_Code(SMB_Error), err_string, sizeof(err_string) - 1); } else { SMB_Get_Error_Msg(SMB_Get_Last_Error(), err_string, sizeof(err_string) - 1); } printf(" %s\n", err_string); exit(1); } /* We need to negotiate a protocol better than PC NetWork Program */ if (SMB_Negotiate(con, SMB_Prots) < 0) { fprintf(stderr, "Unable to negotiate a protocol with server %s ...\n", server); if (SMB_Get_Last_Error() == SMBlibE_Remote) { SMB_Error = SMB_Get_Last_SMB_Err(); SMB_Get_SMB_Error_Msg(SMBlib_Error_Class(SMB_Error), SMBlib_Error_Code(SMB_Error), err_string, sizeof(err_string) - 1); } else { SMB_Get_Error_Msg(SMB_Get_Last_Error(), err_string, sizeof(err_string) - 1); } printf(" %s\n", err_string); exit(1); } sprintf(service_name, "\\\\%s\\%s", server, service); /* Could blow up */ /* Now loop through all password possibilities ... */ memset(password, 0, sizeof(password)); while (next_password(password, pwlen) == TRUE) { if ((tree = SMB_Logon_And_TCon(con, NULL, username, password, service_name, "?????")) == NULL) { if (verbose == TRUE) { /* Lets hear about the error */ fprintf(stderr, "Unable to logon and tree connect to server %s ...\n", server); fprintf(stderr, "With username: %s, and password: %s\n", username, print_password(password)); if (SMB_Get_Last_Error() == SMBlibE_Remote) { SMB_Error = SMB_Get_Last_SMB_Err(); SMB_Get_SMB_Error_Msg(SMBlib_Error_Class(SMB_Error), SMBlib_Error_Code(SMB_Error), err_string, sizeof(err_string) - 1); } else { SMB_Get_Error_Msg(SMB_Get_Last_Error(), err_string, sizeof(err_string) - 1); } printf(" %s\n", err_string); } } else { /* Password match */ fprintf(stderr, "Logged in with password:%s\n", print_password(password)); /* Exit now ... */ exit(0); } } fprintf(stderr, "Passwords exhausted."); }
//----------------------------------------------------------------------------- // Main Function //----------------------------------------------------------------------------- void main(void) { // initialize board Sys_Init(); putchar(' '); //the quotes in this line may not format correctly Port_Init(); XBR0_Init(); PCA_Init(); ADC_Init(); SMB_Init(); //drive motor config printf("\rBegin Speed Controller Initialization\n"); PCA0CPL2 = 0xFFFF - PW_SC; PCA0CPH2 = (0xFFFF - PW_SC) >> 8; counts = 0; while(counts < 100); //wait 1 second printf("\rSC init finished\n"); //start_ping(); // set the PCA output to a neutral setting PW_SS = PW_CENTER_SS; PCA0CPL0 = 0xFFFF - PW_SS; PCA0CPH0 = (0xFFFF - PW_SS)>>8; /* //print beginning message printf("Embedded Control Steering Calibration\n"); printf ("\n\rr or l for direction, space for center, then right, then left\n\r"); while (flag < 3) { Steering_Config(); } */ //select heading/gain desired_heading = pick_heading(); gain_SS = pick_gain(); while(1) { //steering servo //ultrasonic ranger if(!SS1){ //switch is on Steering_Servo(); Ultrasonic_Ranger(); run_stop = 1; } else if(run_stop) { PW_SC = PW_NEUTRAL_SC; //drive motor stop PCA0CPL2 = 0xFFFF - PW_SC; PCA0CPH2 = (0xFFFF - PW_SC) >> 8; desired_heading = pick_heading(); gain_SS = pick_gain(); run_stop = 0; } if(new_display) { new_display = 0; Print_LCD(); } } }
//----------------------------------------------------------------------------- // Main Function //----------------------------------------------------------------------------- void main(void) { desired_range = 150; // initialize board Sys_Init(); putchar(' '); //the quotes in this line may not format correctly PCA_Init(); ADC_Init(); Interrupt_Init(); Port_Init(); XBR0_Init(); SMB_Init(); putchar('\r'); //print beginning message printf("En taro Adun, Executor!\r\n"); // set the PCA output to a neutral setting steering_neutral(); ranger_neutral(); wait(); /* Let stuff warm up */ // Get the PD constants and target heading from the keypad compass_kp = read_gain()/10.; desired_heading = read_heading(); compass_kd = read_gain_high(); ranger_kp = read_gain_thrust()/10.; ranger_kd = read_gain_thrust_high(); //Write the settings to the record printf ( "Compass KP = %d, Compass KD = %d, Desired Heading = %d, Ranger KP = %d, Ranger KD = %d, Desired Range = %d\r\n", compass_kp, compass_kd, desired_heading, ranger_kp, ranger_kd, desired_range ); printf ( "Time, heading, range\r\n "); PCA0CPL1 = 0xFFFF - 3200; PCA0CPH1 = ( 0xFFFF - 3200 ) >> 8 ; // Start at time 0. time = 0; while(1) /* Infinite loop is go */ { if ( nCounts == 50 ) { // Update the LCD loop lcd_clear(); lcd_print( "Batt level: %d\n", get_battery_voltage() ); lcd_print("Heading :%d\n", heading/10); lcd_print("Alt: %d", range ); if (SS) lcd_print("PAUSED\n"); else lcd_print("\n"); lcd_print("# forHead, * forGain"); } if ( read_keypad() != -1 ) { // Check the keypad pause(); if ( getKey() == '#' ) { // If # was pressed, get a new heading steering_neutral(); ranger_neutral(); desired_heading = read_heading(); time = 0; printf ( "Compass KP = %d, Compass KD = %d, Desired Heading = %d, Ranger KP = %d, Ranger KD = %d, Desired Range = %d\r\n", compass_kp, compass_kd, desired_heading, ranger_kp, ranger_kd, desired_range ); printf ( "Time, heading, range\r\n "); } else if( getKey() == '*' ) { // If * was pressed, get new gain contants steering_neutral(); ranger_neutral(); compass_kp = read_gain()/10.; compass_kd = read_gain_high(); ranger_kp = read_gain_thrust()/10.; ranger_kd = read_gain_thrust_high(); time = 0; printf ( "Compass KP = %d, Compass KD = %d, Desired Heading = %d, Ranger KP = %d, Ranger KD = %d, Desired Range = %d\r\n", compass_kp, compass_kd, desired_heading, ranger_kp, ranger_kd, desired_range ); printf ( "Time, heading, range\r\n "); } } else pause(); if(SS) //while the SS is off { //printf("The slide switch is OFF \r\n"); steering_neutral(); ranger_neutral(); } if(!SS) //SS is On { //printf("The Slide switch is On \r\n"); if ( new_heading ) printf("%lu,%d,%d\r\n", time, compass_old_error, ranger_old_error ); if (new_heading) //wait for 40ms { heading=read_compass(); //printf("The heading result is %d\r\n", heading); new_heading=0; Steering_Servo( ); } if (new_range) { ReadRanger( ); Speed_Cont( ); //adjust motor speed new_range=0; //reset ranger flag } } } }
void Notify_AP_MHL_TX_Event(unsigned int event, unsigned int event_param, void *param) { if(event != MHL_TX_EVENT_SMB_DATA) MHL_DBG("%s, event_param: %d\n", MHL_TX_Event_Print(event), event_param); switch(event) { case MHL_TX_EVENT_CONNECTION: break; case MHL_TX_EVENT_DISCONNECTION: { MHL_NOTICE("%s, event_param: %d\n", MHL_TX_Event_Print(event), event_param); sii_mhl_connected = MHL_TX_EVENT_DISCONNECTION; hdmi_invoke_cable_callbacks(HDMI_STATE_NO_DEVICE); reset_av_info(); SMB_Denit(); MHL_Connect_type = MHL_CABLE; } break; case MHL_TX_EVENT_HPD_CLEAR: { sii_mhl_connected= MHL_TX_EVENT_DISCONNECTION; hdmi_invoke_cable_callbacks(HDMI_STATE_NO_DEVICE); } break; case MHL_TX_EVENT_HPD_GOT: break; case MHL_TX_EVENT_DEV_CAP_UPDATE: { #ifdef CONFIG_MTK_HDMI_3D_SUPPORT if(event_param == 0xBA) MHL_Connect_type = MHL_3D_GLASSES; else #endif MHL_Connect_type = MHL_SMB_CABLE; } break; case MHL_TX_EVENT_EDID_UPDATE: { update_av_info_edid(true, event_param, 0); } break; case MHL_TX_EVENT_EDID_DONE: { MHL_NOTICE("%s, event_param: %d\n", MHL_TX_Event_Print(event), event_param); ///#ifdef HDCP_ENABLE if(chip_device_id == 0x8346) HDCP_Supported_Info = 140; ///HDCP 1.4 ///#endif sii_mhl_connected = MHL_TX_EVENT_CALLBACK; hdmi_invoke_cable_callbacks(HDMI_STATE_ACTIVE); SMB_Init(); SMB_HandShake_Init(); } break; case MHL_TX_EVENT_SMB_DATA: { //SMARTBOOK: get write burst command SMB_Write_Data((uint8_t *)param); } break; default: return ; } return ; }