STM32 LL(Low Layer) peripheral libraries such as ADC, UART, SPI, I2C etc.
- Specifically designed for embedded applications
- Ultra lightweight
- Easy import to the project and use
- Full feature support
- No HAL dependencies
How to add CPM to the project, check the link
CPMAddPackage(
        NAME STM32Core
        GITHUB_REPOSITORY ximtech/STM32Core
        GIT_TAG origin/main)An ADC (Analog-To-Digital) converter is an electronic circuit that takes in an analog voltage as input and converts it into digital data, a value that represents the voltage level in binary code.
- 
Start project with STM32CubeMX: - Configuration for Polling ADC:
- Configuration for Interrupt ADC:
- Configuration for DMA ADC:
 
- 
Select: Project Manager -> Advanced Settings -> ADC -> LL 
- 
Generate Code 
- 
Add sources to project: 
# add in CmakeLists_template.txt or directly to CmakeLists.txt
# link libraries to project
# Polling ADC
add_subdirectory(${STM32_CORE_SOURCE_DIR}/ADC/Polling)
# Interrupt based ADC
add_subdirectory(${STM32_CORE_SOURCE_DIR}/ADC/IT)
# DMA based ADC
add_subdirectory(${STM32_CORE_SOURCE_DIR}/ADC/DMA)
include_directories(${includes}
        ${ADC_POLLING_DIRECTORY}
        ${ADC_IT_DIRECTORY}
        ${ADC_DMA_DIRECTORY})
file(GLOB_RECURSE SOURCES ${sources}
        ${ADC_POLLING_SOURCES}
        ${ADC_IT_SOURCES}
        ${ADC_DMA_SOURCES})
target_link_libraries(${PROJECT_NAME}.elf Vector)   # add vector if ADC_IT or ADC_DMA is used- Then Build -> Clean -> Rebuild Project
- Polling ADC code examples:
- Interrupt ADC code examples:
- DMA ADC code examples:
For Interrupt and DMA ADC set handler functions in stm32fXxx_it.c
/******************************************************************************/
/* STM32FXxx STM32 Peripheral Interrupt Handlers                              */
/* Add here the Interrupt Handlers for the used peripherals.                  */
/* For the available peripheral interrupt handler names,                      */
/* please refer to the startup file (startup_stm32fXxx.s).                    */
/******************************************************************************/
// This function handles ADC1 global interrupt.
void ADC_IRQHandler(void) {
    conventionCompleteCallbackADC(ADC1, ADC_REGULAR_CHANNEL);   // set ADC type and channel type
}
// This function handles DMA2 stream0 global interrupt.
void DMA2_Stream0_IRQHandler(void) {
    transferCompleteCallbackADC_DMA(DMA2, LL_DMA_STREAM_0); // set DMA type and stream
}Inter-Integrated Circuit (I2C) is a communication bus protocol developed by Philips Semiconductor (now NXP Semiconductors) in 1982. It is a relatively slow protocol but has seen widespread use due to its simplicity and robustness.
- 
Start project with STM32CubeMX: - Configuration for Polling I2C:
- Configuration for Interrupt I2C:
- Configuration for DMA I2C:
 
- 
Select: Project Manager -> Advanced Settings -> I2C -> LL 
- 
Generate Code 
- 
Add sources to project: 
# add in CmakeLists_template.txt or directly to CmakeLists.txt
# link libraries
add_subdirectory(${STM32_CORE_SOURCE_DIR}/I2C/Polling)
add_subdirectory(${STM32_CORE_SOURCE_DIR}/I2C/IT)
add_subdirectory(${STM32_CORE_SOURCE_DIR}/I2C/DMA)
include_directories(${includes}
        ${I2C_POLLING_DIRECTORY}
        ${I2C_IT_DIRECTORY}
        ${I2C_DMA_DIRECTORY})
file(GLOB_RECURSE SOURCES ${sources}
        ${I2C_POLLING_SOURCES}
        ${I2C_IT_SOURCES}
        ${I2C_DMA_SOURCES})
add_executable(${PROJECT_NAME}.elf ${SOURCES} ${LINKER_SCRIPT}) # executable declaration should be before libraries
target_link_libraries(${PROJECT_NAME}.elf RingBuffer)   # add ring buffer if I2C_IT is used
target_link_libraries(${PROJECT_NAME}.elf Vector)   # add vector if I2C_DMA is used- Then Build -> Clean -> Rebuild Project
- Polling I2C code examples:
- TODO: add more examples
The USART peripheral is used to interconnect STM32 MPU devices with other systems, typically via RS232 or RS485 protocols.
- 
Start project with STM32CubeMX: - Configuration for Polling USART:
- Configuration for Interrupt USART:
- Configuration for DMA USART:
 
- 
Select: Project Manager -> Advanced Settings -> USART -> LL 
- 
Generate Code 
- 
Add sources to project: 
# add in CmakeLists_template.txt or directly to CmakeLists.txt
# link libraries
add_subdirectory(${STM32_CORE_SOURCE_DIR}/USART/DMA)
add_subdirectory(${STM32_CORE_SOURCE_DIR}/USART/IT)
add_subdirectory(${STM32_CORE_SOURCE_DIR}/USART/Polling)
include_directories(${includes}
        ${USART_POLLING_DIRECTORY}
        ${USART_IT_DIRECTORY}
        ${USART_DMA_DIRECTORY})
file(GLOB_RECURSE SOURCES ${sources}
        ${USART_POLLING_SOURCES}
        ${USART_IT_SOURCES}
        ${USART_DMA_SOURCES})
target_link_libraries(${PROJECT_NAME}.elf RingBuffer)   # add ring buffer if USART_IT is used
target_link_libraries(${PROJECT_NAME}.elf Vector)   # add vector if USART_DMA is used- Then Build -> Clean -> Rebuild Project
- Polling USART code example:
- Interrupt USART code example:
- DMA USART code example:
SPI is an acronym for (Serial Peripheral Interface) pronounced as “S-P-I” or “Spy”. Which is an interface bus typically used for serial communication between microcomputer systems and other devices, memories, and sensors.
- 
Start project with STM32CubeMX: - Configuration for Polling SPI:
- Configuration for Interrupt SPI:
- Configuration for DMA SPI:
 
- 
Select: Project Manager -> Advanced Settings -> SPI -> LL 
- 
Generate Code 
- 
Add sources to project: 
# add in CmakeLists_template.txt or directly to CmakeLists.txt
# link libraries
add_subdirectory(${STM32_CORE_SOURCE_DIR}/SPI/Polling)
add_subdirectory(${STM32_CORE_SOURCE_DIR}/SPI/IT)
add_subdirectory(${STM32_CORE_SOURCE_DIR}/SPI/DMA)
include_directories(${includes}
        ${SPI_POLLING_DIRECTORY}
        ${SPI_IT_DIRECTORY}
        ${SPI_DMA_DIRECTORY})
file(GLOB_RECURSE SOURCES ${sources}
        ${SPI_POLLING_SOURCES}
        ${SPI_IT_SOURCES}
        ${SPI_DMA_SOURCES})
target_link_libraries(${PROJECT_NAME}.elf RingBuffer)   # add ring buffer if SPI_IT is used
target_link_libraries(${PROJECT_NAME}.elf Vector)   # add vector if SPI_DMA is used- Then Build -> Clean -> Rebuild Project
- Polling SPI code example:
- Interrupt SPI code example:
- DMA SPI code example:
A real-time clock (RTC) is a computer clock that keeps track of the current time.
- 
Start project with STM32CubeMX: - Configuration for Polling SPI:
 
- 
Select: Project Manager -> Advanced Settings -> RTC -> LL 
- 
Generate Code 
- 
Add sources to project: 
# add in CmakeLists_template.txt or directly to CmakeLists.txt
# link libraries
CPMAddPackage(
        NAME GlobalDateTime
        GITHUB_REPOSITORY ximtech/GlobalDateTime
        GIT_TAG origin/main
        OPTIONS
        "ENABLE_TIME_ZONE_SUPPORT ON"
        "ENABLE_TIME_ZONE_HISTORIC_RULES OFF")
add_subdirectory(${STM32_CORE_SOURCE_DIR}/RTC)
include_directories(${includes} ${RTC_DIRECTORY})
file(GLOB_RECURSE SOURCES ${sources} ${RTC_SOURCES})
target_link_libraries(${PROJECT_NAME}.elf GlobalDateTime)   # library requires date-time library- Then Build -> Clean -> Rebuild Project