1. Why should the function be declared in the header file?
The compiler will perform strict parameter type + return type validity checks on all declared prototype functions in actual calls, there is no warning when the real parameter type, return value type, and the variable type that receives the return value are completely valid. Otherwise, an error is invalid and an implicit forced conversion with lost data is reported.
If no prototype application is available for a function, the compiler does not check whether the call format is valid when calling the function. In addition to notifying the compiler to perform a strict validity check, the prototype declaration does not link unreferenced functions to the final program.
2. USB device insertion Detection MechanismHow does a USB Host detect device insertion? First, a 15 K ohm drop-down resistor is attached to the D + and D-of each downstream port of the USB hub to the ground. In this way, when the hub port is left blank, the two drop-down resistors are pulled to a low level. On the USB device side, a K ohm resistor is attached to D + or D. For high-speed and high-speed devices, the uplink resistance is connected to D +, while the low-speed devices are connected to D. In this way, when the device is inserted into the hub, the pressure is divided by the up-pull resistance of k and the drop-down resistance of 15 K. As a result, one of the differential data lines is increased. After the hub detects this status, it reports it to the USB master controller (or reports it to the USB master controller through the hub on the previous layer), so that the device is inserted. A usb high-speed device is first recognized as a full-speed device, and then switched to high-speed mode through confirmation between the host and the device. In high-speed mode, the current transmission mode is used. In this case, the pull-up resistance on D + is disconnected.
A simple experiment: use only one pull-up resistor to connect to the USB + 5 V and D + or D-. Windows will also prompt you to find new hardware, but cannot find the driver. In the Device Manager, an unknown USB device is displayed, and its vid and PID are 0. Based on this, we can easily determine whether the device enumeration is successful.
3. What is sector erasure? What is full-disk erasure?The whole part erasure means to erase the whole part before writing.
When the slice is erased, the slice corresponding to the address to be burned is erased first, and then the write operation is performed. Other slice will not be affected. It should be noted that, even if only one byte of data is programmed to the last sector, the entire sector will be erased first, and all data in this sector will be lost.
4. What is the difference between typedef and # define?
Typedef is used to define the alias of each identifier or keyword. It is part of the language compilation process, but it does not allocate memory. # define is used to define constants and macros, and is not in the compilation process, it is just a simple replacement of characters. Example:
Typedef (int *) pint; and the following line: # define pint2 int *
Same effect? Actually different! In practice, see the difference: pint a, B; has the same effect as int * A; int * B; indicates that two integer pointer variables are defined. Pint2 a, B; has the same effect as int * a, B;
Defines an integer pointer variable A and an integer variable B.
There is also a difference between the two.
5. Role of the keyword volatile
In the Embedded C language, typedef volatile... volatile is often used here:
Volatile affects the compilation result of the compiler. Volatile variables may change at any time. computation related to volatile variables should not be optimized to avoid errors, (VC ++ will compile and optimize the release executable code, and the computation related to variables with the volatile keyword will not be compiled and optimized .). For example, volatile int I = 10; Int J = I; ...int K = I; volatile tells the compiler that I may change at any time, each time you use it, you must read it from the I address. Therefore, the executable code generated by the compiler will read data from the I address again and put it in K. The optimization method is that because the compiler finds that the code between the two data reads from I has not performed any operations on I, it will automatically put the data that was last read in K. Instead of reading from I again. In this way, if I is a register variable or indicates that data on a port is prone to errors, volatile can ensure stable access to special addresses without errors.
6. Data Structure
Typedef Enum indicates that an enumerated data structure is defined,Typedef struct also defines a data structure that contains multiple data items
7. Use extern
Extern can be placed before a variable or function to indicate that the definition of a variable or function is in another file, prompting the compiler to find its definition in other modules when it encounters this variable or function. In addition, extern can be used to specify links.
8. # ifdef
# If constant expression program... // Constant expression non-zero # else program... // Constant expression 0 # endif # ifdef identifier // If the identifier is defined by # define, the program is compiled... # Else program... # Endif is similar to # ifndef to avoid multiple inclusion
9. The error "c2456e: undecleared name inventing extern 'OS _ tcb'" occurs when the uCOS-II operating system is transplanted to the ARM7 development board.Solution: add the header file # include "includes. H" to OS _cpu_c.c.10. when I use I2C bus to read and write the clock chip, the ime array that defines the write time [] appears, "error: c2292e: typedef name 'uint 8' used in expression context ......Solution: place the defined javasime [7] array at the beginning of the function.
11. When reading and writing I2C, The while (0 = i2c_end) cannot be cyclically generated, as if it is in an endless loop.Solution: In the definition interrupt function of target. C or other files, in void vicinit (void), there must be vicintenable = 1 <9.
12. Use the system's tick clock for latency. Errors always occur during compilation. Source \ app \ main. C (249): Warning: # 223-d: function "javasick_itconfig" declared implicitly
Solution: The compiled version is inconsistent with the library function version used. Modify
Versions earlier than 3.0 are as follows: Void Systick_configuration (void) { Systick_clksourceconfig (systick_clksource_hclk ); Nvic_systemhandlerpriorityconfig (systemhandler_systick, 3, 0 ); Required ick_setreload (72000 ); Systick_itconfig (enable ); Required ick_countercmd (required ick_counter_enable ); } Versions later than 3.0 are as follows: Void Systick_configuration (void) { /* Setup into ick timer for 1 msec interrupts */ If (systick_config (systemcoreclock/1000)/* systemcoreclock is Defined in capacity ° system _ stm32f10x. h between ± and equal to hclk frequency */
{ /* Capture Error */ While (1 ); } Nvic_setpriority (effecick_irqn, 3); // The highest priority */ } |
13. Execute CIFS mounting on the server remotely using CRT on the local machine. The error "XXX isNot in the sudoers file. This incident will be reported"
Solution: 1> enter the superuser mode. That is, enter "Su-". The system will ask you to enter the superuser password and enter the password to enter the superuser mode. 2> Add the write permission for the file. That is, enter the command "chmod U + w/etc/sudoers ". 3> edit the/etc/sudoers file. That is, enter the command "Vim/etc/sudoers", enter "I" to enter the editing mode, and find this line: "root all = (all) all "add" XXX all = (all) All "(here XXX is your user name), and save it (that is, Press ESC and then enter ": WQ ") quit. 4> revoke the write permission of a file. That is, enter the command "chmod U-W/etc/sudoers ". Now, the problem is solved.
Add and delete users and passwords in Linux
# Useradd-D/usr/SAM-m Sam
This command creates a user Sam. The-D and-m options are used to generate a main directory/usr/Sam for the login SAM (/usr is the parent directory of the default user main directory ).
# Useradd-S/bin/sh-G group-g adm, root gem
This command creates a new user gem. the user's logon shell is/bin/sh, which belongs to the group user group and also to the ADM and root user groups. The group user group is the main group.
Adding a user account adds a record to a new user in the/etc/passwd file and updates other system files, such as/etc/shadow and/etc/group. The contents of these files will be detailed later.
Linux provides the integrated system management tool userconf, which can be used to manage user accounts in a unified manner.
If a user's account is no longer in use, it can be deleted from the system. To delete a user account, you must delete the user record in system files such as/etc/passwd. If necessary, delete the user's home directory. Delete an existing user account and use the userdel command. The format is as follows:
Userdel option Username
The commonly used option is-R, which is used to delete the user's home directory together.
For example:
# Userdel Sam
This command deletes the records of the user Sam in the System File (mainly/etc/passwd,/etc/shadow,/etc/group), and deletes the user's home directory.
Modifying a user account is to change the user's attributes, such as the user ID, main directory, user group, and logon shell.
Use the usermod command to modify existing user information. The format is as follows:
Usermod option Username
Common options include-C,-D,-M,-G,-G,-S,-u, and-o. These options have the same meaning as those in the useradd command, you can specify a new resource value for the user. In addition, some systems can use the following options:
-L New User Name
This option specifies a new account, changing the original user name to the new user name.
For example:
# Usermod-S/bin/KSh-D/home/Z-G developer Sam
This command changes the logon shell of user Sam to KSh, the main directory to/home/Z, and the user group to developer.
An important part of user management is the management of user passwords. A user account has no password when it was created, but is locked by the system and cannot be used. It can only be used after a password is specified, even if it is null.
The shell command used to specify and modify the user password is passwd. Super Users can specify passwords for themselves and other users. Common users can only use them to modify their own passwords. Command Format:
Passwd option User Name
Available options:
-L the password is disabled.
-U password unlock.
-D indicates that the account has no password.
-F forces the user to change the password upon next login.
If the default user name is used, modify the password of the current user.
For example, if the current user is Sam, the following command modifies the user's own password:
$ Passwd
Old password :******
New Password :*******
Re-enter new password :*******
If you are a super user, you can specify the password of any user in the following form:
# Passwd Sam
New Password :*******
Re-enter new password :*******
When a common user modifies his or her own password, the passwd command First asks for the original password and then asks the user to enter the new password twice. If the two passwords are the same, the original password is not required when the superuser specifies a password for the user.
For the sake of system security, you should select a complicated password. For example, you 'd better use an 8-bit long password, which contains uppercase letters, lowercase letters, and numbers, it should be different from the name and birthday.
When you specify a blank password, run the following commands:
# Passwd-D Sam
This command deletes the password of the user Sam, so that the system will not ask for the password during the next logon.
The passwd command can also use the-l (LOCK) option to lock a user so that the user cannot log on. For example:
# Passwd-l Sam