Add DMA and LiquidCrystal I2C support
- Implemented DMA functionality with a new dma.c and dma.h file. - Added LiquidCrystal I2C driver with liquidcrystal_i2c.c and liquidcrystal_i2c.h files. - Updated CMakeLists.txt to include dma.c and liquidcrystal_i2c.c in the build process. - Modified build.ninja and compile_commands.json to reflect the new source files. - Enhanced the main application to utilize the new DMA and LiquidCrystal I2C features.
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file dma.h
|
||||
* @brief This file contains all the function prototypes for
|
||||
* the dma.c file
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2025 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __DMA_H__
|
||||
#define __DMA_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "main.h"
|
||||
|
||||
/* DMA memory to memory transfer handles -------------------------------------*/
|
||||
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* USER CODE BEGIN Private defines */
|
||||
|
||||
/* USER CODE END Private defines */
|
||||
|
||||
void MX_DMA_Init(void);
|
||||
|
||||
/* USER CODE BEGIN Prototypes */
|
||||
|
||||
/* USER CODE END Prototypes */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __DMA_H__ */
|
||||
|
||||
Executable
+88
@@ -0,0 +1,88 @@
|
||||
#ifndef LIQUIDCRYSTAL_I2C_H_
|
||||
#define LIQUIDCRYSTAL_I2C_H_
|
||||
|
||||
#include "stm32f1xx_hal.h"
|
||||
|
||||
/* Command */
|
||||
#define LCD_CLEARDISPLAY 0x01
|
||||
#define LCD_RETURNHOME 0x02
|
||||
#define LCD_ENTRYMODESET 0x04
|
||||
#define LCD_DISPLAYCONTROL 0x08
|
||||
#define LCD_CURSORSHIFT 0x10
|
||||
#define LCD_FUNCTIONSET 0x20
|
||||
#define LCD_SETCGRAMADDR 0x40
|
||||
#define LCD_SETDDRAMADDR 0x80
|
||||
|
||||
/* Entry Mode */
|
||||
#define LCD_ENTRYRIGHT 0x00
|
||||
#define LCD_ENTRYLEFT 0x02
|
||||
#define LCD_ENTRYSHIFTINCREMENT 0x01
|
||||
#define LCD_ENTRYSHIFTDECREMENT 0x00
|
||||
|
||||
/* Display On/Off */
|
||||
#define LCD_DISPLAYON 0x04
|
||||
#define LCD_DISPLAYOFF 0x00
|
||||
#define LCD_CURSORON 0x02
|
||||
#define LCD_CURSOROFF 0x00
|
||||
#define LCD_BLINKON 0x01
|
||||
#define LCD_BLINKOFF 0x00
|
||||
|
||||
/* Cursor Shift */
|
||||
#define LCD_DISPLAYMOVE 0x08
|
||||
#define LCD_CURSORMOVE 0x00
|
||||
#define LCD_MOVERIGHT 0x04
|
||||
#define LCD_MOVELEFT 0x00
|
||||
|
||||
/* Function Set */
|
||||
#define LCD_8BITMODE 0x10
|
||||
#define LCD_4BITMODE 0x00
|
||||
#define LCD_2LINE 0x08
|
||||
#define LCD_1LINE 0x00
|
||||
#define LCD_5x10DOTS 0x04
|
||||
#define LCD_5x8DOTS 0x00
|
||||
|
||||
/* Backlight */
|
||||
#define LCD_BACKLIGHT 0x08
|
||||
#define LCD_NOBACKLIGHT 0x00
|
||||
|
||||
/* Enable Bit */
|
||||
#define ENABLE 0x04
|
||||
|
||||
/* Read Write Bit */
|
||||
#define RW 0x0
|
||||
|
||||
/* Register Select Bit */
|
||||
#define RS 0x01
|
||||
|
||||
/* Device I2C Address */
|
||||
#define DEVICE_ADDR (0x27 << 1)
|
||||
|
||||
void HD44780_Init(uint8_t rows);
|
||||
void HD44780_Clear();
|
||||
void HD44780_Home();
|
||||
void HD44780_NoDisplay();
|
||||
void HD44780_Display();
|
||||
void HD44780_NoBlink();
|
||||
void HD44780_Blink();
|
||||
void HD44780_NoCursor();
|
||||
void HD44780_Cursor();
|
||||
void HD44780_ScrollDisplayLeft();
|
||||
void HD44780_ScrollDisplayRight();
|
||||
void HD44780_PrintLeft();
|
||||
void HD44780_PrintRight();
|
||||
void HD44780_LeftToRight();
|
||||
void HD44780_RightToLeft();
|
||||
void HD44780_ShiftIncrement();
|
||||
void HD44780_ShiftDecrement();
|
||||
void HD44780_NoBacklight();
|
||||
void HD44780_Backlight();
|
||||
void HD44780_AutoScroll();
|
||||
void HD44780_NoAutoScroll();
|
||||
void HD44780_CreateSpecialChar(uint8_t, uint8_t[]);
|
||||
void HD44780_PrintSpecialChar(uint8_t);
|
||||
void HD44780_SetCursor(uint8_t, uint8_t);
|
||||
void HD44780_SetBacklight(uint8_t new_val);
|
||||
void HD44780_LoadCustomCharacter(uint8_t char_num, uint8_t *rows);
|
||||
void HD44780_PrintStr(const char[]);
|
||||
|
||||
#endif /* LIQUIDCRYSTAL_I2C_H_ */
|
||||
@@ -42,7 +42,7 @@
|
||||
/*#define HAL_CORTEX_MODULE_ENABLED */
|
||||
/*#define HAL_CRC_MODULE_ENABLED */
|
||||
/*#define HAL_DAC_MODULE_ENABLED */
|
||||
/*#define HAL_DMA_MODULE_ENABLED */
|
||||
#define HAL_DMA_MODULE_ENABLED
|
||||
/*#define HAL_ETH_MODULE_ENABLED */
|
||||
/*#define HAL_FLASH_MODULE_ENABLED */
|
||||
#define HAL_GPIO_MODULE_ENABLED
|
||||
|
||||
@@ -55,7 +55,8 @@ void SVC_Handler(void);
|
||||
void DebugMon_Handler(void);
|
||||
void PendSV_Handler(void);
|
||||
void SysTick_Handler(void);
|
||||
void I2C1_EV_IRQHandler(void);
|
||||
void DMA1_Channel6_IRQHandler(void);
|
||||
void DMA1_Channel7_IRQHandler(void);
|
||||
void USART1_IRQHandler(void);
|
||||
void USART2_IRQHandler(void);
|
||||
/* USER CODE BEGIN EFP */
|
||||
|
||||
Reference in New Issue
Block a user