CC1310 Configuration process of GPIO peripheralsIssuing time:2022-11-16 16:50 CC1310 Configuration process of GPIO peripheralsConfiguration process of GPIO peripherals If we want to configure a pin of CC1310 chip for GPIO peripherals, we must ensure that the chip pin and the pin of GPIO peripherals index have correct correspondence. It is mainly divided into the initialization of corresponding pins and the initialization of corresponding GPIO peripherals. Pin initialization First, we want to use a pin of CC1310 as a GPIO pin. We must initialize the pin. The initialization of pins can be divided into three steps as shown in the figure above. Pin declaration The declaration I'm talking about here is not like the variable declaration in C language, but in the routine of CC1310, the physical address of each pin is predefined, and we can use the predefined CC1310_ LAUNCHPAD. h file. Note that this step is not necessary. It is only convenient for us to understand the program more easily when writing the program, and enhances the overall portability of the code. But if we use this pin predefined declaration method, we must ensure that our predefined name points to the physical address of the IO pin we want to use. As shown in the figure below: Here is another nonsense. Why add the predefined pin If I want to use a red led light as the indicator of CC1310 working status, and choose to use IO_ As the output pin of an led lamp, I will_ The physical address of 0 is predefined as CC1310_ LAUNCHPAD_ PIN_ RLED, so that when we want to change the level of the red LED light pin when writing the application, we can directly call the predefined name, which will be more convenient for us to understand the role of the pin. If we want to use IO later_ 6 is the output pin of the red led light, so only use the IO_ 0 changed to IO_ 6, instead of modifying the application program we wrote, which increases the overall portability of the application code. In addition, if you want to add a green led light later to indicate some other working states of CC1310, I can also predefine it here in advance, without setting the actual pin physical address, so that we can continue to expand the program functions later. Add pin declaration After we predefine the pin we want to use, we can use it during pin initialization. However, before pin initialization, we must configure its corresponding attributes. This is to prepare for the pin initialization by writing the pin and the corresponding attributes into the corresponding register. We can use CC1310_ The following code is found in the LAUNCHPAD. c file:
PIN in this code_ The Config form configures the attributes of all pins used in the program. If we want to add some predefined pins, we need to add the pin names to be used in the modified attribute configuration table and add the pin attributes we want to implement. In addition, this part of the code also stipulates that the hardware and software interrupts generated by these pins are the interrupts with the lowest priority. Pin initialization After adding the pin name to be used to the pin configuration table, you can use this table to initialize the pin. PIN called during pin initialization_ The init() function is completed. In TI routines, this function calls Board in the main function_ Init function. Let's go in Board_ Init() function.
To PIN_ PIN passed in PIN_ init() function_ The pins in the Config table will be configured as GPIO pins and have the added pin attributes. No PIN_ All pins in the Config table will be configured to the status of both input and output disabled. Note: In the same application, PIN_ init() cannot be called multiple times. After the above PIN initialization is completed, we can use the driver/PIN The API provided in the h file uses these pins. If we want to use some pins directly, we can call the PIN_ The open() function is not recommended in applications with operating systems, because it is not thread safe. |