diff --git a/bsp/stm32f411RE/Libraries/BSP/Adafruit_Shield/Release_Notes.html b/bsp/stm32f411RE/Libraries/BSP/Adafruit_Shield/Release_Notes.html deleted file mode 100644 index 0de6c275c1..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Adafruit_Shield/Release_Notes.html +++ /dev/null @@ -1,182 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - Release Notes for Adafruit_Shield Drivers - - - - - - - - - - -
-


-

-
- - - - - - -
- - - - - - - - - -
-

Back to Release page

-
-

Release -Notes for Adafruit_Shield  Drivers

-

Copyright -2015 STMicroelectronics

-

-
-

 

- - - - - - -
- - -

Update History

-

V2.0.1 / 04-November-2015

Main -Changes

- - - -
  • Fix GNU GCC warning on missing break instruction in SD_GetDataResponse()

V2.0.0 / 10-September-2015

Main -Changes

- - - -
  • Improve SD over SPI protocol implementation
  • Note: This new implementation requires to increase Heap_Size by 0x200 
  • Note: This driver version needs BSP Nucleo driver V2.0.0 and later

V1.1.0 / 22-July-2014

-

Main -Changes

- - - -
    -
  • Add new user API BSP_LCD_DrawBitmap() to draw a bitmap picture loaded in the STM32 MCU internal memory
  • -
  • Add new static API SetDisplayWindow(), needed by BSP_LCD_DrawBitmap()
    -
  • -
  • Update static API DrawChar()
  • -
  • Note: This driver version needs ST7735 component driver V1.1.0 and later.
    -
  • - -
-

V1.0.0 / 22-April-2014

Main -Changes

- -
  • First official release.

License

-
-
-Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met:
-
-
  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions -in binary form must reproduce the above copyright notice, this list of -conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of STMicroelectronics nor the names of its contributors may be used to endorse or promote products derived
    -
    -
-        from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- -
-
- - -
-
-

For -complete documentation on STM32 Microcontrollers -visit www.st.com/STM32

-
-

-
-
-

 

-
- - \ No newline at end of file diff --git a/bsp/stm32f411RE/Libraries/BSP/Adafruit_Shield/stm32_adafruit_lcd.c b/bsp/stm32f411RE/Libraries/BSP/Adafruit_Shield/stm32_adafruit_lcd.c deleted file mode 100644 index d1f6073334..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Adafruit_Shield/stm32_adafruit_lcd.c +++ /dev/null @@ -1,1060 +0,0 @@ -/** - ****************************************************************************** - * @file stm32_adafruit_lcd.c - * @author MCD Application Team - * @version V2.0.1 - * @date 04-November-2015 - * @brief This file includes the driver for Liquid Crystal Display (LCD) module - * mounted on the Adafruit 1.8" TFT LCD shield (reference ID 802), - * that is used with the STM32 Nucleo board through SPI interface. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* File Info : ----------------------------------------------------------------- - User NOTES -1. How To use this driver: --------------------------- - - The LCD st7735 component driver MUST be included with this driver. - -2. Driver description: ---------------------- - + Initialization steps: - o Initialize the LCD using the BSP_LCD_Init() function. - - + Display on LCD - o Clear the whole LCD using the BSP_LCD_Clear() function or only one specified - string line using the BSP_LCD_ClearStringLine() function. - o Display a character on the specified line and column using the BSP_LCD_DisplayChar() - function or a complete string line using the BSP_LCD_DisplayStringAtLine() function. - o Display a string line on the specified position (x,y in pixel) and align mode - using the BSP_LCD_DisplayStringAtLine() function. - o Draw and fill a basic shapes (dot, line, rectangle, circle, ellipse, ..) - on LCD using a set of functions. - -------------------------------------------------------------------------------*/ - -/* Includes ------------------------------------------------------------------*/ -#include "stm32_adafruit_lcd.h" -#include "../../../Utilities/Fonts/fonts.h" -#include "../../../Utilities/Fonts/font24.c" -#include "../../../Utilities/Fonts/font20.c" -#include "../../../Utilities/Fonts/font16.c" -#include "../../../Utilities/Fonts/font12.c" -#include "../../../Utilities/Fonts/font8.c" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32_ADAFRUIT - * @{ - */ - -/** @addtogroup STM32_ADAFRUIT_LCD - * @{ - */ - -/** @defgroup STM32_ADAFRUIT_LCD_Private_TypesDefinitions - * @{ - */ - -/** - * @} - */ - -/** @defgroup STM32_ADAFRUIT_LCD_Private_Defines - * @{ - */ -#define POLY_X(Z) ((int32_t)((Points + (Z))->X)) -#define POLY_Y(Z) ((int32_t)((Points + (Z))->Y)) -#define NULL (void *)0 - -#define MAX_HEIGHT_FONT 17 -#define MAX_WIDTH_FONT 24 -#define OFFSET_BITMAP 54 -/** - * @} - */ - -/** @defgroup STM32_ADAFRUIT_LCD_Private_Macros - * @{ - */ -#define ABS(X) ((X) > 0 ? (X) : -(X)) - -/** - * @} - */ - -/** @defgroup STM32_ADAFRUIT_LCD_Private_Variables - * @{ - */ -LCD_DrawPropTypeDef DrawProp; - -static LCD_DrvTypeDef *lcd_drv; - -/* Max size of bitmap will based on a font24 (17x24) */ -static uint8_t bitmap[MAX_HEIGHT_FONT*MAX_WIDTH_FONT*2+OFFSET_BITMAP] = {0}; - -/** - * @} - */ - -/** @defgroup STM32_ADAFRUIT_LCD_Private_FunctionPrototypes - * @{ - */ -static void DrawChar(uint16_t Xpos, uint16_t Ypos, const uint8_t *c); -static void FillTriangle(uint16_t x1, uint16_t x2, uint16_t x3, uint16_t y1, uint16_t y2, uint16_t y3); -static void SetDisplayWindow(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height); -/** - * @} - */ - - -/** @defgroup STM32_ADAFRUIT_LCD_Private_Functions - * @{ - */ - -/** - * @brief Initializes the LCD. - * @param None - * @retval LCD state - */ -uint8_t BSP_LCD_Init(void) -{ - uint8_t ret = LCD_ERROR; - - /* Default value for draw propriety */ - DrawProp.BackColor = 0xFFFF; - DrawProp.pFont = &Font24; - DrawProp.TextColor = 0x0000; - - lcd_drv = &st7735_drv; - - /* LCD Init */ - lcd_drv->Init(); - - /* Clear the LCD screen */ - BSP_LCD_Clear(LCD_COLOR_WHITE); - - /* Initialize the font */ - BSP_LCD_SetFont(&LCD_DEFAULT_FONT); - - ret = LCD_OK; - - return ret; -} - -/** - * @brief Gets the LCD X size. - * @param None - * @retval Used LCD X size - */ -uint32_t BSP_LCD_GetXSize(void) -{ - return(lcd_drv->GetLcdPixelWidth()); -} - -/** - * @brief Gets the LCD Y size. - * @param None - * @retval Used LCD Y size - */ -uint32_t BSP_LCD_GetYSize(void) -{ - return(lcd_drv->GetLcdPixelHeight()); -} - -/** - * @brief Gets the LCD text color. - * @param None - * @retval Used text color. - */ -uint16_t BSP_LCD_GetTextColor(void) -{ - return DrawProp.TextColor; -} - -/** - * @brief Gets the LCD background color. - * @param None - * @retval Used background color - */ -uint16_t BSP_LCD_GetBackColor(void) -{ - return DrawProp.BackColor; -} - -/** - * @brief Sets the LCD text color. - * @param Color: Text color code RGB(5-6-5) - * @retval None - */ -void BSP_LCD_SetTextColor(uint16_t Color) -{ - DrawProp.TextColor = Color; -} - -/** - * @brief Sets the LCD background color. - * @param Color: Background color code RGB(5-6-5) - * @retval None - */ -void BSP_LCD_SetBackColor(uint16_t Color) -{ - DrawProp.BackColor = Color; -} - -/** - * @brief Sets the LCD text font. - * @param fonts: Font to be used - * @retval None - */ -void BSP_LCD_SetFont(sFONT *pFonts) -{ - DrawProp.pFont = pFonts; -} - -/** - * @brief Gets the LCD text font. - * @param None - * @retval Used font - */ -sFONT *BSP_LCD_GetFont(void) -{ - return DrawProp.pFont; -} - -/** - * @brief Clears the hole LCD. - * @param Color: Color of the background - * @retval None - */ -void BSP_LCD_Clear(uint16_t Color) -{ - uint32_t counter = 0; - uint32_t color_backup = DrawProp.TextColor; - DrawProp.TextColor = Color; - - for(counter = 0; counter < BSP_LCD_GetYSize(); counter++) - { - BSP_LCD_DrawHLine(0, counter, BSP_LCD_GetXSize()); - } - DrawProp.TextColor = color_backup; - BSP_LCD_SetTextColor(DrawProp.TextColor); -} - -/** - * @brief Clears the selected line. - * @param Line: Line to be cleared - * This parameter can be one of the following values: - * @arg 0..9: if the Current fonts is Font16x24 - * @arg 0..19: if the Current fonts is Font12x12 or Font8x12 - * @arg 0..29: if the Current fonts is Font8x8 - * @retval None - */ -void BSP_LCD_ClearStringLine(uint16_t Line) -{ - uint32_t color_backup = DrawProp.TextColor; - DrawProp.TextColor = DrawProp.BackColor;; - - /* Draw a rectangle with background color */ - BSP_LCD_FillRect(0, (Line * DrawProp.pFont->Height), BSP_LCD_GetXSize(), DrawProp.pFont->Height); - - DrawProp.TextColor = color_backup; - BSP_LCD_SetTextColor(DrawProp.TextColor); -} - -/** - * @brief Displays one character. - * @param Xpos: Start column address - * @param Ypos: Line where to display the character shape. - * @param Ascii: Character ascii code - * This parameter must be a number between Min_Data = 0x20 and Max_Data = 0x7E - * @retval None - */ -void BSP_LCD_DisplayChar(uint16_t Xpos, uint16_t Ypos, uint8_t Ascii) -{ - DrawChar(Xpos, Ypos, &DrawProp.pFont->table[(Ascii-' ') *\ - DrawProp.pFont->Height * ((DrawProp.pFont->Width + 7) / 8)]); -} - -/** - * @brief Displays characters on the LCD. - * @param Xpos: X position (in pixel) - * @param Ypos: Y position (in pixel) - * @param Text: Pointer to string to display on LCD - * @param Mode: Display mode - * This parameter can be one of the following values: - * @arg CENTER_MODE - * @arg RIGHT_MODE - * @arg LEFT_MODE - * @retval None - */ -void BSP_LCD_DisplayStringAt(uint16_t Xpos, uint16_t Ypos, uint8_t *Text, Line_ModeTypdef Mode) -{ - uint16_t refcolumn = 1, i = 0; - uint32_t size = 0, xsize = 0; - uint8_t *ptr = Text; - - /* Get the text size */ - while (*ptr++) size ++ ; - - /* Characters number per line */ - xsize = (BSP_LCD_GetXSize()/DrawProp.pFont->Width); - - switch (Mode) - { - case CENTER_MODE: - { - refcolumn = Xpos + ((xsize - size)* DrawProp.pFont->Width) / 2; - break; - } - case LEFT_MODE: - { - refcolumn = Xpos; - break; - } - case RIGHT_MODE: - { - refcolumn = - Xpos + ((xsize - size)*DrawProp.pFont->Width); - break; - } - default: - { - refcolumn = Xpos; - break; - } - } - - /* Send the string character by character on lCD */ - while ((*Text != 0) & (((BSP_LCD_GetXSize() - (i*DrawProp.pFont->Width)) & 0xFFFF) >= DrawProp.pFont->Width)) - { - /* Display one character on LCD */ - BSP_LCD_DisplayChar(refcolumn, Ypos, *Text); - /* Decrement the column position by 16 */ - refcolumn += DrawProp.pFont->Width; - /* Point on the next character */ - Text++; - i++; - } -} - -/** - * @brief Displays a character on the LCD. - * @param Line: Line where to display the character shape - * This parameter can be one of the following values: - * @arg 0..19: if the Current fonts is Font8 - * @arg 0..12: if the Current fonts is Font12 - * @arg 0...9: if the Current fonts is Font16 - * @arg 0...7: if the Current fonts is Font20 - * @arg 0...5: if the Current fonts is Font24 - * @param ptr: Pointer to string to display on LCD - * @retval None - */ -void BSP_LCD_DisplayStringAtLine(uint16_t Line, uint8_t *ptr) -{ - BSP_LCD_DisplayStringAt(0, LINE(Line), ptr, LEFT_MODE); -} - -/** - * @brief Draws a pixel on LCD. - * @param Xpos: X position - * @param Ypos: Y position - * @param RGB_Code: Pixel color in RGB mode (5-6-5) - * @retval None - */ -void BSP_LCD_DrawPixel(uint16_t Xpos, uint16_t Ypos, uint16_t RGB_Code) -{ - if(lcd_drv->WritePixel != NULL) - { - lcd_drv->WritePixel(Xpos, Ypos, RGB_Code); - } -} - -/** - * @brief Draws an horizontal line. - * @param Xpos: X position - * @param Ypos: Y position - * @param Length: Line length - * @retval None - */ -void BSP_LCD_DrawHLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length) -{ - uint32_t index = 0; - - if(lcd_drv->DrawHLine != NULL) - { - lcd_drv->DrawHLine(DrawProp.TextColor, Xpos, Ypos, Length); - } - else - { - for(index = 0; index < Length; index++) - { - BSP_LCD_DrawPixel((Xpos + index), Ypos, DrawProp.TextColor); - } - } -} - -/** - * @brief Draws a vertical line. - * @param Xpos: X position - * @param Ypos: Y position - * @param Length: Line length - * @retval None - */ -void BSP_LCD_DrawVLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length) -{ - uint32_t index = 0; - - if(lcd_drv->DrawVLine != NULL) - { - lcd_drv->DrawVLine(DrawProp.TextColor, Xpos, Ypos, Length); - } - else - { - for(index = 0; index < Length; index++) - { - BSP_LCD_DrawPixel(Xpos, Ypos + index, DrawProp.TextColor); - } - } -} - -/** - * @brief Draws an uni-line (between two points). - * @param x1: Point 1 X position - * @param y1: Point 1 Y position - * @param x2: Point 2 X position - * @param y2: Point 2 Y position - * @retval None - */ -void BSP_LCD_DrawLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) -{ - int16_t deltax = 0, deltay = 0, x = 0, y = 0, xinc1 = 0, xinc2 = 0, - yinc1 = 0, yinc2 = 0, den = 0, num = 0, numadd = 0, numpixels = 0, - curpixel = 0; - - deltax = ABS(x2 - x1); /* The difference between the x's */ - deltay = ABS(y2 - y1); /* The difference between the y's */ - x = x1; /* Start x off at the first pixel */ - y = y1; /* Start y off at the first pixel */ - - if (x2 >= x1) /* The x-values are increasing */ - { - xinc1 = 1; - xinc2 = 1; - } - else /* The x-values are decreasing */ - { - xinc1 = -1; - xinc2 = -1; - } - - if (y2 >= y1) /* The y-values are increasing */ - { - yinc1 = 1; - yinc2 = 1; - } - else /* The y-values are decreasing */ - { - yinc1 = -1; - yinc2 = -1; - } - - if (deltax >= deltay) /* There is at least one x-value for every y-value */ - { - xinc1 = 0; /* Don't change the x when numerator >= denominator */ - yinc2 = 0; /* Don't change the y for every iteration */ - den = deltax; - num = deltax / 2; - numadd = deltay; - numpixels = deltax; /* There are more x-values than y-values */ - } - else /* There is at least one y-value for every x-value */ - { - xinc2 = 0; /* Don't change the x for every iteration */ - yinc1 = 0; /* Don't change the y when numerator >= denominator */ - den = deltay; - num = deltay / 2; - numadd = deltax; - numpixels = deltay; /* There are more y-values than x-values */ - } - - for (curpixel = 0; curpixel <= numpixels; curpixel++) - { - BSP_LCD_DrawPixel(x, y, DrawProp.TextColor); /* Draw the current pixel */ - num += numadd; /* Increase the numerator by the top of the fraction */ - if (num >= den) /* Check if numerator >= denominator */ - { - num -= den; /* Calculate the new numerator value */ - x += xinc1; /* Change the x as appropriate */ - y += yinc1; /* Change the y as appropriate */ - } - x += xinc2; /* Change the x as appropriate */ - y += yinc2; /* Change the y as appropriate */ - } -} - -/** - * @brief Draws a rectangle. - * @param Xpos: X position - * @param Ypos: Y position - * @param Width: Rectangle width - * @param Height: Rectangle height - * @retval None - */ -void BSP_LCD_DrawRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height) -{ - /* Draw horizontal lines */ - BSP_LCD_DrawHLine(Xpos, Ypos, Width); - BSP_LCD_DrawHLine(Xpos, (Ypos+ Height), Width); - - /* Draw vertical lines */ - BSP_LCD_DrawVLine(Xpos, Ypos, Height); - BSP_LCD_DrawVLine((Xpos + Width), Ypos, Height); -} - -/** - * @brief Draws a circle. - * @param Xpos: X position - * @param Ypos: Y position - * @param Radius: Circle radius - * @retval None - */ -void BSP_LCD_DrawCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius) -{ - int32_t D; /* Decision Variable */ - uint32_t CurX; /* Current X Value */ - uint32_t CurY; /* Current Y Value */ - - D = 3 - (Radius << 1); - CurX = 0; - CurY = Radius; - - while (CurX <= CurY) - { - BSP_LCD_DrawPixel((Xpos + CurX), (Ypos - CurY), DrawProp.TextColor); - - BSP_LCD_DrawPixel((Xpos - CurX), (Ypos - CurY), DrawProp.TextColor); - - BSP_LCD_DrawPixel((Xpos + CurY), (Ypos - CurX), DrawProp.TextColor); - - BSP_LCD_DrawPixel((Xpos - CurY), (Ypos - CurX), DrawProp.TextColor); - - BSP_LCD_DrawPixel((Xpos + CurX), (Ypos + CurY), DrawProp.TextColor); - - BSP_LCD_DrawPixel((Xpos - CurX), (Ypos + CurY), DrawProp.TextColor); - - BSP_LCD_DrawPixel((Xpos + CurY), (Ypos + CurX), DrawProp.TextColor); - - BSP_LCD_DrawPixel((Xpos - CurY), (Ypos + CurX), DrawProp.TextColor); - - /* Initialize the font */ - BSP_LCD_SetFont(&LCD_DEFAULT_FONT); - - if (D < 0) - { - D += (CurX << 2) + 6; - } - else - { - D += ((CurX - CurY) << 2) + 10; - CurY--; - } - CurX++; - } -} - -/** - * @brief Draws an poly-line (between many points). - * @param Points: Pointer to the points array - * @param PointCount: Number of points - * @retval None - */ -void BSP_LCD_DrawPolygon(pPoint Points, uint16_t PointCount) -{ - int16_t X = 0, Y = 0; - - if(PointCount < 2) - { - return; - } - - BSP_LCD_DrawLine(Points->X, Points->Y, (Points+PointCount-1)->X, (Points+PointCount-1)->Y); - - while(--PointCount) - { - X = Points->X; - Y = Points->Y; - Points++; - BSP_LCD_DrawLine(X, Y, Points->X, Points->Y); - } -} - -/** - * @brief Draws an ellipse on LCD. - * @param Xpos: X position - * @param Ypos: Y position - * @param XRadius: Ellipse X radius - * @param YRadius: Ellipse Y radius - * @retval None - */ -void BSP_LCD_DrawEllipse(int Xpos, int Ypos, int XRadius, int YRadius) -{ - int x = 0, y = -YRadius, err = 2-2*XRadius, e2; - float K = 0, rad1 = 0, rad2 = 0; - - rad1 = XRadius; - rad2 = YRadius; - - K = (float)(rad2/rad1); - - do { - BSP_LCD_DrawPixel((Xpos-(uint16_t)(x/K)), (Ypos+y), DrawProp.TextColor); - BSP_LCD_DrawPixel((Xpos+(uint16_t)(x/K)), (Ypos+y), DrawProp.TextColor); - BSP_LCD_DrawPixel((Xpos+(uint16_t)(x/K)), (Ypos-y), DrawProp.TextColor); - BSP_LCD_DrawPixel((Xpos-(uint16_t)(x/K)), (Ypos-y), DrawProp.TextColor); - - e2 = err; - if (e2 <= x) { - err += ++x*2+1; - if (-y == x && e2 <= y) e2 = 0; - } - if (e2 > y) err += ++y*2+1; - } - while (y <= 0); -} - -/** - * @brief Draws a bitmap picture loaded in the STM32 MCU internal memory. - * @param Xpos: Bmp X position in the LCD - * @param Ypos: Bmp Y position in the LCD - * @param pBmp: Pointer to Bmp picture address - * @retval None - */ -void BSP_LCD_DrawBitmap(uint16_t Xpos, uint16_t Ypos, uint8_t *pBmp) -{ - uint32_t height = 0, width = 0; - - /* Read bitmap width */ - width = *(uint16_t *) (pBmp + 18); - width |= (*(uint16_t *) (pBmp + 20)) << 16; - - /* Read bitmap height */ - height = *(uint16_t *) (pBmp + 22); - height |= (*(uint16_t *) (pBmp + 24)) << 16; - - /* Remap Ypos, st7735 works with inverted X in case of bitmap */ - /* X = 0, cursor is on Top corner */ - if(lcd_drv == &st7735_drv) - { - Ypos = BSP_LCD_GetYSize() - Ypos - height; - } - - SetDisplayWindow(Xpos, Ypos, width, height); - - if(lcd_drv->DrawBitmap != NULL) - { - lcd_drv->DrawBitmap(Xpos, Ypos, pBmp); - } - SetDisplayWindow(0, 0, BSP_LCD_GetXSize(), BSP_LCD_GetYSize()); -} - -/** - * @brief Draws a full rectangle. - * @param Xpos: X position - * @param Ypos: Y position - * @param Width: Rectangle width - * @param Height: Rectangle height - * @retval None - */ -void BSP_LCD_FillRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height) -{ - BSP_LCD_SetTextColor(DrawProp.TextColor); - do - { - BSP_LCD_DrawHLine(Xpos, Ypos++, Width); - } - while(Height--); -} - -/** - * @brief Draws a full circle. - * @param Xpos: X position - * @param Ypos: Y position - * @param Radius: Circle radius - * @retval None - */ -void BSP_LCD_FillCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius) -{ - int32_t D; /* Decision Variable */ - uint32_t CurX; /* Current X Value */ - uint32_t CurY; /* Current Y Value */ - - D = 3 - (Radius << 1); - - CurX = 0; - CurY = Radius; - - BSP_LCD_SetTextColor(DrawProp.TextColor); - - while (CurX <= CurY) - { - if(CurY > 0) - { - BSP_LCD_DrawHLine(Xpos - CurY, Ypos + CurX, 2*CurY); - BSP_LCD_DrawHLine(Xpos - CurY, Ypos - CurX, 2*CurY); - } - - if(CurX > 0) - { - BSP_LCD_DrawHLine(Xpos - CurX, Ypos - CurY, 2*CurX); - BSP_LCD_DrawHLine(Xpos - CurX, Ypos + CurY, 2*CurX); - } - if (D < 0) - { - D += (CurX << 2) + 6; - } - else - { - D += ((CurX - CurY) << 2) + 10; - CurY--; - } - CurX++; - } - - BSP_LCD_SetTextColor(DrawProp.TextColor); - BSP_LCD_DrawCircle(Xpos, Ypos, Radius); -} - -/** - * @brief Draws a full poly-line (between many points). - * @param Points: Pointer to the points array - * @param PointCount: Number of points - * @retval None - */ -void BSP_LCD_FillPolygon(pPoint Points, uint16_t PointCount) -{ - int16_t X = 0, Y = 0, X2 = 0, Y2 = 0, X_center = 0, Y_center = 0, X_first = 0, Y_first = 0, pixelX = 0, pixelY = 0, counter = 0; - uint16_t IMAGE_LEFT = 0, IMAGE_RIGHT = 0, IMAGE_TOP = 0, IMAGE_BOTTOM = 0; - - IMAGE_LEFT = IMAGE_RIGHT = Points->X; - IMAGE_TOP= IMAGE_BOTTOM = Points->Y; - - for(counter = 1; counter < PointCount; counter++) - { - pixelX = POLY_X(counter); - if(pixelX < IMAGE_LEFT) - { - IMAGE_LEFT = pixelX; - } - if(pixelX > IMAGE_RIGHT) - { - IMAGE_RIGHT = pixelX; - } - - pixelY = POLY_Y(counter); - if(pixelY < IMAGE_TOP) - { - IMAGE_TOP = pixelY; - } - if(pixelY > IMAGE_BOTTOM) - { - IMAGE_BOTTOM = pixelY; - } - } - - if(PointCount < 2) - { - return; - } - - X_center = (IMAGE_LEFT + IMAGE_RIGHT)/2; - Y_center = (IMAGE_BOTTOM + IMAGE_TOP)/2; - - X_first = Points->X; - Y_first = Points->Y; - - while(--PointCount) - { - X = Points->X; - Y = Points->Y; - Points++; - X2 = Points->X; - Y2 = Points->Y; - - FillTriangle(X, X2, X_center, Y, Y2, Y_center); - FillTriangle(X, X_center, X2, Y, Y_center, Y2); - FillTriangle(X_center, X2, X, Y_center, Y2, Y); - } - - FillTriangle(X_first, X2, X_center, Y_first, Y2, Y_center); - FillTriangle(X_first, X_center, X2, Y_first, Y_center, Y2); - FillTriangle(X_center, X2, X_first, Y_center, Y2, Y_first); -} - -/** - * @brief Draws a full ellipse. - * @param Xpos: X position - * @param Ypos: Y position - * @param XRadius: Ellipse X radius - * @param YRadius: Ellipse Y radius - * @retval None - */ -void BSP_LCD_FillEllipse(int Xpos, int Ypos, int XRadius, int YRadius) -{ - int x = 0, y = -YRadius, err = 2-2*XRadius, e2; - float K = 0, rad1 = 0, rad2 = 0; - - rad1 = XRadius; - rad2 = YRadius; - - K = (float)(rad2/rad1); - - do - { - BSP_LCD_DrawHLine((Xpos-(uint16_t)(x/K)), (Ypos+y), (2*(uint16_t)(x/K) + 1)); - BSP_LCD_DrawHLine((Xpos-(uint16_t)(x/K)), (Ypos-y), (2*(uint16_t)(x/K) + 1)); - - e2 = err; - if (e2 <= x) - { - err += ++x*2+1; - if (-y == x && e2 <= y) e2 = 0; - } - if (e2 > y) err += ++y*2+1; - } - while (y <= 0); -} - -/** - * @brief Enables the display. - * @param None - * @retval None - */ -void BSP_LCD_DisplayOn(void) -{ - lcd_drv->DisplayOn(); -} - -/** - * @brief Disables the display. - * @param None - * @retval None - */ -void BSP_LCD_DisplayOff(void) -{ - lcd_drv->DisplayOff(); -} - -/******************************************************************************* - Static Functions -*******************************************************************************/ - -/** - * @brief Draws a character on LCD. - * @param Xpos: Line where to display the character shape - * @param Ypos: Start column address - * @param pChar: Pointer to the character data - * @retval None - */ -static void DrawChar(uint16_t Xpos, uint16_t Ypos, const uint8_t *pChar) -{ - uint32_t counterh = 0, counterw = 0, index = 0; - uint16_t height = 0, width = 0; - uint8_t offset = 0; - uint8_t *pchar = NULL; - uint32_t line = 0; - - height = DrawProp.pFont->Height; - width = DrawProp.pFont->Width; - - /* Fill bitmap header*/ - *(uint16_t *) (bitmap + 2) = (uint16_t)(height*width*2+OFFSET_BITMAP); - *(uint16_t *) (bitmap + 4) = (uint16_t)((height*width*2+OFFSET_BITMAP)>>16); - *(uint16_t *) (bitmap + 10) = OFFSET_BITMAP; - *(uint16_t *) (bitmap + 18) = (uint16_t)(width); - *(uint16_t *) (bitmap + 20) = (uint16_t)((width)>>16); - *(uint16_t *) (bitmap + 22) = (uint16_t)(height); - *(uint16_t *) (bitmap + 24) = (uint16_t)((height)>>16); - - offset = 8 *((width + 7)/8) - width ; - - for(counterh = 0; counterh < height; counterh++) - { - pchar = ((uint8_t *)pChar + (width + 7)/8 * counterh); - - if(((width + 7)/8) == 3) - { - line = (pchar[0]<< 16) | (pchar[1]<< 8) | pchar[2]; - } - - if(((width + 7)/8) == 2) - { - line = (pchar[0]<< 8) | pchar[1]; - } - - if(((width + 7)/8) == 1) - { - line = pchar[0]; - } - - for (counterw = 0; counterw < width; counterw++) - { - /* Image in the bitmap is written from the bottom to the top */ - /* Need to invert image in the bitmap */ - index = (((height-counterh-1)*width)+(counterw))*2+OFFSET_BITMAP; - if(line & (1 << (width- counterw + offset- 1))) - { - bitmap[index] = (uint8_t)DrawProp.TextColor; - bitmap[index+1] = (uint8_t)(DrawProp.TextColor >> 8); - } - else - { - bitmap[index] = (uint8_t)DrawProp.BackColor; - bitmap[index+1] = (uint8_t)(DrawProp.BackColor >> 8); - } - } - } - - BSP_LCD_DrawBitmap(Xpos, Ypos, bitmap); -} - -/** - * @brief Fills a triangle (between 3 points). - * @param Points: Pointer to the points array - * @param x1: Point 1 X position - * @param y1: Point 1 Y position - * @param x2: Point 2 X position - * @param y2: Point 2 Y position - * @param x3: Point 3 X position - * @param y3: Point 3 Y position - * @retval None - */ -static void FillTriangle(uint16_t x1, uint16_t x2, uint16_t x3, uint16_t y1, uint16_t y2, uint16_t y3) -{ - int16_t deltax = 0, deltay = 0, x = 0, y = 0, xinc1 = 0, xinc2 = 0, - yinc1 = 0, yinc2 = 0, den = 0, num = 0, numadd = 0, numpixels = 0, - curpixel = 0; - - deltax = ABS(x2 - x1); /* The difference between the x's */ - deltay = ABS(y2 - y1); /* The difference between the y's */ - x = x1; /* Start x off at the first pixel */ - y = y1; /* Start y off at the first pixel */ - - if (x2 >= x1) /* The x-values are increasing */ - { - xinc1 = 1; - xinc2 = 1; - } - else /* The x-values are decreasing */ - { - xinc1 = -1; - xinc2 = -1; - } - - if (y2 >= y1) /* The y-values are increasing */ - { - yinc1 = 1; - yinc2 = 1; - } - else /* The y-values are decreasing */ - { - yinc1 = -1; - yinc2 = -1; - } - - if (deltax >= deltay) /* There is at least one x-value for every y-value */ - { - xinc1 = 0; /* Don't change the x when numerator >= denominator */ - yinc2 = 0; /* Don't change the y for every iteration */ - den = deltax; - num = deltax / 2; - numadd = deltay; - numpixels = deltax; /* There are more x-values than y-values */ - } - else /* There is at least one y-value for every x-value */ - { - xinc2 = 0; /* Don't change the x for every iteration */ - yinc1 = 0; /* Don't change the y when numerator >= denominator */ - den = deltay; - num = deltay / 2; - numadd = deltax; - numpixels = deltay; /* There are more y-values than x-values */ - } - - for (curpixel = 0; curpixel <= numpixels; curpixel++) - { - BSP_LCD_DrawLine(x, y, x3, y3); - - num += numadd; /* Increase the numerator by the top of the fraction */ - if (num >= den) /* Check if numerator >= denominator */ - { - num -= den; /* Calculate the new numerator value */ - x += xinc1; /* Change the x as appropriate */ - y += yinc1; /* Change the y as appropriate */ - } - x += xinc2; /* Change the x as appropriate */ - y += yinc2; /* Change the y as appropriate */ - } -} - -/** - * @brief Sets display window. - * @param LayerIndex: layer index - * @param Xpos: LCD X position - * @param Ypos: LCD Y position - * @param Width: LCD window width - * @param Height: LCD window height - * @retval None - */ -static void SetDisplayWindow(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height) -{ - if(lcd_drv->SetDisplayWindow != NULL) - { - lcd_drv->SetDisplayWindow(Xpos, Ypos, Width, Height); - } -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/Adafruit_Shield/stm32_adafruit_lcd.h b/bsp/stm32f411RE/Libraries/BSP/Adafruit_Shield/stm32_adafruit_lcd.h deleted file mode 100644 index 2bc7f069c8..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Adafruit_Shield/stm32_adafruit_lcd.h +++ /dev/null @@ -1,197 +0,0 @@ -/** - ****************************************************************************** - * @file stm32_adafruit_lcd.h - * @author MCD Application Team - * @version V2.0.1 - * @date 04-November-2015 - * @brief This file contains the common defines and functions prototypes for - * the stm32_adafruit_lcd.c driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32_ADAFRUIT_LCD_H -#define __STM32_ADAFRUIT_LCD_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "../Components/st7735/st7735.h" -#include "../../../Utilities/Fonts/fonts.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32_ADAFRUIT - * @{ - */ - -/** @addtogroup STM32_ADAFRUIT_LCD - * @{ - */ - - -/** @defgroup STM32_ADAFRUIT_LCD_Exported_Types - * @{ - */ - -/** - * @brief Draw Properties structures definition - */ -typedef struct -{ - uint32_t TextColor; - uint32_t BackColor; - sFONT *pFont; - -}LCD_DrawPropTypeDef; - -/** - * @brief Point structures definition - */ -typedef struct -{ - int16_t X; - int16_t Y; - -}Point, * pPoint; - -/** - * @brief Line mode structures definition - */ -typedef enum -{ - CENTER_MODE = 0x01, /*!< Center mode */ - RIGHT_MODE = 0x02, /*!< Right mode */ - LEFT_MODE = 0x03 /*!< Left mode */ - -}Line_ModeTypdef; - -/** - * @} - */ - -/** @defgroup STM32_ADAFRUIT_LCD_Exported_Constants - * @{ - */ - -#define __IO volatile - -/** - * @brief LCD status structure definition - */ -#define LCD_OK 0x00 -#define LCD_ERROR 0x01 -#define LCD_TIMEOUT 0x02 - -/** - * @brief LCD color - */ -#define LCD_COLOR_BLACK 0x0000 -#define LCD_COLOR_GREY 0xF7DE -#define LCD_COLOR_BLUE 0x001F -#define LCD_COLOR_RED 0xF800 -#define LCD_COLOR_GREEN 0x07E0 -#define LCD_COLOR_CYAN 0x07FF -#define LCD_COLOR_MAGENTA 0xF81F -#define LCD_COLOR_YELLOW 0xFFE0 -#define LCD_COLOR_WHITE 0xFFFF - -/** - * @brief LCD default font - */ -#define LCD_DEFAULT_FONT Font8 - -/** - * @} - */ - -/** @defgroup STM32_ADAFRUIT_LCD_Exported_Functions - * @{ - */ -uint8_t BSP_LCD_Init(void); -uint32_t BSP_LCD_GetXSize(void); -uint32_t BSP_LCD_GetYSize(void); - -uint16_t BSP_LCD_GetTextColor(void); -uint16_t BSP_LCD_GetBackColor(void); -void BSP_LCD_SetTextColor(__IO uint16_t Color); -void BSP_LCD_SetBackColor(__IO uint16_t Color); -void BSP_LCD_SetFont(sFONT *fonts); -sFONT *BSP_LCD_GetFont(void); - -void BSP_LCD_Clear(uint16_t Color); -void BSP_LCD_ClearStringLine(uint16_t Line); -void BSP_LCD_DisplayStringAtLine(uint16_t Line, uint8_t *ptr); -void BSP_LCD_DisplayStringAt(uint16_t Xpos, uint16_t Ypos, uint8_t *Text, Line_ModeTypdef Mode); -void BSP_LCD_DisplayChar(uint16_t Xpos, uint16_t Ypos, uint8_t Ascii); - -void BSP_LCD_DrawPixel(uint16_t Xpos, uint16_t Ypos, uint16_t RGB_Code); -void BSP_LCD_DrawHLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length); -void BSP_LCD_DrawVLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length); -void BSP_LCD_DrawLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2); -void BSP_LCD_DrawRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height); -void BSP_LCD_DrawCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius); -void BSP_LCD_DrawPolygon(pPoint Points, uint16_t PointCount); -void BSP_LCD_DrawEllipse(int Xpos, int Ypos, int XRadius, int YRadius); -void BSP_LCD_DrawBitmap(uint16_t Xpos, uint16_t Ypos, uint8_t *pBmp); -void BSP_LCD_FillRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height); -void BSP_LCD_FillCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius); -void BSP_LCD_FillPolygon(pPoint Points, uint16_t PointCount); -void BSP_LCD_FillEllipse(int Xpos, int Ypos, int XRadius, int YRadius); - -void BSP_LCD_DisplayOff(void); -void BSP_LCD_DisplayOn(void); - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32_ADAFRUIT_LCD_H */ -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/Adafruit_Shield/stm32_adafruit_sd.c b/bsp/stm32f411RE/Libraries/BSP/Adafruit_Shield/stm32_adafruit_sd.c deleted file mode 100644 index cc2977546a..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Adafruit_Shield/stm32_adafruit_sd.c +++ /dev/null @@ -1,1030 +0,0 @@ -/** - ****************************************************************************** - * @file stm32_adafruit_sd.c - * @author MCD Application Team - * @version V2.0.1 - * @date 04-November-2015 - * @brief This file provides a set of functions needed to manage the SD card - * mounted on the Adafruit 1.8" TFT LCD shield (reference ID 802), - * that is used with the STM32 Nucleo board through SPI interface. - * It implements a high level communication layer for read and write - * from/to this memory. The needed STM32XXxx hardware resources (SPI and - * GPIO) are defined in stm32XXxx_nucleo.h file, and the initialization is - * performed in SD_IO_Init() function declared in stm32XXxx_nucleo.c - * file. - * You can easily tailor this driver to any other development board, - * by just adapting the defines for hardware resources and - * SD_IO_Init() function. - * - * +-------------------------------------------------------+ - * | Pin assignment | - * +-------------------------+---------------+-------------+ - * | STM32XXxx SPI Pins | SD | Pin | - * +-------------------------+---------------+-------------+ - * | SD_SPI_CS_PIN | ChipSelect | 1 | - * | SD_SPI_MOSI_PIN / MOSI | DataIn | 2 | - * | | GND | 3 (0 V) | - * | | VDD | 4 (3.3 V)| - * | SD_SPI_SCK_PIN / SCLK | Clock | 5 | - * | | GND | 6 (0 V) | - * | SD_SPI_MISO_PIN / MISO | DataOut | 7 | - * +-------------------------+---------------+-------------+ - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* File Info : ----------------------------------------------------------------- - User NOTES -1. How to use this driver: --------------------------- - - This driver does not need a specific component driver for the micro SD device - to be included with. - -2. Driver description: ---------------------- - + Initialization steps: - o Initialize the micro SD card using the BSP_SD_Init() function. - o Checking the SD card presence is not managed because SD detection pin is - not physically mapped on the Adafruit shield. - o The function BSP_SD_GetCardInfo() is used to get the micro SD card information - which is stored in the structure "SD_CardInfo". - - + Micro SD card operations - o The micro SD card can be accessed with read/write block(s) operations once - it is ready for access. The access can be performed in polling - mode by calling the functions BSP_SD_ReadBlocks()/BSP_SD_WriteBlocks() - - o The SD erase block(s) is performed using the function BSP_SD_Erase() with - specifying the number of blocks to erase. - o The SD runtime status is returned when calling the function BSP_SD_GetStatus(). - -------------------------------------------------------------------------------*/ - -/* Includes ------------------------------------------------------------------*/ -#include "stm32_adafruit_sd.h" -#include "stdlib.h" -#include "string.h" -#include "stdio.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32_ADAFRUIT - * @{ - */ - -/** @defgroup STM32_ADAFRUIT_SD - * @{ - */ - -/* Private typedef -----------------------------------------------------------*/ - -/** @defgroup STM32_ADAFRUIT_SD_Private_Types_Definitions - * @{ - */ -typedef struct { - uint8_t r1; - uint8_t r2; - uint8_t r3; - uint8_t r4; - uint8_t r5; -} SD_CmdAnswer_typedef; - -/** - * @} - */ - -/* Private define ------------------------------------------------------------*/ - -/** @defgroup STM32_ADAFRUIT_SD_Private_Defines - * @{ - */ -#define SD_DUMMY_BYTE 0xFF - -#define SD_MAX_FRAME_LENGTH 17 /* Lenght = 16 + 1 */ -#define SD_CMD_LENGTH 6 - -#define SD_MAX_TRY 100 /* Number of try */ - -#define SD_CSD_STRUCT_V1 0x2 /* CSD struct version V1 */ -#define SD_CSD_STRUCT_V2 0x1 /* CSD struct version V2 */ - - -/** - * @brief SD ansewer format - */ -typedef enum { - SD_ANSWER_R1_EXPECTED, - SD_ANSWER_R1B_EXPECTED, - SD_ANSWER_R2_EXPECTED, - SD_ANSWER_R3_EXPECTED, - SD_ANSWER_R4R5_EXPECTED, - SD_ANSWER_R7_EXPECTED, -}SD_Answer_type; - -/** - * @brief Start Data tokens: - * Tokens (necessary because at nop/idle (and CS active) only 0xff is - * on the data/command line) - */ -#define SD_TOKEN_START_DATA_SINGLE_BLOCK_READ 0xFE /* Data token start byte, Start Single Block Read */ -#define SD_TOKEN_START_DATA_MULTIPLE_BLOCK_READ 0xFE /* Data token start byte, Start Multiple Block Read */ -#define SD_TOKEN_START_DATA_SINGLE_BLOCK_WRITE 0xFE /* Data token start byte, Start Single Block Write */ -#define SD_TOKEN_START_DATA_MULTIPLE_BLOCK_WRITE 0xFD /* Data token start byte, Start Multiple Block Write */ -#define SD_TOKEN_STOP_DATA_MULTIPLE_BLOCK_WRITE 0xFD /* Data toke stop byte, Stop Multiple Block Write */ - -/** - * @brief Commands: CMDxx = CMD-number | 0x40 - */ -#define SD_CMD_GO_IDLE_STATE 0 /* CMD0 = 0x40 */ -#define SD_CMD_SEND_OP_COND 1 /* CMD1 = 0x41 */ -#define SD_CMD_SEND_IF_COND 8 /* CMD8 = 0x48 */ -#define SD_CMD_SEND_CSD 9 /* CMD9 = 0x49 */ -#define SD_CMD_SEND_CID 10 /* CMD10 = 0x4A */ -#define SD_CMD_STOP_TRANSMISSION 12 /* CMD12 = 0x4C */ -#define SD_CMD_SEND_STATUS 13 /* CMD13 = 0x4D */ -#define SD_CMD_SET_BLOCKLEN 16 /* CMD16 = 0x50 */ -#define SD_CMD_READ_SINGLE_BLOCK 17 /* CMD17 = 0x51 */ -#define SD_CMD_READ_MULT_BLOCK 18 /* CMD18 = 0x52 */ -#define SD_CMD_SET_BLOCK_COUNT 23 /* CMD23 = 0x57 */ -#define SD_CMD_WRITE_SINGLE_BLOCK 24 /* CMD24 = 0x58 */ -#define SD_CMD_WRITE_MULT_BLOCK 25 /* CMD25 = 0x59 */ -#define SD_CMD_PROG_CSD 27 /* CMD27 = 0x5B */ -#define SD_CMD_SET_WRITE_PROT 28 /* CMD28 = 0x5C */ -#define SD_CMD_CLR_WRITE_PROT 29 /* CMD29 = 0x5D */ -#define SD_CMD_SEND_WRITE_PROT 30 /* CMD30 = 0x5E */ -#define SD_CMD_SD_ERASE_GRP_START 32 /* CMD32 = 0x60 */ -#define SD_CMD_SD_ERASE_GRP_END 33 /* CMD33 = 0x61 */ -#define SD_CMD_UNTAG_SECTOR 34 /* CMD34 = 0x62 */ -#define SD_CMD_ERASE_GRP_START 35 /* CMD35 = 0x63 */ -#define SD_CMD_ERASE_GRP_END 36 /* CMD36 = 0x64 */ -#define SD_CMD_UNTAG_ERASE_GROUP 37 /* CMD37 = 0x65 */ -#define SD_CMD_ERASE 38 /* CMD38 = 0x66 */ -#define SD_CMD_SD_APP_OP_COND 41 /* CMD41 = 0x69 */ -#define SD_CMD_APP_CMD 55 /* CMD55 = 0x77 */ -#define SD_CMD_READ_OCR 58 /* CMD55 = 0x79 */ - -/** - * @brief SD reponses and error flags - */ -typedef enum -{ -/* R1 answer value */ - SD_R1_NO_ERROR = (0x00), - SD_R1_IN_IDLE_STATE = (0x01), - SD_R1_ERASE_RESET = (0x02), - SD_R1_ILLEGAL_COMMAND = (0x04), - SD_R1_COM_CRC_ERROR = (0x08), - SD_R1_ERASE_SEQUENCE_ERROR= (0x10), - SD_R1_ADDRESS_ERROR = (0x20), - SD_R1_PARAMETER_ERROR = (0x40), - -/* R2 answer value */ - SD_R2_NO_ERROR = 0x00, - SD_R2_CARD_LOCKED = 0x01, - SD_R2_LOCKUNLOCK_ERROR = 0x02, - SD_R2_ERROR = 0x04, - SD_R2_CC_ERROR = 0x08, - SD_R2_CARD_ECC_FAILED = 0x10, - SD_R2_WP_VIOLATION = 0x20, - SD_R2_ERASE_PARAM = 0x40, - SD_R2_OUTOFRANGE = 0x80, - -/** - * @brief Data response error - */ - SD_DATA_OK = (0x05), - SD_DATA_CRC_ERROR = (0x0B), - SD_DATA_WRITE_ERROR = (0x0D), - SD_DATA_OTHER_ERROR = (0xFF) -} SD_Error; - -/** - * @} - */ - -/* Private macro -------------------------------------------------------------*/ - -/** @defgroup STM32_ADAFRUIT_SD_Private_Macros - * @{ - */ - -/** - * @} - */ - -/* Private variables ---------------------------------------------------------*/ - -/** @defgroup STM32_ADAFRUIT_SD_Private_Variables - * @{ - */ -__IO uint8_t SdStatus = SD_NOT_PRESENT; - -/* flag_SDHC : - 0 : Standard capacity - 1 : High capacity -*/ -uint16_t flag_SDHC = 0; - -/** - * @} - */ - -/* Private function prototypes -----------------------------------------------*/ -static uint8_t SD_GetCIDRegister(SD_CID* Cid); -static uint8_t SD_GetCSDRegister(SD_CSD* Csd); -static uint8_t SD_GetDataResponse(void); -static uint8_t SD_GoIdleState(void); -static SD_CmdAnswer_typedef SD_SendCmd(uint8_t Cmd, uint32_t Arg, uint8_t Crc, uint8_t Answer); -static uint8_t SD_WaitData(uint8_t data); -static uint8_t SD_ReadData(void); -/** @defgroup STM32_ADAFRUIT_SD_Private_Function_Prototypes - * @{ - */ -/** - * @} - */ - -/* Private functions ---------------------------------------------------------*/ - -/** @defgroup STM32_ADAFRUIT_SD_Private_Functions - * @{ - */ - -/** - * @brief Initializes the SD/SD communication. - * @param None - * @retval The SD Response: - * - MSD_ERROR: Sequence failed - * - MSD_OK: Sequence succeed - */ -uint8_t BSP_SD_Init(void) -{ - /* Configure IO functionalities for SD pin */ - SD_IO_Init(); - - /* SD detection pin is not physically mapped on the Adafruit shield */ - SdStatus = SD_PRESENT; - - /* SD initialized and set to SPI mode properly */ - return SD_GoIdleState(); -} - -/** - * @brief Returns information about specific card. - * @param pCardInfo: Pointer to a SD_CardInfo structure that contains all SD - * card information. - * @retval The SD Response: - * - MSD_ERROR: Sequence failed - * - MSD_OK: Sequence succeed - */ -uint8_t BSP_SD_GetCardInfo(SD_CardInfo *pCardInfo) -{ - uint8_t status; - - status = SD_GetCSDRegister(&(pCardInfo->Csd)); - status|= SD_GetCIDRegister(&(pCardInfo->Cid)); - if(flag_SDHC == 1 ) - { - pCardInfo->CardBlockSize = 512; - pCardInfo->CardCapacity = (pCardInfo->Csd.version.v2.DeviceSize + 1) * pCardInfo->CardBlockSize; - } - else - { - pCardInfo->CardCapacity = (pCardInfo->Csd.version.v1.DeviceSize + 1) ; - pCardInfo->CardCapacity *= (1 << (pCardInfo->Csd.version.v1.DeviceSizeMul + 2)); - pCardInfo->CardBlockSize = 1 << (pCardInfo->Csd.RdBlockLen); - pCardInfo->CardCapacity *= pCardInfo->CardBlockSize; - } - - return status; -} - -/** - * @brief Reads block(s) from a specified address in the SD card, in polling mode. - * @param pData: Pointer to the buffer that will contain the data to transmit - * @param ReadAddr: Address from where data is to be read - * @param BlockSize: SD card data block size, that should be 512 - * @param NumOfBlocks: Number of SD blocks to read - * @retval SD status - */ -uint8_t BSP_SD_ReadBlocks(uint32_t* pData, uint32_t ReadAddr, uint16_t BlockSize, uint32_t NumberOfBlocks) -{ - uint32_t offset = 0; - uint8_t retr = BSP_SD_ERROR; - uint8_t *ptr = NULL; - SD_CmdAnswer_typedef response; - - /* Send CMD16 (SD_CMD_SET_BLOCKLEN) to set the size of the block and - Check if the SD acknowledged the set block length command: R1 response (0x00: no errors) */ - response = SD_SendCmd(SD_CMD_SET_BLOCKLEN, BlockSize, 0xFF, SD_ANSWER_R1_EXPECTED); - SD_IO_CSState(1); - SD_IO_WriteByte(SD_DUMMY_BYTE); - if ( response.r1 != SD_R1_NO_ERROR) - { - goto error; - } - - ptr = malloc(sizeof(uint8_t)*BlockSize); - if( ptr == NULL ) - { - goto error; - } - memset(ptr, SD_DUMMY_BYTE, sizeof(uint8_t)*BlockSize); - - /* Data transfer */ - while (NumberOfBlocks--) - { - /* Send CMD17 (SD_CMD_READ_SINGLE_BLOCK) to read one block */ - /* Check if the SD acknowledged the read block command: R1 response (0x00: no errors) */ - response = SD_SendCmd(SD_CMD_READ_SINGLE_BLOCK, (ReadAddr + offset)/(flag_SDHC == 1 ?BlockSize: 1), 0xFF, SD_ANSWER_R1_EXPECTED); - if ( response.r1 != SD_R1_NO_ERROR) - { - goto error; - } - - /* Now look for the data token to signify the start of the data */ - if (SD_WaitData(SD_TOKEN_START_DATA_SINGLE_BLOCK_READ) == BSP_SD_OK) - { - /* Read the SD block data : read NumByteToRead data */ - SD_IO_WriteReadData(ptr, (uint8_t*)pData + offset, BlockSize); - - /* Set next read address*/ - offset += BlockSize; - /* get CRC bytes (not really needed by us, but required by SD) */ - SD_IO_WriteByte(SD_DUMMY_BYTE); - SD_IO_WriteByte(SD_DUMMY_BYTE); - } - else - { - goto error; - } - - /* End the command data read cycle */ - SD_IO_CSState(1); - SD_IO_WriteByte(SD_DUMMY_BYTE); - } - - retr = BSP_SD_OK; - -error : - /* Send dummy byte: 8 Clock pulses of delay */ - SD_IO_CSState(1); - SD_IO_WriteByte(SD_DUMMY_BYTE); - if(ptr != NULL) free(ptr); - - /* Return the reponse */ - return retr; -} - -/** - * @brief Writes block(s) to a specified address in the SD card, in polling mode. - * @param pData: Pointer to the buffer that will contain the data to transmit - * @param WriteAddr: Address from where data is to be written - * @param BlockSize: SD card data block size, that should be 512 - * @param NumOfBlocks: Number of SD blocks to write - * @retval SD status - */ -uint8_t BSP_SD_WriteBlocks(uint32_t* pData, uint32_t WriteAddr, uint16_t BlockSize, uint32_t NumberOfBlocks) -{ - uint32_t offset = 0; - uint8_t retr = BSP_SD_ERROR; - uint8_t *ptr = NULL; - SD_CmdAnswer_typedef response; - - /* Send CMD16 (SD_CMD_SET_BLOCKLEN) to set the size of the block and - Check if the SD acknowledged the set block length command: R1 response (0x00: no errors) */ - response = SD_SendCmd(SD_CMD_SET_BLOCKLEN, BlockSize, 0xFF, SD_ANSWER_R1_EXPECTED); - SD_IO_CSState(1); - SD_IO_WriteByte(SD_DUMMY_BYTE); - if ( response.r1 != SD_R1_NO_ERROR) - { - goto error; - } - - ptr = malloc(sizeof(uint8_t)*BlockSize); - if (ptr == NULL) - { - goto error; - } - - /* Data transfer */ - while (NumberOfBlocks--) - { - /* Send CMD24 (SD_CMD_WRITE_SINGLE_BLOCK) to write blocks and - Check if the SD acknowledged the write block command: R1 response (0x00: no errors) */ - response = SD_SendCmd(SD_CMD_WRITE_SINGLE_BLOCK, (WriteAddr + offset)/(flag_SDHC == 1 ? BlockSize: 1), 0xFF, SD_ANSWER_R1_EXPECTED); - if (response.r1 != SD_R1_NO_ERROR) - { - goto error; - } - - /* Send dummy byte for NWR timing : one byte between CMDWRITE and TOKEN */ - SD_IO_WriteByte(SD_DUMMY_BYTE); - SD_IO_WriteByte(SD_DUMMY_BYTE); - - /* Send the data token to signify the start of the data */ - SD_IO_WriteByte(SD_TOKEN_START_DATA_SINGLE_BLOCK_WRITE); - - /* Write the block data to SD */ - SD_IO_WriteReadData((uint8_t*)pData + offset, ptr, BlockSize); - - /* Set next write address */ - offset += BlockSize; - - /* Put CRC bytes (not really needed by us, but required by SD) */ - SD_IO_WriteByte(SD_DUMMY_BYTE); - SD_IO_WriteByte(SD_DUMMY_BYTE); - - /* Read data response */ - if (SD_GetDataResponse() != SD_DATA_OK) - { - /* Set response value to failure */ - goto error; - } - - SD_IO_CSState(1); - SD_IO_WriteByte(SD_DUMMY_BYTE); - } - retr = BSP_SD_OK; - -error : - if(ptr != NULL) free(ptr); - /* Send dummy byte: 8 Clock pulses of delay */ - SD_IO_CSState(1); - SD_IO_WriteByte(SD_DUMMY_BYTE); - - /* Return the reponse */ - return retr; -} - -/** - * @brief Erases the specified memory area of the given SD card. - * @param StartAddr: Start byte address - * @param EndAddr: End byte address - * @retval SD status - */ -uint8_t BSP_SD_Erase(uint32_t StartAddr, uint32_t EndAddr) -{ - uint8_t retr = BSP_SD_ERROR; - SD_CmdAnswer_typedef response; - - /* Send CMD32 (Erase group start) and check if the SD acknowledged the erase command: R1 response (0x00: no errors) */ - response = SD_SendCmd(SD_CMD_SD_ERASE_GRP_START, StartAddr, 0xFF, SD_ANSWER_R1_EXPECTED); - SD_IO_CSState(1); - SD_IO_WriteByte(SD_DUMMY_BYTE); if (response.r1 == SD_R1_NO_ERROR) - { - /* Send CMD33 (Erase group end) and Check if the SD acknowledged the erase command: R1 response (0x00: no errors) */ - response = SD_SendCmd(SD_CMD_SD_ERASE_GRP_END, EndAddr, 0xFF, SD_ANSWER_R1_EXPECTED); - SD_IO_CSState(1); - SD_IO_WriteByte(SD_DUMMY_BYTE); - if (response.r1 == SD_R1_NO_ERROR) - { - /* Send CMD38 (Erase) and Check if the SD acknowledged the erase command: R1 response (0x00: no errors) */ - response = SD_SendCmd(SD_CMD_ERASE, 0, 0xFF, SD_ANSWER_R1B_EXPECTED); - if (response.r1 == SD_R1_NO_ERROR) - { - retr = BSP_SD_OK; - } - SD_IO_CSState(1); - SD_IO_WriteByte(SD_DUMMY_BYTE); - } - } - - /* Return the reponse */ - return retr; -} - -/** - * @brief Returns the SD status. - * @param None - * @retval The SD status. - */ -uint8_t BSP_SD_GetStatus(void) -{ - SD_CmdAnswer_typedef retr; - - /* Send CMD13 (SD_SEND_STATUS) to get SD status */ - retr = SD_SendCmd(SD_CMD_SEND_STATUS, 0, 0xFF, SD_ANSWER_R2_EXPECTED); - SD_IO_CSState(1); - SD_IO_WriteByte(SD_DUMMY_BYTE); - - /* Find SD status according to card state */ - if(( retr.r1 == SD_R1_NO_ERROR) && ( retr.r2 == SD_R2_NO_ERROR)) - { - return BSP_SD_OK; - } - - return BSP_SD_ERROR; -} - -/** - * @brief Reads the SD card SCD register. - * Reading the contents of the CSD register in SPI mode is a simple - * read-block transaction. - * @param Csd: pointer on an SCD register structure - * @retval SD status - */ -uint8_t SD_GetCSDRegister(SD_CSD* Csd) -{ - uint16_t counter = 0; - uint8_t CSD_Tab[16]; - uint8_t retr = BSP_SD_ERROR; - SD_CmdAnswer_typedef response; - - /* Send CMD9 (CSD register) or CMD10(CSD register) and Wait for response in the R1 format (0x00 is no errors) */ - response = SD_SendCmd(SD_CMD_SEND_CSD, 0, 0xFF, SD_ANSWER_R1_EXPECTED); - if(response.r1 == SD_R1_NO_ERROR) - { - if (SD_WaitData(SD_TOKEN_START_DATA_SINGLE_BLOCK_READ) == BSP_SD_OK) - { - for (counter = 0; counter < 16; counter++) - { - /* Store CSD register value on CSD_Tab */ - CSD_Tab[counter] = SD_IO_WriteByte(SD_DUMMY_BYTE); - } - - /* Get CRC bytes (not really needed by us, but required by SD) */ - SD_IO_WriteByte(SD_DUMMY_BYTE); - SD_IO_WriteByte(SD_DUMMY_BYTE); - - /************************************************************************* - CSD header decoding - *************************************************************************/ - - /* Byte 0 */ - Csd->CSDStruct = (CSD_Tab[0] & 0xC0) >> 6; - Csd->Reserved1 = CSD_Tab[0] & 0x3F; - - /* Byte 1 */ - Csd->TAAC = CSD_Tab[1]; - - /* Byte 2 */ - Csd->NSAC = CSD_Tab[2]; - - /* Byte 3 */ - Csd->MaxBusClkFrec = CSD_Tab[3]; - - /* Byte 4/5 */ - Csd->CardComdClasses = (CSD_Tab[4] << 4) | ((CSD_Tab[5] & 0xF0) >> 4); - Csd->RdBlockLen = CSD_Tab[5] & 0x0F; - - /* Byte 6 */ - Csd->PartBlockRead = (CSD_Tab[6] & 0x80) >> 7; - Csd->WrBlockMisalign = (CSD_Tab[6] & 0x40) >> 6; - Csd->RdBlockMisalign = (CSD_Tab[6] & 0x20) >> 5; - Csd->DSRImpl = (CSD_Tab[6] & 0x10) >> 4; - - /************************************************************************* - CSD v1/v2 decoding - *************************************************************************/ - - if(flag_SDHC == 0) - { - Csd->version.v1.Reserved1 = ((CSD_Tab[6] & 0x0C) >> 2); - - Csd->version.v1.DeviceSize = ((CSD_Tab[6] & 0x03) << 10) - | (CSD_Tab[7] << 2) - | ((CSD_Tab[8] & 0xC0) >> 6); - Csd->version.v1.MaxRdCurrentVDDMin = (CSD_Tab[8] & 0x38) >> 3; - Csd->version.v1.MaxRdCurrentVDDMax = (CSD_Tab[8] & 0x07); - Csd->version.v1.MaxWrCurrentVDDMin = (CSD_Tab[9] & 0xE0) >> 5; - Csd->version.v1.MaxWrCurrentVDDMax = (CSD_Tab[9] & 0x1C) >> 2; - Csd->version.v1.DeviceSizeMul = ((CSD_Tab[9] & 0x03) << 1) - |((CSD_Tab[10] & 0x80) >> 7); - } - else - { - Csd->version.v2.Reserved1 = ((CSD_Tab[6] & 0x0F) << 2) | ((CSD_Tab[7] & 0xC0) >> 6); - Csd->version.v2.DeviceSize= ((CSD_Tab[7] & 0x3F) << 16) | (CSD_Tab[8] << 8) | CSD_Tab[9]; - Csd->version.v2.Reserved2 = ((CSD_Tab[10] & 0x80) >> 8); - } - - Csd->EraseSingleBlockEnable = (CSD_Tab[10] & 0x40) >> 6; - Csd->EraseSectorSize = ((CSD_Tab[10] & 0x3F) << 1) - |((CSD_Tab[11] & 0x80) >> 7); - Csd->WrProtectGrSize = (CSD_Tab[11] & 0x7F); - Csd->WrProtectGrEnable = (CSD_Tab[12] & 0x80) >> 7; - Csd->Reserved2 = (CSD_Tab[12] & 0x60) >> 5; - Csd->WrSpeedFact = (CSD_Tab[12] & 0x1C) >> 2; - Csd->MaxWrBlockLen = ((CSD_Tab[12] & 0x03) << 2) - |((CSD_Tab[13] & 0xC0) >> 6); - Csd->WriteBlockPartial = (CSD_Tab[13] & 0x20) >> 5; - Csd->Reserved3 = (CSD_Tab[13] & 0x1F); - Csd->FileFormatGrouop = (CSD_Tab[14] & 0x80) >> 7; - Csd->CopyFlag = (CSD_Tab[14] & 0x40) >> 6; - Csd->PermWrProtect = (CSD_Tab[14] & 0x20) >> 5; - Csd->TempWrProtect = (CSD_Tab[14] & 0x10) >> 4; - Csd->FileFormat = (CSD_Tab[14] & 0x0C) >> 2; - Csd->Reserved4 = (CSD_Tab[14] & 0x03); - Csd->crc = (CSD_Tab[15] & 0xFE) >> 1; - Csd->Reserved5 = (CSD_Tab[15] & 0x01); - - retr = BSP_SD_OK; - } - } - - /* Send dummy byte: 8 Clock pulses of delay */ - SD_IO_CSState(1); - SD_IO_WriteByte(SD_DUMMY_BYTE); - - /* Return the reponse */ - return retr; -} - -/** - * @brief Reads the SD card CID register. - * Reading the contents of the CID register in SPI mode is a simple - * read-block transaction. - * @param Cid: pointer on an CID register structure - * @retval SD status - */ -uint8_t SD_GetCIDRegister(SD_CID* Cid) -{ - uint32_t counter = 0; - uint8_t retr = BSP_SD_ERROR; - uint8_t CID_Tab[16]; - SD_CmdAnswer_typedef response; - - /* Send CMD10 (CID register) and Wait for response in the R1 format (0x00 is no errors) */ - response = SD_SendCmd(SD_CMD_SEND_CID, 0, 0xFF, SD_ANSWER_R1_EXPECTED); - if(response.r1 == SD_R1_NO_ERROR) - { - if(SD_WaitData(SD_TOKEN_START_DATA_SINGLE_BLOCK_READ) == BSP_SD_OK) - { - /* Store CID register value on CID_Tab */ - for (counter = 0; counter < 16; counter++) - { - CID_Tab[counter] = SD_IO_WriteByte(SD_DUMMY_BYTE); - } - - /* Get CRC bytes (not really needed by us, but required by SD) */ - SD_IO_WriteByte(SD_DUMMY_BYTE); - SD_IO_WriteByte(SD_DUMMY_BYTE); - - /* Byte 0 */ - Cid->ManufacturerID = CID_Tab[0]; - - /* Byte 1 */ - Cid->OEM_AppliID = CID_Tab[1] << 8; - - /* Byte 2 */ - Cid->OEM_AppliID |= CID_Tab[2]; - - /* Byte 3 */ - Cid->ProdName1 = CID_Tab[3] << 24; - - /* Byte 4 */ - Cid->ProdName1 |= CID_Tab[4] << 16; - - /* Byte 5 */ - Cid->ProdName1 |= CID_Tab[5] << 8; - - /* Byte 6 */ - Cid->ProdName1 |= CID_Tab[6]; - - /* Byte 7 */ - Cid->ProdName2 = CID_Tab[7]; - - /* Byte 8 */ - Cid->ProdRev = CID_Tab[8]; - - /* Byte 9 */ - Cid->ProdSN = CID_Tab[9] << 24; - - /* Byte 10 */ - Cid->ProdSN |= CID_Tab[10] << 16; - - /* Byte 11 */ - Cid->ProdSN |= CID_Tab[11] << 8; - - /* Byte 12 */ - Cid->ProdSN |= CID_Tab[12]; - - /* Byte 13 */ - Cid->Reserved1 |= (CID_Tab[13] & 0xF0) >> 4; - Cid->ManufactDate = (CID_Tab[13] & 0x0F) << 8; - - /* Byte 14 */ - Cid->ManufactDate |= CID_Tab[14]; - - /* Byte 15 */ - Cid->CID_CRC = (CID_Tab[15] & 0xFE) >> 1; - Cid->Reserved2 = 1; - - retr = BSP_SD_OK; - } - } - - /* Send dummy byte: 8 Clock pulses of delay */ - SD_IO_CSState(1); - SD_IO_WriteByte(SD_DUMMY_BYTE); - - /* Return the reponse */ - return retr; -} - -/** - * @brief Sends 5 bytes command to the SD card and get response - * @param Cmd: The user expected command to send to SD card. - * @param Arg: The command argument. - * @param Crc: The CRC. - * @param Answer: SD_ANSWER_NOT_EXPECTED or SD_ANSWER_EXPECTED - * @retval SD status - */ -SD_CmdAnswer_typedef SD_SendCmd(uint8_t Cmd, uint32_t Arg, uint8_t Crc, uint8_t Answer) -{ - uint8_t frame[SD_CMD_LENGTH], frameout[SD_CMD_LENGTH]; - SD_CmdAnswer_typedef retr = {0xFF, 0xFF , 0xFF, 0xFF, 0xFF}; - - /* R1 Lenght = NCS(0)+ 6 Bytes command + NCR(min1 max8) + 1 Bytes answer + NEC(0) = 15bytes */ - /* R1b identical to R1 + Busy information */ - /* R2 Lenght = NCS(0)+ 6 Bytes command + NCR(min1 max8) + 2 Bytes answer + NEC(0) = 16bytes */ - - /* Prepare Frame to send */ - frame[0] = (Cmd | 0x40); /* Construct byte 1 */ - frame[1] = (uint8_t)(Arg >> 24); /* Construct byte 2 */ - frame[2] = (uint8_t)(Arg >> 16); /* Construct byte 3 */ - frame[3] = (uint8_t)(Arg >> 8); /* Construct byte 4 */ - frame[4] = (uint8_t)(Arg); /* Construct byte 5 */ - frame[5] = (Crc | 0x01); /* Construct byte 6 */ - - /* Send the command */ - SD_IO_CSState(0); - SD_IO_WriteReadData(frame, frameout, SD_CMD_LENGTH); /* Send the Cmd bytes */ - - switch(Answer) - { - case SD_ANSWER_R1_EXPECTED : - retr.r1 = SD_ReadData(); - break; - case SD_ANSWER_R1B_EXPECTED : - retr.r1 = SD_ReadData(); - retr.r2 = SD_IO_WriteByte(SD_DUMMY_BYTE); - /* Set CS High */ - SD_IO_CSState(1); - HAL_Delay(1); - /* Set CS Low */ - SD_IO_CSState(0); - - /* Wait IO line return 0xFF */ - while (SD_IO_WriteByte(SD_DUMMY_BYTE) != 0xFF); - break; - case SD_ANSWER_R2_EXPECTED : - retr.r1 = SD_ReadData(); - retr.r2 = SD_IO_WriteByte(SD_DUMMY_BYTE); - break; - case SD_ANSWER_R3_EXPECTED : - case SD_ANSWER_R7_EXPECTED : - retr.r1 = SD_ReadData(); - retr.r2 = SD_IO_WriteByte(SD_DUMMY_BYTE); - retr.r3 = SD_IO_WriteByte(SD_DUMMY_BYTE); - retr.r4 = SD_IO_WriteByte(SD_DUMMY_BYTE); - retr.r5 = SD_IO_WriteByte(SD_DUMMY_BYTE); - break; - default : - break; - } - return retr; -} - -/** - * @brief Gets the SD card data response and check the busy flag. - * @param None - * @retval The SD status: Read data response xxx01 - * - status 010: Data accecpted - * - status 101: Data rejected due to a crc error - * - status 110: Data rejected due to a Write error. - * - status 111: Data rejected due to other error. - */ -uint8_t SD_GetDataResponse(void) -{ - uint8_t dataresponse; - uint8_t rvalue = SD_DATA_OTHER_ERROR; - - dataresponse = SD_IO_WriteByte(SD_DUMMY_BYTE); - SD_IO_WriteByte(SD_DUMMY_BYTE); /* read the busy response byte*/ - - /* Mask unused bits */ - switch (dataresponse & 0x1F) - { - case SD_DATA_OK: - rvalue = SD_DATA_OK; - - /* Set CS High */ - SD_IO_CSState(1); - /* Set CS Low */ - SD_IO_CSState(0); - - /* Wait IO line return 0xFF */ - while (SD_IO_WriteByte(SD_DUMMY_BYTE) != 0xFF); - break; - case SD_DATA_CRC_ERROR: - rvalue = SD_DATA_CRC_ERROR; - break; - case SD_DATA_WRITE_ERROR: - rvalue = SD_DATA_WRITE_ERROR; - break; - default: - break; - } - - /* Return response */ - return rvalue; -} - - -/** - * @brief Put the SD in Idle state. - * @param None - * @retval SD status - */ -uint8_t SD_GoIdleState(void) -{ - SD_CmdAnswer_typedef response; - __IO uint8_t counter = 0; - /* Send CMD0 (SD_CMD_GO_IDLE_STATE) to put SD in SPI mode and - wait for In Idle State Response (R1 Format) equal to 0x01 */ - do{ - counter++; - response = SD_SendCmd(SD_CMD_GO_IDLE_STATE, 0, 0x95, SD_ANSWER_R1_EXPECTED); - SD_IO_CSState(1); - SD_IO_WriteByte(SD_DUMMY_BYTE); - if(counter >= SD_MAX_TRY) - { - return BSP_SD_ERROR; - } - } - while(response.r1 != SD_R1_IN_IDLE_STATE); - - - /* Send CMD8 (SD_CMD_SEND_IF_COND) to check the power supply status - and wait until response (R7 Format) equal to 0xAA and */ - response = SD_SendCmd(SD_CMD_SEND_IF_COND, 0x1AA, 0x87, SD_ANSWER_R7_EXPECTED); - SD_IO_CSState(1); - SD_IO_WriteByte(SD_DUMMY_BYTE); - if((response.r1 & SD_R1_ILLEGAL_COMMAND) == SD_R1_ILLEGAL_COMMAND) - { - /* initialise card V1 */ - do - { - /* initialise card V1 */ - /* Send CMD55 (SD_CMD_APP_CMD) before any ACMD command: R1 response (0x00: no errors) */ - response = SD_SendCmd(SD_CMD_APP_CMD, 0x00000000, 0xFF, SD_ANSWER_R1_EXPECTED); - SD_IO_CSState(1); - SD_IO_WriteByte(SD_DUMMY_BYTE); - - /* Send ACMD41 (SD_CMD_SD_APP_OP_COND) to initialize SDHC or SDXC cards: R1 response (0x00: no errors) */ - response = SD_SendCmd(SD_CMD_SD_APP_OP_COND, 0x00000000, 0xFF, SD_ANSWER_R1_EXPECTED); - SD_IO_CSState(1); - SD_IO_WriteByte(SD_DUMMY_BYTE); - } - while(response.r1 == SD_R1_IN_IDLE_STATE); - flag_SDHC = 0; - } - else if(response.r1 == SD_R1_IN_IDLE_STATE) - { - /* initialise card V2 */ - do { - - /* Send CMD55 (SD_CMD_APP_CMD) before any ACMD command: R1 response (0x00: no errors) */ - response = SD_SendCmd(SD_CMD_APP_CMD, 0, 0xFF, SD_ANSWER_R1_EXPECTED); - SD_IO_CSState(1); - SD_IO_WriteByte(SD_DUMMY_BYTE); - - /* Send ACMD41 (SD_CMD_SD_APP_OP_COND) to initialize SDHC or SDXC cards: R1 response (0x00: no errors) */ - response = SD_SendCmd(SD_CMD_SD_APP_OP_COND, 0x40000000, 0xFF, SD_ANSWER_R1_EXPECTED); - SD_IO_CSState(1); - SD_IO_WriteByte(SD_DUMMY_BYTE); - } - while(response.r1 == SD_R1_IN_IDLE_STATE); - - if((response.r1 & SD_R1_ILLEGAL_COMMAND) == SD_R1_ILLEGAL_COMMAND) - { - do { - /* Send CMD55 (SD_CMD_APP_CMD) before any ACMD command: R1 response (0x00: no errors) */ - response = SD_SendCmd(SD_CMD_APP_CMD, 0, 0xFF, SD_ANSWER_R1_EXPECTED); - SD_IO_CSState(1); - SD_IO_WriteByte(SD_DUMMY_BYTE); - if(response.r1 != SD_R1_IN_IDLE_STATE) - { - return BSP_SD_ERROR; - } - /* Send ACMD41 (SD_CMD_SD_APP_OP_COND) to initialize SDHC or SDXC cards: R1 response (0x00: no errors) */ - response = SD_SendCmd(SD_CMD_SD_APP_OP_COND, 0x00000000, 0xFF, SD_ANSWER_R1_EXPECTED); - SD_IO_CSState(1); - SD_IO_WriteByte(SD_DUMMY_BYTE); - } - while(response.r1 == SD_R1_IN_IDLE_STATE); - } - - /* Send CMD58 (SD_CMD_READ_OCR) to initialize SDHC or SDXC cards: R3 response (0x00: no errors) */ - response = SD_SendCmd(SD_CMD_READ_OCR, 0x00000000, 0xFF, SD_ANSWER_R3_EXPECTED); - SD_IO_CSState(1); - SD_IO_WriteByte(SD_DUMMY_BYTE); - if(response.r1 != SD_R1_NO_ERROR) - { - return BSP_SD_ERROR; - } - flag_SDHC = (response.r2 & 0x40) >> 6; - } - else - { - return BSP_SD_ERROR; - } - - return BSP_SD_OK; -} - -/** - * @brief Waits a data until a value different from SD_DUMMY_BITE - * @param None - * @retval the value read - */ -uint8_t SD_ReadData(void) -{ - uint8_t timeout = 0x08; - uint8_t readvalue; - - /* Check if response is got or a timeout is happen */ - do { - readvalue = SD_IO_WriteByte(SD_DUMMY_BYTE); - timeout--; - - }while ((readvalue == SD_DUMMY_BYTE) && timeout); - - /* Right response got */ - return readvalue; -} - -/** - * @brief Waits a data from the SD card - * @param data : Expected data from the SD card - * @retval BSP_SD_OK or BSP_SD_TIMEOUT - */ -uint8_t SD_WaitData(uint8_t data) -{ - uint16_t timeout = 0xFFFF; - uint8_t readvalue; - - /* Check if response is got or a timeout is happen */ - - do { - readvalue = SD_IO_WriteByte(SD_DUMMY_BYTE); - timeout--; - }while ((readvalue != data) && timeout); - - if (timeout == 0) - { - /* After time out */ - return BSP_SD_TIMEOUT; - } - - /* Right response got */ - return BSP_SD_OK; -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/Adafruit_Shield/stm32_adafruit_sd.h b/bsp/stm32f411RE/Libraries/BSP/Adafruit_Shield/stm32_adafruit_sd.h deleted file mode 100644 index 399d2c0ebc..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Adafruit_Shield/stm32_adafruit_sd.h +++ /dev/null @@ -1,240 +0,0 @@ -/** - ****************************************************************************** - * @file stm32_adafruit_sd.h - * @author MCD Application Team - * @version V2.0.1 - * @date 04-November-2015 - * @brief This file contains the common defines and functions prototypes for - * the stm32_adafruit_sd.c driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32_ADAFRUIT_SD_H -#define __STM32_ADAFRUIT_SD_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include - -/** @addtogroup BSP - * @{ - */ -#define __IO volatile - -/** @addtogroup STM32_ADAFRUIT - * @{ - */ - -/** @defgroup STM32_ADAFRUIT_SD - * @{ - */ - -/** @defgroup STM32_ADAFRUIT_SD_Exported_Types - * @{ - */ - -/** - * @brief SD status structure definition - */ -enum { - BSP_SD_OK = 0x00, - MSD_OK = 0x00, - BSP_SD_ERROR = 0x01, - BSP_SD_TIMEOUT -}; - -typedef struct -{ - uint8_t Reserved1:2; /* Reserved */ - uint16_t DeviceSize:12; /* Device Size */ - uint8_t MaxRdCurrentVDDMin:3; /* Max. read current @ VDD min */ - uint8_t MaxRdCurrentVDDMax:3; /* Max. read current @ VDD max */ - uint8_t MaxWrCurrentVDDMin:3; /* Max. write current @ VDD min */ - uint8_t MaxWrCurrentVDDMax:3; /* Max. write current @ VDD max */ - uint8_t DeviceSizeMul:3; /* Device size multiplier */ -} struct_v1; - - -typedef struct -{ - uint8_t Reserved1:6; /* Reserved */ - uint32_t DeviceSize:22; /* Device Size */ - uint8_t Reserved2:1; /* Reserved */ -} struct_v2; - -/** - * @brief Card Specific Data: CSD Register - */ -typedef struct -{ - /* Header part */ - uint8_t CSDStruct:2; /* CSD structure */ - uint8_t Reserved1:6; /* Reserved */ - uint8_t TAAC:8; /* Data read access-time 1 */ - uint8_t NSAC:8; /* Data read access-time 2 in CLK cycles */ - uint8_t MaxBusClkFrec:8; /* Max. bus clock frequency */ - uint16_t CardComdClasses:12; /* Card command classes */ - uint8_t RdBlockLen:4; /* Max. read data block length */ - uint8_t PartBlockRead:1; /* Partial blocks for read allowed */ - uint8_t WrBlockMisalign:1; /* Write block misalignment */ - uint8_t RdBlockMisalign:1; /* Read block misalignment */ - uint8_t DSRImpl:1; /* DSR implemented */ - - /* v1 or v2 struct */ - union csd_version { - struct_v1 v1; - struct_v2 v2; - } version; - - uint8_t EraseSingleBlockEnable:1; /* Erase single block enable */ - uint8_t EraseSectorSize:7; /* Erase group size multiplier */ - uint8_t WrProtectGrSize:7; /* Write protect group size */ - uint8_t WrProtectGrEnable:1; /* Write protect group enable */ - uint8_t Reserved2:2; /* Reserved */ - uint8_t WrSpeedFact:3; /* Write speed factor */ - uint8_t MaxWrBlockLen:4; /* Max. write data block length */ - uint8_t WriteBlockPartial:1; /* Partial blocks for write allowed */ - uint8_t Reserved3:5; /* Reserved */ - uint8_t FileFormatGrouop:1; /* File format group */ - uint8_t CopyFlag:1; /* Copy flag (OTP) */ - uint8_t PermWrProtect:1; /* Permanent write protection */ - uint8_t TempWrProtect:1; /* Temporary write protection */ - uint8_t FileFormat:2; /* File Format */ - uint8_t Reserved4:2; /* Reserved */ - uint8_t crc:7; /* Reserved */ - uint8_t Reserved5:1; /* always 1*/ - -} SD_CSD; - -/** - * @brief Card Identification Data: CID Register - */ -typedef struct -{ - __IO uint8_t ManufacturerID; /* ManufacturerID */ - __IO uint16_t OEM_AppliID; /* OEM/Application ID */ - __IO uint32_t ProdName1; /* Product Name part1 */ - __IO uint8_t ProdName2; /* Product Name part2*/ - __IO uint8_t ProdRev; /* Product Revision */ - __IO uint32_t ProdSN; /* Product Serial Number */ - __IO uint8_t Reserved1; /* Reserved1 */ - __IO uint16_t ManufactDate; /* Manufacturing Date */ - __IO uint8_t CID_CRC; /* CID CRC */ - __IO uint8_t Reserved2; /* always 1 */ -} SD_CID; - -/** - * @brief SD Card information - */ -typedef struct -{ - SD_CSD Csd; - SD_CID Cid; - uint32_t CardCapacity; /* Card Capacity */ - uint32_t CardBlockSize; /* Card Block Size */ -} SD_CardInfo; - -/** - * @} - */ - -/** @defgroup STM32_ADAFRUIT_SPI_SD_Exported_Constants - * @{ - */ - -/** - * @brief Block Size - */ -#define SD_BLOCK_SIZE 0x200 - -/** - * @brief SD detection on its memory slot - */ -#define SD_PRESENT ((uint8_t)0x01) -#define SD_NOT_PRESENT ((uint8_t)0x00) - -/** - * @} - */ - -/** @defgroup STM32_ADAFRUIT_SD_Exported_Macro - * @{ - */ - -/** - * @} - */ - -/** @defgroup STM32_ADAFRUIT_SD_Exported_Functions - * @{ - */ -uint8_t BSP_SD_Init(void); -uint8_t BSP_SD_ReadBlocks(uint32_t *pData, uint32_t ReadAddr, uint16_t BlockSize, uint32_t NumberOfBlocks); -uint8_t BSP_SD_WriteBlocks(uint32_t *pData, uint32_t WriteAddr, uint16_t BlockSize, uint32_t NumberOfBlocks); -uint8_t BSP_SD_Erase(uint32_t StartAddr, uint32_t EndAddr); -uint8_t BSP_SD_GetStatus(void); -uint8_t BSP_SD_GetCardInfo(SD_CardInfo *pCardInfo); - -/* Link functions for SD Card peripheral*/ -void SD_IO_Init(void); -void SD_IO_CSState(uint8_t state); -void SD_IO_WriteReadData(const uint8_t *DataIn, uint8_t *DataOut, uint16_t DataLength); -uint8_t SD_IO_WriteByte(uint8_t Data); - -/* Link function for HAL delay */ -void HAL_Delay(__IO uint32_t Delay); - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32_ADAFRUIT_SD_H */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/Common/Release_Notes.html b/bsp/stm32f411RE/Libraries/BSP/Components/Common/Release_Notes.html deleted file mode 100644 index e173ae5366..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/Common/Release_Notes.html +++ /dev/null @@ -1,759 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - Release Notes for BSP Components Common Drivers - - - - - - - - - - -
-


-

-
- - - - - - -
- - - - - - - - - -
-

Back to Release page

-
- -

Release -Notes for BSP Components Common  Drivers

- -

Copyright -2015 STMicroelectronics

-

-
-

 

- - - - - - -
- - -

Update History

-

V4.0.1 / 21-July-2015

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  • tsensor.h: Fix compilation issue on TSENSOR_InitTypeDef

V4.0.0 / 22-June-2015

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  • accelero.h: add *DeInit field in ACCELERO_DrvTypeDef structure
  • audio.h: add *DeInit field in AUDIO_DrvTypeDef structure
  • idd.h: 
    • add Shunt0StabDelay, Shunt1StabDelay, Shunt2StabDelay, Shunt3StabDelay, Shunt4StabDelay and ShuntNbOnBoard fields in IDD_ConfigTypeDef structure
    • rename ShuntNumber field to ShuntNbUsed in IDD_ConfigTypeDef structure
  • magneto.h: add *DeInit field in MAGNETO_DrvTypeDef structure
  • Important Note:  this release V4.0.0 is not backward compatible with V3.0.0

V3.0.0 / 28-April-2015

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  • accelero.h: add *LowPower field in ACCELERO_DrvTypeDef structure
  • magneto.h: add *LowPower field in MAGNETO_DrvTypeDef structure
  • gyro.h: add *DeInit and *LowPower fields in GYRO_DrvTypeDef structure
  • camera.h: add CAMERA_COLOR_EFFECT_NONE define
  • idd.h: 
    • add MeasureNb, DeltaDelayUnit and DeltaDelayValue fields in IDD_ConfigTypeDef structure
    • rename PreDelay field to PreDelayUnit in IDD_ConfigTypeDef structure
    -
  • Important Note:  this release V3.0.0 is not backward compatible with V2.2.0
    -
  • -

V2.2.0 / 09-February-2015

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  • Magnetometer driver function prototypes added (magneto.h file)
  • Update "idd.h" file to provide DeInit() and WakeUp() services in IDD current measurement driver

V2.1.0 / 06-February-2015

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  • IDD current measurement driver function prototypes added (idd.h file)
  • io.h: add new typedef enum IO_PinState with IO_PIN_RESET and IO_PIN_SET values

V2.0.0 / 15-December-2014

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  • Update "io.h" file to support MFX (Multi Function eXpander) device available on some STM32 boards
    • add new entries for IO_ModeTypedef enumeration structure
    • update the IO_DrvTypeDef structure
      • Update all return values and function parameters to uint32_t
      • Add a return value for Config field
  • Important Note:  this version V2.0.0 is not backward compatible with V1.2.1

V1.2.1 / 02-December-2014

-

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  • gyro.h: change “__GIRO_H” by “__GYRO_H” to fix compilation issue under Mac OS

V1.2.0 / 18-June-2014

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  • EPD (E Paper Display)  driver function prototype added (epd.h file)
    -

V1.1.0 / 21-March-2014

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  • Temperature Sensor driver function prototype added

V1.0.0 / 18-February-2014

- - - - - - - - - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  • First official release with  Accelerometer, Audio, Camera, Gyroscope, IO, LCD and Touch Screen drivers function prototypes

License

-
-Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met:
-
-
  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions -in binary form must reproduce the above copyright notice, this list of -conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of STMicroelectronics nor the names of its contributors may be used to endorse or promote products derived
    -
    -
-        from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- -
-

- - -
-
-

For -complete documentation on STM32 Microcontrollers -visit www.st.com/STM32

-
-

-
-
-

 

-
- - \ No newline at end of file diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/Common/accelero.h b/bsp/stm32f411RE/Libraries/BSP/Components/Common/accelero.h deleted file mode 100644 index 0de8232949..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/Common/accelero.h +++ /dev/null @@ -1,143 +0,0 @@ -/** - ****************************************************************************** - * @file accelero.h - * @author MCD Application Team - * @version V4.0.1 - * @date 21-July-2015 - * @brief This header file contains the functions prototypes for the Accelerometer driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __ACCELERO_H -#define __ACCELERO_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup Components - * @{ - */ - -/** @addtogroup ACCELERO - * @{ - */ - -/** @defgroup ACCELERO_Exported_Types - * @{ - */ - -/** @defgroup ACCELERO_Driver_structure Accelerometer Driver structure - * @{ - */ -typedef struct -{ - void (*Init)(uint16_t); - void (*DeInit)(void); - uint8_t (*ReadID)(void); - void (*Reset)(void); - void (*LowPower)(void); - void (*ConfigIT)(void); - void (*EnableIT)(uint8_t); - void (*DisableIT)(uint8_t); - uint8_t (*ITStatus)(uint16_t); - void (*ClearIT)(void); - void (*FilterConfig)(uint8_t); - void (*FilterCmd)(uint8_t); - void (*GetXYZ)(int16_t *); -}ACCELERO_DrvTypeDef; -/** - * @} - */ - -/** @defgroup ACCELERO_Configuration_structure Accelerometer Configuration structure - * @{ - */ - -/* ACCELERO struct */ -typedef struct -{ - uint8_t Power_Mode; /* Power-down/Normal Mode */ - uint8_t AccOutput_DataRate; /* OUT data rate */ - uint8_t Axes_Enable; /* Axes enable */ - uint8_t High_Resolution; /* High Resolution enabling/disabling */ - uint8_t BlockData_Update; /* Block Data Update */ - uint8_t Endianness; /* Endian Data selection */ - uint8_t AccFull_Scale; /* Full Scale selection */ - uint8_t Communication_Mode; -}ACCELERO_InitTypeDef; - -/* ACCELERO High Pass Filter struct */ -typedef struct -{ - uint8_t HighPassFilter_Mode_Selection; /* Internal filter mode */ - uint8_t HighPassFilter_CutOff_Frequency; /* High pass filter cut-off frequency */ - uint8_t HighPassFilter_AOI1; /* HPF_enabling/disabling for AOI function on interrupt 1 */ - uint8_t HighPassFilter_AOI2; /* HPF_enabling/disabling for AOI function on interrupt 2 */ - uint8_t HighPassFilter_Data_Sel; - uint8_t HighPassFilter_Stat; -}ACCELERO_FilterConfigTypeDef; - -/** - * @} - */ - - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __ACCELERO_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/Common/audio.h b/bsp/stm32f411RE/Libraries/BSP/Components/Common/audio.h deleted file mode 100644 index 8b93673ff8..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/Common/audio.h +++ /dev/null @@ -1,122 +0,0 @@ -/** - ****************************************************************************** - * @file audio.h - * @author MCD Application Team - * @version V4.0.1 - * @date 21-July-2015 - * @brief This header file contains the common defines and functions prototypes - * for the Audio driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __AUDIO_H -#define __AUDIO_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup Components - * @{ - */ - -/** @addtogroup AUDIO - * @{ - */ - -/** @defgroup AUDIO_Exported_Constants - * @{ - */ - -/* Codec audio Standards */ -#define CODEC_STANDARD 0x04 -#define I2S_STANDARD I2S_STANDARD_PHILIPS - -/** - * @} - */ - -/** @defgroup AUDIO_Exported_Types - * @{ - */ - -/** @defgroup AUDIO_Driver_structure Audio Driver structure - * @{ - */ -typedef struct -{ - uint32_t (*Init)(uint16_t, uint16_t, uint8_t, uint32_t); - void (*DeInit)(void); - uint32_t (*ReadID)(uint16_t); - uint32_t (*Play)(uint16_t, uint16_t*, uint16_t); - uint32_t (*Pause)(uint16_t); - uint32_t (*Resume)(uint16_t); - uint32_t (*Stop)(uint16_t, uint32_t); - uint32_t (*SetFrequency)(uint16_t, uint32_t); - uint32_t (*SetVolume)(uint16_t, uint8_t); - uint32_t (*SetMute)(uint16_t, uint32_t); - uint32_t (*SetOutputMode)(uint16_t, uint8_t); - uint32_t (*Reset)(uint16_t); -}AUDIO_DrvTypeDef; -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __AUDIO_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/Common/camera.h b/bsp/stm32f411RE/Libraries/BSP/Components/Common/camera.h deleted file mode 100644 index c64f32fdc1..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/Common/camera.h +++ /dev/null @@ -1,141 +0,0 @@ -/** - ****************************************************************************** - * @file camera.h - * @author MCD Application Team - * @version V4.0.1 - * @date 21-July-2015 - * @brief This header file contains the common defines and functions prototypes - * for the camera driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __CAMERA_H -#define __CAMERA_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup Components - * @{ - */ - -/** @addtogroup CAMERA - * @{ - */ - - -/** @defgroup CAMERA_Exported_Types - * @{ - */ - -/** @defgroup CAMERA_Driver_structure Camera Driver structure - * @{ - */ -typedef struct -{ - void (*Init)(uint16_t, uint32_t); - uint16_t (*ReadID)(uint16_t); - void (*Config)(uint16_t, uint32_t, uint32_t, uint32_t); -}CAMERA_DrvTypeDef; -/** - * @} - */ - -/** - * @} - */ - -/** @defgroup CAMERA_Exported_Constants - * @{ - */ -#define CAMERA_R160x120 0x00 /* QQVGA Resolution */ -#define CAMERA_R320x240 0x01 /* QVGA Resolution */ -#define CAMERA_R480x272 0x02 /* 480x272 Resolution */ -#define CAMERA_R640x480 0x03 /* VGA Resolution */ - -#define CAMERA_CONTRAST_BRIGHTNESS 0x00 /* Camera contrast brightness features */ -#define CAMERA_BLACK_WHITE 0x01 /* Camera black white feature */ -#define CAMERA_COLOR_EFFECT 0x03 /* Camera color effect feature */ - -#define CAMERA_BRIGHTNESS_LEVEL0 0x00 /* Brightness level -2 */ -#define CAMERA_BRIGHTNESS_LEVEL1 0x01 /* Brightness level -1 */ -#define CAMERA_BRIGHTNESS_LEVEL2 0x02 /* Brightness level 0 */ -#define CAMERA_BRIGHTNESS_LEVEL3 0x03 /* Brightness level +1 */ -#define CAMERA_BRIGHTNESS_LEVEL4 0x04 /* Brightness level +2 */ - -#define CAMERA_CONTRAST_LEVEL0 0x05 /* Contrast level -2 */ -#define CAMERA_CONTRAST_LEVEL1 0x06 /* Contrast level -1 */ -#define CAMERA_CONTRAST_LEVEL2 0x07 /* Contrast level 0 */ -#define CAMERA_CONTRAST_LEVEL3 0x08 /* Contrast level +1 */ -#define CAMERA_CONTRAST_LEVEL4 0x09 /* Contrast level +2 */ - -#define CAMERA_BLACK_WHITE_BW 0x00 /* Black and white effect */ -#define CAMERA_BLACK_WHITE_NEGATIVE 0x01 /* Negative effect */ -#define CAMERA_BLACK_WHITE_BW_NEGATIVE 0x02 /* BW and Negative effect */ -#define CAMERA_BLACK_WHITE_NORMAL 0x03 /* Normal effect */ - -#define CAMERA_COLOR_EFFECT_NONE 0x00 /* No effects */ -#define CAMERA_COLOR_EFFECT_BLUE 0x01 /* Blue effect */ -#define CAMERA_COLOR_EFFECT_GREEN 0x02 /* Green effect */ -#define CAMERA_COLOR_EFFECT_RED 0x03 /* Red effect */ -#define CAMERA_COLOR_EFFECT_ANTIQUE 0x04 /* Antique effect */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __CAMERA_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/Common/epd.h b/bsp/stm32f411RE/Libraries/BSP/Components/Common/epd.h deleted file mode 100644 index a06be10d55..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/Common/epd.h +++ /dev/null @@ -1,115 +0,0 @@ -/** - ****************************************************************************** - * @file epd.h - * @author MCD Application Team - * @version V4.0.1 - * @date 21-July-2015 - * @brief This file contains all the functions prototypes for the - * EPD (E Paper Display) driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __EPD_H -#define __EPD_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup Components - * @{ - */ - -/** @addtogroup Common - * @{ - */ - -/** @addtogroup EPD - * @{ - */ - -/** @defgroup EPD_Exported_Types - * @{ - */ - -/** @defgroup EPD_Driver_structure E Paper Display Driver structure - * @{ - */ -typedef struct -{ - void (*Init)(void); - void (*WritePixel)(uint8_t); - - /* Optimized operation */ - void (*SetDisplayWindow)(uint16_t, uint16_t, uint16_t, uint16_t); - void (*RefreshDisplay)(void); - void (*CloseChargePump)(void); - - uint16_t (*GetEpdPixelWidth)(void); - uint16_t (*GetEpdPixelHeight)(void); - void (*DrawImage)(uint16_t, uint16_t, uint16_t, uint16_t, uint8_t*); -} -EPD_DrvTypeDef; -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - - -#ifdef __cplusplus -} -#endif - -#endif /* EPD_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/Common/gyro.h b/bsp/stm32f411RE/Libraries/BSP/Components/Common/gyro.h deleted file mode 100644 index 462928c903..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/Common/gyro.h +++ /dev/null @@ -1,145 +0,0 @@ -/** - ****************************************************************************** - * @file gyro.h - * @author MCD Application Team - * @version V4.0.1 - * @date 21-July-2015 - * @brief This header file contains the functions prototypes for the gyroscope driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __GYRO_H -#define __GYRO_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup Components - * @{ - */ - -/** @addtogroup GYRO - * @{ - */ - -/** @defgroup GYRO_Exported_Types - * @{ - */ - -/** @defgroup GYRO_Driver_structure Gyroscope Driver structure - * @{ - */ -typedef struct -{ - void (*Init)(uint16_t); - void (*DeInit)(void); - uint8_t (*ReadID)(void); - void (*Reset)(void); - void (*LowPower)(uint16_t); - void (*ConfigIT)(uint16_t); - void (*EnableIT)(uint8_t); - void (*DisableIT)(uint8_t); - uint8_t (*ITStatus)(uint16_t, uint16_t); - void (*ClearIT)(uint16_t, uint16_t); - void (*FilterConfig)(uint8_t); - void (*FilterCmd)(uint8_t); - void (*GetXYZ)(float *); -}GYRO_DrvTypeDef; -/** - * @} - */ - -/** @defgroup GYRO_Config_structure Gyroscope Configuration structure - * @{ - */ - -typedef struct -{ - uint8_t Power_Mode; /* Power-down/Sleep/Normal Mode */ - uint8_t Output_DataRate; /* OUT data rate */ - uint8_t Axes_Enable; /* Axes enable */ - uint8_t Band_Width; /* Bandwidth selection */ - uint8_t BlockData_Update; /* Block Data Update */ - uint8_t Endianness; /* Endian Data selection */ - uint8_t Full_Scale; /* Full Scale selection */ -}GYRO_InitTypeDef; - -/* GYRO High Pass Filter struct */ -typedef struct -{ - uint8_t HighPassFilter_Mode_Selection; /* Internal filter mode */ - uint8_t HighPassFilter_CutOff_Frequency; /* High pass filter cut-off frequency */ -}GYRO_FilterConfigTypeDef; - -/*GYRO Interrupt struct */ -typedef struct -{ - uint8_t Latch_Request; /* Latch interrupt request into CLICK_SRC register */ - uint8_t Interrupt_Axes; /* X, Y, Z Axes Interrupts */ - uint8_t Interrupt_ActiveEdge; /* Interrupt Active edge */ -}GYRO_InterruptConfigTypeDef; - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __GYRO_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/Common/idd.h b/bsp/stm32f411RE/Libraries/BSP/Components/Common/idd.h deleted file mode 100644 index 1b8a762e39..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/Common/idd.h +++ /dev/null @@ -1,168 +0,0 @@ -/** - ****************************************************************************** - * @file idd.h - * @author MCD Application Team - * @version V4.0.1 - * @date 21-July-2015 - * @brief This file contains all the functions prototypes for the IDD driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __IDD_H -#define __IDD_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup Components - * @{ - */ - -/** @addtogroup IDD - * @{ - */ - -/** @defgroup IDD_Exported_Types IDD Exported Types - * @{ - */ - -/** @defgroup IDD_Config_structure IDD Configuration structure - * @{ - */ -typedef struct -{ - uint16_t AmpliGain; /*!< Specifies ampli gain value - */ - uint16_t VddMin; /*!< Specifies minimum MCU VDD can reach to protect MCU from reset - */ - uint16_t Shunt0Value; /*!< Specifies value of Shunt 0 if existing - */ - uint16_t Shunt1Value; /*!< Specifies value of Shunt 1 if existing - */ - uint16_t Shunt2Value; /*!< Specifies value of Shunt 2 if existing - */ - uint16_t Shunt3Value; /*!< Specifies value of Shunt 3 if existing - */ - uint16_t Shunt4Value; /*!< Specifies value of Shunt 4 if existing - */ - uint16_t Shunt0StabDelay; /*!< Specifies delay of Shunt 0 stabilization if existing - */ - uint16_t Shunt1StabDelay; /*!< Specifies delay of Shunt 1 stabilization if existing - */ - uint16_t Shunt2StabDelay; /*!< Specifies delay of Shunt 2 stabilization if existing - */ - uint16_t Shunt3StabDelay; /*!< Specifies delay of Shunt 3 stabilization if existing - */ - uint16_t Shunt4StabDelay; /*!< Specifies delay of Shunt 4 stabilization if existing - */ - uint8_t ShuntNbOnBoard; /*!< Specifies number of shunts that are present on board - This parameter can be a value of @ref IDD_shunt_number */ - uint8_t ShuntNbUsed; /*!< Specifies number of shunts used for measurement - This parameter can be a value of @ref IDD_shunt_number */ - uint8_t VrefMeasurement; /*!< Specifies if Vref is automatically measured before each Idd measurement - This parameter can be a value of @ref IDD_Vref_Measurement */ - uint8_t Calibration; /*!< Specifies if calibration is done before each Idd measurement - */ - uint8_t PreDelayUnit; /*!< Specifies Pre delay unit - This parameter can be a value of @ref IDD_PreDelay */ - uint8_t PreDelayValue; /*!< Specifies Pre delay value in selected unit - */ - uint8_t MeasureNb; /*!< Specifies number of Measure to be performed - This parameter can be a value between 1 and 256 */ - uint8_t DeltaDelayUnit; /*!< Specifies Delta delay unit - This parameter can be a value of @ref IDD_DeltaDelay */ - uint8_t DeltaDelayValue; /*!< Specifies Delta delay between 2 measures - value can be between 1 and 128 */ -}IDD_ConfigTypeDef; -/** - * @} - */ - -/** @defgroup IDD_Driver_structure IDD Driver structure - * @{ - */ -typedef struct -{ - void (*Init)(uint16_t); - void (*DeInit)(uint16_t); - uint16_t (*ReadID)(uint16_t); - void (*Reset)(uint16_t); - void (*LowPower)(uint16_t); - void (*WakeUp)(uint16_t); - void (*Start)(uint16_t); - void (*Config)(uint16_t,IDD_ConfigTypeDef); - void (*GetValue)(uint16_t, uint32_t *); - void (*EnableIT)(uint16_t); - void (*ClearIT)(uint16_t); - uint8_t (*GetITStatus)(uint16_t); - void (*DisableIT)(uint16_t); - void (*ErrorEnableIT)(uint16_t); - void (*ErrorClearIT)(uint16_t); - uint8_t (*ErrorGetITStatus)(uint16_t); - void (*ErrorDisableIT)(uint16_t); - uint8_t (*ErrorGetSrc)(uint16_t); - uint8_t (*ErrorGetCode)(uint16_t); -}IDD_DrvTypeDef; -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __IDD_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/Common/io.h b/bsp/stm32f411RE/Libraries/BSP/Components/Common/io.h deleted file mode 100644 index b33c00e669..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/Common/io.h +++ /dev/null @@ -1,150 +0,0 @@ -/** - ****************************************************************************** - * @file io.h - * @author MCD Application Team - * @version V4.0.1 - * @date 21-July-2015 - * @brief This file contains all the functions prototypes for the IO driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __IO_H -#define __IO_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup Components - * @{ - */ - -/** @addtogroup IO - * @{ - */ - -/** @defgroup IO_Exported_Types - * @{ - */ - -/** - * @brief IO Bit SET and Bit RESET enumeration - */ -typedef enum -{ - IO_PIN_RESET = 0, - IO_PIN_SET -}IO_PinState; - -typedef enum -{ - IO_MODE_INPUT = 0, /* input floating */ - IO_MODE_OUTPUT, /* output Push Pull */ - IO_MODE_IT_RISING_EDGE, /* float input - irq detect on rising edge */ - IO_MODE_IT_FALLING_EDGE, /* float input - irq detect on falling edge */ - IO_MODE_IT_LOW_LEVEL, /* float input - irq detect on low level */ - IO_MODE_IT_HIGH_LEVEL, /* float input - irq detect on high level */ - /* following modes only available on MFX*/ - IO_MODE_ANALOG, /* analog mode */ - IO_MODE_OFF, /* when pin isn't used*/ - IO_MODE_INPUT_PU, /* input with internal pull up resistor */ - IO_MODE_INPUT_PD, /* input with internal pull down resistor */ - IO_MODE_OUTPUT_OD, /* Open Drain output without internal resistor */ - IO_MODE_OUTPUT_OD_PU, /* Open Drain output with internal pullup resistor */ - IO_MODE_OUTPUT_OD_PD, /* Open Drain output with internal pulldown resistor */ - IO_MODE_OUTPUT_PP, /* PushPull output without internal resistor */ - IO_MODE_OUTPUT_PP_PU, /* PushPull output with internal pullup resistor */ - IO_MODE_OUTPUT_PP_PD, /* PushPull output with internal pulldown resistor */ - IO_MODE_IT_RISING_EDGE_PU, /* push up resistor input - irq on rising edge */ - IO_MODE_IT_RISING_EDGE_PD, /* push dw resistor input - irq on rising edge */ - IO_MODE_IT_FALLING_EDGE_PU, /* push up resistor input - irq on falling edge */ - IO_MODE_IT_FALLING_EDGE_PD, /* push dw resistor input - irq on falling edge */ - IO_MODE_IT_LOW_LEVEL_PU, /* push up resistor input - irq detect on low level */ - IO_MODE_IT_LOW_LEVEL_PD, /* push dw resistor input - irq detect on low level */ - IO_MODE_IT_HIGH_LEVEL_PU, /* push up resistor input - irq detect on high level */ - IO_MODE_IT_HIGH_LEVEL_PD, /* push dw resistor input - irq detect on high level */ - -}IO_ModeTypedef; - -/** @defgroup IO_Driver_structure IO Driver structure - * @{ - */ -typedef struct -{ - void (*Init)(uint16_t); - uint16_t (*ReadID)(uint16_t); - void (*Reset)(uint16_t); - - void (*Start)(uint16_t, uint32_t); - uint8_t (*Config)(uint16_t, uint32_t, IO_ModeTypedef); - void (*WritePin)(uint16_t, uint32_t, uint8_t); - uint32_t (*ReadPin)(uint16_t, uint32_t); - - void (*EnableIT)(uint16_t); - void (*DisableIT)(uint16_t); - uint32_t (*ITStatus)(uint16_t, uint32_t); - void (*ClearIT)(uint16_t, uint32_t); - -}IO_DrvTypeDef; -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __IO_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/Common/lcd.h b/bsp/stm32f411RE/Libraries/BSP/Components/Common/lcd.h deleted file mode 100644 index 9ff398b4e9..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/Common/lcd.h +++ /dev/null @@ -1,114 +0,0 @@ -/** - ****************************************************************************** - * @file lcd.h - * @author MCD Application Team - * @version V4.0.1 - * @date 21-July-2015 - * @brief This file contains all the functions prototypes for the LCD driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __LCD_H -#define __LCD_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup Components - * @{ - */ - -/** @addtogroup LCD - * @{ - */ - -/** @defgroup LCD_Exported_Types - * @{ - */ - -/** @defgroup LCD_Driver_structure LCD Driver structure - * @{ - */ -typedef struct -{ - void (*Init)(void); - uint16_t (*ReadID)(void); - void (*DisplayOn)(void); - void (*DisplayOff)(void); - void (*SetCursor)(uint16_t, uint16_t); - void (*WritePixel)(uint16_t, uint16_t, uint16_t); - uint16_t (*ReadPixel)(uint16_t, uint16_t); - - /* Optimized operation */ - void (*SetDisplayWindow)(uint16_t, uint16_t, uint16_t, uint16_t); - void (*DrawHLine)(uint16_t, uint16_t, uint16_t, uint16_t); - void (*DrawVLine)(uint16_t, uint16_t, uint16_t, uint16_t); - - uint16_t (*GetLcdPixelWidth)(void); - uint16_t (*GetLcdPixelHeight)(void); - void (*DrawBitmap)(uint16_t, uint16_t, uint8_t*); - void (*DrawRGBImage)(uint16_t, uint16_t, uint16_t, uint16_t, uint8_t*); -}LCD_DrvTypeDef; -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __LCD_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/Common/magneto.h b/bsp/stm32f411RE/Libraries/BSP/Components/Common/magneto.h deleted file mode 100644 index dc27dd03ab..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/Common/magneto.h +++ /dev/null @@ -1,125 +0,0 @@ -/** - ****************************************************************************** - * @file magneto.h - * @author MCD Application Team - * @version V4.0.1 - * @date 21-July-2015 - * @brief This header file contains the functions prototypes for the MAGNETO driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __MAGNETO_H -#define __MAGNETO_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup Components - * @{ - */ - -/** @addtogroup MAGNETO - * @{ - */ - -/** @defgroup MAGNETO_Exported_Types - * @{ - */ - -/** @defgroup MAGNETO_Config_structure Magnetometer Configuration structure - * @{ - */ -typedef struct -{ - uint8_t Register1; - uint8_t Register2; - uint8_t Register3; - uint8_t Register4; - uint8_t Register5; -}MAGNETO_InitTypeDef; -/** - * @} - */ - -/** @defgroup MAGNETO_Driver_structure Magnetometer Driver structure - * @{ - */ -typedef struct -{ - void (*Init)(MAGNETO_InitTypeDef); - void (*DeInit)(void); - uint8_t (*ReadID)(void); - void (*Reset)(void); - void (*LowPower)(void); - void (*ConfigIT)(void); - void (*EnableIT)(uint8_t); - void (*DisableIT)(uint8_t); - uint8_t (*ITStatus)(uint16_t); - void (*ClearIT)(void); - void (*FilterConfig)(uint8_t); - void (*FilterCmd)(uint8_t); - void (*GetXYZ)(int16_t *); -}MAGNETO_DrvTypeDef; -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __MAGNETO_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/Common/ts.h b/bsp/stm32f411RE/Libraries/BSP/Components/Common/ts.h deleted file mode 100644 index 73705964bd..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/Common/ts.h +++ /dev/null @@ -1,107 +0,0 @@ -/** - ****************************************************************************** - * @file ts.h - * @author MCD Application Team - * @version V4.0.1 - * @date 21-July-2015 - * @brief This file contains all the functions prototypes for the Touch Screen driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __TS_H -#define __TS_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup Components - * @{ - */ - -/** @addtogroup TS - * @{ - */ - -/** @defgroup TS_Exported_Types - * @{ - */ - -/** @defgroup TS_Driver_structure Touch Sensor Driver structure - * @{ - */ -typedef struct -{ - void (*Init)(uint16_t); - uint16_t (*ReadID)(uint16_t); - void (*Reset)(uint16_t); - void (*Start)(uint16_t); - uint8_t (*DetectTouch)(uint16_t); - void (*GetXY)(uint16_t, uint16_t*, uint16_t*); - void (*EnableIT)(uint16_t); - void (*ClearIT)(uint16_t); - uint8_t (*GetITStatus)(uint16_t); - void (*DisableIT)(uint16_t); -}TS_DrvTypeDef; -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __TS_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/Common/tsensor.h b/bsp/stm32f411RE/Libraries/BSP/Components/Common/tsensor.h deleted file mode 100644 index 4ea0ffc217..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/Common/tsensor.h +++ /dev/null @@ -1,118 +0,0 @@ -/** - ****************************************************************************** - * @file tsensor.h - * @author MCD Application Team - * @version V4.0.1 - * @date 21-July-2015 - * @brief This header file contains the functions prototypes for the - * Temperature Sensor driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __TSENSOR_H -#define __TSENSOR_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup Components - * @{ - */ - -/** @addtogroup TSENSOR - * @{ - */ - -/** @defgroup TSENSOR_Exported_Types - * @{ - */ - -/** @defgroup TSENSOR_Config_structure Temperature Sensor Configuration structure - * @{ - */ -typedef struct -{ - uint8_t AlertMode; /* Alert Mode Temperature out of range*/ - uint8_t ConversionMode; /* Continuous/One Shot Mode */ - uint8_t ConversionResolution; /* Temperature Resolution */ - uint8_t ConversionRate; /* Number of measure per second */ - uint8_t TemperatureLimitHigh; /* High Temperature Limit Range */ - uint8_t TemperatureLimitLow; /* Low Temperature Limit Range */ -}TSENSOR_InitTypeDef; -/** - * @} - */ - -/** @defgroup TSENSOR_Driver_structure Temperature Sensor Driver structure - * @{ - */ -typedef struct -{ - void (*Init)(uint16_t, TSENSOR_InitTypeDef *); - uint8_t (*IsReady)(uint16_t, uint32_t); - uint8_t (*ReadStatus)(uint16_t); - uint16_t (*ReadTemp)(uint16_t); -}TSENSOR_DrvTypeDef; -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __TSENSOR_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/ampire480272/Release_Notes.html b/bsp/stm32f411RE/Libraries/BSP/Components/ampire480272/Release_Notes.html deleted file mode 100644 index 0acbf7e8fa..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/ampire480272/Release_Notes.html +++ /dev/null @@ -1,231 +0,0 @@ - - - - - - - - - - - - - - - - - - - Release Notes for Ampire480272 LCD Component Driver - - - - - - - - - -
-


-

-
- - - - - - -
- - - - - - - - - -
-

Back to Release page

-
-

Release -Notes for Ampire480272 LCD Component Driver

-

Copyright -2014 STMicroelectronics

-

-
-

 

- - - - - - -
- - -

Update History

-

V1.0.0 / 18-February-2014

- - - - - - - - - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- - - - - -
    -
  • - - First official release
  • -

License

-
-Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met:
-
-
  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions -in binary form must reproduce the above copyright notice, this list of -conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of STMicroelectronics nor the names of its contributors may be used to endorse or promote products derived
    -
    -
-        from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- -
-

- - -
-
-

For -complete documentation on STM32 Microcontrollers -visit www.st.com/STM32

-
-

-
-
-

 

-
- - \ No newline at end of file diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/ampire480272/ampire480272.h b/bsp/stm32f411RE/Libraries/BSP/Components/ampire480272/ampire480272.h deleted file mode 100644 index cafb53c3ca..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/ampire480272/ampire480272.h +++ /dev/null @@ -1,121 +0,0 @@ -/** - ****************************************************************************** - * @file ampire480272.h - * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 - * @brief This file contains all the constants parameters for the ampire480272 - * LCD component. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2014 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __AMPIRE480272_H -#define __AMPIRE480272_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup Components - * @{ - */ - -/** @addtogroup ampire480272 - * @{ - */ - -/** @defgroup AMPIRE480272_Exported_Types - * @{ - */ - -/** - * @} - */ - -/** @defgroup AMPIRE480272_Exported_Constants - * @{ - */ - -/** - * @brief AMPIRE480272 Size - */ -#define AMPIRE480272_WIDTH ((uint16_t)480) /* LCD PIXEL WIDTH */ -#define AMPIRE480272_HEIGHT ((uint16_t)272) /* LCD PIXEL HEIGHT */ - -/** - * @brief AMPIRE480272 Timing - */ -#define AMPIRE480272_HSYNC ((uint16_t)41) /* Horizontal synchronization */ -#define AMPIRE480272_HBP ((uint16_t)2) /* Horizontal back porch */ -#define AMPIRE480272_HFP ((uint16_t)2) /* Horizontal front porch */ -#define AMPIRE480272_VSYNC ((uint16_t)10) /* Vertical synchronization */ -#define AMPIRE480272_VBP ((uint16_t)2) /* Vertical back porch */ -#define AMPIRE480272_VFP ((uint16_t)2) /* Vertical front porch */ - -/** - * @brief AMPIRE480272 frequency divider - */ -#define AMPIRE480272_FREQUENCY_DIVIDER 5 /* LCD Frequency divider */ -/** - * @} - */ - -/** @defgroup AMPIRE480272_Exported_Functions - * @{ - */ - -/** - * @} - */ -#ifdef __cplusplus -} -#endif - -#endif /* __AMPIRE480272_H */ -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/ampire640480/Release_Notes.html b/bsp/stm32f411RE/Libraries/BSP/Components/ampire640480/Release_Notes.html deleted file mode 100644 index b3ddcb0b64..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/ampire640480/Release_Notes.html +++ /dev/null @@ -1,232 +0,0 @@ - - - - - - - - - - - - - - - - - - - Release Notes for Ampire480272 LCD Component Driver - - - - - - - - - -
-


-

-
- - - - - - -
- - - - - - - - - -
-

Back to Release page

-
-

Release -Notes for Ampire640480 LCD Component Driver

-

Copyright -2014 STMicroelectronics

-

-
-

 

- - - - - - -
- - -

Update History

-

V1.0.0 / 18-February-2014

- - - - - - - - - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- - - - - - -
    -
  • First official release
  • -

License

-
-Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met:
-
-
  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions -in binary form must reproduce the above copyright notice, this list of -conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of STMicroelectronics nor the names of its contributors may be used to endorse or promote products derived
    -
    -
-        from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- -
-

- - -
-
-

For -complete documentation on STM32 Microcontrollers -visit www.st.com/STM32

-
-

-
-
-

 

-
- - \ No newline at end of file diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/ampire640480/ampire640480.h b/bsp/stm32f411RE/Libraries/BSP/Components/ampire640480/ampire640480.h deleted file mode 100644 index 2e49c7cc7e..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/ampire640480/ampire640480.h +++ /dev/null @@ -1,121 +0,0 @@ -/** - ****************************************************************************** - * @file ampire640480.h - * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 - * @brief This file contains all the constants parameters for the ampire640480 - * LCD component. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2014 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __AMPIRE640480_H -#define __AMPIRE640480_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup Components - * @{ - */ - -/** @addtogroup ampire640480 - * @{ - */ - -/** @defgroup AMPIRE640480_Exported_Types - * @{ - */ - -/** - * @} - */ - -/** @defgroup AMPIRE640480_Exported_Constants - * @{ - */ - -/** - * @brief AMPIRE640480 Size - */ -#define AMPIRE640480_WIDTH ((uint16_t)640) /* LCD PIXEL WIDTH */ -#define AMPIRE640480_HEIGHT ((uint16_t)480) /* LCD PIXEL HEIGHT */ - -/** - * @brief AMPIRE640480 Timing - */ -#define AMPIRE640480_HSYNC ((uint16_t)30) /* Horizontal synchronization */ -#define AMPIRE640480_HBP ((uint16_t)114) /* Horizontal back porch */ -#define AMPIRE640480_HFP ((uint16_t)16) /* Horizontal front porch */ -#define AMPIRE640480_VSYNC ((uint16_t)3) /* Vertical synchronization */ -#define AMPIRE640480_VBP ((uint16_t)32) /* Vertical back porch */ -#define AMPIRE640480_VFP ((uint16_t)10) /* Vertical front porch */ - -/** - * @brief AMPIRE640480 frequency divider - */ -#define AMPIRE640480_FREQUENCY_DIVIDER 3 /* LCD Frequency divider */ -/** - * @} - */ - -/** @defgroup AMPIRE640480_Exported_Functions - * @{ - */ - -/** - * @} - */ -#ifdef __cplusplus -} -#endif - -#endif /* __AMPIRE640480_H */ -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/cs43l22/Release_Notes.html b/bsp/stm32f411RE/Libraries/BSP/Components/cs43l22/Release_Notes.html deleted file mode 100644 index e70b212145..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/cs43l22/Release_Notes.html +++ /dev/null @@ -1,659 +0,0 @@ - - - - - - - - - - - - - - - - - - - - Release Notes for CS43L22 Component Driver - - - - - - - - - - -
-


-

-
- - - - - - -
- - - - - - - - - -
-

Back to Release page

-
-

Release -Notes for CS43L22 Component Driver

-

Copyright -2014 STMicroelectronics

-

-
-

 

- - - - - - -
- - -

Update History

-

V2.0.2 / 02-October-2015

- - - - - - - - - - - - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  • cs43l22.c/.h: 
    • Move VOLUME_CONVERT macro from cs43l22.h to cs43l22.c as internally used to convert volume.
    • Add literals instead of magic number for cs34l22 registers.

V2.0.1 / 16-September-2015

- - - - - - - - - - - - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  • cs43l22.c: 
    • Enable the digital soft ramp to avoid clac noise.
    • Improve mute/unmute by muting/unmuting also the DAC inputs. 

V2.0.0 / 24-June-2015

- - - - - - - - - - - - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  • cs43l22.h/.c: 
    • Add codec de-initialization function: cs43l22_DeInit()
    • Add Audio IO de-initialization function prototype: AUDIO_IO_DeInit()
    • NOTE: This release must be used with BSP Common -driver V4.0.0 or later

V1.1.0 / 10-February-2015

- - - - - - - - - - - - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  • cs43l22.h/.c: 
    • Add AUDIO_FREQUENCY_xxx defines for frequencies capabilities (8K to 192K)
    • Add codec reset function: cs43l22_Reset()

V1.0.1 / 02-December-2014

- - - - - - - - - - - - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
  • cs43l22.h: change "\" by "/" in the include path to fix compilation issue under Linux
  • -
- -

V1.0.0 / 18-February-2014

- - - - - - - - - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
  • First official release of CS43L22 audio codec  
  • -

License

-
-Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met:
-
-
  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions -in binary form must reproduce the above copyright notice, this list of -conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of STMicroelectronics nor the names of its contributors may be used to endorse or promote products derived
    -
    -
-        from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- -
-

- - -
-
-

For -complete documentation on STM32 Microcontrollers -visit www.st.com/STM32

-
-

-
-
-

 

-
- - \ No newline at end of file diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/cs43l22/cs43l22.c b/bsp/stm32f411RE/Libraries/BSP/Components/cs43l22/cs43l22.c deleted file mode 100644 index c54ad847fc..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/cs43l22/cs43l22.c +++ /dev/null @@ -1,494 +0,0 @@ -/** - ****************************************************************************** - * @file cs43l22.c - * @author MCD Application Team - * @version V2.0.2 - * @date 06-October-2015 - * @brief This file provides the CS43L22 Audio Codec driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Includes ------------------------------------------------------------------*/ -#include "cs43l22.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup Components - * @{ - */ - -/** @addtogroup CS43L22 - * @brief This file provides a set of functions needed to drive the - * CS43L22 audio codec. - * @{ - */ - -/** @defgroup CS43L22_Private_Types - * @{ - */ - -/** - * @} - */ - -/** @defgroup CS43L22_Private_Defines - * @{ - */ -#define VOLUME_CONVERT(Volume) (((Volume) > 100)? 100:((uint8_t)(((Volume) * 255) / 100))) -/* Uncomment this line to enable verifying data sent to codec after each write - operation (for debug purpose) */ -#if !defined (VERIFY_WRITTENDATA) -/* #define VERIFY_WRITTENDATA */ -#endif /* VERIFY_WRITTENDATA */ -/** - * @} - */ - -/** @defgroup CS43L22_Private_Macros - * @{ - */ - -/** - * @} - */ - -/** @defgroup CS43L22_Private_Variables - * @{ - */ - -/* Audio codec driver structure initialization */ -AUDIO_DrvTypeDef cs43l22_drv = -{ - cs43l22_Init, - cs43l22_DeInit, - cs43l22_ReadID, - - cs43l22_Play, - cs43l22_Pause, - cs43l22_Resume, - cs43l22_Stop, - - cs43l22_SetFrequency, - cs43l22_SetVolume, - cs43l22_SetMute, - cs43l22_SetOutputMode, - cs43l22_Reset, -}; - -static uint8_t Is_cs43l22_Stop = 1; - -volatile uint8_t OutputDev = 0; - -/** - * @} - */ - -/** @defgroup CS43L22_Function_Prototypes - * @{ - */ -static uint8_t CODEC_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value); -/** - * @} - */ - -/** @defgroup CS43L22_Private_Functions - * @{ - */ - -/** - * @brief Initializes the audio codec and the control interface. - * @param DeviceAddr: Device address on communication Bus. - * @param OutputDevice: can be OUTPUT_DEVICE_SPEAKER, OUTPUT_DEVICE_HEADPHONE, - * OUTPUT_DEVICE_BOTH or OUTPUT_DEVICE_AUTO . - * @param Volume: Initial volume level (from 0 (Mute) to 100 (Max)) - * @retval 0 if correct communication, else wrong communication - */ -uint32_t cs43l22_Init(uint16_t DeviceAddr, uint16_t OutputDevice, uint8_t Volume, uint32_t AudioFreq) -{ - uint32_t counter = 0; - - /* Initialize the Control interface of the Audio Codec */ - AUDIO_IO_Init(); - - /* Keep Codec powered OFF */ - counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_POWER_CTL1, 0x01); - - /*Save Output device for mute ON/OFF procedure*/ - switch (OutputDevice) - { - case OUTPUT_DEVICE_SPEAKER: - OutputDev = 0xFA; - break; - - case OUTPUT_DEVICE_HEADPHONE: - OutputDev = 0xAF; - break; - - case OUTPUT_DEVICE_BOTH: - OutputDev = 0xAA; - break; - - case OUTPUT_DEVICE_AUTO: - OutputDev = 0x05; - break; - - default: - OutputDev = 0x05; - break; - } - - counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_POWER_CTL2, OutputDev); - - /* Clock configuration: Auto detection */ - counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_CLOCKING_CTL, 0x81); - - /* Set the Slave Mode and the audio Standard */ - counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_INTERFACE_CTL1, CODEC_STANDARD); - - /* Set the Master volume */ - counter += cs43l22_SetVolume(DeviceAddr, Volume); - - /* If the Speaker is enabled, set the Mono mode and volume attenuation level */ - if(OutputDevice != OUTPUT_DEVICE_HEADPHONE) - { - /* Set the Speaker Mono mode */ - counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_PLAYBACK_CTL2, 0x06); - - /* Set the Speaker attenuation level */ - counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_SPEAKER_A_VOL, 0x00); - counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_SPEAKER_B_VOL, 0x00); - } - - /* Additional configuration for the CODEC. These configurations are done to reduce - the time needed for the Codec to power off. If these configurations are removed, - then a long delay should be added between powering off the Codec and switching - off the I2S peripheral MCLK clock (which is the operating clock for Codec). - If this delay is not inserted, then the codec will not shut down properly and - it results in high noise after shut down. */ - - /* Disable the analog soft ramp */ - counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_ANALOG_ZC_SR_SETT, 0x00); - /* Disable the digital soft ramp */ - counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_MISC_CTL, 0x04); - /* Disable the limiter attack level */ - counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_LIMIT_CTL1, 0x00); - /* Adjust Bass and Treble levels */ - counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_TONE_CTL, 0x0F); - /* Adjust PCM volume level */ - counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_PCMA_VOL, 0x0A); - counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_PCMB_VOL, 0x0A); - - /* Return communication control value */ - return counter; -} - -/** - * @brief Deinitializes the audio codec. - * @param None - * @retval None - */ -void cs43l22_DeInit(void) -{ - /* Deinitialize Audio Codec interface */ - AUDIO_IO_DeInit(); -} - -/** - * @brief Get the CS43L22 ID. - * @param DeviceAddr: Device address on communication Bus. - * @retval The CS43L22 ID - */ -uint32_t cs43l22_ReadID(uint16_t DeviceAddr) -{ - uint8_t Value; - /* Initialize the Control interface of the Audio Codec */ - AUDIO_IO_Init(); - - Value = AUDIO_IO_Read(DeviceAddr, CS43L22_CHIPID_ADDR); - Value = (Value & CS43L22_ID_MASK); - - return((uint32_t) Value); -} - -/** - * @brief Start the audio Codec play feature. - * @note For this codec no Play options are required. - * @param DeviceAddr: Device address on communication Bus. - * @retval 0 if correct communication, else wrong communication - */ -uint32_t cs43l22_Play(uint16_t DeviceAddr, uint16_t* pBuffer, uint16_t Size) -{ - uint32_t counter = 0; - - if(Is_cs43l22_Stop == 1) - { - /* Enable the digital soft ramp */ - counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_MISC_CTL, 0x06); - - /* Enable Output device */ - counter += cs43l22_SetMute(DeviceAddr, AUDIO_MUTE_OFF); - - /* Power on the Codec */ - counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_POWER_CTL1, 0x9E); - Is_cs43l22_Stop = 0; - } - - /* Return communication control value */ - return counter; -} - -/** - * @brief Pauses playing on the audio codec. - * @param DeviceAddr: Device address on communication Bus. - * @retval 0 if correct communication, else wrong communication - */ -uint32_t cs43l22_Pause(uint16_t DeviceAddr) -{ - uint32_t counter = 0; - - /* Pause the audio file playing */ - /* Mute the output first */ - counter += cs43l22_SetMute(DeviceAddr, AUDIO_MUTE_ON); - - /* Put the Codec in Power save mode */ - counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_POWER_CTL1, 0x01); - - return counter; -} - -/** - * @brief Resumes playing on the audio codec. - * @param DeviceAddr: Device address on communication Bus. - * @retval 0 if correct communication, else wrong communication - */ -uint32_t cs43l22_Resume(uint16_t DeviceAddr) -{ - uint32_t counter = 0; - volatile uint32_t index = 0x00; - /* Resumes the audio file playing */ - /* Unmute the output first */ - counter += cs43l22_SetMute(DeviceAddr, AUDIO_MUTE_OFF); - - for(index = 0x00; index < 0xFF; index++); - - counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_POWER_CTL2, OutputDev); - - /* Exit the Power save mode */ - counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_POWER_CTL1, 0x9E); - - return counter; -} - -/** - * @brief Stops audio Codec playing. It powers down the codec. - * @param DeviceAddr: Device address on communication Bus. - * @param CodecPdwnMode: selects the power down mode. - * - CODEC_PDWN_HW: Physically power down the codec. When resuming from this - * mode, the codec is set to default configuration - * (user should re-Initialize the codec in order to - * play again the audio stream). - * @retval 0 if correct communication, else wrong communication - */ -uint32_t cs43l22_Stop(uint16_t DeviceAddr, uint32_t CodecPdwnMode) -{ - uint32_t counter = 0; - - /* Mute the output first */ - counter += cs43l22_SetMute(DeviceAddr, AUDIO_MUTE_ON); - - /* Disable the digital soft ramp */ - counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_MISC_CTL, 0x04); - - /* Power down the DAC and the speaker (PMDAC and PMSPK bits)*/ - counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_POWER_CTL1, 0x9F); - - Is_cs43l22_Stop = 1; - return counter; -} - -/** - * @brief Sets higher or lower the codec volume level. - * @param DeviceAddr: Device address on communication Bus. - * @param Volume: a byte value from 0 to 255 (refer to codec registers - * description for more details). - * @retval 0 if correct communication, else wrong communication - */ -uint32_t cs43l22_SetVolume(uint16_t DeviceAddr, uint8_t Volume) -{ - uint32_t counter = 0; - uint8_t convertedvol = VOLUME_CONVERT(Volume); - - if(Volume > 0xE6) - { - /* Set the Master volume */ - counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_MASTER_A_VOL, convertedvol - 0xE7); - counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_MASTER_B_VOL, convertedvol - 0xE7); - } - else - { - /* Set the Master volume */ - counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_MASTER_A_VOL, convertedvol + 0x19); - counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_MASTER_B_VOL, convertedvol + 0x19); - } - - return counter; -} - -/** - * @brief Sets new frequency. - * @param DeviceAddr: Device address on communication Bus. - * @param AudioFreq: Audio frequency used to play the audio stream. - * @retval 0 if correct communication, else wrong communication - */ -uint32_t cs43l22_SetFrequency(uint16_t DeviceAddr, uint32_t AudioFreq) -{ - return 0; -} - -/** - * @brief Enables or disables the mute feature on the audio codec. - * @param DeviceAddr: Device address on communication Bus. - * @param Cmd: AUDIO_MUTE_ON to enable the mute or AUDIO_MUTE_OFF to disable the - * mute mode. - * @retval 0 if correct communication, else wrong communication - */ -uint32_t cs43l22_SetMute(uint16_t DeviceAddr, uint32_t Cmd) -{ - uint32_t counter = 0; - - /* Set the Mute mode */ - if(Cmd == AUDIO_MUTE_ON) - { - counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_POWER_CTL2, 0xFF); - counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_HEADPHONE_A_VOL, 0x01); - counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_HEADPHONE_B_VOL, 0x01); - } - else /* AUDIO_MUTE_OFF Disable the Mute */ - { - counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_HEADPHONE_A_VOL, 0x00); - counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_HEADPHONE_B_VOL, 0x00); - counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_POWER_CTL2, OutputDev); - } - return counter; -} - -/** - * @brief Switch dynamically (while audio file is played) the output target - * (speaker or headphone). - * @note This function modifies a global variable of the audio codec driver: OutputDev. - * @param DeviceAddr: Device address on communication Bus. - * @param Output: specifies the audio output target: OUTPUT_DEVICE_SPEAKER, - * OUTPUT_DEVICE_HEADPHONE, OUTPUT_DEVICE_BOTH or OUTPUT_DEVICE_AUTO - * @retval 0 if correct communication, else wrong communication - */ -uint32_t cs43l22_SetOutputMode(uint16_t DeviceAddr, uint8_t Output) -{ - uint32_t counter = 0; - - switch (Output) - { - case OUTPUT_DEVICE_SPEAKER: - counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_POWER_CTL2, 0xFA); /* SPK always ON & HP always OFF */ - OutputDev = 0xFA; - break; - - case OUTPUT_DEVICE_HEADPHONE: - counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_POWER_CTL2, 0xAF); /* SPK always OFF & HP always ON */ - OutputDev = 0xAF; - break; - - case OUTPUT_DEVICE_BOTH: - counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_POWER_CTL2, 0xAA); /* SPK always ON & HP always ON */ - OutputDev = 0xAA; - break; - - case OUTPUT_DEVICE_AUTO: - counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_POWER_CTL2, 0x05); /* Detect the HP or the SPK automatically */ - OutputDev = 0x05; - break; - - default: - counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_POWER_CTL2, 0x05); /* Detect the HP or the SPK automatically */ - OutputDev = 0x05; - break; - } - return counter; -} - -/** - * @brief Resets cs43l22 registers. - * @param DeviceAddr: Device address on communication Bus. - * @retval 0 if correct communication, else wrong communication - */ -uint32_t cs43l22_Reset(uint16_t DeviceAddr) -{ - return 0; -} - -/** - * @brief Writes/Read a single data. - * @param Addr: I2C address - * @param Reg: Reg address - * @param Value: Data to be written - * @retval None - */ -static uint8_t CODEC_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value) -{ - uint32_t result = 0; - - AUDIO_IO_Write(Addr, Reg, Value); - -#ifdef VERIFY_WRITTENDATA - /* Verify that the data has been correctly written */ - result = (AUDIO_IO_Read(Addr, Reg) == Value)? 0:1; -#endif /* VERIFY_WRITTENDATA */ - - return result; -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/cs43l22/cs43l22.h b/bsp/stm32f411RE/Libraries/BSP/Components/cs43l22/cs43l22.h deleted file mode 100644 index d17853176a..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/cs43l22/cs43l22.h +++ /dev/null @@ -1,228 +0,0 @@ -/** - ****************************************************************************** - * @file cs43l22.h - * @author MCD Application Team - * @version V2.0.2 - * @date 06-October-2015 - * @brief This file contains all the functions prototypes for the cs43l22.c driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __CS43L22_H -#define __CS43L22_H - -/* Includes ------------------------------------------------------------------*/ -#include "../Common/audio.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup Component - * @{ - */ - -/** @addtogroup CS43L22 - * @{ - */ - -/** @defgroup CS43L22_Exported_Types - * @{ - */ - -/** - * @} - */ - -/** @defgroup CS43L22_Exported_Constants - * @{ - */ - -/******************************************************************************/ -/*************************** Codec User defines ******************************/ -/******************************************************************************/ -/* Codec output DEVICE */ -#define OUTPUT_DEVICE_SPEAKER 1 -#define OUTPUT_DEVICE_HEADPHONE 2 -#define OUTPUT_DEVICE_BOTH 3 -#define OUTPUT_DEVICE_AUTO 4 - -/* Volume Levels values */ -#define DEFAULT_VOLMIN 0x00 -#define DEFAULT_VOLMAX 0xFF -#define DEFAULT_VOLSTEP 0x04 - -#define AUDIO_PAUSE 0 -#define AUDIO_RESUME 1 - -/* Codec POWER DOWN modes */ -#define CODEC_PDWN_HW 1 -#define CODEC_PDWN_SW 2 - -/* MUTE commands */ -#define AUDIO_MUTE_ON 1 -#define AUDIO_MUTE_OFF 0 - -/* AUDIO FREQUENCY */ -#define AUDIO_FREQUENCY_192K ((uint32_t)192000) -#define AUDIO_FREQUENCY_96K ((uint32_t)96000) -#define AUDIO_FREQUENCY_48K ((uint32_t)48000) -#define AUDIO_FREQUENCY_44K ((uint32_t)44100) -#define AUDIO_FREQUENCY_32K ((uint32_t)32000) -#define AUDIO_FREQUENCY_22K ((uint32_t)22050) -#define AUDIO_FREQUENCY_16K ((uint32_t)16000) -#define AUDIO_FREQUENCY_11K ((uint32_t)11025) -#define AUDIO_FREQUENCY_8K ((uint32_t)8000) - -/** CS43l22 Registers ***/ -#define CS43L22_REG_ID 0x01 -#define CS43L22_REG_POWER_CTL1 0x02 -#define CS43L22_REG_POWER_CTL2 0x04 -#define CS43L22_REG_CLOCKING_CTL 0x05 -#define CS43L22_REG_INTERFACE_CTL1 0x06 -#define CS43L22_REG_INTERFACE_CTL2 0x07 -#define CS43L22_REG_PASSTHR_A_SELECT 0x08 -#define CS43L22_REG_PASSTHR_B_SELECT 0x09 -#define CS43L22_REG_ANALOG_ZC_SR_SETT 0x0A -#define CS43L22_REG_PASSTHR_GANG_CTL 0x0C -#define CS43L22_REG_PLAYBACK_CTL1 0x0D -#define CS43L22_REG_MISC_CTL 0x0E -#define CS43L22_REG_PLAYBACK_CTL2 0x0F -#define CS43L22_REG_PASSTHR_A_VOL 0x14 -#define CS43L22_REG_PASSTHR_B_VOL 0x15 -#define CS43L22_REG_PCMA_VOL 0x1A -#define CS43L22_REG_PCMB_VOL 0x1B -#define CS43L22_REG_BEEP_FREQ_ON_TIME 0x1C -#define CS43L22_REG_BEEP_VOL_OFF_TIME 0x1D -#define CS43L22_REG_BEEP_TONE_CFG 0x1E -#define CS43L22_REG_TONE_CTL 0x1F -#define CS43L22_REG_MASTER_A_VOL 0x20 -#define CS43L22_REG_MASTER_B_VOL 0x21 -#define CS43L22_REG_HEADPHONE_A_VOL 0x22 -#define CS43L22_REG_HEADPHONE_B_VOL 0x23 -#define CS43L22_REG_SPEAKER_A_VOL 0x24 -#define CS43L22_REG_SPEAKER_B_VOL 0x25 -#define CS43L22_REG_CH_MIXER_SWAP 0x26 -#define CS43L22_REG_LIMIT_CTL1 0x27 -#define CS43L22_REG_LIMIT_CTL2 0x28 -#define CS43L22_REG_LIMIT_ATTACK_RATE 0x29 -#define CS43L22_REG_OVF_CLK_STATUS 0x2E -#define CS43L22_REG_BATT_COMPENSATION 0x2F -#define CS43L22_REG_VP_BATTERY_LEVEL 0x30 -#define CS43L22_REG_SPEAKER_STATUS 0x31 -#define CS43L22_REG_TEMPMONITOR_CTL 0x32 -#define CS43L22_REG_THERMAL_FOLDBACK 0x33 -#define CS43L22_REG_CHARGE_PUMP_FREQ 0x34 - -/******************************************************************************/ -/****************************** REGISTER MAPPING ******************************/ -/******************************************************************************/ -/** - * @brief CS43L22 ID - */ -#define CS43L22_ID 0xE0 -#define CS43L22_ID_MASK 0xF8 -/** - * @brief Chip ID Register: Chip I.D. and Revision Register - * Read only register - * Default value: 0x01 - * [7:3] CHIPID[4:0]: I.D. code for the CS43L22. - * Default value: 11100b - * [2:0] REVID[2:0]: CS43L22 revision level. - * Default value: - * 000 - Rev A0 - * 001 - Rev A1 - * 010 - Rev B0 - * 011 - Rev B1 - */ -#define CS43L22_CHIPID_ADDR 0x01 - -/** - * @} - */ - -/** @defgroup CS43L22_Exported_Macros - * @{ - */ - -/** - * @} - */ - -/** @defgroup CS43L22_Exported_Functions - * @{ - */ - -/*------------------------------------------------------------------------------ - Audio Codec functions -------------------------------------------------------------------------------*/ -/* High Layer codec functions */ -uint32_t cs43l22_Init(uint16_t DeviceAddr, uint16_t OutputDevice, uint8_t Volume, uint32_t AudioFreq); -void cs43l22_DeInit(void); -uint32_t cs43l22_ReadID(uint16_t DeviceAddr); -uint32_t cs43l22_Play(uint16_t DeviceAddr, uint16_t* pBuffer, uint16_t Size); -uint32_t cs43l22_Pause(uint16_t DeviceAddr); -uint32_t cs43l22_Resume(uint16_t DeviceAddr); -uint32_t cs43l22_Stop(uint16_t DeviceAddr, uint32_t Cmd); -uint32_t cs43l22_SetVolume(uint16_t DeviceAddr, uint8_t Volume); -uint32_t cs43l22_SetFrequency(uint16_t DeviceAddr, uint32_t AudioFreq); -uint32_t cs43l22_SetMute(uint16_t DeviceAddr, uint32_t Cmd); -uint32_t cs43l22_SetOutputMode(uint16_t DeviceAddr, uint8_t Output); -uint32_t cs43l22_Reset(uint16_t DeviceAddr); - -/* AUDIO IO functions */ -void AUDIO_IO_Init(void); -void AUDIO_IO_DeInit(void); -void AUDIO_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value); -uint8_t AUDIO_IO_Read(uint8_t Addr, uint8_t Reg); - -/* Audio driver structure */ -extern AUDIO_DrvTypeDef cs43l22_drv; - -#endif /* __CS43L22_H */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/exc7200/Release_Notes.html b/bsp/stm32f411RE/Libraries/BSP/Components/exc7200/Release_Notes.html deleted file mode 100644 index 9ff31788a6..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/exc7200/Release_Notes.html +++ /dev/null @@ -1,162 +0,0 @@ - - - - - - - - - - - - - - - - - Release Notes for STM32 BSP EXC7200 Components Drivers - - - - - - - - - - -
-


-

-
- - - - - - -
- - - - - - - - - -
-

Back to Release page

-
-

Release -Notes for EXC7200 Component Driver

-

Copyright -2015 STMicroelectronics

-

-
-

 

- - - - - - -

Update History


V1.0.1 -/ 21-September-2015

-Main -Changes
  • exc7200.c:
    • Update the I2C slave read address within exc7200_TS_DetectTouch() function.
    • Update exc7200_TS_GetXY() function to return correct Touch Screen positions.

V1.0.0 -/ 28-April-2015

-

Main -Changes

- - - - - - - - - -
  • First official -release

License

-Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met:
-
-
  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions -in binary form must reproduce the above copyright notice, this list of -conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of STMicroelectronics nor the names of its contributors may be used to endorse or promote products derived
    -
    -
-        from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- -
-

- - -
-
-
For -complete documentation on STM32 Microcontrollers -visit www.st.com/STM32
-

-
-

-
-
-

 

-
- - \ No newline at end of file diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/exc7200/exc7200.c b/bsp/stm32f411RE/Libraries/BSP/Components/exc7200/exc7200.c deleted file mode 100644 index e60d6fa29f..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/exc7200/exc7200.c +++ /dev/null @@ -1,242 +0,0 @@ -/** - ****************************************************************************** - * @file exc7200.c - * @author MCD Application Team - * @version V1.0.1 - * @date 21-September-2015 - * @brief This file provides a set of functions needed to manage the EXC7200 - * Touch-screen controller. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Includes ------------------------------------------------------------------*/ -#include "exc7200.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup Component - * @{ - */ - -/** @defgroup EXC7200 - * @{ - */ - -/* Private typedef -----------------------------------------------------------*/ - -/** @defgroup EXC7200_Private_Types_Definitions - * @{ - */ - -/* Private define ------------------------------------------------------------*/ - -/** @defgroup EXC7200_Private_Defines - * @{ - */ - -/* Private macro -------------------------------------------------------------*/ - -/** @defgroup EXC7200_Private_Macros - * @{ - */ - -/* Private variables ---------------------------------------------------------*/ - -/** @defgroup EXC7200_Private_Variables - * @{ - */ - -/* Touch screen driver structure initialization */ -TS_DrvTypeDef exc7200_ts_drv = -{ - exc7200_Init, - exc7200_ReadID, - exc7200_Reset, - - exc7200_TS_Start, - exc7200_TS_DetectTouch, - exc7200_TS_GetXY, - - exc7200_TS_EnableIT, - exc7200_TS_ClearIT, - exc7200_TS_ITStatus, - exc7200_TS_DisableIT, -}; - -uint8_t aBufferTS[10]; - -/** - * @} - */ - -/* Private function prototypes -----------------------------------------------*/ - -/** @defgroup exc7200_Private_Function_Prototypes - * @{ - */ - -/* Private functions ---------------------------------------------------------*/ - -/** @defgroup exc7200_Private_Functions - * @{ - */ - -/** - * @brief Initialize the exc7200 and configure the needed hardware resources - * @param DeviceAddr: Device address on communication Bus. - * @retval None - */ -void exc7200_Init(uint16_t DeviceAddr) -{ - /* Initialize IO BUS layer */ - IOE_Init(); - -} - -/** - * @brief Reset the exc7200 by Software. - * @param DeviceAddr: Device address on communication Bus. - * @retval None - */ -void exc7200_Reset(uint16_t DeviceAddr) -{ - -} - -/** - * @brief Read the exc7200 IO Expander device ID. - * @param DeviceAddr: Device address on communication Bus. - * @retval The Device ID (two bytes). - */ -uint16_t exc7200_ReadID(uint16_t DeviceAddr) -{ - return 0; -} - -/** - * @brief Configures the touch Screen Controller (Single point detection) - * @param DeviceAddr: Device address on communication Bus. - * @retval None. - */ -void exc7200_TS_Start(uint16_t DeviceAddr) -{ -} - -/** - * @brief Return if there is touch detected or not. - * @param DeviceAddr: Device address on communication Bus. - * @retval Touch detected state. - */ -uint8_t exc7200_TS_DetectTouch(uint16_t DeviceAddr) -{ - /* Read TS data : Send I2C Slave address + 1 Bit0=1 for:read */ - IOE_ReadMultiple(DeviceAddr | 1, EXC7200_READ_CMD, aBufferTS, 10); - - /* check for first byte */ - if (aBufferTS[1]==0x83) - { - return 1; - } - - return 0; -} - -/** - * @brief Get the touch screen X and Y positions values - * @param DeviceAddr: Device address on communication Bus. - * @param X: Pointer to X position value - * @param Y: Pointer to Y position value - * @retval None. - */ -void exc7200_TS_GetXY(uint16_t DeviceAddr, uint16_t *X, uint16_t *Y) -{ - /* Calculate positions */ - *X = (((aBufferTS[3]&0x00ff) << 4) | ((aBufferTS[2]&0x00f0) >> 4)) << 1; - *Y = (((aBufferTS[5]&0x00ff) << 4) | ((aBufferTS[4]&0x00f0) >> 4)) << 1; - - /* Dummy Read to deactivate read mode */ - IOE_ReadMultiple(DeviceAddr, EXC7200_READ_CMD, aBufferTS, 10); -} - -/** - * @brief Configure the selected source to generate a global interrupt or not - * @param DeviceAddr: Device address on communication Bus. - * @retval None - */ -void exc7200_TS_EnableIT(uint16_t DeviceAddr) -{ -} - -/** - * @brief Configure the selected source to generate a global interrupt or not - * @param DeviceAddr: Device address on communication Bus. - * @retval None - */ -void exc7200_TS_DisableIT(uint16_t DeviceAddr) -{ -} - -/** - * @brief Configure the selected source to generate a global interrupt or not - * @param DeviceAddr: Device address on communication Bus. - * @retval TS interrupts status - */ -uint8_t exc7200_TS_ITStatus(uint16_t DeviceAddr) -{ - return 0; -} - -/** - * @brief Configure the selected source to generate a global interrupt or not - * @param DeviceAddr: Device address on communication Bus. - * @retval None - */ -void exc7200_TS_ClearIT(uint16_t DeviceAddr) -{ -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/exc7200/exc7200.h b/bsp/stm32f411RE/Libraries/BSP/Components/exc7200/exc7200.h deleted file mode 100644 index 3b90f32dd8..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/exc7200/exc7200.h +++ /dev/null @@ -1,137 +0,0 @@ -/** - ****************************************************************************** - * @file exc7200.h - * @author MCD Application Team - * @version V1.0.1 - * @date 21-September-2015 - * @brief This file contains all the functions prototypes for the - * exc7200.c IO expander driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __EXC7200_H -#define __EXC7200_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "../Common/ts.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup Component - * @{ - */ - -/** @defgroup EXC7200 - * @{ - */ - -/* Exported types ------------------------------------------------------------*/ - -/** @defgroup EXC7200_Exported_Types - * @{ - */ - -/* Exported constants --------------------------------------------------------*/ - -/** @defgroup EXC7200_Exported_Constants - * @{ - */ - -/* */ -#define EXC7200_READ_CMD 0x09 - -/** - * @} - */ - -/* Exported macro ------------------------------------------------------------*/ - -/** @defgroup exc7200_Exported_Macros - * @{ - */ - -/* Exported functions --------------------------------------------------------*/ - -/** @defgroup exc7200_Exported_Functions - * @{ - */ - -/** - * @brief exc7200 Control functions - */ -void exc7200_Init(uint16_t DeviceAddr); -void exc7200_Reset(uint16_t DeviceAddr); -uint16_t exc7200_ReadID(uint16_t DeviceAddr); -void exc7200_TS_Start(uint16_t DeviceAddr); -uint8_t exc7200_TS_DetectTouch(uint16_t DeviceAddr); -void exc7200_TS_GetXY(uint16_t DeviceAddr, uint16_t *X, uint16_t *Y); -void exc7200_TS_EnableIT(uint16_t DeviceAddr); -void exc7200_TS_DisableIT(uint16_t DeviceAddr); -uint8_t exc7200_TS_ITStatus (uint16_t DeviceAddr); -void exc7200_TS_ClearIT (uint16_t DeviceAddr); - -void IOE_Init(void); -void IOE_Delay(uint32_t delay); -uint8_t IOE_Read(uint8_t addr, uint8_t reg); -uint16_t IOE_ReadMultiple(uint8_t addr, uint8_t reg, uint8_t *buffer, uint16_t length); -void IOE_WriteMultiple(uint8_t addr, uint8_t reg, uint8_t *buffer, uint16_t length); - -/* Touch screen driver structure */ -extern TS_DrvTypeDef exc7200_ts_drv; - -#ifdef __cplusplus -} -#endif -#endif /* __EXC7200_H */ - - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/ft6x06/Release_Notes.html b/bsp/stm32f411RE/Libraries/BSP/Components/ft6x06/Release_Notes.html deleted file mode 100644 index d4ac77a115..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/ft6x06/Release_Notes.html +++ /dev/null @@ -1,156 +0,0 @@ - - - - - - - - - - - - - - - - Release Notes for STM32 BSP Components Drivers - - - - - - - - - - -
-


-

-
- - - - - - -
- - - - - - - - - -
-

Back to Release page

-
-

Release -Notes for FT6X06 Component Driver

-

Copyright -2015 STMicroelectronics

-

-
-

 

- - - - - - -

Update History

V1.0.0 -/ 03-August-2015

-

Main -Changes

- - - - - - - - - -
  • First official release

License

-Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met:
-
-
  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions -in binary form must reproduce the above copyright notice, this list of -conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of STMicroelectronics nor the names of its contributors may be used to endorse or promote products derived
    -
    -
-        from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- -
-

- - -
-
-
For -complete documentation on STM32 Microcontrollers -visit www.st.com/STM32
-
-

-
-
-

 

-
- - \ No newline at end of file diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/ft6x06/ft6x06.c b/bsp/stm32f411RE/Libraries/BSP/Components/ft6x06/ft6x06.c deleted file mode 100644 index 4bc610b42e..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/ft6x06/ft6x06.c +++ /dev/null @@ -1,516 +0,0 @@ -/** - ****************************************************************************** - * @file ft6x06.c - * @author MCD Application Team - * @version V1.0.0 - * @date 03-August-2015 - * @brief This file provides a set of functions needed to manage the FT6X06 - * IO Expander devices. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Includes ------------------------------------------------------------------*/ -#include "ft6x06.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup Component - * @{ - */ - -/** @defgroup FT6X06 - * @{ - */ - -/* Private typedef -----------------------------------------------------------*/ - -/** @defgroup FT6X06_Private_Defines FT6X06 Private Defines - * @{ - */ -#define FT6x06_MAX_INSTANCE 2 -/** - * @} - */ - -/* Private macro -------------------------------------------------------------*/ - -/** @defgroup FT6X06_Private_Variables FT6X06 Private Variables - * @{ - */ - -/* Touch screen driver structure initialization */ -TS_DrvTypeDef ft6x06_ts_drv = -{ - ft6x06_Init, - ft6x06_ReadID, - ft6x06_Reset, - - ft6x06_TS_Start, - ft6x06_TS_DetectTouch, - ft6x06_TS_GetXY, - - ft6x06_TS_EnableIT, - ft6x06_TS_ClearIT, - ft6x06_TS_ITStatus, - ft6x06_TS_DisableIT - -}; - -/* ft6x06 instances by address */ -uint8_t ft6x06[FT6x06_MAX_INSTANCE] = {0}; - -/* Global ft6x06 handle */ -static ft6x06_handle_TypeDef ft6x06_handle = { FT6206_I2C_NOT_INITIALIZED, 0, 0}; - -/** - * @} - */ - -/** @defgroup ft6x06_Private_Function_Prototypes ft6x06 Private Function Prototypes - * @{ - */ -static uint8_t ft6x06_GetInstance(uint16_t DeviceAddr); -/* Private functions prototypes-----------------------------------------------*/ -#if (TS_AUTO_CALIBRATION_SUPPORTED == 1) -/** - * @brief Start TouchScreen calibration phase - * @param DeviceAddr: FT6206 Device address for communication on I2C Bus. - * @retval Status FT6206_STATUS_OK or FT6206_STATUS_NOT_OK. - */ -static uint32_t ft6x06_TS_Calibration(uint16_t DeviceAddr); -#endif /* TS_AUTO_CALIBRATION_SUPPORTED == 1 */ - -/** - * @brief Basic static configuration of TouchScreen - * @param DeviceAddr: FT6206 Device address for communication on I2C Bus. - * @retval Status FT6206_STATUS_OK or FT6206_STATUS_NOT_OK. - */ -static uint32_t ft6x06_TS_Configure(uint16_t DeviceAddr); - -/** - * @} - */ - -/** @defgroup ft6x06_Private_Functions ft6x06 Private Functions - * @{ - */ - -/** - * @brief Initialize the ft6x06 communication bus - * from MCU to FT6206 : ie I2C channel initialization (if required). - * @param DeviceAddr: Device address on communication Bus (I2C slave address of FT6206). - * @retval None - */ -void ft6x06_Init(uint16_t DeviceAddr) -{ - uint8_t instance; - uint8_t empty; - - /* Check if device instance already exists */ - instance = ft6x06_GetInstance(DeviceAddr); - - /* To prevent double initialization */ - if(instance == 0xFF) - { - /* Look for empty instance */ - empty = ft6x06_GetInstance(0); - - if(empty < FT6x06_MAX_INSTANCE) - { - /* Register the current device instance */ - ft6x06[empty] = DeviceAddr; - - /* Initialize IO BUS layer */ - TS_IO_Init(); - } - } -} - -/** - * @brief Software Reset the ft6x06. - * @note : Not applicable to FT6206. - * @param DeviceAddr: Device address on communication Bus (I2C slave address of FT6206). - * @retval None - */ -void ft6x06_Reset(uint16_t DeviceAddr) -{ - /* Do nothing */ - /* No software reset sequence available in FT6206 IC */ -} - -/** - * @brief Read the ft6x06 device ID, pre initialize I2C in case of need to be - * able to read the FT6206 device ID, and verify this is a FT6206. - * @param DeviceAddr: I2C FT6x06 Slave address. - * @retval The Device ID (two bytes). - */ -uint16_t ft6x06_ReadID(uint16_t DeviceAddr) -{ - /* Initialize I2C link if needed */ - TS_IO_Init(); - - /* Return the device ID value */ - return (TS_IO_Read(DeviceAddr, FT6206_CHIP_ID_REG)); -} - -/** - * @brief Configures the touch Screen IC device to start detecting touches - * It goes through an internal calibration process (Hw calibration sequence of - * the touch screen). - * @param DeviceAddr: Device address on communication Bus (I2C slave address). - * @retval None. - */ -void ft6x06_TS_Start(uint16_t DeviceAddr) -{ -#if (TS_AUTO_CALIBRATION_SUPPORTED == 1) - /* Hw Calibration sequence start : should be done once after each power up */ - /* This is called internal calibration of the touch screen */ - ft6x06_TS_Calibration(DeviceAddr); -#endif - /* Minimum static configuration of FT6206 */ - ft6x06_TS_Configure(DeviceAddr); - - /* By default set FT6206 IC in Polling mode : no INT generation on FT6206 for new touch available */ - /* Note TS_INT is active low */ - ft6x06_TS_DisableIT(DeviceAddr); -} - -/** - * @brief Return if there is touches detected or not. - * Try to detect new touches and forget the old ones (reset internal global - * variables). - * @param DeviceAddr: Device address on communication Bus. - * @retval : Number of active touches detected (can be 0, 1 or 2). - */ -uint8_t ft6x06_TS_DetectTouch(uint16_t DeviceAddr) -{ - volatile uint8_t nbTouch = 0; - - /* Read register FT6206_TD_STAT_REG to check number of touches detection */ - nbTouch = TS_IO_Read(DeviceAddr, FT6206_TD_STAT_REG); - nbTouch &= FT6206_TD_STAT_MASK; - - if(nbTouch > FT6206_MAX_DETECTABLE_TOUCH) - { - /* If invalid number of touch detected, set it to zero */ - nbTouch = 0; - } - - /* Update ft6x06 driver internal global : current number of active touches */ - ft6x06_handle.currActiveTouchNb = nbTouch; - - /* Reset current active touch index on which to work on */ - ft6x06_handle.currActiveTouchIdx = 0; - - return(nbTouch); -} - -/** - * @brief Get the touch screen X and Y positions values - * Manage multi touch thanks to touch Index global - * variable 'ft6x06_handle.currActiveTouchIdx'. - * @param DeviceAddr: Device address on communication Bus. - * @param X: Pointer to X position value - * @param Y: Pointer to Y position value - * @retval None. - */ -void ft6x06_TS_GetXY(uint16_t DeviceAddr, uint16_t *X, uint16_t *Y) -{ - uint8_t regAddress = 0; - uint8_t dataxy[4]; - - if(ft6x06_handle.currActiveTouchIdx < ft6x06_handle.currActiveTouchNb) - { - switch(ft6x06_handle.currActiveTouchIdx) - { - case 0 : - regAddress = FT6206_P1_XH_REG; - break; - case 1 : - regAddress = FT6206_P2_XH_REG; - break; - - default : - break; - } - - /* Read X and Y positions */ - TS_IO_ReadMultiple(DeviceAddr, regAddress, dataxy, sizeof(dataxy)); - - /* Send back ready X position to caller */ - *X = ((dataxy[0] & FT6206_MSB_MASK) << 8) | (dataxy[1] & FT6206_LSB_MASK); - - /* Send back ready Y position to caller */ - *Y = ((dataxy[2] & FT6206_MSB_MASK) << 8) | (dataxy[3] & FT6206_LSB_MASK); - - ft6x06_handle.currActiveTouchIdx++; - } -} - -/** - * @brief Configure the FT6206 device to generate IT on given INT pin - * connected to MCU as EXTI. - * @param DeviceAddr: Device address on communication Bus (Slave I2C address of FT6206). - * @retval None - */ -void ft6x06_TS_EnableIT(uint16_t DeviceAddr) -{ - uint8_t regValue = 0; - regValue = (FT6206_G_MODE_INTERRUPT_TRIGGER & (FT6206_G_MODE_INTERRUPT_MASK >> FT6206_G_MODE_INTERRUPT_SHIFT)) << FT6206_G_MODE_INTERRUPT_SHIFT; - - /* Set interrupt trigger mode in FT6206_GMODE_REG */ - TS_IO_Write(DeviceAddr, FT6206_GMODE_REG, regValue); -} - -/** - * @brief Configure the FT6206 device to stop generating IT on the given INT pin - * connected to MCU as EXTI. - * @param DeviceAddr: Device address on communication Bus (Slave I2C address of FT6206). - * @retval None - */ -void ft6x06_TS_DisableIT(uint16_t DeviceAddr) -{ - uint8_t regValue = 0; - regValue = (FT6206_G_MODE_INTERRUPT_POLLING & (FT6206_G_MODE_INTERRUPT_MASK >> FT6206_G_MODE_INTERRUPT_SHIFT)) << FT6206_G_MODE_INTERRUPT_SHIFT; - - /* Set interrupt polling mode in FT6206_GMODE_REG */ - TS_IO_Write(DeviceAddr, FT6206_GMODE_REG, regValue); -} - -/** - * @brief Get IT status from FT6206 interrupt status registers - * Should be called Following an EXTI coming to the MCU to know the detailed - * reason of the interrupt. - * @note : This feature is not applicable to FT6206. - * @param DeviceAddr: Device address on communication Bus (I2C slave address of FT6206). - * @retval TS interrupts status : always return 0 here - */ -uint8_t ft6x06_TS_ITStatus(uint16_t DeviceAddr) -{ - /* Always return 0 as feature not applicable to FT6206 */ - return 0; -} - -/** - * @brief Clear IT status in FT6206 interrupt status clear registers - * Should be called Following an EXTI coming to the MCU. - * @note : This feature is not applicable to FT6206. - * @param DeviceAddr: Device address on communication Bus (I2C slave address of FT6206). - * @retval None - */ -void ft6x06_TS_ClearIT(uint16_t DeviceAddr) -{ - /* Nothing to be done here for FT6206 */ -} - -/**** NEW FEATURES enabled when Multi-touch support is enabled ****/ - -#if (TS_MULTI_TOUCH_SUPPORTED == 1) - -/** - * @brief Get the last touch gesture identification (zoom, move up/down...). - * @param DeviceAddr: Device address on communication Bus (I2C slave address of FT6x06). - * @param pGestureId : Pointer to get last touch gesture Identification. - * @retval None. - */ -void ft6x06_TS_GetGestureID(uint16_t DeviceAddr, uint32_t * pGestureId) -{ - volatile uint8_t ucReadData = 0; - - ucReadData = TS_IO_Read(DeviceAddr, FT6206_GEST_ID_REG); - - * pGestureId = ucReadData; -} - -/** - * @brief Get the touch detailed informations on touch number 'touchIdx' (0..1) - * This touch detailed information contains : - * - weight that was applied to this touch - * - sub-area of the touch in the touch panel - * - event of linked to the touch (press down, lift up, ...) - * @param DeviceAddr: Device address on communication Bus (I2C slave address of FT6x06). - * @param touchIdx : Passed index of the touch (0..1) on which we want to get the - * detailed information. - * @param pWeight : Pointer to to get the weight information of 'touchIdx'. - * @param pArea : Pointer to to get the sub-area information of 'touchIdx'. - * @param pEvent : Pointer to to get the event information of 'touchIdx'. - - * @retval None. - */ -void ft6x06_TS_GetTouchInfo(uint16_t DeviceAddr, - uint32_t touchIdx, - uint32_t * pWeight, - uint32_t * pArea, - uint32_t * pEvent) -{ - uint8_t regAddress = 0; - uint8_t dataxy[3]; - - if(touchIdx < ft6x06_handle.currActiveTouchNb) - { - switch(touchIdx) - { - case 0 : - regAddress = FT6206_P1_WEIGHT_REG; - break; - - case 1 : - regAddress = FT6206_P2_WEIGHT_REG; - break; - - default : - break; - - } /* end switch(touchIdx) */ - - /* Read weight, area and Event Id of touch index */ - TS_IO_ReadMultiple(DeviceAddr, regAddress, dataxy, sizeof(dataxy)); - - /* Return weight of touch index */ - * pWeight = (dataxy[0] & FT6206_TOUCH_WEIGHT_MASK) >> FT6206_TOUCH_WEIGHT_SHIFT; - /* Return area of touch index */ - * pArea = (dataxy[1] & FT6206_TOUCH_AREA_MASK) >> FT6206_TOUCH_AREA_SHIFT; - /* Return Event Id of touch index */ - * pEvent = (dataxy[2] & FT6206_TOUCH_EVT_FLAG_MASK) >> FT6206_TOUCH_EVT_FLAG_SHIFT; - - } /* of if(touchIdx < ft6x06_handle.currActiveTouchNb) */ -} - -#endif /* TS_MULTI_TOUCH_SUPPORTED == 1 */ - -#if (TS_AUTO_CALIBRATION_SUPPORTED == 1) -/** - * @brief Start TouchScreen calibration phase - * @param DeviceAddr: FT6206 Device address for communication on I2C Bus. - * @retval Status FT6206_STATUS_OK or FT6206_STATUS_NOT_OK. - */ -static uint32_t ft6x06_TS_Calibration(uint16_t DeviceAddr) -{ - uint32_t nbAttempt = 0; - volatile uint8_t ucReadData; - volatile uint8_t regValue; - uint32_t status = FT6206_STATUS_OK; - uint8_t bEndCalibration = 0; - - /* >> Calibration sequence start */ - - /* Switch FT6206 back to factory mode to calibrate */ - regValue = (FT6206_DEV_MODE_FACTORY & FT6206_DEV_MODE_MASK) << FT6206_DEV_MODE_SHIFT; - TS_IO_Write(DeviceAddr, FT6206_DEV_MODE_REG, regValue); /* 0x40 */ - - /* Read back the same register FT6206_DEV_MODE_REG */ - ucReadData = TS_IO_Read(DeviceAddr, FT6206_DEV_MODE_REG); - TS_IO_Delay(300); /* Wait 300 ms */ - - if(((ucReadData & (FT6206_DEV_MODE_MASK << FT6206_DEV_MODE_SHIFT)) >> FT6206_DEV_MODE_SHIFT) != FT6206_DEV_MODE_FACTORY ) - { - /* Return error to caller */ - return(FT6206_STATUS_NOT_OK); - } - - /* Start calibration command */ - TS_IO_Write(DeviceAddr, FT6206_TD_STAT_REG, 0x04); - TS_IO_Delay(300); /* Wait 300 ms */ - - /* 100 attempts to wait switch from factory mode (calibration) to working mode */ - for (nbAttempt=0; ((nbAttempt < 100) && (!bEndCalibration)) ; nbAttempt++) - { - ucReadData = TS_IO_Read(DeviceAddr, FT6206_DEV_MODE_REG); - ucReadData = (ucReadData & (FT6206_DEV_MODE_MASK << FT6206_DEV_MODE_SHIFT)) >> FT6206_DEV_MODE_SHIFT; - if(ucReadData == FT6206_DEV_MODE_WORKING) - { - /* Auto Switch to FT6206_DEV_MODE_WORKING : means calibration have ended */ - bEndCalibration = 1; /* exit for loop */ - } - - TS_IO_Delay(200); /* Wait 200 ms */ - } - - /* Calibration sequence end << */ - - return(status); -} -#endif /* TS_AUTO_CALIBRATION_SUPPORTED == 1 */ - -/** - * @brief Basic static configuration of TouchScreen - * @param DeviceAddr: FT6206 Device address for communication on I2C Bus. - * @retval Status FT6206_STATUS_OK or FT6206_STATUS_NOT_OK. - */ -static uint32_t ft6x06_TS_Configure(uint16_t DeviceAddr) -{ - uint32_t status = FT6206_STATUS_OK; - - /* Nothing special to be done for FT6206 */ - - return(status); -} - -/** - * @brief Check if the device instance of the selected address is already registered - * and return its index - * @param DeviceAddr: Device address on communication Bus. - * @retval Index of the device instance if registered, 0xFF if not. - */ -static uint8_t ft6x06_GetInstance(uint16_t DeviceAddr) -{ - uint8_t idx = 0; - - /* Check all the registered instances */ - for(idx = 0; idx < FT6x06_MAX_INSTANCE ; idx ++) - { - if(ft6x06[idx] == DeviceAddr) - { - return idx; - } - } - - return 0xFF; -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/ft6x06/ft6x06.h b/bsp/stm32f411RE/Libraries/BSP/Components/ft6x06/ft6x06.h deleted file mode 100644 index 8a4700ca7a..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/ft6x06/ft6x06.h +++ /dev/null @@ -1,467 +0,0 @@ -/** - ****************************************************************************** - * @file ft6x06.h - * @author MCD Application Team - * @version V1.0.0 - * @date 03-August-2015 - * @brief This file contains all the functions prototypes for the - * ft6x06.c IO expander driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __FT6X06_H -#define __FT6X06_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* Set Multi-touch as non supported */ -#ifndef TS_MULTI_TOUCH_SUPPORTED - #define TS_MULTI_TOUCH_SUPPORTED 0 -#endif - -/* Set Auto-calibration as non supported */ -#ifndef TS_AUTO_CALIBRATION_SUPPORTED - #define TS_AUTO_CALIBRATION_SUPPORTED 0 -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "../Common/ts.h" - -/* Macros --------------------------------------------------------------------*/ - -/** @typedef ft6x06_handle_TypeDef - * ft6x06 Handle definition. - */ -typedef struct -{ - uint8_t i2cInitialized; - - /* field holding the current number of simultaneous active touches */ - uint8_t currActiveTouchNb; - - /* field holding the touch index currently managed */ - uint8_t currActiveTouchIdx; - -} ft6x06_handle_TypeDef; - - /** @addtogroup BSP - * @{ - */ - - /** @addtogroup Component - * @{ - */ - - /** @defgroup FT6X06 - * @{ - */ - - /* Exported types ------------------------------------------------------------*/ - - /** @defgroup FT6X06_Exported_Types - * @{ - */ - - /* Exported constants --------------------------------------------------------*/ - - /** @defgroup FT6X06_Exported_Constants - * @{ - */ - - /* Maximum border values of the touchscreen pad */ -#define FT_6206_MAX_WIDTH ((uint16_t)800) /* Touchscreen pad max width */ -#define FT_6206_MAX_HEIGHT ((uint16_t)480) /* Touchscreen pad max height */ - - /* Possible values of driver functions return status */ -#define FT6206_STATUS_OK 0 -#define FT6206_STATUS_NOT_OK 1 - - /* Possible values of global variable 'TS_I2C_Initialized' */ -#define FT6206_I2C_NOT_INITIALIZED 0 -#define FT6206_I2C_INITIALIZED 1 - - /* Max detectable simultaneous touches */ -#define FT6206_MAX_DETECTABLE_TOUCH 2 - - /** - * @brief : Definitions for FT6206 I2C register addresses on 8 bit - **/ - - /* Current mode register of the FT6206 (R/W) */ -#define FT6206_DEV_MODE_REG 0x00 - - /* Possible values of FT6206_DEV_MODE_REG */ -#define FT6206_DEV_MODE_WORKING 0x00 -#define FT6206_DEV_MODE_FACTORY 0x04 - -#define FT6206_DEV_MODE_MASK 0x7 -#define FT6206_DEV_MODE_SHIFT 4 - - /* Gesture ID register */ -#define FT6206_GEST_ID_REG 0x01 - - /* Possible values of FT6206_GEST_ID_REG */ -#define FT6206_GEST_ID_NO_GESTURE 0x00 -#define FT6206_GEST_ID_MOVE_UP 0x10 -#define FT6206_GEST_ID_MOVE_RIGHT 0x14 -#define FT6206_GEST_ID_MOVE_DOWN 0x18 -#define FT6206_GEST_ID_MOVE_LEFT 0x1C -#define FT6206_GEST_ID_ZOOM_IN 0x48 -#define FT6206_GEST_ID_ZOOM_OUT 0x49 - - /* Touch Data Status register : gives number of active touch points (0..2) */ -#define FT6206_TD_STAT_REG 0x02 - - /* Values related to FT6206_TD_STAT_REG */ -#define FT6206_TD_STAT_MASK 0x0F -#define FT6206_TD_STAT_SHIFT 0x00 - - /* Values Pn_XH and Pn_YH related */ -#define FT6206_TOUCH_EVT_FLAG_PRESS_DOWN 0x00 -#define FT6206_TOUCH_EVT_FLAG_LIFT_UP 0x01 -#define FT6206_TOUCH_EVT_FLAG_CONTACT 0x02 -#define FT6206_TOUCH_EVT_FLAG_NO_EVENT 0x03 - -#define FT6206_TOUCH_EVT_FLAG_SHIFT 6 -#define FT6206_TOUCH_EVT_FLAG_MASK (3 << FT6206_TOUCH_EVT_FLAG_SHIFT) - -#define FT6206_MSB_MASK 0x0F -#define FT6206_MSB_SHIFT 0 - - /* Values Pn_XL and Pn_YL related */ -#define FT6206_LSB_MASK 0xFF -#define FT6206_LSB_SHIFT 0 - -#define FT6206_P1_XH_REG 0x03 -#define FT6206_P1_XL_REG 0x04 -#define FT6206_P1_YH_REG 0x05 -#define FT6206_P1_YL_REG 0x06 - - /* Touch Pressure register value (R) */ -#define FT6206_P1_WEIGHT_REG 0x07 - - /* Values Pn_WEIGHT related */ -#define FT6206_TOUCH_WEIGHT_MASK 0xFF -#define FT6206_TOUCH_WEIGHT_SHIFT 0 - - /* Touch area register */ -#define FT6206_P1_MISC_REG 0x08 - - /* Values related to FT6206_Pn_MISC_REG */ -#define FT6206_TOUCH_AREA_MASK (0x04 << 4) -#define FT6206_TOUCH_AREA_SHIFT 0x04 - -#define FT6206_P2_XH_REG 0x09 -#define FT6206_P2_XL_REG 0x0A -#define FT6206_P2_YH_REG 0x0B -#define FT6206_P2_YL_REG 0x0C -#define FT6206_P2_WEIGHT_REG 0x0D -#define FT6206_P2_MISC_REG 0x0E - - /* Threshold for touch detection */ -#define FT6206_TH_GROUP_REG 0x80 - - /* Values FT6206_TH_GROUP_REG : threshold related */ -#define FT6206_THRESHOLD_MASK 0xFF -#define FT6206_THRESHOLD_SHIFT 0 - - /* Filter function coefficients */ -#define FT6206_TH_DIFF_REG 0x85 - - /* Control register */ -#define FT6206_CTRL_REG 0x86 - - /* Values related to FT6206_CTRL_REG */ - - /* Will keep the Active mode when there is no touching */ -#define FT6206_CTRL_KEEP_ACTIVE_MODE 0x00 - - /* Switching from Active mode to Monitor mode automatically when there is no touching */ -#define FT6206_CTRL_KEEP_AUTO_SWITCH_MONITOR_MODE 0x01 - - /* The time period of switching from Active mode to Monitor mode when there is no touching */ -#define FT6206_TIMEENTERMONITOR_REG 0x87 - - /* Report rate in Active mode */ -#define FT6206_PERIODACTIVE_REG 0x88 - - /* Report rate in Monitor mode */ -#define FT6206_PERIODMONITOR_REG 0x89 - - /* The value of the minimum allowed angle while Rotating gesture mode */ -#define FT6206_RADIAN_VALUE_REG 0x91 - - /* Maximum offset while Moving Left and Moving Right gesture */ -#define FT6206_OFFSET_LEFT_RIGHT_REG 0x92 - - /* Maximum offset while Moving Up and Moving Down gesture */ -#define FT6206_OFFSET_UP_DOWN_REG 0x93 - - /* Minimum distance while Moving Left and Moving Right gesture */ -#define FT6206_DISTANCE_LEFT_RIGHT_REG 0x94 - - /* Minimum distance while Moving Up and Moving Down gesture */ -#define FT6206_DISTANCE_UP_DOWN_REG 0x95 - - /* Maximum distance while Zoom In and Zoom Out gesture */ -#define FT6206_DISTANCE_ZOOM_REG 0x96 - - /* High 8-bit of LIB Version info */ -#define FT6206_LIB_VER_H_REG 0xA1 - - /* Low 8-bit of LIB Version info */ -#define FT6206_LIB_VER_L_REG 0xA2 - - /* Chip Selecting */ -#define FT6206_CIPHER_REG 0xA3 - - /* Interrupt mode register (used when in interrupt mode) */ -#define FT6206_GMODE_REG 0xA4 - -#define FT6206_G_MODE_INTERRUPT_MASK 0x03 -#define FT6206_G_MODE_INTERRUPT_SHIFT 0x00 - - /* Possible values of FT6206_GMODE_REG */ -#define FT6206_G_MODE_INTERRUPT_POLLING 0x00 -#define FT6206_G_MODE_INTERRUPT_TRIGGER 0x01 - - /* Current power mode the FT6206 system is in (R) */ -#define FT6206_PWR_MODE_REG 0xA5 - - /* FT6206 firmware version */ -#define FT6206_FIRMID_REG 0xA6 - - /* FT6206 Chip identification register */ -#define FT6206_CHIP_ID_REG 0xA8 - - /* Possible values of FT6206_CHIP_ID_REG */ -#define FT6206_ID_VALUE 0x11 - - /* Release code version */ -#define FT6206_RELEASE_CODE_ID_REG 0xAF - - /* Current operating mode the FT6206 system is in (R) */ -#define FT6206_STATE_REG 0xBC - - /** - * @} - */ - - /* Exported macro ------------------------------------------------------------*/ - - /** @defgroup ft6x06_Exported_Macros - * @{ - */ - - /* Exported functions --------------------------------------------------------*/ - - /** @defgroup ft6x06_Exported_Functions - * @{ - */ - - /** - * @brief ft6x06 Control functions - */ - - -/** - * @brief Initialize the ft6x06 communication bus - * from MCU to FT6206 : ie I2C channel initialization (if required). - * @param DeviceAddr: Device address on communication Bus (I2C slave address of FT6206). - * @retval None - */ -void ft6x06_Init(uint16_t DeviceAddr); - -/** - * @brief Software Reset the ft6x06. - * @param DeviceAddr: Device address on communication Bus (I2C slave address of FT6206). - * @retval None - */ -void ft6x06_Reset(uint16_t DeviceAddr); - -/** - * @brief Read the ft6x06 device ID, pre intitalize I2C in case of need to be - * able to read the FT6206 device ID, and verify this is a FT6206. - * @param DeviceAddr: I2C FT6x06 Slave address. - * @retval The Device ID (two bytes). - */ -uint16_t ft6x06_ReadID(uint16_t DeviceAddr); - -/** - * @brief Configures the touch Screen IC device to start detecting touches - * @param DeviceAddr: Device address on communication Bus (I2C slave address). - * @retval None. - */ -void ft6x06_TS_Start(uint16_t DeviceAddr); - -/** - * @brief Return if there is touches detected or not. - * Try to detect new touches and forget the old ones (reset internal global - * variables). - * @param DeviceAddr: Device address on communication Bus. - * @retval : Number of active touches detected (can be 0, 1 or 2). - */ -uint8_t ft6x06_TS_DetectTouch(uint16_t DeviceAddr); - -/** - * @brief Get the touch screen X and Y positions values - * Manage multi touch thanks to touch Index global - * variable 'ft6x06_handle.currActiveTouchIdx'. - * @param DeviceAddr: Device address on communication Bus. - * @param X: Pointer to X position value - * @param Y: Pointer to Y position value - * @retval None. - */ -void ft6x06_TS_GetXY(uint16_t DeviceAddr, uint16_t *X, uint16_t *Y); - -/** - * @brief Configure the FT6206 device to generate IT on given INT pin - * connected to MCU as EXTI. - * @param DeviceAddr: Device address on communication Bus (Slave I2C address of FT6206). - * @retval None - */ -void ft6x06_TS_EnableIT(uint16_t DeviceAddr); - -/** - * @brief Configure the FT6206 device to stop generating IT on the given INT pin - * connected to MCU as EXTI. - * @param DeviceAddr: Device address on communication Bus (Slave I2C address of FT6206). - * @retval None - */ -void ft6x06_TS_DisableIT(uint16_t DeviceAddr); - -/** - * @brief Get IT status from FT6206 interrupt status registers - * Should be called Following an EXTI coming to the MCU to know the detailed - * reason of the interrupt. - * @param DeviceAddr: Device address on communication Bus (I2C slave address of FT6206). - * @retval TS interrupts status - */ -uint8_t ft6x06_TS_ITStatus (uint16_t DeviceAddr); - -/** - * @brief Clear IT status in FT6206 interrupt status clear registers - * Should be called Following an EXTI coming to the MCU. - * @param DeviceAddr: Device address on communication Bus (I2C slave address of FT6206). - * @retval TS interrupts status - */ -void ft6x06_TS_ClearIT (uint16_t DeviceAddr); - -/**** NEW FEATURES enabled when Multi-touch support is enabled ****/ - -#if (TS_MULTI_TOUCH_SUPPORTED == 1) - -/** - * @brief Get the last touch gesture identification (zoom, move up/down...). - * @param DeviceAddr: Device address on communication Bus (I2C slave address of FT6x06). - * @param pGestureId : Pointer to get last touch gesture Identification. - * @retval None. - */ -void ft6x06_TS_GetGestureID(uint16_t DeviceAddr, uint32_t * pGestureId); - -/** - * @brief Get the touch detailed informations on touch number 'touchIdx' (0..1) - * This touch detailed information contains : - * - weight that was applied to this touch - * - sub-area of the touch in the touch panel - * - event of linked to the touch (press down, lift up, ...) - * @param DeviceAddr: Device address on communication Bus (I2C slave address of FT6x06). - * @param touchIdx : Passed index of the touch (0..1) on which we want to get the - * detailed information. - * @param pWeight : Pointer to to get the weight information of 'touchIdx'. - * @param pArea : Pointer to to get the sub-area information of 'touchIdx'. - * @param pEvent : Pointer to to get the event information of 'touchIdx'. - - * @retval None. - */ -void ft6x06_TS_GetTouchInfo(uint16_t DeviceAddr, - uint32_t touchIdx, - uint32_t * pWeight, - uint32_t * pArea, - uint32_t * pEvent); - -#endif /* TS_MULTI_TOUCH_SUPPORTED == 1 */ - -/* Imported TS IO functions --------------------------------------------------------*/ - -/** @defgroup ft6x06_Imported_Functions - * @{ - */ - -/* TouchScreen (TS) external IO functions */ -extern void TS_IO_Init(void); -extern void TS_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value); -extern uint8_t TS_IO_Read(uint8_t Addr, uint8_t Reg); -extern uint16_t TS_IO_ReadMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length); -extern void TS_IO_Delay(uint32_t Delay); - - /** - * @} - */ - - /* Imported global variables --------------------------------------------------------*/ - - /** @defgroup ft6x06_Imported_Globals - * @{ - */ - - -/* Touch screen driver structure */ -extern TS_DrvTypeDef ft6x06_ts_drv; - - /** - * @} - */ - -#ifdef __cplusplus -} -#endif -#endif /* __FT6X06_H */ - - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/ili9325/Release_Notes.html b/bsp/stm32f411RE/Libraries/BSP/Components/ili9325/Release_Notes.html deleted file mode 100644 index 80b4d18542..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/ili9325/Release_Notes.html +++ /dev/null @@ -1,447 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - Release Notes for ILI9325 BSP Component Driver - - - - - - - - - -
-


-

-
- - - - - - -
- - - - - - - - - -
-

Back to Release page

-
-

Release -Notes for ILI9325 Component Driver

-

Copyright -2014 STMicroelectronics

-

-
-

 

- - - - - - -
- - -

Update History

-

V1.0.2 / 02-December-2014

- - - - - - - - - - - - - - - - - - - - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- - - - - - - - - - - - - - - -
    -
  • ili9325.h: change "\" by "/" in the include path to fix compilation issue under Linux
  • -
- -

V1.0.1 / 19-June-2014

- - - - - - - - - - - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- - - - -

- - - - - - - - -
    -
  • Align driver with the STM32Cube BSP architecture by removing check for initialization in ili9325_Init() 
    -
  • -
  • Initializes -only the LCD IO in read ID APIs instead of all initialization sequence -and remove the check for initialization in ili9325_ReadID() function
  • -
  • Comments clean up and typo corrections
  • -
- -

V1.0.0 / 18-February-2014

- - - - - - - - - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- - -

- - - - - - -
    -
  • First official release
  • -

License

-
-Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met:
-
-
  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions -in binary form must reproduce the above copyright notice, this list of -conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of STMicroelectronics nor the names of its contributors may be used to endorse or promote products derived
    -
    -
-        from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- -
-

- - -
-
-

For -complete documentation on STM32 Microcontrollers -visit www.st.com/STM32

-
-

-
-
-

 

-
- - \ No newline at end of file diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/ili9325/ili9325.c b/bsp/stm32f411RE/Libraries/BSP/Components/ili9325/ili9325.c deleted file mode 100644 index 0d9e7d3ced..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/ili9325/ili9325.c +++ /dev/null @@ -1,531 +0,0 @@ -/** - ****************************************************************************** - * @file ili9325.c - * @author MCD Application Team - * @version V1.0.2 - * @date 02-December-2014 - * @brief This file includes the LCD driver for ILI9325 LCD. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2014 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Includes ------------------------------------------------------------------*/ -#include "ili9325.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup Components - * @{ - */ - -/** @addtogroup ili9325 - * @brief This file provides a set of functions needed to drive the - * ILI9325 LCD. - * @{ - */ - -/** @defgroup ILI9325_Private_TypesDefinitions - * @{ - */ - -/** - * @} - */ - -/** @defgroup ILI9325_Private_Defines - * @{ - */ - -/** - * @} - */ - -/** @defgroup ILI9325_Private_Macros - * @{ - */ - -/** - * @} - */ - -/** @defgroup ILI9325_Private_Variables - * @{ - */ -LCD_DrvTypeDef ili9325_drv = -{ - ili9325_Init, - ili9325_ReadID, - ili9325_DisplayOn, - ili9325_DisplayOff, - ili9325_SetCursor, - ili9325_WritePixel, - ili9325_ReadPixel, - ili9325_SetDisplayWindow, - ili9325_DrawHLine, - ili9325_DrawVLine, - ili9325_GetLcdPixelWidth, - ili9325_GetLcdPixelHeight, - ili9325_DrawBitmap, - ili9325_DrawRGBImage, -}; - -/** - * @} - */ - -/** @defgroup ILI9325_Private_FunctionPrototypes - * @{ - */ - -/** - * @} - */ - -/** @defgroup ILI9325_Private_Functions - * @{ - */ - -/** - * @brief Initialize the ILI9325 LCD Component. - * @param None - * @retval None - */ -void ili9325_Init(void) -{ - /* Initialize ILI9325 low level bus layer ----------------------------------*/ - LCD_IO_Init(); - - /* Start Initial Sequence --------------------------------------------------*/ - ili9325_WriteReg(LCD_REG_0, 0x0001); /* Start internal OSC. */ - ili9325_WriteReg(LCD_REG_1, 0x0100); /* Set SS and SM bit */ - ili9325_WriteReg(LCD_REG_2, 0x0700); /* Set 1 line inversion */ - ili9325_WriteReg(LCD_REG_3, 0x1018); /* Set GRAM write direction and BGR=1. */ - ili9325_WriteReg(LCD_REG_4, 0x0000); /* Resize register */ - ili9325_WriteReg(LCD_REG_8, 0x0202); /* Set the back porch and front porch */ - ili9325_WriteReg(LCD_REG_9, 0x0000); /* Set non-display area refresh cycle ISC[3:0] */ - ili9325_WriteReg(LCD_REG_10, 0x0000); /* FMARK function */ - ili9325_WriteReg(LCD_REG_12, 0x0000); /* RGB interface setting */ - ili9325_WriteReg(LCD_REG_13, 0x0000); /* Frame marker Position */ - ili9325_WriteReg(LCD_REG_15, 0x0000); /* RGB interface polarity */ - - /* Power On sequence -------------------------------------------------------*/ - ili9325_WriteReg(LCD_REG_16, 0x0000); /* SAP, BT[3:0], AP, DSTB, SLP, STB */ - ili9325_WriteReg(LCD_REG_17, 0x0000); /* DC1[2:0], DC0[2:0], VC[2:0] */ - ili9325_WriteReg(LCD_REG_18, 0x0000); /* VREG1OUT voltage */ - ili9325_WriteReg(LCD_REG_19, 0x0000); /* VDV[4:0] for VCOM amplitude */ - - ili9325_WriteReg(LCD_REG_16, 0x17B0); /* SAP, BT[3:0], AP, DSTB, SLP, STB */ - ili9325_WriteReg(LCD_REG_17, 0x0137); /* DC1[2:0], DC0[2:0], VC[2:0] */ - - ili9325_WriteReg(LCD_REG_18, 0x0139); /* VREG1OUT voltage */ - - ili9325_WriteReg(LCD_REG_19, 0x1d00); /* VDV[4:0] for VCOM amplitude */ - ili9325_WriteReg(LCD_REG_41, 0x0013); /* VCM[4:0] for VCOMH */ - - ili9325_WriteReg(LCD_REG_32, 0x0000); /* GRAM horizontal Address */ - ili9325_WriteReg(LCD_REG_33, 0x0000); /* GRAM Vertical Address */ - - /* Adjust the Gamma Curve (ILI9325) ----------------------------------------*/ - ili9325_WriteReg(LCD_REG_48, 0x0007); - ili9325_WriteReg(LCD_REG_49, 0x0302); - ili9325_WriteReg(LCD_REG_50, 0x0105); - ili9325_WriteReg(LCD_REG_53, 0x0206); - ili9325_WriteReg(LCD_REG_54, 0x0808); - ili9325_WriteReg(LCD_REG_55, 0x0206); - ili9325_WriteReg(LCD_REG_56, 0x0504); - ili9325_WriteReg(LCD_REG_57, 0x0007); - ili9325_WriteReg(LCD_REG_60, 0x0105); - ili9325_WriteReg(LCD_REG_61, 0x0808); - - /* Set GRAM area -----------------------------------------------------------*/ - ili9325_WriteReg(LCD_REG_80, 0x0000); /* Horizontal GRAM Start Address */ - ili9325_WriteReg(LCD_REG_81, 0x00EF); /* Horizontal GRAM End Address */ - ili9325_WriteReg(LCD_REG_82, 0x0000); /* Vertical GRAM Start Address */ - ili9325_WriteReg(LCD_REG_83, 0x013F); /* Vertical GRAM End Address */ - - ili9325_WriteReg(LCD_REG_96, 0xA700); /* Gate Scan Line(GS=1, scan direction is G320~G1) */ - ili9325_WriteReg(LCD_REG_97, 0x0001); /* NDL,VLE, REV */ - ili9325_WriteReg(LCD_REG_106, 0x0000); /* set scrolling line */ - - /* Partial Display Control -------------------------------------------------*/ - ili9325_WriteReg(LCD_REG_128, 0x0000); - ili9325_WriteReg(LCD_REG_129, 0x0000); - ili9325_WriteReg(LCD_REG_130, 0x0000); - ili9325_WriteReg(LCD_REG_131, 0x0000); - ili9325_WriteReg(LCD_REG_132, 0x0000); - ili9325_WriteReg(LCD_REG_133, 0x0000); - - /* Panel Control -----------------------------------------------------------*/ - ili9325_WriteReg(LCD_REG_144, 0x0010); - ili9325_WriteReg(LCD_REG_146, 0x0000); - ili9325_WriteReg(LCD_REG_147, 0x0003); - ili9325_WriteReg(LCD_REG_149, 0x0110); - ili9325_WriteReg(LCD_REG_151, 0x0000); - ili9325_WriteReg(LCD_REG_152, 0x0000); - - /* set GRAM write direction and BGR = 1 */ - /* I/D=00 (Horizontal : increment, Vertical : decrement) */ - /* AM=1 (address is updated in vertical writing direction) */ - ili9325_WriteReg(LCD_REG_3, 0x1018); - - /* 262K color and display ON */ - ili9325_WriteReg(LCD_REG_7, 0x0173); - - /* Set the Cursor */ - ili9325_SetCursor(0, 0); - - /* Prepare to write GRAM */ - LCD_IO_WriteReg(LCD_REG_34); -} - -/** - * @brief Enables the Display. - * @param None - * @retval None - */ -void ili9325_DisplayOn(void) -{ - /* Power On sequence -------------------------------------------------------*/ - ili9325_WriteReg(LCD_REG_16, 0x0000); /* SAP, BT[3:0], AP, DSTB, SLP, STB */ - ili9325_WriteReg(LCD_REG_17, 0x0000); /* DC1[2:0], DC0[2:0], VC[2:0] */ - ili9325_WriteReg(LCD_REG_18, 0x0000); /* VREG1OUT voltage */ - ili9325_WriteReg(LCD_REG_19, 0x0000); /* VDV[4:0] for VCOM amplitude*/ - - ili9325_WriteReg(LCD_REG_16, 0x17B0); /* SAP, BT[3:0], AP, DSTB, SLP, STB */ - ili9325_WriteReg(LCD_REG_17, 0x0137); /* DC1[2:0], DC0[2:0], VC[2:0] */ - - ili9325_WriteReg(LCD_REG_18, 0x0139); /* VREG1OUT voltage */ - - ili9325_WriteReg(LCD_REG_19, 0x1d00); /* VDV[4:0] for VCOM amplitude */ - ili9325_WriteReg(LCD_REG_41, 0x0013); /* VCM[4:0] for VCOMH */ - - /* Display On */ - ili9325_WriteReg(LCD_REG_7, 0x0173); /* 262K color and display ON */ -} - -/** - * @brief Disables the Display. - * @param None - * @retval None - */ -void ili9325_DisplayOff(void) -{ - /* Power Off sequence ------------------------------------------------------*/ - ili9325_WriteReg(LCD_REG_16, 0x0000); /* SAP, BT[3:0], AP, DSTB, SLP, STB */ - ili9325_WriteReg(LCD_REG_17, 0x0000); /* DC1[2:0], DC0[2:0], VC[2:0] */ - ili9325_WriteReg(LCD_REG_18, 0x0000); /* VREG1OUT voltage */ - ili9325_WriteReg(LCD_REG_19, 0x0000); /* VDV[4:0] for VCOM amplitude*/ - - ili9325_WriteReg(LCD_REG_41, 0x0000); /* VCM[4:0] for VCOMH */ - - /* Display Off */ - ili9325_WriteReg(LCD_REG_7, 0x0); -} - -/** - * @brief Get the LCD pixel Width. - * @param None - * @retval The Lcd Pixel Width - */ -uint16_t ili9325_GetLcdPixelWidth(void) -{ - return (uint16_t)320; -} - -/** - * @brief Get the LCD pixel Height. - * @param None - * @retval The Lcd Pixel Height - */ -uint16_t ili9325_GetLcdPixelHeight(void) -{ - return (uint16_t)240; -} - -/** - * @brief Get the ILI9325 ID. - * @param None - * @retval The ILI9325 ID - */ -uint16_t ili9325_ReadID(void) -{ - LCD_IO_Init(); - return (ili9325_ReadReg(0x00)); -} - -/** - * @brief Set Cursor position. - * @param Xpos: specifies the X position. - * @param Ypos: specifies the Y position. - * @retval None - */ -void ili9325_SetCursor(uint16_t Xpos, uint16_t Ypos) -{ - ili9325_WriteReg(LCD_REG_32, Ypos); - ili9325_WriteReg(LCD_REG_33, (ILI9325_LCD_PIXEL_WIDTH - 1 - Xpos)); -} - -/** - * @brief Write pixel. - * @param Xpos: specifies the X position. - * @param Ypos: specifies the Y position. - * @param RGB_Code: the RGB pixel color - * @retval None - */ -void ili9325_WritePixel(uint16_t Xpos, uint16_t Ypos, uint16_t RGB_Code) -{ - /* Set Cursor */ - ili9325_SetCursor(Xpos, Ypos); - - /* Prepare to write GRAM */ - LCD_IO_WriteReg(LCD_REG_34); - - /* Write 16-bit GRAM Reg */ - LCD_IO_WriteData(RGB_Code); -} - -/** - * @brief Read pixel. - * @param None - * @retval The RGB pixel color - */ -uint16_t ili9325_ReadPixel(uint16_t Xpos, uint16_t Ypos) -{ - /* Set Cursor */ - ili9325_SetCursor(Xpos, Ypos); - - /* Prepare to write GRAM */ - LCD_IO_WriteReg(LCD_REG_34); - - /* Dummy read */ - LCD_IO_ReadData(); - - /* Read 16-bit Reg */ - return (LCD_IO_ReadData()); -} - -/** - * @brief Writes to the selected LCD register. - * @param LCD_Reg: Address of the selected register. - * @param LCD_RegValue: Value to write to the selected register. - * @retval None - */ -void ili9325_WriteReg(uint8_t LCD_Reg, uint16_t LCD_RegValue) -{ - LCD_IO_WriteReg(LCD_Reg); - - /* Write 16-bit GRAM Reg */ - LCD_IO_WriteData(LCD_RegValue); -} - -/** - * @brief Reads the selected LCD Register. - * @param LCD_Reg: address of the selected register. - * @retval LCD Register Value. - */ -uint16_t ili9325_ReadReg(uint8_t LCD_Reg) -{ - /* Write 16-bit Index (then Read Reg) */ - LCD_IO_WriteReg(LCD_Reg); - - /* Read 16-bit Reg */ - return (LCD_IO_ReadData()); -} - -/** - * @brief Sets a display window - * @param Xpos: specifies the X bottom left position. - * @param Ypos: specifies the Y bottom left position. - * @param Height: display window height. - * @param Width: display window width. - * @retval None - */ -void ili9325_SetDisplayWindow(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height) -{ - /* Horizontal GRAM Start Address */ - ili9325_WriteReg(LCD_REG_80, (Ypos)); - /* Horizontal GRAM End Address */ - ili9325_WriteReg(LCD_REG_81, (Ypos + Height - 1)); - - /* Vertical GRAM Start Address */ - ili9325_WriteReg(LCD_REG_82, ILI9325_LCD_PIXEL_WIDTH - Xpos - Width); - /* Vertical GRAM End Address */ - ili9325_WriteReg(LCD_REG_83, ILI9325_LCD_PIXEL_WIDTH - Xpos - 1); -} - -/** - * @brief Draw vertical line. - * @param RGB_Code: Specifies the RGB color - * @param Xpos: specifies the X position. - * @param Ypos: specifies the Y position. - * @param Length: specifies the Line length. - * @retval None - */ -void ili9325_DrawHLine(uint16_t RGB_Code, uint16_t Xpos, uint16_t Ypos, uint16_t Length) -{ - uint16_t i = 0; - - /* Set Cursor */ - ili9325_SetCursor(Xpos, Ypos); - - /* Prepare to write GRAM */ - LCD_IO_WriteReg(LCD_REG_34); - - for(i = 0; i < Length; i++) - { - /* Write 16-bit GRAM Reg */ - LCD_IO_WriteData(RGB_Code); - } -} - -/** - * @brief Draw vertical line. - * @param RGB_Code: Specifies the RGB color - * @param Xpos: specifies the X position. - * @param Ypos: specifies the Y position. - * @param Length: specifies the Line length. - * @retval None - */ -void ili9325_DrawVLine(uint16_t RGB_Code, uint16_t Xpos, uint16_t Ypos, uint16_t Length) -{ - uint16_t i = 0; - - /* set GRAM write direction and BGR = 1 */ - /* I/D=00 (Horizontal : increment, Vertical : decrement) */ - /* AM=1 (address is updated in vertical writing direction) */ - ili9325_WriteReg(LCD_REG_3, 0x1010); - - /* Set Cursor */ - ili9325_SetCursor(Xpos, Ypos); - - /* Prepare to write GRAM */ - LCD_IO_WriteReg(LCD_REG_34); - - for(i = 0; i < Length; i++) - { - /* Write 16-bit GRAM Reg */ - LCD_IO_WriteData(RGB_Code); - } - - /* set GRAM write direction and BGR = 1 */ - /* I/D=00 (Horizontal : increment, Vertical : decrement) */ - /* AM=1 (address is updated in vertical writing direction) */ - ili9325_WriteReg(LCD_REG_3, 0x1018); -} - -/** - * @brief Displays a bitmap picture. - * @param BmpAddress: Bmp picture address. - * @param Xpos: Bmp X position in the LCD - * @param Ypos: Bmp Y position in the LCD - * @retval None - */ -void ili9325_DrawBitmap(uint16_t Xpos, uint16_t Ypos, uint8_t *pbmp) -{ - uint32_t index = 0, size = 0; - /* Read bitmap size */ - size = *(volatile uint16_t *) (pbmp + 2); - size |= (*(volatile uint16_t *) (pbmp + 4)) << 16; - /* Get bitmap data address offset */ - index = *(volatile uint16_t *) (pbmp + 10); - index |= (*(volatile uint16_t *) (pbmp + 12)) << 16; - size = (size - index)/2; - pbmp += index; - /* Set GRAM write direction and BGR = 1 */ - /* I/D=00 (Horizontal : decrement, Vertical : decrement) */ - /* AM=1 (address is updated in vertical writing direction) */ - ili9325_WriteReg(LCD_REG_3, 0x1008); - - /* Set Cursor */ - ili9325_SetCursor(Xpos, Ypos); - - /* Prepare to write GRAM */ - LCD_IO_WriteReg(LCD_REG_34); - - for(index = 0; index < size; index++) - { - /* Write 16-bit GRAM Reg */ - LCD_IO_WriteData(*(volatile uint16_t *)pbmp); - pbmp += 2; - } - - /* Set GRAM write direction and BGR = 1 */ - /* I/D = 01 (Horizontal : increment, Vertical : decrement) */ - /* AM = 1 (address is updated in vertical writing direction) */ - ili9325_WriteReg(LCD_REG_3, 0x1018); -} - -/** - * @brief Displays picture. - * @param pdata: picture address. - * @param Xpos: Image X position in the LCD - * @param Ypos: Image Y position in the LCD - * @param Xsize: Image X size in the LCD - * @param Ysize: Image Y size in the LCD - * @retval None - */ -void ili9325_DrawRGBImage(uint16_t Xpos, uint16_t Ypos, uint16_t Xsize, uint16_t Ysize, uint8_t *pdata) -{ - uint32_t index = 0, size = 0; - - size = (Xsize * Ysize); - - /* Set Cursor */ - ili9325_SetCursor(Xpos, Ypos); - - /* Prepare to write GRAM */ - LCD_IO_WriteReg(LCD_REG_34); - - for(index = 0; index < size; index++) - { - /* Write 16-bit GRAM Reg */ - LCD_IO_WriteData(*(volatile uint16_t *)pdata); - pdata += 2; - } -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/ili9325/ili9325.h b/bsp/stm32f411RE/Libraries/BSP/Components/ili9325/ili9325.h deleted file mode 100644 index 32889db47a..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/ili9325/ili9325.h +++ /dev/null @@ -1,256 +0,0 @@ -/** - ****************************************************************************** - * @file ili9325.h - * @author MCD Application Team - * @version V1.0.2 - * @date 02-December-2014 - * @brief This file contains all the functions prototypes for the ili9325.c - * driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2014 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __ILI9325_H -#define __ILI9325_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "../Common/lcd.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup Components - * @{ - */ - -/** @addtogroup ili9325 - * @{ - */ - -/** @defgroup ILI9325_Exported_Types - * @{ - */ - -/** - * @} - */ - -/** @defgroup ILI9325_Exported_Constants - * @{ - */ -/** - * @brief ILI9325 ID - */ -#define ILI9325_ID 0x9325 - -/** - * @brief ILI9325 Size - */ -#define ILI9325_LCD_PIXEL_WIDTH ((uint16_t)320) -#define ILI9325_LCD_PIXEL_HEIGHT ((uint16_t)240) - -/** - * @brief ILI9325 Registers - */ -#define LCD_REG_0 0x00 -#define LCD_REG_1 0x01 -#define LCD_REG_2 0x02 -#define LCD_REG_3 0x03 -#define LCD_REG_4 0x04 -#define LCD_REG_5 0x05 -#define LCD_REG_6 0x06 -#define LCD_REG_7 0x07 -#define LCD_REG_8 0x08 -#define LCD_REG_9 0x09 -#define LCD_REG_10 0x0A -#define LCD_REG_12 0x0C -#define LCD_REG_13 0x0D -#define LCD_REG_14 0x0E -#define LCD_REG_15 0x0F -#define LCD_REG_16 0x10 -#define LCD_REG_17 0x11 -#define LCD_REG_18 0x12 -#define LCD_REG_19 0x13 -#define LCD_REG_20 0x14 -#define LCD_REG_21 0x15 -#define LCD_REG_22 0x16 -#define LCD_REG_23 0x17 -#define LCD_REG_24 0x18 -#define LCD_REG_25 0x19 -#define LCD_REG_26 0x1A -#define LCD_REG_27 0x1B -#define LCD_REG_28 0x1C -#define LCD_REG_29 0x1D -#define LCD_REG_30 0x1E -#define LCD_REG_31 0x1F -#define LCD_REG_32 0x20 -#define LCD_REG_33 0x21 -#define LCD_REG_34 0x22 -#define LCD_REG_36 0x24 -#define LCD_REG_37 0x25 -#define LCD_REG_40 0x28 -#define LCD_REG_41 0x29 -#define LCD_REG_43 0x2B -#define LCD_REG_45 0x2D -#define LCD_REG_48 0x30 -#define LCD_REG_49 0x31 -#define LCD_REG_50 0x32 -#define LCD_REG_51 0x33 -#define LCD_REG_52 0x34 -#define LCD_REG_53 0x35 -#define LCD_REG_54 0x36 -#define LCD_REG_55 0x37 -#define LCD_REG_56 0x38 -#define LCD_REG_57 0x39 -#define LCD_REG_58 0x3A -#define LCD_REG_59 0x3B -#define LCD_REG_60 0x3C -#define LCD_REG_61 0x3D -#define LCD_REG_62 0x3E -#define LCD_REG_63 0x3F -#define LCD_REG_64 0x40 -#define LCD_REG_65 0x41 -#define LCD_REG_66 0x42 -#define LCD_REG_67 0x43 -#define LCD_REG_68 0x44 -#define LCD_REG_69 0x45 -#define LCD_REG_70 0x46 -#define LCD_REG_71 0x47 -#define LCD_REG_72 0x48 -#define LCD_REG_73 0x49 -#define LCD_REG_74 0x4A -#define LCD_REG_75 0x4B -#define LCD_REG_76 0x4C -#define LCD_REG_77 0x4D -#define LCD_REG_78 0x4E -#define LCD_REG_79 0x4F -#define LCD_REG_80 0x50 -#define LCD_REG_81 0x51 -#define LCD_REG_82 0x52 -#define LCD_REG_83 0x53 -#define LCD_REG_96 0x60 -#define LCD_REG_97 0x61 -#define LCD_REG_106 0x6A -#define LCD_REG_118 0x76 -#define LCD_REG_128 0x80 -#define LCD_REG_129 0x81 -#define LCD_REG_130 0x82 -#define LCD_REG_131 0x83 -#define LCD_REG_132 0x84 -#define LCD_REG_133 0x85 -#define LCD_REG_134 0x86 -#define LCD_REG_135 0x87 -#define LCD_REG_136 0x88 -#define LCD_REG_137 0x89 -#define LCD_REG_139 0x8B -#define LCD_REG_140 0x8C -#define LCD_REG_141 0x8D -#define LCD_REG_143 0x8F -#define LCD_REG_144 0x90 -#define LCD_REG_145 0x91 -#define LCD_REG_146 0x92 -#define LCD_REG_147 0x93 -#define LCD_REG_148 0x94 -#define LCD_REG_149 0x95 -#define LCD_REG_150 0x96 -#define LCD_REG_151 0x97 -#define LCD_REG_152 0x98 -#define LCD_REG_153 0x99 -#define LCD_REG_154 0x9A -#define LCD_REG_157 0x9D -#define LCD_REG_192 0xC0 -#define LCD_REG_193 0xC1 -#define LCD_REG_229 0xE5 -/** - * @} - */ - -/** @defgroup ILI9325_Exported_Functions - * @{ - */ -void ili9325_Init(void); -uint16_t ili9325_ReadID(void); -void ili9325_WriteReg(uint8_t LCD_Reg, uint16_t LCD_RegValue); -uint16_t ili9325_ReadReg(uint8_t LCD_Reg); - -void ili9325_DisplayOn(void); -void ili9325_DisplayOff(void); -void ili9325_SetCursor(uint16_t Xpos, uint16_t Ypos); -void ili9325_WritePixel(uint16_t Xpos, uint16_t Ypos, uint16_t RGB_Code); -uint16_t ili9325_ReadPixel(uint16_t Xpos, uint16_t Ypos); - -void ili9325_DrawHLine(uint16_t RGB_Code, uint16_t Xpos, uint16_t Ypos, uint16_t Length); -void ili9325_DrawVLine(uint16_t RGB_Code, uint16_t Xpos, uint16_t Ypos, uint16_t Length); -void ili9325_DrawBitmap(uint16_t Xpos, uint16_t Ypos, uint8_t *pbmp); -void ili9325_DrawRGBImage(uint16_t Xpos, uint16_t Ypos, uint16_t Xsize, uint16_t Ysize, uint8_t *pdata); - -void ili9325_SetDisplayWindow(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height); - - -uint16_t ili9325_GetLcdPixelWidth(void); -uint16_t ili9325_GetLcdPixelHeight(void); - -/* LCD driver structure */ -extern LCD_DrvTypeDef ili9325_drv; - -/* LCD IO functions */ -void LCD_IO_Init(void); -void LCD_IO_WriteData(uint16_t RegValue); -void LCD_IO_WriteReg(uint8_t Reg); -uint16_t LCD_IO_ReadData(void); - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __ILI9325_H */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/ili9341/Release_Notes.html b/bsp/stm32f411RE/Libraries/BSP/Components/ili9341/Release_Notes.html deleted file mode 100644 index 307fd82f2d..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/ili9341/Release_Notes.html +++ /dev/null @@ -1,417 +0,0 @@ - - - - - - - - - - - - - - - - - - - - Release Notes for ILI9341 Component Driver - - - - - - - - - -
-


-

-
- - - - - - -
- - - - - - - - - -
-

Back to Release page

-
-

Release -Notes for ILI9341 Component Driver

-

Copyright -2014 STMicroelectronics

-

-
-

 

- - - - - - -

Update History

-

V1.0.2 / 02-December-2014

- - - - - - - - - - - - - - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- - - - - - - - - -
    -
  • ili9341.h: change "\" by "/" in the include path to fix compilation issue under Linux
  • -
- -

V1.0.1 / 19-June-2014

- - - - - - - - - - - - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- - - - - -

- - - - - - - - - -
    -
  • Align driver with the STM32Cube BSP architecture by removing check for initialization in ili9341_Init() 
    -
  • Initializes -only the LCD IO in read ID APIs instead of all initialization sequence -and remove the check for initialization in ili9341_ReadID() function
  • Comments clean up and typo corrections
  • -
- - - -

V1.0.0 / 18-February-2014

- - - - - - - - - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- -
  • First official release

License

-Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met:
-
-
  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions -in binary form must reproduce the above copyright notice, this list of -conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of STMicroelectronics nor the names of its contributors may be used to endorse or promote products derived
    -
    -
-        from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- -
-

- - -
-
- For -complete documentation on STM32 Microcontrollers -visit www.st.com/STM32 -
-

-
-
-

 

-
- - \ No newline at end of file diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/ili9341/ili9341.c b/bsp/stm32f411RE/Libraries/BSP/Components/ili9341/ili9341.c deleted file mode 100644 index 7b6ad1fba0..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/ili9341/ili9341.c +++ /dev/null @@ -1,346 +0,0 @@ -/** - ****************************************************************************** - * @file ili9341.c - * @author MCD Application Team - * @version V1.0.2 - * @date 02-December-2014 - * @brief This file includes the LCD driver for ILI9341 LCD. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2014 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Includes ------------------------------------------------------------------*/ -#include "ili9341.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup Components - * @{ - */ - -/** @addtogroup ILI9341 - * @brief This file provides a set of functions needed to drive the - * ILI9341 LCD. - * @{ - */ - -/** @defgroup ILI9341_Private_TypesDefinitions - * @{ - */ -/** - * @} - */ - -/** @defgroup ILI9341_Private_Defines - * @{ - */ -/** - * @} - */ - -/** @defgroup ILI9341_Private_Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup ILI9341_Private_Variables - * @{ - */ - -LCD_DrvTypeDef ili9341_drv = -{ - ili9341_Init, - ili9341_ReadID, - ili9341_DisplayOn, - ili9341_DisplayOff, - 0, - 0, - 0, - 0, - 0, - 0, - ili9341_GetLcdPixelWidth, - ili9341_GetLcdPixelHeight, - 0, - 0, -}; - -/** - * @} - */ - -/** @defgroup ILI9341_Private_FunctionPrototypes - * @{ - */ - -/** - * @} - */ - -/** @defgroup ILI9341_Private_Functions - * @{ - */ - -/** - * @brief Power on the LCD. - * @param None - * @retval None - */ -void ili9341_Init(void) -{ - /* Initialize ILI9341 low level bus layer ----------------------------------*/ - LCD_IO_Init(); - - /* Configure LCD */ - ili9341_WriteReg(0xCA); - ili9341_WriteData(0xC3); - ili9341_WriteData(0x08); - ili9341_WriteData(0x50); - ili9341_WriteReg(LCD_POWERB); - ili9341_WriteData(0x00); - ili9341_WriteData(0xC1); - ili9341_WriteData(0x30); - ili9341_WriteReg(LCD_POWER_SEQ); - ili9341_WriteData(0x64); - ili9341_WriteData(0x03); - ili9341_WriteData(0x12); - ili9341_WriteData(0x81); - ili9341_WriteReg(LCD_DTCA); - ili9341_WriteData(0x85); - ili9341_WriteData(0x00); - ili9341_WriteData(0x78); - ili9341_WriteReg(LCD_POWERA); - ili9341_WriteData(0x39); - ili9341_WriteData(0x2C); - ili9341_WriteData(0x00); - ili9341_WriteData(0x34); - ili9341_WriteData(0x02); - ili9341_WriteReg(LCD_PRC); - ili9341_WriteData(0x20); - ili9341_WriteReg(LCD_DTCB); - ili9341_WriteData(0x00); - ili9341_WriteData(0x00); - ili9341_WriteReg(LCD_FRMCTR1); - ili9341_WriteData(0x00); - ili9341_WriteData(0x1B); - ili9341_WriteReg(LCD_DFC); - ili9341_WriteData(0x0A); - ili9341_WriteData(0xA2); - ili9341_WriteReg(LCD_POWER1); - ili9341_WriteData(0x10); - ili9341_WriteReg(LCD_POWER2); - ili9341_WriteData(0x10); - ili9341_WriteReg(LCD_VCOM1); - ili9341_WriteData(0x45); - ili9341_WriteData(0x15); - ili9341_WriteReg(LCD_VCOM2); - ili9341_WriteData(0x90); - ili9341_WriteReg(LCD_MAC); - ili9341_WriteData(0xC8); - ili9341_WriteReg(LCD_3GAMMA_EN); - ili9341_WriteData(0x00); - ili9341_WriteReg(LCD_RGB_INTERFACE); - ili9341_WriteData(0xC2); - ili9341_WriteReg(LCD_DFC); - ili9341_WriteData(0x0A); - ili9341_WriteData(0xA7); - ili9341_WriteData(0x27); - ili9341_WriteData(0x04); - - /* Colomn address set */ - ili9341_WriteReg(LCD_COLUMN_ADDR); - ili9341_WriteData(0x00); - ili9341_WriteData(0x00); - ili9341_WriteData(0x00); - ili9341_WriteData(0xEF); - /* Page address set */ - ili9341_WriteReg(LCD_PAGE_ADDR); - ili9341_WriteData(0x00); - ili9341_WriteData(0x00); - ili9341_WriteData(0x01); - ili9341_WriteData(0x3F); - ili9341_WriteReg(LCD_INTERFACE); - ili9341_WriteData(0x01); - ili9341_WriteData(0x00); - ili9341_WriteData(0x06); - - ili9341_WriteReg(LCD_GRAM); - LCD_Delay(200); - - ili9341_WriteReg(LCD_GAMMA); - ili9341_WriteData(0x01); - - ili9341_WriteReg(LCD_PGAMMA); - ili9341_WriteData(0x0F); - ili9341_WriteData(0x29); - ili9341_WriteData(0x24); - ili9341_WriteData(0x0C); - ili9341_WriteData(0x0E); - ili9341_WriteData(0x09); - ili9341_WriteData(0x4E); - ili9341_WriteData(0x78); - ili9341_WriteData(0x3C); - ili9341_WriteData(0x09); - ili9341_WriteData(0x13); - ili9341_WriteData(0x05); - ili9341_WriteData(0x17); - ili9341_WriteData(0x11); - ili9341_WriteData(0x00); - ili9341_WriteReg(LCD_NGAMMA); - ili9341_WriteData(0x00); - ili9341_WriteData(0x16); - ili9341_WriteData(0x1B); - ili9341_WriteData(0x04); - ili9341_WriteData(0x11); - ili9341_WriteData(0x07); - ili9341_WriteData(0x31); - ili9341_WriteData(0x33); - ili9341_WriteData(0x42); - ili9341_WriteData(0x05); - ili9341_WriteData(0x0C); - ili9341_WriteData(0x0A); - ili9341_WriteData(0x28); - ili9341_WriteData(0x2F); - ili9341_WriteData(0x0F); - - ili9341_WriteReg(LCD_SLEEP_OUT); - LCD_Delay(200); - ili9341_WriteReg(LCD_DISPLAY_ON); - /* GRAM start writing */ - ili9341_WriteReg(LCD_GRAM); -} - -/** - * @brief Disables the Display. - * @param None - * @retval LCD Register Value. - */ -uint16_t ili9341_ReadID(void) -{ - LCD_IO_Init(); - return ((uint16_t)ili9341_ReadData(LCD_READ_ID4, LCD_READ_ID4_SIZE)); -} - -/** - * @brief Enables the Display. - * @param None - * @retval None - */ -void ili9341_DisplayOn(void) -{ - /* Display On */ - ili9341_WriteReg(LCD_DISPLAY_ON); -} - -/** - * @brief Disables the Display. - * @param None - * @retval None - */ -void ili9341_DisplayOff(void) -{ - /* Display Off */ - ili9341_WriteReg(LCD_DISPLAY_OFF); -} - -/** - * @brief Writes to the selected LCD register. - * @param LCD_Reg: address of the selected register. - * @retval None - */ -void ili9341_WriteReg(uint8_t LCD_Reg) -{ - LCD_IO_WriteReg(LCD_Reg); -} - -/** - * @brief Writes data to the selected LCD register. - * @param LCD_Reg: address of the selected register. - * @retval None - */ -void ili9341_WriteData(uint16_t RegValue) -{ - LCD_IO_WriteData(RegValue); -} - -/** - * @brief Reads the selected LCD Register. - * @param RegValue: Address of the register to read - * @param ReadSize: Number of bytes to read - * @retval LCD Register Value. - */ -uint32_t ili9341_ReadData(uint16_t RegValue, uint8_t ReadSize) -{ - /* Read a max of 4 bytes */ - return (LCD_IO_ReadData(RegValue, ReadSize)); -} - -/** - * @brief Get LCD PIXEL WIDTH. - * @param None - * @retval LCD PIXEL WIDTH. - */ -uint16_t ili9341_GetLcdPixelWidth(void) -{ - /* Return LCD PIXEL WIDTH */ - return ILI9341_LCD_PIXEL_WIDTH; -} - -/** - * @brief Get LCD PIXEL HEIGHT. - * @param None - * @retval LCD PIXEL HEIGHT. - */ -uint16_t ili9341_GetLcdPixelHeight(void) -{ - /* Return LCD PIXEL HEIGHT */ - return ILI9341_LCD_PIXEL_HEIGHT; -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/ili9341/ili9341.h b/bsp/stm32f411RE/Libraries/BSP/Components/ili9341/ili9341.h deleted file mode 100644 index 4e4deb2a5a..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/ili9341/ili9341.h +++ /dev/null @@ -1,249 +0,0 @@ -/** - ****************************************************************************** - * @file ili9341.h - * @author MCD Application Team - * @version V1.0.2 - * @date 02-December-2014 - * @brief This file contains all the functions prototypes for the ili9341.c - * driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2014 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __ILI9341_H -#define __ILI9341_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "../Common/lcd.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup Components - * @{ - */ - -/** @addtogroup ILI9341 - * @{ - */ - -/** @defgroup ILI9341_Exported_Types - * @{ - */ -/** - * @} - */ - -/** @defgroup ILI9341_Exported_Constants - * @{ - */ - -/** - * @brief ILI9341 chip IDs - */ -#define ILI9341_ID 0x9341 - -/** - * @brief ILI9341 Size - */ -#define ILI9341_LCD_PIXEL_WIDTH ((uint16_t)240) -#define ILI9341_LCD_PIXEL_HEIGHT ((uint16_t)320) - -/** - * @brief ILI9341 Timing - */ -/* Timing configuration (Typical configuration from ILI9341 datasheet) - HSYNC=10 (9+1) - HBP=20 (29-10+1) - ActiveW=240 (269-20-10+1) - HFP=10 (279-240-20-10+1) - - VSYNC=2 (1+1) - VBP=2 (3-2+1) - ActiveH=320 (323-2-2+1) - VFP=4 (327-320-2-2+1) -*/ -#define ILI9341_HSYNC ((uint32_t)9) /* Horizontal synchronization */ -#define ILI9341_HBP ((uint32_t)29) /* Horizontal back porch */ -#define ILI9341_HFP ((uint32_t)2) /* Horizontal front porch */ -#define ILI9341_VSYNC ((uint32_t)1) /* Vertical synchronization */ -#define ILI9341_VBP ((uint32_t)3) /* Vertical back porch */ -#define ILI9341_VFP ((uint32_t)2) /* Vertical front porch */ - -/** - * @brief ILI9341 Registers - */ - -/* Level 1 Commands */ -#define LCD_SWRESET 0x01 /* Software Reset */ -#define LCD_READ_DISPLAY_ID 0x04 /* Read display identification information */ -#define LCD_RDDST 0x09 /* Read Display Status */ -#define LCD_RDDPM 0x0A /* Read Display Power Mode */ -#define LCD_RDDMADCTL 0x0B /* Read Display MADCTL */ -#define LCD_RDDCOLMOD 0x0C /* Read Display Pixel Format */ -#define LCD_RDDIM 0x0D /* Read Display Image Format */ -#define LCD_RDDSM 0x0E /* Read Display Signal Mode */ -#define LCD_RDDSDR 0x0F /* Read Display Self-Diagnostic Result */ -#define LCD_SPLIN 0x10 /* Enter Sleep Mode */ -#define LCD_SLEEP_OUT 0x11 /* Sleep out register */ -#define LCD_PTLON 0x12 /* Partial Mode ON */ -#define LCD_NORMAL_MODE_ON 0x13 /* Normal Display Mode ON */ -#define LCD_DINVOFF 0x20 /* Display Inversion OFF */ -#define LCD_DINVON 0x21 /* Display Inversion ON */ -#define LCD_GAMMA 0x26 /* Gamma register */ -#define LCD_DISPLAY_OFF 0x28 /* Display off register */ -#define LCD_DISPLAY_ON 0x29 /* Display on register */ -#define LCD_COLUMN_ADDR 0x2A /* Colomn address register */ -#define LCD_PAGE_ADDR 0x2B /* Page address register */ -#define LCD_GRAM 0x2C /* GRAM register */ -#define LCD_RGBSET 0x2D /* Color SET */ -#define LCD_RAMRD 0x2E /* Memory Read */ -#define LCD_PLTAR 0x30 /* Partial Area */ -#define LCD_VSCRDEF 0x33 /* Vertical Scrolling Definition */ -#define LCD_TEOFF 0x34 /* Tearing Effect Line OFF */ -#define LCD_TEON 0x35 /* Tearing Effect Line ON */ -#define LCD_MAC 0x36 /* Memory Access Control register*/ -#define LCD_VSCRSADD 0x37 /* Vertical Scrolling Start Address */ -#define LCD_IDMOFF 0x38 /* Idle Mode OFF */ -#define LCD_IDMON 0x39 /* Idle Mode ON */ -#define LCD_PIXEL_FORMAT 0x3A /* Pixel Format register */ -#define LCD_WRITE_MEM_CONTINUE 0x3C /* Write Memory Continue */ -#define LCD_READ_MEM_CONTINUE 0x3E /* Read Memory Continue */ -#define LCD_SET_TEAR_SCANLINE 0x44 /* Set Tear Scanline */ -#define LCD_GET_SCANLINE 0x45 /* Get Scanline */ -#define LCD_WDB 0x51 /* Write Brightness Display register */ -#define LCD_RDDISBV 0x52 /* Read Display Brightness */ -#define LCD_WCD 0x53 /* Write Control Display register*/ -#define LCD_RDCTRLD 0x54 /* Read CTRL Display */ -#define LCD_WRCABC 0x55 /* Write Content Adaptive Brightness Control */ -#define LCD_RDCABC 0x56 /* Read Content Adaptive Brightness Control */ -#define LCD_WRITE_CABC 0x5E /* Write CABC Minimum Brightness */ -#define LCD_READ_CABC 0x5F /* Read CABC Minimum Brightness */ -#define LCD_READ_ID1 0xDA /* Read ID1 */ -#define LCD_READ_ID2 0xDB /* Read ID2 */ -#define LCD_READ_ID3 0xDC /* Read ID3 */ - -/* Level 2 Commands */ -#define LCD_RGB_INTERFACE 0xB0 /* RGB Interface Signal Control */ -#define LCD_FRMCTR1 0xB1 /* Frame Rate Control (In Normal Mode) */ -#define LCD_FRMCTR2 0xB2 /* Frame Rate Control (In Idle Mode) */ -#define LCD_FRMCTR3 0xB3 /* Frame Rate Control (In Partial Mode) */ -#define LCD_INVTR 0xB4 /* Display Inversion Control */ -#define LCD_BPC 0xB5 /* Blanking Porch Control register */ -#define LCD_DFC 0xB6 /* Display Function Control register */ -#define LCD_ETMOD 0xB7 /* Entry Mode Set */ -#define LCD_BACKLIGHT1 0xB8 /* Backlight Control 1 */ -#define LCD_BACKLIGHT2 0xB9 /* Backlight Control 2 */ -#define LCD_BACKLIGHT3 0xBA /* Backlight Control 3 */ -#define LCD_BACKLIGHT4 0xBB /* Backlight Control 4 */ -#define LCD_BACKLIGHT5 0xBC /* Backlight Control 5 */ -#define LCD_BACKLIGHT7 0xBE /* Backlight Control 7 */ -#define LCD_BACKLIGHT8 0xBF /* Backlight Control 8 */ -#define LCD_POWER1 0xC0 /* Power Control 1 register */ -#define LCD_POWER2 0xC1 /* Power Control 2 register */ -#define LCD_VCOM1 0xC5 /* VCOM Control 1 register */ -#define LCD_VCOM2 0xC7 /* VCOM Control 2 register */ -#define LCD_NVMWR 0xD0 /* NV Memory Write */ -#define LCD_NVMPKEY 0xD1 /* NV Memory Protection Key */ -#define LCD_RDNVM 0xD2 /* NV Memory Status Read */ -#define LCD_READ_ID4 0xD3 /* Read ID4 */ -#define LCD_PGAMMA 0xE0 /* Positive Gamma Correction register */ -#define LCD_NGAMMA 0xE1 /* Negative Gamma Correction register */ -#define LCD_DGAMCTRL1 0xE2 /* Digital Gamma Control 1 */ -#define LCD_DGAMCTRL2 0xE3 /* Digital Gamma Control 2 */ -#define LCD_INTERFACE 0xF6 /* Interface control register */ - -/* Extend register commands */ -#define LCD_POWERA 0xCB /* Power control A register */ -#define LCD_POWERB 0xCF /* Power control B register */ -#define LCD_DTCA 0xE8 /* Driver timing control A */ -#define LCD_DTCB 0xEA /* Driver timing control B */ -#define LCD_POWER_SEQ 0xED /* Power on sequence register */ -#define LCD_3GAMMA_EN 0xF2 /* 3 Gamma enable register */ -#define LCD_PRC 0xF7 /* Pump ratio control register */ - -/* Size of read registers */ -#define LCD_READ_ID4_SIZE 3 /* Size of Read ID4 */ - -/** - * @} - */ - -/** @defgroup ILI9341_Exported_Functions - * @{ - */ -void ili9341_Init(void); -uint16_t ili9341_ReadID(void); -void ili9341_WriteReg(uint8_t LCD_Reg); -void ili9341_WriteData(uint16_t RegValue); -uint32_t ili9341_ReadData(uint16_t RegValue, uint8_t ReadSize); -void ili9341_DisplayOn(void); -void ili9341_DisplayOff(void); -uint16_t ili9341_GetLcdPixelWidth(void); -uint16_t ili9341_GetLcdPixelHeight(void); - -/* LCD driver structure */ -extern LCD_DrvTypeDef ili9341_drv; - -/* LCD IO functions */ -void LCD_IO_Init(void); -void LCD_IO_WriteData(uint16_t RegValue); -void LCD_IO_WriteReg(uint8_t Reg); -uint32_t LCD_IO_ReadData(uint16_t RegValue, uint8_t ReadSize); -void LCD_Delay (uint32_t delay); - -#ifdef __cplusplus -} -#endif - -#endif /* __ILI9341_H */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/l3gd20/Release_Notes.html b/bsp/stm32f411RE/Libraries/BSP/Components/l3gd20/Release_Notes.html deleted file mode 100644 index 119fb0ac6a..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/l3gd20/Release_Notes.html +++ /dev/null @@ -1,461 +0,0 @@ - - - - - - - - - - - - - - - - - - - - Release Notes for L3GD20 Component Driver - - - - - - - - - - -
-


-

-
- - - - - - -
- - - - - - - - - -
-

Back to Release page

-
-

Release -Notes for L3GD20 Component Driver

-

Copyright -2015 STMicroelectronics

-

-
-

 

- - - - - - -

Update History

-

V2.0.0 / 24-June-2015

- - - - - - - - - - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  • l3gd20.h/.c: 
    • Add gyroscope de-initialization function: L3GD20_DeInit()
    • Add gyroscope low power configuration function: L3GD20_LowPower()
    • NOTE: This release must be used with BSP Common -driver V4.0.0 or later

V1.1.1 / 27-November-2014

- - - - - - - - - - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
  • l3gd20.h: change "\" by "/" in the include path to fix compilation issue under Linux
    -
  • Miscellaneous formatting and comments update
  • -
- -

V1.1.0 / 10-June-2014

- - - - - - - - - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
  • Update to support new revision of L3GD20 component having new device ID 0xD5 (new define added: I_AM_L3GD20_TR)
  • -
- -

V1.0.0 / 18-February-2014

- - - - - - - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  • First official release of L3GD20 gyroscope

License

-Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met:
-
-
  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions -in binary form must reproduce the above copyright notice, this list of -conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of STMicroelectronics nor the names of its contributors may be used to endorse or promote products derived
    -
    -
-        from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- -
-

- - -
-
-
For -complete documentation on STM32 Microcontrollers -visit www.st.com/STM32
-

-
-

-
-
-

 

-
- - \ No newline at end of file diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/l3gd20/l3gd20.c b/bsp/stm32f411RE/Libraries/BSP/Components/l3gd20/l3gd20.c deleted file mode 100644 index 84e731e555..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/l3gd20/l3gd20.c +++ /dev/null @@ -1,416 +0,0 @@ -/** - ****************************************************************************** - * @file l3gd20.c - * @author MCD Application Team - * @version V2.0.0 - * @date 26-June-2015 - * @brief This file provides a set of functions needed to manage the L3GD20, - * ST MEMS motion sensor, 3-axis digital output gyroscope. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ -/* Includes ------------------------------------------------------------------*/ -#include "l3gd20.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup Components - * @{ - */ - -/** @addtogroup L3GD20 - * @{ - */ - -/** @defgroup L3GD20_Private_TypesDefinitions - * @{ - */ - -/** - * @} - */ - -/** @defgroup L3GD20_Private_Defines - * @{ - */ - -/** - * @} - */ - -/** @defgroup L3GD20_Private_Macros - * @{ - */ - -/** - * @} - */ - -/** @defgroup L3GD20_Private_Variables - * @{ - */ -GYRO_DrvTypeDef L3gd20Drv = -{ - L3GD20_Init, - L3GD20_DeInit, - L3GD20_ReadID, - L3GD20_RebootCmd, - L3GD20_LowPower, - L3GD20_INT1InterruptConfig, - L3GD20_EnableIT, - L3GD20_DisableIT, - 0, - 0, - L3GD20_FilterConfig, - L3GD20_FilterCmd, - L3GD20_ReadXYZAngRate -}; - -/** - * @} - */ - -/** @defgroup L3GD20_Private_FunctionPrototypes - * @{ - */ - -/** - * @} - */ - -/** @defgroup L3GD20_Private_Functions - * @{ - */ - -/** - * @brief Set L3GD20 Initialization. - * @param L3GD20_InitStruct: pointer to a L3GD20_InitTypeDef structure - * that contains the configuration setting for the L3GD20. - * @retval None - */ -void L3GD20_Init(uint16_t InitStruct) -{ - uint8_t ctrl = 0x00; - - /* Configure the low level interface */ - GYRO_IO_Init(); - - /* Write value to MEMS CTRL_REG1 register */ - ctrl = (uint8_t) InitStruct; - GYRO_IO_Write(&ctrl, L3GD20_CTRL_REG1_ADDR, 1); - - /* Write value to MEMS CTRL_REG4 register */ - ctrl = (uint8_t) (InitStruct >> 8); - GYRO_IO_Write(&ctrl, L3GD20_CTRL_REG4_ADDR, 1); -} - - - -/** - * @brief L3GD20 De-initialization - * @param None - * @retval None - */ -void L3GD20_DeInit(void) -{ -} - -/** - * @brief Read ID address of L3GD20 - * @param None - * @retval ID name - */ -uint8_t L3GD20_ReadID(void) -{ - uint8_t tmp; - - /* Configure the low level interface */ - GYRO_IO_Init(); - - /* Read WHO I AM register */ - GYRO_IO_Read(&tmp, L3GD20_WHO_AM_I_ADDR, 1); - - /* Return the ID */ - return (uint8_t)tmp; -} - -/** - * @brief Reboot memory content of L3GD20 - * @param None - * @retval None - */ -void L3GD20_RebootCmd(void) -{ - uint8_t tmpreg; - - /* Read CTRL_REG5 register */ - GYRO_IO_Read(&tmpreg, L3GD20_CTRL_REG5_ADDR, 1); - - /* Enable or Disable the reboot memory */ - tmpreg |= L3GD20_BOOT_REBOOTMEMORY; - - /* Write value to MEMS CTRL_REG5 register */ - GYRO_IO_Write(&tmpreg, L3GD20_CTRL_REG5_ADDR, 1); -} - -/** - * @brief Set L3GD20 in low-power mode - * @param - * @retval None - */ -void L3GD20_LowPower(uint16_t InitStruct) -{ - uint8_t ctrl = 0x00; - - /* Write value to MEMS CTRL_REG1 register */ - ctrl = (uint8_t) InitStruct; - GYRO_IO_Write(&ctrl, L3GD20_CTRL_REG1_ADDR, 1); -} - -/** - * @brief Set L3GD20 Interrupt INT1 configuration - * @param Int1Config: the configuration setting for the L3GD20 Interrupt. - * @retval None - */ -void L3GD20_INT1InterruptConfig(uint16_t Int1Config) -{ - uint8_t ctrl_cfr = 0x00, ctrl3 = 0x00; - - /* Read INT1_CFG register */ - GYRO_IO_Read(&ctrl_cfr, L3GD20_INT1_CFG_ADDR, 1); - - /* Read CTRL_REG3 register */ - GYRO_IO_Read(&ctrl3, L3GD20_CTRL_REG3_ADDR, 1); - - ctrl_cfr &= 0x80; - ctrl_cfr |= ((uint8_t) Int1Config >> 8); - - ctrl3 &= 0xDF; - ctrl3 |= ((uint8_t) Int1Config); - - /* Write value to MEMS INT1_CFG register */ - GYRO_IO_Write(&ctrl_cfr, L3GD20_INT1_CFG_ADDR, 1); - - /* Write value to MEMS CTRL_REG3 register */ - GYRO_IO_Write(&ctrl3, L3GD20_CTRL_REG3_ADDR, 1); -} - -/** - * @brief Enable INT1 or INT2 interrupt - * @param IntSel: choice of INT1 or INT2 - * This parameter can be: - * @arg L3GD20_INT1 - * @arg L3GD20_INT2 - * @retval None - */ -void L3GD20_EnableIT(uint8_t IntSel) -{ - uint8_t tmpreg; - - /* Read CTRL_REG3 register */ - GYRO_IO_Read(&tmpreg, L3GD20_CTRL_REG3_ADDR, 1); - - if(IntSel == L3GD20_INT1) - { - tmpreg &= 0x7F; - tmpreg |= L3GD20_INT1INTERRUPT_ENABLE; - } - else if(IntSel == L3GD20_INT2) - { - tmpreg &= 0xF7; - tmpreg |= L3GD20_INT2INTERRUPT_ENABLE; - } - - /* Write value to MEMS CTRL_REG3 register */ - GYRO_IO_Write(&tmpreg, L3GD20_CTRL_REG3_ADDR, 1); -} - -/** - * @brief Disable INT1 or INT2 interrupt - * @param IntSel: choice of INT1 or INT2 - * This parameter can be: - * @arg L3GD20_INT1 - * @arg L3GD20_INT2 - * @retval None - */ -void L3GD20_DisableIT(uint8_t IntSel) -{ - uint8_t tmpreg; - - /* Read CTRL_REG3 register */ - GYRO_IO_Read(&tmpreg, L3GD20_CTRL_REG3_ADDR, 1); - - if(IntSel == L3GD20_INT1) - { - tmpreg &= 0x7F; - tmpreg |= L3GD20_INT1INTERRUPT_DISABLE; - } - else if(IntSel == L3GD20_INT2) - { - tmpreg &= 0xF7; - tmpreg |= L3GD20_INT2INTERRUPT_DISABLE; - } - - /* Write value to MEMS CTRL_REG3 register */ - GYRO_IO_Write(&tmpreg, L3GD20_CTRL_REG3_ADDR, 1); -} - -/** - * @brief Set High Pass Filter Modality - * @param FilterStruct: contains the configuration setting for the L3GD20. - * @retval None - */ -void L3GD20_FilterConfig(uint8_t FilterStruct) -{ - uint8_t tmpreg; - - /* Read CTRL_REG2 register */ - GYRO_IO_Read(&tmpreg, L3GD20_CTRL_REG2_ADDR, 1); - - tmpreg &= 0xC0; - - /* Configure MEMS: mode and cutoff frequency */ - tmpreg |= FilterStruct; - - /* Write value to MEMS CTRL_REG2 register */ - GYRO_IO_Write(&tmpreg, L3GD20_CTRL_REG2_ADDR, 1); -} - -/** - * @brief Enable or Disable High Pass Filter - * @param HighPassFilterState: new state of the High Pass Filter feature. - * This parameter can be: - * @arg: L3GD20_HIGHPASSFILTER_DISABLE - * @arg: L3GD20_HIGHPASSFILTER_ENABLE - * @retval None - */ -void L3GD20_FilterCmd(uint8_t HighPassFilterState) -{ - uint8_t tmpreg; - - /* Read CTRL_REG5 register */ - GYRO_IO_Read(&tmpreg, L3GD20_CTRL_REG5_ADDR, 1); - - tmpreg &= 0xEF; - - tmpreg |= HighPassFilterState; - - /* Write value to MEMS CTRL_REG5 register */ - GYRO_IO_Write(&tmpreg, L3GD20_CTRL_REG5_ADDR, 1); -} - -/** - * @brief Get status for L3GD20 data - * @param None - * @retval Data status in a L3GD20 Data - */ -uint8_t L3GD20_GetDataStatus(void) -{ - uint8_t tmpreg; - - /* Read STATUS_REG register */ - GYRO_IO_Read(&tmpreg, L3GD20_STATUS_REG_ADDR, 1); - - return tmpreg; -} - -/** -* @brief Calculate the L3GD20 angular data. -* @param pfData: Data out pointer -* @retval None -*/ -void L3GD20_ReadXYZAngRate(float *pfData) -{ - uint8_t tmpbuffer[6] ={0}; - int16_t RawData[3] = {0}; - uint8_t tmpreg = 0; - float sensitivity = 0; - int i =0; - - GYRO_IO_Read(&tmpreg,L3GD20_CTRL_REG4_ADDR,1); - - GYRO_IO_Read(tmpbuffer,L3GD20_OUT_X_L_ADDR,6); - - /* check in the control register 4 the data alignment (Big Endian or Little Endian)*/ - if(!(tmpreg & L3GD20_BLE_MSB)) - { - for(i=0; i<3; i++) - { - RawData[i]=(int16_t)(((uint16_t)tmpbuffer[2*i+1] << 8) + tmpbuffer[2*i]); - } - } - else - { - for(i=0; i<3; i++) - { - RawData[i]=(int16_t)(((uint16_t)tmpbuffer[2*i] << 8) + tmpbuffer[2*i+1]); - } - } - - /* Switch the sensitivity value set in the CRTL4 */ - switch(tmpreg & L3GD20_FULLSCALE_SELECTION) - { - case L3GD20_FULLSCALE_250: - sensitivity=L3GD20_SENSITIVITY_250DPS; - break; - - case L3GD20_FULLSCALE_500: - sensitivity=L3GD20_SENSITIVITY_500DPS; - break; - - case L3GD20_FULLSCALE_2000: - sensitivity=L3GD20_SENSITIVITY_2000DPS; - break; - } - /* Divide by sensitivity */ - for(i=0; i<3; i++) - { - pfData[i]=(float)(RawData[i] * sensitivity); - } -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/l3gd20/l3gd20.h b/bsp/stm32f411RE/Libraries/BSP/Components/l3gd20/l3gd20.h deleted file mode 100644 index f2206447e8..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/l3gd20/l3gd20.h +++ /dev/null @@ -1,324 +0,0 @@ -/** - ****************************************************************************** - * @file l3gd20.h - * @author MCD Application Team - * @version V2.0.0 - * @date 26-June-2015 - * @brief This file contains all the functions prototypes for the l3gd20.c driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __L3GD20_H -#define __L3GD20_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "../Common/gyro.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup Components - * @{ - */ - -/** @addtogroup L3GD20 - * @{ - */ - -/** @defgroup L3GD20_Exported_Constants - * @{ - */ - -/******************************************************************************/ -/*************************** START REGISTER MAPPING **************************/ -/******************************************************************************/ -#define L3GD20_WHO_AM_I_ADDR 0x0F /* device identification register */ -#define L3GD20_CTRL_REG1_ADDR 0x20 /* Control register 1 */ -#define L3GD20_CTRL_REG2_ADDR 0x21 /* Control register 2 */ -#define L3GD20_CTRL_REG3_ADDR 0x22 /* Control register 3 */ -#define L3GD20_CTRL_REG4_ADDR 0x23 /* Control register 4 */ -#define L3GD20_CTRL_REG5_ADDR 0x24 /* Control register 5 */ -#define L3GD20_REFERENCE_REG_ADDR 0x25 /* Reference register */ -#define L3GD20_OUT_TEMP_ADDR 0x26 /* Out temp register */ -#define L3GD20_STATUS_REG_ADDR 0x27 /* Status register */ -#define L3GD20_OUT_X_L_ADDR 0x28 /* Output Register X */ -#define L3GD20_OUT_X_H_ADDR 0x29 /* Output Register X */ -#define L3GD20_OUT_Y_L_ADDR 0x2A /* Output Register Y */ -#define L3GD20_OUT_Y_H_ADDR 0x2B /* Output Register Y */ -#define L3GD20_OUT_Z_L_ADDR 0x2C /* Output Register Z */ -#define L3GD20_OUT_Z_H_ADDR 0x2D /* Output Register Z */ -#define L3GD20_FIFO_CTRL_REG_ADDR 0x2E /* Fifo control Register */ -#define L3GD20_FIFO_SRC_REG_ADDR 0x2F /* Fifo src Register */ - -#define L3GD20_INT1_CFG_ADDR 0x30 /* Interrupt 1 configuration Register */ -#define L3GD20_INT1_SRC_ADDR 0x31 /* Interrupt 1 source Register */ -#define L3GD20_INT1_TSH_XH_ADDR 0x32 /* Interrupt 1 Threshold X register */ -#define L3GD20_INT1_TSH_XL_ADDR 0x33 /* Interrupt 1 Threshold X register */ -#define L3GD20_INT1_TSH_YH_ADDR 0x34 /* Interrupt 1 Threshold Y register */ -#define L3GD20_INT1_TSH_YL_ADDR 0x35 /* Interrupt 1 Threshold Y register */ -#define L3GD20_INT1_TSH_ZH_ADDR 0x36 /* Interrupt 1 Threshold Z register */ -#define L3GD20_INT1_TSH_ZL_ADDR 0x37 /* Interrupt 1 Threshold Z register */ -#define L3GD20_INT1_DURATION_ADDR 0x38 /* Interrupt 1 DURATION register */ - -/******************************************************************************/ -/**************************** END REGISTER MAPPING ***************************/ -/******************************************************************************/ - -#define I_AM_L3GD20 ((uint8_t)0xD4) -#define I_AM_L3GD20_TR ((uint8_t)0xD5) - -/** @defgroup Power_Mode_selection - * @{ - */ -#define L3GD20_MODE_POWERDOWN ((uint8_t)0x00) -#define L3GD20_MODE_ACTIVE ((uint8_t)0x08) -/** - * @} - */ - -/** @defgroup OutPut_DataRate_Selection - * @{ - */ -#define L3GD20_OUTPUT_DATARATE_1 ((uint8_t)0x00) -#define L3GD20_OUTPUT_DATARATE_2 ((uint8_t)0x40) -#define L3GD20_OUTPUT_DATARATE_3 ((uint8_t)0x80) -#define L3GD20_OUTPUT_DATARATE_4 ((uint8_t)0xC0) -/** - * @} - */ - -/** @defgroup Axes_Selection - * @{ - */ -#define L3GD20_X_ENABLE ((uint8_t)0x02) -#define L3GD20_Y_ENABLE ((uint8_t)0x01) -#define L3GD20_Z_ENABLE ((uint8_t)0x04) -#define L3GD20_AXES_ENABLE ((uint8_t)0x07) -#define L3GD20_AXES_DISABLE ((uint8_t)0x00) -/** - * @} - */ - -/** @defgroup Bandwidth_Selection - * @{ - */ -#define L3GD20_BANDWIDTH_1 ((uint8_t)0x00) -#define L3GD20_BANDWIDTH_2 ((uint8_t)0x10) -#define L3GD20_BANDWIDTH_3 ((uint8_t)0x20) -#define L3GD20_BANDWIDTH_4 ((uint8_t)0x30) -/** - * @} - */ - -/** @defgroup Full_Scale_Selection - * @{ - */ -#define L3GD20_FULLSCALE_250 ((uint8_t)0x00) -#define L3GD20_FULLSCALE_500 ((uint8_t)0x10) -#define L3GD20_FULLSCALE_2000 ((uint8_t)0x20) -#define L3GD20_FULLSCALE_SELECTION ((uint8_t)0x30) -/** - * @} - */ - -/** @defgroup Full_Scale_Sensitivity - * @{ - */ -#define L3GD20_SENSITIVITY_250DPS ((float)8.75f) /*!< gyroscope sensitivity with 250 dps full scale [DPS/LSB] */ -#define L3GD20_SENSITIVITY_500DPS ((float)17.50f) /*!< gyroscope sensitivity with 500 dps full scale [DPS/LSB] */ -#define L3GD20_SENSITIVITY_2000DPS ((float)70.00f) /*!< gyroscope sensitivity with 2000 dps full scale [DPS/LSB] */ -/** - * @} - */ - - -/** @defgroup Block_Data_Update - * @{ - */ -#define L3GD20_BlockDataUpdate_Continous ((uint8_t)0x00) -#define L3GD20_BlockDataUpdate_Single ((uint8_t)0x80) -/** - * @} - */ - -/** @defgroup Endian_Data_selection - * @{ - */ -#define L3GD20_BLE_LSB ((uint8_t)0x00) -#define L3GD20_BLE_MSB ((uint8_t)0x40) -/** - * @} - */ - -/** @defgroup High_Pass_Filter_status - * @{ - */ -#define L3GD20_HIGHPASSFILTER_DISABLE ((uint8_t)0x00) -#define L3GD20_HIGHPASSFILTER_ENABLE ((uint8_t)0x10) -/** - * @} - */ - -/** @defgroup INT1_INT2_selection - * @{ - */ -#define L3GD20_INT1 ((uint8_t)0x00) -#define L3GD20_INT2 ((uint8_t)0x01) -/** - * @} - */ - -/** @defgroup INT1_Interrupt_status - * @{ - */ -#define L3GD20_INT1INTERRUPT_DISABLE ((uint8_t)0x00) -#define L3GD20_INT1INTERRUPT_ENABLE ((uint8_t)0x80) -/** - * @} - */ - -/** @defgroup INT2_Interrupt_status - * @{ - */ -#define L3GD20_INT2INTERRUPT_DISABLE ((uint8_t)0x00) -#define L3GD20_INT2INTERRUPT_ENABLE ((uint8_t)0x08) -/** - * @} - */ - -/** @defgroup INT1_Interrupt_ActiveEdge - * @{ - */ -#define L3GD20_INT1INTERRUPT_LOW_EDGE ((uint8_t)0x20) -#define L3GD20_INT1INTERRUPT_HIGH_EDGE ((uint8_t)0x00) -/** - * @} - */ - -/** @defgroup Boot_Mode_selection - * @{ - */ -#define L3GD20_BOOT_NORMALMODE ((uint8_t)0x00) -#define L3GD20_BOOT_REBOOTMEMORY ((uint8_t)0x80) -/** - * @} - */ - -/** @defgroup High_Pass_Filter_Mode - * @{ - */ -#define L3GD20_HPM_NORMAL_MODE_RES ((uint8_t)0x00) -#define L3GD20_HPM_REF_SIGNAL ((uint8_t)0x10) -#define L3GD20_HPM_NORMAL_MODE ((uint8_t)0x20) -#define L3GD20_HPM_AUTORESET_INT ((uint8_t)0x30) -/** - * @} - */ - -/** @defgroup High_Pass_CUT OFF_Frequency - * @{ - */ -#define L3GD20_HPFCF_0 0x00 -#define L3GD20_HPFCF_1 0x01 -#define L3GD20_HPFCF_2 0x02 -#define L3GD20_HPFCF_3 0x03 -#define L3GD20_HPFCF_4 0x04 -#define L3GD20_HPFCF_5 0x05 -#define L3GD20_HPFCF_6 0x06 -#define L3GD20_HPFCF_7 0x07 -#define L3GD20_HPFCF_8 0x08 -#define L3GD20_HPFCF_9 0x09 -/** - * @} - */ - -/** - * @} - */ -/** @defgroup L3GD20_Exported_Functions - * @{ - */ -/* Sensor Configuration Functions */ -void L3GD20_Init(uint16_t InitStruct); -void L3GD20_DeInit(void); -void L3GD20_LowPower(uint16_t InitStruct); -uint8_t L3GD20_ReadID(void); -void L3GD20_RebootCmd(void); - -/* Interrupt Configuration Functions */ -void L3GD20_INT1InterruptConfig(uint16_t Int1Config); -void L3GD20_EnableIT(uint8_t IntSel); -void L3GD20_DisableIT(uint8_t IntSel); - -/* High Pass Filter Configuration Functions */ -void L3GD20_FilterConfig(uint8_t FilterStruct); -void L3GD20_FilterCmd(uint8_t HighPassFilterState); -void L3GD20_ReadXYZAngRate(float *pfData); -uint8_t L3GD20_GetDataStatus(void); - -/* Gyroscope IO functions */ -void GYRO_IO_Init(void); -void GYRO_IO_DeInit(void); -void GYRO_IO_Write(uint8_t *pBuffer, uint8_t WriteAddr, uint16_t NumByteToWrite); -void GYRO_IO_Read(uint8_t *pBuffer, uint8_t ReadAddr, uint16_t NumByteToRead); - -/* Gyroscope driver structure */ -extern GYRO_DrvTypeDef L3gd20Drv; - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus - } -#endif - -#endif /* __L3GD20_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/lis302dl/Release_Notes.html b/bsp/stm32f411RE/Libraries/BSP/Components/lis302dl/Release_Notes.html deleted file mode 100644 index 1d98fd2d0c..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/lis302dl/Release_Notes.html +++ /dev/null @@ -1,510 +0,0 @@ - - - - - - - - - - - - - - - - - - - Release Notes for LIS302DL Component Driver - - - - - - - - - - -
-


-

-
- - - - - - -
- - - - - - - - - -
-

Back to Release page

-
-

Release -Notes for LIS302DL Component Driver

-

Copyright -2015 STMicroelectronics

- -

- -
-

 

- - - - - - -
-

Update History

-

V2.0.0 / 03-August-2015

- - - - - - - - - - - - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  • lis302dl.h/.c:
    • Add mems accelerometer de-initialization -function: LIS302DL_DeInit()
    • NOTE: This release must be used with BSP Common -driver V4.0.0 or later

V1.0.2 / 02-December-2014

- - - - - - - - - - - - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
  • lis302dl.h: change "\" by "/" in the include path to fix compilation issue under Linux
  • -
- -

V1.0.1 / 19-June-2014

- - - - - - - - - - - - - - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
  • Comments clean up and typo corrections
  • -
- - - -

V1.0.0 / 18-February-2014

- - - - - - - - - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
  • First official release
  • -
-

License

- -
-Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met:
-
-
  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions -in binary form must reproduce the above copyright notice, this list of -conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of STMicroelectronics nor the names of its contributors may be used to endorse or promote products derived
    -
    -
-        from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- -
-

- - -
-
-
For -complete documentation on STM32 Microcontrollers -visit www.st.com/STM32
-

-
-
-

 

-
- - \ No newline at end of file diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/lis302dl/lis302dl.c b/bsp/stm32f411RE/Libraries/BSP/Components/lis302dl/lis302dl.c deleted file mode 100644 index bd54e69b44..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/lis302dl/lis302dl.c +++ /dev/null @@ -1,423 +0,0 @@ -/** - ****************************************************************************** - * @file lis302dl.c - * @author MCD Application Team - * @version V2.0.0 - * @date 03-August-2015 - * @brief This file provides a set of functions needed to manage the LIS302DL - * MEMS accelerometer. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Includes ------------------------------------------------------------------*/ -#include "lis302dl.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup Components - * @{ - */ - -/** @addtogroup LIS302DL - * @brief This file includes the motion sensor driver for LIS302DL motion sensor - * devices. - * @{ - */ - - -/** @defgroup LIS302DL_Private_TypesDefinitions - * @{ - */ - -/** - * @} - */ - -/** @defgroup LIS302DL_Private_Defines - * @{ - */ - -/** - * @} - */ - -/** @defgroup LIS302DL_Private_Macros - * @{ - */ - -/** - * @} - */ - -/** @defgroup LIS302DL_Private_Variables - * @{ - */ - -ACCELERO_DrvTypeDef Lis302dlDrv = -{ - LIS302DL_Init, - LIS302DL_DeInit, - LIS302DL_ReadID, - LIS302DL_RebootCmd, - LIS302DL_Click_IntConfig, - 0, - 0, - 0, - 0, - LIS302DL_Click_IntClear, - LIS302DL_FilterConfig, - 0, - LIS302DL_ReadACC, -}; - -/** - * @} - */ - -/** @defgroup LIS302DL_Private_FunctionPrototypes - * @{ - */ - -/** - * @} - */ - -/** @defgroup LIS302DL_Private_Functions - * @{ - */ - -/** - * @brief Set LIS302DL Initialization. - * @param InitStruct: contains mask of different init parameters - * @retval None - */ -void LIS302DL_Init(uint16_t InitStruct) -{ - uint8_t ctrl = 0x00; - - /* Configure the low level interface */ - ACCELERO_IO_Init(); - - ctrl = (uint8_t) InitStruct; - - /* Write value to MEMS CTRL_REG1 register */ - ACCELERO_IO_Write(&ctrl, LIS302DL_CTRL_REG1_ADDR, 1); -} - -/** - * @brief LIS302DL De-Initialization. - * @param None - * @retval None. - */ -void LIS302DL_DeInit(void) -{ - -} - -/** - * @brief Read LIS302DL device ID. - * @param None - * @retval The Device ID (two bytes). - */ -uint8_t LIS302DL_ReadID(void) -{ - uint8_t tmp = 0; - - /* Configure the low level interface */ - ACCELERO_IO_Init(); - - /* Read WHO_AM_I register */ - ACCELERO_IO_Read(&tmp, LIS302DL_WHO_AM_I_ADDR, 1); - - /* Return the ID */ - return (uint16_t)tmp; -} - -/** - * @brief Set LIS302DL Internal High Pass Filter configuration. - * @param FilterStruct: contains data for filter config - * @retval None - */ -void LIS302DL_FilterConfig(uint8_t FilterStruct) -{ - uint8_t ctrl = 0x00; - - /* Read CTRL_REG2 register */ - ACCELERO_IO_Read(&ctrl, LIS302DL_CTRL_REG2_ADDR, 1); - - /* Clear high pass filter cut-off level, interrupt and data selection bits */ - ctrl &= (uint8_t)~(LIS302DL_FILTEREDDATASELECTION_OUTPUTREGISTER | \ - LIS302DL_HIGHPASSFILTER_LEVEL_3 | \ - LIS302DL_HIGHPASSFILTERINTERRUPT_1_2); - - ctrl |= FilterStruct; - - /* Write value to MEMS CTRL_REG2 register */ - ACCELERO_IO_Write(&ctrl, LIS302DL_CTRL_REG2_ADDR, 1); -} - -/** - * @brief Set LIS302DL Interrupt configuration. - * @param LIS302DL_InterruptConfig_TypeDef: pointer to a LIS302DL_InterruptConfig_TypeDef - * structure that contains the configuration setting for the LIS302DL Interrupt. - * @retval None - */ -void LIS302DL_InterruptConfig(LIS302DL_InterruptConfigTypeDef *LIS302DL_IntConfigStruct) -{ - uint8_t ctrl = 0x00; - - /* Read CLICK_CFG register */ - ACCELERO_IO_Read(&ctrl, LIS302DL_CLICK_CFG_REG_ADDR, 1); - - /* Configure latch Interrupt request, click interrupts and double click interrupts */ - ctrl = (uint8_t)(LIS302DL_IntConfigStruct->Latch_Request| \ - LIS302DL_IntConfigStruct->SingleClick_Axes | \ - LIS302DL_IntConfigStruct->DoubleClick_Axes); - - /* Write value to MEMS CLICK_CFG register */ - ACCELERO_IO_Write(&ctrl, LIS302DL_CLICK_CFG_REG_ADDR, 1); -} - -/** - * @brief Set LIS302DL Interrupt configuration - * @param None - * @retval None - */ -void LIS302DL_Click_IntConfig(void) -{ - uint8_t ctrl = 0x00; - LIS302DL_InterruptConfigTypeDef LIS302DL_InterruptStruct; - - ACCELERO_IO_ITConfig(); - - /* Set configuration of Internal High Pass Filter of LIS302DL */ - LIS302DL_InterruptStruct.Latch_Request = LIS302DL_INTERRUPTREQUEST_LATCHED; - LIS302DL_InterruptStruct.SingleClick_Axes = LIS302DL_CLICKINTERRUPT_Z_ENABLE; - LIS302DL_InterruptStruct.DoubleClick_Axes = LIS302DL_DOUBLECLICKINTERRUPT_Z_ENABLE; - LIS302DL_InterruptConfig(&LIS302DL_InterruptStruct); - - /* Configure Interrupt control register: enable Click interrupt on INT1 and - INT2 on Z axis high event */ - ctrl = 0x3F; - ACCELERO_IO_Write(&ctrl, LIS302DL_CTRL_REG3_ADDR, 1); - - /* Enable Interrupt generation on click on Z axis */ - ctrl = 0x50; - ACCELERO_IO_Write(&ctrl, LIS302DL_CLICK_CFG_REG_ADDR, 1); - - /* Configure Click Threshold on X/Y axis (10 x 0.5g) */ - ctrl = 0xAA; - ACCELERO_IO_Write(&ctrl, LIS302DL_CLICK_THSY_X_REG_ADDR, 1); - - /* Configure Click Threshold on Z axis (10 x 0.5g) */ - ctrl = 0x0A; - ACCELERO_IO_Write(&ctrl, LIS302DL_CLICK_THSZ_REG_ADDR, 1); - - /* Enable interrupt on Y axis high event */ - ctrl = 0x4C; - ACCELERO_IO_Write(&ctrl, LIS302DL_FF_WU_CFG1_REG_ADDR, 1); - - /* Configure Time Limit */ - ctrl = 0x03; - ACCELERO_IO_Write(&ctrl, LIS302DL_CLICK_TIMELIMIT_REG_ADDR, 1); - - /* Configure Latency */ - ctrl = 0x7F; - ACCELERO_IO_Write(&ctrl, LIS302DL_CLICK_LATENCY_REG_ADDR, 1); - - /* Configure Click Window */ - ctrl = 0x7F; - ACCELERO_IO_Write(&ctrl, LIS302DL_CLICK_WINDOW_REG_ADDR, 1); -} - -/** - * @brief Clear LIS302DL click Interrupt - * @param None - * @retval None - */ -void LIS302DL_Click_IntClear(void) -{ - uint8_t buffer[6], clickreg = 0; - - /* Read click and status registers if the available MEMS Accelerometer is LIS302DL */ - ACCELERO_IO_Read(&clickreg, LIS302DL_CLICK_SRC_REG_ADDR, 1); - ACCELERO_IO_Read(buffer, LIS302DL_STATUS_REG_ADDR, 6); -} - -/** - * @brief Change the lowpower mode for LIS302DL - * @param LowPowerMode: New state for the low power mode. - * This parameter can be one of the following values: - * @arg LIS302DL_LOWPOWERMODE_POWERDOWN: Power down mode - * @arg LIS302DL_LOWPOWERMODE_ACTIVE: Active mode - * @retval None - */ -void LIS302DL_LowpowerCmd(uint8_t LowPowerMode) -{ - uint8_t tmpreg; - - /* Read CTRL_REG1 register */ - ACCELERO_IO_Read(&tmpreg, LIS302DL_CTRL_REG1_ADDR, 1); - - /* Set new low power mode configuration */ - tmpreg &= (uint8_t)~LIS302DL_LOWPOWERMODE_ACTIVE; - tmpreg |= LowPowerMode; - - /* Write value to MEMS CTRL_REG1 register */ - ACCELERO_IO_Write(&tmpreg, LIS302DL_CTRL_REG1_ADDR, 1); -} - -/** - * @brief Data Rate command - * @param DataRateValue: Data rate value - * This parameter can be one of the following values: - * @arg LIS302DL_DATARATE_100: 100 Hz output data rate - * @arg LIS302DL_DATARATE_400: 400 Hz output data rate - * @retval None - */ -void LIS302DL_DataRateCmd(uint8_t DataRateValue) -{ - uint8_t tmpreg; - - /* Read CTRL_REG1 register */ - ACCELERO_IO_Read(&tmpreg, LIS302DL_CTRL_REG1_ADDR, 1); - - /* Set new Data rate configuration */ - tmpreg &= (uint8_t)~LIS302DL_DATARATE_400; - tmpreg |= DataRateValue; - - /* Write value to MEMS CTRL_REG1 register */ - ACCELERO_IO_Write(&tmpreg, LIS302DL_CTRL_REG1_ADDR, 1); -} - -/** - * @brief Change the Full Scale of LIS302DL - * @param FS_value: new full scale value. - * This parameter can be one of the following values: - * @arg LIS302DL_FULLSCALE_2_3: +-2.3g - * @arg LIS302DL_FULLSCALE_9_2: +-9.2g - * @retval None - */ -void LIS302DL_FullScaleCmd(uint8_t FS_value) -{ - uint8_t tmpreg; - - /* Read CTRL_REG1 register */ - ACCELERO_IO_Read(&tmpreg, LIS302DL_CTRL_REG1_ADDR, 1); - - /* Set new full scale configuration */ - tmpreg &= (uint8_t)~LIS302DL_FULLSCALE_9_2; - tmpreg |= FS_value; - - /* Write value to MEMS CTRL_REG1 register */ - ACCELERO_IO_Write(&tmpreg, LIS302DL_CTRL_REG1_ADDR, 1); -} - -/** - * @brief Reboot memory content of LIS302DL. - * @param None - * @retval None - */ -void LIS302DL_RebootCmd(void) -{ - uint8_t tmpreg; - /* Read CTRL_REG2 register */ - ACCELERO_IO_Read(&tmpreg, LIS302DL_CTRL_REG2_ADDR, 1); - - /* Enable or Disable the reboot memory */ - tmpreg |= LIS302DL_BOOT_REBOOTMEMORY; - - /* Write value to MEMS CTRL_REG2 register */ - ACCELERO_IO_Write(&tmpreg, LIS302DL_CTRL_REG2_ADDR, 1); -} - -/** - * @brief Read LIS302DL output register, and calculate the acceleration - * ACC[mg]=SENSITIVITY* (out_h*256+out_l)/16 (12 bit rappresentation) - * @param pfData: Data out pointer - * @retval None - */ -void LIS302DL_ReadACC(int16_t *pData) -{ - int8_t buffer[6]; - int16_t pnRawData[3]; - uint8_t sensitivity = LIS302DL_SENSITIVITY_2_3G; - uint8_t crtl, i = 0x00; - - ACCELERO_IO_Read(&crtl, LIS302DL_CTRL_REG1_ADDR, 1); - ACCELERO_IO_Read((uint8_t*)buffer, LIS302DL_OUT_X_ADDR, 6); - - for(i=0; i<3; i++) - { - pnRawData[i] = buffer[2*i]; - } - - switch(crtl & LIS302DL_FULLSCALE_9_2) - { - /* FS bit = 0 ==> Sensitivity typical value = 18milligals/digit*/ - case LIS302DL_FULLSCALE_2_3: - sensitivity = LIS302DL_SENSITIVITY_2_3G; - break; - - /* FS bit = 1 ==> Sensitivity typical value = 72milligals/digit*/ - case LIS302DL_FULLSCALE_9_2: - sensitivity = LIS302DL_SENSITIVITY_9_2G; - break; - - default: - break; - } - - /* Obtain the mg value for the three axis */ - for(i=0; i<3; i++) - { - pData[i]=(pnRawData[i] * sensitivity); - } -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/lis302dl/lis302dl.h b/bsp/stm32f411RE/Libraries/BSP/Components/lis302dl/lis302dl.h deleted file mode 100644 index 49f9656b77..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/lis302dl/lis302dl.h +++ /dev/null @@ -1,720 +0,0 @@ -/** - ****************************************************************************** - * @file lis302dl.h - * @author MCD Application Team - * @version V2.0.0 - * @date 03-August-2015 - * @brief This file contains all the functions prototypes for the lis302dl.c - * firmware driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __LIS302DL_H -#define __LIS302DL_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "../Common/accelero.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup Components - * @{ - */ - -/** @addtogroup LIS302DL - * @{ - */ - - -/** @defgroup LIS302DL_Exported_Types - * @{ - */ -/* LIS302DL struct */ -typedef struct -{ - uint8_t Power_Mode; /* Power-down/Active Mode */ - uint8_t Output_DataRate; /* OUT data rate 100 Hz / 400 Hz */ - uint8_t Axes_Enable; /* Axes enable */ - uint8_t Full_Scale; /* Full scale */ - uint8_t Self_Test; /* Self test */ -}LIS302DL_InitTypeDef; - -/* Interrupt struct */ -typedef struct -{ - uint8_t Latch_Request; /* Latch interrupt request into CLICK_SRC register*/ - uint8_t SingleClick_Axes; /* Single Click Axes Interrupts */ - uint8_t DoubleClick_Axes; /* Double Click Axes Interrupts */ -}LIS302DL_InterruptConfigTypeDef; - -/* High Pass Filter struct */ -typedef struct -{ - uint8_t HighPassFilter_Data_Selection; /* Internal filter bypassed or data from internal filter send to output register*/ - uint8_t HighPassFilter_CutOff_Frequency; /* High pass filter cut-off frequency */ - uint8_t HighPassFilter_Interrupt; /* High pass filter enabled for Freefall/WakeUp #1 or #2 */ -}LIS302DL_FilterConfigTypeDef; - -/** - * @} - */ - -/** @defgroup LIS302DL_Exported_Constants - * @{ - */ - -/******************************************************************************/ -/*************************** START REGISTER MAPPING **************************/ -/******************************************************************************/ - -/******************************************************************************* -* WHO_AM_I Register: Device Identification Register -* Read only register -* Default value: 0x3B -*******************************************************************************/ -#define LIS302DL_WHO_AM_I_ADDR 0x0F - -/******************************************************************************* -* CTRL_REG1 Register: Control Register 1 -* Read Write register -* Default value: 0x07 -* 7 DR: Data Rate selection. -* 0 - 100 Hz output data rate -* 1 - 400 Hz output data rate -* 6 PD: Power Down control. -* 0 - power down mode -* 1 - active mode -* 5 FS: Full Scale selection. -* 0 - Typical measurement range 2.3 -* 1 - Typical measurement range 9.2 -* 4:3 STP-STM Self Test Enable: -* STP | STM | mode -* ---------------------------- -* 0 | 0 | Normal mode -* 0 | 1 | Self Test M -* 1 | 0 | Self Test P -* 2 Zen: Z axis enable. -* 0 - Z axis disabled -* 1- Z axis enabled -* 1 Yen: Y axis enable. -* 0 - Y axis disabled -* 1- Y axis enabled -* 0 Xen: X axis enable. -* 0 - X axis disabled -* 1- X axis enabled -*******************************************************************************/ -#define LIS302DL_CTRL_REG1_ADDR 0x20 - -/******************************************************************************* -* CTRL_REG2 Regsiter: Control Register 2 -* Read Write register -* Default value: 0x00 -* 7 SIM: SPI Serial Interface Mode Selection. -* 0 - 4 wire interface -* 1 - 3 wire interface -* 6 BOOT: Reboot memory content -* 0 - normal mode -* 1 - reboot memory content -* 5 Reserved -* 4 FDS: Filtered data selection. -* 0 - internal filter bypassed -* 1 - data from internal filter sent to output register -* 3 HP FF_WU2: High pass filter enabled for FreeFall/WakeUp#2. -* 0 - filter bypassed -* 1 - filter enabled -* 2 HP FF_WU1: High pass filter enabled for FreeFall/WakeUp#1. -* 0 - filter bypassed -* 1 - filter enabled -* 1:0 HP coeff2-HP coeff1 High pass filter cut-off frequency (ft) configuration. -* ft= ODR[hz]/6*HP coeff -* HP coeff2 | HP coeff1 | HP coeff -* ------------------------------------------- -* 0 | 0 | 8 -* 0 | 1 | 16 -* 1 | 0 | 32 -* 1 | 1 | 64 -* HP coeff | ft[hz] | ft[hz] | -* |ODR 100Hz | ODR 400Hz | -* -------------------------------------------- -* 00 | 2 | 8 | -* 01 | 1 | 4 | -* 10 | 0.5 | 2 | -* 11 | 0.25 | 1 | -*******************************************************************************/ -#define LIS302DL_CTRL_REG2_ADDR 0x21 - -/******************************************************************************* -* CTRL_REG3 Register: Interrupt Control Register -* Read Write register -* Default value: 0x00 -* 7 IHL active: Interrupt active high/low. -* 0 - active high -* 1 - active low -* 6 PP_OD: push-pull/open-drain. -* 0 - push-pull -* 1 - open-drain -* 5:3 I2_CFG2 - I2_CFG0 Data signal on INT2 pad control bits -* 2:0 I1_CFG2 - I1_CFG0 Data signal on INT1 pad control bits -* I1(2)_CFG2 | I1(2)_CFG1 | I1(2)_CFG0 | INT1(2) Pad -* ---------------------------------------------------------- -* 0 | 0 | 0 | GND -* 0 | 0 | 1 | FreeFall/WakeUp#1 -* 0 | 1 | 0 | FreeFall/WakeUp#2 -* 0 | 1 | 1 | FreeFall/WakeUp#1 or FreeFall/WakeUp#2 -* 1 | 0 | 0 | Data ready -* 1 | 1 | 1 | Click interrupt -*******************************************************************************/ -#define LIS302DL_CTRL_REG3_ADDR 0x22 - -/******************************************************************************* -* HP_FILTER_RESET Register: Dummy register. Reading at this address zeroes -* instantaneously the content of the internal high pass filter. If the high pass -* filter is enabled all three axes are instantaneously set to 0g. -* This allows to overcome the settling time of the high pass filter. -* Read only register -* Default value: Dummy -*******************************************************************************/ -#define LIS302DL_HP_FILTER_RESET_REG_ADDR 0x23 - -/******************************************************************************* -* STATUS_REG Register: Status Register -* Default value: 0x00 -* 7 ZYXOR: X, Y and Z axis data overrun. -* 0: no overrun has occurred -* 1: new data has overwritten the previous one before it was read -* 6 ZOR: Z axis data overrun. -* 0: no overrun has occurred -* 1: new data for Z-axis has overwritten the previous one before it was read -* 5 yOR: y axis data overrun. -* 0: no overrun has occurred -* 1: new data for y-axis has overwritten the previous one before it was read -* 4 XOR: X axis data overrun. -* 0: no overrun has occurred -* 1: new data for X-axis has overwritten the previous one before it was read -* 3 ZYXDA: X, Y and Z axis new data available -* 0: a new set of data is not yet available -* 1: a new set of data is available -* 2 ZDA: Z axis new data available. -* 0: a new set of data is not yet available -* 1: a new data for Z axis is available -* 1 YDA: Y axis new data available -* 0: a new set of data is not yet available -* 1: a new data for Y axis is available -* 0 XDA: X axis new data available -* 0: a new set of data is not yet available -* 1: a new data for X axis is available -*******************************************************************************/ -#define LIS302DL_STATUS_REG_ADDR 0x27 - -/******************************************************************************* -* OUT_X Register: X-axis output Data -* Read only register -* Default value: output -* 7:0 XD7-XD0: X-axis output Data -*******************************************************************************/ -#define LIS302DL_OUT_X_ADDR 0x29 - -/******************************************************************************* -* OUT_Y Register: Y-axis output Data -* Read only register -* Default value: output -* 7:0 YD7-YD0: Y-axis output Data -*******************************************************************************/ -#define LIS302DL_OUT_Y_ADDR 0x2B - -/******************************************************************************* -* OUT_Z Register: Z-axis output Data -* Read only register -* Default value: output -* 7:0 ZD7-ZD0: Z-axis output Data -*******************************************************************************/ -#define LIS302DL_OUT_Z_ADDR 0x2D - -/******************************************************************************* -* FF_WW_CFG_1 Register: Configuration register for Interrupt 1 source. -* Read write register -* Default value: 0x00 -* 7 AOI: AND/OR combination of Interrupt events. -* 0: OR combination of interrupt events -* 1: AND combination of interrupt events -* 6 LIR: Latch/not latch interrupt request -* 0: interrupt request not latched -* 1: interrupt request latched -* 5 ZHIE: Enable interrupt generation on Z high event. -* 0: disable interrupt request -* 1: enable interrupt request on measured accel. value higher than preset threshold -* 4 ZLIE: Enable interrupt generation on Z low event. -* 0: disable interrupt request -* 1: enable interrupt request on measured accel. value lower than preset threshold -* 3 YHIE: Enable interrupt generation on Y high event. -* 0: disable interrupt request -* 1: enable interrupt request on measured accel. value higher than preset threshold -* 2 YLIE: Enable interrupt generation on Y low event. -* 0: disable interrupt request -* 1: enable interrupt request on measured accel. value lower than preset threshold -* 1 XHIE: Enable interrupt generation on X high event. -* 0: disable interrupt request -* 1: enable interrupt request on measured accel. value higher than preset threshold -* 0 XLIE: Enable interrupt generation on X low event. -* 0: disable interrupt request -* 1: enable interrupt request on measured accel. value lower than preset threshold -*******************************************************************************/ -#define LIS302DL_FF_WU_CFG1_REG_ADDR 0x30 - -/******************************************************************************* -* FF_WU_SRC_1 Register: Interrupt 1 source register. -* Reading at this address clears FF_WU_SRC_1 register and the FF, WU 1 interrupt -* and allow the refreshment of data in the FF_WU_SRC_1 register if the latched option -* was chosen. -* Read only register -* Default value: 0x00 -* 7 Reserved -* 6 IA: Interrupt active. -* 0: no interrupt has been generated -* 1: one or more interrupts have been generated -* 5 ZH: Z high. -* 0: no interrupt -* 1: ZH event has occurred -* 4 ZL: Z low. -* 0: no interrupt -* 1: ZL event has occurred -* 3 YH: Y high. -* 0: no interrupt -* 1: YH event has occurred -* 2 YL: Y low. -* 0: no interrupt -* 1: YL event has occurred -* 1 YH: X high. -* 0: no interrupt -* 1: XH event has occurred -* 0 YL: X low. -* 0: no interrupt -* 1: XL event has occurred -*******************************************************************************/ -#define LIS302DL_FF_WU_SRC1_REG_ADDR 0x31 - -/******************************************************************************* -* FF_WU_THS_1 Register: Threshold register -* Read Write register -* Default value: 0x00 -* 7 DCRM: Reset mode selection. -* 0 - counter resetted -* 1 - counter decremented -* 6 THS6-THS0: Free-fall/wake-up threshold value. -*******************************************************************************/ -#define LIS302DL_FF_WU_THS1_REG_ADDR 0x32 - -/******************************************************************************* -* FF_WU_DURATION_1 Register: duration Register -* Read Write register -* Default value: 0x00 -* 7:0 D7-D0 Duration value. (Duration steps and maximum values depend on the ODR chosen) - ******************************************************************************/ -#define LIS302DL_FF_WU_DURATION1_REG_ADDR 0x33 - -/******************************************************************************* -* FF_WW_CFG_2 Register: Configuration register for Interrupt 2 source. -* Read write register -* Default value: 0x00 -* 7 AOI: AND/OR combination of Interrupt events. -* 0: OR combination of interrupt events -* 1: AND combination of interrupt events -* 6 LIR: Latch/not latch interrupt request -* 0: interrupt request not latched -* 1: interrupt request latched -* 5 ZHIE: Enable interrupt generation on Z high event. -* 0: disable interrupt request -* 1: enable interrupt request on measured accel. value higher than preset threshold -* 4 ZLIE: Enable interrupt generation on Z low event. -* 0: disable interrupt request -* 1: enable interrupt request on measured accel. value lower than preset threshold -* 3 YHIE: Enable interrupt generation on Y high event. -* 0: disable interrupt request -* 1: enable interrupt request on measured accel. value higher than preset threshold -* 2 YLIE: Enable interrupt generation on Y low event. -* 0: disable interrupt request -* 1: enable interrupt request on measured accel. value lower than preset threshold -* 1 XHIE: Enable interrupt generation on X high event. -* 0: disable interrupt request -* 1: enable interrupt request on measured accel. value higher than preset threshold -* 0 XLIE: Enable interrupt generation on X low event. -* 0: disable interrupt request -* 1: enable interrupt request on measured accel. value lower than preset threshold -*******************************************************************************/ -#define LIS302DL_FF_WU_CFG2_REG_ADDR 0x34 - -/******************************************************************************* -* FF_WU_SRC_2 Register: Interrupt 2 source register. -* Reading at this address clears FF_WU_SRC_2 register and the FF, WU 2 interrupt -* and allow the refreshment of data in the FF_WU_SRC_2 register if the latched option -* was chosen. -* Read only register -* Default value: 0x00 -* 7 Reserved -* 6 IA: Interrupt active. -* 0: no interrupt has been generated -* 1: one or more interrupts have been generated -* 5 ZH: Z high. -* 0: no interrupt -* 1: ZH event has occurred -* 4 ZL: Z low. -* 0: no interrupt -* 1: ZL event has occurred -* 3 YH: Y high. -* 0: no interrupt -* 1: YH event has occurred -* 2 YL: Y low. -* 0: no interrupt -* 1: YL event has occurred -* 1 YH: X high. -* 0: no interrupt -* 1: XH event has occurred -* 0 YL: X low. -* 0: no interrupt -* 1: XL event has occurred -*******************************************************************************/ -#define LIS302DL_FF_WU_SRC2_REG_ADDR 0x35 - -/******************************************************************************* -* FF_WU_THS_2 Register: Threshold register -* Read Write register -* Default value: 0x00 -* 7 DCRM: Reset mode selection. -* 0 - counter resetted -* 1 - counter decremented -* 6 THS6-THS0: Free-fall/wake-up threshold value. -*******************************************************************************/ -#define LIS302DL_FF_WU_THS2_REG_ADDR 0x36 - -/******************************************************************************* -* FF_WU_DURATION_2 Register: duration Register -* Read Write register -* Default value: 0x00 -* 7:0 D7-D0 Duration value. (Duration steps and maximum values depend on the ODR chosen) - ******************************************************************************/ -#define LIS302DL_FF_WU_DURATION2_REG_ADDR 0x37 - -/****************************************************************************** -* CLICK_CFG Register: click Register -* Read Write register -* Default value: 0x00 -* 7 Reserved -* 6 LIR: Latch Interrupt request. -* 0: interrupt request not latched -* 1: interrupt request latched -* 5 Double_Z: Enable interrupt generation on double click event on Z axis. -* 0: disable interrupt request -* 1: enable interrupt request -* 4 Single_Z: Enable interrupt generation on single click event on Z axis. -* 0: disable interrupt request -* 1: enable interrupt request -* 3 Double_Y: Enable interrupt generation on double click event on Y axis. -* 0: disable interrupt request -* 1: enable interrupt request -* 2 Single_Y: Enable interrupt generation on single click event on Y axis. -* 0: disable interrupt request -* 1: enable interrupt request -* 1 Double_X: Enable interrupt generation on double click event on X axis. -* 0: disable interrupt request -* 1: enable interrupt request -* 0 Single_y: Enable interrupt generation on single click event on X axis. -* 0: disable interrupt request -* 1: enable interrupt request - ******************************************************************************/ -#define LIS302DL_CLICK_CFG_REG_ADDR 0x38 - -/****************************************************************************** -* CLICK_SRC Register: click status Register -* Read only register -* Default value: 0x00 -* 7 Reserved -* 6 IA: Interrupt active. -* 0: no interrupt has been generated -* 1: one or more interrupts have been generated -* 5 Double_Z: Double click on Z axis event. -* 0: no interrupt -* 1: Double Z event has occurred -* 4 Single_Z: Z low. -* 0: no interrupt -* 1: Single Z event has occurred -* 3 Double_Y: Y high. -* 0: no interrupt -* 1: Double Y event has occurred -* 2 Single_Y: Y low. -* 0: no interrupt -* 1: Single Y event has occurred -* 1 Double_X: X high. -* 0: no interrupt -* 1: Double X event has occurred -* 0 Single_X: X low. -* 0: no interrupt -* 1: Single X event has occurred -*******************************************************************************/ -#define LIS302DL_CLICK_SRC_REG_ADDR 0x39 - -/******************************************************************************* -* CLICK_THSY_X Register: Click threshold Y and X register -* Read Write register -* Default value: 0x00 -* 7:4 THSy3-THSy0: Click threshold on Y axis, step 0.5g -* 3:0 THSx3-THSx0: Click threshold on X axis, step 0.5g -*******************************************************************************/ -#define LIS302DL_CLICK_THSY_X_REG_ADDR 0x3B - -/******************************************************************************* -* CLICK_THSZ Register: Click threshold Z register -* Read Write register -* Default value: 0x00 -* 7:4 Reserved -* 3:0 THSz3-THSz0: Click threshold on Z axis, step 0.5g -*******************************************************************************/ -#define LIS302DL_CLICK_THSZ_REG_ADDR 0x3C - -/******************************************************************************* -* CLICK_TimeLimit Register: Time Limit register -* Read Write register -* Default value: 0x00 -* 7:0 Dur7-Dur0: Time Limit value, step 0.5g -*******************************************************************************/ -#define LIS302DL_CLICK_TIMELIMIT_REG_ADDR 0x3D - -/******************************************************************************* -* CLICK_Latency Register: Latency register -* Read Write register -* Default value: 0x00 -* 7:0 Lat7-Lat0: Latency value, step 1msec -*******************************************************************************/ -#define LIS302DL_CLICK_LATENCY_REG_ADDR 0x3E - -/******************************************************************************* -* CLICK_Window Register: Window register -* Read Write register -* Default value: 0x00 -* 7:0 Win7-Win0: Window value, step 1msec -*******************************************************************************/ -#define LIS302DL_CLICK_WINDOW_REG_ADDR 0x3F - -/******************************************************************************/ -/**************************** END REGISTER MAPPING ***************************/ -/******************************************************************************/ -#define I_AM_LIS302DL 0x3B - -#define LIS302DL_SENSITIVITY_2_3G 18 /* 18 mg/digit*/ -#define LIS302DL_SENSITIVITY_9_2G 72 /* 72 mg/digit*/ - -/** @defgroup Data_Rate_selection - * @{ - */ -#define LIS302DL_DATARATE_100 ((uint8_t)0x00) -#define LIS302DL_DATARATE_400 ((uint8_t)0x80) -/** - * @} - */ - -/** @defgroup Power_Mode_selection - * @{ - */ -#define LIS302DL_LOWPOWERMODE_POWERDOWN ((uint8_t)0x00) -#define LIS302DL_LOWPOWERMODE_ACTIVE ((uint8_t)0x40) -/** - * @} - */ - -/** @defgroup Full_Scale_selection - * @{ - */ -#define LIS302DL_FULLSCALE_2_3 ((uint8_t)0x00) -#define LIS302DL_FULLSCALE_9_2 ((uint8_t)0x20) -/** - * @} - */ - -/** @defgroup Self_Test_selection - * @{ - */ -#define LIS302DL_SELFTEST_NORMAL ((uint8_t)0x00) -#define LIS302DL_SELFTEST_P ((uint8_t)0x10) -#define LIS302DL_SELFTEST_M ((uint8_t)0x08) -/** - * @} - */ - -/** @defgroup Direction_XYZ_selection - * @{ - */ -#define LIS302DL_X_ENABLE ((uint8_t)0x01) -#define LIS302DL_Y_ENABLE ((uint8_t)0x02) -#define LIS302DL_Z_ENABLE ((uint8_t)0x04) -#define LIS302DL_XYZ_ENABLE ((uint8_t)0x07) -/** - * @} - */ - - /** @defgroup SPI_Serial_Interface_Mode_selection - * @{ - */ -#define LIS302DL_SERIALINTERFACE_4WIRE ((uint8_t)0x00) -#define LIS302DL_SERIALINTERFACE_3WIRE ((uint8_t)0x80) -/** - * @} - */ - - /** @defgroup Boot_Mode_selection - * @{ - */ -#define LIS302DL_BOOT_NORMALMODE ((uint8_t)0x00) -#define LIS302DL_BOOT_REBOOTMEMORY ((uint8_t)0x40) -/** - * @} - */ - - /** @defgroup Filtered_Data_Selection_Mode_selection - * @{ - */ -#define LIS302DL_FILTEREDDATASELECTION_BYPASSED ((uint8_t)0x00) -#define LIS302DL_FILTEREDDATASELECTION_OUTPUTREGISTER ((uint8_t)0x20) -/** - * @} - */ - - /** @defgroup High_Pass_Filter_Interrupt_selection - * @{ - */ -#define LIS302DL_HIGHPASSFILTERINTERRUPT_OFF ((uint8_t)0x00) -#define LIS302DL_HIGHPASSFILTERINTERRUPT_1 ((uint8_t)0x04) -#define LIS302DL_HIGHPASSFILTERINTERRUPT_2 ((uint8_t)0x08) -#define LIS302DL_HIGHPASSFILTERINTERRUPT_1_2 ((uint8_t)0x0C) -/** - * @} - */ - - /** @defgroup High_Pass_Filter_selection - * @{ - */ -#define LIS302DL_HIGHPASSFILTER_LEVEL_0 ((uint8_t)0x00) -#define LIS302DL_HIGHPASSFILTER_LEVEL_1 ((uint8_t)0x01) -#define LIS302DL_HIGHPASSFILTER_LEVEL_2 ((uint8_t)0x02) -#define LIS302DL_HIGHPASSFILTER_LEVEL_3 ((uint8_t)0x03) -/** - * @} - */ - -/** @defgroup latch_Interrupt_Request_selection - * @{ - */ -#define LIS302DL_INTERRUPTREQUEST_NOTLATCHED ((uint8_t)0x00) -#define LIS302DL_INTERRUPTREQUEST_LATCHED ((uint8_t)0x40) -/** - * @} - */ - -/** @defgroup Click_Interrupt_XYZ_selection - * @{ - */ -#define LIS302DL_CLICKINTERRUPT_XYZ_DISABLE ((uint8_t)0x00) -#define LIS302DL_CLICKINTERRUPT_X_ENABLE ((uint8_t)0x01) -#define LIS302DL_CLICKINTERRUPT_Y_ENABLE ((uint8_t)0x04) -#define LIS302DL_CLICKINTERRUPT_Z_ENABLE ((uint8_t)0x10) -#define LIS302DL_CLICKINTERRUPT_XYZ_ENABLE ((uint8_t)0x15) -/** - * @} - */ - -/** @defgroup Double_Click_Interrupt_XYZ_selection - * @{ - */ -#define LIS302DL_DOUBLECLICKINTERRUPT_XYZ_DISABLE ((uint8_t)0x00) -#define LIS302DL_DOUBLECLICKINTERRUPT_X_ENABLE ((uint8_t)0x02) -#define LIS302DL_DOUBLECLICKINTERRUPT_Y_ENABLE ((uint8_t)0x08) -#define LIS302DL_DOUBLECLICKINTERRUPT_Z_ENABLE ((uint8_t)0x20) -#define LIS302DL_DOUBLECLICKINTERRUPT_XYZ_ENABLE ((uint8_t)0x2A) -/** - * @} - */ - -/** - * @} - */ - -/** @defgroup LIS302DL_Exported_Functions - * @{ - */ -void LIS302DL_Init(uint16_t InitStruct); -void LIS302DL_DeInit(void); -uint8_t LIS302DL_ReadID(void); -void LIS302DL_FilterConfig(uint8_t FilterStruct); -void LIS302DL_InterruptConfig(LIS302DL_InterruptConfigTypeDef *LIS302DL_IntConfigStruct); -void LIS302DL_Click_IntConfig(void); -void LIS302DL_Click_IntClear(void); -void LIS302DL_LowpowerCmd(uint8_t LowPowerMode); -void LIS302DL_FullScaleCmd(uint8_t FS_value); -void LIS302DL_DataRateCmd(uint8_t DataRateValue); -void LIS302DL_RebootCmd(void); -void LIS302DL_ReadACC(int16_t *pData); - -/* Accelerometer driver structure */ -extern ACCELERO_DrvTypeDef Lis302dlDrv; - -/* Accelerometer IO functions */ -void ACCELERO_IO_Init(void); -void ACCELERO_IO_ITConfig(void); -void ACCELERO_IO_Write(uint8_t* pBuffer, uint8_t WriteAddr, uint16_t NumByteToWrite); -void ACCELERO_IO_Read(uint8_t* pBuffer, uint8_t ReadAddr, uint16_t NumByteToRead); - -#ifdef __cplusplus -} -#endif - -#endif /* __LIS302DL_H */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/lis3dsh/Release_Notes.html b/bsp/stm32f411RE/Libraries/BSP/Components/lis3dsh/Release_Notes.html deleted file mode 100644 index c30545b6ff..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/lis3dsh/Release_Notes.html +++ /dev/null @@ -1,514 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - Release Notes for LIS3DSH Component Driver - - - - - - - - - - -
-


-

-
- - - - - - -
- - - - - - - - - -
-

Back to Release page

-
-

Release -Notes for LIS3DSH Component Driver

-

Copyright -2015 STMicroelectronics

-

-
-

 

- - - - - - -

Update History

-

V2.0.0 / 03-August-2015

- - - - - - - - - - - - - - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  • lis3dsh.h/c: 
    • Add mems accelerometer de-initialization -function: LIS3DSH_DeInit()
    • NOTE: This release must be used with BSP Common -driver V4.0.0 or later

V1.0.2 / 02-December-2014

- - - - - - - - - - - - - - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
  • lis3dsh.h: change "\" by "/" in the include path to fix compilation issue under Linux
  • -
- - -

V1.0.1 / 19-June-2014

- - - - - - - - - - - - - - - - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
  • Comments clean up and typo corrections
  • -
- - -

V1.0.0 / 18-February-2014

- - - - - - - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
  • First official release
  • -
-

License


-Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met:
-
-
  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions -in binary form must reproduce the above copyright notice, this list of -conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of STMicroelectronics nor the names of its contributors may be used to endorse or promote products derived
    -
    -
-        from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- -
- - - -
-
-
For -complete documentation on STM32 Microcontrollers -visit www.st.com/STM32
-
-

-
-
-

 

-
- - \ No newline at end of file diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/lis3dsh/lis3dsh.c b/bsp/stm32f411RE/Libraries/BSP/Components/lis3dsh/lis3dsh.c deleted file mode 100644 index 494c48310a..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/lis3dsh/lis3dsh.c +++ /dev/null @@ -1,431 +0,0 @@ -/** - ****************************************************************************** - * @file lis3dsh.c - * @author MCD Application Team - * @version V2.0.0 - * @date 03-August-2015 - * @brief This file provides a set of functions needed to manage the LIS3DSH - * MEMS Accelerometer. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Includes ------------------------------------------------------------------*/ -#include "lis3dsh.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup Components - * @{ - */ - -/** @addtogroup LIS3DSH - * @brief This file includes the motion sensor driver for LIS3DSH motion sensor - * devices. - * @{ - */ - -/** @defgroup LIS3DSH_Private_TypesDefinitions - * @{ - */ - -/** - * @} - */ - -/** @defgroup LIS3DSH_Private_Defines - * @{ - */ - -/** - * @} - */ - -/** @defgroup LIS3DSH_Private_Macros - * @{ - */ - -/** - * @} - */ - -/** @defgroup LIS3DSH_Private_Variables - * @{ - */ -ACCELERO_DrvTypeDef Lis3dshDrv = -{ - LIS3DSH_Init, - LIS3DSH_DeInit, - LIS3DSH_ReadID, - LIS3DSH_RebootCmd, - LIS3DSH_Click_IntConfig, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - LIS3DSH_ReadACC, -}; - -/** - * @} - */ - -/** @defgroup LIS3DSH_Private_FunctionPrototypes - * @{ - */ - -/** - * @} - */ - -/** @defgroup LIS3DSH_Private_Functions - * @{ - */ - -/** - * @brief Set LIS3DSH Initialization. - * @param InitStruct: contains mask of different init parameters - * @retval None - */ -void LIS3DSH_Init(uint16_t InitStruct) -{ - uint8_t ctrl = 0x00; - - /* Configure the low level interface */ - ACCELERO_IO_Init(); - - /* Configure MEMS: power mode(ODR) and axes enable */ - ctrl = (uint8_t) (InitStruct); - - /* Write value to MEMS CTRL_REG4 register */ - ACCELERO_IO_Write(&ctrl, LIS3DSH_CTRL_REG4_ADDR, 1); - - /* Configure MEMS: full scale and self test */ - ctrl = (uint8_t) (InitStruct >> 8); - - /* Write value to MEMS CTRL_REG5 register */ - ACCELERO_IO_Write(&ctrl, LIS3DSH_CTRL_REG5_ADDR, 1); -} - -/** - * @brief LIS3DSH De-Initialization. - * @param None - * @retval None. - */ -void LIS3DSH_DeInit(void) -{ - -} - -/** - * @brief Read LIS3DSH device ID. - * @param None - * @retval The Device ID (two bytes). - */ -uint8_t LIS3DSH_ReadID(void) -{ - uint8_t tmp = 0; - - /* Configure the low level interface */ - ACCELERO_IO_Init(); - - /* Read WHO_AM_I register */ - ACCELERO_IO_Read(&tmp, LIS3DSH_WHO_AM_I_ADDR, 1); - - /* Return the ID */ - return (uint16_t)tmp; -} - -/** - * @brief Set LIS3DSH Interrupt configuration - * @param LIS3DSH_InterruptConfig_TypeDef: pointer to a LIS3DSH_InterruptConfig_TypeDef - * structure that contains the configuration setting for the LIS3DSH Interrupt. - * @retval None - */ -void LIS3DSH_InterruptConfig(LIS3DSH_InterruptConfigTypeDef *LIS3DSH_IntConfigStruct) -{ - uint8_t ctrl = 0x00; - - /* Configure Interrupt Selection , Request and Signal */ - ctrl = (uint8_t)(LIS3DSH_IntConfigStruct->Interrupt_Selection_Enable | \ - LIS3DSH_IntConfigStruct->Interrupt_Request | \ - LIS3DSH_IntConfigStruct->Interrupt_Signal); - - /* Write value to MEMS CTRL_REG3 register */ - ACCELERO_IO_Write(&ctrl, LIS3DSH_CTRL_REG3_ADDR, 1); - - /* Configure State Machine 1 */ - ctrl = (uint8_t)(LIS3DSH_IntConfigStruct->State_Machine1_Enable | \ - LIS3DSH_IntConfigStruct->State_Machine1_Interrupt); - - /* Write value to MEMS CTRL_REG1 register */ - ACCELERO_IO_Write(&ctrl, LIS3DSH_CTRL_REG1_ADDR, 1); - - /* Configure State Machine 2 */ - ctrl = (uint8_t)(LIS3DSH_IntConfigStruct->State_Machine2_Enable | \ - LIS3DSH_IntConfigStruct->State_Machine2_Interrupt); - - /* Write value to MEMS CTRL_REG2 register */ - ACCELERO_IO_Write(&ctrl, LIS3DSH_CTRL_REG2_ADDR, 1); -} - -/** - * @brief Set LIS3DSH for click detection - * @param None - * @retval None - */ -void LIS3DSH_Click_IntConfig(void) -{ - uint8_t ctrl = 0x00; - LIS3DSH_InterruptConfigTypeDef LIS3DSH_InterruptStruct; - - ACCELERO_IO_ITConfig(); - - /* Set LIS3DSH Interrupt configuration */ - LIS3DSH_InterruptStruct.Interrupt_Selection_Enable = LIS3DSH_INTERRUPT_2_ENABLE; - LIS3DSH_InterruptStruct.Interrupt_Request = LIS3DSH_INTERRUPT_REQUEST_LATCHED; - LIS3DSH_InterruptStruct.Interrupt_Signal = LIS3DSH_INTERRUPT_SIGNAL_HIGH; - LIS3DSH_InterruptStruct.State_Machine1_Enable = LIS3DSH_SM_DISABLE; - LIS3DSH_InterruptStruct.State_Machine2_Enable = LIS3DSH_SM_ENABLE; - LIS3DSH_InterruptStruct.State_Machine2_Interrupt = LIS3DSH_SM_INT1; - LIS3DSH_InterruptConfig(&LIS3DSH_InterruptStruct); - - /* Set LIS3DSH State Machines configuration */ - ctrl=0x03; - ACCELERO_IO_Write(&ctrl, LIS3DSH_TIM2_1_L_ADDR,1); - ctrl=0xC8; - ACCELERO_IO_Write(&ctrl, LIS3DSH_TIM1_1_L_ADDR,1); - ctrl=0x45; - ACCELERO_IO_Write(&ctrl, LIS3DSH_THRS2_1_ADDR,1); - ctrl=0xFC; - ACCELERO_IO_Write(&ctrl, LIS3DSH_MASK1_A_ADDR,1); - ctrl=0xA1; - ACCELERO_IO_Write(&ctrl, LIS3DSH_SETT1_ADDR,1); - ctrl=0x01; - ACCELERO_IO_Write(&ctrl, LIS3DSH_PR1_ADDR,1); - - ACCELERO_IO_Write(&ctrl, LIS3DSH_SETT2_ADDR,1); - - /* Configure State Machine 2 to detect single click */ - ACCELERO_IO_Write(&ctrl, LIS3DSH_ST2_1_ADDR,1); - ctrl=0x06; - ACCELERO_IO_Write(&ctrl, LIS3DSH_ST2_2_ADDR,1); - ctrl=0x28; - ACCELERO_IO_Write(&ctrl, LIS3DSH_ST2_3_ADDR,1); - ctrl=0x11; - ACCELERO_IO_Write(&ctrl, LIS3DSH_ST2_4_ADDR,1); -} - -/** - * @brief Change the lowpower mode for LIS3DSH. - * @param LowPowerMode: new state for the lowpower mode. - * This parameter can be one of the following values: - * @arg LIS3DSH_DATARATE_POWERDOWN: Power down mode - * @arg LIS3DSH_DATARATE_3_125: Normal mode. ODR: 3.125 Hz - * @arg LIS3DSH_DATARATE_6_25: Normal mode. ODR: 6.25 Hz - * @arg LIS3DSH_DATARATE_12_5: Normal mode. ODR: 12.5 Hz - * @arg LIS3DSH_DATARATE_25: Normal mode. ODR: 25 Hz - * @arg LIS3DSH_DATARATE_50: Normal mode. ODR: 50 Hz - * @arg LIS3DSH_DATARATE_100: Normal mode. ODR: 100 Hz - * @arg LIS3DSH_DATARATE_400: Normal mode. ODR: 400 Hz - * @arg LIS3DSH_DATARATE_800: Normal mode. ODR: 800 Hz - * @arg LIS3DSH_DATARATE_1600: Normal mode. ODR: 1600 Hz - * @retval None - */ -void LIS3DSH_ODR_LowpowerCmd(uint8_t ODR_LowPowerMode) -{ - uint8_t tmpreg; - - /* Read CTRL_REG4 register */ - ACCELERO_IO_Read(&tmpreg, LIS3DSH_CTRL_REG4_ADDR, 1); - - /* Set new low power mode configuration */ - tmpreg &= (uint8_t)~LIS3DSH_DATARATE_100; - tmpreg |= ODR_LowPowerMode; - - /* Write value to MEMS CTRL_REG4 register */ - ACCELERO_IO_Write(&tmpreg, LIS3DSH_CTRL_REG4_ADDR, 1); -} - -/** - * @brief Data Rate command. - * @param DataRateValue: Data rate value. - * This parameter can be one of the following values: - * @arg LIS3DSH_DATARATE_3_125: 3.125 Hz output data rate - * @arg LIS3DSH_DATARATE_6_25: 6.25 Hz output data rate - * @arg LIS3DSH_DATARATE_12_5: 12.5 Hz output data rate - * @arg LIS3DSH_DATARATE_25: 25 Hz output data rate - * @arg LIS3DSH_DATARATE_50: 50 Hz output data rate - * @arg LIS3DSH_DATARATE_100: 100 Hz output data rate - * @arg LIS3DSH_DATARATE_400: 400 Hz output data rate - * @arg LIS3DSH_DATARATE_800: 800 Hz output data rate - * @arg LIS3DSH_DATARATE_1600: 1600 Hz output data rate - * @retval None - */ -void LIS3DSH_DataRateCmd(uint8_t DataRateValue) -{ - uint8_t tmpreg; - - /* Read CTRL_REG4 register */ - ACCELERO_IO_Read(&tmpreg, LIS3DSH_CTRL_REG4_ADDR, 1); - - /* Set new data rate configuration from 100 to 400Hz */ - tmpreg &= (uint8_t)~LIS3DSH_DATARATE_400; - tmpreg |= DataRateValue; - - /* Write value to MEMS CTRL_REG4 register */ - ACCELERO_IO_Write(&tmpreg, LIS3DSH_CTRL_REG4_ADDR, 1); -} - -/** - * @brief Change the Full Scale of LIS3DSH. - * @param FS_value: new full scale value. - * This parameter can be one of the following values: - * @arg LIS3DSH_FULLSCALE_2: +-2g - * @arg LIS3DSH_FULLSCALE_4: +-4g - * @arg LIS3DSH_FULLSCALE_6: +-6g - * @arg LIS3DSH_FULLSCALE_8: +-8g - * @arg LIS3DSH_FULLSCALE_16: +-16g - * @retval None - */ -void LIS3DSH_FullScaleCmd(uint8_t FS_value) -{ - uint8_t tmpreg; - - /* Read CTRL_REG5 register */ - ACCELERO_IO_Read(&tmpreg, LIS3DSH_CTRL_REG5_ADDR, 1); - - /* Set new full scale configuration */ - tmpreg &= (uint8_t)~LIS3DSH_FULLSCALE_16; - tmpreg |= FS_value; - - /* Write value to MEMS CTRL_REG5 register */ - ACCELERO_IO_Write(&tmpreg, LIS3DSH_CTRL_REG5_ADDR, 1); -} - -/** - * @brief Reboot memory content of LIS3DSH. - * @param None - * @retval None - */ -void LIS3DSH_RebootCmd(void) -{ - uint8_t tmpreg; - /* Read CTRL_REG6 register */ - ACCELERO_IO_Read(&tmpreg, LIS3DSH_CTRL_REG6_ADDR, 1); - - /* Enable or Disable the reboot memory */ - tmpreg |= LIS3DSH_BOOT_FORCED; - - /* Write value to MEMS CTRL_REG6 register */ - ACCELERO_IO_Write(&tmpreg, LIS3DSH_CTRL_REG6_ADDR, 1); -} - -/** - * @brief Read LIS3DSH output register, and calculate the acceleration - * ACC[mg]=SENSITIVITY* (out_h*256+out_l)/16 (12 bit representation). - * @param pointer on floating buffer. - * @retval None - */ -void LIS3DSH_ReadACC(int16_t *pData) -{ - int8_t buffer[6]; - uint8_t crtl, i = 0x00; - float sensitivity = LIS3DSH_SENSITIVITY_0_06G; - float valueinfloat = 0; - - ACCELERO_IO_Read(&crtl, LIS3DSH_CTRL_REG5_ADDR, 1); - ACCELERO_IO_Read((uint8_t*)&buffer[0], LIS3DSH_OUT_X_L_ADDR, 1); - ACCELERO_IO_Read((uint8_t*)&buffer[1], LIS3DSH_OUT_X_H_ADDR, 1); - ACCELERO_IO_Read((uint8_t*)&buffer[2], LIS3DSH_OUT_Y_L_ADDR, 1); - ACCELERO_IO_Read((uint8_t*)&buffer[3], LIS3DSH_OUT_Y_H_ADDR, 1); - ACCELERO_IO_Read((uint8_t*)&buffer[4], LIS3DSH_OUT_Z_L_ADDR, 1); - ACCELERO_IO_Read((uint8_t*)&buffer[5], LIS3DSH_OUT_Z_H_ADDR, 1); - - switch(crtl & LIS3DSH__FULLSCALE_SELECTION) - { - /* FS bit = 000 ==> Sensitivity typical value = 0.06milligals/digit */ - case LIS3DSH_FULLSCALE_2: - sensitivity = LIS3DSH_SENSITIVITY_0_06G; - break; - - /* FS bit = 001 ==> Sensitivity typical value = 0.12milligals/digit */ - case LIS3DSH_FULLSCALE_4: - sensitivity = LIS3DSH_SENSITIVITY_0_12G; - break; - - /* FS bit = 010 ==> Sensitivity typical value = 0.18milligals/digit */ - case LIS3DSH_FULLSCALE_6: - sensitivity = LIS3DSH_SENSITIVITY_0_18G; - break; - - /* FS bit = 011 ==> Sensitivity typical value = 0.24milligals/digit */ - case LIS3DSH_FULLSCALE_8: - sensitivity = LIS3DSH_SENSITIVITY_0_24G; - break; - - /* FS bit = 100 ==> Sensitivity typical value = 0.73milligals/digit */ - case LIS3DSH_FULLSCALE_16: - sensitivity = LIS3DSH_SENSITIVITY_0_73G; - break; - - default: - break; - } - - /* Obtain the mg value for the three axis */ - for(i=0; i<3; i++) - { - valueinfloat = ((buffer[2*i+1] << 8) + buffer[2*i]) * sensitivity; - pData[i] = (int16_t)valueinfloat; - } -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/lis3dsh/lis3dsh.h b/bsp/stm32f411RE/Libraries/BSP/Components/lis3dsh/lis3dsh.h deleted file mode 100644 index a0f0070e51..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/lis3dsh/lis3dsh.h +++ /dev/null @@ -1,1255 +0,0 @@ -/** - ****************************************************************************** - * @file lis3dsh.h - * @author MCD Application Team - * @version V2.0.0 - * @date 03-August-2015 - * @brief This file contains all the functions prototypes for the lis3dsh.c - * firmware driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __LIS3DSH_H -#define __LIS3DSH_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "../Common/accelero.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup Components - * @{ - */ - -/** @addtogroup LIS302DL - * @{ - */ - -/** @defgroup LIS3DSH_Exported_Types - * @{ - */ -/* LIS3DSH struct */ -typedef struct -{ - uint8_t Output_DataRate; /* Output Data Rate into CTRL_REG4 register */ - uint8_t Axes_Enable; /* Axes enable into CTRL_REG4 register */ - uint8_t SPI_Wire; /* SPI Wire into CTRL_REG5 register */ - uint8_t Self_Test; /* Self test into CTRL_REG5 register */ - uint8_t Full_Scale; /* Full scale into CTRL_REG5 register */ - uint8_t Filter_BW; /* Filter BW into CTRL_REG5 register */ -}LIS3DSH_InitTypeDef; - -/* LIS3DSH Interrupt struct */ -typedef struct -{ - uint8_t Interrupt_Request; /* Latch/Pulse Interrupt request into CTRL_REG3 register */ - uint8_t Interrupt_Selection_Enable; /* Interrupt1/2 selection enable into CTRL_REG3 register */ - uint8_t Interrupt_Signal; /* Interrupt signal active Low/High into CTRL_REG3 register */ - uint8_t State_Machine1_Enable; /* State Machine 1 enable/disable into CTRL_REG1 register */ - uint8_t State_Machine1_Interrupt; /* State Machine 1 routed Interrupt into CTRL_REG1 register */ - uint8_t State_Machine2_Enable; /* State Machine 2 enable/disable into CTRL_REG2 register */ - uint8_t State_Machine2_Interrupt; /* State Machine 2 routed Interrupt into CTRL_REG1 register */ -}LIS3DSH_InterruptConfigTypeDef; -/** - * @} - */ - -/** @defgroup LIS3DSH_Exported_Constants - * @{ - */ - -/******************************************************************************/ -/*************************** START REGISTER MAPPING **************************/ -/******************************************************************************/ - -/******************************************************************************* -* OUT_T Register: Temperature Output Register -* Read only register -* Default value: 0x21 -* 7:0 Temp7-Temp0: Temperature output Data -*******************************************************************************/ -#define LIS3DSH_OUT_T_ADDR 0x0C - -/******************************************************************************* -* INFO1 Register: Information Register 1 -* Read only register -* Default value: 0x21 -*******************************************************************************/ -#define LIS3DSH_INFO1_ADDR 0x0D - -/******************************************************************************* -* INFO2 Register: Information Register 2 -* Read only register -* Default value: 0x00 -*******************************************************************************/ -#define LIS3DSH_INFO2_ADDR 0x0E - -/******************************************************************************* -* WHO_AM_I Register: Device Identification Register -* Read only register -* Default value: 0x3F -*******************************************************************************/ -#define LIS3DSH_WHO_AM_I_ADDR 0x0F - -/******************************************************************************* -* OFF_X Register: X-axis Offset Compensation Register -* Read Write register -* Default value: 0x00 -* 7:0 OFFx_7-OFFx_0: X-axis Offset Compensation Value -*******************************************************************************/ -#define LIS3DSH_OFF_X_ADDR 0x10 - -/******************************************************************************* -* OFF_Y Register: Y-axis Offset Compensation Register -* Read Write register -* Default value: 0x00 -* 7:0 OFFy_7-OFFy_0: Y-axis Offset Compensation Value -*******************************************************************************/ -#define LIS3DSH_OFF_Y_ADDR 0x11 - -/******************************************************************************* -* OFF_Z Register: Z-axis Offset Compensation Register -* Read Write register -* Default value: 0x00 -* 7:0 OFFz_7-OFFz_0: Z-axis Offset Compensation Value -*******************************************************************************/ -#define LIS3DSH_OFF_Z_ADDR 0x12 - -/******************************************************************************* -* CS_X Register: X-axis Constant Shift Register -* Read Write register -* Default value: 0x00 -* 7:0 CS_7-CS_0: X-axis Constant Shift Value -*******************************************************************************/ -#define LIS3DSH_CS_X_ADDR 0x13 - -/******************************************************************************* -* CS_Y Register: Y-axis Constant Shift Register -* Read Write register -* Default value: 0x00 -* 7:0 CS_7-CS_0: Y-axis Constant Shift Value -*******************************************************************************/ -#define LIS3DSH_CS_Y_ADDR 0x14 - -/******************************************************************************* -* CS_Z Register: Z-axis Constant Shift Value Register -* Read Write register -* Default value: 0x00 -* 7:0 CS_7-CS_0: Z-axis Constant Shift Value -*******************************************************************************/ -#define LIS3DSH_CS_Z_ADDR 0x15 - -/******************************************************************************* -* LC_L Register: Long Counter Low Register -* Read Write register -* Default value: 0x01 -* 7:0 LC_L_7-LC_L_0: Long Counter Low Value -*******************************************************************************/ -#define LIS3DSH_LC_L_ADDR 0x16 - -/******************************************************************************* -* LC_H Register: Long Counter High Register -* Read Write register -* Default value: 0x00 -* 7:0 LC_H_7-LC_H_0: Long Counter Low Value -*******************************************************************************/ -#define LIS3DSH_LC_H_ADDR 0x17 - -/******************************************************************************* -* STAT Register: State Machine Register -* Read only register -* Default value: 0x00 -* 7 LONG: LONG flag common to both State Machines -* 0 - no interrupt -* 1 - LongCounter interrupt flag -* 6 SYNCW: Common information for OUTW host action waiting -* 0 - no action waiting from Host -* 1 - Host action is waiting after OUTW command -* 5 SYNC1: -* 0 - State Machine 1 running normally -* 1 - SM1 stopped and waiting for restart request from SM2 -* 4 SYNC2: -* 0 - State Machine 2 running normally -* 1 - SM2 stopped and waiting for restart request from SM1 -* 3 INT_SM1: Interrupt signal on SM1 is reset when OUTS1 register is read -* 0 - no interrupt on State Machine 1 -* 1 - State Machine 1 interrupt happened -* 2 INT_SM2: Interrupt signal on SM2 is reset when OUTS2 register is read -* 0 - no interrupt on State Machine 2 -* 1 - State Machine 2 interrupt happened -* 1 DOR: Data OverRun bit -* 0 - no overrun -* 1 - data overrun -* 0 DRDY: New data are ready in output registers -* 0 - data not ready -* 1 - data ready -*******************************************************************************/ -#define LIS3DSH_STAT_ADDR 0x18 - -/******************************************************************************* -* PEAK1 Register: Peak 1 Register -* Read only register -* Default value: 0x00 -* 7:0 PKx_7-PKx_0: Peak 1 Value for SM1 -*******************************************************************************/ -#define LIS3DSH_PEAK1_ADDR 0x19 - -/******************************************************************************* -* PEAK2 Register: Peak 2 Register -* Read only register -* Default value: 0x00 -* 7:0 PKx_7-PKx_0: Peak 2 value for SM2 -*******************************************************************************/ -#define LIS3DSH_PEAK2_ADDR 0x1A - -/******************************************************************************* -* VFC_1 Register: Vector Filter Coefficient 1 Register -* Read Write register -* Default value: 0x00 -* 7:0 VFC1_7-VFC1_0: Vector Filter Coefficient 1 Value -*******************************************************************************/ -#define LIS3DSH_VFC_1_ADDR 0x1B - -/******************************************************************************* -* VFC_2 Register: Vector Filter Coefficient 2 Register -* Read Write register -* Default value: 0x00 -* 7:0 VFC2_7-VFC2_0: Vector Filter Coefficient 2 Value -*******************************************************************************/ -#define LIS3DSH_VFC_2_ADDR 0x1C - -/******************************************************************************* -* VFC_3 Register: Vector Filter Coefficient 3 Register -* Read Write register -* Default value: 0x00 -* 7:0 VFC3_7-VFC3_0: Vector Filter Coefficient 3 Value -*******************************************************************************/ -#define LIS3DSH_VFC_3_ADDR 0x1D - -/******************************************************************************* -* VFC_4 Register: Vector Filter Coefficient 4 Register -* Read Write register -* Default value: 0x00 -* 7:0 VFC4_7-VFC4_0: Vector Filter Coefficient 4 Value -*******************************************************************************/ -#define LIS3DSH_VFC_4_ADDR 0x1E - -/******************************************************************************* -* THRS3 Register: Threshold Value 3 Register -* Read Write register -* Default value: 0x00 -* 7:0 THRS3_7-THRS3_0: Common Threshold for Overrun Detection Value -*******************************************************************************/ -#define LIS3DSH_THRS3_ADDR 0x1F - -/******************************************************************************* -* CTRL_REG4 Register: Control Register 4 -* Read Write register -* Default value: 0x07 -* 7:4 ODR3-ODR0: Data rate selection -* ODR3 | ODR2 | ODR1 | ORD0 | ORD Selection -* ------------------------------------------- -* 0 | 0 | 0 | 0 | Power Down (Default) -* 0 | 0 | 0 | 1 | 3.125 Hz -* 0 | 0 | 1 | 0 | 6.25 Hz -* 0 | 0 | 1 | 1 | 12.5 Hz -* 0 | 1 | 0 | 0 | 25 Hz -* 0 | 1 | 0 | 1 | 50 Hz -* 0 | 1 | 1 | 0 | 100 Hz -* 0 | 1 | 1 | 1 | 400 Hz -* 1 | 0 | 0 | 0 | 800 Hz -* 1 | 0 | 0 | 1 | 1600 Hz -* -* 3 BDU: Block data update -* 0: Output register not updated until High and Low reading (Default) -* 1: Continuous update -* 2 ZEN: -* 0: Z-axis disable (Default) -* 1: Z-axis enable -* 1 YEN: -* 0: Y-axis disable (Default) -* 1: Y-axis enable -* 0 XEN: -* 0: Y-axis disable (Default) -* 1: Y-axis enable -*******************************************************************************/ -#define LIS3DSH_CTRL_REG4_ADDR 0x20 - -/******************************************************************************* -* CTRL_REG1 Register: Control Register 1 (SM1 interrupt configuration register) -* Read Write register -* Default value: 0x00 -* 7:5 HYST1_2-HYST1_0: Hysteresis which is added or subtracted from the -* threshold values (THRS1_1 and THRS2_1) of SM1. -* 000 = 0 (Default) -* 111 = 7 (maximum Hysteresis) -* 4 Reserved -* 3 SM1_INT: -* 0: State Machine 1 interrupt routed to INT1 (Default) -* 1: State Machine 1 interrupt routed to INT2 -* 2 Reserved -* 1 Reserved -* 0 SM1_EN: -* 0: State Machine 1 disabled. Temporary memories and registers -* related to this State Machine are left intact. (Default) -* 1: State Machine 1 enabled. -*******************************************************************************/ -#define LIS3DSH_CTRL_REG1_ADDR 0x21 - -/******************************************************************************* -* CTRL_REG2 Register: Control Register 2 (SM2 interrupt configuration register) -* Read Write register -* Default value: 0x00 -* 7:5 HYST2_2-HYST2_0: Hysteresis which is added or subtracted from the -* threshold values (THRS1_2 and THRS2_2) of SM1. -* 000 = 0 (Default) -* 111 = 7 (maximum Hysteresis) -* 4 Reserved -* 3 SM2_INT: -* 0: State Machine 2 interrupt routed to INT1 (Default) -* 1: State Machine 2 interrupt routed to INT2 -* 2 Reserved -* 1 Reserved -* 0 SM2_EN: -* 0: State Machine 2 disabled. Temporary memories and registers -* related to this State Machine are left intact. (Default) -* 1: State Machine 2 enabled. -*******************************************************************************/ -#define LIS3DSH_CTRL_REG2_ADDR 0x22 - -/******************************************************************************* -* CTRL_REG3 Register: Control Register 3 -* Read Write register -* Default value: 0x00 -* 7 DR_EN: Data-ready interrupt -* 0 - Data-ready interrupt disabled (Default) -* 1 - Data-ready interrupt enabled and routed to INT1 -* 6 IEA: -* 0 - Interrupt signal active LOW (Default) -* 1 - Interrupt signal active HIGH -* 5 IEL: -* 0 - Interrupt latched (Default) -* 1 - Interrupt pulsed -* 4 INT2_EN: -* 0 - INT2 signal disabled (High-Z state) (Default) -* 1 - INT2 signal enabled (signal pin fully functional) -* 3 INT1_EN: -* 0 - INT1 (DRDY) signal disabled (High-Z state) (Default) -* 1 - INT1 (DRDY) signal enabled (signal pin fully functional) DR_EN bit in CTRL_REG3 register should be taken into account too -* 2 VLIFT: -* 0 - Vector filter disabled (Default) -* 1 - Vector filter enabled -* 1 Reserved -* 0 STRT: Soft Reset -* 0 - (Default) -* 1 - it resets the whole internal logic circuitry. It automatically returns to 0. -*******************************************************************************/ -#define LIS3DSH_CTRL_REG3_ADDR 0x23 - -/******************************************************************************* -* CTRL_REG5 Register: Control Register 5 -* Read Write register -* Default value: 0x00 -* 7:6 BW2-BW1: Anti aliasing filter bandwidth -* BW2 | BW1 | BW Selection -* ------------------------- -* 0 | 0 | 800 Hz (Default) -* 0 | 1 | 40 Hz -* 1 | 0 | 200 Hz -* 1 | 1 | 50 Hz -* -* 5:3 FSCALE2-FSCALE0: Full scale selection -* FSCALE2 | FSCALE1 | FSCALE0 | Full scale selection -* -------------------------------------------------- -* 0 | 0 | 0 | +/-2g (Default) -* 0 | 0 | 1 | +/-4g -* 0 | 1 | 0 | +/-6g -* 0 | 1 | 1 | +/-8g -* 1 | 0 | 0 | +/-16g -* -* 2:1 ST2_ST1: Self-test Enable -* ST2 | ST1 | ST Selection -* ------------------------- -* 0 | 0 | Normal Mode (Default) -* 0 | 1 | Positive sign self-test -* 1 | 0 | Negative sign-test -* 1 | 1 | Not Allowed -* -* 0 SIM: SPI serial internal interface mode selection -* 0: 4-wire interface (Default) -* 1: 3-wire interface -*******************************************************************************/ -#define LIS3DSH_CTRL_REG5_ADDR 0x24 - -/******************************************************************************* -* CTRL_REG6 Register: Control Register 6 -* Read Write register -* Default value: 0x00 -* 7 BOOT: Force reboot, cleared as soon as the reboot is finished. Active High. -* 6 FIFO_EN: FIFO Enable -* 0: disable (Default) -* 1: enable -* 5 STP_WTM: Stop on Watermark - FIFO depth can be limited at the Watermark value, by setting to “1” the STP_WTM bit. -* 0: disable (Default) -* 1: enable -* 4 IF_ADD_INC: Register address automatically increased during a multiple byte access with a serial interface (I2C or SPI) -* 0: disable (Default) -* 1: enable -* 3 I1_EMPTY: Enable FIFO Empty indication on INT1 pin. -* 0: disable (Default) -* 1: enable -* 2 I1_WTM: FIFO Watermark interrupt on INT1 pin. -* 0: disable (Default) -* 1: enable -* 1 I1_OVERRUN: FIFO Overrun interrupt on INT1 pin. -* 0: disable (Default) -* 1: enable -* 0 I2_BOOT: BOOT interrupt on INT2 pin. -* 0: disable (Default) -* 1: enable -*******************************************************************************/ -#define LIS3DSH_CTRL_REG6_ADDR 0x25 - -/******************************************************************************* -* STATUS Register: Status Data Register -* Read only register -* Default value: 0x00 -* 7 ZYXOR: X, Y and Z-axis Data Overrun. -* 0: no Overrun has occurred (Default) -* 1: a new set of data has overwritten the previous ones -* 6 ZOR: Z-axis Data Overrun. -* 0: no Overrun has occurred (Default) -* 1: a new data for the Z-axis has overwritten the previous ones -* 5 YOR: Y-axis Data Overrun. -* 0: no Overrun has occurred (Default) -* 1: a new data for the Y-axis has overwritten the previous ones -* 4 XOR: X-axis Data Overrun. -* 0: no Overrun has occurred (Default) -* 1: a new data for the X-axis has overwritten the previous ones -* 3 ZYXDA: X, Y and Z-axis new Data Available. -* 0: a new set of data is not yet available (Default) -* 1: a new set of data is available -* 2 ZDA: Z-axis new data available. -* 0: a new data for the Z-axis is not yet available (Default) -* 1: a new data for Z-axis is available -* 1 YDA: Y-axis new data available. -* 0: a new data for the Y-axis is not yet available (Default) -* 1: a new data for Y-axis is available -* 0 XDA: X-axis new data available. -* 0: a new data for the X-axis is not yet available (Default) -* 1: a new data for X-axis is available -*******************************************************************************/ -#define LIS3DSH_STATUS_ADDR 0x27 - -/******************************************************************************* -* OUT_X_L Register: X-axis Output Acceleration Low Data -* Read only register -* Default value: output -* 7:0 XD7-XD0: X-axis output Data -*******************************************************************************/ -#define LIS3DSH_OUT_X_L_ADDR 0x28 - -/******************************************************************************* -* OUT_X_H Register: X-axis Output Acceleration High Data -* Read only register -* Default value: output -* 15:8 XD15-XD8: X-axis output Data -*******************************************************************************/ -#define LIS3DSH_OUT_X_H_ADDR 0x29 - -/******************************************************************************* -* OUT_Y_L Register: Y-axis Output Acceleration Low Data -* Read only register -* Default value: output -* 7:0 YD7-YD0: Y-axis output Data -*******************************************************************************/ -#define LIS3DSH_OUT_Y_L_ADDR 0x2A - -/******************************************************************************* -* OUT_Y_H Register: Y-axis Output Acceleration High Data -* Read only register -* Default value: output -* 15:8 YD15-YD8: Y-axis output Data -*******************************************************************************/ -#define LIS3DSH_OUT_Y_H_ADDR 0x2B - -/******************************************************************************* -* OUT_Z_L Register: Z-axis Output Acceleration Low Data -* Read only register -* Default value: output -* 7:0 ZD7-ZD0: Z-axis output Data -*******************************************************************************/ -#define LIS3DSH_OUT_Z_L_ADDR 0x2C - -/******************************************************************************* -* OUT_Z_H Register: Z-axis Output Acceleration High Data -* Read only register -* Default value: output -* 15:8 ZD15-ZD8: Z-axis output Data -*******************************************************************************/ -#define LIS3DSH_OUT_Z_H_ADDR 0x2D - -/******************************************************************************* -* FIFO_CTRL Register: FIFO Control Register -* Read/Write register -* Default value: 0x00 -* 7:5 FMODE2-FMODE0: FIFO mode -* FMODE2 | FMODE1 | FMODE0 | Mode description -* -------------------------------------------------- -* 0 | 0 | 0 | Bypass mode. FIFO turned off. (Default) -* 0 | 0 | 1 | FIFO mode. Stop collecting data when FIFO is full. -* 0 | 1 | 0 | Stream mode. If the FIFO is full, the new sample overwrites the older one (circular buffer). -* 0 | 1 | 1 | Stream mode until trigger is de-asserted, then FIFO mode. -* 1 | 0 | 0 | Bypass mode until trigger is de-asserted, then Stream mode. -* 1 | 0 | 1 | Not to use. -* 1 | 1 | 0 | Not to use. -* 1 | 1 | 1 | Bypass mode until trigger is de-asserted, then FIFO mode. -* -* 4:0 WTMP4-WTMP0: FIFO Watermark pointer. It is the FIFO depth when the Watermark is enabled -*******************************************************************************/ -#define LIS3DSH_FIFO_CTRL_ADDR 0x2E - -/******************************************************************************* -* FIFO_SRC Register: FIFO Source Register -* Read only register -* Default value: 0x00 -* 7 WTM: Watermark status. -* 0: FIFO filling is lower than WTM level (Default) -* 1: FIFO filling is equal or higher than WTM level -* 6 OVRN_FIFO: Overrun bit status. -* 0: FIFO is not completely filled (Default) -* 1: FIFO is completely filled -* 5 EMPTY: Overrun bit status. -* 0: FIFO not empty (Default) -* 1: FIFO empty -* 4:0 FSS: Number of samples stored in the FIFO - 1 -*******************************************************************************/ -#define LIS3DSH_FIFO_SRC_ADDR 0x2F - -/******************************************************************************* -* ST1_X Register: State Machine 1 Code Registers -* Write only register -* Default value: 0x00 -* 7:0 ST1_7-ST1_0: State Machine 1 Code Registers -*******************************************************************************/ -#define LIS3DSH_ST1_1_ADDR 0x40 -#define LIS3DSH_ST1_2_ADDR 0x41 -#define LIS3DSH_ST1_3_ADDR 0x42 -#define LIS3DSH_ST1_4_ADDR 0x43 -#define LIS3DSH_ST1_5_ADDR 0x44 -#define LIS3DSH_ST1_6_ADDR 0x45 -#define LIS3DSH_ST1_7_ADDR 0x46 -#define LIS3DSH_ST1_8_ADDR 0x47 -#define LIS3DSH_ST1_9_ADDR 0x48 -#define LIS3DSH_ST1_10_ADDR 0x49 -#define LIS3DSH_ST1_11_ADDR 0x4A -#define LIS3DSH_ST1_12_ADDR 0x4B -#define LIS3DSH_ST1_13_ADDR 0x4C -#define LIS3DSH_ST1_14_ADDR 0x4D -#define LIS3DSH_ST1_15_ADDR 0x4E -#define LIS3DSH_ST1_16_ADDR 0x4F - -/******************************************************************************* -* TIM4_1 Register: SM1 General Timer 4 Register -* Write only register -* Default value: 0x00 -* 7:0 TM_7-TM_0: SM1 Timer 4 Counter 1 Value -*******************************************************************************/ -#define LIS3DSH_TIM4_1_ADDR 0x50 - -/******************************************************************************* -* TIM3_1 Register: SM1 General Timer 3 Register -* Write only register -* Default value: 0x00 -* 7:0 TM_7-TM_0: SM1 Timer 3 Counter 1 Value -*******************************************************************************/ -#define LIS3DSH_TIM3_1_ADDR 0x51 - -/******************************************************************************* -* TIM2_1_L Register: SM1 General Timer 2 Low Register -* Write only register -* Default value: 0x00 -* 7:0 TM_7-TM_0: SM1 Timer 2 Counter 1 Low Value -*******************************************************************************/ -#define LIS3DSH_TIM2_1_L_ADDR 0x52 - -/******************************************************************************* -* TIM2_1_H Register: SM1 General Timer 2 High Register -* Write only register -* Default value: 0x00 -* 15:8 TM_15-TM_8: SM1 Timer 2 Counter 1 High Value -*******************************************************************************/ -#define LIS3DSH_TIM2_1_H_ADDR 0x53 - -/******************************************************************************* -* TIM1_1_L Register: SM1 General Timer 1 Low Register -* Write only register -* Default value: 0x00 -* 7:0 TM_7-TM_0: SM1 Timer 1 Counter 1 Low Value -*******************************************************************************/ -#define LIS3DSH_TIM1_1_L_ADDR 0x54 - -/******************************************************************************* -* TIM1_1_H Register: SM1 General Timer 1 High Register -* Write only register -* Default value: 0x00 -* 15:8 TM_15-TM_8: SM1 Timer 1 Counter 1 High Value -*******************************************************************************/ -#define LIS3DSH_TIM1_1_H_ADDR 0x55 - -/******************************************************************************* -* THRS2_1 Register: SM1 Threshold Value 1 Register -* Write only register -* Default value: 0x00 -* 7:0 THS7-THS0: SM1 Threshold Value 1 -*******************************************************************************/ -#define LIS3DSH_THRS2_1_ADDR 0x56 - -/******************************************************************************* -* THRS1_1 Register: SM1 Threshold Value 2 Register -* Write only register -* Default value: 0x00 -* 7:0 THS7-THS0: SM1 Threshold Value 2 -*******************************************************************************/ -#define LIS3DSH_THRS1_1_ADDR 0x57 - -/******************************************************************************* -* MASK1_B Register: SM1 Swap Axis and Sign Mask Register -* Write only register -* Default value: 0x00 -* 7 P_X: X-Axis Positive Motion Detection -* 0: X+ disabled -* 1: X+ enabled -* 6 N_X: X-Axis Negative Motion Detection -* 0: X- disabled -* 1: X- enabled -* 5 P_Y: Y-Axis Positive Motion Detection -* 0: Y+ disabled -* 1: Y+ enabled -* 4 N_Y: Y-Axis Negative Motion Detection -* 0: Y- disabled -* 1: Y- enabled -* 3 P_Z: X-Axis Positive Motion Detection -* 0: Z+ disabled -* 1: Z+ enabled -* 2 N_Z: X-Axis Negative Motion Detection -* 0: Z- disabled -* 1: Z- enabled -* 1 P_V: -* 0: V+ disabled -* 1: V+ enabled -* 0 N_V: -* 0: V- disabled -* 1: V- enabled -*******************************************************************************/ -#define LIS3DSH_MASK1_B_ADDR 0x59 - -/******************************************************************************* -* MASK1_A Register: SM1 Default Axis and Sign Mask Register -* Write only register -* Default value: 0x00 -* 7 P_X: X-Axis Positive Motion Detection -* 0: X+ disabled -* 1: X+ enabled -* 6 N_X: X-Axis Negative Motion Detection -* 0: X- disabled -* 1: X- enabled -* 5 P_Y: Y-Axis Positive Motion Detection -* 0: Y+ disabled -* 1: Y+ enabled -* 4 N_Y: Y-Axis Negative Motion Detection -* 0: Y- disabled -* 1: Y- enabled -* 3 P_Z: X-Axis Positive Motion Detection -* 0: Z+ disabled -* 1: Z+ enabled -* 2 N_Z: X-Axis Negative Motion Detection -* 0: Z- disabled -* 1: Z- enabled -* 1 P_V: -* 0: V+ disabled -* 1: V+ enabled -* 0 N_V: -* 0: V- disabled -* 1: V- enabled -*******************************************************************************/ -#define LIS3DSH_MASK1_A_ADDR 0x5A - -/******************************************************************************* -* SETT1 Register: SM1 Detection Settings Register -* Write only register -* Default value: 0x00 -* 7 P_DET: SM1 peak detection bit -* 0: peak detection disabled (Default) -* 1: peak detection enabled -* 6 THR3_SA: -* 0: no action (Default) -* 1: threshold 3 enabled for axis and sign mask reset (MASK1_B) -* 5 ABS: -* 0: unsigned thresholds THRSx (Default) -* 1: signed thresholds THRSx -* 4 Reserved -* 3 Reserved -* 2 THR3_MA: -* 0: no action (Default) -* 1: threshold 3 enabled for axis and sign mask reset (MASK1_A) -* 1 R_TAM: Next condition validation flag -* 0: mask frozen on the axis that triggers the condition (Default) -* 1: standard mask always evaluated -* 0 SITR: -* 0: no actions (Default) -* 1: STOP and CONT commands generate an interrupt and perform output -* actions as OUTC command. -*******************************************************************************/ -#define LIS3DSH_SETT1_ADDR 0x5B - -/******************************************************************************* -* PR1 Register: SM1 Program and Reset Pointers Register -* Read only register -* Default value: 0x00 -* 7:4 PP3-PP0: SM1 program pointer address -* 3:0 RP3-RP0: SM1 reset pointer address -*******************************************************************************/ -#define LIS3DSH_PR1_ADDR 0x5C - -/******************************************************************************* -* TC1_L Register: SM1 General Timer Counter Low Register -* Read only register -* Default value: 0x00 -* 7:0 TC1_7-TC1_0: SM1 General Timer Counter Low Value -*******************************************************************************/ -#define LIS3DSH_TC1_L_ADDR 0x5D - -/******************************************************************************* -* TC1_H Register: SM1 General Timer Counter High Register -* Read only register -* Default value: 0x00 -* 15:8 TC1_15-TC1_8: SM1 General Timer Counter High Value -*******************************************************************************/ -#define LIS3DSH_TC1_H_ADDR 0x5E - -/******************************************************************************* -* OUTS1 Register: SM1 Output Set Flag Register -* Read only register -* Default value: 0x00 -* 7 P_X: -* 0: X+ noshow -* 1: X+ show -* 6 N_X: -* 0: X- noshow -* 1: X- show -* 5 P_Y: -* 0: Y+ noshow -* 1: Y+ show -* 4 N_Y: -* 0: Y- noshow -* 1: Y- show -* 3 P_Z: -* 0: Z+ noshow -* 1: Z+ show -* 2 N_Z: -* 0: Z- noshow -* 1: Z- show -* 1 P_V: -* 0: V+ noshow -* 1: V+ show -* 0 N_V: -* 0: V- noshow -* 1: V- show -*******************************************************************************/ -#define LIS3DSH_OUTS1_ADDR 0x5F - -/******************************************************************************* -* ST2_X Register: State Machine 2 Code Registers -* Write only register -* Default value: 0x00 -* 7:0 ST2_7-ST2_0: State Machine 2 Code Registers -*******************************************************************************/ -#define LIS3DSH_ST2_1_ADDR 0x60 -#define LIS3DSH_ST2_2_ADDR 0x61 -#define LIS3DSH_ST2_3_ADDR 0x62 -#define LIS3DSH_ST2_4_ADDR 0x63 -#define LIS3DSH_ST2_5_ADDR 0x64 -#define LIS3DSH_ST2_6_ADDR 0x65 -#define LIS3DSH_ST2_7_ADDR 0x66 -#define LIS3DSH_ST2_8_ADDR 0x67 -#define LIS3DSH_ST2_9_ADDR 0x68 -#define LIS3DSH_ST2_10_ADDR 0x69 -#define LIS3DSH_ST2_11_ADDR 0x6A -#define LIS3DSH_ST2_12_ADDR 0x6B -#define LIS3DSH_ST2_13_ADDR 0x6C -#define LIS3DSH_ST2_14_ADDR 0x6D -#define LIS3DSH_ST2_15_ADDR 0x6E -#define LIS3DSH_ST2_16_ADDR 0x6F - -/******************************************************************************* -* TIM4_2 Register: SM2 General Timer 4 Register -* Write only register -* Default value: 0x00 -* 7:0 TM_7-TM_0: SM2 Timer 4 Counter 1 Value -*******************************************************************************/ -#define LIS3DSH_TIM4_2_ADDR 0x70 - -/******************************************************************************* -* TIM3_2 Register: SM2 General Timer 3 Register -* Write only register -* Default value: 0x00 -* 7:0 TM_7-TM_0: SM2 Timer 3 Counter 2 Value -*******************************************************************************/ -#define LIS3DSH_TIM3_2_ADDR 0x71 - -/******************************************************************************* -* TIM2_2_L Register: SM2 General Timer 2 Low Register -* Write only register -* Default value: 0x00 -* 7:0 TM_7-TM_0: SM2 Timer 2 Counter 2 Low Value -*******************************************************************************/ -#define LIS3DSH_TIM2_2_L_ADDR 0x72 - -/******************************************************************************* -* TIM2_2_H Register: SM2 General Timer 2 High Register -* Write only register -* Default value: 0x00 -* 15:8 TM_15-TM_8: SM2 Timer 2 Counter 2 High Value -*******************************************************************************/ -#define LIS3DSH_TIM2_2_H_ADDR 0x73 - -/******************************************************************************* -* TIM1_2_L Register: SM2 General Timer 1 Low Register -* Write only register -* Default value: 0x00 -* 7:0 TM_7-TM_0: SM2 Timer 1 Counter 2 Low Value -*******************************************************************************/ -#define LIS3DSH_TIM1_2_L_ADDR 0x74 - -/******************************************************************************* -* TIM1_2_H Register: SM2 General Timer 1 High Register -* Write only register -* Default value: 0x00 -* 15:8 TM_15-TM_8: SM2 Timer 1 Counter 2 High Value -*******************************************************************************/ -#define LIS3DSH_TIM1_2_H_ADDR 0x75 - -/******************************************************************************* -* THRS2_2 Register: SM2 Threshold Value 1 Register -* Write only register -* Default value: 0x00 -* 7:0 THS7-THS0: SM2 Threshold Value -*******************************************************************************/ -#define LIS3DSH_THRS2_2_ADDR 0x76 - -/******************************************************************************* -* THRS1_2 Register: SM2 Threshold Value 2 Register -* Write only register -* Default value: 0x00 -* 7:0 THS7-THS0: SM2 Threshold Value -*******************************************************************************/ -#define LIS3DSH_THRS1_2_ADDR 0x77 - -/******************************************************************************* -* DES2 Register: SM2 Decimation Counter Value Register -* Write only register -* Default value: 0x00 -* 7:0 D7-D0: SM2 Decimation Counter Value -*******************************************************************************/ -#define LIS3DSH_DES2_ADDR 0x78 - -/******************************************************************************* -* MASK2_B Register: SM2 Axis and Sign Mask Register -* Write only register -* Default value: 0x00 -* 7 P_X: X-Axis Positive Motion Detection -* 0: X+ disabled -* 1: X+ enabled -* 6 N_X: X-Axis Negative Motion Detection -* 0: X- disabled -* 1: X- enabled -* 5 P_Y: Y-Axis Positive Motion Detection -* 0: Y+ disabled -* 1: Y+ enabled -* 4 N_Y: Y-Axis Negative Motion Detection -* 0: Y- disabled -* 1: Y- enabled -* 3 P_Z: X-Axis Positive Motion Detection -* 0: Z+ disabled -* 1: Z+ enabled -* 2 N_Z: X-Axis Negative Motion Detection -* 0: Z- disabled -* 1: Z- enabled -* 1 P_V: -* 0: V+ disabled -* 1: V+ enabled -* 0 N_V: -* 0: V- disabled -* 1: V- enabled -*******************************************************************************/ -#define LIS3DSH_MASK2_B_ADDR 0x79 - -/******************************************************************************* -* MASK2_A Register: SM2 Axis and Sign Mask Register -* Write only register -* Default value: 0x00 -* 7 P_X: X-Axis Positive Motion Detection -* 0: X+ disabled -* 1: X+ enabled -* 6 N_X: X-Axis Negative Motion Detection -* 0: X- disabled -* 1: X- enabled -* 5 P_Y: Y-Axis Positive Motion Detection -* 0: Y+ disabled -* 1: Y+ enabled -* 4 N_Y: Y-Axis Negative Motion Detection -* 0: Y- disabled -* 1: Y- enabled -* 3 P_Z: X-Axis Positive Motion Detection -* 0: Z+ disabled -* 1: Z+ enabled -* 2 N_Z: X-Axis Negative Motion Detection -* 0: Z- disabled -* 1: Z- enabled -* 1 P_V: -* 0: V+ disabled -* 1: V+ enabled -* 0 N_V: -* 0: V- disabled -* 1: V- enabled -*******************************************************************************/ -#define LIS3DSH_MASK2_A_ADDR 0x7A - -/******************************************************************************* -* SETT2 Register: SM2 Detection Settings Register -* Write only register -* Default value: 0x00 -* 7 P_DET: SM2 peak detection -* 0: peak detection disabled (Default) -* 1: peak detection enabled -* 6 THR3_SA: -* 0: no action (Default) -* 1: threshold 3 limit value for axis and sign mask reset (MASK2_B) -* 5 ABS: -* 0: unsigned thresholds (Default) -* 1: signed thresholds -* 4 RADI: -* 0: raw data -* 1: diff data for State Machine 2 -* 3 D_CS: -* 0: DIFF2 enabled (difference between current data and previous data) -* 1: constant shift enabled (difference between current data and constant values) -* 2 THR3_MA: -* 0: no action (Default) -* 1: threshold 3 enabled for axis and sign mask reset (MASK2_A) -* 1 R_TAM: Next condition validation flag -* 0: mask frozen on the axis that triggers the condition (Default) -* 1: standard mask always evaluated -* 0 SITR: -* 0: no actions (Default) -* 1: STOP and CONT commands generate an interrupt and perform output -* actions as OUTC command. -*******************************************************************************/ -#define LIS3DSH_SETT2_ADDR 0x7B - -/******************************************************************************* -* PR2 Register: SM2 Program and Reset Pointers Register -* Read only register -* Default value: 0x00 -* 7:4 PP3-PP0: SM1 program pointer address -* 3:0 RP3-RP0: SM1 reset pointer address -*******************************************************************************/ -#define LIS3DSH_PR2_ADDR 0x7C - -/******************************************************************************* -* TC2_L Register: SM2 General Timer Counter Low Register -* Read only register -* Default value: 0x00 -* 7:0 TC2_7-TC2_0: SM2 General Timer Counter Low Value -*******************************************************************************/ -#define LIS3DSH_TC2_L_ADDR 0x7D - -/******************************************************************************* -* TC2_H Register: SM2 General Timer Counter High Register -* Read only register -* Default value: 0x00 -* 15:8 TC2_15-TC2_8: SM2 General Timer Counter High Value -*******************************************************************************/ -#define LIS3DSH_TC2_H_ADDR 0x7E - -/******************************************************************************* -* OUTS2 Register: SM2 Output Set Flag Register -* Read only register -* Default value: 0x00 -* 7 P_X: -* 0: X+ noshow -* 1: X+ show -* 6 N_X: -* 0: X- noshow -* 1: X- show -* 5 P_Y: -* 0: Y+ noshow -* 1: Y+ show -* 4 N_Y: -* 0: Y- noshow -* 1: Y- show -* 3 P_Z: -* 0: Z+ noshow -* 1: Z+ show -* 2 N_Z: -* 0: Z- noshow -* 1: Z- show -* 1 P_V: -* 0: V+ noshow -* 1: V+ show -* 0 N_V: -* 0: V- noshow -* 1: V- show -*******************************************************************************/ -#define LIS3DSH_OUTS2_ADDR 0x7F - -/******************************************************************************/ -/**************************** END REGISTER MAPPING ***************************/ -/******************************************************************************/ -#define I_AM_LIS3DSH 0x3F - -/** @defgroup Sensitivity_selection - * @{ - */ -#define LIS3DSH_SENSITIVITY_0_06G 0.06 /* 0.06 mg/digit*/ -#define LIS3DSH_SENSITIVITY_0_12G 0.12 /* 0.12 mg/digit*/ -#define LIS3DSH_SENSITIVITY_0_18G 0.18 /* 0.18 mg/digit*/ -#define LIS3DSH_SENSITIVITY_0_24G 0.24 /* 0.24 mg/digit*/ -#define LIS3DSH_SENSITIVITY_0_73G 0.73 /* 0.73 mg/digit*/ -/** - * @} - */ - -/** @defgroup Data_Rate_Power_Mode_selection - * @{ - */ -#define LIS3DSH_DATARATE_POWERDOWN ((uint8_t)0x00) /* Power Down Mode*/ -#define LIS3DSH_DATARATE_3_125 ((uint8_t)0x10) /* 3.125 Hz Normal Mode */ -#define LIS3DSH_DATARATE_6_25 ((uint8_t)0x20) /* 6.25 Hz Normal Mode */ -#define LIS3DSH_DATARATE_12_5 ((uint8_t)0x30) /* 12.5 Hz Normal Mode */ -#define LIS3DSH_DATARATE_25 ((uint8_t)0x40) /* 25 Hz Normal Mode */ -#define LIS3DSH_DATARATE_50 ((uint8_t)0x50) /* 50 Hz Normal Mode */ -#define LIS3DSH_DATARATE_100 ((uint8_t)0x60) /* 100 Hz Normal Mode */ -#define LIS3DSH_DATARATE_400 ((uint8_t)0x70) /* 400 Hz Normal Mode */ -#define LIS3DSH_DATARATE_800 ((uint8_t)0x80) /* 800 Hz Normal Mode */ -#define LIS3DSH_DATARATE_1600 ((uint8_t)0x90) /* 1600 Hz Normal Mode */ -/** - * @} - */ - -/** @defgroup Full_Scale_selection - * @{ - */ -#define LIS3DSH_FULLSCALE_2 ((uint8_t)0x00) /* 2 g */ -#define LIS3DSH_FULLSCALE_4 ((uint8_t)0x08) /* 4 g */ -#define LIS3DSH_FULLSCALE_6 ((uint8_t)0x10) /* 6 g */ -#define LIS3DSH_FULLSCALE_8 ((uint8_t)0x18) /* 8 g */ -#define LIS3DSH_FULLSCALE_16 ((uint8_t)0x20) /* 16 g */ -#define LIS3DSH__FULLSCALE_SELECTION ((uint8_t)0x38) -/** - * @} - */ - -/** @defgroup Anti-Aliasing_Filter_Bandwidth - * @{ - */ -#define LIS3DSH_FILTER_BW_800 ((uint8_t)0x00) /* 800 Hz */ -#define LIS3DSH_FILTER_BW_40 ((uint8_t)0x08) /* 40 Hz */ -#define LIS3DSH_FILTER_BW_200 ((uint8_t)0x10) /* 200 Hz */ -#define LIS3DSH_FILTER_BW_50 ((uint8_t)0x18) /* 50 Hz */ -/** - * @} - */ - -/** @defgroup Self_Test_selection - * @{ - */ -#define LIS3DSH_SELFTEST_NORMAL ((uint8_t)0x00) -#define LIS3DSH_SELFTEST_P ((uint8_t)0x02) -#define LIS3DSH_SELFTEST_M ((uint8_t)0x04) -/** - * @} - */ - -/** @defgroup Direction_XYZ_selection - * @{ - */ -#define LIS3DSH_X_ENABLE ((uint8_t)0x01) -#define LIS3DSH_Y_ENABLE ((uint8_t)0x02) -#define LIS3DSH_Z_ENABLE ((uint8_t)0x04) -#define LIS3DSH_XYZ_ENABLE ((uint8_t)0x07) -/** - * @} - */ - -/** @defgroup SPI_Serial_Interface_Mode_selection - * @{ - */ -#define LIS3DSH_SERIALINTERFACE_4WIRE ((uint8_t)0x00) -#define LIS3DSH_SERIALINTERFACE_3WIRE ((uint8_t)0x01) -/** - * @} - */ - -/** @defgroup Interrupt_Request_selection Interrupt_Selection_Enable - * @{ - */ -#define LIS3DSH_INTERRUPT_REQUEST_LATCHED ((uint8_t)0x00) -#define LIS3DSH_INTERRUPT_REQUEST_PULSED ((uint8_t)0x20) -/** - * @} - */ - -/** @defgroup Interrupt_Selection_Enable - * @{ - */ -#define LIS3DSH_INTERRUPT_1_ENABLE ((uint8_t)0x88) -#define LIS3DSH_INTERRUPT_2_ENABLE ((uint8_t)0x00) -#define LIS3DSH_INTERRUPT_1_2_ENABLE ((uint8_t)0x88) -/** - * @} - */ - -/** @defgroup Interrupt_Signal_Active_Selection - * @{ - */ -#define LIS3DSH_INTERRUPT_SIGNAL_LOW ((uint8_t)0x00) -#define LIS3DSH_INTERRUPT_SIGNAL_HIGH ((uint8_t)0x40) -/** - * @} - */ - -/** @defgroup State_Machine_Enable - * @{ - */ -#define LIS3DSH_SM_ENABLE ((uint8_t)0x01) -#define LIS3DSH_SM_DISABLE ((uint8_t)0x00) -/** - * @} - */ - -/** @defgroup State_Machine_Routed_Interrupt - * @{ - */ -#define LIS3DSH_SM_INT1 ((uint8_t)0x00) -#define LIS3DSH_SM_INT2 ((uint8_t)0x08) -/** - * @} - */ - -/** @defgroup Boot_Mode_selection - * @{ - */ -#define LIS3DSH_BOOT_NORMALMODE ((uint8_t)0x00) -#define LIS3DSH_BOOT_FORCED ((uint8_t)0x80) -/** - * @} - */ - - -/** @defgroup FIFO_Mode_selection - * @{ - */ -#define LIS3DSH_FIFO_BYPASS_MODE ((uint8_t)0x00) -#define LIS3DSH_FIFO_MODE ((uint8_t)0x20) -#define LIS3DSH_FIFO_STREAM_MODE ((uint8_t)0x40) -#define LIS3DSH_FIFO_SF_TRIGGER_MODE ((uint8_t)0x60) -#define LIS3DSH_FIFO_BS_TRIGGER_MODE ((uint8_t)0x80) -#define LIS3DSH_FIFO_BF_TRIGGER_MODE ((uint8_t)0xE0) -/** - * @} - */ - -/** - * @} - */ - -/** @defgroup LIS3DSH_Exported_Macros - * @{ - */ - -/** - * @} - */ - -/** @defgroup LIS3DSH_Exported_Functions - * @{ - */ -void LIS3DSH_Init(uint16_t InitStruct); -void LIS3DSH_DeInit(void); -uint8_t LIS3DSH_ReadID(void); -void LIS3DSH_InterruptConfig(LIS3DSH_InterruptConfigTypeDef *LIS3DSH_IntConfigStruct); -void LIS3DSH_Click_IntConfig(void); -void LIS3DSH_ODR_LowpowerCmd(uint8_t ODR_LowPowerMode); -void LIS3DSH_DataRateCmd(uint8_t DataRateValue); -void LIS3DSH_FullScaleCmd(uint8_t FS_value); -void LIS3DSH_RebootCmd(void); -void LIS3DSH_ReadACC(int16_t *pData); - -/* Accelerometer driver structure */ -extern ACCELERO_DrvTypeDef Lis3dshDrv; - -/* Accelerometer IO functions */ -void ACCELERO_IO_Init(void); -void ACCELERO_IO_ITConfig(void); -void ACCELERO_IO_Write(uint8_t* pBuffer, uint8_t WriteAddr, uint16_t NumByteToWrite); -void ACCELERO_IO_Read(uint8_t* pBuffer, uint8_t ReadAddr, uint16_t NumByteToRead); - -#ifdef __cplusplus -} -#endif - -#endif /* __LIS3DSH_H */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/lsm303dlhc/Release_Notes.html b/bsp/stm32f411RE/Libraries/BSP/Components/lsm303dlhc/Release_Notes.html deleted file mode 100644 index bad5aaafa2..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/lsm303dlhc/Release_Notes.html +++ /dev/null @@ -1,365 +0,0 @@ - - - - - - - - - - - - - - - - - - - Release Notes for LSM303DLHC Component Driver - - - - - - - - - - -
-


-

-
- - - - - - -
- - - - - - - - - -
-

Back to Release page

-
-

Release -Notes for LSM303DLHC Component Driver

-

Copyright -2015 STMicroelectronics

-

-
-

 

- - - - - - -

Update History

-

V2.0.0 / 24-June-2015

- - - - - - - - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  • lsm303dlhc.c: 
    • Add accelerometer de-initialization function: LSM303DLHC_AccDeInit()
    • NOTE: This release must be used with BSP Common -driver V4.0.0
      -

V1.0.1 / 20-November-2014

- - - - - - - - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
  • lsm303dlhc.h: change "\" by "/" in the include path to fix compilation issue under Linux
    -
  • -
  • Miscellaneous comments update
  • -
- -

V1.0.0 / 18-February-2014

- - - - - - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  • First official release

License

-Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met:
-
-
  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions -in binary form must reproduce the above copyright notice, this list of -conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of STMicroelectronics nor the names of its contributors may be used to endorse or promote products derived
    -
    -
-        from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- -
- - - -
-
-
For -complete documentation on STM32 Microcontrollers -visit www.st.com/STM32
-
-

-
-
-

 

-
- - \ No newline at end of file diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/lsm303dlhc/lsm303dlhc.c b/bsp/stm32f411RE/Libraries/BSP/Components/lsm303dlhc/lsm303dlhc.c deleted file mode 100644 index 276c7568ac..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/lsm303dlhc/lsm303dlhc.c +++ /dev/null @@ -1,578 +0,0 @@ -/** - ****************************************************************************** - * @file lsm303dlhc.c - * @author MCD Application Team - * @version V2.0.0 - * @date 24-June-2015 - * @brief This file provides a set of functions needed to manage the lsm303dlhc - * MEMS accelerometer. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ -/* Includes ------------------------------------------------------------------*/ -#include "lsm303dlhc.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup Components - * @{ - */ - -/** @addtogroup LSM303DLHC - * @{ - */ - -/** @defgroup LSM303DLHC_Private_TypesDefinitions - * @{ - */ - -/** - * @} - */ - -/** @defgroup LSM303DLHC_Private_Defines - * @{ - */ - -/** - * @} - */ - -/** @defgroup LSM303DLHC_Private_Macros - * @{ - */ - -/** - * @} - */ - -/** @defgroup LSM303DLHC_Private_Variables - * @{ - */ -ACCELERO_DrvTypeDef Lsm303dlhcDrv = -{ - LSM303DLHC_AccInit, - LSM303DLHC_AccDeInit, - LSM303DLHC_AccReadID, - LSM303DLHC_AccRebootCmd, - 0, - LSM303DLHC_AccZClickITConfig, - 0, - 0, - 0, - 0, - LSM303DLHC_AccFilterConfig, - LSM303DLHC_AccFilterCmd, - LSM303DLHC_AccReadXYZ -}; - -/** - * @} - */ - -/** @defgroup LSM303DLHC_Private_Functions - * @{ - */ - -/** - * @brief Set LSM303DLHC Initialization. - * @param InitStruct: Init parameters - * @retval None - */ -void LSM303DLHC_AccInit(uint16_t InitStruct) -{ - uint8_t ctrl = 0x00; - - /* Low level init */ - COMPASSACCELERO_IO_Init(); - - /* Write value to ACC MEMS CTRL_REG1 register */ - ctrl = (uint8_t) InitStruct; - COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG1_A, ctrl); - - /* Write value to ACC MEMS CTRL_REG4 register */ - ctrl = (uint8_t) (InitStruct << 8); - COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG4_A, ctrl); -} - -/** - * @brief LSM303DLHC De-initialization. - * @param None - * @retval None - */ -void LSM303DLHC_AccDeInit(void) -{ -} - -/** - * @brief Read LSM303DLHC ID. - * @param None - * @retval ID - */ -uint8_t LSM303DLHC_AccReadID(void) -{ - uint8_t ctrl = 0x00; - - /* Low level init */ - COMPASSACCELERO_IO_Init(); - - /* Read value at Who am I register address */ - ctrl = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_WHO_AM_I_ADDR); - - return ctrl; -} - -/** - * @brief Reboot memory content of LSM303DLHC - * @param None - * @retval None - */ -void LSM303DLHC_AccRebootCmd(void) -{ - uint8_t tmpreg; - - /* Read CTRL_REG5 register */ - tmpreg = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG5_A); - - /* Enable or Disable the reboot memory */ - tmpreg |= LSM303DLHC_BOOT_REBOOTMEMORY; - - /* Write value to ACC MEMS CTRL_REG5 register */ - COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG5_A, tmpreg); -} - -/** - * @brief Set High Pass Filter Modality - * @param FilterStruct: contains data for filter config - * @retval None - */ -void LSM303DLHC_AccFilterConfig(uint8_t FilterStruct) -{ - uint8_t tmpreg; - - /* Read CTRL_REG2 register */ - tmpreg = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG2_A); - - tmpreg &= 0x0C; - tmpreg |= FilterStruct; - - /* Write value to ACC MEMS CTRL_REG2 register */ - COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG2_A, tmpreg); -} - -/** - * @brief Enable or Disable High Pass Filter - * @param HighPassFilterState: new state of the High Pass Filter feature. - * This parameter can be: - * @arg: LSM303DLHC_HIGHPASSFILTER_DISABLE - * @arg: LSM303DLHC_HIGHPASSFILTER_ENABLE - * @retval None - */ -void LSM303DLHC_AccFilterCmd(uint8_t HighPassFilterState) -{ - uint8_t tmpreg; - - /* Read CTRL_REG2 register */ - tmpreg = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG2_A); - - tmpreg &= 0xF7; - - tmpreg |= HighPassFilterState; - - /* Write value to ACC MEMS CTRL_REG2 register */ - COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG2_A, tmpreg); -} - -/** - * @brief Read X, Y & Z Acceleration values - * @param pData: Data out pointer - * @retval None - */ -void LSM303DLHC_AccReadXYZ(int16_t* pData) -{ - int16_t pnRawData[3]; - uint8_t ctrlx[2]={0,0}; - int8_t buffer[6]; - uint8_t i = 0; - uint8_t sensitivity = LSM303DLHC_ACC_SENSITIVITY_2G; - - /* Read the acceleration control register content */ - ctrlx[0] = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG4_A); - ctrlx[1] = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG5_A); - - /* Read output register X, Y & Z acceleration */ - buffer[0] = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_OUT_X_L_A); - buffer[1] = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_OUT_X_H_A); - buffer[2] = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_OUT_Y_L_A); - buffer[3] = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_OUT_Y_H_A); - buffer[4] = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_OUT_Z_L_A); - buffer[5] = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_OUT_Z_H_A); - - /* Check in the control register4 the data alignment*/ - if(!(ctrlx[0] & LSM303DLHC_BLE_MSB)) - { - for(i=0; i<3; i++) - { - pnRawData[i]=((int16_t)((uint16_t)buffer[2*i+1] << 8) + buffer[2*i]); - } - } - else /* Big Endian Mode */ - { - for(i=0; i<3; i++) - { - pnRawData[i]=((int16_t)((uint16_t)buffer[2*i] << 8) + buffer[2*i+1]); - } - } - - /* Normal mode */ - /* Switch the sensitivity value set in the CRTL4 */ - switch(ctrlx[0] & LSM303DLHC_FULLSCALE_16G) - { - case LSM303DLHC_FULLSCALE_2G: - sensitivity = LSM303DLHC_ACC_SENSITIVITY_2G; - break; - case LSM303DLHC_FULLSCALE_4G: - sensitivity = LSM303DLHC_ACC_SENSITIVITY_4G; - break; - case LSM303DLHC_FULLSCALE_8G: - sensitivity = LSM303DLHC_ACC_SENSITIVITY_8G; - break; - case LSM303DLHC_FULLSCALE_16G: - sensitivity = LSM303DLHC_ACC_SENSITIVITY_16G; - break; - } - - /* Obtain the mg value for the three axis */ - for(i=0; i<3; i++) - { - pData[i]=(pnRawData[i] * sensitivity); - } -} - -/** - * @brief Enable or Disable High Pass Filter on CLick - * @param HighPassFilterState: new state of the High Pass Filter feature. - * This parameter can be: - * @arg: LSM303DLHC_HPF_CLICK_DISABLE - * @arg: LSM303DLHC_HPF_CLICK_ENABLE - * @retval None - */ -void LSM303DLHC_AccFilterClickCmd(uint8_t HighPassFilterClickState) -{ - uint8_t tmpreg = 0x00; - - /* Read CTRL_REG2 register */ - tmpreg = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG2_A); - - tmpreg &= ~(LSM303DLHC_HPF_CLICK_ENABLE); - - tmpreg |= HighPassFilterClickState; - - /* Write value to ACC MEMS CTRL_REG2 regsister */ - COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG2_A, tmpreg); -} - -/** - * @brief Enable LSM303DLHC Interrupt1 - * @param LSM303DLHC_IT: specifies the LSM303DLHC interrupt source to be enabled. - * This parameter can be any combination of the following values: - * @arg LSM303DLHC_IT1_CLICK - * @arg LSM303DLHC_IT1_AOI1 - * @arg LSM303DLHC_IT1_AOI2 - * @arg LSM303DLHC_IT1_DRY1 - * @arg LSM303DLHC_IT1_DRY2 - * @arg LSM303DLHC_IT1_WTM - * @arg LSM303DLHC_IT1_OVERRUN - * @retval None - */ -void LSM303DLHC_AccIT1Enable(uint8_t LSM303DLHC_IT) -{ - uint8_t tmpval = 0x00; - - /* Read CTRL_REG3 register */ - tmpval = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG3_A); - - /* Enable IT1 */ - tmpval |= LSM303DLHC_IT; - - /* Write value to MEMS CTRL_REG3 register */ - COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG3_A, tmpval); -} - -/** - * @brief Disable LSM303DLHC Interrupt1 - * @param LSM303DLHC_IT: specifies the LSM303DLHC interrupt source to be disabled. - * This parameter can be any combination of the following values: - * @arg LSM303DLHC_IT1_CLICK - * @arg LSM303DLHC_IT1_AOI1 - * @arg LSM303DLHC_IT1_AOI2 - * @arg LSM303DLHC_IT1_DRY1 - * @arg LSM303DLHC_IT1_DRY2 - * @arg LSM303DLHC_IT1_WTM - * @arg LSM303DLHC_IT1_OVERRUN - * @retval None - */ -void LSM303DLHC_AccIT1Disable(uint8_t LSM303DLHC_IT) -{ - uint8_t tmpval = 0x00; - - /* Read CTRL_REG3 register */ - tmpval = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG3_A); - - /* Disable IT1 */ - tmpval &= ~LSM303DLHC_IT; - - /* Write value to MEMS CTRL_REG3 register */ - COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG3_A, tmpval); -} - -/** - * @brief Enable LSM303DLHC Interrupt2 - * @param LSM303DLHC_IT: specifies the LSM303DLHC interrupt source to be enabled. - * This parameter can be any combination of the following values: - * @arg LSM303DLHC_IT2_CLICK - * @arg LSM303DLHC_IT2_INT1 - * @arg LSM303DLHC_IT2_INT2 - * @arg LSM303DLHC_IT2_BOOT - * @arg LSM303DLHC_IT2_ACT - * @arg LSM303DLHC_IT2_HLACTIVE - * @retval None - */ -void LSM303DLHC_AccIT2Enable(uint8_t LSM303DLHC_IT) -{ - uint8_t tmpval = 0x00; - - /* Read CTRL_REG3 register */ - tmpval = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG6_A); - - /* Enable IT2 */ - tmpval |= LSM303DLHC_IT; - - /* Write value to MEMS CTRL_REG3 register */ - COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG6_A, tmpval); -} - -/** - * @brief Disable LSM303DLHC Interrupt2 - * @param LSM303DLHC_IT: specifies the LSM303DLHC interrupt source to be disabled. - * This parameter can be any combination of the following values: - * @arg LSM303DLHC_IT2_CLICK - * @arg LSM303DLHC_IT2_INT1 - * @arg LSM303DLHC_IT2_INT2 - * @arg LSM303DLHC_IT2_BOOT - * @arg LSM303DLHC_IT2_ACT - * @arg LSM303DLHC_IT2_HLACTIVE - * @retval None - */ -void LSM303DLHC_AccIT2Disable(uint8_t LSM303DLHC_IT) -{ - uint8_t tmpval = 0x00; - - /* Read CTRL_REG3 register */ - tmpval = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG6_A); - - /* Disable IT2 */ - tmpval &= ~LSM303DLHC_IT; - - /* Write value to MEMS CTRL_REG3 register */ - COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG6_A, tmpval); -} - -/** - * @brief INT1 interrupt enable - * @param ITCombination: Or or And combination - * ITAxes: Axes to be enabled - * @retval None - */ -void LSM303DLHC_AccINT1InterruptEnable(uint8_t ITCombination, uint8_t ITAxes) -{ - uint8_t tmpval = 0x00; - - /* Read INT1_CFR register */ - tmpval = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_INT1_CFG_A); - - /* Enable the selected interrupt */ - tmpval |= (ITAxes | ITCombination); - - /* Write value to MEMS INT1_CFR register */ - COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303DLHC_INT1_CFG_A, tmpval); -} - -/** - * @brief INT1 interrupt disable - * @param ITCombination: Or or And combination - * ITAxes: Axes to be enabled - * @retval None - */ -void LSM303DLHC_AccINT1InterruptDisable(uint8_t ITCombination, uint8_t ITAxes) -{ - uint8_t tmpval = 0x00; - - /* Read INT1_CFR register */ - tmpval = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_INT1_CFG_A); - - /* Disable the selected interrupt */ - tmpval &= ~(ITAxes | ITCombination); - - /* Write value to MEMS INT1_CFR register */ - COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303DLHC_INT1_CFG_A, tmpval); -} - -/** - * @brief INT2 interrupt enable - * @param ITCombination: Or or And combination - * ITAxes: axes to be enabled - * @retval None - */ -void LSM303DLHC_AccINT2InterruptEnable(uint8_t ITCombination, uint8_t ITAxes) -{ - uint8_t tmpval = 0x00; - - /* Read INT2_CFR register */ - tmpval = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_INT2_CFG_A); - - /* Enable the selected interrupt */ - tmpval |= (ITAxes | ITCombination); - - /* Write value to MEMS INT2_CFR register */ - COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303DLHC_INT2_CFG_A, tmpval); -} - -/** - * @brief INT2 interrupt config - * @param ITCombination: Or or And combination - * ITAxes: axes to be enabled - * @retval None - */ -void LSM303DLHC_AccINT2InterruptDisable(uint8_t ITCombination, uint8_t ITAxes) -{ - uint8_t tmpval = 0x00; - - /* Read INT2_CFR register */ - tmpval = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_INT2_CFG_A); - - /* Disable the selected interrupt */ - tmpval &= ~(ITAxes | ITCombination); - - /* Write value to MEMS INT2_CFR register */ - COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303DLHC_INT2_CFG_A, tmpval); -} - -/** - * @brief Click interrupt enable - * @param ITClick: the selected interrupt to enable - * @retval None - */ -void LSM303DLHC_AccClickITEnable(uint8_t ITClick) -{ - uint8_t tmpval = 0x00; - - /* Read CLICK_CFR register */ - tmpval = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_CLICK_CFG_A); - - /* Enable the selected interrupt */ - tmpval |= ITClick; - - /* Write value to MEMS CLICK CFG register */ - COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303DLHC_CLICK_CFG_A, tmpval); - - /* Configure Click Threshold on Z axis */ - tmpval = 0x0A; - COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303DLHC_CLICK_THS_A, tmpval); - - /* Configure Time Limit */ - tmpval = 0x05; - COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303DLHC_TIME_LIMIT_A, tmpval); - - /* Configure Latency */ - COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303DLHC_TIME_LATENCY_A, tmpval); - - /* Configure Click Window */ - tmpval = 0x32; - COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303DLHC_TIME_WINDOW_A, tmpval); -} - -/** - * @brief Click interrupt disable - * @param ITClick: the selected click interrupt to disable - * @retval None - */ -void LSM303DLHC_AccClickITDisable(uint8_t ITClick) -{ - uint8_t tmpval = 0x00; - - /* Read CLICK_CFR register */ - tmpval = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_CLICK_CFG_A); - - /* Disable the selected interrupt */ - tmpval &= ~ITClick; - - /* Write value to MEMS CLICK_CFR register */ - COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303DLHC_CLICK_CFG_A, tmpval); -} - -/** - * @brief Click on Z axis interrupt config - * @param None - * @retval None - */ -void LSM303DLHC_AccZClickITConfig(void) -{ - /* Configure low level IT config */ - COMPASSACCELERO_IO_ITConfig(); - - /* Select click IT as INT1 interrupt */ - LSM303DLHC_AccIT1Enable(LSM303DLHC_IT1_CLICK); - - /* Enable High pass filter for click IT */ - LSM303DLHC_AccFilterClickCmd(LSM303DLHC_HPF_CLICK_ENABLE); - - /* Enable simple click IT on Z axis, */ - LSM303DLHC_AccClickITEnable(LSM303DLHC_Z_SINGLE_CLICK); -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/lsm303dlhc/lsm303dlhc.h b/bsp/stm32f411RE/Libraries/BSP/Components/lsm303dlhc/lsm303dlhc.h deleted file mode 100644 index fe43be0f4d..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/lsm303dlhc/lsm303dlhc.h +++ /dev/null @@ -1,498 +0,0 @@ -/** - ****************************************************************************** - * @file lsm303dlhc.h - * @author MCD Application Team - * @version V2.0.0 - * @date 24-June-2015 - * @brief This file contains all the functions prototypes for the lsm303dlhc.c driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __LSM303DLHC_H -#define __LSM303DLHC_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "../Common/accelero.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup Components - * @{ - */ - -/** @addtogroup LSM303DLHC - * @{ - */ - -/** @defgroup LSM303DLHC_Exported_Types - * @{ - */ - -/** - * @} - */ - -/******************************************************************************/ -/*************************** START REGISTER MAPPING **************************/ -/******************************************************************************/ -/* Exported constant IO ------------------------------------------------------*/ -#define ACC_I2C_ADDRESS 0x32 -#define MAG_I2C_ADDRESS 0x3C - -/* Acceleration Registers */ -#define LSM303DLHC_WHO_AM_I_ADDR 0x0F /* device identification register */ -#define LSM303DLHC_CTRL_REG1_A 0x20 /* Control register 1 acceleration */ -#define LSM303DLHC_CTRL_REG2_A 0x21 /* Control register 2 acceleration */ -#define LSM303DLHC_CTRL_REG3_A 0x22 /* Control register 3 acceleration */ -#define LSM303DLHC_CTRL_REG4_A 0x23 /* Control register 4 acceleration */ -#define LSM303DLHC_CTRL_REG5_A 0x24 /* Control register 5 acceleration */ -#define LSM303DLHC_CTRL_REG6_A 0x25 /* Control register 6 acceleration */ -#define LSM303DLHC_REFERENCE_A 0x26 /* Reference register acceleration */ -#define LSM303DLHC_STATUS_REG_A 0x27 /* Status register acceleration */ -#define LSM303DLHC_OUT_X_L_A 0x28 /* Output Register X acceleration */ -#define LSM303DLHC_OUT_X_H_A 0x29 /* Output Register X acceleration */ -#define LSM303DLHC_OUT_Y_L_A 0x2A /* Output Register Y acceleration */ -#define LSM303DLHC_OUT_Y_H_A 0x2B /* Output Register Y acceleration */ -#define LSM303DLHC_OUT_Z_L_A 0x2C /* Output Register Z acceleration */ -#define LSM303DLHC_OUT_Z_H_A 0x2D /* Output Register Z acceleration */ -#define LSM303DLHC_FIFO_CTRL_REG_A 0x2E /* Fifo control Register acceleration */ -#define LSM303DLHC_FIFO_SRC_REG_A 0x2F /* Fifo src Register acceleration */ - -#define LSM303DLHC_INT1_CFG_A 0x30 /* Interrupt 1 configuration Register acceleration */ -#define LSM303DLHC_INT1_SOURCE_A 0x31 /* Interrupt 1 source Register acceleration */ -#define LSM303DLHC_INT1_THS_A 0x32 /* Interrupt 1 Threshold register acceleration */ -#define LSM303DLHC_INT1_DURATION_A 0x33 /* Interrupt 1 DURATION register acceleration */ - -#define LSM303DLHC_INT2_CFG_A 0x34 /* Interrupt 2 configuration Register acceleration */ -#define LSM303DLHC_INT2_SOURCE_A 0x35 /* Interrupt 2 source Register acceleration */ -#define LSM303DLHC_INT2_THS_A 0x36 /* Interrupt 2 Threshold register acceleration */ -#define LSM303DLHC_INT2_DURATION_A 0x37 /* Interrupt 2 DURATION register acceleration */ - -#define LSM303DLHC_CLICK_CFG_A 0x38 /* Click configuration Register acceleration */ -#define LSM303DLHC_CLICK_SOURCE_A 0x39 /* Click 2 source Register acceleration */ -#define LSM303DLHC_CLICK_THS_A 0x3A /* Click 2 Threshold register acceleration */ - -#define LSM303DLHC_TIME_LIMIT_A 0x3B /* Time Limit Register acceleration */ -#define LSM303DLHC_TIME_LATENCY_A 0x3C /* Time Latency Register acceleration */ -#define LSM303DLHC_TIME_WINDOW_A 0x3D /* Time window register acceleration */ - -/* Magnetic field Registers */ -#define LSM303DLHC_CRA_REG_M 0x00 /* Control register A magnetic field */ -#define LSM303DLHC_CRB_REG_M 0x01 /* Control register B magnetic field */ -#define LSM303DLHC_MR_REG_M 0x02 /* Control register MR magnetic field */ -#define LSM303DLHC_OUT_X_H_M 0x03 /* Output Register X magnetic field */ -#define LSM303DLHC_OUT_X_L_M 0x04 /* Output Register X magnetic field */ -#define LSM303DLHC_OUT_Z_H_M 0x05 /* Output Register Z magnetic field */ -#define LSM303DLHC_OUT_Z_L_M 0x06 /* Output Register Z magnetic field */ -#define LSM303DLHC_OUT_Y_H_M 0x07 /* Output Register Y magnetic field */ -#define LSM303DLHC_OUT_Y_L_M 0x08 /* Output Register Y magnetic field */ - -#define LSM303DLHC_SR_REG_M 0x09 /* Status Register magnetic field */ -#define LSM303DLHC_IRA_REG_M 0x0A /* IRA Register magnetic field */ -#define LSM303DLHC_IRB_REG_M 0x0B /* IRB Register magnetic field */ -#define LSM303DLHC_IRC_REG_M 0x0C /* IRC Register magnetic field */ - -#define LSM303DLHC_TEMP_OUT_H_M 0x31 /* Temperature Register magnetic field */ -#define LSM303DLHC_TEMP_OUT_L_M 0x32 /* Temperature Register magnetic field */ - -/******************************************************************************/ -/**************************** END REGISTER MAPPING ***************************/ -/******************************************************************************/ - -#define I_AM_LMS303DLHC ((uint8_t)0x33) - -/** @defgroup Acc_Power_Mode_selection - * @{ - */ -#define LSM303DLHC_NORMAL_MODE ((uint8_t)0x00) -#define LSM303DLHC_LOWPOWER_MODE ((uint8_t)0x08) -/** - * @} - */ - -/** @defgroup Acc_OutPut_DataRate_Selection - * @{ - */ -#define LSM303DLHC_ODR_1_HZ ((uint8_t)0x10) /*!< Output Data Rate = 1 Hz */ -#define LSM303DLHC_ODR_10_HZ ((uint8_t)0x20) /*!< Output Data Rate = 10 Hz */ -#define LSM303DLHC_ODR_25_HZ ((uint8_t)0x30) /*!< Output Data Rate = 25 Hz */ -#define LSM303DLHC_ODR_50_HZ ((uint8_t)0x40) /*!< Output Data Rate = 50 Hz */ -#define LSM303DLHC_ODR_100_HZ ((uint8_t)0x50) /*!< Output Data Rate = 100 Hz */ -#define LSM303DLHC_ODR_200_HZ ((uint8_t)0x60) /*!< Output Data Rate = 200 Hz */ -#define LSM303DLHC_ODR_400_HZ ((uint8_t)0x70) /*!< Output Data Rate = 400 Hz */ -#define LSM303DLHC_ODR_1620_HZ_LP ((uint8_t)0x80) /*!< Output Data Rate = 1620 Hz only in Low Power Mode */ -#define LSM303DLHC_ODR_1344_HZ ((uint8_t)0x90) /*!< Output Data Rate = 1344 Hz in Normal mode and 5376 Hz in Low Power Mode */ -/** - * @} - */ - -/** @defgroup Acc_Axes_Selection - * @{ - */ -#define LSM303DLHC_X_ENABLE ((uint8_t)0x01) -#define LSM303DLHC_Y_ENABLE ((uint8_t)0x02) -#define LSM303DLHC_Z_ENABLE ((uint8_t)0x04) -#define LSM303DLHC_AXES_ENABLE ((uint8_t)0x07) -#define LSM303DLHC_AXES_DISABLE ((uint8_t)0x00) -/** - * @} - */ - -/** @defgroup Acc_High_Resolution - * @{ - */ -#define LSM303DLHC_HR_ENABLE ((uint8_t)0x08) -#define LSM303DLHC_HR_DISABLE ((uint8_t)0x00) -/** - * @} - */ - -/** @defgroup Acc_Full_Scale_Selection - * @{ - */ -#define LSM303DLHC_FULLSCALE_2G ((uint8_t)0x00) /*!< ±2 g */ -#define LSM303DLHC_FULLSCALE_4G ((uint8_t)0x10) /*!< ±4 g */ -#define LSM303DLHC_FULLSCALE_8G ((uint8_t)0x20) /*!< ±8 g */ -#define LSM303DLHC_FULLSCALE_16G ((uint8_t)0x30) /*!< ±16 g */ -/** - * @} - */ - -/** @defgroup Acc_Full_Scale_Selection - * @{ - */ -#define LSM303DLHC_ACC_SENSITIVITY_2G ((uint8_t)1) /*!< accelerometer sensitivity with 2 g full scale [mg/LSB] */ -#define LSM303DLHC_ACC_SENSITIVITY_4G ((uint8_t)2) /*!< accelerometer sensitivity with 4 g full scale [mg/LSB] */ -#define LSM303DLHC_ACC_SENSITIVITY_8G ((uint8_t)4) /*!< accelerometer sensitivity with 8 g full scale [mg/LSB] */ -#define LSM303DLHC_ACC_SENSITIVITY_16G ((uint8_t)12) /*!< accelerometer sensitivity with 12 g full scale [mg/LSB] */ -/** - * @} - */ - -/** @defgroup Acc_Block_Data_Update - * @{ - */ -#define LSM303DLHC_BlockUpdate_Continous ((uint8_t)0x00) /*!< Continuos Update */ -#define LSM303DLHC_BlockUpdate_Single ((uint8_t)0x80) /*!< Single Update: output registers not updated until MSB and LSB reading */ -/** - * @} - */ - -/** @defgroup Acc_Endian_Data_selection - * @{ - */ -#define LSM303DLHC_BLE_LSB ((uint8_t)0x00) /*!< Little Endian: data LSB @ lower address */ -#define LSM303DLHC_BLE_MSB ((uint8_t)0x40) /*!< Big Endian: data MSB @ lower address */ -/** - * @} - */ - -/** @defgroup Acc_Boot_Mode_selection - * @{ - */ -#define LSM303DLHC_BOOT_NORMALMODE ((uint8_t)0x00) -#define LSM303DLHC_BOOT_REBOOTMEMORY ((uint8_t)0x80) -/** - * @} - */ - -/** @defgroup Acc_High_Pass_Filter_Mode - * @{ - */ -#define LSM303DLHC_HPM_NORMAL_MODE_RES ((uint8_t)0x00) -#define LSM303DLHC_HPM_REF_SIGNAL ((uint8_t)0x40) -#define LSM303DLHC_HPM_NORMAL_MODE ((uint8_t)0x80) -#define LSM303DLHC_HPM_AUTORESET_INT ((uint8_t)0xC0) -/** - * @} - */ - -/** @defgroup Acc_High_Pass_CUT OFF_Frequency - * @{ - */ -#define LSM303DLHC_HPFCF_8 ((uint8_t)0x00) -#define LSM303DLHC_HPFCF_16 ((uint8_t)0x10) -#define LSM303DLHC_HPFCF_32 ((uint8_t)0x20) -#define LSM303DLHC_HPFCF_64 ((uint8_t)0x30) -/** - * @} - */ - -/** @defgroup Acc_High_Pass_Filter_status - * @{ - */ -#define LSM303DLHC_HIGHPASSFILTER_DISABLE ((uint8_t)0x00) -#define LSM303DLHC_HIGHPASSFILTER_ENABLE ((uint8_t)0x08) -/** - * @} - */ - -/** @defgroup Acc_High_Pass_Filter_Click_status - * @{ - */ -#define LSM303DLHC_HPF_CLICK_DISABLE ((uint8_t)0x00) -#define LSM303DLHC_HPF_CLICK_ENABLE ((uint8_t)0x04) -/** - * @} - */ - -/** @defgroup Acc_High_Pass_Filter_AOI1_status - * @{ - */ -#define LSM303DLHC_HPF_AOI1_DISABLE ((uint8_t)0x00) -#define LSM303DLHC_HPF_AOI1_ENABLE ((uint8_t)0x01) -/** - * @} - */ - -/** @defgroup Acc_High_Pass_Filter_AOI2_status - * @{ - */ -#define LSM303DLHC_HPF_AOI2_DISABLE ((uint8_t)0x00) -#define LSM303DLHC_HPF_AOI2_ENABLE ((uint8_t)0x02) -/** - * @} - */ - -/** @defgroup Acc_Interrupt1_Configuration_definition - * @{ - */ -#define LSM303DLHC_IT1_CLICK ((uint8_t)0x80) -#define LSM303DLHC_IT1_AOI1 ((uint8_t)0x40) -#define LSM303DLHC_IT1_AOI2 ((uint8_t)0x20) -#define LSM303DLHC_IT1_DRY1 ((uint8_t)0x10) -#define LSM303DLHC_IT1_DRY2 ((uint8_t)0x08) -#define LSM303DLHC_IT1_WTM ((uint8_t)0x04) -#define LSM303DLHC_IT1_OVERRUN ((uint8_t)0x02) -/** - * @} - */ - -/** @defgroup Acc_Interrupt2_Configuration_definition - * @{ - */ -#define LSM303DLHC_IT2_CLICK ((uint8_t)0x80) -#define LSM303DLHC_IT2_INT1 ((uint8_t)0x40) -#define LSM303DLHC_IT2_INT2 ((uint8_t)0x20) -#define LSM303DLHC_IT2_BOOT ((uint8_t)0x10) -#define LSM303DLHC_IT2_ACT ((uint8_t)0x08) -#define LSM303DLHC_IT2_HLACTIVE ((uint8_t)0x02) -/** - * @} - */ - -/** @defgroup Acc_INT_Combination_Status - * @{ - */ -#define LSM303DLHC_OR_COMBINATION ((uint8_t)0x00) /*!< OR combination of enabled IRQs */ -#define LSM303DLHC_AND_COMBINATION ((uint8_t)0x80) /*!< AND combination of enabled IRQs */ -#define LSM303DLHC_MOV_RECOGNITION ((uint8_t)0x40) /*!< 6D movement recognition */ -#define LSM303DLHC_POS_RECOGNITION ((uint8_t)0xC0) /*!< 6D position recognition */ -/** - * @} - */ - -/** @defgroup Acc_INT_Axes - * @{ - */ -#define LSM303DLHC_Z_HIGH ((uint8_t)0x20) /*!< Z High enabled IRQs */ -#define LSM303DLHC_Z_LOW ((uint8_t)0x10) /*!< Z low enabled IRQs */ -#define LSM303DLHC_Y_HIGH ((uint8_t)0x08) /*!< Y High enabled IRQs */ -#define LSM303DLHC_Y_LOW ((uint8_t)0x04) /*!< Y low enabled IRQs */ -#define LSM303DLHC_X_HIGH ((uint8_t)0x02) /*!< X High enabled IRQs */ -#define LSM303DLHC_X_LOW ((uint8_t)0x01) /*!< X low enabled IRQs */ -/** - * @} - */ - -/** @defgroup Acc_INT_Click -* @{ -*/ -#define LSM303DLHC_Z_DOUBLE_CLICK ((uint8_t)0x20) /*!< Z double click IRQs */ -#define LSM303DLHC_Z_SINGLE_CLICK ((uint8_t)0x10) /*!< Z single click IRQs */ -#define LSM303DLHC_Y_DOUBLE_CLICK ((uint8_t)0x08) /*!< Y double click IRQs */ -#define LSM303DLHC_Y_SINGLE_CLICK ((uint8_t)0x04) /*!< Y single click IRQs */ -#define LSM303DLHC_X_DOUBLE_CLICK ((uint8_t)0x02) /*!< X double click IRQs */ -#define LSM303DLHC_X_SINGLE_CLICK ((uint8_t)0x01) /*!< X single click IRQs */ -/** -* @} -*/ - -/** @defgroup Acc_INT1_Interrupt_status - * @{ - */ -#define LSM303DLHC_INT1INTERRUPT_DISABLE ((uint8_t)0x00) -#define LSM303DLHC_INT1INTERRUPT_ENABLE ((uint8_t)0x80) -/** - * @} - */ - -/** @defgroup Acc_INT1_Interrupt_ActiveEdge - * @{ - */ -#define LSM303DLHC_INT1INTERRUPT_LOW_EDGE ((uint8_t)0x20) -#define LSM303DLHC_INT1INTERRUPT_HIGH_EDGE ((uint8_t)0x00) -/** - * @} - */ - -/** @defgroup Mag_Data_Rate - * @{ - */ -#define LSM303DLHC_ODR_0_75_HZ ((uint8_t) 0x00) /*!< Output Data Rate = 0.75 Hz */ -#define LSM303DLHC_ODR_1_5_HZ ((uint8_t) 0x04) /*!< Output Data Rate = 1.5 Hz */ -#define LSM303DLHC_ODR_3_0_HZ ((uint8_t) 0x08) /*!< Output Data Rate = 3 Hz */ -#define LSM303DLHC_ODR_7_5_HZ ((uint8_t) 0x0C) /*!< Output Data Rate = 7.5 Hz */ -#define LSM303DLHC_ODR_15_HZ ((uint8_t) 0x10) /*!< Output Data Rate = 15 Hz */ -#define LSM303DLHC_ODR_30_HZ ((uint8_t) 0x14) /*!< Output Data Rate = 30 Hz */ -#define LSM303DLHC_ODR_75_HZ ((uint8_t) 0x18) /*!< Output Data Rate = 75 Hz */ -#define LSM303DLHC_ODR_220_HZ ((uint8_t) 0x1C) /*!< Output Data Rate = 220 Hz */ -/** - * @} - */ - -/** @defgroup Mag_Full_Scale - * @{ - */ -#define LSM303DLHC_FS_1_3_GA ((uint8_t) 0x20) /*!< Full scale = ±1.3 Gauss */ -#define LSM303DLHC_FS_1_9_GA ((uint8_t) 0x40) /*!< Full scale = ±1.9 Gauss */ -#define LSM303DLHC_FS_2_5_GA ((uint8_t) 0x60) /*!< Full scale = ±2.5 Gauss */ -#define LSM303DLHC_FS_4_0_GA ((uint8_t) 0x80) /*!< Full scale = ±4.0 Gauss */ -#define LSM303DLHC_FS_4_7_GA ((uint8_t) 0xA0) /*!< Full scale = ±4.7 Gauss */ -#define LSM303DLHC_FS_5_6_GA ((uint8_t) 0xC0) /*!< Full scale = ±5.6 Gauss */ -#define LSM303DLHC_FS_8_1_GA ((uint8_t) 0xE0) /*!< Full scale = ±8.1 Gauss */ -/** - * @} - */ - -/** - * @defgroup Magnetometer_Sensitivity - * @{ - */ -#define LSM303DLHC_M_SENSITIVITY_XY_1_3Ga 1100 /*!< magnetometer X Y axes sensitivity for 1.3 Ga full scale [LSB/Ga] */ -#define LSM303DLHC_M_SENSITIVITY_XY_1_9Ga 855 /*!< magnetometer X Y axes sensitivity for 1.9 Ga full scale [LSB/Ga] */ -#define LSM303DLHC_M_SENSITIVITY_XY_2_5Ga 670 /*!< magnetometer X Y axes sensitivity for 2.5 Ga full scale [LSB/Ga] */ -#define LSM303DLHC_M_SENSITIVITY_XY_4Ga 450 /*!< magnetometer X Y axes sensitivity for 4 Ga full scale [LSB/Ga] */ -#define LSM303DLHC_M_SENSITIVITY_XY_4_7Ga 400 /*!< magnetometer X Y axes sensitivity for 4.7 Ga full scale [LSB/Ga] */ -#define LSM303DLHC_M_SENSITIVITY_XY_5_6Ga 330 /*!< magnetometer X Y axes sensitivity for 5.6 Ga full scale [LSB/Ga] */ -#define LSM303DLHC_M_SENSITIVITY_XY_8_1Ga 230 /*!< magnetometer X Y axes sensitivity for 8.1 Ga full scale [LSB/Ga] */ -#define LSM303DLHC_M_SENSITIVITY_Z_1_3Ga 980 /*!< magnetometer Z axis sensitivity for 1.3 Ga full scale [LSB/Ga] */ -#define LSM303DLHC_M_SENSITIVITY_Z_1_9Ga 760 /*!< magnetometer Z axis sensitivity for 1.9 Ga full scale [LSB/Ga] */ -#define LSM303DLHC_M_SENSITIVITY_Z_2_5Ga 600 /*!< magnetometer Z axis sensitivity for 2.5 Ga full scale [LSB/Ga] */ -#define LSM303DLHC_M_SENSITIVITY_Z_4Ga 400 /*!< magnetometer Z axis sensitivity for 4 Ga full scale [LSB/Ga] */ -#define LSM303DLHC_M_SENSITIVITY_Z_4_7Ga 355 /*!< magnetometer Z axis sensitivity for 4.7 Ga full scale [LSB/Ga] */ -#define LSM303DLHC_M_SENSITIVITY_Z_5_6Ga 295 /*!< magnetometer Z axis sensitivity for 5.6 Ga full scale [LSB/Ga] */ -#define LSM303DLHC_M_SENSITIVITY_Z_8_1Ga 205 /*!< magnetometer Z axis sensitivity for 8.1 Ga full scale [LSB/Ga] */ -/** - * @} - */ - -/** @defgroup Mag_Working_Mode - * @{ - */ -#define LSM303DLHC_CONTINUOS_CONVERSION ((uint8_t) 0x00) /*!< Continuous-Conversion Mode */ -#define LSM303DLHC_SINGLE_CONVERSION ((uint8_t) 0x01) /*!< Single-Conversion Mode */ -#define LSM303DLHC_SLEEP ((uint8_t) 0x02) /*!< Sleep Mode */ -/** - * @} - */ - -/** @defgroup Mag_Temperature_Sensor - * @{ - */ -#define LSM303DLHC_TEMPSENSOR_ENABLE ((uint8_t) 0x80) /*!< Temp sensor Enable */ -#define LSM303DLHC_TEMPSENSOR_DISABLE ((uint8_t) 0x00) /*!< Temp sensor Disable */ -/** - * @} - */ - -/** @defgroup LSM303DLHC_Exported_Functions - * @{ - */ -/* ACC functions */ -void LSM303DLHC_AccInit(uint16_t InitStruct); -void LSM303DLHC_AccDeInit(void); -uint8_t LSM303DLHC_AccReadID(void); -void LSM303DLHC_AccRebootCmd(void); -void LSM303DLHC_AccFilterConfig(uint8_t FilterStruct); -void LSM303DLHC_AccFilterCmd(uint8_t HighPassFilterState); -void LSM303DLHC_AccReadXYZ(int16_t* pData); -void LSM303DLHC_AccFilterClickCmd(uint8_t HighPassFilterClickState); -void LSM303DLHC_AccIT1Enable(uint8_t LSM303DLHC_IT); -void LSM303DLHC_AccIT1Disable(uint8_t LSM303DLHC_IT); -void LSM303DLHC_AccIT2Enable(uint8_t LSM303DLHC_IT); -void LSM303DLHC_AccIT2Disable(uint8_t LSM303DLHC_IT); -void LSM303DLHC_AccINT1InterruptEnable(uint8_t ITCombination, uint8_t ITAxes); -void LSM303DLHC_AccINT1InterruptDisable(uint8_t ITCombination, uint8_t ITAxes); -void LSM303DLHC_AccINT2InterruptEnable(uint8_t ITCombination, uint8_t ITAxes); -void LSM303DLHC_AccINT2InterruptDisable(uint8_t ITCombination, uint8_t ITAxes); -void LSM303DLHC_AccClickITEnable(uint8_t ITClick); -void LSM303DLHC_AccClickITDisable(uint8_t ITClick); -void LSM303DLHC_AccZClickITConfig(void); - -/* COMPASS / ACCELERO IO functions */ -void COMPASSACCELERO_IO_Init(void); -void COMPASSACCELERO_IO_ITConfig(void); -void COMPASSACCELERO_IO_Write(uint16_t DeviceAddr, uint8_t RegisterAddr, uint8_t Value); -uint8_t COMPASSACCELERO_IO_Read(uint16_t DeviceAddr, uint8_t RegisterAddr); - -/* ACC driver structure */ -extern ACCELERO_DrvTypeDef Lsm303dlhcDrv; - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __LSM303DLHC_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/mfxstm32l152/Release_Notes.html b/bsp/stm32f411RE/Libraries/BSP/Components/mfxstm32l152/Release_Notes.html deleted file mode 100644 index ea8ff3021b..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/mfxstm32l152/Release_Notes.html +++ /dev/null @@ -1,296 +0,0 @@ - - - - - - - - - - - - - - - - - - - Release Notes for MFXSTM32L152 Component Driver - - - - - - - - - - -
-


-

-
- - - - - - -
- - - - - - - - - -
-

Back to Release page

-
-

Release -Notes for MFXSTM32L152 Component Driver

-

Copyright -2015 STMicroelectronics

-

-
-

 

- - - - - - -

Update History

-

V2.0.0 / 24-June-2015

- - - - - - - - - - - - - -

Main -Changes

  • Add Shunt management of MFXSTM32L152 component
    • new mfxstm32l152_IDD_ConfigShuntNbLimit() and mfxstm32l152_IDD_GetShuntUsed() APIs
  • Add mfxstm32l152_WriteReg() API
  • NOTE: This release must be used with BSP Common driver V4.0.0 or later

V1.2.0 / 28-April-2015

- - - - - - - - - - - - - -

Main -Changes

    -
  • mfxstm32l152_IO_Config(): remove unnecessary delay
  • -
  • mfxstm32l152_TS_DetectTouch(): improve TouchScreen speed
  • -
  • mfxstm32l152_IDD_Config(): add configuration of number of measure to be performed, with delay between 2 measures
  • -
  • NOTE: This release must be used with BSP Common driver V3.0.0
  • -

V1.1.0 / 10-February-2015

- - - - - - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  • Low Power management of MFXSTM32L152 component:
    • New mfxstm32l152_DeInit() and mfxstm32l152_WakeUp() API
    • mfxstm32l152_LowPower() API completed to be MFXSTM32L152 in Standby mode
  • NOTE: This release must be used with BSP Common driver V2.2.0 or later

V1.0.0 / 05-February-2015

- - - - - - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  • First official release of MFXSTM32L152 Component driver.
  • NOTE: This release must be used with BSP Common driver V2.1.0 or later.

License

-Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met:
-
-
  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions -in binary form must reproduce the above copyright notice, this list of -conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of STMicroelectronics nor the names of its contributors may be used to endorse or promote products derived
    -
    -
-        from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- -
- - - -
-
-
For -complete documentation on STM32 Microcontrollers -visit www.st.com/STM32
-
-

-
-
-

 

-
- - \ No newline at end of file diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/mfxstm32l152/mfxstm32l152.c b/bsp/stm32f411RE/Libraries/BSP/Components/mfxstm32l152/mfxstm32l152.c deleted file mode 100644 index 4ce5028ede..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/mfxstm32l152/mfxstm32l152.c +++ /dev/null @@ -1,1584 +0,0 @@ -/** - ****************************************************************************** - * @file mfxstm32l152.c - * @author MCD Application Team - * @version V2.0.0 - * @date 24-June-2015 - * @brief This file provides a set of functions needed to manage the MFXSTM32L152 - * IO Expander devices. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Includes ------------------------------------------------------------------*/ -#include "mfxstm32l152.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup Component - * @{ - */ - -/** @defgroup MFXSTM32L152 - * @{ - */ - -/* Private typedef -----------------------------------------------------------*/ - -/** @defgroup MFXSTM32L152_Private_Types_Definitions - * @{ - */ - -/* Private define ------------------------------------------------------------*/ - -/** @defgroup MFXSTM32L152_Private_Defines - * @{ - */ -#define MFXSTM32L152_MAX_INSTANCE 3 - -/* Private macro -------------------------------------------------------------*/ - -/** @defgroup MFXSTM32L152_Private_Macros - * @{ - */ - -/* Private variables ---------------------------------------------------------*/ - -/** @defgroup MFXSTM32L152_Private_Variables - * @{ - */ - -/* Touch screen driver structure initialization */ -TS_DrvTypeDef mfxstm32l152_ts_drv = -{ - mfxstm32l152_Init, - mfxstm32l152_ReadID, - mfxstm32l152_Reset, - - mfxstm32l152_TS_Start, - mfxstm32l152_TS_DetectTouch, - mfxstm32l152_TS_GetXY, - - mfxstm32l152_TS_EnableIT, - mfxstm32l152_TS_ClearIT, - mfxstm32l152_TS_ITStatus, - mfxstm32l152_TS_DisableIT, -}; - -/* IO driver structure initialization */ -IO_DrvTypeDef mfxstm32l152_io_drv = -{ - mfxstm32l152_Init, - mfxstm32l152_ReadID, - mfxstm32l152_Reset, - - mfxstm32l152_IO_Start, - mfxstm32l152_IO_Config, - mfxstm32l152_IO_WritePin, - mfxstm32l152_IO_ReadPin, - - mfxstm32l152_IO_EnableIT, - mfxstm32l152_IO_DisableIT, - mfxstm32l152_IO_ITStatus, - mfxstm32l152_IO_ClearIT, -}; - -/* IDD driver structure initialization */ -IDD_DrvTypeDef mfxstm32l152_idd_drv = -{ - mfxstm32l152_Init, - mfxstm32l152_DeInit, - mfxstm32l152_ReadID, - mfxstm32l152_Reset, - mfxstm32l152_LowPower, - mfxstm32l152_WakeUp, - - mfxstm32l152_IDD_Start, - mfxstm32l152_IDD_Config, - mfxstm32l152_IDD_GetValue, - - mfxstm32l152_IDD_EnableIT, - mfxstm32l152_IDD_ClearIT, - mfxstm32l152_IDD_GetITStatus, - mfxstm32l152_IDD_DisableIT, - - mfxstm32l152_Error_EnableIT, - mfxstm32l152_Error_ClearIT, - mfxstm32l152_Error_GetITStatus, - mfxstm32l152_Error_DisableIT, - mfxstm32l152_Error_ReadSrc, - mfxstm32l152_Error_ReadMsg -}; - - -/* mfxstm32l152 instances by address */ -uint8_t mfxstm32l152[MFXSTM32L152_MAX_INSTANCE] = {0}; -/** - * @} - */ - -/* Private function prototypes -----------------------------------------------*/ - -/** @defgroup MFXSTM32L152_Private_Function_Prototypes - * @{ - */ -static uint8_t mfxstm32l152_GetInstance(uint16_t DeviceAddr); -static uint8_t mfxstm32l152_ReleaseInstance(uint16_t DeviceAddr); -static void mfxstm32l152_reg24_setPinValue(uint16_t DeviceAddr, uint8_t RegisterAddr, uint32_t PinPosition, uint8_t PinValue ); - -/* Private functions ---------------------------------------------------------*/ - -/** @defgroup MFXSTM32L152_Private_Functions - * @{ - */ - -/** - * @brief Initialize the mfxstm32l152 and configure the needed hardware resources - * @param DeviceAddr: Device address on communication Bus. - * @retval None - */ -void mfxstm32l152_Init(uint16_t DeviceAddr) -{ - uint8_t instance; - uint8_t empty; - - /* Check if device instance already exists */ - instance = mfxstm32l152_GetInstance(DeviceAddr); - - /* To prevent double initialization */ - if(instance == 0xFF) - { - /* Look for empty instance */ - empty = mfxstm32l152_GetInstance(0); - - if(empty < MFXSTM32L152_MAX_INSTANCE) - { - /* Register the current device instance */ - mfxstm32l152[empty] = DeviceAddr; - - /* Initialize IO BUS layer */ - MFX_IO_Init(); - } - } - - mfxstm32l152_SetIrqOutPinPolarity(DeviceAddr, MFXSTM32L152_OUT_PIN_POLARITY_HIGH); - mfxstm32l152_SetIrqOutPinType(DeviceAddr, MFXSTM32L152_OUT_PIN_TYPE_PUSHPULL); -} - -/** - * @brief DeInitialize the mfxstm32l152 and unconfigure the needed hardware resources - * @param DeviceAddr: Device address on communication Bus. - * @retval None - */ -void mfxstm32l152_DeInit(uint16_t DeviceAddr) -{ - uint8_t instance; - - /* release existing instance */ - instance = mfxstm32l152_ReleaseInstance(DeviceAddr); - - /* De-Init only if instance was previously registered */ - if(instance != 0xFF) - { - /* De-Initialize IO BUS layer */ - MFX_IO_DeInit(); - } -} - -/** - * @brief Reset the mfxstm32l152 by Software. - * @param DeviceAddr: Device address on communication Bus. - * @retval None - */ -void mfxstm32l152_Reset(uint16_t DeviceAddr) -{ - /* Soft Reset */ - MFX_IO_Write(DeviceAddr, MFXSTM32L152_REG_ADR_SYS_CTRL, MFXSTM32L152_SWRST); - - /* Wait for a delay to ensure registers erasing */ - MFX_IO_Delay(10); -} - -/** - * @brief Put mfxstm32l152 Device in Low Power standby mode - * @param DeviceAddr: Device address on communication Bus. - * @retval None - */ -void mfxstm32l152_LowPower(uint16_t DeviceAddr) -{ - /* Enter standby mode */ - MFX_IO_Write(DeviceAddr, MFXSTM32L152_REG_ADR_SYS_CTRL, MFXSTM32L152_STANDBY); - - /* enable wakeup pin */ - MFX_IO_EnableWakeupPin(); -} - -/** - * @brief WakeUp mfxstm32l152 from standby mode - * @param DeviceAddr: Device address on communication Bus. - * @retval None - */ -void mfxstm32l152_WakeUp(uint16_t DeviceAddr) -{ - uint8_t instance; - - /* Check if device instance already exists */ - instance = mfxstm32l152_GetInstance(DeviceAddr); - - /* if instance does not exist, first initialize pins*/ - if(instance == 0xFF) - { - /* enable wakeup pin */ - MFX_IO_EnableWakeupPin(); - } - - /* toggle wakeup pin */ - MFX_IO_Wakeup(); -} - -/** - * @brief Read the MFXSTM32L152 IO Expander device ID. - * @param DeviceAddr: Device address on communication Bus. - * @retval The Device ID (two bytes). - */ -uint16_t mfxstm32l152_ReadID(uint16_t DeviceAddr) -{ - uint8_t id; - - /* Wait for a delay to ensure the state of registers */ - MFX_IO_Delay(1); - - /* Initialize IO BUS layer */ - MFX_IO_Init(); - - id = MFX_IO_Read(DeviceAddr, MFXSTM32L152_REG_ADR_ID); - - /* Return the device ID value */ - return (id); -} - -/** - * @brief Read the MFXSTM32L152 device firmware version. - * @param DeviceAddr: Device address on communication Bus. - * @retval The Device FW version (two bytes). - */ -uint16_t mfxstm32l152_ReadFwVersion(uint16_t DeviceAddr) -{ - uint8_t data[2]; - - MFX_IO_ReadMultiple((uint8_t) DeviceAddr, MFXSTM32L152_REG_ADR_FW_VERSION_MSB, data, sizeof(data)) ; - - /* Recompose MFX firmware value */ - return ((data[0] << 8) | data[1]); -} - -/** - * @brief Enable the interrupt mode for the selected IT source - * @param DeviceAddr: Device address on communication Bus. - * @param Source: The interrupt source to be configured, could be: - * @arg MFXSTM32L152_IRQ_GPIO: IO interrupt - * @arg MFXSTM32L152_IRQ_IDD : IDD interrupt - * @arg MFXSTM32L152_IRQ_ERROR : Error interrupt - * @arg MFXSTM32L152_IRQ_TS_DET : Touch Screen Controller Touch Detected interrupt - * @arg MFXSTM32L152_IRQ_TS_NE : Touch Screen FIFO Not Empty - * @arg MFXSTM32L152_IRQ_TS_TH : Touch Screen FIFO threshold triggered - * @arg MFXSTM32L152_IRQ_TS_FULL : Touch Screen FIFO Full - * @arg MFXSTM32L152_IRQ_TS_OVF : Touch Screen FIFO Overflow - * @retval None - */ -void mfxstm32l152_EnableITSource(uint16_t DeviceAddr, uint8_t Source) -{ - uint8_t tmp = 0; - - /* Get the current value of the INT_EN register */ - tmp = MFX_IO_Read(DeviceAddr, MFXSTM32L152_REG_ADR_IRQ_SRC_EN); - - /* Set the interrupts to be Enabled */ - tmp |= Source; - - /* Set the register */ - MFX_IO_Write(DeviceAddr, MFXSTM32L152_REG_ADR_IRQ_SRC_EN, tmp); -} - -/** - * @brief Disable the interrupt mode for the selected IT source - * @param DeviceAddr: Device address on communication Bus. - * @param Source: The interrupt source to be configured, could be: - * @arg MFXSTM32L152_IRQ_GPIO: IO interrupt - * @arg MFXSTM32L152_IRQ_IDD : IDD interrupt - * @arg MFXSTM32L152_IRQ_ERROR : Error interrupt - * @arg MFXSTM32L152_IRQ_TS_DET : Touch Screen Controller Touch Detected interrupt - * @arg MFXSTM32L152_IRQ_TS_NE : Touch Screen FIFO Not Empty - * @arg MFXSTM32L152_IRQ_TS_TH : Touch Screen FIFO threshold triggered - * @arg MFXSTM32L152_IRQ_TS_FULL : Touch Screen FIFO Full - * @arg MFXSTM32L152_IRQ_TS_OVF : Touch Screen FIFO Overflow - * @retval None - */ -void mfxstm32l152_DisableITSource(uint16_t DeviceAddr, uint8_t Source) -{ - uint8_t tmp = 0; - - /* Get the current value of the INT_EN register */ - tmp = MFX_IO_Read(DeviceAddr, MFXSTM32L152_REG_ADR_IRQ_SRC_EN); - - /* Set the interrupts to be Enabled */ - tmp &= ~Source; - - /* Set the register */ - MFX_IO_Write(DeviceAddr, MFXSTM32L152_REG_ADR_IRQ_SRC_EN, tmp); -} - - -/** - * @brief Returns the selected Global interrupt source pending bit value - * @param DeviceAddr: Device address on communication Bus. - * @param Source: the Global interrupt source to be checked, could be: - * @arg MFXSTM32L152_IRQ_GPIO: IO interrupt - * @arg MFXSTM32L152_IRQ_IDD : IDD interrupt - * @arg MFXSTM32L152_IRQ_ERROR : Error interrupt - * @arg MFXSTM32L152_IRQ_TS_DET : Touch Screen Controller Touch Detected interrupt - * @arg MFXSTM32L152_IRQ_TS_NE : Touch Screen FIFO Not Empty - * @arg MFXSTM32L152_IRQ_TS_TH : Touch Screen FIFO threshold triggered - * @arg MFXSTM32L152_IRQ_TS_FULL : Touch Screen FIFO Full - * @arg MFXSTM32L152_IRQ_TS_OVF : Touch Screen FIFO Overflow - * @retval The value of the checked Global interrupt source status. - */ -uint8_t mfxstm32l152_GlobalITStatus(uint16_t DeviceAddr, uint8_t Source) -{ - /* Return the global IT source status (pending or not)*/ - return((MFX_IO_Read(DeviceAddr, MFXSTM32L152_REG_ADR_IRQ_PENDING) & Source)); -} - -/** - * @brief Clear the selected Global interrupt pending bit(s) - * @param DeviceAddr: Device address on communication Bus. - * @param Source: the Global interrupt source to be cleared, could be any combination - * of the below values. The acknowledge signal for MFXSTM32L152_GPIOs configured in input - * with interrupt is not on this register but in IRQ_GPI_ACK1, IRQ_GPI_ACK2 registers. - * @arg MFXSTM32L152_IRQ_IDD : IDD interrupt - * @arg MFXSTM32L152_IRQ_ERROR : Error interrupt - * @arg MFXSTM32L152_IRQ_TS_DET : Touch Screen Controller Touch Detected interrupt - * @arg MFXSTM32L152_IRQ_TS_NE : Touch Screen FIFO Not Empty - * @arg MFXSTM32L152_IRQ_TS_TH : Touch Screen FIFO threshold triggered - * @arg MFXSTM32L152_IRQ_TS_FULL : Touch Screen FIFO Full - * @arg MFXSTM32L152_IRQ_TS_OVF : Touch Screen FIFO Overflow - * /\/\ IMPORTANT NOTE /\/\ must not use MFXSTM32L152_IRQ_GPIO as argument, see IRQ_GPI_ACK1 and IRQ_GPI_ACK2 registers - * @retval None - */ -void mfxstm32l152_ClearGlobalIT(uint16_t DeviceAddr, uint8_t Source) -{ - /* Write 1 to the bits that have to be cleared */ - MFX_IO_Write(DeviceAddr, MFXSTM32L152_REG_ADR_IRQ_ACK, Source); -} - -/** - * @brief Set the global interrupt Polarity of IRQ_OUT_PIN. - * @param DeviceAddr: Device address on communication Bus. - * @param Polarity: the IT mode polarity, could be one of the following values: - * @arg MFXSTM32L152_OUT_PIN_POLARITY_LOW: Interrupt output line is active Low edge - * @arg MFXSTM32L152_OUT_PIN_POLARITY_HIGH: Interrupt line output is active High edge - * @retval None - */ -void mfxstm32l152_SetIrqOutPinPolarity(uint16_t DeviceAddr, uint8_t Polarity) -{ - uint8_t tmp = 0; - - /* Get the current register value */ - tmp = MFX_IO_Read(DeviceAddr, MFXSTM32L152_REG_ADR_MFX_IRQ_OUT); - - /* Mask the polarity bits */ - tmp &= ~(uint8_t)0x02; - - /* Modify the Interrupt Output line configuration */ - tmp |= Polarity; - - /* Set the new register value */ - MFX_IO_Write(DeviceAddr, MFXSTM32L152_REG_ADR_MFX_IRQ_OUT, tmp); - - /* Wait for 1 ms for MFX to change IRQ_out pin config, before activate it */ - MFX_IO_Delay(1); - -} - -/** - * @brief Set the global interrupt Type of IRQ_OUT_PIN. - * @param DeviceAddr: Device address on communication Bus. - * @param Type: Interrupt line activity type, could be one of the following values: - * @arg MFXSTM32L152_OUT_PIN_TYPE_OPENDRAIN: Open Drain output Interrupt line - * @arg MFXSTM32L152_OUT_PIN_TYPE_PUSHPULL: Push Pull output Interrupt line - * @retval None - */ -void mfxstm32l152_SetIrqOutPinType(uint16_t DeviceAddr, uint8_t Type) -{ - uint8_t tmp = 0; - - /* Get the current register value */ - tmp = MFX_IO_Read(DeviceAddr, MFXSTM32L152_REG_ADR_MFX_IRQ_OUT); - - /* Mask the type bits */ - tmp &= ~(uint8_t)0x01; - - /* Modify the Interrupt Output line configuration */ - tmp |= Type; - - /* Set the new register value */ - MFX_IO_Write(DeviceAddr, MFXSTM32L152_REG_ADR_MFX_IRQ_OUT, tmp); - - /* Wait for 1 ms for MFX to change IRQ_out pin config, before activate it */ - MFX_IO_Delay(1); - -} - - -/* ------------------------------------------------------------------ */ -/* ----------------------- GPIO ------------------------------------- */ -/* ------------------------------------------------------------------ */ - - -/** - * @brief Start the IO functionality used and enable the AF for selected IO pin(s). - * @param DeviceAddr: Device address on communication Bus. - * @param AF_en: 0 to disable, else enabled. - * @retval None - */ -void mfxstm32l152_IO_Start(uint16_t DeviceAddr, uint32_t IO_Pin) -{ - uint8_t mode; - - /* Get the current register value */ - mode = MFX_IO_Read(DeviceAddr, MFXSTM32L152_REG_ADR_SYS_CTRL); - - /* Set the IO Functionalities to be Enabled */ - mode |= MFXSTM32L152_GPIO_EN; - - /* Enable ALTERNATE functions */ - /* AGPIO[0..3] can be either IDD or GPIO */ - /* AGPIO[4..7] can be either TS or GPIO */ - /* if IDD or TS are enabled no matter the value this bit GPIO are not available for those pins */ - /* however the MFX will waste some cycles to to handle these potential GPIO (pooling, etc) */ - /* so if IDD and TS are both active it is better to let ALTERNATE off (0) */ - /* if however IDD or TS are not connected then set it on gives more GPIOs availability */ - /* remind that AGPIO are less efficient then normal GPIO (They use pooling rather then EXTI */ - if (IO_Pin > 0xFFFF) - { - mode |= MFXSTM32L152_ALTERNATE_GPIO_EN; - } - else - { - mode &= ~MFXSTM32L152_ALTERNATE_GPIO_EN; - } - - /* Write the new register value */ - MFX_IO_Write(DeviceAddr, MFXSTM32L152_REG_ADR_SYS_CTRL, mode); - - /* Wait for 1 ms for MFX to change IRQ_out pin config, before activate it */ - MFX_IO_Delay(1); -} - -/** - * @brief Configures the IO pin(s) according to IO mode structure value. - * @param DeviceAddr: Device address on communication Bus. - * @param IO_Pin: The output pin to be set or reset. This parameter can be one - * of the following values: - * @arg MFXSTM32L152_GPIO_PIN_x: where x can be from 0 to 23. - * @param IO_Mode: The IO pin mode to configure, could be one of the following values: - * @arg IO_MODE_INPUT - * @arg IO_MODE_OUTPUT - * @arg IO_MODE_IT_RISING_EDGE - * @arg IO_MODE_IT_FALLING_EDGE - * @arg IO_MODE_IT_LOW_LEVEL - * @arg IO_MODE_IT_HIGH_LEVEL - * @arg IO_MODE_INPUT_PU, - * @arg IO_MODE_INPUT_PD, - * @arg IO_MODE_OUTPUT_OD_PU, - * @arg IO_MODE_OUTPUT_OD_PD, - * @arg IO_MODE_OUTPUT_PP_PU, - * @arg IO_MODE_OUTPUT_PP_PD, - * @arg IO_MODE_IT_RISING_EDGE_PU - * @arg IO_MODE_IT_FALLING_EDGE_PU - * @arg IO_MODE_IT_LOW_LEVEL_PU - * @arg IO_MODE_IT_HIGH_LEVEL_PU - * @arg IO_MODE_IT_RISING_EDGE_PD - * @arg IO_MODE_IT_FALLING_EDGE_PD - * @arg IO_MODE_IT_LOW_LEVEL_PD - * @arg IO_MODE_IT_HIGH_LEVEL_PD - * @retval None - */ -uint8_t mfxstm32l152_IO_Config(uint16_t DeviceAddr, uint32_t IO_Pin, IO_ModeTypedef IO_Mode) -{ - uint8_t error_code = 0; - - /* Configure IO pin according to selected IO mode */ - switch(IO_Mode) - { - case IO_MODE_OFF: /* Off or analog mode */ - case IO_MODE_ANALOG: /* Off or analog mode */ - mfxstm32l152_IO_DisablePinIT(DeviceAddr, IO_Pin); /* first disable IT */ - mfxstm32l152_IO_InitPin(DeviceAddr, IO_Pin, MFXSTM32L152_GPIO_DIR_IN); - mfxstm32l152_reg24_setPinValue(DeviceAddr, MFXSTM32L152_REG_ADR_GPIO_TYPE1, IO_Pin, MFXSTM32L152_GPI_WITHOUT_PULL_RESISTOR); - mfxstm32l152_reg24_setPinValue(DeviceAddr, MFXSTM32L152_REG_ADR_GPIO_PUPD1, IO_Pin, MFXSTM32L152_GPIO_PULL_DOWN); - break; - - case IO_MODE_INPUT: /* Input mode */ - mfxstm32l152_IO_DisablePinIT(DeviceAddr, IO_Pin); /* first disable IT */ - mfxstm32l152_IO_InitPin(DeviceAddr, IO_Pin, MFXSTM32L152_GPIO_DIR_IN); - mfxstm32l152_reg24_setPinValue(DeviceAddr, MFXSTM32L152_REG_ADR_GPIO_TYPE1, IO_Pin, MFXSTM32L152_GPI_WITHOUT_PULL_RESISTOR); - mfxstm32l152_reg24_setPinValue(DeviceAddr, MFXSTM32L152_REG_ADR_GPIO_PUPD1, IO_Pin, MFXSTM32L152_GPIO_PULL_UP); - break; - - case IO_MODE_INPUT_PU: /* Input mode */ - mfxstm32l152_IO_DisablePinIT(DeviceAddr, IO_Pin); /* first disable IT */ - mfxstm32l152_IO_InitPin(DeviceAddr, IO_Pin, MFXSTM32L152_GPIO_DIR_IN); - mfxstm32l152_reg24_setPinValue(DeviceAddr, MFXSTM32L152_REG_ADR_GPIO_TYPE1, IO_Pin, MFXSTM32L152_GPI_WITH_PULL_RESISTOR); - mfxstm32l152_reg24_setPinValue(DeviceAddr, MFXSTM32L152_REG_ADR_GPIO_PUPD1, IO_Pin, MFXSTM32L152_GPIO_PULL_UP); - break; - - case IO_MODE_INPUT_PD: /* Input mode */ - mfxstm32l152_IO_DisablePinIT(DeviceAddr, IO_Pin); /* first disable IT */ - mfxstm32l152_IO_InitPin(DeviceAddr, IO_Pin, MFXSTM32L152_GPIO_DIR_IN); - mfxstm32l152_reg24_setPinValue(DeviceAddr, MFXSTM32L152_REG_ADR_GPIO_TYPE1, IO_Pin, MFXSTM32L152_GPI_WITH_PULL_RESISTOR); - mfxstm32l152_reg24_setPinValue(DeviceAddr, MFXSTM32L152_REG_ADR_GPIO_PUPD1, IO_Pin, MFXSTM32L152_GPIO_PULL_DOWN); - break; - - case IO_MODE_OUTPUT: /* Output mode */ - case IO_MODE_OUTPUT_PP_PD: /* Output mode */ - mfxstm32l152_IO_DisablePinIT(DeviceAddr, IO_Pin); /* first disable IT */ - mfxstm32l152_IO_InitPin(DeviceAddr, IO_Pin, MFXSTM32L152_GPIO_DIR_OUT); - mfxstm32l152_reg24_setPinValue(DeviceAddr, MFXSTM32L152_REG_ADR_GPIO_TYPE1, IO_Pin, MFXSTM32L152_GPO_PUSH_PULL); - mfxstm32l152_reg24_setPinValue(DeviceAddr, MFXSTM32L152_REG_ADR_GPIO_PUPD1, IO_Pin, MFXSTM32L152_GPIO_PULL_DOWN); - break; - - case IO_MODE_OUTPUT_PP_PU: /* Output mode */ - mfxstm32l152_IO_DisablePinIT(DeviceAddr, IO_Pin); /* first disable IT */ - mfxstm32l152_IO_InitPin(DeviceAddr, IO_Pin, MFXSTM32L152_GPIO_DIR_OUT); - mfxstm32l152_reg24_setPinValue(DeviceAddr, MFXSTM32L152_REG_ADR_GPIO_TYPE1, IO_Pin, MFXSTM32L152_GPO_PUSH_PULL); - mfxstm32l152_reg24_setPinValue(DeviceAddr, MFXSTM32L152_REG_ADR_GPIO_PUPD1, IO_Pin, MFXSTM32L152_GPIO_PULL_UP); - break; - - case IO_MODE_OUTPUT_OD_PD: /* Output mode */ - mfxstm32l152_IO_DisablePinIT(DeviceAddr, IO_Pin); /* first disable IT */ - mfxstm32l152_IO_InitPin(DeviceAddr, IO_Pin, MFXSTM32L152_GPIO_DIR_OUT); - mfxstm32l152_reg24_setPinValue(DeviceAddr, MFXSTM32L152_REG_ADR_GPIO_TYPE1, IO_Pin, MFXSTM32L152_GPO_OPEN_DRAIN); - mfxstm32l152_reg24_setPinValue(DeviceAddr, MFXSTM32L152_REG_ADR_GPIO_PUPD1, IO_Pin, MFXSTM32L152_GPIO_PULL_DOWN); - break; - - case IO_MODE_OUTPUT_OD_PU: /* Output mode */ - mfxstm32l152_IO_DisablePinIT(DeviceAddr, IO_Pin); /* first disable IT */ - mfxstm32l152_IO_InitPin(DeviceAddr, IO_Pin, MFXSTM32L152_GPIO_DIR_OUT); - mfxstm32l152_reg24_setPinValue(DeviceAddr, MFXSTM32L152_REG_ADR_GPIO_TYPE1, IO_Pin, MFXSTM32L152_GPO_OPEN_DRAIN); - mfxstm32l152_reg24_setPinValue(DeviceAddr, MFXSTM32L152_REG_ADR_GPIO_PUPD1, IO_Pin, MFXSTM32L152_GPIO_PULL_UP); - break; - - case IO_MODE_IT_RISING_EDGE: /* Interrupt rising edge mode */ - mfxstm32l152_IO_EnableIT(DeviceAddr); - mfxstm32l152_IO_InitPin(DeviceAddr, IO_Pin, MFXSTM32L152_GPIO_DIR_IN); - mfxstm32l152_reg24_setPinValue(DeviceAddr, MFXSTM32L152_REG_ADR_GPIO_TYPE1, IO_Pin, MFXSTM32L152_GPI_WITHOUT_PULL_RESISTOR); - mfxstm32l152_reg24_setPinValue(DeviceAddr, MFXSTM32L152_REG_ADR_GPIO_PUPD1, IO_Pin, MFXSTM32L152_GPIO_PULL_UP); - mfxstm32l152_IO_SetIrqEvtMode(DeviceAddr, IO_Pin, MFXSTM32L152_IRQ_GPI_EVT_EDGE); - mfxstm32l152_IO_SetIrqTypeMode(DeviceAddr, IO_Pin, MFXSTM32L152_IRQ_GPI_TYPE_HLRE); - mfxstm32l152_IO_EnablePinIT(DeviceAddr, IO_Pin); /* last to do: enable IT */ - break; - - case IO_MODE_IT_RISING_EDGE_PU: /* Interrupt rising edge mode */ - mfxstm32l152_IO_EnableIT(DeviceAddr); - mfxstm32l152_IO_InitPin(DeviceAddr, IO_Pin, MFXSTM32L152_GPIO_DIR_IN); - mfxstm32l152_reg24_setPinValue(DeviceAddr, MFXSTM32L152_REG_ADR_GPIO_TYPE1, IO_Pin, MFXSTM32L152_GPI_WITH_PULL_RESISTOR); - mfxstm32l152_reg24_setPinValue(DeviceAddr, MFXSTM32L152_REG_ADR_GPIO_PUPD1, IO_Pin, MFXSTM32L152_GPIO_PULL_UP); - mfxstm32l152_IO_SetIrqEvtMode(DeviceAddr, IO_Pin, MFXSTM32L152_IRQ_GPI_EVT_EDGE); - mfxstm32l152_IO_SetIrqTypeMode(DeviceAddr, IO_Pin, MFXSTM32L152_IRQ_GPI_TYPE_HLRE); - mfxstm32l152_IO_EnablePinIT(DeviceAddr, IO_Pin); /* last to do: enable IT */ - break; - - case IO_MODE_IT_RISING_EDGE_PD: /* Interrupt rising edge mode */ - mfxstm32l152_IO_EnableIT(DeviceAddr); - mfxstm32l152_IO_InitPin(DeviceAddr, IO_Pin, MFXSTM32L152_GPIO_DIR_IN); - mfxstm32l152_reg24_setPinValue(DeviceAddr, MFXSTM32L152_REG_ADR_GPIO_TYPE1, IO_Pin, MFXSTM32L152_GPI_WITH_PULL_RESISTOR); - mfxstm32l152_reg24_setPinValue(DeviceAddr, MFXSTM32L152_REG_ADR_GPIO_PUPD1, IO_Pin, MFXSTM32L152_GPIO_PULL_DOWN); - mfxstm32l152_IO_SetIrqEvtMode(DeviceAddr, IO_Pin, MFXSTM32L152_IRQ_GPI_EVT_EDGE); - mfxstm32l152_IO_SetIrqTypeMode(DeviceAddr, IO_Pin, MFXSTM32L152_IRQ_GPI_TYPE_HLRE); - mfxstm32l152_IO_EnablePinIT(DeviceAddr, IO_Pin); /* last to do: enable IT */ - break; - - case IO_MODE_IT_FALLING_EDGE: /* Interrupt falling edge mode */ - mfxstm32l152_IO_EnableIT(DeviceAddr); - mfxstm32l152_IO_InitPin(DeviceAddr, IO_Pin, MFXSTM32L152_GPIO_DIR_IN); - mfxstm32l152_reg24_setPinValue(DeviceAddr, MFXSTM32L152_REG_ADR_GPIO_TYPE1, IO_Pin, MFXSTM32L152_GPI_WITHOUT_PULL_RESISTOR); - mfxstm32l152_reg24_setPinValue(DeviceAddr, MFXSTM32L152_REG_ADR_GPIO_PUPD1, IO_Pin, MFXSTM32L152_GPIO_PULL_UP); - mfxstm32l152_IO_SetIrqEvtMode(DeviceAddr, IO_Pin, MFXSTM32L152_IRQ_GPI_EVT_EDGE); - mfxstm32l152_IO_SetIrqTypeMode(DeviceAddr, IO_Pin, MFXSTM32L152_IRQ_GPI_TYPE_LLFE); - mfxstm32l152_IO_EnablePinIT(DeviceAddr, IO_Pin); /* last to do: enable IT */ - break; - - case IO_MODE_IT_FALLING_EDGE_PU: /* Interrupt falling edge mode */ - mfxstm32l152_IO_EnableIT(DeviceAddr); - mfxstm32l152_IO_InitPin(DeviceAddr, IO_Pin, MFXSTM32L152_GPIO_DIR_IN); - mfxstm32l152_reg24_setPinValue(DeviceAddr, MFXSTM32L152_REG_ADR_GPIO_TYPE1, IO_Pin, MFXSTM32L152_GPI_WITH_PULL_RESISTOR); - mfxstm32l152_reg24_setPinValue(DeviceAddr, MFXSTM32L152_REG_ADR_GPIO_PUPD1, IO_Pin, MFXSTM32L152_GPIO_PULL_UP); - mfxstm32l152_IO_SetIrqEvtMode(DeviceAddr, IO_Pin, MFXSTM32L152_IRQ_GPI_EVT_EDGE); - mfxstm32l152_IO_SetIrqTypeMode(DeviceAddr, IO_Pin, MFXSTM32L152_IRQ_GPI_TYPE_LLFE); - mfxstm32l152_IO_EnablePinIT(DeviceAddr, IO_Pin); /* last to do: enable IT */ - break; - - case IO_MODE_IT_FALLING_EDGE_PD: /* Interrupt falling edge mode */ - mfxstm32l152_IO_EnableIT(DeviceAddr); - mfxstm32l152_IO_InitPin(DeviceAddr, IO_Pin, MFXSTM32L152_GPIO_DIR_IN); - mfxstm32l152_reg24_setPinValue(DeviceAddr, MFXSTM32L152_REG_ADR_GPIO_TYPE1, IO_Pin, MFXSTM32L152_GPI_WITH_PULL_RESISTOR); - mfxstm32l152_reg24_setPinValue(DeviceAddr, MFXSTM32L152_REG_ADR_GPIO_PUPD1, IO_Pin, MFXSTM32L152_GPIO_PULL_DOWN); - mfxstm32l152_IO_SetIrqEvtMode(DeviceAddr, IO_Pin, MFXSTM32L152_IRQ_GPI_EVT_EDGE); - mfxstm32l152_IO_SetIrqTypeMode(DeviceAddr, IO_Pin, MFXSTM32L152_IRQ_GPI_TYPE_LLFE); - mfxstm32l152_IO_EnablePinIT(DeviceAddr, IO_Pin); /* last to do: enable IT */ - break; - - case IO_MODE_IT_LOW_LEVEL: /* Low level interrupt mode */ - mfxstm32l152_IO_EnableIT(DeviceAddr); - mfxstm32l152_IO_InitPin(DeviceAddr, IO_Pin, MFXSTM32L152_GPIO_DIR_IN); - mfxstm32l152_reg24_setPinValue(DeviceAddr, MFXSTM32L152_REG_ADR_GPIO_TYPE1, IO_Pin, MFXSTM32L152_GPI_WITHOUT_PULL_RESISTOR); - mfxstm32l152_reg24_setPinValue(DeviceAddr, MFXSTM32L152_REG_ADR_GPIO_PUPD1, IO_Pin, MFXSTM32L152_GPIO_PULL_UP); - mfxstm32l152_IO_SetIrqEvtMode(DeviceAddr, IO_Pin, MFXSTM32L152_IRQ_GPI_EVT_LEVEL); - mfxstm32l152_IO_SetIrqTypeMode(DeviceAddr, IO_Pin, MFXSTM32L152_IRQ_GPI_TYPE_LLFE); - mfxstm32l152_IO_EnablePinIT(DeviceAddr, IO_Pin); /* last to do: enable IT */ - break; - - case IO_MODE_IT_LOW_LEVEL_PU: /* Low level interrupt mode */ - mfxstm32l152_IO_EnableIT(DeviceAddr); - mfxstm32l152_IO_InitPin(DeviceAddr, IO_Pin, MFXSTM32L152_GPIO_DIR_IN); - mfxstm32l152_reg24_setPinValue(DeviceAddr, MFXSTM32L152_REG_ADR_GPIO_TYPE1, IO_Pin, MFXSTM32L152_GPI_WITH_PULL_RESISTOR); - mfxstm32l152_reg24_setPinValue(DeviceAddr, MFXSTM32L152_REG_ADR_GPIO_PUPD1, IO_Pin, MFXSTM32L152_GPIO_PULL_UP); - mfxstm32l152_IO_SetIrqEvtMode(DeviceAddr, IO_Pin, MFXSTM32L152_IRQ_GPI_EVT_LEVEL); - mfxstm32l152_IO_SetIrqTypeMode(DeviceAddr, IO_Pin, MFXSTM32L152_IRQ_GPI_TYPE_LLFE); - mfxstm32l152_IO_EnablePinIT(DeviceAddr, IO_Pin); /* last to do: enable IT */ - break; - - case IO_MODE_IT_LOW_LEVEL_PD: /* Low level interrupt mode */ - mfxstm32l152_IO_EnableIT(DeviceAddr); - mfxstm32l152_IO_InitPin(DeviceAddr, IO_Pin, MFXSTM32L152_GPIO_DIR_IN); - mfxstm32l152_reg24_setPinValue(DeviceAddr, MFXSTM32L152_REG_ADR_GPIO_TYPE1, IO_Pin, MFXSTM32L152_GPI_WITH_PULL_RESISTOR); - mfxstm32l152_reg24_setPinValue(DeviceAddr, MFXSTM32L152_REG_ADR_GPIO_PUPD1, IO_Pin, MFXSTM32L152_GPIO_PULL_DOWN); - mfxstm32l152_IO_SetIrqEvtMode(DeviceAddr, IO_Pin, MFXSTM32L152_IRQ_GPI_EVT_LEVEL); - mfxstm32l152_IO_SetIrqTypeMode(DeviceAddr, IO_Pin, MFXSTM32L152_IRQ_GPI_TYPE_LLFE); - mfxstm32l152_IO_EnablePinIT(DeviceAddr, IO_Pin); /* last to do: enable IT */ - break; - - case IO_MODE_IT_HIGH_LEVEL: /* High level interrupt mode */ - mfxstm32l152_IO_EnableIT(DeviceAddr); - mfxstm32l152_IO_InitPin(DeviceAddr, IO_Pin, MFXSTM32L152_GPIO_DIR_IN); - mfxstm32l152_reg24_setPinValue(DeviceAddr, MFXSTM32L152_REG_ADR_GPIO_TYPE1, IO_Pin, MFXSTM32L152_GPI_WITHOUT_PULL_RESISTOR); - mfxstm32l152_reg24_setPinValue(DeviceAddr, MFXSTM32L152_REG_ADR_GPIO_PUPD1, IO_Pin, MFXSTM32L152_GPIO_PULL_UP); - mfxstm32l152_IO_SetIrqEvtMode(DeviceAddr, IO_Pin, MFXSTM32L152_IRQ_GPI_EVT_LEVEL); - mfxstm32l152_IO_SetIrqTypeMode(DeviceAddr, IO_Pin, MFXSTM32L152_IRQ_GPI_TYPE_HLRE); - mfxstm32l152_IO_EnablePinIT(DeviceAddr, IO_Pin); /* last to do: enable IT */ - break; - - case IO_MODE_IT_HIGH_LEVEL_PU: /* High level interrupt mode */ - mfxstm32l152_IO_EnableIT(DeviceAddr); - mfxstm32l152_IO_InitPin(DeviceAddr, IO_Pin, MFXSTM32L152_GPIO_DIR_IN); - mfxstm32l152_reg24_setPinValue(DeviceAddr, MFXSTM32L152_REG_ADR_GPIO_TYPE1, IO_Pin, MFXSTM32L152_GPI_WITH_PULL_RESISTOR); - mfxstm32l152_reg24_setPinValue(DeviceAddr, MFXSTM32L152_REG_ADR_GPIO_PUPD1, IO_Pin, MFXSTM32L152_GPIO_PULL_UP); - mfxstm32l152_IO_SetIrqEvtMode(DeviceAddr, IO_Pin, MFXSTM32L152_IRQ_GPI_EVT_LEVEL); - mfxstm32l152_IO_SetIrqTypeMode(DeviceAddr, IO_Pin, MFXSTM32L152_IRQ_GPI_TYPE_HLRE); - mfxstm32l152_IO_EnablePinIT(DeviceAddr, IO_Pin); /* last to do: enable IT */ - break; - - case IO_MODE_IT_HIGH_LEVEL_PD: /* High level interrupt mode */ - mfxstm32l152_IO_EnableIT(DeviceAddr); - mfxstm32l152_IO_InitPin(DeviceAddr, IO_Pin, MFXSTM32L152_GPIO_DIR_IN); - mfxstm32l152_reg24_setPinValue(DeviceAddr, MFXSTM32L152_REG_ADR_GPIO_TYPE1, IO_Pin, MFXSTM32L152_GPI_WITH_PULL_RESISTOR); - mfxstm32l152_reg24_setPinValue(DeviceAddr, MFXSTM32L152_REG_ADR_GPIO_PUPD1, IO_Pin, MFXSTM32L152_GPIO_PULL_DOWN); - mfxstm32l152_IO_SetIrqEvtMode(DeviceAddr, IO_Pin, MFXSTM32L152_IRQ_GPI_EVT_LEVEL); - mfxstm32l152_IO_SetIrqTypeMode(DeviceAddr, IO_Pin, MFXSTM32L152_IRQ_GPI_TYPE_HLRE); - mfxstm32l152_IO_EnablePinIT(DeviceAddr, IO_Pin); /* last to do: enable IT */ - break; - - default: - error_code = (uint8_t) IO_Mode; - break; - } - - return error_code; -} - -/** - * @brief Initialize the selected IO pin direction. - * @param DeviceAddr: Device address on communication Bus. - * @param IO_Pin: The IO pin to be configured. This parameter could be any - * combination of the following values: - * @arg MFXSTM32L152_GPIO_PIN_x: Where x can be from 0 to 23. - * @param Direction: could be MFXSTM32L152_GPIO_DIR_IN or MFXSTM32L152_GPIO_DIR_OUT. - * @retval None - */ -void mfxstm32l152_IO_InitPin(uint16_t DeviceAddr, uint32_t IO_Pin, uint8_t Direction) -{ - mfxstm32l152_reg24_setPinValue(DeviceAddr, MFXSTM32L152_REG_ADR_GPIO_DIR1, IO_Pin, Direction); -} - -/** - * @brief Set the global interrupt Type. - * @param DeviceAddr: Device address on communication Bus. - * @param IO_Pin: The IO pin to be configured. This parameter could be any - * combination of the following values: - * @arg MFXSTM32L152_GPIO_PIN_x: Where x can be from 0 to 23. - * @param Evt: Interrupt line activity type, could be one of the following values: - * @arg MFXSTM32L152_IRQ_GPI_EVT_LEVEL: Interrupt line is active in level model - * @arg MFXSTM32L152_IRQ_GPI_EVT_EDGE: Interrupt line is active in edge model - * @retval None - */ -void mfxstm32l152_IO_SetIrqEvtMode(uint16_t DeviceAddr, uint32_t IO_Pin, uint8_t Evt) -{ - mfxstm32l152_reg24_setPinValue(DeviceAddr, MFXSTM32L152_REG_ADR_IRQ_GPI_EVT1, IO_Pin, Evt); - MFX_IO_Delay(1); -} - -/** - * @brief Configure the Edge for which a transition is detectable for the - * selected pin. - * @param DeviceAddr: Device address on communication Bus. - * @param IO_Pin: The IO pin to be configured. This parameter could be any - * combination of the following values: - * @arg MFXSTM32L152_GPIO_PIN_x: Where x can be from 0 to 23. - * @param Evt: Interrupt line activity type, could be one of the following values: - * @arg MFXSTM32L152_IRQ_GPI_TYPE_LLFE: Interrupt line is active in Low Level or Falling Edge - * @arg MFXSTM32L152_IRQ_GPI_TYPE_HLRE: Interrupt line is active in High Level or Rising Edge - * @retval None - */ -void mfxstm32l152_IO_SetIrqTypeMode(uint16_t DeviceAddr, uint32_t IO_Pin, uint8_t Type) -{ - mfxstm32l152_reg24_setPinValue(DeviceAddr, MFXSTM32L152_REG_ADR_IRQ_GPI_TYPE1, IO_Pin, Type); - MFX_IO_Delay(1); -} - -/** - * @brief When GPIO is in output mode, puts the corresponding GPO in High (1) or Low (0) level. - * @param DeviceAddr: Device address on communication Bus. - * @param IO_Pin: The output pin to be set or reset. This parameter can be one - * of the following values: - * @arg MFXSTM32L152_GPIO_PIN_x: where x can be from 0 to 23. - * @param PinState: The new IO pin state. - * @retval None - */ -void mfxstm32l152_IO_WritePin(uint16_t DeviceAddr, uint32_t IO_Pin, uint8_t PinState) -{ - /* Apply the bit value to the selected pin */ - if (PinState != 0) - { - /* Set the SET register */ - mfxstm32l152_reg24_setPinValue(DeviceAddr, MFXSTM32L152_REG_ADR_GPO_SET1, IO_Pin, 1); - } - else - { - /* Set the CLEAR register */ - mfxstm32l152_reg24_setPinValue(DeviceAddr, MFXSTM32L152_REG_ADR_GPO_CLR1, IO_Pin, 1); - } -} - -/** - * @brief Return the state of the selected IO pin(s). - * @param DeviceAddr: Device address on communication Bus. - * @param IO_Pin: The output pin to be set or reset. This parameter can be one - * of the following values: - * @arg MFXSTM32L152_GPIO_PIN_x: where x can be from 0 to 23. - * @retval IO pin(s) state. - */ -uint32_t mfxstm32l152_IO_ReadPin(uint16_t DeviceAddr, uint32_t IO_Pin) -{ - uint8_t tmp1; - uint16_t tmp2; - uint32_t tmp3; - - tmp1 = MFX_IO_Read(DeviceAddr, MFXSTM32L152_REG_ADR_GPIO_STATE1); - tmp2 = (uint16_t) MFX_IO_Read(DeviceAddr, MFXSTM32L152_REG_ADR_GPIO_STATE2); - tmp3 = (uint32_t) MFX_IO_Read(DeviceAddr, MFXSTM32L152_REG_ADR_GPIO_STATE3); - tmp3 = tmp1 + (tmp2 << 8) + (tmp3 << 16); - - return(tmp3 & IO_Pin); -} - -/** - * @brief Enable the global IO interrupt source. - * @param DeviceAddr: Device address on communication Bus. - * @retval None - */ -void mfxstm32l152_IO_EnableIT(uint16_t DeviceAddr) -{ - MFX_IO_ITConfig(); - - /* Enable global IO IT source */ - mfxstm32l152_EnableITSource(DeviceAddr, MFXSTM32L152_IRQ_GPIO); -} - -/** - * @brief Disable the global IO interrupt source. - * @param DeviceAddr: Device address on communication Bus. - * @retval None - */ -void mfxstm32l152_IO_DisableIT(uint16_t DeviceAddr) -{ - /* Disable global IO IT source */ - mfxstm32l152_DisableITSource(DeviceAddr, MFXSTM32L152_IRQ_GPIO); -} - -/** - * @brief Enable interrupt mode for the selected IO pin(s). - * @param DeviceAddr: Device address on communication Bus. - * @param IO_Pin: The IO interrupt to be enabled. This parameter could be any - * combination of the following values: - * @arg MFXSTM32L152_GPIO_PIN_x: where x can be from 0 to 23. - * @retval None - */ -void mfxstm32l152_IO_EnablePinIT(uint16_t DeviceAddr, uint32_t IO_Pin) -{ - mfxstm32l152_reg24_setPinValue(DeviceAddr, MFXSTM32L152_REG_ADR_IRQ_GPI_SRC1, IO_Pin, 1); -} - -/** - * @brief Disable interrupt mode for the selected IO pin(s). - * @param DeviceAddr: Device address on communication Bus. - * @param IO_Pin: The IO interrupt to be disabled. This parameter could be any - * combination of the following values: - * @arg MFXSTM32L152_GPIO_PIN_x: where x can be from 0 to 23. - * @retval None - */ -void mfxstm32l152_IO_DisablePinIT(uint16_t DeviceAddr, uint32_t IO_Pin) -{ - mfxstm32l152_reg24_setPinValue(DeviceAddr, MFXSTM32L152_REG_ADR_IRQ_GPI_SRC1, IO_Pin, 0); -} - - -/** - * @brief Check the status of the selected IO interrupt pending bit - * @param DeviceAddr: Device address on communication Bus. - * @param IO_Pin: The IO interrupt to be checked could be: - * @arg MFXSTM32L152_GPIO_PIN_x Where x can be from 0 to 23. - * @retval Status of the checked IO pin(s). - */ -uint32_t mfxstm32l152_IO_ITStatus(uint16_t DeviceAddr, uint32_t IO_Pin) -{ - /* Get the Interrupt status */ - uint8_t tmp1; - uint16_t tmp2; - uint32_t tmp3; - - tmp1 = MFX_IO_Read(DeviceAddr, MFXSTM32L152_REG_ADR_IRQ_GPI_PENDING1); - tmp2 = (uint16_t) MFX_IO_Read(DeviceAddr, MFXSTM32L152_REG_ADR_IRQ_GPI_PENDING2); - tmp3 = (uint32_t) MFX_IO_Read(DeviceAddr, MFXSTM32L152_REG_ADR_IRQ_GPI_PENDING3); - tmp3 = tmp1 + (tmp2 << 8) + (tmp3 << 16); - - return(tmp3 & IO_Pin); -} - -/** - * @brief Clear the selected IO interrupt pending bit(s). It clear automatically also the general MFXSTM32L152_REG_ADR_IRQ_PENDING - * @param DeviceAddr: Device address on communication Bus. - * @param IO_Pin: the IO interrupt to be cleared, could be: - * @arg MFXSTM32L152_GPIO_PIN_x: Where x can be from 0 to 23. - * @retval None - */ -void mfxstm32l152_IO_ClearIT(uint16_t DeviceAddr, uint32_t IO_Pin) -{ - /* Clear the IO IT pending bit(s) by acknowledging */ - /* it cleans automatically also the Global IRQ_GPIO */ - /* normally this function is called under interrupt */ - uint8_t pin_0_7, pin_8_15, pin_16_23; - - pin_0_7 = IO_Pin & 0x0000ff; - pin_8_15 = IO_Pin >> 8; - pin_8_15 = pin_8_15 & 0x00ff; - pin_16_23 = IO_Pin >> 16; - - if (pin_0_7) - { - MFX_IO_Write(DeviceAddr, MFXSTM32L152_REG_ADR_IRQ_GPI_ACK1, pin_0_7); - } - if (pin_8_15) - { - MFX_IO_Write(DeviceAddr, MFXSTM32L152_REG_ADR_IRQ_GPI_ACK2, pin_8_15); - } - if (pin_16_23) - { - MFX_IO_Write(DeviceAddr, MFXSTM32L152_REG_ADR_IRQ_GPI_ACK3, pin_16_23); - } -} - - -/** - * @brief Enable the AF for aGPIO. - * @param DeviceAddr: Device address on communication Bus. - * @retval None - */ -void mfxstm32l152_IO_EnableAF(uint16_t DeviceAddr) -{ - uint8_t mode; - - /* Get the current register value */ - mode = MFX_IO_Read(DeviceAddr, MFXSTM32L152_REG_ADR_SYS_CTRL); - - /* Enable ALTERNATE functions */ - /* AGPIO[0..3] can be either IDD or GPIO */ - /* AGPIO[4..7] can be either TS or GPIO */ - /* if IDD or TS are enabled no matter the value this bit GPIO are not available for those pins */ - /* however the MFX will waste some cycles to to handle these potential GPIO (pooling, etc) */ - /* so if IDD and TS are both active it is better to let ALTERNATE disabled (0) */ - /* if however IDD or TS are not connected then set it on gives more GPIOs availability */ - /* remind that AGPIO are less efficient then normal GPIO (they use pooling rather then EXTI) */ - mode |= MFXSTM32L152_ALTERNATE_GPIO_EN; - - /* Write the new register value */ - MFX_IO_Write(DeviceAddr, MFXSTM32L152_REG_ADR_SYS_CTRL, mode); -} - -/** - * @brief Disable the AF for aGPIO. - * @param DeviceAddr: Device address on communication Bus. - * @retval None - */ - void mfxstm32l152_IO_DisableAF(uint16_t DeviceAddr) -{ - uint8_t mode; - - /* Get the current register value */ - mode = MFX_IO_Read(DeviceAddr, MFXSTM32L152_REG_ADR_SYS_CTRL); - - /* Enable ALTERNATE functions */ - /* AGPIO[0..3] can be either IDD or GPIO */ - /* AGPIO[4..7] can be either TS or GPIO */ - /* if IDD or TS are enabled no matter the value this bit GPIO are not available for those pins */ - /* however the MFX will waste some cycles to to handle these potential GPIO (pooling, etc) */ - /* so if IDD and TS are both active it is better to let ALTERNATE disabled (0) */ - /* if however IDD or TS are not connected then set it on gives more GPIOs availability */ - /* remind that AGPIO are less efficient then normal GPIO (they use pooling rather then EXTI) */ - mode &= ~MFXSTM32L152_ALTERNATE_GPIO_EN; - - /* Write the new register value */ - MFX_IO_Write(DeviceAddr, MFXSTM32L152_REG_ADR_SYS_CTRL, mode); - -} - - -/* ------------------------------------------------------------------ */ -/* --------------------- TOUCH SCREEN ------------------------------- */ -/* ------------------------------------------------------------------ */ - -/** - * @brief Configures the touch Screen Controller (Single point detection) - * @param DeviceAddr: Device address on communication Bus. - * @retval None. - */ -void mfxstm32l152_TS_Start(uint16_t DeviceAddr) -{ - uint8_t mode; - - /* Get the current register value */ - mode = MFX_IO_Read(DeviceAddr, MFXSTM32L152_REG_ADR_SYS_CTRL); - - /* Set the Functionalities to be Enabled */ - mode |= MFXSTM32L152_TS_EN; - - /* Set the new register value */ - MFX_IO_Write(DeviceAddr, MFXSTM32L152_REG_ADR_SYS_CTRL, mode); - - /* Wait for 2 ms */ - MFX_IO_Delay(2); - - /* Select 2 nF filter capacitor */ - /* Configuration: - - Touch average control : 4 samples - - Touch delay time : 500 uS - - Panel driver setting time: 500 uS - */ - MFX_IO_Write(DeviceAddr, MFXSTM32L152_TS_SETTLING, 0x32); - MFX_IO_Write(DeviceAddr, MFXSTM32L152_TS_TOUCH_DET_DELAY, 0x5); - MFX_IO_Write(DeviceAddr, MFXSTM32L152_TS_AVE, 0x04); - - /* Configure the Touch FIFO threshold: single point reading */ - MFX_IO_Write(DeviceAddr, MFXSTM32L152_TS_FIFO_TH, 0x01); - - /* Clear the FIFO memory content. */ - MFX_IO_Write(DeviceAddr, MFXSTM32L152_TS_FIFO_TH, MFXSTM32L152_TS_CLEAR_FIFO); - - /* Touch screen control configuration : - - No window tracking index - */ - MFX_IO_Write(DeviceAddr, MFXSTM32L152_TS_TRACK, 0x00); - - - /* Clear all the IT status pending bits if any */ - mfxstm32l152_IO_ClearIT(DeviceAddr, 0xFFFFFF); - - /* Wait for 1 ms delay */ - MFX_IO_Delay(1); -} - -/** - * @brief Return if there is touch detected or not. - * @param DeviceAddr: Device address on communication Bus. - * @retval Touch detected state. - */ -uint8_t mfxstm32l152_TS_DetectTouch(uint16_t DeviceAddr) -{ - uint8_t state; - uint8_t ret = 0; - - state = MFX_IO_Read(DeviceAddr, MFXSTM32L152_TS_FIFO_STA); - state = ((state & (uint8_t)MFXSTM32L152_TS_CTRL_STATUS) == (uint8_t)MFXSTM32L152_TS_CTRL_STATUS); - - if(state > 0) - { - if(MFX_IO_Read(DeviceAddr, MFXSTM32L152_TS_FIFO_LEVEL) > 0) - { - ret = 1; - } - } - - return ret; -} - -/** - * @brief Get the touch screen X and Y positions values - * @param DeviceAddr: Device address on communication Bus. - * @param X: Pointer to X position value - * @param Y: Pointer to Y position value - * @retval None. - */ -void mfxstm32l152_TS_GetXY(uint16_t DeviceAddr, uint16_t *X, uint16_t *Y) -{ - uint8_t data_xy[3]; - - MFX_IO_ReadMultiple(DeviceAddr, MFXSTM32L152_TS_XY_DATA, data_xy, sizeof(data_xy)) ; - - /* Calculate positions values */ - *X = (data_xy[1]<<4) + (data_xy[0]>>4); - *Y = (data_xy[2]<<4) + (data_xy[0]&4); - - /* Reset the FIFO memory content. */ - MFX_IO_Write(DeviceAddr, MFXSTM32L152_TS_FIFO_TH, MFXSTM32L152_TS_CLEAR_FIFO); -} - -/** - * @brief Configure the selected source to generate a global interrupt or not - * @param DeviceAddr: Device address on communication Bus. - * @retval None - */ -void mfxstm32l152_TS_EnableIT(uint16_t DeviceAddr) -{ - MFX_IO_ITConfig(); - - /* Enable global TS IT source */ - mfxstm32l152_EnableITSource(DeviceAddr, MFXSTM32L152_IRQ_TS_DET); -} - -/** - * @brief Configure the selected source to generate a global interrupt or not - * @param DeviceAddr: Device address on communication Bus. - * @retval None - */ -void mfxstm32l152_TS_DisableIT(uint16_t DeviceAddr) -{ - /* Disable global TS IT source */ - mfxstm32l152_DisableITSource(DeviceAddr, MFXSTM32L152_IRQ_TS_DET); -} - -/** - * @brief Configure the selected source to generate a global interrupt or not - * @param DeviceAddr: Device address on communication Bus. - * @retval TS interrupts status - */ -uint8_t mfxstm32l152_TS_ITStatus(uint16_t DeviceAddr) -{ - /* Return TS interrupts status */ - return(mfxstm32l152_GlobalITStatus(DeviceAddr, MFXSTM32L152_IRQ_TS)); -} - -/** - * @brief Configure the selected source to generate a global interrupt or not - * @param DeviceAddr: Device address on communication Bus. - * @retval None - */ -void mfxstm32l152_TS_ClearIT(uint16_t DeviceAddr) -{ - /* Clear the global TS IT source */ - mfxstm32l152_ClearGlobalIT(DeviceAddr, MFXSTM32L152_IRQ_TS); -} - -/* ------------------------------------------------------------------ */ -/* --------------------- IDD MEASUREMENT ---------------------------- */ -/* ------------------------------------------------------------------ */ - -/** - * @brief Launch IDD current measurement - * @param DeviceAddr: Device address on communication Bus - * @retval None. - */ -void mfxstm32l152_IDD_Start(uint16_t DeviceAddr) -{ - uint8_t mode = 0; - - /* Get the current register value */ - mode = MFX_IO_Read((uint8_t) DeviceAddr, MFXSTM32L152_REG_ADR_IDD_CTRL); - - /* Set the Functionalities to be enabled */ - mode |= MFXSTM32L152_IDD_CTRL_REQ; - - /* Start measurement campaign */ - MFX_IO_Write((uint8_t) DeviceAddr, MFXSTM32L152_REG_ADR_IDD_CTRL, mode); -} - -/** - * @brief Configures the IDD current measurement - * @param DeviceAddr: Device address on communication Bus. - * @param MfxIddConfig: Parameters depending on hardware config. - * @retval None - */ -void mfxstm32l152_IDD_Config(uint16_t DeviceAddr, IDD_ConfigTypeDef MfxIddConfig) -{ - uint8_t value = 0; - uint8_t mode = 0; - - /* Get the current register value */ - mode = MFX_IO_Read((uint8_t) DeviceAddr, MFXSTM32L152_REG_ADR_SYS_CTRL); - - if((mode & MFXSTM32L152_IDD_EN) != MFXSTM32L152_IDD_EN) - { - /* Set the Functionalities to be enabled */ - mode |= MFXSTM32L152_IDD_EN; - - /* Set the new register value */ - MFX_IO_Write((uint8_t) DeviceAddr, MFXSTM32L152_REG_ADR_SYS_CTRL, mode); - } - - /* Control register setting: number of shunts */ - value = ((MfxIddConfig.ShuntNbUsed << 1) & MFXSTM32L152_IDD_CTRL_SHUNT_NB); - value |= (MfxIddConfig.VrefMeasurement & MFXSTM32L152_IDD_CTRL_VREF_DIS); - value |= (MfxIddConfig.Calibration & MFXSTM32L152_IDD_CTRL_CAL_DIS); - MFX_IO_Write((uint8_t) DeviceAddr, MFXSTM32L152_REG_ADR_IDD_CTRL, value); - - /* Idd pre delay configuration: unit and value*/ - value = (MfxIddConfig.PreDelayUnit & MFXSTM32L152_IDD_PREDELAY_UNIT) | - (MfxIddConfig.PreDelayValue & MFXSTM32L152_IDD_PREDELAY_VALUE); - MFX_IO_Write((uint8_t) DeviceAddr, MFXSTM32L152_REG_ADR_IDD_PRE_DELAY, value); - - /* Shunt 0 register value: MSB then LSB */ - value = (uint8_t) (MfxIddConfig.Shunt0Value >> 8); - MFX_IO_Write((uint8_t) DeviceAddr, MFXSTM32L152_REG_ADR_IDD_SHUNT0_MSB, value); - value = (uint8_t) (MfxIddConfig.Shunt0Value); - MFX_IO_Write((uint8_t) DeviceAddr, MFXSTM32L152_REG_ADR_IDD_SHUNT0_LSB, value); - - /* Shunt 1 register value: MSB then LSB */ - value = (uint8_t) (MfxIddConfig.Shunt1Value >> 8); - MFX_IO_Write((uint8_t) DeviceAddr, MFXSTM32L152_REG_ADR_IDD_SHUNT1_MSB, value); - value = (uint8_t) (MfxIddConfig.Shunt1Value); - MFX_IO_Write((uint8_t) DeviceAddr, MFXSTM32L152_REG_ADR_IDD_SHUNT1_LSB, value); - - /* Shunt 2 register value: MSB then LSB */ - value = (uint8_t) (MfxIddConfig.Shunt2Value >> 8); - MFX_IO_Write((uint8_t) DeviceAddr, MFXSTM32L152_REG_ADR_IDD_SHUNT2_MSB, value); - value = (uint8_t) (MfxIddConfig.Shunt2Value); - MFX_IO_Write((uint8_t) DeviceAddr, MFXSTM32L152_REG_ADR_IDD_SHUNT2_LSB, value); - - /* Shunt 3 register value: MSB then LSB */ - value = (uint8_t) (MfxIddConfig.Shunt3Value >> 8); - MFX_IO_Write((uint8_t) DeviceAddr, MFXSTM32L152_REG_ADR_IDD_SHUNT3_MSB, value); - value = (uint8_t) (MfxIddConfig.Shunt3Value); - MFX_IO_Write((uint8_t) DeviceAddr, MFXSTM32L152_REG_ADR_IDD_SHUNT3_LSB, value); - - /* Shunt 4 register value: MSB then LSB */ - value = (uint8_t) (MfxIddConfig.Shunt4Value >> 8); - MFX_IO_Write((uint8_t) DeviceAddr, MFXSTM32L152_REG_ADR_IDD_SHUNT4_MSB, value); - value = (uint8_t) (MfxIddConfig.Shunt4Value); - MFX_IO_Write((uint8_t) DeviceAddr, MFXSTM32L152_REG_ADR_IDD_SHUNT4_LSB, value); - - /* Shunt 0 stabilization delay */ - value = MfxIddConfig.Shunt0StabDelay; - MFX_IO_Write((uint8_t) DeviceAddr, MFXSTM32L152_REG_ADR_IDD_SH0_STABILIZATION, value); - - /* Shunt 1 stabilization delay */ - value = MfxIddConfig.Shunt1StabDelay; - MFX_IO_Write((uint8_t) DeviceAddr, MFXSTM32L152_REG_ADR_IDD_SH1_STABILIZATION, value); - - /* Shunt 2 stabilization delay */ - value = MfxIddConfig.Shunt2StabDelay; - MFX_IO_Write((uint8_t) DeviceAddr, MFXSTM32L152_REG_ADR_IDD_SH2_STABILIZATION, value); - - /* Shunt 3 stabilization delay */ - value = MfxIddConfig.Shunt3StabDelay; - MFX_IO_Write((uint8_t) DeviceAddr, MFXSTM32L152_REG_ADR_IDD_SH3_STABILIZATION, value); - - /* Shunt 4 stabilization delay */ - value = MfxIddConfig.Shunt4StabDelay; - MFX_IO_Write((uint8_t) DeviceAddr, MFXSTM32L152_REG_ADR_IDD_SH4_STABILIZATION, value); - - /* Idd ampli gain value: MSB then LSB */ - value = (uint8_t) (MfxIddConfig.AmpliGain >> 8); - MFX_IO_Write((uint8_t) DeviceAddr, MFXSTM32L152_REG_ADR_IDD_GAIN_MSB, value); - value = (uint8_t) (MfxIddConfig.AmpliGain); - MFX_IO_Write((uint8_t) DeviceAddr, MFXSTM32L152_REG_ADR_IDD_GAIN_LSB, value); - - /* Idd VDD min value: MSB then LSB */ - value = (uint8_t) (MfxIddConfig.VddMin >> 8); - MFX_IO_Write((uint8_t) DeviceAddr, MFXSTM32L152_REG_ADR_IDD_VDD_MIN_MSB, value); - value = (uint8_t) (MfxIddConfig.VddMin); - MFX_IO_Write((uint8_t) DeviceAddr, MFXSTM32L152_REG_ADR_IDD_VDD_MIN_LSB, value); - - /* Idd number of measurements */ - value = MfxIddConfig.MeasureNb; - MFX_IO_Write((uint8_t) DeviceAddr, MFXSTM32L152_REG_ADR_IDD_NBR_OF_MEAS, value); - - /* Idd delta delay configuration: unit and value */ - value = (MfxIddConfig.DeltaDelayUnit & MFXSTM32L152_IDD_DELTADELAY_UNIT) | - (MfxIddConfig.DeltaDelayValue & MFXSTM32L152_IDD_DELTADELAY_VALUE); - MFX_IO_Write((uint8_t) DeviceAddr, MFXSTM32L152_REG_ADR_IDD_MEAS_DELTA_DELAY, value); - - /* Idd number of shut on board */ - value = MfxIddConfig.ShuntNbOnBoard; - MFX_IO_Write((uint8_t) DeviceAddr, MFXSTM32L152_REG_ADR_IDD_SHUNTS_ON_BOARD, value); -} - -/** - * @brief This function allows to modify number of shunt used for a measurement - * @param DeviceAddr: Device address on communication Bus - * @retval None. - */ -void mfxstm32l152_IDD_ConfigShuntNbLimit(uint16_t DeviceAddr, uint8_t ShuntNbLimit) -{ - uint8_t mode = 0; - - /* Get the current register value */ - mode = MFX_IO_Read((uint8_t) DeviceAddr, MFXSTM32L152_REG_ADR_IDD_CTRL); - - /* Clear number of shunt limit */ - mode &= ~(MFXSTM32L152_IDD_CTRL_SHUNT_NB); - - /* Clear number of shunt limit */ - mode |= ((ShuntNbLimit << 1) & MFXSTM32L152_IDD_CTRL_SHUNT_NB); - - /* Write noewx desired limit */ - MFX_IO_Write((uint8_t) DeviceAddr, MFXSTM32L152_REG_ADR_IDD_CTRL, mode); -} - -/** - * @brief Get Idd current value - * @param DeviceAddr: Device address on communication Bus - * @param ReadValue: Pointer on value to be read - * @retval Idd value in 10 nA. - */ -void mfxstm32l152_IDD_GetValue(uint16_t DeviceAddr, uint32_t *ReadValue) -{ - uint8_t data[3]; - - MFX_IO_ReadMultiple((uint8_t) DeviceAddr, MFXSTM32L152_REG_ADR_IDD_VALUE_MSB, data, sizeof(data)) ; - - /* Recompose Idd current value */ - *ReadValue = (data[0] << 16) | (data[1] << 8) | data[2]; - -} - -/** - * @brief Get Last shunt used for measurement - * @param DeviceAddr: Device address on communication Bus - * @retval Last shunt used - */ -uint8_t mfxstm32l152_IDD_GetShuntUsed(uint16_t DeviceAddr) -{ - return(MFX_IO_Read((uint8_t) DeviceAddr, MFXSTM32L152_REG_ADR_IDD_SHUNT_USED)); -} - -/** - * @brief Configure mfx to enable Idd interrupt - * @param DeviceAddr: Device address on communication Bus. - * @retval None - */ -void mfxstm32l152_IDD_EnableIT(uint16_t DeviceAddr) -{ - MFX_IO_ITConfig(); - - /* Enable global IDD interrupt source */ - mfxstm32l152_EnableITSource(DeviceAddr, MFXSTM32L152_IRQ_IDD); -} - -/** - * @brief Clear Idd global interrupt - * @param DeviceAddr: Device address on communication Bus. - * @retval None - */ -void mfxstm32l152_IDD_ClearIT(uint16_t DeviceAddr) -{ - /* Clear the global IDD interrupt source */ - mfxstm32l152_ClearGlobalIT(DeviceAddr, MFXSTM32L152_IRQ_IDD); -} - -/** - * @brief get Idd interrupt status - * @param DeviceAddr: Device address on communication Bus. - * @retval IDD interrupts status - */ -uint8_t mfxstm32l152_IDD_GetITStatus(uint16_t DeviceAddr) -{ - /* Return IDD interrupt status */ - return(mfxstm32l152_GlobalITStatus(DeviceAddr, MFXSTM32L152_IRQ_IDD)); -} - -/** - * @brief disable Idd interrupt - * @param DeviceAddr: Device address on communication Bus. - * @retval None. - */ -void mfxstm32l152_IDD_DisableIT(uint16_t DeviceAddr) -{ - /* Disable global IDD interrupt source */ - mfxstm32l152_DisableITSource(DeviceAddr, MFXSTM32L152_IRQ_IDD); -} - - -/* ------------------------------------------------------------------ */ -/* --------------------- ERROR MANAGEMENT --------------------------- */ -/* ------------------------------------------------------------------ */ - -/** - * @brief Read Error Source. - * @param DeviceAddr: Device address on communication Bus. - * @retval Error message code with error source - */ -uint8_t mfxstm32l152_Error_ReadSrc(uint16_t DeviceAddr) -{ - /* Get the current source register value */ - return(MFX_IO_Read((uint8_t) DeviceAddr, MFXSTM32L152_REG_ADR_ERROR_SRC)); -} - -/** - * @brief Read Error Message - * @param DeviceAddr: Device address on communication Bus. - * @retval Error message code with error source - */ -uint8_t mfxstm32l152_Error_ReadMsg(uint16_t DeviceAddr) -{ - /* Get the current message register value */ - return(MFX_IO_Read((uint8_t) DeviceAddr, MFXSTM32L152_REG_ADR_ERROR_MSG)); -} - -/** - * @brief Enable Error global interrupt - * @param DeviceAddr: Device address on communication Bus. - * @retval None - */ - -void mfxstm32l152_Error_EnableIT(uint16_t DeviceAddr) -{ - MFX_IO_ITConfig(); - - /* Enable global Error interrupt source */ - mfxstm32l152_EnableITSource(DeviceAddr, MFXSTM32L152_IRQ_ERROR); -} - -/** - * @brief Clear Error global interrupt - * @param DeviceAddr: Device address on communication Bus. - * @retval None - */ -void mfxstm32l152_Error_ClearIT(uint16_t DeviceAddr) -{ - /* Clear the global Error interrupt source */ - mfxstm32l152_ClearGlobalIT(DeviceAddr, MFXSTM32L152_IRQ_ERROR); -} - -/** - * @brief get Error interrupt status - * @param DeviceAddr: Device address on communication Bus. - * @retval Error interrupts status - */ -uint8_t mfxstm32l152_Error_GetITStatus(uint16_t DeviceAddr) -{ - /* Return Error interrupt status */ - return(mfxstm32l152_GlobalITStatus(DeviceAddr, MFXSTM32L152_IRQ_ERROR)); -} - -/** - * @brief disable Error interrupt - * @param DeviceAddr: Device address on communication Bus. - * @retval None. - */ -void mfxstm32l152_Error_DisableIT(uint16_t DeviceAddr) -{ - /* Disable global Error interrupt source */ - mfxstm32l152_DisableITSource(DeviceAddr, MFXSTM32L152_IRQ_ERROR); -} - -/** - * @brief FOR DEBUG ONLY - */ -uint8_t mfxstm32l152_ReadReg(uint16_t DeviceAddr, uint8_t RegAddr) -{ - /* Get the current register value */ - return(MFX_IO_Read((uint8_t) DeviceAddr, RegAddr)); -} - -void mfxstm32l152_WriteReg(uint16_t DeviceAddr, uint8_t RegAddr, uint8_t Value) -{ - /* set the current register value */ - MFX_IO_Write((uint8_t) DeviceAddr, RegAddr, Value); -} - -/* ------------------------------------------------------------------ */ -/* ----------------------- Private functions ------------------------ */ -/* ------------------------------------------------------------------ */ -/** - * @brief Check if the device instance of the selected address is already registered - * and return its index - * @param DeviceAddr: Device address on communication Bus. - * @retval Index of the device instance if registered, 0xFF if not. - */ -static uint8_t mfxstm32l152_GetInstance(uint16_t DeviceAddr) -{ - uint8_t idx = 0; - - /* Check all the registered instances */ - for(idx = 0; idx < MFXSTM32L152_MAX_INSTANCE ; idx ++) - { - if(mfxstm32l152[idx] == DeviceAddr) - { - return idx; - } - } - - return 0xFF; -} - -/** - * @brief Release registered device instance - * @param DeviceAddr: Device address on communication Bus. - * @retval Index of released device instance, 0xFF if not. - */ -static uint8_t mfxstm32l152_ReleaseInstance(uint16_t DeviceAddr) -{ - uint8_t idx = 0; - - /* Check for all the registered instances */ - for(idx = 0; idx < MFXSTM32L152_MAX_INSTANCE ; idx ++) - { - if(mfxstm32l152[idx] == DeviceAddr) - { - mfxstm32l152[idx] = 0; - return idx; - } - } - return 0xFF; -} - -/** - * @brief Internal routine - * @param DeviceAddr: Device address on communication Bus. - * @param RegisterAddr: Register Address - * @param PinPosition: Pin [0:23] - * @param PinValue: 0/1 - * @retval None - */ -void mfxstm32l152_reg24_setPinValue(uint16_t DeviceAddr, uint8_t RegisterAddr, uint32_t PinPosition, uint8_t PinValue ) -{ - uint8_t tmp = 0; - uint8_t pin_0_7, pin_8_15, pin_16_23; - - pin_0_7 = PinPosition & 0x0000ff; - pin_8_15 = PinPosition >> 8; - pin_8_15 = pin_8_15 & 0x00ff; - pin_16_23 = PinPosition >> 16; - - if (pin_0_7) - { - /* Get the current register value */ - tmp = MFX_IO_Read(DeviceAddr, RegisterAddr); - - /* Set the selected pin direction */ - if (PinValue != 0) - { - tmp |= (uint8_t)pin_0_7; - } - else - { - tmp &= ~(uint8_t)pin_0_7; - } - - /* Set the new register value */ - MFX_IO_Write(DeviceAddr, RegisterAddr, tmp); - } - - if (pin_8_15) - { - /* Get the current register value */ - tmp = MFX_IO_Read(DeviceAddr, RegisterAddr+1); - - /* Set the selected pin direction */ - if (PinValue != 0) - { - tmp |= (uint8_t)pin_8_15; - } - else - { - tmp &= ~(uint8_t)pin_8_15; - } - - /* Set the new register value */ - MFX_IO_Write(DeviceAddr, RegisterAddr+1, tmp); - } - - if (pin_16_23) - { - /* Get the current register value */ - tmp = MFX_IO_Read(DeviceAddr, RegisterAddr+2); - - /* Set the selected pin direction */ - if (PinValue != 0) - { - tmp |= (uint8_t)pin_16_23; - } - else - { - tmp &= ~(uint8_t)pin_16_23; - } - - /* Set the new register value */ - MFX_IO_Write(DeviceAddr, RegisterAddr+2, tmp); - } -} - - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/mfxstm32l152/mfxstm32l152.h b/bsp/stm32f411RE/Libraries/BSP/Components/mfxstm32l152/mfxstm32l152.h deleted file mode 100644 index c26b3f19d5..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/mfxstm32l152/mfxstm32l152.h +++ /dev/null @@ -1,668 +0,0 @@ -/** - ****************************************************************************** - * @file mfxstm32l152.h - * @author MCD Application Team - * @version V2.0.0 - * @date 24-June-2015 - * @brief This file contains all the functions prototypes for the - * mfxstm32l152.c IO expander driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __MFXSTM32L152_H -#define __MFXSTM32L152_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "../Common/ts.h" -#include "../Common/io.h" -#include "../Common/idd.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup Component - * @{ - */ - -/** @defgroup MFXSTM32L152 - * @{ - */ - -/* Exported types ------------------------------------------------------------*/ - -/** @defgroup MFXSTM32L152_Exported_Types - * @{ - */ -typedef struct -{ - uint8_t SYS_CTRL; - uint8_t ERROR_SRC; - uint8_t ERROR_MSG; - uint8_t IRQ_OUT; - uint8_t IRQ_SRC_EN; - uint8_t IRQ_PENDING; - uint8_t IDD_CTRL; - uint8_t IDD_PRE_DELAY; - uint8_t IDD_SHUNT0_MSB; - uint8_t IDD_SHUNT0_LSB; - uint8_t IDD_SHUNT1_MSB; - uint8_t IDD_SHUNT1_LSB; - uint8_t IDD_SHUNT2_MSB; - uint8_t IDD_SHUNT2_LSB; - uint8_t IDD_SHUNT3_MSB; - uint8_t IDD_SHUNT3_LSB; - uint8_t IDD_SHUNT4_MSB; - uint8_t IDD_SHUNT4_LSB; - uint8_t IDD_GAIN_MSB; - uint8_t IDD_GAIN_LSB; - uint8_t IDD_VDD_MIN_MSB; - uint8_t IDD_VDD_MIN_LSB; - uint8_t IDD_VALUE_MSB; - uint8_t IDD_VALUE_MID; - uint8_t IDD_VALUE_LSB; - uint8_t IDD_CAL_OFFSET_MSB; - uint8_t IDD_CAL_OFFSET_LSB; - uint8_t IDD_SHUNT_USED; -}IDD_dbgTypeDef; - -/** - * @} - */ - -/* Exported constants --------------------------------------------------------*/ - -/** @defgroup MFXSTM32L152_Exported_Constants - * @{ - */ - - /** - * @brief MFX COMMON defines - */ - - /** - * @brief Register address: chip IDs (R) - */ -#define MFXSTM32L152_REG_ADR_ID ((uint8_t)0x00) - /** - * @brief Register address: chip FW_VERSION (R) - */ -#define MFXSTM32L152_REG_ADR_FW_VERSION_MSB ((uint8_t)0x01) -#define MFXSTM32L152_REG_ADR_FW_VERSION_LSB ((uint8_t)0x00) - /** - * @brief Register address: System Control Register (R/W) - */ -#define MFXSTM32L152_REG_ADR_SYS_CTRL ((uint8_t)0x40) - /** - * @brief Register address: Vdd monitoring (R) - */ -#define MFXSTM32L152_REG_ADR_VDD_REF_MSB ((uint8_t)0x06) -#define MFXSTM32L152_REG_ADR_VDD_REF_LSB ((uint8_t)0x07) - /** - * @brief Register address: Error source - */ -#define MFXSTM32L152_REG_ADR_ERROR_SRC ((uint8_t)0x03) - /** - * @brief Register address: Error Message - */ -#define MFXSTM32L152_REG_ADR_ERROR_MSG ((uint8_t)0x04) - - /** - * @brief Reg Addr IRQs: to config the pin that informs Main MCU that MFX events appear - */ -#define MFXSTM32L152_REG_ADR_MFX_IRQ_OUT ((uint8_t)0x41) - /** - * @brief Reg Addr IRQs: to select the events which activate the MFXSTM32L152_IRQ_OUT signal - */ -#define MFXSTM32L152_REG_ADR_IRQ_SRC_EN ((uint8_t)0x42) - /** - * @brief Reg Addr IRQs: the Main MCU must read the IRQ_PENDING register to know the interrupt reason - */ -#define MFXSTM32L152_REG_ADR_IRQ_PENDING ((uint8_t)0x08) - /** - * @brief Reg Addr IRQs: the Main MCU must acknowledge it thanks to a writing access to the IRQ_ACK register - */ -#define MFXSTM32L152_REG_ADR_IRQ_ACK ((uint8_t)0x44) - - /** - * @brief MFXSTM32L152_REG_ADR_ID choices - */ -#define MFXSTM32L152_ID_1 ((uint8_t)0x7B) -#define MFXSTM32L152_ID_2 ((uint8_t)0x79) - - /** - * @brief MFXSTM32L152_REG_ADR_SYS_CTRL choices - */ -#define MFXSTM32L152_SWRST ((uint8_t)0x80) -#define MFXSTM32L152_STANDBY ((uint8_t)0x40) -#define MFXSTM32L152_ALTERNATE_GPIO_EN ((uint8_t)0x08) /* by the way if IDD and TS are enabled they take automatically the AF pins*/ -#define MFXSTM32L152_IDD_EN ((uint8_t)0x04) -#define MFXSTM32L152_TS_EN ((uint8_t)0x02) -#define MFXSTM32L152_GPIO_EN ((uint8_t)0x01) - - /** - * @brief MFXSTM32L152_REG_ADR_ERROR_SRC choices - */ -#define MFXSTM32L152_IDD_ERROR_SRC ((uint8_t)0x04) /* Error raised by Idd */ -#define MFXSTM32L152_TS_ERROR_SRC ((uint8_t)0x02) /* Error raised by Touch Screen */ -#define MFXSTM32L152_GPIO_ERROR_SRC ((uint8_t)0x01) /* Error raised by Gpio */ - - /** - * @brief MFXSTM32L152_REG_ADR_MFX_IRQ_OUT choices - */ -#define MFXSTM32L152_OUT_PIN_TYPE_OPENDRAIN ((uint8_t)0x00) -#define MFXSTM32L152_OUT_PIN_TYPE_PUSHPULL ((uint8_t)0x01) -#define MFXSTM32L152_OUT_PIN_POLARITY_LOW ((uint8_t)0x00) -#define MFXSTM32L152_OUT_PIN_POLARITY_HIGH ((uint8_t)0x02) - - /** - * @brief REG_ADR_IRQ_SRC_EN, REG_ADR_IRQ_PENDING & REG_ADR_IRQ_ACK choices - */ -#define MFXSTM32L152_IRQ_TS_OVF ((uint8_t)0x80) /* TouchScreen FIFO Overflow irq*/ -#define MFXSTM32L152_IRQ_TS_FULL ((uint8_t)0x40) /* TouchScreen FIFO Full irq*/ -#define MFXSTM32L152_IRQ_TS_TH ((uint8_t)0x20) /* TouchScreen FIFO threshold triggered irq*/ -#define MFXSTM32L152_IRQ_TS_NE ((uint8_t)0x10) /* TouchScreen FIFO Not Empty irq*/ -#define MFXSTM32L152_IRQ_TS_DET ((uint8_t)0x08) /* TouchScreen Detect irq*/ -#define MFXSTM32L152_IRQ_ERROR ((uint8_t)0x04) /* Error message from MFXSTM32L152 firmware irq */ -#define MFXSTM32L152_IRQ_IDD ((uint8_t)0x02) /* IDD function irq */ -#define MFXSTM32L152_IRQ_GPIO ((uint8_t)0x01) /* General GPIO irq (only for SRC_EN and PENDING) */ -#define MFXSTM32L152_IRQ_ALL ((uint8_t)0xFF) /* All global interrupts */ -#define MFXSTM32L152_IRQ_TS (MFXSTM32L152_IRQ_TS_DET | MFXSTM32L152_IRQ_TS_NE | MFXSTM32L152_IRQ_TS_TH | MFXSTM32L152_IRQ_TS_FULL | MFXSTM32L152_IRQ_TS_OVF ) - - - /** - * @brief GPIO: 24 programmable input/output called MFXSTM32L152_GPIO[23:0] are provided - */ - - /** - * @brief Reg addr: GPIO DIRECTION (R/W): GPIO pins direction: (0) input, (1) output. - */ -#define MFXSTM32L152_REG_ADR_GPIO_DIR1 ((uint8_t)0x60) /* gpio [0:7] */ -#define MFXSTM32L152_REG_ADR_GPIO_DIR2 ((uint8_t)0x61) /* gpio [8:15] */ -#define MFXSTM32L152_REG_ADR_GPIO_DIR3 ((uint8_t)0x62) /* agpio [0:7] */ - /** - * @brief Reg addr: GPIO TYPE (R/W): If GPIO in output: (0) output push pull, (1) output open drain. - * If GPIO in input: (0) input without pull resistor, (1) input with pull resistor. - */ -#define MFXSTM32L152_REG_ADR_GPIO_TYPE1 ((uint8_t)0x64) /* gpio [0:7] */ -#define MFXSTM32L152_REG_ADR_GPIO_TYPE2 ((uint8_t)0x65) /* gpio [8:15] */ -#define MFXSTM32L152_REG_ADR_GPIO_TYPE3 ((uint8_t)0x66) /* agpio [0:7] */ - /** - * @brief Reg addr: GPIO PULL_UP_PULL_DOWN (R/W): discussion open with Jean Claude - */ -#define MFXSTM32L152_REG_ADR_GPIO_PUPD1 ((uint8_t)0x68) /* gpio [0:7] */ -#define MFXSTM32L152_REG_ADR_GPIO_PUPD2 ((uint8_t)0x69) /* gpio [8:15] */ -#define MFXSTM32L152_REG_ADR_GPIO_PUPD3 ((uint8_t)0x6A) /* agpio [0:7] */ - /** - * @brief Reg addr: GPIO SET (W): When GPIO is in output mode, write (1) puts the corresponding GPO in High level. - */ -#define MFXSTM32L152_REG_ADR_GPO_SET1 ((uint8_t)0x6C) /* gpio [0:7] */ -#define MFXSTM32L152_REG_ADR_GPO_SET2 ((uint8_t)0x6D) /* gpio [8:15] */ -#define MFXSTM32L152_REG_ADR_GPO_SET3 ((uint8_t)0x6E) /* agpio [0:7] */ - /** - * @brief Reg addr: GPIO CLEAR (W): When GPIO is in output mode, write (1) puts the corresponding GPO in Low level. - */ -#define MFXSTM32L152_REG_ADR_GPO_CLR1 ((uint8_t)0x70) /* gpio [0:7] */ -#define MFXSTM32L152_REG_ADR_GPO_CLR2 ((uint8_t)0x71) /* gpio [8:15] */ -#define MFXSTM32L152_REG_ADR_GPO_CLR3 ((uint8_t)0x72) /* agpio [0:7] */ - /** - * @brief Reg addr: GPIO STATE (R): Give state of the GPIO pin. - */ -#define MFXSTM32L152_REG_ADR_GPIO_STATE1 ((uint8_t)0x10) /* gpio [0:7] */ -#define MFXSTM32L152_REG_ADR_GPIO_STATE2 ((uint8_t)0x11) /* gpio [8:15] */ -#define MFXSTM32L152_REG_ADR_GPIO_STATE3 ((uint8_t)0x12) /* agpio [0:7] */ - - /** - * @brief GPIO IRQ_GPIs - */ -/* GPIOs can INDIVIDUALLY generate interruption to the Main MCU thanks to the MFXSTM32L152_IRQ_OUT signal */ -/* the general MFXSTM32L152_IRQ_GPIO_SRC_EN shall be enabled too */ - /** - * @brief GPIO IRQ_GPI_SRC1/2/3 (R/W): registers enable or not the feature to generate irq - */ -#define MFXSTM32L152_REG_ADR_IRQ_GPI_SRC1 ((uint8_t)0x48) /* gpio [0:7] */ -#define MFXSTM32L152_REG_ADR_IRQ_GPI_SRC2 ((uint8_t)0x49) /* gpio [8:15] */ -#define MFXSTM32L152_REG_ADR_IRQ_GPI_SRC3 ((uint8_t)0x4A) /* agpio [0:7] */ - /** - * @brief GPIO IRQ_GPI_EVT1/2/3 (R/W): Irq generated on level (0) or edge (1). - */ -#define MFXSTM32L152_REG_ADR_IRQ_GPI_EVT1 ((uint8_t)0x4C) /* gpio [0:7] */ -#define MFXSTM32L152_REG_ADR_IRQ_GPI_EVT2 ((uint8_t)0x4D) /* gpio [8:15] */ -#define MFXSTM32L152_REG_ADR_IRQ_GPI_EVT3 ((uint8_t)0x4E) /* agpio [0:7] */ - /** - * @brief GPIO IRQ_GPI_TYPE1/2/3 (R/W): Irq generated on (0) : Low level or Falling edge. (1) : High level or Rising edge. - */ -#define MFXSTM32L152_REG_ADR_IRQ_GPI_TYPE1 ((uint8_t)0x50) /* gpio [0:7] */ -#define MFXSTM32L152_REG_ADR_IRQ_GPI_TYPE2 ((uint8_t)0x51) /* gpio [8:15] */ -#define MFXSTM32L152_REG_ADR_IRQ_GPI_TYPE3 ((uint8_t)0x52) /* agpio [0:7] */ - /** - * @brief GPIO IRQ_GPI_PENDING1/2/3 (R): irq occurs - */ -#define MFXSTM32L152_REG_ADR_IRQ_GPI_PENDING1 ((uint8_t)0x0C) /* gpio [0:7] */ -#define MFXSTM32L152_REG_ADR_IRQ_GPI_PENDING2 ((uint8_t)0x0D) /* gpio [8:15] */ -#define MFXSTM32L152_REG_ADR_IRQ_GPI_PENDING3 ((uint8_t)0x0E) /* agpio [0:7] */ - /** - * @brief GPIO IRQ_GPI_ACK1/2/3 (W): Write (1) to acknowledge IRQ event - */ -#define MFXSTM32L152_REG_ADR_IRQ_GPI_ACK1 ((uint8_t)0x54) /* gpio [0:7] */ -#define MFXSTM32L152_REG_ADR_IRQ_GPI_ACK2 ((uint8_t)0x55) /* gpio [8:15] */ -#define MFXSTM32L152_REG_ADR_IRQ_GPI_ACK3 ((uint8_t)0x56) /* agpio [0:7] */ - - - /** - * @brief GPIO: IO Pins definition - */ -#define MFXSTM32L152_GPIO_PIN_0 ((uint32_t)0x0001) -#define MFXSTM32L152_GPIO_PIN_1 ((uint32_t)0x0002) -#define MFXSTM32L152_GPIO_PIN_2 ((uint32_t)0x0004) -#define MFXSTM32L152_GPIO_PIN_3 ((uint32_t)0x0008) -#define MFXSTM32L152_GPIO_PIN_4 ((uint32_t)0x0010) -#define MFXSTM32L152_GPIO_PIN_5 ((uint32_t)0x0020) -#define MFXSTM32L152_GPIO_PIN_6 ((uint32_t)0x0040) -#define MFXSTM32L152_GPIO_PIN_7 ((uint32_t)0x0080) - -#define MFXSTM32L152_GPIO_PIN_8 ((uint32_t)0x0100) -#define MFXSTM32L152_GPIO_PIN_9 ((uint32_t)0x0200) -#define MFXSTM32L152_GPIO_PIN_10 ((uint32_t)0x0400) -#define MFXSTM32L152_GPIO_PIN_11 ((uint32_t)0x0800) -#define MFXSTM32L152_GPIO_PIN_12 ((uint32_t)0x1000) -#define MFXSTM32L152_GPIO_PIN_13 ((uint32_t)0x2000) -#define MFXSTM32L152_GPIO_PIN_14 ((uint32_t)0x4000) -#define MFXSTM32L152_GPIO_PIN_15 ((uint32_t)0x8000) - -#define MFXSTM32L152_GPIO_PIN_16 ((uint32_t)0x010000) -#define MFXSTM32L152_GPIO_PIN_17 ((uint32_t)0x020000) -#define MFXSTM32L152_GPIO_PIN_18 ((uint32_t)0x040000) -#define MFXSTM32L152_GPIO_PIN_19 ((uint32_t)0x080000) -#define MFXSTM32L152_GPIO_PIN_20 ((uint32_t)0x100000) -#define MFXSTM32L152_GPIO_PIN_21 ((uint32_t)0x200000) -#define MFXSTM32L152_GPIO_PIN_22 ((uint32_t)0x400000) -#define MFXSTM32L152_GPIO_PIN_23 ((uint32_t)0x800000) - -#define MFXSTM32L152_AGPIO_PIN_0 MFXSTM32L152_GPIO_PIN_16 -#define MFXSTM32L152_AGPIO_PIN_1 MFXSTM32L152_GPIO_PIN_17 -#define MFXSTM32L152_AGPIO_PIN_2 MFXSTM32L152_GPIO_PIN_18 -#define MFXSTM32L152_AGPIO_PIN_3 MFXSTM32L152_GPIO_PIN_19 -#define MFXSTM32L152_AGPIO_PIN_4 MFXSTM32L152_GPIO_PIN_20 -#define MFXSTM32L152_AGPIO_PIN_5 MFXSTM32L152_GPIO_PIN_21 -#define MFXSTM32L152_AGPIO_PIN_6 MFXSTM32L152_GPIO_PIN_22 -#define MFXSTM32L152_AGPIO_PIN_7 MFXSTM32L152_GPIO_PIN_23 - -#define MFXSTM32L152_GPIO_PINS_ALL ((uint32_t)0xFFFFFF) - - /** - * @brief GPIO: constant - */ -#define MFXSTM32L152_GPIO_DIR_IN ((uint8_t)0x0) -#define MFXSTM32L152_GPIO_DIR_OUT ((uint8_t)0x1) -#define MFXSTM32L152_IRQ_GPI_EVT_LEVEL ((uint8_t)0x0) -#define MFXSTM32L152_IRQ_GPI_EVT_EDGE ((uint8_t)0x1) -#define MFXSTM32L152_IRQ_GPI_TYPE_LLFE ((uint8_t)0x0) /* Low Level Falling Edge */ -#define MFXSTM32L152_IRQ_GPI_TYPE_HLRE ((uint8_t)0x1) /*High Level Raising Edge */ -#define MFXSTM32L152_GPI_WITHOUT_PULL_RESISTOR ((uint8_t)0x0) -#define MFXSTM32L152_GPI_WITH_PULL_RESISTOR ((uint8_t)0x1) -#define MFXSTM32L152_GPO_PUSH_PULL ((uint8_t)0x0) -#define MFXSTM32L152_GPO_OPEN_DRAIN ((uint8_t)0x1) -#define MFXSTM32L152_GPIO_PULL_DOWN ((uint8_t)0x0) -#define MFXSTM32L152_GPIO_PULL_UP ((uint8_t)0x1) - - - /** - * @brief TOUCH SCREEN Registers - */ - - /** - * @brief Touch Screen Registers - */ -#define MFXSTM32L152_TS_SETTLING ((uint8_t)0xA0) -#define MFXSTM32L152_TS_TOUCH_DET_DELAY ((uint8_t)0xA1) -#define MFXSTM32L152_TS_AVE ((uint8_t)0xA2) -#define MFXSTM32L152_TS_TRACK ((uint8_t)0xA3) -#define MFXSTM32L152_TS_FIFO_TH ((uint8_t)0xA4) -#define MFXSTM32L152_TS_FIFO_STA ((uint8_t)0x20) -#define MFXSTM32L152_TS_FIFO_LEVEL ((uint8_t)0x21) -#define MFXSTM32L152_TS_XY_DATA ((uint8_t)0x24) - - /** - * @brief TS registers masks - */ -#define MFXSTM32L152_TS_CTRL_STATUS ((uint8_t)0x08) -#define MFXSTM32L152_TS_CLEAR_FIFO ((uint8_t)0x80) - - -/** - * @brief Register address: Idd control register (R/W) - */ -#define MFXSTM32L152_REG_ADR_IDD_CTRL ((uint8_t)0x80) - -/** - * @brief Register address: Idd pre delay register (R/W) - */ -#define MFXSTM32L152_REG_ADR_IDD_PRE_DELAY ((uint8_t)0x81) - -/** - * @brief Register address: Idd Shunt registers (R/W) - */ -#define MFXSTM32L152_REG_ADR_IDD_SHUNT0_MSB ((uint8_t)0x82) -#define MFXSTM32L152_REG_ADR_IDD_SHUNT0_LSB ((uint8_t)0x83) -#define MFXSTM32L152_REG_ADR_IDD_SHUNT1_MSB ((uint8_t)0x84) -#define MFXSTM32L152_REG_ADR_IDD_SHUNT1_LSB ((uint8_t)0x85) -#define MFXSTM32L152_REG_ADR_IDD_SHUNT2_MSB ((uint8_t)0x86) -#define MFXSTM32L152_REG_ADR_IDD_SHUNT2_LSB ((uint8_t)0x87) -#define MFXSTM32L152_REG_ADR_IDD_SHUNT3_MSB ((uint8_t)0x88) -#define MFXSTM32L152_REG_ADR_IDD_SHUNT3_LSB ((uint8_t)0x89) -#define MFXSTM32L152_REG_ADR_IDD_SHUNT4_MSB ((uint8_t)0x8A) -#define MFXSTM32L152_REG_ADR_IDD_SHUNT4_LSB ((uint8_t)0x8B) - -/** - * @brief Register address: Idd ampli gain register (R/W) - */ -#define MFXSTM32L152_REG_ADR_IDD_GAIN_MSB ((uint8_t)0x8C) -#define MFXSTM32L152_REG_ADR_IDD_GAIN_LSB ((uint8_t)0x8D) - -/** - * @brief Register address: Idd VDD min register (R/W) - */ -#define MFXSTM32L152_REG_ADR_IDD_VDD_MIN_MSB ((uint8_t)0x8E) -#define MFXSTM32L152_REG_ADR_IDD_VDD_MIN_LSB ((uint8_t)0x8F) - -/** - * @brief Register address: Idd value register (R) - */ -#define MFXSTM32L152_REG_ADR_IDD_VALUE_MSB ((uint8_t)0x14) -#define MFXSTM32L152_REG_ADR_IDD_VALUE_MID ((uint8_t)0x15) -#define MFXSTM32L152_REG_ADR_IDD_VALUE_LSB ((uint8_t)0x16) - -/** - * @brief Register address: Idd calibration offset register (R) - */ -#define MFXSTM32L152_REG_ADR_IDD_CAL_OFFSET_MSB ((uint8_t)0x18) -#define MFXSTM32L152_REG_ADR_IDD_CAL_OFFSET_LSB ((uint8_t)0x19) - -/** - * @brief Register address: Idd shunt used offset register (R) - */ -#define MFXSTM32L152_REG_ADR_IDD_SHUNT_USED ((uint8_t)0x1A) - -/** - * @brief Register address: shunt stabilisation delay registers (R/W) - */ -#define MFXSTM32L152_REG_ADR_IDD_SH0_STABILIZATION ((uint8_t)0x90) -#define MFXSTM32L152_REG_ADR_IDD_SH1_STABILIZATION ((uint8_t)0x91) -#define MFXSTM32L152_REG_ADR_IDD_SH2_STABILIZATION ((uint8_t)0x92) -#define MFXSTM32L152_REG_ADR_IDD_SH3_STABILIZATION ((uint8_t)0x93) -#define MFXSTM32L152_REG_ADR_IDD_SH4_STABILIZATION ((uint8_t)0x94) - -/** - * @brief Register address: Idd number of measurements register (R/W) - */ -#define MFXSTM32L152_REG_ADR_IDD_NBR_OF_MEAS ((uint8_t)0x96) - -/** - * @brief Register address: Idd delta delay between 2 measurements register (R/W) - */ -#define MFXSTM32L152_REG_ADR_IDD_MEAS_DELTA_DELAY ((uint8_t)0x97) - -/** - * @brief Register address: Idd number of shunt on board register (R/W) - */ -#define MFXSTM32L152_REG_ADR_IDD_SHUNTS_ON_BOARD ((uint8_t)0x98) - - - -/** @defgroup IDD_Control_Register_Defines IDD Control Register Defines - * @{ - */ -/** - * @brief IDD control register masks - */ -#define MFXSTM32L152_IDD_CTRL_REQ ((uint8_t)0x01) -#define MFXSTM32L152_IDD_CTRL_SHUNT_NB ((uint8_t)0x0E) -#define MFXSTM32L152_IDD_CTRL_VREF_DIS ((uint8_t)0x40) -#define MFXSTM32L152_IDD_CTRL_CAL_DIS ((uint8_t)0x80) - -/** - * @brief IDD Shunt Number - */ -#define MFXSTM32L152_IDD_SHUNT_NB_1 ((uint8_t) 0x01) -#define MFXSTM32L152_IDD_SHUNT_NB_2 ((uint8_t) 0x02) -#define MFXSTM32L152_IDD_SHUNT_NB_3 ((uint8_t) 0x03) -#define MFXSTM32L152_IDD_SHUNT_NB_4 ((uint8_t) 0x04) -#define MFXSTM32L152_IDD_SHUNT_NB_5 ((uint8_t) 0x05) - -/** - * @brief Vref Measurement - */ -#define MFXSTM32L152_IDD_VREF_AUTO_MEASUREMENT_ENABLE ((uint8_t) 0x00) -#define MFXSTM32L152_IDD_VREF_AUTO_MEASUREMENT_DISABLE ((uint8_t) 0x70) - -/** - * @brief IDD Calibration - */ -#define MFXSTM32L152_IDD_AUTO_CALIBRATION_ENABLE ((uint8_t) 0x00) -#define MFXSTM32L152_IDD_AUTO_CALIBRATION_DISABLE ((uint8_t) 0x80) -/** - * @} - */ - -/** @defgroup IDD_PreDelay_Defines IDD PreDelay Defines - * @{ - */ -/** - * @brief IDD PreDelay masks - */ -#define MFXSTM32L152_IDD_PREDELAY_UNIT ((uint8_t) 0x80) -#define MFXSTM32L152_IDD_PREDELAY_VALUE ((uint8_t) 0x7F) - - -/** - * @brief IDD PreDelay unit - */ -#define MFXSTM32L152_IDD_PREDELAY_0_5_MS ((uint8_t) 0x00) -#define MFXSTM32L152_IDD_PREDELAY_20_MS ((uint8_t) 0x80) -/** - * @} - */ - -/** @defgroup IDD_DeltaDelay_Defines IDD Delta DElay Defines - * @{ - */ -/** - * @brief IDD Delta Delay masks - */ -#define MFXSTM32L152_IDD_DELTADELAY_UNIT ((uint8_t) 0x80) -#define MFXSTM32L152_IDD_DELTADELAY_VALUE ((uint8_t) 0x7F) - - -/** - * @brief IDD Delta Delay unit - */ -#define MFXSTM32L152_IDD_DELTADELAY_0_5_MS ((uint8_t) 0x00) -#define MFXSTM32L152_IDD_DELTADELAY_20_MS ((uint8_t) 0x80) - - -/** - * @} - */ - -/** - * @} - */ - - -/* Exported macro ------------------------------------------------------------*/ - -/** @defgroup MFXSTM32L152_Exported_Macros - * @{ - */ - -/** - * @} - */ - -/* Exported functions --------------------------------------------------------*/ - -/** @defgroup MFXSTM32L152_Exported_Functions - * @{ - */ - -/** - * @brief MFXSTM32L152 Control functions - */ -void mfxstm32l152_Init(uint16_t DeviceAddr); -void mfxstm32l152_DeInit(uint16_t DeviceAddr); -void mfxstm32l152_Reset(uint16_t DeviceAddr); -uint16_t mfxstm32l152_ReadID(uint16_t DeviceAddr); -uint16_t mfxstm32l152_ReadFwVersion(uint16_t DeviceAddr); -void mfxstm32l152_LowPower(uint16_t DeviceAddr); -void mfxstm32l152_WakeUp(uint16_t DeviceAddr); - -void mfxstm32l152_EnableITSource(uint16_t DeviceAddr, uint8_t Source); -void mfxstm32l152_DisableITSource(uint16_t DeviceAddr, uint8_t Source); -uint8_t mfxstm32l152_GlobalITStatus(uint16_t DeviceAddr, uint8_t Source); -void mfxstm32l152_ClearGlobalIT(uint16_t DeviceAddr, uint8_t Source); - -void mfxstm32l152_SetIrqOutPinPolarity(uint16_t DeviceAddr, uint8_t Polarity); -void mfxstm32l152_SetIrqOutPinType(uint16_t DeviceAddr, uint8_t Type); - - -/** - * @brief MFXSTM32L152 IO functionalities functions - */ -void mfxstm32l152_IO_Start(uint16_t DeviceAddr, uint32_t IO_Pin); -uint8_t mfxstm32l152_IO_Config(uint16_t DeviceAddr, uint32_t IO_Pin, IO_ModeTypedef IO_Mode); -void mfxstm32l152_IO_WritePin(uint16_t DeviceAddr, uint32_t IO_Pin, uint8_t PinState); -uint32_t mfxstm32l152_IO_ReadPin(uint16_t DeviceAddr, uint32_t IO_Pin); -void mfxstm32l152_IO_EnableIT(uint16_t DeviceAddr); -void mfxstm32l152_IO_DisableIT(uint16_t DeviceAddr); -uint32_t mfxstm32l152_IO_ITStatus(uint16_t DeviceAddr, uint32_t IO_Pin); -void mfxstm32l152_IO_ClearIT(uint16_t DeviceAddr, uint32_t IO_Pin); - -void mfxstm32l152_IO_InitPin(uint16_t DeviceAddr, uint32_t IO_Pin, uint8_t Direction); -void mfxstm32l152_IO_EnableAF(uint16_t DeviceAddr); -void mfxstm32l152_IO_DisableAF(uint16_t DeviceAddr); -void mfxstm32l152_IO_SetIrqTypeMode(uint16_t DeviceAddr, uint32_t IO_Pin, uint8_t Type); -void mfxstm32l152_IO_SetIrqEvtMode(uint16_t DeviceAddr, uint32_t IO_Pin, uint8_t Evt); -void mfxstm32l152_IO_EnablePinIT(uint16_t DeviceAddr, uint32_t IO_Pin); -void mfxstm32l152_IO_DisablePinIT(uint16_t DeviceAddr, uint32_t IO_Pin); - -/** - * @brief MFXSTM32L152 Touch screen functionalities functions - */ -void mfxstm32l152_TS_Start(uint16_t DeviceAddr); -uint8_t mfxstm32l152_TS_DetectTouch(uint16_t DeviceAddr); -void mfxstm32l152_TS_GetXY(uint16_t DeviceAddr, uint16_t *X, uint16_t *Y); -void mfxstm32l152_TS_EnableIT(uint16_t DeviceAddr); -void mfxstm32l152_TS_DisableIT(uint16_t DeviceAddr); -uint8_t mfxstm32l152_TS_ITStatus (uint16_t DeviceAddr); -void mfxstm32l152_TS_ClearIT (uint16_t DeviceAddr); - -/** - * @brief MFXSTM32L152 IDD current measurement functionalities functions - */ -void mfxstm32l152_IDD_Start(uint16_t DeviceAddr); -void mfxstm32l152_IDD_Config(uint16_t DeviceAddr, IDD_ConfigTypeDef MfxIddConfig); -void mfxstm32l152_IDD_ConfigShuntNbLimit(uint16_t DeviceAddr, uint8_t ShuntNbLimit); -void mfxstm32l152_IDD_GetValue(uint16_t DeviceAddr, uint32_t *ReadValue); -uint8_t mfxstm32l152_IDD_GetShuntUsed(uint16_t DeviceAddr); -void mfxstm32l152_IDD_EnableIT(uint16_t DeviceAddr); -void mfxstm32l152_IDD_ClearIT(uint16_t DeviceAddr); -uint8_t mfxstm32l152_IDD_GetITStatus(uint16_t DeviceAddr); -void mfxstm32l152_IDD_DisableIT(uint16_t DeviceAddr); - -/** - * @brief MFXSTM32L152 Error management functions - */ -uint8_t mfxstm32l152_Error_ReadSrc(uint16_t DeviceAddr); -uint8_t mfxstm32l152_Error_ReadMsg(uint16_t DeviceAddr); -void mfxstm32l152_Error_EnableIT(uint16_t DeviceAddr); -void mfxstm32l152_Error_ClearIT(uint16_t DeviceAddr); -uint8_t mfxstm32l152_Error_GetITStatus(uint16_t DeviceAddr); -void mfxstm32l152_Error_DisableIT(uint16_t DeviceAddr); - -uint8_t mfxstm32l152_ReadReg(uint16_t DeviceAddr, uint8_t RegAddr); -void mfxstm32l152_WriteReg(uint16_t DeviceAddr, uint8_t RegAddr, uint8_t Value); - - - -/** - * @brief iobus prototypes (they should be defined in common/stm32_iobus.h) - */ -void MFX_IO_Init(void); -void MFX_IO_DeInit(void); -void MFX_IO_ITConfig (void); -void MFX_IO_EnableWakeupPin(void); -void MFX_IO_Wakeup(void); -void MFX_IO_Delay(uint32_t delay); -void MFX_IO_Write(uint16_t addr, uint8_t reg, uint8_t value); -uint8_t MFX_IO_Read(uint16_t addr, uint8_t reg); -uint16_t MFX_IO_ReadMultiple(uint16_t addr, uint8_t reg, uint8_t *buffer, uint16_t length); - -/** - * @} - */ - -/* Touch screen driver structure */ -extern TS_DrvTypeDef mfxstm32l152_ts_drv; - -/* IO driver structure */ -extern IO_DrvTypeDef mfxstm32l152_io_drv; - -/* IDD driver structure */ -extern IDD_DrvTypeDef mfxstm32l152_idd_drv; - - -#ifdef __cplusplus -} -#endif -#endif /* __MFXSTM32L152_H */ - - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/n25q128a/Release_Notes.html b/bsp/stm32f411RE/Libraries/BSP/Components/n25q128a/Release_Notes.html deleted file mode 100644 index 566b62194a..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/n25q128a/Release_Notes.html +++ /dev/null @@ -1,157 +0,0 @@ - - - - - - - - - - - - - - - - Release Notes for STM32 BSP Components Drivers - - - - - - - - - - -
-


-

-
- - - - - - -
- - - - - - - - - -
-

Back to Release page

-
-

Release -Notes for N25Q128A Component Driver

-

Copyright -2015 STMicroelectronics

-

-
-

 

- - - - - - -

Update History


V1.0.0 -/ 29-May-2015

-

Main -Changes

- - - - - - - - - -
  • First official -release of N25Q128A QuadSPI Flash Component driver

License

-Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met:
-
-
  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions -in binary form must reproduce the above copyright notice, this list of -conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of STMicroelectronics nor the names of its contributors may be used to endorse or promote products derived
    -
    -
-        from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- -
-

- - -
-
-
For -complete documentation on STM32 Microcontrollers -visit www.st.com/STM32
-
-

-
-
-

 

-
- - \ No newline at end of file diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/n25q128a/n25q128a.h b/bsp/stm32f411RE/Libraries/BSP/Components/n25q128a/n25q128a.h deleted file mode 100644 index cd0253b8a4..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/n25q128a/n25q128a.h +++ /dev/null @@ -1,219 +0,0 @@ -/** - ****************************************************************************** - * @file n25q128a.h - * @author MCD Application Team - * @version V1.0.0 - * @date 29-May-2015 - * @brief This file contains all the description of the N25Q128A QSPI memory. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __N25Q128A_H -#define __N25Q128A_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup Components - * @{ - */ - -/** @addtogroup n25q128a - * @{ - */ - -/** @defgroup N25Q128A_Exported_Types - * @{ - */ - -/** - * @} - */ - -/** @defgroup N25Q128A_Exported_Constants - * @{ - */ - -/** - * @brief N25Q128A Configuration - */ -#define N25Q128A_FLASH_SIZE 0x1000000 /* 128 MBits => 16MBytes */ -#define N25Q128A_SECTOR_SIZE 0x10000 /* 256 sectors of 64KBytes */ -#define N25Q128A_SUBSECTOR_SIZE 0x1000 /* 4096 subsectors of 4kBytes */ -#define N25Q128A_PAGE_SIZE 0x100 /* 65536 pages of 256 bytes */ - -#define N25Q128A_DUMMY_CYCLES_READ 8 -#define N25Q128A_DUMMY_CYCLES_READ_QUAD 10 - -#define N25Q128A_BULK_ERASE_MAX_TIME 250000 -#define N25Q128A_SECTOR_ERASE_MAX_TIME 3000 -#define N25Q128A_SUBSECTOR_ERASE_MAX_TIME 800 - -/** - * @brief N25Q128A Commands - */ -/* Reset Operations */ -#define RESET_ENABLE_CMD 0x66 -#define RESET_MEMORY_CMD 0x99 - -/* Identification Operations */ -#define READ_ID_CMD 0x9E -#define READ_ID_CMD2 0x9F -#define MULTIPLE_IO_READ_ID_CMD 0xAF -#define READ_SERIAL_FLASH_DISCO_PARAM_CMD 0x5A - -/* Read Operations */ -#define READ_CMD 0x03 -#define FAST_READ_CMD 0x0B -#define DUAL_OUT_FAST_READ_CMD 0x3B -#define DUAL_INOUT_FAST_READ_CMD 0xBB -#define QUAD_OUT_FAST_READ_CMD 0x6B -#define QUAD_INOUT_FAST_READ_CMD 0xEB - -/* Write Operations */ -#define WRITE_ENABLE_CMD 0x06 -#define WRITE_DISABLE_CMD 0x04 - -/* Register Operations */ -#define READ_STATUS_REG_CMD 0x05 -#define WRITE_STATUS_REG_CMD 0x01 - -#define READ_LOCK_REG_CMD 0xE8 -#define WRITE_LOCK_REG_CMD 0xE5 - -#define READ_FLAG_STATUS_REG_CMD 0x70 -#define CLEAR_FLAG_STATUS_REG_CMD 0x50 - -#define READ_NONVOL_CFG_REG_CMD 0xB5 -#define WRITE_NONVOL_CFG_REG_CMD 0xB1 - -#define READ_VOL_CFG_REG_CMD 0x85 -#define WRITE_VOL_CFG_REG_CMD 0x81 - -#define READ_ENHANCED_VOL_CFG_REG_CMD 0x65 -#define WRITE_ENHANCED_VOL_CFG_REG_CMD 0x61 - -/* Program Operations */ -#define PAGE_PROG_CMD 0x02 -#define DUAL_IN_FAST_PROG_CMD 0xA2 -#define EXT_DUAL_IN_FAST_PROG_CMD 0xD2 -#define QUAD_IN_FAST_PROG_CMD 0x32 -#define EXT_QUAD_IN_FAST_PROG_CMD 0x12 - -/* Erase Operations */ -#define SUBSECTOR_ERASE_CMD 0x20 -#define SECTOR_ERASE_CMD 0xD8 -#define BULK_ERASE_CMD 0xC7 - -#define PROG_ERASE_RESUME_CMD 0x7A -#define PROG_ERASE_SUSPEND_CMD 0x75 - -/* One-Time Programmable Operations */ -#define READ_OTP_ARRAY_CMD 0x4B -#define PROG_OTP_ARRAY_CMD 0x42 - -/** - * @brief N25Q128A Registers - */ -/* Status Register */ -#define N25Q128A_SR_WIP ((uint8_t)0x01) /*!< Write in progress */ -#define N25Q128A_SR_WREN ((uint8_t)0x02) /*!< Write enable latch */ -#define N25Q128A_SR_BLOCKPR ((uint8_t)0x5C) /*!< Block protected against program and erase operations */ -#define N25Q128A_SR_PRBOTTOM ((uint8_t)0x20) /*!< Protected memory area defined by BLOCKPR starts from top or bottom */ -#define N25Q128A_SR_SRWREN ((uint8_t)0x80) /*!< Status register write enable/disable */ - -/* Nonvolatile Configuration Register */ -#define N25Q128A_NVCR_LOCK ((uint16_t)0x0001) /*!< Lock nonvolatile configuration register */ -#define N25Q128A_NVCR_DUAL ((uint16_t)0x0004) /*!< Dual I/O protocol */ -#define N25Q128A_NVCR_QUAB ((uint16_t)0x0008) /*!< Quad I/O protocol */ -#define N25Q128A_NVCR_RH ((uint16_t)0x0010) /*!< Reset/hold */ -#define N25Q128A_NVCR_ODS ((uint16_t)0x01C0) /*!< Output driver strength */ -#define N25Q128A_NVCR_XIP ((uint16_t)0x0E00) /*!< XIP mode at power-on reset */ -#define N25Q128A_NVCR_NB_DUMMY ((uint16_t)0xF000) /*!< Number of dummy clock cycles */ - -/* Volatile Configuration Register */ -#define N25Q128A_VCR_WRAP ((uint8_t)0x03) /*!< Wrap */ -#define N25Q128A_VCR_XIP ((uint8_t)0x08) /*!< XIP */ -#define N25Q128A_VCR_NB_DUMMY ((uint8_t)0xF0) /*!< Number of dummy clock cycles */ - -/* Enhanced Volatile Configuration Register */ -#define N25Q128A_EVCR_ODS ((uint8_t)0x07) /*!< Output driver strength */ -#define N25Q128A_EVCR_VPPA ((uint8_t)0x08) /*!< Vpp accelerator */ -#define N25Q128A_EVCR_RH ((uint8_t)0x10) /*!< Reset/hold */ -#define N25Q128A_EVCR_DUAL ((uint8_t)0x40) /*!< Dual I/O protocol */ -#define N25Q128A_EVCR_QUAD ((uint8_t)0x80) /*!< Quad I/O protocol */ - -/* Flag Status Register */ -#define N25Q128A_FSR_PRERR ((uint8_t)0x02) /*!< Protection error */ -#define N25Q128A_FSR_PGSUS ((uint8_t)0x04) /*!< Program operation suspended */ -#define N25Q128A_FSR_VPPERR ((uint8_t)0x08) /*!< Invalid voltage during program or erase */ -#define N25Q128A_FSR_PGERR ((uint8_t)0x10) /*!< Program error */ -#define N25Q128A_FSR_ERERR ((uint8_t)0x20) /*!< Erase error */ -#define N25Q128A_FSR_ERSUS ((uint8_t)0x40) /*!< Erase operation suspended */ -#define N25Q128A_FSR_READY ((uint8_t)0x80) /*!< Ready or command in progress */ - -/** - * @} - */ - -/** @defgroup N25Q128A_Exported_Functions - * @{ - */ -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __N25Q128A_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/n25q256a/Release_Notes.html b/bsp/stm32f411RE/Libraries/BSP/Components/n25q256a/Release_Notes.html deleted file mode 100644 index d8d5b2ad9d..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/n25q256a/Release_Notes.html +++ /dev/null @@ -1,157 +0,0 @@ - - - - - - - - - - - - - - - - Release Notes for STM32 BSP N25Q256A Components Drivers - - - - - - - - - - -
-


-

-
- - - - - - -
- - - - - - - - - -
-

Back to Release page

-
-

Release -Notes for N25Q256A Component Driver

-

Copyright -2015 STMicroelectronics

-

-
-

 

- - - - - - -

Update History

V1.0.0 -/ 02-March-2015

-

Main -Changes

- - - - - - - - - -
  • First official -release

License

-Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met:
-
-
  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions -in binary form must reproduce the above copyright notice, this list of -conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of STMicroelectronics nor the names of its contributors may be used to endorse or promote products derived
    -
    -
-        from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- -
-

- - -
-
-
For -complete documentation on STM32 Microcontrollers -visit www.st.com/STM32
-
-

-
-
-

 

-
- - \ No newline at end of file diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/n25q256a/n25q256a.h b/bsp/stm32f411RE/Libraries/BSP/Components/n25q256a/n25q256a.h deleted file mode 100644 index a46770f081..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/n25q256a/n25q256a.h +++ /dev/null @@ -1,261 +0,0 @@ -/** - ****************************************************************************** - * @file n25q256a.h - * @author MCD Application Team - * @version V1.0.0 - * @date 02-March-2015 - * @brief This file contains all the description of the N25Q256A QSPI memory. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __N25Q256A_H -#define __N25Q256A_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup Components - * @{ - */ - -/** @addtogroup n25q256a - * @{ - */ - -/** @defgroup N25Q256A_Exported_Types - * @{ - */ - -/** - * @} - */ - -/** @defgroup N25Q256A_Exported_Constants - * @{ - */ - -/** - * @brief N25Q256A Configuration - */ -#define N25Q256A_FLASH_SIZE 0x2000000 /* 256 MBits => 32MBytes */ -#define N25Q256A_SECTOR_SIZE 0x10000 /* 512 sectors of 64KBytes */ -#define N25Q256A_SUBSECTOR_SIZE 0x1000 /* 8192 subsectors of 4kBytes */ -#define N25Q256A_PAGE_SIZE 0x100 /* 131072 pages of 256 bytes */ - -#define N25Q256A_DUMMY_CYCLES_READ 8 -#define N25Q256A_DUMMY_CYCLES_READ_QUAD 10 -#define N25Q256A_DUMMY_CYCLES_READ_DTR 6 -#define N25Q256A_DUMMY_CYCLES_READ_QUAD_DTR 8 - -#define N25Q256A_BULK_ERASE_MAX_TIME 480000 -#define N25Q256A_SECTOR_ERASE_MAX_TIME 3000 -#define N25Q256A_SUBSECTOR_ERASE_MAX_TIME 800 - -/** - * @brief N25Q256A Commands - */ -/* Reset Operations */ -#define RESET_ENABLE_CMD 0x66 -#define RESET_MEMORY_CMD 0x99 - -/* Identification Operations */ -#define READ_ID_CMD 0x9E -#define READ_ID_CMD2 0x9F -#define MULTIPLE_IO_READ_ID_CMD 0xAF -#define READ_SERIAL_FLASH_DISCO_PARAM_CMD 0x5A - -/* Read Operations */ -#define READ_CMD 0x03 -#define READ_4_BYTE_ADDR_CMD 0x13 - -#define FAST_READ_CMD 0x0B -#define FAST_READ_DTR_CMD 0x0D -#define FAST_READ_4_BYTE_ADDR_CMD 0x0C - -#define DUAL_OUT_FAST_READ_CMD 0x3B -#define DUAL_OUT_FAST_READ_DTR_CMD 0x3D -#define DUAL_OUT_FAST_READ_4_BYTE_ADDR_CMD 0x3C - -#define DUAL_INOUT_FAST_READ_CMD 0xBB -#define DUAL_INOUT_FAST_READ_DTR_CMD 0xBD -#define DUAL_INOUT_FAST_READ_4_BYTE_ADDR_CMD 0xBC - -#define QUAD_OUT_FAST_READ_CMD 0x6B -#define QUAD_OUT_FAST_READ_DTR_CMD 0x6D -#define QUAD_OUT_FAST_READ_4_BYTE_ADDR_CMD 0x6C - -#define QUAD_INOUT_FAST_READ_CMD 0xEB -#define QUAD_INOUT_FAST_READ_DTR_CMD 0xED -#define QUAD_INOUT_FAST_READ_4_BYTE_ADDR_CMD 0xEC - -/* Write Operations */ -#define WRITE_ENABLE_CMD 0x06 -#define WRITE_DISABLE_CMD 0x04 - -/* Register Operations */ -#define READ_STATUS_REG_CMD 0x05 -#define WRITE_STATUS_REG_CMD 0x01 - -#define READ_LOCK_REG_CMD 0xE8 -#define WRITE_LOCK_REG_CMD 0xE5 - -#define READ_FLAG_STATUS_REG_CMD 0x70 -#define CLEAR_FLAG_STATUS_REG_CMD 0x50 - -#define READ_NONVOL_CFG_REG_CMD 0xB5 -#define WRITE_NONVOL_CFG_REG_CMD 0xB1 - -#define READ_VOL_CFG_REG_CMD 0x85 -#define WRITE_VOL_CFG_REG_CMD 0x81 - -#define READ_ENHANCED_VOL_CFG_REG_CMD 0x65 -#define WRITE_ENHANCED_VOL_CFG_REG_CMD 0x61 - -#define READ_EXT_ADDR_REG_CMD 0xC8 -#define WRITE_EXT_ADDR_REG_CMD 0xC5 - -/* Program Operations */ -#define PAGE_PROG_CMD 0x02 -#define PAGE_PROG_4_BYTE_ADDR_CMD 0x12 - -#define DUAL_IN_FAST_PROG_CMD 0xA2 -#define EXT_DUAL_IN_FAST_PROG_CMD 0xD2 - -#define QUAD_IN_FAST_PROG_CMD 0x32 -#define EXT_QUAD_IN_FAST_PROG_CMD 0x12 /*0x38*/ -#define QUAD_IN_FAST_PROG_4_BYTE_ADDR_CMD 0x34 - -/* Erase Operations */ -#define SUBSECTOR_ERASE_CMD 0x20 -#define SUBSECTOR_ERASE_4_BYTE_ADDR_CMD 0x21 - -#define SECTOR_ERASE_CMD 0xD8 -#define SECTOR_ERASE_4_BYTE_ADDR_CMD 0xDC - -#define BULK_ERASE_CMD 0xC7 - -#define PROG_ERASE_RESUME_CMD 0x7A -#define PROG_ERASE_SUSPEND_CMD 0x75 - -/* One-Time Programmable Operations */ -#define READ_OTP_ARRAY_CMD 0x4B -#define PROG_OTP_ARRAY_CMD 0x42 - -/* 4-byte Address Mode Operations */ -#define ENTER_4_BYTE_ADDR_MODE_CMD 0xB7 -#define EXIT_4_BYTE_ADDR_MODE_CMD 0xE9 - -/* Quad Operations */ -#define ENTER_QUAD_CMD 0x35 -#define EXIT_QUAD_CMD 0xF5 - -/** - * @brief N25Q256A Registers - */ -/* Status Register */ -#define N25Q256A_SR_WIP ((uint8_t)0x01) /*!< Write in progress */ -#define N25Q256A_SR_WREN ((uint8_t)0x02) /*!< Write enable latch */ -#define N25Q256A_SR_BLOCKPR ((uint8_t)0x5C) /*!< Block protected against program and erase operations */ -#define N25Q256A_SR_PRBOTTOM ((uint8_t)0x20) /*!< Protected memory area defined by BLOCKPR starts from top or bottom */ -#define N25Q256A_SR_SRWREN ((uint8_t)0x80) /*!< Status register write enable/disable */ - -/* Nonvolatile Configuration Register */ -#define N25Q256A_NVCR_NBADDR ((uint16_t)0x0001) /*!< 3-bytes or 4-bytes addressing */ -#define N25Q256A_NVCR_SEGMENT ((uint16_t)0x0002) /*!< Upper or lower 128Mb segment selected by default */ -#define N25Q256A_NVCR_DUAL ((uint16_t)0x0004) /*!< Dual I/O protocol */ -#define N25Q256A_NVCR_QUAB ((uint16_t)0x0008) /*!< Quad I/O protocol */ -#define N25Q256A_NVCR_RH ((uint16_t)0x0010) /*!< Reset/hold */ -#define N25Q256A_NVCR_ODS ((uint16_t)0x01C0) /*!< Output driver strength */ -#define N25Q256A_NVCR_XIP ((uint16_t)0x0E00) /*!< XIP mode at power-on reset */ -#define N25Q256A_NVCR_NB_DUMMY ((uint16_t)0xF000) /*!< Number of dummy clock cycles */ - -/* Volatile Configuration Register */ -#define N25Q256A_VCR_WRAP ((uint8_t)0x03) /*!< Wrap */ -#define N25Q256A_VCR_XIP ((uint8_t)0x08) /*!< XIP */ -#define N25Q256A_VCR_NB_DUMMY ((uint8_t)0xF0) /*!< Number of dummy clock cycles */ - -/* Extended Address Register */ -#define N25Q256A_EAR_A24 ((uint8_t)0x01) /*!< Select the lower or upper 128Mb segment */ - -/* Enhanced Volatile Configuration Register */ -#define N25Q256A_EVCR_ODS ((uint8_t)0x07) /*!< Output driver strength */ -#define N25Q256A_EVCR_VPPA ((uint8_t)0x08) /*!< Vpp accelerator */ -#define N25Q256A_EVCR_RH ((uint8_t)0x10) /*!< Reset/hold */ -#define N25Q256A_EVCR_DUAL ((uint8_t)0x40) /*!< Dual I/O protocol */ -#define N25Q256A_EVCR_QUAD ((uint8_t)0x80) /*!< Quad I/O protocol */ - -/* Flag Status Register */ -#define N25Q256A_FSR_NBADDR ((uint8_t)0x01) /*!< 3-bytes or 4-bytes addressing */ -#define N25Q256A_FSR_PRERR ((uint8_t)0x02) /*!< Protection error */ -#define N25Q256A_FSR_PGSUS ((uint8_t)0x04) /*!< Program operation suspended */ -#define N25Q256A_FSR_VPPERR ((uint8_t)0x08) /*!< Invalid voltage during program or erase */ -#define N25Q256A_FSR_PGERR ((uint8_t)0x10) /*!< Program error */ -#define N25Q256A_FSR_ERERR ((uint8_t)0x20) /*!< Erase error */ -#define N25Q256A_FSR_ERSUS ((uint8_t)0x40) /*!< Erase operation suspended */ -#define N25Q256A_FSR_READY ((uint8_t)0x80) /*!< Ready or command in progress */ - -/** - * @} - */ - -/** @defgroup N25Q256A_Exported_Functions - * @{ - */ -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __N25Q256A_H */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/n25q512a/Release_Notes.html b/bsp/stm32f411RE/Libraries/BSP/Components/n25q512a/Release_Notes.html deleted file mode 100644 index 9b441ea1e7..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/n25q512a/Release_Notes.html +++ /dev/null @@ -1,158 +0,0 @@ - - - - - - - - - - - - - - - - - Release Notes for STM32 BSP Components Drivers - - - - - - - - - -
-


-

-
- - - - - - -
- - - - - - - - - -
-

Back to Release page

-
-

Release -Notes for N25Q512A Component Driver

-

Copyright -2015 STMicroelectronics

-

-
-

 

- - - - - - -

Update History

V1.0.0 -/ 28-April-2015

-

Main -Changes

- - - - - - - - - -
  • First official -release

License

-Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met:
-
-
  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions -in binary form must reproduce the above copyright notice, this list of -conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of STMicroelectronics nor the names of its contributors may be used to endorse or promote products derived
    -
    -
-        from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- -
-

- - -
-
-
For -complete documentation on STM32 Microcontrollers -visit www.st.com/STM32
-

-
-

-
-
-

 

-
- - \ No newline at end of file diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/n25q512a/n25q512a.h b/bsp/stm32f411RE/Libraries/BSP/Components/n25q512a/n25q512a.h deleted file mode 100644 index 4494679ec2..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/n25q512a/n25q512a.h +++ /dev/null @@ -1,261 +0,0 @@ -/** - ****************************************************************************** - * @file n25q512a.h - * @author MCD Application Team - * @version V1.0.0 - * @date 28-April-2015 - * @brief This file contains all the description of the N25Q512A QSPI memory. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __N25Q512A_H -#define __N25Q512A_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup Components - * @{ - */ - -/** @addtogroup n25q512a - * @{ - */ - -/** @defgroup N25Q512A_Exported_Types - * @{ - */ - -/** - * @} - */ - -/** @defgroup N25Q512A_Exported_Constants - * @{ - */ - -/** - * @brief N25Q512A Configuration - */ -#define N25Q512A_FLASH_SIZE 0x4000000 /* 512 MBits => 64MBytes */ -#define N25Q512A_SECTOR_SIZE 0x10000 /* 1024 sectors of 64KBytes */ -#define N25Q512A_SUBSECTOR_SIZE 0x1000 /* 16384 subsectors of 4kBytes */ -#define N25Q512A_PAGE_SIZE 0x100 /* 262144 pages of 256 bytes */ - -#define N25Q512A_DUMMY_CYCLES_READ 8 -#define N25Q512A_DUMMY_CYCLES_READ_QUAD 10 -#define N25Q512A_DUMMY_CYCLES_READ_DTR 6 -#define N25Q512A_DUMMY_CYCLES_READ_QUAD_DTR 8 - -#define N25Q512A_BULK_ERASE_MAX_TIME 480000 -#define N25Q512A_SECTOR_ERASE_MAX_TIME 3000 -#define N25Q512A_SUBSECTOR_ERASE_MAX_TIME 800 - -/** - * @brief N25Q512A Commands - */ -/* Reset Operations */ -#define RESET_ENABLE_CMD 0x66 -#define RESET_MEMORY_CMD 0x99 - -/* Identification Operations */ -#define READ_ID_CMD 0x9E -#define READ_ID_CMD2 0x9F -#define MULTIPLE_IO_READ_ID_CMD 0xAF -#define READ_SERIAL_FLASH_DISCO_PARAM_CMD 0x5A - -/* Read Operations */ -#define READ_CMD 0x03 -#define READ_4_BYTE_ADDR_CMD 0x13 - -#define FAST_READ_CMD 0x0B -#define FAST_READ_DTR_CMD 0x0D -#define FAST_READ_4_BYTE_ADDR_CMD 0x0C - -#define DUAL_OUT_FAST_READ_CMD 0x3B -#define DUAL_OUT_FAST_READ_DTR_CMD 0x3D -#define DUAL_OUT_FAST_READ_4_BYTE_ADDR_CMD 0x3C - -#define DUAL_INOUT_FAST_READ_CMD 0xBB -#define DUAL_INOUT_FAST_READ_DTR_CMD 0xBD -#define DUAL_INOUT_FAST_READ_4_BYTE_ADDR_CMD 0xBC - -#define QUAD_OUT_FAST_READ_CMD 0x6B -#define QUAD_OUT_FAST_READ_DTR_CMD 0x6D -#define QUAD_OUT_FAST_READ_4_BYTE_ADDR_CMD 0x6C - -#define QUAD_INOUT_FAST_READ_CMD 0xEB -#define QUAD_INOUT_FAST_READ_DTR_CMD 0xED -#define QUAD_INOUT_FAST_READ_4_BYTE_ADDR_CMD 0xEC - -/* Write Operations */ -#define WRITE_ENABLE_CMD 0x06 -#define WRITE_DISABLE_CMD 0x04 - -/* Register Operations */ -#define READ_STATUS_REG_CMD 0x05 -#define WRITE_STATUS_REG_CMD 0x01 - -#define READ_LOCK_REG_CMD 0xE8 -#define WRITE_LOCK_REG_CMD 0xE5 - -#define READ_FLAG_STATUS_REG_CMD 0x70 -#define CLEAR_FLAG_STATUS_REG_CMD 0x50 - -#define READ_NONVOL_CFG_REG_CMD 0xB5 -#define WRITE_NONVOL_CFG_REG_CMD 0xB1 - -#define READ_VOL_CFG_REG_CMD 0x85 -#define WRITE_VOL_CFG_REG_CMD 0x81 - -#define READ_ENHANCED_VOL_CFG_REG_CMD 0x65 -#define WRITE_ENHANCED_VOL_CFG_REG_CMD 0x61 - -#define READ_EXT_ADDR_REG_CMD 0xC8 -#define WRITE_EXT_ADDR_REG_CMD 0xC5 - -/* Program Operations */ -#define PAGE_PROG_CMD 0x02 -#define PAGE_PROG_4_BYTE_ADDR_CMD 0x12 - -#define DUAL_IN_FAST_PROG_CMD 0xA2 -#define EXT_DUAL_IN_FAST_PROG_CMD 0xD2 - -#define QUAD_IN_FAST_PROG_CMD 0x32 -#define EXT_QUAD_IN_FAST_PROG_CMD 0x12 /*0x38*/ -#define QUAD_IN_FAST_PROG_4_BYTE_ADDR_CMD 0x34 - -/* Erase Operations */ -#define SUBSECTOR_ERASE_CMD 0x20 -#define SUBSECTOR_ERASE_4_BYTE_ADDR_CMD 0x21 - -#define SECTOR_ERASE_CMD 0xD8 -#define SECTOR_ERASE_4_BYTE_ADDR_CMD 0xDC - -#define BULK_ERASE_CMD 0xC7 - -#define PROG_ERASE_RESUME_CMD 0x7A -#define PROG_ERASE_SUSPEND_CMD 0x75 - -/* One-Time Programmable Operations */ -#define READ_OTP_ARRAY_CMD 0x4B -#define PROG_OTP_ARRAY_CMD 0x42 - -/* 4-byte Address Mode Operations */ -#define ENTER_4_BYTE_ADDR_MODE_CMD 0xB7 -#define EXIT_4_BYTE_ADDR_MODE_CMD 0xE9 - -/* Quad Operations */ -#define ENTER_QUAD_CMD 0x35 -#define EXIT_QUAD_CMD 0xF5 - -/** - * @brief N25Q512A Registers - */ -/* Status Register */ -#define N25Q512A_SR_WIP ((uint8_t)0x01) /*!< Write in progress */ -#define N25Q512A_SR_WREN ((uint8_t)0x02) /*!< Write enable latch */ -#define N25Q512A_SR_BLOCKPR ((uint8_t)0x5C) /*!< Block protected against program and erase operations */ -#define N25Q512A_SR_PRBOTTOM ((uint8_t)0x20) /*!< Protected memory area defined by BLOCKPR starts from top or bottom */ -#define N25Q512A_SR_SRWREN ((uint8_t)0x80) /*!< Status register write enable/disable */ - -/* Non volatile Configuration Register */ -#define N25Q512A_NVCR_NBADDR ((uint16_t)0x0001) /*!< 3-bytes or 4-bytes addressing */ -#define N25Q512A_NVCR_SEGMENT ((uint16_t)0x0002) /*!< Upper or lower 128Mb segment selected by default */ -#define N25Q512A_NVCR_DUAL ((uint16_t)0x0004) /*!< Dual I/O protocol */ -#define N25Q512A_NVCR_QUAB ((uint16_t)0x0008) /*!< Quad I/O protocol */ -#define N25Q512A_NVCR_RH ((uint16_t)0x0010) /*!< Reset/hold */ -#define N25Q512A_NVCR_ODS ((uint16_t)0x01C0) /*!< Output driver strength */ -#define N25Q512A_NVCR_XIP ((uint16_t)0x0E00) /*!< XIP mode at power-on reset */ -#define N25Q512A_NVCR_NB_DUMMY ((uint16_t)0xF000) /*!< Number of dummy clock cycles */ - -/* Volatile Configuration Register */ -#define N25Q512A_VCR_WRAP ((uint8_t)0x03) /*!< Wrap */ -#define N25Q512A_VCR_XIP ((uint8_t)0x08) /*!< XIP */ -#define N25Q512A_VCR_NB_DUMMY ((uint8_t)0xF0) /*!< Number of dummy clock cycles */ - -/* Extended Address Register */ -#define N25Q512A_EAR_A24 ((uint8_t)0x01) /*!< Select the lower or upper 128Mb segment */ - -/* Enhanced Volatile Configuration Register */ -#define N25Q512A_EVCR_ODS ((uint8_t)0x07) /*!< Output driver strength */ -#define N25Q512A_EVCR_VPPA ((uint8_t)0x08) /*!< Vpp accelerator */ -#define N25Q512A_EVCR_RH ((uint8_t)0x10) /*!< Reset/hold */ -#define N25Q512A_EVCR_DUAL ((uint8_t)0x40) /*!< Dual I/O protocol */ -#define N25Q512A_EVCR_QUAD ((uint8_t)0x80) /*!< Quad I/O protocol */ - -/* Flag Status Register */ -#define N25Q512A_FSR_NBADDR ((uint8_t)0x01) /*!< 3-bytes or 4-bytes addressing */ -#define N25Q512A_FSR_PRERR ((uint8_t)0x02) /*!< Protection error */ -#define N25Q512A_FSR_PGSUS ((uint8_t)0x04) /*!< Program operation suspended */ -#define N25Q512A_FSR_VPPERR ((uint8_t)0x08) /*!< Invalid voltage during program or erase */ -#define N25Q512A_FSR_PGERR ((uint8_t)0x10) /*!< Program error */ -#define N25Q512A_FSR_ERERR ((uint8_t)0x20) /*!< Erase error */ -#define N25Q512A_FSR_ERSUS ((uint8_t)0x40) /*!< Erase operation suspended */ -#define N25Q512A_FSR_READY ((uint8_t)0x80) /*!< Ready or command in progress */ - -/** - * @} - */ - -/** @defgroup N25Q512A_Exported_Functions - * @{ - */ -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __N25Q512A_H */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/otm8009a/Release_Notes.html b/bsp/stm32f411RE/Libraries/BSP/Components/otm8009a/Release_Notes.html deleted file mode 100644 index 528b921ccd..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/otm8009a/Release_Notes.html +++ /dev/null @@ -1,156 +0,0 @@ - - - - - - - - - - - - - - - - Release Notes for OTM8009A BSP Components Drivers - - - - - - - - - - -
-


-

-
- - - - - - -
- - - - - - - - - -
-

Back to Release page

-
-

Release -Notes for OTM8009A Component Driver

-

Copyright -2015 STMicroelectronics

-

-
-

 

- - - - - - -

Update History

V1.0.0 -/ 03-August-2015

-

Main -Changes

- - - - - - - - - -
  • First official release

License

-Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met:
-
-
  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions -in binary form must reproduce the above copyright notice, this list of -conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of STMicroelectronics nor the names of its contributors may be used to endorse or promote products derived
    -
    -
-        from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- -
-

- - -
-
-
For -complete documentation on STM32 Microcontrollers -visit www.st.com/STM32
-
-

-
-
-

 

-
- - \ No newline at end of file diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/otm8009a/otm8009a.c b/bsp/stm32f411RE/Libraries/BSP/Components/otm8009a/otm8009a.c deleted file mode 100644 index ad5c88504f..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/otm8009a/otm8009a.c +++ /dev/null @@ -1,449 +0,0 @@ -/** - ****************************************************************************** - * @file otm8009a.c - * @author MCD Application Team - * @version V1.0.0 - * @date 03-August-2015 - * @brief This file provides the LCD Driver for KoD KM-040TMP-02-0621 (WVGA) - * DSI LCD Display OTM8009A. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Includes ------------------------------------------------------------------*/ -#include "otm8009a.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup Components - * @{ - */ - -/** @defgroup OTM8009A OTM8009A - * @brief This file provides a set of functions needed to drive the - * otm8009a IC display driver. - * @{ - */ - -/* Private types -------------------------------------------------------------*/ -/* Private variables ---------------------------------------------------------*/ -/* Private constants ---------------------------------------------------------*/ -/** @defgroup OTM8009A_Private_Constants OTM8009A Private Constants - * @{ - */ - -/* - * @brief Constant tables of register settings used to transmit DSI - * command packets as power up initialization sequence of the KoD LCD (OTM8009A LCD Driver) - */ -const uint8_t lcdRegData1[] = {0x80,0x09,0x01,0xFF}; -const uint8_t lcdRegData2[] = {0x80,0x09,0xFF}; -const uint8_t lcdRegData3[] = {0x00,0x09,0x0F,0x0E,0x07,0x10,0x0B,0x0A,0x04,0x07,0x0B,0x08,0x0F,0x10,0x0A,0x01,0xE1}; -const uint8_t lcdRegData4[] = {0x00,0x09,0x0F,0x0E,0x07,0x10,0x0B,0x0A,0x04,0x07,0x0B,0x08,0x0F,0x10,0x0A,0x01,0xE2}; -const uint8_t lcdRegData5[] = {0x79,0x79,0xD8}; -const uint8_t lcdRegData6[] = {0x00,0x01,0xB3}; -const uint8_t lcdRegData7[] = {0x85,0x01,0x00,0x84,0x01,0x00,0xCE}; -const uint8_t lcdRegData8[] = {0x18,0x04,0x03,0x39,0x00,0x00,0x00,0x18,0x03,0x03,0x3A,0x00,0x00,0x00,0xCE}; -const uint8_t lcdRegData9[] = {0x18,0x02,0x03,0x3B,0x00,0x00,0x00,0x18,0x01,0x03,0x3C,0x00,0x00,0x00,0xCE}; -const uint8_t lcdRegData10[] = {0x01,0x01,0x20,0x20,0x00,0x00,0x01,0x02,0x00,0x00,0xCF}; -const uint8_t lcdRegData11[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xCB}; -const uint8_t lcdRegData12[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xCB}; -const uint8_t lcdRegData13[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xCB}; -const uint8_t lcdRegData14[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xCB}; -const uint8_t lcdRegData15[] = {0x00,0x04,0x04,0x04,0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xCB}; -const uint8_t lcdRegData16[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x04,0x04,0x04,0x00,0x00,0x00,0x00,0xCB}; -const uint8_t lcdRegData17[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xCB}; -const uint8_t lcdRegData18[] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xCB}; -const uint8_t lcdRegData19[] = {0x00,0x26,0x09,0x0B,0x01,0x25,0x00,0x00,0x00,0x00,0xCC}; -const uint8_t lcdRegData20[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x26,0x0A,0x0C,0x02,0xCC}; -const uint8_t lcdRegData21[] = {0x25,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xCC}; -const uint8_t lcdRegData22[] = {0x00,0x25,0x0C,0x0A,0x02,0x26,0x00,0x00,0x00,0x00,0xCC}; -const uint8_t lcdRegData23[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x25,0x0B,0x09,0x01,0xCC}; -const uint8_t lcdRegData24[] = {0x26,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xCC}; -const uint8_t lcdRegData25[] = {0xFF,0xFF,0xFF,0xFF}; -/* - * CASET value (Column Address Set) : X direction LCD GRAM boundaries - * depending on LCD orientation mode and PASET value (Page Address Set) : Y direction - * LCD GRAM boundaries depending on LCD orientation mode - * XS[15:0] = 0x000 = 0, XE[15:0] = 0x31F = 799 for landscape mode : apply to CASET - * YS[15:0] = 0x000 = 0, YE[15:0] = 0x31F = 799 for portrait mode : : apply to PASET - */ -const uint8_t lcdRegData27[] = {0x00, 0x00, 0x03, 0x1F, OTM8009A_CMD_CASET}; -/* - * XS[15:0] = 0x000 = 0, XE[15:0] = 0x1DF = 479 for portrait mode : apply to CASET - * YS[15:0] = 0x000 = 0, YE[15:0] = 0x1DF = 479 for landscape mode : apply to PASET - */ -const uint8_t lcdRegData28[] = {0x00, 0x00, 0x01, 0xDF, OTM8009A_CMD_PASET}; - - -const uint8_t ShortRegData1[] = {OTM8009A_CMD_NOP, 0x00}; -const uint8_t ShortRegData2[] = {OTM8009A_CMD_NOP, 0x80}; -const uint8_t ShortRegData3[] = {0xC4, 0x30}; -const uint8_t ShortRegData4[] = {OTM8009A_CMD_NOP, 0x8A}; -const uint8_t ShortRegData5[] = {0xC4, 0x40}; -const uint8_t ShortRegData6[] = {OTM8009A_CMD_NOP, 0xB1}; -const uint8_t ShortRegData7[] = {0xC5, 0xA9}; -const uint8_t ShortRegData8[] = {OTM8009A_CMD_NOP, 0x91}; -const uint8_t ShortRegData9[] = {0xC5, 0x34}; -const uint8_t ShortRegData10[] = {OTM8009A_CMD_NOP, 0xB4}; -const uint8_t ShortRegData11[] = {0xC0, 0x50}; -const uint8_t ShortRegData12[] = {0xD9, 0x4E}; -const uint8_t ShortRegData13[] = {OTM8009A_CMD_NOP, 0x81}; -const uint8_t ShortRegData14[] = {0xC1, 0x66}; -const uint8_t ShortRegData15[] = {OTM8009A_CMD_NOP, 0xA1}; -const uint8_t ShortRegData16[] = {0xC1, 0x08}; -const uint8_t ShortRegData17[] = {OTM8009A_CMD_NOP, 0x92}; -const uint8_t ShortRegData18[] = {0xC5, 0x01}; -const uint8_t ShortRegData19[] = {OTM8009A_CMD_NOP, 0x95}; -const uint8_t ShortRegData20[] = {OTM8009A_CMD_NOP, 0x94}; -const uint8_t ShortRegData21[] = {0xC5, 0x33}; -const uint8_t ShortRegData22[] = {OTM8009A_CMD_NOP, 0xA3}; -const uint8_t ShortRegData23[] = {0xC0, 0x1B}; -const uint8_t ShortRegData24[] = {OTM8009A_CMD_NOP, 0x82}; -const uint8_t ShortRegData25[] = {0xC5, 0x83}; -const uint8_t ShortRegData26[] = {0xC4, 0x83}; -const uint8_t ShortRegData27[] = {0xC1, 0x0E}; -const uint8_t ShortRegData28[] = {OTM8009A_CMD_NOP, 0xA6}; -const uint8_t ShortRegData29[] = {OTM8009A_CMD_NOP, 0xA0}; -const uint8_t ShortRegData30[] = {OTM8009A_CMD_NOP, 0xB0}; -const uint8_t ShortRegData31[] = {OTM8009A_CMD_NOP, 0xC0}; -const uint8_t ShortRegData32[] = {OTM8009A_CMD_NOP, 0xD0}; -const uint8_t ShortRegData33[] = {OTM8009A_CMD_NOP, 0x90}; -const uint8_t ShortRegData34[] = {OTM8009A_CMD_NOP, 0xE0}; -const uint8_t ShortRegData35[] = {OTM8009A_CMD_NOP, 0xF0}; -const uint8_t ShortRegData36[] = {OTM8009A_CMD_SLPOUT, 0x00}; -const uint8_t ShortRegData37[] = {OTM8009A_CMD_COLMOD, OTM8009A_COLMOD_RGB565}; -const uint8_t ShortRegData38[] = {OTM8009A_CMD_COLMOD, OTM8009A_COLMOD_RGB888}; -const uint8_t ShortRegData39[] = {OTM8009A_CMD_MADCTR, OTM8009A_MADCTR_MODE_LANDSCAPE}; -const uint8_t ShortRegData40[] = {OTM8009A_CMD_WRDISBV, 0x7F}; -const uint8_t ShortRegData41[] = {OTM8009A_CMD_WRCTRLD, 0x2C}; -const uint8_t ShortRegData42[] = {OTM8009A_CMD_WRCABC, 0x02}; -const uint8_t ShortRegData43[] = {OTM8009A_CMD_WRCABCMB, 0xFF}; -const uint8_t ShortRegData44[] = {OTM8009A_CMD_DISPON, 0x00}; -const uint8_t ShortRegData45[] = {OTM8009A_CMD_RAMWR, 0x00}; -const uint8_t ShortRegData46[] = {0xCF, 0x00}; -const uint8_t ShortRegData47[] = {0xC5, 0x66}; -const uint8_t ShortRegData48[] = {OTM8009A_CMD_NOP, 0xB6}; -const uint8_t ShortRegData49[] = {0xF5, 0x06}; - -/** - * @} - */ - -/* Private macros ------------------------------------------------------------*/ -/* Private functions ---------------------------------------------------------*/ -/** @defgroup OTM8009A_Exported_Variables - * @{ - */ - -/** - * @} - */ - -/* Exported functions ---------------------------------------------------------*/ -/** @defgroup OTM8009A_Exported_Functions OTM8009A Exported Functions - * @{ - */ - -/** - * @brief DSI IO write short/long command. - * @note : Can be surcharged by application code implementation of the function. - */ -__weak void DSI_IO_WriteCmd(uint32_t NbrParams, uint8_t *pParams) -{ - /* NOTE : This function Should not be modified, when it is needed, - the DSI_IO_WriteCmd could be implemented in the user file - */ -} - -/** - * @brief Initializes the LCD KoD display part by communication in DSI mode in Video Mode - * with IC Display Driver OTM8009A (see IC Driver specification for more information). - * @param hdsi_eval : pointer on DSI configuration structure - * @param hdsivideo_handle : pointer on DSI video mode configuration structure - * @retval Status - */ -uint8_t OTM8009A_Init(uint32_t ColorCoding, uint32_t orientation) -{ - /* Enable CMD2 to access vendor specific commands */ - /* Enter in command 2 mode and set EXTC to enable address shift function (0x00) */ - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData1); - DSI_IO_WriteCmd( 3, (uint8_t *)lcdRegData1); - - /* Enter ORISE Command 2 */ - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData2); /* Shift address to 0x80 */ - DSI_IO_WriteCmd( 2, (uint8_t *)lcdRegData2); - - ///////////////////////////////////////////////////////////////////// - /* SD_PCH_CTRL - 0xC480h - 129th parameter - Default 0x00 */ - /* Set SD_PT */ - /* -> Source output level during porch and non-display area to GND */ - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData2); - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData3); - OTM8009A_IO_Delay(10); - /* Not documented */ - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData4); - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData5); - OTM8009A_IO_Delay(10); - ///////////////////////////////////////////////////////////////////// - - /* PWR_CTRL4 - 0xC4B0h - 178th parameter - Default 0xA8 */ - /* Set gvdd_en_test */ - /* -> enable GVDD test mode !!! */ - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData6); - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData7); - - /* PWR_CTRL2 - 0xC590h - 146th parameter - Default 0x79 */ - /* Set pump 4 vgh voltage */ - /* -> from 15.0v down to 13.0v */ - /* Set pump 5 vgh voltage */ - /* -> from -12.0v downto -9.0v */ - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData8); - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData9); - - /* P_DRV_M - 0xC0B4h - 181th parameter - Default 0x00 */ - /* -> Column inversion */ - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData10); - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData11); - - /* VCOMDC - 0xD900h - 1st parameter - Default 0x39h */ - /* VCOM Voltage settings */ - /* -> from -1.0000v downto -1.2625v */ - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData1); - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData12); - - /* Oscillator adjustment for Idle/Normal mode (LPDT only) set to 65Hz (default is 60Hz) */ - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData13); - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData14); - - /* Video mode internal */ - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData15); - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData16); - - /* PWR_CTRL2 - 0xC590h - 147h parameter - Default 0x00 */ - /* Set pump 4&5 x6 */ - /* -> ONLY VALID when PUMP4_EN_ASDM_HV = "0" */ - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData17); - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData18); - - /* PWR_CTRL2 - 0xC590h - 150th parameter - Default 0x33h */ - /* Change pump4 clock ratio */ - /* -> from 1 line to 1/2 line */ - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData19); - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData9); - - /* GVDD/NGVDD settings */ - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData1); - DSI_IO_WriteCmd( 2, (uint8_t *)lcdRegData5); - - /* PWR_CTRL2 - 0xC590h - 149th parameter - Default 0x33h */ - /* Rewrite the default value ! */ - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData20); - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData21); - - /* Panel display timing Setting 3 */ - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData22); - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData23); - - /* Power control 1 */ - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData24); - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData25); - - /* Source driver precharge */ - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData13); - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData26); - - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData15); - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData27); - - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData28); - DSI_IO_WriteCmd( 2, (uint8_t *)lcdRegData6); - - /* GOAVST */ - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData2); - DSI_IO_WriteCmd( 6, (uint8_t *)lcdRegData7); - - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData29); - DSI_IO_WriteCmd( 14, (uint8_t *)lcdRegData8); - - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData30); - DSI_IO_WriteCmd( 14, (uint8_t *)lcdRegData9); - - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData31); - DSI_IO_WriteCmd( 10, (uint8_t *)lcdRegData10); - - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData32); - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData46); - - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData2); - DSI_IO_WriteCmd( 10, (uint8_t *)lcdRegData11); - - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData33); - DSI_IO_WriteCmd( 15, (uint8_t *)lcdRegData12); - - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData29); - DSI_IO_WriteCmd( 15, (uint8_t *)lcdRegData13); - - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData30); - DSI_IO_WriteCmd( 10, (uint8_t *)lcdRegData14); - - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData31); - DSI_IO_WriteCmd( 15, (uint8_t *)lcdRegData15); - - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData32); - DSI_IO_WriteCmd( 15, (uint8_t *)lcdRegData16); - - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData34); - DSI_IO_WriteCmd( 10, (uint8_t *)lcdRegData17); - - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData35); - DSI_IO_WriteCmd( 10, (uint8_t *)lcdRegData18); - - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData2); - DSI_IO_WriteCmd( 10, (uint8_t *)lcdRegData19); - - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData33); - DSI_IO_WriteCmd( 15, (uint8_t *)lcdRegData20); - - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData29); - DSI_IO_WriteCmd( 15, (uint8_t *)lcdRegData21); - - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData30); - DSI_IO_WriteCmd( 10, (uint8_t *)lcdRegData22); - - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData31); - DSI_IO_WriteCmd( 15, (uint8_t *)lcdRegData23); - - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData32); - DSI_IO_WriteCmd( 15, (uint8_t *)lcdRegData24); - - ///////////////////////////////////////////////////////////////////////////// - /* PWR_CTRL1 - 0xc580h - 130th parameter - default 0x00 */ - /* Pump 1 min and max DM */ - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData13); - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData47); - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData48); - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData49); - ///////////////////////////////////////////////////////////////////////////// - - /* Exit CMD2 mode */ - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData1); - DSI_IO_WriteCmd( 3, (uint8_t *)lcdRegData25); - - /*************************************************************************** */ - /* Standard DCS Initialization TO KEEP CAN BE DONE IN HSDT */ - /*************************************************************************** */ - - /* NOP - goes back to DCS std command ? */ - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData1); - - /* Gamma correction 2.2+ table (HSDT possible) */ - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData1); - DSI_IO_WriteCmd( 16, (uint8_t *)lcdRegData3); - - /* Gamma correction 2.2- table (HSDT possible) */ - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData1); - DSI_IO_WriteCmd( 16, (uint8_t *)lcdRegData4); - - /* Send Sleep Out command to display : no parameter */ - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData36); - - /* Wait for sleep out exit */ - OTM8009A_IO_Delay(120); - - switch(ColorCoding) - { - case OTM8009A_FORMAT_RBG565 : - /* Set Pixel color format to RGB565 */ - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData37); - break; - case OTM8009A_FORMAT_RGB888 : - /* Set Pixel color format to RGB888 */ - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData38); - break; - default : - break; - } - - /* Send command to configure display in landscape orientation mode. By default - the orientation mode is portrait */ - if(orientation == OTM8009A_ORIENTATION_LANDSCAPE) - { - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData39); - DSI_IO_WriteCmd( 4, (uint8_t *)lcdRegData27); - DSI_IO_WriteCmd( 4, (uint8_t *)lcdRegData28); - } - - /** CABC : Content Adaptive Backlight Control section start >> */ - /* Note : defaut is 0 (lowest Brightness), 0xFF is highest Brightness, try 0x7F : intermediate value */ - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData40); - - /* defaut is 0, try 0x2C - Brightness Control Block, Display Dimming & BackLight on */ - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData41); - - /* defaut is 0, try 0x02 - image Content based Adaptive Brightness [Still Picture] */ - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData42); - - /* defaut is 0 (lowest Brightness), 0xFF is highest Brightness */ - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData43); - - /** CABC : Content Adaptive Backlight Control section end << */ - - /* Send Command Display On */ - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData44); - - /* NOP command */ - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData1); - - /* Send Command GRAM memory write (no parameters) : this initiates frame write via other DSI commands sent by */ - /* DSI host from LTDC incoming pixels in video mode */ - DSI_IO_WriteCmd(0, (uint8_t *)ShortRegData45); - - return 0; -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/otm8009a/otm8009a.h b/bsp/stm32f411RE/Libraries/BSP/Components/otm8009a/otm8009a.h deleted file mode 100644 index 94b9e78000..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/otm8009a/otm8009a.h +++ /dev/null @@ -1,224 +0,0 @@ -/** - ****************************************************************************** - * @file otm8009a.h - * @author MCD Application Team - * @version V1.0.0 - * @date 03-August-2015 - * @brief This file contains all the constants parameters for the OTM8009A - * which is the LCD Driver for KoD KM-040TMP-02-0621 (WVGA) - * DSI LCD Display. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __OTM8009A_H -#define __OTM8009A_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup Components - * @{ - */ - -/** @addtogroup otm8009a - * @{ - */ - -/** @addtogroup OTM8009A_Exported_Variables - * @{ - */ - -#if defined ( __GNUC__ ) -#ifndef __weak -#define __weak __attribute__((weak)) -#endif /* __weak */ -#endif /* __GNUC__ */ - -/** - * @brief LCD_OrientationTypeDef - * Possible values of Display Orientation - */ -#define OTM8009A_ORIENTATION_PORTRAIT ((uint32_t)0x00) /* Portrait orientation choice of LCD screen */ -#define OTM8009A_ORIENTATION_LANDSCAPE ((uint32_t)0x01) /* Landscape orientation choice of LCD screen */ - -/** - * @brief Possible values of - * pixel data format (ie color coding) transmitted on DSI Data lane in DSI packets - */ -#define OTM8009A_FORMAT_RGB888 ((uint32_t)0x00) /* Pixel format chosen is RGB888 : 24 bpp */ -#define OTM8009A_FORMAT_RBG565 ((uint32_t)0x02) /* Pixel format chosen is RGB565 : 16 bpp */ - -/** - * @brief otm8009a_480x800 Size - */ - -/* Width and Height in Portrait mode */ -#define OTM8009A_480X800_WIDTH ((uint16_t)480) /* LCD PIXEL WIDTH */ -#define OTM8009A_480X800_HEIGHT ((uint16_t)800) /* LCD PIXEL HEIGHT */ - -/* Width and Height in Landscape mode */ -#define OTM8009A_800X480_WIDTH ((uint16_t)800) /* LCD PIXEL WIDTH */ -#define OTM8009A_800X480_HEIGHT ((uint16_t)480) /* LCD PIXEL HEIGHT */ - -/** - * @brief OTM8009A_480X800 Timing parameters for Portrait orientation mode - */ -#define OTM8009A_480X800_HSYNC ((uint16_t)120) /* Horizontal synchronization */ -#define OTM8009A_480X800_HBP ((uint16_t)120) /* Horizontal back porch */ -#define OTM8009A_480X800_HFP ((uint16_t)120) /* Horizontal front porch */ -#define OTM8009A_480X800_VSYNC ((uint16_t)12) /* Vertical synchronization */ -#define OTM8009A_480X800_VBP ((uint16_t)12) /* Vertical back porch */ -#define OTM8009A_480X800_VFP ((uint16_t)12) /* Vertical front porch */ - -/** - * @brief OTM8009A_800X480 Timing parameters for Landscape orientation mode - * Same values as for Portrait mode in fact. - */ -#define OTM8009A_800X480_HSYNC OTM8009A_480X800_HSYNC /* Horizontal synchronization */ -#define OTM8009A_800X480_HBP OTM8009A_480X800_HBP /* Horizontal back porch */ -#define OTM8009A_800X480_HFP OTM8009A_480X800_HFP /* Horizontal front porch */ -#define OTM8009A_800X480_VSYNC OTM8009A_480X800_VSYNC /* Vertical synchronization */ -#define OTM8009A_800X480_VBP OTM8009A_480X800_VBP /* Vertical back porch */ -#define OTM8009A_800X480_VFP OTM8009A_480X800_VFP /* Vertical front porch */ - - -/* List of OTM8009A used commands */ -/* Detailed in OTM8009A Data Sheet 'DATA_SHEET_OTM8009A_V0 92.pdf' */ -/* Version of 14 June 2012 */ -#define OTM8009A_CMD_NOP 0x00 /* NOP command */ -#define OTM8009A_CMD_SWRESET 0x01 /* Sw reset command */ -#define OTM8009A_CMD_RDDMADCTL 0x0B /* Read Display MADCTR command : read memory display access ctrl */ -#define OTM8009A_CMD_RDDCOLMOD 0x0C /* Read Display pixel format */ -#define OTM8009A_CMD_SLPIN 0x10 /* Sleep In command */ -#define OTM8009A_CMD_SLPOUT 0x11 /* Sleep Out command */ -#define OTM8009A_CMD_PTLON 0x12 /* Partial mode On command */ - -#define OTM8009A_CMD_DISPOFF 0x28 /* Display Off command */ -#define OTM8009A_CMD_DISPON 0x29 /* Display On command */ - -#define OTM8009A_CMD_CASET 0x2A /* Column address set command */ -#define OTM8009A_CMD_PASET 0x2B /* Page address set command */ - -#define OTM8009A_CMD_RAMWR 0x2C /* Memory (GRAM) write command */ -#define OTM8009A_CMD_RAMRD 0x2E /* Memory (GRAM) read command */ - -#define OTM8009A_CMD_PLTAR 0x30 /* Partial area command (4 parameters) */ - -#define OTM8009A_CMD_TEOFF 0x34 /* Tearing Effect Line Off command : command with no parameter */ - -#define OTM8009A_CMD_TEEON 0x35 /* Tearing Effect Line On command : command with 1 parameter 'TELOM' */ - -/* Parameter TELOM : Tearing Effect Line Output Mode : possible values */ -#define OTM8009A_TEEON_TELOM_VBLANKING_INFO_ONLY 0x00 -#define OTM8009A_TEEON_TELOM_VBLANKING_AND_HBLANKING_INFO 0x01 - -#define OTM8009A_CMD_MADCTR 0x36 /* Memory Access write control command */ - -/* Possible used values of MADCTR */ -#define OTM8009A_MADCTR_MODE_PORTRAIT 0x00 -#define OTM8009A_MADCTR_MODE_LANDSCAPE 0x60 /* MY = 0, MX = 1, MV = 1, ML = 0, RGB = 0 */ - -#define OTM8009A_CMD_IDMOFF 0x38 /* Idle mode Off command */ -#define OTM8009A_CMD_IDMON 0x39 /* Idle mode On command */ - -#define OTM8009A_CMD_COLMOD 0x3A /* Interface Pixel format command */ - -/* Possible values of COLMOD parameter corresponding to used pixel formats */ -#define OTM8009A_COLMOD_RGB565 0x55 -#define OTM8009A_COLMOD_RGB888 0x77 - -#define OTM8009A_CMD_RAMWRC 0x3C /* Memory write continue command */ -#define OTM8009A_CMD_RAMRDC 0x3E /* Memory read continue command */ - -#define OTM8009A_CMD_WRTESCN 0x44 /* Write Tearing Effect Scan line command */ -#define OTM8009A_CMD_RDSCNL 0x45 /* Read Tearing Effect Scan line command */ - -/* CABC Management : ie : Content Adaptive Back light Control in IC OTM8009a */ -#define OTM8009A_CMD_WRDISBV 0x51 /* Write Display Brightness command */ -#define OTM8009A_CMD_WRCTRLD 0x53 /* Write CTRL Display command */ -#define OTM8009A_CMD_WRCABC 0x55 /* Write Content Adaptive Brightness command */ -#define OTM8009A_CMD_WRCABCMB 0x5E /* Write CABC Minimum Brightness command */ - -/** - * @brief OTM8009A_480X800 frequency divider - */ -#define OTM8009A_480X800_FREQUENCY_DIVIDER 2 /* LCD Frequency divider */ - -/** - * @} - */ - -/* Exported macro ------------------------------------------------------------*/ - -/** @defgroup OTM8009A_Exported_Macros OTM8009A Exported Macros - * @{ - */ - -/** - * @} - */ - -/* Exported functions --------------------------------------------------------*/ - -/** @addtogroup OTM8009A_Exported_Functions - * @{ - */ -void DSI_IO_WriteCmd(uint32_t NbrParams, uint8_t *pParams); -uint8_t OTM8009A_Init(uint32_t ColorCoding, uint32_t orientation); -void OTM8009A_IO_Delay(uint32_t Delay); -/** - * @} - */ -#ifdef __cplusplus -} -#endif - -#endif /* __OTM8009A_480X800_H */ -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/ov2640/Release_Notes.html b/bsp/stm32f411RE/Libraries/BSP/Components/ov2640/Release_Notes.html deleted file mode 100644 index 49b7c8fdc8..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/ov2640/Release_Notes.html +++ /dev/null @@ -1,426 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - Release Notes for OV2640 Component Driver - - - - - - - - - -
-


-

-
- - - - - - -
- - - - - - - - - -
-

Back to Release page

-
-

Release -Notes for OV2640 Component Driver

-

Copyright -2014 STMicroelectronics

-

-
-

 

- - - - - - -
- - -

Update History

-

V1.0.2 / 02-December-2014

- - - - - - - - - - - - - - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- - - - - - - - - -
    -
  • ov2640.h: change "\" by "/" in the include path to fix compilation issue under Linux
  • -
- -

V1.0.1 / 19-June-2014

- - - - - - - - - - - - - - - - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- - - - - - - - - -

- - - - - - - - - - - - - -
    -
  • Align driver -with the STM32Cube BSP architecture by removing check for -initialization in ov2640_Init() and  ov2640_ReadID() functions
  • -
  • Comments clean up and typo corrections
  • -
- -

V1.0.0 / 18-February-2014

- - - - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- - - - - - -
    -
  • First official release
  • -

License

-
-Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met:
-
-
  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions -in binary form must reproduce the above copyright notice, this list of -conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of STMicroelectronics nor the names of its contributors may be used to endorse or promote products derived
    -
    -
-        from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- -
-

- - -
-
-

For -complete documentation on STM32 Microcontrollers -visit www.st.com/STM32

-
-

-
-
-

 

-
- - \ No newline at end of file diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/ov2640/ov2640.c b/bsp/stm32f411RE/Libraries/BSP/Components/ov2640/ov2640.c deleted file mode 100644 index e8e40febb0..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/ov2640/ov2640.c +++ /dev/null @@ -1,1351 +0,0 @@ -/** - ****************************************************************************** - * @file ov2640.c - * @author MCD Application Team - * @version V1.0.2 - * @date 02-December-2014 - * @brief This file provides the OV2640 camera driver - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2014 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Includes ------------------------------------------------------------------*/ -#include "ov2640.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup Components - * @{ - */ - -/** @addtogroup OV2640 - * @brief This file provides a set of functions needed to drive the - * OV2640 Camera module. - * @{ - */ - -/** @defgroup OV2640_Private_TypesDefinitions - * @{ - */ - -/** - * @} - */ - -/** @defgroup OV2640_Private_Defines - * @{ - */ - -/** - * @} - */ - -/** @defgroup OV2640_Private_Macros - * @{ - */ - -/** - * @} - */ - -/** @defgroup OV2640_Private_FunctionPrototypes - * @{ - */ -static uint32_t ov2640_ConvertValue(uint32_t feature, uint32_t value); -/** - * @} - */ - -/** @defgroup OV2640_Private_Variables - * @{ - */ - -CAMERA_DrvTypeDef ov2640_drv = -{ - ov2640_Init, - ov2640_ReadID, - ov2640_Config, -}; - -/* Initialization sequence for 480x272 resolution */ -const unsigned char OV2640_480x272[][2]= -{ - {0xff, 0x00}, /* Device control register list Table 12 */ - {0x2c, 0xff}, /* Reserved */ - {0x2e, 0xdf}, /* Reserved */ - {0xff, 0x01}, /* Device control register list Table 13 */ - {0x3c, 0x32}, /* Reserved */ - {0x11, 0x00}, /* Clock Rate Control */ - {0x09, 0x02}, /* Common control 2 */ - {0x04, 0xA8}, /* Mirror */ - {0x13, 0xe5}, /* Common control 8 */ - {0x14, 0x48}, /* Common control 9 */ - {0x2c, 0x0c}, /* Reserved */ - {0x33, 0x78}, /* Reserved */ - {0x3a, 0x33}, /* Reserved */ - {0x3b, 0xfB}, /* Reserved */ - {0x3e, 0x00}, /* Reserved */ - {0x43, 0x11}, /* Reserved */ - {0x16, 0x10}, /* Reserved */ - {0x4a, 0x81}, /* Reserved */ - {0x21, 0x99}, /* Reserved */ - {0x24, 0x40}, /* Luminance signal High range */ - {0x25, 0x38}, /* Luminance signal low range */ - {0x26, 0x82}, /* */ - {0x5c, 0x00}, /* Reserved */ - {0x63, 0x00}, /* Reserved */ - {0x46, 0x3f}, /* Frame length adjustment */ - {0x0c, 0x3c}, /* Common control 3 */ - {0x61, 0x70}, /* Histogram algo low level */ - {0x62, 0x80}, /* Histogram algo high level */ - {0x7c, 0x05}, /* Reserved */ - {0x20, 0x80}, /* Reserved */ - {0x28, 0x30}, /* Reserved */ - {0x6c, 0x00}, /* Reserved */ - {0x6d, 0x80}, /* Reserved */ - {0x6e, 0x00}, /* Reserved */ - {0x70, 0x02}, /* Reserved */ - {0x71, 0x94}, /* Reserved */ - {0x73, 0xc1}, /* Reserved */ - {0x3d, 0x34}, /* Reserved */ - {0x5a, 0x57}, /* Reserved */ - {0x12, 0x00}, /* Common control 7 */ - {0x11, 0x00}, /* Clock Rate Control 2*/ - {0x17, 0x11}, /* Horiz window start MSB 8bits */ - {0x18, 0x75}, /* Horiz window end MSB 8bits */ - {0x19, 0x01}, /* Vert window line start MSB 8bits */ - {0x1a, 0x97}, /* Vert window line end MSB 8bits */ - {0x32, 0x36}, - {0x03, 0x0f}, - {0x37, 0x40}, - {0x4f, 0xbb}, - {0x50, 0x9c}, - {0x5a, 0x57}, - {0x6d, 0x80}, - {0x6d, 0x38}, - {0x39, 0x02}, - {0x35, 0x88}, - {0x22, 0x0a}, - {0x37, 0x40}, - {0x23, 0x00}, - {0x34, 0xa0}, - {0x36, 0x1a}, - {0x06, 0x02}, - {0x07, 0xc0}, - {0x0d, 0xb7}, - {0x0e, 0x01}, - {0x4c, 0x00}, - {0xff, 0x00}, - {0xe5, 0x7f}, - {0xf9, 0xc0}, - {0x41, 0x24}, - {0xe0, 0x14}, - {0x76, 0xff}, - {0x33, 0xa0}, - {0x42, 0x20}, - {0x43, 0x18}, - {0x4c, 0x00}, - {0x87, 0xd0}, - {0x88, 0x3f}, - {0xd7, 0x03}, - {0xd9, 0x10}, - {0xd3, 0x82}, - {0xc8, 0x08}, - {0xc9, 0x80}, - {0x7d, 0x00}, - {0x7c, 0x03}, - {0x7d, 0x48}, - {0x7c, 0x08}, - {0x7d, 0x20}, - {0x7d, 0x10}, - {0x7d, 0x0e}, - {0x90, 0x00}, - {0x91, 0x0e}, - {0x91, 0x1a}, - {0x91, 0x31}, - {0x91, 0x5a}, - {0x91, 0x69}, - {0x91, 0x75}, - {0x91, 0x7e}, - {0x91, 0x88}, - {0x91, 0x8f}, - {0x91, 0x96}, - {0x91, 0xa3}, - {0x91, 0xaf}, - {0x91, 0xc4}, - {0x91, 0xd7}, - {0x91, 0xe8}, - {0x91, 0x20}, - {0x92, 0x00}, - {0x93, 0x06}, - {0x93, 0xe3}, - {0x93, 0x02}, - {0x93, 0x02}, - {0x93, 0x00}, - {0x93, 0x04}, - {0x93, 0x00}, - {0x93, 0x03}, - {0x93, 0x00}, - {0x93, 0x00}, - {0x93, 0x00}, - {0x93, 0x00}, - {0x93, 0x00}, - {0x93, 0x00}, - {0x93, 0x00}, - {0x96, 0x00}, - {0x97, 0x08}, - {0x97, 0x19}, - {0x97, 0x02}, - {0x97, 0x0c}, - {0x97, 0x24}, - {0x97, 0x30}, - {0x97, 0x28}, - {0x97, 0x26}, - {0x97, 0x02}, - {0x97, 0x98}, - {0x97, 0x80}, - {0x97, 0x00}, - {0x97, 0x00}, - {0xc3, 0xef}, - {0xff, 0x00}, - {0xba, 0xdc}, - {0xbb, 0x08}, - {0xb6, 0x24}, - {0xb8, 0x33}, - {0xb7, 0x20}, - {0xb9, 0x30}, - {0xb3, 0xb4}, - {0xb4, 0xca}, - {0xb5, 0x43}, - {0xb0, 0x5c}, - {0xb1, 0x4f}, - {0xb2, 0x06}, - {0xc7, 0x00}, - {0xc6, 0x51}, - {0xc5, 0x11}, - {0xc4, 0x9c}, - {0xbf, 0x00}, - {0xbc, 0x64}, - {0xa6, 0x00}, - {0xa7, 0x1e}, - {0xa7, 0x6b}, - {0xa7, 0x47}, - {0xa7, 0x33}, - {0xa7, 0x00}, - {0xa7, 0x23}, - {0xa7, 0x2e}, - {0xa7, 0x85}, - {0xa7, 0x42}, - {0xa7, 0x33}, - {0xa7, 0x00}, - {0xa7, 0x23}, - {0xa7, 0x1b}, - {0xa7, 0x74}, - {0xa7, 0x42}, - {0xa7, 0x33}, - {0xa7, 0x00}, - {0xa7, 0x23}, - {0xc0, 0xc8}, - {0xc1, 0x96}, - {0x8c, 0x00}, - {0x86, 0x3d}, - {0x50, 0x92}, - {0x51, 0x90}, - {0x52, 0x2c}, - {0x53, 0x00}, - {0x54, 0x00}, - {0x55, 0x88}, - {0x5a, 0x50}, - {0x5b, 0x3c}, - {0x5c, 0x00}, - {0xd3, 0x04}, - {0x7f, 0x00}, - {0xda, 0x00}, - {0xe5, 0x1f}, - {0xe1, 0x67}, - {0xe0, 0x00}, - {0xdd, 0x7f}, - {0x05, 0x00}, - {0xff, 0x00}, - {0xe0, 0x04}, - {0xc0, 0xc8}, - {0xc1, 0x96}, - {0x86, 0x3d}, - {0x50, 0x92}, - {0x51, 0x90}, - {0x52, 0x2c}, - {0x53, 0x00}, - {0x54, 0x00}, - {0x55, 0x88}, - {0x57, 0x00}, - {0x5a, 0x50}, - {0x5b, 0x3c}, - {0x5c, 0x00}, - {0xd3, 0x04}, - {0xe0, 0x00}, - {0xFF, 0x00}, - {0x05, 0x00}, - {0xDA, 0x08}, - {0xda, 0x09}, - {0x98, 0x00}, - {0x99, 0x00}, - {0x00, 0x00}, - {0xff, 0x00}, - {0xe0, 0x04}, - {0xc0, 0xc8}, - {0xc1, 0x96}, - {0x86, 0x35}, - {0x50, 0x80}, - {0x51, 0x90}, - {0x52, 0x2c}, - {0x53, 0x00}, - {0x54, 0x00}, - {0x55, 0x88}, - {0x57, 0x00}, - {0x5a, 0x78}, - {0x5b, 0x44}, - {0x5c, 0x00}, - {0xd3, 0x04}, - {0xe0, 0x00}, -}; - -/* Initialization sequence for VGA resolution (640x480)*/ -const unsigned char OV2640_VGA[][2]= -{ - {0xff, 0x00}, /* Device control register list Table 12 */ - {0x2c, 0xff}, /* Reserved */ - {0x2e, 0xdf}, /* Reserved */ - {0xff, 0x01}, /* Device control register list Table 13 */ - {0x3c, 0x32}, /* Reserved */ - {0x11, 0x00}, /* Clock Rate Control */ - {0x09, 0x02}, /* Common control 2 */ - {0x04, 0xA8}, /* Mirror */ - {0x13, 0xe5}, /* Common control 8 */ - {0x14, 0x48}, /* Common control 9 */ - {0x2c, 0x0c}, /* Reserved */ - {0x33, 0x78}, /* Reserved */ - {0x3a, 0x33}, /* Reserved */ - {0x3b, 0xfB}, /* Reserved */ - {0x3e, 0x00}, /* Reserved */ - {0x43, 0x11}, /* Reserved */ - {0x16, 0x10}, /* Reserved */ - {0x4a, 0x81}, /* Reserved */ - {0x21, 0x99}, /* Reserved */ - {0x24, 0x40}, /* Luminance signal High range */ - {0x25, 0x38}, /* Luminance signal low range */ - {0x26, 0x82}, /* */ - {0x5c, 0x00}, /* Reserved */ - {0x63, 0x00}, /* Reserved */ - {0x46, 0x3f}, /* Frame length adjustment */ - {0x0c, 0x3c}, /* Common control 3 */ - {0x61, 0x70}, /* Histogram algo low level */ - {0x62, 0x80}, /* Histogram algo high level */ - {0x7c, 0x05}, /* Reserved */ - {0x20, 0x80}, /* Reserved */ - {0x28, 0x30}, /* Reserved */ - {0x6c, 0x00}, /* Reserved */ - {0x6d, 0x80}, /* Reserved */ - {0x6e, 0x00}, /* Reserved */ - {0x70, 0x02}, /* Reserved */ - {0x71, 0x94}, /* Reserved */ - {0x73, 0xc1}, /* Reserved */ - {0x3d, 0x34}, /* Reserved */ - {0x5a, 0x57}, /* Reserved */ - {0x12, 0x00}, /* Common control 7 */ - {0x11, 0x00}, /* Clock Rate Control 2*/ - {0x17, 0x11}, /* Horiz window start MSB 8bits */ - {0x18, 0x75}, /* Horiz window end MSB 8bits */ - {0x19, 0x01}, /* Vert window line start MSB 8bits */ - {0x1a, 0x97}, /* Vert window line end MSB 8bits */ - {0x32, 0x36}, - {0x03, 0x0f}, - {0x37, 0x40}, - {0x4f, 0xbb}, - {0x50, 0x9c}, - {0x5a, 0x57}, - {0x6d, 0x80}, - {0x6d, 0x38}, - {0x39, 0x02}, - {0x35, 0x88}, - {0x22, 0x0a}, - {0x37, 0x40}, - {0x23, 0x00}, - {0x34, 0xa0}, - {0x36, 0x1a}, - {0x06, 0x02}, - {0x07, 0xc0}, - {0x0d, 0xb7}, - {0x0e, 0x01}, - {0x4c, 0x00}, - {0xff, 0x00}, - {0xe5, 0x7f}, - {0xf9, 0xc0}, - {0x41, 0x24}, - {0xe0, 0x14}, - {0x76, 0xff}, - {0x33, 0xa0}, - {0x42, 0x20}, - {0x43, 0x18}, - {0x4c, 0x00}, - {0x87, 0xd0}, - {0x88, 0x3f}, - {0xd7, 0x03}, - {0xd9, 0x10}, - {0xd3, 0x82}, - {0xc8, 0x08}, - {0xc9, 0x80}, - {0x7d, 0x00}, - {0x7c, 0x03}, - {0x7d, 0x48}, - {0x7c, 0x08}, - {0x7d, 0x20}, - {0x7d, 0x10}, - {0x7d, 0x0e}, - {0x90, 0x00}, - {0x91, 0x0e}, - {0x91, 0x1a}, - {0x91, 0x31}, - {0x91, 0x5a}, - {0x91, 0x69}, - {0x91, 0x75}, - {0x91, 0x7e}, - {0x91, 0x88}, - {0x91, 0x8f}, - {0x91, 0x96}, - {0x91, 0xa3}, - {0x91, 0xaf}, - {0x91, 0xc4}, - {0x91, 0xd7}, - {0x91, 0xe8}, - {0x91, 0x20}, - {0x92, 0x00}, - {0x93, 0x06}, - {0x93, 0xe3}, - {0x93, 0x02}, - {0x93, 0x02}, - {0x93, 0x00}, - {0x93, 0x04}, - {0x93, 0x00}, - {0x93, 0x03}, - {0x93, 0x00}, - {0x93, 0x00}, - {0x93, 0x00}, - {0x93, 0x00}, - {0x93, 0x00}, - {0x93, 0x00}, - {0x93, 0x00}, - {0x96, 0x00}, - {0x97, 0x08}, - {0x97, 0x19}, - {0x97, 0x02}, - {0x97, 0x0c}, - {0x97, 0x24}, - {0x97, 0x30}, - {0x97, 0x28}, - {0x97, 0x26}, - {0x97, 0x02}, - {0x97, 0x98}, - {0x97, 0x80}, - {0x97, 0x00}, - {0x97, 0x00}, - {0xc3, 0xef}, - {0xff, 0x00}, - {0xba, 0xdc}, - {0xbb, 0x08}, - {0xb6, 0x24}, - {0xb8, 0x33}, - {0xb7, 0x20}, - {0xb9, 0x30}, - {0xb3, 0xb4}, - {0xb4, 0xca}, - {0xb5, 0x43}, - {0xb0, 0x5c}, - {0xb1, 0x4f}, - {0xb2, 0x06}, - {0xc7, 0x00}, - {0xc6, 0x51}, - {0xc5, 0x11}, - {0xc4, 0x9c}, - {0xbf, 0x00}, - {0xbc, 0x64}, - {0xa6, 0x00}, - {0xa7, 0x1e}, - {0xa7, 0x6b}, - {0xa7, 0x47}, - {0xa7, 0x33}, - {0xa7, 0x00}, - {0xa7, 0x23}, - {0xa7, 0x2e}, - {0xa7, 0x85}, - {0xa7, 0x42}, - {0xa7, 0x33}, - {0xa7, 0x00}, - {0xa7, 0x23}, - {0xa7, 0x1b}, - {0xa7, 0x74}, - {0xa7, 0x42}, - {0xa7, 0x33}, - {0xa7, 0x00}, - {0xa7, 0x23}, - {0xc0, 0xc8}, - {0xc1, 0x96}, - {0x8c, 0x00}, - {0x86, 0x3d}, - {0x50, 0x92}, - {0x51, 0x90}, - {0x52, 0x2c}, - {0x53, 0x00}, - {0x54, 0x00}, - {0x55, 0x88}, - {0x5a, 0x50}, - {0x5b, 0x3c}, - {0x5c, 0x00}, - {0xd3, 0x04}, - {0x7f, 0x00}, - {0xda, 0x00}, - {0xe5, 0x1f}, - {0xe1, 0x67}, - {0xe0, 0x00}, - {0xdd, 0x7f}, - {0x05, 0x00}, - {0xff, 0x00}, - {0xe0, 0x04}, - {0xc0, 0xc8}, - {0xc1, 0x96}, - {0x86, 0x3d}, - {0x50, 0x92}, - {0x51, 0x90}, - {0x52, 0x2c}, - {0x53, 0x00}, - {0x54, 0x00}, - {0x55, 0x88}, - {0x57, 0x00}, - {0x5a, 0x50}, - {0x5b, 0x3c}, - {0x5c, 0x00}, - {0xd3, 0x04}, - {0xe0, 0x00}, - {0xFF, 0x00}, - {0x05, 0x00}, - {0xDA, 0x08}, - {0xda, 0x09}, - {0x98, 0x00}, - {0x99, 0x00}, - {0x00, 0x00}, - {0xff, 0x00}, - {0xe0, 0x04}, - {0xc0, 0xc8}, - {0xc1, 0x96}, - {0x86, 0x3d}, - {0x50, 0x89}, - {0x51, 0x90}, - {0x52, 0x2c}, - {0x53, 0x00}, - {0x54, 0x00}, - {0x55, 0x88}, - {0x57, 0x00}, - {0x5a, 0xA0}, - {0x5b, 0x78}, - {0x5c, 0x00}, - {0xd3, 0x02}, - {0xe0, 0x00}, -}; - -/* Initialization sequence for QVGA resolution (320x240) */ -const unsigned char OV2640_QVGA[][2]= -{ - {0xff, 0x00}, - {0x2c, 0xff}, - {0x2e, 0xdf}, - {0xff, 0x01}, - {0x3c, 0x32}, - {0x11, 0x00}, - {0x09, 0x02}, - {0x04, 0xA8}, - {0x13, 0xe5}, - {0x14, 0x48}, - {0x2c, 0x0c}, - {0x33, 0x78}, - {0x3a, 0x33}, - {0x3b, 0xfB}, - {0x3e, 0x00}, - {0x43, 0x11}, - {0x16, 0x10}, - {0x4a, 0x81}, - {0x21, 0x99}, - {0x24, 0x40}, - {0x25, 0x38}, - {0x26, 0x82}, - {0x5c, 0x00}, - {0x63, 0x00}, - {0x46, 0x3f}, - {0x0c, 0x3c}, - {0x61, 0x70}, - {0x62, 0x80}, - {0x7c, 0x05}, - {0x20, 0x80}, - {0x28, 0x30}, - {0x6c, 0x00}, - {0x6d, 0x80}, - {0x6e, 0x00}, - {0x70, 0x02}, - {0x71, 0x94}, - {0x73, 0xc1}, - {0x3d, 0x34}, - {0x5a, 0x57}, - {0x12, 0x00}, - {0x11, 0x00}, - {0x17, 0x11}, - {0x18, 0x75}, - {0x19, 0x01}, - {0x1a, 0x97}, - {0x32, 0x36}, - {0x03, 0x0f}, - {0x37, 0x40}, - {0x4f, 0xbb}, - {0x50, 0x9c}, - {0x5a, 0x57}, - {0x6d, 0x80}, - {0x6d, 0x38}, - {0x39, 0x02}, - {0x35, 0x88}, - {0x22, 0x0a}, - {0x37, 0x40}, - {0x23, 0x00}, - {0x34, 0xa0}, - {0x36, 0x1a}, - {0x06, 0x02}, - {0x07, 0xc0}, - {0x0d, 0xb7}, - {0x0e, 0x01}, - {0x4c, 0x00}, - {0xff, 0x00}, - {0xe5, 0x7f}, - {0xf9, 0xc0}, - {0x41, 0x24}, - {0xe0, 0x14}, - {0x76, 0xff}, - {0x33, 0xa0}, - {0x42, 0x20}, - {0x43, 0x18}, - {0x4c, 0x00}, - {0x87, 0xd0}, - {0x88, 0x3f}, - {0xd7, 0x03}, - {0xd9, 0x10}, - {0xd3, 0x82}, - {0xc8, 0x08}, - {0xc9, 0x80}, - {0x7d, 0x00}, - {0x7c, 0x03}, - {0x7d, 0x48}, - {0x7c, 0x08}, - {0x7d, 0x20}, - {0x7d, 0x10}, - {0x7d, 0x0e}, - {0x90, 0x00}, - {0x91, 0x0e}, - {0x91, 0x1a}, - {0x91, 0x31}, - {0x91, 0x5a}, - {0x91, 0x69}, - {0x91, 0x75}, - {0x91, 0x7e}, - {0x91, 0x88}, - {0x91, 0x8f}, - {0x91, 0x96}, - {0x91, 0xa3}, - {0x91, 0xaf}, - {0x91, 0xc4}, - {0x91, 0xd7}, - {0x91, 0xe8}, - {0x91, 0x20}, - {0x92, 0x00}, - {0x93, 0x06}, - {0x93, 0xe3}, - {0x93, 0x02}, - {0x93, 0x02}, - {0x93, 0x00}, - {0x93, 0x04}, - {0x93, 0x00}, - {0x93, 0x03}, - {0x93, 0x00}, - {0x93, 0x00}, - {0x93, 0x00}, - {0x93, 0x00}, - {0x93, 0x00}, - {0x93, 0x00}, - {0x93, 0x00}, - {0x96, 0x00}, - {0x97, 0x08}, - {0x97, 0x19}, - {0x97, 0x02}, - {0x97, 0x0c}, - {0x97, 0x24}, - {0x97, 0x30}, - {0x97, 0x28}, - {0x97, 0x26}, - {0x97, 0x02}, - {0x97, 0x98}, - {0x97, 0x80}, - {0x97, 0x00}, - {0x97, 0x00}, - {0xc3, 0xef}, - {0xff, 0x00}, - {0xba, 0xdc}, - {0xbb, 0x08}, - {0xb6, 0x24}, - {0xb8, 0x33}, - {0xb7, 0x20}, - {0xb9, 0x30}, - {0xb3, 0xb4}, - {0xb4, 0xca}, - {0xb5, 0x43}, - {0xb0, 0x5c}, - {0xb1, 0x4f}, - {0xb2, 0x06}, - {0xc7, 0x00}, - {0xc6, 0x51}, - {0xc5, 0x11}, - {0xc4, 0x9c}, - {0xbf, 0x00}, - {0xbc, 0x64}, - {0xa6, 0x00}, - {0xa7, 0x1e}, - {0xa7, 0x6b}, - {0xa7, 0x47}, - {0xa7, 0x33}, - {0xa7, 0x00}, - {0xa7, 0x23}, - {0xa7, 0x2e}, - {0xa7, 0x85}, - {0xa7, 0x42}, - {0xa7, 0x33}, - {0xa7, 0x00}, - {0xa7, 0x23}, - {0xa7, 0x1b}, - {0xa7, 0x74}, - {0xa7, 0x42}, - {0xa7, 0x33}, - {0xa7, 0x00}, - {0xa7, 0x23}, - {0xc0, 0xc8}, - {0xc1, 0x96}, - {0x8c, 0x00}, - {0x86, 0x3d}, - {0x50, 0x92}, - {0x51, 0x90}, - {0x52, 0x2c}, - {0x53, 0x00}, - {0x54, 0x00}, - {0x55, 0x88}, - {0x5a, 0x50}, - {0x5b, 0x3c}, - {0x5c, 0x00}, - {0xd3, 0x04}, - {0x7f, 0x00}, - {0xda, 0x00}, - {0xe5, 0x1f}, - {0xe1, 0x67}, - {0xe0, 0x00}, - {0xdd, 0x7f}, - {0x05, 0x00}, - {0xff, 0x00}, - {0xe0, 0x04}, - {0xc0, 0xc8}, - {0xc1, 0x96}, - {0x86, 0x3d}, - {0x50, 0x92}, - {0x51, 0x90}, - {0x52, 0x2c}, - {0x53, 0x00}, - {0x54, 0x00}, - {0x55, 0x88}, - {0x57, 0x00}, - {0x5a, 0x50}, - {0x5b, 0x3C}, - {0x5c, 0x00}, - {0xd3, 0x08}, - {0xe0, 0x00}, - {0xFF, 0x00}, - {0x05, 0x00}, - {0xDA, 0x08}, - {0xda, 0x09}, - {0x98, 0x00}, - {0x99, 0x00}, - {0x00, 0x00}, -}; - -/* Initialization sequence for QQVGA resolution (160x120) */ -const char OV2640_QQVGA[][2]= -{ - {0xff, 0x00}, - {0x2c, 0xff}, - {0x2e, 0xdf}, - {0xff, 0x01}, - {0x3c, 0x32}, - {0x11, 0x00}, - {0x09, 0x02}, - {0x04, 0xA8}, - {0x13, 0xe5}, - {0x14, 0x48}, - {0x2c, 0x0c}, - {0x33, 0x78}, - {0x3a, 0x33}, - {0x3b, 0xfB}, - {0x3e, 0x00}, - {0x43, 0x11}, - {0x16, 0x10}, - {0x4a, 0x81}, - {0x21, 0x99}, - {0x24, 0x40}, - {0x25, 0x38}, - {0x26, 0x82}, - {0x5c, 0x00}, - {0x63, 0x00}, - {0x46, 0x3f}, - {0x0c, 0x3c}, - {0x61, 0x70}, - {0x62, 0x80}, - {0x7c, 0x05}, - {0x20, 0x80}, - {0x28, 0x30}, - {0x6c, 0x00}, - {0x6d, 0x80}, - {0x6e, 0x00}, - {0x70, 0x02}, - {0x71, 0x94}, - {0x73, 0xc1}, - {0x3d, 0x34}, - {0x5a, 0x57}, - {0x12, 0x00}, - {0x11, 0x00}, - {0x17, 0x11}, - {0x18, 0x75}, - {0x19, 0x01}, - {0x1a, 0x97}, - {0x32, 0x36}, - {0x03, 0x0f}, - {0x37, 0x40}, - {0x4f, 0xbb}, - {0x50, 0x9c}, - {0x5a, 0x57}, - {0x6d, 0x80}, - {0x6d, 0x38}, - {0x39, 0x02}, - {0x35, 0x88}, - {0x22, 0x0a}, - {0x37, 0x40}, - {0x23, 0x00}, - {0x34, 0xa0}, - {0x36, 0x1a}, - {0x06, 0x02}, - {0x07, 0xc0}, - {0x0d, 0xb7}, - {0x0e, 0x01}, - {0x4c, 0x00}, - {0xff, 0x00}, - {0xe5, 0x7f}, - {0xf9, 0xc0}, - {0x41, 0x24}, - {0xe0, 0x14}, - {0x76, 0xff}, - {0x33, 0xa0}, - {0x42, 0x20}, - {0x43, 0x18}, - {0x4c, 0x00}, - {0x87, 0xd0}, - {0x88, 0x3f}, - {0xd7, 0x03}, - {0xd9, 0x10}, - {0xd3, 0x82}, - {0xc8, 0x08}, - {0xc9, 0x80}, - {0x7d, 0x00}, - {0x7c, 0x03}, - {0x7d, 0x48}, - {0x7c, 0x08}, - {0x7d, 0x20}, - {0x7d, 0x10}, - {0x7d, 0x0e}, - {0x90, 0x00}, - {0x91, 0x0e}, - {0x91, 0x1a}, - {0x91, 0x31}, - {0x91, 0x5a}, - {0x91, 0x69}, - {0x91, 0x75}, - {0x91, 0x7e}, - {0x91, 0x88}, - {0x91, 0x8f}, - {0x91, 0x96}, - {0x91, 0xa3}, - {0x91, 0xaf}, - {0x91, 0xc4}, - {0x91, 0xd7}, - {0x91, 0xe8}, - {0x91, 0x20}, - {0x92, 0x00}, - {0x93, 0x06}, - {0x93, 0xe3}, - {0x93, 0x02}, - {0x93, 0x02}, - {0x93, 0x00}, - {0x93, 0x04}, - {0x93, 0x00}, - {0x93, 0x03}, - {0x93, 0x00}, - {0x93, 0x00}, - {0x93, 0x00}, - {0x93, 0x00}, - {0x93, 0x00}, - {0x93, 0x00}, - {0x93, 0x00}, - {0x96, 0x00}, - {0x97, 0x08}, - {0x97, 0x19}, - {0x97, 0x02}, - {0x97, 0x0c}, - {0x97, 0x24}, - {0x97, 0x30}, - {0x97, 0x28}, - {0x97, 0x26}, - {0x97, 0x02}, - {0x97, 0x98}, - {0x97, 0x80}, - {0x97, 0x00}, - {0x97, 0x00}, - {0xc3, 0xef}, - {0xff, 0x00}, - {0xba, 0xdc}, - {0xbb, 0x08}, - {0xb6, 0x24}, - {0xb8, 0x33}, - {0xb7, 0x20}, - {0xb9, 0x30}, - {0xb3, 0xb4}, - {0xb4, 0xca}, - {0xb5, 0x43}, - {0xb0, 0x5c}, - {0xb1, 0x4f}, - {0xb2, 0x06}, - {0xc7, 0x00}, - {0xc6, 0x51}, - {0xc5, 0x11}, - {0xc4, 0x9c}, - {0xbf, 0x00}, - {0xbc, 0x64}, - {0xa6, 0x00}, - {0xa7, 0x1e}, - {0xa7, 0x6b}, - {0xa7, 0x47}, - {0xa7, 0x33}, - {0xa7, 0x00}, - {0xa7, 0x23}, - {0xa7, 0x2e}, - {0xa7, 0x85}, - {0xa7, 0x42}, - {0xa7, 0x33}, - {0xa7, 0x00}, - {0xa7, 0x23}, - {0xa7, 0x1b}, - {0xa7, 0x74}, - {0xa7, 0x42}, - {0xa7, 0x33}, - {0xa7, 0x00}, - {0xa7, 0x23}, - {0xc0, 0xc8}, - {0xc1, 0x96}, - {0x8c, 0x00}, - {0x86, 0x3d}, - {0x50, 0x92}, - {0x51, 0x90}, - {0x52, 0x2c}, - {0x53, 0x00}, - {0x54, 0x00}, - {0x55, 0x88}, - {0x5a, 0x50}, - {0x5b, 0x3c}, - {0x5c, 0x00}, - {0xd3, 0x04}, - {0x7f, 0x00}, - {0xda, 0x00}, - {0xe5, 0x1f}, - {0xe1, 0x67}, - {0xe0, 0x00}, - {0xdd, 0x7f}, - {0x05, 0x00}, - {0xff, 0x00}, - {0xe0, 0x04}, - {0xc0, 0xc8}, - {0xc1, 0x96}, - {0x86, 0x3d}, - {0x50, 0x92}, - {0x51, 0x90}, - {0x52, 0x2c}, - {0x53, 0x00}, - {0x54, 0x00}, - {0x55, 0x88}, - {0x57, 0x00}, - {0x5a, 0x28}, - {0x5b, 0x1E}, - {0x5c, 0x00}, - {0xd3, 0x08}, - {0xe0, 0x00}, - {0xFF, 0x00}, - {0x05, 0x00}, - {0xDA, 0x08}, - {0xda, 0x09}, - {0x98, 0x00}, - {0x99, 0x00}, - {0x00, 0x00}, -}; - -/** - * @} - */ - -/** @defgroup OV2640_Private_Functions - * @{ - */ - -/** - * @brief Initializes the OV2640 CAMERA component. - * @param DeviceAddr: Device address on communication Bus. - * @param resolution: Camera resolution - * @retval None - */ -void ov2640_Init(uint16_t DeviceAddr, uint32_t resolution) -{ - uint32_t index; - - /* Initialize I2C */ - CAMERA_IO_Init(); - - /* Prepare the camera to be configured */ - CAMERA_IO_Write(DeviceAddr, OV2640_DSP_RA_DLMT, 0x01); - CAMERA_IO_Write(DeviceAddr, OV2640_SENSOR_COM7, 0x80); - CAMERA_Delay(200); - - /* Initialize OV2640 */ - switch (resolution) - { - case CAMERA_R160x120: - { - for(index=0; index<(sizeof(OV2640_QQVGA)/2); index++) - { - CAMERA_IO_Write(DeviceAddr, OV2640_QQVGA[index][0], OV2640_QQVGA[index][1]); - CAMERA_Delay(1); - } - break; - } - case CAMERA_R320x240: - { - for(index=0; index<(sizeof(OV2640_QVGA)/2); index++) - { - CAMERA_IO_Write(DeviceAddr, OV2640_QVGA[index][0], OV2640_QVGA[index][1]); - CAMERA_Delay(1); - } - break; - } - case CAMERA_R480x272: - { - for(index=0; index<(sizeof(OV2640_480x272)/2); index++) - { - CAMERA_IO_Write(DeviceAddr, OV2640_480x272[index][0], OV2640_480x272[index][1]); - CAMERA_Delay(2); - } - break; - } - case CAMERA_R640x480: - { - for(index=0; index<(sizeof(OV2640_VGA)/2); index++) - { - CAMERA_IO_Write(DeviceAddr, OV2640_VGA[index][0], OV2640_VGA[index][1]); - CAMERA_Delay(2); - } - break; - } - default: - { - break; - } - } -} - -/** - * @brief Configures the OV2640 camera feature. - * @param DeviceAddr: Device address on communication Bus. - * @param feature: Camera feature to be configured - * @param value: Value to be configured - * @param brightness_value: Brightness value to be configured - * @retval None - */ -void ov2640_Config(uint16_t DeviceAddr, uint32_t feature, uint32_t value, uint32_t brightness_value) -{ - uint8_t value1, value2; - uint32_t value_tmp; - uint32_t br_value; - - /* Convert the input value into ov2640 parameters */ - value_tmp = ov2640_ConvertValue(feature, value); - br_value = ov2640_ConvertValue(CAMERA_CONTRAST_BRIGHTNESS, brightness_value); - - switch(feature) - { - case CAMERA_BLACK_WHITE: - { - CAMERA_IO_Write(DeviceAddr, 0xff, 0x00); - CAMERA_IO_Write(DeviceAddr, 0x7c, 0x00); - CAMERA_IO_Write(DeviceAddr, 0x7d, value_tmp); - CAMERA_IO_Write(DeviceAddr, 0x7c, 0x05); - CAMERA_IO_Write(DeviceAddr, 0x7d, 0x80); - CAMERA_IO_Write(DeviceAddr, 0x7d, 0x80); - break; - } - case CAMERA_CONTRAST_BRIGHTNESS: - { - value1 = (uint8_t)(value_tmp); - value2 = (uint8_t)(value_tmp >> 8); - CAMERA_IO_Write(DeviceAddr, 0xff, 0x00); - CAMERA_IO_Write(DeviceAddr, 0x7c, 0x00); - CAMERA_IO_Write(DeviceAddr, 0x7d, 0x04); - CAMERA_IO_Write(DeviceAddr, 0x7c, 0x07); - CAMERA_IO_Write(DeviceAddr, 0x7d, br_value); - CAMERA_IO_Write(DeviceAddr, 0x7d, value1); - CAMERA_IO_Write(DeviceAddr, 0x7d, value2); - CAMERA_IO_Write(DeviceAddr, 0x7d, 0x06); - break; - } - case CAMERA_COLOR_EFFECT: - { - value1 = (uint8_t)(value_tmp); - value2 = (uint8_t)(value_tmp >> 8); - CAMERA_IO_Write(DeviceAddr, 0xff, 0x00); - CAMERA_IO_Write(DeviceAddr, 0x7c, 0x00); - CAMERA_IO_Write(DeviceAddr, 0x7d, 0x18); - CAMERA_IO_Write(DeviceAddr, 0x7c, 0x05); - CAMERA_IO_Write(DeviceAddr, 0x7d, value1); - CAMERA_IO_Write(DeviceAddr, 0x7d, value2); - break; - } - default: - { - break; - } - } -} - -/** - * @brief Read the OV2640 Camera identity. - * @param DeviceAddr: Device address on communication Bus. - * @retval the OV2640 ID - */ -uint16_t ov2640_ReadID(uint16_t DeviceAddr) -{ - /* Initialize I2C */ - CAMERA_IO_Init(); - - /* Prepare the sensor to read the Camera ID */ - CAMERA_IO_Write(DeviceAddr, OV2640_DSP_RA_DLMT, 0x01); - - /* Get the camera ID */ - return (CAMERA_IO_Read(DeviceAddr, OV2640_SENSOR_PIDH)); -} - -/****************************************************************************** - Static Functions -*******************************************************************************/ -/** - * @brief Convert input values into ov2640 parameters. - * @param feature: Camera feature to be configured - * @param value: Value to be configured - * @retval The converted value - */ -static uint32_t ov2640_ConvertValue(uint32_t feature, uint32_t value) -{ - uint32_t ret = 0; - - switch(feature) - { - case CAMERA_BLACK_WHITE: - { - switch(value) - { - case CAMERA_BLACK_WHITE_BW: - { - ret = OV2640_BLACK_WHITE_BW; - break; - } - case CAMERA_BLACK_WHITE_NEGATIVE: - { - ret = OV2640_BLACK_WHITE_NEGATIVE; - break; - } - case CAMERA_BLACK_WHITE_BW_NEGATIVE: - { - ret = OV2640_BLACK_WHITE_BW_NEGATIVE; - break; - } - case CAMERA_BLACK_WHITE_NORMAL: - { - ret = OV2640_BLACK_WHITE_NORMAL; - break; - } - default: - { - ret = OV2640_BLACK_WHITE_NORMAL; - break; - } - } - break; - } - case CAMERA_CONTRAST_BRIGHTNESS: - { - switch(value) - { - case CAMERA_BRIGHTNESS_LEVEL0: - { - ret = OV2640_BRIGHTNESS_LEVEL0; - break; - } - case CAMERA_BRIGHTNESS_LEVEL1: - { - ret = OV2640_BRIGHTNESS_LEVEL1; - break; - } - case CAMERA_BRIGHTNESS_LEVEL2: - { - ret = OV2640_BRIGHTNESS_LEVEL2; - break; - } - case CAMERA_BRIGHTNESS_LEVEL3: - { - ret = OV2640_BRIGHTNESS_LEVEL3; - break; - } - case CAMERA_BRIGHTNESS_LEVEL4: - { - ret = OV2640_BRIGHTNESS_LEVEL4; - break; - } - case CAMERA_CONTRAST_LEVEL0: - { - ret = OV2640_CONTRAST_LEVEL0; - break; - } - case CAMERA_CONTRAST_LEVEL1: - { - ret = OV2640_CONTRAST_LEVEL1; - break; - } - case CAMERA_CONTRAST_LEVEL2: - { - ret = OV2640_CONTRAST_LEVEL2; - break; - } - case CAMERA_CONTRAST_LEVEL3: - { - ret = OV2640_CONTRAST_LEVEL3; - break; - } - case CAMERA_CONTRAST_LEVEL4: - { - ret = OV2640_CONTRAST_LEVEL4; - break; - } - default: - { - ret = OV2640_CONTRAST_LEVEL0; - break; - } - } - break; - } - case CAMERA_COLOR_EFFECT: - { - switch(value) - { - case CAMERA_COLOR_EFFECT_ANTIQUE: - { - ret = OV2640_COLOR_EFFECT_ANTIQUE; - break; - } - case CAMERA_COLOR_EFFECT_BLUE: - { - ret = OV2640_COLOR_EFFECT_BLUE; - break; - } - case CAMERA_COLOR_EFFECT_GREEN: - { - ret = OV2640_COLOR_EFFECT_GREEN; - break; - } - case CAMERA_COLOR_EFFECT_RED: - { - ret = OV2640_COLOR_EFFECT_RED; - break; - } - default: - { - ret = OV2640_COLOR_EFFECT_RED; - break; - } - } - break; - default: - { - ret = 0; - break; - } - } - } - - return ret; -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/ov2640/ov2640.h b/bsp/stm32f411RE/Libraries/BSP/Components/ov2640/ov2640.h deleted file mode 100644 index 2147c2e3c4..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/ov2640/ov2640.h +++ /dev/null @@ -1,226 +0,0 @@ -/** - ****************************************************************************** - * @file ov2640.h - * @author MCD Application Team - * @version V1.0.2 - * @date 02-December-2014 - * @brief This file contains all the functions prototypes for the ov2640.c - * driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2014 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __OV2640_H -#define __OV2640_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "../Common/camera.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup Components - * @{ - */ - -/** @addtogroup ov2640 - * @{ - */ - -/** @defgroup OV2640_Exported_Types - * @{ - */ - -/** - * @} - */ - -/** @defgroup OV2640_Exported_Constants - * @{ - */ -/** - * @brief OV2640 ID - */ -#define OV2640_ID 0x26 -/** - * @brief OV2640 Registers - */ -/* OV2640 Registers definition when DSP bank selected (0xFF = 0x00) */ -#define OV2640_DSP_R_BYPASS 0x05 -#define OV2640_DSP_Qs 0x44 -#define OV2640_DSP_CTRL 0x50 -#define OV2640_DSP_HSIZE1 0x51 -#define OV2640_DSP_VSIZE1 0x52 -#define OV2640_DSP_XOFFL 0x53 -#define OV2640_DSP_YOFFL 0x54 -#define OV2640_DSP_VHYX 0x55 -#define OV2640_DSP_DPRP 0x56 -#define OV2640_DSP_TEST 0x57 -#define OV2640_DSP_ZMOW 0x5A -#define OV2640_DSP_ZMOH 0x5B -#define OV2640_DSP_ZMHH 0x5C -#define OV2640_DSP_BPADDR 0x7C -#define OV2640_DSP_BPDATA 0x7D -#define OV2640_DSP_CTRL2 0x86 -#define OV2640_DSP_CTRL3 0x87 -#define OV2640_DSP_SIZEL 0x8C -#define OV2640_DSP_HSIZE2 0xC0 -#define OV2640_DSP_VSIZE2 0xC1 -#define OV2640_DSP_CTRL0 0xC2 -#define OV2640_DSP_CTRL1 0xC3 -#define OV2640_DSP_R_DVP_SP 0xD3 -#define OV2640_DSP_IMAGE_MODE 0xDA -#define OV2640_DSP_RESET 0xE0 -#define OV2640_DSP_MS_SP 0xF0 -#define OV2640_DSP_SS_ID 0x7F -#define OV2640_DSP_SS_CTRL 0xF8 -#define OV2640_DSP_MC_BIST 0xF9 -#define OV2640_DSP_MC_AL 0xFA -#define OV2640_DSP_MC_AH 0xFB -#define OV2640_DSP_MC_D 0xFC -#define OV2640_DSP_P_STATUS 0xFE -#define OV2640_DSP_RA_DLMT 0xFF - -/* OV2640 Registers definition when sensor bank selected (0xFF = 0x01) */ -#define OV2640_SENSOR_GAIN 0x00 -#define OV2640_SENSOR_COM1 0x03 -#define OV2640_SENSOR_REG04 0x04 -#define OV2640_SENSOR_REG08 0x08 -#define OV2640_SENSOR_COM2 0x09 -#define OV2640_SENSOR_PIDH 0x0A -#define OV2640_SENSOR_PIDL 0x0B -#define OV2640_SENSOR_COM3 0x0C -#define OV2640_SENSOR_COM4 0x0D -#define OV2640_SENSOR_AEC 0x10 -#define OV2640_SENSOR_CLKRC 0x11 -#define OV2640_SENSOR_COM7 0x12 -#define OV2640_SENSOR_COM8 0x13 -#define OV2640_SENSOR_COM9 0x14 -#define OV2640_SENSOR_COM10 0x15 -#define OV2640_SENSOR_HREFST 0x17 -#define OV2640_SENSOR_HREFEND 0x18 -#define OV2640_SENSOR_VSTART 0x19 -#define OV2640_SENSOR_VEND 0x1A -#define OV2640_SENSOR_MIDH 0x1C -#define OV2640_SENSOR_MIDL 0x1D -#define OV2640_SENSOR_AEW 0x24 -#define OV2640_SENSOR_AEB 0x25 -#define OV2640_SENSOR_W 0x26 -#define OV2640_SENSOR_REG2A 0x2A -#define OV2640_SENSOR_FRARL 0x2B -#define OV2640_SENSOR_ADDVSL 0x2D -#define OV2640_SENSOR_ADDVHS 0x2E -#define OV2640_SENSOR_YAVG 0x2F -#define OV2640_SENSOR_REG32 0x32 -#define OV2640_SENSOR_ARCOM2 0x34 -#define OV2640_SENSOR_REG45 0x45 -#define OV2640_SENSOR_FLL 0x46 -#define OV2640_SENSOR_FLH 0x47 -#define OV2640_SENSOR_COM19 0x48 -#define OV2640_SENSOR_ZOOMS 0x49 -#define OV2640_SENSOR_COM22 0x4B -#define OV2640_SENSOR_COM25 0x4E -#define OV2640_SENSOR_BD50 0x4F -#define OV2640_SENSOR_BD60 0x50 -#define OV2640_SENSOR_REG5D 0x5D -#define OV2640_SENSOR_REG5E 0x5E -#define OV2640_SENSOR_REG5F 0x5F -#define OV2640_SENSOR_REG60 0x60 -#define OV2640_SENSOR_HISTO_LOW 0x61 -#define OV2640_SENSOR_HISTO_HIGH 0x62 - -/** - * @brief OV2640 Features Parameters - */ -#define OV2640_BRIGHTNESS_LEVEL0 0x40 /* Brightness level -2 */ -#define OV2640_BRIGHTNESS_LEVEL1 0x30 /* Brightness level -1 */ -#define OV2640_BRIGHTNESS_LEVEL2 0x20 /* Brightness level 0 */ -#define OV2640_BRIGHTNESS_LEVEL3 0x10 /* Brightness level +1 */ -#define OV2640_BRIGHTNESS_LEVEL4 0x00 /* Brightness level +2 */ - -#define OV2640_BLACK_WHITE_BW 0x18 /* Black and white effect */ -#define OV2640_BLACK_WHITE_NEGATIVE 0x40 /* Negative effect */ -#define OV2640_BLACK_WHITE_BW_NEGATIVE 0x58 /* BW and Negative effect */ -#define OV2640_BLACK_WHITE_NORMAL 0x00 /* Normal effect */ - -#define OV2640_CONTRAST_LEVEL0 0x3418 /* Contrast level -2 */ -#define OV2640_CONTRAST_LEVEL1 0x2A1C /* Contrast level -2 */ -#define OV2640_CONTRAST_LEVEL2 0x2020 /* Contrast level -2 */ -#define OV2640_CONTRAST_LEVEL3 0x1624 /* Contrast level -2 */ -#define OV2640_CONTRAST_LEVEL4 0x0C28 /* Contrast level -2 */ - -#define OV2640_COLOR_EFFECT_ANTIQUE 0xA640 /* Antique effect */ -#define OV2640_COLOR_EFFECT_BLUE 0x40A0 /* Blue effect */ -#define OV2640_COLOR_EFFECT_GREEN 0x4040 /* Green effect */ -#define OV2640_COLOR_EFFECT_RED 0xC040 /* Red effect */ -/** - * @} - */ - -/** @defgroup OV2640_Exported_Functions - * @{ - */ -void ov2640_Init(uint16_t DeviceAddr, uint32_t resolution); -void ov2640_Config(uint16_t DeviceAddr, uint32_t feature, uint32_t value, uint32_t BR_value); -uint16_t ov2640_ReadID(uint16_t DeviceAddr); - -void CAMERA_IO_Init(void); -void CAMERA_IO_Write(uint8_t addr, uint8_t reg, uint8_t value); -uint8_t CAMERA_IO_Read(uint8_t addr, uint8_t reg); -void CAMERA_Delay(uint32_t delay); - -/* CAMERA driver structure */ -extern CAMERA_DrvTypeDef ov2640_drv; -/** - * @} - */ -#ifdef __cplusplus -} -#endif - -#endif /* __OV2640_H */ -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/s25fl512s/Release_Notes.html b/bsp/stm32f411RE/Libraries/BSP/Components/s25fl512s/Release_Notes.html deleted file mode 100644 index 923fe3de82..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/s25fl512s/Release_Notes.html +++ /dev/null @@ -1,158 +0,0 @@ - - - - - - - - - - - - - - - - - Release Notes for STM32 BSP Components Drivers - - - - - - - - - - -
-


-

-
- - - - - - -
- - - - - - - - - -
-

Back to Release page

-
-

Release -Notes for S25FL512S Component Driver

-

Copyright -2015 STMicroelectronics

-

-
-

 

- - - - - - -

Update History

V1.0.0 -/ 03-August-2015

-

Main -Changes

- - - - - - - - - -
  • First official release

License

-Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met:
-
-
  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions -in binary form must reproduce the above copyright notice, this list of -conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of STMicroelectronics nor the names of its contributors may be used to endorse or promote products derived
    -
    -
-        from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- -
-

- - -
-
-
For -complete documentation on STM32 Microcontrollers -visit www.st.com/STM32
-

-
-

-
-
-

 

-
- - \ No newline at end of file diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/s25fl512s/s25fl512s.h b/bsp/stm32f411RE/Libraries/BSP/Components/s25fl512s/s25fl512s.h deleted file mode 100644 index f0031fb3ff..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/s25fl512s/s25fl512s.h +++ /dev/null @@ -1,261 +0,0 @@ -/** - ****************************************************************************** - * @file s25fl512s.h - * @author MCD Application Team - * @version V1.0.0 - * @date 03-August-2015 - * @brief This file contains all the description of the S25FL512S QSPI memory. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __S25FL512S_H -#define __S25FL512S_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup Components - * @{ - */ - -/** @addtogroup s25fl512s - * @brief This file provides a set of definitions for the Spansion - * S25FL512S memory (configuration, commands, registers). - * @{ - */ - -/** @defgroup S25FL512S_Exported_Types - * @{ - */ - -/** - * @} - */ - -/** @defgroup S25FL512S_Exported_Constants - * @{ - */ - -/* S25FL512SAGMFI01 Spansion Memory */ -/** - * @brief S25FL512S Configuration - */ -#define S25FL512S_FLASH_SIZE 0x4000000 /* 512 MBits => 64MBytes */ -#define S25FL512S_SECTOR_SIZE 0x40000 /* 256 sectors of 256KBytes */ -#define S25FL512S_PAGE_SIZE 0x200 /* 131072 pages of 512 bytes */ - -#define S25FL512S_BULK_ERASE_MAX_TIME 460000 -#define S25FL512S_SECTOR_ERASE_MAX_TIME 2600 - - -/** - * @brief S25FL512S Commands - */ -/* Reset Operations */ -#define S25FL512S_SOFTWARE_RESET_CMD 0xF0 -#define S25FL512S_MODE_BIT_RESET_CMD 0xFF - -/* Identification Operations */ -#define S25FL512S_READ_ID_CMD 0x90 -#define S25FL512S_READ_ID_CMD2 0x9F -#define S25FL512S_READ_ELECTRONIC_SIGNATURE 0xAB -#define S25FL512S_READ_SERIAL_FLASH_DISCO_PARAM_CMD 0x5A - -/* Register Operations */ -#define S25FL512S_READ_STATUS_REG1_CMD 0x05 -#define S25FL512S_READ_STATUS_REG2_CMD 0x07 -#define S25FL512S_READ_CONFIGURATION_REG1_CMD 0x35 -#define S25FL512S_WRITE_STATUS_CMD_REG_CMD 0x01 -#define S25FL512S_WRITE_DISABLE_CMD 0x04 -#define S25FL512S_WRITE_ENABLE_CMD 0x06 -#define S25FL512S_CLEAR_STATUS_REG1_CMD 0x30 -#define S25FL512S_READ_AUTOBOOT_REG_CMD 0x14 -#define S25FL512S_WRITE_AUTOBOOT_REG_CMD 0x15 -#define S25FL512S_READ_BANK_REG_CMD 0x16 -#define S25FL512S_WRITE_BANK_REG_CMD 0x17 -#define S25FL512S_ACCESS_BANK_REG_CMD 0xB9 -#define S25FL512S_READ_DATA_LEARNING_PATTERN_CMD 0x41 -#define S25FL512S_PGM_NV_DATA_LEARNING_REG_CMD 0x43 -#define S25FL512S_WRITE_VOL_DATA_LEARNING_REG_CMD 0x4A - -/* Read Operations */ -#define S25FL512S_READ_CMD 0x03 -#define S25FL512S_READ_4_BYTE_ADDR_CMD 0x13 - -#define S25FL512S_FAST_READ_CMD 0x0B -#define S25FL512S_FAST_READ_4_BYTE_ADDR_CMD 0x0C -#define S25FL512S_FAST_READ_DDR_CMD 0x0D -#define S25FL512S_FAST_READ__DDR_4_BYTE_ADDR_CMD 0x0E - -#define S25FL512S_DUAL_OUT_FAST_READ_CMD 0x3B -#define S25FL512S_DUAL_OUT_FAST_READ_4_BYTE_ADDR_CMD 0x3C - -#define S25FL512S_QUAD_OUT_FAST_READ_CMD 0x6B -#define S25FL512S_QUAD_OUT_FAST_READ_4_BYTE_ADDR_CMD 0x6C - -#define S25FL512S_DUAL_INOUT_FAST_READ_CMD 0xBB -#define S25FL512S_DUAL_INOUT_FAST_READ_DTR_CMD 0xBD -#define S25FL512S_DUAL_INOUT_FAST_READ_4_BYTE_ADDR_CMD 0xBC -#define S25FL512S_DDR_DUAL_INOUT_READ_4_BYTE_ADDR_CMD 0xBE - -#define S25FL512S_QUAD_INOUT_FAST_READ_CMD 0xEB -#define S25FL512S_QUAD_INOUT_FAST_READ_4_BYTE_ADDR_CMD 0xEC -#define S25FL512S_QUAD_INOUT_FAST_READ_DDR_CMD 0xED -#define S25FL512S_QUAD_INOUT_READ_DDR_4_BYTE_ADDR_CMD 0xEE - - -/* Program Operations */ -#define S25FL512S_PAGE_PROG_CMD 0x02 -#define S25FL512S_PAGE_PROG_4_BYTE_ADDR_CMD 0x12 - -#define S25FL512S_QUAD_IN_FAST_PROG_CMD 0x32 -#define S25FL512S_QUAD_IN_FAST_PROG_ALTERNATE_CMD 0x38 -#define S25FL512S_QUAD_IN_FAST_PROG_4_BYTE_ADDR_CMD 0x34 - -#define S25FL512S_PROGRAM_SUSPEND_CMD 0x85 -#define S25FL512S_PROGRAM_RESUME_CMD 0x8A - -/* Erase Operations */ -#define S25FL512S_SECTOR_ERASE_CMD 0xD8 -#define S25FL512S_SECTOR_ERASE_4_BYTE_ADDR_CMD 0xDC - -#define S25FL512S_BULK_ERASE_CMD 0x60 -#define S25FL512S_BULK_ERASE_ALTERNATE_CMD 0xC7 - -#define S25FL512S_PROG_ERASE_SUSPEND_CMD 0x75 -#define S25FL512S_PROG_ERASE_RESUME_CMD 0x7A - -/* One-Time Programmable Operations */ -#define S25FL512S_PROG_OTP_ARRAY_CMD 0x42 -#define S25FL512S_READ_OTP_ARRAY_CMD 0x4B - -/* Advanced Sector Protection Operations */ -#define S25FL512S_READ_DYB_CMD 0xE0 -#define S25FL512S_WRITE_DYB_CMD 0xE1 - -#define S25FL512S_READ_PPB_CMD 0xE2 -#define S25FL512S_PROGRAM_PPB_CMD 0xE3 -#define S25FL512S_ERASE_PPB_CMD 0xE4 - -#define S25FL512S_READ_ASP_CMD 0x2B -#define S25FL512S_PROGRAM_ASP_CMD 0x2F - -#define S25FL512S_READ_PPB_LOCKBIT_CMD 0xA7 -#define S25FL512S_WRITE_PPB_LOCKBIT_CMD 0xA6 - -#define S25FL512S_READ_PASSWORD_CMD 0xE7 -#define S25FL512S_PROGRAM_PASSWORD_CMD 0xE8 -#define S25FL512S_UNLOCK_PASSWORD_CMD 0xE9 - - - -/** - * @brief S25FL512S Registers - */ -/* Status Register-1 */ -#define S25FL512S_SR1_WIP ((uint8_t)0x01) /*!< Write in progress, device busy */ -#define S25FL512S_SR1_WREN ((uint8_t)0x02) /*!< Write Registers, program or commands are accepted */ -#define S25FL512S_SR1_BP0 ((uint8_t)0x04) /*!< Sector0 protected from Program or Erase */ -#define S25FL512S_SR1_BP1 ((uint8_t)0x08) /*!< Sector1 protected from Program or Erase */ -#define S25FL512S_SR1_BP2 ((uint8_t)0x10) /*!< Sector2 protected from Program or Erase */ -#define S25FL512S_SR1_ERERR ((uint8_t)0x20) /*!< Erase error */ -#define S25FL512S_SR1_PGERR ((uint8_t)0x40) /*!< Program error */ -#define S25FL512S_SR1_SRWD ((uint8_t)0x80) /*!< Status Register Write Disable */ - -/* Status Register-2 */ -#define S25FL512S_SR2_PS ((uint8_t)0x01) /*!< Program in Suspend mode */ -#define S25FL512S_SR2_ES ((uint8_t)0x02) /*!< Erase Suspend Mode */ - -/* Configuration Register CR1 */ -#define S25FL512S_CR1_FREEZE ((uint8_t)0x01) /*!< Block protection and OTP locked */ -#define S25FL512S_CR1_QUAD ((uint8_t)0x02) /*!< Quad mode enable */ -#define S25FL512S_CR1_BPNV ((uint8_t)0x08) /*!< BP2-0 bits of Status Reg are volatile */ -#define S25FL512S_CR1_TBPROT ((uint8_t)0x20) /*!< BPstarts at bottom */ -#define S25FL512S_CR1_LC_MASK ((uint8_t)0xC0) /*!< Latency Code mask */ -#define S25FL512S_CR1_LC0 ((uint8_t)0x00) /*!< Latency Code = 0 */ -#define S25FL512S_CR1_LC1 ((uint8_t)0x40) /*!< Latency Code = 1 */ -#define S25FL512S_CR1_LC2 ((uint8_t)0x80) /*!< Latency Code = 2 */ -#define S25FL512S_CR1_LC3 ((uint8_t)0xC0) /*!< Latency Code = 3 */ - -/* AutoBoot Register */ -#define S25FL512S_AB_EN ((uint32_t)0x00000001) /*!< AutoBoot Enabled */ -#define S25FL512S_AB_SD_MASK ((uint32_t)0x000001FE) /*!< AutoBoot Start Delay mask */ -#define S25FL512S_AB_SA_MASK ((uint32_t)0xFFFFFE00) /*!< AutoBoot Start Address mask */ - -/* Bank Address Register */ -#define S25FL512S_BA_BA24 ((uint8_t)0x01) /*!< A24 for 512 Mb device */ -#define S25FL512S_BA_BA25 ((uint8_t)0x02) /*!< A25 for 512 Mb device */ -#define S25FL512S_BA_EXTADD ((uint8_t)0x80) /*!< 4 bytes addressing required from command */ - -/* ASP Register */ -#define S25FL512S_ASP_PSTMLB ((uint16_t)0x0002) /*!< Persistent protection mode not permanently enabled */ -#define S25FL512S_ASP_PWSMLB ((uint16_t)0x0003) /*!< Password protection mode not permanently enabled */ - -/* PPB Lock Register */ -#define S25FL512S_PPBLOCK ((uint8_t)0x01) /*!< PPB array may be programmed or erased */ - -/** - * @} - */ - -/** @defgroup S25FL512S_Exported_Functions - * @{ - */ -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __S25FL512S_H */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/s5k5cag/Release_Notes.html b/bsp/stm32f411RE/Libraries/BSP/Components/s5k5cag/Release_Notes.html deleted file mode 100644 index deef4d643c..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/s5k5cag/Release_Notes.html +++ /dev/null @@ -1,1081 +0,0 @@ - - - - - - - - -Release Notes for S5K5CAG Component Driver - - - - - - - - - - - - -
- -

 

- -
- - - - - -
- - - - - - - -
-

Back to Release page

-
-

Release Notes for S5K5CAG Component Driver

-

Copyright - 2015 STMicroelectronics

-

-
-

 

- - - - -
-

Update History

V1.0.0 / 05-March-2015

-

Main Changes

- -
    -
  • First official -release
  • -
-

License

-

Redistribution and use in source and - binary forms, with or without modification, are permitted provided that the - following conditions are met:

-
    -
  1. Redistributions - of source code must retain the above copyright notice, this list of - conditions and the following disclaimer.
  2. -
  3. Redistributions - in binary form must reproduce the above copyright notice, this list of - conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution.
  4. -
  5. Neither - the name of STMicroelectronics nor the names of its contributors may - be used to endorse or promote products derived
  6. -
-

       from this software without specific prior written - permission.
-
-
THIS - SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS - IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE.

-

 

-
-
-
-

For - complete documentation on STM32 Microcontrollers - visit www.st.com/STM32

-
-

-
- -
- -

 

- -
- - \ No newline at end of file diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/s5k5cag/s5k5cag.c b/bsp/stm32f411RE/Libraries/BSP/Components/s5k5cag/s5k5cag.c deleted file mode 100644 index d8c66d4ceb..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/s5k5cag/s5k5cag.c +++ /dev/null @@ -1,3450 +0,0 @@ -/** - ****************************************************************************** - * @file s5k5cag.c - * @author MCD Application Team - * @version V1.0.0 - * @date 05-March-2015 - * @brief This file provides the S5K5CAG camera driver - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Includes ------------------------------------------------------------------*/ -#include "s5k5cag.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup Components - * @{ - */ - -/** @addtogroup S5K5CAG - * @brief This file provides a set of functions needed to drive the - * S5K5CAG Camera module. - * @{ - */ - -/** @defgroup S5K5CAG_Private_TypesDefinitions - * @{ - */ - -/** - * @} - */ - -/** @defgroup S5K5CAG_Private_Defines - * @{ - */ - -/** - * @} - */ - -/** @defgroup S5K5CAG_Private_Macros - * @{ - */ - -/** - * @} - */ - -/** @defgroup S5K5CAG_Private_FunctionPrototypes - * @{ - */ -static uint32_t s5k5cag_ConvertValue(uint32_t feature, uint32_t value); -/** - * @} - */ - -/** @defgroup S5K5CAG_Private_Variables - * @{ - */ - -CAMERA_DrvTypeDef s5k5cag_drv = -{ - s5k5cag_Init, - s5k5cag_ReadID, - s5k5cag_Config, -}; - -/* Common initialization sequence for all resolutions */ -const uint16_t S5K5CAG_Common[][2]= -{ - /* ARM GO */ - /* Direct mode */ - {0xFCFC, 0xD000}, - {0x0010, 0x0001}, /* Reset */ - {0x1030, 0x0000}, /* Clear host interrupt so main will wait */ - {0x0014, 0x0001}, /* ARM go */ - {0xFFFF, 0x0064}, /* Min.10ms delay is required */ - - /* Set IO driving current */ - {0x0028, 0xD000}, - {0x002A, 0x1082}, - {0x0F12, 0x0155}, /* [9:8] D4, [7:6] D3, [5:4] D2, [3:2] D1, [1:0] D0 */ - {0x0F12, 0x0155}, /* [9:8] D9, [7:6] D8, [5:4] D7, [3:2] D6, [1:0] D5 */ - {0x0F12, 0x1555}, /* [5:4] GPIO3, [3:2] GPIO2, [1:0] GPIO1 */ - {0x0F12, 0x0555}, /* [11:10] SDA, [9:8] SCA, [7:6] PCLK, [3:2] VSYNC, [1:0] HSYNC */ - - /* Start T&P part */ - {0x0028, 0x7000}, - {0x002A, 0x2CF8}, - {0x0F12, 0xB510}, - {0x0F12, 0x490F}, - {0x0F12, 0x2000}, - {0x0F12, 0x8048}, - {0x0F12, 0x8088}, - {0x0F12, 0x490E}, - {0x0F12, 0x480E}, - {0x0F12, 0xF000}, - {0x0F12, 0xF949}, - {0x0F12, 0x490E}, - {0x0F12, 0x480E}, - {0x0F12, 0x6341}, - {0x0F12, 0x490E}, - {0x0F12, 0x38C0}, - {0x0F12, 0x63C1}, - {0x0F12, 0x490E}, - {0x0F12, 0x6301}, - {0x0F12, 0x490E}, - {0x0F12, 0x3040}, - {0x0F12, 0x6181}, - {0x0F12, 0x490D}, - {0x0F12, 0x480E}, - {0x0F12, 0xF000}, - {0x0F12, 0xF93A}, - {0x0F12, 0x490D}, - {0x0F12, 0x480E}, - {0x0F12, 0xF000}, - {0x0F12, 0xF936}, - {0x0F12, 0xBC10}, - {0x0F12, 0xBC08}, - {0x0F12, 0x4718}, - {0x0F12, 0x0000}, - {0x0F12, 0x1080}, - {0x0F12, 0xD000}, - {0x0F12, 0x2D69}, - {0x0F12, 0x7000}, - {0x0F12, 0x89A9}, - {0x0F12, 0x0000}, - {0x0F12, 0x2DBB}, - {0x0F12, 0x7000}, - {0x0F12, 0x0140}, - {0x0F12, 0x7000}, - {0x0F12, 0x2DED}, - {0x0F12, 0x7000}, - {0x0F12, 0x2E65}, - {0x0F12, 0x7000}, - {0x0F12, 0x2E79}, - {0x0F12, 0x7000}, - {0x0F12, 0x2E4D}, - {0x0F12, 0x7000}, - {0x0F12, 0x013D}, - {0x0F12, 0x0001}, - {0x0F12, 0x2F03}, - {0x0F12, 0x7000}, - {0x0F12, 0x5823}, - {0x0F12, 0x0000}, - {0x0F12, 0xB570}, - {0x0F12, 0x6804}, - {0x0F12, 0x6845}, - {0x0F12, 0x6881}, - {0x0F12, 0x6840}, - {0x0F12, 0x2900}, - {0x0F12, 0x6880}, - {0x0F12, 0xD007}, - {0x0F12, 0x4976}, - {0x0F12, 0x8949}, - {0x0F12, 0x084A}, - {0x0F12, 0x1880}, - {0x0F12, 0xF000}, - {0x0F12, 0xF914}, - {0x0F12, 0x80A0}, - {0x0F12, 0xE000}, - {0x0F12, 0x80A0}, - {0x0F12, 0x88A0}, - {0x0F12, 0x2800}, - {0x0F12, 0xD010}, - {0x0F12, 0x68A9}, - {0x0F12, 0x6828}, - {0x0F12, 0x084A}, - {0x0F12, 0x1880}, - {0x0F12, 0xF000}, - {0x0F12, 0xF908}, - {0x0F12, 0x8020}, - {0x0F12, 0x1D2D}, - {0x0F12, 0xCD03}, - {0x0F12, 0x084A}, - {0x0F12, 0x1880}, - {0x0F12, 0xF000}, - {0x0F12, 0xF901}, - {0x0F12, 0x8060}, - {0x0F12, 0xBC70}, - {0x0F12, 0xBC08}, - {0x0F12, 0x4718}, - {0x0F12, 0x2000}, - {0x0F12, 0x8060}, - {0x0F12, 0x8020}, - {0x0F12, 0xE7F8}, - {0x0F12, 0xB510}, - {0x0F12, 0xF000}, - {0x0F12, 0xF8FC}, - {0x0F12, 0x4865}, - {0x0F12, 0x4966}, - {0x0F12, 0x8800}, - {0x0F12, 0x4A66}, - {0x0F12, 0x2805}, - {0x0F12, 0xD003}, - {0x0F12, 0x4B65}, - {0x0F12, 0x795B}, - {0x0F12, 0x2B00}, - {0x0F12, 0xD005}, - {0x0F12, 0x2001}, - {0x0F12, 0x8008}, - {0x0F12, 0x8010}, - {0x0F12, 0xBC10}, - {0x0F12, 0xBC08}, - {0x0F12, 0x4718}, - {0x0F12, 0x2800}, - {0x0F12, 0xD1FA}, - {0x0F12, 0x2000}, - {0x0F12, 0x8008}, - {0x0F12, 0x8010}, - {0x0F12, 0xE7F6}, - {0x0F12, 0xB570}, - {0x0F12, 0x0004}, - {0x0F12, 0x485D}, - {0x0F12, 0x2C00}, - {0x0F12, 0x8D00}, - {0x0F12, 0xD001}, - {0x0F12, 0x2501}, - {0x0F12, 0xE000}, - {0x0F12, 0x2500}, - {0x0F12, 0x4E5B}, - {0x0F12, 0x4328}, - {0x0F12, 0x8030}, - {0x0F12, 0x207D}, - {0x0F12, 0x00C0}, - {0x0F12, 0xF000}, - {0x0F12, 0xF8DE}, - {0x0F12, 0x4858}, - {0x0F12, 0x2C00}, - {0x0F12, 0x8C40}, - {0x0F12, 0x0329}, - {0x0F12, 0x4308}, - {0x0F12, 0x8130}, - {0x0F12, 0x4856}, - {0x0F12, 0x2C00}, - {0x0F12, 0x8A40}, - {0x0F12, 0x01A9}, - {0x0F12, 0x4308}, - {0x0F12, 0x80B0}, - {0x0F12, 0x2C00}, - {0x0F12, 0xD00B}, - {0x0F12, 0x4853}, - {0x0F12, 0x8A01}, - {0x0F12, 0x4853}, - {0x0F12, 0xF000}, - {0x0F12, 0xF8BD}, - {0x0F12, 0x4953}, - {0x0F12, 0x8809}, - {0x0F12, 0x4348}, - {0x0F12, 0x0400}, - {0x0F12, 0x0C00}, - {0x0F12, 0xF000}, - {0x0F12, 0xF8C4}, - {0x0F12, 0x0020}, - {0x0F12, 0xF000}, - {0x0F12, 0xF8C9}, - {0x0F12, 0x484F}, - {0x0F12, 0x7004}, - {0x0F12, 0xE7AF}, - {0x0F12, 0xB510}, - {0x0F12, 0x0004}, - {0x0F12, 0xF000}, - {0x0F12, 0xF8CA}, - {0x0F12, 0x6020}, - {0x0F12, 0x494C}, - {0x0F12, 0x8B49}, - {0x0F12, 0x0789}, - {0x0F12, 0xD0BD}, - {0x0F12, 0x0040}, - {0x0F12, 0x6020}, - {0x0F12, 0xE7BA}, - {0x0F12, 0xB510}, - {0x0F12, 0xF000}, - {0x0F12, 0xF8C7}, - {0x0F12, 0x4848}, - {0x0F12, 0x8880}, - {0x0F12, 0x0601}, - {0x0F12, 0x4840}, - {0x0F12, 0x1609}, - {0x0F12, 0x8281}, - {0x0F12, 0xE7B0}, - {0x0F12, 0xB5F8}, - {0x0F12, 0x000F}, - {0x0F12, 0x4C3A}, - {0x0F12, 0x3420}, - {0x0F12, 0x2500}, - {0x0F12, 0x5765}, - {0x0F12, 0x0039}, - {0x0F12, 0xF000}, - {0x0F12, 0xF8BF}, - {0x0F12, 0x9000}, - {0x0F12, 0x2600}, - {0x0F12, 0x57A6}, - {0x0F12, 0x4C38}, - {0x0F12, 0x42AE}, - {0x0F12, 0xD01B}, - {0x0F12, 0x4D3D}, - {0x0F12, 0x8AE8}, - {0x0F12, 0x2800}, - {0x0F12, 0xD013}, - {0x0F12, 0x4832}, - {0x0F12, 0x8A01}, - {0x0F12, 0x8B80}, - {0x0F12, 0x4378}, - {0x0F12, 0xF000}, - {0x0F12, 0xF881}, - {0x0F12, 0x89A9}, - {0x0F12, 0x1A41}, - {0x0F12, 0x4837}, - {0x0F12, 0x3820}, - {0x0F12, 0x8AC0}, - {0x0F12, 0x4348}, - {0x0F12, 0x17C1}, - {0x0F12, 0x0D89}, - {0x0F12, 0x1808}, - {0x0F12, 0x1280}, - {0x0F12, 0x8AA1}, - {0x0F12, 0x1A08}, - {0x0F12, 0x82A0}, - {0x0F12, 0xE003}, - {0x0F12, 0x88A8}, - {0x0F12, 0x0600}, - {0x0F12, 0x1600}, - {0x0F12, 0x82A0}, - {0x0F12, 0x2014}, - {0x0F12, 0x5E20}, - {0x0F12, 0x42B0}, - {0x0F12, 0xD011}, - {0x0F12, 0xF000}, - {0x0F12, 0xF89F}, - {0x0F12, 0x1D40}, - {0x0F12, 0x00C3}, - {0x0F12, 0x1A18}, - {0x0F12, 0x214B}, - {0x0F12, 0xF000}, - {0x0F12, 0xF863}, - {0x0F12, 0x211F}, - {0x0F12, 0xF000}, - {0x0F12, 0xF89E}, - {0x0F12, 0x2114}, - {0x0F12, 0x5E61}, - {0x0F12, 0x0FC9}, - {0x0F12, 0x0149}, - {0x0F12, 0x4301}, - {0x0F12, 0x4826}, - {0x0F12, 0x81C1}, - {0x0F12, 0x9800}, - {0x0F12, 0xBCF8}, - {0x0F12, 0xBC08}, - {0x0F12, 0x4718}, - {0x0F12, 0xB5F1}, - {0x0F12, 0xB082}, - {0x0F12, 0x2500}, - {0x0F12, 0x4822}, - {0x0F12, 0x9001}, - {0x0F12, 0x2400}, - {0x0F12, 0x2028}, - {0x0F12, 0x4368}, - {0x0F12, 0x4A21}, - {0x0F12, 0x4917}, - {0x0F12, 0x1882}, - {0x0F12, 0x39E0}, - {0x0F12, 0x1847}, - {0x0F12, 0x9200}, - {0x0F12, 0x0066}, - {0x0F12, 0x19B8}, - {0x0F12, 0x9A01}, - {0x0F12, 0x3060}, - {0x0F12, 0x8B01}, - {0x0F12, 0x5BB8}, - {0x0F12, 0x8812}, - {0x0F12, 0xF000}, - {0x0F12, 0xF884}, - {0x0F12, 0x9900}, - {0x0F12, 0x5388}, - {0x0F12, 0x1C64}, - {0x0F12, 0x2C14}, - {0x0F12, 0xDBF1}, - {0x0F12, 0x1C6D}, - {0x0F12, 0x2D03}, - {0x0F12, 0xDBE5}, - {0x0F12, 0x9802}, - {0x0F12, 0x6800}, - {0x0F12, 0x0600}, - {0x0F12, 0x0E00}, - {0x0F12, 0xF000}, - {0x0F12, 0xF87E}, - {0x0F12, 0xBCFE}, - {0x0F12, 0xBC08}, - {0x0F12, 0x4718}, - {0x0F12, 0x0000}, - {0x0F12, 0x0C3C}, - {0x0F12, 0x7000}, - {0x0F12, 0x26E8}, - {0x0F12, 0x7000}, - {0x0F12, 0x6100}, - {0x0F12, 0xD000}, - {0x0F12, 0x6500}, - {0x0F12, 0xD000}, - {0x0F12, 0x1A7C}, - {0x0F12, 0x7000}, - {0x0F12, 0x2C2C}, - {0x0F12, 0x7000}, - {0x0F12, 0xF400}, - {0x0F12, 0xD000}, - {0x0F12, 0x167C}, - {0x0F12, 0x7000}, - {0x0F12, 0x3368}, - {0x0F12, 0x7000}, - {0x0F12, 0x1D6C}, - {0x0F12, 0x7000}, - {0x0F12, 0x40A0}, - {0x0F12, 0x00DD}, - {0x0F12, 0xF520}, - {0x0F12, 0xD000}, - {0x0F12, 0x2C29}, - {0x0F12, 0x7000}, - {0x0F12, 0x1A54}, - {0x0F12, 0x7000}, - {0x0F12, 0x1564}, - {0x0F12, 0x7000}, - {0x0F12, 0xF2A0}, - {0x0F12, 0xD000}, - {0x0F12, 0x2440}, - {0x0F12, 0x7000}, - {0x0F12, 0x05A0}, - {0x0F12, 0x7000}, - {0x0F12, 0x4778}, - {0x0F12, 0x46C0}, - {0x0F12, 0xC000}, - {0x0F12, 0xE59F}, - {0x0F12, 0xFF1C}, - {0x0F12, 0xE12F}, - {0x0F12, 0x1A3F}, - {0x0F12, 0x0001}, - {0x0F12, 0x4778}, - {0x0F12, 0x46C0}, - {0x0F12, 0xF004}, - {0x0F12, 0xE51F}, - {0x0F12, 0x1F48}, - {0x0F12, 0x0001}, - {0x0F12, 0x4778}, - {0x0F12, 0x46C0}, - {0x0F12, 0xC000}, - {0x0F12, 0xE59F}, - {0x0F12, 0xFF1C}, - {0x0F12, 0xE12F}, - {0x0F12, 0x24BD}, - {0x0F12, 0x0000}, - {0x0F12, 0x4778}, - {0x0F12, 0x46C0}, - {0x0F12, 0xC000}, - {0x0F12, 0xE59F}, - {0x0F12, 0xFF1C}, - {0x0F12, 0xE12F}, - {0x0F12, 0xF53F}, - {0x0F12, 0x0000}, - {0x0F12, 0x4778}, - {0x0F12, 0x46C0}, - {0x0F12, 0xC000}, - {0x0F12, 0xE59F}, - {0x0F12, 0xFF1C}, - {0x0F12, 0xE12F}, - {0x0F12, 0xF5D9}, - {0x0F12, 0x0000}, - {0x0F12, 0x4778}, - {0x0F12, 0x46C0}, - {0x0F12, 0xC000}, - {0x0F12, 0xE59F}, - {0x0F12, 0xFF1C}, - {0x0F12, 0xE12F}, - {0x0F12, 0x013D}, - {0x0F12, 0x0001}, - {0x0F12, 0x4778}, - {0x0F12, 0x46C0}, - {0x0F12, 0xC000}, - {0x0F12, 0xE59F}, - {0x0F12, 0xFF1C}, - {0x0F12, 0xE12F}, - {0x0F12, 0xF5C9}, - {0x0F12, 0x0000}, - {0x0F12, 0x4778}, - {0x0F12, 0x46C0}, - {0x0F12, 0xC000}, - {0x0F12, 0xE59F}, - {0x0F12, 0xFF1C}, - {0x0F12, 0xE12F}, - {0x0F12, 0xFAA9}, - {0x0F12, 0x0000}, - {0x0F12, 0x4778}, - {0x0F12, 0x46C0}, - {0x0F12, 0xC000}, - {0x0F12, 0xE59F}, - {0x0F12, 0xFF1C}, - {0x0F12, 0xE12F}, - {0x0F12, 0x36DD}, - {0x0F12, 0x0000}, - {0x0F12, 0x4778}, - {0x0F12, 0x46C0}, - {0x0F12, 0xC000}, - {0x0F12, 0xE59F}, - {0x0F12, 0xFF1C}, - {0x0F12, 0xE12F}, - {0x0F12, 0x36ED}, - {0x0F12, 0x0000}, - {0x0F12, 0x4778}, - {0x0F12, 0x46C0}, - {0x0F12, 0xC000}, - {0x0F12, 0xE59F}, - {0x0F12, 0xFF1C}, - {0x0F12, 0xE12F}, - {0x0F12, 0x3723}, - {0x0F12, 0x0000}, - {0x0F12, 0x4778}, - {0x0F12, 0x46C0}, - {0x0F12, 0xC000}, - {0x0F12, 0xE59F}, - {0x0F12, 0xFF1C}, - {0x0F12, 0xE12F}, - {0x0F12, 0x5823}, - {0x0F12, 0x0000}, - {0x0F12, 0x7D3E}, - {0x0F12, 0x0000}, - /* End T&P part */ - - /* CIS/APS/Analog setting- 400LSBSYSCLK 45M */ - {0x0028, 0x7000}, - {0x002A, 0x157A}, - {0x0F12, 0x0001}, - {0x002A, 0x1578}, - {0x0F12, 0x0001}, - {0x002A, 0x1576}, - {0x0F12, 0x0020}, - {0x002A, 0x1574}, - {0x0F12, 0x0006}, - {0x002A, 0x156E}, - {0x0F12, 0x0001}, /* Slope calibration tolerance in units of 1/256 */ - {0x002A, 0x1568}, - {0x0F12, 0x00FC}, - - /* ADC control */ - {0x002A, 0x155A}, - {0x0F12, 0x01CC}, /* ADC SAT of 450mV for 10bit default in EVT1 */ - {0x002A, 0x157E}, - {0x0F12, 0x0C80}, /* 3200 Max. Reset ramp DCLK counts (default 2048 0x800) */ - {0x0F12, 0x0578}, /* 1400 Max. Reset ramp DCLK counts for x3.5 */ - {0x002A, 0x157C}, - {0x0F12, 0x0190}, /* 400 Reset ramp for x1 in DCLK counts */ - {0x002A, 0x1570}, - {0x0F12, 0x00A0}, /* 224 LSB */ - {0x0F12, 0x0010}, /* reset threshold */ - {0x002A, 0x12C4}, - {0x0F12, 0x006A}, /* 106 additional timing columns */ - {0x002A, 0x12C8}, - {0x0F12, 0x08AC}, /* 2220 ADC columns in normal mode including Hold & Latch */ - {0x0F12, 0x0050}, /* 80 addition of ADC columns in Y-ave mode (default 244 0x74) */ - - {0x002A, 0x1696}, - {0x0F12, 0x0000}, /* based on APS guidelines */ - {0x0F12, 0x0000}, /* based on APS guidelines */ - {0x0F12, 0x00C6}, /* default. 1492 used for ADC dark characteristics */ - {0x0F12, 0x00C6}, /* default. 1492 used for ADC dark characteristics */ - {0x002A, 0x1690}, - {0x0F12, 0x0001}, /* when set double sampling is activated - requires different set of pointers */ - {0x002A, 0x12B0}, - {0x0F12, 0x0055}, /* comp and pixel bias control 0xF40E - default for EVT1 */ - {0x0F12, 0x005A}, /* comp and pixel bias control 0xF40E for binning mode */ - {0x002A, 0x337A}, - {0x0F12, 0x0006}, /* [7] - is used for rest-only mode (EVT0 value is 0xD and HW 0x6) */ - {0x002A, 0x169E}, /* [3:0]- specifies the target (default 7)- DCLK = 64MHz instead of 116MHz */ - {0x0F12, 0x000A}, - {0x0028, 0xD000}, - {0x002A, 0xF406}, - {0x0F12, 0x1000}, /* [11]: Enable DBLR Regulation */ - {0x002A, 0xF40A}, - {0x0F12, 0x6998}, /* [3:0]: VPIX ~2.8V */ - {0x002A, 0xF418}, - {0x0F12, 0x0078}, /* [0]: Static RC-filter */ - {0x0F12, 0x04FE}, /* [7:4]: Full RC-filter */ - {0x002A, 0xF52C}, - {0x0F12, 0x8800}, /* [11]: Add load to CDS block */ - - {0x002A, 0x3274}, - {0x0F12, 0x0155}, - {0x0F12, 0x0155}, - {0x0F12, 0x1555}, - {0x0F12, 0x0555}, - - /* Asserting CDS pointers - Long exposure MS Normal */ - /* Conditions: 10bit, ADC_SAT = 450mV ; ramp_del = 22 ; ramp_start = 34 */ - {0x0028, 0x7000}, - {0x002A, 0x12D2}, - {0x0F12, 0x0003}, /* #senHal_pContSenModesRegsArray[0][0]2 700012D2 */ - {0x0F12, 0x0003}, /* #senHal_pContSenModesRegsArray[0][1]2 700012D4 */ - {0x0F12, 0x0003}, /* #senHal_pContSenModesRegsArray[0][2]2 700012D6 */ - {0x0F12, 0x0003}, /* #senHal_pContSenModesRegsArray[0][3]2 700012D8 */ - {0x0F12, 0x0884}, /* #senHal_pContSenModesRegsArray[1][0]2 700012DA */ - {0x0F12, 0x08CF}, /* #senHal_pContSenModesRegsArray[1][1]2 700012DC */ - {0x0F12, 0x0500}, /* #senHal_pContSenModesRegsArray[1][2]2 700012DE */ - {0x0F12, 0x054B}, /* #senHal_pContSenModesRegsArray[1][3]2 700012E0 */ - {0x0F12, 0x0001}, /* #senHal_pContSenModesRegsArray[2][0]2 700012E2 */ - {0x0F12, 0x0001}, /* #senHal_pContSenModesRegsArray[2][1]2 700012E4 */ - {0x0F12, 0x0001}, /* #senHal_pContSenModesRegsArray[2][2]2 700012E6 */ - {0x0F12, 0x0001}, /* #senHal_pContSenModesRegsArray[2][3]2 700012E8 */ - {0x0F12, 0x0885}, /* #senHal_pContSenModesRegsArray[3][0]2 700012EA */ - {0x0F12, 0x0467}, /* #senHal_pContSenModesRegsArray[3][1]2 700012EC */ - {0x0F12, 0x0501}, /* #senHal_pContSenModesRegsArray[3][2]2 700012EE */ - {0x0F12, 0x02A5}, /* #senHal_pContSenModesRegsArray[3][3]2 700012F0 */ - {0x0F12, 0x0001}, /* #senHal_pContSenModesRegsArray[4][0]2 700012F2 */ - {0x0F12, 0x046A}, /* #senHal_pContSenModesRegsArray[4][1]2 700012F4 */ - {0x0F12, 0x0001}, /* #senHal_pContSenModesRegsArray[4][2]2 700012F6 */ - {0x0F12, 0x02A8}, /* #senHal_pContSenModesRegsArray[4][3]2 700012F8 */ - {0x0F12, 0x0885}, /* #senHal_pContSenModesRegsArray[5][0]2 700012FA */ - {0x0F12, 0x08D0}, /* #senHal_pContSenModesRegsArray[5][1]2 700012FC */ - {0x0F12, 0x0501}, /* #senHal_pContSenModesRegsArray[5][2]2 700012FE */ - {0x0F12, 0x054C}, /* #senHal_pContSenModesRegsArray[5][3]2 70001300 */ - {0x0F12, 0x0006}, /* #senHal_pContSenModesRegsArray[6][0]2 70001302 */ - {0x0F12, 0x0020}, /* #senHal_pContSenModesRegsArray[6][1]2 70001304 */ - {0x0F12, 0x0006}, /* #senHal_pContSenModesRegsArray[6][2]2 70001306 */ - {0x0F12, 0x0020}, /* #senHal_pContSenModesRegsArray[6][3]2 70001308 */ - {0x0F12, 0x0881}, /* #senHal_pContSenModesRegsArray[7][0]2 7000130A */ - {0x0F12, 0x0463}, /* #senHal_pContSenModesRegsArray[7][1]2 7000130C */ - {0x0F12, 0x04FD}, /* #senHal_pContSenModesRegsArray[7][2]2 7000130E */ - {0x0F12, 0x02A1}, /* #senHal_pContSenModesRegsArray[7][3]2 70001310 */ - {0x0F12, 0x0006}, /* #senHal_pContSenModesRegsArray[8][0]2 70001312 */ - {0x0F12, 0x0489}, /* #senHal_pContSenModesRegsArray[8][1]2 70001314 */ - {0x0F12, 0x0006}, /* #senHal_pContSenModesRegsArray[8][2]2 70001316 */ - {0x0F12, 0x02C7}, /* #senHal_pContSenModesRegsArray[8][3]2 70001318 */ - {0x0F12, 0x0881}, /* #senHal_pContSenModesRegsArray[9][0]2 7000131A */ - {0x0F12, 0x08CC}, /* #senHal_pContSenModesRegsArray[9][1]2 7000131C */ - {0x0F12, 0x04FD}, /* #senHal_pContSenModesRegsArray[9][2]2 7000131E */ - {0x0F12, 0x0548}, /* #senHal_pContSenModesRegsArray[9][3]2 70001320 */ - {0x0F12, 0x03A2}, /* #senHal_pContSenModesRegsArray[10][0] 2 70001322 */ - {0x0F12, 0x01D3}, /* #senHal_pContSenModesRegsArray[10][1] 2 70001324 */ - {0x0F12, 0x01E0}, /* #senHal_pContSenModesRegsArray[10][2] 2 70001326 */ - {0x0F12, 0x00F2}, /* #senHal_pContSenModesRegsArray[10][3] 2 70001328 */ - {0x0F12, 0x03F2}, /* #senHal_pContSenModesRegsArray[11][0] 2 7000132A */ - {0x0F12, 0x0223}, /* #senHal_pContSenModesRegsArray[11][1] 2 7000132C */ - {0x0F12, 0x0230}, /* #senHal_pContSenModesRegsArray[11][2] 2 7000132E */ - {0x0F12, 0x0142}, /* #senHal_pContSenModesRegsArray[11][3] 2 70001330 */ - {0x0F12, 0x03A2}, /* #senHal_pContSenModesRegsArray[12][0] 2 70001332 */ - {0x0F12, 0x063C}, /* #senHal_pContSenModesRegsArray[12][1] 2 70001334 */ - {0x0F12, 0x01E0}, /* #senHal_pContSenModesRegsArray[12][2] 2 70001336 */ - {0x0F12, 0x0399}, /* #senHal_pContSenModesRegsArray[12][3] 2 70001338 */ - {0x0F12, 0x03F2}, /* #senHal_pContSenModesRegsArray[13][0] 2 7000133A */ - {0x0F12, 0x068C}, /* #senHal_pContSenModesRegsArray[13][1] 2 7000133C */ - {0x0F12, 0x0230}, /* #senHal_pContSenModesRegsArray[13][2] 2 7000133E */ - {0x0F12, 0x03E9}, /* #senHal_pContSenModesRegsArray[13][3] 2 70001340 */ - {0x0F12, 0x0002}, /* #senHal_pContSenModesRegsArray[14][0] 2 70001342 */ - {0x0F12, 0x0002}, /* #senHal_pContSenModesRegsArray[14][1] 2 70001344 */ - {0x0F12, 0x0002}, /* #senHal_pContSenModesRegsArray[14][2] 2 70001346 */ - {0x0F12, 0x0002}, /* #senHal_pContSenModesRegsArray[14][3] 2 70001348 */ - {0x0F12, 0x003C}, /* #senHal_pContSenModesRegsArray[15][0] 2 7000134A */ - {0x0F12, 0x003C}, /* #senHal_pContSenModesRegsArray[15][1] 2 7000134C */ - {0x0F12, 0x003C}, /* #senHal_pContSenModesRegsArray[15][2] 2 7000134E */ - {0x0F12, 0x003C}, /* #senHal_pContSenModesRegsArray[15][3] 2 70001350 */ - {0x0F12, 0x01D3}, /* #senHal_pContSenModesRegsArray[16][0] 2 70001352 */ - {0x0F12, 0x01D3}, /* #senHal_pContSenModesRegsArray[16][1] 2 70001354 */ - {0x0F12, 0x00F2}, /* #senHal_pContSenModesRegsArray[16][2] 2 70001356 */ - {0x0F12, 0x00F2}, /* #senHal_pContSenModesRegsArray[16][3] 2 70001358 */ - {0x0F12, 0x020B}, /* #senHal_pContSenModesRegsArray[17][0] 2 7000135A */ - {0x0F12, 0x024A}, /* #senHal_pContSenModesRegsArray[17][1] 2 7000135C */ - {0x0F12, 0x012A}, /* #senHal_pContSenModesRegsArray[17][2] 2 7000135E */ - {0x0F12, 0x0169}, /* #senHal_pContSenModesRegsArray[17][3] 2 70001360 */ - {0x0F12, 0x0002}, /* #senHal_pContSenModesRegsArray[18][0] 2 70001362 */ - {0x0F12, 0x046B}, /* #senHal_pContSenModesRegsArray[18][1] 2 70001364 */ - {0x0F12, 0x0002}, /* #senHal_pContSenModesRegsArray[18][2] 2 70001366 */ - {0x0F12, 0x02A9}, /* #senHal_pContSenModesRegsArray[18][3] 2 70001368 */ - {0x0F12, 0x0419}, /* #senHal_pContSenModesRegsArray[19][0] 2 7000136A */ - {0x0F12, 0x04A5}, /* #senHal_pContSenModesRegsArray[19][1] 2 7000136C */ - {0x0F12, 0x0257}, /* #senHal_pContSenModesRegsArray[19][2] 2 7000136E */ - {0x0F12, 0x02E3}, /* #senHal_pContSenModesRegsArray[19][3] 2 70001370 */ - {0x0F12, 0x0630}, /* #senHal_pContSenModesRegsArray[20][0] 2 70001372 */ - {0x0F12, 0x063C}, /* #senHal_pContSenModesRegsArray[20][1] 2 70001374 */ - {0x0F12, 0x038D}, /* #senHal_pContSenModesRegsArray[20][2] 2 70001376 */ - {0x0F12, 0x0399}, /* #senHal_pContSenModesRegsArray[20][3] 2 70001378 */ - {0x0F12, 0x0668}, /* #senHal_pContSenModesRegsArray[21][0] 2 7000137A */ - {0x0F12, 0x06B3}, /* #senHal_pContSenModesRegsArray[21][1] 2 7000137C */ - {0x0F12, 0x03C5}, /* #senHal_pContSenModesRegsArray[21][2] 2 7000137E */ - {0x0F12, 0x0410}, /* #senHal_pContSenModesRegsArray[21][3] 2 70001380 */ - {0x0F12, 0x0001}, /* #senHal_pContSenModesRegsArray[22][0] 2 70001382 */ - {0x0F12, 0x0001}, /* #senHal_pContSenModesRegsArray[22][1] 2 70001384 */ - {0x0F12, 0x0001}, /* #senHal_pContSenModesRegsArray[22][2] 2 70001386 */ - {0x0F12, 0x0001}, /* #senHal_pContSenModesRegsArray[22][3] 2 70001388 */ - {0x0F12, 0x03A2}, /* #senHal_pContSenModesRegsArray[23][0] 2 7000138A */ - {0x0F12, 0x01D3}, /* #senHal_pContSenModesRegsArray[23][1] 2 7000138C */ - {0x0F12, 0x01E0}, /* #senHal_pContSenModesRegsArray[23][2] 2 7000138E */ - {0x0F12, 0x00F2}, /* #senHal_pContSenModesRegsArray[23][3] 2 70001390 */ - {0x0F12, 0x0000}, /* #senHal_pContSenModesRegsArray[24][0] 2 70001392 */ - {0x0F12, 0x0461}, /* #senHal_pContSenModesRegsArray[24][1] 2 70001394 */ - {0x0F12, 0x0000}, /* #senHal_pContSenModesRegsArray[24][2] 2 70001396 */ - {0x0F12, 0x029F}, /* #senHal_pContSenModesRegsArray[24][3] 2 70001398 */ - {0x0F12, 0x0000}, /* #senHal_pContSenModesRegsArray[25][0] 2 7000139A */ - {0x0F12, 0x063C}, /* #senHal_pContSenModesRegsArray[25][1] 2 7000139C */ - {0x0F12, 0x0000}, /* #senHal_pContSenModesRegsArray[25][2] 2 7000139E */ - {0x0F12, 0x0399}, /* #senHal_pContSenModesRegsArray[25][3] 2 700013A0 */ - {0x0F12, 0x003D}, /* #senHal_pContSenModesRegsArray[26][0] 2 700013A2 */ - {0x0F12, 0x003D}, /* #senHal_pContSenModesRegsArray[26][1] 2 700013A4 */ - {0x0F12, 0x003D}, /* #senHal_pContSenModesRegsArray[26][2] 2 700013A6 */ - {0x0F12, 0x003D}, /* #senHal_pContSenModesRegsArray[26][3] 2 700013A8 */ - {0x0F12, 0x01D0}, /* #senHal_pContSenModesRegsArray[27][0] 2 700013AA */ - {0x0F12, 0x01D0}, /* #senHal_pContSenModesRegsArray[27][1] 2 700013AC */ - {0x0F12, 0x00EF}, /* #senHal_pContSenModesRegsArray[27][2] 2 700013AE */ - {0x0F12, 0x00EF}, /* #senHal_pContSenModesRegsArray[27][3] 2 700013B0 */ - {0x0F12, 0x020C}, /* #senHal_pContSenModesRegsArray[28][0] 2 700013B2 */ - {0x0F12, 0x024B}, /* #senHal_pContSenModesRegsArray[28][1] 2 700013B4 */ - {0x0F12, 0x012B}, /* #senHal_pContSenModesRegsArray[28][2] 2 700013B6 */ - {0x0F12, 0x016A}, /* #senHal_pContSenModesRegsArray[28][3] 2 700013B8 */ - {0x0F12, 0x039F}, /* #senHal_pContSenModesRegsArray[29][0] 2 700013BA */ - {0x0F12, 0x045E}, /* #senHal_pContSenModesRegsArray[29][1] 2 700013BC */ - {0x0F12, 0x01DD}, /* #senHal_pContSenModesRegsArray[29][2] 2 700013BE */ - {0x0F12, 0x029C}, /* #senHal_pContSenModesRegsArray[29][3] 2 700013C0 */ - {0x0F12, 0x041A}, /* #senHal_pContSenModesRegsArray[30][0] 2 700013C2 */ - {0x0F12, 0x04A6}, /* #senHal_pContSenModesRegsArray[30][1] 2 700013C4 */ - {0x0F12, 0x0258}, /* #senHal_pContSenModesRegsArray[30][2] 2 700013C6 */ - {0x0F12, 0x02E4}, /* #senHal_pContSenModesRegsArray[30][3] 2 700013C8 */ - {0x0F12, 0x062D}, /* #senHal_pContSenModesRegsArray[31][0] 2 700013CA */ - {0x0F12, 0x0639}, /* #senHal_pContSenModesRegsArray[31][1] 2 700013CC */ - {0x0F12, 0x038A}, /* #senHal_pContSenModesRegsArray[31][2] 2 700013CE */ - {0x0F12, 0x0396}, /* #senHal_pContSenModesRegsArray[31][3] 2 700013D0 */ - {0x0F12, 0x0669}, /* #senHal_pContSenModesRegsArray[32][0] 2 700013D2 */ - {0x0F12, 0x06B4}, /* #senHal_pContSenModesRegsArray[32][1] 2 700013D4 */ - {0x0F12, 0x03C6}, /* #senHal_pContSenModesRegsArray[32][2] 2 700013D6 */ - {0x0F12, 0x0411}, /* #senHal_pContSenModesRegsArray[32][3] 2 700013D8 */ - {0x0F12, 0x087C}, /* #senHal_pContSenModesRegsArray[33][0] 2 700013DA */ - {0x0F12, 0x08C7}, /* #senHal_pContSenModesRegsArray[33][1] 2 700013DC */ - {0x0F12, 0x04F8}, /* #senHal_pContSenModesRegsArray[33][2] 2 700013DE */ - {0x0F12, 0x0543}, /* #senHal_pContSenModesRegsArray[33][3] 2 700013E0 */ - {0x0F12, 0x0040}, /* #senHal_pContSenModesRegsArray[34][0] 2 700013E2 */ - {0x0F12, 0x0040}, /* #senHal_pContSenModesRegsArray[34][1] 2 700013E4 */ - {0x0F12, 0x0040}, /* #senHal_pContSenModesRegsArray[34][2] 2 700013E6 */ - {0x0F12, 0x0040}, /* #senHal_pContSenModesRegsArray[34][3] 2 700013E8 */ - {0x0F12, 0x01D0}, /* #senHal_pContSenModesRegsArray[35][0] 2 700013EA */ - {0x0F12, 0x01D0}, /* #senHal_pContSenModesRegsArray[35][1] 2 700013EC */ - {0x0F12, 0x00EF}, /* #senHal_pContSenModesRegsArray[35][2] 2 700013EE */ - {0x0F12, 0x00EF}, /* #senHal_pContSenModesRegsArray[35][3] 2 700013F0 */ - {0x0F12, 0x020F}, /* #senHal_pContSenModesRegsArray[36][0] 2 700013F2 */ - {0x0F12, 0x024E}, /* #senHal_pContSenModesRegsArray[36][1] 2 700013F4 */ - {0x0F12, 0x012E}, /* #senHal_pContSenModesRegsArray[36][2] 2 700013F6 */ - {0x0F12, 0x016D}, /* #senHal_pContSenModesRegsArray[36][3] 2 700013F8 */ - {0x0F12, 0x039F}, /* #senHal_pContSenModesRegsArray[37][0] 2 700013FA */ - {0x0F12, 0x045E}, /* #senHal_pContSenModesRegsArray[37][1] 2 700013FC */ - {0x0F12, 0x01DD}, /* #senHal_pContSenModesRegsArray[37][2] 2 700013FE */ - {0x0F12, 0x029C}, /* #senHal_pContSenModesRegsArray[37][3] 2 70001400 */ - {0x0F12, 0x041D}, /* #senHal_pContSenModesRegsArray[38][0] 2 70001402 */ - {0x0F12, 0x04A9}, /* #senHal_pContSenModesRegsArray[38][1] 2 70001404 */ - {0x0F12, 0x025B}, /* #senHal_pContSenModesRegsArray[38][2] 2 70001406 */ - {0x0F12, 0x02E7}, /* #senHal_pContSenModesRegsArray[38][3] 2 70001408 */ - {0x0F12, 0x062D}, /* #senHal_pContSenModesRegsArray[39][0] 2 7000140A */ - {0x0F12, 0x0639}, /* #senHal_pContSenModesRegsArray[39][1] 2 7000140C */ - {0x0F12, 0x038A}, /* #senHal_pContSenModesRegsArray[39][2] 2 7000140E */ - {0x0F12, 0x0396}, /* #senHal_pContSenModesRegsArray[39][3] 2 70001410 */ - {0x0F12, 0x066C}, /* #senHal_pContSenModesRegsArray[40][0] 2 70001412 */ - {0x0F12, 0x06B7}, /* #senHal_pContSenModesRegsArray[40][1] 2 70001414 */ - {0x0F12, 0x03C9}, /* #senHal_pContSenModesRegsArray[40][2] 2 70001416 */ - {0x0F12, 0x0414}, /* #senHal_pContSenModesRegsArray[40][3] 2 70001418 */ - {0x0F12, 0x087C}, /* #senHal_pContSenModesRegsArray[41][0] 2 7000141A */ - {0x0F12, 0x08C7}, /* #senHal_pContSenModesRegsArray[41][1] 2 7000141C */ - {0x0F12, 0x04F8}, /* #senHal_pContSenModesRegsArray[41][2] 2 7000141E */ - {0x0F12, 0x0543}, /* #senHal_pContSenModesRegsArray[41][3] 2 70001420 */ - {0x0F12, 0x0040}, /* #senHal_pContSenModesRegsArray[42][0] 2 70001422 */ - {0x0F12, 0x0040}, /* #senHal_pContSenModesRegsArray[42][1] 2 70001424 */ - {0x0F12, 0x0040}, /* #senHal_pContSenModesRegsArray[42][2] 2 70001426 */ - {0x0F12, 0x0040}, /* #senHal_pContSenModesRegsArray[42][3] 2 70001428 */ - {0x0F12, 0x01D0}, /* #senHal_pContSenModesRegsArray[43][0] 2 7000142A */ - {0x0F12, 0x01D0}, /* #senHal_pContSenModesRegsArray[43][1] 2 7000142C */ - {0x0F12, 0x00EF}, /* #senHal_pContSenModesRegsArray[43][2] 2 7000142E */ - {0x0F12, 0x00EF}, /* #senHal_pContSenModesRegsArray[43][3] 2 70001430 */ - {0x0F12, 0x020F}, /* #senHal_pContSenModesRegsArray[44][0] 2 70001432 */ - {0x0F12, 0x024E}, /* #senHal_pContSenModesRegsArray[44][1] 2 70001434 */ - {0x0F12, 0x012E}, /* #senHal_pContSenModesRegsArray[44][2] 2 70001436 */ - {0x0F12, 0x016D}, /* #senHal_pContSenModesRegsArray[44][3] 2 70001438 */ - {0x0F12, 0x039F}, /* #senHal_pContSenModesRegsArray[45][0] 2 7000143A */ - {0x0F12, 0x045E}, /* #senHal_pContSenModesRegsArray[45][1] 2 7000143C */ - {0x0F12, 0x01DD}, /* #senHal_pContSenModesRegsArray[45][2] 2 7000143E */ - {0x0F12, 0x029C}, /* #senHal_pContSenModesRegsArray[45][3] 2 70001440 */ - {0x0F12, 0x041D}, /* #senHal_pContSenModesRegsArray[46][0] 2 70001442 */ - {0x0F12, 0x04A9}, /* #senHal_pContSenModesRegsArray[46][1] 2 70001444 */ - {0x0F12, 0x025B}, /* #senHal_pContSenModesRegsArray[46][2] 2 70001446 */ - {0x0F12, 0x02E7}, /* #senHal_pContSenModesRegsArray[46][3] 2 70001448 */ - {0x0F12, 0x062D}, /* #senHal_pContSenModesRegsArray[47][0] 2 7000144A */ - {0x0F12, 0x0639}, /* #senHal_pContSenModesRegsArray[47][1] 2 7000144C */ - {0x0F12, 0x038A}, /* #senHal_pContSenModesRegsArray[47][2] 2 7000144E */ - {0x0F12, 0x0396}, /* #senHal_pContSenModesRegsArray[47][3] 2 70001450 */ - {0x0F12, 0x066C}, /* #senHal_pContSenModesRegsArray[48][0] 2 70001452 */ - {0x0F12, 0x06B7}, /* #senHal_pContSenModesRegsArray[48][1] 2 70001454 */ - {0x0F12, 0x03C9}, /* #senHal_pContSenModesRegsArray[48][2] 2 70001456 */ - {0x0F12, 0x0414}, /* #senHal_pContSenModesRegsArray[48][3] 2 70001458 */ - {0x0F12, 0x087C}, /* #senHal_pContSenModesRegsArray[49][0] 2 7000145A */ - {0x0F12, 0x08C7}, /* #senHal_pContSenModesRegsArray[49][1] 2 7000145C */ - {0x0F12, 0x04F8}, /* #senHal_pContSenModesRegsArray[49][2] 2 7000145E */ - {0x0F12, 0x0543}, /* #senHal_pContSenModesRegsArray[49][3] 2 70001460 */ - {0x0F12, 0x003D}, /* #senHal_pContSenModesRegsArray[50][0] 2 70001462 */ - {0x0F12, 0x003D}, /* #senHal_pContSenModesRegsArray[50][1] 2 70001464 */ - {0x0F12, 0x003D}, /* #senHal_pContSenModesRegsArray[50][2] 2 70001466 */ - {0x0F12, 0x003D}, /* #senHal_pContSenModesRegsArray[50][3] 2 70001468 */ - {0x0F12, 0x01D2}, /* #senHal_pContSenModesRegsArray[51][0] 2 7000146A */ - {0x0F12, 0x01D2}, /* #senHal_pContSenModesRegsArray[51][1] 2 7000146C */ - {0x0F12, 0x00F1}, /* #senHal_pContSenModesRegsArray[51][2] 2 7000146E */ - {0x0F12, 0x00F1}, /* #senHal_pContSenModesRegsArray[51][3] 2 70001470 */ - {0x0F12, 0x020C}, /* #senHal_pContSenModesRegsArray[52][0] 2 70001472 */ - {0x0F12, 0x024B}, /* #senHal_pContSenModesRegsArray[52][1] 2 70001474 */ - {0x0F12, 0x012B}, /* #senHal_pContSenModesRegsArray[52][2] 2 70001476 */ - {0x0F12, 0x016A}, /* #senHal_pContSenModesRegsArray[52][3] 2 70001478 */ - {0x0F12, 0x03A1}, /* #senHal_pContSenModesRegsArray[53][0] 2 7000147A */ - {0x0F12, 0x0460}, /* #senHal_pContSenModesRegsArray[53][1] 2 7000147C */ - {0x0F12, 0x01DF}, /* #senHal_pContSenModesRegsArray[53][2] 2 7000147E */ - {0x0F12, 0x029E}, /* #senHal_pContSenModesRegsArray[53][3] 2 70001480 */ - {0x0F12, 0x041A}, /* #senHal_pContSenModesRegsArray[54][0] 2 70001482 */ - {0x0F12, 0x04A6}, /* #senHal_pContSenModesRegsArray[54][1] 2 70001484 */ - {0x0F12, 0x0258}, /* #senHal_pContSenModesRegsArray[54][2] 2 70001486 */ - {0x0F12, 0x02E4}, /* #senHal_pContSenModesRegsArray[54][3] 2 70001488 */ - {0x0F12, 0x062F}, /* #senHal_pContSenModesRegsArray[55][0] 2 7000148A */ - {0x0F12, 0x063B}, /* #senHal_pContSenModesRegsArray[55][1] 2 7000148C */ - {0x0F12, 0x038C}, /* #senHal_pContSenModesRegsArray[55][2] 2 7000148E */ - {0x0F12, 0x0398}, /* #senHal_pContSenModesRegsArray[55][3] 2 70001490 */ - {0x0F12, 0x0669}, /* #senHal_pContSenModesRegsArray[56][0] 2 70001492 */ - {0x0F12, 0x06B4}, /* #senHal_pContSenModesRegsArray[56][1] 2 70001494 */ - {0x0F12, 0x03C6}, /* #senHal_pContSenModesRegsArray[56][2] 2 70001496 */ - {0x0F12, 0x0411}, /* #senHal_pContSenModesRegsArray[56][3] 2 70001498 */ - {0x0F12, 0x087E}, /* #senHal_pContSenModesRegsArray[57][0] 2 7000149A */ - {0x0F12, 0x08C9}, /* #senHal_pContSenModesRegsArray[57][1] 2 7000149C */ - {0x0F12, 0x04FA}, /* #senHal_pContSenModesRegsArray[57][2] 2 7000149E */ - {0x0F12, 0x0545}, /* #senHal_pContSenModesRegsArray[57][3] 2 700014A0 */ - {0x0F12, 0x03A2}, /* #senHal_pContSenModesRegsArray[58][0] 2 700014A2 */ - {0x0F12, 0x01D3}, /* #senHal_pContSenModesRegsArray[58][1] 2 700014A4 */ - {0x0F12, 0x01E0}, /* #senHal_pContSenModesRegsArray[58][2] 2 700014A6 */ - {0x0F12, 0x00F2}, /* #senHal_pContSenModesRegsArray[58][3] 2 700014A8 */ - {0x0F12, 0x03AF}, /* #senHal_pContSenModesRegsArray[59][0] 2 700014AA */ - {0x0F12, 0x01E0}, /* #senHal_pContSenModesRegsArray[59][1] 2 700014AC */ - {0x0F12, 0x01ED}, /* #senHal_pContSenModesRegsArray[59][2] 2 700014AE */ - {0x0F12, 0x00FF}, /* #senHal_pContSenModesRegsArray[59][3] 2 700014B0 */ - {0x0F12, 0x0000}, /* #senHal_pContSenModesRegsArray[60][0] 2 700014B2 */ - {0x0F12, 0x0461}, /* #senHal_pContSenModesRegsArray[60][1] 2 700014B4 */ - {0x0F12, 0x0000}, /* #senHal_pContSenModesRegsArray[60][2] 2 700014B6 */ - {0x0F12, 0x029F}, /* #senHal_pContSenModesRegsArray[60][3] 2 700014B8 */ - {0x0F12, 0x0000}, /* #senHal_pContSenModesRegsArray[61][0] 2 700014BA */ - {0x0F12, 0x046E}, /* #senHal_pContSenModesRegsArray[61][1] 2 700014BC */ - {0x0F12, 0x0000}, /* #senHal_pContSenModesRegsArray[61][2] 2 700014BE */ - {0x0F12, 0x02AC}, /* #senHal_pContSenModesRegsArray[61][3] 2 700014C0 */ - {0x0F12, 0x0000}, /* #senHal_pContSenModesRegsArray[62][0] 2 700014C2 */ - {0x0F12, 0x063C}, /* #senHal_pContSenModesRegsArray[62][1] 2 700014C4 */ - {0x0F12, 0x0000}, /* #senHal_pContSenModesRegsArray[62][2] 2 700014C6 */ - {0x0F12, 0x0399}, /* #senHal_pContSenModesRegsArray[62][3] 2 700014C8 */ - {0x0F12, 0x0000}, /* #senHal_pContSenModesRegsArray[63][0] 2 700014CA */ - {0x0F12, 0x0649}, /* #senHal_pContSenModesRegsArray[63][1] 2 700014CC */ - {0x0F12, 0x0000}, /* #senHal_pContSenModesRegsArray[63][2] 2 700014CE */ - {0x0F12, 0x03A6}, /* #senHal_pContSenModesRegsArray[63][3] 2 700014D0 */ - {0x0F12, 0x0000}, /* #senHal_pContSenModesRegsArray[64][0] 2 700014D2 */ - {0x0F12, 0x0000}, /* #senHal_pContSenModesRegsArray[64][1] 2 700014D4 */ - {0x0F12, 0x0000}, /* #senHal_pContSenModesRegsArray[64][2] 2 700014D6 */ - {0x0F12, 0x0000}, /* #senHal_pContSenModesRegsArray[64][3] 2 700014D8 */ - {0x0F12, 0x0000}, /* #senHal_pContSenModesRegsArray[65][0] 2 700014DA */ - {0x0F12, 0x0000}, /* #senHal_pContSenModesRegsArray[65][1] 2 700014DC */ - {0x0F12, 0x0000}, /* #senHal_pContSenModesRegsArray[65][2] 2 700014DE */ - {0x0F12, 0x0000}, /* #senHal_pContSenModesRegsArray[65][3] 2 700014E0 */ - {0x0F12, 0x03AA}, /* #senHal_pContSenModesRegsArray[66][0] 2 700014E2 */ - {0x0F12, 0x01DB}, /* #senHal_pContSenModesRegsArray[66][1] 2 700014E4 */ - {0x0F12, 0x01E8}, /* #senHal_pContSenModesRegsArray[66][2] 2 700014E6 */ - {0x0F12, 0x00FA}, /* #senHal_pContSenModesRegsArray[66][3] 2 700014E8 */ - {0x0F12, 0x03B7}, /* #senHal_pContSenModesRegsArray[67][0] 2 700014EA */ - {0x0F12, 0x01E8}, /* #senHal_pContSenModesRegsArray[67][1] 2 700014EC */ - {0x0F12, 0x01F5}, /* #senHal_pContSenModesRegsArray[67][2] 2 700014EE */ - {0x0F12, 0x0107}, /* #senHal_pContSenModesRegsArray[67][3] 2 700014F0 */ - {0x0F12, 0x0000}, /* #senHal_pContSenModesRegsArray[68][0] 2 700014F2 */ - {0x0F12, 0x0469}, /* #senHal_pContSenModesRegsArray[68][1] 2 700014F4 */ - {0x0F12, 0x0000}, /* #senHal_pContSenModesRegsArray[68][2] 2 700014F6 */ - {0x0F12, 0x02A7}, /* #senHal_pContSenModesRegsArray[68][3] 2 700014F8 */ - {0x0F12, 0x0000}, /* #senHal_pContSenModesRegsArray[69][0] 2 700014FA */ - {0x0F12, 0x0476}, /* #senHal_pContSenModesRegsArray[69][1] 2 700014FC */ - {0x0F12, 0x0000}, /* #senHal_pContSenModesRegsArray[69][2] 2 700014FE */ - {0x0F12, 0x02B4}, /* #senHal_pContSenModesRegsArray[69][3] 2 70001500 */ - {0x0F12, 0x0000}, /* #senHal_pContSenModesRegsArray[70][0] 2 70001502 */ - {0x0F12, 0x0644}, /* #senHal_pContSenModesRegsArray[70][1] 2 70001504 */ - {0x0F12, 0x0000}, /* #senHal_pContSenModesRegsArray[70][2] 2 70001506 */ - {0x0F12, 0x03A1}, /* #senHal_pContSenModesRegsArray[70][3] 2 70001508 */ - {0x0F12, 0x0000}, /* #senHal_pContSenModesRegsArray[71][0] 2 7000150A */ - {0x0F12, 0x0651}, /* #senHal_pContSenModesRegsArray[71][1] 2 7000150C */ - {0x0F12, 0x0000}, /* #senHal_pContSenModesRegsArray[71][2] 2 7000150E */ - {0x0F12, 0x03AE}, /* #senHal_pContSenModesRegsArray[71][3] 2 70001510 */ - {0x0F12, 0x0000}, /* #senHal_pContSenModesRegsArray[72][0] 2 70001512 */ - {0x0F12, 0x0000}, /* #senHal_pContSenModesRegsArray[72][1] 2 70001514 */ - {0x0F12, 0x0000}, /* #senHal_pContSenModesRegsArray[72][2] 2 70001516 */ - {0x0F12, 0x0000}, /* #senHal_pContSenModesRegsArray[72][3] 2 70001518 */ - {0x0F12, 0x0000}, /* #senHal_pContSenModesRegsArray[73][0] 2 7000151A */ - {0x0F12, 0x0000}, /* #senHal_pContSenModesRegsArray[73][1] 2 7000151C */ - {0x0F12, 0x0000}, /* #senHal_pContSenModesRegsArray[73][2] 2 7000151E */ - {0x0F12, 0x0000}, /* #senHal_pContSenModesRegsArray[73][3] 2 70001520 */ - {0x0F12, 0x0001}, /* #senHal_pContSenModesRegsArray[74][0] 2 70001522 */ - {0x0F12, 0x0001}, /* #senHal_pContSenModesRegsArray[74][1] 2 70001524 */ - {0x0F12, 0x0001}, /* #senHal_pContSenModesRegsArray[74][2] 2 70001526 */ - {0x0F12, 0x0001}, /* #senHal_pContSenModesRegsArray[74][3] 2 70001528 */ - {0x0F12, 0x000F}, /* #senHal_pContSenModesRegsArray[75][0] 2 7000152A */ - {0x0F12, 0x000F}, /* #senHal_pContSenModesRegsArray[75][1] 2 7000152C */ - {0x0F12, 0x000F}, /* #senHal_pContSenModesRegsArray[75][2] 2 7000152E */ - {0x0F12, 0x000F}, /* #senHal_pContSenModesRegsArray[75][3] 2 70001530 */ - {0x0F12, 0x05AD}, /* #senHal_pContSenModesRegsArray[76][0] 2 70001532 */ - {0x0F12, 0x03DE}, /* #senHal_pContSenModesRegsArray[76][1] 2 70001534 */ - {0x0F12, 0x030A}, /* #senHal_pContSenModesRegsArray[76][2] 2 70001536 */ - {0x0F12, 0x021C}, /* #senHal_pContSenModesRegsArray[76][3] 2 70001538 */ - {0x0F12, 0x062F}, /* #senHal_pContSenModesRegsArray[77][0] 2 7000153A */ - {0x0F12, 0x0460}, /* #senHal_pContSenModesRegsArray[77][1] 2 7000153C */ - {0x0F12, 0x038C}, /* #senHal_pContSenModesRegsArray[77][2] 2 7000153E */ - {0x0F12, 0x029E}, /* #senHal_pContSenModesRegsArray[77][3] 2 70001540 */ - {0x0F12, 0x07FC}, /* #senHal_pContSenModesRegsArray[78][0] 2 70001542 */ - {0x0F12, 0x0847}, /* #senHal_pContSenModesRegsArray[78][1] 2 70001544 */ - {0x0F12, 0x0478}, /* #senHal_pContSenModesRegsArray[78][2] 2 70001546 */ - {0x0F12, 0x04C3}, /* #senHal_pContSenModesRegsArray[78][3] 2 70001548 */ - {0x0F12, 0x0000}, /* #senHal_pContSenModesRegsArray[79][0] 2 7000154A */ - {0x0F12, 0x0000}, /* #senHal_pContSenModesRegsArray[79][1] 2 7000154C */ - {0x0F12, 0x0000}, /* #senHal_pContSenModesRegsArray[79][2] 2 7000154E */ - {0x0F12, 0x0000}, /* #senHal_pContSenModesRegsArray[79][3] 2 70001550 */ - /* Analog Setting END */ - - /* ISP-FE Setting */ - {0x002A, 0x158A}, - {0x0F12, 0xEAF0}, - {0x002A, 0x15C6}, - {0x0F12, 0x0020}, - {0x0F12, 0x0060}, - {0x002A, 0x15BC}, - {0x0F12, 0x0200}, - /* Analog Offset for MSM */ - {0x002A, 0x1608}, - {0x0F12, 0x0100}, /* #gisp_msm_sAnalogOffset[0] */ - {0x0F12, 0x0100}, /* #gisp_msm_sAnalogOffset[1] */ - {0x0F12, 0x0100}, /* #gisp_msm_sAnalogOffset[2] */ - {0x0F12, 0x0100}, /* #gisp_msm_sAnalogOffset[3] */ - /* ISP-FE Setting END */ - - /* ===== Frame rate setting ===== */ - /* How to set */ - /* 1. Exposure value */ - /* dec2hex((1 / (frame rate you want(ms))) * 100d * 4d) */ - /* 2. Analog Digital gain */ - /* dec2hex((Analog gain you want) * 256d) */ - - /* Set preview exposure time */ - {0x002A, 0x0530}, - {0x0F12, 0x3415}, /* #lt_uMaxExp1 */ - {0x0F12, 0x0000}, - {0x0F12, 0x6720}, /* #lt_uMaxExp2 */ - {0x0F12, 0x0000}, - {0x002A, 0x167C}, - {0x0F12, 0x9AB0}, /* #evt1_lt_uMaxExp3 */ - {0x0F12, 0x0000}, - {0x0F12, 0xD055}, /* #evt1_lt_uMaxExp4 */ - {0x0F12, 0x0000}, - - /* Set capture exposure time */ - {0x002A, 0x0538}, - {0x0F12, 0x9C40}, /* #lt_uCapMaxExp1 */ - {0x0F12, 0x0000}, - {0x0F12, 0xD055}, /* #lt_uCapMaxExp2 */ - {0x0F12, 0x0000}, - {0x002A, 0x1684}, - {0x0F12, 0x0360}, /* #evt1_lt_uCapMaxExp3 */ - {0x0F12, 0x0001}, - {0x0F12, 0x3880}, /* #evt1_lt_uCapMaxExp4 */ - {0x0F12, 0x0001}, - - /* Set gain */ - {0x002A, 0x0540}, - {0x0F12, 0x0150}, /* #lt_uMaxAnGain1 */ - {0x0F12, 0x0280}, /* #lt_uMaxAnGain2 */ - {0x002A, 0x168C}, - {0x0F12, 0x02A0}, /* #evt1_lt_uMaxAnGain3 */ - {0x0F12, 0x0700}, /* #evt1_lt_uMaxAnGain4 */ - {0x002A, 0x0544}, - {0x0F12, 0x0100}, /* #lt_uMaxDigGain */ - {0x0F12, 0x1000}, /* #lt_uMaxTotGain */ - {0x002A, 0x1694}, - {0x0F12, 0x0001}, /* #evt1_senHal_bExpandForbid */ - {0x002A, 0x051A}, - {0x0F12, 0x0111}, /* #lt_uLimitHigh */ - {0x0F12, 0x00F0}, /* #lt_uLimitLow */ - {0x002A, 0x0562}, - {0x0F12, 0x0001}, - - /* Set Auto Exposure */ - /* AE target */ - {0x002A, 0x0F70}, - {0x0F12, 0x003A}, /* #TVAR_ae_BrAve */ - /* AE mode */ - {0x002A, 0x0F76}, /* Disable illumination & contrast #ae_StatMode */ - {0x0F12, 0x000F}, - /* AE weight */ - {0x002A, 0x0F7E}, - {0x0F12, 0x0101}, /* #ae_WeightTbl_16_0_ */ - {0x0F12, 0x0101}, /* #ae_WeightTbl_16_1_ */ - {0x0F12, 0x0101}, /* #ae_WeightTbl_16_2_ */ - {0x0F12, 0x0101}, /* #ae_WeightTbl_16_3_ */ - {0x0F12, 0x0101}, /* #ae_WeightTbl_16_4_ */ - {0x0F12, 0x0101}, /* #ae_WeightTbl_16_5_ */ - {0x0F12, 0x0101}, /* #ae_WeightTbl_16_6_ */ - {0x0F12, 0x0101}, /* #ae_WeightTbl_16_7_ */ - {0x0F12, 0x0101}, /* #ae_WeightTbl_16_8_ */ - {0x0F12, 0x0303}, /* #ae_WeightTbl_16_9_ */ - {0x0F12, 0x0303}, /* #ae_WeightTbl_16_10 */ - {0x0F12, 0x0101}, /* #ae_WeightTbl_16_11 */ - {0x0F12, 0x0101}, /* #ae_WeightTbl_16_12 */ - {0x0F12, 0x0303}, /* #ae_WeightTbl_16_13 */ - {0x0F12, 0x0303}, /* #ae_WeightTbl_16_14 */ - {0x0F12, 0x0101}, /* #ae_WeightTbl_16_15 */ - {0x0F12, 0x0101}, /* #ae_WeightTbl_16_16 */ - {0x0F12, 0x0303}, /* #ae_WeightTbl_16_17 */ - {0x0F12, 0x0303}, /* #ae_WeightTbl_16_18 */ - {0x0F12, 0x0101}, /* #ae_WeightTbl_16_19 */ - {0x0F12, 0x0101}, /* #ae_WeightTbl_16_20 */ - {0x0F12, 0x0303}, /* #ae_WeightTbl_16_21 */ - {0x0F12, 0x0303}, /* #ae_WeightTbl_16_22 */ - {0x0F12, 0x0101}, /* #ae_WeightTbl_16_23 */ - {0x0F12, 0x0101}, /* #ae_WeightTbl_16_24 */ - {0x0F12, 0x0101}, /* #ae_WeightTbl_16_25 */ - {0x0F12, 0x0101}, /* #ae_WeightTbl_16_26 */ - {0x0F12, 0x0101}, /* #ae_WeightTbl_16_27 */ - {0x0F12, 0x0101}, /* #ae_WeightTbl_16_28 */ - {0x0F12, 0x0101}, /* #ae_WeightTbl_16_29 */ - {0x0F12, 0x0101}, /* #ae_WeightTbl_16_30 */ - {0x0F12, 0x0101}, /* #ae_WeightTbl_16_31 */ - - /* Set Flicker */ - {0x002A, 0x04D2}, - {0x0F12, 0x065F}, /* Anti-flicker disabled */ - {0x002A, 0x04BA}, - {0x0F12, 0x0002}, - {0x002A, 0x0C04}, - {0x0F12, 0xFFFF}, - - /* Set GAS */ - /* GAS alpha */ - /* R, Gr, Gb, B per light source */ - {0x002A, 0x06CE}, - {0x0F12, 0x00ED}, /* #TVAR_ash_GASAlpha[0] Horizon */ - {0x0F12, 0x00EB}, /* #TVAR_ash_GASAlpha[1] */ - {0x0F12, 0x00EB}, /* #TVAR_ash_GASAlpha[2] */ - {0x0F12, 0x00E9}, /* #TVAR_ash_GASAlpha[3] */ - {0x0F12, 0x00ED}, /* #TVAR_ash_GASAlpha[4] IncandA */ - {0x0F12, 0x00EB}, /* #TVAR_ash_GASAlpha[5] */ - {0x0F12, 0x00EB}, /* #TVAR_ash_GASAlpha[6] */ - {0x0F12, 0x00E9}, /* #TVAR_ash_GASAlpha[7] */ - {0x0F12, 0x00ED}, /* #TVAR_ash_GASAlpha[8] WW */ - {0x0F12, 0x00EB}, /* #TVAR_ash_GASAlpha[9] */ - {0x0F12, 0x00EB}, /* #TVAR_ash_GASAlpha[10] */ - {0x0F12, 0x00E9}, /* #TVAR_ash_GASAlpha[11] */ - {0x0F12, 0x00ED}, /* #TVAR_ash_GASAlpha[12] CWF */ - {0x0F12, 0x00EB}, /* #TVAR_ash_GASAlpha[13] */ - {0x0F12, 0x00EB}, /* #TVAR_ash_GASAlpha[14] */ - {0x0F12, 0x00E9}, /* #TVAR_ash_GASAlpha[15] */ - {0x0F12, 0x00ED}, /* #TVAR_ash_GASAlpha[16] D50 */ - {0x0F12, 0x00EB}, /* #TVAR_ash_GASAlpha[17] */ - {0x0F12, 0x00EB}, /* #TVAR_ash_GASAlpha[18] */ - {0x0F12, 0x00E9}, /* #TVAR_ash_GASAlpha[19] */ - {0x0F12, 0x00ED}, /* #TVAR_ash_GASAlpha[20] D65 */ - {0x0F12, 0x00EB}, /* #TVAR_ash_GASAlpha[21] */ - {0x0F12, 0x00EB}, /* #TVAR_ash_GASAlpha[22] */ - {0x0F12, 0x00E9}, /* #TVAR_ash_GASAlpha[23] */ - {0x0F12, 0x00ED}, /* #TVAR_ash_GASAlpha[24] D75 */ - {0x0F12, 0x00EB}, /* #TVAR_ash_GASAlpha[25] */ - {0x0F12, 0x00EB}, /* #TVAR_ash_GASAlpha[26] */ - {0x0F12, 0x00E9}, /* #TVAR_ash_GASAlpha[27] */ - {0x0F12, 0x00ED}, /* #TVAR_ash_GASOutdoorAlpha[0] Outdoor*/ - {0x0F12, 0x00EB}, /* #TVAR_ash_GASOutdoorAlpha[1] */ - {0x0F12, 0x00EB}, /* #TVAR_ash_GASOutdoorAlpha[2] */ - {0x0F12, 0x00E9}, /* #TVAR_ash_GASOutdoorAlpha[3] */ - - /* GAS beta */ - {0x0F12, 0x002D}, /* #ash_GASBeta[0] Horizon */ - {0x0F12, 0x0016}, /* #ash_GASBeta[1] */ - {0x0F12, 0x0016}, /* #ash_GASBeta[2] */ - {0x0F12, 0x0000}, /* #ash_GASBeta[3] */ - {0x0F12, 0x002D}, /* #ash_GASBeta[4] IncandA */ - {0x0F12, 0x0016}, /* #ash_GASBeta[5] */ - {0x0F12, 0x0016}, /* #ash_GASBeta[6] */ - {0x0F12, 0x0000}, /* #ash_GASBeta[7] */ - {0x0F12, 0x002D}, /* #ash_GASBeta[8] WW */ - {0x0F12, 0x0016}, /* #ash_GASBeta[9] */ - {0x0F12, 0x0016}, /* #ash_GASBeta[10] */ - {0x0F12, 0x0000}, /* #ash_GASBeta[11] */ - {0x0F12, 0x002D}, /* #ash_GASBeta[12] CWF */ - {0x0F12, 0x0016}, /* #ash_GASBeta[13] */ - {0x0F12, 0x0016}, /* #ash_GASBeta[14] */ - {0x0F12, 0x0000}, /* #ash_GASBeta[15] */ - {0x0F12, 0x002D}, /* #ash_GASBeta[16] D50 */ - {0x0F12, 0x0016}, /* #ash_GASBeta[17] */ - {0x0F12, 0x0016}, /* #ash_GASBeta[18] */ - {0x0F12, 0x0000}, /* #ash_GASBeta[19] */ - {0x0F12, 0x002D}, /* #ash_GASBeta[20] D65 */ - {0x0F12, 0x0016}, /* #ash_GASBeta[21] */ - {0x0F12, 0x0016}, /* #ash_GASBeta[22] */ - {0x0F12, 0x0000}, /* #ash_GASBeta[23] */ - {0x0F12, 0x002D}, /* #ash_GASBeta[24] D75 */ - {0x0F12, 0x0016}, /* #ash_GASBeta[25] */ - {0x0F12, 0x0016}, /* #ash_GASBeta[26] */ - {0x0F12, 0x0000}, /* #ash_GASBeta[27] */ - {0x0F12, 0x002D}, /* #ash_GASOutdoorBeta[0] Outdoor */ - {0x0F12, 0x0016}, /* #ash_GASOutdoorBeta[1] */ - {0x0F12, 0x0016}, /* #ash_GASOutdoorBeta[2] */ - {0x0F12, 0x0000}, /* #ash_GASOutdoorBeta[3] */ - - {0x002A, 0x06B4}, - {0x0F12, 0x0001}, /* #wbt_bUseOutdoorASH ON:1 OFF:0 */ - - /* Parabolic function */ - {0x002A, 0x075A}, - {0x0F12, 0x0000}, /* #ash_bParabolicEstimation */ - {0x0F12, 0x0400}, /* #ash_uParabolicCenterX */ - {0x0F12, 0x0300}, /* #ash_uParabolicCenterY */ - {0x0F12, 0x0010}, /* #ash_uParabolicScalingA */ - {0x0F12, 0x0011}, /* #ash_uParabolicScalingB */ - {0x002A, 0x06C6}, - {0x0F12, 0x00ED}, /* ash_CGrasAlphas_0_ */ - {0x0F12, 0x00EB}, /* ash_CGrasAlphas_1_ */ - {0x0F12, 0x00EB}, /* ash_CGrasAlphas_2_ */ - {0x0F12, 0x00E9}, /* ash_CGrasAlphas_3_ */ - {0x002A, 0x0E3C}, - {0x0F12, 0x00C0}, /* #awbb_Alpha_Comp_Mode */ - {0x002A, 0x074E}, - {0x0F12, 0x0000}, /* #ash_bLumaMode - use Beta : 0001 not use Beta : 0000 */ - /* GAS LUT start address 7000_347C */ - {0x002A, 0x0754}, - {0x0F12, 0x347C}, - {0x0F12, 0x7000}, - - /* GAS LUT - param_start TVAR_ash_pGAS (Change the shading setting) */ - {0x002A, 0x347C}, - {0x0F12, 0x019D}, /* #TVAR_ash_pGAS[0] */ - {0x0F12, 0x0163}, /* #TVAR_ash_pGAS[1] */ - {0x0F12, 0x0137}, /* #TVAR_ash_pGAS[2] */ - {0x0F12, 0x010B}, /* #TVAR_ash_pGAS[3] */ - {0x0F12, 0x00EB}, /* #TVAR_ash_pGAS[4] */ - {0x0F12, 0x00D7}, /* #TVAR_ash_pGAS[5] */ - {0x0F12, 0x00D0}, /* #TVAR_ash_pGAS[6] */ - {0x0F12, 0x00D6}, /* #TVAR_ash_pGAS[7] */ - {0x0F12, 0x00EC}, /* #TVAR_ash_pGAS[8] */ - {0x0F12, 0x0119}, /* #TVAR_ash_pGAS[9] */ - {0x0F12, 0x014C}, /* #TVAR_ash_pGAS[10] */ - {0x0F12, 0x0181}, /* #TVAR_ash_pGAS[11] */ - {0x0F12, 0x01CE}, /* #TVAR_ash_pGAS[12] */ - {0x0F12, 0x017E}, /* #TVAR_ash_pGAS[13] */ - {0x0F12, 0x0149}, /* #TVAR_ash_pGAS[14] */ - {0x0F12, 0x010E}, /* #TVAR_ash_pGAS[15] */ - {0x0F12, 0x00DC}, /* #TVAR_ash_pGAS[16] */ - {0x0F12, 0x00B7}, /* #TVAR_ash_pGAS[17] */ - {0x0F12, 0x00A4}, /* #TVAR_ash_pGAS[18] */ - {0x0F12, 0x009E}, /* #TVAR_ash_pGAS[19] */ - {0x0F12, 0x00A3}, /* #TVAR_ash_pGAS[20] */ - {0x0F12, 0x00BD}, /* #TVAR_ash_pGAS[21] */ - {0x0F12, 0x00E6}, /* #TVAR_ash_pGAS[22] */ - {0x0F12, 0x0125}, /* #TVAR_ash_pGAS[23] */ - {0x0F12, 0x0169}, /* #TVAR_ash_pGAS[24] */ - {0x0F12, 0x019C}, /* #TVAR_ash_pGAS[25] */ - {0x0F12, 0x014F}, /* #TVAR_ash_pGAS[26] */ - {0x0F12, 0x010E}, /* #TVAR_ash_pGAS[27] */ - {0x0F12, 0x00CD}, /* #TVAR_ash_pGAS[28] */ - {0x0F12, 0x009B}, /* #TVAR_ash_pGAS[29] */ - {0x0F12, 0x0076}, /* #TVAR_ash_pGAS[30] */ - {0x0F12, 0x0061}, /* #TVAR_ash_pGAS[31] */ - {0x0F12, 0x0058}, /* #TVAR_ash_pGAS[32] */ - {0x0F12, 0x0063}, /* #TVAR_ash_pGAS[33] */ - {0x0F12, 0x007E}, /* #TVAR_ash_pGAS[34] */ - {0x0F12, 0x00A9}, /* #TVAR_ash_pGAS[35] */ - {0x0F12, 0x00E7}, /* #TVAR_ash_pGAS[36] */ - {0x0F12, 0x0136}, /* #TVAR_ash_pGAS[37] */ - {0x0F12, 0x017E}, /* #TVAR_ash_pGAS[38] */ - {0x0F12, 0x0129}, /* #TVAR_ash_pGAS[39] */ - {0x0F12, 0x00E1}, /* #TVAR_ash_pGAS[40] */ - {0x0F12, 0x009F}, /* #TVAR_ash_pGAS[41] */ - {0x0F12, 0x006B}, /* #TVAR_ash_pGAS[42] */ - {0x0F12, 0x0046}, /* #TVAR_ash_pGAS[43] */ - {0x0F12, 0x0030}, /* #TVAR_ash_pGAS[44] */ - {0x0F12, 0x0029}, /* #TVAR_ash_pGAS[45] */ - {0x0F12, 0x0033}, /* #TVAR_ash_pGAS[46] */ - {0x0F12, 0x004F}, /* #TVAR_ash_pGAS[47] */ - {0x0F12, 0x007F}, /* #TVAR_ash_pGAS[48] */ - {0x0F12, 0x00BD}, /* #TVAR_ash_pGAS[49] */ - {0x0F12, 0x0111}, /* #TVAR_ash_pGAS[50] */ - {0x0F12, 0x015D}, /* #TVAR_ash_pGAS[51] */ - {0x0F12, 0x0110}, /* #TVAR_ash_pGAS[52] */ - {0x0F12, 0x00C6}, /* #TVAR_ash_pGAS[53] */ - {0x0F12, 0x0082}, /* #TVAR_ash_pGAS[54] */ - {0x0F12, 0x004B}, /* #TVAR_ash_pGAS[55] */ - {0x0F12, 0x0026}, /* #TVAR_ash_pGAS[56] */ - {0x0F12, 0x0011}, /* #TVAR_ash_pGAS[57] */ - {0x0F12, 0x000C}, /* #TVAR_ash_pGAS[58] */ - {0x0F12, 0x0016}, /* #TVAR_ash_pGAS[59] */ - {0x0F12, 0x0032}, /* #TVAR_ash_pGAS[60] */ - {0x0F12, 0x0061}, /* #TVAR_ash_pGAS[61] */ - {0x0F12, 0x00A1}, /* #TVAR_ash_pGAS[62] */ - {0x0F12, 0x00F4}, /* #TVAR_ash_pGAS[63] */ - {0x0F12, 0x014C}, /* #TVAR_ash_pGAS[64] */ - {0x0F12, 0x0102}, /* #TVAR_ash_pGAS[65] */ - {0x0F12, 0x00BB}, /* #TVAR_ash_pGAS[66] */ - {0x0F12, 0x0075}, /* #TVAR_ash_pGAS[67] */ - {0x0F12, 0x003F}, /* #TVAR_ash_pGAS[68] */ - {0x0F12, 0x0019}, /* #TVAR_ash_pGAS[69] */ - {0x0F12, 0x0005}, /* #TVAR_ash_pGAS[70] */ - {0x0F12, 0x0000}, /* #TVAR_ash_pGAS[71] */ - {0x0F12, 0x000A}, /* #TVAR_ash_pGAS[72] */ - {0x0F12, 0x0025}, /* #TVAR_ash_pGAS[73] */ - {0x0F12, 0x0055}, /* #TVAR_ash_pGAS[74] */ - {0x0F12, 0x0098}, /* #TVAR_ash_pGAS[75] */ - {0x0F12, 0x00EA}, /* #TVAR_ash_pGAS[76] */ - {0x0F12, 0x0143}, /* #TVAR_ash_pGAS[77] */ - {0x0F12, 0x0106}, /* #TVAR_ash_pGAS[78] */ - {0x0F12, 0x00BF}, /* #TVAR_ash_pGAS[79] */ - {0x0F12, 0x007B}, /* #TVAR_ash_pGAS[80] */ - {0x0F12, 0x0043}, /* #TVAR_ash_pGAS[81] */ - {0x0F12, 0x001F}, /* #TVAR_ash_pGAS[82] */ - {0x0F12, 0x000D}, /* #TVAR_ash_pGAS[83] */ - {0x0F12, 0x0006}, /* #TVAR_ash_pGAS[84] */ - {0x0F12, 0x0010}, /* #TVAR_ash_pGAS[85] */ - {0x0F12, 0x002C}, /* #TVAR_ash_pGAS[86] */ - {0x0F12, 0x005D}, /* #TVAR_ash_pGAS[87] */ - {0x0F12, 0x009D}, /* #TVAR_ash_pGAS[88] */ - {0x0F12, 0x00F2}, /* #TVAR_ash_pGAS[89] */ - {0x0F12, 0x0147}, /* #TVAR_ash_pGAS[90] */ - {0x0F12, 0x0115}, /* #TVAR_ash_pGAS[91] */ - {0x0F12, 0x00D2}, /* #TVAR_ash_pGAS[92] */ - {0x0F12, 0x008C}, /* #TVAR_ash_pGAS[93] */ - {0x0F12, 0x0059}, /* #TVAR_ash_pGAS[94] */ - {0x0F12, 0x0034}, /* #TVAR_ash_pGAS[95] */ - {0x0F12, 0x0022}, /* #TVAR_ash_pGAS[96] */ - {0x0F12, 0x001B}, /* #TVAR_ash_pGAS[97] */ - {0x0F12, 0x0027}, /* #TVAR_ash_pGAS[98] */ - {0x0F12, 0x0047}, /* #TVAR_ash_pGAS[99] */ - {0x0F12, 0x0077}, /* #TVAR_ash_pGAS[100] */ - {0x0F12, 0x00B6}, /* #TVAR_ash_pGAS[101] */ - {0x0F12, 0x0108}, /* #TVAR_ash_pGAS[102] */ - {0x0F12, 0x015F}, /* #TVAR_ash_pGAS[103] */ - {0x0F12, 0x0136}, /* #TVAR_ash_pGAS[104] */ - {0x0F12, 0x00F1}, /* #TVAR_ash_pGAS[105] */ - {0x0F12, 0x00AE}, /* #TVAR_ash_pGAS[106] */ - {0x0F12, 0x007C}, /* #TVAR_ash_pGAS[107] */ - {0x0F12, 0x0058}, /* #TVAR_ash_pGAS[108] */ - {0x0F12, 0x0046}, /* #TVAR_ash_pGAS[109] */ - {0x0F12, 0x0040}, /* #TVAR_ash_pGAS[110] */ - {0x0F12, 0x004E}, /* #TVAR_ash_pGAS[111] */ - {0x0F12, 0x006C}, /* #TVAR_ash_pGAS[112] */ - {0x0F12, 0x009C}, /* #TVAR_ash_pGAS[113] */ - {0x0F12, 0x00DB}, /* #TVAR_ash_pGAS[114] */ - {0x0F12, 0x012F}, /* #TVAR_ash_pGAS[115] */ - {0x0F12, 0x017C}, /* #TVAR_ash_pGAS[116] */ - {0x0F12, 0x015C}, /* #TVAR_ash_pGAS[117] */ - {0x0F12, 0x0120}, /* #TVAR_ash_pGAS[118] */ - {0x0F12, 0x00DF}, /* #TVAR_ash_pGAS[119] */ - {0x0F12, 0x00AF}, /* #TVAR_ash_pGAS[120] */ - {0x0F12, 0x008F}, /* #TVAR_ash_pGAS[121] */ - {0x0F12, 0x007D}, /* #TVAR_ash_pGAS[122] */ - {0x0F12, 0x0079}, /* #TVAR_ash_pGAS[123] */ - {0x0F12, 0x0084}, /* #TVAR_ash_pGAS[124] */ - {0x0F12, 0x00A3}, /* #TVAR_ash_pGAS[125] */ - {0x0F12, 0x00D1}, /* #TVAR_ash_pGAS[126] */ - {0x0F12, 0x0110}, /* #TVAR_ash_pGAS[127] */ - {0x0F12, 0x015E}, /* #TVAR_ash_pGAS[128] */ - {0x0F12, 0x019A}, /* #TVAR_ash_pGAS[129] */ - {0x0F12, 0x0178}, /* #TVAR_ash_pGAS[130] */ - {0x0F12, 0x0144}, /* #TVAR_ash_pGAS[131] */ - {0x0F12, 0x010C}, /* #TVAR_ash_pGAS[132] */ - {0x0F12, 0x00DF}, /* #TVAR_ash_pGAS[133] */ - {0x0F12, 0x00C1}, /* #TVAR_ash_pGAS[134] */ - {0x0F12, 0x00B3}, /* #TVAR_ash_pGAS[135] */ - {0x0F12, 0x00B0}, /* #TVAR_ash_pGAS[136] */ - {0x0F12, 0x00BC}, /* #TVAR_ash_pGAS[137] */ - {0x0F12, 0x00D6}, /* #TVAR_ash_pGAS[138] */ - {0x0F12, 0x0103}, /* #TVAR_ash_pGAS[139] */ - {0x0F12, 0x0144}, /* #TVAR_ash_pGAS[140] */ - {0x0F12, 0x0187}, /* #TVAR_ash_pGAS[141] */ - {0x0F12, 0x01C2}, /* #TVAR_ash_pGAS[142] */ - {0x0F12, 0x0167}, /* #TVAR_ash_pGAS[143] */ - {0x0F12, 0x013A}, /* #TVAR_ash_pGAS[144] */ - {0x0F12, 0x010D}, /* #TVAR_ash_pGAS[145] */ - {0x0F12, 0x00E5}, /* #TVAR_ash_pGAS[146] */ - {0x0F12, 0x00C6}, /* #TVAR_ash_pGAS[147] */ - {0x0F12, 0x00B7}, /* #TVAR_ash_pGAS[148] */ - {0x0F12, 0x00B0}, /* #TVAR_ash_pGAS[149] */ - {0x0F12, 0x00B6}, /* #TVAR_ash_pGAS[150] */ - {0x0F12, 0x00C9}, /* #TVAR_ash_pGAS[151] */ - {0x0F12, 0x00EC}, /* #TVAR_ash_pGAS[152] */ - {0x0F12, 0x011C}, /* #TVAR_ash_pGAS[153] */ - {0x0F12, 0x014B}, /* #TVAR_ash_pGAS[154] */ - {0x0F12, 0x0192}, /* #TVAR_ash_pGAS[155] */ - {0x0F12, 0x0155}, /* #TVAR_ash_pGAS[156] */ - {0x0F12, 0x0125}, /* #TVAR_ash_pGAS[157] */ - {0x0F12, 0x00EE}, /* #TVAR_ash_pGAS[158] */ - {0x0F12, 0x00BF}, /* #TVAR_ash_pGAS[159] */ - {0x0F12, 0x00A2}, /* #TVAR_ash_pGAS[160] */ - {0x0F12, 0x008D}, /* #TVAR_ash_pGAS[161] */ - {0x0F12, 0x0087}, /* #TVAR_ash_pGAS[162] */ - {0x0F12, 0x008F}, /* #TVAR_ash_pGAS[163] */ - {0x0F12, 0x00A1}, /* #TVAR_ash_pGAS[164] */ - {0x0F12, 0x00C5}, /* #TVAR_ash_pGAS[165] */ - {0x0F12, 0x00F8}, /* #TVAR_ash_pGAS[166] */ - {0x0F12, 0x0135}, /* #TVAR_ash_pGAS[167] */ - {0x0F12, 0x0166}, /* #TVAR_ash_pGAS[168] */ - {0x0F12, 0x012F}, /* #TVAR_ash_pGAS[169] */ - {0x0F12, 0x00F2}, /* #TVAR_ash_pGAS[170] */ - {0x0F12, 0x00B6}, /* #TVAR_ash_pGAS[171] */ - {0x0F12, 0x0089}, /* #TVAR_ash_pGAS[172] */ - {0x0F12, 0x0068}, /* #TVAR_ash_pGAS[173] */ - {0x0F12, 0x0055}, /* #TVAR_ash_pGAS[174] */ - {0x0F12, 0x004F}, /* #TVAR_ash_pGAS[175] */ - {0x0F12, 0x0058}, /* #TVAR_ash_pGAS[176] */ - {0x0F12, 0x006E}, /* #TVAR_ash_pGAS[177] */ - {0x0F12, 0x0092}, /* #TVAR_ash_pGAS[178] */ - {0x0F12, 0x00C5}, /* #TVAR_ash_pGAS[179] */ - {0x0F12, 0x0109}, /* #TVAR_ash_pGAS[180] */ - {0x0F12, 0x0147}, /* #TVAR_ash_pGAS[181] */ - {0x0F12, 0x010D}, /* #TVAR_ash_pGAS[182] */ - {0x0F12, 0x00C9}, /* #TVAR_ash_pGAS[183] */ - {0x0F12, 0x008E}, /* #TVAR_ash_pGAS[184] */ - {0x0F12, 0x0061}, /* #TVAR_ash_pGAS[185] */ - {0x0F12, 0x003E}, /* #TVAR_ash_pGAS[186] */ - {0x0F12, 0x002A}, /* #TVAR_ash_pGAS[187] */ - {0x0F12, 0x0025}, /* #TVAR_ash_pGAS[188] */ - {0x0F12, 0x002F}, /* #TVAR_ash_pGAS[189] */ - {0x0F12, 0x0047}, /* #TVAR_ash_pGAS[190] */ - {0x0F12, 0x006F}, /* #TVAR_ash_pGAS[191] */ - {0x0F12, 0x00A2}, /* #TVAR_ash_pGAS[192] */ - {0x0F12, 0x00E9}, /* #TVAR_ash_pGAS[193] */ - {0x0F12, 0x0130}, /* #TVAR_ash_pGAS[194] */ - {0x0F12, 0x00F3}, /* #TVAR_ash_pGAS[195] */ - {0x0F12, 0x00B1}, /* #TVAR_ash_pGAS[196] */ - {0x0F12, 0x0076}, /* #TVAR_ash_pGAS[197] */ - {0x0F12, 0x0045}, /* #TVAR_ash_pGAS[198] */ - {0x0F12, 0x0022}, /* #TVAR_ash_pGAS[199] */ - {0x0F12, 0x000F}, /* #TVAR_ash_pGAS[200] */ - {0x0F12, 0x000A}, /* #TVAR_ash_pGAS[201] */ - {0x0F12, 0x0015}, /* #TVAR_ash_pGAS[202] */ - {0x0F12, 0x002E}, /* #TVAR_ash_pGAS[203] */ - {0x0F12, 0x0058}, /* #TVAR_ash_pGAS[204] */ - {0x0F12, 0x008D}, /* #TVAR_ash_pGAS[205] */ - {0x0F12, 0x00D4}, /* #TVAR_ash_pGAS[206] */ - {0x0F12, 0x011A}, /* #TVAR_ash_pGAS[207] */ - {0x0F12, 0x00E9}, /* #TVAR_ash_pGAS[208] */ - {0x0F12, 0x00A7}, /* #TVAR_ash_pGAS[209] */ - {0x0F12, 0x0068}, /* #TVAR_ash_pGAS[210] */ - {0x0F12, 0x0038}, /* #TVAR_ash_pGAS[211] */ - {0x0F12, 0x0017}, /* #TVAR_ash_pGAS[212] */ - {0x0F12, 0x0004}, /* #TVAR_ash_pGAS[213] */ - {0x0F12, 0x0000}, /* #TVAR_ash_pGAS[214] */ - {0x0F12, 0x000B}, /* #TVAR_ash_pGAS[215] */ - {0x0F12, 0x0025}, /* #TVAR_ash_pGAS[216] */ - {0x0F12, 0x004F}, /* #TVAR_ash_pGAS[217] */ - {0x0F12, 0x0084}, /* #TVAR_ash_pGAS[218] */ - {0x0F12, 0x00CB}, /* #TVAR_ash_pGAS[219] */ - {0x0F12, 0x0117}, /* #TVAR_ash_pGAS[220] */ - {0x0F12, 0x00EA}, /* #TVAR_ash_pGAS[221] */ - {0x0F12, 0x00A8}, /* #TVAR_ash_pGAS[222] */ - {0x0F12, 0x006E}, /* #TVAR_ash_pGAS[223] */ - {0x0F12, 0x003D}, /* #TVAR_ash_pGAS[224] */ - {0x0F12, 0x001B}, /* #TVAR_ash_pGAS[225] */ - {0x0F12, 0x0009}, /* #TVAR_ash_pGAS[226] */ - {0x0F12, 0x0006}, /* #TVAR_ash_pGAS[227] */ - {0x0F12, 0x0010}, /* #TVAR_ash_pGAS[228] */ - {0x0F12, 0x002B}, /* #TVAR_ash_pGAS[229] */ - {0x0F12, 0x0056}, /* #TVAR_ash_pGAS[230] */ - {0x0F12, 0x008B}, /* #TVAR_ash_pGAS[231] */ - {0x0F12, 0x00D1}, /* #TVAR_ash_pGAS[232] */ - {0x0F12, 0x011B}, /* #TVAR_ash_pGAS[233] */ - {0x0F12, 0x00F9}, /* #TVAR_ash_pGAS[234] */ - {0x0F12, 0x00B6}, /* #TVAR_ash_pGAS[235] */ - {0x0F12, 0x007D}, /* #TVAR_ash_pGAS[236] */ - {0x0F12, 0x004E}, /* #TVAR_ash_pGAS[237] */ - {0x0F12, 0x002D}, /* #TVAR_ash_pGAS[238] */ - {0x0F12, 0x001C}, /* #TVAR_ash_pGAS[239] */ - {0x0F12, 0x0019}, /* #TVAR_ash_pGAS[240] */ - {0x0F12, 0x0025}, /* #TVAR_ash_pGAS[241] */ - {0x0F12, 0x0042}, /* #TVAR_ash_pGAS[242] */ - {0x0F12, 0x006C}, /* #TVAR_ash_pGAS[243] */ - {0x0F12, 0x00A0}, /* #TVAR_ash_pGAS[244] */ - {0x0F12, 0x00E6}, /* #TVAR_ash_pGAS[245] */ - {0x0F12, 0x0130}, /* #TVAR_ash_pGAS[246] */ - {0x0F12, 0x0114}, /* #TVAR_ash_pGAS[247] */ - {0x0F12, 0x00D5}, /* #TVAR_ash_pGAS[248] */ - {0x0F12, 0x0099}, /* #TVAR_ash_pGAS[249] */ - {0x0F12, 0x006D}, /* #TVAR_ash_pGAS[250] */ - {0x0F12, 0x004E}, /* #TVAR_ash_pGAS[251] */ - {0x0F12, 0x003E}, /* #TVAR_ash_pGAS[252] */ - {0x0F12, 0x003C}, /* #TVAR_ash_pGAS[253] */ - {0x0F12, 0x0049}, /* #TVAR_ash_pGAS[254] */ - {0x0F12, 0x0065}, /* #TVAR_ash_pGAS[255] */ - {0x0F12, 0x008D}, /* #TVAR_ash_pGAS[256] */ - {0x0F12, 0x00C2}, /* #TVAR_ash_pGAS[257] */ - {0x0F12, 0x0109}, /* #TVAR_ash_pGAS[258] */ - {0x0F12, 0x014C}, /* #TVAR_ash_pGAS[259] */ - {0x0F12, 0x0135}, /* #TVAR_ash_pGAS[260] */ - {0x0F12, 0x00FC}, /* #TVAR_ash_pGAS[261] */ - {0x0F12, 0x00C2}, /* #TVAR_ash_pGAS[262] */ - {0x0F12, 0x0099}, /* #TVAR_ash_pGAS[263] */ - {0x0F12, 0x007D}, /* #TVAR_ash_pGAS[264] */ - {0x0F12, 0x006F}, /* #TVAR_ash_pGAS[265] */ - {0x0F12, 0x006D}, /* #TVAR_ash_pGAS[266] */ - {0x0F12, 0x007C}, /* #TVAR_ash_pGAS[267] */ - {0x0F12, 0x0095}, /* #TVAR_ash_pGAS[268] */ - {0x0F12, 0x00BC}, /* #TVAR_ash_pGAS[269] */ - {0x0F12, 0x00F1}, /* #TVAR_ash_pGAS[270] */ - {0x0F12, 0x0135}, /* #TVAR_ash_pGAS[271] */ - {0x0F12, 0x016E}, /* #TVAR_ash_pGAS[272] */ - {0x0F12, 0x0154}, /* #TVAR_ash_pGAS[273] */ - {0x0F12, 0x011D}, /* #TVAR_ash_pGAS[274] */ - {0x0F12, 0x00E9}, /* #TVAR_ash_pGAS[275] */ - {0x0F12, 0x00C2}, /* #TVAR_ash_pGAS[276] */ - {0x0F12, 0x00A7}, /* #TVAR_ash_pGAS[277] */ - {0x0F12, 0x009C}, /* #TVAR_ash_pGAS[278] */ - {0x0F12, 0x009B}, /* #TVAR_ash_pGAS[279] */ - {0x0F12, 0x00A8}, /* #TVAR_ash_pGAS[280] */ - {0x0F12, 0x00C2}, /* #TVAR_ash_pGAS[281] */ - {0x0F12, 0x00E8}, /* #TVAR_ash_pGAS[282] */ - {0x0F12, 0x011C}, /* #TVAR_ash_pGAS[283] */ - {0x0F12, 0x015C}, /* #TVAR_ash_pGAS[284] */ - {0x0F12, 0x018F}, /* #TVAR_ash_pGAS[285] */ - {0x0F12, 0x0158}, /* #TVAR_ash_pGAS[286] */ - {0x0F12, 0x012B}, /* #TVAR_ash_pGAS[287] */ - {0x0F12, 0x0100}, /* #TVAR_ash_pGAS[288] */ - {0x0F12, 0x00DA}, /* #TVAR_ash_pGAS[289] */ - {0x0F12, 0x00BF}, /* #TVAR_ash_pGAS[290] */ - {0x0F12, 0x00AE}, /* #TVAR_ash_pGAS[291] */ - {0x0F12, 0x00AD}, /* #TVAR_ash_pGAS[292] */ - {0x0F12, 0x00B8}, /* #TVAR_ash_pGAS[293] */ - {0x0F12, 0x00D2}, /* #TVAR_ash_pGAS[294] */ - {0x0F12, 0x00FB}, /* #TVAR_ash_pGAS[295] */ - {0x0F12, 0x012C}, /* #TVAR_ash_pGAS[296] */ - {0x0F12, 0x015B}, /* #TVAR_ash_pGAS[297] */ - {0x0F12, 0x01A0}, /* #TVAR_ash_pGAS[298] */ - {0x0F12, 0x0150}, /* #TVAR_ash_pGAS[299] */ - {0x0F12, 0x011F}, /* #TVAR_ash_pGAS[300] */ - {0x0F12, 0x00E7}, /* #TVAR_ash_pGAS[301] */ - {0x0F12, 0x00BA}, /* #TVAR_ash_pGAS[302] */ - {0x0F12, 0x009D}, /* #TVAR_ash_pGAS[303] */ - {0x0F12, 0x008C}, /* #TVAR_ash_pGAS[304] */ - {0x0F12, 0x008B}, /* #TVAR_ash_pGAS[305] */ - {0x0F12, 0x0095}, /* #TVAR_ash_pGAS[306] */ - {0x0F12, 0x00AF}, /* #TVAR_ash_pGAS[307] */ - {0x0F12, 0x00D6}, /* #TVAR_ash_pGAS[308] */ - {0x0F12, 0x010E}, /* #TVAR_ash_pGAS[309] */ - {0x0F12, 0x014C}, /* #TVAR_ash_pGAS[310] */ - {0x0F12, 0x017C}, /* #TVAR_ash_pGAS[311] */ - {0x0F12, 0x012E}, /* #TVAR_ash_pGAS[312] */ - {0x0F12, 0x00EE}, /* #TVAR_ash_pGAS[313] */ - {0x0F12, 0x00B4}, /* #TVAR_ash_pGAS[314] */ - {0x0F12, 0x0088}, /* #TVAR_ash_pGAS[315] */ - {0x0F12, 0x0068}, /* #TVAR_ash_pGAS[316] */ - {0x0F12, 0x0055}, /* #TVAR_ash_pGAS[317] */ - {0x0F12, 0x0050}, /* #TVAR_ash_pGAS[318] */ - {0x0F12, 0x005E}, /* #TVAR_ash_pGAS[319] */ - {0x0F12, 0x007A}, /* #TVAR_ash_pGAS[320] */ - {0x0F12, 0x00A4}, /* #TVAR_ash_pGAS[321] */ - {0x0F12, 0x00DA}, /* #TVAR_ash_pGAS[322] */ - {0x0F12, 0x0121}, /* #TVAR_ash_pGAS[323] */ - {0x0F12, 0x0161}, /* #TVAR_ash_pGAS[324] */ - {0x0F12, 0x010B}, /* #TVAR_ash_pGAS[325] */ - {0x0F12, 0x00C9}, /* #TVAR_ash_pGAS[326] */ - {0x0F12, 0x008E}, /* #TVAR_ash_pGAS[327] */ - {0x0F12, 0x0061}, /* #TVAR_ash_pGAS[328] */ - {0x0F12, 0x003F}, /* #TVAR_ash_pGAS[329] */ - {0x0F12, 0x002B}, /* #TVAR_ash_pGAS[330] */ - {0x0F12, 0x0028}, /* #TVAR_ash_pGAS[331] */ - {0x0F12, 0x0034}, /* #TVAR_ash_pGAS[332] */ - {0x0F12, 0x0052}, /* #TVAR_ash_pGAS[333] */ - {0x0F12, 0x007D}, /* #TVAR_ash_pGAS[334] */ - {0x0F12, 0x00B4}, /* #TVAR_ash_pGAS[335] */ - {0x0F12, 0x00F9}, /* #TVAR_ash_pGAS[336] */ - {0x0F12, 0x0141}, /* #TVAR_ash_pGAS[337] */ - {0x0F12, 0x00F9}, /* #TVAR_ash_pGAS[338] */ - {0x0F12, 0x00B3}, /* #TVAR_ash_pGAS[339] */ - {0x0F12, 0x0079}, /* #TVAR_ash_pGAS[340] */ - {0x0F12, 0x0048}, /* #TVAR_ash_pGAS[341] */ - {0x0F12, 0x0024}, /* #TVAR_ash_pGAS[342] */ - {0x0F12, 0x0010}, /* #TVAR_ash_pGAS[343] */ - {0x0F12, 0x000C}, /* #TVAR_ash_pGAS[344] */ - {0x0F12, 0x0018}, /* #TVAR_ash_pGAS[345] */ - {0x0F12, 0x0035}, /* #TVAR_ash_pGAS[346] */ - {0x0F12, 0x0062}, /* #TVAR_ash_pGAS[347] */ - {0x0F12, 0x009A}, /* #TVAR_ash_pGAS[348] */ - {0x0F12, 0x00DF}, /* #TVAR_ash_pGAS[349] */ - {0x0F12, 0x0128}, /* #TVAR_ash_pGAS[350] */ - {0x0F12, 0x00F2}, /* #TVAR_ash_pGAS[351] */ - {0x0F12, 0x00AE}, /* #TVAR_ash_pGAS[352] */ - {0x0F12, 0x0071}, /* #TVAR_ash_pGAS[353] */ - {0x0F12, 0x003E}, /* #TVAR_ash_pGAS[354] */ - {0x0F12, 0x001B}, /* #TVAR_ash_pGAS[355] */ - {0x0F12, 0x0005}, /* #TVAR_ash_pGAS[356] */ - {0x0F12, 0x0000}, /* #TVAR_ash_pGAS[357] */ - {0x0F12, 0x000C}, /* #TVAR_ash_pGAS[358] */ - {0x0F12, 0x0029}, /* #TVAR_ash_pGAS[359] */ - {0x0F12, 0x0053}, /* #TVAR_ash_pGAS[360] */ - {0x0F12, 0x008A}, /* #TVAR_ash_pGAS[361] */ - {0x0F12, 0x00D1}, /* #TVAR_ash_pGAS[362] */ - {0x0F12, 0x0118}, /* #TVAR_ash_pGAS[363] */ - {0x0F12, 0x00F4}, /* #TVAR_ash_pGAS[364] */ - {0x0F12, 0x00B2}, /* #TVAR_ash_pGAS[365] */ - {0x0F12, 0x0076}, /* #TVAR_ash_pGAS[366] */ - {0x0F12, 0x0044}, /* #TVAR_ash_pGAS[367] */ - {0x0F12, 0x0020}, /* #TVAR_ash_pGAS[368] */ - {0x0F12, 0x000B}, /* #TVAR_ash_pGAS[369] */ - {0x0F12, 0x0005}, /* #TVAR_ash_pGAS[370] */ - {0x0F12, 0x000F}, /* #TVAR_ash_pGAS[371] */ - {0x0F12, 0x002C}, /* #TVAR_ash_pGAS[372] */ - {0x0F12, 0x0055}, /* #TVAR_ash_pGAS[373] */ - {0x0F12, 0x008A}, /* #TVAR_ash_pGAS[374] */ - {0x0F12, 0x00CF}, /* #TVAR_ash_pGAS[375] */ - {0x0F12, 0x0117}, /* #TVAR_ash_pGAS[376] */ - {0x0F12, 0x0106}, /* #TVAR_ash_pGAS[377] */ - {0x0F12, 0x00C2}, /* #TVAR_ash_pGAS[378] */ - {0x0F12, 0x0088}, /* #TVAR_ash_pGAS[379] */ - {0x0F12, 0x0057}, /* #TVAR_ash_pGAS[380] */ - {0x0F12, 0x0033}, /* #TVAR_ash_pGAS[381] */ - {0x0F12, 0x001F}, /* #TVAR_ash_pGAS[382] */ - {0x0F12, 0x0017}, /* #TVAR_ash_pGAS[383] */ - {0x0F12, 0x0021}, /* #TVAR_ash_pGAS[384] */ - {0x0F12, 0x003C}, /* #TVAR_ash_pGAS[385] */ - {0x0F12, 0x0065}, /* #TVAR_ash_pGAS[386] */ - {0x0F12, 0x0099}, /* #TVAR_ash_pGAS[387] */ - {0x0F12, 0x00DC}, /* #TVAR_ash_pGAS[388] */ - {0x0F12, 0x0125}, /* #TVAR_ash_pGAS[389] */ - {0x0F12, 0x0125}, /* #TVAR_ash_pGAS[390] */ - {0x0F12, 0x00E2}, /* #TVAR_ash_pGAS[391] */ - {0x0F12, 0x00A4}, /* #TVAR_ash_pGAS[392] */ - {0x0F12, 0x0077}, /* #TVAR_ash_pGAS[393] */ - {0x0F12, 0x0053}, /* #TVAR_ash_pGAS[394] */ - {0x0F12, 0x003F}, /* #TVAR_ash_pGAS[395] */ - {0x0F12, 0x0038}, /* #TVAR_ash_pGAS[396] */ - {0x0F12, 0x0042}, /* #TVAR_ash_pGAS[397] */ - {0x0F12, 0x005B}, /* #TVAR_ash_pGAS[398] */ - {0x0F12, 0x0081}, /* #TVAR_ash_pGAS[399] */ - {0x0F12, 0x00B3}, /* #TVAR_ash_pGAS[400] */ - {0x0F12, 0x00F8}, /* #TVAR_ash_pGAS[401] */ - {0x0F12, 0x013D}, /* #TVAR_ash_pGAS[402] */ - {0x0F12, 0x0148}, /* #TVAR_ash_pGAS[403] */ - {0x0F12, 0x010C}, /* #TVAR_ash_pGAS[404] */ - {0x0F12, 0x00D2}, /* #TVAR_ash_pGAS[405] */ - {0x0F12, 0x00A4}, /* #TVAR_ash_pGAS[406] */ - {0x0F12, 0x0084}, /* #TVAR_ash_pGAS[407] */ - {0x0F12, 0x0071}, /* #TVAR_ash_pGAS[408] */ - {0x0F12, 0x006A}, /* #TVAR_ash_pGAS[409] */ - {0x0F12, 0x0072}, /* #TVAR_ash_pGAS[410] */ - {0x0F12, 0x0089}, /* #TVAR_ash_pGAS[411] */ - {0x0F12, 0x00AC}, /* #TVAR_ash_pGAS[412] */ - {0x0F12, 0x00DE}, /* #TVAR_ash_pGAS[413] */ - {0x0F12, 0x011E}, /* #TVAR_ash_pGAS[414] */ - {0x0F12, 0x015A}, /* #TVAR_ash_pGAS[415] */ - {0x0F12, 0x0167}, /* #TVAR_ash_pGAS[416] */ - {0x0F12, 0x0130}, /* #TVAR_ash_pGAS[417] */ - {0x0F12, 0x00FC}, /* #TVAR_ash_pGAS[418] */ - {0x0F12, 0x00D1}, /* #TVAR_ash_pGAS[419] */ - {0x0F12, 0x00B5}, /* #TVAR_ash_pGAS[420] */ - {0x0F12, 0x00A2}, /* #TVAR_ash_pGAS[421] */ - {0x0F12, 0x009D}, /* #TVAR_ash_pGAS[422] */ - {0x0F12, 0x00A2}, /* #TVAR_ash_pGAS[423] */ - {0x0F12, 0x00B8}, /* #TVAR_ash_pGAS[424] */ - {0x0F12, 0x00D9}, /* #TVAR_ash_pGAS[425] */ - {0x0F12, 0x0106}, /* #TVAR_ash_pGAS[426] */ - {0x0F12, 0x0140}, /* #TVAR_ash_pGAS[427] */ - {0x0F12, 0x0174}, /* #TVAR_ash_pGAS[428] */ - {0x0F12, 0x0139}, /* #TVAR_ash_pGAS[429] */ - {0x0F12, 0x0111}, /* #TVAR_ash_pGAS[430] */ - {0x0F12, 0x00EC}, /* #TVAR_ash_pGAS[431] */ - {0x0F12, 0x00C6}, /* #TVAR_ash_pGAS[432] */ - {0x0F12, 0x00AF}, /* #TVAR_ash_pGAS[433] */ - {0x0F12, 0x00A4}, /* #TVAR_ash_pGAS[434] */ - {0x0F12, 0x00A2}, /* #TVAR_ash_pGAS[435] */ - {0x0F12, 0x00AD}, /* #TVAR_ash_pGAS[436] */ - {0x0F12, 0x00C2}, /* #TVAR_ash_pGAS[437] */ - {0x0F12, 0x00E6}, /* #TVAR_ash_pGAS[438] */ - {0x0F12, 0x0111}, /* #TVAR_ash_pGAS[439] */ - {0x0F12, 0x0141}, /* #TVAR_ash_pGAS[440] */ - {0x0F12, 0x017D}, /* #TVAR_ash_pGAS[441] */ - {0x0F12, 0x012B}, /* #TVAR_ash_pGAS[442] */ - {0x0F12, 0x00FF}, /* #TVAR_ash_pGAS[443] */ - {0x0F12, 0x00CD}, /* #TVAR_ash_pGAS[444] */ - {0x0F12, 0x00A5}, /* #TVAR_ash_pGAS[445] */ - {0x0F12, 0x008F}, /* #TVAR_ash_pGAS[446] */ - {0x0F12, 0x0082}, /* #TVAR_ash_pGAS[447] */ - {0x0F12, 0x0082}, /* #TVAR_ash_pGAS[448] */ - {0x0F12, 0x0089}, /* #TVAR_ash_pGAS[449] */ - {0x0F12, 0x00A0}, /* #TVAR_ash_pGAS[450] */ - {0x0F12, 0x00C2}, /* #TVAR_ash_pGAS[451] */ - {0x0F12, 0x00F2}, /* #TVAR_ash_pGAS[452] */ - {0x0F12, 0x012C}, /* #TVAR_ash_pGAS[453] */ - {0x0F12, 0x0156}, /* #TVAR_ash_pGAS[454] */ - {0x0F12, 0x0102}, /* #TVAR_ash_pGAS[455] */ - {0x0F12, 0x00CB}, /* #TVAR_ash_pGAS[456] */ - {0x0F12, 0x009B}, /* #TVAR_ash_pGAS[457] */ - {0x0F12, 0x0075}, /* #TVAR_ash_pGAS[458] */ - {0x0F12, 0x005D}, /* #TVAR_ash_pGAS[459] */ - {0x0F12, 0x004F}, /* #TVAR_ash_pGAS[460] */ - {0x0F12, 0x004E}, /* #TVAR_ash_pGAS[461] */ - {0x0F12, 0x0059}, /* #TVAR_ash_pGAS[462] */ - {0x0F12, 0x006F}, /* #TVAR_ash_pGAS[463] */ - {0x0F12, 0x0091}, /* #TVAR_ash_pGAS[464] */ - {0x0F12, 0x00BE}, /* #TVAR_ash_pGAS[465] */ - {0x0F12, 0x00FD}, /* #TVAR_ash_pGAS[466] */ - {0x0F12, 0x0134}, /* #TVAR_ash_pGAS[467] */ - {0x0F12, 0x00E1}, /* #TVAR_ash_pGAS[468] */ - {0x0F12, 0x00A5}, /* #TVAR_ash_pGAS[469] */ - {0x0F12, 0x0075}, /* #TVAR_ash_pGAS[470] */ - {0x0F12, 0x004F}, /* #TVAR_ash_pGAS[471] */ - {0x0F12, 0x0035}, /* #TVAR_ash_pGAS[472] */ - {0x0F12, 0x0028}, /* #TVAR_ash_pGAS[473] */ - {0x0F12, 0x0025}, /* #TVAR_ash_pGAS[474] */ - {0x0F12, 0x0030}, /* #TVAR_ash_pGAS[475] */ - {0x0F12, 0x0048}, /* #TVAR_ash_pGAS[476] */ - {0x0F12, 0x006C}, /* #TVAR_ash_pGAS[477] */ - {0x0F12, 0x009A}, /* #TVAR_ash_pGAS[478] */ - {0x0F12, 0x00D6}, /* #TVAR_ash_pGAS[479] */ - {0x0F12, 0x0119}, /* #TVAR_ash_pGAS[480] */ - {0x0F12, 0x00CA}, /* #TVAR_ash_pGAS[481] */ - {0x0F12, 0x0090}, /* #TVAR_ash_pGAS[482] */ - {0x0F12, 0x005C}, /* #TVAR_ash_pGAS[483] */ - {0x0F12, 0x0036}, /* #TVAR_ash_pGAS[484] */ - {0x0F12, 0x001B}, /* #TVAR_ash_pGAS[485] */ - {0x0F12, 0x000D}, /* #TVAR_ash_pGAS[486] */ - {0x0F12, 0x000B}, /* #TVAR_ash_pGAS[487] */ - {0x0F12, 0x0015}, /* #TVAR_ash_pGAS[488] */ - {0x0F12, 0x002A}, /* #TVAR_ash_pGAS[489] */ - {0x0F12, 0x004F}, /* #TVAR_ash_pGAS[490] */ - {0x0F12, 0x007C}, /* #TVAR_ash_pGAS[491] */ - {0x0F12, 0x00B9}, /* #TVAR_ash_pGAS[492] */ - {0x0F12, 0x00FA}, /* #TVAR_ash_pGAS[493] */ - {0x0F12, 0x00BF}, /* #TVAR_ash_pGAS[494] */ - {0x0F12, 0x0086}, /* #TVAR_ash_pGAS[495] */ - {0x0F12, 0x0053}, /* #TVAR_ash_pGAS[496] */ - {0x0F12, 0x002C}, /* #TVAR_ash_pGAS[497] */ - {0x0F12, 0x0010}, /* #TVAR_ash_pGAS[498] */ - {0x0F12, 0x0002}, /* #TVAR_ash_pGAS[499] */ - {0x0F12, 0x0000}, /* #TVAR_ash_pGAS[500] */ - {0x0F12, 0x0007}, /* #TVAR_ash_pGAS[501] */ - {0x0F12, 0x001D}, /* #TVAR_ash_pGAS[502] */ - {0x0F12, 0x0040}, /* #TVAR_ash_pGAS[503] */ - {0x0F12, 0x006B}, /* #TVAR_ash_pGAS[504] */ - {0x0F12, 0x00A8}, /* #TVAR_ash_pGAS[505] */ - {0x0F12, 0x00EC}, /* #TVAR_ash_pGAS[506] */ - {0x0F12, 0x00C4}, /* #TVAR_ash_pGAS[507] */ - {0x0F12, 0x0089}, /* #TVAR_ash_pGAS[508] */ - {0x0F12, 0x0057}, /* #TVAR_ash_pGAS[509] */ - {0x0F12, 0x002F}, /* #TVAR_ash_pGAS[510] */ - {0x0F12, 0x0015}, /* #TVAR_ash_pGAS[511] */ - {0x0F12, 0x0008}, /* #TVAR_ash_pGAS[512] */ - {0x0F12, 0x0003}, /* #TVAR_ash_pGAS[513] */ - {0x0F12, 0x000B}, /* #TVAR_ash_pGAS[514] */ - {0x0F12, 0x001E}, /* #TVAR_ash_pGAS[515] */ - {0x0F12, 0x003F}, /* #TVAR_ash_pGAS[516] */ - {0x0F12, 0x006B}, /* #TVAR_ash_pGAS[517] */ - {0x0F12, 0x00A6}, /* #TVAR_ash_pGAS[518] */ - {0x0F12, 0x00E5}, /* #TVAR_ash_pGAS[519] */ - {0x0F12, 0x00D2}, /* #TVAR_ash_pGAS[520] */ - {0x0F12, 0x0097}, /* #TVAR_ash_pGAS[521] */ - {0x0F12, 0x0065}, /* #TVAR_ash_pGAS[522] */ - {0x0F12, 0x0041}, /* #TVAR_ash_pGAS[523] */ - {0x0F12, 0x0027}, /* #TVAR_ash_pGAS[524] */ - {0x0F12, 0x0018}, /* #TVAR_ash_pGAS[525] */ - {0x0F12, 0x0014}, /* #TVAR_ash_pGAS[526] */ - {0x0F12, 0x001A}, /* #TVAR_ash_pGAS[527] */ - {0x0F12, 0x002E}, /* #TVAR_ash_pGAS[528] */ - {0x0F12, 0x004F}, /* #TVAR_ash_pGAS[529] */ - {0x0F12, 0x0076}, /* #TVAR_ash_pGAS[530] */ - {0x0F12, 0x00B3}, /* #TVAR_ash_pGAS[531] */ - {0x0F12, 0x00F1}, /* #TVAR_ash_pGAS[532] */ - {0x0F12, 0x00EE}, /* #TVAR_ash_pGAS[533] */ - {0x0F12, 0x00B3}, /* #TVAR_ash_pGAS[534] */ - {0x0F12, 0x0082}, /* #TVAR_ash_pGAS[535] */ - {0x0F12, 0x005D}, /* #TVAR_ash_pGAS[536] */ - {0x0F12, 0x0043}, /* #TVAR_ash_pGAS[537] */ - {0x0F12, 0x0036}, /* #TVAR_ash_pGAS[538] */ - {0x0F12, 0x0031}, /* #TVAR_ash_pGAS[539] */ - {0x0F12, 0x0037}, /* #TVAR_ash_pGAS[540] */ - {0x0F12, 0x004B}, /* #TVAR_ash_pGAS[541] */ - {0x0F12, 0x0067}, /* #TVAR_ash_pGAS[542] */ - {0x0F12, 0x0092}, /* #TVAR_ash_pGAS[543] */ - {0x0F12, 0x00CD}, /* #TVAR_ash_pGAS[544] */ - {0x0F12, 0x0107}, /* #TVAR_ash_pGAS[545] */ - {0x0F12, 0x0110}, /* #TVAR_ash_pGAS[546] */ - {0x0F12, 0x00DA}, /* #TVAR_ash_pGAS[547] */ - {0x0F12, 0x00AA}, /* #TVAR_ash_pGAS[548] */ - {0x0F12, 0x0086}, /* #TVAR_ash_pGAS[549] */ - {0x0F12, 0x006F}, /* #TVAR_ash_pGAS[550] */ - {0x0F12, 0x0061}, /* #TVAR_ash_pGAS[551] */ - {0x0F12, 0x005B}, /* #TVAR_ash_pGAS[552] */ - {0x0F12, 0x0061}, /* #TVAR_ash_pGAS[553] */ - {0x0F12, 0x0072}, /* #TVAR_ash_pGAS[554] */ - {0x0F12, 0x008D}, /* #TVAR_ash_pGAS[555] */ - {0x0F12, 0x00B6}, /* #TVAR_ash_pGAS[556] */ - {0x0F12, 0x00F1}, /* #TVAR_ash_pGAS[557] */ - {0x0F12, 0x0129}, /* #TVAR_ash_pGAS[558] */ - {0x0F12, 0x0134}, /* #TVAR_ash_pGAS[559] */ - {0x0F12, 0x0102}, /* #TVAR_ash_pGAS[560] */ - {0x0F12, 0x00D2}, /* #TVAR_ash_pGAS[561] */ - {0x0F12, 0x00B0}, /* #TVAR_ash_pGAS[562] */ - {0x0F12, 0x009A}, /* #TVAR_ash_pGAS[563] */ - {0x0F12, 0x008D}, /* #TVAR_ash_pGAS[564] */ - {0x0F12, 0x0089}, /* #TVAR_ash_pGAS[565] */ - {0x0F12, 0x008C}, /* #TVAR_ash_pGAS[566] */ - {0x0F12, 0x0099}, /* #TVAR_ash_pGAS[567] */ - {0x0F12, 0x00B2}, /* #TVAR_ash_pGAS[568] */ - {0x0F12, 0x00D9}, /* #TVAR_ash_pGAS[569] */ - {0x0F12, 0x010E}, /* #TVAR_ash_pGAS[570] */ - {0x0F12, 0x0142}, /* #TVAR_ash_pGAS[571] */ - - {0x002A, 0x0D30}, - {0x0F12, 0x02A7}, /* #awbb_GLocusR */ - {0x0F12, 0x0343}, /* #awbb_GLocusB */ - {0x002A, 0x06B8}, - {0x0F12, 0x00C7}, /* #TVAR_ash_AwbAshCord_0_ */ - {0x0F12, 0x00d9}, /* #TVAR_ash_AwbAshCord_1_ */ - {0x0F12, 0x0110}, /* #TVAR_ash_AwbAshCord_2_ */ - {0x0F12, 0x0129}, /* #TVAR_ash_AwbAshCord_3_ */ - {0x0F12, 0x0159}, /* #TVAR_ash_AwbAshCord_4_ */ - {0x0F12, 0x0179}, /* #TVAR_ash_AwbAshCord_5_ */ - {0x0F12, 0x018c}, /* #TVAR_ash_AwbAshCord_6_ */ - - /* Set CCM */ - /* CCM start address 7000_33A4 */ - {0x002A, 0x0698}, - {0x0F12, 0x33A4}, - {0x0F12, 0x7000}, - {0x002A, 0x33A4}, - {0x0F12, 0x0172}, /* #TVAR_wbt_pBaseCcms[0] Horizon */ - {0x0F12, 0xFF64}, /* #TVAR_wbt_pBaseCcms[1] */ - {0x0F12, 0xFFA0}, /* #TVAR_wbt_pBaseCcms[2] */ - {0x0F12, 0xFF4D}, /* #TVAR_wbt_pBaseCcms[3] */ - {0x0F12, 0x01FA}, /* #TVAR_wbt_pBaseCcms[4] */ - {0x0F12, 0xFEF4}, /* #TVAR_wbt_pBaseCcms[5] */ - {0x0F12, 0xFFD9}, /* #TVAR_wbt_pBaseCcms[6] */ - {0x0F12, 0x0025}, /* #TVAR_wbt_pBaseCcms[7] */ - {0x0F12, 0x026F}, /* #TVAR_wbt_pBaseCcms[8] */ - {0x0F12, 0x0299}, /* #TVAR_wbt_pBaseCcms[9] */ - {0x0F12, 0x012F}, /* #TVAR_wbt_pBaseCcms[10] */ - {0x0F12, 0xFE21}, /* #TVAR_wbt_pBaseCcms[11] */ - {0x0F12, 0x0143}, /* #TVAR_wbt_pBaseCcms[12] */ - {0x0F12, 0xFF4E}, /* #TVAR_wbt_pBaseCcms[13] */ - {0x0F12, 0x0183}, /* #TVAR_wbt_pBaseCcms[14] */ - {0x0F12, 0xFEBA}, /* #TVAR_wbt_pBaseCcms[15] */ - {0x0F12, 0x0191}, /* #TVAR_wbt_pBaseCcms[16] */ - {0x0F12, 0x013D}, /* #TVAR_wbt_pBaseCcms[17] */ - {0x0F12, 0x0172}, /* #TVAR_wbt_pBaseCcms[18] Inca */ - {0x0F12, 0xFF64}, /* #TVAR_wbt_pBaseCcms[19] */ - {0x0F12, 0xFFA0}, /* #TVAR_wbt_pBaseCcms[20] */ - {0x0F12, 0xFF4D}, /* #TVAR_wbt_pBaseCcms[21] */ - {0x0F12, 0x01FA}, /* #TVAR_wbt_pBaseCcms[22] */ - {0x0F12, 0xFEF4}, /* #TVAR_wbt_pBaseCcms[23] */ - {0x0F12, 0xFFD9}, /* #TVAR_wbt_pBaseCcms[24] */ - {0x0F12, 0x0025}, /* #TVAR_wbt_pBaseCcms[25] */ - {0x0F12, 0x026F}, /* #TVAR_wbt_pBaseCcms[26] */ - {0x0F12, 0x0299}, /* #TVAR_wbt_pBaseCcms[27] */ - {0x0F12, 0x012F}, /* #TVAR_wbt_pBaseCcms[28] */ - {0x0F12, 0xFE21}, /* #TVAR_wbt_pBaseCcms[29] */ - {0x0F12, 0x0143}, /* #TVAR_wbt_pBaseCcms[30] */ - {0x0F12, 0xFF4E}, /* #TVAR_wbt_pBaseCcms[31] */ - {0x0F12, 0x0183}, /* #TVAR_wbt_pBaseCcms[32] */ - {0x0F12, 0xFEBA}, /* #TVAR_wbt_pBaseCcms[33] */ - {0x0F12, 0x0191}, /* #TVAR_wbt_pBaseCcms[34] */ - {0x0F12, 0x013D}, /* #TVAR_wbt_pBaseCcms[35] */ - {0x0F12, 0x01C8}, /* #TVAR_wbt_pBaseCcms[36] WW */ - {0x0F12, 0xFF57}, /* #TVAR_wbt_pBaseCcms[37] */ - {0x0F12, 0xFFC3}, /* #TVAR_wbt_pBaseCcms[38] */ - {0x0F12, 0xFF67}, /* #TVAR_wbt_pBaseCcms[39] */ - {0x0F12, 0x01AD}, /* #TVAR_wbt_pBaseCcms[40] */ - {0x0F12, 0xFF39}, /* #TVAR_wbt_pBaseCcms[41] */ - {0x0F12, 0xFFE6}, /* #TVAR_wbt_pBaseCcms[42] */ - {0x0F12, 0xFFF0}, /* #TVAR_wbt_pBaseCcms[43] */ - {0x0F12, 0x01B0}, /* #TVAR_wbt_pBaseCcms[44] */ - {0x0F12, 0x00EF}, /* #TVAR_wbt_pBaseCcms[45] */ - {0x0F12, 0x00EE}, /* #TVAR_wbt_pBaseCcms[46] */ - {0x0F12, 0xFF1D}, /* #TVAR_wbt_pBaseCcms[47] */ - {0x0F12, 0x01A4}, /* #TVAR_wbt_pBaseCcms[48] */ - {0x0F12, 0xFF70}, /* #TVAR_wbt_pBaseCcms[49] */ - {0x0F12, 0x01D0}, /* #TVAR_wbt_pBaseCcms[50] */ - {0x0F12, 0xFF3B}, /* #TVAR_wbt_pBaseCcms[51] */ - {0x0F12, 0x016F}, /* #TVAR_wbt_pBaseCcms[52] */ - {0x0F12, 0x012C}, /* #TVAR_wbt_pBaseCcms[53] */ - {0x0F12, 0x01C8}, /* #TVAR_wbt_pBaseCcms[54] CWF */ - {0x0F12, 0xFF57}, /* #TVAR_wbt_pBaseCcms[55] */ - {0x0F12, 0xFFC3}, /* #TVAR_wbt_pBaseCcms[56] */ - {0x0F12, 0xFF67}, /* #TVAR_wbt_pBaseCcms[57] */ - {0x0F12, 0x01AD}, /* #TVAR_wbt_pBaseCcms[58] */ - {0x0F12, 0xFF39}, /* #TVAR_wbt_pBaseCcms[59] */ - {0x0F12, 0xFFE6}, /* #TVAR_wbt_pBaseCcms[60] */ - {0x0F12, 0xFFF0}, /* #TVAR_wbt_pBaseCcms[61] */ - {0x0F12, 0x01B0}, /* #TVAR_wbt_pBaseCcms[62] */ - {0x0F12, 0x00EF}, /* #TVAR_wbt_pBaseCcms[63] */ - {0x0F12, 0x00EE}, /* #TVAR_wbt_pBaseCcms[64] */ - {0x0F12, 0xFF1D}, /* #TVAR_wbt_pBaseCcms[65] */ - {0x0F12, 0x01A4}, /* #TVAR_wbt_pBaseCcms[66] */ - {0x0F12, 0xFF70}, /* #TVAR_wbt_pBaseCcms[67] */ - {0x0F12, 0x01D0}, /* #TVAR_wbt_pBaseCcms[68] */ - {0x0F12, 0xFF3B}, /* #TVAR_wbt_pBaseCcms[69] */ - {0x0F12, 0x016F}, /* #TVAR_wbt_pBaseCcms[70] */ - {0x0F12, 0x012C}, /* #TVAR_wbt_pBaseCcms[71] */ - {0x0F12, 0x0184}, /* #TVAR_wbt_pBaseCcms[72] D50 */ - {0x0F12, 0xFFA0}, /* #TVAR_wbt_pBaseCcms[73] */ - {0x0F12, 0xFFF4}, /* #TVAR_wbt_pBaseCcms[74] */ - {0x0F12, 0xFF71}, /* #TVAR_wbt_pBaseCcms[75] */ - {0x0F12, 0x019E}, /* #TVAR_wbt_pBaseCcms[76] */ - {0x0F12, 0xFF45}, /* #TVAR_wbt_pBaseCcms[77] */ - {0x0F12, 0xFFFE}, /* #TVAR_wbt_pBaseCcms[78] */ - {0x0F12, 0x0006}, /* #TVAR_wbt_pBaseCcms[79] */ - {0x0F12, 0x018A}, /* #TVAR_wbt_pBaseCcms[80] */ - {0x0F12, 0x0110}, /* #TVAR_wbt_pBaseCcms[81] */ - {0x0F12, 0x010F}, /* #TVAR_wbt_pBaseCcms[82] */ - {0x0F12, 0xFF52}, /* #TVAR_wbt_pBaseCcms[83] */ - {0x0F12, 0x01D7}, /* #TVAR_wbt_pBaseCcms[84] */ - {0x0F12, 0xFF9D}, /* #TVAR_wbt_pBaseCcms[85] */ - {0x0F12, 0x0203}, /* #TVAR_wbt_pBaseCcms[86] */ - {0x0F12, 0xFF55}, /* #TVAR_wbt_pBaseCcms[87] */ - {0x0F12, 0x0163}, /* #TVAR_wbt_pBaseCcms[88] */ - {0x0F12, 0x0126}, /* #TVAR_wbt_pBaseCcms[89] */ - {0x0F12, 0x0199}, /* #TVAR_wbt_pBaseCcms[90] D65*/ - {0x0F12, 0xFFA5}, /* #TVAR_wbt_pBaseCcms[91] */ - {0x0F12, 0xFFFC}, /* #TVAR_wbt_pBaseCcms[92] */ - {0x0F12, 0xFF6F}, /* #TVAR_wbt_pBaseCcms[93] */ - {0x0F12, 0x019F}, /* #TVAR_wbt_pBaseCcms[94] */ - {0x0F12, 0xFF43}, /* #TVAR_wbt_pBaseCcms[95] */ - {0x0F12, 0xFFFB}, /* #TVAR_wbt_pBaseCcms[96] */ - {0x0F12, 0x0003}, /* #TVAR_wbt_pBaseCcms[97] */ - {0x0F12, 0x018E}, /* #TVAR_wbt_pBaseCcms[98] */ - {0x0F12, 0x010C}, /* #TVAR_wbt_pBaseCcms[99] */ - {0x0F12, 0x010B}, /* #TVAR_wbt_pBaseCcms[100] */ - {0x0F12, 0xFF4B}, /* #TVAR_wbt_pBaseCcms[101] */ - {0x0F12, 0x01F6}, /* #TVAR_wbt_pBaseCcms[102] */ - {0x0F12, 0xFFBC}, /* #TVAR_wbt_pBaseCcms[103] */ - {0x0F12, 0x0222}, /* #TVAR_wbt_pBaseCcms[104] */ - {0x0F12, 0xFF4F}, /* #TVAR_wbt_pBaseCcms[105] */ - {0x0F12, 0x0162}, /* #TVAR_wbt_pBaseCcms[106] */ - {0x0F12, 0x0124}, /* #TVAR_wbt_pBaseCcms[107] */ - {0x002A, 0x06A0}, /* Outdoor CCM address 7000_3380 */ - {0x0F12, 0x3380}, - {0x0F12, 0x7000}, - {0x002A, 0x3380}, /* Outdoor CCM */ - {0x0F12, 0x01E0}, /* #TVAR_wbt_pOutdoorCcm[0] */ - {0x0F12, 0xFF80}, /* #TVAR_wbt_pOutdoorCcm[1] */ - {0x0F12, 0xFFD0}, /* #TVAR_wbt_pOutdoorCcm[2] */ - {0x0F12, 0xFF61}, /* #TVAR_wbt_pOutdoorCcm[3] */ - {0x0F12, 0x01BD}, /* #TVAR_wbt_pOutdoorCcm[4] */ - {0x0F12, 0xFF34}, /* #TVAR_wbt_pOutdoorCcm[5] */ - {0x0F12, 0xFFFE}, /* #TVAR_wbt_pOutdoorCcm[6] */ - {0x0F12, 0xFFF6}, /* #TVAR_wbt_pOutdoorCcm[7] */ - {0x0F12, 0x019D}, /* #TVAR_wbt_pOutdoorCcm[8] */ - {0x0F12, 0x0107}, /* #TVAR_wbt_pOutdoorCcm[9] */ - {0x0F12, 0x010F}, /* #TVAR_wbt_pOutdoorCcm[10] */ - {0x0F12, 0xFF67}, /* #TVAR_wbt_pOutdoorCcm[11] */ - {0x0F12, 0x016C}, /* #TVAR_wbt_pOutdoorCcm[12] */ - {0x0F12, 0xFF54}, /* #TVAR_wbt_pOutdoorCcm[13] */ - {0x0F12, 0x01FC}, /* #TVAR_wbt_pOutdoorCcm[14] */ - {0x0F12, 0xFF82}, /* #TVAR_wbt_pOutdoorCcm[15] */ - {0x0F12, 0x015D}, /* #TVAR_wbt_pOutdoorCcm[16] */ - {0x0F12, 0x00FD}, /* #TVAR_wbt_pOutdoorCcm[17] */ - - /* White balance */ - {0x002A, 0x0C48}, - {0x0F12, 0x03C8}, /* awbb_IndoorGrZones_m_BGrid[0] */ - {0x0F12, 0x03E2}, /* awbb_IndoorGrZones_m_BGrid[1] */ - {0x0F12, 0x038A}, /* awbb_IndoorGrZones_m_BGrid[2] */ - {0x0F12, 0x03F4}, /* awbb_IndoorGrZones_m_BGrid[3] */ - {0x0F12, 0x034E}, /* awbb_IndoorGrZones_m_BGrid[4] */ - {0x0F12, 0x03E2}, /* awbb_IndoorGrZones_m_BGrid[5] */ - {0x0F12, 0x030A}, /* awbb_IndoorGrZones_m_BGrid[6] */ - {0x0F12, 0x03B8}, /* awbb_IndoorGrZones_m_BGrid[7] */ - {0x0F12, 0x02C8}, /* awbb_IndoorGrZones_m_BGrid[8] */ - {0x0F12, 0x038A}, /* awbb_IndoorGrZones_m_BGrid[9] */ - {0x0F12, 0x029C}, /* awbb_IndoorGrZones_m_BGrid[10] */ - {0x0F12, 0x0356}, /* awbb_IndoorGrZones_m_BGrid[11] */ - {0x0F12, 0x0286}, /* awbb_IndoorGrZones_m_BGrid[12] */ - {0x0F12, 0x0322}, /* awbb_IndoorGrZones_m_BGrid[13] */ - {0x0F12, 0x026C}, /* awbb_IndoorGrZones_m_BGrid[14] */ - {0x0F12, 0x02F6}, /* awbb_IndoorGrZones_m_BGrid[15] */ - {0x0F12, 0x0254}, /* awbb_IndoorGrZones_m_BGrid[16] */ - {0x0F12, 0x02CA}, /* awbb_IndoorGrZones_m_BGrid[17] */ - {0x0F12, 0x023E}, /* awbb_IndoorGrZones_m_BGrid[18] */ - {0x0F12, 0x02B8}, /* awbb_IndoorGrZones_m_BGrid[19] */ - {0x0F12, 0x022E}, /* awbb_IndoorGrZones_m_BGrid[20] */ - {0x0F12, 0x02A4}, /* awbb_IndoorGrZones_m_BGrid[21] */ - {0x0F12, 0x0226}, /* awbb_IndoorGrZones_m_BGrid[22] */ - {0x0F12, 0x0294}, /* awbb_IndoorGrZones_m_BGrid[23] */ - {0x0F12, 0x0220}, /* awbb_IndoorGrZones_m_BGrid[24] */ - {0x0F12, 0x027E}, /* awbb_IndoorGrZones_m_BGrid[25] */ - {0x0F12, 0x022A}, /* awbb_IndoorGrZones_m_BGrid[26] */ - {0x0F12, 0x025E}, /* awbb_IndoorGrZones_m_BGrid[27] */ - {0x0F12, 0x0000}, /* awbb_IndoorGrZones_m_BGrid[28] */ - {0x0F12, 0x0000}, /* awbb_IndoorGrZones_m_BGrid[29] */ - {0x0F12, 0x0000}, /* awbb_IndoorGrZones_m_BGrid[30] */ - {0x0F12, 0x0000}, /* awbb_IndoorGrZones_m_BGrid[31] */ - {0x0F12, 0x0000}, /* awbb_IndoorGrZones_m_BGrid[32] */ - {0x0F12, 0x0000}, /* awbb_IndoorGrZones_m_BGrid[33] */ - {0x0F12, 0x0000}, /* awbb_IndoorGrZones_m_BGrid[34] */ - {0x0F12, 0x0000}, /* awbb_IndoorGrZones_m_BGrid[35] */ - {0x0F12, 0x0000}, /* awbb_IndoorGrZones_m_BGrid[36] */ - {0x0F12, 0x0000}, /* awbb_IndoorGrZones_m_BGrid[37] */ - {0x0F12, 0x0000}, /* awbb_IndoorGrZones_m_BGrid[38] */ - {0x0F12, 0x0000}, /* awbb_IndoorGrZones_m_BGrid[39] */ - {0x0F12, 0x0005}, /* awbb_IndoorGrZones_m_GridStep */ - {0x002A, 0x0C9C}, - {0x0F12, 0x000E}, - {0x002A, 0x0CA0}, /* awbb_IndoorGrZones_m_Boffs */ - {0x0F12, 0x00FE}, - {0x002A, 0x0CA4}, - {0x0F12, 0x027E}, /* awbb_OutdoorGrZones_m_BGrid[0] */ - {0x0F12, 0x02AE}, /* awbb_OutdoorGrZones_m_BGrid[1] */ - {0x0F12, 0x025C}, /* awbb_OutdoorGrZones_m_BGrid[2] */ - {0x0F12, 0x02B2}, /* awbb_OutdoorGrZones_m_BGrid[3] */ - {0x0F12, 0x0244}, /* awbb_OutdoorGrZones_m_BGrid[4] */ - {0x0F12, 0x02A0}, /* awbb_OutdoorGrZones_m_BGrid[5] */ - {0x0F12, 0x0236}, /* awbb_OutdoorGrZones_m_BGrid[6] */ - {0x0F12, 0x0290}, /* awbb_OutdoorGrZones_m_BGrid[7] */ - {0x0F12, 0x0230}, /* awbb_OutdoorGrZones_m_BGrid[8] */ - {0x0F12, 0x027A}, /* awbb_OutdoorGrZones_m_BGrid[9] */ - {0x0F12, 0x0236}, /* awbb_OutdoorGrZones_m_BGrid[10] */ - {0x0F12, 0x025E}, /* awbb_OutdoorGrZones_m_BGrid[11] */ - {0x0F12, 0x0000}, /* awbb_OutdoorGrZones_m_BGrid[12] */ - {0x0F12, 0x0000}, /* awbb_OutdoorGrZones_m_BGrid[13] */ - {0x0F12, 0x0000}, /* awbb_OutdoorGrZones_m_BGrid[14] */ - {0x0F12, 0x0000}, /* awbb_OutdoorGrZones_m_BGrid[15] */ - {0x0F12, 0x0000}, /* awbb_OutdoorGrZones_m_BGrid[16] */ - {0x0F12, 0x0000}, /* awbb_OutdoorGrZones_m_BGrid[17] */ - {0x0F12, 0x0000}, /* awbb_OutdoorGrZones_m_BGrid[18] */ - {0x0F12, 0x0000}, /* awbb_OutdoorGrZones_m_BGrid[19] */ - {0x0F12, 0x0000}, /* awbb_OutdoorGrZones_m_BGrid[20] */ - {0x0F12, 0x0000}, /* awbb_OutdoorGrZones_m_BGrid[21] */ - {0x0F12, 0x0000}, /* awbb_OutdoorGrZones_m_BGrid[22] */ - {0x0F12, 0x0000}, /* awbb_OutdoorGrZones_m_BGrid[23] */ - {0x0F12, 0x0005}, - {0x002A, 0x0CD8}, /* awbb_OutdoorGrZones_m_GridStep */ - {0x0F12, 0x0006}, - {0x002A, 0x0CDC}, /* awbb_OutdoorGrZones_m_Boffs */ - {0x0F12, 0x01EE}, - - {0x002A, 0x0D88}, - {0x0F12, 0xFFAD}, /* awbb_OutdoorDetectionZone_m_BGrid[0] */ - {0x0F12, 0x005D}, /* awbb_OutdoorDetectionZone_m_BGrid[1] */ - {0x0F12, 0xFF6B}, /* awbb_OutdoorDetectionZone_m_BGrid[2] */ - {0x0F12, 0x00A0}, /* awbb_OutdoorDetectionZone_m_BGrid[3] */ - {0x0F12, 0xFEFE}, /* awbb_OutdoorDetectionZone_m_BGrid[4] */ - {0x0F12, 0x010D}, /* awbb_OutdoorDetectionZone_m_BGrid[5] */ - {0x0F12, 0xFE99}, /* awbb_OutdoorDetectionZone_m_BGrid[6] */ - {0x0F12, 0x0172}, /* awbb_OutdoorDetectionZone_m_BGrid[7] */ - {0x0F12, 0xFE6A}, /* awbb_OutdoorDetectionZone_m_BGrid[8] */ - {0x0F12, 0x01A8}, /* awbb_OutdoorDetectionZone_m_BGrid[9] */ - {0x0F12, 0x1388}, /* awbb_OutdoorDetectionZone_ZInfo_m_AbsGridStep */ - {0x0F12, 0x0000}, /* awbb_OutdoorDetectionZone_ZInfo_m_MaxNB */ - {0x0F12, 0x0005}, /* awbb_OutdoorDetectionZone_ZInfo_m_NBoffs */ - {0x0F12, 0x0000}, - {0x0F12, 0x1387}, - {0x0F12, 0x0000}, - {0x0F12, 0x1388}, - {0x0F12, 0x0000}, - - {0x002A, 0x0DA8}, - {0x0F12, 0x0913}, - {0x002A, 0x0DA4}, - {0x0F12, 0x0008}, - - {0x002A, 0x0CE0}, - {0x0F12, 0x03EA}, /* awbb_LowBrGrZones_m_BGrid[0] */ - {0x0F12, 0x044E}, /* awbb_LowBrGrZones_m_BGrid[1] */ - {0x0F12, 0x035E}, /* awbb_LowBrGrZones_m_BGrid[2] */ - {0x0F12, 0x044C}, /* awbb_LowBrGrZones_m_BGrid[3] */ - {0x0F12, 0x02FA}, /* awbb_LowBrGrZones_m_BGrid[4] */ - {0x0F12, 0x0434}, /* awbb_LowBrGrZones_m_BGrid[5] */ - {0x0F12, 0x02AA}, /* awbb_LowBrGrZones_m_BGrid[6] */ - {0x0F12, 0x03F2}, /* awbb_LowBrGrZones_m_BGrid[7] */ - {0x0F12, 0x0266}, /* awbb_LowBrGrZones_m_BGrid[8] */ - {0x0F12, 0x03AE}, /* awbb_LowBrGrZones_m_BGrid[9] */ - {0x0F12, 0x022C}, /* awbb_L0CA4owBrGrZones_m_BGrid[10] */ - {0x0F12, 0x035A}, /* awbb_LowBrGrZones_m_BGrid[11] */ - {0x0F12, 0x020E}, /* awbb_LowBrGrZones_m_BGrid[12] */ - {0x0F12, 0x0314}, /* awbb_LowBrGrZones_m_BGrid[13] */ - {0x0F12, 0x01F4}, /* awbb_LowBrGrZones_m_BGrid[14] */ - {0x0F12, 0x02E0}, /* awbb_LowBrGrZones_m_BGrid[15] */ - {0x0F12, 0x01E2}, /* awbb_LowBrGrZones_m_BGrid[16] */ - {0x0F12, 0x02AA}, /* awbb_LowBrGrZones_m_BGrid[17] */ - {0x0F12, 0x01E6}, /* awbb_LowBrGrZones_m_BGrid[18] */ - {0x0F12, 0x0264}, /* awbb_LowBrGrZones_m_BGrid[19] */ - {0x0F12, 0x0000}, /* awbb_LowBrGrZones_m_BGrid[20] */ - {0x0F12, 0x0000}, /* awbb_LowBrGrZones_m_BGrid[21] */ - {0x0F12, 0x0000}, /* awbb_LowBrGrZones_m_BGrid[22] */ - {0x0F12, 0x0000}, /* awbb_LowBrGrZones_m_BGrid[23] */ - {0x0F12, 0x0006}, /* awbb_LowBrGrZones_m_GridStep */ - {0x002A, 0x0D14}, - {0x0F12, 0x000A}, - {0x002A, 0x0D18}, /* awbb_LowBrGrZones_m_Boffs */ - {0x0F12, 0x009A}, - {0x002A, 0x0D1C}, - {0x0F12, 0x036C}, /* awbb_CrclLowT_R_c */ - {0x002A, 0x0D20}, - {0x0F12, 0x011C}, /* awbb_CrclLowT_B_c */ - {0x002A, 0x0D24}, - {0x0F12, 0x6184}, /* awbb_CrclLowT_Rad_c */ - {0x002A, 0x0D2C}, - {0x0F12, 0x0135}, /* awbb_IntcR */ - {0x0F12, 0x012B}, /* awbb_IntcB */ - {0x002A, 0x0D28}, - {0x0F12, 0x024E}, - {0x0F12, 0x027B}, - {0x002A, 0x0E4C}, - {0x0F12, 0x0000}, - {0x002A, 0x0D4C}, - {0x0F12, 0x0653}, - {0x0F12, 0x02EB}, - {0x0F12, 0x002C}, - {0x0F12, 0x000B}, - {0x002A, 0x0D5C}, /* awbb_LowTempRB */ - {0x0F12, 0x7FFF}, - {0x0F12, 0x0050}, - {0x002A, 0x0D46}, - {0x0F12, 0x053A}, /* awbb_MvEq_RBthresh */ - {0x002A, 0x0D4A}, - {0x0F12, 0x000A}, - {0x002A, 0x0DD4}, - {0x0F12, 0xFFFE}, - {0x0F12, 0xFFEC}, - {0x0F12, 0x0000}, - {0x0F12, 0x0000}, - {0x0F12, 0x0000}, - {0x0F12, 0x0000}, - {0x0F12, 0xFFFD}, - {0x0F12, 0xFFEC}, - {0x0F12, 0x0000}, - {0x0F12, 0x0000}, - {0x0F12, 0x0000}, - {0x0F12, 0x0000}, - {0x0F12, 0xFFFC}, - {0x0F12, 0xFFEC}, - {0x0F12, 0x0000}, - {0x0F12, 0x0000}, - {0x0F12, 0x0000}, - {0x0F12, 0x0000}, - - {0x0F12, 0x0000}, - {0x0F12, 0x0028}, - {0x0F12, 0x0000}, - {0x0F12, 0x0000}, - {0x0F12, 0x0000}, - {0x0F12, 0x0000}, - {0x0F12, 0x0000}, - {0x0F12, 0x0028}, - {0x0F12, 0x0000}, - {0x0F12, 0x0000}, - {0x0F12, 0x0000}, - {0x0F12, 0x0000}, - {0x0F12, 0x0000}, - {0x0F12, 0x0028}, - {0x0F12, 0x0000}, - {0x0F12, 0x0000}, - {0x0F12, 0x0000}, - {0x0F12, 0x0000}, - - {0x0F12, 0x02F0}, - {0x0F12, 0x0358}, - {0x0F12, 0x03A5}, - {0x0F12, 0x0F9C}, - {0x0F12, 0x0FFA}, - {0x0F12, 0x10B5}, - {0x0F12, 0x1126}, - {0x0F12, 0x1176}, - {0x0F12, 0x1220}, - {0x0F12, 0x00B2}, - {0x0F12, 0x00B8}, - {0x0F12, 0x00B7}, - {0x0F12, 0x00B3}, - {0x002A, 0x0E3E}, - {0x0F12, 0x0000}, - {0x002A, 0x22DE}, - {0x0F12, 0x0004}, - {0x002A, 0x337C}, - {0x0F12, 0x00B3}, - {0x0F12, 0x0040}, - {0x002A, 0x0E44}, - {0x0F12, 0x053C}, - {0x0F12, 0x0400}, - {0x0F12, 0x055C}, - {0x002A, 0x0E36}, - {0x0F12, 0x0000}, - {0x0F12, 0x0000}, - {0x0F12, 0x0000}, - - {0x002A, 0x0E4A}, /* Grid offset enable */ - {0x0F12, 0x0001}, - - /* Set GAMMA */ - {0x002A, 0x3288}, - {0x0F12, 0x0000}, /* #SARR_usDualGammaLutRGBIndoor_0__0_ 0x70003288 */ - {0x0F12, 0x0004}, /* #SARR_usDualGammaLutRGBIndoor_0__1_ 0x7000328A */ - {0x0F12, 0x0010}, /* #SARR_usDualGammaLutRGBIndoor_0__2_ 0x7000328C */ - {0x0F12, 0x002A}, /* #SARR_usDualGammaLutRGBIndoor_0__3_ 0x7000328E */ - {0x0F12, 0x0062}, /* #SARR_usDualGammaLutRGBIndoor_0__4_ 0x70003290 */ - {0x0F12, 0x00D5}, /* #SARR_usDualGammaLutRGBIndoor_0__5_ 0x70003292 */ - {0x0F12, 0x0138}, /* #SARR_usDualGammaLutRGBIndoor_0__6_ 0x70003294 */ - {0x0F12, 0x0161}, /* #SARR_usDualGammaLutRGBIndoor_0__7_ 0x70003296 */ - {0x0F12, 0x0186}, /* #SARR_usDualGammaLutRGBIndoor_0__8_ 0x70003298 */ - {0x0F12, 0x01BC}, /* #SARR_usDualGammaLutRGBIndoor_0__9_ 0x7000329A */ - {0x0F12, 0x01E8}, /* #SARR_usDualGammaLutRGBIndoor_0__10_ 0x7000329C */ - {0x0F12, 0x020F}, /* #SARR_usDualGammaLutRGBIndoor_0__11_ 0x7000329E */ - {0x0F12, 0x0232}, /* #SARR_usDualGammaLutRGBIndoor_0__12_ 0x700032A0 */ - {0x0F12, 0x0273}, /* #SARR_usDualGammaLutRGBIndoor_0__13_ 0x700032A2 */ - {0x0F12, 0x02AF}, /* #SARR_usDualGammaLutRGBIndoor_0__14_ 0x700032A4 */ - {0x0F12, 0x0309}, /* #SARR_usDualGammaLutRGBIndoor_0__15_ 0x700032A6 */ - {0x0F12, 0x0355}, /* #SARR_usDualGammaLutRGBIndoor_0__16_ 0x700032A8 */ - {0x0F12, 0x0394}, /* #SARR_usDualGammaLutRGBIndoor_0__17_ 0x700032AA */ - {0x0F12, 0x03CE}, /* #SARR_usDualGammaLutRGBIndoor_0__18_ 0x700032AC */ - {0x0F12, 0x03FF}, /* #SARR_usDualGammaLutRGBIndoor_0__19_ 0x700032AE */ - {0x0F12, 0x0000}, /* #SARR_usDualGammaLutRGBIndoor_1__0_ 0x700032B0 */ - {0x0F12, 0x0004}, /* #SARR_usDualGammaLutRGBIndoor_1__1_ 0x700032B2 */ - {0x0F12, 0x0010}, /* #SARR_usDualGammaLutRGBIndoor_1__2_ 0x700032B4 */ - {0x0F12, 0x002A}, /* #SARR_usDualGammaLutRGBIndoor_1__3_ 0x700032B6 */ - {0x0F12, 0x0062}, /* #SARR_usDualGammaLutRGBIndoor_1__4_ 0x700032B8 */ - {0x0F12, 0x00D5}, /* #SARR_usDualGammaLutRGBIndoor_1__5_ 0x700032BA */ - {0x0F12, 0x0138}, /* #SARR_usDualGammaLutRGBIndoor_1__6_ 0x700032BC */ - {0x0F12, 0x0161}, /* #SARR_usDualGammaLutRGBIndoor_1__7_ 0x700032BE */ - {0x0F12, 0x0186}, /* #SARR_usDualGammaLutRGBIndoor_1__8_ 0x700032C0 */ - {0x0F12, 0x01BC}, /* #SARR_usDualGammaLutRGBIndoor_1__9_ 0x700032C2 */ - {0x0F12, 0x01E8}, /* #SARR_usDualGammaLutRGBIndoor_1__10_ 0x700032C4 */ - {0x0F12, 0x020F}, /* #SARR_usDualGammaLutRGBIndoor_1__11_ 0x700032C6 */ - {0x0F12, 0x0232}, /* #SARR_usDualGammaLutRGBIndoor_1__12_ 0x700032C8 */ - {0x0F12, 0x0273}, /* #SARR_usDualGammaLutRGBIndoor_1__13_ 0x700032CA */ - {0x0F12, 0x02AF}, /* #SARR_usDualGammaLutRGBIndoor_1__14_ 0x700032CC */ - {0x0F12, 0x0309}, /* #SARR_usDualGammaLutRGBIndoor_1__15_ 0x700032CE */ - {0x0F12, 0x0355}, /* #SARR_usDualGammaLutRGBIndoor_1__16_ 0x700032D0 */ - {0x0F12, 0x0394}, /* #SARR_usDualGammaLutRGBIndoor_1__17_ 0x700032D2 */ - {0x0F12, 0x03CE}, /* #SARR_usDualGammaLutRGBIndoor_1__18_ 0x700032D4 */ - {0x0F12, 0x03FF}, /* #SARR_usDualGammaLutRGBIndoor_1__19_ 0x700032D6 */ - {0x0F12, 0x0000}, /* #SARR_usDualGammaLutRGBIndoor_2__0_ 0x700032D8 */ - {0x0F12, 0x0004}, /* #SARR_usDualGammaLutRGBIndoor_2__1_ 0x700032DA */ - {0x0F12, 0x0010}, /* #SARR_usDualGammaLutRGBIndoor_2__2_ 0x700032DC */ - {0x0F12, 0x002A}, /* #SARR_usDualGammaLutRGBIndoor_2__3_ 0x700032DE */ - {0x0F12, 0x0062}, /* #SARR_usDualGammaLutRGBIndoor_2__4_ 0x700032E0 */ - {0x0F12, 0x00D5}, /* #SARR_usDualGammaLutRGBIndoor_2__5_ 0x700032E2 */ - {0x0F12, 0x0138}, /* #SARR_usDualGammaLutRGBIndoor_2__6_ 0x700032E4 */ - {0x0F12, 0x0161}, /* #SARR_usDualGammaLutRGBIndoor_2__7_ 0x700032E6 */ - {0x0F12, 0x0186}, /* #SARR_usDualGammaLutRGBIndoor_2__8_ 0x700032E8 */ - {0x0F12, 0x01BC}, /* #SARR_usDualGammaLutRGBIndoor_2__9_ 0x700032EA */ - {0x0F12, 0x01E8}, /* #SARR_usDualGammaLutRGBIndoor_2__10_ 0x700032EC */ - {0x0F12, 0x020F}, /* #SARR_usDualGammaLutRGBIndoor_2__11_ 0x700032EE */ - {0x0F12, 0x0232}, /* #SARR_usDualGammaLutRGBIndoor_2__12_ 0x700032F0 */ - {0x0F12, 0x0273}, /* #SARR_usDualGammaLutRGBIndoor_2__13_ 0x700032F2 */ - {0x0F12, 0x02AF}, /* #SARR_usDualGammaLutRGBIndoor_2__14_ 0x700032F4 */ - {0x0F12, 0x0309}, /* #SARR_usDualGammaLutRGBIndoor_2__15_ 0x700032F6 */ - {0x0F12, 0x0355}, /* #SARR_usDualGammaLutRGBIndoor_2__16_ 0x700032F8 */ - {0x0F12, 0x0394}, /* #SARR_usDualGammaLutRGBIndoor_2__17_ 0x700032FA */ - {0x0F12, 0x03CE}, /* #SARR_usDualGammaLutRGBIndoor_2__18_ 0x700032FC */ - {0x0F12, 0x03FF}, /* #SARR_usDualGammaLutRGBIndoor_2__19_ 0x700032FE */ - {0x0F12, 0x0000}, /* #SARR_usDualGammaLutRGBOutdoor_0__0_ 0x70003300 */ - {0x0F12, 0x0004}, /* #SARR_usDualGammaLutRGBOutdoor_0__1_ 0x70003302 */ - {0x0F12, 0x0010}, /* #SARR_usDualGammaLutRGBOutdoor_0__2_ 0x70003304 */ - {0x0F12, 0x002A}, /* #SARR_usDualGammaLutRGBOutdoor_0__3_ 0x70003306 */ - {0x0F12, 0x0062}, /* #SARR_usDualGammaLutRGBOutdoor_0__4_ 0x70003308 */ - {0x0F12, 0x00D5}, /* #SARR_usDualGammaLutRGBOutdoor_0__5_ 0x7000330A */ - {0x0F12, 0x0138}, /* #SARR_usDualGammaLutRGBOutdoor_0__6_ 0x7000330C */ - {0x0F12, 0x0161}, /* #SARR_usDualGammaLutRGBOutdoor_0__7_ 0x7000330E */ - {0x0F12, 0x0186}, /* #SARR_usDualGammaLutRGBOutdoor_0__8_ 0x70003310 */ - {0x0F12, 0x01BC}, /* #SARR_usDualGammaLutRGBOutdoor_0__9_ 0x70003312 */ - {0x0F12, 0x01E8}, /* #SARR_usDualGammaLutRGBOutdoor_0__10_0x70003314 */ - {0x0F12, 0x020F}, /* #SARR_usDualGammaLutRGBOutdoor_0__11_0x70003316 */ - {0x0F12, 0x0232}, /* #SARR_usDualGammaLutRGBOutdoor_0__12_0x70003318 */ - {0x0F12, 0x0273}, /* #SARR_usDualGammaLutRGBOutdoor_0__13_0x7000331A */ - {0x0F12, 0x02AF}, /* #SARR_usDualGammaLutRGBOutdoor_0__14_0x7000331C */ - {0x0F12, 0x0309}, /* #SARR_usDualGammaLutRGBOutdoor_0__15_0x7000331E */ - {0x0F12, 0x0355}, /* #SARR_usDualGammaLutRGBOutdoor_0__16_0x70003320 */ - {0x0F12, 0x0394}, /* #SARR_usDualGammaLutRGBOutdoor_0__17_0x70003322 */ - {0x0F12, 0x03CE}, /* #SARR_usDualGammaLutRGBOutdoor_0__18_0x70003324 */ - {0x0F12, 0x03FF}, /* #SARR_usDualGammaLutRGBOutdoor_0__19_0x70003326 */ - {0x0F12, 0x0000}, /* #SARR_usDualGammaLutRGBOutdoor_1__0_ 0x70003328 */ - {0x0F12, 0x0004}, /* #SARR_usDualGammaLutRGBOutdoor_1__1_ 0x7000332A */ - {0x0F12, 0x0010}, /* #SARR_usDualGammaLutRGBOutdoor_1__2_ 0x7000332C */ - {0x0F12, 0x002A}, /* #SARR_usDualGammaLutRGBOutdoor_1__3_ 0x7000332E */ - {0x0F12, 0x0062}, /* #SARR_usDualGammaLutRGBOutdoor_1__4_ 0x70003330 */ - {0x0F12, 0x00D5}, /* #SARR_usDualGammaLutRGBOutdoor_1__5_ 0x70003332 */ - {0x0F12, 0x0138}, /* #SARR_usDualGammaLutRGBOutdoor_1__6_ 0x70003334 */ - {0x0F12, 0x0161}, /* #SARR_usDualGammaLutRGBOutdoor_1__7_ 0x70003336 */ - {0x0F12, 0x0186}, /* #SARR_usDualGammaLutRGBOutdoor_1__8_ 0x70003338 */ - {0x0F12, 0x01BC}, /* #SARR_usDualGammaLutRGBOutdoor_1__9_ 0x7000333A */ - {0x0F12, 0x01E8}, /* #SARR_usDualGammaLutRGBOutdoor_1__10_0x7000333C */ - {0x0F12, 0x020F}, /* #SARR_usDualGammaLutRGBOutdoor_1__11_0x7000333E */ - {0x0F12, 0x0232}, /* #SARR_usDualGammaLutRGBOutdoor_1__12_0x70003340 */ - {0x0F12, 0x0273}, /* #SARR_usDualGammaLutRGBOutdoor_1__13_0x70003342 */ - {0x0F12, 0x02AF}, /* #SARR_usDualGammaLutRGBOutdoor_1__14_0x70003344 */ - {0x0F12, 0x0309}, /* #SARR_usDualGammaLutRGBOutdoor_1__15_0x70003346 */ - {0x0F12, 0x0355}, /* #SARR_usDualGammaLutRGBOutdoor_1__16_0x70003348 */ - {0x0F12, 0x0394}, /* #SARR_usDualGammaLutRGBOutdoor_1__17_0x7000334A */ - {0x0F12, 0x03CE}, /* #SARR_usDualGammaLutRGBOutdoor_1__18_0x7000334C */ - {0x0F12, 0x03FF}, /* #SARR_usDualGammaLutRGBOutdoor_1__19_0x7000334E */ - {0x0F12, 0x0000}, /* #SARR_usDualGammaLutRGBOutdoor_2__0_ 0x70003350 */ - {0x0F12, 0x0004}, /* #SARR_usDualGammaLutRGBOutdoor_2__1_ 0x70003352 */ - {0x0F12, 0x0010}, /* #SARR_usDualGammaLutRGBOutdoor_2__2_ 0x70003354 */ - {0x0F12, 0x002A}, /* #SARR_usDualGammaLutRGBOutdoor_2__3_ 0x70003356 */ - {0x0F12, 0x0062}, /* #SARR_usDualGammaLutRGBOutdoor_2__4_ 0x70003358 */ - {0x0F12, 0x00D5}, /* #SARR_usDualGammaLutRGBOutdoor_2__5_ 0x7000335A */ - {0x0F12, 0x0138}, /* #SARR_usDualGammaLutRGBOutdoor_2__6_ 0x7000335C */ - {0x0F12, 0x0161}, /* #SARR_usDualGammaLutRGBOutdoor_2__7_ 0x7000335E */ - {0x0F12, 0x0186}, /* #SARR_usDualGammaLutRGBOutdoor_2__8_ 0x70003360 */ - {0x0F12, 0x01BC}, /* #SARR_usDualGammaLutRGBOutdoor_2__9_ 0x70003362 */ - {0x0F12, 0x01E8}, /* #SARR_usDualGammaLutRGBOutdoor_2__10_0x70003364 */ - {0x0F12, 0x020F}, /* #SARR_usDualGammaLutRGBOutdoor_2__11_0x70003366 */ - {0x0F12, 0x0232}, /* #SARR_usDualGammaLutRGBOutdoor_2__12_0x70003368 */ - {0x0F12, 0x0273}, /* #SARR_usDualGammaLutRGBOutdoor_2__13_0x7000336A */ - {0x0F12, 0x02AF}, /* #SARR_usDualGammaLutRGBOutdoor_2__14_0x7000336C */ - {0x0F12, 0x0309}, /* #SARR_usDualGammaLutRGBOutdoor_2__15_0x7000336E */ - {0x0F12, 0x0355}, /* #SARR_usDualGammaLutRGBOutdoor_2__16_0x70003370 */ - {0x0F12, 0x0394}, /* #SARR_usDualGammaLutRGBOutdoor_2__17_0x70003372 */ - {0x0F12, 0x03CE}, /* #SARR_usDualGammaLutRGBOutdoor_2__18_0x70003374 */ - {0x0F12, 0x03FF}, /* #SARR_usDualGammaLutRGBOutdoor_2__19_0x70003376 */ - - {0x002A, 0x06A6}, - {0x0F12, 0x00CA}, /* #SARR_AwbCcmCord_0_ */ - {0x0F12, 0x00EA}, /* #SARR_AwbCcmCord_1_ */ - {0x0F12, 0x0110}, /* #SARR_AwbCcmCord_2_ */ - {0x0F12, 0x0124}, /* #SARR_AwbCcmCord_3_ */ - {0x0F12, 0x0160}, /* #SARR_AwbCcmCord_4_ */ - {0x0F12, 0x0180}, /* #SARR_AwbCcmCord_5_ */ - - /* Set AFIT */ - /* Noise index */ - {0x002A, 0x0764}, - {0x0F12, 0x0041}, /* #afit_uNoiseIndInDoor[0] */ - {0x0F12, 0x0063}, /* #afit_uNoiseIndInDoor[1] */ - {0x0F12, 0x00BB}, /* #afit_uNoiseIndInDoor[2] */ - {0x0F12, 0x0193}, /* #afit_uNoiseIndInDoor[3] */ - {0x0F12, 0x02BC}, /* #afit_uNoiseIndInDoor[4] */ - - /* AFIT table start address 7000_07C4 */ - {0x002A, 0x0770}, - {0x0F12, 0x07C4}, - {0x0F12, 0x7000}, - - /* AFIT table (Variables) */ - {0x002A, 0x07C4}, - {0x0F12, 0x0000}, /* #TVAR_afit_pBaseVals[0] */ - {0x0F12, 0x0000}, /* #TVAR_afit_pBaseVals[1] */ - {0x0F12, 0x0000}, /* #TVAR_afit_pBaseVals[2] */ - {0x0F12, 0x0000}, /* #TVAR_afit_pBaseVals[3] */ - {0x0F12, 0x0000}, /* #TVAR_afit_pBaseVals[4] */ - {0x0F12, 0x00C4}, /* #TVAR_afit_pBaseVals[5] */ - {0x0F12, 0x03FF}, /* #TVAR_afit_pBaseVals[6] */ - {0x0F12, 0x009C}, /* #TVAR_afit_pBaseVals[7] */ - {0x0F12, 0x017C}, /* #TVAR_afit_pBaseVals[8] */ - {0x0F12, 0x03FF}, /* #TVAR_afit_pBaseVals[9] */ - {0x0F12, 0x000C}, /* #TVAR_afit_pBaseVals[10] */ - {0x0F12, 0x0010}, /* #TVAR_afit_pBaseVals[11] */ - {0x0F12, 0x0104}, /* #TVAR_afit_pBaseVals[12] */ - {0x0F12, 0x03E8}, /* #TVAR_afit_pBaseVals[13] */ - {0x0F12, 0x0023}, /* #TVAR_afit_pBaseVals[14] */ - {0x0F12, 0x012C}, /* #TVAR_afit_pBaseVals[15] */ - {0x0F12, 0x0070}, /* #TVAR_afit_pBaseVals[16] */ - {0x0F12, 0x0010}, /* #TVAR_afit_pBaseVals[17] */ - {0x0F12, 0x0010}, /* #TVAR_afit_pBaseVals[18] */ - {0x0F12, 0x01AA}, /* #TVAR_afit_pBaseVals[19] */ - {0x0F12, 0x0064}, /* #TVAR_afit_pBaseVals[20] */ - {0x0F12, 0x0064}, /* #TVAR_afit_pBaseVals[21] */ - {0x0F12, 0x000A}, /* #TVAR_afit_pBaseVals[22] */ - {0x0F12, 0x000A}, /* #TVAR_afit_pBaseVals[23] */ - {0x0F12, 0x003C}, /* #TVAR_afit_pBaseVals[24] */ - {0x0F12, 0x0024}, /* #TVAR_afit_pBaseVals[25] */ - {0x0F12, 0x002A}, /* #TVAR_afit_pBaseVals[26] */ - {0x0F12, 0x0024}, /* #TVAR_afit_pBaseVals[27] */ - {0x0F12, 0x002A}, /* #TVAR_afit_pBaseVals[28] */ - {0x0F12, 0x0024}, /* #TVAR_afit_pBaseVals[29] */ - {0x0F12, 0x0A24}, /* #TVAR_afit_pBaseVals[30] */ - {0x0F12, 0x1701}, /* #TVAR_afit_pBaseVals[31] */ - {0x0F12, 0x0229}, /* #TVAR_afit_pBaseVals[32] */ - {0x0F12, 0x1403}, /* #TVAR_afit_pBaseVals[33] */ - {0x0F12, 0x0000}, /* #TVAR_afit_pBaseVals[34] */ - {0x0F12, 0x0000}, /* #TVAR_afit_pBaseVals[35] */ - {0x0F12, 0x0000}, /* #TVAR_afit_pBaseVals[36] */ - {0x0F12, 0x00FF}, /* #TVAR_afit_pBaseVals[37] */ - {0x0F12, 0x043B}, /* #TVAR_afit_pBaseVals[38] */ - {0x0F12, 0x1414}, /* #TVAR_afit_pBaseVals[39] */ - {0x0F12, 0x0301}, /* #TVAR_afit_pBaseVals[40] */ - {0x0F12, 0xFF07}, /* #TVAR_afit_pBaseVals[41] */ - {0x0F12, 0x051E}, /* #TVAR_afit_pBaseVals[42] */ - {0x0F12, 0x0A1E}, /* #TVAR_afit_pBaseVals[43] */ - {0x0F12, 0x0F0F}, /* #TVAR_afit_pBaseVals[44] */ - {0x0F12, 0x0A05}, /* #TVAR_afit_pBaseVals[45] */ - {0x0F12, 0x0A3C}, /* #TVAR_afit_pBaseVals[46] */ - {0x0F12, 0x0A28}, /* #TVAR_afit_pBaseVals[47] */ - {0x0F12, 0x0002}, /* #TVAR_afit_pBaseVals[48] */ - {0x0F12, 0x00FF}, /* #TVAR_afit_pBaseVals[49] */ - {0x0F12, 0x1002}, /* #TVAR_afit_pBaseVals[50] */ - {0x0F12, 0x001D}, /* #TVAR_afit_pBaseVals[51] */ - {0x0F12, 0x0900}, /* #TVAR_afit_pBaseVals[52] */ - {0x0F12, 0x0600}, /* #TVAR_afit_pBaseVals[53] */ - {0x0F12, 0x0504}, /* #TVAR_afit_pBaseVals[54] */ - {0x0F12, 0x0305}, /* #TVAR_afit_pBaseVals[55] */ - {0x0F12, 0x5003}, /* #TVAR_afit_pBaseVals[56] */ - {0x0F12, 0x006E}, /* #TVAR_afit_pBaseVals[57] */ - {0x0F12, 0x0078}, /* #TVAR_afit_pBaseVals[58] */ - {0x0F12, 0x0080}, /* #TVAR_afit_pBaseVals[59] */ - {0x0F12, 0x1414}, /* #TVAR_afit_pBaseVals[60] */ - {0x0F12, 0x0101}, /* #TVAR_afit_pBaseVals[61] */ - {0x0F12, 0x5002}, /* #TVAR_afit_pBaseVals[62] */ - {0x0F12, 0x7850}, /* #TVAR_afit_pBaseVals[63] */ - {0x0F12, 0x2878}, /* #TVAR_afit_pBaseVals[64] */ - {0x0F12, 0x0A00}, /* #TVAR_afit_pBaseVals[65] */ - {0x0F12, 0x1403}, /* #TVAR_afit_pBaseVals[66] */ - {0x0F12, 0x1E0C}, /* #TVAR_afit_pBaseVals[67] */ - {0x0F12, 0x070A}, /* #TVAR_afit_pBaseVals[68] */ - {0x0F12, 0x32FF}, /* #TVAR_afit_pBaseVals[69] */ - {0x0F12, 0x5004}, /* #TVAR_afit_pBaseVals[70] */ - {0x0F12, 0x0F40}, /* #TVAR_afit_pBaseVals[71] */ - {0x0F12, 0x400F}, /* #TVAR_afit_pBaseVals[72] */ - {0x0F12, 0x0204}, /* #TVAR_afit_pBaseVals[73] */ - {0x0F12, 0x1E03}, /* #TVAR_afit_pBaseVals[74] */ - {0x0F12, 0x011E}, /* #TVAR_afit_pBaseVals[75] */ - {0x0F12, 0x0101}, /* #TVAR_afit_pBaseVals[76] */ - {0x0F12, 0x5050}, /* #TVAR_afit_pBaseVals[77] */ - {0x0F12, 0x7878}, /* #TVAR_afit_pBaseVals[78] */ - {0x0F12, 0x0028}, /* #TVAR_afit_pBaseVals[79] */ - {0x0F12, 0x030A}, /* #TVAR_afit_pBaseVals[80] */ - {0x0F12, 0x0714}, /* #TVAR_afit_pBaseVals[81] */ - {0x0F12, 0x0A1E}, /* #TVAR_afit_pBaseVals[82] */ - {0x0F12, 0xFF07}, /* #TVAR_afit_pBaseVals[83] */ - {0x0F12, 0x0432}, /* #TVAR_afit_pBaseVals[84] */ - {0x0F12, 0x4050}, /* #TVAR_afit_pBaseVals[85] */ - {0x0F12, 0x0F0F}, /* #TVAR_afit_pBaseVals[86] */ - {0x0F12, 0x0440}, /* #TVAR_afit_pBaseVals[87] */ - {0x0F12, 0x0302}, /* #TVAR_afit_pBaseVals[88] */ - {0x0F12, 0x1E1E}, /* #TVAR_afit_pBaseVals[89] */ - {0x0F12, 0x0101}, /* #TVAR_afit_pBaseVals[90] */ - {0x0F12, 0x5001}, /* #TVAR_afit_pBaseVals[91] */ - {0x0F12, 0x7850}, /* #TVAR_afit_pBaseVals[92] */ - {0x0F12, 0x2878}, /* #TVAR_afit_pBaseVals[93] */ - {0x0F12, 0x0A00}, /* #TVAR_afit_pBaseVals[94] */ - {0x0F12, 0x1403}, /* #TVAR_afit_pBaseVals[95] */ - {0x0F12, 0x1E07}, /* #TVAR_afit_pBaseVals[96] */ - {0x0F12, 0x070A}, /* #TVAR_afit_pBaseVals[97] */ - {0x0F12, 0x32FF}, /* #TVAR_afit_pBaseVals[98] */ - {0x0F12, 0x5004}, /* #TVAR_afit_pBaseVals[99] */ - {0x0F12, 0x0F40}, /* #TVAR_afit_pBaseVals[100] */ - {0x0F12, 0x400F}, /* #TVAR_afit_pBaseVals[101] */ - {0x0F12, 0x0204}, /* #TVAR_afit_pBaseVals[102] */ - {0x0F12, 0x0003}, /* #TVAR_afit_pBaseVals[103] */ - {0x0F12, 0x0000}, /* #TVAR_afit_pBaseVals[104] */ - {0x0F12, 0x0000}, /* #TVAR_afit_pBaseVals[105] */ - {0x0F12, 0x0000}, /* #TVAR_afit_pBaseVals[106] */ - {0x0F12, 0x0000}, /* #TVAR_afit_pBaseVals[107] */ - {0x0F12, 0x0000}, /* #TVAR_afit_pBaseVals[108] */ - {0x0F12, 0x00C4}, /* #TVAR_afit_pBaseVals[109] */ - {0x0F12, 0x03FF}, /* #TVAR_afit_pBaseVals[110] */ - {0x0F12, 0x009C}, /* #TVAR_afit_pBaseVals[111] */ - {0x0F12, 0x017C}, /* #TVAR_afit_pBaseVals[112] */ - {0x0F12, 0x03FF}, /* #TVAR_afit_pBaseVals[113] */ - {0x0F12, 0x000C}, /* #TVAR_afit_pBaseVals[114] */ - {0x0F12, 0x0010}, /* #TVAR_afit_pBaseVals[115] */ - {0x0F12, 0x0104}, /* #TVAR_afit_pBaseVals[116] */ - {0x0F12, 0x03E8}, /* #TVAR_afit_pBaseVals[117] */ - {0x0F12, 0x0023}, /* #TVAR_afit_pBaseVals[118] */ - {0x0F12, 0x012C}, /* #TVAR_afit_pBaseVals[119] */ - {0x0F12, 0x0070}, /* #TVAR_afit_pBaseVals[120] */ - {0x0F12, 0x0008}, /* #TVAR_afit_pBaseVals[121] */ - {0x0F12, 0x0008}, /* #TVAR_afit_pBaseVals[122] */ - {0x0F12, 0x01AA}, /* #TVAR_afit_pBaseVals[123] */ - {0x0F12, 0x003C}, /* #TVAR_afit_pBaseVals[124] */ - {0x0F12, 0x003C}, /* #TVAR_afit_pBaseVals[125] */ - {0x0F12, 0x0005}, /* #TVAR_afit_pBaseVals[126] */ - {0x0F12, 0x0005}, /* #TVAR_afit_pBaseVals[127] */ - {0x0F12, 0x0050}, /* #TVAR_afit_pBaseVals[128] */ - {0x0F12, 0x0024}, /* #TVAR_afit_pBaseVals[129] */ - {0x0F12, 0x002A}, /* #TVAR_afit_pBaseVals[130] */ - {0x0F12, 0x0024}, /* #TVAR_afit_pBaseVals[131] */ - {0x0F12, 0x002A}, /* #TVAR_afit_pBaseVals[132] */ - {0x0F12, 0x0024}, /* #TVAR_afit_pBaseVals[133] */ - {0x0F12, 0x0A24}, /* #TVAR_afit_pBaseVals[134] */ - {0x0F12, 0x1701}, /* #TVAR_afit_pBaseVals[135] */ - {0x0F12, 0x0229}, /* #TVAR_afit_pBaseVals[136] */ - {0x0F12, 0x1403}, /* #TVAR_afit_pBaseVals[137] */ - {0x0F12, 0x0000}, /* #TVAR_afit_pBaseVals[138] */ - {0x0F12, 0x0000}, /* #TVAR_afit_pBaseVals[139] */ - {0x0F12, 0x0000}, /* #TVAR_afit_pBaseVals[140] */ - {0x0F12, 0x00FF}, /* #TVAR_afit_pBaseVals[141] */ - {0x0F12, 0x043B}, /* #TVAR_afit_pBaseVals[142] */ - {0x0F12, 0x1414}, /* #TVAR_afit_pBaseVals[143] */ - {0x0F12, 0x0301}, /* #TVAR_afit_pBaseVals[144] */ - {0x0F12, 0xFF07}, /* #TVAR_afit_pBaseVals[145] */ - {0x0F12, 0x051E}, /* #TVAR_afit_pBaseVals[146] */ - {0x0F12, 0x0A1E}, /* #TVAR_afit_pBaseVals[147] */ - {0x0F12, 0x0F0F}, /* #TVAR_afit_pBaseVals[148] */ - {0x0F12, 0x0A03}, /* #TVAR_afit_pBaseVals[149] */ - {0x0F12, 0x0A3C}, /* #TVAR_afit_pBaseVals[150] */ - {0x0F12, 0x0A28}, /* #TVAR_afit_pBaseVals[151] */ - {0x0F12, 0x0002}, /* #TVAR_afit_pBaseVals[152] */ - {0x0F12, 0x00FF}, /* #TVAR_afit_pBaseVals[153] */ - {0x0F12, 0x1102}, /* #TVAR_afit_pBaseVals[154] */ - {0x0F12, 0x001D}, /* #TVAR_afit_pBaseVals[155] */ - {0x0F12, 0x0900}, /* #TVAR_afit_pBaseVals[156] */ - {0x0F12, 0x0600}, /* #TVAR_afit_pBaseVals[157] */ - {0x0F12, 0x0504}, /* #TVAR_afit_pBaseVals[158] */ - {0x0F12, 0x0305}, /* #TVAR_afit_pBaseVals[159] */ - {0x0F12, 0x6403}, /* #TVAR_afit_pBaseVals[160] */ - {0x0F12, 0x0080}, /* #TVAR_afit_pBaseVals[161] */ - {0x0F12, 0x0080}, /* #TVAR_afit_pBaseVals[162] */ - {0x0F12, 0x0080}, /* #TVAR_afit_pBaseVals[163] */ - {0x0F12, 0x1919}, /* #TVAR_afit_pBaseVals[164] */ - {0x0F12, 0x0101}, /* #TVAR_afit_pBaseVals[165] */ - {0x0F12, 0x3C02}, /* #TVAR_afit_pBaseVals[166] */ - {0x0F12, 0x553C}, /* #TVAR_afit_pBaseVals[167] */ - {0x0F12, 0x2855}, /* #TVAR_afit_pBaseVals[168] */ - {0x0F12, 0x0A00}, /* #TVAR_afit_pBaseVals[169] */ - {0x0F12, 0x1403}, /* #TVAR_afit_pBaseVals[170] */ - {0x0F12, 0x1E0C}, /* #TVAR_afit_pBaseVals[171] */ - {0x0F12, 0x070A}, /* #TVAR_afit_pBaseVals[172] */ - {0x0F12, 0x32FF}, /* #TVAR_afit_pBaseVals[173] */ - {0x0F12, 0x5004}, /* #TVAR_afit_pBaseVals[174] */ - {0x0F12, 0x0F40}, /* #TVAR_afit_pBaseVals[175] */ - {0x0F12, 0x400F}, /* #TVAR_afit_pBaseVals[176] */ - {0x0F12, 0x0204}, /* #TVAR_afit_pBaseVals[177] */ - {0x0F12, 0x1E03}, /* #TVAR_afit_pBaseVals[178] */ - {0x0F12, 0x011E}, /* #TVAR_afit_pBaseVals[179] */ - {0x0F12, 0x0101}, /* #TVAR_afit_pBaseVals[180] */ - {0x0F12, 0x3232}, /* #TVAR_afit_pBaseVals[181] */ - {0x0F12, 0x3C3C}, /* #TVAR_afit_pBaseVals[182] */ - {0x0F12, 0x0028}, /* #TVAR_afit_pBaseVals[183] */ - {0x0F12, 0x030A}, /* #TVAR_afit_pBaseVals[184] */ - {0x0F12, 0x0714}, /* #TVAR_afit_pBaseVals[185] */ - {0x0F12, 0x0A1E}, /* #TVAR_afit_pBaseVals[186] */ - {0x0F12, 0xFF07}, /* #TVAR_afit_pBaseVals[187] */ - {0x0F12, 0x0432}, /* #TVAR_afit_pBaseVals[188] */ - {0x0F12, 0x4050}, /* #TVAR_afit_pBaseVals[189] */ - {0x0F12, 0x0F0F}, /* #TVAR_afit_pBaseVals[190] */ - {0x0F12, 0x0440}, /* #TVAR_afit_pBaseVals[191] */ - {0x0F12, 0x0302}, /* #TVAR_afit_pBaseVals[192] */ - {0x0F12, 0x1E1E}, /* #TVAR_afit_pBaseVals[193] */ - {0x0F12, 0x0101}, /* #TVAR_afit_pBaseVals[194] */ - {0x0F12, 0x3201}, /* #TVAR_afit_pBaseVals[195] */ - {0x0F12, 0x3C32}, /* #TVAR_afit_pBaseVals[196] */ - {0x0F12, 0x283C}, /* #TVAR_afit_pBaseVals[197] */ - {0x0F12, 0x0A00}, /* #TVAR_afit_pBaseVals[198] */ - {0x0F12, 0x1403}, /* #TVAR_afit_pBaseVals[199] */ - {0x0F12, 0x1E07}, /* #TVAR_afit_pBaseVals[200] */ - {0x0F12, 0x070A}, /* #TVAR_afit_pBaseVals[201] */ - {0x0F12, 0x32FF}, /* #TVAR_afit_pBaseVals[202] */ - {0x0F12, 0x5004}, /* #TVAR_afit_pBaseVals[203] */ - {0x0F12, 0x0F40}, /* #TVAR_afit_pBaseVals[204] */ - {0x0F12, 0x400F}, /* #TVAR_afit_pBaseVals[205] */ - {0x0F12, 0x0204}, /* #TVAR_afit_pBaseVals[206] */ - {0x0F12, 0x0003}, /* #TVAR_afit_pBaseVals[207] */ - {0x0F12, 0x0000}, /* #TVAR_afit_pBaseVals[208] */ - {0x0F12, 0x0000}, /* #TVAR_afit_pBaseVals[209] */ - {0x0F12, 0x0000}, /* #TVAR_afit_pBaseVals[210] */ - {0x0F12, 0x0000}, /* #TVAR_afit_pBaseVals[211] */ - {0x0F12, 0x0000}, /* #TVAR_afit_pBaseVals[212] */ - {0x0F12, 0x00C4}, /* #TVAR_afit_pBaseVals[213] */ - {0x0F12, 0x03FF}, /* #TVAR_afit_pBaseVals[214] */ - {0x0F12, 0x009C}, /* #TVAR_afit_pBaseVals[215] */ - {0x0F12, 0x017C}, /* #TVAR_afit_pBaseVals[216] */ - {0x0F12, 0x03FF}, /* #TVAR_afit_pBaseVals[217] */ - {0x0F12, 0x000C}, /* #TVAR_afit_pBaseVals[218] */ - {0x0F12, 0x0010}, /* #TVAR_afit_pBaseVals[219] */ - {0x0F12, 0x0104}, /* #TVAR_afit_pBaseVals[220] */ - {0x0F12, 0x03E8}, /* #TVAR_afit_pBaseVals[221] */ - {0x0F12, 0x0023}, /* #TVAR_afit_pBaseVals[222] */ - {0x0F12, 0x012C}, /* #TVAR_afit_pBaseVals[223] */ - {0x0F12, 0x0070}, /* #TVAR_afit_pBaseVals[224] */ - {0x0F12, 0x0004}, /* #TVAR_afit_pBaseVals[225] */ - {0x0F12, 0x0004}, /* #TVAR_afit_pBaseVals[226] */ - {0x0F12, 0x01AA}, /* #TVAR_afit_pBaseVals[227] */ - {0x0F12, 0x001E}, /* #TVAR_afit_pBaseVals[228] */ - {0x0F12, 0x001E}, /* #TVAR_afit_pBaseVals[229] */ - {0x0F12, 0x0005}, /* #TVAR_afit_pBaseVals[230] */ - {0x0F12, 0x0005}, /* #TVAR_afit_pBaseVals[231] */ - {0x0F12, 0x0064}, /* #TVAR_afit_pBaseVals[232] */ - {0x0F12, 0x0024}, /* #TVAR_afit_pBaseVals[233] */ - {0x0F12, 0x002A}, /* #TVAR_afit_pBaseVals[234] */ - {0x0F12, 0x0024}, /* #TVAR_afit_pBaseVals[235] */ - {0x0F12, 0x002A}, /* #TVAR_afit_pBaseVals[236] */ - {0x0F12, 0x0024}, /* #TVAR_afit_pBaseVals[237] */ - {0x0F12, 0x0A24}, /* #TVAR_afit_pBaseVals[238] */ - {0x0F12, 0x1701}, /* #TVAR_afit_pBaseVals[239] */ - {0x0F12, 0x0229}, /* #TVAR_afit_pBaseVals[240] */ - {0x0F12, 0x1403}, /* #TVAR_afit_pBaseVals[241] */ - {0x0F12, 0x0000}, /* #TVAR_afit_pBaseVals[242] */ - {0x0F12, 0x0000}, /* #TVAR_afit_pBaseVals[243] */ - {0x0F12, 0x0101}, /* #TVAR_afit_pBaseVals[244] */ - {0x0F12, 0x00FF}, /* #TVAR_afit_pBaseVals[245] */ - {0x0F12, 0x043B}, /* #TVAR_afit_pBaseVals[246] */ - {0x0F12, 0x1414}, /* #TVAR_afit_pBaseVals[247] */ - {0x0F12, 0x0301}, /* #TVAR_afit_pBaseVals[248] */ - {0x0F12, 0xFF07}, /* #TVAR_afit_pBaseVals[249] */ - {0x0F12, 0x051E}, /* #TVAR_afit_pBaseVals[250] */ - {0x0F12, 0x0A1E}, /* #TVAR_afit_pBaseVals[251] */ - {0x0F12, 0x0F0F}, /* #TVAR_afit_pBaseVals[252] */ - {0x0F12, 0x0A04}, /* #TVAR_afit_pBaseVals[253] */ - {0x0F12, 0x0A3C}, /* #TVAR_afit_pBaseVals[254] */ - {0x0F12, 0x0528}, /* #TVAR_afit_pBaseVals[255] */ - {0x0F12, 0x0002}, /* #TVAR_afit_pBaseVals[256] */ - {0x0F12, 0x00FF}, /* #TVAR_afit_pBaseVals[257] */ - {0x0F12, 0x1002}, /* #TVAR_afit_pBaseVals[258] */ - {0x0F12, 0x001D}, /* #TVAR_afit_pBaseVals[259] */ - {0x0F12, 0x0900}, /* #TVAR_afit_pBaseVals[260] */ - {0x0F12, 0x0600}, /* #TVAR_afit_pBaseVals[261] */ - {0x0F12, 0x0504}, /* #TVAR_afit_pBaseVals[262] */ - {0x0F12, 0x0305}, /* #TVAR_afit_pBaseVals[263] */ - {0x0F12, 0x7803}, /* #TVAR_afit_pBaseVals[264] */ - {0x0F12, 0x0080}, /* #TVAR_afit_pBaseVals[265] */ - {0x0F12, 0x0080}, /* #TVAR_afit_pBaseVals[266] */ - {0x0F12, 0x0080}, /* #TVAR_afit_pBaseVals[267] */ - {0x0F12, 0x2323}, /* #TVAR_afit_pBaseVals[268] */ - {0x0F12, 0x0101}, /* #TVAR_afit_pBaseVals[269] */ - {0x0F12, 0x2A02}, /* #TVAR_afit_pBaseVals[270] */ - {0x0F12, 0x462A}, /* #TVAR_afit_pBaseVals[271] */ - {0x0F12, 0x2846}, /* #TVAR_afit_pBaseVals[272] */ - {0x0F12, 0x0A00}, /* #TVAR_afit_pBaseVals[273] */ - {0x0F12, 0x1403}, /* #TVAR_afit_pBaseVals[274] */ - {0x0F12, 0x1E0C}, /* #TVAR_afit_pBaseVals[275] */ - {0x0F12, 0x070A}, /* #TVAR_afit_pBaseVals[276] */ - {0x0F12, 0x32FF}, /* #TVAR_afit_pBaseVals[277] */ - {0x0F12, 0x5A04}, /* #TVAR_afit_pBaseVals[278] */ - {0x0F12, 0x0F40}, /* #TVAR_afit_pBaseVals[279] */ - {0x0F12, 0x400F}, /* #TVAR_afit_pBaseVals[280] */ - {0x0F12, 0x0204}, /* #TVAR_afit_pBaseVals[281] */ - {0x0F12, 0x2303}, /* #TVAR_afit_pBaseVals[282] */ - {0x0F12, 0x0123}, /* #TVAR_afit_pBaseVals[283] */ - {0x0F12, 0x0101}, /* #TVAR_afit_pBaseVals[284] */ - {0x0F12, 0x262A}, /* #TVAR_afit_pBaseVals[285] */ - {0x0F12, 0x2C2C}, /* #TVAR_afit_pBaseVals[286] */ - {0x0F12, 0x0028}, /* #TVAR_afit_pBaseVals[287] */ - {0x0F12, 0x030A}, /* #TVAR_afit_pBaseVals[288] */ - {0x0F12, 0x0714}, /* #TVAR_afit_pBaseVals[289] */ - {0x0F12, 0x0A1E}, /* #TVAR_afit_pBaseVals[290] */ - {0x0F12, 0xFF07}, /* #TVAR_afit_pBaseVals[291] */ - {0x0F12, 0x0432}, /* #TVAR_afit_pBaseVals[292] */ - {0x0F12, 0x4050}, /* #TVAR_afit_pBaseVals[293] */ - {0x0F12, 0x0F0F}, /* #TVAR_afit_pBaseVals[294] */ - {0x0F12, 0x0440}, /* #TVAR_afit_pBaseVals[295] */ - {0x0F12, 0x0302}, /* #TVAR_afit_pBaseVals[296] */ - {0x0F12, 0x2323}, /* #TVAR_afit_pBaseVals[297] */ - {0x0F12, 0x0101}, /* #TVAR_afit_pBaseVals[298] */ - {0x0F12, 0x2A01}, /* #TVAR_afit_pBaseVals[299] */ - {0x0F12, 0x2C26}, /* #TVAR_afit_pBaseVals[300] */ - {0x0F12, 0x282C}, /* #TVAR_afit_pBaseVals[301] */ - {0x0F12, 0x0A00}, /* #TVAR_afit_pBaseVals[302] */ - {0x0F12, 0x1403}, /* #TVAR_afit_pBaseVals[303] */ - {0x0F12, 0x1E07}, /* #TVAR_afit_pBaseVals[304] */ - {0x0F12, 0x070A}, /* #TVAR_afit_pBaseVals[305] */ - {0x0F12, 0x32FF}, /* #TVAR_afit_pBaseVals[306] */ - {0x0F12, 0x5004}, /* #TVAR_afit_pBaseVals[307] */ - {0x0F12, 0x0F40}, /* #TVAR_afit_pBaseVals[308] */ - {0x0F12, 0x400F}, /* #TVAR_afit_pBaseVals[309] */ - {0x0F12, 0x0204}, /* #TVAR_afit_pBaseVals[310] */ - {0x0F12, 0x0003}, /* #TVAR_afit_pBaseVals[311] */ - {0x0F12, 0x0000}, /* #TVAR_afit_pBaseVals[312] */ - {0x0F12, 0x0000}, /* #TVAR_afit_pBaseVals[313] */ - {0x0F12, 0x0000}, /* #TVAR_afit_pBaseVals[314] */ - {0x0F12, 0x0000}, /* #TVAR_afit_pBaseVals[315] */ - {0x0F12, 0x0000}, /* #TVAR_afit_pBaseVals[316] */ - {0x0F12, 0x00C4}, /* #TVAR_afit_pBaseVals[317] */ - {0x0F12, 0x03FF}, /* #TVAR_afit_pBaseVals[318] */ - {0x0F12, 0x009C}, /* #TVAR_afit_pBaseVals[319] */ - {0x0F12, 0x017C}, /* #TVAR_afit_pBaseVals[320] */ - {0x0F12, 0x03FF}, /* #TVAR_afit_pBaseVals[321] */ - {0x0F12, 0x000C}, /* #TVAR_afit_pBaseVals[322] */ - {0x0F12, 0x0010}, /* #TVAR_afit_pBaseVals[323] */ - {0x0F12, 0x0000}, /* #TVAR_afit_pBaseVals[324] */ - {0x0F12, 0x0000}, /* #TVAR_afit_pBaseVals[325] */ - {0x0F12, 0x0023}, /* #TVAR_afit_pBaseVals[326] */ - {0x0F12, 0x012C}, /* #TVAR_afit_pBaseVals[327] */ - {0x0F12, 0x0070}, /* #TVAR_afit_pBaseVals[328] */ - {0x0F12, 0x0000}, /* #TVAR_afit_pBaseVals[329] */ - {0x0F12, 0x0000}, /* #TVAR_afit_pBaseVals[330] */ - {0x0F12, 0x01AA}, /* #TVAR_afit_pBaseVals[331] */ - {0x0F12, 0x001E}, /* #TVAR_afit_pBaseVals[332] */ - {0x0F12, 0x001E}, /* #TVAR_afit_pBaseVals[333] */ - {0x0F12, 0x000A}, /* #TVAR_afit_pBaseVals[334] */ - {0x0F12, 0x000A}, /* #TVAR_afit_pBaseVals[335] */ - {0x0F12, 0x00E6}, /* #TVAR_afit_pBaseVals[336] */ - {0x0F12, 0x0032}, /* #TVAR_afit_pBaseVals[337] */ - {0x0F12, 0x0032}, /* #TVAR_afit_pBaseVals[338] */ - {0x0F12, 0x0028}, /* #TVAR_afit_pBaseVals[339] */ - {0x0F12, 0x0032}, /* #TVAR_afit_pBaseVals[340] */ - {0x0F12, 0x0028}, /* #TVAR_afit_pBaseVals[341] */ - {0x0F12, 0x0A24}, /* #TVAR_afit_pBaseVals[342] */ - {0x0F12, 0x1701}, /* #TVAR_afit_pBaseVals[343] */ - {0x0F12, 0x0229}, /* #TVAR_afit_pBaseVals[344] */ - {0x0F12, 0x1403}, /* #TVAR_afit_pBaseVals[345] */ - {0x0F12, 0x0000}, /* #TVAR_afit_pBaseVals[346] */ - {0x0F12, 0x0000}, /* #TVAR_afit_pBaseVals[347] */ - {0x0F12, 0x0504}, /* #TVAR_afit_pBaseVals[348] */ - {0x0F12, 0x00FF}, /* #TVAR_afit_pBaseVals[349] */ - {0x0F12, 0x043B}, /* #TVAR_afit_pBaseVals[350] */ - {0x0F12, 0x1414}, /* #TVAR_afit_pBaseVals[351] */ - {0x0F12, 0x0301}, /* #TVAR_afit_pBaseVals[352] */ - {0x0F12, 0xFF07}, /* #TVAR_afit_pBaseVals[353] */ - {0x0F12, 0x051E}, /* #TVAR_afit_pBaseVals[354] */ - {0x0F12, 0x0A1E}, /* #TVAR_afit_pBaseVals[355] */ - {0x0F12, 0x0F0F}, /* #TVAR_afit_pBaseVals[356] */ - {0x0F12, 0x0A04}, /* #TVAR_afit_pBaseVals[357] */ - {0x0F12, 0x0A3C}, /* #TVAR_afit_pBaseVals[358] */ - {0x0F12, 0x0532}, /* #TVAR_afit_pBaseVals[359] */ - {0x0F12, 0x0002}, /* #TVAR_afit_pBaseVals[360] */ - {0x0F12, 0x00FF}, /* #TVAR_afit_pBaseVals[361] */ - {0x0F12, 0x1002}, /* #TVAR_afit_pBaseVals[362] */ - {0x0F12, 0x001D}, /* #TVAR_afit_pBaseVals[363] */ - {0x0F12, 0x0900}, /* #TVAR_afit_pBaseVals[364] */ - {0x0F12, 0x0600}, /* #TVAR_afit_pBaseVals[365] */ - {0x0F12, 0x0504}, /* #TVAR_afit_pBaseVals[366] */ - {0x0F12, 0x0305}, /* #TVAR_afit_pBaseVals[367] */ - {0x0F12, 0x7802}, /* #TVAR_afit_pBaseVals[368] */ - {0x0F12, 0x0080}, /* #TVAR_afit_pBaseVals[369] */ - {0x0F12, 0x0080}, /* #TVAR_afit_pBaseVals[370] */ - {0x0F12, 0x0080}, /* #TVAR_afit_pBaseVals[371] */ - {0x0F12, 0x2328}, /* #TVAR_afit_pBaseVals[372] */ - {0x0F12, 0x0101}, /* #TVAR_afit_pBaseVals[373] */ - {0x0F12, 0x2A02}, /* #TVAR_afit_pBaseVals[374] */ - {0x0F12, 0x2628}, /* #TVAR_afit_pBaseVals[375] */ - {0x0F12, 0x2826}, /* #TVAR_afit_pBaseVals[376] */ - {0x0F12, 0x0A00}, /* #TVAR_afit_pBaseVals[377] */ - {0x0F12, 0x1903}, /* #TVAR_afit_pBaseVals[378] */ - {0x0F12, 0x1E0F}, /* #TVAR_afit_pBaseVals[379] */ - {0x0F12, 0x070A}, /* #TVAR_afit_pBaseVals[380] */ - {0x0F12, 0x32FF}, /* #TVAR_afit_pBaseVals[381] */ - {0x0F12, 0x7804}, /* #TVAR_afit_pBaseVals[382] */ - {0x0F12, 0x0F40}, /* #TVAR_afit_pBaseVals[383] */ - {0x0F12, 0x400F}, /* #TVAR_afit_pBaseVals[384] */ - {0x0F12, 0x0204}, /* #TVAR_afit_pBaseVals[385] */ - {0x0F12, 0x2803}, /* #TVAR_afit_pBaseVals[386] */ - {0x0F12, 0x0123}, /* #TVAR_afit_pBaseVals[387] */ - {0x0F12, 0x0101}, /* #TVAR_afit_pBaseVals[388] */ - {0x0F12, 0x2024}, /* #TVAR_afit_pBaseVals[389] */ - {0x0F12, 0x1C1C}, /* #TVAR_afit_pBaseVals[390] */ - {0x0F12, 0x0028}, /* #TVAR_afit_pBaseVals[391] */ - {0x0F12, 0x030A}, /* #TVAR_afit_pBaseVals[392] */ - {0x0F12, 0x0A0A}, /* #TVAR_afit_pBaseVals[393] */ - {0x0F12, 0x0A2D}, /* #TVAR_afit_pBaseVals[394] */ - {0x0F12, 0xFF07}, /* #TVAR_afit_pBaseVals[395] */ - {0x0F12, 0x0432}, /* #TVAR_afit_pBaseVals[396] */ - {0x0F12, 0x4050}, /* #TVAR_afit_pBaseVals[397] */ - {0x0F12, 0x0F0F}, /* #TVAR_afit_pBaseVals[398] */ - {0x0F12, 0x0440}, /* #TVAR_afit_pBaseVals[399] */ - {0x0F12, 0x0302}, /* #TVAR_afit_pBaseVals[400] */ - {0x0F12, 0x2328}, /* #TVAR_afit_pBaseVals[401] */ - {0x0F12, 0x0101}, /* #TVAR_afit_pBaseVals[402] */ - {0x0F12, 0x3C01}, /* #TVAR_afit_pBaseVals[403] */ - {0x0F12, 0x1C3C}, /* #TVAR_afit_pBaseVals[404] */ - {0x0F12, 0x281C}, /* #TVAR_afit_pBaseVals[405] */ - {0x0F12, 0x0A00}, /* #TVAR_afit_pBaseVals[406] */ - {0x0F12, 0x0A03}, /* #TVAR_afit_pBaseVals[407] */ - {0x0F12, 0x2D0A}, /* #TVAR_afit_pBaseVals[408] */ - {0x0F12, 0x070A}, /* #TVAR_afit_pBaseVals[409] */ - {0x0F12, 0x32FF}, /* #TVAR_afit_pBaseVals[410] */ - {0x0F12, 0x5004}, /* #TVAR_afit_pBaseVals[411] */ - {0x0F12, 0x0F40}, /* #TVAR_afit_pBaseVals[412] */ - {0x0F12, 0x400F}, /* #TVAR_afit_pBaseVals[413] */ - {0x0F12, 0x0204}, /* #TVAR_afit_pBaseVals[414] */ - {0x0F12, 0x0003}, /* #TVAR_afit_pBaseVals[415] */ - {0x0F12, 0x0000}, /* #TVAR_afit_pBaseVals[416] */ - {0x0F12, 0x0000}, /* #TVAR_afit_pBaseVals[417] */ - {0x0F12, 0x0000}, /* #TVAR_afit_pBaseVals[418] */ - {0x0F12, 0x0000}, /* #TVAR_afit_pBaseVals[419] */ - {0x0F12, 0x0000}, /* #TVAR_afit_pBaseVals[420] */ - {0x0F12, 0x00C4}, /* #TVAR_afit_pBaseVals[421] */ - {0x0F12, 0x03FF}, /* #TVAR_afit_pBaseVals[422] */ - {0x0F12, 0x009C}, /* #TVAR_afit_pBaseVals[423] */ - {0x0F12, 0x017C}, /* #TVAR_afit_pBaseVals[424] */ - {0x0F12, 0x03FF}, /* #TVAR_afit_pBaseVals[425] */ - {0x0F12, 0x000C}, /* #TVAR_afit_pBaseVals[426] */ - {0x0F12, 0x0010}, /* #TVAR_afit_pBaseVals[427] */ - {0x0F12, 0x0000}, /* #TVAR_afit_pBaseVals[428] */ - {0x0F12, 0x0000}, /* #TVAR_afit_pBaseVals[429] */ - {0x0F12, 0x003C}, /* #TVAR_afit_pBaseVals[430] */ - {0x0F12, 0x006F}, /* #TVAR_afit_pBaseVals[431] */ - {0x0F12, 0x0070}, /* #TVAR_afit_pBaseVals[432] */ - {0x0F12, 0x0000}, /* #TVAR_afit_pBaseVals[433] */ - {0x0F12, 0x0000}, /* #TVAR_afit_pBaseVals[434] */ - {0x0F12, 0x01AA}, /* #TVAR_afit_pBaseVals[435] */ - {0x0F12, 0x0014}, /* #TVAR_afit_pBaseVals[436] */ - {0x0F12, 0x0014}, /* #TVAR_afit_pBaseVals[437] */ - {0x0F12, 0x000A}, /* #TVAR_afit_pBaseVals[438] */ - {0x0F12, 0x000A}, /* #TVAR_afit_pBaseVals[439] */ - {0x0F12, 0x0122}, /* #TVAR_afit_pBaseVals[440] */ - {0x0F12, 0x003C}, /* #TVAR_afit_pBaseVals[441] */ - {0x0F12, 0x0032}, /* #TVAR_afit_pBaseVals[442] */ - {0x0F12, 0x0023}, /* #TVAR_afit_pBaseVals[443] */ - {0x0F12, 0x0023}, /* #TVAR_afit_pBaseVals[444] */ - {0x0F12, 0x0032}, /* #TVAR_afit_pBaseVals[445] */ - {0x0F12, 0x0A24}, /* #TVAR_afit_pBaseVals[446] */ - {0x0F12, 0x1701}, /* #TVAR_afit_pBaseVals[447] */ - {0x0F12, 0x0229}, /* #TVAR_afit_pBaseVals[448] */ - {0x0F12, 0x1403}, /* #TVAR_afit_pBaseVals[449] */ - {0x0F12, 0x0000}, /* #TVAR_afit_pBaseVals[450] */ - {0x0F12, 0x0000}, /* #TVAR_afit_pBaseVals[451] */ - {0x0F12, 0x0505}, /* #TVAR_afit_pBaseVals[452] */ - {0x0F12, 0x00FF}, /* #TVAR_afit_pBaseVals[453] */ - {0x0F12, 0x043B}, /* #TVAR_afit_pBaseVals[454] */ - {0x0F12, 0x1414}, /* #TVAR_afit_pBaseVals[455] */ - {0x0F12, 0x0301}, /* #TVAR_afit_pBaseVals[456] */ - {0x0F12, 0xFF07}, /* #TVAR_afit_pBaseVals[457] */ - {0x0F12, 0x051E}, /* #TVAR_afit_pBaseVals[458] */ - {0x0F12, 0x0A1E}, /* #TVAR_afit_pBaseVals[459] */ - {0x0F12, 0x0000}, /* #TVAR_afit_pBaseVals[460] */ - {0x0F12, 0x0A04}, /* #TVAR_afit_pBaseVals[461] */ - {0x0F12, 0x0A3C}, /* #TVAR_afit_pBaseVals[462] */ - {0x0F12, 0x0532}, /* #TVAR_afit_pBaseVals[463] */ - {0x0F12, 0x0002}, /* #TVAR_afit_pBaseVals[464] */ - {0x0F12, 0x0096}, /* #TVAR_afit_pBaseVals[465] */ - {0x0F12, 0x1002}, /* #TVAR_afit_pBaseVals[466] */ - {0x0F12, 0x001E}, /* #TVAR_afit_pBaseVals[467] */ - {0x0F12, 0x0900}, /* #TVAR_afit_pBaseVals[468] */ - {0x0F12, 0x0600}, /* #TVAR_afit_pBaseVals[469] */ - {0x0F12, 0x0504}, /* #TVAR_afit_pBaseVals[470] */ - {0x0F12, 0x0305}, /* #TVAR_afit_pBaseVals[471] */ - {0x0F12, 0x7D02}, /* #TVAR_afit_pBaseVals[472] */ - {0x0F12, 0x0080}, /* #TVAR_afit_pBaseVals[473] */ - {0x0F12, 0x0080}, /* #TVAR_afit_pBaseVals[474] */ - {0x0F12, 0x0080}, /* #TVAR_afit_pBaseVals[475] */ - {0x0F12, 0x5050}, /* #TVAR_afit_pBaseVals[476] */ - {0x0F12, 0x0101}, /* #TVAR_afit_pBaseVals[477] */ - {0x0F12, 0x1C02}, /* #TVAR_afit_pBaseVals[478] */ - {0x0F12, 0x191C}, /* #TVAR_afit_pBaseVals[479] */ - {0x0F12, 0x2819}, /* #TVAR_afit_pBaseVals[480] */ - {0x0F12, 0x0A00}, /* #TVAR_afit_pBaseVals[481] */ - {0x0F12, 0x1E03}, /* #TVAR_afit_pBaseVals[482] */ - {0x0F12, 0x1E0F}, /* #TVAR_afit_pBaseVals[483] */ - {0x0F12, 0x0508}, /* #TVAR_afit_pBaseVals[484] */ - {0x0F12, 0x32FF}, /* #TVAR_afit_pBaseVals[485] */ - {0x0F12, 0x8204}, /* #TVAR_afit_pBaseVals[486] */ - {0x0F12, 0x1448}, /* #TVAR_afit_pBaseVals[487] */ - {0x0F12, 0x4015}, /* #TVAR_afit_pBaseVals[488] */ - {0x0F12, 0x0204}, /* #TVAR_afit_pBaseVals[489] */ - {0x0F12, 0x5003}, /* #TVAR_afit_pBaseVals[490] */ - {0x0F12, 0x0150}, /* #TVAR_afit_pBaseVals[491] */ - {0x0F12, 0x0101}, /* #TVAR_afit_pBaseVals[492] */ - {0x0F12, 0x1E1E}, /* #TVAR_afit_pBaseVals[493] */ - {0x0F12, 0x1212}, /* #TVAR_afit_pBaseVals[494] */ - {0x0F12, 0x0028}, /* #TVAR_afit_pBaseVals[495] */ - {0x0F12, 0x030A}, /* #TVAR_afit_pBaseVals[496] */ - {0x0F12, 0x0A10}, /* #TVAR_afit_pBaseVals[497] */ - {0x0F12, 0x0819}, /* #TVAR_afit_pBaseVals[498] */ - {0x0F12, 0xFF05}, /* #TVAR_afit_pBaseVals[499] */ - {0x0F12, 0x0432}, /* #TVAR_afit_pBaseVals[500] */ - {0x0F12, 0x4052}, /* #TVAR_afit_pBaseVals[501] */ - {0x0F12, 0x1514}, /* #TVAR_afit_pBaseVals[502] */ - {0x0F12, 0x0440}, /* #TVAR_afit_pBaseVals[503] */ - {0x0F12, 0x0302}, /* #TVAR_afit_pBaseVals[504] */ - {0x0F12, 0x5050}, /* #TVAR_afit_pBaseVals[505] */ - {0x0F12, 0x0101}, /* #TVAR_afit_pBaseVals[506] */ - {0x0F12, 0x1E01}, /* #TVAR_afit_pBaseVals[507] */ - {0x0F12, 0x121E}, /* #TVAR_afit_pBaseVals[508] */ - {0x0F12, 0x2812}, /* #TVAR_afit_pBaseVals[509] */ - {0x0F12, 0x0A00}, /* #TVAR_afit_pBaseVals[510] */ - {0x0F12, 0x1003}, /* #TVAR_afit_pBaseVals[511] */ - {0x0F12, 0x190A}, /* #TVAR_afit_pBaseVals[512] */ - {0x0F12, 0x0508}, /* #TVAR_afit_pBaseVals[513] */ - {0x0F12, 0x32FF}, /* #TVAR_afit_pBaseVals[514] */ - {0x0F12, 0x5204}, /* #TVAR_afit_pBaseVals[515] */ - {0x0F12, 0x1440}, /* #TVAR_afit_pBaseVals[516] */ - {0x0F12, 0x4015}, /* #TVAR_afit_pBaseVals[517] */ - {0x0F12, 0x0204}, /* #TVAR_afit_pBaseVals[518] */ - {0x0F12, 0x0003}, /* #TVAR_afit_pBaseVals[519] */ - - /* Update Changed Registers */ - {0x002A, 0x0664}, - {0x0F12, 0x013E}, /* seti_uContrastCenter */ - - /* ====== SET PLL ===== */ - /* How to set */ - /* 1. MCLK */ - /* hex(CLK you want) * 1000) */ - /* 2.System CLK */ - /* hex((CLK you want) * 1000 / 4) */ - /* 3.PCLK */ - /* hex((CLK you want) * 1000 / 4) */ - - /* Set input CLK */ - {0x002A, 0x01CC}, - {0x0F12, 0x5DC0}, /* #REG_TC_IPRM_InClockLSBs */ - {0x0F12, 0x0000}, - {0x002A, 0x01EE}, - {0x0F12, 0x0003}, /* #REG_TC_IPRM_UseNPviClocks - Number of PLL setting */ - /* Set system CLK - 32MHz(0x1F40), 58MHz(0x38a4), can be 24MHz lowest */ - {0x002A, 0x01F6}, - /*{0x0F12, 0x38a4}, */ /* @0x700001F6 First system clock frequency in KHz divided by 4 - 58.000MHz */ - {0x0F12, 0x2EE0}, /* 48MHz 1st SYS_CLK */ - {0x0F12, 0x1770}, /* 24MHz REG_TC_IPRM_MinOutRate4KHz_0 */ - {0x0F12, 0x1780}, /* 24.064MHz REG_TC_IPRM_MaxOutRate4KHz_0 */ - {0x0F12, 0x2710}, /* 40MHz 2nd SYS_CLK, for capture */ - {0x0F12, 0x2700}, /* 39.936MHz REG_TC_IPRM_MinOutRate4KHz_1, for capture */ - {0x0F12, 0x2720}, /* 40.064MHz REG_TC_IPRM_MaxOutRate4KHz_1 */ - {0x0F12, 0x38a4}, - {0x0F12, 0x2310}, - {0x0F12, 0x2340}, - /* Update PLL */ - {0x002A, 0x0208}, - {0x0F12, 0x0001}, /* #REG_TC_IPRM_InitParamsUpdated */ -}; - - -/* Initialization sequence for 480x272 resolution */ -const uint16_t S5K5CAG_480x272[][2]= -{ - /* SET PREVIEW CONFIGURATION_0, Camera Normal 10~30fps */ - /*# Size: 480x272 */ - {0x0028, 0x7000}, /* SET PREVIEW CONFIGURATION_0 */ - {0x002A, 0x026C}, /* SET PREVIEW CONFIGURATION_0 */ - {0x0F12, 0x01e0}, /* #REG_0TC_PCFG_usWidth - 480 */ - {0x0F12, 0x0110}, /* #REG_0TC_PCFG_usHeight - 272 */ - {0x0F12, 0x0000}, /* #REG_0TC_PCFG_Format */ - {0x0F12, 0x1780}, /* #REG_0TC_PCFG_usMaxOut4KHzRate - 24.064MHz */ - {0x0F12, 0x1760}, /* #REG_0TC_PCFG_usMinOut4KHzRate - 23.936MHz */ - {0x0F12, 0x0100}, /* #REG_0TC_PCFG_OutClkPerPix88 */ - {0x0F12, 0x0800}, /* #REG_0TC_PCFG_uMaxBpp88 */ - /* #REG_0TC_PCFG_PVIMask */ - /* bit0: swap RGB high/low byte */ - /* bit2: VSYNC data blanking level */ - /* bit3: HSYNC data blanking level */ - /*{0x0F12, 0x0052}, */ /* #REG_0TC_PCFG_PVIMask - s0050 = FALSE in MSM6290 : s0052 = TRUE in MSM6800 - reg 027A */ - {0x0F12, 0x005F}, /* #REG_0TC_PCFG_PVIMask - bit0: swap RGB high/low byte */ - {0x0F12, 0x4000}, /* #REG_0TC_PCFG_OIFMask */ - {0x0F12, 0x0400}, /* #REG_0TC_PCFG_usJpegPacketSize */ - {0x0F12, 0x0258}, /* #REG_0TC_PCFG_usJpegTotalPackets */ - {0x0F12, 0x0000}, /* #REG_0TC_PCFG_uClockInd */ - {0x0F12, 0x0000}, /* #REG_0TC_PCFG_usFrTimeType */ - {0x0F12, 0x0002}, /* #REG_0TC_PCFG_FrRateQualityType 01:Always achieve the best frame rate. 02:Always achieve the best possible image quality (no-binning mode) */ - /*=================S5K5CAGX_CAM_NOM_MAX_FR_TIME,S5K5CAGX_CAM_NOM_MIN_FR_TIME 30fps~15fps (Arima Use)==================*/ - {0x0F12, 0x03E8}, /* #REG_0TC_PCFG_usMaxFrTimeMsecMult10 - 10fps */ - {0x0F12, 0x029A}, /* #REG_0TC_PCFG_usMaxFrTimeMsecMult10 - 15fps */ - /*{0x0F12, 0x014D},*/ /* #REG_0TC_PCFG_usMinFrTimeMsecMult10 - 30fps */ - /*==========================================================================================*/ - {0x0F12, 0x0000}, - {0x0F12, 0x0000}, - {0x0F12, 0x0000}, - {0x0F12, 0x0000}, - {0x0F12, 0x0000}, - {0x0F12, 0x0000}, - {0x0F12, 0x0000}, - {0x0F12, 0x0000}, - - /* New Configuration FW Sync Preview */ - {0x002A, 0x023C}, - {0x0F12, 0x0000}, - {0x002A, 0x0240}, - {0x0F12, 0x0001}, - {0x002A, 0x0230}, - {0x0F12, 0x0001}, - {0x002A, 0x023E}, - {0x0F12, 0x0001}, - {0x002A, 0x0220}, - {0x0F12, 0x0001}, - {0x0F12, 0x0001}, - - {0x0028, 0xD000}, - {0x002A, 0x1000}, - {0x0F12, 0x0001}, -}; - -/* Initialization sequence for VGA resolution (640x480)*/ -const uint16_t S5K5CAG_VGA[][2]= -{ - /* SET PREVIEW CONFIGURATION_0, Camera Normal 10~30fps */ - /*# Size: VGA 640x480 */ - {0x0028, 0x7000}, /* SET PREVIEW CONFIGURATION_0 */ - {0x002A, 0x026C}, /* SET PREVIEW CONFIGURATION_0 */ - {0x0F12, 0x0280}, /* #REG_0TC_PCFG_usWidth - 640 */ - {0x0F12, 0x01E0}, /* #REG_0TC_PCFG_usHeight - 480 */ - {0x0F12, 0x0000}, /* #REG_0TC_PCFG_Format */ - {0x0F12, 0x1780}, /* #REG_0TC_PCFG_usMaxOut4KHzRate - 24.064MHz */ - {0x0F12, 0x1760}, /* #REG_0TC_PCFG_usMinOut4KHzRate - 23.936MHz */ - {0x0F12, 0x0100}, /* #REG_0TC_PCFG_OutClkPerPix88 */ - {0x0F12, 0x0800}, /* #REG_0TC_PCFG_uMaxBpp88 */ - /* #REG_0TC_PCFG_PVIMask */ - /* bit0: swap RGB high/low byte */ - /* bit2: VSYNC data blanking level */ - /* bit3: HSYNC data blanking level */ - /*{0x0F12, 0x0052}, */ /* #REG_0TC_PCFG_PVIMask - s0050 = FALSE in MSM6290 : s0052 = TRUE in MSM6800 - reg 027A */ - {0x0F12, 0x005F}, /* #REG_0TC_PCFG_PVIMask - bit0: swap RGB high/low byte */ - {0x0F12, 0x4000}, /* #REG_0TC_PCFG_OIFMask */ - {0x0F12, 0x0400}, /* #REG_0TC_PCFG_usJpegPacketSize */ - {0x0F12, 0x0258}, /* #REG_0TC_PCFG_usJpegTotalPackets */ - {0x0F12, 0x0000}, /* #REG_0TC_PCFG_uClockInd */ - {0x0F12, 0x0000}, /* #REG_0TC_PCFG_usFrTimeType */ - {0x0F12, 0x0002}, /* #REG_0TC_PCFG_FrRateQualityType 01:Always achieve the best frame rate. 02:Always achieve the best possible image quality (no-binning mode) */ - /*=================S5K5CAGX_CAM_NOM_MAX_FR_TIME,S5K5CAGX_CAM_NOM_MIN_FR_TIME 30fps~15fps (Arima Use)==================*/ - {0x0F12, 0x03E8}, /* #REG_0TC_PCFG_usMaxFrTimeMsecMult10 - 10fps */ - {0x0F12, 0x029A}, /* #REG_0TC_PCFG_usMaxFrTimeMsecMult10 - 15fps */ - /*0x0F12, 0x014D,*/ /* #REG_0TC_PCFG_usMinFrTimeMsecMult10 - 30fps */ - /*==========================================================================================*/ - {0x0F12, 0x0000}, - {0x0F12, 0x0000}, - {0x0F12, 0x0000}, - {0x0F12, 0x0000}, - {0x0F12, 0x0000}, - {0x0F12, 0x0000}, - {0x0F12, 0x0000}, - {0x0F12, 0x0000}, - - /* New Configuration FW Sync Preview */ - {0x002A, 0x023C}, - {0x0F12, 0x0000}, - {0x002A, 0x0240}, - {0x0F12, 0x0001}, - {0x002A, 0x0230}, - {0x0F12, 0x0001}, - {0x002A, 0x023E}, - {0x0F12, 0x0001}, - {0x002A, 0x0220}, - {0x0F12, 0x0001}, - {0x0F12, 0x0001}, - - {0x0028, 0xD000}, - {0x002A, 0x1000}, - {0x0F12, 0x0001}, -}; - -/* Initialization sequence for QVGA resolution (320x240) */ -const uint16_t S5K5CAG_QVGA[][2]= -{ - /* SET PREVIEW CONFIGURATION_0, Camera Normal 10~30fps */ - /*# Size: QVGA 320x240 */ - {0x0028, 0x7000}, /* SET PREVIEW CONFIGURATION_0 */ - {0x002A, 0x026C}, /* SET PREVIEW CONFIGURATION_0 */ - {0x0F12, 0x0140}, /* #REG_0TC_PCFG_usWidth - 320 */ - {0x0F12, 0x00F0}, /* #REG_0TC_PCFG_usHeight - 240 */ - {0x0F12, 0x0000}, /* #REG_0TC_PCFG_Format */ - {0x0F12, 0x1780}, /* #REG_0TC_PCFG_usMaxOut4KHzRate - 24.064MHz */ - {0x0F12, 0x1760}, /* #REG_0TC_PCFG_usMinOut4KHzRate - 23.936MHz */ - {0x0F12, 0x0100}, /* #REG_0TC_PCFG_OutClkPerPix88 */ - {0x0F12, 0x0800}, /* #REG_0TC_PCFG_uMaxBpp88 */ - /* #REG_0TC_PCFG_PVIMask */ - /* bit0: swap RGB high/low byte */ - /* bit2: VSYNC data blanking level */ - /* bit3: HSYNC data blanking level */ - /*{0x0F12, 0x0052}, */ /* #REG_0TC_PCFG_PVIMask - s0050 = FALSE in MSM6290 : s0052 = TRUE in MSM6800 - reg 027A */ - {0x0F12, 0x005F}, /* #REG_0TC_PCFG_PVIMask - bit0: swap RGB high/low byte */ - {0x0F12, 0x4000}, /* #REG_0TC_PCFG_OIFMask */ - {0x0F12, 0x0400}, /* #REG_0TC_PCFG_usJpegPacketSize */ - {0x0F12, 0x0258}, /* #REG_0TC_PCFG_usJpegTotalPackets */ - {0x0F12, 0x0000}, /* #REG_0TC_PCFG_uClockInd */ - {0x0F12, 0x0000}, /* #REG_0TC_PCFG_usFrTimeType */ - {0x0F12, 0x0002}, /* #REG_0TC_PCFG_FrRateQualityType 01:Always achieve the best frame rate. 02:Always achieve the best possible image quality (no-binning mode) */ - /*=================S5K5CAGX_CAM_NOM_MAX_FR_TIME,S5K5CAGX_CAM_NOM_MIN_FR_TIME 30fps~15fps (Arima Use)==================*/ - {0x0F12, 0x03E8}, /* #REG_0TC_PCFG_usMaxFrTimeMsecMult10 - 10fps */ - {0x0F12, 0x029A}, /* #REG_0TC_PCFG_usMaxFrTimeMsecMult10 - 15fps */ - /*{0x0F12, 0x014D},*/ /* #REG_0TC_PCFG_usMinFrTimeMsecMult10 - 30fps */ - /*==========================================================================================*/ - {0x0F12, 0x0000}, - {0x0F12, 0x0000}, - {0x0F12, 0x0000}, - {0x0F12, 0x0000}, - {0x0F12, 0x0000}, - {0x0F12, 0x0000}, - {0x0F12, 0x0000}, - {0x0F12, 0x0000}, - - /* New Configuration FW Sync Preview */ - {0x002A, 0x023C}, - {0x0F12, 0x0000}, - {0x002A, 0x0240}, - {0x0F12, 0x0001}, - {0x002A, 0x0230}, - {0x0F12, 0x0001}, - {0x002A, 0x023E}, - {0x0F12, 0x0001}, - {0x002A, 0x0220}, - {0x0F12, 0x0001}, - {0x0F12, 0x0001}, - - {0x0028, 0xD000}, - {0x002A, 0x1000}, - {0x0F12, 0x0001}, -}; - -/* Initialization sequence for QQVGA resolution (160x120) */ -const uint16_t S5K5CAG_QQVGA[][2]= -{ - /* SET PREVIEW CONFIGURATION_0, Camera Normal 10~30fps */ - /*# Size: QQVGA 160x120 */ - {0x0028, 0x7000}, /* SET PREVIEW CONFIGURATION_0 */ - {0x002A, 0x026C}, /* SET PREVIEW CONFIGURATION_0 */ - {0x0F12, 0x00A0}, /* #REG_0TC_PCFG_usWidth - 160 */ - {0x0F12, 0x0078}, /* #REG_0TC_PCFG_usHeight - 120 */ - {0x0F12, 0x0000}, /* #REG_0TC_PCFG_Format */ - {0x0F12, 0x1780}, /* #REG_0TC_PCFG_usMaxOut4KHzRate - 24.064MHz */ - {0x0F12, 0x1760}, /* #REG_0TC_PCFG_usMinOut4KHzRate - 23.936MHz */ - {0x0F12, 0x0100}, /* #REG_0TC_PCFG_OutClkPerPix88 */ - {0x0F12, 0x0800}, /* #REG_0TC_PCFG_uMaxBpp88 */ - /* #REG_0TC_PCFG_PVIMask */ - /* bit0: swap RGB high/low byte */ - /* bit2: VSYNC data blanking level */ - /* bit3: HSYNC data blanking level */ - /*{0x0F12, 0x0052}, */ /* #REG_0TC_PCFG_PVIMask - s0050 = FALSE in MSM6290 : s0052 = TRUE in MSM6800 - reg 027A */ - {0x0F12, 0x005F}, /* #REG_0TC_PCFG_PVIMask - bit0: swap RGB high/low byte */ - {0x0F12, 0x4000}, /* #REG_0TC_PCFG_OIFMask */ - {0x0F12, 0x0400}, /* #REG_0TC_PCFG_usJpegPacketSize */ - {0x0F12, 0x0258}, /* #REG_0TC_PCFG_usJpegTotalPackets */ - {0x0F12, 0x0000}, /* #REG_0TC_PCFG_uClockInd */ - {0x0F12, 0x0000}, /* #REG_0TC_PCFG_usFrTimeType */ - {0x0F12, 0x0002}, /* #REG_0TC_PCFG_FrRateQualityType 01:Always achieve the best frame rate. 02:Always achieve the best possible image quality (no-binning mode) */ - /*=================S5K5CAGX_CAM_NOM_MAX_FR_TIME,S5K5CAGX_CAM_NOM_MIN_FR_TIME 30fps~15fps (Arima Use)==================*/ - {0x0F12, 0x03E8}, /* #REG_0TC_PCFG_usMaxFrTimeMsecMult10 - 10fps */ - {0x0F12, 0x029A}, /* #REG_0TC_PCFG_usMaxFrTimeMsecMult10 - 15fps */ - /*{0x0F12, 0x014D},*/ /* #REG_0TC_PCFG_usMinFrTimeMsecMult10 - 30fps */ - /*==========================================================================================*/ - {0x0F12, 0x0000}, - {0x0F12, 0x0000}, - {0x0F12, 0x0000}, - {0x0F12, 0x0000}, - {0x0F12, 0x0000}, - {0x0F12, 0x0000}, - {0x0F12, 0x0000}, - {0x0F12, 0x0000}, - - /* New Configuration FW Sync Preview */ - {0x002A, 0x023C}, - {0x0F12, 0x0000}, - {0x002A, 0x0240}, - {0x0F12, 0x0001}, - {0x002A, 0x0230}, - {0x0F12, 0x0001}, - {0x002A, 0x023E}, - {0x0F12, 0x0001}, - {0x002A, 0x0220}, - {0x0F12, 0x0001}, - {0x0F12, 0x0001}, - - {0x0028, 0xD000}, - {0x002A, 0x1000}, - {0x0F12, 0x0001}, -}; - -/** - * @} - */ - -/** @defgroup S5K5CAG_Private_Functions - * @{ - */ - -/** - * @brief Initializes the S5K5CAG CAMERA component. - * @param DeviceAddr: Device address on communication Bus. - * @param resolution: Camera resolution - * @retval None - */ -void s5k5cag_Init(uint16_t DeviceAddr, uint32_t resolution) -{ - uint32_t index; - - /* Initialize I2C */ - CAMERA_IO_Init(); - - if ((resolution == CAMERA_R160x120) || /* Check if resolution is supported */ - (resolution == CAMERA_R320x240) || - (resolution == CAMERA_R480x272) || - (resolution == CAMERA_R640x480)) - { - /* Set common parameters for all resolutions */ - for(index=0; index<(sizeof(S5K5CAG_Common)/4); index++) - { - if(0xFFFF == S5K5CAG_Common[index][0]) - { - CAMERA_Delay(S5K5CAG_Common[index][1]); - } - else - { - CAMERA_IO_Write(DeviceAddr, S5K5CAG_Common[index][0], S5K5CAG_Common[index][1]); - CAMERA_Delay(1); - } - } - - /* Set specific parameters for each resolution */ - switch (resolution) - { - case CAMERA_R160x120: - { - for(index=0; index<(sizeof(S5K5CAG_QQVGA)/4); index++) - { - CAMERA_IO_Write(DeviceAddr, S5K5CAG_QQVGA[index][0], S5K5CAG_QQVGA[index][1]); - CAMERA_Delay(1); - } - break; - } - case CAMERA_R320x240: - { - for(index=0; index<(sizeof(S5K5CAG_QVGA)/4); index++) - { - CAMERA_IO_Write(DeviceAddr, S5K5CAG_QVGA[index][0], S5K5CAG_QVGA[index][1]); - CAMERA_Delay(1); - } - break; - } - case CAMERA_R480x272: - { - for(index=0; index<(sizeof(S5K5CAG_480x272)/4); index++) - { - CAMERA_IO_Write(DeviceAddr, S5K5CAG_480x272[index][0], S5K5CAG_480x272[index][1]); - CAMERA_Delay(1); - } - break; - } - case CAMERA_R640x480: - { - for(index=0; index<(sizeof(S5K5CAG_VGA)/4); index++) - { - CAMERA_IO_Write(DeviceAddr, S5K5CAG_VGA[index][0], S5K5CAG_VGA[index][1]); - CAMERA_Delay(1); - } - break; - } - default: - { - break; - } - } - } -} - -/** - * @brief Configures the S5K5CAG camera feature. - * @param DeviceAddr: Device address on communication Bus. - * @param feature: Camera feature to be configured - * @param value: Value to be configured - * @param brightness_value: Brightness value to be configured - * @retval None - */ -void s5k5cag_Config(uint16_t DeviceAddr, uint32_t feature, uint32_t value, uint32_t brightness_value) -{ - uint32_t value_tmp; - uint32_t br_value; - uint32_t r_gain = 0xA0; - uint32_t g_gain = 0xA0; - uint32_t b_gain = 0xA0; - - /* Convert the input value into s5k5cag parameters */ - value_tmp = s5k5cag_ConvertValue(feature, value); - br_value = s5k5cag_ConvertValue(CAMERA_CONTRAST_BRIGHTNESS, brightness_value); - - switch(feature) - { - case CAMERA_BLACK_WHITE: - { - CAMERA_IO_Write(DeviceAddr, 0x0028, 0x7000); /* Reset previous color effect settings */ - CAMERA_IO_Write(DeviceAddr, 0x002A, 0x04D6); - CAMERA_IO_Write(DeviceAddr, 0x0F12, 0x0001); - CAMERA_Delay(100); /* Wait for 100ms */ - - CAMERA_IO_Write(DeviceAddr, 0x0028, 0x7000); /* REG_TC_GP_SpecialEffects register (0x70000021E) */ - CAMERA_IO_Write(DeviceAddr, 0x002A, 0x021E); /* REG_TC_GP_SpecialEffects register */ - CAMERA_IO_Write(DeviceAddr, 0x0F12, value_tmp); - break; - } - case CAMERA_CONTRAST_BRIGHTNESS: - { - /* Set brightness */ - CAMERA_IO_Write(DeviceAddr, 0x0028, 0x7000); /* REG_TC_UserBrightness register (0x70000020C) */ - CAMERA_IO_Write(DeviceAddr, 0x002A, 0x020C); /* REG_TC_UserBrightness register */ - CAMERA_IO_Write(DeviceAddr, 0x0F12, br_value); - - /* Set contrast */ - CAMERA_IO_Write(DeviceAddr, 0x0028, 0x7000); /* REG_TC_UserContrast register (0x70000020E) */ - CAMERA_IO_Write(DeviceAddr, 0x002A, 0x020E); /* REG_TC_UserContrast register */ - CAMERA_IO_Write(DeviceAddr, 0x0F12, value_tmp); - break; - } - case CAMERA_COLOR_EFFECT: - { - /* Reset previous color effect settings */ - CAMERA_IO_Write(DeviceAddr, 0x0028, 0x7000); /* REG_TC_DBG_ReInitCmd register (0x700004D6) */ - CAMERA_IO_Write(DeviceAddr, 0x002A, 0x04D6); /* REG_TC_DBG_ReInitCmd register */ - CAMERA_IO_Write(DeviceAddr, 0x0F12, 0x0001); - CAMERA_Delay(100); /* Wait for 100ms */ - - if (value_tmp == S5K5CAG_COLOR_EFFECT_ANTIQUE) - { - /* Sepia color effect */ - CAMERA_IO_Write(DeviceAddr, 0x0028, 0x7000); /* REG_TC_GP_SpecialEffects register (0x70000021E) */ - CAMERA_IO_Write(DeviceAddr, 0x002A, 0x021E); /* REG_TC_GP_SpecialEffects register */ - CAMERA_IO_Write(DeviceAddr, 0x0F12, value_tmp); - } - else - { - /* Reset previous special effect view, restore normal view */ - CAMERA_IO_Write(DeviceAddr, 0x0028, 0x7000); /* REG_TC_GP_SpecialEffects register (0x70000021E) */ - CAMERA_IO_Write(DeviceAddr, 0x002A, 0x021E); /* REG_TC_GP_SpecialEffects register */ - CAMERA_IO_Write(DeviceAddr, 0x0F12, S5K5CAG_BLACK_WHITE_NORMAL); - - switch(value_tmp) - { - case S5K5CAG_COLOR_EFFECT_RED : /* Red color effect */ - r_gain = 0xA0; /* Red gain set to a high level */ - g_gain = 0x40; /* Green gain set to a low level */ - b_gain = 0x50; /* Blue gain set to a low level */ - break; - - case S5K5CAG_COLOR_EFFECT_GREEN : /* Green color effect */ - r_gain = 0x60; /* Red gain set to a low level */ - g_gain = 0xA0; /* Green gain set to a high level */ - b_gain = 0x60; /* Blue gain set to a low level */ - break; - - case S5K5CAG_COLOR_EFFECT_BLUE : /* Blue color effect : */ - r_gain = 0x30; /* Red gain set to a low level */ - g_gain = 0x30; /* Green gain set to a low level */ - b_gain = 0xA0; /* Blue gain set to a high level */ - break; - default : /* No color effect applied */ - value_tmp = S5K5CAG_COLOR_EFFECT_NONE; - break; - } - - if (value_tmp != S5K5CAG_COLOR_EFFECT_NONE) - { - /* Set red gain */ - CAMERA_IO_Write(DeviceAddr, 0x0028, 0x7000); /* REG_SF_USER_Rgain register (0x700004A0) */ - CAMERA_IO_Write(DeviceAddr, 0x002A, 0x04A0); /* REG_SF_USER_Rgain register */ - CAMERA_IO_Write(DeviceAddr, 0x0F12, r_gain); - - CAMERA_IO_Write(DeviceAddr, 0x0028, 0x7000); /* REG_SF_USER_RgainChanged register (0x700004A2) */ - CAMERA_IO_Write(DeviceAddr, 0x002A, 0x04A2); /* REG_SF_USER_RgainChanged */ - CAMERA_IO_Write(DeviceAddr, 0x0F12, 0x1); - - /* Set green gain */ - CAMERA_IO_Write(DeviceAddr, 0x0028, 0x7000); /* REG_SF_USER_Ggain register (0x700004A4) */ - CAMERA_IO_Write(DeviceAddr, 0x002A, 0x04A4); /* REG_SF_USER_Ggain register */ - CAMERA_IO_Write(DeviceAddr, 0x0F12, g_gain); - - CAMERA_IO_Write(DeviceAddr, 0x0028, 0x7000); /* REG_SF_USER_GgainChanged register (0x700004A6) */ - CAMERA_IO_Write(DeviceAddr, 0x002A, 0x04A6); /* REG_SF_USER_GgainChanged */ - CAMERA_IO_Write(DeviceAddr, 0x0F12, 0x1); - - /* Set blue gain */ - CAMERA_IO_Write(DeviceAddr, 0x0028, 0x7000); /* REG_SF_USER_Bgain register (0x700004A8) */ - CAMERA_IO_Write(DeviceAddr, 0x002A, 0x04A8); /* REG_SF_USER_Bgain register */ - CAMERA_IO_Write(DeviceAddr, 0x0F12, b_gain); - - CAMERA_IO_Write(DeviceAddr, 0x0028, 0x7000); /* REG_SF_USER_BgainChanged register (0x700004AA) */ - CAMERA_IO_Write(DeviceAddr, 0x002A, 0x04AA); /* REG_SF_USER_BgainChanged */ - CAMERA_IO_Write(DeviceAddr, 0x0F12, 0x1); - } - } - break; - } - default: - { - break; - } - } -} - -/** - * @brief Read the S5K5CAG Camera identity. - * @param DeviceAddr: Device address on communication Bus. - * @retval the S5K5CAG ID - */ -uint16_t s5k5cag_ReadID(uint16_t DeviceAddr) -{ - /* Initialize I2C */ - CAMERA_IO_Init(); - - /* Prepare the sensor to read the Camera ID */ - CAMERA_IO_Write(DeviceAddr, 0xFCFC, 0x0000); /* page 0x0000 */ - - /* Get the camera ID */ - /* INFO_chipId1 @ 0x00000040 */ - return (CAMERA_IO_Read(DeviceAddr, S5K5CAG_INFO_CHIPID1)); -} - -/****************************************************************************** - Static Functions -*******************************************************************************/ -/** - * @brief Convert input values into s5k5cag parameters. - * @param feature: Camera feature to be configured - * @param value: Value to be configured - * @retval The converted value - */ -static uint32_t s5k5cag_ConvertValue(uint32_t feature, uint32_t value) -{ - uint32_t ret = 0; - - switch(feature) - { - case CAMERA_BLACK_WHITE: - { - switch(value) - { - case CAMERA_BLACK_WHITE_BW: - { - ret = S5K5CAG_BLACK_WHITE_BW; - break; - } - case CAMERA_BLACK_WHITE_NEGATIVE: - { - ret = S5K5CAG_BLACK_WHITE_NEGATIVE; - break; - } - case CAMERA_BLACK_WHITE_BW_NEGATIVE: - { - ret = S5K5CAG_BLACK_WHITE_BW_NEGATIVE; - break; - } - case CAMERA_BLACK_WHITE_NORMAL: - { - ret = S5K5CAG_BLACK_WHITE_NORMAL; - break; - } - default: - { - ret = S5K5CAG_BLACK_WHITE_NORMAL; - break; - } - } - break; - } - case CAMERA_CONTRAST_BRIGHTNESS: - { - switch(value) - { - case CAMERA_BRIGHTNESS_LEVEL0: - { - ret = S5K5CAG_BRIGHTNESS_LEVEL0; - break; - } - case CAMERA_BRIGHTNESS_LEVEL1: - { - ret = S5K5CAG_BRIGHTNESS_LEVEL1; - break; - } - case CAMERA_BRIGHTNESS_LEVEL2: - { - ret = S5K5CAG_BRIGHTNESS_LEVEL2; - break; - } - case CAMERA_BRIGHTNESS_LEVEL3: - { - ret = S5K5CAG_BRIGHTNESS_LEVEL3; - break; - } - case CAMERA_BRIGHTNESS_LEVEL4: - { - ret = S5K5CAG_BRIGHTNESS_LEVEL4; - break; - } - case CAMERA_CONTRAST_LEVEL0: - { - ret = S5K5CAG_CONTRAST_LEVEL0; - break; - } - case CAMERA_CONTRAST_LEVEL1: - { - ret = S5K5CAG_CONTRAST_LEVEL1; - break; - } - case CAMERA_CONTRAST_LEVEL2: - { - ret = S5K5CAG_CONTRAST_LEVEL2; - break; - } - case CAMERA_CONTRAST_LEVEL3: - { - ret = S5K5CAG_CONTRAST_LEVEL3; - break; - } - case CAMERA_CONTRAST_LEVEL4: - { - ret = S5K5CAG_CONTRAST_LEVEL4; - break; - } - default: - { - ret = S5K5CAG_CONTRAST_LEVEL0; - break; - } - } - break; - } - case CAMERA_COLOR_EFFECT: - { - switch(value) - { - case CAMERA_COLOR_EFFECT_ANTIQUE: - { - ret = S5K5CAG_COLOR_EFFECT_ANTIQUE; - break; - } - case CAMERA_COLOR_EFFECT_BLUE: - { - ret = S5K5CAG_COLOR_EFFECT_BLUE; - break; - } - case CAMERA_COLOR_EFFECT_GREEN: - { - ret = S5K5CAG_COLOR_EFFECT_GREEN; - break; - } - case CAMERA_COLOR_EFFECT_RED: - { - ret = S5K5CAG_COLOR_EFFECT_RED; - break; - } - default: - { - ret = S5K5CAG_COLOR_EFFECT_NONE; - break; - } - } - break; - default: - { - ret = 0; - break; - } - } - } - - return ret; -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/s5k5cag/s5k5cag.h b/bsp/stm32f411RE/Libraries/BSP/Components/s5k5cag/s5k5cag.h deleted file mode 100644 index ef0eaa7232..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/s5k5cag/s5k5cag.h +++ /dev/null @@ -1,148 +0,0 @@ -/** - ****************************************************************************** - * @file s5k5cag.h - * @author MCD Application Team - * @version V1.0.0 - * @date 05-March-2015 - * @brief This file contains all the functions prototypes for the s5k5cag.c - * driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __S5K5CAG_H -#define __S5K5CAG_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "../Common/camera.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup Components - * @{ - */ - -/** @addtogroup s5k5cag - * @{ - */ - -/** @defgroup S5K5CAG_Exported_Types - * @{ - */ - -/** - * @} - */ - -/** @defgroup S5K5CAG_Exported_Constants - * @{ - */ -/** - * @brief S5K5CAG ID - */ -#define S5K5CAG_ID ((uint16_t)0x05CA) -/** - * @brief S5K5CAG Registers - */ -#define S5K5CAG_INFO_CHIPID1 ((uint16_t)0x0040) -#define S5K5CAG_INFO_CHIPID2 ((uint16_t)0x0042) -#define S5K5CAG_INFO_SVNVERSION ((uint16_t)0x0048) -#define S5K5CAG_INFO_DATE ((uint16_t)0x004E) - -/** - * @brief S5K5CAG Features Parameters - */ -#define S5K5CAG_BRIGHTNESS_LEVEL0 ((uint16_t)0xFF00) /* Brightness level -2 */ -#define S5K5CAG_BRIGHTNESS_LEVEL1 ((uint16_t)0xFFC0) /* Brightness level -1 */ -#define S5K5CAG_BRIGHTNESS_LEVEL2 ((uint16_t)0x0000) /* Brightness level 0 */ -#define S5K5CAG_BRIGHTNESS_LEVEL3 ((uint16_t)0x0050) /* Brightness level +1 */ -#define S5K5CAG_BRIGHTNESS_LEVEL4 ((uint16_t)0x0080) /* Brightness level +2 */ - -#define S5K5CAG_BLACK_WHITE_BW ((uint16_t)0x0001) /* Black and white effect */ -#define S5K5CAG_BLACK_WHITE_NEGATIVE ((uint16_t)0x0003) /* Negative effect */ -#define S5K5CAG_BLACK_WHITE_BW_NEGATIVE ((uint16_t)0x0002) /* BW and Negative effect */ -#define S5K5CAG_BLACK_WHITE_NORMAL ((uint16_t)0x0000) /* Normal effect */ - -#define S5K5CAG_CONTRAST_LEVEL0 ((uint16_t)0xFF80) /* Contrast level -2 */ -#define S5K5CAG_CONTRAST_LEVEL1 ((uint16_t)0xFFC0) /* Contrast level -1 */ -#define S5K5CAG_CONTRAST_LEVEL2 ((uint16_t)0x0000) /* Contrast level 0 */ -#define S5K5CAG_CONTRAST_LEVEL3 ((uint16_t)0x0050) /* Contrast level -1 */ -#define S5K5CAG_CONTRAST_LEVEL4 ((uint16_t)0x0080) /* Contrast level -2 */ - -#define S5K5CAG_COLOR_EFFECT_NONE ((uint16_t)0x0000) /* No color effect */ -#define S5K5CAG_COLOR_EFFECT_ANTIQUE ((uint16_t)0x0004) /* Antique effect */ -#define S5K5CAG_COLOR_EFFECT_BLUE ((uint16_t)0x0001) /* Blue effect */ -#define S5K5CAG_COLOR_EFFECT_GREEN ((uint16_t)0x0002) /* Green effect */ -#define S5K5CAG_COLOR_EFFECT_RED ((uint16_t)0x0003) /* Red effect */ -/** - * @} - */ - -/** @defgroup S5K5CAG_Exported_Functions - * @{ - */ -void s5k5cag_Init(uint16_t DeviceAddr, uint32_t resolution); -void s5k5cag_Config(uint16_t DeviceAddr, uint32_t feature, uint32_t value, uint32_t BR_value); -uint16_t s5k5cag_ReadID(uint16_t DeviceAddr); - -void CAMERA_IO_Init(void); -void CAMERA_IO_Write(uint8_t addr, uint16_t reg, uint16_t value); -uint16_t CAMERA_IO_Read(uint8_t addr, uint16_t reg); -void CAMERA_Delay(uint32_t delay); - -/* CAMERA driver structure */ -extern CAMERA_DrvTypeDef s5k5cag_drv; -/** - * @} - */ -#ifdef __cplusplus -} -#endif - -#endif /* __S5K5CAG_H */ -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/st7735/Release_Notes.html b/bsp/stm32f411RE/Libraries/BSP/Components/st7735/Release_Notes.html deleted file mode 100644 index b445f0907b..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/st7735/Release_Notes.html +++ /dev/null @@ -1,307 +0,0 @@ - - - - - - - - - - - - - - - - - - - Release Notes for ST7735 Component Drivers - - - - - - - - - - -
-


-

-
- - - - - - -
- - - - - - - - - -
-

Back to Release page

-
- -

Release -Notes for ST7735 Component Drivers

- -

Copyright -2014 STMicroelectronics

-

-
-

 

- - - - - - -
- - -

Update History

V1.1.1/ 24-November-2014

- - - - - - - - - - - - - - - - -

Main -Changes

  • st7735.h: change "\" by "/" in the include path to fix compilation issues under -Linux.

V1.1.0/ 22-July-2014

- - - - - - - - - - - - - - - - -

Main -Changes

  • LCD Component driver update in order to harmonize all LCD controllers Link usage (Change LCD_IO_WriteData to LCD_IO_WriteMultipleData) 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

V1.0.0/ 22-April-2014

- - - - - - - - - - - - - - - - -

Main -Changes

  • First official release.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

License

-
-Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met:
-
-
  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions -in binary form must reproduce the above copyright notice, this list of -conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of STMicroelectronics nor the names of its contributors may be used to endorse or promote products derived
    -
    -
-        from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- -
-

- - -
-
-

For -complete documentation on STM32 Microcontrollers -visit www.st.com/STM32

-
-

-
-
-

 

-
- - \ No newline at end of file diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/st7735/st7735.c b/bsp/stm32f411RE/Libraries/BSP/Components/st7735/st7735.c deleted file mode 100644 index 10dedab382..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/st7735/st7735.c +++ /dev/null @@ -1,471 +0,0 @@ -/** - ****************************************************************************** - * @file st7735.c - * @author MCD Application Team - * @version V1.1.1 - * @date 24-November-2014 - * @brief This file includes the driver for ST7735 LCD mounted on the Adafruit - * 1.8" TFT LCD shield (reference ID 802). - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2014 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Includes ------------------------------------------------------------------*/ -#include "st7735.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup Components - * @{ - */ - -/** @addtogroup ST7735 - * @brief This file provides a set of functions needed to drive the - * ST7735 LCD. - * @{ - */ - -/** @defgroup ST7735_Private_TypesDefinitions - * @{ - */ - -/** - * @} - */ - -/** @defgroup ST7735_Private_Defines - * @{ - */ - -/** - * @} - */ - -/** @defgroup ST7735_Private_Macros - * @{ - */ - -/** - * @} - */ - -/** @defgroup ST7735_Private_Variables - * @{ - */ - - -LCD_DrvTypeDef st7735_drv = -{ - st7735_Init, - 0, - st7735_DisplayOn, - st7735_DisplayOff, - st7735_SetCursor, - st7735_WritePixel, - 0, - st7735_SetDisplayWindow, - st7735_DrawHLine, - st7735_DrawVLine, - st7735_GetLcdPixelWidth, - st7735_GetLcdPixelHeight, - st7735_DrawBitmap, -}; - -static uint16_t ArrayRGB[320] = {0}; - -/** -* @} -*/ - -/** @defgroup ST7735_Private_FunctionPrototypes - * @{ - */ - -/** -* @} -*/ - -/** @defgroup ST7735_Private_Functions - * @{ - */ - -/** - * @brief Initialize the ST7735 LCD Component. - * @param None - * @retval None - */ -void st7735_Init(void) -{ - uint8_t data = 0; - - /* Initialize ST7735 low level bus layer -----------------------------------*/ - LCD_IO_Init(); - /* Out of sleep mode, 0 args, no delay */ - st7735_WriteReg(LCD_REG_17, 0x00); - /* Frame rate ctrl - normal mode, 3 args:Rate = fosc/(1x2+40) * (LINE+2C+2D)*/ - LCD_IO_WriteReg(LCD_REG_177); - data = 0x01; - LCD_IO_WriteMultipleData(&data, 1); - data = 0x2C; - LCD_IO_WriteMultipleData(&data, 1); - data = 0x2D; - LCD_IO_WriteMultipleData(&data, 1); - /* Frame rate control - idle mode, 3 args:Rate = fosc/(1x2+40) * (LINE+2C+2D) */ - st7735_WriteReg(LCD_REG_178, 0x01); - st7735_WriteReg(LCD_REG_178, 0x2C); - st7735_WriteReg(LCD_REG_178, 0x2D); - /* Frame rate ctrl - partial mode, 6 args: Dot inversion mode, Line inversion mode */ - st7735_WriteReg(LCD_REG_179, 0x01); - st7735_WriteReg(LCD_REG_179, 0x2C); - st7735_WriteReg(LCD_REG_179, 0x2D); - st7735_WriteReg(LCD_REG_179, 0x01); - st7735_WriteReg(LCD_REG_179, 0x2C); - st7735_WriteReg(LCD_REG_179, 0x2D); - /* Display inversion ctrl, 1 arg, no delay: No inversion */ - st7735_WriteReg(LCD_REG_180, 0x07); - /* Power control, 3 args, no delay: -4.6V , AUTO mode */ - st7735_WriteReg(LCD_REG_192, 0xA2); - st7735_WriteReg(LCD_REG_192, 0x02); - st7735_WriteReg(LCD_REG_192, 0x84); - /* Power control, 1 arg, no delay: VGH25 = 2.4C VGSEL = -10 VGH = 3 * AVDD */ - st7735_WriteReg(LCD_REG_193, 0xC5); - /* Power control, 2 args, no delay: Opamp current small, Boost frequency */ - st7735_WriteReg(LCD_REG_194, 0x0A); - st7735_WriteReg(LCD_REG_194, 0x00); - /* Power control, 2 args, no delay: BCLK/2, Opamp current small & Medium low */ - st7735_WriteReg(LCD_REG_195, 0x8A); - st7735_WriteReg(LCD_REG_195, 0x2A); - /* Power control, 2 args, no delay */ - st7735_WriteReg(LCD_REG_196, 0x8A); - st7735_WriteReg(LCD_REG_196, 0xEE); - /* Power control, 1 arg, no delay */ - st7735_WriteReg(LCD_REG_197, 0x0E); - /* Don't invert display, no args, no delay */ - LCD_IO_WriteReg(LCD_REG_32); - /* Set color mode, 1 arg, no delay: 16-bit color */ - st7735_WriteReg(LCD_REG_58, 0x05); - /* Column addr set, 4 args, no delay: XSTART = 0, XEND = 127 */ - LCD_IO_WriteReg(LCD_REG_42); - data = 0x00; - LCD_IO_WriteMultipleData(&data, 1); - LCD_IO_WriteMultipleData(&data, 1); - LCD_IO_WriteMultipleData(&data, 1); - data = 0x7F; - LCD_IO_WriteMultipleData(&data, 1); - /* Row addr set, 4 args, no delay: YSTART = 0, YEND = 159 */ - LCD_IO_WriteReg(LCD_REG_43); - data = 0x00; - LCD_IO_WriteMultipleData(&data, 1); - LCD_IO_WriteMultipleData(&data, 1); - LCD_IO_WriteMultipleData(&data, 1); - data = 0x9F; - LCD_IO_WriteMultipleData(&data, 1); - /* Magical unicorn dust, 16 args, no delay */ - st7735_WriteReg(LCD_REG_224, 0x02); - st7735_WriteReg(LCD_REG_224, 0x1c); - st7735_WriteReg(LCD_REG_224, 0x07); - st7735_WriteReg(LCD_REG_224, 0x12); - st7735_WriteReg(LCD_REG_224, 0x37); - st7735_WriteReg(LCD_REG_224, 0x32); - st7735_WriteReg(LCD_REG_224, 0x29); - st7735_WriteReg(LCD_REG_224, 0x2d); - st7735_WriteReg(LCD_REG_224, 0x29); - st7735_WriteReg(LCD_REG_224, 0x25); - st7735_WriteReg(LCD_REG_224, 0x2B); - st7735_WriteReg(LCD_REG_224, 0x39); - st7735_WriteReg(LCD_REG_224, 0x00); - st7735_WriteReg(LCD_REG_224, 0x01); - st7735_WriteReg(LCD_REG_224, 0x03); - st7735_WriteReg(LCD_REG_224, 0x10); - /* Sparkles and rainbows, 16 args, no delay */ - st7735_WriteReg(LCD_REG_225, 0x03); - st7735_WriteReg(LCD_REG_225, 0x1d); - st7735_WriteReg(LCD_REG_225, 0x07); - st7735_WriteReg(LCD_REG_225, 0x06); - st7735_WriteReg(LCD_REG_225, 0x2E); - st7735_WriteReg(LCD_REG_225, 0x2C); - st7735_WriteReg(LCD_REG_225, 0x29); - st7735_WriteReg(LCD_REG_225, 0x2D); - st7735_WriteReg(LCD_REG_225, 0x2E); - st7735_WriteReg(LCD_REG_225, 0x2E); - st7735_WriteReg(LCD_REG_225, 0x37); - st7735_WriteReg(LCD_REG_225, 0x3F); - st7735_WriteReg(LCD_REG_225, 0x00); - st7735_WriteReg(LCD_REG_225, 0x00); - st7735_WriteReg(LCD_REG_225, 0x02); - st7735_WriteReg(LCD_REG_225, 0x10); - /* Normal display on, no args, no delay */ - st7735_WriteReg(LCD_REG_19, 0x00); - /* Main screen turn on, no delay */ - st7735_WriteReg(LCD_REG_41, 0x00); - /* Memory access control: MY = 1, MX = 1, MV = 0, ML = 0 */ - st7735_WriteReg(LCD_REG_54, 0xC0); -} - -/** - * @brief Enables the Display. - * @param None - * @retval None - */ -void st7735_DisplayOn(void) -{ - uint8_t data = 0; - LCD_IO_WriteReg(LCD_REG_19); - LCD_Delay(10); - LCD_IO_WriteReg(LCD_REG_41); - LCD_Delay(10); - LCD_IO_WriteReg(LCD_REG_54); - data = 0xC0; - LCD_IO_WriteMultipleData(&data, 1); -} - -/** - * @brief Disables the Display. - * @param None - * @retval None - */ -void st7735_DisplayOff(void) -{ - uint8_t data = 0; - LCD_IO_WriteReg(LCD_REG_19); - LCD_Delay(10); - LCD_IO_WriteReg(LCD_REG_40); - LCD_Delay(10); - LCD_IO_WriteReg(LCD_REG_54); - data = 0xC0; - LCD_IO_WriteMultipleData(&data, 1); -} - -/** - * @brief Sets Cursor position. - * @param Xpos: specifies the X position. - * @param Ypos: specifies the Y position. - * @retval None - */ -void st7735_SetCursor(uint16_t Xpos, uint16_t Ypos) -{ - uint8_t data = 0; - LCD_IO_WriteReg(LCD_REG_42); - data = (Xpos) >> 8; - LCD_IO_WriteMultipleData(&data, 1); - data = (Xpos) & 0xFF; - LCD_IO_WriteMultipleData(&data, 1); - LCD_IO_WriteReg(LCD_REG_43); - data = (Ypos) >> 8; - LCD_IO_WriteMultipleData(&data, 1); - data = (Ypos) & 0xFF; - LCD_IO_WriteMultipleData(&data, 1); - LCD_IO_WriteReg(LCD_REG_44); -} - -/** - * @brief Writes pixel. - * @param Xpos: specifies the X position. - * @param Ypos: specifies the Y position. - * @param RGBCode: the RGB pixel color - * @retval None - */ -void st7735_WritePixel(uint16_t Xpos, uint16_t Ypos, uint16_t RGBCode) -{ - uint8_t data = 0; - if((Xpos >= ST7735_LCD_PIXEL_WIDTH) || (Ypos >= ST7735_LCD_PIXEL_HEIGHT)) - { - return; - } - - /* Set Cursor */ - st7735_SetCursor(Xpos, Ypos); - - data = RGBCode >> 8; - LCD_IO_WriteMultipleData(&data, 1); - data = RGBCode; - LCD_IO_WriteMultipleData(&data, 1); -} - - -/** - * @brief Writes to the selected LCD register. - * @param LCDReg: Address of the selected register. - * @param LCDRegValue: value to write to the selected register. - * @retval None - */ -void st7735_WriteReg(uint8_t LCDReg, uint8_t LCDRegValue) -{ - LCD_IO_WriteReg(LCDReg); - LCD_IO_WriteMultipleData(&LCDRegValue, 1); -} - -/** - * @brief Sets a display window - * @param Xpos: specifies the X bottom left position. - * @param Ypos: specifies the Y bottom left position. - * @param Height: display window height. - * @param Width: display window width. - * @retval None - */ -void st7735_SetDisplayWindow(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height) -{ - uint8_t data = 0; - /* Column addr set, 4 args, no delay: XSTART = Xpos, XEND = (Xpos + Width - 1) */ - LCD_IO_WriteReg(LCD_REG_42); - data = (Xpos) >> 8; - LCD_IO_WriteMultipleData(&data, 1); - data = (Xpos) & 0xFF; - LCD_IO_WriteMultipleData(&data, 1); - data = (Xpos + Width - 1) >> 8; - LCD_IO_WriteMultipleData(&data, 1); - data = (Xpos + Width - 1) & 0xFF; - LCD_IO_WriteMultipleData(&data, 1); - /* Row addr set, 4 args, no delay: YSTART = Ypos, YEND = (Ypos + Height - 1) */ - LCD_IO_WriteReg(LCD_REG_43); - data = (Ypos) >> 8; - LCD_IO_WriteMultipleData(&data, 1); - data = (Ypos) & 0xFF; - LCD_IO_WriteMultipleData(&data, 1); - data = (Ypos + Height - 1) >> 8; - LCD_IO_WriteMultipleData(&data, 1); - data = (Ypos + Height - 1) & 0xFF; - LCD_IO_WriteMultipleData(&data, 1); -} - -/** - * @brief Draws horizontal line. - * @param RGBCode: Specifies the RGB color - * @param Xpos: specifies the X position. - * @param Ypos: specifies the Y position. - * @param Length: specifies the line length. - * @retval None - */ -void st7735_DrawHLine(uint16_t RGBCode, uint16_t Xpos, uint16_t Ypos, uint16_t Length) -{ - uint8_t counter = 0; - - if(Xpos + Length > ST7735_LCD_PIXEL_WIDTH) return; - - /* Set Cursor */ - st7735_SetCursor(Xpos, Ypos); - - for(counter = 0; counter < Length; counter++) - { - ArrayRGB[counter] = RGBCode; - } - LCD_IO_WriteMultipleData((uint8_t*)&ArrayRGB[0], Length * 2); -} - -/** - * @brief Draws vertical line. - * @param RGBCode: Specifies the RGB color - * @param Xpos: specifies the X position. - * @param Ypos: specifies the Y position. - * @param Length: specifies the line length. - * @retval None - */ -void st7735_DrawVLine(uint16_t RGBCode, uint16_t Xpos, uint16_t Ypos, uint16_t Length) -{ - uint8_t counter = 0; - - if(Ypos + Length > ST7735_LCD_PIXEL_HEIGHT) return; - for(counter = 0; counter < Length; counter++) - { - st7735_WritePixel(Xpos, Ypos + counter, RGBCode); - } -} - -/** - * @brief Gets the LCD pixel Width. - * @param None - * @retval The Lcd Pixel Width - */ -uint16_t st7735_GetLcdPixelWidth(void) -{ - return ST7735_LCD_PIXEL_WIDTH; -} - -/** - * @brief Gets the LCD pixel Height. - * @param None - * @retval The Lcd Pixel Height - */ -uint16_t st7735_GetLcdPixelHeight(void) -{ - return ST7735_LCD_PIXEL_HEIGHT; -} - -/** - * @brief Displays a bitmap picture loaded in the internal Flash. - * @param BmpAddress: Bmp picture address in the internal Flash. - * @retval None - */ -void st7735_DrawBitmap(uint16_t Xpos, uint16_t Ypos, uint8_t *pbmp) -{ - uint32_t index = 0, size = 0; - - /* Read bitmap size */ - size = *(volatile uint16_t *) (pbmp + 2); - size |= (*(volatile uint16_t *) (pbmp + 4)) << 16; - /* Get bitmap data address offset */ - index = *(volatile uint16_t *) (pbmp + 10); - index |= (*(volatile uint16_t *) (pbmp + 12)) << 16; - size = (size - index)/2; - pbmp += index; - - /* Set GRAM write direction and BGR = 0 */ - /* Memory access control: MY = 0, MX = 1, MV = 0, ML = 0 */ - st7735_WriteReg(LCD_REG_54, 0x40); - - /* Set Cursor */ - st7735_SetCursor(Xpos, Ypos); - - LCD_IO_WriteMultipleData((uint8_t*)pbmp, size*2); - - /* Set GRAM write direction and BGR = 0 */ - /* Memory access control: MY = 1, MX = 1, MV = 0, ML = 0 */ - st7735_WriteReg(LCD_REG_54, 0xC0); -} - -/** -* @} -*/ - -/** -* @} -*/ - -/** -* @} -*/ - -/** -* @} -*/ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ - diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/st7735/st7735.h b/bsp/stm32f411RE/Libraries/BSP/Components/st7735/st7735.h deleted file mode 100644 index 9e98be4b2c..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/st7735/st7735.h +++ /dev/null @@ -1,214 +0,0 @@ -/** - ****************************************************************************** - * @file st7735.h - * @author MCD Application Team - * @version V1.1.1 - * @date 24-November-2014 - * @brief This file contains all the functions prototypes for the st7735.c - * driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2014 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __ST7735_H -#define __ST7735_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "../Common/lcd.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup Components - * @{ - */ - -/** @addtogroup ST7735 - * @{ - */ - -/** @defgroup ST7735_Exported_Types - * @{ - */ - -/** - * @} - */ - -/** @defgroup ST7735_Exported_Constants - * @{ - */ - -/** - * @brief ST7735 Size - */ -#define ST7735_LCD_PIXEL_WIDTH ((uint16_t)128) -#define ST7735_LCD_PIXEL_HEIGHT ((uint16_t)160) - -/** - * @brief ST7735 Registers - */ -#define LCD_REG_0 0x00 /* No Operation: NOP */ -#define LCD_REG_1 0x01 /* Software reset: SWRESET */ -#define LCD_REG_4 0x04 /* Read Display ID: RDDID */ -#define LCD_REG_9 0x09 /* Read Display Statu: RDDST */ -#define LCD_REG_10 0x0A /* Read Display Power: RDDPM */ -#define LCD_REG_11 0x0B /* Read Display: RDDMADCTL */ -#define LCD_REG_12 0x0C /* Read Display Pixel: RDDCOLMOD */ -#define LCD_REG_13 0x0D /* Read Display Image: RDDIM */ -#define LCD_REG_14 0x0E /* Read Display Signal: RDDSM */ -#define LCD_REG_16 0x10 /* Sleep in & booster off: SLPIN */ -#define LCD_REG_17 0x11 /* Sleep out & booster on: SLPOUT */ -#define LCD_REG_18 0x12 /* Partial mode on: PTLON */ -#define LCD_REG_19 0x13 /* Partial off (Normal): NORON */ -#define LCD_REG_32 0x20 /* Display inversion off: INVOFF */ -#define LCD_REG_33 0x21 /* Display inversion on: INVON */ -#define LCD_REG_38 0x26 /* Gamma curve select: GAMSET */ -#define LCD_REG_40 0x28 /* Display off: DISPOFF */ -#define LCD_REG_41 0x29 /* Display on: DISPON */ -#define LCD_REG_42 0x2A /* Column address set: CASET */ -#define LCD_REG_43 0x2B /* Row address set: RASET */ -#define LCD_REG_44 0x2C /* Memory write: RAMWR */ -#define LCD_REG_45 0x2D /* LUT for 4k,65k,262k color: RGBSET */ -#define LCD_REG_46 0x2E /* Memory read: RAMRD*/ -#define LCD_REG_48 0x30 /* Partial start/end address set: PTLAR */ -#define LCD_REG_52 0x34 /* Tearing effect line off: TEOFF */ -#define LCD_REG_53 0x35 /* Tearing effect mode set & on: TEON */ -#define LCD_REG_54 0x36 /* Memory data access control: MADCTL */ -#define LCD_REG_56 0x38 /* Idle mode off: IDMOFF */ -#define LCD_REG_57 0x39 /* Idle mode on: IDMON */ -#define LCD_REG_58 0x3A /* Interface pixel format: COLMOD */ -#define LCD_REG_177 0xB1 /* In normal mode (Full colors): FRMCTR1 */ -#define LCD_REG_178 0xB2 /* In Idle mode (8-colors): FRMCTR2 */ -#define LCD_REG_179 0xB3 /* In partial mode + Full colors: FRMCTR3 */ -#define LCD_REG_180 0xB4 /* Display inversion control: INVCTR */ -#define LCD_REG_192 0xC0 /* Power control setting: PWCTR1 */ -#define LCD_REG_193 0xC1 /* Power control setting: PWCTR2 */ -#define LCD_REG_194 0xC2 /* In normal mode (Full colors): PWCTR3 */ -#define LCD_REG_195 0xC3 /* In Idle mode (8-colors): PWCTR4 */ -#define LCD_REG_196 0xC4 /* In partial mode + Full colors: PWCTR5 */ -#define LCD_REG_197 0xC5 /* VCOM control 1: VMCTR1 */ -#define LCD_REG_199 0xC7 /* Set VCOM offset control: VMOFCTR */ -#define LCD_REG_209 0xD1 /* Set LCM version code: WRID2 */ -#define LCD_REG_210 0xD2 /* Customer Project code: WRID3 */ -#define LCD_REG_217 0xD9 /* NVM control status: NVCTR1 */ -#define LCD_REG_218 0xDA /* Read ID1: RDID1 */ -#define LCD_REG_219 0xDB /* Read ID2: RDID2 */ -#define LCD_REG_220 0xDC /* Read ID3: RDID3 */ -#define LCD_REG_222 0xDE /* NVM Read Command: NVCTR2 */ -#define LCD_REG_223 0xDF /* NVM Write Command: NVCTR3 */ -#define LCD_REG_224 0xE0 /* Set Gamma adjustment (+ polarity): GAMCTRP1 */ -#define LCD_REG_225 0xE1 /* Set Gamma adjustment (- polarity): GAMCTRN1 */ - -/** - * @brief LCD Lines depending on the chosen fonts. - */ -#define LCD_LINE_0 LINE(0) -#define LCD_LINE_1 LINE(1) -#define LCD_LINE_2 LINE(2) -#define LCD_LINE_3 LINE(3) -#define LCD_LINE_4 LINE(4) -#define LCD_LINE_5 LINE(5) -#define LCD_LINE_6 LINE(6) -#define LCD_LINE_7 LINE(7) -#define LCD_LINE_8 LINE(8) -#define LCD_LINE_9 LINE(9) -#define LCD_LINE_10 LINE(10) -#define LCD_LINE_11 LINE(11) -#define LCD_LINE_12 LINE(12) -#define LCD_LINE_13 LINE(13) -#define LCD_LINE_14 LINE(14) -#define LCD_LINE_15 LINE(15) -#define LCD_LINE_16 LINE(16) -#define LCD_LINE_17 LINE(17) -#define LCD_LINE_18 LINE(18) -#define LCD_LINE_19 LINE(19) - -/** - * @} - */ - -/** @defgroup ADAFRUIT_SPI_LCD_Exported_Functions - * @{ - */ -void st7735_Init(void); -uint16_t st7735_ReadID(void); - -void st7735_DisplayOn(void); -void st7735_DisplayOff(void); -void st7735_SetCursor(uint16_t Xpos, uint16_t Ypos); -void st7735_WritePixel(uint16_t Xpos, uint16_t Ypos, uint16_t RGBCode); -void st7735_WriteReg(uint8_t LCDReg, uint8_t LCDRegValue); -uint8_t st7735_ReadReg(uint8_t LCDReg); - -void st7735_SetDisplayWindow(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height); -void st7735_DrawHLine(uint16_t RGBCode, uint16_t Xpos, uint16_t Ypos, uint16_t Length); -void st7735_DrawVLine(uint16_t RGBCode, uint16_t Xpos, uint16_t Ypos, uint16_t Length); - -uint16_t st7735_GetLcdPixelWidth(void); -uint16_t st7735_GetLcdPixelHeight(void); -void st7735_DrawBitmap(uint16_t Xpos, uint16_t Ypos, uint8_t *pbmp); - -/* LCD driver structure */ -extern LCD_DrvTypeDef st7735_drv; - -/* LCD IO functions */ -void LCD_IO_Init(void); -void LCD_IO_WriteMultipleData(uint8_t *pData, uint32_t Size); -void LCD_IO_WriteReg(uint8_t Reg); -void LCD_Delay(uint32_t delay); -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __ST7735_H */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/stmpe1600/Release_Notes.html b/bsp/stm32f411RE/Libraries/BSP/Components/stmpe1600/Release_Notes.html deleted file mode 100644 index 7716cee4cb..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/stmpe1600/Release_Notes.html +++ /dev/null @@ -1,336 +0,0 @@ - - - - - - - - - - - - - - - - - - - Release Notes for STMPE1600 Component Driver - - - - - - - - - - -
-


-

-
- - - - - - -
- - - - - - - - - -
-

Back to Release page

-
-

Release -Notes for STMPE1600 Component Driver

-

Copyright -2015 STMicroelectronics

-

-
-

 

- - - - - - -
- - -

Update History

V1.1.0 / 10-February-2015

- - - - - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  • Update IO_Pin parameter to uint32_t in all IO functionalities functions.
  • This version is to be used with Common V2.0.0 version.

V1.0.1 / 02-December-2014

- - - - - - - - - - - - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  • stmpe1600.h: change "\" by "/" in the include path to fix compilation issue under Linux

V1.0.0 / 18-February-2014

- - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
  • First official release
  • -

License

-
-Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met:
-
-
  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions -in binary form must reproduce the above copyright notice, this list of -conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of STMicroelectronics nor the names of its contributors may be used to endorse or promote products derived
    -
    -
-        from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- -
-

- - -
-
-

For -complete documentation on STM32 Microcontrollers -visit www.st.com/STM32

-
-

-
-
-

 

-
- - \ No newline at end of file diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/stmpe1600/stmpe1600.c b/bsp/stm32f411RE/Libraries/BSP/Components/stmpe1600/stmpe1600.c deleted file mode 100644 index fc08e6809f..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/stmpe1600/stmpe1600.c +++ /dev/null @@ -1,604 +0,0 @@ -/** - ****************************************************************************** - * @file stmpe1600.c - * @author MCD Application Team - * @version V1.1.0 - * @date 10-February-2015 - * @brief This file provides a set of functions needed to manage the STMPE1600 - * IO Expander devices. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Includes ------------------------------------------------------------------*/ -#include "stmpe1600.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup Components - * @{ - */ - -/** @defgroup STMPE1600 - * @{ - */ - -/* Private typedef -----------------------------------------------------------*/ - -/** @defgroup STMPE1600_Private_Types_Definitions - * @{ - */ - -/* Private define ------------------------------------------------------------*/ - -/** @defgroup STMPE1600_Private_Defines - * @{ - */ -#define STMPE1600_MAX_INSTANCE 2 - -/* Private macro -------------------------------------------------------------*/ - -/** @defgroup STMPE1600_Private_Macros - * @{ - */ - -/* Private variables ---------------------------------------------------------*/ -static uint16_t tmp = 0; - -/** @defgroup STMPE1600_Private_Variables - * @{ - */ -/* IO driver structure initialization */ -IO_DrvTypeDef stmpe1600_io_drv = -{ - stmpe1600_Init, - stmpe1600_ReadID, - stmpe1600_Reset, - stmpe1600_Start, - stmpe1600_IO_Config, - stmpe1600_IO_WritePin, - stmpe1600_IO_ReadPin, - 0, - 0, - stmpe1600_IO_ITStatus, - stmpe1600_IO_ClearIT, -}; - -uint8_t stmpe1600[STMPE1600_MAX_INSTANCE] = {0}; -/** - * @} - */ - -/* Private function prototypes -----------------------------------------------*/ - -/** @defgroup STMPE1600_Private_Function_Prototypes - * @{ - */ -static uint8_t stmpe1600_GetInstance(uint16_t DeviceAddr); - -/* Private functions ---------------------------------------------------------*/ - -/** @defgroup STMPE1600_Private_Functions - * @{ - */ - -/** - * @brief Initialize the stmpe1600 and configure the needed hardware resources - * @param DeviceAddr: Device address on communication Bus. - * @retval None - */ -void stmpe1600_Init(uint16_t DeviceAddr) -{ - uint8_t instance; - uint8_t empty; - - /* Check if device instance already exists */ - instance = stmpe1600_GetInstance(DeviceAddr); - - if(instance == 0xFF) - { - /* Look for empty instance */ - empty = stmpe1600_GetInstance(0); - - if(empty < STMPE1600_MAX_INSTANCE) - { - /* Register the current device instance */ - stmpe1600[empty] = DeviceAddr; - - /* Initialize IO BUS layer */ - IOE_Init(); - - /* Generate stmpe1600 Software reset */ - stmpe1600_Reset(DeviceAddr); - } - } -} - -/** - * @brief Configures the touch Screen Controller (Single point detection) - * @param DeviceAddr: Device address on communication Bus. - * @retval None. - */ -void stmpe1600_Start(uint16_t DeviceAddr, uint32_t IO_Pin) -{ - /*Configuration already done during the initialization */ -} - -/** - * @brief Reset the stmpe1600 by Software. - * @param DeviceAddr: Device address on communication Bus. - * @retval None - */ -void stmpe1600_Reset(uint16_t DeviceAddr) -{ - /* Power Down the stmpe1600 */ - IOE_Write(DeviceAddr, STMPE1600_REG_SYS_CTRL, (uint16_t)0x80); - - /* Wait for a delay to ensure registers erasing */ - IOE_Delay(2); - - /* Power On the Codec after the power off: all registers are reinitialized */ - IOE_Write(DeviceAddr, STMPE1600_REG_SYS_CTRL, (uint16_t)0x00); - - /* Wait for a delay to ensure registers erasing */ - IOE_Delay(2); -} - -/** - * @brief Read the stmpe1600 device ID. - * @param DeviceAddr: Device address on communication Bus. - * @retval The Device ID (two bytes). - */ -uint16_t stmpe1600_ReadID(uint16_t DeviceAddr) -{ - uint8_t tmpData[2] = {0 , 0}; - - /* Initialize IO BUS layer */ - IOE_Init(); - - /* Read the stmpe1600 device ID */ - IOE_ReadMultiple(DeviceAddr, STMPE1600_REG_CHP_ID, tmpData, 2); - - /* Return the device ID value */ - return((uint16_t)tmpData[0] | (((uint16_t)tmpData[1]) << 8)); -} - -/** - * @brief Set the global interrupt Polarity. - * @param DeviceAddr: Device address on communication Bus. - * @param Polarity: could be one of these values; - * @arg STMPE1600_POLARITY_LOW: Interrupt line is active Low/Falling edge - * @arg STMPE1600_POLARITY_HIGH: Interrupt line is active High/Rising edge - * @retval None - */ -void stmpe1600_SetITPolarity(uint16_t DeviceAddr, uint8_t Polarity) -{ - uint8_t tmp = 0; - - /* Get the current register value */ - tmp = IOE_Read(DeviceAddr, STMPE1600_REG_SYS_CTRL); - - /* Mask the polarity bit */ - tmp &= ~(uint16_t)0x01; - - /* Set the Interrupt Output line polarity */ - tmp |= (uint8_t)Polarity; - - /* Set the new register value */ - IOE_Write(DeviceAddr, STMPE1600_REG_SYS_CTRL, tmp); -} - -/** - * @brief Enable the Global interrupt. - * @param DeviceAddr: Device address on communication Bus. - * @retval None - */ -void stmpe1600_EnableGlobalIT(uint16_t DeviceAddr) -{ - uint8_t tmpData[2] = {0 , 0}; - - /* Configure NVIC IT for IOE */ - IOE_ITConfig(); - - /* Get the current register value */ - IOE_ReadMultiple(DeviceAddr, STMPE1600_REG_SYS_CTRL, tmpData, 2); - - tmp = ((uint16_t)tmpData[0] | (((uint16_t)tmpData[1]) << 8)); - - /* Set the global interrupts to be Enabled */ - tmp |= (uint16_t)STMPE1600_IT_ENABLE; - - /* Write Back the Interrupt Control register */ - IOE_WriteMultiple(DeviceAddr, STMPE1600_REG_SYS_CTRL, (uint8_t *)&tmp, 2); -} - -/** - * @brief Disable the Global interrupt. - * @param DeviceAddr: Device address on communication Bus. - * @retval None - */ -void stmpe1600_DisableGlobalIT(uint16_t DeviceAddr) -{ - uint8_t tmpData[2] = {0 , 0}; - - /* Get the current register value */ - IOE_ReadMultiple(DeviceAddr, STMPE1600_REG_SYS_CTRL, tmpData, 2); - - tmp = ((uint16_t)tmpData[0] | (((uint16_t)tmpData[1]) << 8)); - - /* Set the global interrupts to be Enabled */ - tmp &= ~(uint16_t)STMPE1600_IT_ENABLE; - - /* Write Back the Interrupt Control register */ - IOE_WriteMultiple(DeviceAddr, STMPE1600_REG_SYS_CTRL, (uint8_t *)&tmp, 2); -} - -/** - * @brief Initialize the selected pin(s) direction. - * @param DeviceAddr: Device address on communication Bus. - * @param IO_Pin: IO pin(s) to be configured. - * This parameter could be any combination of the following values: - * @arg STMPE1600_PIN_x: where x can be from 0 to 15. - * @param Direction: could be STMPE1600_DIRECTION_IN or STMPE1600_DIRECTION_OUT. - * @retval None - */ -void stmpe1600_IO_InitPin(uint16_t DeviceAddr, uint32_t IO_Pin, uint8_t Direction) -{ - uint8_t tmpData[2] = {0 , 0}; - - /* Get the current register value */ - IOE_ReadMultiple(DeviceAddr, STMPE1600_REG_GPDR, tmpData, 2); - - tmp = ((uint16_t)tmpData[0] | (((uint16_t)tmpData[1]) << 8)); - - /* Set the Pin direction */ - if (Direction != STMPE1600_DIRECTION_IN) - { - tmp |= (uint16_t)IO_Pin; - } - else - { - tmp &= ~(uint16_t)IO_Pin; - } - - /* Set the new register value */ - IOE_WriteMultiple(DeviceAddr, STMPE1600_REG_GPDR, (uint8_t *)&tmp, 2); -} - -/** - * @brief Configure the IO pin(s) according to IO mode structure value. - * @param DeviceAddr: Device address on communication Bus. - * @param IO_Pin: The output pin to be set or reset. This parameter can be one - * of the following values: - * @arg STMPE1600_PIN_x: where x can be from 0 to 7. - * @param IO_Mode: The IO pin mode to configure, could be one of the following values: - * @arg IO_MODE_INPUT - * @arg IO_MODE_OUTPUT - * @arg IO_MODE_IT_RISING_EDGE - * @arg IO_MODE_IT_FALLING_EDGE - * @retval 0 if no error, IO_Mode if error - */ -uint8_t stmpe1600_IO_Config(uint16_t DeviceAddr, uint32_t IO_Pin, IO_ModeTypedef IO_Mode) -{ - uint8_t error_code = 0; - uint8_t buffer[2] = {0,0}; - - /* Configure IO pin according to selected IO mode */ - switch(IO_Mode) - { - case IO_MODE_INPUT: /* Input mode */ - stmpe1600_IO_DisablePinIT(DeviceAddr, IO_Pin); - stmpe1600_IO_InitPin(DeviceAddr, IO_Pin, STMPE1600_DIRECTION_IN); - break; - - case IO_MODE_OUTPUT: /* Output mode */ - stmpe1600_IO_DisablePinIT(DeviceAddr, IO_Pin); - stmpe1600_IO_InitPin(DeviceAddr, IO_Pin, STMPE1600_DIRECTION_OUT); - break; - - case IO_MODE_IT_RISING_EDGE: /* Interrupt rising edge mode */ - stmpe1600_SetITPolarity(DeviceAddr, STMPE1600_POLARITY_HIGH); - stmpe1600_IO_EnablePinIT(DeviceAddr, IO_Pin); - stmpe1600_IO_InitPin(DeviceAddr, IO_Pin, STMPE1600_DIRECTION_IN); - /* Clear all IO IT pending bits if any */ - stmpe1600_IO_ClearIT(DeviceAddr, IO_Pin); - - /* Read GMPR to enable interrupt */ - IOE_ReadMultiple(DeviceAddr , STMPE1600_REG_GPMR, buffer, 2); - break; - - case IO_MODE_IT_FALLING_EDGE: /* Interrupt falling edge mode */ - stmpe1600_SetITPolarity(DeviceAddr, STMPE1600_POLARITY_LOW); - stmpe1600_IO_EnablePinIT(DeviceAddr, IO_Pin); - stmpe1600_IO_InitPin(DeviceAddr, IO_Pin, STMPE1600_DIRECTION_IN); - - /* Clear all IO IT pending bits if any */ - stmpe1600_IO_ClearIT(DeviceAddr, IO_Pin); - - /* Read GMPR to enable interrupt */ - IOE_ReadMultiple(DeviceAddr , STMPE1600_REG_GPMR, buffer, 2); - break; - - default: - error_code = (uint8_t) IO_Mode; - break; - } - return error_code; -} - -/** - * @brief Enable polarity inversion of the selected IO pin(s). - * @param DeviceAddr: Device address on communication Bus. - * @param IO_Pin: IO pin(s) to be configured. - * This parameter could be any combination of the following values: - * @arg STMPE1600_PIN_x: where x can be from 0 to 15. - * @retval None - */ -void stmpe1600_IO_PolarityInv_Enable(uint16_t DeviceAddr, uint32_t IO_Pin) -{ - uint8_t tmpData[2] = {0 , 0}; - - /* Get the current register value */ - IOE_ReadMultiple(DeviceAddr, STMPE1600_REG_GPPIR, tmpData, 2); - - tmp = ((uint16_t)tmpData[0] | (((uint16_t)tmpData[1]) << 8)); - - /* Enable pin polarity inversion */ - tmp |= (uint16_t)IO_Pin; - - /* Set the new register value */ - IOE_WriteMultiple(DeviceAddr, STMPE1600_REG_GPPIR, (uint8_t *)&tmp, 2); -} - -/** - * @brief Disable polarity inversion of the selected IO pins. - * @param DeviceAddr: Device address on communication Bus. - * @param IO_Pin: IO pin(s) to be configured. - * This parameter could be any combination of the following values: - * @arg STMPE1600_PIN_x: where x can be from 0 to 15. - * @retval None - */ -void stmpe1600_IO_PolarityInv_Disable(uint16_t DeviceAddr, uint32_t IO_Pin) -{ - uint8_t tmpData[2] = {0 , 0}; - - /* Get the current register value */ - IOE_ReadMultiple(DeviceAddr, STMPE1600_REG_GPPIR, tmpData, 2); - - tmp = ((uint16_t)tmpData[0] | (((uint16_t)tmpData[1]) << 8)); - - /* Disable pin polarity inversion */ - tmp &= ~ (uint16_t)IO_Pin; - - /* Set the new register value */ - IOE_WriteMultiple(DeviceAddr, STMPE1600_REG_GPPIR, (uint8_t *)&tmp, 2); -} - -/** - * @brief Set the value of the selected IO pins. - * @param DeviceAddr: Device address on communication Bus. - * @param IO_Pin: IO pin(s) to be set. - * This parameter could be any combination of the following values: - * @arg STMPE1600_PIN_x: where x can be from 0 to 15. - * @param PinState: The value to be set. - * @retval None - */ -void stmpe1600_IO_WritePin(uint16_t DeviceAddr, uint32_t IO_Pin, uint8_t PinState) -{ - uint8_t tmpData[2] = {0 , 0}; - - /* Get the current register value */ - IOE_ReadMultiple(DeviceAddr, STMPE1600_REG_GPMR, tmpData, 2); - - tmp = ((uint16_t)tmpData[0] | (((uint16_t)tmpData[1]) << 8)); - - /* Set the pin state */ - if(PinState != 0) - { - tmp |= (uint16_t)IO_Pin; - } - else - { - tmp &= ~(uint16_t)IO_Pin; - } - - /* Set the new register value */ - IOE_WriteMultiple(DeviceAddr, STMPE1600_REG_GPSR, (uint8_t *)&tmp, 2); -} - -/** - * @brief Read the state of the selected IO pin(s). - * @param DeviceAddr: Device address on communication Bus. - * @param IO_Pin: IO pin(s) to be read. - * This parameter could be any combination of the following values: - * @arg STMPE1600_PIN_x: where x can be from 0 to 15. - * @retval State of the selected IO pin(s). - */ -uint32_t stmpe1600_IO_ReadPin(uint16_t DeviceAddr, uint32_t IO_Pin) -{ - uint8_t tmpData[2] = {0 , 0}; - - /* Get the register value */ - IOE_ReadMultiple(DeviceAddr, STMPE1600_REG_GPMR, tmpData, 2); - - tmp = ((uint16_t)tmpData[0] | (((uint16_t)tmpData[1]) << 8)); - - /* Return the pin(s) state */ - return(tmp & IO_Pin); -} - -/** - * @brief Enable the interrupt mode for the selected IO pin(s). - * @param DeviceAddr: Device address on communication Bus. - * @param IO_Pin: IO pin(s) to be configured. - * This parameter could be any combination of the following values: - * @arg STMPE1600_PIN_x: where x can be from 0 to 15. - * @retval None - */ -void stmpe1600_IO_EnablePinIT(uint16_t DeviceAddr, uint32_t IO_Pin) -{ - uint8_t tmpData[2] = {0 , 0}; - - /* Enable global interrupt */ - stmpe1600_EnableGlobalIT(DeviceAddr); - - /* Get the current register value */ - IOE_ReadMultiple(DeviceAddr, STMPE1600_REG_IEGPIOR, tmpData, 2); - - tmp = ((uint16_t)tmpData[0] | (((uint16_t)tmpData[1]) << 8)); - - /* Put pin in IT mode */ - tmp |= (uint16_t)IO_Pin; - - /* Write the new register value */ - IOE_WriteMultiple(DeviceAddr, STMPE1600_REG_IEGPIOR, (uint8_t *)&tmp, 2); -} - -/** - * @brief Disable the interrupt mode for the selected IO pin(s). - * @param DeviceAddr: Device address on communication Bus. - * @param IO_Pin: IO pin(s) to be configured. - * This parameter could be any combination of the following values: - * @arg STMPE1600_PIN_x: where x can be from 0 to 15. - * @retval None - */ -void stmpe1600_IO_DisablePinIT(uint16_t DeviceAddr, uint32_t IO_Pin) -{ - uint8_t tmpData[2] = {0 , 0}; - - /* Get the current register value */ - IOE_ReadMultiple(DeviceAddr, STMPE1600_REG_IEGPIOR, tmpData, 2); - - tmp = ((uint16_t)tmpData[0] | (((uint16_t)tmpData[1]) << 8)); - - /* Disable the IT pin mode */ - tmp &= ~(uint16_t)IO_Pin; - - /* Set the new register value */ - IOE_WriteMultiple(DeviceAddr, STMPE1600_REG_IEGPIOR, (uint8_t *)&tmp, 2); -} - -/** - * @brief Read the IT status of the selected IO pin(s) - * (clears all the pending bits if any). - * @param DeviceAddr: Device address on communication Bus. - * @param IO_Pin: IO pin(s) to be checked. - * This parameter could be any combination of the following values: - * @arg STMPE1600_PIN_x: where x can be from 0 to 15. - * @retval IT Status of the selected IO pin(s). - */ -uint32_t stmpe1600_IO_ITStatus(uint16_t DeviceAddr, uint32_t IO_Pin) -{ - uint8_t tmpData[2] = {0 , 0}; - - /* Get the register value */ - IOE_ReadMultiple(DeviceAddr, STMPE1600_REG_ISGPIOR, tmpData, 2); - - tmp = ((uint16_t)tmpData[0] | (((uint16_t)tmpData[1]) << 8)); - - /* Return the pin IT status */ - return((tmp & IO_Pin) == IO_Pin); -} - -/** - * @brief Detect an IT pending bit from the selected IO pin(s). - * (clears all the pending bits if any). - * @param DeviceAddr: Device address on communication Bus. - * @param IO_Pin: IO pin(s) to be checked. - * This parameter could be any combination of the following values: - * @arg STMPE1600_PIN_x: where x can be from 0 to 15. - * @retval IT pending bit detection status. - */ -uint8_t stmpe1600_IO_ReadIT(uint16_t DeviceAddr, uint32_t IO_Pin) -{ - uint8_t tmpData[2] = {0 , 0}; - - /* Get the register value */ - IOE_ReadMultiple(DeviceAddr, STMPE1600_REG_ISGPIOR, tmpData, 2); - - tmp = ((uint16_t)tmpData[0] | (((uint16_t)tmpData[1]) << 8)); - - /* Return if there is an IT pending bit or not */ - return(tmp & IO_Pin); -} - -/** - * @brief Clear all the IT pending bits if any. - * @param DeviceAddr: Device address on communication Bus. - * @retval None - */ -void stmpe1600_IO_ClearIT(uint16_t DeviceAddr, uint32_t IO_Pin) -{ - uint8_t tmpData[2] = {0 , 0}; - - /* Get the register value to clear all pending bits */ - IOE_ReadMultiple(DeviceAddr, STMPE1600_REG_ISGPIOR, tmpData, 2); -} - -/** - * @brief Check if the device instance of the selected address is already registered - * and return its index - * @param DeviceAddr: Device address on communication Bus. - * @retval Index of the device instance if registered, 0xFF if not. - */ -static uint8_t stmpe1600_GetInstance(uint16_t DeviceAddr) -{ - uint8_t idx = 0; - - /* Check all the registered instances */ - for(idx = 0; idx < STMPE1600_MAX_INSTANCE ; idx ++) - { - /* Return index if there is address match */ - if(stmpe1600[idx] == DeviceAddr) - { - return idx; - } - } - - return 0xFF; -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/stmpe1600/stmpe1600.h b/bsp/stm32f411RE/Libraries/BSP/Components/stmpe1600/stmpe1600.h deleted file mode 100644 index a83231ac3d..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/stmpe1600/stmpe1600.h +++ /dev/null @@ -1,213 +0,0 @@ -/** - ****************************************************************************** - * @file stmpe1600.h - * @author MCD Application Team - * @version V1.1.0 - * @date 10-February-2015 - * @brief This file contains all the functions prototypes for the - * stmpe1600.c IO expander driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2014 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STMPE1600_H -#define __STMPE1600_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "../Common/io.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup Component - * @{ - */ - -/** @defgroup STMPE1600 - * @{ - */ - -/* Exported types ------------------------------------------------------------*/ - -/** @defgroup STMPE1600_Exported_Types - * @{ - */ - -/* Exported constants --------------------------------------------------------*/ - -/** @defgroup STMPE1600_Exported_Constants - * @{ - */ - -/** - * @brief STMPE1600 chip IDs - */ -#define STMPE1600_ID 0x1600 - -/** - * @brief Interrupt enable - */ -#define STMPE1600_IT_ENABLE 0x04 - -/** - * @brief Identification registers & System Control - */ -#define STMPE1600_REG_CHP_ID 0x00 -#define STMPE1600_REG_ID_VERSION 0x02 -#define STMPE1600_REG_SYS_CTRL 0x03 - -/** - * @brief IO Registers - */ - -#define STMPE1600_REG_GPMR 0x10 -#define STMPE1600_REG_GPSR 0x12 -#define STMPE1600_REG_GPDR 0x14 -#define STMPE1600_REG_GPPIR 0x16 - -/** - * @brief Interrupt Control registers - */ -#define STMPE1600_REG_IEGPIOR 0x08 -#define STMPE1600_REG_ISGPIOR 0x0A - -/** - * @brief IO Pins direction - */ -#define STMPE1600_DIRECTION_IN 0x00 -#define STMPE1600_DIRECTION_OUT 0x01 - -/** - * @brief IO IT polarity - */ -#define STMPE1600_POLARITY_LOW 0x00 -#define STMPE1600_POLARITY_HIGH 0x01 - -/** - * @brief IO Pins - */ -#define STMPE1600_PIN_0 0x0001 -#define STMPE1600_PIN_1 0x0002 -#define STMPE1600_PIN_2 0x0004 -#define STMPE1600_PIN_3 0x0008 -#define STMPE1600_PIN_4 0x0010 -#define STMPE1600_PIN_5 0x0020 -#define STMPE1600_PIN_6 0x0040 -#define STMPE1600_PIN_7 0x0080 -#define STMPE1600_PIN_8 0x0100 -#define STMPE1600_PIN_9 0x0200 -#define STMPE1600_PIN_10 0x0400 -#define STMPE1600_PIN_11 0x0800 -#define STMPE1600_PIN_12 0x1000 -#define STMPE1600_PIN_13 0x2000 -#define STMPE1600_PIN_14 0x4000 -#define STMPE1600_PIN_15 0x8000 -#define STMPE1600_PIN_ALL 0xFFFF - -/** - * @} - */ - -/* Exported macro ------------------------------------------------------------*/ - -/** @defgroup STMPE1600_Exported_Macros - * @{ - */ - -/* Exported functions --------------------------------------------------------*/ - -/** @defgroup STMPE1600_Exported_Functions - * @{ - */ - -/** - * @brief STMPE1600 Control functions - */ -void stmpe1600_Init(uint16_t DeviceAddr); -void stmpe1600_Reset(uint16_t DeviceAddr); -uint16_t stmpe1600_ReadID(uint16_t DeviceAddr); -void stmpe1600_SetITPolarity(uint16_t DeviceAddr, uint8_t Polarity); -void stmpe1600_EnableGlobalIT(uint16_t DeviceAddr); -void stmpe1600_DisableGlobalIT(uint16_t DeviceAddr); - -/** - * @brief STMPE1600 IO functionalities functions - */ -void stmpe1600_IO_InitPin(uint16_t DeviceAddr, uint32_t IO_Pin, uint8_t Direction); -uint8_t stmpe1600_IO_Config(uint16_t DeviceAddr, uint32_t IO_Pin, IO_ModeTypedef IO_Mode); -void stmpe1600_IO_PolarityInv_Enable(uint16_t DeviceAddr, uint32_t IO_Pin); -void stmpe1600_IO_PolarityInv_Disable(uint16_t DeviceAddr, uint32_t IO_Pin); -void stmpe1600_IO_WritePin(uint16_t DeviceAddr, uint32_t IO_Pin, uint8_t PinState); -uint32_t stmpe1600_IO_ReadPin(uint16_t DeviceAddr, uint32_t IO_Pin); -void stmpe1600_IO_EnablePinIT(uint16_t DeviceAddr, uint32_t IO_Pin); -void stmpe1600_IO_DisablePinIT(uint16_t DeviceAddr, uint32_t IO_Pin); -uint32_t stmpe1600_IO_ITStatus(uint16_t DeviceAddr, uint32_t IO_Pin); -uint8_t stmpe1600_IO_ReadIT(uint16_t DeviceAddr, uint32_t IO_Pin); -void stmpe1600_IO_ClearIT(uint16_t DeviceAddr, uint32_t IO_Pin); -void stmpe1600_Start(uint16_t DeviceAddr, uint32_t IO_Pin); - -void IOE_Init(void); -void IOE_ITConfig (void); -void IOE_Delay(uint32_t delay); -void IOE_Write(uint8_t addr, uint8_t reg, uint8_t value); -uint8_t IOE_Read(uint8_t addr, uint8_t reg); -uint16_t IOE_ReadMultiple(uint8_t addr, uint8_t reg, uint8_t *buffer, uint16_t length); -void IOE_WriteMultiple(uint8_t addr, uint8_t reg, uint8_t *buffer, uint16_t length); - -/* STMPE1600 driver structure */ -extern IO_DrvTypeDef stmpe1600_io_drv; - - -#ifdef __cplusplus -} -#endif -#endif /* __STMPE1600_H */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/stmpe811/Release_Notes.html b/bsp/stm32f411RE/Libraries/BSP/Components/stmpe811/Release_Notes.html deleted file mode 100644 index 75ed36ca8a..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/stmpe811/Release_Notes.html +++ /dev/null @@ -1,378 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - Release Notes for STMPE811 Component Driver - - - - - - - - - - -
-


-

-
- - - - - - -
- - - - - - - - - -
-

Back to Release page

-
- -

Release -Notes for STMPE811 Component Driver

- -

Copyright -2014 STMicroelectronics

-

-
-

 

- - - - - - -
- - -

Update History

-

V2.0.0 / 15-December-2014

- - - - - - - - - - - - -

Main -Changes

- - - - - - - - - - -
    -
  • All functions: update IO_Pin parameter to uint32_t instead of uint16_t
  • Add a return valud for stmpe811_IO_Config() function
  • Important Note: This new version V2.0.0 break the compatibility with V1.0.2, and it need to be used with STM32Cube BSP Common V2.0.0

V1.0.2 / 02-December-2014

- - - - - - - - - - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  • stmpe811.h: change "\" by "/" in the include path to fix compilation issue under Linux
    -
- -

V1.0.1 / 11-November-2014

- - - - - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- - - - - - - - - -
  • Fix limitation related to the selection of alternate function for TS physical IO
    -
  • Fix wrong pins definition of the TS
  • Swap implementation of stmpe811_IO_EnableAF() and stmpe811_IO_DisableAF() functions
    -
  • Miscellaneous code cleanup of comments update
    -
- -

V1.0.0 / 18-February-2014

- - - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  •  First official release
  • -

License

-
-Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met:
-
-
  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions -in binary form must reproduce the above copyright notice, this list of -conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of STMicroelectronics nor the names of its contributors may be used to endorse or promote products derived
    -
    -
-        from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- -
-

- - -
-
-

For -complete documentation on STM32 Microcontrollers -visit www.st.com/STM32

-
-

-
-
-

 

-
- - \ No newline at end of file diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/stmpe811/stmpe811.c b/bsp/stm32f411RE/Libraries/BSP/Components/stmpe811/stmpe811.c deleted file mode 100644 index 325b858fb1..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/stmpe811/stmpe811.c +++ /dev/null @@ -1,977 +0,0 @@ -/** - ****************************************************************************** - * @file stmpe811.c - * @author MCD Application Team - * @version V2.0.0 - * @date 15-December-2014 - * @brief This file provides a set of functions needed to manage the STMPE811 - * IO Expander devices. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2014 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Includes ------------------------------------------------------------------*/ -#include "stmpe811.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup Components - * @{ - */ - -/** @defgroup STMPE811 - * @{ - */ - -/** @defgroup STMPE811_Private_Types_Definitions - * @{ - */ - -/** @defgroup STMPE811_Private_Defines - * @{ - */ -#define STMPE811_MAX_INSTANCE 2 -/** - * @} - */ - -/** @defgroup STMPE811_Private_Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STMPE811_Private_Variables - * @{ - */ - -/* Touch screen driver structure initialization */ -TS_DrvTypeDef stmpe811_ts_drv = -{ - stmpe811_Init, - stmpe811_ReadID, - stmpe811_Reset, - stmpe811_TS_Start, - stmpe811_TS_DetectTouch, - stmpe811_TS_GetXY, - stmpe811_TS_EnableIT, - stmpe811_TS_ClearIT, - stmpe811_TS_ITStatus, - stmpe811_TS_DisableIT, -}; - -/* IO driver structure initialization */ -IO_DrvTypeDef stmpe811_io_drv = -{ - stmpe811_Init, - stmpe811_ReadID, - stmpe811_Reset, - stmpe811_IO_Start, - stmpe811_IO_Config, - stmpe811_IO_WritePin, - stmpe811_IO_ReadPin, - stmpe811_IO_EnableIT, - stmpe811_IO_DisableIT, - stmpe811_IO_ITStatus, - stmpe811_IO_ClearIT, -}; - -/* stmpe811 instances by address */ -uint8_t stmpe811[STMPE811_MAX_INSTANCE] = {0}; -/** - * @} - */ - -/** @defgroup STMPE811_Private_Function_Prototypes - * @{ - */ -static uint8_t stmpe811_GetInstance(uint16_t DeviceAddr); -/** - * @} - */ - -/** @defgroup STMPE811_Private_Functions - * @{ - */ - -/** - * @brief Initialize the stmpe811 and configure the needed hardware resources - * @param DeviceAddr: Device address on communication Bus. - * @retval None - */ -void stmpe811_Init(uint16_t DeviceAddr) -{ - uint8_t instance; - uint8_t empty; - - /* Check if device instance already exists */ - instance = stmpe811_GetInstance(DeviceAddr); - - /* To prevent double initialization */ - if(instance == 0xFF) - { - /* Look for empty instance */ - empty = stmpe811_GetInstance(0); - - if(empty < STMPE811_MAX_INSTANCE) - { - /* Register the current device instance */ - stmpe811[empty] = DeviceAddr; - - /* Initialize IO BUS layer */ - IOE_Init(); - - /* Generate stmpe811 Software reset */ - stmpe811_Reset(DeviceAddr); - } - } -} - -/** - * @brief Reset the stmpe811 by Software. - * @param DeviceAddr: Device address on communication Bus. - * @retval None - */ -void stmpe811_Reset(uint16_t DeviceAddr) -{ - /* Power Down the stmpe811 */ - IOE_Write(DeviceAddr, STMPE811_REG_SYS_CTRL1, 2); - - /* Wait for a delay to ensure registers erasing */ - IOE_Delay(10); - - /* Power On the Codec after the power off => all registers are reinitialized */ - IOE_Write(DeviceAddr, STMPE811_REG_SYS_CTRL1, 0); - - /* Wait for a delay to ensure registers erasing */ - IOE_Delay(2); -} - -/** - * @brief Read the stmpe811 IO Expander device ID. - * @param DeviceAddr: Device address on communication Bus. - * @retval The Device ID (two bytes). - */ -uint16_t stmpe811_ReadID(uint16_t DeviceAddr) -{ - /* Initialize IO BUS layer */ - IOE_Init(); - - /* Return the device ID value */ - return ((IOE_Read(DeviceAddr, STMPE811_REG_CHP_ID_LSB) << 8) |\ - (IOE_Read(DeviceAddr, STMPE811_REG_CHP_ID_MSB))); -} - -/** - * @brief Enable the Global interrupt. - * @param DeviceAddr: Device address on communication Bus. - * @retval None - */ -void stmpe811_EnableGlobalIT(uint16_t DeviceAddr) -{ - uint8_t tmp = 0; - - /* Read the Interrupt Control register */ - tmp = IOE_Read(DeviceAddr, STMPE811_REG_INT_CTRL); - - /* Set the global interrupts to be Enabled */ - tmp |= (uint8_t)STMPE811_GIT_EN; - - /* Write Back the Interrupt Control register */ - IOE_Write(DeviceAddr, STMPE811_REG_INT_CTRL, tmp); -} - -/** - * @brief Disable the Global interrupt. - * @param DeviceAddr: Device address on communication Bus. - * @retval None - */ -void stmpe811_DisableGlobalIT(uint16_t DeviceAddr) -{ - uint8_t tmp = 0; - - /* Read the Interrupt Control register */ - tmp = IOE_Read(DeviceAddr, STMPE811_REG_INT_CTRL); - - /* Set the global interrupts to be Disabled */ - tmp &= ~(uint8_t)STMPE811_GIT_EN; - - /* Write Back the Interrupt Control register */ - IOE_Write(DeviceAddr, STMPE811_REG_INT_CTRL, tmp); - -} - -/** - * @brief Enable the interrupt mode for the selected IT source - * @param DeviceAddr: Device address on communication Bus. - * @param Source: The interrupt source to be configured, could be: - * @arg STMPE811_GIT_IO: IO interrupt - * @arg STMPE811_GIT_ADC : ADC interrupt - * @arg STMPE811_GIT_FE : Touch Screen Controller FIFO Error interrupt - * @arg STMPE811_GIT_FF : Touch Screen Controller FIFO Full interrupt - * @arg STMPE811_GIT_FOV : Touch Screen Controller FIFO Overrun interrupt - * @arg STMPE811_GIT_FTH : Touch Screen Controller FIFO Threshold interrupt - * @arg STMPE811_GIT_TOUCH : Touch Screen Controller Touch Detected interrupt - * @retval None - */ -void stmpe811_EnableITSource(uint16_t DeviceAddr, uint8_t Source) -{ - uint8_t tmp = 0; - - /* Get the current value of the INT_EN register */ - tmp = IOE_Read(DeviceAddr, STMPE811_REG_INT_EN); - - /* Set the interrupts to be Enabled */ - tmp |= Source; - - /* Set the register */ - IOE_Write(DeviceAddr, STMPE811_REG_INT_EN, tmp); -} - -/** - * @brief Disable the interrupt mode for the selected IT source - * @param DeviceAddr: Device address on communication Bus. - * @param Source: The interrupt source to be configured, could be: - * @arg STMPE811_GIT_IO: IO interrupt - * @arg STMPE811_GIT_ADC : ADC interrupt - * @arg STMPE811_GIT_FE : Touch Screen Controller FIFO Error interrupt - * @arg STMPE811_GIT_FF : Touch Screen Controller FIFO Full interrupt - * @arg STMPE811_GIT_FOV : Touch Screen Controller FIFO Overrun interrupt - * @arg STMPE811_GIT_FTH : Touch Screen Controller FIFO Threshold interrupt - * @arg STMPE811_GIT_TOUCH : Touch Screen Controller Touch Detected interrupt - * @retval None - */ -void stmpe811_DisableITSource(uint16_t DeviceAddr, uint8_t Source) -{ - uint8_t tmp = 0; - - /* Get the current value of the INT_EN register */ - tmp = IOE_Read(DeviceAddr, STMPE811_REG_INT_EN); - - /* Set the interrupts to be Enabled */ - tmp &= ~Source; - - /* Set the register */ - IOE_Write(DeviceAddr, STMPE811_REG_INT_EN, tmp); -} - -/** - * @brief Set the global interrupt Polarity. - * @param DeviceAddr: Device address on communication Bus. - * @param Polarity: the IT mode polarity, could be one of the following values: - * @arg STMPE811_POLARITY_LOW: Interrupt line is active Low/Falling edge - * @arg STMPE811_POLARITY_HIGH: Interrupt line is active High/Rising edge - * @retval None - */ -void stmpe811_SetITPolarity(uint16_t DeviceAddr, uint8_t Polarity) -{ - uint8_t tmp = 0; - - /* Get the current register value */ - tmp = IOE_Read(DeviceAddr, STMPE811_REG_INT_CTRL); - - /* Mask the polarity bits */ - tmp &= ~(uint8_t)0x04; - - /* Modify the Interrupt Output line configuration */ - tmp |= Polarity; - - /* Set the new register value */ - IOE_Write(DeviceAddr, STMPE811_REG_INT_CTRL, tmp); - -} - -/** - * @brief Set the global interrupt Type. - * @param DeviceAddr: Device address on communication Bus. - * @param Type: Interrupt line activity type, could be one of the following values: - * @arg STMPE811_TYPE_LEVEL: Interrupt line is active in level model - * @arg STMPE811_TYPE_EDGE: Interrupt line is active in edge model - * @retval None - */ -void stmpe811_SetITType(uint16_t DeviceAddr, uint8_t Type) -{ - uint8_t tmp = 0; - - /* Get the current register value */ - tmp = IOE_Read(DeviceAddr, STMPE811_REG_INT_CTRL); - - /* Mask the type bits */ - tmp &= ~(uint8_t)0x02; - - /* Modify the Interrupt Output line configuration */ - tmp |= Type; - - /* Set the new register value */ - IOE_Write(DeviceAddr, STMPE811_REG_INT_CTRL, tmp); - -} - -/** - * @brief Check the selected Global interrupt source pending bit - * @param DeviceAddr: Device address on communication Bus. - * @param Source: the Global interrupt source to be checked, could be: - * @arg STMPE811_GIT_IO: IO interrupt - * @arg STMPE811_GIT_ADC : ADC interrupt - * @arg STMPE811_GIT_FE : Touch Screen Controller FIFO Error interrupt - * @arg STMPE811_GIT_FF : Touch Screen Controller FIFO Full interrupt - * @arg STMPE811_GIT_FOV : Touch Screen Controller FIFO Overrun interrupt - * @arg STMPE811_GIT_FTH : Touch Screen Controller FIFO Threshold interrupt - * @arg STMPE811_GIT_TOUCH : Touch Screen Controller Touch Detected interrupt - * @retval The checked Global interrupt source status. - */ -uint8_t stmpe811_GlobalITStatus(uint16_t DeviceAddr, uint8_t Source) -{ - /* Return the global IT source status */ - return((IOE_Read(DeviceAddr, STMPE811_REG_INT_STA) & Source) == Source); -} - -/** - * @brief Return the Global interrupts status - * @param DeviceAddr: Device address on communication Bus. - * @param Source: the Global interrupt source to be checked, could be: - * @arg STMPE811_GIT_IO: IO interrupt - * @arg STMPE811_GIT_ADC : ADC interrupt - * @arg STMPE811_GIT_FE : Touch Screen Controller FIFO Error interrupt - * @arg STMPE811_GIT_FF : Touch Screen Controller FIFO Full interrupt - * @arg STMPE811_GIT_FOV : Touch Screen Controller FIFO Overrun interrupt - * @arg STMPE811_GIT_FTH : Touch Screen Controller FIFO Threshold interrupt - * @arg STMPE811_GIT_TOUCH : Touch Screen Controller Touch Detected interrupt - * @retval The checked Global interrupt source status. - */ -uint8_t stmpe811_ReadGITStatus(uint16_t DeviceAddr, uint8_t Source) -{ - /* Return the global IT source status */ - return((IOE_Read(DeviceAddr, STMPE811_REG_INT_STA) & Source)); -} - -/** - * @brief Clear the selected Global interrupt pending bit(s) - * @param DeviceAddr: Device address on communication Bus. - * @param Source: the Global interrupt source to be cleared, could be any combination - * of the following values: - * @arg STMPE811_GIT_IO: IO interrupt - * @arg STMPE811_GIT_ADC : ADC interrupt - * @arg STMPE811_GIT_FE : Touch Screen Controller FIFO Error interrupt - * @arg STMPE811_GIT_FF : Touch Screen Controller FIFO Full interrupt - * @arg STMPE811_GIT_FOV : Touch Screen Controller FIFO Overrun interrupt - * @arg STMPE811_GIT_FTH : Touch Screen Controller FIFO Threshold interrupt - * @arg STMPE811_GIT_TOUCH : Touch Screen Controller Touch Detected interrupt - * @retval None - */ -void stmpe811_ClearGlobalIT(uint16_t DeviceAddr, uint8_t Source) -{ - /* Write 1 to the bits that have to be cleared */ - IOE_Write(DeviceAddr, STMPE811_REG_INT_STA, Source); -} - -/** - * @brief Start the IO functionality use and disable the AF for selected IO pin(s). - * @param DeviceAddr: Device address on communication Bus. - * @param IO_Pin: The IO pin(s) to put in AF. This parameter can be one - * of the following values: - * @arg STMPE811_PIN_x: where x can be from 0 to 7. - * @retval None - */ -void stmpe811_IO_Start(uint16_t DeviceAddr, uint32_t IO_Pin) -{ - uint8_t mode; - - /* Get the current register value */ - mode = IOE_Read(DeviceAddr, STMPE811_REG_SYS_CTRL2); - - /* Set the Functionalities to be Disabled */ - mode &= ~(STMPE811_IO_FCT | STMPE811_ADC_FCT); - - /* Write the new register value */ - IOE_Write(DeviceAddr, STMPE811_REG_SYS_CTRL2, mode); - - /* Disable AF for the selected IO pin(s) */ - stmpe811_IO_DisableAF(DeviceAddr, (uint8_t)IO_Pin); -} - -/** - * @brief Configures the IO pin(s) according to IO mode structure value. - * @param DeviceAddr: Device address on communication Bus. - * @param IO_Pin: The output pin to be set or reset. This parameter can be one - * of the following values: - * @arg STMPE811_PIN_x: where x can be from 0 to 7. - * @param IO_Mode: The IO pin mode to configure, could be one of the following values: - * @arg IO_MODE_INPUT - * @arg IO_MODE_OUTPUT - * @arg IO_MODE_IT_RISING_EDGE - * @arg IO_MODE_IT_FALLING_EDGE - * @arg IO_MODE_IT_LOW_LEVEL - * @arg IO_MODE_IT_HIGH_LEVEL - * @retval 0 if no error, IO_Mode if error - */ -uint8_t stmpe811_IO_Config(uint16_t DeviceAddr, uint32_t IO_Pin, IO_ModeTypedef IO_Mode) -{ - uint8_t error_code = 0; - - /* Configure IO pin according to selected IO mode */ - switch(IO_Mode) - { - case IO_MODE_INPUT: /* Input mode */ - stmpe811_IO_InitPin(DeviceAddr, IO_Pin, STMPE811_DIRECTION_IN); - break; - - case IO_MODE_OUTPUT: /* Output mode */ - stmpe811_IO_InitPin(DeviceAddr, IO_Pin, STMPE811_DIRECTION_OUT); - break; - - case IO_MODE_IT_RISING_EDGE: /* Interrupt rising edge mode */ - stmpe811_IO_EnableIT(DeviceAddr); - stmpe811_IO_EnablePinIT(DeviceAddr, IO_Pin); - stmpe811_IO_InitPin(DeviceAddr, IO_Pin, STMPE811_DIRECTION_IN); - stmpe811_SetITType(DeviceAddr, STMPE811_TYPE_EDGE); - stmpe811_IO_SetEdgeMode(DeviceAddr, IO_Pin, STMPE811_EDGE_RISING); - break; - - case IO_MODE_IT_FALLING_EDGE: /* Interrupt falling edge mode */ - stmpe811_IO_EnableIT(DeviceAddr); - stmpe811_IO_EnablePinIT(DeviceAddr, IO_Pin); - stmpe811_IO_InitPin(DeviceAddr, IO_Pin, STMPE811_DIRECTION_IN); - stmpe811_SetITType(DeviceAddr, STMPE811_TYPE_EDGE); - stmpe811_IO_SetEdgeMode(DeviceAddr, IO_Pin, STMPE811_EDGE_FALLING); - break; - - case IO_MODE_IT_LOW_LEVEL: /* Low level interrupt mode */ - stmpe811_IO_EnableIT(DeviceAddr); - stmpe811_IO_EnablePinIT(DeviceAddr, IO_Pin); - stmpe811_IO_InitPin(DeviceAddr, IO_Pin, STMPE811_DIRECTION_IN); - stmpe811_SetITType(DeviceAddr, STMPE811_TYPE_LEVEL); - stmpe811_SetITPolarity(DeviceAddr, STMPE811_POLARITY_LOW); - break; - - case IO_MODE_IT_HIGH_LEVEL: /* High level interrupt mode */ - stmpe811_IO_EnableIT(DeviceAddr); - stmpe811_IO_EnablePinIT(DeviceAddr, IO_Pin); - stmpe811_IO_InitPin(DeviceAddr, IO_Pin, STMPE811_DIRECTION_IN); - stmpe811_SetITType(DeviceAddr, STMPE811_TYPE_LEVEL); - stmpe811_SetITPolarity(DeviceAddr, STMPE811_POLARITY_HIGH); - break; - - default: - error_code = (uint8_t) IO_Mode; - break; - } - return error_code; -} - -/** - * @brief Initialize the selected IO pin direction. - * @param DeviceAddr: Device address on communication Bus. - * @param IO_Pin: The IO pin to be configured. This parameter could be any - * combination of the following values: - * @arg STMPE811_PIN_x: Where x can be from 0 to 7. - * @param Direction: could be STMPE811_DIRECTION_IN or STMPE811_DIRECTION_OUT. - * @retval None - */ -void stmpe811_IO_InitPin(uint16_t DeviceAddr, uint32_t IO_Pin, uint8_t Direction) -{ - uint8_t tmp = 0; - - /* Get all the Pins direction */ - tmp = IOE_Read(DeviceAddr, STMPE811_REG_IO_DIR); - - /* Set the selected pin direction */ - if (Direction != STMPE811_DIRECTION_IN) - { - tmp |= (uint8_t)IO_Pin; - } - else - { - tmp &= ~(uint8_t)IO_Pin; - } - - /* Write the register new value */ - IOE_Write(DeviceAddr, STMPE811_REG_IO_DIR, tmp); -} - -/** - * @brief Disable the AF for the selected IO pin(s). - * @param DeviceAddr: Device address on communication Bus. - * @param IO_Pin: The IO pin to be configured. This parameter could be any - * combination of the following values: - * @arg STMPE811_PIN_x: Where x can be from 0 to 7. - * @retval None - */ -void stmpe811_IO_DisableAF(uint16_t DeviceAddr, uint32_t IO_Pin) -{ - uint8_t tmp = 0; - - /* Get the current state of the IO_AF register */ - tmp = IOE_Read(DeviceAddr, STMPE811_REG_IO_AF); - - /* Enable the selected pins alternate function */ - tmp |= (uint8_t)IO_Pin; - - /* Write back the new value in IO AF register */ - IOE_Write(DeviceAddr, STMPE811_REG_IO_AF, tmp); - -} - -/** - * @brief Enable the AF for the selected IO pin(s). - * @param DeviceAddr: Device address on communication Bus. - * @param IO_Pin: The IO pin to be configured. This parameter could be any - * combination of the following values: - * @arg STMPE811_PIN_x: Where x can be from 0 to 7. - * @retval None - */ -void stmpe811_IO_EnableAF(uint16_t DeviceAddr, uint32_t IO_Pin) -{ - uint8_t tmp = 0; - - /* Get the current register value */ - tmp = IOE_Read(DeviceAddr, STMPE811_REG_IO_AF); - - /* Enable the selected pins alternate function */ - tmp &= ~(uint8_t)IO_Pin; - - /* Write back the new register value */ - IOE_Write(DeviceAddr, STMPE811_REG_IO_AF, tmp); -} - -/** - * @brief Configure the Edge for which a transition is detectable for the - * selected pin. - * @param DeviceAddr: Device address on communication Bus. - * @param IO_Pin: The IO pin to be configured. This parameter could be any - * combination of the following values: - * @arg STMPE811_PIN_x: Where x can be from 0 to 7. - * @param Edge: The edge which will be detected. This parameter can be one or - * a combination of following values: STMPE811_EDGE_FALLING and STMPE811_EDGE_RISING . - * @retval None - */ -void stmpe811_IO_SetEdgeMode(uint16_t DeviceAddr, uint32_t IO_Pin, uint8_t Edge) -{ - uint8_t tmp1 = 0, tmp2 = 0; - - /* Get the current registers values */ - tmp1 = IOE_Read(DeviceAddr, STMPE811_REG_IO_FE); - tmp2 = IOE_Read(DeviceAddr, STMPE811_REG_IO_RE); - - /* Disable the Falling Edge */ - tmp1 &= ~(uint8_t)IO_Pin; - - /* Disable the Falling Edge */ - tmp2 &= ~(uint8_t)IO_Pin; - - /* Enable the Falling edge if selected */ - if (Edge & STMPE811_EDGE_FALLING) - { - tmp1 |= (uint8_t)IO_Pin; - } - - /* Enable the Rising edge if selected */ - if (Edge & STMPE811_EDGE_RISING) - { - tmp2 |= (uint8_t)IO_Pin; - } - - /* Write back the new registers values */ - IOE_Write(DeviceAddr, STMPE811_REG_IO_FE, tmp1); - IOE_Write(DeviceAddr, STMPE811_REG_IO_RE, tmp2); -} - -/** - * @brief Write a new IO pin state. - * @param DeviceAddr: Device address on communication Bus. - * @param IO_Pin: The output pin to be set or reset. This parameter can be one - * of the following values: - * @arg STMPE811_PIN_x: where x can be from 0 to 7. - * @param PinState: The new IO pin state. - * @retval None - */ -void stmpe811_IO_WritePin(uint16_t DeviceAddr, uint32_t IO_Pin, uint8_t PinState) -{ - /* Apply the bit value to the selected pin */ - if (PinState != 0) - { - /* Set the register */ - IOE_Write(DeviceAddr, STMPE811_REG_IO_SET_PIN, (uint8_t)IO_Pin); - } - else - { - /* Set the register */ - IOE_Write(DeviceAddr, STMPE811_REG_IO_CLR_PIN, (uint8_t)IO_Pin); - } -} - -/** - * @brief Return the state of the selected IO pin(s). - * @param DeviceAddr: Device address on communication Bus. - * @param IO_Pin: The output pin to be set or reset. This parameter can be one - * of the following values: - * @arg STMPE811_PIN_x: where x can be from 0 to 7. - * @retval IO pin(s) state. - */ -uint32_t stmpe811_IO_ReadPin(uint16_t DeviceAddr, uint32_t IO_Pin) -{ - return((uint32_t)(IOE_Read(DeviceAddr, STMPE811_REG_IO_MP_STA) & (uint8_t)IO_Pin)); -} - -/** - * @brief Enable the global IO interrupt source. - * @param DeviceAddr: Device address on communication Bus. - * @retval None - */ -void stmpe811_IO_EnableIT(uint16_t DeviceAddr) -{ - IOE_ITConfig(); - - /* Enable global IO IT source */ - stmpe811_EnableITSource(DeviceAddr, STMPE811_GIT_IO); - - /* Enable global interrupt */ - stmpe811_EnableGlobalIT(DeviceAddr); -} - -/** - * @brief Disable the global IO interrupt source. - * @param DeviceAddr: Device address on communication Bus. - * @retval None - */ -void stmpe811_IO_DisableIT(uint16_t DeviceAddr) -{ - /* Disable the global interrupt */ - stmpe811_DisableGlobalIT(DeviceAddr); - - /* Disable global IO IT source */ - stmpe811_DisableITSource(DeviceAddr, STMPE811_GIT_IO); -} - -/** - * @brief Enable interrupt mode for the selected IO pin(s). - * @param DeviceAddr: Device address on communication Bus. - * @param IO_Pin: The IO interrupt to be enabled. This parameter could be any - * combination of the following values: - * @arg STMPE811_PIN_x: where x can be from 0 to 7. - * @retval None - */ -void stmpe811_IO_EnablePinIT(uint16_t DeviceAddr, uint32_t IO_Pin) -{ - uint8_t tmp = 0; - - /* Get the IO interrupt state */ - tmp = IOE_Read(DeviceAddr, STMPE811_REG_IO_INT_EN); - - /* Set the interrupts to be enabled */ - tmp |= (uint8_t)IO_Pin; - - /* Write the register new value */ - IOE_Write(DeviceAddr, STMPE811_REG_IO_INT_EN, tmp); -} - -/** - * @brief Disable interrupt mode for the selected IO pin(s). - * @param DeviceAddr: Device address on communication Bus. - * @param IO_Pin: The IO interrupt to be disabled. This parameter could be any - * combination of the following values: - * @arg STMPE811_PIN_x: where x can be from 0 to 7. - * @retval None - */ -void stmpe811_IO_DisablePinIT(uint16_t DeviceAddr, uint32_t IO_Pin) -{ - uint8_t tmp = 0; - - /* Get the IO interrupt state */ - tmp = IOE_Read(DeviceAddr, STMPE811_REG_IO_INT_EN); - - /* Set the interrupts to be Disabled */ - tmp &= ~(uint8_t)IO_Pin; - - /* Write the register new value */ - IOE_Write(DeviceAddr, STMPE811_REG_IO_INT_EN, tmp); -} - -/** - * @brief Check the status of the selected IO interrupt pending bit - * @param DeviceAddr: Device address on communication Bus. - * @param IO_Pin: The IO interrupt to be checked could be: - * @arg STMPE811_PIN_x Where x can be from 0 to 7. - * @retval Status of the checked IO pin(s). - */ -uint32_t stmpe811_IO_ITStatus(uint16_t DeviceAddr, uint32_t IO_Pin) -{ - /* Get the Interrupt status */ - return(IOE_Read(DeviceAddr, STMPE811_REG_IO_INT_STA) & (uint8_t)IO_Pin); -} - -/** - * @brief Clear the selected IO interrupt pending bit(s). - * @param DeviceAddr: Device address on communication Bus. - * @param IO_Pin: the IO interrupt to be cleared, could be: - * @arg STMPE811_PIN_x: Where x can be from 0 to 7. - * @retval None - */ -void stmpe811_IO_ClearIT(uint16_t DeviceAddr, uint32_t IO_Pin) -{ - /* Clear the global IO IT pending bit */ - stmpe811_ClearGlobalIT(DeviceAddr, STMPE811_GIT_IO); - - /* Clear the IO IT pending bit(s) */ - IOE_Write(DeviceAddr, STMPE811_REG_IO_INT_STA, (uint8_t)IO_Pin); - - /* Clear the Edge detection pending bit*/ - IOE_Write(DeviceAddr, STMPE811_REG_IO_ED, (uint8_t)IO_Pin); - - /* Clear the Rising edge pending bit */ - IOE_Write(DeviceAddr, STMPE811_REG_IO_RE, (uint8_t)IO_Pin); - - /* Clear the Falling edge pending bit */ - IOE_Write(DeviceAddr, STMPE811_REG_IO_FE, (uint8_t)IO_Pin); -} - -/** - * @brief Configures the touch Screen Controller (Single point detection) - * @param DeviceAddr: Device address on communication Bus. - * @retval None. - */ -void stmpe811_TS_Start(uint16_t DeviceAddr) -{ - uint8_t mode; - - /* Get the current register value */ - mode = IOE_Read(DeviceAddr, STMPE811_REG_SYS_CTRL2); - - /* Set the Functionalities to be Enabled */ - mode &= ~(STMPE811_IO_FCT); - - /* Write the new register value */ - IOE_Write(DeviceAddr, STMPE811_REG_SYS_CTRL2, mode); - - /* Select TSC pins in TSC alternate mode */ - stmpe811_IO_EnableAF(DeviceAddr, STMPE811_TOUCH_IO_ALL); - - /* Set the Functionalities to be Enabled */ - mode &= ~(STMPE811_TS_FCT | STMPE811_ADC_FCT); - - /* Set the new register value */ - IOE_Write(DeviceAddr, STMPE811_REG_SYS_CTRL2, mode); - - /* Select Sample Time, bit number and ADC Reference */ - IOE_Write(DeviceAddr, STMPE811_REG_ADC_CTRL1, 0x49); - - /* Wait for 2 ms */ - IOE_Delay(2); - - /* Select the ADC clock speed: 3.25 MHz */ - IOE_Write(DeviceAddr, STMPE811_REG_ADC_CTRL2, 0x01); - - /* Select 2 nF filter capacitor */ - /* Configuration: - - Touch average control : 4 samples - - Touch delay time : 500 uS - - Panel driver setting time: 500 uS - */ - IOE_Write(DeviceAddr, STMPE811_REG_TSC_CFG, 0x9A); - - /* Configure the Touch FIFO threshold: single point reading */ - IOE_Write(DeviceAddr, STMPE811_REG_FIFO_TH, 0x01); - - /* Clear the FIFO memory content. */ - IOE_Write(DeviceAddr, STMPE811_REG_FIFO_STA, 0x01); - - /* Put the FIFO back into operation mode */ - IOE_Write(DeviceAddr, STMPE811_REG_FIFO_STA, 0x00); - - /* Set the range and accuracy pf the pressure measurement (Z) : - - Fractional part :7 - - Whole part :1 - */ - IOE_Write(DeviceAddr, STMPE811_REG_TSC_FRACT_XYZ, 0x01); - - /* Set the driving capability (limit) of the device for TSC pins: 50mA */ - IOE_Write(DeviceAddr, STMPE811_REG_TSC_I_DRIVE, 0x01); - - /* Touch screen control configuration (enable TSC): - - No window tracking index - - XYZ acquisition mode - */ - IOE_Write(DeviceAddr, STMPE811_REG_TSC_CTRL, 0x01); - - /* Clear all the status pending bits if any */ - IOE_Write(DeviceAddr, STMPE811_REG_INT_STA, 0xFF); - - /* Wait for 2 ms delay */ - IOE_Delay(2); -} - -/** - * @brief Return if there is touch detected or not. - * @param DeviceAddr: Device address on communication Bus. - * @retval Touch detected state. - */ -uint8_t stmpe811_TS_DetectTouch(uint16_t DeviceAddr) -{ - uint8_t state; - uint8_t ret = 0; - - state = ((IOE_Read(DeviceAddr, STMPE811_REG_TSC_CTRL) & (uint8_t)STMPE811_TS_CTRL_STATUS) == (uint8_t)0x80); - - if(state > 0) - { - if(IOE_Read(DeviceAddr, STMPE811_REG_FIFO_SIZE) > 0) - { - ret = 1; - } - } - else - { - /* Reset FIFO */ - IOE_Write(DeviceAddr, STMPE811_REG_FIFO_STA, 0x01); - /* Enable the FIFO again */ - IOE_Write(DeviceAddr, STMPE811_REG_FIFO_STA, 0x00); - } - - return ret; -} - -/** - * @brief Get the touch screen X and Y positions values - * @param DeviceAddr: Device address on communication Bus. - * @param X: Pointer to X position value - * @param Y: Pointer to Y position value - * @retval None. - */ -void stmpe811_TS_GetXY(uint16_t DeviceAddr, uint16_t *X, uint16_t *Y) -{ - uint8_t dataXYZ[4]; - uint32_t uldataXYZ; - - IOE_ReadMultiple(DeviceAddr, STMPE811_REG_TSC_DATA_NON_INC, dataXYZ, sizeof(dataXYZ)) ; - - /* Calculate positions values */ - uldataXYZ = (dataXYZ[0] << 24)|(dataXYZ[1] << 16)|(dataXYZ[2] << 8)|(dataXYZ[3] << 0); - *X = (uldataXYZ >> 20) & 0x00000FFF; - *Y = (uldataXYZ >> 8) & 0x00000FFF; - - /* Reset FIFO */ - IOE_Write(DeviceAddr, STMPE811_REG_FIFO_STA, 0x01); - /* Enable the FIFO again */ - IOE_Write(DeviceAddr, STMPE811_REG_FIFO_STA, 0x00); -} - -/** - * @brief Configure the selected source to generate a global interrupt or not - * @param DeviceAddr: Device address on communication Bus. - * @retval None - */ -void stmpe811_TS_EnableIT(uint16_t DeviceAddr) -{ - IOE_ITConfig(); - - /* Enable global TS IT source */ - stmpe811_EnableITSource(DeviceAddr, STMPE811_TS_IT); - - /* Enable global interrupt */ - stmpe811_EnableGlobalIT(DeviceAddr); -} - -/** - * @brief Configure the selected source to generate a global interrupt or not - * @param DeviceAddr: Device address on communication Bus. - * @retval None - */ -void stmpe811_TS_DisableIT(uint16_t DeviceAddr) -{ - /* Disable global interrupt */ - stmpe811_DisableGlobalIT(DeviceAddr); - - /* Disable global TS IT source */ - stmpe811_DisableITSource(DeviceAddr, STMPE811_TS_IT); -} - -/** - * @brief Configure the selected source to generate a global interrupt or not - * @param DeviceAddr: Device address on communication Bus. - * @retval TS interrupts status - */ -uint8_t stmpe811_TS_ITStatus(uint16_t DeviceAddr) -{ - /* Return TS interrupts status */ - return(stmpe811_ReadGITStatus(DeviceAddr, STMPE811_TS_IT)); -} - -/** - * @brief Configure the selected source to generate a global interrupt or not - * @param DeviceAddr: Device address on communication Bus. - * @retval None - */ -void stmpe811_TS_ClearIT(uint16_t DeviceAddr) -{ - /* Clear the global TS IT source */ - stmpe811_ClearGlobalIT(DeviceAddr, STMPE811_TS_IT); -} - -/** - * @brief Check if the device instance of the selected address is already registered - * and return its index - * @param DeviceAddr: Device address on communication Bus. - * @retval Index of the device instance if registered, 0xFF if not. - */ -static uint8_t stmpe811_GetInstance(uint16_t DeviceAddr) -{ - uint8_t idx = 0; - - /* Check all the registered instances */ - for(idx = 0; idx < STMPE811_MAX_INSTANCE ; idx ++) - { - if(stmpe811[idx] == DeviceAddr) - { - return idx; - } - } - - return 0xFF; -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/stmpe811/stmpe811.h b/bsp/stm32f411RE/Libraries/BSP/Components/stmpe811/stmpe811.h deleted file mode 100644 index 0ef74f3696..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/stmpe811/stmpe811.h +++ /dev/null @@ -1,291 +0,0 @@ -/** - ****************************************************************************** - * @file stmpe811.h - * @author MCD Application Team - * @version V2.0.0 - * @date 15-December-2014 - * @brief This file contains all the functions prototypes for the - * stmpe811.c IO expander driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2014 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STMPE811_H -#define __STMPE811_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "../Common/ts.h" -#include "../Common/io.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup Components - * @{ - */ - -/** @defgroup STMPE811 - * @{ - */ - -/** @defgroup STMPE811_Exported_Types - * @{ - */ -/** - * @} - */ - -/** @defgroup STMPE811_Exported_Constants - * @{ - */ - -/* Chip IDs */ -#define STMPE811_ID 0x0811 - -/* Identification registers & System Control */ -#define STMPE811_REG_CHP_ID_LSB 0x00 -#define STMPE811_REG_CHP_ID_MSB 0x01 -#define STMPE811_REG_ID_VER 0x02 - -/* Global interrupt Enable bit */ -#define STMPE811_GIT_EN 0x01 - -/* IO expander functionalities */ -#define STMPE811_ADC_FCT 0x01 -#define STMPE811_TS_FCT 0x02 -#define STMPE811_IO_FCT 0x04 -#define STMPE811_TEMPSENS_FCT 0x08 - -/* Global Interrupts definitions */ -#define STMPE811_GIT_IO 0x80 /* IO interrupt */ -#define STMPE811_GIT_ADC 0x40 /* ADC interrupt */ -#define STMPE811_GIT_TEMP 0x20 /* Not implemented */ -#define STMPE811_GIT_FE 0x10 /* FIFO empty interrupt */ -#define STMPE811_GIT_FF 0x08 /* FIFO full interrupt */ -#define STMPE811_GIT_FOV 0x04 /* FIFO overflowed interrupt */ -#define STMPE811_GIT_FTH 0x02 /* FIFO above threshold interrupt */ -#define STMPE811_GIT_TOUCH 0x01 /* Touch is detected interrupt */ -#define STMPE811_ALL_GIT 0x1F /* All global interrupts */ -#define STMPE811_TS_IT (STMPE811_GIT_TOUCH | STMPE811_GIT_FTH | STMPE811_GIT_FOV | STMPE811_GIT_FF | STMPE811_GIT_FE) /* Touch screen interrupts */ - -/* General Control Registers */ -#define STMPE811_REG_SYS_CTRL1 0x03 -#define STMPE811_REG_SYS_CTRL2 0x04 -#define STMPE811_REG_SPI_CFG 0x08 - -/* Interrupt system Registers */ -#define STMPE811_REG_INT_CTRL 0x09 -#define STMPE811_REG_INT_EN 0x0A -#define STMPE811_REG_INT_STA 0x0B -#define STMPE811_REG_IO_INT_EN 0x0C -#define STMPE811_REG_IO_INT_STA 0x0D - -/* IO Registers */ -#define STMPE811_REG_IO_SET_PIN 0x10 -#define STMPE811_REG_IO_CLR_PIN 0x11 -#define STMPE811_REG_IO_MP_STA 0x12 -#define STMPE811_REG_IO_DIR 0x13 -#define STMPE811_REG_IO_ED 0x14 -#define STMPE811_REG_IO_RE 0x15 -#define STMPE811_REG_IO_FE 0x16 -#define STMPE811_REG_IO_AF 0x17 - -/* ADC Registers */ -#define STMPE811_REG_ADC_INT_EN 0x0E -#define STMPE811_REG_ADC_INT_STA 0x0F -#define STMPE811_REG_ADC_CTRL1 0x20 -#define STMPE811_REG_ADC_CTRL2 0x21 -#define STMPE811_REG_ADC_CAPT 0x22 -#define STMPE811_REG_ADC_DATA_CH0 0x30 -#define STMPE811_REG_ADC_DATA_CH1 0x32 -#define STMPE811_REG_ADC_DATA_CH2 0x34 -#define STMPE811_REG_ADC_DATA_CH3 0x36 -#define STMPE811_REG_ADC_DATA_CH4 0x38 -#define STMPE811_REG_ADC_DATA_CH5 0x3A -#define STMPE811_REG_ADC_DATA_CH6 0x3B -#define STMPE811_REG_ADC_DATA_CH7 0x3C - -/* Touch Screen Registers */ -#define STMPE811_REG_TSC_CTRL 0x40 -#define STMPE811_REG_TSC_CFG 0x41 -#define STMPE811_REG_WDM_TR_X 0x42 -#define STMPE811_REG_WDM_TR_Y 0x44 -#define STMPE811_REG_WDM_BL_X 0x46 -#define STMPE811_REG_WDM_BL_Y 0x48 -#define STMPE811_REG_FIFO_TH 0x4A -#define STMPE811_REG_FIFO_STA 0x4B -#define STMPE811_REG_FIFO_SIZE 0x4C -#define STMPE811_REG_TSC_DATA_X 0x4D -#define STMPE811_REG_TSC_DATA_Y 0x4F -#define STMPE811_REG_TSC_DATA_Z 0x51 -#define STMPE811_REG_TSC_DATA_XYZ 0x52 -#define STMPE811_REG_TSC_FRACT_XYZ 0x56 -#define STMPE811_REG_TSC_DATA_INC 0x57 -#define STMPE811_REG_TSC_DATA_NON_INC 0xD7 -#define STMPE811_REG_TSC_I_DRIVE 0x58 -#define STMPE811_REG_TSC_SHIELD 0x59 - -/* Touch Screen Pins definition */ -#define STMPE811_TOUCH_YD STMPE811_PIN_7 -#define STMPE811_TOUCH_XD STMPE811_PIN_6 -#define STMPE811_TOUCH_YU STMPE811_PIN_5 -#define STMPE811_TOUCH_XU STMPE811_PIN_4 -#define STMPE811_TOUCH_IO_ALL (uint32_t)(STMPE811_TOUCH_YD | STMPE811_TOUCH_XD | STMPE811_TOUCH_YU | STMPE811_TOUCH_XU) - -/* IO Pins definition */ -#define STMPE811_PIN_0 0x01 -#define STMPE811_PIN_1 0x02 -#define STMPE811_PIN_2 0x04 -#define STMPE811_PIN_3 0x08 -#define STMPE811_PIN_4 0x10 -#define STMPE811_PIN_5 0x20 -#define STMPE811_PIN_6 0x40 -#define STMPE811_PIN_7 0x80 -#define STMPE811_PIN_ALL 0xFF - -/* IO Pins directions */ -#define STMPE811_DIRECTION_IN 0x00 -#define STMPE811_DIRECTION_OUT 0x01 - -/* IO IT types */ -#define STMPE811_TYPE_LEVEL 0x00 -#define STMPE811_TYPE_EDGE 0x02 - -/* IO IT polarity */ -#define STMPE811_POLARITY_LOW 0x00 -#define STMPE811_POLARITY_HIGH 0x04 - -/* IO Pin IT edge modes */ -#define STMPE811_EDGE_FALLING 0x01 -#define STMPE811_EDGE_RISING 0x02 - -/* TS registers masks */ -#define STMPE811_TS_CTRL_ENABLE 0x01 -#define STMPE811_TS_CTRL_STATUS 0x80 -/** - * @} - */ - -/** @defgroup STMPE811_Exported_Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STMPE811_Exported_Functions - * @{ - */ - -/** - * @brief STMPE811 Control functions - */ -void stmpe811_Init(uint16_t DeviceAddr); -void stmpe811_Reset(uint16_t DeviceAddr); -uint16_t stmpe811_ReadID(uint16_t DeviceAddr); -void stmpe811_EnableGlobalIT(uint16_t DeviceAddr); -void stmpe811_DisableGlobalIT(uint16_t DeviceAddr); -void stmpe811_EnableITSource(uint16_t DeviceAddr, uint8_t Source); -void stmpe811_DisableITSource(uint16_t DeviceAddr, uint8_t Source); -void stmpe811_SetITPolarity(uint16_t DeviceAddr, uint8_t Polarity); -void stmpe811_SetITType(uint16_t DeviceAddr, uint8_t Type); -uint8_t stmpe811_GlobalITStatus(uint16_t DeviceAddr, uint8_t Source); -uint8_t stmpe811_ReadGITStatus(uint16_t DeviceAddr, uint8_t Source); -void stmpe811_ClearGlobalIT(uint16_t DeviceAddr, uint8_t Source); - -/** - * @brief STMPE811 IO functionalities functions - */ -void stmpe811_IO_Start(uint16_t DeviceAddr, uint32_t IO_Pin); -uint8_t stmpe811_IO_Config(uint16_t DeviceAddr, uint32_t IO_Pin, IO_ModeTypedef IO_Mode); -void stmpe811_IO_InitPin(uint16_t DeviceAddr, uint32_t IO_Pin, uint8_t Direction); -void stmpe811_IO_EnableAF(uint16_t DeviceAddr, uint32_t IO_Pin); -void stmpe811_IO_DisableAF(uint16_t DeviceAddr, uint32_t IO_Pin); -void stmpe811_IO_SetEdgeMode(uint16_t DeviceAddr, uint32_t IO_Pin, uint8_t Edge); -void stmpe811_IO_WritePin(uint16_t DeviceAddr, uint32_t IO_Pin, uint8_t PinState); -uint32_t stmpe811_IO_ReadPin(uint16_t DeviceAddr, uint32_t IO_Pin); -void stmpe811_IO_EnableIT(uint16_t DeviceAddr); -void stmpe811_IO_DisableIT(uint16_t DeviceAddr); -void stmpe811_IO_EnablePinIT(uint16_t DeviceAddr, uint32_t IO_Pin); -void stmpe811_IO_DisablePinIT(uint16_t DeviceAddr, uint32_t IO_Pin); -uint32_t stmpe811_IO_ITStatus(uint16_t DeviceAddr, uint32_t IO_Pin); -void stmpe811_IO_ClearIT(uint16_t DeviceAddr, uint32_t IO_Pin); - -/** - * @brief STMPE811 Touch screen functionalities functions - */ -void stmpe811_TS_Start(uint16_t DeviceAddr); -uint8_t stmpe811_TS_DetectTouch(uint16_t DeviceAddr); -void stmpe811_TS_GetXY(uint16_t DeviceAddr, uint16_t *X, uint16_t *Y); -void stmpe811_TS_EnableIT(uint16_t DeviceAddr); -void stmpe811_TS_DisableIT(uint16_t DeviceAddr); -uint8_t stmpe811_TS_ITStatus (uint16_t DeviceAddr); -void stmpe811_TS_ClearIT (uint16_t DeviceAddr); - -void IOE_Init(void); -void IOE_ITConfig (void); -void IOE_Delay(uint32_t delay); -void IOE_Write(uint8_t addr, uint8_t reg, uint8_t value); -uint8_t IOE_Read(uint8_t addr, uint8_t reg); -uint16_t IOE_ReadMultiple(uint8_t addr, uint8_t reg, uint8_t *buffer, uint16_t length); - -/* Touch screen driver structure */ -extern TS_DrvTypeDef stmpe811_ts_drv; - -/* IO driver structure */ -extern IO_DrvTypeDef stmpe811_io_drv; - -#ifdef __cplusplus -} -#endif -#endif /* __STMPE811_H */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/ts3510/Release_Notes.html b/bsp/stm32f411RE/Libraries/BSP/Components/ts3510/Release_Notes.html deleted file mode 100644 index 8ce574d061..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/ts3510/Release_Notes.html +++ /dev/null @@ -1,278 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - Release Notes for TS3510 Component Driver - - - - - - - - - -
-


-

-
- - - - - - -
- - - - - - - - - -
-

Back to Release page

-
-

Release -Notes for TS3510 Component Driver

-

Copyright 2014 STMicroelectronics

-

-
-

 

- - - - - - -
- - -

Update History

-

V1.0.1 / 02-December-2014

- - - - - - - - - - - - - - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- - - - - - - - - -
    -
  • ts3510.h: change "\" by "/" in the include path to fix compilation issue under Linux
  • -
- -

V1.0.0 / 18-February-2014

- - - - - - - - -

Main -Changes

- - - - - - - - - - - -

- - - - - - - - -
    -
  • First official release
  • -

License

-
-Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met:
-
-
  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions -in binary form must reproduce the above copyright notice, this list of -conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of STMicroelectronics nor the names of its contributors may be used to endorse or promote products derived
    -
    -
-        from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- -
-

- - -
-
-

For -complete documentation on STM32 Microcontrollers -visit www.st.com/STM32

-
-

-
-
-

 

-
- - \ No newline at end of file diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/ts3510/ts3510.c b/bsp/stm32f411RE/Libraries/BSP/Components/ts3510/ts3510.c deleted file mode 100644 index 2b671cce97..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/ts3510/ts3510.c +++ /dev/null @@ -1,256 +0,0 @@ -/** - ****************************************************************************** - * @file ts3510.c - * @author MCD Application Team - * @version V1.0.1 - * @date 02-December-2014 - * @brief This file provides a set of functions needed to manage the TS3510 - * IO Expander devices. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2014 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Includes ------------------------------------------------------------------*/ -#include "ts3510.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup Component - * @{ - */ - -/** @defgroup TS3510 - * @{ - */ - -/* Private typedef -----------------------------------------------------------*/ - -/** @defgroup TS3510_Private_Types_Definitions - * @{ - */ - -/* Private define ------------------------------------------------------------*/ - -/** @defgroup TS3510_Private_Defines - * @{ - */ - -/* Private macro -------------------------------------------------------------*/ - -/** @defgroup TS3510_Private_Macros - * @{ - */ - -/* Private variables ---------------------------------------------------------*/ - -/** @defgroup TS3510_Private_Variables - * @{ - */ - -/* Touch screen driver structure initialization */ -TS_DrvTypeDef ts3510_ts_drv = -{ - ts3510_Init, - ts3510_ReadID, - ts3510_Reset, - - ts3510_TS_Start, - ts3510_TS_DetectTouch, - ts3510_TS_GetXY, - - ts3510_TS_EnableIT, - ts3510_TS_ClearIT, - ts3510_TS_ITStatus, - ts3510_TS_DisableIT, -}; - -/** - * @} - */ - -/* Private function prototypes -----------------------------------------------*/ - -/** @defgroup ts3510_Private_Function_Prototypes - * @{ - */ - -/* Private functions ---------------------------------------------------------*/ - -/** @defgroup ts3510_Private_Functions - * @{ - */ - -/** - * @brief Initialize the ts3510 and configure the needed hardware resources - * @param DeviceAddr: Device address on communication Bus. - * @retval None - */ -void ts3510_Init(uint16_t DeviceAddr) -{ - /* Initialize IO BUS layer */ - IOE_Init(); - -} - -/** - * @brief Reset the ts3510 by Software. - * @param DeviceAddr: Device address on communication Bus. - * @retval None - */ -void ts3510_Reset(uint16_t DeviceAddr) -{ - -} - -/** - * @brief Read the ts3510 IO Expander device ID. - * @param DeviceAddr: Device address on communication Bus. - * @retval The Device ID (two bytes). - */ -uint16_t ts3510_ReadID(uint16_t DeviceAddr) -{ - return 0; -} - -/** - * @brief Configures the touch Screen Controller (Single point detection) - * @param DeviceAddr: Device address on communication Bus. - * @retval None. - */ -void ts3510_TS_Start(uint16_t DeviceAddr) -{ -} - -/** - * @brief Return if there is touch detected or not. - * @param DeviceAddr: Device address on communication Bus. - * @retval Touch detected state. - */ -uint8_t ts3510_TS_DetectTouch(uint16_t DeviceAddr) -{ - uint8_t aBufferTS[11]; - uint8_t aTmpBuffer[2] = {TS3510_READ_CMD, TS3510_WRITE_CMD}; - - /* Prepare for LCD read data */ - IOE_WriteMultiple(DeviceAddr, TS3510_SEND_CMD_REG, aTmpBuffer, 2); - - /* Read TS data from LCD */ - IOE_ReadMultiple(DeviceAddr, TS3510_READ_BLOCK_REG, aBufferTS, 11); - - /* check for first byte */ - if((aBufferTS[1] == 0xFF) && (aBufferTS[2] == 0xFF) && (aBufferTS[3] == 0xFF) && (aBufferTS[4] == 0xFF)) - { - return 0; - } - else - { - return 1; - } -} - -/** - * @brief Get the touch screen X and Y positions values - * @param DeviceAddr: Device address on communication Bus. - * @param X: Pointer to X position value - * @param Y: Pointer to Y position value - * @retval None. - */ -void ts3510_TS_GetXY(uint16_t DeviceAddr, uint16_t *X, uint16_t *Y) -{ - uint8_t aBufferTS[11]; - uint8_t aTmpBuffer[2] = {TS3510_READ_CMD, TS3510_WRITE_CMD}; - - /* Prepare for LCD read data */ - IOE_WriteMultiple(DeviceAddr, TS3510_SEND_CMD_REG, aTmpBuffer, 2); - - /* Read TS data from LCD */ - IOE_ReadMultiple(DeviceAddr, TS3510_READ_BLOCK_REG, aBufferTS, 11); - - /* Calculate positions */ - *X = (((aBufferTS[1] << 8) | aBufferTS[2]) << 12) / 640; - *Y = (((aBufferTS[3] << 8) | aBufferTS[4]) << 12) / 480; - - /* set position to be relative to 12bits resolution */ -} - -/** - * @brief Configure the selected source to generate a global interrupt or not - * @param DeviceAddr: Device address on communication Bus. - * @retval None - */ -void ts3510_TS_EnableIT(uint16_t DeviceAddr) -{ -} - -/** - * @brief Configure the selected source to generate a global interrupt or not - * @param DeviceAddr: Device address on communication Bus. - * @retval None - */ -void ts3510_TS_DisableIT(uint16_t DeviceAddr) -{ -} - -/** - * @brief Configure the selected source to generate a global interrupt or not - * @param DeviceAddr: Device address on communication Bus. - * @retval TS interrupts status - */ -uint8_t ts3510_TS_ITStatus(uint16_t DeviceAddr) -{ - return 0; -} - -/** - * @brief Configure the selected source to generate a global interrupt or not - * @param DeviceAddr: Device address on communication Bus. - * @retval None - */ -void ts3510_TS_ClearIT(uint16_t DeviceAddr) -{ -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/ts3510/ts3510.h b/bsp/stm32f411RE/Libraries/BSP/Components/ts3510/ts3510.h deleted file mode 100644 index 67cf1ef955..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/ts3510/ts3510.h +++ /dev/null @@ -1,141 +0,0 @@ -/** - ****************************************************************************** - * @file ts3510.h - * @author MCD Application Team - * @version V1.0.1 - * @date 02-December-2014 - * @brief This file contains all the functions prototypes for the - * ts3510.c IO expander driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2014 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __TS3510_H -#define __TS3510_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "../Common/ts.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup Component - * @{ - */ - -/** @defgroup TS3510 - * @{ - */ - -/* Exported types ------------------------------------------------------------*/ - -/** @defgroup TS3510_Exported_Types - * @{ - */ - -/* Exported constants --------------------------------------------------------*/ - -/** @defgroup TS3510_Exported_Constants - * @{ - */ - -/* */ -#define TS3510_READ_BLOCK_REG 0x8A -#define TS3510_SEND_CMD_REG 0x00 -#define TS3510_READ_CMD 0x81 -#define TS3510_WRITE_CMD 0x08 - - -/** - * @} - */ - -/* Exported macro ------------------------------------------------------------*/ - -/** @defgroup ts3510_Exported_Macros - * @{ - */ - -/* Exported functions --------------------------------------------------------*/ - -/** @defgroup ts3510_Exported_Functions - * @{ - */ - -/** - * @brief ts3510 Control functions - */ -void ts3510_Init(uint16_t DeviceAddr); -void ts3510_Reset(uint16_t DeviceAddr); -uint16_t ts3510_ReadID(uint16_t DeviceAddr); -void ts3510_TS_Start(uint16_t DeviceAddr); -uint8_t ts3510_TS_DetectTouch(uint16_t DeviceAddr); -void ts3510_TS_GetXY(uint16_t DeviceAddr, uint16_t *X, uint16_t *Y); -void ts3510_TS_EnableIT(uint16_t DeviceAddr); -void ts3510_TS_DisableIT(uint16_t DeviceAddr); -uint8_t ts3510_TS_ITStatus (uint16_t DeviceAddr); -void ts3510_TS_ClearIT (uint16_t DeviceAddr); - -void IOE_Init(void); -void IOE_Delay(uint32_t delay); -uint8_t IOE_Read(uint8_t addr, uint8_t reg); -uint16_t IOE_ReadMultiple(uint8_t addr, uint8_t reg, uint8_t *buffer, uint16_t length); -void IOE_WriteMultiple(uint8_t addr, uint8_t reg, uint8_t *buffer, uint16_t length); - -/* Touch screen driver structure */ -extern TS_DrvTypeDef ts3510_ts_drv; - -#ifdef __cplusplus -} -#endif -#endif /* __TS3510_H */ - - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/wm8994/Release_Notes.html b/bsp/stm32f411RE/Libraries/BSP/Components/wm8994/Release_Notes.html deleted file mode 100644 index 1a3f72eedf..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/wm8994/Release_Notes.html +++ /dev/null @@ -1,238 +0,0 @@ - - - - - - - - - - - - - - - - - - - - Release Notes for WM8994 Component Driver - - - - - - - - - - -
-


-

-
- - - - - - -
- - - - - - - - - -
-

Back to Release page

-
-

Release -Notes for WM8994 Component Driver

-

Copyright 2015 STMicroelectronics

-

-
-

 

- - - - - - -
- - -

Update History

- - - - - -

V2.0.0 / 24-June-2015

- - - - - - - -

Main -Changes

- - - - - - - - - - -
  • wm8994.h: 
    • Add codec de-initialization function: wm8994_DeInit()
    • Add Audio IO de-initialization function prototype: AUDIO_IO_DeInit()
    • Add INPUT_DEVICE_INPUT_LINE_1 and INPUT_DEVICE_INPUT_LINE_1 support for AUDIO IN
    • Add Input audio volume control support
  • wm8994.c: 
    • Update wm8994_Init() function to support the Audio IN
    • Update wm8994_Stop() function to only stop the codec if it was configured
    • Enable VMID_BUF_ENA bit in R57 ANTIPOP register (address 0x39) for all configurations
  • NOTE: This release must be used with BSP Common -driver V4.0.0 or later

V1.0.2 / 12-February-2015

- - - - - - - -

Main -Changes

- - - - - - - - - - -
  • wm8994.c: Update the wm8994_Init() function to set the volume after enabling the dynamic charge pump power control mode 

V1.0.1 / 28-November-2014

- - - - - - - -

Main -Changes

- - - - - - - - - - -
  • wm8994.h: change "\" by "/" in the include path to fix compilation issue with Linux

V1.0.0 / 18-February-2014

- - - - - - - -

Main -Changes

- - - - - - - - - - -
  • First official release
  • -

License

-
-Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met:
-
-
  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions -in binary form must reproduce the above copyright notice, this list of -conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of STMicroelectronics nor the names of its contributors may be used to endorse or promote products derived
    -
    -
-        from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- -
-

- - -
-
-

For -complete documentation on STM32 Microcontrollers -visit www.st.com/STM32

-
-

-
-
-

 

-
- - \ No newline at end of file diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/wm8994/wm8994.c b/bsp/stm32f411RE/Libraries/BSP/Components/wm8994/wm8994.c deleted file mode 100644 index 8b69fcfb97..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/wm8994/wm8994.c +++ /dev/null @@ -1,924 +0,0 @@ -/** - ****************************************************************************** - * @file wm8994.c - * @author MCD Application Team - * @version V2.0.0 - * @date 24-June-2015 - * @brief This file provides the WM8994 Audio Codec driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Includes ------------------------------------------------------------------*/ -#include "wm8994.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup Components - * @{ - */ - -/** @addtogroup wm8994 - * @brief This file provides a set of functions needed to drive the - * WM8994 audio codec. - * @{ - */ - -/** @defgroup WM8994_Private_Types - * @{ - */ - -/** - * @} - */ - -/** @defgroup WM8994_Private_Defines - * @{ - */ -/* Uncomment this line to enable verifying data sent to codec after each write - operation (for debug purpose) */ -#if !defined (VERIFY_WRITTENDATA) -/* #define VERIFY_WRITTENDATA */ -#endif /* VERIFY_WRITTENDATA */ -/** - * @} - */ - -/** @defgroup WM8994_Private_Macros - * @{ - */ - -/** - * @} - */ - -/** @defgroup WM8994_Private_Variables - * @{ - */ - -/* Audio codec driver structure initialization */ -AUDIO_DrvTypeDef wm8994_drv = -{ - wm8994_Init, - wm8994_DeInit, - wm8994_ReadID, - - wm8994_Play, - wm8994_Pause, - wm8994_Resume, - wm8994_Stop, - - wm8994_SetFrequency, - wm8994_SetVolume, - wm8994_SetMute, - wm8994_SetOutputMode, - - wm8994_Reset -}; - -static uint32_t outputEnabled = 0; -static uint32_t inputEnabled = 0; -/** - * @} - */ - -/** @defgroup WM8994_Function_Prototypes - * @{ - */ -static uint8_t CODEC_IO_Write(uint8_t Addr, uint16_t Reg, uint16_t Value); -/** - * @} - */ - -/** @defgroup WM8994_Private_Functions - * @{ - */ - -/** - * @brief Initializes the audio codec and the control interface. - * @param DeviceAddr: Device address on communication Bus. - * @param OutputInputDevice: can be OUTPUT_DEVICE_SPEAKER, OUTPUT_DEVICE_HEADPHONE, - * OUTPUT_DEVICE_BOTH, OUTPUT_DEVICE_AUTO, INPUT_DEVICE_DIGITAL_MICROPHONE_1, - * INPUT_DEVICE_DIGITAL_MICROPHONE_2, INPUT_DEVICE_INPUT_LINE_1 or INPUT_DEVICE_INPUT_LINE_2. - * @param Volume: Initial volume level (from 0 (Mute) to 100 (Max)) - * @param AudioFreq: Audio Frequency - * @retval 0 if correct communication, else wrong communication - */ -uint32_t wm8994_Init(uint16_t DeviceAddr, uint16_t OutputInputDevice, uint8_t Volume, uint32_t AudioFreq) -{ - uint32_t counter = 0; - uint16_t output_device = OutputInputDevice & 0xFF; - uint16_t input_device = OutputInputDevice & 0xFF00; - uint16_t power_mgnt_reg_1 = 0; - - /* Initialize the Control interface of the Audio Codec */ - AUDIO_IO_Init(); - /* wm8994 Errata Work-Arounds */ - counter += CODEC_IO_Write(DeviceAddr, 0x102, 0x0003); - counter += CODEC_IO_Write(DeviceAddr, 0x817, 0x0000); - counter += CODEC_IO_Write(DeviceAddr, 0x102, 0x0000); - - /* Enable VMID soft start (fast), Start-up Bias Current Enabled */ - counter += CODEC_IO_Write(DeviceAddr, 0x39, 0x006C); - - /* Enable bias generator, Enable VMID */ - counter += CODEC_IO_Write(DeviceAddr, 0x01, 0x0003); - - /* Add Delay */ - AUDIO_IO_Delay(50); - - /* Path Configurations for output */ - if (output_device > 0) - { - outputEnabled = 1; - switch (output_device) - { - case OUTPUT_DEVICE_SPEAKER: - /* Enable DAC1 (Left), Enable DAC1 (Right), - Disable DAC2 (Left), Disable DAC2 (Right)*/ - counter += CODEC_IO_Write(DeviceAddr, 0x05, 0x0C0C); - - /* Enable the AIF1 Timeslot 0 (Left) to DAC 1 (Left) mixer path */ - counter += CODEC_IO_Write(DeviceAddr, 0x601, 0x0000); - - /* Enable the AIF1 Timeslot 0 (Right) to DAC 1 (Right) mixer path */ - counter += CODEC_IO_Write(DeviceAddr, 0x602, 0x0000); - - /* Disable the AIF1 Timeslot 1 (Left) to DAC 2 (Left) mixer path */ - counter += CODEC_IO_Write(DeviceAddr, 0x604, 0x0002); - - /* Disable the AIF1 Timeslot 1 (Right) to DAC 2 (Right) mixer path */ - counter += CODEC_IO_Write(DeviceAddr, 0x605, 0x0002); - break; - - case OUTPUT_DEVICE_HEADPHONE: - /* Disable DAC1 (Left), Disable DAC1 (Right), - Enable DAC2 (Left), Enable DAC2 (Right)*/ - counter += CODEC_IO_Write(DeviceAddr, 0x05, 0x0303); - - /* Enable the AIF1 Timeslot 0 (Left) to DAC 1 (Left) mixer path */ - counter += CODEC_IO_Write(DeviceAddr, 0x601, 0x0001); - - /* Enable the AIF1 Timeslot 0 (Right) to DAC 1 (Right) mixer path */ - counter += CODEC_IO_Write(DeviceAddr, 0x602, 0x0001); - - /* Disable the AIF1 Timeslot 1 (Left) to DAC 2 (Left) mixer path */ - counter += CODEC_IO_Write(DeviceAddr, 0x604, 0x0000); - - /* Disable the AIF1 Timeslot 1 (Right) to DAC 2 (Right) mixer path */ - counter += CODEC_IO_Write(DeviceAddr, 0x605, 0x0000); - break; - - case OUTPUT_DEVICE_BOTH: - /* Enable DAC1 (Left), Enable DAC1 (Right), - also Enable DAC2 (Left), Enable DAC2 (Right)*/ - counter += CODEC_IO_Write(DeviceAddr, 0x05, 0x0303 | 0x0C0C); - - /* Enable the AIF1 Timeslot 0 (Left) to DAC 1 (Left) mixer path */ - counter += CODEC_IO_Write(DeviceAddr, 0x601, 0x0001); - - /* Enable the AIF1 Timeslot 0 (Right) to DAC 1 (Right) mixer path */ - counter += CODEC_IO_Write(DeviceAddr, 0x602, 0x0001); - - /* Enable the AIF1 Timeslot 1 (Left) to DAC 2 (Left) mixer path */ - counter += CODEC_IO_Write(DeviceAddr, 0x604, 0x0002); - - /* Enable the AIF1 Timeslot 1 (Right) to DAC 2 (Right) mixer path */ - counter += CODEC_IO_Write(DeviceAddr, 0x605, 0x0002); - break; - - case OUTPUT_DEVICE_AUTO : - default: - /* Disable DAC1 (Left), Disable DAC1 (Right), - Enable DAC2 (Left), Enable DAC2 (Right)*/ - counter += CODEC_IO_Write(DeviceAddr, 0x05, 0x0303); - - /* Enable the AIF1 Timeslot 0 (Left) to DAC 1 (Left) mixer path */ - counter += CODEC_IO_Write(DeviceAddr, 0x601, 0x0001); - - /* Enable the AIF1 Timeslot 0 (Right) to DAC 1 (Right) mixer path */ - counter += CODEC_IO_Write(DeviceAddr, 0x602, 0x0001); - - /* Disable the AIF1 Timeslot 1 (Left) to DAC 2 (Left) mixer path */ - counter += CODEC_IO_Write(DeviceAddr, 0x604, 0x0000); - - /* Disable the AIF1 Timeslot 1 (Right) to DAC 2 (Right) mixer path */ - counter += CODEC_IO_Write(DeviceAddr, 0x605, 0x0000); - break; - } - } - else - { - outputEnabled = 0; - } - - /* Path Configurations for input */ - if (input_device > 0) - { - inputEnabled = 1; - switch (input_device) - { - case INPUT_DEVICE_DIGITAL_MICROPHONE_2 : - /* Enable AIF1ADC2 (Left), Enable AIF1ADC2 (Right) - * Enable DMICDAT2 (Left), Enable DMICDAT2 (Right) - * Enable Left ADC, Enable Right ADC */ - counter += CODEC_IO_Write(DeviceAddr, 0x04, 0x0C30); - - /* Enable AIF1 DRC2 Signal Detect & DRC in AIF1ADC2 Left/Right Timeslot 1 */ - counter += CODEC_IO_Write(DeviceAddr, 0x450, 0x00DB); - - /* Disable IN1L, IN1R, IN2L, IN2R, Enable Thermal sensor & shutdown */ - counter += CODEC_IO_Write(DeviceAddr, 0x02, 0x6000); - - /* Enable the DMIC2(Left) to AIF1 Timeslot 1 (Left) mixer path */ - counter += CODEC_IO_Write(DeviceAddr, 0x608, 0x0002); - - /* Enable the DMIC2(Right) to AIF1 Timeslot 1 (Right) mixer path */ - counter += CODEC_IO_Write(DeviceAddr, 0x609, 0x0002); - - /* GPIO1 pin configuration GP1_DIR = output, GP1_FN = AIF1 DRC2 signal detect */ - counter += CODEC_IO_Write(DeviceAddr, 0x700, 0x000E); - break; - - case INPUT_DEVICE_INPUT_LINE_1 : - /* Enable AIF1ADC1 (Left), Enable AIF1ADC1 (Right) - * Enable Left ADC, Enable Right ADC */ - counter += CODEC_IO_Write(DeviceAddr, 0x04, 0x0303); - - /* Enable AIF1 DRC1 Signal Detect & DRC in AIF1ADC1 Left/Right Timeslot 0 */ - counter += CODEC_IO_Write(DeviceAddr, 0x440, 0x00DB); - - /* Enable IN1L and IN1R, Disable IN2L and IN2R, Enable Thermal sensor & shutdown */ - counter += CODEC_IO_Write(DeviceAddr, 0x02, 0x6350); - - /* Enable the ADCL(Left) to AIF1 Timeslot 0 (Left) mixer path */ - counter += CODEC_IO_Write(DeviceAddr, 0x606, 0x0002); - - /* Enable the ADCR(Right) to AIF1 Timeslot 0 (Right) mixer path */ - counter += CODEC_IO_Write(DeviceAddr, 0x607, 0x0002); - - /* GPIO1 pin configuration GP1_DIR = output, GP1_FN = AIF1 DRC1 signal detect */ - counter += CODEC_IO_Write(DeviceAddr, 0x700, 0x000D); - break; - - case INPUT_DEVICE_DIGITAL_MICROPHONE_1 : - case INPUT_DEVICE_INPUT_LINE_2 : - default: - /* Actually, no other input devices supported */ - counter++; - break; - } - } - else - { - inputEnabled = 0; - } - - /* Clock Configurations */ - switch (AudioFreq) - { - case AUDIO_FREQUENCY_8K: - /* AIF1 Sample Rate = 8 (KHz), ratio=256 */ - counter += CODEC_IO_Write(DeviceAddr, 0x210, 0x0003); - break; - - case AUDIO_FREQUENCY_16K: - /* AIF1 Sample Rate = 16 (KHz), ratio=256 */ - counter += CODEC_IO_Write(DeviceAddr, 0x210, 0x0033); - break; - - case AUDIO_FREQUENCY_48K: - /* AIF1 Sample Rate = 48 (KHz), ratio=256 */ - counter += CODEC_IO_Write(DeviceAddr, 0x210, 0x0083); - break; - - case AUDIO_FREQUENCY_96K: - /* AIF1 Sample Rate = 96 (KHz), ratio=256 */ - counter += CODEC_IO_Write(DeviceAddr, 0x210, 0x00A3); - break; - - case AUDIO_FREQUENCY_11K: - /* AIF1 Sample Rate = 11.025 (KHz), ratio=256 */ - counter += CODEC_IO_Write(DeviceAddr, 0x210, 0x0013); - break; - - case AUDIO_FREQUENCY_22K: - /* AIF1 Sample Rate = 22.050 (KHz), ratio=256 */ - counter += CODEC_IO_Write(DeviceAddr, 0x210, 0x0043); - break; - - case AUDIO_FREQUENCY_44K: - /* AIF1 Sample Rate = 44.1 (KHz), ratio=256 */ - counter += CODEC_IO_Write(DeviceAddr, 0x210, 0x0073); - break; - - default: - /* AIF1 Sample Rate = 48 (KHz), ratio=256 */ - counter += CODEC_IO_Write(DeviceAddr, 0x210, 0x0083); - break; - } - /* AIF1 Word Length = 16-bits, AIF1 Format = I2S (Default Register Value) */ - counter += CODEC_IO_Write(DeviceAddr, 0x300, 0x4010); - - /* slave mode */ - counter += CODEC_IO_Write(DeviceAddr, 0x302, 0x0000); - - /* Enable the DSP processing clock for AIF1, Enable the core clock */ - counter += CODEC_IO_Write(DeviceAddr, 0x208, 0x000A); - - /* Enable AIF1 Clock, AIF1 Clock Source = MCLK1 pin */ - counter += CODEC_IO_Write(DeviceAddr, 0x200, 0x0001); - - if (output_device > 0) /* Audio output selected */ - { - /* Analog Output Configuration */ - - /* Enable SPKRVOL PGA, Enable SPKMIXR, Enable SPKLVOL PGA, Enable SPKMIXL */ - counter += CODEC_IO_Write(DeviceAddr, 0x03, 0x0300); - - /* Left Speaker Mixer Volume = 0dB */ - counter += CODEC_IO_Write(DeviceAddr, 0x22, 0x0000); - - /* Speaker output mode = Class D, Right Speaker Mixer Volume = 0dB ((0x23, 0x0100) = class AB)*/ - counter += CODEC_IO_Write(DeviceAddr, 0x23, 0x0000); - - /* Unmute DAC2 (Left) to Left Speaker Mixer (SPKMIXL) path, - Unmute DAC2 (Right) to Right Speaker Mixer (SPKMIXR) path */ - counter += CODEC_IO_Write(DeviceAddr, 0x36, 0x0300); - - /* Enable bias generator, Enable VMID, Enable SPKOUTL, Enable SPKOUTR */ - counter += CODEC_IO_Write(DeviceAddr, 0x01, 0x3003); - - /* Headphone/Speaker Enable */ - - /* Enable Class W, Class W Envelope Tracking = AIF1 Timeslot 0 */ - counter += CODEC_IO_Write(DeviceAddr, 0x51, 0x0005); - - /* Enable bias generator, Enable VMID, Enable HPOUT1 (Left) and Enable HPOUT1 (Right) input stages */ - /* idem for Speaker */ - power_mgnt_reg_1 |= 0x0303 | 0x3003; - counter += CODEC_IO_Write(DeviceAddr, 0x01, power_mgnt_reg_1); - - /* Enable HPOUT1 (Left) and HPOUT1 (Right) intermediate stages */ - counter += CODEC_IO_Write(DeviceAddr, 0x60, 0x0022); - - /* Enable Charge Pump */ - counter += CODEC_IO_Write(DeviceAddr, 0x4C, 0x9F25); - - /* Add Delay */ - AUDIO_IO_Delay(15); - - /* Select DAC1 (Left) to Left Headphone Output PGA (HPOUT1LVOL) path */ - counter += CODEC_IO_Write(DeviceAddr, 0x2D, 0x0001); - - /* Select DAC1 (Right) to Right Headphone Output PGA (HPOUT1RVOL) path */ - counter += CODEC_IO_Write(DeviceAddr, 0x2E, 0x0001); - - /* Enable Left Output Mixer (MIXOUTL), Enable Right Output Mixer (MIXOUTR) */ - /* idem for SPKOUTL and SPKOUTR */ - counter += CODEC_IO_Write(DeviceAddr, 0x03, 0x0030 | 0x0300); - - /* Enable DC Servo and trigger start-up mode on left and right channels */ - counter += CODEC_IO_Write(DeviceAddr, 0x54, 0x0033); - - /* Add Delay */ - AUDIO_IO_Delay(250); - - /* Enable HPOUT1 (Left) and HPOUT1 (Right) intermediate and output stages. Remove clamps */ - counter += CODEC_IO_Write(DeviceAddr, 0x60, 0x00EE); - - /* Unmutes */ - - /* Unmute DAC 1 (Left) */ - counter += CODEC_IO_Write(DeviceAddr, 0x610, 0x00C0); - - /* Unmute DAC 1 (Right) */ - counter += CODEC_IO_Write(DeviceAddr, 0x611, 0x00C0); - - /* Unmute the AIF1 Timeslot 0 DAC path */ - counter += CODEC_IO_Write(DeviceAddr, 0x420, 0x0000); - - /* Unmute DAC 2 (Left) */ - counter += CODEC_IO_Write(DeviceAddr, 0x612, 0x00C0); - - /* Unmute DAC 2 (Right) */ - counter += CODEC_IO_Write(DeviceAddr, 0x613, 0x00C0); - - /* Unmute the AIF1 Timeslot 1 DAC2 path */ - counter += CODEC_IO_Write(DeviceAddr, 0x422, 0x0000); - - /* Volume Control */ - wm8994_SetVolume(DeviceAddr, Volume); - } - - if (input_device > 0) /* Audio input selected */ - { - if ((input_device == INPUT_DEVICE_DIGITAL_MICROPHONE_1) || (input_device == INPUT_DEVICE_DIGITAL_MICROPHONE_2)) - { - /* Enable Microphone bias 1 generator, Enable VMID */ - power_mgnt_reg_1 |= 0x0013; - counter += CODEC_IO_Write(DeviceAddr, 0x01, power_mgnt_reg_1); - - /* ADC oversample enable */ - counter += CODEC_IO_Write(DeviceAddr, 0x620, 0x0002); - - /* AIF ADC2 HPF enable, HPF cut = voice mode 1 fc=127Hz at fs=8kHz */ - counter += CODEC_IO_Write(DeviceAddr, 0x411, 0x3800); - } - else if ((input_device == INPUT_DEVICE_INPUT_LINE_1) || (input_device == INPUT_DEVICE_INPUT_LINE_2)) - { - /* Enable normal bias generator, Enable VMID */ - power_mgnt_reg_1 |= 0x0003; - counter += CODEC_IO_Write(DeviceAddr, 0x01, power_mgnt_reg_1); - - /* Disable mute on IN1L, IN1L Volume = +0dB */ - counter += CODEC_IO_Write(DeviceAddr, 0x18, 0x000B); - - /* Disable mute on IN1R, IN1R Volume = +0dB */ - counter += CODEC_IO_Write(DeviceAddr, 0x1A, 0x000B); - - /* Disable mute on IN1L_TO_MIXINL, Gain = +0dB */ - counter += CODEC_IO_Write(DeviceAddr, 0x29, 0x0025); - - /* Disable mute on IN1R_TO_MIXINL, Gain = +0dB */ - counter += CODEC_IO_Write(DeviceAddr, 0x2A, 0x0025); - - /* IN1LN_TO_IN1L, IN1LP_TO_VMID, IN1RN_TO_IN1R, IN1RP_TO_VMID */ - counter += CODEC_IO_Write(DeviceAddr, 0x28, 0x0011); - - /* AIF ADC1 HPF enable, HPF cut = hifi mode fc=4Hz at fs=48kHz */ - counter += CODEC_IO_Write(DeviceAddr, 0x410, 0x1800); - } - /* Volume Control */ - wm8994_SetVolume(DeviceAddr, Volume); - } - /* Return communication control value */ - return counter; -} - -/** - * @brief Deinitializes the audio codec. - * @param None - * @retval None - */ -void wm8994_DeInit(void) -{ - /* Deinitialize Audio Codec interface */ - AUDIO_IO_DeInit(); -} - -/** - * @brief Get the WM8994 ID. - * @param DeviceAddr: Device address on communication Bus. - * @retval The WM8994 ID - */ -uint32_t wm8994_ReadID(uint16_t DeviceAddr) -{ - /* Initialize the Control interface of the Audio Codec */ - AUDIO_IO_Init(); - - return ((uint32_t)AUDIO_IO_Read(DeviceAddr, WM8994_CHIPID_ADDR)); -} - -/** - * @brief Start the audio Codec play feature. - * @note For this codec no Play options are required. - * @param DeviceAddr: Device address on communication Bus. - * @retval 0 if correct communication, else wrong communication - */ -uint32_t wm8994_Play(uint16_t DeviceAddr, uint16_t* pBuffer, uint16_t Size) -{ - uint32_t counter = 0; - - /* Resumes the audio file playing */ - /* Unmute the output first */ - counter += wm8994_SetMute(DeviceAddr, AUDIO_MUTE_OFF); - - return counter; -} - -/** - * @brief Pauses playing on the audio codec. - * @param DeviceAddr: Device address on communication Bus. - * @retval 0 if correct communication, else wrong communication - */ -uint32_t wm8994_Pause(uint16_t DeviceAddr) -{ - uint32_t counter = 0; - - /* Pause the audio file playing */ - /* Mute the output first */ - counter += wm8994_SetMute(DeviceAddr, AUDIO_MUTE_ON); - - /* Put the Codec in Power save mode */ - counter += CODEC_IO_Write(DeviceAddr, 0x02, 0x01); - - return counter; -} - -/** - * @brief Resumes playing on the audio codec. - * @param DeviceAddr: Device address on communication Bus. - * @retval 0 if correct communication, else wrong communication - */ -uint32_t wm8994_Resume(uint16_t DeviceAddr) -{ - uint32_t counter = 0; - - /* Resumes the audio file playing */ - /* Unmute the output first */ - counter += wm8994_SetMute(DeviceAddr, AUDIO_MUTE_OFF); - - return counter; -} - -/** - * @brief Stops audio Codec playing. It powers down the codec. - * @param DeviceAddr: Device address on communication Bus. - * @param CodecPdwnMode: selects the power down mode. - * - CODEC_PDWN_SW: only mutes the audio codec. When resuming from this - * mode the codec keeps the previous initialization - * (no need to re-Initialize the codec registers). - * - CODEC_PDWN_HW: Physically power down the codec. When resuming from this - * mode, the codec is set to default configuration - * (user should re-Initialize the codec in order to - * play again the audio stream). - * @retval 0 if correct communication, else wrong communication - */ -uint32_t wm8994_Stop(uint16_t DeviceAddr, uint32_t CodecPdwnMode) -{ - uint32_t counter = 0; - - if (outputEnabled != 0) - { - /* Mute the output first */ - counter += wm8994_SetMute(DeviceAddr, AUDIO_MUTE_ON); - - if (CodecPdwnMode == CODEC_PDWN_SW) - { - /* Only output mute required*/ - } - else /* CODEC_PDWN_HW */ - { - /* Mute the AIF1 Timeslot 0 DAC1 path */ - counter += CODEC_IO_Write(DeviceAddr, 0x420, 0x0200); - - /* Mute the AIF1 Timeslot 1 DAC2 path */ - counter += CODEC_IO_Write(DeviceAddr, 0x422, 0x0200); - - /* Disable DAC1L_TO_HPOUT1L */ - counter += CODEC_IO_Write(DeviceAddr, 0x2D, 0x0000); - - /* Disable DAC1R_TO_HPOUT1R */ - counter += CODEC_IO_Write(DeviceAddr, 0x2E, 0x0000); - - /* Disable DAC1 and DAC2 */ - counter += CODEC_IO_Write(DeviceAddr, 0x05, 0x0000); - - /* Reset Codec by writing in 0x0000 address register */ - counter += CODEC_IO_Write(DeviceAddr, 0x0000, 0x0000); - - outputEnabled = 0; - } - } - return counter; -} - -/** - * @brief Sets higher or lower the codec volume level. - * @param DeviceAddr: Device address on communication Bus. - * @param Volume: a byte value from 0 to 255 (refer to codec registers - * description for more details). - * @retval 0 if correct communication, else wrong communication - */ -uint32_t wm8994_SetVolume(uint16_t DeviceAddr, uint8_t Volume) -{ - uint32_t counter = 0; - uint8_t convertedvol = VOLUME_CONVERT(Volume); - - /* Output volume */ - if (outputEnabled != 0) - { - if(convertedvol > 0x3E) - { - /* Unmute audio codec */ - counter += wm8994_SetMute(DeviceAddr, AUDIO_MUTE_OFF); - - /* Left Headphone Volume */ - counter += CODEC_IO_Write(DeviceAddr, 0x1C, 0x3F | 0x140); - - /* Right Headphone Volume */ - counter += CODEC_IO_Write(DeviceAddr, 0x1D, 0x3F | 0x140); - - /* Left Speaker Volume */ - counter += CODEC_IO_Write(DeviceAddr, 0x26, 0x3F | 0x140); - - /* Right Speaker Volume */ - counter += CODEC_IO_Write(DeviceAddr, 0x27, 0x3F | 0x140); - } - else if (Volume == 0) - { - /* Mute audio codec */ - counter += wm8994_SetMute(DeviceAddr, AUDIO_MUTE_ON); - } - else - { - /* Unmute audio codec */ - counter += wm8994_SetMute(DeviceAddr, AUDIO_MUTE_OFF); - - /* Left Headphone Volume */ - counter += CODEC_IO_Write(DeviceAddr, 0x1C, convertedvol | 0x140); - - /* Right Headphone Volume */ - counter += CODEC_IO_Write(DeviceAddr, 0x1D, convertedvol | 0x140); - - /* Left Speaker Volume */ - counter += CODEC_IO_Write(DeviceAddr, 0x26, convertedvol | 0x140); - - /* Right Speaker Volume */ - counter += CODEC_IO_Write(DeviceAddr, 0x27, convertedvol | 0x140); - } - } - - /* Input volume */ - if (inputEnabled != 0) - { - convertedvol = VOLUME_IN_CONVERT(Volume); - - /* Left AIF1 ADC1 volume */ - counter += CODEC_IO_Write(DeviceAddr, 0x400, convertedvol | 0x100); - - /* Right AIF1 ADC1 volume */ - counter += CODEC_IO_Write(DeviceAddr, 0x401, convertedvol | 0x100); - - /* Left AIF1 ADC2 volume */ - counter += CODEC_IO_Write(DeviceAddr, 0x404, convertedvol | 0x100); - - /* Right AIF1 ADC2 volume */ - counter += CODEC_IO_Write(DeviceAddr, 0x405, convertedvol | 0x100); - } - return counter; -} - -/** - * @brief Enables or disables the mute feature on the audio codec. - * @param DeviceAddr: Device address on communication Bus. - * @param Cmd: AUDIO_MUTE_ON to enable the mute or AUDIO_MUTE_OFF to disable the - * mute mode. - * @retval 0 if correct communication, else wrong communication - */ -uint32_t wm8994_SetMute(uint16_t DeviceAddr, uint32_t Cmd) -{ - uint32_t counter = 0; - - if (outputEnabled != 0) - { - /* Set the Mute mode */ - if(Cmd == AUDIO_MUTE_ON) - { - /* Soft Mute the AIF1 Timeslot 0 DAC1 path L&R */ - counter += CODEC_IO_Write(DeviceAddr, 0x420, 0x0200); - - /* Soft Mute the AIF1 Timeslot 1 DAC2 path L&R */ - counter += CODEC_IO_Write(DeviceAddr, 0x422, 0x0200); - } - else /* AUDIO_MUTE_OFF Disable the Mute */ - { - /* Unmute the AIF1 Timeslot 0 DAC1 path L&R */ - counter += CODEC_IO_Write(DeviceAddr, 0x420, 0x0000); - - /* Unmute the AIF1 Timeslot 1 DAC2 path L&R */ - counter += CODEC_IO_Write(DeviceAddr, 0x422, 0x0000); - } - } - return counter; -} - -/** - * @brief Switch dynamically (while audio file is played) the output target - * (speaker or headphone). - * @param DeviceAddr: Device address on communication Bus. - * @param Output: specifies the audio output target: OUTPUT_DEVICE_SPEAKER, - * OUTPUT_DEVICE_HEADPHONE, OUTPUT_DEVICE_BOTH or OUTPUT_DEVICE_AUTO - * @retval 0 if correct communication, else wrong communication - */ -uint32_t wm8994_SetOutputMode(uint16_t DeviceAddr, uint8_t Output) -{ - uint32_t counter = 0; - - switch (Output) - { - case OUTPUT_DEVICE_SPEAKER: - /* Enable DAC1 (Left), Enable DAC1 (Right), - Disable DAC2 (Left), Disable DAC2 (Right)*/ - counter += CODEC_IO_Write(DeviceAddr, 0x05, 0x0C0C); - - /* Enable the AIF1 Timeslot 0 (Left) to DAC 1 (Left) mixer path */ - counter += CODEC_IO_Write(DeviceAddr, 0x601, 0x0000); - - /* Enable the AIF1 Timeslot 0 (Right) to DAC 1 (Right) mixer path */ - counter += CODEC_IO_Write(DeviceAddr, 0x602, 0x0000); - - /* Disable the AIF1 Timeslot 1 (Left) to DAC 2 (Left) mixer path */ - counter += CODEC_IO_Write(DeviceAddr, 0x604, 0x0002); - - /* Disable the AIF1 Timeslot 1 (Right) to DAC 2 (Right) mixer path */ - counter += CODEC_IO_Write(DeviceAddr, 0x605, 0x0002); - break; - - case OUTPUT_DEVICE_HEADPHONE: - /* Disable DAC1 (Left), Disable DAC1 (Right), - Enable DAC2 (Left), Enable DAC2 (Right)*/ - counter += CODEC_IO_Write(DeviceAddr, 0x05, 0x0303); - - /* Enable the AIF1 Timeslot 0 (Left) to DAC 1 (Left) mixer path */ - counter += CODEC_IO_Write(DeviceAddr, 0x601, 0x0001); - - /* Enable the AIF1 Timeslot 0 (Right) to DAC 1 (Right) mixer path */ - counter += CODEC_IO_Write(DeviceAddr, 0x602, 0x0001); - - /* Disable the AIF1 Timeslot 1 (Left) to DAC 2 (Left) mixer path */ - counter += CODEC_IO_Write(DeviceAddr, 0x604, 0x0000); - - /* Disable the AIF1 Timeslot 1 (Right) to DAC 2 (Right) mixer path */ - counter += CODEC_IO_Write(DeviceAddr, 0x605, 0x0000); - break; - - case OUTPUT_DEVICE_BOTH: - /* Enable DAC1 (Left), Enable DAC1 (Right), - also Enable DAC2 (Left), Enable DAC2 (Right)*/ - counter += CODEC_IO_Write(DeviceAddr, 0x05, 0x0303 | 0x0C0C); - - /* Enable the AIF1 Timeslot 0 (Left) to DAC 1 (Left) mixer path */ - counter += CODEC_IO_Write(DeviceAddr, 0x601, 0x0001); - - /* Enable the AIF1 Timeslot 0 (Right) to DAC 1 (Right) mixer path */ - counter += CODEC_IO_Write(DeviceAddr, 0x602, 0x0001); - - /* Enable the AIF1 Timeslot 1 (Left) to DAC 2 (Left) mixer path */ - counter += CODEC_IO_Write(DeviceAddr, 0x604, 0x0002); - - /* Enable the AIF1 Timeslot 1 (Right) to DAC 2 (Right) mixer path */ - counter += CODEC_IO_Write(DeviceAddr, 0x605, 0x0002); - break; - - default: - /* Disable DAC1 (Left), Disable DAC1 (Right), - Enable DAC2 (Left), Enable DAC2 (Right)*/ - counter += CODEC_IO_Write(DeviceAddr, 0x05, 0x0303); - - /* Enable the AIF1 Timeslot 0 (Left) to DAC 1 (Left) mixer path */ - counter += CODEC_IO_Write(DeviceAddr, 0x601, 0x0001); - - /* Enable the AIF1 Timeslot 0 (Right) to DAC 1 (Right) mixer path */ - counter += CODEC_IO_Write(DeviceAddr, 0x602, 0x0001); - - /* Disable the AIF1 Timeslot 1 (Left) to DAC 2 (Left) mixer path */ - counter += CODEC_IO_Write(DeviceAddr, 0x604, 0x0000); - - /* Disable the AIF1 Timeslot 1 (Right) to DAC 2 (Right) mixer path */ - counter += CODEC_IO_Write(DeviceAddr, 0x605, 0x0000); - break; - } - return counter; -} - -/** - * @brief Sets new frequency. - * @param DeviceAddr: Device address on communication Bus. - * @param AudioFreq: Audio frequency used to play the audio stream. - * @retval 0 if correct communication, else wrong communication - */ -uint32_t wm8994_SetFrequency(uint16_t DeviceAddr, uint32_t AudioFreq) -{ - uint32_t counter = 0; - - /* Clock Configurations */ - switch (AudioFreq) - { - case AUDIO_FREQUENCY_8K: - /* AIF1 Sample Rate = 8 (KHz), ratio=256 */ - counter += CODEC_IO_Write(DeviceAddr, 0x210, 0x0003); - break; - - case AUDIO_FREQUENCY_16K: - /* AIF1 Sample Rate = 16 (KHz), ratio=256 */ - counter += CODEC_IO_Write(DeviceAddr, 0x210, 0x0033); - break; - - case AUDIO_FREQUENCY_48K: - /* AIF1 Sample Rate = 48 (KHz), ratio=256 */ - counter += CODEC_IO_Write(DeviceAddr, 0x210, 0x0083); - break; - - case AUDIO_FREQUENCY_96K: - /* AIF1 Sample Rate = 96 (KHz), ratio=256 */ - counter += CODEC_IO_Write(DeviceAddr, 0x210, 0x00A3); - break; - - case AUDIO_FREQUENCY_11K: - /* AIF1 Sample Rate = 11.025 (KHz), ratio=256 */ - counter += CODEC_IO_Write(DeviceAddr, 0x210, 0x0013); - break; - - case AUDIO_FREQUENCY_22K: - /* AIF1 Sample Rate = 22.050 (KHz), ratio=256 */ - counter += CODEC_IO_Write(DeviceAddr, 0x210, 0x0043); - break; - - case AUDIO_FREQUENCY_44K: - /* AIF1 Sample Rate = 44.1 (KHz), ratio=256 */ - counter += CODEC_IO_Write(DeviceAddr, 0x210, 0x0073); - break; - - default: - /* AIF1 Sample Rate = 48 (KHz), ratio=256 */ - counter += CODEC_IO_Write(DeviceAddr, 0x210, 0x0083); - break; - } - return counter; -} - -/** - * @brief Resets wm8994 registers. - * @param DeviceAddr: Device address on communication Bus. - * @retval 0 if correct communication, else wrong communication - */ -uint32_t wm8994_Reset(uint16_t DeviceAddr) -{ - uint32_t counter = 0; - - /* Reset Codec by writing in 0x0000 address register */ - counter = CODEC_IO_Write(DeviceAddr, 0x0000, 0x0000); - outputEnabled = 0; - inputEnabled=0; - - return counter; -} - -/** - * @brief Writes/Read a single data. - * @param Addr: I2C address - * @param Reg: Reg address - * @param Value: Data to be written - * @retval None - */ -static uint8_t CODEC_IO_Write(uint8_t Addr, uint16_t Reg, uint16_t Value) -{ - uint32_t result = 0; - - AUDIO_IO_Write(Addr, Reg, Value); - -#ifdef VERIFY_WRITTENDATA - /* Verify that the data has been correctly written */ - result = (AUDIO_IO_Read(Addr, Reg) == Value)? 0:1; -#endif /* VERIFY_WRITTENDATA */ - - return result; -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/Components/wm8994/wm8994.h b/bsp/stm32f411RE/Libraries/BSP/Components/wm8994/wm8994.h deleted file mode 100644 index 1099a946c8..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/Components/wm8994/wm8994.h +++ /dev/null @@ -1,187 +0,0 @@ -/** - ****************************************************************************** - * @file wm8994.h - * @author MCD Application Team - * @version V2.0.0 - * @date 24-June-2015 - * @brief This file contains all the functions prototypes for the - * wm8994.c driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __WM8994_H -#define __WM8994_H - -/* Includes ------------------------------------------------------------------*/ -#include "../Common/audio.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup Component - * @{ - */ - -/** @addtogroup WM8994 - * @{ - */ - -/** @defgroup WM8994_Exported_Types - * @{ - */ - -/** - * @} - */ - -/** @defgroup WM8994_Exported_Constants - * @{ - */ - -/******************************************************************************/ -/*************************** Codec User defines ******************************/ -/******************************************************************************/ -/* Codec output DEVICE */ -#define OUTPUT_DEVICE_SPEAKER ((uint16_t)0x0001) -#define OUTPUT_DEVICE_HEADPHONE ((uint16_t)0x0002) -#define OUTPUT_DEVICE_BOTH ((uint16_t)0x0003) -#define OUTPUT_DEVICE_AUTO ((uint16_t)0x0004) -#define INPUT_DEVICE_DIGITAL_MICROPHONE_1 ((uint16_t)0x0100) -#define INPUT_DEVICE_DIGITAL_MICROPHONE_2 ((uint16_t)0x0200) -#define INPUT_DEVICE_INPUT_LINE_1 ((uint16_t)0x0300) -#define INPUT_DEVICE_INPUT_LINE_2 ((uint16_t)0x0400) - -/* Volume Levels values */ -#define DEFAULT_VOLMIN 0x00 -#define DEFAULT_VOLMAX 0xFF -#define DEFAULT_VOLSTEP 0x04 - -#define AUDIO_PAUSE 0 -#define AUDIO_RESUME 1 - -/* Codec POWER DOWN modes */ -#define CODEC_PDWN_HW 1 -#define CODEC_PDWN_SW 2 - -/* MUTE commands */ -#define AUDIO_MUTE_ON 1 -#define AUDIO_MUTE_OFF 0 - -/* AUDIO FREQUENCY */ -#define AUDIO_FREQUENCY_192K ((uint32_t)192000) -#define AUDIO_FREQUENCY_96K ((uint32_t)96000) -#define AUDIO_FREQUENCY_48K ((uint32_t)48000) -#define AUDIO_FREQUENCY_44K ((uint32_t)44100) -#define AUDIO_FREQUENCY_32K ((uint32_t)32000) -#define AUDIO_FREQUENCY_22K ((uint32_t)22050) -#define AUDIO_FREQUENCY_16K ((uint32_t)16000) -#define AUDIO_FREQUENCY_11K ((uint32_t)11025) -#define AUDIO_FREQUENCY_8K ((uint32_t)8000) - -#define VOLUME_CONVERT(Volume) (((Volume) > 100)? 100:((uint8_t)(((Volume) * 63) / 100))) -#define VOLUME_IN_CONVERT(Volume) (((Volume) >= 100)? 239:((uint8_t)(((Volume) * 240) / 100))) - -/******************************************************************************/ -/****************************** REGISTER MAPPING ******************************/ -/******************************************************************************/ -/** - * @brief WM8994 ID - */ -#define WM8994_ID 0x8994 - -/** - * @brief Device ID Register: Reading from this register will indicate device - * family ID 8994h - */ -#define WM8994_CHIPID_ADDR 0x00 - -/** - * @} - */ - -/** @defgroup WM8994_Exported_Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup WM8994_Exported_Functions - * @{ - */ - -/*------------------------------------------------------------------------------ - Audio Codec functions -------------------------------------------------------------------------------*/ -/* High Layer codec functions */ -uint32_t wm8994_Init(uint16_t DeviceAddr, uint16_t OutputInputDevice, uint8_t Volume, uint32_t AudioFreq); -void wm8994_DeInit(void); -uint32_t wm8994_ReadID(uint16_t DeviceAddr); -uint32_t wm8994_Play(uint16_t DeviceAddr, uint16_t* pBuffer, uint16_t Size); -uint32_t wm8994_Pause(uint16_t DeviceAddr); -uint32_t wm8994_Resume(uint16_t DeviceAddr); -uint32_t wm8994_Stop(uint16_t DeviceAddr, uint32_t Cmd); -uint32_t wm8994_SetVolume(uint16_t DeviceAddr, uint8_t Volume); -uint32_t wm8994_SetMute(uint16_t DeviceAddr, uint32_t Cmd); -uint32_t wm8994_SetOutputMode(uint16_t DeviceAddr, uint8_t Output); -uint32_t wm8994_SetFrequency(uint16_t DeviceAddr, uint32_t AudioFreq); -uint32_t wm8994_Reset(uint16_t DeviceAddr); - -/* AUDIO IO functions */ -void AUDIO_IO_Init(void); -void AUDIO_IO_DeInit(void); -void AUDIO_IO_Write(uint8_t Addr, uint16_t Reg, uint16_t Value); -uint8_t AUDIO_IO_Read(uint8_t Addr, uint16_t Reg); -void AUDIO_IO_Delay(uint32_t Delay); - -/* Audio driver structure */ -extern AUDIO_DrvTypeDef wm8994_drv; - -#endif /* __WM8994_H */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/Release_Notes.html b/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/Release_Notes.html deleted file mode 100644 index 4ae02e4a78..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/Release_Notes.html +++ /dev/null @@ -1,171 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - Release Notes for STM32446E_EVAL Evaluation Board Drivers - - - - - - - - - - -
-


-

-
- - - - - - -
- - - - - - - - - -
-

Back to Release page

-
-

Release -Notes for STM32446E_EVAL Evaluation Board Drivers

-

Copyright -2015 STMicroelectronics

-

-
-

 

- - - - - - -
- - -

Update History

-

V1.1.0 / 14-August-2015

Main -Changes

- - - -
  • stm32446e_eval.c
    • Add AUDIO_IO_DeInit() function to align with BSP Components Common drivers V4.0.0
  • stm32446e_eval_audio.c
    • Reset audio codec before initialization

V1.0.0 / 11-March-2015

-

Main -Changes

- - - -
    -
  • First official -release

License

- -
-
-Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met:
-
-
  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions -in binary form must reproduce the above copyright notice, this list of -conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of STMicroelectronics nor the names of its contributors may be used to endorse or promote products derived
    -
    -
-        from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- -
-
- - -
-
-

For -complete documentation on STM32 Microcontrollers -visit www.st.com/STM32

-
-

-
-
-

 

-
- - \ No newline at end of file diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/stm32446e_eval.c b/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/stm32446e_eval.c deleted file mode 100644 index eeb225019e..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/stm32446e_eval.c +++ /dev/null @@ -1,1362 +0,0 @@ -/** - ****************************************************************************** - * @file stm32446e_eval.c - * @author MCD Application Team - * @version V1.1.0 - * @date 14-August-2015 - * @brief This file provides a set of firmware functions to manage LEDs, - * push-buttons and COM ports available on STM32446E-EVAL evaluation - * board(MB1045) RevB from STMicroelectronics. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* File Info: ------------------------------------------------------------------ - User NOTE - - This driver requires the stm32446e_eval_io to manage the joystick - -------------------------------------------------------------------------------*/ - -/* Includes ------------------------------------------------------------------*/ -#include "stm32446e_eval.h" -#if defined(USE_IOEXPANDER) -#include "stm32446e_eval_io.h" -#endif /* USE_IOEXPANDER */ - - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32446E_EVAL - * @{ - */ - -/** @defgroup STM32446E_EVAL_LOW_LEVEL STM32446E-EVAL LOW LEVEL - * @{ - */ - -/** @defgroup STM32446E_EVAL_LOW_LEVEL_Private_TypesDefinitions STM32446E Eval Low Level Private Typedef - * @{ - */ -typedef struct -{ - __IO uint16_t REG; - __IO uint16_t RAM; -}LCD_CONTROLLER_TypeDef; -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_LOW_LEVEL_Private_Defines STM32446E Eval Low Level Private Def - * @{ - */ -/** - * @brief STM32446E EVAL BSP Driver version number V1.1.0 - */ -#define __STM32446E_EVAL_BSP_VERSION_MAIN (0x01) /*!< [31:24] main version */ -#define __STM32446E_EVAL_BSP_VERSION_SUB1 (0x01) /*!< [23:16] sub1 version */ -#define __STM32446E_EVAL_BSP_VERSION_SUB2 (0x00) /*!< [15:8] sub2 version */ -#define __STM32446E_EVAL_BSP_VERSION_RC (0x00) /*!< [7:0] release candidate */ -#define __STM32446E_EVAL_BSP_VERSION ((__STM32446E_EVAL_BSP_VERSION_MAIN << 24)\ - |(__STM32446E_EVAL_BSP_VERSION_SUB1 << 16)\ - |(__STM32446E_EVAL_BSP_VERSION_SUB2 << 8 )\ - |(__STM32446E_EVAL_BSP_VERSION_RC)) - -/* compared to F4xG we use BANK1 rather then BANK3 since we use FMC_NE1 signal (not FMC_NE3) */ -#define FMC_BANK1_BASE ((uint32_t)(0x60000000 | 0x00000000)) -#define FMC_BANK3_BASE ((uint32_t)(0x60000000 | 0x08000000)) -#define FMC_BANK1 ((LCD_CONTROLLER_TypeDef *) FMC_BANK1_BASE) - -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_LOW_LEVEL_Private_Macros STM32446E Eval Low Level Private Macro - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_LOW_LEVEL_Private_Variables STM32446E Eval Low Level Variables - * @{ - */ - -#if defined(USE_IOEXPANDER) -const uint32_t GPIO_PIN[LEDn] = {LED1_PIN, - LED2_PIN, - LED3_PIN, - LED4_PIN}; -#else -const uint32_t GPIO_PIN[LEDn] = {LED1_PIN, - LED3_PIN}; -#endif /* USE_IOEXPANDER */ - - -GPIO_TypeDef* BUTTON_PORT[BUTTONn] = {WAKEUP_BUTTON_GPIO_PORT, - TAMPER_BUTTON_GPIO_PORT, - KEY_BUTTON_GPIO_PORT}; - -const uint16_t BUTTON_PIN[BUTTONn] = {WAKEUP_BUTTON_PIN, - TAMPER_BUTTON_PIN, - KEY_BUTTON_PIN}; - -const uint16_t BUTTON_IRQn[BUTTONn] = {WAKEUP_BUTTON_EXTI_IRQn, - TAMPER_BUTTON_EXTI_IRQn, - KEY_BUTTON_EXTI_IRQn}; - -USART_TypeDef* COM_USART[COMn] = {EVAL_COM1}; - -GPIO_TypeDef* COM_TX_PORT[COMn] = {EVAL_COM1_TX_GPIO_PORT}; - -GPIO_TypeDef* COM_RX_PORT[COMn] = {EVAL_COM1_RX_GPIO_PORT}; - -const uint16_t COM_TX_PIN[COMn] = {EVAL_COM1_TX_PIN}; - -const uint16_t COM_RX_PIN[COMn] = {EVAL_COM1_RX_PIN}; - -const uint16_t COM_TX_AF[COMn] = {EVAL_COM1_TX_AF}; - -const uint16_t COM_RX_AF[COMn] = {EVAL_COM1_RX_AF}; - -static FMPI2C_HandleTypeDef hEvalI2c; - -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_LOW_LEVEL_Private_FunctionPrototypes STM32446E Eval Low Level Private Prototypes - * @{ - */ -static void I2Cx_MspInit(void); -static void I2Cx_Init(void); -#if defined(USE_IOEXPANDER) -static void I2Cx_Write(uint8_t Addr, uint8_t Reg, uint8_t Value); -static uint8_t I2Cx_Read(uint8_t Addr, uint8_t Reg); -#endif /* USE_IOEXPANDER */ - -static HAL_StatusTypeDef I2Cx_ReadMultiple(uint8_t Addr, uint16_t Reg, uint16_t MemAddSize, uint8_t *Buffer, uint16_t Length); -static HAL_StatusTypeDef I2Cx_WriteMultiple(uint8_t Addr, uint16_t Reg, uint16_t MemAddSize, uint8_t *Buffer, uint16_t Length); -static HAL_StatusTypeDef I2Cx_IsDeviceReady(uint16_t DevAddress, uint32_t Trials); -static void I2Cx_Error(uint8_t Addr); - -static void FMC_BANK1_WriteData(uint16_t Data); -static void FMC_BANK1_WriteReg(uint8_t Reg); -static uint16_t FMC_BANK1_ReadData(void); -static void FMC_BANK1_Init(void); -static void FMC_BANK1_MspInit(void); - -/* IOExpander IO functions */ -#if defined(USE_IOEXPANDER) -void MFX_IO_Init(void); -void MFX_IO_DeInit(void); -void MFX_IO_ITConfig(void); -void MFX_IO_Delay(uint32_t Delay); -void MFX_IO_Write(uint16_t Addr, uint8_t Reg, uint8_t Value); -uint8_t MFX_IO_Read(uint16_t Addr, uint8_t Reg); -uint16_t MFX_IO_ReadMultiple(uint16_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length); -void MFX_IO_Wakeup(void); -void MFX_IO_EnableWakeupPin(void); -#endif /* USE_IOEXPANDER */ - -/* LCD IO functions */ -void LCD_IO_Init(void); -void LCD_IO_WriteData(uint16_t RegValue); -void LCD_IO_WriteReg(uint8_t Reg); -uint16_t LCD_IO_ReadData(void); - -/* AUDIO IO functions */ -void AUDIO_IO_Init(void); -void AUDIO_IO_DeInit(void); -void AUDIO_IO_Write(uint8_t Addr, uint16_t Reg, uint16_t Value); -uint16_t AUDIO_IO_Read(uint8_t Addr, uint16_t Reg); -void AUDIO_IO_Delay(uint32_t Delay); - -/* CAMERA IO functions */ -void CAMERA_IO_Init(void); -void CAMERA_Delay(uint32_t Delay); -void CAMERA_IO_Write(uint8_t Addr, uint16_t Reg, uint16_t Value); -uint16_t CAMERA_IO_Read(uint8_t Addr, uint16_t Reg); - -/* I2C EEPROM IO function */ -void EEPROM_IO_Init(void); -HAL_StatusTypeDef EEPROM_IO_WriteData(uint16_t DevAddress, uint16_t MemAddress, uint8_t* pBuffer, uint32_t BufferSize); -HAL_StatusTypeDef EEPROM_IO_ReadData(uint16_t DevAddress, uint16_t MemAddress, uint8_t* pBuffer, uint32_t BufferSize); -HAL_StatusTypeDef EEPROM_IO_IsDeviceReady(uint16_t DevAddress, uint32_t Trials); - - -/** - * @} - */ - - - -/** @defgroup STM32446E_EVAL_LOW_LEVEL_Private_Functions STM32446E Eval Low Level Private Functions - * @{ - */ - - /** - * @brief This method returns the STM32446E EVAL BSP Driver revision - * @param None - * @retval version: 0xXYZR (8bits for each decimal, R for RC) - */ -uint32_t BSP_GetVersion(void) -{ - return __STM32446E_EVAL_BSP_VERSION; -} - -/** - * @brief Configures LEDs. - * @param Led: LED to be configured. - * This parameter can be one of the following values: - * @arg LED1 - * @arg LED2 - * @arg LED3 - * @arg LED4 - * @retval None - */ -void BSP_LED_Init(Led_TypeDef Led) -{ -#if !defined(USE_STM32446E_EVAL_REVA) - GPIO_InitTypeDef gpio_init_structure; - - /* On RevB led1 and Led3 are on GPIO while Led2 and Led4 on Mfx*/ - if ((Led == LED1) || (Led == LED3)) - { - /* Enable the GPIO_LED clock */ - LEDx_GPIO_CLK_ENABLE(); - - /* Configure the GPIO_LED pin */ - gpio_init_structure.Pin = GPIO_PIN[Led]; - gpio_init_structure.Mode = GPIO_MODE_OUTPUT_PP; - gpio_init_structure.Pull = GPIO_PULLUP; - gpio_init_structure.Speed = GPIO_SPEED_HIGH; - - HAL_GPIO_Init(LEDx_GPIO_PORT, &gpio_init_structure); - - /* By default, turn off LED */ - HAL_GPIO_WritePin(LEDx_GPIO_PORT, GPIO_PIN[Led], GPIO_PIN_SET); - } - else /* Led2 and Led4 */ - { -#endif /* !USE_STM32446E_EVAL_REVA */ - -#if defined(USE_IOEXPANDER) /* (USE_IOEXPANDER always defined for RevA) */ - /* Initialize the IO functionalities (Mfx) */ - BSP_IO_Init(); - /* GPIO_PIN[Led] depends on the board revision: */ - /* - in case of RevA all leds are on IOEXPANDER (Mfx) */ - /* - in case of RevB just led 2 and led4 on IOEXPANDER (Mfx) */ - BSP_IO_ConfigPin(GPIO_PIN[Led], IO_MODE_OUTPUT_PP_PU); - BSP_IO_WritePin(GPIO_PIN[Led], BSP_IO_PIN_SET); -#endif /* USE_IOEXPANDER */ - -#if !defined(USE_STM32446E_EVAL_REVA) - } -#endif /* !USE_STM32446E_EVAL_REVA */ -} - - -/** - * @brief DeInit LEDs. - * @param Led: LED to be configured. - * This parameter can be one of the following values: - * @arg LED1 - * @arg LED2 - * @arg LED3 - * @arg LED4 - * @note Led DeInit does not disable the GPIO clock nor disable the Mfx - * @retval None - */ -void BSP_LED_DeInit(Led_TypeDef Led) -{ -#if !defined(USE_STM32446E_EVAL_REVA) - GPIO_InitTypeDef gpio_init_structure; - - /* On RevB led1 and Led3 are on GPIO while Led2 and Led4 on Mfx*/ - if ((Led == LED1) || (Led == LED3)) - { - /* Turn off LED */ - HAL_GPIO_WritePin(LEDx_GPIO_PORT, GPIO_PIN[Led], GPIO_PIN_RESET); - /* DeInit the GPIO_LED pin */ - gpio_init_structure.Pin = GPIO_PIN[Led]; - HAL_GPIO_DeInit(LEDx_GPIO_PORT, gpio_init_structure.Pin); - } - else - { -#endif /* !USE_STM32446E_EVAL_REVA */ - -#if defined(USE_IOEXPANDER) /* (USE_IOEXPANDER always defined for RevA) */ - /* GPIO_PIN[Led] depends on the board revision: */ - /* - in case of RevA all leds are on IOEXPANDER (Mfx) */ - /* - in case of RevB just led 2 and led4 on IOEXPANDER (Mfx) */ - BSP_IO_ConfigPin(GPIO_PIN[Led], IO_MODE_OFF); -#endif /* USE_IOEXPANDER */ - -#if !defined(USE_STM32446E_EVAL_REVA) - } -#endif /* !USE_STM32446E_EVAL_REVA */ -} - -/** - * @brief Turns selected LED On. - * @param Led: LED to be set on - * This parameter can be one of the following values: - * @arg LED1 - * @arg LED2 - * @arg LED3 - * @arg LED4 - * @retval None - */ -void BSP_LED_On(Led_TypeDef Led) -{ - -#if !defined(USE_STM32446E_EVAL_REVA) - /* On RevB led1 and Led3 are on GPIO while Led2 and Led4 on Mfx*/ - if ((Led == LED1) || (Led == LED3)) - { - HAL_GPIO_WritePin(LEDx_GPIO_PORT, GPIO_PIN[Led], GPIO_PIN_RESET); - } - else - { -#endif /* !USE_STM32446E_EVAL_REVA */ - -#if defined(USE_IOEXPANDER) /* (USE_IOEXPANDER always defined for RevA) */ - /* GPIO_PIN[Led] depends on the board revision: */ - /* - in case of RevA all leds are on IOEXPANDER (Mfx) */ - /* - in case of RevB just led 2 and led4 on IOEXPANDER (Mfx) */ - BSP_IO_WritePin(GPIO_PIN[Led], BSP_IO_PIN_RESET); -#endif /* USE_IOEXPANDER */ - -#if !defined(USE_STM32446E_EVAL_REVA) - } -#endif /* !USE_STM32446E_EVAL_REVA */ -} - -/** - * @brief Turns selected LED Off. - * @param Led: LED to be set off - * This parameter can be one of the following values: - * @arg LED1 - * @arg LED2 - * @arg LED3 - * @arg LED4 - * @retval None - */ -void BSP_LED_Off(Led_TypeDef Led) -{ - -#if !defined(USE_STM32446E_EVAL_REVA) - /* On RevB led1 and Led3 are on GPIO while Led2 and Led4 on Mfx*/ - if ((Led == LED1) || (Led == LED3)) - { - HAL_GPIO_WritePin(LEDx_GPIO_PORT, GPIO_PIN[Led], GPIO_PIN_SET); - } - else - { -#endif /* !USE_STM32446E_EVAL_REVA */ - -#if defined(USE_IOEXPANDER) /* (USE_IOEXPANDER always defined for RevA) */ - /* GPIO_PIN[Led] depends on the board revision: */ - /* - in case of RevA all leds are on IOEXPANDER (Mfx) */ - /* - in case of RevB just led 2 and led4 on IOEXPANDER (Mfx) */ - BSP_IO_WritePin(GPIO_PIN[Led], BSP_IO_PIN_SET); -#endif /* USE_IOEXPANDER */ - -#if !defined(USE_STM32446E_EVAL_REVA) - } -#endif /* !USE_STM32446E_EVAL_REVA */ - -} - -/** - * @brief Toggles the selected LED. - * @param Led: LED to be toggled - * This parameter can be one of the following values: - * @arg LED1 - * @arg LED2 - * @arg LED3 - * @arg LED4 - * @retval None - */ -void BSP_LED_Toggle(Led_TypeDef Led) -{ - -#if !defined(USE_STM32446E_EVAL_REVA) - /* On RevB led1 and Led3 are on GPIO while Led2 and Led4 on Mfx*/ - if ((Led == LED1) || (Led == LED3)) - { - HAL_GPIO_TogglePin(LEDx_GPIO_PORT, GPIO_PIN[Led]); - } - else - { -#endif /* !USE_STM32446E_EVAL_REVA */ - -#if defined(USE_IOEXPANDER) /* (USE_IOEXPANDER always defined for RevA) */ - /* GPIO_PIN[Led] depends on the board revision: */ - /* - in case of RevA all leds are on IOEXPANDER (Mfx) */ - /* - in case of RevB just led 2 and led4 on IOEXPANDER (Mfx) */ - BSP_IO_TogglePin(GPIO_PIN[Led]); -#endif /* USE_IOEXPANDER */ - -#if !defined(USE_STM32446E_EVAL_REVA) - } -#endif /* !USE_STM32446E_EVAL_REVA */ -} - -/** - * @brief Configures button GPIO and EXTI Line. - * @param Button: Button to be configured - * This parameter can be one of the following values: - * @arg BUTTON_WAKEUP: Wakeup Push Button - * @arg BUTTON_TAMPER: Tamper Push Button - * @arg BUTTON_KEY: Key Push Button - * @param ButtonMode: Button mode - * This parameter can be one of the following values: - * @arg BUTTON_MODE_GPIO: Button will be used as simple IO - * @arg BUTTON_MODE_EXTI: Button will be connected to EXTI line - * with interrupt generation capability - * @note On STM32446E-EVAL evaluation board, the three buttons (Wakeup, Tamper - * and key buttons) are mapped on the same push button named "Wakeup/Tamper" - * on the board serigraphy. - * @retval None - */ -void BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef ButtonMode) -{ - GPIO_InitTypeDef gpio_init_structure; - - /* Enable the BUTTON clock */ - BUTTONx_GPIO_CLK_ENABLE(Button); - - if(ButtonMode == BUTTON_MODE_GPIO) - { - /* Configure Button pin as input */ - gpio_init_structure.Pin = BUTTON_PIN[Button]; - gpio_init_structure.Mode = GPIO_MODE_INPUT; - gpio_init_structure.Pull = GPIO_NOPULL; - gpio_init_structure.Speed = GPIO_SPEED_FAST; - HAL_GPIO_Init(BUTTON_PORT[Button], &gpio_init_structure); - } - - if(ButtonMode == BUTTON_MODE_EXTI) - { - /* Configure Button pin as input with External interrupt */ - gpio_init_structure.Pin = BUTTON_PIN[Button]; - gpio_init_structure.Pull = GPIO_NOPULL; - gpio_init_structure.Speed = GPIO_SPEED_FAST; - - if(Button != BUTTON_WAKEUP) - { - gpio_init_structure.Mode = GPIO_MODE_IT_FALLING; - } - else - { - gpio_init_structure.Mode = GPIO_MODE_IT_RISING; - } - - HAL_GPIO_Init(BUTTON_PORT[Button], &gpio_init_structure); - - /* Enable and set Button EXTI Interrupt to the lowest priority */ - HAL_NVIC_SetPriority((IRQn_Type)(BUTTON_IRQn[Button]), 0x0F, 0x00); - HAL_NVIC_EnableIRQ((IRQn_Type)(BUTTON_IRQn[Button])); - } -} - -/** - * @brief Push Button DeInit. - * @param Button: Button to be configured - * This parameter can be one of the following values: - * @arg BUTTON_WAKEUP: Wakeup Push Button - * @arg BUTTON_TAMPER: Tamper Push Button - * @arg BUTTON_KEY: Key Push Button - * @note On STM32446E-EVAL evaluation board, the three buttons (Wakeup, Tamper - * and key buttons) are mapped on the same push button nammed "Wakeup/Tamper" - * on the board serigraphy. - * @note PB DeInit does not disable the GPIO clock - * @retval None - */ -void BSP_PB_DeInit(Button_TypeDef Button) -{ - GPIO_InitTypeDef gpio_init_structure; - - gpio_init_structure.Pin = BUTTON_PIN[Button]; - HAL_NVIC_DisableIRQ((IRQn_Type)(BUTTON_IRQn[Button])); - HAL_GPIO_DeInit(BUTTON_PORT[Button], gpio_init_structure.Pin); -} - - -/** - * @brief Returns the selected button state. - * @param Button: Button to be checked - * This parameter can be one of the following values: - * @arg BUTTON_WAKEUP: Wakeup Push Button - * @arg BUTTON_TAMPER: Tamper Push Button - * @arg BUTTON_KEY: Key Push Button - * @note On STM32446E-EVAL evaluation board, the three buttons (Wakeup, Tamper - * and key buttons) are mapped on the same push button nammed "Wakeup/Tamper" - * on the board serigraphy. - * @retval The Button GPIO pin value - */ -uint32_t BSP_PB_GetState(Button_TypeDef Button) -{ - return HAL_GPIO_ReadPin(BUTTON_PORT[Button], BUTTON_PIN[Button]); -} - -/** - * @brief Configures COM port. - * @param COM: COM port to be configured. - * This parameter can be one of the following values: - * @arg COM1 - * @arg COM2 - * @param huart: Pointer to a UART_HandleTypeDef structure that contains the - * configuration information for the specified USART peripheral. - * @retval None - */ -void BSP_COM_Init(COM_TypeDef COM, UART_HandleTypeDef *huart) -{ - GPIO_InitTypeDef gpio_init_structure; - - /* Enable GPIO clock */ - EVAL_COMx_TX_GPIO_CLK_ENABLE(COM); - EVAL_COMx_RX_GPIO_CLK_ENABLE(COM); - - /* Enable USART clock */ - EVAL_COMx_CLK_ENABLE(COM); - - /* Configure USART Tx as alternate function */ - gpio_init_structure.Pin = COM_TX_PIN[COM]; - gpio_init_structure.Mode = GPIO_MODE_AF_PP; - gpio_init_structure.Speed = GPIO_SPEED_FAST; - gpio_init_structure.Pull = GPIO_PULLUP; - gpio_init_structure.Alternate = COM_TX_AF[COM]; - HAL_GPIO_Init(COM_TX_PORT[COM], &gpio_init_structure); - - /* Configure USART Rx as alternate function */ - gpio_init_structure.Pin = COM_RX_PIN[COM]; - gpio_init_structure.Mode = GPIO_MODE_AF_PP; - gpio_init_structure.Alternate = COM_RX_AF[COM]; - HAL_GPIO_Init(COM_RX_PORT[COM], &gpio_init_structure); - - /* USART configuration */ - huart->Instance = COM_USART[COM]; - HAL_UART_Init(huart); -} - -/** - * @brief DeInit COM port. - * @param COM: COM port to be configured. - * This parameter can be one of the following values: - * @arg COM1 - * @arg COM2 - * @param huart: Pointer to a UART_HandleTypeDef structure that contains the - * configuration information for the specified USART peripheral. - * @retval None - */ -void BSP_COM_DeInit(COM_TypeDef COM, UART_HandleTypeDef *huart) -{ - /* USART configuration */ - huart->Instance = COM_USART[COM]; - HAL_UART_DeInit(huart); - - /* Enable USART clock */ - EVAL_COMx_CLK_DISABLE(COM); - - /* DeInit GPIO pins can be done in the application - (by surcharging this __weak function) */ - - /* GPIO pins clock, FMC clock and DMA clock can be shut down in the application - by surcharging this __weak function */ -} - -#if defined(USE_IOEXPANDER) - -/** - * @brief Configures joystick GPIO and EXTI modes. - * @param JoyMode: Button mode. - * This parameter can be one of the following values: - * @arg JOY_MODE_GPIO: Joystick pins will be used as simple IOs - * @arg JOY_MODE_EXTI: Joystick pins will be connected to EXTI line - * with interrupt generation capability - * @retval IO_OK: if all initializations are OK. Other value if error. - */ -uint8_t BSP_JOY_Init(JOYMode_TypeDef JoyMode) -{ - uint8_t ret = 0; - - /* Initialize the IO functionalities */ - ret = BSP_IO_Init(); - - /* Configure joystick pins in IT mode */ - if(JoyMode == JOY_MODE_EXTI) - { - /* Configure IO interrupt acquisition mode */ - BSP_IO_ConfigPin(JOY_ALL_PINS, IO_MODE_IT_FALLING_EDGE_PU); - } - else - { - BSP_IO_ConfigPin(JOY_ALL_PINS, IO_MODE_INPUT_PU); - } - - return ret; -} - - -/** - * @brief DeInit joystick GPIOs. - * @note JOY DeInit does not disable the Mfx, just set the Mfx pins in Off mode - * @retval None. - */ -void BSP_JOY_DeInit(void) -{ - BSP_IO_ConfigPin(JOY_ALL_PINS, IO_MODE_OFF); -} - -/** - * @brief Returns the current joystick status. - * @param None - * @retval Code of the joystick key pressed - * This code can be one of the following values: - * @arg JOY_NONE - * @arg JOY_SEL - * @arg JOY_DOWN - * @arg JOY_LEFT - * @arg JOY_RIGHT - * @arg JOY_UP - */ -JOYState_TypeDef BSP_JOY_GetState(void) -{ - uint16_t pin_status = 0; - - /* Read the status joystick pins */ - pin_status = BSP_IO_ReadPin(JOY_ALL_PINS); - - /* Check the pressed keys */ - if((pin_status & JOY_NONE_PIN) == JOY_NONE) - { - return(JOYState_TypeDef) JOY_NONE; - } - else if(!(pin_status & JOY_SEL_PIN)) - { - return(JOYState_TypeDef) JOY_SEL; - } - else if(!(pin_status & JOY_DOWN_PIN)) - { - return(JOYState_TypeDef) JOY_DOWN; - } - else if(!(pin_status & JOY_LEFT_PIN)) - { - return(JOYState_TypeDef) JOY_LEFT; - } - else if(!(pin_status & JOY_RIGHT_PIN)) - { - return(JOYState_TypeDef) JOY_RIGHT; - } - else if(!(pin_status & JOY_UP_PIN)) - { - return(JOYState_TypeDef) JOY_UP; - } - else - { - return(JOYState_TypeDef) JOY_NONE; - } -} - -#endif /* USE_IOEXPANDER */ - - -/******************************************************************************* - BUS OPERATIONS -*******************************************************************************/ - -/******************************* I2C Routines *********************************/ -/** - * @brief Initializes I2C MSP. - * @param None - * @retval None - */ -static void I2Cx_MspInit(void) -{ - GPIO_InitTypeDef gpio_init_structure; - - /*** Configure the GPIOs ***/ - /* Enable GPIO clock */ - EVAL_I2Cx_SCL_SDA_GPIO_CLK_ENABLE(); - - /* Configure I2C Tx as alternate function */ - gpio_init_structure.Pin = EVAL_I2Cx_SCL_PIN; - gpio_init_structure.Mode = GPIO_MODE_AF_OD; - gpio_init_structure.Pull = GPIO_NOPULL; - gpio_init_structure.Speed = GPIO_SPEED_FAST; - gpio_init_structure.Alternate = EVAL_I2Cx_SCL_SDA_AF; - HAL_GPIO_Init(EVAL_I2Cx_SCL_SDA_GPIO_PORT, &gpio_init_structure); - - /* Configure I2C Rx as alternate function */ - gpio_init_structure.Pin = EVAL_I2Cx_SDA_PIN; - HAL_GPIO_Init(EVAL_I2Cx_SCL_SDA_GPIO_PORT, &gpio_init_structure); - - /*** Configure the I2C peripheral ***/ - /* Enable I2C clock */ - EVAL_I2Cx_CLK_ENABLE(); - - /* Force the I2C peripheral clock reset */ - EVAL_I2Cx_FORCE_RESET(); - - /* Release the I2C peripheral clock reset */ - EVAL_I2Cx_RELEASE_RESET(); - - /* Enable and set I2Cx Interrupt to a lower priority */ - HAL_NVIC_SetPriority(EVAL_I2Cx_EV_IRQn, 0x05, 0); - HAL_NVIC_EnableIRQ(EVAL_I2Cx_EV_IRQn); - - /* Enable and set I2Cx Interrupt to a lower priority */ - HAL_NVIC_SetPriority(EVAL_I2Cx_ER_IRQn, 0x05, 0); - HAL_NVIC_EnableIRQ(EVAL_I2Cx_ER_IRQn); -} - -/** - * @brief Initializes I2C HAL. - * @param None - * @retval None - */ -static void I2Cx_Init(void) -{ - if(HAL_FMPI2C_GetState(&hEvalI2c) == HAL_FMPI2C_STATE_RESET) - { - hEvalI2c.Instance = EVAL_I2Cx; - hEvalI2c.Init.Timing = EVAL_I2Cx_TIMING; - hEvalI2c.Init.OwnAddress1 = 0; - hEvalI2c.Init.AddressingMode = FMPI2C_ADDRESSINGMODE_7BIT; - hEvalI2c.Init.DualAddressMode = FMPI2C_DUALADDRESS_DISABLE; - hEvalI2c.Init.OwnAddress2 = 0; - hEvalI2c.Init.GeneralCallMode = FMPI2C_GENERALCALL_DISABLE; - hEvalI2c.Init.NoStretchMode = FMPI2C_NOSTRETCH_DISABLE; - - /* Init the I2C */ - I2Cx_MspInit(); - HAL_FMPI2C_Init(&hEvalI2c); - } -} - -#if defined(USE_IOEXPANDER) - - -/** - * @brief Writes a single data. - * @param Addr: I2C address - * @param Reg: Register address - * @param Value: Data to be written - * @retval None - */ -static void I2Cx_Write(uint8_t Addr, uint8_t Reg, uint8_t Value) -{ - HAL_StatusTypeDef status = HAL_OK; - - status = HAL_FMPI2C_Mem_Write(&hEvalI2c, Addr, (uint16_t)Reg, FMPI2C_MEMADD_SIZE_8BIT, &Value, 1, 100); - - /* Check the communication status */ - if(status != HAL_OK) - { - /* Execute user timeout callback */ - I2Cx_Error(Addr); - } -} - -/** - * @brief Reads a single data. - * @param Addr: I2C address - * @param Reg: Register address - * @retval Read data - */ -static uint8_t I2Cx_Read(uint8_t Addr, uint8_t Reg) -{ - HAL_StatusTypeDef status = HAL_OK; - uint8_t Value = 0; - - status = HAL_FMPI2C_Mem_Read(&hEvalI2c, Addr, Reg, FMPI2C_MEMADD_SIZE_8BIT, &Value, 1, 1000); - - /* Check the communication status */ - if(status != HAL_OK) - { - /* Execute user timeout callback */ - I2Cx_Error(Addr); - } - return Value; -} - -#endif /* USE_IOEXPANDER */ - -/** - * @brief Reads multiple data. - * @param Addr: I2C address - * @param Reg: Reg address - * @param Buffer: Pointer to data buffer - * @param Length: Length of the data - * @retval Number of read data - */ -static HAL_StatusTypeDef I2Cx_ReadMultiple(uint8_t Addr, uint16_t Reg, uint16_t MemAddSize, uint8_t *Buffer, uint16_t Length) -{ - HAL_StatusTypeDef status = HAL_OK; - - status = HAL_FMPI2C_Mem_Read(&hEvalI2c, Addr, (uint16_t)Reg, MemAddSize, Buffer, Length, 1000); - - /* Check the communication status */ - if(status != HAL_OK) - { - /* I2C error occurred */ - I2Cx_Error(Addr); - } - return status; -} - -/** - * @brief Writes a value in a register of the device through BUS in using DMA mode. - * @param Addr: Device address on BUS Bus. - * @param Reg: The target register address to write - * @param pBuffer: The target register value to be written - * @param Length: buffer size to be written - * @retval HAL status - */ -static HAL_StatusTypeDef I2Cx_WriteMultiple(uint8_t Addr, uint16_t Reg, uint16_t MemAddSize, uint8_t *Buffer, uint16_t Length) -{ - HAL_StatusTypeDef status = HAL_OK; - - status = HAL_FMPI2C_Mem_Write(&hEvalI2c, Addr, (uint16_t)Reg, MemAddSize, Buffer, Length, 1000); - - /* Check the communication status */ - if(status != HAL_OK) - { - /* Re-Initialize the I2C Bus */ - I2Cx_Error(Addr); - } - return status; -} - -/** - * @brief Checks if target device is ready for communication. - * @note This function is used with Memory devices - * @param DevAddress: Target device address - * @param Trials: Number of trials - * @retval HAL status - */ -static HAL_StatusTypeDef I2Cx_IsDeviceReady(uint16_t DevAddress, uint32_t Trials) -{ - return (HAL_FMPI2C_IsDeviceReady(&hEvalI2c, DevAddress, Trials, 1000)); -} - -/** - * @brief Manages error callback by re-initializing I2C. - * @param Addr: I2C Address - * @retval None - */ -static void I2Cx_Error(uint8_t Addr) -{ - /* De-initialize the I2C communication bus */ - HAL_FMPI2C_DeInit(&hEvalI2c); - - /* Re-Initialize the I2C communication bus */ - I2Cx_Init(); -} - -/*************************** FMC Routines ************************************/ -/** - * @brief Initializes FMC_BANK1 MSP. - * @param None - * @retval None - */ -static void FMC_BANK1_MspInit(void) -{ - GPIO_InitTypeDef gpio_init_structure; - - /* Enable FMC clock */ - __HAL_RCC_FMC_CLK_ENABLE(); - - /* Enable GPIOs clock */ - __HAL_RCC_GPIOD_CLK_ENABLE(); - __HAL_RCC_GPIOE_CLK_ENABLE(); - __HAL_RCC_GPIOF_CLK_ENABLE(); - - /* Common GPIO configuration */ - gpio_init_structure.Mode = GPIO_MODE_AF_PP; - gpio_init_structure.Pull = GPIO_PULLUP; - gpio_init_structure.Speed = GPIO_SPEED_HIGH; - gpio_init_structure.Alternate = GPIO_AF12_FMC; - - /* GPIOD configuration */ /* GPIO_PIN_7 is FMC_NE1 */ - gpio_init_structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_8 |\ - GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_14 | GPIO_PIN_15 | GPIO_PIN_7; - - HAL_GPIO_Init(GPIOD, &gpio_init_structure); - - /* GPIOE configuration */ - gpio_init_structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_3| GPIO_PIN_4 | GPIO_PIN_7 |\ - GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12 |\ - GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15; - HAL_GPIO_Init(GPIOE, &gpio_init_structure); - - /* GPIOF configuration */ - gpio_init_structure.Pin = GPIO_PIN_0 ; - HAL_GPIO_Init(GPIOF, &gpio_init_structure); -} - - -/** - * @brief Initializes LCD IO. - * @param None - * @retval None - */ -static void FMC_BANK1_Init(void) -{ - SRAM_HandleTypeDef hsram; - FMC_NORSRAM_TimingTypeDef sram_timing; - - /*** Configure the SRAM Bank 1 ***/ - /* Configure IPs */ - hsram.Instance = FMC_NORSRAM_DEVICE; - hsram.Extended = FMC_NORSRAM_EXTENDED_DEVICE; - - sram_timing.AddressSetupTime = 5; - sram_timing.AddressHoldTime = 1; - sram_timing.DataSetupTime = 9; - sram_timing.BusTurnAroundDuration = 0; - sram_timing.CLKDivision = 2; - sram_timing.DataLatency = 2; - sram_timing.AccessMode = FMC_ACCESS_MODE_A; - - hsram.Init.NSBank = FMC_NORSRAM_BANK1; - hsram.Init.DataAddressMux = FMC_DATA_ADDRESS_MUX_DISABLE; - hsram.Init.MemoryType = FMC_MEMORY_TYPE_SRAM; - hsram.Init.MemoryDataWidth = FMC_NORSRAM_MEM_BUS_WIDTH_16; - hsram.Init.BurstAccessMode = FMC_BURST_ACCESS_MODE_DISABLE; - hsram.Init.WaitSignalPolarity = FMC_WAIT_SIGNAL_POLARITY_LOW; - hsram.Init.WrapMode = FMC_WRAP_MODE_DISABLE; - hsram.Init.WaitSignalActive = FMC_WAIT_TIMING_BEFORE_WS; - hsram.Init.WriteOperation = FMC_WRITE_OPERATION_ENABLE; - hsram.Init.WaitSignal = FMC_WAIT_SIGNAL_DISABLE; - hsram.Init.ExtendedMode = FMC_EXTENDED_MODE_DISABLE; - hsram.Init.AsynchronousWait = FMC_ASYNCHRONOUS_WAIT_DISABLE; - hsram.Init.WriteBurst = FMC_WRITE_BURST_DISABLE; - hsram.Init.ContinuousClock = FMC_CONTINUOUS_CLOCK_SYNC_ONLY; - hsram.Init.WriteFifo = FMC_WRITE_FIFO_DISABLE; - hsram.Init.PageSize = FMC_PAGE_SIZE_NONE; - - /* Initialize the SRAM controller */ - FMC_BANK1_MspInit(); - HAL_SRAM_Init(&hsram, &sram_timing, &sram_timing); -} - - -/** - * @brief Writes register value. - * @param Data: Data to be written - * @retval None - */ -static void FMC_BANK1_WriteData(uint16_t Data) -{ - /* Write 16-bit Reg */ - FMC_BANK1->RAM = Data; -} - -/** - * @brief Writes register address. - * @param Reg: Register to be written - * @retval None - */ -static void FMC_BANK1_WriteReg(uint8_t Reg) -{ - /* Write 16-bit Index, then write register */ - FMC_BANK1->REG = Reg; -} - -/** - * @brief Reads register value. - * @param None - * @retval Read value - */ -static uint16_t FMC_BANK1_ReadData(void) -{ - return FMC_BANK1->RAM; -} - -/******************************************************************************* - LINK OPERATIONS -*******************************************************************************/ - -#if defined(USE_IOEXPANDER) - -/********************************* LINK MFX ***********************************/ - -/** - * @brief Initializes MFX low level. - * @param None - * @retval None - */ -void MFX_IO_Init(void) -{ - I2Cx_Init(); -} - -/** - * @brief DeInitializes MFX low level. - * @param None - * @retval None - */ -void MFX_IO_DeInit(void) -{ -} - -/** - * @brief Configures MFX low level interrupt. - * @param None - * @retval None - */ -void MFX_IO_ITConfig(void) -{ - GPIO_InitTypeDef gpio_init_structure; - - /* Enable the GPIO EXTI clock */ - __HAL_RCC_GPIOA_CLK_ENABLE(); - __HAL_RCC_SYSCFG_CLK_ENABLE(); - - /* PA0 is the MFX_OUT_IRQ (often used for EXTI_WKUP) */ - gpio_init_structure.Pin = GPIO_PIN_0; - gpio_init_structure.Pull = GPIO_NOPULL; - gpio_init_structure.Speed = GPIO_SPEED_LOW; - gpio_init_structure.Mode = GPIO_MODE_IT_RISING; - HAL_GPIO_Init(GPIOA, &gpio_init_structure); - - /* Enable and set GPIO EXTI Interrupt to the lowest priority */ - HAL_NVIC_SetPriority((IRQn_Type)(EXTI0_IRQn), 0x0F, 0x0F); - HAL_NVIC_EnableIRQ((IRQn_Type)(EXTI0_IRQn)); -} - -/** - * @brief MFX writes single data. - * @param Addr: I2C address - * @param Reg: Register address - * @param Value: Data to be written - * @retval None - */ -void MFX_IO_Write(uint16_t Addr, uint8_t Reg, uint8_t Value) -{ - I2Cx_Write((uint8_t) Addr, Reg, Value); -} - -/** - * @brief MFX reads single data. - * @param Addr: I2C address - * @param Reg: Register address - * @retval Read data - */ -uint8_t MFX_IO_Read(uint16_t Addr, uint8_t Reg) -{ - return I2Cx_Read((uint8_t) Addr, Reg); -} - -/** - * @brief MFX reads multiple data. - * @param Addr: I2C address - * @param Reg: Register address - * @param Buffer: Pointer to data buffer - * @param Length: Length of the data - * @retval Number of read data - */ -uint16_t MFX_IO_ReadMultiple(uint16_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length) -{ - return I2Cx_ReadMultiple((uint8_t) Addr, (uint16_t)Reg, FMPI2C_MEMADD_SIZE_8BIT, Buffer, Length); -} - -/** - * @brief MFX delay - * @param Delay: Delay in ms - * @retval None - */ -void MFX_IO_Delay(uint32_t Delay) -{ - HAL_Delay(Delay); -} - -/** - * @brief Used by Lx family but requested for MFX component compatibility. - * @param None - * @retval None - */ -void MFX_IO_Wakeup(void) -{ -} - -/** - * @brief Used by Lx family but requested for MXF component compatibility. - * @param None - * @retval None - */ -void MFX_IO_EnableWakeupPin(void) -{ -} - -#endif /* USE_IOEXPANDER */ - -/********************************* LINK LCD ***********************************/ - -/** - * @brief Initializes LCD low level. - * @param None - * @retval None - */ -void LCD_IO_Init(void) -{ - FMC_BANK1_Init(); -} - -/** - * @brief Writes data on LCD data register. - * @param Data: Data to be written - * @retval None - */ -void LCD_IO_WriteData(uint16_t RegValue) -{ - /* Write 16-bit Reg */ - FMC_BANK1_WriteData(RegValue); -} - -/** - * @brief Writes register on LCD register. - * @param Reg: Register to be written - * @retval None - */ -void LCD_IO_WriteReg(uint8_t Reg) -{ - /* Write 16-bit Index, then Write Reg */ - FMC_BANK1_WriteReg(Reg); -} - -/** - * @brief Reads data from LCD data register. - * @param None - * @retval Read data. - */ -uint16_t LCD_IO_ReadData(void) -{ - return FMC_BANK1_ReadData(); -} - -/********************************* LINK AUDIO *********************************/ - -/** - * @brief Initializes Audio low level. - * @param None - * @retval None - */ -void AUDIO_IO_Init(void) -{ - I2Cx_Init(); -} - -/** - * @brief DeInitializes Audio low level. - */ -void AUDIO_IO_DeInit(void) -{ - -} - -/** - * @brief Writes a single data. - * @param Addr: I2C address - * @param Reg: Reg address - * @param Value: Data to be written - * @retval None - */ -void AUDIO_IO_Write(uint8_t Addr, uint16_t Reg, uint16_t Value) -{ - uint16_t tmp = Value; - - Value = ((uint16_t)(tmp >> 8) & 0x00FF); - - Value |= ((uint16_t)(tmp << 8)& 0xFF00); - - I2Cx_WriteMultiple(Addr, Reg, FMPI2C_MEMADD_SIZE_16BIT,(uint8_t*)&Value, 2); -} - -/** - * @brief Reads a single data. - * @param Addr: I2C address - * @param Reg: Reg address - * @retval Data to be read - */ -uint16_t AUDIO_IO_Read(uint8_t Addr, uint16_t Reg) -{ - uint16_t read_value = 0, tmp = 0; - - I2Cx_ReadMultiple(Addr, Reg, FMPI2C_MEMADD_SIZE_16BIT, (uint8_t*)&read_value, 2); - - tmp = ((uint16_t)(read_value >> 8) & 0x00FF); - - tmp |= ((uint16_t)(read_value << 8)& 0xFF00); - - read_value = tmp; - - return read_value; -} - -/** - * @brief AUDIO Codec delay - * @param Delay: Delay in ms - * @retval None - */ -void AUDIO_IO_Delay(uint32_t Delay) -{ - HAL_Delay(Delay); -} - -/********************************* LINK CAMERA ********************************/ - -/** - * @brief Initializes Camera low level. - * @param None - * @retval None - */ -void CAMERA_IO_Init(void) -{ - I2Cx_Init(); -} - -/** - * @brief Camera writes single data. - * @param Addr: I2C address - * @param Reg: Register address - * @param Value: Data to be written - * @retval None - */ -void CAMERA_IO_Write(uint8_t Addr, uint16_t Reg, uint16_t Value) -{ - uint16_t tmp = Value; - /* For S5K5CAG sensor, 16 bits accesses are used */ - Value = ((uint16_t)(tmp >> 8) & 0x00FF); - Value |= ((uint16_t)(tmp << 8)& 0xFF00); - I2Cx_WriteMultiple(Addr, Reg, FMPI2C_MEMADD_SIZE_16BIT,(uint8_t*)&Value, 2); -} - -/** - * @brief Camera reads single data. - * @param Addr: I2C address - * @param Reg: Register address - * @retval Read data - */ -uint16_t CAMERA_IO_Read(uint8_t Addr, uint16_t Reg) -{ - uint16_t read_value = 0, tmp = 0; - /* For S5K5CAG sensor, 16 bits accesses are used */ - I2Cx_ReadMultiple(Addr, Reg, FMPI2C_MEMADD_SIZE_16BIT, (uint8_t*)&read_value, 2); - tmp = ((uint16_t)(read_value >> 8) & 0x00FF); - tmp |= ((uint16_t)(read_value << 8)& 0xFF00); - read_value = tmp; - return read_value; -} - -/** - * @brief Camera delay - * @param Delay: Delay in ms - * @retval None - */ -void CAMERA_Delay(uint32_t Delay) -{ - HAL_Delay(Delay); -} - -/******************************** LINK I2C EEPROM *****************************/ - -/** - * @brief Initializes peripherals used by the I2C EEPROM driver. - * @param None - * @retval None - */ -void EEPROM_IO_Init(void) -{ - I2Cx_Init(); -} - -/** - * @brief Write data to I2C EEPROM driver in using DMA channel. - * @param DevAddress: Target device address - * @param MemAddress: Internal memory address - * @param pBuffer: Pointer to data buffer - * @param BufferSize: Amount of data to be sent - * @retval HAL status - */ -HAL_StatusTypeDef EEPROM_IO_WriteData(uint16_t DevAddress, uint16_t MemAddress, uint8_t* pBuffer, uint32_t BufferSize) -{ - return (I2Cx_WriteMultiple(DevAddress, MemAddress, FMPI2C_MEMADD_SIZE_16BIT, pBuffer, BufferSize)); -} - -/** - * @brief Read data from I2C EEPROM driver in using DMA channel. - * @param DevAddress: Target device address - * @param MemAddress: Internal memory address - * @param pBuffer: Pointer to data buffer - * @param BufferSize: Amount of data to be read - * @retval HAL status - */ -HAL_StatusTypeDef EEPROM_IO_ReadData(uint16_t DevAddress, uint16_t MemAddress, uint8_t* pBuffer, uint32_t BufferSize) -{ - return (I2Cx_ReadMultiple(DevAddress, MemAddress, FMPI2C_MEMADD_SIZE_16BIT, pBuffer, BufferSize)); -} - -/** - * @brief Checks if target device is ready for communication. - * @note This function is used with Memory devices - * @param DevAddress: Target device address - * @param Trials: Number of trials - * @retval HAL status - */ -HAL_StatusTypeDef EEPROM_IO_IsDeviceReady(uint16_t DevAddress, uint32_t Trials) -{ - return (I2Cx_IsDeviceReady(DevAddress, Trials)); -} - - - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/stm32446e_eval.h b/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/stm32446e_eval.h deleted file mode 100644 index 9dfafc89b7..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/stm32446e_eval.h +++ /dev/null @@ -1,407 +0,0 @@ -/** - ****************************************************************************** - * @file stm32446e_eval.h - * @author MCD Application Team - * @version V1.1.0 - * @date 14-August-2015 - * @brief This file contains definitions for STM32446E_EVAL's LEDs, - * push-buttons and COM ports hardware resources. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* IMPORTANT: in order to compile with RevA following flag shall be defined */ -/* in the preprocessor options: USE_STM32446E_EVAL_REVA !!!!!!!!!! */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32446E_EVAL_H -#define __STM32446E_EVAL_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* USE_STM32446E_EVAL_REVA must USE USE_IOEXPANDER */ -#if defined(USE_STM32446E_EVAL_REVA) -#ifndef USE_IOEXPANDER -#define USE_IOEXPANDER -#endif // USE_IOEXPANDER -#endif // USE_STM32446E_EVAL_REVA - -/* Includes ------------------------------------------------------------------*/ -#include "stm32f4xx_hal.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32446E_EVAL - * @{ - */ - -/** @defgroup STM32446E_EVAL_LOW_LEVEL STM32446E-EVAL LOW LEVEL - * @{ - */ - -/** @defgroup STM32446E_EVAL_LOW_LEVEL_Exported_Types STM32446E EVAL Low Level Exported Types - * @{ - */ -typedef enum -{ -#if defined(USE_IOEXPANDER) -LED1 = 0, -LED_GREEN = LED1, -LED2 = 1, -LED_ORANGE = LED2, -LED3 = 2, -LED_RED = LED3, -LED4 = 3, -LED_BLUE = LED4 -#else -LED1 = 0, -LED_GREEN = LED1, -LED3 = 1, -LED_RED = LED3, -#endif /* USE_IOEXPANDER */ -}Led_TypeDef; - - -typedef enum -{ - BUTTON_WAKEUP = 0, - BUTTON_TAMPER = 1, - BUTTON_KEY = 2 -}Button_TypeDef; - -typedef enum -{ - BUTTON_MODE_GPIO = 0, - BUTTON_MODE_EXTI = 1 -}ButtonMode_TypeDef; - -#if defined(USE_IOEXPANDER) -typedef enum -{ - JOY_MODE_GPIO = 0, - JOY_MODE_EXTI = 1 -}JOYMode_TypeDef; - -typedef enum -{ - JOY_NONE = 0, - JOY_SEL = 1, - JOY_DOWN = 2, - JOY_LEFT = 3, - JOY_RIGHT = 4, - JOY_UP = 5 -}JOYState_TypeDef; -#endif /* USE_IOEXPANDER */ - -typedef enum -{ - COM1 = 0, - COM2 = 1 -}COM_TypeDef; -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_LOW_LEVEL_Exported_Constants STM32446E EVAL Low Level Exported Constants - * @{ - */ - -/** - * @brief Define for STM32446E_EVAL board - */ -#if !defined (USE_STM32446E_EVAL) - #define USE_STM32446E_EVAL -#endif - -/** @addtogroup STM32446E_EVAL_LOW_LEVEL_LED STM32446E EVAL Low Level Led - * @{ - */ - -#if !defined(USE_STM32446E_EVAL_REVA) - -#if defined(USE_IOEXPANDER) -#define LEDn ((uint8_t)4) -#define LED2_PIN IO_PIN_21 -#define LED4_PIN IO_PIN_23 -#else -#define LEDn ((uint8_t)2) -#endif /* USE_IOEXPANDER */ - -#define LEDx_GPIO_PORT GPIOB -#define LEDx_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE() -#define LEDx_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE() -#define LED1_PIN GPIO_PIN_11 -#define LED3_PIN GPIO_PIN_4 - -#else - -#define LEDn ((uint8_t)4) -#define LED1_PIN IO_PIN_20 -#define LED3_PIN IO_PIN_22 -#define LED2_PIN IO_PIN_21 -#define LED4_PIN IO_PIN_23 - -#endif // !USE_STM32446E_EVAL_REVA - - -/** - * @} - */ - -/** @addtogroup STM32446E_EVAL_LOW_LEVEL_BUTTON STM32446E EVAL Low Level Button - * @{ - */ -/* Joystick pins are connected to IO Expander (accessible through FMPI2C interface) */ -#define BUTTONn ((uint8_t)3) - -/** - * @brief Wakeup push-button - */ -#define WAKEUP_BUTTON_PIN GPIO_PIN_13 -#define WAKEUP_BUTTON_GPIO_PORT GPIOC -#define WAKEUP_BUTTON_GPIO_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE() -#define WAKEUP_BUTTON_GPIO_CLK_DISABLE() __HAL_RCC_GPIOC_CLK_DISABLE() -#define WAKEUP_BUTTON_EXTI_IRQn EXTI15_10_IRQn - -/** - * @brief Tamper push-button - */ -#define TAMPER_BUTTON_PIN GPIO_PIN_13 -#define TAMPER_BUTTON_GPIO_PORT GPIOC -#define TAMPER_BUTTON_GPIO_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE() -#define TAMPER_BUTTON_GPIO_CLK_DISABLE() __HAL_RCC_GPIOC_CLK_DISABLE() -#define TAMPER_BUTTON_EXTI_IRQn EXTI15_10_IRQn - -/** - * @brief Key push-button - */ -#define KEY_BUTTON_PIN GPIO_PIN_13 -#define KEY_BUTTON_GPIO_PORT GPIOC -#define KEY_BUTTON_GPIO_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE() -#define KEY_BUTTON_GPIO_CLK_DISABLE() __HAL_RCC_GPIOC_CLK_DISABLE() -#define KEY_BUTTON_EXTI_IRQn EXTI15_10_IRQn - -/** - * @brief MFX Irq Out Pin - */ -#define MFX_IRQOUT_PIN GPIO_PIN_0 -#define MFX_IRQOUT_GPIO_PORT GPIOA -#define MFX_IRQOUT_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE() -#define MFX_IRQOUT_GPIO_CLK_DISABLE() __HAL_RCC_GPIOA_CLK_DISABLE() -#define MFX_IRQOUT_EXTI_IRQn EXTI0_IRQn - -#define BUTTONx_GPIO_CLK_ENABLE(__INDEX__) do { if((__INDEX__) == 0) {WAKEUP_BUTTON_GPIO_CLK_ENABLE();} else\ - if((__INDEX__) == 1) {TAMPER_BUTTON_GPIO_CLK_ENABLE();} else\ - {KEY_BUTTON_GPIO_CLK_ENABLE(); }} while(0) - -#define BUTTONx_GPIO_CLK_DISABLE(__INDEX__) (((__INDEX__) == 0) ? WAKEUP_BUTTON_GPIO_CLK_DISABLE() :\ - ((__INDEX__) == 1) ? TAMPER_BUTTON_GPIO_CLK_DISABLE() : KEY_BUTTON_GPIO_CLK_DISABLE()) -/** - * @} - */ - -/** @addtogroup STM32446E_EVAL_LOW_LEVEL_COM STM32446E EVAL Low Level COM - * @{ - */ -#define COMn ((uint8_t)1) - -/** - * @brief Definition for COM port1, connected to USART1 - */ -#define EVAL_COM1 USART1 -#define EVAL_COM1_CLK_ENABLE() __HAL_RCC_USART1_CLK_ENABLE() -#define EVAL_COM1_CLK_DISABLE() __HAL_RCC_USART1_CLK_DISABLE() - -#define EVAL_COM1_TX_PIN GPIO_PIN_9 -#define EVAL_COM1_TX_GPIO_PORT GPIOA -#define EVAL_COM1_TX_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE() -#define EVAL_COM1_TX_GPIO_CLK_DISABLE() __HAL_RCC_GPIOA_CLK_DISABLE() -#define EVAL_COM1_TX_AF GPIO_AF7_USART1 - -#define EVAL_COM1_RX_PIN GPIO_PIN_10 -#define EVAL_COM1_RX_GPIO_PORT GPIOA -#define EVAL_COM1_RX_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE() -#define EVAL_COM1_RX_GPIO_CLK_DISABLE() __HAL_RCC_GPIOA_CLK_DISABLE() -#define EVAL_COM1_RX_AF GPIO_AF7_USART1 - -#define EVAL_COM1_IRQn USART1_IRQn - -#define EVAL_COMx_CLK_ENABLE(__INDEX__) do { if((__INDEX__) == COM1) {EVAL_COM1_CLK_ENABLE();} } while(0) -#define EVAL_COMx_CLK_DISABLE(__INDEX__) (((__INDEX__) == 0) ? EVAL_COM1_CLK_DISABLE() : 0) - -#define EVAL_COMx_TX_GPIO_CLK_ENABLE(__INDEX__) do { if((__INDEX__) == COM1) {EVAL_COM1_TX_GPIO_CLK_ENABLE();} } while(0) -#define EVAL_COMx_TX_GPIO_CLK_DISABLE(__INDEX__) (((__INDEX__) == 0) ? EVAL_COM1_TX_GPIO_CLK_DISABLE() : 0) - -#define EVAL_COMx_RX_GPIO_CLK_ENABLE(__INDEX__) do { if((__INDEX__) == COM1) {EVAL_COM1_RX_GPIO_CLK_ENABLE();} } while(0) -#define EVAL_COMx_RX_GPIO_CLK_DISABLE(__INDEX__) (((__INDEX__) == 0) ? EVAL_COM1_RX_GPIO_CLK_DISABLE() : 0) - -/** - * @brief Joystick Pins definition - */ -#if defined(USE_IOEXPANDER) - -#define JOY_SEL_PIN IO_PIN_5 -#define JOY_UP_PIN IO_PIN_4 -#define JOY_DOWN_PIN IO_PIN_3 -#define JOY_LEFT_PIN IO_PIN_2 -#define JOY_RIGHT_PIN IO_PIN_1 -#define JOY_NONE_PIN JOY_ALL_PINS -#define JOY_ALL_PINS (IO_PIN_5 | IO_PIN_1 | IO_PIN_2 | IO_PIN_3 | IO_PIN_4) - -#endif /* USE_IOEXPANDER */ - -/** - * @brief Eval Pins definition connected to MFX - */ - -#if defined(USE_IOEXPANDER) - -#define XSDN_PIN IO_PIN_10 -#define RSTI_PIN IO_PIN_11 -#define CAM_PLUG_PIN IO_PIN_12 -#define AUDIO_INT_PIN IO_PIN_5 -#define OTG_FS1_OVER_CURRENT_PIN IO_PIN_6 -#define OTG_FS1_POWER_SWITCH_PIN IO_PIN_7 -#define OTG_FS2_OVER_CURRENT_PIN IO_PIN_8 -#define SD_DETECT_PIN IO_PIN_15 - -#endif /* USE_IOEXPANDER */ - - -/* Exported constant IO ------------------------------------------------------*/ - -/* The MFX_I2C_ADDR input pin selects the MFX I2C device address - MFX_I2C_ADDR input pin MFX I2C device address - 0 b: 1000 010x (0x84) - 1 b: 1000 011x (0x86) - This input is sampled during the MFX firmware startup. */ - -#define IO_I2C_ADDRESS ((uint16_t)0x84) /*mfx MFX_I2C_ADDR 0*/ -#define IO_I2C_ADDRESS_2 ((uint16_t)0x86) /*mfx MFX_I2C_ADDR 1*/ -#define TS_I2C_ADDRESS ((uint16_t)0x84) /*mfx MFX_I2C_ADDR 0*/ -#define TS_I2C_ADDRESS_2 ((uint16_t)0x86) /*mfx MFX_I2C_ADDR 1*/ - - -#define CAMERA_I2C_ADDRESS ((uint16_t)0x5A) -#define AUDIO_I2C_ADDRESS ((uint16_t)0x34) -#define EEPROM_I2C_ADDRESS_A01 ((uint16_t)0xA0) -#define EEPROM_I2C_ADDRESS_A02 ((uint16_t)0xA6) - - -/* User can use this section to tailor I2Cx/I2Cx instance used and associated - resources */ -/* Definition for I2Cx clock resources */ -#define EVAL_I2Cx FMPI2C1 -#define EVAL_I2Cx_CLK_ENABLE() __HAL_RCC_FMPI2C1_CLK_ENABLE() -#define EVAL_I2Cx_CLK_DISABLE() __HAL_RCC_FMPI2C1_CLK_DISABLE() -#define EVAL_DMAx_CLK_ENABLE() __HAL_RCC_DMA1_CLK_ENABLE() -#define EVAL_I2Cx_SCL_SDA_GPIO_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE() -#define EVAL_I2Cx_SCL_SDA_GPIO_CLK_DISABLE() __HAL_RCC_GPIOD_CLK_DISABLE() - -#define EVAL_I2Cx_FORCE_RESET() __HAL_RCC_FMPI2C1_FORCE_RESET() -#define EVAL_I2Cx_RELEASE_RESET() __HAL_RCC_FMPI2C1_RELEASE_RESET() - -/* Definition for I2Cx Pins */ -#define EVAL_I2Cx_SCL_PIN GPIO_PIN_12 -#define EVAL_I2Cx_SCL_SDA_GPIO_PORT GPIOD -#define EVAL_I2Cx_SCL_SDA_AF GPIO_AF4_FMPI2C1 -#define EVAL_I2Cx_SDA_PIN GPIO_PIN_13 - -/* I2C interrupt requests */ -#define EVAL_I2Cx_EV_IRQn FMPI2C1_EV_IRQn -#define EVAL_I2Cx_ER_IRQn FMPI2C1_ER_IRQn - -#ifndef EVAL_I2Cx_TIMING -#define EVAL_I2Cx_TIMING ((uint32_t)0x00805252) -#endif /* EVAL_I2Cx_TIMING */ - - -/** - * @} - */ - -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_LOW_LEVEL_Exported_Macros STM32446E EVAL Low Level Exported Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_LOW_LEVEL_Exported_Functions STM32446E EVAL Low Level Exported Functions - * @{ - */ -uint32_t BSP_GetVersion(void); -void BSP_LED_Init(Led_TypeDef Led); -void BSP_LED_DeInit(Led_TypeDef Led); -void BSP_LED_On(Led_TypeDef Led); -void BSP_LED_Off(Led_TypeDef Led); -void BSP_LED_Toggle(Led_TypeDef Led); -void BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef ButtonMode); -void BSP_PB_DeInit(Button_TypeDef Button); -uint32_t BSP_PB_GetState(Button_TypeDef Button); -void BSP_COM_Init(COM_TypeDef COM, UART_HandleTypeDef *husart); -void BSP_COM_DeInit(COM_TypeDef COM, UART_HandleTypeDef *huart); -#if defined(USE_IOEXPANDER) -uint8_t BSP_JOY_Init(JOYMode_TypeDef JoyMode); -void BSP_JOY_DeInit(void); -JOYState_TypeDef BSP_JOY_GetState(void); -void BSP_MFX_reg_access_for_debug(void); -#endif /* USE_IOEXPANDER */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32446E_EVAL_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/stm32446e_eval_audio.c b/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/stm32446e_eval_audio.c deleted file mode 100644 index af65a03271..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/stm32446e_eval_audio.c +++ /dev/null @@ -1,1368 +0,0 @@ -/** - ****************************************************************************** - * @file stm32446e_eval_audio.c - * @author MCD Application Team - * @version V1.1.0 - * @date 14-August-2015 - * @brief This file provides the Audio driver for the STM32446E-EVAL evaluation board. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/*============================================================================== - User NOTES - -How To use this driver: ------------------------ - + This driver supports STM32F4xx devices on STM32446E-EVAL (MB1045) Evaluation boards. - + Call the function BSP_AUDIO_OUT_Init( - OutputDevice: physical output mode (OUTPUT_DEVICE_SPEAKER, - OUTPUT_DEVICE_HEADPHONE or OUTPUT_DEVICE_BOTH) - Volume : Initial volume to be set (0 is min (mute), 100 is max (100%) - AudioFreq : Audio frequency in Hz (8000, 16000, 22500, 32000...) - this parameter is relative to the audio file/stream type. - ) - This function configures all the hardware required for the audio application (codec, I2C, SAI, - GPIOs, DMA and interrupt if needed). This function returns AUDIO_OK if configuration is OK. - If the returned value is different from AUDIO_OK or the function is stuck then the communication with - the codec or the MFX has failed (try to un-plug the power or reset device in this case). - - OUTPUT_DEVICE_SPEAKER : only speaker will be set as output for the audio stream. - - OUTPUT_DEVICE_HEADPHONE: only headphones will be set as output for the audio stream. - - OUTPUT_DEVICE_BOTH : both Speaker and Headphone are used as outputs for the audio stream - at the same time. - Note. On STM32446E-EVAL SAI_DMA is configured in CIRCULAR mode. Due to this the application - does NOT need to call BSP_AUDIO_OUT_ChangeBuffer() to assure streaming. - + Call the function BSP_EVAL_AUDIO_OUT_Play( - pBuffer: pointer to the audio data file address - Size : size of the buffer to be sent in Bytes - ) - to start playing (for the first time) from the audio file/stream. - + Call the function BSP_AUDIO_OUT_Pause() to pause playing - + Call the function BSP_AUDIO_OUT_Resume() to resume playing. - Note. After calling BSP_AUDIO_OUT_Pause() function for pause, only BSP_AUDIO_OUT_Resume() should be called - for resume (it is not allowed to call BSP_AUDIO_OUT_Play() in this case). - Note. This function should be called only when the audio file is played or paused (not stopped). - + For each mode, you may need to implement the relative callback functions into your code. - The Callback functions are named AUDIO_OUT_XXX_CallBack() and only their prototypes are declared in - the stm32446e_eval_audio.h file. (refer to the example for more details on the callbacks implementations) - + To Stop playing, to modify the volume level, the frequency, the audio frame slot, - the device output mode the mute or the stop, use the functions: BSP_AUDIO_OUT_SetVolume(), - AUDIO_OUT_SetFrequency(), BSP_AUDIO_OUT_SetAudioFrameSlot(), BSP_AUDIO_OUT_SetOutputMode(), - BSP_AUDIO_OUT_SetMute() and BSP_AUDIO_OUT_Stop(). - + The driver API and the callback functions are at the end of the stm32446e_eval_audio.h file. - - -Driver architecture: --------------------- - + This driver provides the High Audio Layer: consists of the function API exported in the stm32446e_eval_audio.h file - (BSP_AUDIO_OUT_Init(), BSP_AUDIO_OUT_Play() ...) - + This driver provide also the Media Access Layer (MAL): which consists of functions allowing to access the media containing/ - providing the audio file/stream. These functions are also included as local functions into - the stm32446e_eval_audio_codec.c file (I2Sx_Init(), I2Sx_DeInit(), SAIx_Init() and SAIx_DeInit()) - -Known Limitations: ------------------- - 1- If the TDM Format used to play in parallel 2 audio Stream (the first Stream is configured in codec SLOT0 and second - Stream in SLOT1) the Pause/Resume, volume and mute feature will control the both streams. - 2- Parsing of audio file is not implemented (in order to determine audio file properties: Mono/Stereo, Data size, - File size, Audio Frequency, Audio Data header size ...). The configuration is fixed for the given audio file. - 3- Supports only Stereo audio streaming. - 4- Supports only 16-bits audio data size. -==============================================================================*/ - -/* Includes ------------------------------------------------------------------*/ -#include "stm32446e_eval_audio.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32446E_EVAL - * @{ - */ - -/** @defgroup STM32446E_EVAL_AUDIO STM32446E-EVAL AUDIO - * @brief This file includes the low layer driver for wm8994 Audio Codec - * available on STM32446E-EVAL evaluation board(MB1045). - * @{ - */ - -/** @defgroup STM32446E_EVAL_AUDIO_Private_Types STM32446E Eval Audio Private Types - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_AUDIO_Private_Defines STM32446E Eval Audio Private Defines - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_AUDIO_Private_Macros STM32446E Eval Audio Private macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_AUDIO_Private_Variables STM32446E Eval Audio Private Variables - * @{ - */ - -/* -Note: - these global variables are not compliant to naming rules (upper case without "_" ), - but we keep this naming for compatibility, in fact these variables (not static) - could have been used by the application, example the stm32f4xx_it.c: - void DMA2_Stream6_IRQHandler(void) - { HAL_DMA_IRQHandler(haudio_out_sai.hdmatx); } -*/ -AUDIO_DrvTypeDef *audio_drv; -SAI_HandleTypeDef haudio_out_sai; -I2S_HandleTypeDef haudio_in_i2s; -TIM_HandleTypeDef haudio_tim; - -PDMFilter_InitStruct Filter[2]; -uint8_t Channel_Demux[128] = { - 0x00, 0x01, 0x00, 0x01, 0x02, 0x03, 0x02, 0x03, - 0x00, 0x01, 0x00, 0x01, 0x02, 0x03, 0x02, 0x03, - 0x04, 0x05, 0x04, 0x05, 0x06, 0x07, 0x06, 0x07, - 0x04, 0x05, 0x04, 0x05, 0x06, 0x07, 0x06, 0x07, - 0x00, 0x01, 0x00, 0x01, 0x02, 0x03, 0x02, 0x03, - 0x00, 0x01, 0x00, 0x01, 0x02, 0x03, 0x02, 0x03, - 0x04, 0x05, 0x04, 0x05, 0x06, 0x07, 0x06, 0x07, - 0x04, 0x05, 0x04, 0x05, 0x06, 0x07, 0x06, 0x07, - 0x08, 0x09, 0x08, 0x09, 0x0a, 0x0b, 0x0a, 0x0b, - 0x08, 0x09, 0x08, 0x09, 0x0a, 0x0b, 0x0a, 0x0b, - 0x0c, 0x0d, 0x0c, 0x0d, 0x0e, 0x0f, 0x0e, 0x0f, - 0x0c, 0x0d, 0x0c, 0x0d, 0x0e, 0x0f, 0x0e, 0x0f, - 0x08, 0x09, 0x08, 0x09, 0x0a, 0x0b, 0x0a, 0x0b, - 0x08, 0x09, 0x08, 0x09, 0x0a, 0x0b, 0x0a, 0x0b, - 0x0c, 0x0d, 0x0c, 0x0d, 0x0e, 0x0f, 0x0e, 0x0f, - 0x0c, 0x0d, 0x0c, 0x0d, 0x0e, 0x0f, 0x0e, 0x0f -}; - -uint16_t __IO AudioInVolume = DEFAULT_AUDIO_IN_VOLUME; - -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_AUDIO_Private_Function_Prototypes STM32446E Eval Audio Private Prototypes - * @{ - */ -static void SAIx_Init(uint32_t AudioFreq); -static void SAIx_DeInit(void); -static void I2Sx_Init(uint32_t AudioFreq); -static void I2Sx_DeInit(void); -static void TIMx_IC_MspInit(TIM_HandleTypeDef *htim); -static void TIMx_IC_MspDeInit(TIM_HandleTypeDef *htim); -static void TIMx_Init(void); -static void TIMx_DeInit(void); -static void PDMDecoder_Init(uint32_t AudioFreq, uint32_t ChnlNbr); -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_AUDIO_out_Private_Functions STM32446E Eval AudioOut Private Functions - * @{ - */ - -/** - * @brief Configures the audio peripherals. - * @param OutputDevice: OUTPUT_DEVICE_SPEAKER, OUTPUT_DEVICE_HEADPHONE, - * or OUTPUT_DEVICE_BOTH. - * @param Volume: Initial volume level (from 0 (Mute) to 100 (Max)) - * @param AudioFreq: Audio frequency used to play the audio stream. - * @note The I2S PLL input clock must be done in the user application. - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_Init(uint16_t OutputDevice, uint8_t Volume, uint32_t AudioFreq) -{ - uint8_t ret = AUDIO_ERROR; - uint32_t deviceid = 0x00; - - SAIx_DeInit(); - - /* PLL clock is set depending by the AudioFreq (44.1khz vs 48khz groups) */ - BSP_AUDIO_OUT_ClockConfig(&haudio_out_sai, AudioFreq, NULL); - - /* SAI data transfer preparation: - Prepare the Media to be used for the audio transfer from memory to SAI peripheral */ - haudio_out_sai.Instance = AUDIO_SAIx; - if(HAL_SAI_GetState(&haudio_out_sai) == HAL_SAI_STATE_RESET) - { - /* Init the SAI MSP: this __weak function can be redefined by the application*/ - BSP_AUDIO_OUT_MspInit(&haudio_out_sai, NULL); - } - SAIx_Init(AudioFreq); - - /* wm8994 codec initialization */ - deviceid = wm8994_drv.ReadID(AUDIO_I2C_ADDRESS); - - if((deviceid) == WM8994_ID) - { - /* Initialize the audio driver structure */ - audio_drv = &wm8994_drv; - ret = AUDIO_OK; - } - else - { - ret = AUDIO_ERROR; - } - - if(ret == AUDIO_OK) - { - /* Resets the audio codec. */ - audio_drv->Reset(AUDIO_I2C_ADDRESS); - /* Initialize the codec internal registers */ - audio_drv->Init(AUDIO_I2C_ADDRESS, OutputDevice, Volume, AudioFreq); - } - - return ret; -} - -/** - * @brief Starts playing audio stream from a data buffer for a determined size. - * @param pBuffer: Pointer to the buffer - * @param Size: Number of audio data BYTES. - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_Play(uint16_t* pBuffer, uint32_t Size) -{ - /* Call the audio Codec Play function */ - if(audio_drv->Play(AUDIO_I2C_ADDRESS, pBuffer, Size) != 0) - { - return AUDIO_ERROR; - } - else - { - /* Update the Media layer and enable it for play */ - HAL_SAI_Transmit_DMA(&haudio_out_sai, (uint8_t*) pBuffer, DMA_MAX(Size / AUDIODATA_SIZE)); - - return AUDIO_OK; - } -} - -/** - * @brief Sends n-Bytes on the SAI interface. - * @param pData: pointer on data address - * @param Size: number of data to be written - * @retval None - */ -void BSP_AUDIO_OUT_ChangeBuffer(uint16_t *pData, uint16_t Size) -{ - HAL_SAI_Transmit_DMA(&haudio_out_sai, (uint8_t*) pData, Size); -} - -/** - * @brief This function Pauses the audio file stream. In case - * of using DMA, the DMA Pause feature is used. - * @WARNING When calling BSP_AUDIO_OUT_Pause() function for pause, only - * BSP_AUDIO_OUT_Resume() function should be called for resume (use of BSP_AUDIO_OUT_Play() - * function for resume could lead to unexpected behavior). - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_Pause(void) -{ - /* Call the Audio Codec Pause/Resume function */ - if(audio_drv->Pause(AUDIO_I2C_ADDRESS) != 0) - { - return AUDIO_ERROR; - } - else - { - /* Call the Media layer pause function */ - HAL_SAI_DMAPause(&haudio_out_sai); - - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; - } -} - -/** - * @brief This function Resumes the audio file stream. - * @WARNING When calling BSP_AUDIO_OUT_Pause() function for pause, only - * BSP_AUDIO_OUT_Resume() function should be called for resume (use of BSP_AUDIO_OUT_Play() - * function for resume could lead to unexpected behavior). - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_Resume(void) -{ - /* Call the Audio Codec Pause/Resume function */ - if(audio_drv->Resume(AUDIO_I2C_ADDRESS) != 0) - { - return AUDIO_ERROR; - } - else - { - /* Call the Media layer pause/resume function */ - HAL_SAI_DMAResume(&haudio_out_sai); - - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; - } -} - -/** - * @brief Stops audio playing and Power down the Audio Codec. - * @param Option: could be one of the following parameters - * - CODEC_PDWN_SW: for software power off (by writing registers). - * Then no need to reconfigure the Codec after power on. - * - CODEC_PDWN_HW: completely shut down the codec (physically). - * Then need to reconfigure the Codec after power on. - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_Stop(uint32_t Option) -{ - /* Call the Media layer stop function */ - HAL_SAI_DMAStop(&haudio_out_sai); - - /* Call Audio Codec Stop function */ - if(audio_drv->Stop(AUDIO_I2C_ADDRESS, Option) != 0) - { - return AUDIO_ERROR; - } - else - { - if(Option == CODEC_PDWN_HW) - { - /* Wait at least 100us */ - HAL_Delay(1); - } - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; - } -} - -/** - * @brief Controls the current audio volume level. - * @param Volume: Volume level to be set in percentage from 0% to 100% (0 for - * Mute and 100 for Max volume level). - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_SetVolume(uint8_t Volume) -{ - /* Call the codec volume control function with converted volume value */ - if(audio_drv->SetVolume(AUDIO_I2C_ADDRESS, Volume) != 0) - { - return AUDIO_ERROR; - } - else - { - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; - } -} - -/** - * @brief Enables or disables the MUTE mode by software - * @param Cmd: Could be AUDIO_MUTE_ON to mute sound or AUDIO_MUTE_OFF to - * unmute the codec and restore previous volume level. - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_SetMute(uint32_t Cmd) -{ - /* Call the Codec Mute function */ - if(audio_drv->SetMute(AUDIO_I2C_ADDRESS, Cmd) != 0) - { - return AUDIO_ERROR; - } - else - { - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; - } -} - -/** - * @brief Switch dynamically (while audio file is played) the output target - * (speaker or headphone). - * @param Output: The audio output target: OUTPUT_DEVICE_SPEAKER, - * OUTPUT_DEVICE_HEADPHONE or OUTPUT_DEVICE_BOTH - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_SetOutputMode(uint8_t Output) -{ - /* Call the Codec output device function */ - if(audio_drv->SetOutputMode(AUDIO_I2C_ADDRESS, Output) != 0) - { - return AUDIO_ERROR; - } - else - { - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; - } -} - -/** - * @brief Updates the audio frequency. - * @param AudioFreq: Audio frequency used to play the audio stream. - * @note This API should be called after the BSP_AUDIO_OUT_Init() to adjust the - * audio frequency. - * @retval None - */ -void BSP_AUDIO_OUT_SetFrequency(uint32_t AudioFreq) -{ - /* PLL clock is set depending by the AudioFreq (44.1khz vs 48khz groups) */ - BSP_AUDIO_OUT_ClockConfig(&haudio_out_sai, AudioFreq, NULL); - - /* Disable SAI peripheral to allow access to SAI internal registers */ - __HAL_SAI_DISABLE(&haudio_out_sai); - - /* Update the SAI audio frequency configuration */ - haudio_out_sai.Init.AudioFrequency = AudioFreq; - HAL_SAI_Init(&haudio_out_sai); - - /* Enable SAI peripheral to generate MCLK */ - __HAL_SAI_ENABLE(&haudio_out_sai); -} - -/** - * @brief Updates the Audio frame slot configuration. - * @param AudioFrameSlot: specifies the audio Frame slot - * This parameter can be any value of @ref CODEC_AudioFrame_SLOT_TDMMode - * @note This API should be called after the BSP_AUDIO_OUT_Init() to adjust the - * audio frame slot. - * @retval None - */ -void BSP_AUDIO_OUT_SetAudioFrameSlot(uint32_t AudioFrameSlot) -{ - /* Disable SAI peripheral to allow access to SAI internal registers */ - __HAL_SAI_DISABLE(&haudio_out_sai); - - /* Update the SAI audio frame slot configuration */ - haudio_out_sai.SlotInit.SlotActive = AudioFrameSlot; - HAL_SAI_Init(&haudio_out_sai); - - /* Enable SAI peripheral to generate MCLK */ - __HAL_SAI_ENABLE(&haudio_out_sai); -} - -/** - * @brief Deinit the audio peripherals. - * @param None - * @retval None - */ -void BSP_AUDIO_OUT_DeInit(void) -{ - SAIx_DeInit(); - /* DeInit the SAI MSP : this __weak function can be rewritten by the applic */ - BSP_AUDIO_OUT_MspDeInit(&haudio_out_sai, NULL); -} - -/** - * @brief Tx Transfer completed callbacks. - * @param hsai: SAI handle - * @retval None - */ -void HAL_SAI_TxCpltCallback(SAI_HandleTypeDef *hsai) -{ - /* Manage the remaining file size and new address offset: This function - should be coded by user (its prototype is already declared in stm32446e_eval_audio.h) */ - BSP_AUDIO_OUT_TransferComplete_CallBack(); -} - -/** - * @brief Tx Half Transfer completed callbacks. - * @param hsai: SAI handle - * @retval None - */ -void HAL_SAI_TxHalfCpltCallback(SAI_HandleTypeDef *hsai) -{ - /* Manage the remaining file size and new address offset: This function - should be coded by user (its prototype is already declared in stm32446e_eval_audio.h) */ - BSP_AUDIO_OUT_HalfTransfer_CallBack(); -} - -/** - * @brief SAI error callbacks. - * @param hsai: SAI handle - * @retval None - */ -void HAL_SAI_ErrorCallback(SAI_HandleTypeDef *hsai) -{ - BSP_AUDIO_OUT_Error_CallBack(); -} - -/** - * @brief Manages the DMA full Transfer complete event. - * @param None - * @retval None - */ -__weak void BSP_AUDIO_OUT_TransferComplete_CallBack(void) -{ -} - -/** - * @brief Manages the DMA Half Transfer complete event. - * @param None - * @retval None - */ -__weak void BSP_AUDIO_OUT_HalfTransfer_CallBack(void) -{ -} - -/** - * @brief Manages the DMA FIFO error event. - * @param None - * @retval None - */ -__weak void BSP_AUDIO_OUT_Error_CallBack(void) -{ -} - -/** - * @brief Initializes BSP_AUDIO_OUT MSP. - * @param hsai: SAI handle - * @retval None - */ -__weak void BSP_AUDIO_OUT_MspInit(SAI_HandleTypeDef *hsai, void *Params) -{ - static DMA_HandleTypeDef hdma_sai_tx; - GPIO_InitTypeDef gpio_init_structure; - - /* Enable SAI clock */ - AUDIO_SAIx_CLK_ENABLE(); - - /* Enable GPIO clock */ - AUDIO_SAIx_MCLK_SCK_ENABLE(); - AUDIO_SAIx_SD_FS_ENABLE(); - - /* CODEC_SAI pins configuration: FS, SCK, MCK and SD pins ------------------*/ - gpio_init_structure.Mode = GPIO_MODE_AF_PP; - gpio_init_structure.Pull = GPIO_NOPULL; - gpio_init_structure.Speed = GPIO_SPEED_HIGH; - - gpio_init_structure.Alternate = AUDIO_SAIx_MCLK_SD_FS_AF; - gpio_init_structure.Pin = AUDIO_SAIx_FS_PIN | AUDIO_SAIx_SD_PIN; - HAL_GPIO_Init(AUDIO_SAIx_SD_FS_GPIO_PORT, &gpio_init_structure); - - gpio_init_structure.Alternate = AUDIO_SAIx_MCLK_SD_FS_AF; - gpio_init_structure.Pin = AUDIO_SAIx_MCK_PIN; - HAL_GPIO_Init(AUDIO_SAIx_MCLK_SCK_GPIO_PORT, &gpio_init_structure); - - gpio_init_structure.Alternate = AUDIO_SAIx_SCK_AF; - gpio_init_structure.Pin = AUDIO_SAIx_SCK_PIN ; - HAL_GPIO_Init(AUDIO_SAIx_MCLK_SCK_GPIO_PORT, &gpio_init_structure); - - /* Enable the DMA clock */ - AUDIO_SAIx_DMAx_CLK_ENABLE(); - - if(hsai->Instance == AUDIO_SAIx) - { - /* Configure the hdma_sai_tx handle parameters */ - hdma_sai_tx.Init.Channel = AUDIO_SAIx_DMAx_CHANNEL; - hdma_sai_tx.Init.Direction = DMA_MEMORY_TO_PERIPH; - hdma_sai_tx.Init.PeriphInc = DMA_PINC_DISABLE; - hdma_sai_tx.Init.MemInc = DMA_MINC_ENABLE; - hdma_sai_tx.Init.PeriphDataAlignment = AUDIO_SAIx_DMAx_PERIPH_DATA_SIZE; - hdma_sai_tx.Init.MemDataAlignment = AUDIO_SAIx_DMAx_MEM_DATA_SIZE; - hdma_sai_tx.Init.Mode = DMA_CIRCULAR; - hdma_sai_tx.Init.Priority = DMA_PRIORITY_HIGH; - hdma_sai_tx.Init.FIFOMode = DMA_FIFOMODE_ENABLE; - hdma_sai_tx.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; - hdma_sai_tx.Init.MemBurst = DMA_MBURST_SINGLE; - hdma_sai_tx.Init.PeriphBurst = DMA_PBURST_SINGLE; - - hdma_sai_tx.Instance = AUDIO_SAIx_DMAx_STREAM; - - /* Associate the DMA handle */ - __HAL_LINKDMA(hsai, hdmatx, hdma_sai_tx); - - /* Deinitialize the Stream for new transfer */ - HAL_DMA_DeInit(&hdma_sai_tx); - - /* Configure the DMA Stream */ - HAL_DMA_Init(&hdma_sai_tx); - } - - /* SAI DMA IRQ Channel configuration */ - HAL_NVIC_SetPriority(AUDIO_SAIx_DMAx_IRQ, AUDIO_OUT_IRQ_PREPRIO, 0); - HAL_NVIC_EnableIRQ(AUDIO_SAIx_DMAx_IRQ); -} - -/** - * @brief Deinitializes SAI MSP. - * @param hsai: SAI handle - * @retval None - */ -__weak void BSP_AUDIO_OUT_MspDeInit(SAI_HandleTypeDef *hsai, void *Params) -{ - GPIO_InitTypeDef gpio_init_structure; - - /* SAI DMA IRQ Channel deactivation */ - HAL_NVIC_DisableIRQ(AUDIO_SAIx_DMAx_IRQ); - - if(hsai->Instance == AUDIO_SAIx) - { - /* Deinitialize the DMA stream */ - HAL_DMA_DeInit(hsai->hdmatx); - } - - /* Disable SAI peripheral */ - __HAL_SAI_DISABLE(hsai); - - /* Deactives CODEC_SAI pins FS, SCK, MCK and SD by putting them in input mode */ - gpio_init_structure.Pin = AUDIO_SAIx_FS_PIN | AUDIO_SAIx_SD_PIN; - HAL_GPIO_DeInit(AUDIO_SAIx_SD_FS_GPIO_PORT, gpio_init_structure.Pin); - - gpio_init_structure.Pin = AUDIO_SAIx_MCK_PIN; - HAL_GPIO_DeInit(AUDIO_SAIx_MCLK_SCK_GPIO_PORT, gpio_init_structure.Pin); - - gpio_init_structure.Pin = AUDIO_SAIx_SCK_PIN ; - HAL_GPIO_DeInit(AUDIO_SAIx_MCLK_SCK_GPIO_PORT, gpio_init_structure.Pin); - - /* Disable SAI clock */ - AUDIO_SAIx_CLK_DISABLE(); - - /* GPIO pins clock and DMA clock can be shut down in the application - by surcharging this __weak function */ -} - -/** - * @brief Clock Config. - * @param hsai: might be required to set audio peripheral predivider if any. - * @param AudioFreq: Audio frequency used to play the audio stream. - * @note This API is called by BSP_AUDIO_OUT_Init() and BSP_AUDIO_OUT_SetFrequency() - * Being __weak it can be overwritten by the application - * @retval None - */ -__weak void BSP_AUDIO_OUT_ClockConfig(SAI_HandleTypeDef *hsai, uint32_t AudioFreq, void *Params) -{ - RCC_PeriphCLKInitTypeDef rcc_ex_clk_init_struct; - - HAL_RCCEx_GetPeriphCLKConfig(&rcc_ex_clk_init_struct); - - /* Set the PLL configuration according to the audio frequency */ - if((AudioFreq == AUDIO_FREQUENCY_11K) || (AudioFreq == AUDIO_FREQUENCY_22K) || (AudioFreq == AUDIO_FREQUENCY_44K)) - { - /* Configure PLLSAI prescalers */ - /* PLLSAI_VCO: VCO_429M - SAI_CLK(first level) = PLLSAI_VCO/PLLSAIQ = 429/2 = 214.5 Mhz - SAI_CLK_x = SAI_CLK(first level)/PLLSAIDIVQ = 214.5/19 = 11.289 Mhz */ - rcc_ex_clk_init_struct.PeriphClockSelection = RCC_PERIPHCLK_SAI2; - rcc_ex_clk_init_struct.Sai2ClockSelection = RCC_SAI2CLKSOURCE_PLLSAI; - rcc_ex_clk_init_struct.PLLSAI.PLLSAIM = 8; - rcc_ex_clk_init_struct.PLLSAI.PLLSAIN = 429; - rcc_ex_clk_init_struct.PLLSAI.PLLSAIQ = 2; - rcc_ex_clk_init_struct.PLLSAIDivQ = 19; - - HAL_RCCEx_PeriphCLKConfig(&rcc_ex_clk_init_struct); - - } - else /* AUDIO_FREQUENCY_8K, AUDIO_FREQUENCY_16K, AUDIO_FREQUENCY_48K), AUDIO_FREQUENCY_96K */ - { - /* SAI clock config - PLLSAI_VCO: VCO_344M - SAI_CLK(first level) = PLLSAI_VCO/PLLSAIQ = 344/7 = 49.142 Mhz - SAI_CLK_x = SAI_CLK(first level)/PLLSAIDIVQ = 49.142/1 = 49.142 Mhz */ - rcc_ex_clk_init_struct.PeriphClockSelection = RCC_PERIPHCLK_SAI2; - rcc_ex_clk_init_struct.Sai2ClockSelection = RCC_SAI2CLKSOURCE_PLLSAI; - rcc_ex_clk_init_struct.PLLSAI.PLLSAIM = 8; - rcc_ex_clk_init_struct.PLLSAI.PLLSAIN = 344; - rcc_ex_clk_init_struct.PLLSAI.PLLSAIQ = 7; - rcc_ex_clk_init_struct.PLLSAIDivQ = 1; - - HAL_RCCEx_PeriphCLKConfig(&rcc_ex_clk_init_struct); - } -} - -/******************************************************************************* - Static Functions -*******************************************************************************/ - -/** - * @brief Initializes the Audio Codec audio interface (SAI). - * @param AudioFreq: Audio frequency to be configured for the SAI peripheral. - * @note The default SlotActive configuration is set to CODEC_AUDIOFRAME_SLOT_0123 - * and user can update this configuration using - * @retval None - */ -static void SAIx_Init(uint32_t AudioFreq) -{ - /* Initialize the hAudioOutSai Instance parameter */ - haudio_out_sai.Instance = AUDIO_SAIx; - - /* Disable SAI peripheral to allow access to SAI internal registers */ - __HAL_SAI_DISABLE(&haudio_out_sai); - - /* Configure SAI_Block_x - LSBFirst: Disabled - DataSize: 16 */ - haudio_out_sai.Init.AudioFrequency = AudioFreq; - haudio_out_sai.Init.ClockSource = SAI_CLKSOURCE_PLLSAI; - haudio_out_sai.Init.AudioMode = SAI_MODEMASTER_TX; - haudio_out_sai.Init.NoDivider = SAI_MASTERDIVIDER_ENABLE; - haudio_out_sai.Init.Protocol = SAI_FREE_PROTOCOL; - haudio_out_sai.Init.DataSize = SAI_DATASIZE_16; - haudio_out_sai.Init.FirstBit = SAI_FIRSTBIT_MSB; - haudio_out_sai.Init.ClockStrobing = SAI_CLOCKSTROBING_RISINGEDGE; - haudio_out_sai.Init.Synchro = SAI_ASYNCHRONOUS; - haudio_out_sai.Init.OutputDrive = SAI_OUTPUTDRIVE_ENABLE; - haudio_out_sai.Init.FIFOThreshold = SAI_FIFOTHRESHOLD_1QF; - - /* Configure SAI_Block_x Frame - Frame Length: 64 - Frame active Length: 32 - FS Definition: Start frame + Channel Side identification - FS Polarity: FS active Low - FS Offset: FS asserted one bit before the first bit of slot 0 */ - haudio_out_sai.FrameInit.FrameLength = 64; - haudio_out_sai.FrameInit.ActiveFrameLength = 32; - haudio_out_sai.FrameInit.FSDefinition = SAI_FS_CHANNEL_IDENTIFICATION; - haudio_out_sai.FrameInit.FSPolarity = SAI_FS_ACTIVE_LOW; - haudio_out_sai.FrameInit.FSOffset = SAI_FS_BEFOREFIRSTBIT; - - /* Configure SAI Block_x Slot - Slot First Bit Offset: 0 - Slot Size : 16 - Slot Number: 4 - Slot Active: All slot actives */ - haudio_out_sai.SlotInit.FirstBitOffset = 0; - haudio_out_sai.SlotInit.SlotSize = SAI_SLOTSIZE_DATASIZE; - haudio_out_sai.SlotInit.SlotNumber = 4; - haudio_out_sai.SlotInit.SlotActive = CODEC_AUDIOFRAME_SLOT_0123; - - HAL_SAI_Init(&haudio_out_sai); - - /* Enable SAI peripheral to generate MCLK */ - __HAL_SAI_ENABLE(&haudio_out_sai); -} - - - -/** - * @brief Deinitializes the Audio Codec audio interface (SAI). - * @param None - * @retval None - */ -static void SAIx_DeInit(void) -{ - /* Initialize the hAudioOutSai Instance parameter */ - haudio_out_sai.Instance = AUDIO_SAIx; - - /* Disable SAI peripheral */ - __HAL_SAI_DISABLE(&haudio_out_sai); - - HAL_SAI_DeInit(&haudio_out_sai); -} - - -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_AUDIO_in_Private_Functions STM32446E Eval AudioIn Private functions - * @{ - */ - -/** - * @brief Initializes wave recording. - * @note This function assumes that the I2S input clock (through PLL_R in - * Devices RevA/Z and through dedicated PLLI2S_R in Devices RevB/Y) - * is already configured and ready to be used. - * @param AudioFreq: Audio frequency to be configured for the I2S peripheral. - * @param BitRes: Audio frequency to be configured for the I2S peripheral. - * @param ChnlNbr: Audio frequency to be configured for the I2S peripheral. - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_IN_Init(uint32_t AudioFreq, uint32_t BitRes, uint32_t ChnlNbr) -{ - RCC_PeriphCLKInitTypeDef rcc_ex_clk_init_struct; - - I2Sx_DeInit(); - - HAL_RCCEx_GetPeriphCLKConfig(&rcc_ex_clk_init_struct); - rcc_ex_clk_init_struct.PeriphClockSelection = RCC_PERIPHCLK_I2S_APB1; /*SPI3 & TIM4 on APB1*/ - rcc_ex_clk_init_struct.PLLI2S.PLLI2SN = 384; - rcc_ex_clk_init_struct.PLLI2S.PLLI2SR = 2; - HAL_RCCEx_PeriphCLKConfig(&rcc_ex_clk_init_struct); - - /* Configure the PDM library */ - PDMDecoder_Init(AudioFreq, ChnlNbr); - - /* Configure the I2S peripheral */ - haudio_in_i2s.Instance = AUDIO_I2Sx; - if(HAL_I2S_GetState(&haudio_in_i2s) == HAL_I2S_STATE_RESET) - { - /* Initialize the I2S Msp: this __weak function can be rewritten by the application */ - BSP_AUDIO_IN_MspInit(&haudio_in_i2s, NULL); - } - I2Sx_Init(AudioFreq); - - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; -} - -/** - * @brief Starts audio recording. - * @param pbuf: Main buffer pointer for the recorded data storing - * @param size: Current size of the recorded buffer - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_IN_Record(uint16_t* pbuf, uint32_t size) -{ - uint32_t ret = AUDIO_ERROR; - - /* Start the process receive DMA */ - HAL_I2S_Receive_DMA(&haudio_in_i2s, pbuf, size); - - /* Return AUDIO_OK when all operations are correctly done */ - ret = AUDIO_OK; - - return ret; -} - -/** - * @brief Stops audio recording. - * @param None - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_IN_Stop(void) -{ - uint32_t ret = AUDIO_ERROR; - - /* Call the Media layer pause function */ - HAL_I2S_DMAPause(&haudio_in_i2s); - - /* TIMx Peripheral clock disable */ - AUDIO_TIMx_CLK_DISABLE(); - - /* Return AUDIO_OK when all operations are correctly done */ - ret = AUDIO_OK; - - return ret; -} - -/** - * @brief Pauses the audio file stream. - * @param None - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_IN_Pause(void) -{ - /* Call the Media layer pause function */ - HAL_I2S_DMAPause(&haudio_in_i2s); - - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; -} - -/** - * @brief Resumes the audio file stream. - * @param None - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_IN_Resume(void) -{ - /* Call the Media layer pause/resume function */ - HAL_I2S_DMAResume(&haudio_in_i2s); - - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; -} - -/** - * @brief Controls the audio in volume level. - * @param Volume: Volume level to be set in percentage from 0% to 100% (0 for - * Mute and 100 for Max volume level). - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_IN_SetVolume(uint8_t Volume) -{ - /* Set the Global variable AudioInVolume */ - AudioInVolume = Volume; - - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; -} - -/** - * @brief Deinit the audio IN peripherals. - * @param None - * @retval None - */ -void BSP_AUDIO_IN_DeInit(void) -{ - I2Sx_DeInit(); - /* DeInit the I2S MSP : this __weak function can be rewritten by the applic */ - BSP_AUDIO_IN_MspDeInit(&haudio_in_i2s, NULL); - TIMx_DeInit(); -} - -/** - * @brief Converts audio format from PDM to PCM. - * @param PDMBuf: Pointer to data PDM buffer - * @param PCMBuf: Pointer to data PCM buffer - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_IN_PDMToPCM(uint16_t* PDMBuf, uint16_t* PCMBuf) -{ - uint8_t app_pdm[INTERNAL_BUFF_SIZE*2]; - uint8_t byte1 = 0, byte2 = 0; - uint32_t index = 0; - - /* PDM Demux */ - for(index = 0; index> 8)& 0xFF; - byte1 = (PDMBuf[index] & 0xFF); - app_pdm[(index*2)+1] = Channel_Demux[byte1 & CHANNEL_DEMUX_MASK] | Channel_Demux[byte2 & CHANNEL_DEMUX_MASK] << 4; - app_pdm[(index*2)] = Channel_Demux[(byte1 >> 1) & CHANNEL_DEMUX_MASK] | Channel_Demux[(byte2 >> 1) & CHANNEL_DEMUX_MASK] << 4; - } - - for(index = 0; index < DEFAULT_AUDIO_IN_CHANNEL_NBR; index++) - { - /* PDM to PCM filter */ - PDM_Filter_64_LSB((uint8_t*)&app_pdm[index], (uint16_t*)&(PCMBuf[index]), AudioInVolume , (PDMFilter_InitStruct *)&Filter[index]); - } - - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; -} - - /** - * @brief Rx Transfer completed callbacks. - * @param hi2s: I2S handle - * @retval None - */ -void HAL_I2S_RxCpltCallback(I2S_HandleTypeDef *hi2s) -{ - /* Call the record update function to get the next buffer to fill and its size (size is ignored) */ - BSP_AUDIO_IN_TransferComplete_CallBack(); -} - -/** - * @brief Rx Half Transfer completed callbacks. - * @param hi2s: I2S handle - * @retval None - */ -void HAL_I2S_RxHalfCpltCallback(I2S_HandleTypeDef *hi2s) -{ - /* Manage the remaining file size and new address offset: This function - should be coded by user (its prototype is already declared in stm32446e_eval_audio.h) */ - BSP_AUDIO_IN_HalfTransfer_CallBack(); -} - -/** - * @brief I2S error callbacks. - * @param hi2s: I2S handle - * @retval None - */ -void HAL_I2S_ErrorCallback(I2S_HandleTypeDef *hi2s) -{ - /* Manage the error generated on DMA FIFO: This function - should be coded by user (its prototype is already declared in stm32446e_eval_audio.h) */ - BSP_AUDIO_IN_Error_Callback(); -} - -/** - * @brief User callback when record buffer is filled. - * @param None - * @retval None - */ -__weak void BSP_AUDIO_IN_TransferComplete_CallBack(void) -{ - /* This function should be implemented by the user application. - It is called into this driver when the current buffer is filled - to prepare the next buffer pointer and its size. */ -} - -/** - * @brief Manages the DMA Half Transfer complete event. - * @param None - * @retval None - */ -__weak void BSP_AUDIO_IN_HalfTransfer_CallBack(void) -{ - /* This function should be implemented by the user application. - It is called into this driver when the current buffer is filled - to prepare the next buffer pointer and its size. */ -} - -/** - * @brief Audio IN Error callback function. - * @param None - * @retval None - */ -__weak void BSP_AUDIO_IN_Error_Callback(void) -{ - /* This function is called when an Interrupt due to transfer error on or peripheral - error occurs. */ -} - -/** - * @brief Initializes BSP_AUDIO_IN MSP. - * @param hsai: I2S handle - * @retval None - */ -__weak void BSP_AUDIO_IN_MspInit(I2S_HandleTypeDef *hi2s, void *Params) -{ - static DMA_HandleTypeDef hdma_i2s_rx; - GPIO_InitTypeDef gpio_init_structure; - - /* Configure the Timer which clocks the MEMS */ - /* Moved inside MSP to allow applic to redefine the TIMx_MspInit */ - TIMx_Init(); - - /* Enable I2S clock */ - AUDIO_I2Sx_CLK_ENABLE(); - - /* Enable SCK and SD GPIO clock */ - AUDIO_I2Sx_SD_GPIO_CLK_ENABLE(); - AUDIO_I2Sx_SCK_GPIO_CLK_ENABLE(); - /* CODEC_I2S pins configuration: SCK and SD pins */ - gpio_init_structure.Pin = AUDIO_I2Sx_SCK_PIN; - gpio_init_structure.Mode = GPIO_MODE_AF_PP; - gpio_init_structure.Pull = GPIO_NOPULL; - gpio_init_structure.Speed = GPIO_SPEED_FAST; - gpio_init_structure.Alternate = AUDIO_I2Sx_SCK_AF; - HAL_GPIO_Init(AUDIO_I2Sx_SCK_GPIO_PORT, &gpio_init_structure); - - gpio_init_structure.Pin = AUDIO_I2Sx_SD_PIN; - gpio_init_structure.Alternate = AUDIO_I2Sx_SD_AF; - HAL_GPIO_Init(AUDIO_I2Sx_SD_GPIO_PORT, &gpio_init_structure); - - /* Enable the DMA clock */ - AUDIO_I2Sx_DMAx_CLK_ENABLE(); - - if(hi2s->Instance == AUDIO_I2Sx) - { - /* Configure the hdma_i2s_rx handle parameters */ - hdma_i2s_rx.Init.Channel = AUDIO_I2Sx_DMAx_CHANNEL; - hdma_i2s_rx.Init.Direction = DMA_PERIPH_TO_MEMORY; - hdma_i2s_rx.Init.PeriphInc = DMA_PINC_DISABLE; - hdma_i2s_rx.Init.MemInc = DMA_MINC_ENABLE; - hdma_i2s_rx.Init.PeriphDataAlignment = AUDIO_I2Sx_DMAx_PERIPH_DATA_SIZE; - hdma_i2s_rx.Init.MemDataAlignment = AUDIO_I2Sx_DMAx_MEM_DATA_SIZE; - hdma_i2s_rx.Init.Mode = DMA_CIRCULAR; - hdma_i2s_rx.Init.Priority = DMA_PRIORITY_HIGH; - hdma_i2s_rx.Init.FIFOMode = DMA_FIFOMODE_DISABLE; - hdma_i2s_rx.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; - hdma_i2s_rx.Init.MemBurst = DMA_MBURST_SINGLE; - hdma_i2s_rx.Init.PeriphBurst = DMA_MBURST_SINGLE; - - hdma_i2s_rx.Instance = AUDIO_I2Sx_DMAx_STREAM; - - /* Associate the DMA handle */ - __HAL_LINKDMA(hi2s, hdmarx, hdma_i2s_rx); - - /* Deinitialize the Stream for new transfer */ - HAL_DMA_DeInit(&hdma_i2s_rx); - - /* Configure the DMA Stream */ - HAL_DMA_Init(&hdma_i2s_rx); - } - - /* I2S DMA IRQ Channel configuration */ - HAL_NVIC_SetPriority(AUDIO_I2Sx_DMAx_IRQ, AUDIO_IN_IRQ_PREPRIO, 0); - HAL_NVIC_EnableIRQ(AUDIO_I2Sx_DMAx_IRQ); -} - -/** - * @brief DeInitializes BSP_AUDIO_IN MSP. - * @param hsai: I2S handle - * @retval None - */ -__weak void BSP_AUDIO_IN_MspDeInit(I2S_HandleTypeDef *hi2s, void *Params) -{ - GPIO_InitTypeDef gpio_init_structure; - - static DMA_HandleTypeDef hdma_i2s_rx; - - /* I2S DMA IRQ Channel deactivation */ - HAL_NVIC_DisableIRQ(AUDIO_I2Sx_DMAx_IRQ); - - if(hi2s->Instance == AUDIO_I2Sx) - { - /* Deinitialize the Stream for new transfer */ - HAL_DMA_DeInit(&hdma_i2s_rx); - } - - /* Disable I2S block */ - __HAL_I2S_DISABLE(hi2s); - - /* Disable pins: SCK and SD pins */ - gpio_init_structure.Pin = AUDIO_I2Sx_SCK_PIN; - HAL_GPIO_DeInit(AUDIO_I2Sx_SCK_GPIO_PORT, gpio_init_structure.Pin); - gpio_init_structure.Pin = AUDIO_I2Sx_SD_PIN; - HAL_GPIO_DeInit(AUDIO_I2Sx_SD_GPIO_PORT, gpio_init_structure.Pin); - - /* Disable I2S clock */ - AUDIO_I2Sx_CLK_DISABLE(); - - /* GPIO pins clock and DMA clock can be shut down in the applic - by surcgarging this __weak function */ -} - - -/******************************************************************************* - Static Functions -*******************************************************************************/ - -/** - * @brief Initializes the PDM library. - * @param AudioFreq: Audio sampling frequency - * @param ChnlNbr: Number of audio channels (1: mono; 2: stereo) - * @retval None - */ -static void PDMDecoder_Init(uint32_t AudioFreq, uint32_t ChnlNbr) -{ - uint32_t i = 0; - - /* Enable CRC peripheral to unlock the PDM library */ - __HAL_RCC_CRC_CLK_ENABLE(); - - for(i = 0; i < ChnlNbr; i++) - { - /* Filter LP & HP Init */ - Filter[i].LP_HZ = AudioFreq/2; - Filter[i].HP_HZ = 10; - Filter[i].Fs = AudioFreq; - Filter[i].Out_MicChannels = ChnlNbr; - Filter[i].In_MicChannels = ChnlNbr; - PDM_Filter_Init((PDMFilter_InitStruct *)&Filter[i]); - } -} - -/** - * @brief Initializes the Audio Codec audio interface (I2S) - * @note This function assumes that the I2S input clock (through PLL_R in - * Devices RevA/Z and through dedicated PLLI2S_R in Devices RevB/Y) - * is already configured and ready to be used. - * @param AudioFreq: Audio frequency to be configured for the I2S peripheral. - * @retval None - */ -static void I2Sx_Init(uint32_t AudioFreq) -{ - /* Initialize the hAudioInI2s Instance parameter */ - haudio_in_i2s.Instance = AUDIO_I2Sx; - - /* Disable I2S block */ - __HAL_I2S_DISABLE(&haudio_in_i2s); - - /* I2S2 peripheral configuration */ - haudio_in_i2s.Init.AudioFreq = 4 * AudioFreq; - haudio_in_i2s.Init.ClockSource = I2S_CLOCK_PLL; - haudio_in_i2s.Init.CPOL = I2S_CPOL_HIGH; - haudio_in_i2s.Init.DataFormat = I2S_DATAFORMAT_16B; - haudio_in_i2s.Init.MCLKOutput = I2S_MCLKOUTPUT_DISABLE; - haudio_in_i2s.Init.Mode = I2S_MODE_MASTER_RX; - haudio_in_i2s.Init.Standard = I2S_STANDARD_LSB; - - /* Init the I2S */ - HAL_I2S_Init(&haudio_in_i2s); - - /* Disable I2S block */ - __HAL_I2S_ENABLE(&haudio_in_i2s); - -} - -/** - * @brief Deinitializes the Audio Codec audio interface (I2S). - * @param None - * @retval None - */ -static void I2Sx_DeInit(void) -{ - /* Initialize the hAudioInI2s Instance parameter */ - haudio_in_i2s.Instance = AUDIO_I2Sx; - - /* Disable I2S block */ - __HAL_I2S_DISABLE(&haudio_in_i2s); - - /* DeInit the I2S */ - HAL_I2S_DeInit(&haudio_in_i2s); -} - - -/** - * @brief Initializes the TIM INput Capture MSP. - * @param htim: TIM handle - * @retval None - */ -static void TIMx_IC_MspInit(TIM_HandleTypeDef *htim) -{ - GPIO_InitTypeDef gpio_init_structure; - - /* Enable peripherals and GPIO Clocks --------------------------------------*/ - /* TIMx Peripheral clock enable */ - AUDIO_TIMx_CLK_ENABLE(); - - /* Enable GPIO Channels Clock */ - AUDIO_TIMx_GPIO_CLK_ENABLE(); - - /* Configure I/Os ----------------------------------------------------------*/ - /* Common configuration for all channels */ - gpio_init_structure.Mode = GPIO_MODE_AF_PP; - gpio_init_structure.Pull = GPIO_NOPULL; - gpio_init_structure.Speed = GPIO_SPEED_HIGH; - gpio_init_structure.Alternate = AUDIO_TIMx_AF; - - /* Configure TIM input channel */ - gpio_init_structure.Pin = AUDIO_TIMx_IN_GPIO_PIN; - HAL_GPIO_Init(AUDIO_TIMx_GPIO_PORT, &gpio_init_structure); - - /* Configure TIM output channel */ - gpio_init_structure.Pin = AUDIO_TIMx_OUT_GPIO_PIN; - HAL_GPIO_Init(AUDIO_TIMx_GPIO_PORT, &gpio_init_structure); - -} - -/** - * @brief Initializes the TIM INput Capture MSP. - * @param htim: TIM handle - * @retval None - */ -static void TIMx_IC_MspDeInit(TIM_HandleTypeDef *htim) -{ - /* Disable TIMx Peripheral clock */ - AUDIO_TIMx_CLK_DISABLE(); - - /* GPIO pins clock and DMA clock can be shut down in the applic - by surcgarging this __weak function */ -} - -/** - * @brief Configure TIM as a clock divider by 2. - * I2S_SCK is externally connected to TIMx input channel - * @param None - * @retval None - */ -static void TIMx_Init(void) -{ - TIM_IC_InitTypeDef s_ic_config; - TIM_OC_InitTypeDef s_oc_config; - TIM_ClockConfigTypeDef s_clk_source_config; - TIM_SlaveConfigTypeDef s_slave_config; - - /* Configure the TIM peripheral --------------------------------------------*/ - /* Set TIMx instance */ - haudio_tim.Instance = AUDIO_TIMx; - /* Timer Input Capture Configuration Structure declaration */ - /* Initialize TIMx peripheral as follow: - + Period = 0xFFFF - + Prescaler = 0 - + ClockDivision = 0 - + Counter direction = Up - */ - haudio_tim.Init.Period = 1; - haudio_tim.Init.Prescaler = 0; - haudio_tim.Init.ClockDivision = 0; - haudio_tim.Init.CounterMode = TIM_COUNTERMODE_UP; - - /* Initialize the TIMx peripheral with the structure above */ - TIMx_IC_MspInit(&haudio_tim); - HAL_TIM_IC_Init(&haudio_tim); - - /* Configure the Input Capture channel -------------------------------------*/ - /* Configure the Input Capture of channel 2 */ - s_ic_config.ICPolarity = TIM_ICPOLARITY_FALLING; - s_ic_config.ICSelection = TIM_ICSELECTION_DIRECTTI; - s_ic_config.ICPrescaler = TIM_ICPSC_DIV1; - s_ic_config.ICFilter = 0; - HAL_TIM_IC_ConfigChannel(&haudio_tim, &s_ic_config, AUDIO_TIMx_IN_CHANNEL); - - /* Select external clock mode 1 */ - s_clk_source_config.ClockSource = TIM_CLOCKSOURCE_ETRMODE1; - s_clk_source_config.ClockPolarity = TIM_CLOCKPOLARITY_NONINVERTED; - s_clk_source_config.ClockPrescaler = TIM_CLOCKPRESCALER_DIV1; - s_clk_source_config.ClockFilter = 0; - HAL_TIM_ConfigClockSource(&haudio_tim, &s_clk_source_config); - - /* Select Input Channel as input trigger */ - s_slave_config.InputTrigger = TIM_TS_TI1FP1; - s_slave_config.SlaveMode = TIM_SLAVEMODE_EXTERNAL1; - s_slave_config.TriggerPolarity = TIM_TRIGGERPOLARITY_NONINVERTED; - s_slave_config.TriggerPrescaler = TIM_CLOCKPRESCALER_DIV1; - s_slave_config.TriggerFilter = 0; - HAL_TIM_SlaveConfigSynchronization(&haudio_tim, &s_slave_config); - - /* Output Compare PWM Mode configuration: Channel2 */ - s_oc_config.OCMode = TIM_OCMODE_PWM1; - s_oc_config.OCIdleState = TIM_OCIDLESTATE_SET; - s_oc_config.Pulse = 1; - s_oc_config.OCPolarity = TIM_OCPOLARITY_HIGH; - s_oc_config.OCNPolarity = TIM_OCNPOLARITY_HIGH; - s_oc_config.OCFastMode = TIM_OCFAST_DISABLE; - s_oc_config.OCNIdleState = TIM_OCNIDLESTATE_SET; - - /* Initialize the TIM4 Channel2 with the structure above */ - HAL_TIM_PWM_ConfigChannel(&haudio_tim, &s_oc_config, AUDIO_TIMx_OUT_CHANNEL); - - /* Start the TIM4 Channel2 */ - HAL_TIM_PWM_Start(&haudio_tim, AUDIO_TIMx_OUT_CHANNEL); - - /* Start the TIM4 Channel1 */ - HAL_TIM_IC_Start(&haudio_tim, AUDIO_TIMx_IN_CHANNEL); -} - -/** - * @brief Configure TIM as a clock divider by 2. - * I2S_SCK is externally connected to TIMx input channel - * @param None - * @retval None - */ -static void TIMx_DeInit(void) -{ - haudio_tim.Instance = AUDIO_TIMx; - - /* Stop the TIM4 Channel2 */ - HAL_TIM_PWM_Stop(&haudio_tim, AUDIO_TIMx_OUT_CHANNEL); - /* Stop the TIM4 Channel1 */ - HAL_TIM_IC_Stop(&haudio_tim, AUDIO_TIMx_IN_CHANNEL); - - HAL_TIM_IC_DeInit(&haudio_tim); - - /* Initialize the TIMx peripheral with the structure above */ - TIMx_IC_MspDeInit(&haudio_tim); -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/stm32446e_eval_audio.h b/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/stm32446e_eval_audio.h deleted file mode 100644 index cf2939b8ed..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/stm32446e_eval_audio.h +++ /dev/null @@ -1,328 +0,0 @@ -/** - ****************************************************************************** - * @file stm32446e_eval_audio.h - * @author MCD Application Team - * @version V1.1.0 - * @date 14-August-2015 - * @brief This file contains the common defines and functions prototypes for - * the stm32446e_eval_audio.c driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32446E_EVAL_AUDIO_H -#define __STM32446E_EVAL_AUDIO_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -/* Include audio component Driver */ -#include "../Components/wm8994/wm8994.h" -#include "stm32446e_eval.h" -#include "../../../Middlewares/ST/STM32_Audio/Addons/PDM/pdm_filter.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32446E_EVAL - * @{ - */ - -/** @defgroup STM32446E_EVAL_AUDIO STM32446E-EVAL AUDIO - * @{ - */ - -/** @defgroup STM32446E_EVAL_AUDIO_Exported_Types STM32446E EVAL Audio Exported Types - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_AUDIO_Exported_Constants STM32446E EVAL Audio Exported Constants - * @{ - */ - -/*------------------------------------------------------------------------------ - USER SAI defines parameters - -----------------------------------------------------------------------------*/ -/** @defgroup CODEC_AudioFrame_SLOT_TDMMode STM32446E EVAL Audio Slot TDM mode - * @brief In W8994 codec the Audio frame contains 4 slots : TDM Mode - * TDM format : - * +------------------|------------------|--------------------|-------------------+ - * | CODEC_SLOT0 Left | CODEC_SLOT1 Left | CODEC_SLOT0 Right | CODEC_SLOT1 Right | - * +------------------------------------------------------------------------------+ - * @{ - */ -/* To have 2 separate audio stream in Both headphone and speaker the 4 slot must be activated */ -#define CODEC_AUDIOFRAME_SLOT_0123 SAI_SLOTACTIVE_0 | SAI_SLOTACTIVE_1 | SAI_SLOTACTIVE_2 | SAI_SLOTACTIVE_3 -/* To have an audio stream in headphone only SAI Slot 0 and Slot 2 must be activated */ -#define CODEC_AUDIOFRAME_SLOT_02 SAI_SLOTACTIVE_0 | SAI_SLOTACTIVE_2 -/* To have an audio stream in speaker only SAI Slot 1 and Slot 3 must be activated */ -#define CODEC_AUDIOFRAME_SLOT_13 SAI_SLOTACTIVE_1 | SAI_SLOTACTIVE_3 -/** - * @} - */ - -/* SAI peripheral configuration defines */ -#define AUDIO_SAIx SAI2_Block_B -#define AUDIO_SAIx_CLK_ENABLE() __HAL_RCC_SAI2_CLK_ENABLE() -#define AUDIO_SAIx_CLK_DISABLE() __HAL_RCC_SAI2_CLK_DISABLE() -#define AUDIO_SAIx_SCK_AF GPIO_AF8_SAI2 -#define AUDIO_SAIx_MCLK_SD_FS_AF GPIO_AF10_SAI2 - - -#define AUDIO_SAIx_MCLK_SCK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE() -#define AUDIO_SAIx_MCLK_SCK_DISABLE() __HAL_RCC_GPIOA_CLK_DISABLE() -#define AUDIO_SAIx_MCK_PIN GPIO_PIN_1 /* PA1 */ -#define AUDIO_SAIx_SCK_PIN GPIO_PIN_2 /* PA2 */ -#define AUDIO_SAIx_MCLK_SCK_GPIO_PORT GPIOA -#define AUDIO_SAIx_SD_FS_ENABLE() __HAL_RCC_GPIOG_CLK_ENABLE() -#define AUDIO_SAIx_SD_FS_DISABLE() __HAL_RCC_GPIOG_CLK_DISABLE() -#define AUDIO_SAIx_FS_PIN GPIO_PIN_9 /* PG9 */ -#define AUDIO_SAIx_SD_PIN GPIO_PIN_10 /* PG10 */ -#define AUDIO_SAIx_SD_FS_GPIO_PORT GPIOG - - -/* SAI DMA Stream definitions */ -#define AUDIO_SAIx_DMAx_CLK_ENABLE() __HAL_RCC_DMA2_CLK_ENABLE() -#define AUDIO_SAIx_DMAx_CLK_DISABLE() __HAL_RCC_DMA2_CLK_DISABLE() -#define AUDIO_SAIx_DMAx_STREAM DMA2_Stream6 -#define AUDIO_SAIx_DMAx_CHANNEL DMA_CHANNEL_3 -#define AUDIO_SAIx_DMAx_IRQ DMA2_Stream6_IRQn -#define AUDIO_SAIx_DMAx_PERIPH_DATA_SIZE DMA_PDATAALIGN_HALFWORD -#define AUDIO_SAIx_DMAx_MEM_DATA_SIZE DMA_MDATAALIGN_HALFWORD -#define DMA_MAX_SZE 0xFFFF - -#define AUDIO_SAIx_DMAx_IRQHandler DMA2_Stream6_IRQHandler - -/* Select the interrupt preemption priority for the DMA interrupt */ -#define AUDIO_OUT_IRQ_PREPRIO ((uint32_t)5) /* Select the preemption priority level(0 is the highest) */ - -/*------------------------------------------------------------------------------ - AUDIO IN CONFIGURATION -------------------------------------------------------------------------------*/ -/* SPI Configuration defines */ -#define AUDIO_I2Sx SPI3 -#define AUDIO_I2Sx_CLK_ENABLE() __HAL_RCC_SPI3_CLK_ENABLE() -#define AUDIO_I2Sx_CLK_DISABLE() __HAL_RCC_SPI3_CLK_DISABLE() -#define AUDIO_I2Sx_SCK_PIN GPIO_PIN_3 -#define AUDIO_I2Sx_SCK_GPIO_PORT GPIOB -#define AUDIO_I2Sx_SCK_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE() -#define AUDIO_I2Sx_SCK_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE() -#define AUDIO_I2Sx_SCK_AF GPIO_AF6_SPI3 - -#define AUDIO_I2Sx_SD_PIN GPIO_PIN_1 -#define AUDIO_I2Sx_SD_GPIO_PORT GPIOC -#define AUDIO_I2Sx_SD_GPIO_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE() -#define AUDIO_I2Sx_SD_GPIO_CLK_DISABLE() __HAL_RCC_GPIOC_CLK_DISABLE() -#define AUDIO_I2Sx_SD_AF GPIO_AF5_SPI3 - -/* I2S DMA Stream Rx definitions */ -#define AUDIO_I2Sx_DMAx_CLK_ENABLE() __HAL_RCC_DMA1_CLK_ENABLE() -#define AUDIO_I2Sx_DMAx_CLK_DISABLE() __HAL_RCC_DMA1_CLK_DISABLE() -#define AUDIO_I2Sx_DMAx_STREAM DMA1_Stream2 -#define AUDIO_I2Sx_DMAx_CHANNEL DMA_CHANNEL_0 -#define AUDIO_I2Sx_DMAx_IRQ DMA1_Stream2_IRQn -#define AUDIO_I2Sx_DMAx_PERIPH_DATA_SIZE DMA_PDATAALIGN_HALFWORD -#define AUDIO_I2Sx_DMAx_MEM_DATA_SIZE DMA_MDATAALIGN_HALFWORD - -#define AUDIO_I2Sx_DMAx_IRQHandler DMA1_Stream2_IRQHandler - -/* Select the interrupt preemption priority and subpriority for the IT/DMA interrupt */ -#define AUDIO_IN_IRQ_PREPRIO ((uint32_t)6) /* Select the preemption priority level(0 is the highest) */ - - -/* Two channels are used: - - one channel as input which is connected to I2S SCK in stereo mode - - one channel as output which divides the frequency on the input -*/ - -#define AUDIO_TIMx_CLK_ENABLE() __HAL_RCC_TIM4_CLK_ENABLE() -#define AUDIO_TIMx_CLK_DISABLE() __HAL_RCC_TIM4_CLK_DISABLE() -#define AUDIO_TIMx TIM4 -#define AUDIO_TIMx_IN_CHANNEL TIM_CHANNEL_1 -#define AUDIO_TIMx_OUT_CHANNEL TIM_CHANNEL_2 /* Select channel 2 as output */ -#define AUDIO_TIMx_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE() -#define AUDIO_TIMx_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE() -#define AUDIO_TIMx_GPIO_PORT GPIOB -#define AUDIO_TIMx_IN_GPIO_PIN GPIO_PIN_6 -#define AUDIO_TIMx_OUT_GPIO_PIN GPIO_PIN_7 -#define AUDIO_TIMx_AF GPIO_AF2_TIM4 - -/*------------------------------------------------------------------------------ - CONFIGURATION: Audio Driver Configuration parameters -------------------------------------------------------------------------------*/ - -#define AUDIODATA_SIZE 2 /* 16-bits audio data size */ - -/* Audio status definition */ -#define AUDIO_OK ((uint8_t)0) -#define AUDIO_ERROR ((uint8_t)1) -#define AUDIO_TIMEOUT ((uint8_t)2) - -/* AudioFreq * DataSize (2 bytes) * NumChannels (Stereo: 2) */ -#define DEFAULT_AUDIO_IN_FREQ I2S_AUDIOFREQ_16K -#define DEFAULT_AUDIO_IN_BIT_RESOLUTION ((uint8_t)16) -#define DEFAULT_AUDIO_IN_CHANNEL_NBR ((uint8_t)2) /* Mono = 1, Stereo = 2 */ -#define DEFAULT_AUDIO_IN_VOLUME ((uint16_t)64) - -/* PDM buffer input size */ -#define INTERNAL_BUFF_SIZE (128*DEFAULT_AUDIO_IN_FREQ/16000*DEFAULT_AUDIO_IN_CHANNEL_NBR) -/* PCM buffer output size */ -#define PCM_OUT_SIZE (DEFAULT_AUDIO_IN_FREQ/1000*2) -#define CHANNEL_DEMUX_MASK ((uint8_t)0x55) - -/*------------------------------------------------------------------------------ - OPTIONAL Configuration defines parameters -------------------------------------------------------------------------------*/ - -/* Delay for the Codec to be correctly reset */ -#define CODEC_RESET_DELAY ((uint8_t)5) - - -/*------------------------------------------------------------------------------ - OUTPUT DEVICES definition -------------------------------------------------------------------------------*/ - -/* Alias on existing output devices to adapt for 2 headphones output */ -#define OUTPUT_DEVICE_HEADPHONE1 OUTPUT_DEVICE_HEADPHONE -#define OUTPUT_DEVICE_HEADPHONE2 OUTPUT_DEVICE_SPEAKER /* Headphone2 is connected to Speaker output of the wm8994 */ - -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_AUDIO_Exported_Variables STM32446E EVAL Audio Exported Variables - * @{ - */ -extern __IO uint16_t AudioInVolume; - /** - * @} - */ - -/** @defgroup STM32446E_EVAL_AUDIO_Exported_Macros STM32446E EVAL Audio Exported Macros - * @{ - */ -#define DMA_MAX(x) (((x) <= DMA_MAX_SZE)? (x):DMA_MAX_SZE) -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_AUDIO_OUT_Exported_Functions STM32446E EVAL AudioOUT Exported Functions - * @{ - */ -uint8_t BSP_AUDIO_OUT_Init(uint16_t OutputDevice, uint8_t Volume, uint32_t AudioFreq); -uint8_t BSP_AUDIO_OUT_Play(uint16_t* pBuffer, uint32_t Size); -void BSP_AUDIO_OUT_ChangeBuffer(uint16_t *pData, uint16_t Size); -uint8_t BSP_AUDIO_OUT_Pause(void); -uint8_t BSP_AUDIO_OUT_Resume(void); -uint8_t BSP_AUDIO_OUT_Stop(uint32_t Option); -uint8_t BSP_AUDIO_OUT_SetVolume(uint8_t Volume); -void BSP_AUDIO_OUT_SetFrequency(uint32_t AudioFreq); -void BSP_AUDIO_OUT_SetAudioFrameSlot(uint32_t AudioFrameSlot); -uint8_t BSP_AUDIO_OUT_SetMute(uint32_t Cmd); -uint8_t BSP_AUDIO_OUT_SetOutputMode(uint8_t Output); -void BSP_AUDIO_OUT_DeInit(void); - -/* User Callbacks: user has to implement these functions in his code if they are needed. */ -/* This function is called when the requested data has been completely transferred.*/ -void BSP_AUDIO_OUT_TransferComplete_CallBack(void); - -/* This function is called when half of the requested buffer has been transferred. */ -void BSP_AUDIO_OUT_HalfTransfer_CallBack(void); - -/* This function is called when an Interrupt due to transfer error on or peripheral - error occurs. */ -void BSP_AUDIO_OUT_Error_CallBack(void); - -/* These function can be modified in case the current settings (e.g. DMA stream) - need to be changed for specific application needs */ -void BSP_AUDIO_OUT_ClockConfig(SAI_HandleTypeDef *hsai, uint32_t AudioFreq, void *Params); -void BSP_AUDIO_OUT_MspInit(SAI_HandleTypeDef *hsai, void *Params); -void BSP_AUDIO_OUT_MspDeInit(SAI_HandleTypeDef *hsai, void *Params); - -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_AUDIO_IN_Exported_Functions STM32446E EVAL AudioIN Exported Functions - * @{ - */ -uint8_t BSP_AUDIO_IN_Init(uint32_t AudioFreq, uint32_t BitRes, uint32_t ChnlNbr); -uint8_t BSP_AUDIO_IN_Record(uint16_t *pData, uint32_t Size); -uint8_t BSP_AUDIO_IN_Stop(void); -uint8_t BSP_AUDIO_IN_Pause(void); -uint8_t BSP_AUDIO_IN_Resume(void); -uint8_t BSP_AUDIO_IN_SetVolume(uint8_t Volume); -void BSP_AUDIO_IN_DeInit(void); -uint8_t BSP_AUDIO_IN_PDMToPCM(uint16_t* PDMBuf, uint16_t* PCMBuf); -/* User Callbacks: user has to implement these functions in his code if they are needed. */ -/* This function should be implemented by the user application. - It is called into this driver when the current buffer is filled to prepare the next - buffer pointer and its size. */ -void BSP_AUDIO_IN_TransferComplete_CallBack(void); -void BSP_AUDIO_IN_HalfTransfer_CallBack(void); - -/* This function is called when an Interrupt due to transfer error on or peripheral - error occurs. */ -void BSP_AUDIO_IN_Error_Callback(void); - -/* These function can be modified in case the current settings (e.g. DMA stream) - need to be changed for specific application needs */ -void BSP_AUDIO_IN_MspInit(I2S_HandleTypeDef *hi2s, void *Params); -void BSP_AUDIO_IN_MspDeInit(I2S_HandleTypeDef *hi2s, void *Params); - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32446E_EVAL_AUDIO_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/stm32446e_eval_camera.c b/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/stm32446e_eval_camera.c deleted file mode 100644 index f885e0ba20..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/stm32446e_eval_camera.c +++ /dev/null @@ -1,686 +0,0 @@ -/** - ****************************************************************************** - * @file stm32446e_eval_camera.c - * @author MCD Application Team - * @version V1.1.0 - * @date 14-August-2015 - * @brief This file includes the driver for Camera modules mounted on - * STM32446E-EVAL evaluation board. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* File Info: ------------------------------------------------------------------ - User NOTES -1. How to use this driver: --------------------------- - - This driver is used to drive the camera. - - The S5K5CAG component driver MUST be included with this driver. - -2. Driver description: ---------------------- - + Initialization steps: - o Initialize the camera using the BSP_CAMERA_Init() function. - o Start the camera capture/snapshot using the CAMERA_Start() function. - o Suspend, resume or stop the camera capture using the following functions: - - BSP_CAMERA_Suspend() - - BSP_CAMERA_Resume() - - BSP_CAMERA_Stop() - - + Options - o Increase or decrease on the fly the brightness and/or contrast - using the following function: - - BSP_CAMERA_ContrastBrightnessConfig - o Add a special effect on the fly using the following functions: - - BSP_CAMERA_BlackWhiteConfig() - - BSP_CAMERA_ColorEffectConfig() - -------------------------------------------------------------------------------*/ - -/* Includes ------------------------------------------------------------------*/ -#include "stm32446e_eval_camera.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32446E_EVAL - * @{ - */ - -/** @defgroup STM32446E_EVAL_CAMERA STM32446E-EVAL CAMERA - * @{ - */ - -/** @defgroup STM32446E_EVAL_CAMERA_Private_TypesDefinitions STM32446E Eval Camera Private TypesDef - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_CAMERA_Private_Defines STM32446E Eval Camera Private Defines - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_CAMERA_Private_Macros STM32446E Eval Camera Private Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_CAMERA_Private_Variables STM32446E Eval Camera Private Variables - * @{ - */ - - /* -Note: - camera_drv variable is not compliant to naming rules (upper case without "_" ), - but we keep this naming for compatibility, in fact these variables (not static) - could have been used by the application, example the stm32f4xx_it.c. -*/ -CAMERA_DrvTypeDef *camera_drv; - -static DCMI_HandleTypeDef hDcmiEval; -uint32_t currentResolution; -static uint32_t cameraHwAddress; -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_CAMERA_Private_FunctionPrototypes STM32446E Eval Camera Private Prototypes - * @{ - */ -static uint32_t GetSize(uint32_t Resolution); -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_CAMERA_Private_Functions STM32446E Eval Camera Private Functions - * @{ - */ - -/** - * @brief Initializes the camera. - * @param Camera: Pointer to the camera configuration structure - * @retval Camera status - */ -uint8_t BSP_CAMERA_Init(uint32_t Resolution) -{ - DCMI_HandleTypeDef *phdcmi; - - uint8_t ret = CAMERA_ERROR; - - /* Get the DCMI handle structure */ - phdcmi = &hDcmiEval; - - /*** Configures the DCMI to interface with the camera module ***/ - /* DCMI configuration */ - phdcmi->Init.CaptureRate = DCMI_CR_ALL_FRAME; - phdcmi->Init.HSPolarity = DCMI_HSPOLARITY_HIGH; - phdcmi->Init.SynchroMode = DCMI_SYNCHRO_HARDWARE; - phdcmi->Init.VSPolarity = DCMI_VSPOLARITY_HIGH; - phdcmi->Init.ExtendedDataMode = DCMI_EXTEND_DATA_8B; - phdcmi->Init.PCKPolarity = DCMI_PCKPOLARITY_RISING; - phdcmi->Init.ByteSelectMode = DCMI_BSM_ALL; - phdcmi->Init.ByteSelectStart = DCMI_OEBS_ODD; - phdcmi->Init.LineSelectMode = DCMI_LSM_ALL; - phdcmi->Init.LineSelectStart = DCMI_OELS_ODD; - phdcmi->Instance = DCMI; - - /* Configure IO functionalities for CAMERA detect pin */ - BSP_IO_Init(); - - /* Apply Camera hardware reset */ - BSP_CAMERA_HwReset(); - - /* Check if the CAMERA is plugged */ - if(BSP_IO_ReadPin(CAM_PLUG_PIN)) - { - return CAMERA_ERROR; - } - - if (s5k5cag_ReadID(CAMERA_I2C_ADDRESS) == S5K5CAG_ID) - { - /* Initialize the camera driver structure */ - camera_drv = &s5k5cag_drv; - cameraHwAddress = CAMERA_I2C_ADDRESS; - - /* DCMI Initialization */ - BSP_CAMERA_MspInit(&hDcmiEval, NULL); - HAL_DCMI_Init(phdcmi); - - /* Camera Init */ - camera_drv->Init(cameraHwAddress, Resolution); - - currentResolution = Resolution; - - /* Return CAMERA_OK status */ - ret = CAMERA_OK; - } - else - { - /* No supported camera sensor found */ - ret = CAMERA_ERROR; - } - - return ret; -} - - -/** - * @brief DeInitializes the camera. - * @param Camera: Pointer to the camera configuration structure - * @retval Camera status - */ -uint8_t BSP_CAMERA_DeInit(void) -{ - hDcmiEval.Instance = DCMI; - - HAL_DCMI_DeInit(&hDcmiEval); - BSP_CAMERA_MspDeInit(&hDcmiEval, NULL); - return CAMERA_OK; -} - -/** - * @brief Starts the camera capture in continuous mode. - * @param buff: pointer to the camera output buffer - * @retval None - */ -void BSP_CAMERA_ContinuousStart(uint8_t *buff) -{ - /* Start the camera capture */ - HAL_DCMI_Start_DMA(&hDcmiEval, DCMI_MODE_CONTINUOUS, (uint32_t)buff, GetSize(currentResolution)); -} - -/** - * @brief Starts the camera capture in snapshot mode. - * @param buff: pointer to the camera output buffer - * @retval None - */ -void BSP_CAMERA_SnapshotStart(uint8_t *buff) -{ - /* Start the camera capture */ - HAL_DCMI_Start_DMA(&hDcmiEval, DCMI_MODE_SNAPSHOT, (uint32_t)buff, GetSize(currentResolution)); -} - -/** - * @brief Suspend the CAMERA capture - * @param None - * @retval None - */ -void BSP_CAMERA_Suspend(void) -{ - /* Disable the DMA */ - __HAL_DMA_DISABLE(hDcmiEval.DMA_Handle); - /* Disable the DCMI */ - __HAL_DCMI_DISABLE(&hDcmiEval); - -} - -/** - * @brief Resume the CAMERA capture - * @param None - * @retval None - */ -void BSP_CAMERA_Resume(void) -{ - /* Enable the DCMI */ - __HAL_DCMI_ENABLE(&hDcmiEval); - /* Enable the DMA */ - __HAL_DMA_ENABLE(hDcmiEval.DMA_Handle); -} - -/** - * @brief Stop the CAMERA capture - * @param None - * @retval Camera status - */ -uint8_t BSP_CAMERA_Stop(void) -{ - DCMI_HandleTypeDef *phdcmi; - - uint8_t ret = CAMERA_ERROR; - - /* Get the DCMI handle structure */ - phdcmi = &hDcmiEval; - - if(HAL_DCMI_Stop(phdcmi) == HAL_OK) - { - ret = CAMERA_OK; - } - - /* Set Camera in Power Down */ - BSP_CAMERA_PwrDown(); - - return ret; -} - -/** - * @brief CAMERA hardware reset - * @param None - * @retval None - */ -void BSP_CAMERA_HwReset(void) -{ - /* Camera sensor RESET sequence */ - BSP_IO_ConfigPin(RSTI_PIN, IO_MODE_OUTPUT); - BSP_IO_ConfigPin(XSDN_PIN, IO_MODE_OUTPUT); - - /* Assert the camera STANDBY pin (active high) */ - BSP_IO_WritePin(XSDN_PIN, BSP_IO_PIN_SET); - - /* Assert the camera RSTI pin (active low) */ - BSP_IO_WritePin(RSTI_PIN, BSP_IO_PIN_RESET); - - HAL_Delay(100); /* RST and XSDN signals asserted during 100ms */ - - /* De-assert the camera STANDBY pin (active high) */ - BSP_IO_WritePin(XSDN_PIN, BSP_IO_PIN_RESET); - - HAL_Delay(3); /* RST de-asserted and XSDN asserted during 3ms */ - - /* De-assert the camera RSTI pin (active low) */ - BSP_IO_WritePin(RSTI_PIN, BSP_IO_PIN_SET); - - HAL_Delay(6); /* RST de-asserted during 3ms */ -} - -/** - * @brief CAMERA power down - * @param None - * @retval None - */ -void BSP_CAMERA_PwrDown(void) -{ - /* Camera power down sequence */ - BSP_IO_ConfigPin(RSTI_PIN, IO_MODE_OUTPUT); - BSP_IO_ConfigPin(XSDN_PIN, IO_MODE_OUTPUT); - - /* De-assert the camera STANDBY pin (active high) */ - BSP_IO_WritePin(XSDN_PIN, BSP_IO_PIN_RESET); - - /* Assert the camera RSTI pin (active low) */ - BSP_IO_WritePin(RSTI_PIN, BSP_IO_PIN_RESET); -} - -/** - * @brief Configures the camera contrast and brightness. - * @param contrast_level: Contrast level - * This parameter can be one of the following values: - * @arg CAMERA_CONTRAST_LEVEL4: for contrast +2 - * @arg CAMERA_CONTRAST_LEVEL3: for contrast +1 - * @arg CAMERA_CONTRAST_LEVEL2: for contrast 0 - * @arg CAMERA_CONTRAST_LEVEL1: for contrast -1 - * @arg CAMERA_CONTRAST_LEVEL0: for contrast -2 - * @param brightness_level: Contrast level - * This parameter can be one of the following values: - * @arg CAMERA_BRIGHTNESS_LEVEL4: for brightness +2 - * @arg CAMERA_BRIGHTNESS_LEVEL3: for brightness +1 - * @arg CAMERA_BRIGHTNESS_LEVEL2: for brightness 0 - * @arg CAMERA_BRIGHTNESS_LEVEL1: for brightness -1 - * @arg CAMERA_BRIGHTNESS_LEVEL0: for brightness -2 - * @retval None - */ -void BSP_CAMERA_ContrastBrightnessConfig(uint32_t contrast_level, uint32_t brightness_level) -{ - if(camera_drv->Config != NULL) - { - camera_drv->Config(cameraHwAddress, CAMERA_CONTRAST_BRIGHTNESS, contrast_level, brightness_level); - } -} - -/** - * @brief Configures the camera white balance. - * @param Mode: black_white mode - * This parameter can be one of the following values: - * @arg CAMERA_BLACK_WHITE_BW - * @arg CAMERA_BLACK_WHITE_NEGATIVE - * @arg CAMERA_BLACK_WHITE_BW_NEGATIVE - * @arg CAMERA_BLACK_WHITE_NORMAL - * @retval None - */ -void BSP_CAMERA_BlackWhiteConfig(uint32_t Mode) -{ - if(camera_drv->Config != NULL) - { - camera_drv->Config(cameraHwAddress, CAMERA_BLACK_WHITE, Mode, 0); - } -} - -/** - * @brief Configures the camera color effect. - * @param Effect: Color effect - * This parameter can be one of the following values: - * @arg CAMERA_COLOR_EFFECT_ANTIQUE - * @arg CAMERA_COLOR_EFFECT_BLUE - * @arg CAMERA_COLOR_EFFECT_GREEN - * @arg CAMERA_COLOR_EFFECT_RED - * @retval None - */ -void BSP_CAMERA_ColorEffectConfig(uint32_t Effect) -{ - if(camera_drv->Config != NULL) - { - camera_drv->Config(cameraHwAddress, CAMERA_COLOR_EFFECT, Effect, 0); - } -} - -/** - * @brief Handles DCMI interrupt request. - * @param None - * @retval None - */ -void BSP_CAMERA_IRQHandler(void) -{ - HAL_DCMI_IRQHandler(&hDcmiEval); -} - -/** - * @brief Handles DMA interrupt request. - * @param None - * @retval None - */ -void BSP_CAMERA_DMA_IRQHandler(void) -{ - HAL_DMA_IRQHandler(hDcmiEval.DMA_Handle); -} - -/** - * @brief Get the capture size. - * @param resolution: the current resolution. - * @retval capture size. - */ -static uint32_t GetSize(uint32_t Resolution) -{ - uint32_t size = 0; - - /* Get capture size */ - switch (Resolution) - { - case CAMERA_R160x120: - { - size = 0x2580; - } - break; - case CAMERA_R320x240: - { - size = 0x9600; - } - break; - case CAMERA_R480x272: - { - size = 0xFF00; - } - break; - case CAMERA_R640x480: - { - size = 0x25800; - } - break; - default: - { - break; - } - } - - return size; -} - -/** - * @brief Initializes the DCMI MSP. - * @param hdcmi: HDMI handle - * @retval None - */ -__weak void BSP_CAMERA_MspInit(DCMI_HandleTypeDef *hdcmi, void *Params) -{ - static DMA_HandleTypeDef hdma_eval; - GPIO_InitTypeDef gpio_init_structure; - - /*** Enable peripherals and GPIO clocks ***/ - /* Enable DCMI clock */ - __HAL_RCC_DCMI_CLK_ENABLE(); - - /* Enable DMA2 clock */ - __HAL_RCC_DMA2_CLK_ENABLE(); - - /* Enable GPIO clocks */ - __HAL_RCC_GPIOA_CLK_ENABLE(); - __HAL_RCC_GPIOB_CLK_ENABLE(); - __HAL_RCC_GPIOC_CLK_ENABLE(); - __HAL_RCC_GPIOD_CLK_ENABLE(); - __HAL_RCC_GPIOE_CLK_ENABLE(); - - /*** Configure the GPIO ***/ - /* Configure DCMI GPIO as alternate function */ - gpio_init_structure.Pin = GPIO_PIN_4 | GPIO_PIN_6; - gpio_init_structure.Mode = GPIO_MODE_AF_PP; - gpio_init_structure.Pull = GPIO_PULLUP; - gpio_init_structure.Speed = GPIO_SPEED_HIGH; - gpio_init_structure.Alternate = GPIO_AF13_DCMI; - HAL_GPIO_Init(GPIOA, &gpio_init_structure); - -#if !defined(USE_STM32446E_EVAL_REVA) - gpio_init_structure.Pin = GPIO_PIN_6 | GPIO_PIN_7 | GPIO_PIN_8 | GPIO_PIN_9; -#else - gpio_init_structure.Pin = GPIO_PIN_7 | GPIO_PIN_8 | GPIO_PIN_9; -#endif // !USE_STM32446E_EVAL_REVA - gpio_init_structure.Mode = GPIO_MODE_AF_PP; - gpio_init_structure.Pull = GPIO_PULLUP; - gpio_init_structure.Speed = GPIO_SPEED_HIGH; - gpio_init_structure.Alternate = GPIO_AF13_DCMI; - HAL_GPIO_Init(GPIOB, &gpio_init_structure); - - gpio_init_structure.Pin = GPIO_PIN_6 | GPIO_PIN_7 | GPIO_PIN_8 |\ - GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 |\ - GPIO_PIN_12; - gpio_init_structure.Mode = GPIO_MODE_AF_PP; - gpio_init_structure.Pull = GPIO_PULLUP; - gpio_init_structure.Speed = GPIO_SPEED_HIGH; - gpio_init_structure.Alternate = GPIO_AF13_DCMI; - HAL_GPIO_Init(GPIOC, &gpio_init_structure); - -#if !defined(USE_STM32446E_EVAL_REVA) - gpio_init_structure.Pin = GPIO_PIN_2 | GPIO_PIN_6; -#else - gpio_init_structure.Pin = GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_6; -#endif // !USE_STM32446E_EVAL_REVA - gpio_init_structure.Mode = GPIO_MODE_AF_PP; - gpio_init_structure.Pull = GPIO_PULLUP; - gpio_init_structure.Speed = GPIO_SPEED_HIGH; - gpio_init_structure.Alternate = GPIO_AF13_DCMI; - HAL_GPIO_Init(GPIOD, &gpio_init_structure); - - - /*** Configure the DMA ***/ - /* Set the parameters to be configured */ - hdma_eval.Init.Channel = DMA_CHANNEL_1; - hdma_eval.Init.Direction = DMA_PERIPH_TO_MEMORY; - hdma_eval.Init.PeriphInc = DMA_PINC_DISABLE; - hdma_eval.Init.MemInc = DMA_MINC_ENABLE; - hdma_eval.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; - hdma_eval.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; - hdma_eval.Init.Mode = DMA_CIRCULAR; - hdma_eval.Init.Priority = DMA_PRIORITY_HIGH; - hdma_eval.Init.FIFOMode = DMA_FIFOMODE_DISABLE; - hdma_eval.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; - hdma_eval.Init.MemBurst = DMA_MBURST_SINGLE; - hdma_eval.Init.PeriphBurst = DMA_PBURST_SINGLE; - - hdma_eval.Instance = DMA2_Stream1; - - /* Associate the initialized DMA handle to the DCMI handle */ - __HAL_LINKDMA(hdcmi, DMA_Handle, hdma_eval); - - /*** Configure the NVIC for DCMI and DMA ***/ - /* NVIC configuration for DCMI transfer complete interrupt */ - HAL_NVIC_SetPriority(DCMI_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(DCMI_IRQn); - - /* NVIC configuration for DMA2D transfer complete interrupt */ - HAL_NVIC_SetPriority(DMA2_Stream1_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(DMA2_Stream1_IRQn); - - /* Configure the DMA stream */ - HAL_DMA_Init(hdcmi->DMA_Handle); -} - - -/** - * @brief DeInitializes the DCMI MSP. - * @param hdcmi: HDMI handle - * @retval None - */ -__weak void BSP_CAMERA_MspDeInit(DCMI_HandleTypeDef *hdcmi, void *Params) -{ - /* Disable NVIC for DCMI transfer complete interrupt */ - HAL_NVIC_DisableIRQ(DCMI_IRQn); - - /* Disable NVIC for DMA2 transfer complete interrupt */ - HAL_NVIC_DisableIRQ(DMA2_Stream1_IRQn); - - /* Configure the DMA stream */ - HAL_DMA_DeInit(hdcmi->DMA_Handle); - - /* Disable DCMI clock */ - __HAL_RCC_DCMI_CLK_DISABLE(); - - /* GPIO pins clock and DMA clock can be shut down in the application - by surcharging this __weak function */ -} - -/** - * @brief Line event callback - * @param hdcmi: pointer to the DCMI handle - * @retval None - */ -void HAL_DCMI_LineEventCallback(DCMI_HandleTypeDef *hdcmi) -{ - BSP_CAMERA_LineEventCallback(); -} - -/** - * @brief Line Event callback. - * @param None - * @retval None - */ -__weak void BSP_CAMERA_LineEventCallback(void) -{ - /* NOTE : This function Should not be modified, when the callback is needed, - the HAL_DCMI_LineEventCallback could be implemented in the user file - */ -} - -/** - * @brief VSYNC event callback - * @param hdcmi: pointer to the DCMI handle - * @retval None - */ -void HAL_DCMI_VsyncEventCallback(DCMI_HandleTypeDef *hdcmi) -{ - BSP_CAMERA_VsyncEventCallback(); -} - -/** - * @brief VSYNC Event callback. - * @param None - * @retval None - */ -__weak void BSP_CAMERA_VsyncEventCallback(void) -{ - /* NOTE : This function Should not be modified, when the callback is needed, - the HAL_DCMI_VsyncEventCallback could be implemented in the user file - */ -} - -/** - * @brief Frame event callback - * @param hdcmi: pointer to the DCMI handle - * @retval None - */ -void HAL_DCMI_FrameEventCallback(DCMI_HandleTypeDef *hdcmi) -{ - BSP_CAMERA_FrameEventCallback(); -} - -/** - * @brief Frame Event callback. - * @param None - * @retval None - */ -__weak void BSP_CAMERA_FrameEventCallback(void) -{ - /* NOTE : This function Should not be modified, when the callback is needed, - the HAL_DCMI_FrameEventCallback could be implemented in the user file - */ -} - -/** - * @brief Error callback - * @param hdcmi: pointer to the DCMI handle - * @retval None - */ -void HAL_DCMI_ErrorCallback(DCMI_HandleTypeDef *hdcmi) -{ - BSP_CAMERA_ErrorCallback(); -} - -/** - * @brief Error callback. - * @param None - * @retval None - */ -__weak void BSP_CAMERA_ErrorCallback(void) -{ - /* NOTE : This function Should not be modified, when the callback is needed, - the HAL_DCMI_ErrorCallback could be implemented in the user file - */ -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/stm32446e_eval_camera.h b/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/stm32446e_eval_camera.h deleted file mode 100644 index 0befc678b4..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/stm32446e_eval_camera.h +++ /dev/null @@ -1,150 +0,0 @@ -/** - ****************************************************************************** - * @file stm32446e_eval_camera.h - * @author MCD Application Team - * @version V1.1.0 - * @date 14-August-2015 - * @brief This file contains the common defines and functions prototypes for - * the stm32446e_eval_camera.c driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32446E_EVAL_CAMERA_H -#define __STM32446E_EVAL_CAMERA_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -/* Include Camera component Driver */ -#include "../Components/s5k5cag/s5k5cag.h" - -/* Include IO Driver */ -#include "stm32446e_eval_io.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32446E_EVAL - * @{ - */ - -/** @defgroup STM32446E_EVAL_CAMERA STM32446E-EVAL CAMERA - * @{ - */ - -/** @defgroup STM32446E_EVAL_CAMERA_Exported_Types STM32446E EVAL Camera Exported Types - * @{ - */ - -/** - * @brief Camera State structures definition - */ -typedef enum -{ - CAMERA_OK = 0x00, - CAMERA_ERROR = 0x01, - CAMERA_TIMEOUT = 0x02 -}Camera_StatusTypeDef; - -#define RESOLUTION_R160x120 CAMERA_R160x120 /* QQVGA Resolution */ -#define RESOLUTION_R320x240 CAMERA_R320x240 /* QVGA Resolution */ -#define RESOLUTION_R480x272 CAMERA_R480x272 /* 480x272 Resolution */ -#define RESOLUTION_R640x480 CAMERA_R640x480 /* VGA Resolution */ -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_CAMERA_Exported_Constants STM32446E EVAL Camera Exported Constants - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_CAMERA_Exported_Functions STM32446E EVAL Camera Exported Functions - * @{ - */ -uint8_t BSP_CAMERA_Init(uint32_t Resolution); -uint8_t BSP_CAMERA_DeInit(void); -void BSP_CAMERA_ContinuousStart(uint8_t *buff); -void BSP_CAMERA_SnapshotStart(uint8_t *buff); -void BSP_CAMERA_Suspend(void); -void BSP_CAMERA_Resume(void); -uint8_t BSP_CAMERA_Stop(void); -void BSP_CAMERA_HwReset(void); -void BSP_CAMERA_PwrDown(void); -void BSP_CAMERA_LineEventCallback(void); -void BSP_CAMERA_VsyncEventCallback(void); -void BSP_CAMERA_FrameEventCallback(void); -void BSP_CAMERA_ErrorCallback(void); - -/* Camera features functions prototype */ -void BSP_CAMERA_ContrastBrightnessConfig(uint32_t contrast_level, uint32_t brightness_level); -void BSP_CAMERA_BlackWhiteConfig(uint32_t Mode); -void BSP_CAMERA_ColorEffectConfig(uint32_t Effect); - -/* To be called in DCMI_IRQHandler function */ -void BSP_CAMERA_IRQHandler(void); -/* To be called in DMA2_Stream1_IRQHandler function */ -void BSP_CAMERA_DMA_IRQHandler(void); - -/* These functions can be modified in case the current settings (e.g. DMA stream) - need to be changed for specific application needs */ -void BSP_CAMERA_MspInit(DCMI_HandleTypeDef *hdcmi, void *Params); -void BSP_CAMERA_MspDeInit(DCMI_HandleTypeDef *hdcmi, void *Params); - - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32446E_EVAL_CAMERA_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/stm32446e_eval_eeprom.c b/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/stm32446e_eval_eeprom.c deleted file mode 100644 index eea6339ed9..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/stm32446e_eval_eeprom.c +++ /dev/null @@ -1,478 +0,0 @@ -/** - ****************************************************************************** - * @file stm32446e_eval_eeprom.c - * @author MCD Application Team - * @version V1.1.0 - * @date 14-August-2015 - * @brief This file provides a set of functions needed to manage an I2C M24LR64 - * EEPROM memory. - * To be able to use this driver, the switch EE_M24LR64 must be defined - * in your toolchain compiler preprocessor - * - * =================================================================== - * Notes: - * - This driver is intended for STM32F4xx families devices only. - * - The I2C EEPROM memory (M24LR64) is available on separate daughter - * board ANT7-M24LR-A, which is not provided with the STM32446E_EVAL - * board. - * To use this driver you have to connect the ANT7-M24LR-A to CN3 - * connector of STM32446E_EVAL board. - * =================================================================== - * - * It implements a high level communication layer for read and write - * from/to this memory. The needed STM32F4xx hardware resources (I2C and - * GPIO) are defined in stm32446e_eval.h file, and the initialization is - * performed in EEPROM_IO_Init() function declared in stm32446e_eval.c - * file. - * You can easily tailor this driver to any other development board, - * by just adapting the defines for hardware resources and - * EEPROM_IO_Init() function. - * - * @note In this driver, basic read and write functions (BSP_EEPROM_ReadBuffer() - * and BSP_EEPROM_WritePage()) use DMA mode to perform the data - * transfer to/from EEPROM memory. - * - * @note Regarding BSP_EEPROM_WritePage(), it is a optimized function to perform - * small write (less than 1 page) BUT The number of bytes (combined to write start address) must not - * cross the EEPROM page boundary. This function can only write into - * the boundaries of an EEPROM page. - * This function doesn't check on boundaries condition (in this driver - * the function BSP_EEPROM_WriteBuffer() which calls BSP_EEPROM_WritePage() is - * responsible of checking on Page boundaries). - * - * - * +-----------------------------------------------------------------+ - * | Pin assignment for M24LR64 EEPROM | - * +---------------------------------------+-----------+-------------+ - * | STM32F4xx I2C Pins | EEPROM | Pin | - * +---------------------------------------+-----------+-------------+ - * | . | E0(GND) | 1 (0V) | - * | . | AC0 | 2 | - * | . | AC1 | 3 | - * | . | VSS | 4 (0V) | - * | SDA | SDA | 5 | - * | SCL | SCL | 6 | - * | . | E1(GND) | 7 (0V) | - * | . | VDD | 8 (3.3V) | - * +---------------------------------------+-----------+-------------+ - * - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ -/* Includes ------------------------------------------------------------------*/ -#include "stm32446e_eval_eeprom.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32446E_EVAL - * @{ - */ - -/** @defgroup STM32446E_EVAL_EEPROM STM32446E-EVAL EEPROM - * @brief This file includes the I2C EEPROM driver of STM32446E-EVAL evaluation board. - * @{ - */ - -/** @defgroup STM32446E_EVAL_EEPROM_Private_Types STM32446E Eval Eeprom Private Types - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_EEPROM_Private_Defines STM32446E Eval Eeprom Private Defines - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_EEPROM_Private_Macros STM32446E Eval Eeprom Private Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_EEPROM_Private_Variables STM32446E Eval Eeprom Private Variables - * @{ - */ -__IO uint16_t EEPROMAddress = 0; -__IO uint16_t EEPROMDataRead; -__IO uint8_t EEPROMDataWrite; -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_EEPROM_Private_Function_Prototypes STM32446E Eval Eeprom Private Prototypes - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_EEPROM_Private_Functions STM32446E Eval Eeprom Private Functions - * @{ - */ - -/** - * @brief Initializes peripherals used by the I2C EEPROM driver. - * @param None - * - * @note There are 2 different versions of M24LR64 (A01 & A02). - * Then try to connect on 1st one (EEPROM_I2C_ADDRESS_A01) - * and if problem, check the 2nd one (EEPROM_I2C_ADDRESS_A02) - * @retval EEPROM_OK (0) if operation is correctly performed, else return value - * different from EEPROM_OK (0) - */ -uint32_t BSP_EEPROM_Init(void) -{ - /* I2C Initialization */ - EEPROM_IO_Init(); - - /* Select the EEPROM address for A01 and check if OK */ - EEPROMAddress = EEPROM_I2C_ADDRESS_A01; - if(EEPROM_IO_IsDeviceReady(EEPROMAddress, EEPROM_MAX_TRIALS) != HAL_OK) - { - /* Select the EEPROM address for A02 and check if OK */ - EEPROMAddress = EEPROM_I2C_ADDRESS_A02; - if(EEPROM_IO_IsDeviceReady(EEPROMAddress, EEPROM_MAX_TRIALS) != HAL_OK) - { - return EEPROM_FAIL; - } - } - return EEPROM_OK; -} - -/** - * @brief DeInitializes the EEPROM. - * @param None - * @retval EEPROM state - */ -uint8_t BSP_EEPROM_DeInit(void) -{ - /* I2C won't be disabled because common to other functionalities */ - return EEPROM_OK; -} - -/** - * @brief Reads a block of data from the EEPROM. - * @param pBuffer: pointer to the buffer that receives the data read from - * the EEPROM. - * @param ReadAddr: EEPROM's internal address to start reading from. - * @param NumByteToRead: pointer to the variable holding number of bytes to - * be read from the EEPROM. - * - * @note The variable pointed by NumByteToRead is reset to 0 when all the - * data are read from the EEPROM. Application should monitor this - * variable in order know when the transfer is complete. - * - * @retval EEPROM_OK (0) if operation is correctly performed, else return value - * different from EEPROM_OK (0) or the timeout user callback. - */ -uint32_t BSP_EEPROM_ReadBuffer(uint8_t* pBuffer, uint16_t ReadAddr, uint16_t* NumByteToRead) -{ - uint32_t buffersize = *NumByteToRead; - - /* Set the pointer to the Number of data to be read. This pointer will be used - by the DMA Transfer Completer interrupt Handler in order to reset the - variable to 0. User should check on this variable in order to know if the - DMA transfer has been complete or not. */ - EEPROMDataRead = *NumByteToRead; - - if(EEPROM_IO_ReadData(EEPROMAddress, ReadAddr, pBuffer, buffersize) != HAL_OK) - { - BSP_EEPROM_TIMEOUT_UserCallback(); - return EEPROM_FAIL; - } - - /* If all operations OK, return EEPROM_OK (0) */ - return EEPROM_OK; -} - -/** - * @brief Writes more than one byte to the EEPROM with a single WRITE cycle. - * - * @note The number of bytes (combined to write start address) must not - * cross the EEPROM page boundary. This function can only write into - * the boundaries of an EEPROM page. - * This function doesn't check on boundaries condition (in this driver - * the function BSP_EEPROM_WriteBuffer() which calls BSP_EEPROM_WritePage() is - * responsible of checking on Page boundaries). - * - * @param pBuffer: pointer to the buffer containing the data to be written to - * the EEPROM. - * @param WriteAddr: EEPROM's internal address to write to. - * @param NumByteToWrite: pointer to the variable holding number of bytes to - * be written into the EEPROM. - * - * @note The variable pointed by NumByteToWrite is reset to 0 when all the - * data are written to the EEPROM. Application should monitor this - * variable in order know when the transfer is complete. - * - * @note This function just configure the communication and enable the DMA - * channel to transfer data. Meanwhile, the user application may perform - * other tasks in parallel. - * - * @retval EEPROM_OK (0) if operation is correctly performed, else return value - * different from EEPROM_OK (0) or the timeout user callback. - */ -uint32_t BSP_EEPROM_WritePage(uint8_t* pBuffer, uint16_t WriteAddr, uint8_t* NumByteToWrite) -{ - uint32_t buffersize = *NumByteToWrite; - uint32_t status = EEPROM_OK; - - /* Set the pointer to the Number of data to be written. This pointer will be used - by the DMA Transfer Completer interrupt Handler in order to reset the - variable to 0. User should check on this variable in order to know if the - DMA transfer has been complete or not. */ - EEPROMDataWrite = *NumByteToWrite; - - if(EEPROM_IO_WriteData(EEPROMAddress, WriteAddr, pBuffer, buffersize) != HAL_OK) - { - BSP_EEPROM_TIMEOUT_UserCallback(); - status = EEPROM_FAIL; - } - - if(BSP_EEPROM_WaitEepromStandbyState() != EEPROM_OK) - { - return EEPROM_FAIL; - } - - /* If all operations OK, return EEPROM_OK (0) */ - return status; -} - -/** - * @brief Writes buffer of data to the I2C EEPROM. - * @param pBuffer: pointer to the buffer containing the data to be written - * to the EEPROM. - * @param WriteAddr: EEPROM's internal address to write to. - * @param NumByteToWrite: number of bytes to write to the EEPROM. - * @retval EEPROM_OK (0) if operation is correctly performed, else return value - * different from EEPROM_OK (0) or the timeout user callback. - */ -uint32_t BSP_EEPROM_WriteBuffer(uint8_t *pBuffer, uint16_t WriteAddr, uint16_t NumByteToWrite) -{ - uint16_t numofpage = 0, numofsingle = 0, count = 0; - uint16_t addr = 0; - uint8_t dataindex = 0; - uint32_t status = EEPROM_OK; - - addr = WriteAddr % EEPROM_PAGESIZE; - count = EEPROM_PAGESIZE - addr; - numofpage = NumByteToWrite / EEPROM_PAGESIZE; - numofsingle = NumByteToWrite % EEPROM_PAGESIZE; - - /* If WriteAddr is EEPROM_PAGESIZE aligned */ - if(addr == 0) - { - /* If NumByteToWrite < EEPROM_PAGESIZE */ - if(numofpage == 0) - { - /* Store the number of data to be written */ - dataindex = numofsingle; - /* Start writing data */ - status = BSP_EEPROM_WritePage(pBuffer, WriteAddr, (uint8_t*)(&dataindex)); - if(status != EEPROM_OK) - { - return status; - } - } - /* If NumByteToWrite > EEPROM_PAGESIZE */ - else - { - while(numofpage--) - { - /* Store the number of data to be written */ - dataindex = EEPROM_PAGESIZE; - status = BSP_EEPROM_WritePage(pBuffer, WriteAddr, (uint8_t*)(&dataindex)); - if(status != EEPROM_OK) - { - return status; - } - - WriteAddr += EEPROM_PAGESIZE; - pBuffer += EEPROM_PAGESIZE; - } - - if(numofsingle!=0) - { - /* Store the number of data to be written */ - dataindex = numofsingle; - status = BSP_EEPROM_WritePage(pBuffer, WriteAddr, (uint8_t*)(&dataindex)); - if(status != EEPROM_OK) - { - return status; - } - } - } - } - /* If WriteAddr is not EEPROM_PAGESIZE aligned */ - else - { - /* If NumByteToWrite < EEPROM_PAGESIZE */ - if(numofpage== 0) - { - /* If the number of data to be written is more than the remaining space - in the current page: */ - if(NumByteToWrite > count) - { - /* Store the number of data to be written */ - dataindex = count; - /* Write the data contained in same page */ - status = BSP_EEPROM_WritePage(pBuffer, WriteAddr, (uint8_t*)(&dataindex)); - if(status != EEPROM_OK) - { - return status; - } - - /* Store the number of data to be written */ - dataindex = (NumByteToWrite - count); - /* Write the remaining data in the following page */ - status = BSP_EEPROM_WritePage((uint8_t*)(pBuffer + count), (WriteAddr + count), (uint8_t*)(&dataindex)); - if(status != EEPROM_OK) - { - return status; - } - } - else - { - /* Store the number of data to be written */ - dataindex = numofsingle; - status = BSP_EEPROM_WritePage(pBuffer, WriteAddr, (uint8_t*)(&dataindex)); - if(status != EEPROM_OK) - { - return status; - } - } - } - /* If NumByteToWrite > EEPROM_PAGESIZE */ - else - { - NumByteToWrite -= count; - numofpage = NumByteToWrite / EEPROM_PAGESIZE; - numofsingle = NumByteToWrite % EEPROM_PAGESIZE; - - if(count != 0) - { - /* Store the number of data to be written */ - dataindex = count; - status = BSP_EEPROM_WritePage(pBuffer, WriteAddr, (uint8_t*)(&dataindex)); - if(status != EEPROM_OK) - { - return status; - } - WriteAddr += count; - pBuffer += count; - } - - while(numofpage--) - { - /* Store the number of data to be written */ - dataindex = EEPROM_PAGESIZE; - status = BSP_EEPROM_WritePage(pBuffer, WriteAddr, (uint8_t*)(&dataindex)); - if(status != EEPROM_OK) - { - return status; - } - WriteAddr += EEPROM_PAGESIZE; - pBuffer += EEPROM_PAGESIZE; - } - if(numofsingle != 0) - { - /* Store the number of data to be written */ - dataindex = numofsingle; - status = BSP_EEPROM_WritePage(pBuffer, WriteAddr, (uint8_t*)(&dataindex)); - if(status != EEPROM_OK) - { - return status; - } - } - } - } - - /* If all operations OK, return EEPROM_OK (0) */ - return EEPROM_OK; -} - -/** - * @brief Wait for EEPROM Standby state. - * - * @note This function allows to wait and check that EEPROM has finished the - * last operation. It is mostly used after Write operation: after receiving - * the buffer to be written, the EEPROM may need additional time to actually - * perform the write operation. During this time, it doesn't answer to - * I2C packets addressed to it. Once the write operation is complete - * the EEPROM responds to its address. - * - * @param None - * @retval EEPROM_OK (0) if operation is correctly performed, else return value - * different from EEPROM_OK (0) or the timeout user callback. - */ -uint32_t BSP_EEPROM_WaitEepromStandbyState(void) -{ - /* Check if the maximum allowed number of trials has bee reached */ - if(EEPROM_IO_IsDeviceReady(EEPROMAddress, EEPROM_MAX_TRIALS) != HAL_OK) - { - /* If the maximum number of trials has been reached, exit the function */ - BSP_EEPROM_TIMEOUT_UserCallback(); - return EEPROM_TIMEOUT; - } - return EEPROM_OK; -} - -/** - * @brief Basic management of the timeout situation. - * @param None - * @retval None - */ -__weak void BSP_EEPROM_TIMEOUT_UserCallback(void) -{ -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/stm32446e_eval_eeprom.h b/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/stm32446e_eval_eeprom.h deleted file mode 100644 index 89fc3dd65f..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/stm32446e_eval_eeprom.h +++ /dev/null @@ -1,140 +0,0 @@ -/** - ****************************************************************************** - * @file stm32446e_eval_eeprom.h - * @author MCD Application Team - * @version V1.1.0 - * @date 14-August-2015 - * @brief This file contains all the functions prototypes for - * the stm32446e_eval_eeprom.c firmware driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32F446E_EVAL_EEPROM_H -#define __STM32F446E_EVAL_EEPROM_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm32446e_eval.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32446E_EVAL - * @{ - */ - -/** @defgroup STM32446E_EVAL_EEPROM STM32446E-EVAL EEPROM - * @brief This file includes the I2C EEPROM driver of STM32446E-EVAL evaluation board. - * @{ - */ - -/** @defgroup STM32446E_EVAL_EEPROM_Exported_Types STM32446E EVAL EEPROM Exported Types - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_EEPROM_Exported_Constants STM32446E EVAL EEPROM Exported Constants - * @{ - */ -/* EEPROM hardware address and page size */ -#define EEPROM_PAGESIZE ((uint8_t)4) -#define EEPROM_MAX_SIZE ((uint16_t)0x2000) /* 64Kbit */ - - -/* Maximum number of trials for EEPROM_WaitEepromStandbyState() function */ -#define EEPROM_MAX_TRIALS ((uint32_t)3000) - -#define EEPROM_OK ((uint32_t)0) -#define EEPROM_FAIL ((uint32_t)1) -#define EEPROM_TIMEOUT ((uint32_t)2) -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_EEPROM_Exported_Macros STM32446E EVAL EEPROM Exported Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_EEPROM_Exported_Functions STM32446E EVAL EEPROM Exported Functions - * @{ - */ -uint32_t BSP_EEPROM_Init(void); -uint8_t BSP_EEPROM_DeInit(void); -uint32_t BSP_EEPROM_ReadBuffer(uint8_t* pBuffer, uint16_t ReadAddr, uint16_t* NumByteToRead); -uint32_t BSP_EEPROM_WritePage(uint8_t* pBuffer, uint16_t WriteAddr, uint8_t* NumByteToWrite); -uint32_t BSP_EEPROM_WriteBuffer(uint8_t* pBuffer, uint16_t WriteAddr, uint16_t NumByteToWrite); -uint32_t BSP_EEPROM_WaitEepromStandbyState(void); - -/* USER Callbacks: This function is declared as __weak in EEPROM driver and - should be implemented into user application. - BSP_EEPROM_TIMEOUT_UserCallback() function is called whenever a timeout condition - occurs during communication (waiting on an event that doesn't occur, bus - errors, busy devices ...). */ -void BSP_EEPROM_TIMEOUT_UserCallback(void); - -/* Link function for I2C EEPROM peripheral */ -void EEPROM_IO_Init(void); -HAL_StatusTypeDef EEPROM_IO_WriteData(uint16_t DevAddress, uint16_t MemAddress, uint8_t *pBuffer, uint32_t BufferSize); -HAL_StatusTypeDef EEPROM_IO_ReadData(uint16_t DevAddress, uint16_t MemAddress, uint8_t *pBuffer, uint32_t BufferSize); -HAL_StatusTypeDef EEPROM_IO_IsDeviceReady(uint16_t DevAddress, uint32_t Trials); - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32446E_EVAL_EEPROM_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/stm32446e_eval_io.c b/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/stm32446e_eval_io.c deleted file mode 100644 index 18de633673..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/stm32446e_eval_io.c +++ /dev/null @@ -1,327 +0,0 @@ -/** - ****************************************************************************** - * @file stm32446e_eval_io.c - * @author MCD Application Team - * @version V1.1.0 - * @date 14-August-2015 - * @brief This file provides a set of functions needed to manage the IO pins - * on STM32446E-EVAL evaluation board. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* File Info : ----------------------------------------------------------------- - User NOTES -1. How To use this driver: --------------------------- - - This driver is used to drive the IO module of the STM32446E-EVAL evaluation - board. - - The MFXSTM32L152 IO expander device component driver must be included with this - driver in order to run the IO functionalities commanded by the IO expander (MFX) - device mounted on the evaluation board. - -2. Driver description: ---------------------- - + Initialization steps: - o Initialize the IO module using the BSP_IO_Init() function. This - function includes the MSP layer hardware resources initialization and the - communication layer configuration to start the IO functionalities use. - - + IO functionalities use - o The IO pin mode is configured when calling the function BSP_IO_ConfigPin(), you - must specify the desired IO mode by choosing the "IO_ModeTypedef" parameter - predefined value. - o If an IO pin is used in interrupt mode, the function BSP_IO_ITGetStatus() is - needed to get the interrupt status. To clear the IT pending bits, you should - call the function BSP_IO_ITClear() with specifying the IO pending bit to clear. - o The IT is handled using the corresponding external interrupt IRQ handler, - the user IT callback treatment is implemented on the same external interrupt - callback. - o The IRQ_OUT pin (common for all functionalities: TS, JOY, SD, etc) can be - configured using the function BSP_IO_ConfigIrqOutPin() - o To get/set an IO pin combination state you can use the functions - BSP_IO_ReadPin()/BSP_IO_WritePin() or the function BSP_IO_TogglePin() to toggle the pin - state. - -------------------------------------------------------------------------------*/ - -/* Includes ------------------------------------------------------------------*/ -#include "stm32446e_eval_io.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32446E_EVAL - * @{ - */ - -/** @defgroup STM32446E_EVAL_IO STM32446E-EVAL IO - * @{ - */ - -/** @defgroup STM32446E_EVAL_IO_Private_Types_Definitions STM32446E Eval Io Private TypesDef - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_IO_Private_Defines STM32446E Eval Io Private Defines - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_IO_Private_Macros STM32446E Eval Io Private Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_IO_Private_Variables STM32446E Eval Io Private Variables - * @{ - */ -static IO_DrvTypeDef *IoDrv = NULL; -static uint8_t mfxstm32l152Identifier; - -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_IO_Private_Function_Prototypes STM32446E Eval Io Private Prototypes - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_IO_Private_Functions STM32446E Eval Io Private Functions - * @{ - */ - -/** - * @brief Initializes and configures the IO functionalities and configures all - * necessary hardware resources (MFX, ...). - * @note BSP_IO_Init() is using HAL_Delay() function to ensure that MFXSTM32L152 - * IO Expander is correctly reset. HAL_Delay() function provides accurate - * delay (in milliseconds) based on variable incremented in SysTick ISR. - * This implies that if BSP_IO_Init() is called from a peripheral ISR process, - * then the SysTick interrupt must have higher priority (numerically lower) - * than the peripheral interrupt. Otherwise the caller ISR process will be blocked. - * @param None - * @retval IO_OK if all initializations are OK. Other value if error. - */ -uint8_t BSP_IO_Init(void) -{ - uint8_t ret = IO_OK; - - if ( IoDrv == NULL) - { - /* Read ID and verify the IO expander is ready */ - mfxstm32l152Identifier=0; - mfxstm32l152Identifier = mfxstm32l152_io_drv.ReadID(IO_I2C_ADDRESS); - if((mfxstm32l152Identifier == MFXSTM32L152_ID_1) || (mfxstm32l152Identifier == MFXSTM32L152_ID_2)) - { - /* Initialize the IO driver structure */ - IoDrv = &mfxstm32l152_io_drv; - } - else - { - ret = IO_ERROR; - } - - if(ret == IO_OK) - { - IoDrv->Init(IO_I2C_ADDRESS); - IoDrv->Start(IO_I2C_ADDRESS, IO_PIN_ALL); - } - } - - return ret; -} - -/** - * @brief DeInit allows Mfx Initialization to be executed again - * @note BSP_IO_Init() has no effect if the IoDrv is already initialized - * BSP_IO_DeInit() allows to erase the pointer such to allow init to be effective - * @param None - * @retval IO_OK - */ -uint8_t BSP_IO_DeInit(void) -{ - IoDrv = NULL; - return IO_OK; -} - -/** - * @brief Gets the selected pins IT status. - * @param IoPin: Selected pins to check the status. - * This parameter can be any combination of the IO pins. - * @retval IO_OK if read status OK. Other value if error. - */ -uint32_t BSP_IO_ITGetStatus(uint32_t IoPin) -{ - /* Return the IO Pin IT status */ - return (IoDrv->ITStatus(IO_I2C_ADDRESS, IoPin)); -} - -/** - * @brief Clears all the IO IT pending bits. - * @param None - * @retval None - */ -void BSP_IO_ITClear(void) -{ - /* Clear all IO IT pending bits */ - IoDrv->ClearIT(IO_I2C_ADDRESS, MFXSTM32L152_GPIO_PINS_ALL); -} - -/** - * @brief Configures the IO pin(s) according to IO mode structure value. - * @param IoPin: IO pin(s) to be configured. - * This parameter can be one of the following values: - * @arg MFXSTM32L152_GPIO_PIN_x: where x can be from 0 to 23. - * @param IoMode: IO pin mode to configure - * This parameter can be one of the following values: - * @arg IO_MODE_INPUT - * @arg IO_MODE_OUTPUT - * @arg IO_MODE_IT_RISING_EDGE - * @arg IO_MODE_IT_FALLING_EDGE - * @arg IO_MODE_IT_LOW_LEVEL - * @arg IO_MODE_IT_HIGH_LEVEL - * @arg IO_MODE_ANALOG - * @arg IO_MODE_OFF - * @arg IO_MODE_INPUT_PU, - * @arg IO_MODE_INPUT_PD, - * @arg IO_MODE_OUTPUT_OD, - * @arg IO_MODE_OUTPUT_OD_PU, - * @arg IO_MODE_OUTPUT_OD_PD, - * @arg IO_MODE_OUTPUT_PP, - * @arg IO_MODE_OUTPUT_PP_PU, - * @arg IO_MODE_OUTPUT_PP_PD, - * @arg IO_MODE_IT_RISING_EDGE_PU - * @arg IO_MODE_IT_FALLING_EDGE_PU - * @arg IO_MODE_IT_LOW_LEVEL_PU - * @arg IO_MODE_IT_HIGH_LEVEL_PU - * @arg IO_MODE_IT_RISING_EDGE_PD - * @arg IO_MODE_IT_FALLING_EDGE_PD - * @arg IO_MODE_IT_LOW_LEVEL_PD - * @arg IO_MODE_IT_HIGH_LEVEL_PD - * @retval IO_OK if all initializations are OK. Other value if error. - */ -uint8_t BSP_IO_ConfigPin(uint32_t IoPin, IO_ModeTypedef IoMode) -{ - /* Configure the selected IO pin(s) mode */ - IoDrv->Config(IO_I2C_ADDRESS, IoPin, IoMode); - - return IO_OK; -} - -/** - * @brief Sets the IRQ_OUT pin polarity and type - * @param IoIrqOutPinPolarity: High/Low - * @param IoIrqOutPinType: OpenDrain/PushPull - * @retval OK - */ -uint8_t BSP_IO_ConfigIrqOutPin(uint8_t IoIrqOutPinPolarity, uint8_t IoIrqOutPinType) -{ - if((mfxstm32l152Identifier == MFXSTM32L152_ID_1) || (mfxstm32l152Identifier == MFXSTM32L152_ID_2)) - { - /* Initialize the IO driver structure */ - mfxstm32l152_SetIrqOutPinPolarity(IO_I2C_ADDRESS, IoIrqOutPinPolarity); - mfxstm32l152_SetIrqOutPinType(IO_I2C_ADDRESS, IoIrqOutPinType); - } - - return IO_OK; -} - -/** - * @brief Sets the selected pins state. - * @param IoPin: Selected pins to write. - * This parameter can be any combination of the IO pins. - * @param PinState: New pins state to write - * @retval None - */ -void BSP_IO_WritePin(uint32_t IoPin, BSP_IO_PinStateTypeDef PinState) -{ - /* Set the Pin state */ - IoDrv->WritePin(IO_I2C_ADDRESS, IoPin, PinState); -} - -/** - * @brief Gets the selected pins current state. - * @param IoPin: Selected pins to read. - * This parameter can be any combination of the IO pins. - * @retval The current pins state - */ -uint32_t BSP_IO_ReadPin(uint32_t IoPin) -{ - return(IoDrv->ReadPin(IO_I2C_ADDRESS, IoPin)); -} - -/** - * @brief Toggles the selected pins state. - * @param IoPin: Selected pins to toggle. - * This parameter can be any combination of the IO pins. - * @note This function is only used to toggle one pin in the same time - * @retval None - */ -void BSP_IO_TogglePin(uint32_t IoPin) -{ - /* Toggle the current pin state */ - if(IoDrv->ReadPin(IO_I2C_ADDRESS, IoPin) != 0) /* Set */ - { - IoDrv->WritePin(IO_I2C_ADDRESS, IoPin, 0); /* Reset */ - } - else - { - IoDrv->WritePin(IO_I2C_ADDRESS, IoPin, 1); /* Set */ - } -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/stm32446e_eval_io.h b/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/stm32446e_eval_io.h deleted file mode 100644 index f9af0d3149..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/stm32446e_eval_io.h +++ /dev/null @@ -1,159 +0,0 @@ -/** - ****************************************************************************** - * @file stm32446e_eval_io.h - * @author MCD Application Team - * @version V1.1.0 - * @date 14-August-2015 - * @brief This file contains the common defines and functions prototypes for - * the stm32446e_eval_io.c driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32446E_EVAL_IO_H -#define __STM32446E_EVAL_IO_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm32446e_eval.h" -/* Include IO component driver */ -#include "../Components/mfxstm32l152/mfxstm32l152.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32446E_EVAL - * @{ - */ - -/** @defgroup STM32446E_EVAL_IO STM32446E-EVAL IO - * @{ - */ - -/** @defgroup STM32446E_EVAL_IO_Exported_Types STM32446E EVAL IO Exported Types - * @{ - */ - -typedef enum -{ - BSP_IO_PIN_RESET = 0, - BSP_IO_PIN_SET = 1 -}BSP_IO_PinStateTypeDef; - -typedef enum -{ - IO_OK = 0, - IO_ERROR = 1, - IO_TIMEOUT = 2 -}IO_StatusTypeDef; - -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_IO_Exported_Constants STM32446E EVAL IO Exported Constants - * @{ - */ -#define IO_PIN_0 ((uint32_t)0x0001) -#define IO_PIN_1 ((uint32_t)0x0002) -#define IO_PIN_2 ((uint32_t)0x0004) -#define IO_PIN_3 ((uint32_t)0x0008) -#define IO_PIN_4 ((uint32_t)0x0010) -#define IO_PIN_5 ((uint32_t)0x0020) -#define IO_PIN_6 ((uint32_t)0x0040) -#define IO_PIN_7 ((uint32_t)0x0080) -#define IO_PIN_8 ((uint32_t)0x0100) -#define IO_PIN_9 ((uint32_t)0x0200) -#define IO_PIN_10 ((uint32_t)0x0400) -#define IO_PIN_11 ((uint32_t)0x0800) -#define IO_PIN_12 ((uint32_t)0x1000) -#define IO_PIN_13 ((uint32_t)0x2000) -#define IO_PIN_14 ((uint32_t)0x4000) -#define IO_PIN_15 ((uint32_t)0x8000) -#define IO_PIN_16 ((uint32_t)0x010000) -#define IO_PIN_17 ((uint32_t)0x020000) -#define IO_PIN_18 ((uint32_t)0x040000) -#define IO_PIN_19 ((uint32_t)0x080000) -#define IO_PIN_20 ((uint32_t)0x100000) -#define IO_PIN_21 ((uint32_t)0x200000) -#define IO_PIN_22 ((uint32_t)0x400000) -#define IO_PIN_23 ((uint32_t)0x800000) -#define IO_PIN_ALL ((uint32_t)0xFFFFFF) -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_IO_Exported_Macro STM32446E EVAL IO Exported Macro - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_IO_Exported_Functions STM32446E EVAL IO Exported Functions - * @{ - */ -uint8_t BSP_IO_Init(void); -uint8_t BSP_IO_DeInit(void); -uint8_t BSP_IO_ConfigIrqOutPin(uint8_t IoIrqOutPinPolarity, uint8_t IoIrqOutPinType); -uint32_t BSP_IO_ITGetStatus(uint32_t IoPin); -void BSP_IO_ITClear(void); -uint8_t BSP_IO_ConfigPin(uint32_t IoPin, IO_ModeTypedef IoMode); -void BSP_IO_WritePin(uint32_t IoPin, BSP_IO_PinStateTypeDef PinState); -uint32_t BSP_IO_ReadPin(uint32_t IoPin); -void BSP_IO_TogglePin(uint32_t IoPin); - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32446E_EVAL_IO_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/stm32446e_eval_lcd.c b/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/stm32446e_eval_lcd.c deleted file mode 100644 index ada440e09f..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/stm32446e_eval_lcd.c +++ /dev/null @@ -1,1088 +0,0 @@ -/** - ****************************************************************************** - * @file stm32446e_eval_lcd.c - * @author MCD Application Team - * @version V1.1.0 - * @date 14-August-2015 - * @brief This file includes the driver for Liquid Crystal Display (LCD) module - * mounted on STM32446E-EVAL evaluation board. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* File Info : ----------------------------------------------------------------- - User NOTES -1. How To use this driver: --------------------------- - - This driver is used to drive indirectly an LCD TFT. - - This driver supports the ILI9325 LCD mounted on MB785 daughter board - - The ILI9325 component driver MUST be included with this driver. - -2. Driver description: ---------------------- - + Initialization steps: - o Initialize the LCD using the BSP_LCD_Init() function. - - + Display on LCD - o Clear the hole LCD using BSP_LCD_Clear() function or only one specified string - line using the BSP_LCD_ClearStringLine() function. - o Display a character on the specified line and column using the BSP_LCD_DisplayChar() - function or a complete string line using the BSP_LCD_DisplayStringAtLine() function. - o Display a string line on the specified position (x,y in pixel) and align mode - using the BSP_LCD_DisplayStringAtLine() function. - o Draw and fill a basic shapes (dot, line, rectangle, circle, ellipse, .. bitmap) - on LCD using the available set of functions. - -------------------------------------------------------------------------------*/ - -/* Includes ------------------------------------------------------------------*/ -#include "stm32446e_eval_lcd.h" -#include "../../../Utilities/Fonts/fonts.h" -#include "../../../Utilities/Fonts/font24.c" -#include "../../../Utilities/Fonts/font20.c" -#include "../../../Utilities/Fonts/font16.c" -#include "../../../Utilities/Fonts/font12.c" -#include "../../../Utilities/Fonts/font8.c" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32446E_EVAL - * @{ - */ - -/** @defgroup STM32446E_EVAL_LCD STM32446E-EVAL LCD - * @{ - */ - -/** @defgroup STM32446E_EVAL_LCD_Private_TypesDefinitions STM32446E Eval Lcd Private TypesDef - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_LCD_Private_Defines STM32446E Eval Lcd Private Defines - * @{ - */ -#define POLY_X(Z) ((int32_t)((Points + Z)->X)) -#define POLY_Y(Z) ((int32_t)((Points + Z)->Y)) -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_LCD_Private_Macros STM32446E Eval Lcd Private Macros - * @{ - */ -#define ABS(X) ((X) > 0 ? (X) : -(X)) -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_LCD_Private_Variables STM32446E Eval Lcd Private Variables - * @{ - */ -LCD_DrawPropTypeDef DrawProp; -static LCD_DrvTypeDef *LcdDrv; -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_LCD_Private_FunctionPrototypes STM32446E Eval Lcd Private Prototypes - * @{ - */ -static void DrawChar(uint16_t Xpos, uint16_t Ypos, const uint8_t *c); -static void SetDisplayWindow(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height); -static void FillTriangle(uint16_t x1, uint16_t x2, uint16_t x3, uint16_t y1, uint16_t y2, uint16_t y3); -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_LCD_Private_Functions STM32446E Eval Lcd Private Functions - * @{ - */ - -/** - * @brief Initializes the LCD. - * @param None - * @retval LCD state - */ -uint8_t BSP_LCD_Init(void) -{ - uint8_t ret = LCD_ERROR; - - /* Default value for draw propriety */ - DrawProp.BackColor = 0xFFFF; - DrawProp.pFont = &Font24; - DrawProp.TextColor = 0x0000; - - if(ili9325_drv.ReadID() == ILI9325_ID) - { - LcdDrv = &ili9325_drv; - - /* LCD Init */ - LcdDrv->Init(); - - /* Initialize the font */ - BSP_LCD_SetFont(&LCD_DEFAULT_FONT); - - ret = LCD_OK; - } - - return ret; -} - -/** - * @brief DeInitializes the LCD. - * @param None - * @retval LCD state - */ -uint8_t BSP_LCD_DeInit(void) -{ - /* Actually LcdDrv does not provide a DeInit function */ - return LCD_OK; -} - -/** - * @brief Gets the LCD X size. - * @param None - * @retval Used LCD X size - */ -uint32_t BSP_LCD_GetXSize(void) -{ - return(LcdDrv->GetLcdPixelWidth()); -} - -/** - * @brief Gets the LCD Y size. - * @param None - * @retval Used LCD Y size - */ -uint32_t BSP_LCD_GetYSize(void) -{ - return(LcdDrv->GetLcdPixelHeight()); -} - -/** - * @brief Gets the LCD text color. - * @param None - * @retval Used text color. - */ -uint16_t BSP_LCD_GetTextColor(void) -{ - return DrawProp.TextColor; -} - -/** - * @brief Gets the LCD background color. - * @param None - * @retval Used background color - */ -uint16_t BSP_LCD_GetBackColor(void) -{ - return DrawProp.BackColor; -} - -/** - * @brief Sets the LCD text color. - * @param Color: Text color code RGB(5-6-5) - * @retval None - */ -void BSP_LCD_SetTextColor(uint16_t Color) -{ - DrawProp.TextColor = Color; -} - -/** - * @brief Sets the LCD background color. - * @param Color: Background color code RGB(5-6-5) - * @retval None - */ -void BSP_LCD_SetBackColor(uint16_t Color) -{ - DrawProp.BackColor = Color; -} - -/** - * @brief Sets the LCD text font. - * @param fonts: Font to be used - * @retval None - */ -void BSP_LCD_SetFont(sFONT *fonts) -{ - DrawProp.pFont = fonts; -} - -/** - * @brief Gets the LCD text font. - * @param None - * @retval Used font - */ -sFONT *BSP_LCD_GetFont(void) -{ - return DrawProp.pFont; -} - -/** - * @brief Clears the hole LCD. - * @param Color: Color of the background - * @retval None - */ -void BSP_LCD_Clear(uint16_t Color) -{ - uint32_t counter = 0; - uint32_t y_size = 0; - uint32_t color_backup = DrawProp.TextColor; - - DrawProp.TextColor = Color; - y_size = BSP_LCD_GetYSize(); - - for(counter = 0; counter < y_size; counter++) - { - BSP_LCD_DrawHLine(0, counter, BSP_LCD_GetXSize()); - } - DrawProp.TextColor = color_backup; - BSP_LCD_SetTextColor(DrawProp.TextColor); -} - -/** - * @brief Clears the selected line. - * @param Line: Line to be cleared - * This parameter can be one of the following values: - * @arg 0..9: if the Current fonts is Font16x24 - * @arg 0..19: if the Current fonts is Font12x12 or Font8x12 - * @arg 0..29: if the Current fonts is Font8x8 - * @retval None - */ -void BSP_LCD_ClearStringLine(uint16_t Line) -{ - uint32_t color_backup = DrawProp.TextColor; - - DrawProp.TextColor = DrawProp.BackColor;; - - /* Draw a rectangle with background color */ - BSP_LCD_FillRect(0, (Line * DrawProp.pFont->Height), BSP_LCD_GetXSize(), DrawProp.pFont->Height); - - DrawProp.TextColor = color_backup; - BSP_LCD_SetTextColor(DrawProp.TextColor); -} - -/** - * @brief Displays one character. - * @param Xpos: Start column address - * @param Ypos: Line where to display the character shape. - * @param Ascii: Character ascii code - * This parameter must be a number between Min_Data = 0x20 and Max_Data = 0x7E - * @retval None - */ -void BSP_LCD_DisplayChar(uint16_t Xpos, uint16_t Ypos, uint8_t Ascii) -{ - DrawChar(Xpos, Ypos, &DrawProp.pFont->table[(Ascii-' ') *\ - DrawProp.pFont->Height * ((DrawProp.pFont->Width + 7) / 8)]); -} - -/** - * @brief Displays characters on the LCD. - * @param Xpos: X position (in pixel) - * @param Ypos: Y position (in pixel) - * @param Text: Pointer to string to display on LCD - * @param Mode: Display mode - * This parameter can be one of the following values: - * @arg CENTER_MODE - * @arg RIGHT_MODE - * @arg LEFT_MODE - * @retval None - */ -void BSP_LCD_DisplayStringAt(uint16_t Xpos, uint16_t Ypos, uint8_t *Text, Line_ModeTypdef Mode) -{ - uint16_t refcolumn = 1, i = 0; - uint32_t size = 0, xsize = 0; - uint8_t *ptr = Text; - - /* Get the text size */ - while (*ptr++) size ++ ; - - /* Characters number per line */ - xsize = (BSP_LCD_GetXSize()/DrawProp.pFont->Width); - - switch (Mode) - { - case CENTER_MODE: - { - refcolumn = Xpos + ((xsize - size)* DrawProp.pFont->Width) / 2; - break; - } - case LEFT_MODE: - { - refcolumn = Xpos; - break; - } - case RIGHT_MODE: - { - refcolumn = - Xpos + ((xsize - size)*DrawProp.pFont->Width); - break; - } - default: - { - refcolumn = Xpos; - break; - } - } - - /* Check that the Start column is located in the screen */ - if ((refcolumn < 1) || (refcolumn >= 0x8000)) - { - refcolumn = 1; - } - - /* Send the string character by character on lCD */ - while ((*Text != 0) & (((BSP_LCD_GetXSize() - (i*DrawProp.pFont->Width)) & 0xFFFF) >= DrawProp.pFont->Width)) - { - /* Display one character on LCD */ - BSP_LCD_DisplayChar(refcolumn, Ypos, *Text); - /* Decrement the column position by 16 */ - refcolumn += DrawProp.pFont->Width; - /* Point on the next character */ - Text++; - i++; - } -} - -/** - * @brief Displays a character on the LCD. - * @param Line: Line where to display the character shape - * This parameter can be one of the following values: - * @arg 0..9: if the Current fonts is Font16x24 - * @arg 0..19: if the Current fonts is Font12x12 or Font8x12 - * @arg 0..29: if the Current fonts is Font8x8 - * @param ptr: Pointer to string to display on LCD - * @retval None - */ -void BSP_LCD_DisplayStringAtLine(uint16_t Line, uint8_t *ptr) -{ - BSP_LCD_DisplayStringAt(0, LINE(Line), ptr, LEFT_MODE); -} - -/** - * @brief Reads an LCD pixel. - * @param Xpos: X position - * @param Ypos: Y position - * @retval RGB pixel color - */ -uint16_t BSP_LCD_ReadPixel(uint16_t Xpos, uint16_t Ypos) -{ - uint16_t ret = 0; - - if(LcdDrv->ReadPixel != NULL) - { - ret = LcdDrv->ReadPixel(Xpos, Ypos); - } - - return ret; -} - -/** - * @brief Draws a pixel on LCD. - * @param Xpos: X position - * @param Ypos: Y position - * @param RGB_Code: Pixel color in RGB mode (5-6-5) - * @retval None - */ -void BSP_LCD_DrawPixel(uint16_t Xpos, uint16_t Ypos, uint16_t RGB_Code) -{ - if(LcdDrv->WritePixel != NULL) - { - LcdDrv->WritePixel(Xpos, Ypos, RGB_Code); - } -} - -/** - * @brief Draws an horizontal line. - * @param Xpos: X position - * @param Ypos: Y position - * @param Length: Line length - * @retval None - */ -void BSP_LCD_DrawHLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length) -{ - uint32_t index = 0; - - if(LcdDrv->DrawHLine != NULL) - { - LcdDrv->DrawHLine(DrawProp.TextColor, Xpos, Ypos, Length); - } - else - { - for(index = 0; index < Length; index++) - { - BSP_LCD_DrawPixel((Xpos + index), Ypos, DrawProp.TextColor); - } - } -} - -/** - * @brief Draws a vertical line. - * @param Xpos: X position - * @param Ypos: Y position - * @param Length: Line length - * @retval None - */ -void BSP_LCD_DrawVLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length) -{ - uint32_t index = 0; - - if(LcdDrv->DrawVLine != NULL) - { - LcdDrv->DrawVLine(DrawProp.TextColor, Xpos, Ypos, Length); - } - else - { - for(index = 0; index < Length; index++) - { - BSP_LCD_DrawPixel(Xpos, Ypos + index, DrawProp.TextColor); - } - } -} - -/** - * @brief Draws an uni-line (between two points). - * @param x1: Point 1 X position - * @param y1: Point 1 Y position - * @param x2: Point 2 X position - * @param y2: Point 2 Y position - * @retval None - */ -void BSP_LCD_DrawLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) -{ - int16_t deltax = 0, deltay = 0, x = 0, y = 0, xinc1 = 0, xinc2 = 0, - yinc1 = 0, yinc2 = 0, den = 0, num = 0, numadd = 0, numpixels = 0, - curpixel = 0; - - deltax = ABS(x2 - x1); /* The difference between the x's */ - deltay = ABS(y2 - y1); /* The difference between the y's */ - x = x1; /* Start x off at the first pixel */ - y = y1; /* Start y off at the first pixel */ - - if (x2 >= x1) /* The x-values are increasing */ - { - xinc1 = 1; - xinc2 = 1; - } - else /* The x-values are decreasing */ - { - xinc1 = -1; - xinc2 = -1; - } - - if (y2 >= y1) /* The y-values are increasing */ - { - yinc1 = 1; - yinc2 = 1; - } - else /* The y-values are decreasing */ - { - yinc1 = -1; - yinc2 = -1; - } - - if (deltax >= deltay) /* There is at least one x-value for every y-value */ - { - xinc1 = 0; /* Don't change the x when numerator >= denominator */ - yinc2 = 0; /* Don't change the y for every iteration */ - den = deltax; - num = deltax / 2; - numadd = deltay; - numpixels = deltax; /* There are more x-values than y-values */ - } - else /* There is at least one y-value for every x-value */ - { - xinc2 = 0; /* Don't change the x for every iteration */ - yinc1 = 0; /* Don't change the y when numerator >= denominator */ - den = deltay; - num = deltay / 2; - numadd = deltax; - numpixels = deltay; /* There are more y-values than x-values */ - } - - for (curpixel = 0; curpixel <= numpixels; curpixel++) - { - BSP_LCD_DrawPixel(x, y, DrawProp.TextColor); /* Draw the current pixel */ - num += numadd; /* Increase the numerator by the top of the fraction */ - if (num >= den) /* Check if numerator >= denominator */ - { - num -= den; /* Calculate the new numerator value */ - x += xinc1; /* Change the x as appropriate */ - y += yinc1; /* Change the y as appropriate */ - } - x += xinc2; /* Change the x as appropriate */ - y += yinc2; /* Change the y as appropriate */ - } -} - -/** - * @brief Draws a rectangle. - * @param Xpos: X position - * @param Ypos: Y position - * @param Width: Rectangle width - * @param Height: Rectangle height - * @retval None - */ -void BSP_LCD_DrawRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height) -{ - /* Draw horizontal lines */ - BSP_LCD_DrawHLine(Xpos, Ypos, Width); - BSP_LCD_DrawHLine(Xpos, (Ypos+ Height), Width); - - /* Draw vertical lines */ - BSP_LCD_DrawVLine(Xpos, Ypos, Height); - BSP_LCD_DrawVLine((Xpos + Width), Ypos, Height); -} - -/** - * @brief Draws a circle. - * @param Xpos: X position - * @param Ypos: Y position - * @param Radius: Circle radius - * @retval None - */ -void BSP_LCD_DrawCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius) -{ - int32_t decision; /* Decision Variable */ - uint32_t current_x; /* Current X Value */ - uint32_t current_y; /* Current Y Value */ - - decision = 3 - (Radius << 1); - current_x = 0; - current_y = Radius; - - while (current_x <= current_y) - { - BSP_LCD_DrawPixel((Xpos + current_x), (Ypos - current_y), DrawProp.TextColor); - - BSP_LCD_DrawPixel((Xpos - current_x), (Ypos - current_y), DrawProp.TextColor); - - BSP_LCD_DrawPixel((Xpos + current_y), (Ypos - current_x), DrawProp.TextColor); - - BSP_LCD_DrawPixel((Xpos - current_y), (Ypos - current_x), DrawProp.TextColor); - - BSP_LCD_DrawPixel((Xpos + current_x), (Ypos + current_y), DrawProp.TextColor); - - BSP_LCD_DrawPixel((Xpos - current_x), (Ypos + current_y), DrawProp.TextColor); - - BSP_LCD_DrawPixel((Xpos + current_y), (Ypos + current_x), DrawProp.TextColor); - - BSP_LCD_DrawPixel((Xpos - current_y), (Ypos + current_x), DrawProp.TextColor); - - /* Initialize the font */ - BSP_LCD_SetFont(&LCD_DEFAULT_FONT); - - if (decision < 0) - { - decision += (current_x << 2) + 6; - } - else - { - decision += ((current_x - current_y) << 2) + 10; - current_y--; - } - current_x++; - } -} - -/** - * @brief Draws an poly-line (between many points). - * @param Points: Pointer to the points array - * @param PointCount: Number of points - * @retval None - */ -void BSP_LCD_DrawPolygon(pPoint Points, uint16_t PointCount) -{ - int16_t x = 0, y = 0; - - if(PointCount < 2) - { - return; - } - - BSP_LCD_DrawLine(Points->X, Points->Y, (Points+PointCount-1)->X, (Points+PointCount-1)->Y); - - while(--PointCount) - { - x = Points->X; - y = Points->Y; - Points++; - BSP_LCD_DrawLine(x, y, Points->X, Points->Y); - } -} - -/** - * @brief Draws an ellipse on LCD. - * @param Xpos: X position - * @param Ypos: Y position - * @param XRadius: Ellipse X radius - * @param YRadius: Ellipse Y radius - * @retval None - */ -void BSP_LCD_DrawEllipse(int Xpos, int Ypos, int XRadius, int YRadius) -{ - int x = 0, y = -YRadius, err = 2-2*XRadius, e2; - float k = 0, rad1 = 0, rad2 = 0; - - rad1 = XRadius; - rad2 = YRadius; - - k = (float)(rad2/rad1); - - do { - BSP_LCD_DrawPixel((Xpos-(uint16_t)(x/k)), (Ypos+y), DrawProp.TextColor); - BSP_LCD_DrawPixel((Xpos+(uint16_t)(x/k)), (Ypos+y), DrawProp.TextColor); - BSP_LCD_DrawPixel((Xpos+(uint16_t)(x/k)), (Ypos-y), DrawProp.TextColor); - BSP_LCD_DrawPixel((Xpos-(uint16_t)(x/k)), (Ypos-y), DrawProp.TextColor); - - e2 = err; - if (e2 <= x) { - err += ++x*2+1; - if (-y == x && e2 <= y) e2 = 0; - } - if (e2 > y) err += ++y*2+1; - } - while (y <= 0); -} - -/** - * @brief Draws a bitmap picture (16 bpp). - * @param Xpos: Bmp X position in the LCD - * @param Ypos: Bmp Y position in the LCD - * @param pbmp: Pointer to Bmp picture address. - * @retval None - */ -void BSP_LCD_DrawBitmap(uint16_t Xpos, uint16_t Ypos, uint8_t *pbmp) -{ - uint32_t height = 0; - uint32_t width = 0; - - - /* Read bitmap width */ - width = *(uint16_t *) (pbmp + 18); - width |= (*(uint16_t *) (pbmp + 20)) << 16; - - /* Read bitmap height */ - height = *(uint16_t *) (pbmp + 22); - height |= (*(uint16_t *) (pbmp + 24)) << 16; - - SetDisplayWindow(Xpos, Ypos, width, height); - - if(LcdDrv->DrawBitmap != NULL) - { - LcdDrv->DrawBitmap(Xpos, Ypos, pbmp); - } - SetDisplayWindow(0, 0, BSP_LCD_GetXSize(), BSP_LCD_GetYSize()); -} - -/** - * @brief Draws RGB Image (16 bpp). - * @param Xpos: X position in the LCD - * @param Ypos: Y position in the LCD - * @param Xsize: X size in the LCD - * @param Ysize: Y size in the LCD - * @param pdata: Pointer to the RGB Image address. - * @retval None - */ -void BSP_LCD_DrawRGBImage(uint16_t Xpos, uint16_t Ypos, uint16_t Xsize, uint16_t Ysize, uint8_t *pdata) -{ - - SetDisplayWindow(Xpos, Ypos, Xsize, Ysize); - - if(LcdDrv->DrawRGBImage != NULL) - { - LcdDrv->DrawRGBImage(Xpos, Ypos, Xsize, Ysize, pdata); - } - SetDisplayWindow(0, 0, BSP_LCD_GetXSize(), BSP_LCD_GetYSize()); -} - -/** - * @brief Draws a full rectangle. - * @param Xpos: X position - * @param Ypos: Y position - * @param Width: Rectangle width - * @param Height: Rectangle height - * @retval None - */ -void BSP_LCD_FillRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height) -{ - BSP_LCD_SetTextColor(DrawProp.TextColor); - do - { - BSP_LCD_DrawHLine(Xpos, Ypos++, Width); - } - while(Height--); -} - -/** - * @brief Draws a full circle. - * @param Xpos: X position - * @param Ypos: Y position - * @param Radius: Circle radius - * @retval None - */ -void BSP_LCD_FillCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius) -{ - int32_t decision; /* Decision Variable */ - uint32_t current_x; /* Current X Value */ - uint32_t current_y; /* Current Y Value */ - - decision = 3 - (Radius << 1); - - current_x = 0; - current_y = Radius; - - BSP_LCD_SetTextColor(DrawProp.TextColor); - - while (current_x <= current_y) - { - if(current_y > 0) - { - BSP_LCD_DrawHLine(Xpos - current_y, Ypos + current_x, 2*current_y); - BSP_LCD_DrawHLine(Xpos - current_y, Ypos - current_x, 2*current_y); - } - - if(current_x > 0) - { - BSP_LCD_DrawHLine(Xpos - current_x, Ypos - current_y, 2*current_x); - BSP_LCD_DrawHLine(Xpos - current_x, Ypos + current_y, 2*current_x); - } - if (decision < 0) - { - decision += (current_x << 2) + 6; - } - else - { - decision += ((current_x - current_y) << 2) + 10; - current_y--; - } - current_x++; - } - - BSP_LCD_SetTextColor(DrawProp.TextColor); - BSP_LCD_DrawCircle(Xpos, Ypos, Radius); -} - -/** - * @brief Draws a full poly-line (between many points). - * @param Points: Pointer to the points array - * @param PointCount: Number of points - * @retval None - */ -void BSP_LCD_FillPolygon(pPoint Points, uint16_t PointCount) -{ - int16_t X = 0, Y = 0, X2 = 0, Y2 = 0, X_center = 0, Y_center = 0, X_first = 0, Y_first = 0, pixelX = 0, pixelY = 0, counter = 0; - uint16_t IMAGE_LEFT = 0, IMAGE_RIGHT = 0, IMAGE_TOP = 0, IMAGE_BOTTOM = 0; - - IMAGE_LEFT = IMAGE_RIGHT = Points->X; - IMAGE_TOP= IMAGE_BOTTOM = Points->Y; - - for(counter = 1; counter < PointCount; counter++) - { - pixelX = POLY_X(counter); - if(pixelX < IMAGE_LEFT) - { - IMAGE_LEFT = pixelX; - } - if(pixelX > IMAGE_RIGHT) - { - IMAGE_RIGHT = pixelX; - } - - pixelY = POLY_Y(counter); - if(pixelY < IMAGE_TOP) - { - IMAGE_TOP = pixelY; - } - if(pixelY > IMAGE_BOTTOM) - { - IMAGE_BOTTOM = pixelY; - } - } - - if(PointCount < 2) - { - return; - } - - X_center = (IMAGE_LEFT + IMAGE_RIGHT)/2; - Y_center = (IMAGE_BOTTOM + IMAGE_TOP)/2; - - X_first = Points->X; - Y_first = Points->Y; - - while(--PointCount) - { - X = Points->X; - Y = Points->Y; - Points++; - X2 = Points->X; - Y2 = Points->Y; - - FillTriangle(X, X2, X_center, Y, Y2, Y_center); - FillTriangle(X, X_center, X2, Y, Y_center, Y2); - FillTriangle(X_center, X2, X, Y_center, Y2, Y); - } - - FillTriangle(X_first, X2, X_center, Y_first, Y2, Y_center); - FillTriangle(X_first, X_center, X2, Y_first, Y_center, Y2); - FillTriangle(X_center, X2, X_first, Y_center, Y2, Y_first); -} - -/** - * @brief Draws a full ellipse. - * @param Xpos: X position - * @param Ypos: Y position - * @param XRadius: Ellipse X radius - * @param YRadius: Ellipse Y radius - * @retval None - */ -void BSP_LCD_FillEllipse(int Xpos, int Ypos, int XRadius, int YRadius) -{ - int x = 0, y = -YRadius, err = 2-2*XRadius, e2; - float k = 0, rad1 = 0, rad2 = 0; - - rad1 = XRadius; - rad2 = YRadius; - - k = (float)(rad2/rad1); - - do - { - BSP_LCD_DrawHLine((Xpos-(uint16_t)(x/k)), (Ypos+y), (2*(uint16_t)(x/k) + 1)); - BSP_LCD_DrawHLine((Xpos-(uint16_t)(x/k)), (Ypos-y), (2*(uint16_t)(x/k) + 1)); - - e2 = err; - if (e2 <= x) - { - err += ++x*2+1; - if (-y == x && e2 <= y) e2 = 0; - } - if (e2 > y) err += ++y*2+1; - } - while (y <= 0); -} - -/** - * @brief Enables the display. - * @param None - * @retval None - */ -void BSP_LCD_DisplayOn(void) -{ - LcdDrv->DisplayOn(); -} - -/** - * @brief Disables the display. - * @param None - * @retval None - */ -void BSP_LCD_DisplayOff(void) -{ - LcdDrv->DisplayOff(); -} - -/****************************************************************************** - Static Functions -*******************************************************************************/ - -/** - * @brief Draws a character on LCD. - * @param Xpos: Line where to display the character shape - * @param Ypos: Start column address - * @param c: Pointer to the character data - * @retval None - */ -static void DrawChar(uint16_t Xpos, uint16_t Ypos, const uint8_t *c) -{ - uint32_t i = 0, j = 0; - uint16_t height, width; - uint8_t offset; - uint8_t *pchar; - uint32_t line; - - height = DrawProp.pFont->Height; - width = DrawProp.pFont->Width; - - offset = 8 *((width + 7)/8) - width ; - - for(i = 0; i < height; i++) - { - pchar = ((uint8_t *)c + (width + 7)/8 * i); - - switch(((width + 7)/8)) - { - case 1: - line = pchar[0]; - break; - - case 2: - line = (pchar[0]<< 8) | pchar[1]; - break; - - case 3: - default: - line = (pchar[0]<< 16) | (pchar[1]<< 8) | pchar[2]; - break; - } - - for (j = 0; j < width; j++) - { - if(line & (1 << (width- j + offset- 1))) - { - BSP_LCD_DrawPixel((Xpos + j), Ypos, DrawProp.TextColor); - } - else - { - BSP_LCD_DrawPixel((Xpos + j), Ypos, DrawProp.BackColor); - } - } - Ypos++; - } -} - -/** - * @brief Sets display window. - * @param LayerIndex: layer index - * @param Xpos: LCD X position - * @param Ypos: LCD Y position - * @param Width: LCD window width - * @param Height: LCD window height - * @retval None - */ -static void SetDisplayWindow(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height) -{ - if(LcdDrv->SetDisplayWindow != NULL) - { - LcdDrv->SetDisplayWindow(Xpos, Ypos, Width, Height); - } -} - -/** - * @brief Fills a triangle (between 3 points). - * @param Points: Pointer to the points array - * @param x1: Point 1 X position - * @param y1: Point 1 Y position - * @param x2: Point 2 X position - * @param y2: Point 2 Y position - * @param x3: Point 3 X position - * @param y3: Point 3 Y position - * @retval None - */ -static void FillTriangle(uint16_t x1, uint16_t x2, uint16_t x3, uint16_t y1, uint16_t y2, uint16_t y3) -{ - int16_t deltax = 0, deltay = 0, x = 0, y = 0, xinc1 = 0, xinc2 = 0, - yinc1 = 0, yinc2 = 0, den = 0, num = 0, numadd = 0, numpixels = 0, - curpixel = 0; - - deltax = ABS(x2 - x1); /* The difference between the x's */ - deltay = ABS(y2 - y1); /* The difference between the y's */ - x = x1; /* Start x off at the first pixel */ - y = y1; /* Start y off at the first pixel */ - - if (x2 >= x1) /* The x-values are increasing */ - { - xinc1 = 1; - xinc2 = 1; - } - else /* The x-values are decreasing */ - { - xinc1 = -1; - xinc2 = -1; - } - - if (y2 >= y1) /* The y-values are increasing */ - { - yinc1 = 1; - yinc2 = 1; - } - else /* The y-values are decreasing */ - { - yinc1 = -1; - yinc2 = -1; - } - - if (deltax >= deltay) /* There is at least one x-value for every y-value */ - { - xinc1 = 0; /* Don't change the x when numerator >= denominator */ - yinc2 = 0; /* Don't change the y for every iteration */ - den = deltax; - num = deltax / 2; - numadd = deltay; - numpixels = deltax; /* There are more x-values than y-values */ - } - else /* There is at least one y-value for every x-value */ - { - xinc2 = 0; /* Don't change the x for every iteration */ - yinc1 = 0; /* Don't change the y when numerator >= denominator */ - den = deltay; - num = deltay / 2; - numadd = deltax; - numpixels = deltay; /* There are more y-values than x-values */ - } - - for (curpixel = 0; curpixel <= numpixels; curpixel++) - { - BSP_LCD_DrawLine(x, y, x3, y3); - - num += numadd; /* Increase the numerator by the top of the fraction */ - if (num >= den) /* Check if numerator >= denominator */ - { - num -= den; /* Calculate the new numerator value */ - x += xinc1; /* Change the x as appropriate */ - y += yinc1; /* Change the y as appropriate */ - } - x += xinc2; /* Change the x as appropriate */ - y += yinc2; /* Change the y as appropriate */ - } -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/stm32446e_eval_lcd.h b/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/stm32446e_eval_lcd.h deleted file mode 100644 index 55e525f4cb..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/stm32446e_eval_lcd.h +++ /dev/null @@ -1,202 +0,0 @@ -/** - ****************************************************************************** - * @file stm32446e_eval_lcd.h - * @author MCD Application Team - * @version V1.1.0 - * @date 14-August-2015 - * @brief This file contains the common defines and functions prototypes for - * the stm32446e_eval_lcd.c driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32446E_EVAL_LCD_H -#define __STM32446E_EVAL_LCD_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm32446e_eval.h" -#include "../Components/ili9325/ili9325.h" -#include "../../../Utilities/Fonts/fonts.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32446E_EVAL - * @{ - */ - -/** @defgroup STM32446E_EVAL_LCD STM32446E-EVAL LCD - * @{ - */ - -/** @defgroup STM32446E_EVAL_LCD_Exported_Types STM32446E EVAL LCD Exported Types - * @{ - */ -typedef struct -{ - uint32_t TextColor; - uint32_t BackColor; - sFONT *pFont; -}LCD_DrawPropTypeDef; -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_LCD_Exported_Constants STM32446E EVAL LCD Exported Constants - * @{ - */ -/** - * @brief LCD status structure definition - */ -#define LCD_OK ((uint8_t)0x00) -#define LCD_ERROR ((uint8_t)0x01) -#define LCD_TIMEOUT ((uint8_t)0x02) - -typedef struct -{ - int16_t X; - int16_t Y; -}Point, * pPoint; - -/** - * @brief Line mode structures definition - */ -typedef enum -{ - CENTER_MODE = 0x01, /* Center mode */ - RIGHT_MODE = 0x02, /* Right mode */ - LEFT_MODE = 0x03 /* Left mode */ -}Line_ModeTypdef; - -/** - * @brief LCD color - */ -#define LCD_COLOR_BLUE ((uint16_t)0x001F) -#define LCD_COLOR_GREEN ((uint16_t)0x07E0) -#define LCD_COLOR_RED ((uint16_t)0xF800) -#define LCD_COLOR_CYAN ((uint16_t)0x07FF) -#define LCD_COLOR_MAGENTA ((uint16_t)0xF81F) -#define LCD_COLOR_YELLOW ((uint16_t)0xFFE0) -#define LCD_COLOR_LIGHTBLUE ((uint16_t)0x841F) -#define LCD_COLOR_LIGHTGREEN ((uint16_t)0x87F0) -#define LCD_COLOR_LIGHTRED ((uint16_t)0xFC10) -#define LCD_COLOR_LIGHTMAGENTA ((uint16_t)0xFC1F) -#define LCD_COLOR_LIGHTYELLOW ((uint16_t)0xFFF0) -#define LCD_COLOR_DARKBLUE ((uint16_t)0x0010) -#define LCD_COLOR_DARKGREEN ((uint16_t)0x0400) -#define LCD_COLOR_DARKRED ((uint16_t)0x8000) -#define LCD_COLOR_DARKCYAN ((uint16_t)0x0410) -#define LCD_COLOR_DARKMAGENTA ((uint16_t)0x8010) -#define LCD_COLOR_DARKYELLOW ((uint16_t)0x8400) -#define LCD_COLOR_WHITE ((uint16_t)0xFFFF) -#define LCD_COLOR_LIGHTGRAY ((uint16_t)0xD69A) -#define LCD_COLOR_GRAY ((uint16_t)0x8410) -#define LCD_COLOR_DARKGRAY ((uint16_t)0x4208) -#define LCD_COLOR_BLACK ((uint16_t)0x0000) -#define LCD_COLOR_BROWN ((uint16_t)0xA145) -#define LCD_COLOR_ORANGE ((uint16_t)0xFD20) - -/** - * @brief LCD default font - */ -#define LCD_DEFAULT_FONT Font24 - -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_LCD_Exported_Functions STM32446E EVAL LCD Exported Functions - * @{ - */ -uint8_t BSP_LCD_Init(void); -uint8_t BSP_LCD_DeInit(void); -uint32_t BSP_LCD_GetXSize(void); -uint32_t BSP_LCD_GetYSize(void); - -uint16_t BSP_LCD_GetTextColor(void); -uint16_t BSP_LCD_GetBackColor(void); -void BSP_LCD_SetTextColor(__IO uint16_t Color); -void BSP_LCD_SetBackColor(__IO uint16_t Color); -void BSP_LCD_SetFont(sFONT *fonts); -sFONT *BSP_LCD_GetFont(void); - -void BSP_LCD_Clear(uint16_t Color); -void BSP_LCD_ClearStringLine(uint16_t Line); -void BSP_LCD_DisplayStringAtLine(uint16_t Line, uint8_t *ptr); -void BSP_LCD_DisplayStringAt(uint16_t Xpos, uint16_t Ypos, uint8_t *Text, Line_ModeTypdef Mode); -void BSP_LCD_DisplayChar(uint16_t Xpos, uint16_t Ypos, uint8_t Ascii); - -uint16_t BSP_LCD_ReadPixel(uint16_t Xpos, uint16_t Ypos); -void BSP_LCD_DrawPixel(uint16_t Xpos, uint16_t Ypos, uint16_t RGB_Code); -void BSP_LCD_DrawHLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length); -void BSP_LCD_DrawVLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length); -void BSP_LCD_DrawLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2); -void BSP_LCD_DrawRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height); -void BSP_LCD_DrawCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius); -void BSP_LCD_DrawPolygon(pPoint Points, uint16_t PointCount); -void BSP_LCD_DrawEllipse(int Xpos, int Ypos, int XRadius, int YRadius); -void BSP_LCD_DrawBitmap(uint16_t Xpos, uint16_t Ypos, uint8_t *pbmp); -void BSP_LCD_DrawRGBImage(uint16_t Xpos, uint16_t Ypos, uint16_t Xsize, uint16_t Ysize, uint8_t *pbmp); -void BSP_LCD_FillRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height); -void BSP_LCD_FillCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius); -void BSP_LCD_FillPolygon(pPoint Points, uint16_t PointCount); -void BSP_LCD_FillEllipse(int Xpos, int Ypos, int XRadius, int YRadius); - -void BSP_LCD_DisplayOff(void); -void BSP_LCD_DisplayOn(void); - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32446E_EVAL_LCD_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/stm32446e_eval_qspi.c b/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/stm32446e_eval_qspi.c deleted file mode 100644 index 99438dd0f7..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/stm32446e_eval_qspi.c +++ /dev/null @@ -1,831 +0,0 @@ -/** - ****************************************************************************** - * @file stm32446e_eval_qspi.c - * @author MCD Application Team - * @version V1.1.0 - * @date 14-August-2015 - * @brief This file includes a standard driver for the N25Q256A QSPI - * memory mounted on STM32446E-EVAL board. - @verbatim - ============================================================================== - ##### How to use this driver ##### - ============================================================================== - [..] - (#) This driver is used to drive the N25Q256A QSPI external - memory mounted on STM32446E-EVAL evaluation board. - - (#) This driver need a specific component driver (N25Q256A) to be included with. - - (#) Initialization steps: - (++) Initialize the QPSI external memory using the BSP_QSPI_Init() function. This - function includes the MSP layer hardware resources initialization and the - QSPI interface with the external memory. - - (#) QSPI memory operations - (++) QSPI memory can be accessed with read/write operations once it is - initialized. - Read/write operation can be performed with AHB access using the functions - BSP_QSPI_Read()/BSP_QSPI_Write(). - (++) The function BSP_QSPI_GetInfo() returns the configuration of the QSPI memory. - (see the QSPI memory data sheet) - (++) Perform erase block operation using the function BSP_QSPI_Erase_Block() and by - specifying the block address. You can perform an erase operation of the whole - chip by calling the function BSP_QSPI_Erase_Chip(). - (++) The function BSP_QSPI_GetStatus() returns the current status of the QSPI memory. - (see the QSPI memory data sheet) - @endverbatim - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Includes ------------------------------------------------------------------*/ -#include "stm32446e_eval_qspi.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32446E_EVAL - * @{ - */ - -/** @defgroup STM32446E_EVAL_QSPI STM32446E-EVAL QSPI - * @{ - */ - - -/* Private variables ---------------------------------------------------------*/ - -/** @defgroup STM32446E_EVAL_QSPI_Private_Variables Private Variables - * @{ - */ -QSPI_HandleTypeDef QSPIHandle; - -/** - * @} - */ - - - -/* Private functions ---------------------------------------------------------*/ - -/** @defgroup STM32446E_EVAL_QSPI_Private_Functions Private Functions - * @{ - */ -static uint8_t QSPI_ResetMemory (QSPI_HandleTypeDef *hqspi); -static uint8_t QSPI_EnterFourBytesAddress(QSPI_HandleTypeDef *hqspi); -static uint8_t QSPI_DummyCyclesCfg (QSPI_HandleTypeDef *hqspi); -static uint8_t QSPI_WriteEnable (QSPI_HandleTypeDef *hqspi); -static uint8_t QSPI_AutoPollingMemReady(QSPI_HandleTypeDef *hqspi, uint32_t Timeout); - -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_QSPI_Exported_Functions Exported Functions - * @{ - */ - -/** - * @brief Initializes the QSPI interface. - * @retval QSPI memory status - */ -uint8_t BSP_QSPI_Init(void) -{ - QSPIHandle.Instance = QUADSPI; - - /* Call the DeInit function to reset the driver */ - if (HAL_QSPI_DeInit(&QSPIHandle) != HAL_OK) - { - return QSPI_ERROR; - } - - /* System level initialization */ - BSP_QSPI_MspInit(&QSPIHandle, NULL); - - /* QSPI initialization */ - QSPIHandle.Init.ClockPrescaler = 1; /* QSPI freq = 180 MHz/(1+1) = 90 Mhz */ - QSPIHandle.Init.FifoThreshold = 4; - QSPIHandle.Init.SampleShifting = QSPI_SAMPLE_SHIFTING_HALFCYCLE; - QSPIHandle.Init.FlashSize = POSITION_VAL(N25Q256A_FLASH_SIZE) - 1; - QSPIHandle.Init.ChipSelectHighTime = QSPI_CS_HIGH_TIME_2_CYCLE; - QSPIHandle.Init.ClockMode = QSPI_CLOCK_MODE_0; - QSPIHandle.Init.FlashID = QSPI_FLASH_ID_1; - QSPIHandle.Init.DualFlash = QSPI_DUALFLASH_DISABLE; - - if (HAL_QSPI_Init(&QSPIHandle) != HAL_OK) - { - return QSPI_ERROR; - } - - /* QSPI memory reset */ - if (QSPI_ResetMemory(&QSPIHandle) != QSPI_OK) - { - return QSPI_NOT_SUPPORTED; - } - - /* Set the QSPI memory in 4-bytes address mode */ - if (QSPI_EnterFourBytesAddress(&QSPIHandle) != QSPI_OK) - { - return QSPI_NOT_SUPPORTED; - } - - /* Configuration of the dummy cycles on QSPI memory side */ - if (QSPI_DummyCyclesCfg(&QSPIHandle) != QSPI_OK) - { - return QSPI_NOT_SUPPORTED; - } - - return QSPI_OK; -} - -/** - * @brief De-Initializes the QSPI interface. - * @retval QSPI memory status - */ -uint8_t BSP_QSPI_DeInit(void) -{ - QSPIHandle.Instance = QUADSPI; - - /* Call the DeInit function to reset the driver */ - if (HAL_QSPI_DeInit(&QSPIHandle) != HAL_OK) - { - return QSPI_ERROR; - } - - /* System level De-initialization */ - BSP_QSPI_MspDeInit(&QSPIHandle, NULL); - - return QSPI_OK; -} - -/** - * @brief Reads an amount of data from the QSPI memory. - * @param pData: Pointer to data to be read - * @param ReadAddr: Read start address - * @param Size: Size of data to read - * @retval QSPI memory status - */ -uint8_t BSP_QSPI_Read(uint8_t* pData, uint32_t ReadAddr, uint32_t Size) -{ - QSPI_CommandTypeDef s_command; - - /* Initialize the read command */ - s_command.InstructionMode = QSPI_INSTRUCTION_1_LINE; - s_command.Instruction = QUAD_INOUT_FAST_READ_CMD; - s_command.AddressMode = QSPI_ADDRESS_4_LINES; - s_command.AddressSize = QSPI_ADDRESS_32_BITS; - s_command.Address = ReadAddr; - s_command.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE; - s_command.DataMode = QSPI_DATA_4_LINES; - s_command.DummyCycles = N25Q256A_DUMMY_CYCLES_READ_QUAD; - s_command.NbData = Size; - s_command.DdrMode = QSPI_DDR_MODE_DISABLE; - s_command.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY; - s_command.SIOOMode = QSPI_SIOO_INST_EVERY_CMD; - - /* Configure the command */ - if (HAL_QSPI_Command(&QSPIHandle, &s_command, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - /* Reception of the data */ - if (HAL_QSPI_Receive(&QSPIHandle, pData, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - return QSPI_OK; -} - -/** - * @brief Writes an amount of data to the QSPI memory. - * @param pData: Pointer to data to be written - * @param WriteAddr: Write start address - * @param Size: Size of data to write - * @retval QSPI memory status - */ -uint8_t BSP_QSPI_Write(uint8_t* pData, uint32_t WriteAddr, uint32_t Size) -{ - QSPI_CommandTypeDef s_command; - uint32_t end_addr, current_size, current_addr; - - /* Calculation of the size between the write address and the end of the page */ - current_addr = 0; - - while (current_addr <= WriteAddr) - { - current_addr += N25Q256A_PAGE_SIZE; - } - current_size = current_addr - WriteAddr; - - /* Check if the size of the data is less than the remaining place in the page */ - if (current_size > Size) - { - current_size = Size; - } - - /* Initialize the adress variables */ - current_addr = WriteAddr; - end_addr = WriteAddr + Size; - - /* Initialize the program command */ - s_command.InstructionMode = QSPI_INSTRUCTION_1_LINE; - s_command.Instruction = EXT_QUAD_IN_FAST_PROG_CMD; - s_command.AddressMode = QSPI_ADDRESS_4_LINES; - s_command.AddressSize = QSPI_ADDRESS_32_BITS; - s_command.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE; - s_command.DataMode = QSPI_DATA_4_LINES; - s_command.DummyCycles = 0; - s_command.DdrMode = QSPI_DDR_MODE_DISABLE; - s_command.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY; - s_command.SIOOMode = QSPI_SIOO_INST_EVERY_CMD; - - /* Perform the write page by page */ - do - { - s_command.Address = current_addr; - s_command.NbData = current_size; - - /* Enable write operations */ - if (QSPI_WriteEnable(&QSPIHandle) != QSPI_OK) - { - return QSPI_ERROR; - } - - /* Configure the command */ - if (HAL_QSPI_Command(&QSPIHandle, &s_command, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - /* Transmission of the data */ - if (HAL_QSPI_Transmit(&QSPIHandle, pData, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - /* Configure automatic polling mode to wait for end of program */ - if (QSPI_AutoPollingMemReady(&QSPIHandle, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != QSPI_OK) - { - return QSPI_ERROR; - } - - /* Update the address and size variables for next page programming */ - current_addr += current_size; - pData += current_size; - current_size = ((current_addr + N25Q256A_PAGE_SIZE) > end_addr) ? (end_addr - current_addr) : N25Q256A_PAGE_SIZE; - } while (current_addr < end_addr); - - return QSPI_OK; -} - -/** - * @brief Erases the specified block of the QSPI memory. - * @param BlockAddress: Block address to erase - * @retval QSPI memory status - */ -uint8_t BSP_QSPI_Erase_Block(uint32_t BlockAddress) -{ - QSPI_CommandTypeDef s_command; - - /* Initialize the erase command */ - s_command.InstructionMode = QSPI_INSTRUCTION_1_LINE; - s_command.Instruction = SUBSECTOR_ERASE_CMD; - s_command.AddressMode = QSPI_ADDRESS_1_LINE; - s_command.AddressSize = QSPI_ADDRESS_32_BITS; - s_command.Address = BlockAddress; - s_command.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE; - s_command.DataMode = QSPI_DATA_NONE; - s_command.DummyCycles = 0; - s_command.DdrMode = QSPI_DDR_MODE_DISABLE; - s_command.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY; - s_command.SIOOMode = QSPI_SIOO_INST_EVERY_CMD; - - /* Enable write operations */ - if (QSPI_WriteEnable(&QSPIHandle) != QSPI_OK) - { - return QSPI_ERROR; - } - - /* Send the command */ - if (HAL_QSPI_Command(&QSPIHandle, &s_command, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - /* Configure automatic polling mode to wait for end of erase */ - if (QSPI_AutoPollingMemReady(&QSPIHandle, N25Q256A_SUBSECTOR_ERASE_MAX_TIME) != QSPI_OK) - { - return QSPI_ERROR; - } - - return QSPI_OK; -} - -/** - * @brief Erases the entire QSPI memory. - * @retval QSPI memory status - */ -uint8_t BSP_QSPI_Erase_Chip(void) -{ - QSPI_CommandTypeDef s_command; - - /* Initialize the erase command */ - s_command.InstructionMode = QSPI_INSTRUCTION_1_LINE; - s_command.Instruction = BULK_ERASE_CMD; - s_command.AddressMode = QSPI_ADDRESS_NONE; - s_command.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE; - s_command.DataMode = QSPI_DATA_NONE; - s_command.DummyCycles = 0; - s_command.DdrMode = QSPI_DDR_MODE_DISABLE; - s_command.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY; - s_command.SIOOMode = QSPI_SIOO_INST_EVERY_CMD; - - /* Enable write operations */ - if (QSPI_WriteEnable(&QSPIHandle) != QSPI_OK) - { - return QSPI_ERROR; - } - - /* Send the command */ - if (HAL_QSPI_Command(&QSPIHandle, &s_command, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - /* Configure automatic polling mode to wait for end of erase */ - if (QSPI_AutoPollingMemReady(&QSPIHandle, N25Q256A_BULK_ERASE_MAX_TIME) != QSPI_OK) - { - return QSPI_ERROR; - } - - return QSPI_OK; -} - -/** - * @brief Reads current status of the QSPI memory. - * @retval QSPI memory status - */ -uint8_t BSP_QSPI_GetStatus(void) -{ - QSPI_CommandTypeDef s_command; - uint8_t reg; - - /* Initialize the read flag status register command */ - s_command.InstructionMode = QSPI_INSTRUCTION_1_LINE; - s_command.Instruction = READ_FLAG_STATUS_REG_CMD; - s_command.AddressMode = QSPI_ADDRESS_NONE; - s_command.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE; - s_command.DataMode = QSPI_DATA_1_LINE; - s_command.DummyCycles = 0; - s_command.NbData = 1; - s_command.DdrMode = QSPI_DDR_MODE_DISABLE; - s_command.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY; - s_command.SIOOMode = QSPI_SIOO_INST_EVERY_CMD; - - /* Configure the command */ - if (HAL_QSPI_Command(&QSPIHandle, &s_command, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - /* Reception of the data */ - if (HAL_QSPI_Receive(&QSPIHandle, ®, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - /* Check the value of the register */ - if ((reg & (N25Q256A_FSR_PRERR | N25Q256A_FSR_VPPERR | N25Q256A_FSR_PGERR | N25Q256A_FSR_ERERR)) != 0) - { - return QSPI_ERROR; - } - else if ((reg & (N25Q256A_FSR_PGSUS | N25Q256A_FSR_ERSUS)) != 0) - { - return QSPI_SUSPENDED; - } - else if ((reg & N25Q256A_FSR_READY) != 0) - { - return QSPI_OK; - } - else - { - return QSPI_BUSY; - } -} - -/** - * @brief Return the configuration of the QSPI memory. - * @param pInfo: pointer on the configuration structure - * @retval QSPI memory status - */ -uint8_t BSP_QSPI_GetInfo(QSPI_Info* pInfo) -{ - /* Configure the structure with the memory configuration */ - pInfo->FlashSize = N25Q256A_FLASH_SIZE; - pInfo->EraseSectorSize = N25Q256A_SUBSECTOR_SIZE; - pInfo->EraseSectorsNumber = (N25Q256A_FLASH_SIZE/N25Q256A_SUBSECTOR_SIZE); - pInfo->ProgPageSize = N25Q256A_PAGE_SIZE; - pInfo->ProgPagesNumber = (N25Q256A_FLASH_SIZE/N25Q256A_PAGE_SIZE); - - return QSPI_OK; -} - -/** - * @brief Configure the QSPI in memory-mapped mode - * @param None - * @retval QSPI memory status - */ -uint8_t BSP_QSPI_MemoryMappedMode(void) -{ - QSPI_CommandTypeDef s_command; - QSPI_MemoryMappedTypeDef s_mem_mapped_cfg; - - /* Configure the command for the read instruction */ - s_command.InstructionMode = QSPI_INSTRUCTION_1_LINE; - s_command.Instruction = QUAD_INOUT_FAST_READ_CMD; - s_command.AddressMode = QSPI_ADDRESS_4_LINES; - s_command.AddressSize = QSPI_ADDRESS_32_BITS; - s_command.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE; - s_command.DataMode = QSPI_DATA_4_LINES; - s_command.DummyCycles = N25Q256A_DUMMY_CYCLES_READ_QUAD; - s_command.DdrMode = QSPI_DDR_MODE_DISABLE; - s_command.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY; - s_command.SIOOMode = QSPI_SIOO_INST_EVERY_CMD; - - /* Configure the memory mapped mode */ - s_mem_mapped_cfg.TimeOutActivation = QSPI_TIMEOUT_COUNTER_ENABLE; - s_mem_mapped_cfg.TimeOutPeriod = 1; - - if (HAL_QSPI_MemoryMapped(&QSPIHandle, &s_command, &s_mem_mapped_cfg) != HAL_OK) - { - return QSPI_ERROR; - } - - return QSPI_OK; -} - -/** - * @} - */ - -/** @addtogroup STM32446E_EVAL_QSPI_Private_Functions - * @{ - */ - -/** - * @brief QSPI MSP Initialization - * This function configures the hardware resources used in this example: - * - Peripheral's clock enable - * - Peripheral's GPIO Configuration - * - NVIC configuration for QSPI interrupt - * @retval None - */ -__weak void BSP_QSPI_MspInit(QSPI_HandleTypeDef *hqspi, void *Params) -{ - GPIO_InitTypeDef gpio_init_structure; - - /*##-1- Enable peripherals and GPIO Clocks #################################*/ - /* Enable the QuadSPI memory interface clock */ - QSPI_CLK_ENABLE(); - /* Reset the QuadSPI memory interface */ - QSPI_FORCE_RESET(); - QSPI_RELEASE_RESET(); - /* Enable GPIO clocks */ - QSPI_CS_GPIO_CLK_ENABLE(); - QSPI_CLK_GPIO_CLK_ENABLE(); - QSPI_Dx_GPIO_CLK_ENABLE(); - - /*##-2- Configure peripheral GPIO ##########################################*/ - /* QSPI CS GPIO pin configuration */ - gpio_init_structure.Pin = QSPI_CS_PIN; - gpio_init_structure.Mode = GPIO_MODE_AF_PP; - gpio_init_structure.Pull = GPIO_PULLUP; - gpio_init_structure.Speed = GPIO_SPEED_HIGH; - gpio_init_structure.Alternate = GPIO_AF10_QSPI; - HAL_GPIO_Init(QSPI_CS_GPIO_PORT, &gpio_init_structure); - - /* QSPI CLK GPIO pin configuration */ - gpio_init_structure.Pin = QSPI_CLK_PIN; - gpio_init_structure.Pull = GPIO_NOPULL; - gpio_init_structure.Alternate = GPIO_AF9_QSPI; - HAL_GPIO_Init(QSPI_CLK_GPIO_PORT, &gpio_init_structure); - - /* QSPI D0 GPIO pin configuration */ - gpio_init_structure.Pin = QSPI_D0_PIN; - gpio_init_structure.Alternate = GPIO_AF10_QSPI; - HAL_GPIO_Init(QSPI_D0_GPIO_PORT, &gpio_init_structure); - - /* QSPI D1 GPIO pin configuration */ - gpio_init_structure.Pin = QSPI_D1_PIN; - gpio_init_structure.Alternate = GPIO_AF10_QSPI; - HAL_GPIO_Init(QSPI_D1_GPIO_PORT, &gpio_init_structure); - - /* QSPI D2 GPIO pin configuration */ - gpio_init_structure.Pin = QSPI_D2_PIN; - gpio_init_structure.Alternate = GPIO_AF9_QSPI; - HAL_GPIO_Init(QSPI_D2_GPIO_PORT, &gpio_init_structure); - - /* QSPI D3 GPIO pin configuration */ - gpio_init_structure.Pin = QSPI_D3_PIN; - gpio_init_structure.Alternate = GPIO_AF9_QSPI; - HAL_GPIO_Init(QSPI_D3_GPIO_PORT, &gpio_init_structure); -} - - -/** - * @brief QSPI MSP De-Initialization - * This function frees the hardware resources used in this example: - * - Disable the Peripheral's clock - * - Revert GPIO and NVIC configuration to their default state - * @retval None - */ -__weak void BSP_QSPI_MspDeInit(QSPI_HandleTypeDef *hqspi, void *Params) -{ - /*##-1- Disable the NVIC for QSPI ###########################################*/ - HAL_NVIC_DisableIRQ(QUADSPI_IRQn); - - /*##-2- Disable peripherals and GPIO Clocks ################################*/ - /* De-Configure QSPI specific pins (not common to any other blocks) */ - HAL_GPIO_DeInit(QSPI_D0_GPIO_PORT, QSPI_D0_PIN); - HAL_GPIO_DeInit(QSPI_D1_GPIO_PORT, QSPI_D1_PIN); - HAL_GPIO_DeInit(QSPI_D2_GPIO_PORT, QSPI_D2_PIN); - HAL_GPIO_DeInit(QSPI_D3_GPIO_PORT, QSPI_D3_PIN); - - /*##-3- Reset peripherals ##################################################*/ - /* Reset the QuadSPI memory interface */ - QSPI_FORCE_RESET(); - QSPI_RELEASE_RESET(); - - /* Disable the QuadSPI memory interface clock */ - QSPI_CLK_DISABLE(); -} - -/** - * @brief This function reset the QSPI memory. - * @param hqspi: QSPI handle - * @retval None - */ -static uint8_t QSPI_ResetMemory(QSPI_HandleTypeDef *hqspi) -{ - QSPI_CommandTypeDef s_command; - - /* Initialize the reset enable command */ - s_command.InstructionMode = QSPI_INSTRUCTION_1_LINE; - s_command.Instruction = RESET_ENABLE_CMD; - s_command.AddressMode = QSPI_ADDRESS_NONE; - s_command.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE; - s_command.DataMode = QSPI_DATA_NONE; - s_command.DummyCycles = 0; - s_command.DdrMode = QSPI_DDR_MODE_DISABLE; - s_command.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY; - s_command.SIOOMode = QSPI_SIOO_INST_EVERY_CMD; - - /* Send the command */ - if (HAL_QSPI_Command(&QSPIHandle, &s_command, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - /* Send the reset memory command */ - s_command.Instruction = RESET_MEMORY_CMD; - if (HAL_QSPI_Command(&QSPIHandle, &s_command, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - /* Configure automatic polling mode to wait the memory is ready */ - if (QSPI_AutoPollingMemReady(&QSPIHandle, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != QSPI_OK) - { - return QSPI_ERROR; - } - - return QSPI_OK; -} - -/** - * @brief This function set the QSPI memory in 4-byte address mode - * @param hqspi: QSPI handle - * @retval None - */ -static uint8_t QSPI_EnterFourBytesAddress(QSPI_HandleTypeDef *hqspi) -{ - QSPI_CommandTypeDef s_command; - - /* Initialize the command */ - s_command.InstructionMode = QSPI_INSTRUCTION_1_LINE; - s_command.Instruction = ENTER_4_BYTE_ADDR_MODE_CMD; - s_command.AddressMode = QSPI_ADDRESS_NONE; - s_command.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE; - s_command.DataMode = QSPI_DATA_NONE; - s_command.DummyCycles = 0; - s_command.DdrMode = QSPI_DDR_MODE_DISABLE; - s_command.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY; - s_command.SIOOMode = QSPI_SIOO_INST_EVERY_CMD; - - /* Enable write operations */ - if (QSPI_WriteEnable(&QSPIHandle) != QSPI_OK) - { - return QSPI_ERROR; - } - - /* Send the command */ - if (HAL_QSPI_Command(&QSPIHandle, &s_command, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - /* Configure automatic polling mode to wait the memory is ready */ - if (QSPI_AutoPollingMemReady(&QSPIHandle, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != QSPI_OK) - { - return QSPI_ERROR; - } - - return QSPI_OK; -} - -/** - * @brief This function configure the dummy cycles on memory side. - * @param hqspi: QSPI handle - * @retval None - */ -static uint8_t QSPI_DummyCyclesCfg(QSPI_HandleTypeDef *hqspi) -{ - QSPI_CommandTypeDef s_command; - uint8_t reg; - - /* Initialize the read volatile configuration register command */ - s_command.InstructionMode = QSPI_INSTRUCTION_1_LINE; - s_command.Instruction = READ_VOL_CFG_REG_CMD; - s_command.AddressMode = QSPI_ADDRESS_NONE; - s_command.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE; - s_command.DataMode = QSPI_DATA_1_LINE; - s_command.DummyCycles = 0; - s_command.NbData = 1; - s_command.DdrMode = QSPI_DDR_MODE_DISABLE; - s_command.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY; - s_command.SIOOMode = QSPI_SIOO_INST_EVERY_CMD; - - /* Configure the command */ - if (HAL_QSPI_Command(&QSPIHandle, &s_command, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - /* Reception of the data */ - if (HAL_QSPI_Receive(&QSPIHandle, ®, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - /* Enable write operations */ - if (QSPI_WriteEnable(&QSPIHandle) != QSPI_OK) - { - return QSPI_ERROR; - } - - /* Update volatile configuration register (with new dummy cycles) */ - s_command.Instruction = WRITE_VOL_CFG_REG_CMD; - MODIFY_REG(reg, N25Q256A_VCR_NB_DUMMY, (N25Q256A_DUMMY_CYCLES_READ_QUAD << POSITION_VAL(N25Q256A_VCR_NB_DUMMY))); - - /* Configure the write volatile configuration register command */ - if (HAL_QSPI_Command(&QSPIHandle, &s_command, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - /* Transmission of the data */ - if (HAL_QSPI_Transmit(&QSPIHandle, ®, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - return QSPI_OK; -} - -/** - * @brief This function send a Write Enable and wait it is effective. - * @param hqspi: QSPI handle - * @retval None - */ -static uint8_t QSPI_WriteEnable(QSPI_HandleTypeDef *hqspi) -{ - QSPI_CommandTypeDef s_command; - QSPI_AutoPollingTypeDef s_config; - - /* Enable write operations */ - s_command.InstructionMode = QSPI_INSTRUCTION_1_LINE; - s_command.Instruction = WRITE_ENABLE_CMD; - s_command.AddressMode = QSPI_ADDRESS_NONE; - s_command.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE; - s_command.DataMode = QSPI_DATA_NONE; - s_command.DummyCycles = 0; - s_command.DdrMode = QSPI_DDR_MODE_DISABLE; - s_command.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY; - s_command.SIOOMode = QSPI_SIOO_INST_EVERY_CMD; - - if (HAL_QSPI_Command(&QSPIHandle, &s_command, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - /* Configure automatic polling mode to wait for write enabling */ - s_config.Match = N25Q256A_SR_WREN; - s_config.Mask = N25Q256A_SR_WREN; - s_config.MatchMode = QSPI_MATCH_MODE_AND; - s_config.StatusBytesSize = 1; - s_config.Interval = 0x10; - s_config.AutomaticStop = QSPI_AUTOMATIC_STOP_ENABLE; - - s_command.Instruction = READ_STATUS_REG_CMD; - s_command.DataMode = QSPI_DATA_1_LINE; - - if (HAL_QSPI_AutoPolling(&QSPIHandle, &s_command, &s_config, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - return QSPI_OK; -} - -/** - * @brief This function read the SR of the memory and wait the EOP. - * @param hqspi: QSPI handle - * @retval None - */ -static uint8_t QSPI_AutoPollingMemReady(QSPI_HandleTypeDef *hqspi, uint32_t Timeout) -{ - QSPI_CommandTypeDef s_command; - QSPI_AutoPollingTypeDef s_config; - - /* Configure automatic polling mode to wait for memory ready */ - s_command.InstructionMode = QSPI_INSTRUCTION_1_LINE; - s_command.Instruction = READ_STATUS_REG_CMD; - s_command.AddressMode = QSPI_ADDRESS_NONE; - s_command.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE; - s_command.DataMode = QSPI_DATA_1_LINE; - s_command.DummyCycles = 0; - s_command.DdrMode = QSPI_DDR_MODE_DISABLE; - s_command.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY; - s_command.SIOOMode = QSPI_SIOO_INST_EVERY_CMD; - - s_config.Match = 0; - s_config.Mask = N25Q256A_SR_WIP; - s_config.MatchMode = QSPI_MATCH_MODE_AND; - s_config.StatusBytesSize = 1; - s_config.Interval = 0x10; - s_config.AutomaticStop = QSPI_AUTOMATIC_STOP_ENABLE; - - if (HAL_QSPI_AutoPolling(&QSPIHandle, &s_command, &s_config, Timeout) != HAL_OK) - { - return QSPI_ERROR; - } - - return QSPI_OK; -} -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ - diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/stm32446e_eval_qspi.h b/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/stm32446e_eval_qspi.h deleted file mode 100644 index b55f349fec..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/stm32446e_eval_qspi.h +++ /dev/null @@ -1,176 +0,0 @@ -/** - ****************************************************************************** - * @file stm32446e_eval_qspi.h - * @author MCD Application Team - * @version V1.1.0 - * @date 14-August-2015 - * @brief This file contains the common defines and functions prototypes for - * the stm32446e_eval_qspi.c driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32446E_EVAL - * @{ - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32446E_EVAL_QSPI_H -#define __STM32446E_EVAL_QSPI_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm32f4xx_hal.h" -#include "../Components/n25q256a/n25q256a.h" - -/** @defgroup STM32446E_EVAL_QSPI STM32446E-EVAL QSPI - * @{ - */ - - -/* Exported constants --------------------------------------------------------*/ -/** @defgroup STM32446E_EVAL_QSPI_Exported_Constants Exported Constants - * @{ - */ -/* QSPI Error codes */ -#define QSPI_OK ((uint8_t)0x00) -#define QSPI_ERROR ((uint8_t)0x01) -#define QSPI_BUSY ((uint8_t)0x02) -#define QSPI_NOT_SUPPORTED ((uint8_t)0x04) -#define QSPI_SUSPENDED ((uint8_t)0x08) - - -/* Definition for QSPI clock resources */ -#define QSPI_CLK_ENABLE() __HAL_RCC_QSPI_CLK_ENABLE() -#define QSPI_CLK_DISABLE() __HAL_RCC_QSPI_CLK_DISABLE() -#define QSPI_CS_GPIO_CLK_ENABLE() __HAL_RCC_GPIOG_CLK_ENABLE() -#define QSPI_CS_GPIO_CLK_DISABLE() __HAL_RCC_GPIOG_CLK_DISABLE() -#if !defined(USE_STM32446E_EVAL_REVA) -#define QSPI_CLK_GPIO_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE() -#define QSPI_CLK_GPIO_CLK_DISABLE() __HAL_RCC_GPIOD_CLK_DISABLE() -#else -#define QSPI_CLK_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE() -#define QSPI_CLK_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE() -#endif // !USE_STM32446E_EVAL_REVA -#define QSPI_Dx_GPIO_CLK_ENABLE() __HAL_RCC_GPIOF_CLK_ENABLE() -#define QSPI_Dx_GPIO_CLK_DISABLE() __HAL_RCC_GPIOF_CLK_DISABLE() - -#define QSPI_FORCE_RESET() __HAL_RCC_QSPI_FORCE_RESET() -#define QSPI_RELEASE_RESET() __HAL_RCC_QSPI_RELEASE_RESET() - -/* Definition for QSPI Pins */ -#define QSPI_CS_PIN GPIO_PIN_6 -#define QSPI_CS_GPIO_PORT GPIOG -#if !defined(USE_STM32446E_EVAL_REVA) -#define QSPI_CLK_PIN GPIO_PIN_3 -#define QSPI_CLK_GPIO_PORT GPIOD -#else -#define QSPI_CLK_PIN GPIO_PIN_2 -#define QSPI_CLK_GPIO_PORT GPIOB -#endif // !USE_STM32446E_EVAL_REVA -#define QSPI_D0_PIN GPIO_PIN_8 -#define QSPI_D0_GPIO_PORT GPIOF -#define QSPI_D1_PIN GPIO_PIN_9 -#define QSPI_D1_GPIO_PORT GPIOF -#define QSPI_D2_PIN GPIO_PIN_7 -#define QSPI_D2_GPIO_PORT GPIOF -#define QSPI_D3_PIN GPIO_PIN_6 -#define QSPI_D3_GPIO_PORT GPIOF - - -/** - * @} - */ - -/* Exported types ------------------------------------------------------------*/ -/** @defgroup STM32446E_EVAL_QSPI_Exported_Types Exported Types - * @{ - */ -/* QSPI Info */ -typedef struct { - uint32_t FlashSize; /*!< Size of the flash */ - uint32_t EraseSectorSize; /*!< Size of sectors for the erase operation */ - uint32_t EraseSectorsNumber; /*!< Number of sectors for the erase operation */ - uint32_t ProgPageSize; /*!< Size of pages for the program operation */ - uint32_t ProgPagesNumber; /*!< Number of pages for the program operation */ -} QSPI_Info; - -/** - * @} - */ - - -/* Exported functions --------------------------------------------------------*/ -/** @defgroup STM32446E_EVAL_QSPI_Exported_Functions Exported Functions - * @{ - */ -uint8_t BSP_QSPI_Init (void); -uint8_t BSP_QSPI_DeInit (void); -uint8_t BSP_QSPI_Read (uint8_t* pData, uint32_t ReadAddr, uint32_t Size); -uint8_t BSP_QSPI_Write (uint8_t* pData, uint32_t WriteAddr, uint32_t Size); -uint8_t BSP_QSPI_Erase_Block(uint32_t BlockAddress); -uint8_t BSP_QSPI_Erase_Chip (void); -uint8_t BSP_QSPI_GetStatus (void); -uint8_t BSP_QSPI_GetInfo (QSPI_Info* pInfo); -uint8_t BSP_QSPI_MemoryMappedMode(void); - -/* These function can be modified in case the current settings (e.g. DMA stream) - need to be changed for specific application needs */ -void BSP_QSPI_MspInit(QSPI_HandleTypeDef *hqspi, void *Params); -void BSP_QSPI_MspDeInit(QSPI_HandleTypeDef *hqspi, void *Params); - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32446E_EVAL_QSPI_H */ -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/stm32446e_eval_sd.c b/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/stm32446e_eval_sd.c deleted file mode 100644 index 3d3fb543a9..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/stm32446e_eval_sd.c +++ /dev/null @@ -1,612 +0,0 @@ -/** - ****************************************************************************** - * @file stm32446e_eval_sd.c - * @author MCD Application Team - * @version V1.1.0 - * @date 14-August-2015 - * @brief This file includes the uSD card driver mounted on STM32446E-EVAL - * evaluation board. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* File Info : ----------------------------------------------------------------- - User NOTES -1. How To use this driver: --------------------------- - - This driver is used to drive the micro SD external card mounted on STM32446E-EVAL - evaluation board. - - This driver does not need a specific component driver for the micro SD device - to be included with. - -2. Driver description: ---------------------- - + Initialization steps: - o Initialize the micro SD card using the BSP_SD_Init() function. This - function includes the MSP layer hardware resources initialization and the - SDIO interface configuration to interface with the external micro SD. It - also includes the micro SD initialization sequence. - o To check the SD card presence you can use the function BSP_SD_IsDetected() which - returns the detection status - o If SD presence detection interrupt mode is desired, you must configure the - SD detection interrupt mode by calling the function BSP_SD_ITConfig(). The interrupt - is generated as an external interrupt whenever the micro SD card is - plugged/unplugged in/from the evaluation board. The SD detection interrupt - is handled by calling the function BSP_SD_DetectIT() which is called in the IRQ - handler file, the user callback is implemented in the function BSP_SD_DetectCallback(). - o The function BSP_SD_GetCardInfo() is used to get the micro SD card information - which is stored in the structure "HAL_SD_CardInfoTypedef". - - + Micro SD card operations - o The micro SD card can be accessed with read/write block(s) operations once - it is ready for access. The access can be performed whether using the polling - mode by calling the functions BSP_SD_ReadBlocks()/BSP_SD_WriteBlocks(), or by DMA - transfer using the functions BSP_SD_ReadBlocks_DMA()/BSP_SD_WriteBlocks_DMA() - o The DMA transfer complete is used with interrupt mode. Once the SD transfer - is complete, the SD interrupt is handled using the function BSP_SD_IRQHandler(), - the DMA Tx/Rx transfer complete are handled using the functions - BSP_SD_DMA_Tx_IRQHandler()/BSP_SD_DMA_Rx_IRQHandler(). The corresponding user callbacks - are implemented by the user at application level. - o The SD erase block(s) is performed using the function BSP_SD_Erase() with specifying - the number of blocks to erase. - o The SD runtime status is returned when calling the function BSP_SD_GetStatus(). - -------------------------------------------------------------------------------*/ - -/* Includes ------------------------------------------------------------------*/ -#include "stm32446e_eval_sd.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32446E_EVAL - * @{ - */ - -/** @defgroup STM32446E_EVAL_SD STM32446E-EVAL SD - * @{ - */ - - -/** @defgroup STM32446E_EVAL_SD_Private_TypesDefinitions STM32446E Eval Sd Private TypesDef - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_SD_Private_Defines STM32446E Eval Sd Private Defines - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_SD_Private_Macros STM32446E Eval Sd Private Macro - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_SD_Private_Variables STM32446E Eval Sd Private Variables - * @{ - */ -static SD_HandleTypeDef uSdHandle; -static SD_CardInfo uSdCardInfo; -static uint8_t UseExtiModeDetection = 0; - -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_SD_Private_FunctionPrototypes STM32446E Eval Sd Private Prototypes - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_SD_Private_Functions STM32446E Eval Sd Private Functions - * @{ - */ - -/** - * @brief Initializes the SD card device. - * @param None - * @retval SD status - */ -uint8_t BSP_SD_Init(void) -{ - uint8_t sd_state = MSD_OK; - - /* uSD device interface configuration */ - uSdHandle.Instance = SDIO; - - uSdHandle.Init.ClockEdge = SDIO_CLOCK_EDGE_RISING; - uSdHandle.Init.ClockBypass = SDIO_CLOCK_BYPASS_DISABLE; - uSdHandle.Init.ClockPowerSave = SDIO_CLOCK_POWER_SAVE_DISABLE; - uSdHandle.Init.BusWide = SDIO_BUS_WIDE_1B; - uSdHandle.Init.HardwareFlowControl = SDIO_HARDWARE_FLOW_CONTROL_ENABLE; - uSdHandle.Init.ClockDiv = SDIO_TRANSFER_CLK_DIV; - - /* Initialize IO functionalities (MFX) used by SD detect pin */ - BSP_IO_Init(); - - /* Check if the SD card is plugged in the slot */ - BSP_IO_ConfigPin(SD_DETECT_PIN, IO_MODE_INPUT); - if(BSP_SD_IsDetected() != SD_PRESENT) - { - return MSD_ERROR_SD_NOT_PRESENT; - } - - /* Msp SD initialization */ - BSP_SD_MspInit(&uSdHandle, NULL); - - /* HAL SD initialization */ - if(HAL_SD_Init(&uSdHandle, &uSdCardInfo) != SD_OK) - { - sd_state = MSD_ERROR; - } - - /* Configure SD Bus width */ - if(sd_state == MSD_OK) - { - /* Enable wide operation */ - if(HAL_SD_WideBusOperation_Config(&uSdHandle, SDIO_BUS_WIDE_4B) != SD_OK) - { - sd_state = MSD_ERROR; - } - else - { - sd_state = MSD_OK; - } - } - - return sd_state; -} - -/** - * @brief DeInitializes the SD card device. - * @param None - * @retval SD status - */ -uint8_t BSP_SD_DeInit(void) -{ - uint8_t sd_state = MSD_OK; - - uSdHandle.Instance = SDIO; - - /* Set back Mfx pin to INPUT mode in case it was in exti */ - UseExtiModeDetection = 0; - BSP_IO_ConfigPin(SD_DETECT_PIN, IO_MODE_INPUT); - - /* HAL SD deinitialization */ - if(HAL_SD_DeInit(&uSdHandle) != HAL_OK) - { - sd_state = MSD_ERROR; - } - - /* Msp SD deinitialization */ - uSdHandle.Instance = SDIO; - BSP_SD_MspDeInit(&uSdHandle, NULL); - - return sd_state; -} - -/** - * @brief Configures Interrupt mode for SD detection pin. - * @param None - * @retval Returns 0 - */ -uint8_t BSP_SD_ITConfig(void) -{ - /* Configure Interrupt mode for SD detection pin */ - /* Note: disabling exti mode can be done calling SD_DeInit() */ - UseExtiModeDetection = 1; - BSP_SD_IsDetected(); - - return 0; -} - -/** - * @brief Detects if SD card is correctly plugged in the memory slot or not. - * @param None - * @retval Returns if SD is detected or not - */ -uint8_t BSP_SD_IsDetected(void) -{ - __IO uint8_t status = SD_PRESENT; - - /* Check SD card detect pin */ - if((BSP_IO_ReadPin(SD_DETECT_PIN)&SD_DETECT_PIN) != SD_DETECT_PIN) - { - if (UseExtiModeDetection) - { - BSP_IO_ConfigPin(SD_DETECT_PIN, IO_MODE_IT_RISING_EDGE); - } - - } - else - { - status = SD_NOT_PRESENT; - if (UseExtiModeDetection) - { - BSP_IO_ConfigPin(SD_DETECT_PIN, IO_MODE_IT_FALLING_EDGE); - } - } - - return status; -} - - - -/** - * @brief Reads block(s) from a specified address in an SD card, in polling mode. - * @param pData: Pointer to the buffer that will contain the data to transmit - * @param ReadAddr: Address from where data is to be read - * @param BlockSize: SD card data block size, that should be 512 - * @param NumOfBlocks: Number of SD blocks to read - * @retval SD status - */ -uint8_t BSP_SD_ReadBlocks(uint32_t *pData, uint64_t ReadAddr, uint32_t BlockSize, uint32_t NumOfBlocks) -{ - if(HAL_SD_ReadBlocks(&uSdHandle, pData, ReadAddr, BlockSize, NumOfBlocks) != SD_OK) - { - return MSD_ERROR; - } - else - { - return MSD_OK; - } -} - -/** - * @brief Writes block(s) to a specified address in an SD card, in polling mode. - * @param pData: Pointer to the buffer that will contain the data to transmit - * @param WriteAddr: Address from where data is to be written - * @param BlockSize: SD card data block size, that should be 512 - * @param NumOfBlocks: Number of SD blocks to write - * @retval SD status - */ -uint8_t BSP_SD_WriteBlocks(uint32_t *pData, uint64_t WriteAddr, uint32_t BlockSize, uint32_t NumOfBlocks) -{ - if(HAL_SD_WriteBlocks(&uSdHandle, pData, WriteAddr, BlockSize, NumOfBlocks) != SD_OK) - { - return MSD_ERROR; - } - else - { - return MSD_OK; - } -} - -/** - * @brief Reads block(s) from a specified address in an SD card, in DMA mode. - * @param pData: Pointer to the buffer that will contain the data to transmit - * @param ReadAddr: Address from where data is to be read - * @param BlockSize: SD card data block size, that should be 512 - * @param NumOfBlocks: Number of SD blocks to read - * @retval SD status - */ -uint8_t BSP_SD_ReadBlocks_DMA(uint32_t *pData, uint64_t ReadAddr, uint32_t BlockSize, uint32_t NumOfBlocks) -{ - uint8_t sd_state = MSD_OK; - - /* Read block(s) in DMA transfer mode */ - if(HAL_SD_ReadBlocks_DMA(&uSdHandle, pData, ReadAddr, BlockSize, NumOfBlocks) != SD_OK) - { - sd_state = MSD_ERROR; - } - - /* Wait until transfer is complete */ - if(sd_state == MSD_OK) - { - if(HAL_SD_CheckReadOperation(&uSdHandle, (uint32_t)SD_DATATIMEOUT) != SD_OK) - { - sd_state = MSD_ERROR; - } - else - { - sd_state = MSD_OK; - } - } - - return sd_state; -} - -/** - * @brief Writes block(s) to a specified address in an SD card, in DMA mode. - * @param pData: Pointer to the buffer that will contain the data to transmit - * @param WriteAddr: Address from where data is to be written - * @param BlockSize: SD card data block size, that should be 512 - * @param NumOfBlocks: Number of SD blocks to write - * @retval SD status - */ -uint8_t BSP_SD_WriteBlocks_DMA(uint32_t *pData, uint64_t WriteAddr, uint32_t BlockSize, uint32_t NumOfBlocks) -{ - uint8_t sd_state = MSD_OK; - - /* Write block(s) in DMA transfer mode */ - if(HAL_SD_WriteBlocks_DMA(&uSdHandle, pData, WriteAddr, BlockSize, NumOfBlocks) != SD_OK) - { - sd_state = MSD_ERROR; - } - - /* Wait until transfer is complete */ - if(sd_state == MSD_OK) - { - if(HAL_SD_CheckWriteOperation(&uSdHandle, (uint32_t)SD_DATATIMEOUT) != SD_OK) - { - sd_state = MSD_ERROR; - } - else - { - sd_state = MSD_OK; - } - } - - return sd_state; -} - -/** - * @brief Erases the specified memory area of the given SD card. - * @param StartAddr: Start byte address - * @param EndAddr: End byte address - * @retval SD status - */ -uint8_t BSP_SD_Erase(uint64_t StartAddr, uint64_t EndAddr) -{ - if(HAL_SD_Erase(&uSdHandle, StartAddr, EndAddr) != SD_OK) - { - return MSD_ERROR; - } - else - { - return MSD_OK; - } -} - -/** - * @brief Initializes the SD MSP. - * @param hsd: SD handle - * @retval None - */ -__weak void BSP_SD_MspInit(SD_HandleTypeDef *hsd, void *Params) -{ - static DMA_HandleTypeDef dma_rx_handle; - static DMA_HandleTypeDef dma_tx_handle; - GPIO_InitTypeDef gpio_init_structure; - - /* SD pins are in conflict with Camera pins therefore Camera is power down */ - /* __weak function can be modified by the application */ - BSP_IO_ConfigPin(RSTI_PIN, IO_MODE_OUTPUT); - BSP_IO_ConfigPin(XSDN_PIN, IO_MODE_OUTPUT); - /* De-assert the camera STANDBY pin (active high) */ - BSP_IO_WritePin(XSDN_PIN, BSP_IO_PIN_RESET); - /* Assert the camera RSTI pin (active low) */ - BSP_IO_WritePin(RSTI_PIN, BSP_IO_PIN_RESET); - HAL_Delay(100); - - /* Enable SDIO clock */ - __HAL_RCC_SDIO_CLK_ENABLE(); - - /* Enable DMA2 clocks */ - __DMAx_TxRx_CLK_ENABLE(); - - /* Enable GPIOs clock */ - __HAL_RCC_GPIOC_CLK_ENABLE(); - __HAL_RCC_GPIOD_CLK_ENABLE(); - - /* Common GPIO configuration */ - gpio_init_structure.Mode = GPIO_MODE_AF_PP; - gpio_init_structure.Pull = GPIO_PULLUP; - gpio_init_structure.Speed = GPIO_SPEED_HIGH; - gpio_init_structure.Alternate = GPIO_AF12_SDIO; - - /* GPIOC configuration */ - gpio_init_structure.Pin = GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12; - - HAL_GPIO_Init(GPIOC, &gpio_init_structure); - - /* GPIOD configuration */ - gpio_init_structure.Pin = GPIO_PIN_2; - HAL_GPIO_Init(GPIOD, &gpio_init_structure); - - /* NVIC configuration for SDIO interrupts */ - HAL_NVIC_SetPriority(SDIO_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(SDIO_IRQn); - - /* Configure DMA Rx parameters */ - dma_rx_handle.Init.Channel = SD_DMAx_Rx_CHANNEL; - dma_rx_handle.Init.Direction = DMA_PERIPH_TO_MEMORY; - dma_rx_handle.Init.PeriphInc = DMA_PINC_DISABLE; - dma_rx_handle.Init.MemInc = DMA_MINC_ENABLE; - dma_rx_handle.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; - dma_rx_handle.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; - dma_rx_handle.Init.Mode = DMA_PFCTRL; - dma_rx_handle.Init.Priority = DMA_PRIORITY_VERY_HIGH; - dma_rx_handle.Init.FIFOMode = DMA_FIFOMODE_ENABLE; - dma_rx_handle.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; - dma_rx_handle.Init.MemBurst = DMA_MBURST_INC4; - dma_rx_handle.Init.PeriphBurst = DMA_PBURST_INC4; - - dma_rx_handle.Instance = SD_DMAx_Rx_STREAM; - - /* Associate the DMA handle */ - __HAL_LINKDMA(hsd, hdmarx, dma_rx_handle); - - /* Deinitialize the stream for new transfer */ - HAL_DMA_DeInit(&dma_rx_handle); - - /* Configure the DMA stream */ - HAL_DMA_Init(&dma_rx_handle); - - /* Configure DMA Tx parameters */ - dma_tx_handle.Init.Channel = SD_DMAx_Tx_CHANNEL; - dma_tx_handle.Init.Direction = DMA_MEMORY_TO_PERIPH; - dma_tx_handle.Init.PeriphInc = DMA_PINC_DISABLE; - dma_tx_handle.Init.MemInc = DMA_MINC_ENABLE; - dma_tx_handle.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; - dma_tx_handle.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; - dma_tx_handle.Init.Mode = DMA_PFCTRL; - dma_tx_handle.Init.Priority = DMA_PRIORITY_VERY_HIGH; - dma_tx_handle.Init.FIFOMode = DMA_FIFOMODE_ENABLE; - dma_tx_handle.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; - dma_tx_handle.Init.MemBurst = DMA_MBURST_INC4; - dma_tx_handle.Init.PeriphBurst = DMA_PBURST_INC4; - - dma_tx_handle.Instance = SD_DMAx_Tx_STREAM; - - /* Associate the DMA handle */ - __HAL_LINKDMA(hsd, hdmatx, dma_tx_handle); - - /* Deinitialize the stream for new transfer */ - HAL_DMA_DeInit(&dma_tx_handle); - - /* Configure the DMA stream */ - HAL_DMA_Init(&dma_tx_handle); - - /* NVIC configuration for DMA transfer complete interrupt */ - HAL_NVIC_SetPriority(SD_DMAx_Rx_IRQn, 6, 0); - HAL_NVIC_EnableIRQ(SD_DMAx_Rx_IRQn); - - /* NVIC configuration for DMA transfer complete interrupt */ - HAL_NVIC_SetPriority(SD_DMAx_Tx_IRQn, 6, 0); - HAL_NVIC_EnableIRQ(SD_DMAx_Tx_IRQn); -} - -/** - * @brief DeInitializes the SD MSP. - * @param hsd: SD handle - * @retval None - */ -__weak void BSP_SD_MspDeInit(SD_HandleTypeDef *hsd, void *Params) -{ - static DMA_HandleTypeDef dma_rx_handle; - static DMA_HandleTypeDef dma_tx_handle; - - /* Disable NVIC for DMA transfer complete interrupts */ - HAL_NVIC_DisableIRQ(SD_DMAx_Rx_IRQn); - HAL_NVIC_DisableIRQ(SD_DMAx_Tx_IRQn); - - /* Deinitialize the stream for new transfer */ - dma_rx_handle.Instance = SD_DMAx_Rx_STREAM; - HAL_DMA_DeInit(&dma_rx_handle); - - /* Deinitialize the stream for new transfer */ - dma_tx_handle.Instance = SD_DMAx_Tx_STREAM; - HAL_DMA_DeInit(&dma_tx_handle); - - /* Disable NVIC for SDIO interrupts */ - HAL_NVIC_DisableIRQ(SDIO_IRQn); - - /* DeInit GPIO pins can be done in the application - (by surcharging this __weak function) */ - - /* Disable SDIO clock */ - __HAL_RCC_SDIO_CLK_DISABLE(); - - /* GPIO pins clock and DMA clocks can be shut down in the application - by surcharging this __weak function */ -} - -/** - * @brief Handles SD card interrupt request. - * @param None - * @retval None - */ -void BSP_SD_IRQHandler(void) -{ - HAL_SD_IRQHandler(&uSdHandle); -} - -/** - * @brief Handles SD DMA Tx transfer interrupt request. - * @param None - * @retval None - */ -void BSP_SD_DMA_Tx_IRQHandler(void) -{ - HAL_DMA_IRQHandler(uSdHandle.hdmatx); -} - -/** - * @brief Handles SD DMA Rx transfer interrupt request. - * @param None - * @retval None - */ -void BSP_SD_DMA_Rx_IRQHandler(void) -{ - HAL_DMA_IRQHandler(uSdHandle.hdmarx); -} - -/** - * @brief Gets the current SD card data status. - * @param None - * @retval Data transfer state. - * This value can be one of the following values: - * @arg SD_TRANSFER_OK: No data transfer is acting - * @arg SD_TRANSFER_BUSY: Data transfer is acting - * @arg SD_TRANSFER_ERROR: Data transfer error - */ -HAL_SD_TransferStateTypedef BSP_SD_GetStatus(void) -{ - return(HAL_SD_GetStatus(&uSdHandle)); -} - -/** - * @brief Get SD information about specific SD card. - * @param CardInfo: Pointer to HAL_SD_CardInfoTypedef structure - * @retval None - */ -void BSP_SD_GetCardInfo(HAL_SD_CardInfoTypedef *CardInfo) -{ - /* Get SD card Information */ - HAL_SD_Get_CardInfo(&uSdHandle, CardInfo); -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/stm32446e_eval_sd.h b/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/stm32446e_eval_sd.h deleted file mode 100644 index 96d8110a58..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/stm32446e_eval_sd.h +++ /dev/null @@ -1,159 +0,0 @@ -/** - ****************************************************************************** - * @file stm32446e_eval_sd.h - * @author MCD Application Team - * @version V1.1.0 - * @date 14-August-2015 - * @brief This file contains the common defines and functions prototypes for - * the stm32446e_eval_sd.c driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32446E_EVAL_SD_H -#define __STM32446E_EVAL_SD_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm32446e_eval.h" -#include "stm32446e_eval_io.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32446E_EVAL - * @{ - */ - -/** @defgroup STM32446E_EVAL_SD STM32446E-EVAL SD - * @{ - */ - -/** @defgroup STM32446E_EVAL_SD_Exported_Types STM32446E EVAL SD Exported Types - * @{ - */ - -/** - * @brief SD Card information structure - */ -#define SD_CardInfo HAL_SD_CardInfoTypedef -/** - * @} - */ - -/** - * @brief SD status structure definition - */ -#define MSD_OK ((uint8_t)0x00) -#define MSD_ERROR ((uint8_t)0x01) -#define MSD_ERROR_SD_NOT_PRESENT ((uint8_t)0x02) - -/** @defgroup STM32446E_EVAL_SD_Exported_Constants STM32446E EVAL SD Exported Constants - * @{ - */ -#define SD_PRESENT ((uint8_t)0x01) -#define SD_NOT_PRESENT ((uint8_t)0x00) - -#define SD_DATATIMEOUT ((uint32_t)100000000) - -/* DMA definitions for SD DMA transfer */ -#define __DMAx_TxRx_CLK_ENABLE __HAL_RCC_DMA2_CLK_ENABLE -#define SD_DMAx_Tx_CHANNEL DMA_CHANNEL_4 -#define SD_DMAx_Rx_CHANNEL DMA_CHANNEL_4 -#define SD_DMAx_Tx_STREAM DMA2_Stream6 -#define SD_DMAx_Rx_STREAM DMA2_Stream3 -#define SD_DMAx_Tx_IRQn DMA2_Stream6_IRQn -#define SD_DMAx_Rx_IRQn DMA2_Stream3_IRQn -#define SD_DMAx_Tx_IRQHandler DMA2_Stream6_IRQHandler -#define SD_DMAx_Rx_IRQHandler DMA2_Stream3_IRQHandler -#define SD_DetectIRQHandler() HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_8) -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_SD_Exported_Macro STM32446E EVAL SD Exported Macro - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_SD_Exported_Functions STM32446E EVAL SD Exported Functions - * @{ - */ -uint8_t BSP_SD_Init(void); -uint8_t BSP_SD_DeInit(void); -uint8_t BSP_SD_ITConfig(void); -void BSP_SD_DetectIT(void); -void BSP_SD_DetectCallback(void); -uint8_t BSP_SD_ReadBlocks(uint32_t *pData, uint64_t ReadAddr, uint32_t BlockSize, uint32_t NumOfBlocks); -uint8_t BSP_SD_WriteBlocks(uint32_t *pData, uint64_t WriteAddr, uint32_t BlockSize, uint32_t NumOfBlocks); -uint8_t BSP_SD_ReadBlocks_DMA(uint32_t *pData, uint64_t ReadAddr, uint32_t BlockSize, uint32_t NumOfBlocks); -uint8_t BSP_SD_WriteBlocks_DMA(uint32_t *pData, uint64_t WriteAddr, uint32_t BlockSize, uint32_t NumOfBlocks); -uint8_t BSP_SD_Erase(uint64_t StartAddr, uint64_t EndAddr); -void BSP_SD_IRQHandler(void); -void BSP_SD_DMA_Tx_IRQHandler(void); -void BSP_SD_DMA_Rx_IRQHandler(void); -HAL_SD_TransferStateTypedef BSP_SD_GetStatus(void); -void BSP_SD_GetCardInfo(HAL_SD_CardInfoTypedef *CardInfo); -uint8_t BSP_SD_IsDetected(void); - -/* These function can be modified in case the current settings (e.g. DMA stream) - need to be changed for specific application needs */ -void BSP_SD_MspInit(SD_HandleTypeDef *hsd, void *Params); -void BSP_SD_MspDeInit(SD_HandleTypeDef *hsd, void *Params); - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32446E_EVAL_SD_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/stm32446e_eval_sdram.c b/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/stm32446e_eval_sdram.c deleted file mode 100644 index bb946901fd..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/stm32446e_eval_sdram.c +++ /dev/null @@ -1,510 +0,0 @@ -/** - ****************************************************************************** - * @file stm32446e_eval_sdram.c - * @author MCD Application Team - * @version V1.1.0 - * @date 14-August-2015 - * @brief This file includes the SDRAM driver for the MT48LC4M32B2B5-7 memory - * device mounted on STM32446E-EVAL evaluation board. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* File Info : ----------------------------------------------------------------- - User NOTES -1. How To use this driver: --------------------------- - - This driver is used to drive the MT48LC4M32B2B5-7 SDRAM external memory mounted - on STM32446E-EVAL evaluation board. - - This driver does not need a specific component driver for the SDRAM device - to be included with. - -2. Driver description: ---------------------- - + Initialization steps: - o Initialize the SDRAM external memory using the BSP_SDRAM_Init() function. This - function includes the MSP layer hardware resources initialization and the - FMC controller configuration to interface with the external SDRAM memory. - o It contains the SDRAM initialization sequence to program the SDRAM external - device using the function BSP_SDRAM_Initialization_sequence(). Note that this - sequence is standard for all SDRAM devices, but can include some differences - from a device to another. If it is the case, the right sequence should be - implemented separately. - - + SDRAM read/write operations - o SDRAM external memory can be accessed with read/write operations once it is - initialized. - Read/write operation can be performed with AHB access using the functions - BSP_SDRAM_ReadData()/BSP_SDRAM_WriteData(), or by DMA transfer using the functions - BSP_SDRAM_ReadData_DMA()/BSP_SDRAM_WriteData_DMA(). - o The AHB access is performed with 16-bit width transaction, the DMA transfer - configuration is fixed at single (no burst) halfword transfer (see the - BSP_SDRAM_MspInit() __weak function). - o User can implement his own functions for read/write access with his desired - configurations. - o If interrupt mode is used for DMA transfer, the function BSP_SDRAM_DMA_IRQHandler() - is called in IRQ handler file, to serve the generated interrupt once the DMA - transfer is complete. - o You can send a command to the SDRAM device in runtime using the function - BSP_SDRAM_Sendcmd(), and giving the desired command as parameter chosen between - the predefined commands of the "FMC_SDRAM_CommandTypeDef" structure. - -------------------------------------------------------------------------------*/ - -/* Includes ------------------------------------------------------------------*/ -#include "stm32446e_eval_sdram.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32446E_EVAL - * @{ - */ - -/** @defgroup STM32446E_EVAL_SDRAM STM32446E-EVAL SDRAM - * @{ - */ - -/** @defgroup STM32446E_EVAL_SDRAM_Private_Types_Definitions STM32446E Eval SDRAM Private TypesDef - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_SDRAM_Private_Defines STM32446E Eval SDRAM Private Defines - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_SDRAM_Private_Macros STM32446E Eval SDRAM Private Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_SDRAM_Private_Variables STM32446E Eval SDRAM Private Variables - * @{ - */ -static SDRAM_HandleTypeDef sdramHandle; -static FMC_SDRAM_TimingTypeDef Timing; -static FMC_SDRAM_CommandTypeDef Command; -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_SDRAM_Private_Function_Prototypes STM32446E Eval SDRAM Private Prototypes - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_SDRAM_Private_Functions STM32446E Eval SDRAM Private Functions - * @{ - */ - -/** - * @brief Initializes the SDRAM device. - * @param None - * @retval SDRAM status - */ -uint8_t BSP_SDRAM_Init(void) -{ - static uint8_t sdramstatus = SDRAM_ERROR; - /* SDRAM device configuration */ - sdramHandle.Instance = FMC_SDRAM_DEVICE; - - /* Timing configuration for 90Mhz as SD clock frequency (System clock is up to 180Mhz */ - Timing.LoadToActiveDelay = 2; - Timing.ExitSelfRefreshDelay = 7; - Timing.SelfRefreshTime = 4; - Timing.RowCycleDelay = 7; - Timing.WriteRecoveryTime = 2; - Timing.RPDelay = 2; - Timing.RCDDelay = 2; - - sdramHandle.Init.SDBank = FMC_SDRAM_BANK1; - sdramHandle.Init.ColumnBitsNumber = FMC_SDRAM_COLUMN_BITS_NUM_8; - sdramHandle.Init.RowBitsNumber = FMC_SDRAM_ROW_BITS_NUM_12; - sdramHandle.Init.MemoryDataWidth = SDRAM_MEMORY_WIDTH; - sdramHandle.Init.InternalBankNumber = FMC_SDRAM_INTERN_BANKS_NUM_4; - sdramHandle.Init.CASLatency = FMC_SDRAM_CAS_LATENCY_2; - sdramHandle.Init.WriteProtection = FMC_SDRAM_WRITE_PROTECTION_DISABLE; - sdramHandle.Init.SDClockPeriod = SDCLOCK_PERIOD; - sdramHandle.Init.ReadBurst = FMC_SDRAM_RBURST_ENABLE; - sdramHandle.Init.ReadPipeDelay = FMC_SDRAM_RPIPE_DELAY_0; - - /* SDRAM controller initialization */ - - BSP_SDRAM_MspInit(&sdramHandle, NULL); /* __weak function can be rewritten by the applic */ - - if(HAL_SDRAM_Init(&sdramHandle, &Timing) != HAL_OK) - { - sdramstatus = SDRAM_ERROR; - } - else - { - sdramstatus = SDRAM_OK; - } - - /* SDRAM initialization sequence */ - BSP_SDRAM_Initialization_sequence(REFRESH_COUNT); - - return sdramstatus; -} - -/** - * @brief DeInitializes the SDRAM device. - * @param None - * @retval SDRAM status - */ -uint8_t BSP_SDRAM_DeInit(void) -{ - static uint8_t sdramstatus = SDRAM_ERROR; - /* SDRAM device configuration */ - sdramHandle.Instance = FMC_SDRAM_DEVICE; - - if(HAL_SDRAM_DeInit(&sdramHandle) != HAL_OK) - { - sdramstatus = SDRAM_ERROR; - } - else - { - sdramstatus = SDRAM_OK; - } - - /* SDRAM controller initialization */ - BSP_SDRAM_MspDeInit(&sdramHandle, NULL); - - return sdramstatus; -} - -/** - * @brief Programs the SDRAM device. - * @param RefreshCount: SDRAM refresh counter value - * @retval None - */ -void BSP_SDRAM_Initialization_sequence(uint32_t RefreshCount) -{ - __IO uint32_t tmpmrd = 0; - - /* Step 1: Configure a clock configuration enable command */ - Command.CommandMode = FMC_SDRAM_CMD_CLK_ENABLE; - Command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1; - Command.AutoRefreshNumber = 1; - Command.ModeRegisterDefinition = 0; - - /* Send the command */ - HAL_SDRAM_SendCommand(&sdramHandle, &Command, SDRAM_TIMEOUT); - - /* Step 2: Insert 100 us minimum delay */ - /* Inserted delay is equal to 1 ms due to systick time base unit (ms) */ - HAL_Delay(1); - - /* Step 3: Configure a PALL (precharge all) command */ - Command.CommandMode = FMC_SDRAM_CMD_PALL; - Command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1; - Command.AutoRefreshNumber = 1; - Command.ModeRegisterDefinition = 0; - - /* Send the command */ - HAL_SDRAM_SendCommand(&sdramHandle, &Command, SDRAM_TIMEOUT); - - /* Step 4: Configure an Auto Refresh command */ - Command.CommandMode = FMC_SDRAM_CMD_AUTOREFRESH_MODE; - Command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1; - Command.AutoRefreshNumber = 8; - Command.ModeRegisterDefinition = 0; - - /* Send the command */ - HAL_SDRAM_SendCommand(&sdramHandle, &Command, SDRAM_TIMEOUT); - - /* Step 5: Program the external memory mode register */ - tmpmrd = (uint32_t)SDRAM_MODEREG_BURST_LENGTH_1 |\ - SDRAM_MODEREG_BURST_TYPE_SEQUENTIAL |\ - SDRAM_MODEREG_CAS_LATENCY_2 |\ - SDRAM_MODEREG_OPERATING_MODE_STANDARD |\ - SDRAM_MODEREG_WRITEBURST_MODE_SINGLE; - - Command.CommandMode = FMC_SDRAM_CMD_LOAD_MODE; - Command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1; - Command.AutoRefreshNumber = 1; - Command.ModeRegisterDefinition = tmpmrd; - - /* Send the command */ - HAL_SDRAM_SendCommand(&sdramHandle, &Command, SDRAM_TIMEOUT); - - /* Step 6: Set the refresh rate counter */ - /* Set the device refresh rate */ - HAL_SDRAM_ProgramRefreshRate(&sdramHandle, RefreshCount); -} - -/** - * @brief Reads an mount of data from the SDRAM memory in polling mode. - * @param uwStartAddress: Read start address - * @param pData: Pointer to data to be read - * @param uwDataSize: Size of read data from the memory - * @retval SDRAM status - */ -uint8_t BSP_SDRAM_ReadData(uint32_t uwStartAddress, uint32_t *pData, uint32_t uwDataSize) -{ - if(HAL_SDRAM_Read_32b(&sdramHandle, (uint32_t *)uwStartAddress, pData, uwDataSize) != HAL_OK) - { - return SDRAM_ERROR; - } - else - { - return SDRAM_OK; - } -} - -/** - * @brief Reads an mount of data from the SDRAM memory in DMA mode. - * @param uwStartAddress: Read start address - * @param pData: Pointer to data to be read - * @param uwDataSize: Size of read data from the memory - * @retval SDRAM status - */ -uint8_t BSP_SDRAM_ReadData_DMA(uint32_t uwStartAddress, uint32_t *pData, uint32_t uwDataSize) -{ - if(HAL_SDRAM_Read_DMA(&sdramHandle, (uint32_t *)uwStartAddress, pData, uwDataSize) != HAL_OK) - { - return SDRAM_ERROR; - } - else - { - return SDRAM_OK; - } -} - -/** - * @brief Writes an mount of data to the SDRAM memory in polling mode. - * @param uwStartAddress: Write start address - * @param pData: Pointer to data to be written - * @param uwDataSize: Size of written data from the memory - * @retval SDRAM status - */ -uint8_t BSP_SDRAM_WriteData(uint32_t uwStartAddress, uint32_t *pData, uint32_t uwDataSize) -{ - if(HAL_SDRAM_Write_32b(&sdramHandle, (uint32_t *)uwStartAddress, pData, uwDataSize) != HAL_OK) - { - return SDRAM_ERROR; - } - else - { - return SDRAM_OK; - } -} - -/** - * @brief Writes an mount of data to the SDRAM memory in DMA mode. - * @param uwStartAddress: Write start address - * @param pData: Pointer to data to be written - * @param uwDataSize: Size of written data from the memory - * @retval SDRAM status - */ -uint8_t BSP_SDRAM_WriteData_DMA(uint32_t uwStartAddress, uint32_t *pData, uint32_t uwDataSize) -{ - if(HAL_SDRAM_Write_DMA(&sdramHandle, (uint32_t *)uwStartAddress, pData, uwDataSize) != HAL_OK) - { - return SDRAM_ERROR; - } - else - { - return SDRAM_OK; - } -} - -/** - * @brief Sends command to the SDRAM bank. - * @param SdramCmd: Pointer to SDRAM command structure - * @retval HAL status - */ -uint8_t BSP_SDRAM_Sendcmd(FMC_SDRAM_CommandTypeDef *SdramCmd) -{ - if(HAL_SDRAM_SendCommand(&sdramHandle, SdramCmd, SDRAM_TIMEOUT) != HAL_OK) - { - return SDRAM_ERROR; - } - else - { - return SDRAM_OK; - } -} - -/** - * @brief Handles SDRAM DMA transfer interrupt request. - * @param None - * @retval None - */ -void BSP_SDRAM_DMA_IRQHandler(void) -{ - HAL_DMA_IRQHandler(sdramHandle.hdma); -} - -/** - * @brief Initializes SDRAM MSP. - * @param hsdram: SDRAM handle - * @retval None - */ -__weak void BSP_SDRAM_MspInit(SDRAM_HandleTypeDef *hsdram, void *Params) -{ - static DMA_HandleTypeDef dma_handle; - GPIO_InitTypeDef gpio_init_structure; - - /* Enable FMC clock */ - __HAL_RCC_FMC_CLK_ENABLE(); - - /* Enable chosen DMAx clock */ - __DMAx_CLK_ENABLE(); - - /* Enable GPIOs clock */ - __HAL_RCC_GPIOA_CLK_ENABLE(); - __HAL_RCC_GPIOC_CLK_ENABLE(); - __HAL_RCC_GPIOD_CLK_ENABLE(); - __HAL_RCC_GPIOE_CLK_ENABLE(); - __HAL_RCC_GPIOF_CLK_ENABLE(); - __HAL_RCC_GPIOG_CLK_ENABLE(); - - /* Common GPIO configuration */ - gpio_init_structure.Mode = GPIO_MODE_AF_PP; - gpio_init_structure.Pull = GPIO_PULLUP; - gpio_init_structure.Speed = GPIO_SPEED_FAST; - gpio_init_structure.Alternate = GPIO_AF12_FMC; - - /* GPIOA configuration */ - gpio_init_structure.Pin = GPIO_PIN_7; - HAL_GPIO_Init(GPIOA, &gpio_init_structure); - - /* GPIOC configuration */ - gpio_init_structure.Pin = GPIO_PIN_5 | GPIO_PIN_4; - HAL_GPIO_Init(GPIOC, &gpio_init_structure); - - /* GPIOD configuration */ - gpio_init_structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_8| GPIO_PIN_9 | GPIO_PIN_10 |\ - GPIO_PIN_14 | GPIO_PIN_15; - - - HAL_GPIO_Init(GPIOD, &gpio_init_structure); - - /* GPIOE configuration */ - gpio_init_structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_7| GPIO_PIN_8 | GPIO_PIN_9 |\ - GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 |\ - GPIO_PIN_15; - - HAL_GPIO_Init(GPIOE, &gpio_init_structure); - - /* GPIOF configuration */ - gpio_init_structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2| GPIO_PIN_3 | GPIO_PIN_4 |\ - GPIO_PIN_5 | GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 |\ - GPIO_PIN_15; - - HAL_GPIO_Init(GPIOF, &gpio_init_structure); - - /* GPIOG configuration */ - gpio_init_structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_4| GPIO_PIN_5 | GPIO_PIN_8 |\ - GPIO_PIN_15 | GPIO_PIN_2; - HAL_GPIO_Init(GPIOG, &gpio_init_structure); - - /* Configure common DMA parameters */ - dma_handle.Init.Channel = SDRAM_DMAx_CHANNEL; - dma_handle.Init.Direction = DMA_MEMORY_TO_MEMORY; - dma_handle.Init.PeriphInc = DMA_PINC_ENABLE; - dma_handle.Init.MemInc = DMA_MINC_ENABLE; - dma_handle.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; - dma_handle.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; - dma_handle.Init.Mode = DMA_NORMAL; - dma_handle.Init.Priority = DMA_PRIORITY_HIGH; - dma_handle.Init.FIFOMode = DMA_FIFOMODE_DISABLE; - dma_handle.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; - dma_handle.Init.MemBurst = DMA_MBURST_SINGLE; - dma_handle.Init.PeriphBurst = DMA_PBURST_SINGLE; - - dma_handle.Instance = SDRAM_DMAx_STREAM; - - /* Associate the DMA handle */ - __HAL_LINKDMA(hsdram, hdma, dma_handle); - - /* Deinitialize the stream for new transfer */ - HAL_DMA_DeInit(&dma_handle); - - /* Configure the DMA stream */ - HAL_DMA_Init(&dma_handle); - - /* NVIC configuration for DMA transfer complete interrupt */ - HAL_NVIC_SetPriority(SDRAM_DMAx_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(SDRAM_DMAx_IRQn); -} - - -/** - * @brief DeInitializes SDRAM MSP. - * @param hsdram: SDRAM handle - * @retval None - */ -__weak void BSP_SDRAM_MspDeInit(SDRAM_HandleTypeDef *hsdram, void *Params) -{ - static DMA_HandleTypeDef dma_handle; - - /* Disable NVIC configuration for DMA interrupt */ - HAL_NVIC_DisableIRQ(SDRAM_DMAx_IRQn); - - /* Deinitialize the stream for new transfer */ - dma_handle.Instance = SDRAM_DMAx_STREAM; - HAL_DMA_DeInit(&dma_handle); - - /* DeInit GPIO pins can be done in the application - (by surcharging this __weak function) */ - - /* GPIO pins clock, FMC clock and DMA clock can be shut down in the application - by surcharging this __weak function */ -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/stm32446e_eval_sdram.h b/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/stm32446e_eval_sdram.h deleted file mode 100644 index 7b75303db5..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/stm32446e_eval_sdram.h +++ /dev/null @@ -1,165 +0,0 @@ -/** - ****************************************************************************** - * @file stm32446e_eval_sdram.h - * @author MCD Application Team - * @version V1.1.0 - * @date 14-August-2015 - * @brief This file contains the common defines and functions prototypes for - * the stm32446e_eval_sdram.c driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32446E_EVAL_SDRAM_H -#define __STM32446E_EVAL_SDRAM_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm32f4xx_hal.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32446E_EVAL - * @{ - */ - -/** @defgroup STM32446E_EVAL_SDRAM STM32446E-EVAL SDRAM - * @{ - */ - -/** @defgroup STM32446E_EVAL_SDRAM_Exported_Types STM32446E EVAL SDRAM Exported Types - * @{ - */ - -/** - * @brief SDRAM status structure definition - */ -#define SDRAM_OK ((uint8_t)0x00) -#define SDRAM_ERROR ((uint8_t)0x01) - -/** @defgroup STM32446E_EVAL_SDRAM_Exported_Constants STM32446E EVAL SDRAM Exported Constants - * @{ - */ -#define SDRAM_DEVICE_ADDR ((uint32_t)0xC0000000) -#define SDRAM_DEVICE_SIZE ((uint32_t)0x800000) /* SDRAM device size in MBytes */ - -/* #define SDRAM_MEMORY_WIDTH FMC_SDRAM_MEM_BUS_WIDTH_8 */ -#define SDRAM_MEMORY_WIDTH FMC_SDRAM_MEM_BUS_WIDTH_16 - -#define SDCLOCK_PERIOD FMC_SDRAM_CLOCK_PERIOD_2 -/* #define SDCLOCK_PERIOD FMC_SDRAM_CLOCK_PERIOD_3 */ - -#define REFRESH_COUNT ((uint32_t)0x0569) /* SDRAM refresh counter (90Mhz SD clock) */ - -#define SDRAM_TIMEOUT ((uint32_t)0xFFFF) - -/* DMA definitions for SDRAM DMA transfer */ -#define __DMAx_CLK_ENABLE __HAL_RCC_DMA2_CLK_ENABLE -#define __DMAx_CLK_DISABLE __HAL_RCC_DMA2_CLK_DISABLE -#define SDRAM_DMAx_CHANNEL DMA_CHANNEL_0 -#define SDRAM_DMAx_STREAM DMA2_Stream0 -#define SDRAM_DMAx_IRQn DMA2_Stream0_IRQn -#define SDRAM_DMAx_IRQHandler DMA2_Stream0_IRQHandler -/** - * @} - */ - -/** - * @brief FMC SDRAM Mode definition register defines - */ -#define SDRAM_MODEREG_BURST_LENGTH_1 ((uint16_t)0x0000) -#define SDRAM_MODEREG_BURST_LENGTH_2 ((uint16_t)0x0001) -#define SDRAM_MODEREG_BURST_LENGTH_4 ((uint16_t)0x0002) -#define SDRAM_MODEREG_BURST_LENGTH_8 ((uint16_t)0x0004) -#define SDRAM_MODEREG_BURST_TYPE_SEQUENTIAL ((uint16_t)0x0000) -#define SDRAM_MODEREG_BURST_TYPE_INTERLEAVED ((uint16_t)0x0008) -#define SDRAM_MODEREG_CAS_LATENCY_2 ((uint16_t)0x0020) -#define SDRAM_MODEREG_CAS_LATENCY_3 ((uint16_t)0x0030) -#define SDRAM_MODEREG_OPERATING_MODE_STANDARD ((uint16_t)0x0000) -#define SDRAM_MODEREG_WRITEBURST_MODE_PROGRAMMED ((uint16_t)0x0000) -#define SDRAM_MODEREG_WRITEBURST_MODE_SINGLE ((uint16_t)0x0200) -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_SDRAM_Exported_Macro STM32446E EVAL SDRAM Exported Macro - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_SDRAM_Exported_Functions STM32446E EVAL SDRAM Exported Functions - * @{ - */ -uint8_t BSP_SDRAM_Init(void); -uint8_t BSP_SDRAM_DeInit(void); -void BSP_SDRAM_Initialization_sequence(uint32_t RefreshCount); -uint8_t BSP_SDRAM_ReadData(uint32_t uwStartAddress, uint32_t *pData, uint32_t uwDataSize); -uint8_t BSP_SDRAM_ReadData_DMA(uint32_t uwStartAddress, uint32_t *pData, uint32_t uwDataSize); -uint8_t BSP_SDRAM_WriteData(uint32_t uwStartAddress, uint32_t *pData, uint32_t uwDataSize); -uint8_t BSP_SDRAM_WriteData_DMA(uint32_t uwStartAddress, uint32_t *pData, uint32_t uwDataSize); -uint8_t BSP_SDRAM_Sendcmd(FMC_SDRAM_CommandTypeDef *SdramCmd); -void BSP_SDRAM_DMA_IRQHandler(void); - -/* These function can be modified in case the current settings (e.g. DMA stream) - need to be changed for specific application needs */ -void BSP_SDRAM_MspInit(SDRAM_HandleTypeDef *hsdram, void *Params); -void BSP_SDRAM_MspDeInit(SDRAM_HandleTypeDef *hsdram, void *Params); - - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32446E_EVAL_SDRAM_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/stm32446e_eval_ts.c b/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/stm32446e_eval_ts.c deleted file mode 100644 index 09d2ec65e0..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/stm32446e_eval_ts.c +++ /dev/null @@ -1,324 +0,0 @@ -/** - ****************************************************************************** - * @file stm32446e_eval_ts.c - * @author MCD Application Team - * @version V1.1.0 - * @date 14-August-2015 - * @brief This file provides a set of functions needed to manage the Touch - * Screen on STM32446E-EVAL evaluation board. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* File Info : ----------------------------------------------------------------- - User NOTES -1. How To use this driver: --------------------------- - - This driver is used to drive the touch screen module of the STM32446E-EVAL - evaluation board on AMPIRE 480x272 LCD mounted on MB1046 daughter board. - - the MFXSTM32L152 IO expander device component - driver must be included in order to run the TS module commanded by the IO - expander device, the MFX IO expander device component driver must be - also included in case of interrupt mode use of the TS. - -2. Driver description: ---------------------- - + Initialization steps: - o Initialize the TS module using the BSP_TS_Init() function. This - function includes the MSP layer hardware resources initialization and the - communication layer configuration to start the TS use. The LCD size properties - (x and y) are passed as parameters. - o If TS interrupt mode is desired, you must configure the TS interrupt mode - by calling the function BSP_TS_ITConfig(). The TS interrupt mode is generated - as an external interrupt whenever a touch is detected. - The interrupt mode internally uses the IO functionalities driver driven by - the IO expander, to configure the IT line. - - + Touch screen use - o The touch screen state is captured whenever the function BSP_TS_GetState() is - used. This function returns information about the last LCD touch occurred - in the TS_StateTypeDef structure. - o If TS interrupt mode is used, the function BSP_TS_ITGetStatus() is needed to get - the interrupt status. To clear the IT pending bits, you should call the - function BSP_TS_ITClear(). - o The IT is handled using the corresponding external interrupt IRQ handler, - the user IT callback treatment is implemented on the same external interrupt - callback. - -------------------------------------------------------------------------------*/ - -/* Includes ------------------------------------------------------------------*/ -#include "stm32446e_eval_ts.h" -#include "stm32446e_eval_io.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32446E_EVAL - * @{ - */ - -/** @defgroup STM32446E_EVAL_TS STM32446E-EVAL TS - * @{ - */ - -/** @defgroup STM32446E_EVAL_TS_Private_Types_Definitions STM32446E Eval TS Private TypesDef - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_TS_Private_Defines STM32446E Eval TS Private Defines - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_TS_Private_Macros STM32446E Eval TS Private Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_TS_Private_Variables STM32446E Eval TS Private Variables - * @{ - */ -static TS_DrvTypeDef *ts_driver; -static uint16_t tsBundaryX, tsBundaryY; -static uint8_t tsOrientation; -static uint8_t AddressI2C; -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_TS_Private_Function_Prototypes STM32446E Eval TS Private prototypes - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_TS_Private_Functions STM32446E Eval TS Private Functions - * @{ - */ - -/** - * @brief Initializes and configures the touch screen functionalities and - * configures all necessary hardware resources (GPIOs, clocks..). - * @param xSize: Maximum X size of the TS area on LCD - * ySize: Maximum Y size of the TS area on LCD - * @retval TS_OK if all initializations are OK. Other value if error. - */ -uint8_t BSP_TS_Init(uint16_t xSize, uint16_t ySize) -{ - uint8_t mfxstm32l152_id = 0; - - tsBundaryX = xSize; - tsBundaryY = ySize; - - /* Initialize IO functionalities (MFX) used by TS */ - BSP_IO_Init(); - - /* Read ID and verify if the IO expander is ready */ - mfxstm32l152_id = mfxstm32l152_io_drv.ReadID(IO_I2C_ADDRESS); - if((mfxstm32l152_id == MFXSTM32L152_ID_1) || (mfxstm32l152_id == MFXSTM32L152_ID_2)) - { - /* Initialize the TS driver structure */ - ts_driver = &mfxstm32l152_ts_drv; - AddressI2C = TS_I2C_ADDRESS; - tsOrientation = TS_SWAP_NONE; - } - - - /* Initialize the TS driver */ - ts_driver->Init(AddressI2C); - ts_driver->Start(AddressI2C); - - return TS_OK; -} - -/** - * @brief DeInitializes the TouchScreen. - * @param None - * @retval TS state - */ -uint8_t BSP_TS_DeInit(void) -{ - /* Actually ts_driver does not provide a DeInit function */ - return TS_OK; -} - -/** - * @brief Enables the touch screen interrupts. - * @param None - * @retval TS_OK if all initializations are OK. Other value if error. - */ -uint8_t BSP_TS_ITEnable(void) -{ - /* Enable the TS ITs */ - ts_driver->EnableIT(AddressI2C); - return TS_OK; -} - -/** - * @brief Disables the touch screen interrupts. - * @param None - * @retval TS_OK if all initializations are OK. Other value if error. - */ -uint8_t BSP_TS_ITDisable(void) -{ - /* Disable the TS ITs */ - ts_driver->DisableIT(AddressI2C); - return TS_OK; -} - -/** - * @brief Configures and enables the touch screen interrupts. - * @param None - * @retval TS_OK if all initializations are OK. Other value if error. - */ -uint8_t BSP_TS_ITConfig(void) -{ - /* Initialize the IO */ - BSP_IO_Init(); - - /* Enable the TS ITs */ - ts_driver->EnableIT(AddressI2C); - - return TS_OK; -} - -/** - * @brief Clears all touch screen interrupts. - * @param None - * @retval None - */ -void BSP_TS_ITClear(void) -{ - /* Clear TS IT pending bits */ - ts_driver->ClearIT(AddressI2C); -} - -/** - * @brief Gets the touch screen interrupt status. - * @param None - * @retval TS_OK if all initializations are OK. Other value if error. - */ -uint8_t BSP_TS_ITGetStatus(void) -{ - /* Return the TS IT status */ - return (ts_driver->GetITStatus(AddressI2C)); -} - -/** - * @brief Clears touch screen FIFO containing 128 x,y values. - * @param None - * @retval None - */ -void BSP_TS_FIFOClear(void) -{ - /* ts.h does not foresee an API that allows clearing the FIFO */ - /* reading GetXY currently read one value from the FIFO */ - /* but the FIFO can contain up to 128 values ... */ - /* which would mean 128 I2C read. */ - /* Best is to modify ts.h (not done for compatibility with other families) */ -} - -/** - * @brief Returns status and positions of the touch screen. - * @param TS_State: Pointer to touch screen current state structure - * @retval TS_OK if all initializations are OK. Other value if error. - */ -uint8_t BSP_TS_GetState(TS_StateTypeDef *TS_State) -{ - static uint32_t _x = 0, _y = 0; - uint16_t x_diff, y_diff , x , y; - uint16_t swap; - - TS_State->TouchDetected = ts_driver->DetectTouch(AddressI2C); - - if(TS_State->TouchDetected) - { - ts_driver->GetXY(AddressI2C, &x, &y); - - if(tsOrientation & TS_SWAP_X) - { - x = 4096 - x; - } - - if(tsOrientation & TS_SWAP_Y) - { - y = 4096 - y; - } - - if(tsOrientation & TS_SWAP_XY) - { - swap = y; - y = x; - x = swap; - } - - x_diff = x > _x? (x - _x): (_x - x); - y_diff = y > _y? (y - _y): (_y - y); - - if (x_diff + y_diff > 5) - { - _x = x; - _y = y; - } - - TS_State->x = (tsBundaryX * _x) >> 12; - TS_State->y = (tsBundaryY * _y) >> 12; - } - return TS_OK; -} - - - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/stm32446e_eval_ts.h b/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/stm32446e_eval_ts.h deleted file mode 100644 index d0eae23641..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32446E_EVAL/stm32446e_eval_ts.h +++ /dev/null @@ -1,140 +0,0 @@ -/** - ****************************************************************************** - * @file stm32446e_eval_ts.h - * @author MCD Application Team - * @version V1.1.0 - * @date 14-August-2015 - * @brief This file contains the common defines and functions prototypes for - * the stm32446e_eval_ts.c driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32446E_EVAL_TS_H -#define __STM32446E_EVAL_TS_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm32446e_eval.h" -/* Include IOExpander(MFX) component Driver */ -#include "../Components/mfxstm32l152/mfxstm32l152.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32446E_EVAL - * @{ - */ - -/** @defgroup STM32446E_EVAL_TS STM32446E-EVAL TS - * @{ - */ - -/** @defgroup STM32446E_EVAL_TS_Exported_Types STM32446E EVAL TS Exported Types - * @{ - */ -typedef struct -{ - uint16_t TouchDetected; - uint16_t x; - uint16_t y; - uint16_t z; -}TS_StateTypeDef; -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_TS_Exported_Constants STM32446E EVAL TS Exported Constants - * @{ - */ -#define TS_SWAP_NONE ((uint8_t)0x00) -#define TS_SWAP_X ((uint8_t)0x01) -#define TS_SWAP_Y ((uint8_t)0x02) -#define TS_SWAP_XY ((uint8_t)0x04) - -typedef enum -{ - TS_OK = 0x00, - TS_ERROR = 0x01, - TS_TIMEOUT = 0x02 -}TS_StatusTypeDef; - -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_TS_Exported_Macros STM32446E EVAL TS Exported Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32446E_EVAL_TS_Exported_Functions STM32446E EVAL TS Exported Functions - * @{ - */ -uint8_t BSP_TS_Init(uint16_t xSize, uint16_t ySize); -uint8_t BSP_TS_DeInit(void); -uint8_t BSP_TS_GetState(TS_StateTypeDef *TS_State); -uint8_t BSP_TS_ITEnable(void); -uint8_t BSP_TS_ITDisable(void); -uint8_t BSP_TS_ITConfig(void); -uint8_t BSP_TS_ITGetStatus(void); -void BSP_TS_ITClear(void); -void BSP_TS_FIFOClear(void); - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32446E_EVAL_TS_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32469I-Discovery/Release_Notes.html b/bsp/stm32f411RE/Libraries/BSP/STM32469I-Discovery/Release_Notes.html deleted file mode 100644 index 0d24ff12e3..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32469I-Discovery/Release_Notes.html +++ /dev/null @@ -1,177 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - Release Notes for STM32446E_EVAL Evaluation Board Drivers - - - - - - - - - - -
-


-

-
- - - - - - -
- - - - - - - - - -
-

Back to Release page

-
-

Release -Notes for STM32469I_Discovery Board Drivers

-

Copyright -2015 STMicroelectronics

-

-
-

 

- - - - - - -
- - -

Update History

V1.0.1 / 29-September-2015

-

Main -Changes

- - - -
  • stm32469i_discovery_lcd.c update:
    • Add delay within BSP_LCD_Reset() function

V0.2.0 / 10-July-2015

-

Main -Changes

- - - -
  • Second Beta Release for STM32469I_Discovery board drivers.
  • Add support of Rev.B Discovery boards.
  • stm32469i_eval update:
    • Add AUDIO_IO_DeInit() function
    • Update TS_I2C_ADDRESS
    • Update MULTI_TOUCH management
  • stm32469i_eval_audio update:
    • Remove CODEC_Reset() static function
    • Update BSP_AUDIO_OUT_Init() function to no more use CODEC_Reset() function
  • stm32469i_eval_lcd update:
    • update lcd_x_size and lcd_y_size declaration and definition
    • update BSP_LCD_GetXSize() and BSP_LCD_GetYSize() functions
  • stm32469i_eval_sd update
    • update BSP_SD_Init() function with appropriate hardware flow control configuration

V0.1.0 / 12-June-2015

-

Main -Changes

- - - -
    -
  • First Beta Release for STM32469I_Discovery board drivers.
  • -

License

- -
-
-Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met:
-
-
  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions -in binary form must reproduce the above copyright notice, this list of -conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of STMicroelectronics nor the names of its contributors may be used to endorse or promote products derived
    -
    -
-        from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- -
-
- - -
-
-

For -complete documentation on STM32 Microcontrollers -visit www.st.com/STM32

-
-

-
-
-

 

-
- - \ No newline at end of file diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32469I-Discovery/stm32469i_discovery.c b/bsp/stm32f411RE/Libraries/BSP/STM32469I-Discovery/stm32469i_discovery.c deleted file mode 100644 index 1fc6c3db38..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32469I-Discovery/stm32469i_discovery.c +++ /dev/null @@ -1,945 +0,0 @@ -/** - ****************************************************************************** - * @file stm32469i_discovery.c - * @author MCD Application Team - * @version V1.0.1 - * @date 29-September-2015 - * @brief This file provides a set of firmware functions to manage LEDs, - * push-buttons, external SDRAM, external QSPI Flash, RF EEPROM, - * available on STM32469I-Discovery - * board (MB1189) RevA/B from STMicroelectronics. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Includes ------------------------------------------------------------------*/ -#include "stm32469i_discovery.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32469I_Discovery - * @{ - */ - -/** @defgroup STM32469I_Discovery_LOW_LEVEL STM32469I-Discovery LOW LEVEL - * @{ - */ - -/** @defgroup STM32469I_Discovery_LOW_LEVEL_Private_TypesDefinitions STM32469I Discovery Low Level Private Typedef - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I_Discovery_LOW_LEVEL_Private_Defines LOW_LEVEL Private Defines - * @{ - */ -/** - * @brief STM32469I Discovery BSP Driver version number V1.0.1 - */ -#define __STM32469I_DISCOVERY_BSP_VERSION_MAIN (0x01) /*!< [31:24] main version */ -#define __STM32469I_DISCOVERY_BSP_VERSION_SUB1 (0x00) /*!< [23:16] sub1 version */ -#define __STM32469I_DISCOVERY_BSP_VERSION_SUB2 (0x01) /*!< [15:8] sub2 version */ -#define __STM32469I_DISCOVERY_BSP_VERSION_RC (0x00) /*!< [7:0] release candidate */ -#define __STM32469I_DISCOVERY_BSP_VERSION ((__STM32469I_DISCOVERY_BSP_VERSION_MAIN << 24)\ - |(__STM32469I_DISCOVERY_BSP_VERSION_SUB1 << 16)\ - |(__STM32469I_DISCOVERY_BSP_VERSION_SUB2 << 8 )\ - |(__STM32469I_DISCOVERY_BSP_VERSION_RC)) -/** - * @} - */ - -/** @defgroup STM32469I_Discovery_LOW_LEVEL_Private_Macros LOW_LEVEL Private Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I_Discovery_LOW_LEVEL_Private_Variables LOW_LEVEL Private Variables - * @{ - */ -uint32_t GPIO_PIN[LEDn] = {LED1_PIN, - LED2_PIN, - LED3_PIN, - LED4_PIN}; - -GPIO_TypeDef* GPIO_PORT[LEDn] = {LED1_GPIO_PORT, - LED2_GPIO_PORT, - LED3_GPIO_PORT, - LED4_GPIO_PORT}; - -GPIO_TypeDef* BUTTON_PORT[BUTTONn] = {WAKEUP_BUTTON_GPIO_PORT }; - -const uint16_t BUTTON_PIN[BUTTONn] = {WAKEUP_BUTTON_PIN }; - -const uint16_t BUTTON_IRQn[BUTTONn] = {WAKEUP_BUTTON_EXTI_IRQn }; - - -static I2C_HandleTypeDef heval_I2c1; -static I2C_HandleTypeDef heval_I2c2; - -/** - * @} - */ - -/** @defgroup STM32469I_Discovery_LOW_LEVEL_Private_FunctionPrototypes LOW_LEVEL Private FunctionPrototypes - * @{ - */ -static void I2C1_MspInit(void); -static void I2C2_MspInit(void); -static void I2C1_Init(void); -static void I2C2_Init(void); - -#if defined(USE_IOEXPANDER) -static void I2C1_Write(uint8_t Addr, uint8_t Reg, uint8_t Value); -static uint8_t I2C1_Read(uint8_t Addr, uint8_t Reg); -#endif /* USE_IOEXPANDER */ -static HAL_StatusTypeDef I2C1_ReadMultiple(uint8_t Addr, uint16_t Reg, uint16_t MemAddSize, uint8_t *Buffer, uint16_t Length); -static HAL_StatusTypeDef I2C2_ReadMultiple(uint8_t Addr, uint16_t Reg, uint16_t MemAddSize, uint8_t *Buffer, uint16_t Length); -static HAL_StatusTypeDef I2C1_WriteMultiple(uint8_t Addr, uint16_t Reg, uint16_t MemAddSize, uint8_t *Buffer, uint16_t Length); -static HAL_StatusTypeDef I2C2_WriteMultiple(uint8_t Addr, uint16_t Reg, uint16_t MemAddSize, uint8_t *Buffer, uint16_t Length); -static HAL_StatusTypeDef I2C1_IsDeviceReady(uint16_t DevAddress, uint32_t Trials); -static void I2C1_Error(uint8_t Addr); -static void I2C2_Error(uint8_t Addr); - -/* AUDIO IO functions */ -void AUDIO_IO_Init(void); -void AUDIO_IO_DeInit(void); -void AUDIO_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value); -uint8_t AUDIO_IO_Read(uint8_t Addr, uint8_t Reg); -void AUDIO_IO_Delay(uint32_t Delay); - - -/* I2C EEPROM IO function */ -void EEPROM_IO_Init(void); -HAL_StatusTypeDef EEPROM_IO_WriteData(uint16_t DevAddress, uint16_t MemAddress, uint8_t* pBuffer, uint32_t BufferSize); -HAL_StatusTypeDef EEPROM_IO_ReadData(uint16_t DevAddress, uint16_t MemAddress, uint8_t* pBuffer, uint32_t BufferSize); -HAL_StatusTypeDef EEPROM_IO_IsDeviceReady(uint16_t DevAddress, uint32_t Trials); - -/* TouchScreen (TS) IO functions */ -void TS_IO_Init(void); -void TS_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value); -uint8_t TS_IO_Read(uint8_t Addr, uint8_t Reg); -uint16_t TS_IO_ReadMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length); -void TS_IO_WriteMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length); -void TS_IO_Delay(uint32_t Delay); -void OTM8009A_IO_Delay(uint32_t Delay); -/** - * @} - */ - -/** @defgroup STM32469I_Discovery_BSP_Public_Functions BSP Public Functions - * @{ - */ - - /** - * @brief This method returns the STM32469I Discovery BSP Driver revision - * @retval version: 0xXYZR (8bits for each decimal, R for RC) - */ -uint32_t BSP_GetVersion(void) -{ - return __STM32469I_DISCOVERY_BSP_VERSION; -} - -/** - * @brief Configures LED GPIO. - * @param Led: LED to be configured. - * This parameter can be one of the following values: - * @arg LED1 - * @arg LED2 - * @arg LED3 - * @arg LED4 - * @retval None - */ -void BSP_LED_Init(Led_TypeDef Led) -{ - GPIO_InitTypeDef gpio_init_structure; - - if (Led <= LED4) - { - /* Configure the GPIO_LED pin */ - gpio_init_structure.Pin = GPIO_PIN[Led]; - gpio_init_structure.Mode = GPIO_MODE_OUTPUT_PP; - gpio_init_structure.Pull = GPIO_PULLUP; - gpio_init_structure.Speed = GPIO_SPEED_HIGH; - - switch(Led) - { - case LED1 : - LED1_GPIO_CLK_ENABLE(); - break; - case LED2 : - LED2_GPIO_CLK_ENABLE(); - break; - case LED3 : - LED3_GPIO_CLK_ENABLE(); - break; - case LED4 : - LED4_GPIO_CLK_ENABLE(); - break; - default : - break; - - } /* end switch */ - - HAL_GPIO_Init(GPIO_PORT[Led], &gpio_init_structure); - - /* By default, turn off LED by setting a high level on corresponding GPIO */ - HAL_GPIO_WritePin(GPIO_PORT[Led], GPIO_PIN[Led], GPIO_PIN_SET); - - } /* of if (Led <= LED4) */ - -} - - -/** - * @brief DeInit LEDs. - * @param Led: LED to be configured. - * This parameter can be one of the following values: - * @arg LED1 - * @arg LED2 - * @arg LED3 - * @arg LED4 - * @note Led DeInit does not disable the GPIO clock nor disable the Mfx - * @retval None - */ -void BSP_LED_DeInit(Led_TypeDef Led) -{ - GPIO_InitTypeDef gpio_init_structure; - - if (Led <= LED4) - { - /* DeInit the GPIO_LED pin */ - gpio_init_structure.Pin = GPIO_PIN[Led]; - - /* Turn off LED */ - HAL_GPIO_WritePin(GPIO_PORT[Led], GPIO_PIN[Led], GPIO_PIN_SET); - HAL_GPIO_DeInit(GPIO_PORT[Led], gpio_init_structure.Pin); - } - -} - -/** - * @brief Turns selected LED On. - * @param Led: LED to be set on - * This parameter can be one of the following values: - * @arg LED1 - * @arg LED2 - * @arg LED3 - * @arg LED4 - * @retval None - */ -void BSP_LED_On(Led_TypeDef Led) -{ - if (Led <= LED4) - { - HAL_GPIO_WritePin(GPIO_PORT[Led], GPIO_PIN[Led], GPIO_PIN_RESET); - } - -} - -/** - * @brief Turns selected LED Off. - * @param Led: LED to be set off - * This parameter can be one of the following values: - * @arg LED1 - * @arg LED2 - * @arg LED3 - * @arg LED4 - * @retval None - */ -void BSP_LED_Off(Led_TypeDef Led) -{ - if (Led <= LED4) - { - HAL_GPIO_WritePin(GPIO_PORT[Led], GPIO_PIN[Led], GPIO_PIN_SET); - } -} - -/** - * @brief Toggles the selected LED. - * @param Led: LED to be toggled - * This parameter can be one of the following values: - * @arg LED1 - * @arg LED2 - * @arg LED3 - * @arg LED4 - * @retval None - */ -void BSP_LED_Toggle(Led_TypeDef Led) -{ - if (Led <= LED4) - { - HAL_GPIO_TogglePin(GPIO_PORT[Led], GPIO_PIN[Led]); - } -} - -/** - * @brief Configures button GPIO and EXTI Line. - * @param Button: Button to be configured - * This parameter can be one of the following values: - * @arg BUTTON_WAKEUP: Wakeup Push Button - * @arg BUTTON_USER: User Push Button - * @param Button_Mode: Button mode - * This parameter can be one of the following values: - * @arg BUTTON_MODE_GPIO: Button will be used as simple IO - * @arg BUTTON_MODE_EXTI: Button will be connected to EXTI line - * with interrupt generation capability - * @retval None - */ -void BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef Button_Mode) -{ - GPIO_InitTypeDef gpio_init_structure; - - /* Enable the BUTTON clock */ - BUTTON_GPIO_CLK_ENABLE(); - - if(Button_Mode == BUTTON_MODE_GPIO) - { - /* Configure Button pin as input */ - gpio_init_structure.Pin = BUTTON_PIN[Button]; - gpio_init_structure.Mode = GPIO_MODE_INPUT; - gpio_init_structure.Pull = GPIO_NOPULL; - gpio_init_structure.Speed = GPIO_SPEED_FAST; - HAL_GPIO_Init(BUTTON_PORT[Button], &gpio_init_structure); - } - - if(Button_Mode == BUTTON_MODE_EXTI) - { - /* Configure Button pin as input with External interrupt */ - gpio_init_structure.Pin = BUTTON_PIN[Button]; - gpio_init_structure.Pull = GPIO_NOPULL; - gpio_init_structure.Speed = GPIO_SPEED_FAST; - - gpio_init_structure.Mode = GPIO_MODE_IT_RISING; - - HAL_GPIO_Init(BUTTON_PORT[Button], &gpio_init_structure); - - /* Enable and set Button EXTI Interrupt to the lowest priority */ - HAL_NVIC_SetPriority((IRQn_Type)(BUTTON_IRQn[Button]), 0x0F, 0x00); - HAL_NVIC_EnableIRQ((IRQn_Type)(BUTTON_IRQn[Button])); - } -} - -/** - * @brief Push Button DeInit. - * @param Button: Button to be configured - * This parameter can be one of the following values: - * @arg BUTTON_WAKEUP: Wakeup Push Button - * @arg BUTTON_USER: User Push Button - * @note PB DeInit does not disable the GPIO clock - * @retval None - */ -void BSP_PB_DeInit(Button_TypeDef Button) -{ - GPIO_InitTypeDef gpio_init_structure; - - gpio_init_structure.Pin = BUTTON_PIN[Button]; - HAL_NVIC_DisableIRQ((IRQn_Type)(BUTTON_IRQn[Button])); - HAL_GPIO_DeInit(BUTTON_PORT[Button], gpio_init_structure.Pin); -} - - -/** - * @brief Returns the selected button state. - * @param Button: Button to be checked - * This parameter can be one of the following values: - * @arg BUTTON_WAKEUP: Wakeup Push Button - * @arg BUTTON_USER: User Push Button - * @retval The Button GPIO pin value - */ -uint32_t BSP_PB_GetState(Button_TypeDef Button) -{ - return HAL_GPIO_ReadPin(BUTTON_PORT[Button], BUTTON_PIN[Button]); -} - -/** - * @} - */ - -/** @defgroup STM32469I_Discovery_LOW_LEVEL_Private_Functions STM32469I_Discovery_LOW_LEVEL Private Functions - * @{ - */ - - -/******************************************************************************* - BUS OPERATIONS -*******************************************************************************/ - -/******************************* I2C Routines *********************************/ -/** - * @brief Initializes I2C MSP. - */ -static void I2C1_MspInit(void) -{ - GPIO_InitTypeDef gpio_init_structure; - - /*** Configure the GPIOs ***/ - /* Enable GPIO clock */ - DISCO_I2C1_SCL_SDA_GPIO_CLK_ENABLE(); - - /* Configure I2C Tx as alternate function */ - gpio_init_structure.Pin = DISCO_I2C1_SCL_PIN; - gpio_init_structure.Mode = GPIO_MODE_AF_OD; - gpio_init_structure.Pull = GPIO_NOPULL; - gpio_init_structure.Speed = GPIO_SPEED_FAST; - gpio_init_structure.Alternate = DISCO_I2C1_SCL_SDA_AF; - HAL_GPIO_Init(DISCO_I2C1_SCL_SDA_GPIO_PORT, &gpio_init_structure); - - /* Configure I2C Rx as alternate function */ - gpio_init_structure.Pin = DISCO_I2C1_SDA_PIN; - HAL_GPIO_Init(DISCO_I2C1_SCL_SDA_GPIO_PORT, &gpio_init_structure); - - /*** Configure the I2C peripheral ***/ - /* Enable I2C clock */ - DISCO_I2C1_CLK_ENABLE(); - - /* Force the I2C peripheral clock reset */ - DISCO_I2C1_FORCE_RESET(); - - /* Release the I2C peripheral clock reset */ - DISCO_I2C1_RELEASE_RESET(); - - /* Enable and set I2C1 Interrupt to a lower priority */ - HAL_NVIC_SetPriority(DISCO_I2C1_EV_IRQn, 0x05, 0); - HAL_NVIC_EnableIRQ(DISCO_I2C1_EV_IRQn); - - /* Enable and set I2C1 Interrupt to a lower priority */ - HAL_NVIC_SetPriority(DISCO_I2C1_ER_IRQn, 0x05, 0); - HAL_NVIC_EnableIRQ(DISCO_I2C1_ER_IRQn); -} - -/** - * @brief Initializes I2C MSP. - */ -static void I2C2_MspInit(void) -{ - GPIO_InitTypeDef gpio_init_structure; - - /*** Configure the GPIOs ***/ - /* Enable GPIO clock */ - DISCO_I2C2_SCL_SDA_GPIO_CLK_ENABLE(); - - /* Configure I2C Tx as alternate function */ - gpio_init_structure.Pin = DISCO_I2C2_SCL_PIN; - gpio_init_structure.Mode = GPIO_MODE_AF_OD; - gpio_init_structure.Pull = GPIO_NOPULL; - gpio_init_structure.Speed = GPIO_SPEED_FAST; - gpio_init_structure.Alternate = DISCO_I2C2_SCL_SDA_AF; - HAL_GPIO_Init(DISCO_I2C2_SCL_SDA_GPIO_PORT, &gpio_init_structure); - - /* Configure I2C Rx as alternate function */ - gpio_init_structure.Pin = DISCO_I2C2_SDA_PIN; - HAL_GPIO_Init(DISCO_I2C2_SCL_SDA_GPIO_PORT, &gpio_init_structure); - - /*** Configure the I2C peripheral ***/ - /* Enable I2C clock */ - DISCO_I2C2_CLK_ENABLE(); - - /* Force the I2C peripheral clock reset */ - DISCO_I2C2_FORCE_RESET(); - - /* Release the I2C peripheral clock reset */ - DISCO_I2C2_RELEASE_RESET(); - - /* Enable and set I2C1 Interrupt to a lower priority */ - HAL_NVIC_SetPriority(DISCO_I2C2_EV_IRQn, 0x05, 0); - HAL_NVIC_EnableIRQ(DISCO_I2C2_EV_IRQn); - - /* Enable and set I2C1 Interrupt to a lower priority */ - HAL_NVIC_SetPriority(DISCO_I2C2_ER_IRQn, 0x05, 0); - HAL_NVIC_EnableIRQ(DISCO_I2C2_ER_IRQn); -} - -/** - * @brief Initializes I2C HAL. - */ -static void I2C1_Init(void) -{ - if(HAL_I2C_GetState(&heval_I2c1) == HAL_I2C_STATE_RESET) - { - heval_I2c1.Instance = I2C1; - heval_I2c1.Init.ClockSpeed = I2C1_SCL_FREQ_KHZ; - heval_I2c1.Init.DutyCycle = I2C_DUTYCYCLE_2; - heval_I2c1.Init.OwnAddress1 = 0; - heval_I2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT; - heval_I2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE; - heval_I2c1.Init.OwnAddress2 = 0; - heval_I2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE; - heval_I2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE; - - /* Init the I2C */ - I2C1_MspInit(); - HAL_I2C_Init(&heval_I2c1); - } -} - -/** - * @brief Initializes I2C HAL. - */ -static void I2C2_Init(void) -{ - if(HAL_I2C_GetState(&heval_I2c2) == HAL_I2C_STATE_RESET) - { - heval_I2c2.Instance = I2C2; - heval_I2c2.Init.ClockSpeed = I2C2_SCL_FREQ_KHZ; - heval_I2c2.Init.DutyCycle = I2C_DUTYCYCLE_2; - heval_I2c2.Init.OwnAddress1 = 0; - heval_I2c2.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT; - heval_I2c2.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE; - heval_I2c2.Init.OwnAddress2 = 0; - heval_I2c2.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE; - heval_I2c2.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE; - - /* Init the I2C */ - I2C2_MspInit(); - HAL_I2C_Init(&heval_I2c2); - } -} - -/** - * @brief Writes a single data. - * @param Addr: I2C address - * @param Reg: Register address - * @param Value: Data to be written - */ -static void I2C1_Write(uint8_t Addr, uint8_t Reg, uint8_t Value) -{ - HAL_StatusTypeDef status = HAL_OK; - - status = HAL_I2C_Mem_Write(&heval_I2c1, - Addr, - (uint16_t)Reg, - I2C_MEMADD_SIZE_8BIT, - &Value, - 1, - 100); - - /* Check the communication status */ - if(status != HAL_OK) - { - /* Execute user timeout callback */ - I2C1_Error(Addr); - } -} - -/** - * @brief Reads a single data. - * @param Addr: I2C address - * @param Reg: Register address - * @retval Read data - */ -static uint8_t I2C1_Read(uint8_t Addr, uint8_t Reg) -{ - HAL_StatusTypeDef status = HAL_OK; - uint8_t Value = 0; - - status = HAL_I2C_Mem_Read(&heval_I2c1, - Addr, - Reg, - I2C_MEMADD_SIZE_8BIT, - &Value, - 1, - 1000); - - /* Check the communication status */ - if(status != HAL_OK) - { - /* Execute user timeout callback */ - I2C1_Error(Addr); - } - return Value; -} - -/** - * @brief Reads multiple data. - * @param Addr: I2C address - * @param Reg: Reg address - * @param MemAddress: memory address - * @param Buffer: Pointer to data buffer - * @param Length: Length of the data - * @retval HAL status - */ -static HAL_StatusTypeDef I2C1_ReadMultiple(uint8_t Addr, - uint16_t Reg, - uint16_t MemAddress, - uint8_t *Buffer, - uint16_t Length) -{ - HAL_StatusTypeDef status = HAL_OK; - - status = HAL_I2C_Mem_Read(&heval_I2c1, - Addr, - (uint16_t)Reg, - MemAddress, - Buffer, - Length, - 1000); - - /* Check the communication status */ - if(status != HAL_OK) - { - /* I2C error occured */ - I2C1_Error(Addr); - } - return status; -} - -static HAL_StatusTypeDef I2C2_ReadMultiple(uint8_t Addr, - uint16_t Reg, - uint16_t MemAddress, - uint8_t *Buffer, - uint16_t Length) -{ - HAL_StatusTypeDef status = HAL_OK; - - status = HAL_I2C_Mem_Read(&heval_I2c2, - Addr, - (uint16_t)Reg, - MemAddress, - Buffer, - Length, - 1000); - - /* Check the communication status */ - if(status != HAL_OK) - { - /* I2C2 error occured */ - I2C2_Error(Addr); - } - return status; -} - -/** - * @brief Writes a value in a register of the device through BUS in using DMA mode. - * @param Addr: Device address on BUS Bus. - * @param Reg: The target register address to write - * @param MemAddress: memory address - * @param Buffer: The target register value to be written - * @param Length: buffer size to be written - * @retval HAL status - */ -static HAL_StatusTypeDef I2C1_WriteMultiple(uint8_t Addr, - uint16_t Reg, - uint16_t MemAddress, - uint8_t *Buffer, - uint16_t Length) -{ - HAL_StatusTypeDef status = HAL_OK; - - status = HAL_I2C_Mem_Write(&heval_I2c1, - Addr, - (uint16_t)Reg, - MemAddress, - Buffer, - Length, - 1000); - - /* Check the communication status */ - if(status != HAL_OK) - { - /* Re-Initiaize the I2C Bus */ - I2C1_Error(Addr); - } - return status; -} - -static HAL_StatusTypeDef I2C2_WriteMultiple(uint8_t Addr, - uint16_t Reg, - uint16_t MemAddress, - uint8_t *Buffer, - uint16_t Length) -{ - HAL_StatusTypeDef status = HAL_OK; - - status = HAL_I2C_Mem_Write(&heval_I2c2, - Addr, - (uint16_t)Reg, - MemAddress, - Buffer, - Length, - 1000); - - /* Check the communication status */ - if(status != HAL_OK) - { - /* Re-Initiaize the I2C2 Bus */ - I2C2_Error(Addr); - } - return status; -} - -/** - * @brief Checks if target device is ready for communication. - * @note This function is used with Memory devices - * @param DevAddress: Target device address - * @param Trials: Number of trials - * @retval HAL status - */ -static HAL_StatusTypeDef I2C1_IsDeviceReady(uint16_t DevAddress, uint32_t Trials) -{ - return (HAL_I2C_IsDeviceReady(&heval_I2c1, DevAddress, Trials, 1000)); -} - -/** - * @brief Manages error callback by re-initializing I2C. - * @param Addr: I2C Address - * @retval None - */ -static void I2C1_Error(uint8_t Addr) -{ - /* De-initialize the I2C comunication bus */ - HAL_I2C_DeInit(&heval_I2c1); - - /* Re-Initiaize the I2C comunication bus */ - I2C1_Init(); -} - -static void I2C2_Error(uint8_t Addr) -{ - /* De-initialize the I2C2 comunication bus */ - HAL_I2C_DeInit(&heval_I2c2); - - /* Re-Initiaize the I2C2 comunication bus */ - I2C2_Init(); -} - -/** - * @} - */ - -/******************************************************************************* - LINK OPERATIONS -*******************************************************************************/ - -/********************************* LINK AUDIO *********************************/ - -/** - * @brief Initializes Audio low level. - */ -void AUDIO_IO_Init(void) -{ - I2C2_Init(); -} - -/** - * @brief DeInitializes Audio low level. - */ -void AUDIO_IO_DeInit(void) -{ - -} - -/** - * @brief Writes a single data. - * @param Addr: I2C address - * @param Reg: Reg address - * @param Value: Data to be written - */ -void AUDIO_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value) -{ - I2C2_WriteMultiple(Addr, (uint16_t) Reg, I2C_MEMADD_SIZE_8BIT, (uint8_t*)&Value, 1); -} - -/** - * @brief Reads a single data. - * @param Addr: I2C address - * @param Reg: Reg address - * @retval Data to be read - */ -uint8_t AUDIO_IO_Read(uint8_t Addr, uint8_t Reg) -{ - uint8_t read_value = 0; - - I2C2_ReadMultiple(Addr, (uint16_t) Reg, I2C_MEMADD_SIZE_8BIT, (uint8_t*)&read_value, 1); - - return read_value; -} - -/** - * @brief AUDIO Codec delay - * @param Delay: Delay in ms - */ -void AUDIO_IO_Delay(uint32_t Delay) -{ - HAL_Delay(Delay); -} - -/******************************** LINK I2C EEPROM *****************************/ - -/** - * @brief Initializes peripherals used by the I2C EEPROM driver. - */ -void EEPROM_IO_Init(void) -{ - I2C1_Init(); -} - -/** - * @brief Write data to I2C EEPROM driver in using DMA channel. - * @param DevAddress: Target device address - * @param MemAddress: Internal memory address - * @param pBuffer: Pointer to data buffer - * @param BufferSize: Amount of data to be sent - * @retval HAL status - */ -HAL_StatusTypeDef EEPROM_IO_WriteData(uint16_t DevAddress, uint16_t MemAddress, uint8_t* pBuffer, uint32_t BufferSize) -{ - return (I2C1_WriteMultiple(DevAddress, MemAddress, I2C_MEMADD_SIZE_16BIT, pBuffer, BufferSize)); -} - -/** - * @brief Read data from I2C EEPROM driver in using DMA channel. - * @param DevAddress: Target device address - * @param MemAddress: Internal memory address - * @param pBuffer: Pointer to data buffer - * @param BufferSize: Amount of data to be read - * @retval HAL status - */ -HAL_StatusTypeDef EEPROM_IO_ReadData(uint16_t DevAddress, uint16_t MemAddress, uint8_t* pBuffer, uint32_t BufferSize) -{ - return (I2C1_ReadMultiple(DevAddress, MemAddress, I2C_MEMADD_SIZE_16BIT, pBuffer, BufferSize)); -} - -/** - * @brief Checks if target device is ready for communication. - * @note This function is used with Memory devices - * @param DevAddress: Target device address - * @param Trials: Number of trials - * @retval HAL status - */ -HAL_StatusTypeDef EEPROM_IO_IsDeviceReady(uint16_t DevAddress, uint32_t Trials) -{ - return (I2C1_IsDeviceReady(DevAddress, Trials)); -} - -/******************************** LINK TS (TouchScreen) ***********************/ - -/** - * @brief Initialize I2C communication - * channel from MCU to TouchScreen (TS). - */ -void TS_IO_Init(void) -{ - I2C1_Init(); -} - -/** - * @brief Writes single data with I2C communication - * channel from MCU to TouchScreen. - * @param Addr: I2C address - * @param Reg: Register address - * @param Value: Data to be written - */ -void TS_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value) -{ - I2C1_Write(Addr, Reg, Value); -} - -/** - * @brief Reads single data with I2C communication - * channel from TouchScreen. - * @param Addr: I2C address - * @param Reg: Register address - * @retval Read data - */ -uint8_t TS_IO_Read(uint8_t Addr, uint8_t Reg) -{ - return I2C1_Read(Addr, Reg); -} - -/** - * @brief Reads multiple data with I2C communication - * channel from TouchScreen. - * @param Addr: I2C address - * @param Reg: Register address - * @param Buffer: Pointer to data buffer - * @param Length: Length of the data - * @retval Number of read data - */ -uint16_t TS_IO_ReadMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length) -{ - return I2C1_ReadMultiple(Addr, (uint16_t)Reg, I2C_MEMADD_SIZE_8BIT, Buffer, Length); -} - -/** - * @brief Writes multiple data with I2C communication - * channel from MCU to TouchScreen. - * @param Addr: I2C address - * @param Reg: Register address - * @param Buffer: Pointer to data buffer - * @param Length: Length of the data - * @retval None - */ -void TS_IO_WriteMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length) -{ - I2C1_WriteMultiple(Addr, (uint16_t)Reg, I2C_MEMADD_SIZE_8BIT, Buffer, Length); -} - -/** - * @brief Delay function used in TouchScreen low level driver. - * @param Delay: Delay in ms - * @retval None - */ -void TS_IO_Delay(uint32_t Delay) -{ - HAL_Delay(Delay); -} - -/**************************** LINK OTM8009A (Display driver) ******************/ -/** - * @brief OTM8009A delay - * @param Delay: Delay in ms - */ -void OTM8009A_IO_Delay(uint32_t Delay) -{ - HAL_Delay(Delay); -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32469I-Discovery/stm32469i_discovery.h b/bsp/stm32f411RE/Libraries/BSP/STM32469I-Discovery/stm32469i_discovery.h deleted file mode 100644 index 76b76f996a..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32469I-Discovery/stm32469i_discovery.h +++ /dev/null @@ -1,369 +0,0 @@ -/** - ****************************************************************************** - * @file stm32469i_discovery.h - * @author MCD Application Team - * @version V1.0.1 - * @date 29-September-2015 - * @brief This file contains definitions for STM32469I-Discovery LEDs, - * push-buttons hardware resources. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32469I_DISCOVERY_H -#define __STM32469I_DISCOVERY_H - -#ifdef __cplusplus - extern "C" { -#endif - - - /* Includes ------------------------------------------------------------------*/ -#include "stm32f4xx_hal.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32469I_Discovery - * @{ - */ - -/** @defgroup STM32469I_Discovery_LOW_LEVEL STM32469I-Discovery LOW LEVEL - * @{ - */ - -/** @defgroup STM32469I_Discovery_LOW_LEVEL_Exported_Types STM32469I Discovery Low Level Exported Types - * @{ - */ - -/** @brief Led_TypeDef - * STM32469I_Discovery board leds definitions. - */ -typedef enum -{ - LED1 = 0, - LED_GREEN = LED1, - LED2 = 1, - LED_ORANGE = LED2, - LED3 = 2, - LED_RED = LED3, - LED4 = 3, - LED_BLUE = LED4 - -} Led_TypeDef; - -/** @brief Button_TypeDef - * STM32469I_Discovery board Buttons definitions. - */ -typedef enum -{ - BUTTON_WAKEUP = 0 -} Button_TypeDef; - -#define BUTTON_USER BUTTON_WAKEUP - -/** @brief ButtonMode_TypeDef - * STM32469I_Discovery board Buttons Modes definitions. - */ -typedef enum -{ - BUTTON_MODE_GPIO = 0, - BUTTON_MODE_EXTI = 1 - -} ButtonMode_TypeDef; - -/** @addtogroup Exported_types - * @{ - */ -typedef enum -{ - PB_SET = 0, - PB_RESET = !PB_SET -} ButtonValue_TypeDef; - - -/** @brief DISCO_Status_TypeDef - * STM32469I_DISCO board Status return possible values. - */ -typedef enum -{ - DISCO_OK = 0, - DISCO_ERROR = 1 - -} DISCO_Status_TypeDef; - -/** - * @} - */ - -/** @defgroup STM32469I_Discovery_LOW_LEVEL_Exported_Constants STM32469I Discovery Low Level Exported Constants - * @{ - */ - - -/** @addtogroup STM32469I_Discovery_LOW_LEVEL_LED STM32469I Discovery Low Level Led - * @{ - */ -/* Always four leds for all revisions of Discovery boards */ -#define LEDn ((uint8_t)4) - - -/* 4 Leds are connected to MCU directly on PG6, PD4, PD5, PK3 */ -#define LED1_GPIO_PORT ((GPIO_TypeDef*)GPIOG) -#define LED2_GPIO_PORT ((GPIO_TypeDef*)GPIOD) -#define LED3_GPIO_PORT ((GPIO_TypeDef*)GPIOD) -#define LED4_GPIO_PORT ((GPIO_TypeDef*)GPIOK) - -#define LED1_GPIO_CLK_ENABLE() __HAL_RCC_GPIOG_CLK_ENABLE() -#define LED1_GPIO_CLK_DISABLE() __HAL_RCC_GPIOG_CLK_DISABLE() -#define LED2_GPIO_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE() -#define LED2_GPIO_CLK_DISABLE() __HAL_RCC_GPIOD_CLK_DISABLE() -#define LED3_GPIO_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE() -#define LED3_GPIO_CLK_DISABLE() __HAL_RCC_GPIOD_CLK_DISABLE() -#define LED4_GPIO_CLK_ENABLE() __HAL_RCC_GPIOK_CLK_ENABLE() -#define LED4_GPIO_CLK_DISABLE() __HAL_RCC_GPIOK_CLK_DISABLE() - -#define LED1_PIN ((uint32_t)GPIO_PIN_6) -#define LED2_PIN ((uint32_t)GPIO_PIN_4) -#define LED3_PIN ((uint32_t)GPIO_PIN_5) -#define LED4_PIN ((uint32_t)GPIO_PIN_3) -/** - * @} - */ - -/** @addtogroup STM32469I_Discovery_LOW_LEVEL_BUTTON STM32469I Discovery Low Level Button - * @{ - */ -/* Only one User/Wakeup button */ -#define BUTTONn ((uint8_t)1) - -/** - * @brief Wakeup push-button - */ -#define WAKEUP_BUTTON_PIN GPIO_PIN_0 -#define WAKEUP_BUTTON_GPIO_PORT GPIOA -#define WAKEUP_BUTTON_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE() -#define WAKEUP_BUTTON_GPIO_CLK_DISABLE() __HAL_RCC_GPIOA_CLK_DISABLE() -#define WAKEUP_BUTTON_EXTI_IRQn EXTI0_IRQn - -/* Define the USER button as an alias of the Wakeup button */ -#define USER_BUTTON_PIN WAKEUP_BUTTON_PIN -#define USER_BUTTON_GPIO_PORT WAKEUP_BUTTON_GPIO_PORT -#define USER_BUTTON_GPIO_CLK_ENABLE() WAKEUP_BUTTON_GPIO_CLK_ENABLE() -#define USER_BUTTON_GPIO_CLK_DISABLE() WAKEUP_BUTTON_GPIO_CLK_DISABLE() -#define USER_BUTTON_EXTI_IRQn WAKEUP_BUTTON_EXTI_IRQn - -#define BUTTON_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE() - -/** - * @} - */ - -/** - * @brief Discovery Pins definition - * TODO : to be modified/reviewed - */ -#define AUDIO_INT_PIN GPIO_PIN_7 -#define AUDIO_INT_PORT GPIOB -#define AUDIO_INT_PORT_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE() - -#define OTG_FS1_OVER_CURRENT_PIN GPIO_PIN_7 -#define OTG_FS1_OVER_CURRENT_PORT GPIOB -#define OTG_FS1_OVER_CURRENT_PORT_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE() - -#define OTG_FS1_POWER_SWITCH_PIN GPIO_PIN_2 -#define OTG_FS1_POWER_SWITCH_PORT GPIOB -#define OTG_FS1_POWER_SWITCH_PORT_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE() - -/** - * @brief SD-detect signal - */ -#define SD_DETECT_PIN ((uint32_t)GPIO_PIN_2) -#define SD_DETECT_GPIO_PORT ((GPIO_TypeDef*)GPIOG) -#define SD_DETECT_GPIO_CLK_ENABLE() __HAL_RCC_GPIOG_CLK_ENABLE() -#define SD_DETECT_GPIO_CLK_DISABLE() __HAL_RCC_GPIOG_CLK_DISABLE() -#define SD_DETECT_EXTI_IRQn EXTI2_IRQn - -/** - * @brief TS_INT signal from TouchScreen when it is configured in interrupt mode - * GPIOJ5 is used for that purpose on Manta Dragon Discovery board - */ -#define TS_INT_PIN ((uint32_t)GPIO_PIN_5) -#define TS_INT_GPIO_PORT ((GPIO_TypeDef*)GPIOJ) -#define TS_INT_GPIO_CLK_ENABLE() __HAL_RCC_GPIOJ_CLK_ENABLE() -#define TS_INT_GPIO_CLK_DISABLE() __HAL_RCC_GPIOJ_CLK_DISABLE() -#define TS_INT_EXTI_IRQn EXTI9_5_IRQn - -/** - * @brief TouchScreen FT6206 Slave I2C address - */ -#define TS_I2C_ADDRESS ((uint16_t)0x54) - - -/** - * @brief Audio I2C Slave address - */ -#define AUDIO_I2C_ADDRESS ((uint16_t)0x94) - -/** - * @brief EEPROM I2C Slave address 1 - */ -#define EEPROM_I2C_ADDRESS_A01 ((uint16_t)0xA0) - -/** - * @brief EEPROM I2C Slave address 2 - */ -#define EEPROM_I2C_ADDRESS_A02 ((uint16_t)0xA6) - -/** - * @brief I2C clock speed configuration (in Hz) - * WARNING: - * Make sure that this define is not already declared in other files - * It can be used in parallel by other modules. - */ -#ifndef I2C1_SCL_FREQ_KHZ -#define I2C1_SCL_FREQ_KHZ 400000 /*!< f(I2C_SCL) = 400 kHz */ -#endif /* I2C1_SCL_FREQ_KHZ */ - -/** - * @brief User can use this section to tailor I2C1/I2C1 instance used and associated - * resources. - * Definition for I2C1 clock resources - */ -#define DISCO_I2C1 I2C1 -#define DISCO_I2C1_CLK_ENABLE() __HAL_RCC_I2C1_CLK_ENABLE() -#define DISCO_DMAx_CLK_ENABLE() __HAL_RCC_DMA1_CLK_ENABLE() -#define DISCO_I2C1_SCL_SDA_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE() - -#define DISCO_I2C1_FORCE_RESET() __HAL_RCC_I2C1_FORCE_RESET() -#define DISCO_I2C1_RELEASE_RESET() __HAL_RCC_I2C1_RELEASE_RESET() - -/** @brief Definition for I2C1 Pins - */ -#define DISCO_I2C1_SCL_PIN GPIO_PIN_8 /*!< PB8 */ -#define DISCO_I2C1_SCL_SDA_GPIO_PORT GPIOB -#define DISCO_I2C1_SCL_SDA_AF GPIO_AF4_I2C1 -#define DISCO_I2C1_SDA_PIN GPIO_PIN_9 /*!< PB9 */ - -/** @brief Definition of I2C interrupt requests - */ -#define DISCO_I2C1_EV_IRQn I2C1_EV_IRQn -#define DISCO_I2C1_ER_IRQn I2C1_ER_IRQn - - - -/** - * @brief I2C2 clock speed configuration (in Hz) - * WARNING: - * Make sure that this define is not already declared in other files - * It can be used in parallel by other modules. - */ -#ifndef I2C2_SCL_FREQ_KHZ -#define I2C2_SCL_FREQ_KHZ 100000 /*!< f(I2C2_SCL) < 100 kHz */ -#endif /* I2C2_SCL_FREQ_KHZ */ - -/** - * @brief User can use this section to tailor I2C2/I2C2 instance used and associated - * resources (audio codec). - * Definition for I2C2 clock resources - */ -#define DISCO_I2C2 I2C2 -#define DISCO_I2C2_CLK_ENABLE() __HAL_RCC_I2C2_CLK_ENABLE() -#define DISCO_I2C2_SCL_SDA_GPIO_CLK_ENABLE() __HAL_RCC_GPIOH_CLK_ENABLE() - -#define DISCO_I2C2_FORCE_RESET() __HAL_RCC_I2C2_FORCE_RESET() -#define DISCO_I2C2_RELEASE_RESET() __HAL_RCC_I2C2_RELEASE_RESET() - -/** @brief Definition for I2C2 Pins - */ -#define DISCO_I2C2_SCL_PIN GPIO_PIN_4 /*!< PH4 */ -#define DISCO_I2C2_SCL_SDA_GPIO_PORT GPIOH -#define DISCO_I2C2_SCL_SDA_AF GPIO_AF4_I2C2 -#define DISCO_I2C2_SDA_PIN GPIO_PIN_5 /*!< PH5 */ - -/** @brief Definition of I2C2 interrupt requests - */ -#define DISCO_I2C2_EV_IRQn I2C2_EV_IRQn -#define DISCO_I2C2_ER_IRQn I2C2_ER_IRQn - - -/** - * @} - */ - -/** @defgroup STM32469I_Discovery_LOW_LEVEL_Exported_Macros STM32469I Discovery Low Level Exported Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I_Discovery_LOW_LEVEL_Exported_Functions STM32469I Discovery Low Level Exported Functions - * @{ - */ -uint32_t BSP_GetVersion(void); -void BSP_LED_Init(Led_TypeDef Led); -void BSP_LED_DeInit(Led_TypeDef Led); -void BSP_LED_On(Led_TypeDef Led); -void BSP_LED_Off(Led_TypeDef Led); -void BSP_LED_Toggle(Led_TypeDef Led); -void BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef Button_Mode); -void BSP_PB_DeInit(Button_TypeDef Button); -uint32_t BSP_PB_GetState(Button_TypeDef Button); - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32469I_DISCOVERY_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32469I-Discovery/stm32469i_discovery_audio.c b/bsp/stm32f411RE/Libraries/BSP/STM32469I-Discovery/stm32469i_discovery_audio.c deleted file mode 100644 index cb41475a38..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32469I-Discovery/stm32469i_discovery_audio.c +++ /dev/null @@ -1,1498 +0,0 @@ -/** - ****************************************************************************** - * @file stm32469i_discovery_audio.c - * @author MCD Application Team - * @version V1.0.1 - * @date 29-September-2015 - * @brief This file provides the Audio driver for the STM32469I-Discovery board. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/*============================================================================== - User NOTES - -How To use this driver: ------------------------ - + This driver supports STM32F4xx devices on STM32469I-Discovery (MB1189) Discovery boards. - + Call the function BSP_AUDIO_OUT_Init( - OutputDevice: physical output mode (OUTPUT_DEVICE_HEADPHONE1, - OUTPUT_DEVICE_HEADPHONE2 or OUTPUT_DEVICE_BOTH) - Volume : Initial volume to be set (0 is min (mute), 100 is max (100%) - AudioFreq : Audio frequency in Hz (8000, 16000, 22500, 32000...) - this parameter is relative to the audio file/stream type. - ) - This function configures all the hardware required for the audio application (codec, I2C, SAI, - GPIOs, DMA and interrupt if needed). This function returns AUDIO_OK if configuration is OK. - If the returned value is different from AUDIO_OK or the function is stuck then the communication with - the codec or the MFX has failed (try to un-plug the power or reset device in this case). - - OUTPUT_DEVICE_HEADPHONE1 : only headphones 1 will be set as output for the audio stream. - - OUTPUT_DEVICE_HEADPHONE2 : only headphones 2 will be set as output for the audio stream. - - OUTPUT_DEVICE_BOTH : both Headphones are used as outputs for the audio stream - at the same time. - Note. On STM32469I-Discovery SAI_DMA is configured in CIRCULAR mode. Due to this the application - does NOT need to call BSP_AUDIO_OUT_ChangeBuffer() to assure straming. - + Call the function BSP_Discovery_AUDIO_OUT_Play( - pBuffer: pointer to the audio data file address - Size : size of the buffer to be sent in Bytes - ) - to start playing (for the first time) from the audio file/stream. - + Call the function BSP_AUDIO_OUT_Pause() to pause playing - + Call the function BSP_AUDIO_OUT_Resume() to resume playing. - Note. After calling BSP_AUDIO_OUT_Pause() function for pause, only BSP_AUDIO_OUT_Resume() should be called - for resume (it is not allowed to call BSP_AUDIO_OUT_Play() in this case). - Note. This function should be called only when the audio file is played or paused (not stopped). - + For each mode, you may need to implement the relative callback functions into your code. - The Callback functions are named AUDIO_OUT_XXX_CallBack() and only their prototypes are declared in - the stm32469i_discovery_audio.h file. (refer to the example for more details on the callbacks implementations) - + To Stop playing, to modify the volume level, the frequency, the audio frame slot, - the device output mode the mute or the stop, use the functions: BSP_AUDIO_OUT_SetVolume(), - AUDIO_OUT_SetFrequency(), BSP_AUDIO_OUT_SetAudioFrameSlot(), BSP_AUDIO_OUT_SetOutputMode(), - BSP_AUDIO_OUT_SetMute() and BSP_AUDIO_OUT_Stop(). - + The driver API and the callback functions are at the end of the stm32469i_discovery_audio.h file. - -Driver architecture: --------------------- - + This driver provide the High Audio Layer: consists of the function API exported in the stm32469i_discovery_audio.h file - (BSP_AUDIO_OUT_Init(), BSP_AUDIO_OUT_Play() ...) - + This driver provide also the Media Access Layer (MAL): which consists of functions allowing to access the media containing/ - providing the audio file/stream. These functions are also included as local functions into - the stm32469i_discovery_audio_codec.c file (I2Sx_Init(), I2Sx_DeInit(), SAIx_Init() and SAIx_DeInit()) - -Known Limitations: ------------------- - 1- If the TDM Format used to paly in parallel 2 audio Stream (the first Stream is configured in codec SLOT0 and second - Stream in SLOT1) the Pause/Resume, volume and mute feature will control the both streams. - 2- Parsing of audio file is not implemented (in order to determine audio file properties: Mono/Stereo, Data size, - File size, Audio Frequency, Audio Data header size ...). The configuration is fixed for the given audio file. - 3- Supports only Stereo audio streaming. - 4- Supports only 16-bits audio data size. -==============================================================================*/ - -/* Includes ------------------------------------------------------------------*/ -#include -#include "stm32469i_discovery_audio.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32469I-Discovery - * @{ - */ - -/** @defgroup STM32469I-Discovery_AUDIO STM32469I-Discovery AUDIO - * @brief This file includes the low layer driver for CS43L22 Audio Codec - * available on STM32469I-Discovery board(MB1189). - * @{ - */ - -/** @defgroup STM32469I-Discovery_AUDIO_Private_Types STM32469I Discovery Audio Private Types - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I-Discovery_AUDIO_Private_Defines STM32469I Discovery Audio Private Defines - * @brief Headphone1 (CN27 of STM32469I-Discovery board) is connected to the - * HEADPHONE output of CS43L22 Audio Codec. - * Headphone2 (CN26 of STM32469I-Discovery board) is connected to the - * SPEAKER output of CS43L22 Audio Codec. - * @{ - */ -#define OUTPUT_DEVICE_HEADPHONE1 OUTPUT_DEVICE_HEADPHONE - -/* Headphone2 is connected to Speaker output of the CS43L22 codec */ -#define OUTPUT_DEVICE_HEADPHONE2 OUTPUT_DEVICE_SPEAKER -/** - * @} - */ - -/** @defgroup STM32469I-Discovery_AUDIO_Private_Macros STM32469I Discovery Audio Private macros - * @{ - */ - -/*### PLAY ###*/ -/* SCK(kHz) = SAI_CK_x/(SAIClockDivider*2*256) */ -#define SAIClockDivider(__FREQUENCY__) \ - (__FREQUENCY__ == AUDIO_FREQUENCY_8K) ? 12 \ - : (__FREQUENCY__ == AUDIO_FREQUENCY_11K) ? 2 \ - : (__FREQUENCY__ == AUDIO_FREQUENCY_16K) ? 6 \ - : (__FREQUENCY__ == AUDIO_FREQUENCY_22K) ? 1 \ - : (__FREQUENCY__ == AUDIO_FREQUENCY_32K) ? 3 \ - : (__FREQUENCY__ == AUDIO_FREQUENCY_44K) ? 0 \ - : (__FREQUENCY__ == AUDIO_FREQUENCY_48K) ? 2 : 1 \ - -/** - * @} - */ - -/** @defgroup STM32469I-Discovery_AUDIO_Private_Variables STM32469I Discovery Audio Private Variables - * @{ - */ - -/* -Note: - these global variables are not compliant to naming rules (upper case without "_" ), - but we keep this naming for compatibility, in fact these variables (not static) - could have been used by the application, example the stm32f4xx_it.c: - void DMA2_Stream6_IRQHandler(void) - { HAL_DMA_IRQHandler(haudio_out_sai.hdmatx); } -*/ -AUDIO_DrvTypeDef *audio_drv; -SAI_HandleTypeDef haudio_out_sai; -I2S_HandleTypeDef haudio_in_i2s; -TIM_HandleTypeDef haudio_tim; - -PDMFilter_InitStruct Filter[2]; -uint8_t Channel_Demux[128] = { - 0x00, 0x01, 0x00, 0x01, 0x02, 0x03, 0x02, 0x03, - 0x00, 0x01, 0x00, 0x01, 0x02, 0x03, 0x02, 0x03, - 0x04, 0x05, 0x04, 0x05, 0x06, 0x07, 0x06, 0x07, - 0x04, 0x05, 0x04, 0x05, 0x06, 0x07, 0x06, 0x07, - 0x00, 0x01, 0x00, 0x01, 0x02, 0x03, 0x02, 0x03, - 0x00, 0x01, 0x00, 0x01, 0x02, 0x03, 0x02, 0x03, - 0x04, 0x05, 0x04, 0x05, 0x06, 0x07, 0x06, 0x07, - 0x04, 0x05, 0x04, 0x05, 0x06, 0x07, 0x06, 0x07, - 0x08, 0x09, 0x08, 0x09, 0x0a, 0x0b, 0x0a, 0x0b, - 0x08, 0x09, 0x08, 0x09, 0x0a, 0x0b, 0x0a, 0x0b, - 0x0c, 0x0d, 0x0c, 0x0d, 0x0e, 0x0f, 0x0e, 0x0f, - 0x0c, 0x0d, 0x0c, 0x0d, 0x0e, 0x0f, 0x0e, 0x0f, - 0x08, 0x09, 0x08, 0x09, 0x0a, 0x0b, 0x0a, 0x0b, - 0x08, 0x09, 0x08, 0x09, 0x0a, 0x0b, 0x0a, 0x0b, - 0x0c, 0x0d, 0x0c, 0x0d, 0x0e, 0x0f, 0x0e, 0x0f, - 0x0c, 0x0d, 0x0c, 0x0d, 0x0e, 0x0f, 0x0e, 0x0f -}; - -uint16_t __IO AudioInVolume = DEFAULT_AUDIO_IN_VOLUME; - -/** - * @} - */ - -/** @defgroup STM32469I-Discovery_AUDIO_Private_Function_Prototypes STM32469I Discovery Audio Private Prototypes - * @{ - */ -static void AUDIO_CODEC_Reset(void); -static uint8_t SAIx_Init(uint32_t AudioFreq); -static void SAIx_DeInit(void); -static void I2Sx_Init(uint32_t AudioFreq); -static void I2Sx_DeInit(void); -static void TIMx_IC_MspInit(TIM_HandleTypeDef *htim); -static void TIMx_IC_MspDeInit(TIM_HandleTypeDef *htim); -static void TIMx_Init(void); -static void TIMx_DeInit(void); -static void PDMDecoder_Init(uint32_t AudioFreq, uint32_t ChnlNbr); - -void BSP_AUDIO_OUT_ChangeAudioConfig(uint32_t AudioOutOption); - -/** - * @} - */ - -/** @defgroup STM32469I-Discovery_AUDIO_out_Private_Functions STM32469I Discovery AudioOut Private Functions - * @{ - */ - -/** - * @brief Configures the audio peripherals. - * @param OutputDevice: OUTPUT_DEVICE_SPEAKER, OUTPUT_DEVICE_HEADPHONE, - * or OUTPUT_DEVICE_BOTH. - * @param Volume: Initial volume level (from 0 (Mute) to 100 (Max)) - * @param AudioFreq: Audio frequency used to play the audio stream. - * @note The SAI PLL input clock must be done in the user application. - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_Init(uint16_t OutputDevice, - uint8_t Volume, - uint32_t AudioFreq) -{ - uint8_t ret = AUDIO_OK; - - SAIx_DeInit(); - - /* PLL clock is set depending by the AudioFreq (44.1khz vs 48khz groups) */ - BSP_AUDIO_OUT_ClockConfig(&haudio_out_sai, AudioFreq, NULL); - - /* SAI data transfer preparation: - Prepare the Media to be used for the audio transfer from memory to SAI peripheral */ - haudio_out_sai.Instance = AUDIO_SAIx; - if(HAL_SAI_GetState(&haudio_out_sai) == HAL_SAI_STATE_RESET) - { - /* Init the SAI MSP: this __weak function can be redefined by the application*/ - BSP_AUDIO_OUT_MspInit(&haudio_out_sai, NULL); - } - - if (SAIx_Init(AudioFreq) != AUDIO_OK) - { - ret = AUDIO_ERROR; - } - - if(ret == AUDIO_OK) - { - /* Retieve audio codec identifier */ - if (cs43l22_drv.ReadID(AUDIO_I2C_ADDRESS) == CS43L22_ID) - { - /* Reset the audio codec Registers */ - AUDIO_CODEC_Reset(); - - /* Initialize the audio driver structure */ - audio_drv = &cs43l22_drv; - } - else - { - ret = AUDIO_ERROR; - } - } - - if(ret == AUDIO_OK) - { - /* Initialize the audio codec internal registers */ - if (audio_drv->Init(AUDIO_I2C_ADDRESS, - OutputDevice, - Volume, - AudioFreq) != AUDIO_OK) - { - ret = AUDIO_ERROR; - } - } - - return ret; -} - -/** - * @brief Starts playing audio stream from a data buffer for a determined size. - * @param pBuffer: Pointer to the buffer - * @param Size: Number of audio data BYTES. - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_Play(uint16_t* pBuffer, uint32_t Size) -{ - uint8_t ret = AUDIO_OK; - - /* Call the audio Codec Play function */ - if(audio_drv->Play(AUDIO_I2C_ADDRESS, pBuffer, Size) != 0) - { - ret = AUDIO_ERROR; - } - - /* Initiate a DMA transfer of PCM samples towards the serial audio interface */ - if(ret == AUDIO_OK) - { - if (HAL_SAI_Transmit_DMA(&haudio_out_sai, (uint8_t*) pBuffer, DMA_MAX(Size / AUDIODATA_SIZE))!= HAL_OK) - { - ret = AUDIO_ERROR; - } - } - - return ret; -} - -/** - * @brief Sends n-Bytes on the SAI interface. - * @param pData: pointer on PCM samples buffer - * @param Size: number of data to be written - */ -void BSP_AUDIO_OUT_ChangeBuffer(uint16_t *pData, uint16_t Size) -{ - HAL_SAI_Transmit_DMA(&haudio_out_sai, (uint8_t*) pData, Size); -} - -/** - * @brief This function Pauses the audio file stream. In case - * of using DMA, the DMA Pause feature is used. - * @warning When calling BSP_AUDIO_OUT_Pause() function for pause, only - * BSP_AUDIO_OUT_Resume() function should be called for resume (use of BSP_AUDIO_OUT_Play() - * function for resume could lead to unexpected behavior). - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_Pause(void) -{ - uint8_t ret = AUDIO_OK; - - /* Call the Audio Codec Pause/Resume function */ - if(audio_drv->Pause(AUDIO_I2C_ADDRESS) != 0) - { - ret = AUDIO_ERROR; - } - - /* Pause DMA transfer of PCM samples towards the serial audio interface */ - if(ret == AUDIO_OK) - { - if (HAL_SAI_DMAPause(&haudio_out_sai)!= HAL_OK) - { - ret = AUDIO_ERROR; - } - } - - /* Return AUDIO_OK when all operations are correctly done */ - return ret; -} - -/** - * @brief This function Resumes the audio file stream. - * @WARNING When calling BSP_AUDIO_OUT_Pause() function for pause, only - * BSP_AUDIO_OUT_Resume() function should be called for resume - * (use of BSP_AUDIO_OUT_Play() function for resume could lead to - * unexpected behavior). - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_Resume(void) -{ - uint8_t ret = AUDIO_OK; - - /* Call the Audio Codec Pause/Resume function */ - if(audio_drv->Resume(AUDIO_I2C_ADDRESS) != 0) - { - ret = AUDIO_ERROR; - } - - /* Resume DMA transfer of PCM samples towards the serial audio interface */ - if(ret == AUDIO_OK) - { - if (HAL_SAI_DMAResume(&haudio_out_sai)!= HAL_OK) - { - ret = AUDIO_ERROR; - } - } - - /* Return AUDIO_OK when all operations are correctly done */ - return ret; -} - -/** - * @brief Stops audio playing and Power down the Audio Codec. - * @param Option: could be one of the following parameters - * - CODEC_PDWN_SW: for software power off (by writing registers). - * Then no need to reconfigure the Codec after power on. - * - CODEC_PDWN_HW: completely shut down the codec (physically). - * Then need to reconfigure the Codec after power on. - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_Stop(uint32_t Option) -{ - uint8_t ret = AUDIO_OK; - - /* Call Audio Codec Stop function */ - if(audio_drv->Stop(AUDIO_I2C_ADDRESS, Option) != 0) - { - ret = AUDIO_ERROR; - } - - if(ret == AUDIO_OK) - { - if(Option == CODEC_PDWN_HW) - { - /* Wait at least 100us */ - HAL_Delay(2); - } - - /* Stop DMA transfer of PCM samples towards the serial audio interface */ - if (HAL_SAI_DMAStop(&haudio_out_sai)!= HAL_OK) - { - ret = AUDIO_ERROR; - } - } - /* Return AUDIO_OK when all operations are correctly done */ - return ret; -} - -/** - * @brief Controls the current audio volume level. - * @param Volume: Volume level to be set in percentage from 0% to 100% (0 for - * Mute and 100 for Max volume level). - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_SetVolume(uint8_t Volume) -{ - uint8_t ret = AUDIO_OK; - - /* Call the codec volume control function with converted volume value */ - if(audio_drv->SetVolume(AUDIO_I2C_ADDRESS, Volume) != 0) - { - ret = AUDIO_ERROR; - } - - /* Return AUDIO_OK when all operations are correctly done */ - return ret; -} - -/** - * @brief Enables or disables the MUTE mode by software - * @param Cmd: Could be AUDIO_MUTE_ON to mute sound or AUDIO_MUTE_OFF to - * unmute the codec and restore previous volume level. - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_SetMute(uint32_t Cmd) -{ - uint8_t ret = AUDIO_OK; - - /* Call the Codec Mute function */ - if(audio_drv->SetMute(AUDIO_I2C_ADDRESS, Cmd) != 0) - { - ret = AUDIO_ERROR; - } - - /* Return AUDIO_OK when all operations are correctly done */ - return ret; -} - -/** - * @brief Switch dynamically (while audio file is being played) the output - * target (speaker or headphone). - * @param Output: The audio output target: OUTPUT_DEVICE_SPEAKER, - * OUTPUT_DEVICE_HEADPHONE or OUTPUT_DEVICE_BOTH - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_SetOutputMode(uint8_t Output) -{ - uint8_t ret = AUDIO_OK; - - /* Call the Codec output device function */ - if(audio_drv->SetOutputMode(AUDIO_I2C_ADDRESS, Output) != 0) - { - ret = AUDIO_ERROR; - } - - /* Return AUDIO_OK when all operations are correctly done */ - return ret; -} - -/** - * @brief Updates the audio frequency. - * @param AudioFreq: Audio frequency used to play the audio stream. - * @note This API should be called after the BSP_AUDIO_OUT_Init() to adjust the - * audio frequency. - */ -void BSP_AUDIO_OUT_SetFrequency(uint32_t AudioFreq) -{ - /* PLL clock is set depending by the AudioFreq (44.1khz vs 48khz groups) */ - BSP_AUDIO_OUT_ClockConfig(&haudio_out_sai, AudioFreq, NULL); - - /* Disable SAI peripheral to allow access to SAI internal registers */ - __HAL_SAI_DISABLE(&haudio_out_sai); - - /* Update the SAI audio frequency configuration */ - haudio_out_sai.Init.AudioFrequency = AudioFreq; - HAL_SAI_Init(&haudio_out_sai); - - /* Enable SAI peripheral to generate MCLK */ - __HAL_SAI_ENABLE(&haudio_out_sai); -} - -/** - * @brief Changes the Audio Out Configuration. - * @param AudioOutOption: specifies the audio out new configuration - * This parameter can be any value of @ref BSP_Audio_Out_Option - * @note This API should be called after the BSP_AUDIO_OUT_Init() to adjust the - * audio out configuration. - * @retval None - */ -void BSP_AUDIO_OUT_ChangeAudioConfig(uint32_t AudioOutOption) -{ - /********** Playback Buffer circular/normal mode **********/ - if(AudioOutOption & BSP_AUDIO_OUT_CIRCULARMODE) - { - /* Deinitialize the Stream to update DMA mode */ - HAL_DMA_DeInit(haudio_out_sai.hdmatx); - - /* Update the SAI audio Transfer DMA mode */ - haudio_out_sai.hdmatx->Init.Mode = DMA_CIRCULAR; - - /* Configure the DMA Stream with new Transfer DMA mode */ - HAL_DMA_Init(haudio_out_sai.hdmatx); - } - else /* BSP_AUDIO_OUT_NORMALMODE */ - { - /* Deinitialize the Stream to update DMA mode */ - HAL_DMA_DeInit(haudio_out_sai.hdmatx); - - /* Update the SAI audio Transfer DMA mode */ - haudio_out_sai.hdmatx->Init.Mode = DMA_NORMAL; - - /* Configure the DMA Stream with new Transfer DMA mode */ - HAL_DMA_Init(haudio_out_sai.hdmatx); - } - - /********** Playback Buffer stereo/mono mode **********/ - if(AudioOutOption & BSP_AUDIO_OUT_STEREOMODE) - { - /* Disable SAI peripheral to allow access to SAI internal registers */ - __HAL_SAI_DISABLE(&haudio_out_sai); - - /* Update the SAI audio frame slot configuration */ - haudio_out_sai.Init.MonoStereoMode = SAI_STEREOMODE; - HAL_SAI_Init(&haudio_out_sai); - - /* Enable SAI peripheral to generate MCLK */ - __HAL_SAI_ENABLE(&haudio_out_sai); - } - else /* BSP_AUDIO_OUT_MONOMODE */ - { - /* Disable SAI peripheral to allow access to SAI internal registers */ - __HAL_SAI_DISABLE(&haudio_out_sai); - - /* Update the SAI audio frame slot configuration */ - haudio_out_sai.Init.MonoStereoMode = SAI_MONOMODE; - HAL_SAI_Init(&haudio_out_sai); - - /* Enable SAI peripheral to generate MCLK */ - __HAL_SAI_ENABLE(&haudio_out_sai); - } -} - -/** - * @brief Updates the Audio frame slot configuration. - * @param AudioFrameSlot: specifies the audio Frame slot - * This parameter can be any value of @ref CODEC_AudioFrame_SLOT_TDMMode - * @note This API should be called after the BSP_AUDIO_OUT_Init() to adjust the - * audio frame slot. - */ -void BSP_AUDIO_OUT_SetAudioFrameSlot(uint32_t AudioFrameSlot) -{ - /* Disable SAI peripheral to allow access to SAI internal registers */ - __HAL_SAI_DISABLE(&haudio_out_sai); - - /* Update the SAI audio frame slot configuration */ - haudio_out_sai.SlotInit.SlotActive = AudioFrameSlot; - HAL_SAI_Init(&haudio_out_sai); - - /* Enable SAI peripheral to generate MCLK */ - __HAL_SAI_ENABLE(&haudio_out_sai); -} - -/** - * @brief Deinit the audio peripherals. - */ -void BSP_AUDIO_OUT_DeInit(void) -{ - SAIx_DeInit(); - /* DeInit the SAI MSP : this __weak function can be rewritten by the applic */ - BSP_AUDIO_OUT_MspDeInit(&haudio_out_sai, NULL); - - /* Reset the audio output context */ - memset(&audio_drv, 0, sizeof(audio_drv)); -} - -/** - * @brief Tx Transfer completed callbacks. - * @param hsai: SAI handle - */ -void HAL_SAI_TxCpltCallback(SAI_HandleTypeDef *hsai) -{ - /* Manage the remaining file size and new address offset: This function - should be coded by user (its prototype is already declared in stm32469i_discovery_audio.h) */ - BSP_AUDIO_OUT_TransferComplete_CallBack(); -} - -/** - * @brief Tx Half Transfer completed callbacks. - * @param hsai: SAI handle - */ -void HAL_SAI_TxHalfCpltCallback(SAI_HandleTypeDef *hsai) -{ - /* Manage the remaining file size and new address offset: This function - should be coded by user (its prototype is already declared in stm32469i_discovery_audio.h) */ - BSP_AUDIO_OUT_HalfTransfer_CallBack(); -} - -/** - * @brief SAI error callbacks. - * @param hsai: SAI handle - */ -void HAL_SAI_ErrorCallback(SAI_HandleTypeDef *hsai) -{ - BSP_AUDIO_OUT_Error_CallBack(); -} - -/** - * @brief Manages the DMA full Transfer complete event. - */ -__weak void BSP_AUDIO_OUT_TransferComplete_CallBack(void) -{ -} - -/** - * @brief Manages the DMA Half Transfer complete event. - */ -__weak void BSP_AUDIO_OUT_HalfTransfer_CallBack(void) -{ -} - -/** - * @brief Manages the DMA FIFO error event. - */ -__weak void BSP_AUDIO_OUT_Error_CallBack(void) -{ -} - -/** - * @brief Initializes BSP_AUDIO_OUT MSP. - * @param hsai: SAI handle - * @param Params : pointer on additional configuration parameters, can be NULL. - */ -__weak void BSP_AUDIO_OUT_MspInit(SAI_HandleTypeDef *hsai, void *Params) -{ - static DMA_HandleTypeDef hdma_sai_tx; - GPIO_InitTypeDef gpio_init_structure; - - /* Put CS43L2 codec reset high -----------------------------------*/ - AUDIO_RESET_ENABLE(); - gpio_init_structure.Pin = AUDIO_RESET_PIN; - gpio_init_structure.Mode = GPIO_MODE_OUTPUT_PP; - gpio_init_structure.Pull = GPIO_NOPULL; - gpio_init_structure.Speed = GPIO_SPEED_HIGH; - HAL_GPIO_Init(AUDIO_RESET_GPIO_PORT, &gpio_init_structure); - HAL_GPIO_WritePin(AUDIO_RESET_GPIO_PORT, AUDIO_RESET_PIN, GPIO_PIN_SET); - - /* Enable SAI clock */ - AUDIO_SAIx_CLK_ENABLE(); - - /* Enable GPIO clock */ - AUDIO_SAIx_MCLK_ENABLE(); - AUDIO_SAIx_SCK_SD_FS_ENABLE(); - - /* CODEC_SAI pins configuration: MCK pin -----------------------------------*/ - gpio_init_structure.Pin = AUDIO_SAIx_MCK_PIN; - gpio_init_structure.Mode = GPIO_MODE_AF_PP; - gpio_init_structure.Pull = GPIO_NOPULL; - gpio_init_structure.Speed = GPIO_SPEED_HIGH; - gpio_init_structure.Alternate = AUDIO_SAIx_MCLK_SCK_SD_FS_AF; - HAL_GPIO_Init(AUDIO_SAIx_MCLK_GPIO_PORT, &gpio_init_structure); - - /* CODEC_SAI pins configuration: FS, SCK, MCK and SD pins ------------------*/ - gpio_init_structure.Pin = AUDIO_SAIx_FS_PIN | AUDIO_SAIx_SCK_PIN | AUDIO_SAIx_SD_PIN; - gpio_init_structure.Mode = GPIO_MODE_AF_PP; - gpio_init_structure.Pull = GPIO_NOPULL; - gpio_init_structure.Speed = GPIO_SPEED_HIGH; - gpio_init_structure.Alternate = AUDIO_SAIx_MCLK_SCK_SD_FS_AF; - HAL_GPIO_Init(AUDIO_SAIx_SCK_SD_FS_GPIO_PORT, &gpio_init_structure); - - /* Enable the DMA clock */ - AUDIO_SAIx_DMAx_CLK_ENABLE(); - - if(hsai->Instance == AUDIO_SAIx) - { - /* Configure the hdma_saiTx handle parameters */ - hdma_sai_tx.Init.Channel = AUDIO_SAIx_DMAx_CHANNEL; - hdma_sai_tx.Init.Direction = DMA_MEMORY_TO_PERIPH; - hdma_sai_tx.Init.PeriphInc = DMA_PINC_DISABLE; - hdma_sai_tx.Init.MemInc = DMA_MINC_ENABLE; - hdma_sai_tx.Init.PeriphDataAlignment = AUDIO_SAIx_DMAx_PERIPH_DATA_SIZE; - hdma_sai_tx.Init.MemDataAlignment = AUDIO_SAIx_DMAx_MEM_DATA_SIZE; - hdma_sai_tx.Init.Mode = DMA_CIRCULAR; - hdma_sai_tx.Init.Priority = DMA_PRIORITY_HIGH; - hdma_sai_tx.Init.FIFOMode = DMA_FIFOMODE_ENABLE; - hdma_sai_tx.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; - hdma_sai_tx.Init.MemBurst = DMA_MBURST_SINGLE; - hdma_sai_tx.Init.PeriphBurst = DMA_PBURST_SINGLE; - - hdma_sai_tx.Instance = AUDIO_SAIx_DMAx_STREAM; - - /* Associate the DMA handle */ - __HAL_LINKDMA(hsai, hdmatx, hdma_sai_tx); - - /* Deinitialize the Stream for new transfer */ - HAL_DMA_DeInit(&hdma_sai_tx); - - /* Configure the DMA Stream */ - HAL_DMA_Init(&hdma_sai_tx); - } - - /* SAI DMA IRQ Channel configuration */ - HAL_NVIC_SetPriority(AUDIO_SAIx_DMAx_IRQ, AUDIO_OUT_IRQ_PREPRIO, 0); - HAL_NVIC_EnableIRQ(AUDIO_SAIx_DMAx_IRQ); - -} -/** - * @brief Deinitializes BSP_AUDIO_OUT MSP. - * @param hsai: SAI handle - * @param Params : pointer on additional configuration parameters, can be NULL. - */ -__weak void BSP_AUDIO_OUT_MspDeInit(SAI_HandleTypeDef *hsai, void *Params) -{ - GPIO_InitTypeDef gpio_init_structure; - - /* SAI DMA IRQ Channel deactivation */ - HAL_NVIC_DisableIRQ(AUDIO_SAIx_DMAx_IRQ); - - if(hsai->Instance == AUDIO_SAIx) - { - /* Deinitialize the DMA stream */ - HAL_DMA_DeInit(hsai->hdmatx); - } - - /* Disable SAI peripheral */ - __HAL_SAI_DISABLE(hsai); - - /* Put CS43L2 codec reset low -----------------------------------*/ - HAL_GPIO_WritePin(AUDIO_RESET_GPIO_PORT, AUDIO_RESET_PIN, GPIO_PIN_RESET); - - /* Deactives CODEC_SAI pins FS, SCK, MCK and SD by putting them in input mode */ - gpio_init_structure.Pin = AUDIO_SAIx_MCK_PIN; - HAL_GPIO_DeInit(AUDIO_SAIx_MCLK_GPIO_PORT, gpio_init_structure.Pin); - - gpio_init_structure.Pin = AUDIO_SAIx_FS_PIN | AUDIO_SAIx_SCK_PIN | AUDIO_SAIx_SD_PIN; - HAL_GPIO_DeInit(AUDIO_SAIx_SCK_SD_FS_GPIO_PORT, gpio_init_structure.Pin); - - gpio_init_structure.Pin = AUDIO_RESET_PIN; - HAL_GPIO_DeInit(AUDIO_RESET_GPIO_PORT, gpio_init_structure.Pin); - - - /* Disable SAI clock */ - AUDIO_SAIx_CLK_DISABLE(); - - - /* GPIO pins clock and DMA clock can be shut down in the applic - by surcgarging this __weak function */ -} - -/** - * @brief Clock Config. - * @param hsai: might be required to set audio peripheral predivider if any. - * @param AudioFreq: Audio frequency used to play the audio stream. - * @note This API is called by BSP_AUDIO_OUT_Init() and BSP_AUDIO_OUT_SetFrequency() - * Being __weak it can be overwritten by the application - * @param Params : pointer on additional configuration parameters, can be NULL. - */ -__weak void BSP_AUDIO_OUT_ClockConfig(SAI_HandleTypeDef *hsai, uint32_t AudioFreq, void *Params) -{ - RCC_PeriphCLKInitTypeDef rcc_ex_clk_init_struct; - - HAL_RCCEx_GetPeriphCLKConfig(&rcc_ex_clk_init_struct); - - /* Set the PLL configuration according to the audio frequency */ - if((AudioFreq == AUDIO_FREQUENCY_11K) || (AudioFreq == AUDIO_FREQUENCY_22K) || (AudioFreq == AUDIO_FREQUENCY_44K)) - { - /* Configure PLLI2S prescalers */ - /* PLLI2S_VCO: VCO_429M - I2S_CLK(first level) = PLLI2S_VCO/PLLI2SQ = 429/2 = 214.5 Mhz - I2S_CLK_x = I2S_CLK(first level)/PLLI2SDIVQ = 214.5/19 = 11.289 Mhz */ - rcc_ex_clk_init_struct.PeriphClockSelection = RCC_PERIPHCLK_SAI_PLLI2S; - rcc_ex_clk_init_struct.PLLI2S.PLLI2SN = 429; - rcc_ex_clk_init_struct.PLLI2S.PLLI2SQ = 2; - rcc_ex_clk_init_struct.PLLI2SDivQ = 19; - - HAL_RCCEx_PeriphCLKConfig(&rcc_ex_clk_init_struct); - - } - else /* AUDIO_FREQUENCY_8K, AUDIO_FREQUENCY_16K, AUDIO_FREQUENCY_48K), AUDIO_FREQUENCY_96K */ - { - /* SAI clock config - PLLSAI_VCO: VCO_344M - I2S_CLK(first level) = PLLI2S_VCO/PLLI2SQ = 344/7 = 49.142 Mhz - I2S_CLK_x = SAI_CLK(first level)/PLLI2SDIVQ = 49.142/1 = 49.142 Mhz */ - rcc_ex_clk_init_struct.PeriphClockSelection = RCC_PERIPHCLK_SAI_PLLI2S; - rcc_ex_clk_init_struct.PLLI2S.PLLI2SN = 344; - rcc_ex_clk_init_struct.PLLI2S.PLLI2SQ = 7; - rcc_ex_clk_init_struct.PLLI2SDivQ = 1; - - HAL_RCCEx_PeriphCLKConfig(&rcc_ex_clk_init_struct); - } -} - -/******************************************************************************* - Static Functions -*******************************************************************************/ -/** - * @brief Initializes the Audio Codec audio interface (SAI). - * @param AudioFreq: Audio frequency to be configured for the SAI peripheral. - * @note The default SlotActive configuration is set to CODEC_AUDIOFRAME_SLOT_0123 - * and user can update this configuration using - */ -static uint8_t SAIx_Init(uint32_t AudioFreq) -{ - uint8_t ret = AUDIO_OK; - - /* Initialize the haudio_out_sai Instance parameter */ - haudio_out_sai.Instance = AUDIO_SAIx; - - /* Disable SAI peripheral to allow access to SAI internal registers */ - __HAL_SAI_DISABLE(&haudio_out_sai); - - /* Configure SAI_Block_x - LSBFirst: Disabled - DataSize: 16 */ - haudio_out_sai.Init.AudioFrequency = AudioFreq; - haudio_out_sai.Init.ClockSource = SAI_CLKSOURCE_PLLI2S; - haudio_out_sai.Init.AudioMode = SAI_MODEMASTER_TX; - haudio_out_sai.Init.NoDivider = SAI_MASTERDIVIDER_ENABLE; - haudio_out_sai.Init.Protocol = SAI_FREE_PROTOCOL; - haudio_out_sai.Init.DataSize = SAI_DATASIZE_16; - haudio_out_sai.Init.FirstBit = SAI_FIRSTBIT_MSB; - haudio_out_sai.Init.ClockStrobing = SAI_CLOCKSTROBING_RISINGEDGE; - haudio_out_sai.Init.Synchro = SAI_ASYNCHRONOUS; - haudio_out_sai.Init.OutputDrive = SAI_OUTPUTDRIVE_ENABLE; - haudio_out_sai.Init.FIFOThreshold = SAI_FIFOTHRESHOLD_1QF; -/* - haudio_out_sai.Init.AudioFrequency = SAI_AUDIO_FREQUENCY_MCKDIV; - haudio_out_sai.Init.SynchroExt = SAI_SYNCEXT_DISABLE; - haudio_out_sai.Init.Mckdiv = SAIClockDivider(AudioFreq); - haudio_out_sai.Init.MonoStereoMode = SAI_STEREOMODE; - haudio_out_sai.Init.CompandingMode = SAI_NOCOMPANDING; - haudio_out_sai.Init.TriState = SAI_OUTPUT_NOTRELEASED; -*/ - - /* Configure SAI_Block_x Frame - Frame Length: 64 - Frame active Length: 32 - FS Definition: Start frame + Channel Side identification - FS Polarity: FS active Low - FS Offset: FS asserted one bit before the first bit of slot 0 */ - haudio_out_sai.FrameInit.FrameLength = 64; - haudio_out_sai.FrameInit.ActiveFrameLength = 32; - haudio_out_sai.FrameInit.FSDefinition = SAI_FS_CHANNEL_IDENTIFICATION; - haudio_out_sai.FrameInit.FSPolarity = SAI_FS_ACTIVE_LOW; - haudio_out_sai.FrameInit.FSOffset = SAI_FS_BEFOREFIRSTBIT; - - /* Configure SAI Block_x Slot - Slot First Bit Offset: 0 - Slot Size : 16 - Slot Number: 4 - Slot Active: All slot actives */ - haudio_out_sai.SlotInit.FirstBitOffset = 0; - haudio_out_sai.SlotInit.SlotSize = SAI_SLOTSIZE_DATASIZE; - haudio_out_sai.SlotInit.SlotNumber = 4; - haudio_out_sai.SlotInit.SlotActive = CODEC_AUDIOFRAME_SLOT_0123; - - /* Initializes the SAI peripheral*/ - if (HAL_SAI_Init(&haudio_out_sai) != HAL_OK) - { - ret = AUDIO_ERROR; - } - - /* Enable SAI peripheral to generate MCLK */ - __HAL_SAI_ENABLE(&haudio_out_sai); - - return ret; - -} - -/** - * @brief Deinitializes the Audio Codec audio interface (SAI). - */ -static void SAIx_DeInit(void) -{ - /* Initialize the hAudioOutSai Instance parameter */ - haudio_out_sai.Instance = AUDIO_SAIx; - - /* Disable SAI peripheral */ - __HAL_SAI_DISABLE(&haudio_out_sai); - - HAL_SAI_DeInit(&haudio_out_sai); -} - -/** - * @brief Resets the audio codec. It restores the default configuration of the - * codec (this function shall be called before initializing the codec). - */ -static void AUDIO_CODEC_Reset(void) -{ - HAL_GPIO_WritePin(AUDIO_RESET_GPIO_PORT, AUDIO_RESET_PIN, GPIO_PIN_RESET); - - /* Wait for a delay to insure registers erasing */ - HAL_Delay(CODEC_RESET_DELAY); - - HAL_GPIO_WritePin(AUDIO_RESET_GPIO_PORT, AUDIO_RESET_PIN, GPIO_PIN_SET); - - /* Wait for a delay to insure registers erasing */ - HAL_Delay(CODEC_RESET_DELAY); -} - -/** - * @} - */ - -/** @defgroup STM32469I-Discovery_AUDIO_in_Private_Functions STM32469I Discovery AudioIn Private functions - * @{ - */ - -/** - * @brief Initializes wave recording. - * @note This function assumes that the I2S input clock (through PLL_R in - * Devices RevA/Z and through dedicated PLLI2S_R in Devices RevB/Y) - * is already configured and ready to be used. - * @param AudioFreq: Audio frequency to be configured for the I2S peripheral. - * @param BitRes: Audio frequency to be configured for the I2S peripheral. - * @param ChnlNbr: Audio frequency to be configured for the I2S peripheral. - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_IN_Init(uint32_t AudioFreq, uint32_t BitRes, uint32_t ChnlNbr) -{ - RCC_PeriphCLKInitTypeDef rcc_ex_clk_init_struct; - - I2Sx_DeInit(); - - HAL_RCCEx_GetPeriphCLKConfig(&rcc_ex_clk_init_struct); - rcc_ex_clk_init_struct.PeriphClockSelection = RCC_PERIPHCLK_I2S; - rcc_ex_clk_init_struct.PLLI2S.PLLI2SN = 384; - rcc_ex_clk_init_struct.PLLI2S.PLLI2SR = 2; - HAL_RCCEx_PeriphCLKConfig(&rcc_ex_clk_init_struct); - - /* Configure the PDM library */ - PDMDecoder_Init(AudioFreq, ChnlNbr); - - /* Configure the I2S peripheral */ - haudio_in_i2s.Instance = AUDIO_I2Sx; - if(HAL_I2S_GetState(&haudio_in_i2s) == HAL_I2S_STATE_RESET) - { - /* Initialize the I2S Msp: this __weak function can be rewritten by the application */ - BSP_AUDIO_IN_MspInit(&haudio_in_i2s, NULL); - } - - I2Sx_Init(AudioFreq); - - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; -} - -/** - * @brief Starts audio recording. - * @param pbuf: Main buffer pointer for the recorded data storing - * @param size: Current size of the recorded buffer - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_IN_Record(uint16_t* pbuf, uint32_t size) -{ - uint32_t ret = AUDIO_ERROR; - - /* Start the process receive DMA */ - HAL_I2S_Receive_DMA(&haudio_in_i2s, pbuf, size); - - /* Return AUDIO_OK when all operations are correctly done */ - ret = AUDIO_OK; - - return ret; -} - -/** - * @brief Stops audio recording. - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_IN_Stop(void) -{ - uint32_t ret = AUDIO_ERROR; - - /* Call the Media layer pause function */ - HAL_I2S_DMAPause(&haudio_in_i2s); - - /* TIMx Peripheral clock disable */ - AUDIO_TIMx_CLK_DISABLE(); - - /* Return AUDIO_OK when all operations are correctly done */ - ret = AUDIO_OK; - - return ret; -} - -/** - * @brief Pauses the audio file stream. - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_IN_Pause(void) -{ - /* Call the Media layer pause function */ - HAL_I2S_DMAPause(&haudio_in_i2s); - - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; -} - -/** - * @brief Resumes the audio file stream. - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_IN_Resume(void) -{ - /* Call the Media layer pause/resume function */ - HAL_I2S_DMAResume(&haudio_in_i2s); - - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; -} - -/** - * @brief Controls the audio in volume level. - * @param Volume: Volume level to be set in percentage from 0% to 100% (0 for - * Mute and 100 for Max volume level). - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_IN_SetVolume(uint8_t Volume) -{ - /* Set the Global variable AudioInVolume */ - AudioInVolume = Volume; - - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; -} - -/** - * @brief Deinit the audio IN peripherals. - */ -void BSP_AUDIO_IN_DeInit(void) -{ - I2Sx_DeInit(); - /* DeInit the I2S MSP : this __weak function can be rewritten by the applic */ - BSP_AUDIO_IN_MspDeInit(&haudio_in_i2s, NULL); - TIMx_DeInit(); -} - -/** - * @brief Converts audio format from PDM to PCM. - * @param PDMBuf: Pointer to data PDM buffer - * @param PCMBuf: Pointer to data PCM buffer - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_IN_PDMToPCM(uint16_t* PDMBuf, uint16_t* PCMBuf) -{ - uint8_t app_pdm[INTERNAL_BUFF_SIZE*2]; - uint8_t byte1 = 0, byte2 = 0; - uint32_t index = 0; - - /* PDM Demux */ - for(index = 0; index> 8)& 0xFF; - byte1 = (PDMBuf[index] & 0xFF); - app_pdm[(index*2)+1] = Channel_Demux[byte1 & CHANNEL_DEMUX_MASK] | Channel_Demux[byte2 & CHANNEL_DEMUX_MASK] << 4; - app_pdm[(index*2)] = Channel_Demux[(byte1 >> 1) & CHANNEL_DEMUX_MASK] | Channel_Demux[(byte2 >> 1) & CHANNEL_DEMUX_MASK] << 4; - } - - for(index = 0; index < DEFAULT_AUDIO_IN_CHANNEL_NBR; index++) - { - /* PDM to PCM filter */ - PDM_Filter_64_LSB((uint8_t*)&app_pdm[index], (uint16_t*)&(PCMBuf[index]), AudioInVolume , (PDMFilter_InitStruct *)&Filter[index]); - } - - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; -} - - /** - * @brief Rx Transfer completed callbacks. - * @param hi2s: I2S handle - */ -void HAL_I2S_RxCpltCallback(I2S_HandleTypeDef *hi2s) -{ - /* Call the record update function to get the next buffer to fill and its size (size is ignored) */ - BSP_AUDIO_IN_TransferComplete_CallBack(); -} - -/** - * @brief Rx Half Transfer completed callbacks. - * @param hi2s: I2S handle - */ -void HAL_I2S_RxHalfCpltCallback(I2S_HandleTypeDef *hi2s) -{ - /* Manage the remaining file size and new address offset: This function - should be coded by user (its prototype is already declared in stm32469i_discovery_audio.h) */ - BSP_AUDIO_IN_HalfTransfer_CallBack(); -} - -/** - * @brief I2S error callbacks. - * @param hi2s: I2S handle - */ -void HAL_I2S_ErrorCallback(I2S_HandleTypeDef *hi2s) -{ - /* Manage the error generated on DMA FIFO: This function - should be coded by user (its prototype is already declared in stm32469i_discovery_audio.h) */ - BSP_AUDIO_IN_Error_Callback(); -} - -/** - * @brief User callback when record buffer is filled. - */ -__weak void BSP_AUDIO_IN_TransferComplete_CallBack(void) -{ - /* This function should be implemented by the user application. - It is called into this driver when the current buffer is filled - to prepare the next buffer pointer and its size. */ -} - -/** - * @brief Manages the DMA Half Transfer complete event. - */ -__weak void BSP_AUDIO_IN_HalfTransfer_CallBack(void) -{ - /* This function should be implemented by the user application. - It is called into this driver when the current buffer is filled - to prepare the next buffer pointer and its size. */ -} - -/** - * @brief Audio IN Error callback function. - */ -__weak void BSP_AUDIO_IN_Error_Callback(void) -{ - /* This function is called when an Interrupt due to transfer error on or peripheral - error occurs. */ -} - -/** - * @brief BSP AUDIO IN MSP Init. - * @param hi2s: I2S handle - * @param Params : pointer on additional configuration parameters, can be NULL. - */ -__weak void BSP_AUDIO_IN_MspInit(I2S_HandleTypeDef *hi2s, void *Params) -{ - static DMA_HandleTypeDef hdma_i2s_rx; - GPIO_InitTypeDef gpio_init_structure; - - /* Configure the Timer which clocks the MEMS */ - /* Moved inside MSP to allow applic to redefine the TIMx_MspInit */ - TIMx_Init(); - - /* Enable I2S clock */ - AUDIO_I2Sx_CLK_ENABLE(); - - /* Enable SCK and SD GPIO clock */ - AUDIO_I2Sx_SD_GPIO_CLK_ENABLE(); - AUDIO_I2Sx_SCK_GPIO_CLK_ENABLE(); - /* CODEC_I2S pins configuration: SCK and SD pins */ - gpio_init_structure.Pin = AUDIO_I2Sx_SCK_PIN; - gpio_init_structure.Mode = GPIO_MODE_AF_PP; - gpio_init_structure.Pull = GPIO_NOPULL; - gpio_init_structure.Speed = GPIO_SPEED_FAST; - gpio_init_structure.Alternate = AUDIO_I2Sx_SCK_AF; - HAL_GPIO_Init(AUDIO_I2Sx_SCK_GPIO_PORT, &gpio_init_structure); - - gpio_init_structure.Pin = AUDIO_I2Sx_SD_PIN; - gpio_init_structure.Alternate = AUDIO_I2Sx_SD_AF; - HAL_GPIO_Init(AUDIO_I2Sx_SD_GPIO_PORT, &gpio_init_structure); - - /* Enable PD12 (I2S3_CLK) connected to PB3 via jamper JP4 */ - /* on Eval this was provided by PC6 (initialized in TIMx section) */ -/* - gpio_init_structure.Pin = GPIO_PIN_12; - gpio_init_structure.Mode = GPIO_MODE_AF_PP; - gpio_init_structure.Pull = GPIO_NOPULL; - gpio_init_structure.Speed = GPIO_SPEED_FAST; - gpio_init_structure.Alternate = AUDIO_I2Sx_SCK_AF; - HAL_GPIO_Init(GPIOD, &gpio_init_structure); */ - - - /* Enable the DMA clock */ - AUDIO_I2Sx_DMAx_CLK_ENABLE(); - - if(hi2s->Instance == AUDIO_I2Sx) - { - /* Configure the hdma_i2sRx handle parameters */ - hdma_i2s_rx.Init.Channel = AUDIO_I2Sx_DMAx_CHANNEL; - hdma_i2s_rx.Init.Direction = DMA_PERIPH_TO_MEMORY; - hdma_i2s_rx.Init.PeriphInc = DMA_PINC_DISABLE; - hdma_i2s_rx.Init.MemInc = DMA_MINC_ENABLE; - hdma_i2s_rx.Init.PeriphDataAlignment = AUDIO_I2Sx_DMAx_PERIPH_DATA_SIZE; - hdma_i2s_rx.Init.MemDataAlignment = AUDIO_I2Sx_DMAx_MEM_DATA_SIZE; - hdma_i2s_rx.Init.Mode = DMA_CIRCULAR; - hdma_i2s_rx.Init.Priority = DMA_PRIORITY_HIGH; - hdma_i2s_rx.Init.FIFOMode = DMA_FIFOMODE_DISABLE; - hdma_i2s_rx.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; - hdma_i2s_rx.Init.MemBurst = DMA_MBURST_SINGLE; - hdma_i2s_rx.Init.PeriphBurst = DMA_MBURST_SINGLE; - - hdma_i2s_rx.Instance = AUDIO_I2Sx_DMAx_STREAM; - - /* Associate the DMA handle */ - __HAL_LINKDMA(hi2s, hdmarx, hdma_i2s_rx); - - /* Deinitialize the Stream for new transfer */ - HAL_DMA_DeInit(&hdma_i2s_rx); - - /* Configure the DMA Stream */ - HAL_DMA_Init(&hdma_i2s_rx); - } - - /* I2S DMA IRQ Channel configuration */ - HAL_NVIC_SetPriority(AUDIO_I2Sx_DMAx_IRQ, AUDIO_IN_IRQ_PREPRIO, 0); - HAL_NVIC_EnableIRQ(AUDIO_I2Sx_DMAx_IRQ); -} - -/** - * @brief DeInitializes BSP_AUDIO_IN MSP. - * @param hi2s: I2S handle - * @param Params : pointer on additional configuration parameters, can be NULL. - */ -__weak void BSP_AUDIO_IN_MspDeInit(I2S_HandleTypeDef *hi2s, void *Params) -{ - GPIO_InitTypeDef gpio_init_structure; - - /* I2S DMA IRQ Channel deactivation */ - HAL_NVIC_DisableIRQ(AUDIO_I2Sx_DMAx_IRQ); - - if(hi2s->Instance == AUDIO_I2Sx) - { - /* Deinitialize the Stream for new transfer */ - HAL_DMA_DeInit(hi2s->hdmarx); - } - - /* Disable I2S block */ - __HAL_I2S_DISABLE(hi2s); - - /* Disable pins: SCK and SD pins */ - gpio_init_structure.Pin = AUDIO_I2Sx_SCK_PIN; - HAL_GPIO_DeInit(AUDIO_I2Sx_SCK_GPIO_PORT, gpio_init_structure.Pin); - gpio_init_structure.Pin = AUDIO_I2Sx_SD_PIN; - HAL_GPIO_DeInit(AUDIO_I2Sx_SD_GPIO_PORT, gpio_init_structure.Pin); - - /* Disable I2S clock */ - AUDIO_I2Sx_CLK_DISABLE(); - - /* GPIO pins clock and DMA clock can be shut down in the applic - by surcgarging this __weak function */ -} - -/******************************************************************************* - Static Functions -*******************************************************************************/ - -/** - * @brief Initializes the PDM library. - * @param AudioFreq: Audio sampling frequency - * @param ChnlNbr: Number of audio channels (1: mono; 2: stereo) - */ -static void PDMDecoder_Init(uint32_t AudioFreq, uint32_t ChnlNbr) -{ - uint32_t i = 0; - - /* Enable CRC peripheral to unlock the PDM library */ - __HAL_RCC_CRC_CLK_ENABLE(); - - for(i = 0; i < ChnlNbr; i++) - { - /* Filter LP & HP Init */ - Filter[i].LP_HZ = AudioFreq/2; - Filter[i].HP_HZ = 10; - Filter[i].Fs = AudioFreq; - Filter[i].Out_MicChannels = ChnlNbr; - Filter[i].In_MicChannels = ChnlNbr; - PDM_Filter_Init((PDMFilter_InitStruct *)&Filter[i]); - } -} - -/** - * @brief Initializes the Audio Codec audio interface (I2S) - * @note This function assumes that the I2S input clock (through dedicated PLLI2S_R) - * is already configured and ready to be used. - * @param AudioFreq: Audio frequency to be configured for the I2S peripheral. - */ -static void I2Sx_Init(uint32_t AudioFreq) -{ - /* Initialize the haudio_in_i2s Instance parameter */ - haudio_in_i2s.Instance = AUDIO_I2Sx; - - /* Disable I2S block */ - __HAL_I2S_DISABLE(&haudio_in_i2s); - - /* I2S2 peripheral configuration */ - haudio_in_i2s.Init.AudioFreq = 4 * AudioFreq; - haudio_in_i2s.Init.ClockSource = I2S_CLOCK_PLL; - haudio_in_i2s.Init.CPOL = I2S_CPOL_LOW; - haudio_in_i2s.Init.DataFormat = I2S_DATAFORMAT_16B; - haudio_in_i2s.Init.MCLKOutput = I2S_MCLKOUTPUT_DISABLE; - haudio_in_i2s.Init.Mode = I2S_MODE_MASTER_RX; - haudio_in_i2s.Init.Standard = I2S_STANDARD_LSB; - - /* Init the I2S */ - HAL_I2S_Init(&haudio_in_i2s); - - /* Disable I2S block */ - __HAL_I2S_ENABLE(&haudio_in_i2s); - -} - -/** - * @brief Deinitializes the Audio Codec audio interface (I2S). - */ -static void I2Sx_DeInit(void) -{ - /* Initialize the hAudioInI2s Instance parameter */ - haudio_in_i2s.Instance = AUDIO_I2Sx; - - /* Disable I2S block */ - __HAL_I2S_DISABLE(&haudio_in_i2s); - - /* DeInit the I2S */ - HAL_I2S_DeInit(&haudio_in_i2s); -} - - -/** - * @brief Initializes the TIM INput Capture MSP. - * @param htim: TIM handle - */ -static void TIMx_IC_MspInit(TIM_HandleTypeDef *htim) -{ - GPIO_InitTypeDef gpio_init_structure; - - /* Enable peripherals and GPIO Clocks --------------------------------------*/ - /* TIMx Peripheral clock enable */ - AUDIO_TIMx_CLK_ENABLE(); - - /* Enable GPIO Channels Clock */ - AUDIO_TIMx_GPIO_CLK_ENABLE(); - - /* Configure I/Os ----------------------------------------------------------*/ - /* Common configuration for all channels */ - gpio_init_structure.Mode = GPIO_MODE_AF_PP; - gpio_init_structure.Pull = GPIO_NOPULL; - gpio_init_structure.Speed = GPIO_SPEED_HIGH; - gpio_init_structure.Alternate = AUDIO_TIMx_AF; - - /* Configure TIM input channel */ - gpio_init_structure.Pin = AUDIO_TIMx_IN_GPIO_PIN; - HAL_GPIO_Init(AUDIO_TIMx_GPIO_PORT, &gpio_init_structure); - - /* Configure TIM output channel */ - gpio_init_structure.Pin = AUDIO_TIMx_OUT_GPIO_PIN; - HAL_GPIO_Init(AUDIO_TIMx_GPIO_PORT, &gpio_init_structure); -} - -/** - * @brief Initializes the TIM INput Capture MSP. - * @param htim: TIM handle - */ -static void TIMx_IC_MspDeInit(TIM_HandleTypeDef *htim) -{ - /* Disable TIMx Peripheral clock */ - AUDIO_TIMx_CLK_DISABLE(); - - /* GPIO pins clock and DMA clock can be shut down in the applic - by surcgarging this __weak function */ -} - -/** - * @brief Configure TIM as a clock divider by 2. - * I2S_SCK is externally connected to TIMx input channel - */ -static void TIMx_Init(void) -{ - TIM_IC_InitTypeDef s_ic_config; - TIM_OC_InitTypeDef s_oc_config; - TIM_ClockConfigTypeDef s_clk_source_config; - TIM_SlaveConfigTypeDef s_slave_config; - - /* Configure the TIM peripheral --------------------------------------------*/ - /* Set TIMx instance */ - haudio_tim.Instance = AUDIO_TIMx; - /* Timer Input Capture Configuration Structure declaration */ - /* Initialize TIMx peripheral as follow: - + Period = 0xFFFF - + Prescaler = 0 - + ClockDivision = 0 - + Counter direction = Up - */ - haudio_tim.Init.Period = 1; - haudio_tim.Init.Prescaler = 0; - haudio_tim.Init.ClockDivision = 0; - haudio_tim.Init.CounterMode = TIM_COUNTERMODE_UP; - - /* Initialize the TIMx peripheral with the structure above */ - TIMx_IC_MspInit(&haudio_tim); - HAL_TIM_IC_Init(&haudio_tim); - - /* Configure the Input Capture channel -------------------------------------*/ - /* Configure the Input Capture of channel 2 */ - s_ic_config.ICPolarity = TIM_ICPOLARITY_FALLING; - s_ic_config.ICSelection = TIM_ICSELECTION_DIRECTTI; - s_ic_config.ICPrescaler = TIM_ICPSC_DIV1; - s_ic_config.ICFilter = 0; - HAL_TIM_IC_ConfigChannel(&haudio_tim, &s_ic_config, AUDIO_TIMx_IN_CHANNEL); - - /* Select external clock mode 1 */ - s_clk_source_config.ClockSource = TIM_CLOCKSOURCE_ETRMODE1; - s_clk_source_config.ClockPolarity = TIM_CLOCKPOLARITY_NONINVERTED; - s_clk_source_config.ClockPrescaler = TIM_CLOCKPRESCALER_DIV1; - s_clk_source_config.ClockFilter = 0; - HAL_TIM_ConfigClockSource(&haudio_tim, &s_clk_source_config); - - /* Select Input Channel as input trigger */ - s_slave_config.InputTrigger = TIM_TS_TI1FP1; - s_slave_config.SlaveMode = TIM_SLAVEMODE_EXTERNAL1; - s_slave_config.TriggerPolarity = TIM_TRIGGERPOLARITY_NONINVERTED; - s_slave_config.TriggerPrescaler = TIM_CLOCKPRESCALER_DIV1; - s_slave_config.TriggerFilter = 0; - HAL_TIM_SlaveConfigSynchronization(&haudio_tim, &s_slave_config); - - /* Output Compare PWM Mode configuration: Channel2 */ - s_oc_config.OCMode = TIM_OCMODE_PWM1; - s_oc_config.OCIdleState = TIM_OCIDLESTATE_SET; - s_oc_config.Pulse = 1; - s_oc_config.OCPolarity = TIM_OCPOLARITY_HIGH; - s_oc_config.OCNPolarity = TIM_OCNPOLARITY_HIGH; - s_oc_config.OCFastMode = TIM_OCFAST_DISABLE; - s_oc_config.OCNIdleState = TIM_OCNIDLESTATE_SET; - - /* Initialize the TIM3 Channel2 with the structure above */ - HAL_TIM_PWM_ConfigChannel(&haudio_tim, &s_oc_config, AUDIO_TIMx_OUT_CHANNEL); - - /* Start the TIM3 Channel2 */ - HAL_TIM_PWM_Start(&haudio_tim, AUDIO_TIMx_OUT_CHANNEL); - - /* Start the TIM3 Channel1 */ - HAL_TIM_IC_Start(&haudio_tim, AUDIO_TIMx_IN_CHANNEL); -} - -/** - * @brief Configure TIM as a clock divider by 2. - * I2S_SCK is externally connected to TIMx input channel - */ -static void TIMx_DeInit(void) -{ - haudio_tim.Instance = AUDIO_TIMx; - - /* Stop the TIM3 Channel2 */ - HAL_TIM_PWM_Stop(&haudio_tim, AUDIO_TIMx_OUT_CHANNEL); - /* Stop the TIM3 Channel1 */ - HAL_TIM_IC_Stop(&haudio_tim, AUDIO_TIMx_IN_CHANNEL); - - HAL_TIM_IC_DeInit(&haudio_tim); - - /* Initialize the TIMx peripheral with the structure above */ - TIMx_IC_MspDeInit(&haudio_tim); -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32469I-Discovery/stm32469i_discovery_audio.h b/bsp/stm32f411RE/Libraries/BSP/STM32469I-Discovery/stm32469i_discovery_audio.h deleted file mode 100644 index a1839e313b..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32469I-Discovery/stm32469i_discovery_audio.h +++ /dev/null @@ -1,346 +0,0 @@ -/** - ****************************************************************************** - * @file stm32469i_discovery_audio.h - * @author MCD Application Team - * @version V1.0.1 - * @date 29-September-2015 - * @brief This file contains the common defines and functions prototypes for - * the stm32469i_discovery_audio.c driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32469I_DISCOVERY_AUDIO_H -#define __STM32469I_DISCOVERY_AUDIO_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#if defined(BSP_AUDIO_USE_RTOS) -#include "k_mem.h" -#else -#include -#endif - -/* Include audio component Driver */ -#include "../Components/cs43l22/cs43l22.h" -#include "stm32469i_discovery.h" -#include "../../../Middlewares/ST/STM32_Audio/Addons/PDM/pdm_filter.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32469I-Discovery - * @{ - */ - -/** @addtogroup STM32469I-Discovery_AUDIO - * @{ - */ - -/** @defgroup STM32469I-Discovery_AUDIO_Exported_Types STM32469I Discovery Audio Exported Types - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I-Discovery_AUDIO_Exported_Constants STM32469I Discovery Audio Exported Constants - * @{ - */ - -/** @defgroup BSP_Audio_Out_Option BSP Audio Out Option - * @{ - */ -#define BSP_AUDIO_OUT_CIRCULARMODE ((uint32_t)0x00000001) /* BUFFER CIRCULAR MODE */ -#define BSP_AUDIO_OUT_NORMALMODE ((uint32_t)0x00000002) /* BUFFER NORMAL MODE */ -#define BSP_AUDIO_OUT_STEREOMODE ((uint32_t)0x00000004) /* STEREO MODE */ -#define BSP_AUDIO_OUT_MONOMODE ((uint32_t)0x00000008) /* MONO MODE */ -/** - * @} - */ - -/*------------------------------------------------------------------------------ - USER SAI defines parameters - -----------------------------------------------------------------------------*/ -/** @defgroup CODEC_AudioFrame_SLOT_TDMMode STM32469I Discovery Audio Slot TDM mode - * @brief In W8994 codec the Audio frame contains 4 slots : TDM Mode - * TDM format : - * +------------------|------------------|--------------------|-------------------+ - * | CODEC_SLOT0 Left | CODEC_SLOT1 Left | CODEC_SLOT0 Right | CODEC_SLOT1 Right | - * +------------------------------------------------------------------------------+ - * @{ - */ -/* To have 2 separate audio stream in Both headphone and speaker the 4 slot must be activated */ -#define CODEC_AUDIOFRAME_SLOT_0123 SAI_SLOTACTIVE_0 | SAI_SLOTACTIVE_1 | SAI_SLOTACTIVE_2 | SAI_SLOTACTIVE_3 -/* To have an audio stream in headphone only SAI Slot 0 and Slot 2 must be activated */ -#define CODEC_AUDIOFRAME_SLOT_02 SAI_SLOTACTIVE_0 | SAI_SLOTACTIVE_2 -/* To have an audio stream in speaker only SAI Slot 1 and Slot 3 must be activated */ -#define CODEC_AUDIOFRAME_SLOT_13 SAI_SLOTACTIVE_1 | SAI_SLOTACTIVE_3 -/** - * @} - */ - -/* SAI peripheral configuration defines */ -#define AUDIO_SAIx SAI1_Block_A -#define AUDIO_SAIx_CLK_ENABLE() __HAL_RCC_SAI1_CLK_ENABLE() -#define AUDIO_SAIx_CLK_DISABLE() __HAL_RCC_SAI1_CLK_DISABLE() -#define AUDIO_SAIx_MCLK_SCK_SD_FS_AF GPIO_AF6_SAI1 - -#define AUDIO_SAIx_MCLK_ENABLE() __HAL_RCC_GPIOG_CLK_ENABLE() -#define AUDIO_SAIx_MCLK_DISABLE() __HAL_RCC_GPIOG_CLK_DISABLE() - -#define AUDIO_SAIx_MCK_PIN GPIO_PIN_7 -#define AUDIO_SAIx_MCLK_GPIO_PORT GPIOG - -#define AUDIO_SAIx_SCK_SD_FS_ENABLE() __HAL_RCC_GPIOE_CLK_ENABLE() -#define AUDIO_SAIx_SCK_SD_FS_DISABLE() __HAL_RCC_GPIOE_CLK_DISABLE() -#define AUDIO_SAIx_FS_PIN GPIO_PIN_4 -#define AUDIO_SAIx_SCK_PIN GPIO_PIN_5 -#define AUDIO_SAIx_SD_PIN GPIO_PIN_6 -#define AUDIO_SAIx_SCK_SD_FS_GPIO_PORT GPIOE - -#define AUDIO_RESET_ENABLE() __HAL_RCC_GPIOE_CLK_ENABLE() -#define AUDIO_RESET_DISABLE() __HAL_RCC_GPIOE_CLK_DISABLE() -#define AUDIO_RESET_PIN GPIO_PIN_2 -#define AUDIO_RESET_GPIO_PORT GPIOE - -/* SAI DMA Stream definitions */ -#define AUDIO_SAIx_DMAx_CLK_ENABLE() __HAL_RCC_DMA2_CLK_ENABLE() -#define AUDIO_SAIx_DMAx_CLK_DISABLE() __HAL_RCC_DMA2_CLK_DISABLE() -#define AUDIO_SAIx_DMAx_STREAM DMA2_Stream3 -#define AUDIO_SAIx_DMAx_CHANNEL DMA_CHANNEL_0 -#define AUDIO_SAIx_DMAx_IRQ DMA2_Stream3_IRQn -#define AUDIO_SAIx_DMAx_PERIPH_DATA_SIZE DMA_PDATAALIGN_HALFWORD -#define AUDIO_SAIx_DMAx_MEM_DATA_SIZE DMA_MDATAALIGN_HALFWORD -#define DMA_MAX_SZE 0xFFFF - -#define AUDIO_SAIx_DMAx_IRQHandler DMA2_Stream3_IRQHandler - -/* Select the interrupt preemption priority for the DMA interrupt */ -#define AUDIO_OUT_IRQ_PREPRIO 5 /* Select the preemption priority level(0 is the highest) */ - -/* Disable SAIx PLL */ -#define AUDIO_SAIx_PLL_DISABLE() HAL_RCCEx_DisablePLLSAI1() -/*------------------------------------------------------------------------------ - AUDIO IN CONFIGURATION -------------------------------------------------------------------------------*/ -/* SPI Configuration defines */ -#define AUDIO_I2Sx SPI3 -#define AUDIO_I2Sx_CLK_ENABLE() __HAL_RCC_SPI3_CLK_ENABLE() -#define AUDIO_I2Sx_CLK_DISABLE() __HAL_RCC_SPI3_CLK_DISABLE() -#define AUDIO_I2Sx_SCK_PIN GPIO_PIN_3 -#define AUDIO_I2Sx_SCK_GPIO_PORT GPIOB -#define AUDIO_I2Sx_SCK_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE() -#define AUDIO_I2Sx_SCK_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE() -#define AUDIO_I2Sx_SCK_AF GPIO_AF6_SPI3 - -#define AUDIO_I2Sx_SD_PIN GPIO_PIN_6 -#define AUDIO_I2Sx_SD_GPIO_PORT GPIOD -#define AUDIO_I2Sx_SD_GPIO_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE() -#define AUDIO_I2Sx_SD_GPIO_CLK_DISABLE() __HAL_RCC_GPIOD_CLK_DISABLE() -#define AUDIO_I2Sx_SD_AF GPIO_AF5_I2S3ext - -/* I2S DMA Stream Rx definitions */ -#define AUDIO_I2Sx_DMAx_CLK_ENABLE() __HAL_RCC_DMA1_CLK_ENABLE() -#define AUDIO_I2Sx_DMAx_CLK_DISABLE() __HAL_RCC_DMA1_CLK_DISABLE() -#define AUDIO_I2Sx_DMAx_STREAM DMA1_Stream2 -#define AUDIO_I2Sx_DMAx_CHANNEL DMA_CHANNEL_0 -#define AUDIO_I2Sx_DMAx_IRQ DMA1_Stream2_IRQn -#define AUDIO_I2Sx_DMAx_PERIPH_DATA_SIZE DMA_PDATAALIGN_HALFWORD -#define AUDIO_I2Sx_DMAx_MEM_DATA_SIZE DMA_MDATAALIGN_HALFWORD - -#define AUDIO_I2Sx_DMAx_IRQHandler DMA1_Stream2_IRQHandler - -/* Select the interrupt preemption priority and subpriority for the IT/DMA interrupt */ -#define AUDIO_IN_IRQ_PREPRIO ((uint32_t)6) /* Select the preemption priority level(0 is the highest) */ - - -/* Two channels are used: - - one channel as input which is connected to I2S SCK in stereo mode - - one channel as outupt which divides the frequency on the input -*/ - -#define AUDIO_TIMx_CLK_ENABLE() __HAL_RCC_TIM4_CLK_ENABLE() -#define AUDIO_TIMx_CLK_DISABLE() __HAL_RCC_TIM4_CLK_DISABLE() -#define AUDIO_TIMx TIM4 -#define AUDIO_TIMx_IN_CHANNEL TIM_CHANNEL_1 -#define AUDIO_TIMx_OUT_CHANNEL TIM_CHANNEL_2 /* Select channel 2 as output */ -#define AUDIO_TIMx_GPIO_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE() -#define AUDIO_TIMx_GPIO_CLK_DISABLE() __HAL_RCC_GPIOD_CLK_DISABLE() -#define AUDIO_TIMx_GPIO_PORT GPIOD -#define AUDIO_TIMx_IN_GPIO_PIN GPIO_PIN_12 -#define AUDIO_TIMx_OUT_GPIO_PIN GPIO_PIN_13 -#define AUDIO_TIMx_AF GPIO_AF2_TIM4 - -/*------------------------------------------------------------------------------ - CONFIGURATION: Audio Driver Configuration parameters -------------------------------------------------------------------------------*/ - -#define AUDIODATA_SIZE 2 /* 16-bits audio data size */ - -/* Audio status definition */ -#define AUDIO_OK ((uint8_t)0) -#define AUDIO_ERROR ((uint8_t)1) -#define AUDIO_TIMEOUT ((uint8_t)2) - -/* AudioFreq * DataSize (2 bytes) * NumChannels (Stereo: 2) */ -#define DEFAULT_AUDIO_IN_FREQ I2S_AUDIOFREQ_16K -#define DEFAULT_AUDIO_IN_BIT_RESOLUTION ((uint8_t)16) -#define DEFAULT_AUDIO_IN_CHANNEL_NBR ((uint8_t)2) /* Mono = 1, Stereo = 2 */ -#define DEFAULT_AUDIO_IN_VOLUME ((uint16_t)64) - -/* PDM buffer input size */ -#define INTERNAL_BUFF_SIZE (128*DEFAULT_AUDIO_IN_FREQ/16000*DEFAULT_AUDIO_IN_CHANNEL_NBR) -/* PCM buffer output size */ -#define PCM_OUT_SIZE (DEFAULT_AUDIO_IN_FREQ/1000*DEFAULT_AUDIO_IN_CHANNEL_NBR) -#define CHANNEL_DEMUX_MASK ((uint8_t)0x55) - -/*------------------------------------------------------------------------------ - OPTIONAL Configuration defines parameters -------------------------------------------------------------------------------*/ - -/* Delay for the Codec to be correctly reset */ -#define CODEC_RESET_DELAY ((uint8_t)5) - -/*------------------------------------------------------------------------------ - OUTPUT DEVICES definition -------------------------------------------------------------------------------*/ - -/** - * @} - */ - -/** @defgroup STM32469I-Discovery_AUDIO_Exported_Variables STM32469I-Discovery AUDIO Exported Variables - * @{ - */ -extern __IO uint16_t AudioInVolume; - /** - * @} - */ - -/** @defgroup STM32469I-Discovery_AUDIO_Exported_Macros STM32469I-Discovery AUDIO Exported Macros - * @{ - */ -#define DMA_MAX(x) (((x) <= DMA_MAX_SZE)? (x):DMA_MAX_SZE) -/** - * @} - */ - -/** @defgroup STM32469I-Discovery_AUDIO_OUT_Exported_Functions STM32469I Discovery AudioOUT Exported Functions - * @{ - */ -uint8_t BSP_AUDIO_OUT_Init(uint16_t OutputDevice, uint8_t Volume, uint32_t AudioFreq); -uint8_t BSP_AUDIO_OUT_Play(uint16_t* pBuffer, uint32_t Size); -void BSP_AUDIO_OUT_ChangeBuffer(uint16_t *pData, uint16_t Size); -uint8_t BSP_AUDIO_OUT_Pause(void); -uint8_t BSP_AUDIO_OUT_Resume(void); -uint8_t BSP_AUDIO_OUT_Stop(uint32_t Option); -uint8_t BSP_AUDIO_OUT_SetVolume(uint8_t Volume); -void BSP_AUDIO_OUT_SetFrequency(uint32_t AudioFreq); -void BSP_AUDIO_OUT_SetAudioFrameSlot(uint32_t AudioFrameSlot); -uint8_t BSP_AUDIO_OUT_SetMute(uint32_t Cmd); -uint8_t BSP_AUDIO_OUT_SetOutputMode(uint8_t Output); -void BSP_AUDIO_OUT_DeInit(void); - -/* User Callbacks: user has to implement these functions in his code if they are needed. */ -/* This function is called when the requested data has been completely transferred.*/ -void BSP_AUDIO_OUT_TransferComplete_CallBack(void); - -/* This function is called when half of the requested buffer has been transferred. */ -void BSP_AUDIO_OUT_HalfTransfer_CallBack(void); - -/* This function is called when an Interrupt due to transfer error on or peripheral - error occurs. */ -void BSP_AUDIO_OUT_Error_CallBack(void); - -/* These function can be modified in case the current settings (e.g. DMA stream) - need to be changed for specific application needs */ -void BSP_AUDIO_OUT_ClockConfig(SAI_HandleTypeDef *hsai, uint32_t AudioFreq, void *Params); -void BSP_AUDIO_OUT_MspInit(SAI_HandleTypeDef *hsai, void *Params); -void BSP_AUDIO_OUT_MspDeInit(SAI_HandleTypeDef *hsai, void *Params); - -/** - * @} - */ - -/** @defgroup STM32469I-Discovery_AUDIO_IN_Exported_Functions STM32469I Discovery AudioIN Exported Functions - * @{ - */ -uint8_t BSP_AUDIO_IN_Init(uint32_t AudioFreq, uint32_t BitRes, uint32_t ChnlNbr); -uint8_t BSP_AUDIO_IN_Record(uint16_t *pData, uint32_t Size); -uint8_t BSP_AUDIO_IN_Stop(void); -uint8_t BSP_AUDIO_IN_Pause(void); -uint8_t BSP_AUDIO_IN_Resume(void); -uint8_t BSP_AUDIO_IN_SetVolume(uint8_t Volume); -void BSP_AUDIO_IN_DeInit(void); -uint8_t BSP_AUDIO_IN_PDMToPCM(uint16_t* PDMBuf, uint16_t* PCMBuf); -/* User Callbacks: user has to implement these functions in his code if they are needed. */ -/* This function should be implemented by the user application. - It is called into this driver when the current buffer is filled to prepare the next - buffer pointer and its size. */ -void BSP_AUDIO_IN_TransferComplete_CallBack(void); -void BSP_AUDIO_IN_HalfTransfer_CallBack(void); - -/* This function is called when an Interrupt due to transfer error on or peripheral - error occurs. */ -void BSP_AUDIO_IN_Error_Callback(void); - -/* These function can be modified in case the current settings (e.g. DMA stream) - need to be changed for specific application needs */ -void BSP_AUDIO_IN_MspInit(I2S_HandleTypeDef *hi2s, void *Params); -void BSP_AUDIO_IN_MspDeInit(I2S_HandleTypeDef *hi2s, void *Params); - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32469I_DISCOVERY_AUDIO_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32469I-Discovery/stm32469i_discovery_eeprom.c b/bsp/stm32f411RE/Libraries/BSP/STM32469I-Discovery/stm32469i_discovery_eeprom.c deleted file mode 100644 index d48d0c3bf8..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32469I-Discovery/stm32469i_discovery_eeprom.c +++ /dev/null @@ -1,474 +0,0 @@ -/** - ****************************************************************************** - * @file stm32469i_discovery_eeprom.c - * @author MCD Application Team - * @version V1.0.1 - * @date 29-September-2015 - * @brief This file provides a set of functions needed to manage an I2C M24LR64 - * EEPROM memory. - * To be able to use this driver, the switch EE_M24LR64 must be defined - * in your toolchain compiler preprocessor - * - * =================================================================== - * Notes: - * - This driver is intended for STM32F4xx families devices only. - * - The I2C EEPROM memory (M24LR64) is available on separate daughter - * board ANT7-M24LR-A, which is not provided with the STM32469I-Discovery - * board. - * To use this driver you have to connect the ANT7-M24LR-A to CN11 - * connector of STM32469I-Discovery board. - * =================================================================== - * - * It implements a high level communication layer for read and write - * from/to this memory. The needed STM32F4xx hardware resources (I2C and - * GPIO) are defined in stm32469i_discovery.h file, and the initialization is - * performed in EEPROM_IO_Init() function declared in stm32469i_discovery.c - * file. - * You can easily tailor this driver to any other development board, - * by just adapting the defines for hardware resources and - * EEPROM_IO_Init() function. - * - * @note In this driver, basic read and write functions (BSP_EEPROM_ReadBuffer() - * and BSP_EEPROM_WritePage()) use DMA mode to perform the data - * transfer to/from EEPROM memory. - * - * @note Regarding BSP_EEPROM_WritePage(), it is a optimized function to perform - * small write (less than 1 page) BUT The number of bytes (combined to write start address) must not - * cross the EEPROM page boundary. This function can only write into - * the boundaries of an EEPROM page. - * This function doesn't check on boundaries condition (in this driver - * the function BSP_EEPROM_WriteBuffer() which calls BSP_EEPROM_WritePage() is - * responsible of checking on Page boundaries). - * - * - * +-----------------------------------------------------------------+ - * | Pin assignment for M24LR64 EEPROM | - * +---------------------------------------+-----------+-------------+ - * | STM32F4xx I2C Pins | EEPROM | Pin | - * +---------------------------------------+-----------+-------------+ - * | . | E0(GND) | 1 (0V) | - * | . | AC0 | 2 | - * | . | AC1 | 3 | - * | . | VSS | 4 (0V) | - * | SDA | SDA | 5 | - * | SCL | SCL | 6 | - * | . | E1(GND) | 7 (0V) | - * | . | VDD | 8 (3.3V) | - * +---------------------------------------+-----------+-------------+ - * - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ -/* Includes ------------------------------------------------------------------*/ -#include "stm32469i_discovery_eeprom.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32469I-Discovery - * @{ - */ - -/** @addtogroup STM32469I-Discovery_EEPROM - * @brief This file includes the I2C EEPROM driver of STM32469I-Discovery board. - * @{ - */ - -/** @defgroup STM32469I-Discovery_EEPROM_Private_Types STM32469I Discovery Eeprom Private Types - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I-Discovery_EEPROM_Private_Defines STM32469I Discovery Eeprom Private Defines - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I-Discovery_EEPROM_Private_Macros STM32469I Discovery Eeprom Private Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I-Discovery_EEPROM_Private_Variables STM32469I Discovery Eeprom Private Variables - * @{ - */ -__IO uint16_t EEPROMAddress = 0; -__IO uint32_t EEPROMTimeout = EEPROM_READ_TIMEOUT; -__IO uint16_t EEPROMDataRead; -__IO uint8_t EEPROMDataWrite; -/** - * @} - */ - -/** @defgroup STM32469I-Discovery_EEPROM_Private_Function_Prototypes STM32469I Discovery Eeprom Private Prototypes - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I-Discovery_EEPROM_Private_Functions STM32469I Discovery Eeprom Private Functions - * @{ - */ - -/** - * @brief Initializes peripherals used by the I2C EEPROM driver. - * - * @note There are 2 different versions of M24LR64 (A01 & A02). - * Then try to connect on 1st one (EEPROM_I2C_ADDRESS_A01) - * and if problem, check the 2nd one (EEPROM_I2C_ADDRESS_A02) - * @retval EEPROM_OK (0) if operation is correctly performed, else return value - * different from EEPROM_OK (0) - */ -uint32_t BSP_EEPROM_Init(void) -{ - /* I2C Initialization */ - EEPROM_IO_Init(); - - /* Select the EEPROM address for A01 and check if OK */ - EEPROMAddress = EEPROM_I2C_ADDRESS_A01; - if(EEPROM_IO_IsDeviceReady(EEPROMAddress, EEPROM_MAX_TRIALS) != HAL_OK) - { - /* Select the EEPROM address for A02 and check if OK */ - EEPROMAddress = EEPROM_I2C_ADDRESS_A02; - if(EEPROM_IO_IsDeviceReady(EEPROMAddress, EEPROM_MAX_TRIALS) != HAL_OK) - { - return EEPROM_FAIL; - } - } - return EEPROM_OK; -} - -/** - * @brief DeInitializes the EEPROM. - * @retval EEPROM state - */ -uint8_t BSP_EEPROM_DeInit(void) -{ - /* I2C won't be disabled because common to other functionalities */ - return EEPROM_OK; -} - -/** - * @brief Reads a block of data from the EEPROM. - * @param pBuffer: pointer to the buffer that receives the data read from - * the EEPROM. - * @param ReadAddr: EEPROM's internal address to start reading from. - * @param NumByteToRead: pointer to the variable holding number of bytes to - * be read from the EEPROM. - * - * @note The variable pointed by NumByteToRead is reset to 0 when all the - * data are read from the EEPROM. Application should monitor this - * variable in order know when the transfer is complete. - * - * @retval EEPROM_OK (0) if operation is correctly performed, else return value - * different from EEPROM_OK (0) or the timeout user callback. - */ -uint32_t BSP_EEPROM_ReadBuffer(uint8_t* pBuffer, uint16_t ReadAddr, uint16_t* NumByteToRead) -{ - uint32_t buffersize = *NumByteToRead; - - /* Set the pointer to the Number of data to be read. This pointer will be used - by the DMA Transfer Completer interrupt Handler in order to reset the - variable to 0. User should check on this variable in order to know if the - DMA transfer has been complete or not. */ - EEPROMDataRead = *NumByteToRead; - - if(EEPROM_IO_ReadData(EEPROMAddress, ReadAddr, pBuffer, buffersize) != HAL_OK) - { - BSP_EEPROM_TIMEOUT_UserCallback(); - return EEPROM_FAIL; - } - - /* If all operations OK, return EEPROM_OK (0) */ - return EEPROM_OK; -} - -/** - * @brief Writes more than one byte to the EEPROM with a single WRITE cycle. - * - * @note The number of bytes (combined to write start address) must not - * cross the EEPROM page boundary. This function can only write into - * the boundaries of an EEPROM page. - * This function doesn't check on boundaries condition (in this driver - * the function BSP_EEPROM_WriteBuffer() which calls BSP_EEPROM_WritePage() is - * responsible of checking on Page boundaries). - * - * @param pBuffer: pointer to the buffer containing the data to be written to - * the EEPROM. - * @param WriteAddr: EEPROM's internal address to write to. - * @param NumByteToWrite: pointer to the variable holding number of bytes to - * be written into the EEPROM. - * - * @note The variable pointed by NumByteToWrite is reset to 0 when all the - * data are written to the EEPROM. Application should monitor this - * variable in order know when the transfer is complete. - * - * @note This function just configure the communication and enable the DMA - * channel to transfer data. Meanwhile, the user application may perform - * other tasks in parallel. - * - * @retval EEPROM_OK (0) if operation is correctly performed, else return value - * different from EEPROM_OK (0) or the timeout user callback. - */ -uint32_t BSP_EEPROM_WritePage(uint8_t* pBuffer, uint16_t WriteAddr, uint8_t* NumByteToWrite) -{ - uint32_t buffersize = *NumByteToWrite; - uint32_t status = EEPROM_OK; - - /* Set the pointer to the Number of data to be written. This pointer will be used - by the DMA Transfer Completer interrupt Handler in order to reset the - variable to 0. User should check on this variable in order to know if the - DMA transfer has been complete or not. */ - EEPROMDataWrite = *NumByteToWrite; - - if(EEPROM_IO_WriteData(EEPROMAddress, WriteAddr, pBuffer, buffersize) != HAL_OK) - { - BSP_EEPROM_TIMEOUT_UserCallback(); - status = EEPROM_FAIL; - } - - if(BSP_EEPROM_WaitEepromStandbyState() != EEPROM_OK) - { - return EEPROM_FAIL; - } - - /* If all operations OK, return EEPROM_OK (0) */ - return status; -} - -/** - * @brief Writes buffer of data to the I2C EEPROM. - * @param pBuffer: pointer to the buffer containing the data to be written - * to the EEPROM. - * @param WriteAddr: EEPROM's internal address to write to. - * @param NumByteToWrite: number of bytes to write to the EEPROM. - * @retval EEPROM_OK (0) if operation is correctly performed, else return value - * different from EEPROM_OK (0) or the timeout user callback. - */ -uint32_t BSP_EEPROM_WriteBuffer(uint8_t *pBuffer, uint16_t WriteAddr, uint16_t NumByteToWrite) -{ - uint16_t numofpage = 0, numofsingle = 0, count = 0; - uint16_t addr = 0; - uint8_t dataindex = 0; - uint32_t status = EEPROM_OK; - - addr = WriteAddr % EEPROM_PAGESIZE; - count = EEPROM_PAGESIZE - addr; - numofpage = NumByteToWrite / EEPROM_PAGESIZE; - numofsingle = NumByteToWrite % EEPROM_PAGESIZE; - - /* If WriteAddr is EEPROM_PAGESIZE aligned */ - if(addr == 0) - { - /* If NumByteToWrite < EEPROM_PAGESIZE */ - if(numofpage == 0) - { - /* Store the number of data to be written */ - dataindex = numofsingle; - /* Start writing data */ - status = BSP_EEPROM_WritePage(pBuffer, WriteAddr, (uint8_t*)(&dataindex)); - if(status != EEPROM_OK) - { - return status; - } - } - /* If NumByteToWrite > EEPROM_PAGESIZE */ - else - { - while(numofpage--) - { - /* Store the number of data to be written */ - dataindex = EEPROM_PAGESIZE; - status = BSP_EEPROM_WritePage(pBuffer, WriteAddr, (uint8_t*)(&dataindex)); - if(status != EEPROM_OK) - { - return status; - } - - WriteAddr += EEPROM_PAGESIZE; - pBuffer += EEPROM_PAGESIZE; - } - - if(numofsingle!=0) - { - /* Store the number of data to be written */ - dataindex = numofsingle; - status = BSP_EEPROM_WritePage(pBuffer, WriteAddr, (uint8_t*)(&dataindex)); - if(status != EEPROM_OK) - { - return status; - } - } - } - } - /* If WriteAddr is not EEPROM_PAGESIZE aligned */ - else - { - /* If NumByteToWrite < EEPROM_PAGESIZE */ - if(numofpage== 0) - { - /* If the number of data to be written is more than the remaining space - in the current page: */ - if(NumByteToWrite > count) - { - /* Store the number of data to be written */ - dataindex = count; - /* Write the data contained in same page */ - status = BSP_EEPROM_WritePage(pBuffer, WriteAddr, (uint8_t*)(&dataindex)); - if(status != EEPROM_OK) - { - return status; - } - - /* Store the number of data to be written */ - dataindex = (NumByteToWrite - count); - /* Write the remaining data in the following page */ - status = BSP_EEPROM_WritePage((uint8_t*)(pBuffer + count), (WriteAddr + count), (uint8_t*)(&dataindex)); - if(status != EEPROM_OK) - { - return status; - } - } - else - { - /* Store the number of data to be written */ - dataindex = numofsingle; - status = BSP_EEPROM_WritePage(pBuffer, WriteAddr, (uint8_t*)(&dataindex)); - if(status != EEPROM_OK) - { - return status; - } - } - } - /* If NumByteToWrite > EEPROM_PAGESIZE */ - else - { - NumByteToWrite -= count; - numofpage = NumByteToWrite / EEPROM_PAGESIZE; - numofsingle = NumByteToWrite % EEPROM_PAGESIZE; - - if(count != 0) - { - /* Store the number of data to be written */ - dataindex = count; - status = BSP_EEPROM_WritePage(pBuffer, WriteAddr, (uint8_t*)(&dataindex)); - if(status != EEPROM_OK) - { - return status; - } - WriteAddr += count; - pBuffer += count; - } - - while(numofpage--) - { - /* Store the number of data to be written */ - dataindex = EEPROM_PAGESIZE; - status = BSP_EEPROM_WritePage(pBuffer, WriteAddr, (uint8_t*)(&dataindex)); - if(status != EEPROM_OK) - { - return status; - } - WriteAddr += EEPROM_PAGESIZE; - pBuffer += EEPROM_PAGESIZE; - } - if(numofsingle != 0) - { - /* Store the number of data to be written */ - dataindex = numofsingle; - status = BSP_EEPROM_WritePage(pBuffer, WriteAddr, (uint8_t*)(&dataindex)); - if(status != EEPROM_OK) - { - return status; - } - } - } - } - - /* If all operations OK, return EEPROM_OK (0) */ - return EEPROM_OK; -} - -/** - * @brief Wait for EEPROM Standby state. - * - * @note This function allows to wait and check that EEPROM has finished the - * last operation. It is mostly used after Write operation: after receiving - * the buffer to be written, the EEPROM may need additional time to actually - * perform the write operation. During this time, it doesn't answer to - * I2C packets addressed to it. Once the write operation is complete - * the EEPROM responds to its address. - * - * @retval EEPROM_OK (0) if operation is correctly performed, else return value - * different from EEPROM_OK (0) or the timeout user callback. - */ -uint32_t BSP_EEPROM_WaitEepromStandbyState(void) -{ - /* Check if the maximum allowed number of trials has bee reached */ - if(EEPROM_IO_IsDeviceReady(EEPROMAddress, EEPROM_MAX_TRIALS) != HAL_OK) - { - /* If the maximum number of trials has been reached, exit the function */ - BSP_EEPROM_TIMEOUT_UserCallback(); - return EEPROM_TIMEOUT; - } - return EEPROM_OK; -} - -/** - * @brief Basic management of the timeout situation. - */ -__weak void BSP_EEPROM_TIMEOUT_UserCallback(void) -{ -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32469I-Discovery/stm32469i_discovery_eeprom.h b/bsp/stm32f411RE/Libraries/BSP/STM32469I-Discovery/stm32469i_discovery_eeprom.h deleted file mode 100644 index 18d0162f75..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32469I-Discovery/stm32469i_discovery_eeprom.h +++ /dev/null @@ -1,146 +0,0 @@ -/** - ****************************************************************************** - * @file stm32469i_discovery_eeprom.h - * @author MCD Application Team - * @version V1.0.1 - * @date 29-September-2015 - * @brief This file contains all the functions prototypes for - * the stm32469i_discovery_eeprom.c firmware driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32F469I_DISCOVERY_EEPROM_H -#define __STM32F469I_DISCOVERY_EEPROM_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm32469i_discovery.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32469I-Discovery - * @{ - */ - -/** @addtogroup STM32469I-Discovery_EEPROM - * @brief This file includes the I2C EEPROM driver of STM32469I-Discovery board. - * @{ - */ - -/** @defgroup STM32469I-Discovery_EEPROM_Exported_Types STM32469I Discovery EEPROM Exported Types - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I-Discovery_EEPROM_Exported_Constants STM32469I-Discovery EEPROM Exported Constants - * @{ - */ -/* EEPROM hardware address and page size */ -#define EEPROM_PAGESIZE ((uint8_t)4) -#define EEPROM_MAX_SIZE ((uint16_t)0x2000) /* 64Kbit */ - -/* Maximum Timeout values for flags and events waiting loops. -This timeout is based on systick set to 1ms*/ -/* Timeout for read based if read all the EEPROM : EEPROM_MAX_SIZE * I2C_SPEED (640ms) */ -#define EEPROM_READ_TIMEOUT ((uint32_t)(1000)) -/* Timeout for write based on max write which is EEPROM_PAGESIZE bytes: EEPROM_PAGESIZE * I2C_SPEED (320us) */ -#define EEPROM_WRITE_TIMEOUT ((uint32_t)(10)) - -/* Maximum number of trials for EEPROM_WaitEepromStandbyState() function */ -#define EEPROM_MAX_TRIALS 3000 - -#define EEPROM_OK 0 -#define EEPROM_FAIL 1 -#define EEPROM_TIMEOUT 2 -/** - * @} - */ - -/** @defgroup STM32469I-Discovery_EEPROM_Exported_Macros STM32469I-Discovery EEPROM Exported Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I-Discovery_EEPROM_Exported_Functions STM32469I-Discovery_EEPROM Exported Functions - * @{ - */ -uint32_t BSP_EEPROM_Init(void); -uint8_t BSP_EEPROM_DeInit(void); -uint32_t BSP_EEPROM_ReadBuffer(uint8_t* pBuffer, uint16_t ReadAddr, uint16_t* NumByteToRead); -uint32_t BSP_EEPROM_WritePage(uint8_t* pBuffer, uint16_t WriteAddr, uint8_t* NumByteToWrite); -uint32_t BSP_EEPROM_WriteBuffer(uint8_t* pBuffer, uint16_t WriteAddr, uint16_t NumByteToWrite); -uint32_t BSP_EEPROM_WaitEepromStandbyState(void); - -/* USER Callbacks: This function is declared as __weak in EEPROM driver and - should be implemented into user application. - BSP_EEPROM_TIMEOUT_UserCallback() function is called whenever a timeout condition - occure during communication (waiting on an event that doesn't occur, bus - errors, busy devices ...). */ -void BSP_EEPROM_TIMEOUT_UserCallback(void); - -/* Link function for I2C EEPROM peripheral */ -void EEPROM_IO_Init(void); -HAL_StatusTypeDef EEPROM_IO_WriteData(uint16_t DevAddress, uint16_t MemAddress, uint8_t *pBuffer, uint32_t BufferSize); -HAL_StatusTypeDef EEPROM_IO_ReadData(uint16_t DevAddress, uint16_t MemAddress, uint8_t *pBuffer, uint32_t BufferSize); -HAL_StatusTypeDef EEPROM_IO_IsDeviceReady(uint16_t DevAddress, uint32_t Trials); - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32F469I_DISCOVERY_EEPROM_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32469I-Discovery/stm32469i_discovery_lcd.c b/bsp/stm32f411RE/Libraries/BSP/STM32469I-Discovery/stm32469i_discovery_lcd.c deleted file mode 100644 index 5266ea95e5..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32469I-Discovery/stm32469i_discovery_lcd.c +++ /dev/null @@ -1,1647 +0,0 @@ -/** - ****************************************************************************** - * @file stm32469i_discovery_lcd.c - * @author MCD Application Team - * @version V1.0.1 - * @date 29-September-2015 - * @brief This file includes the driver for Liquid Crystal Display (LCD) module - * mounted on STM32469I-Discovery evaluation board. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* File Info: ------------------------------------------------------------------ - User NOTES -1. How To use this driver: --------------------------- - - This driver is used to drive directly in video mode a LCD TFT using the DSI interface. - The following IPs are implied : DSI Host IP block working - in conjunction to the LTDC controller. - - This driver is linked by construction to LCD KoD mounted on board MB1166. - -2. Driver description: ---------------------- - + Initialization steps: - o Initialize the LCD using the BSP_LCD_Init() function. - o Select the LCD layer to be used using the BSP_LCD_SelectLayer() function. - o Enable the LCD display using the BSP_LCD_DisplayOn() function. - - + Options - o Configure and enable the color keying functionality using the - BSP_LCD_SetColorKeying() function. - o Modify in the fly the transparency and/or the frame buffer address - using the following functions: - - BSP_LCD_SetTransparency() - - BSP_LCD_SetLayerAddress() - - + Display on LCD - o Clear the whole LCD using BSP_LCD_Clear() function or only one specified string - line using the BSP_LCD_ClearStringLine() function. - o Display a character on the specified line and column using the BSP_LCD_DisplayChar() - function or a complete string line using the BSP_LCD_DisplayStringAtLine() function. - o Display a string line on the specified position (x,y in pixel) and align mode - using the BSP_LCD_DisplayStringAtLine() function. - o Draw and fill a basic shapes (dot, line, rectangle, circle, ellipse, .. bitmap) - on LCD using the available set of functions. - -------------------------------------------------------------------------------*/ - -/* Includes ------------------------------------------------------------------*/ -#include "stm32469i_discovery_lcd.h" -#include "../../../Utilities/Fonts/fonts.h" -#include "../../../Utilities/Fonts/font24.c" -#include "../../../Utilities/Fonts/font20.c" -#include "../../../Utilities/Fonts/font16.c" -#include "../../../Utilities/Fonts/font12.c" -#include "../../../Utilities/Fonts/font8.c" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32469I-Discovery - * @{ - */ - -/** @addtogroup STM32469I-Discovery_LCD - * @{ - */ - -/** @defgroup STM32469I-Discovery_LCD_Private_TypesDefinitions LCD Private TypesDefinitions - * @{ - */ -static DSI_VidCfgTypeDef hdsivideo_handle; - -/** - * @} - */ - -/** @defgroup STM32469I-Discovery_LCD_Private_Defines LCD Private Defines - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I-Discovery_LCD_Private_Macros LCD Private Macros - * @{ - */ -#define ABS(X) ((X) > 0 ? (X) : -(X)) - -#define POLY_X(Z) ((int32_t)((Points + (Z))->X)) -#define POLY_Y(Z) ((int32_t)((Points + (Z))->Y)) -/** - * @} - */ - -/** @defgroup STM32469I-Discovery_LCD_Exported_Variables STM32469I Discovery LCD Exported Variables - * @{ - */ - -/** - * @} - */ - - -/** @defgroup STM32469I-Discovery_LCD_Private_Variables LCD Private Variables - * @{ - */ - -DMA2D_HandleTypeDef hdma2d_eval; -LTDC_HandleTypeDef hltdc_eval; -DSI_HandleTypeDef hdsi_eval; -uint32_t lcd_x_size = OTM8009A_800X480_WIDTH; -uint32_t lcd_y_size = OTM8009A_800X480_HEIGHT; - -/** - * @} - */ - - -/** @defgroup STM32469I-Discovery_LCD_Private_Variables LCD Private Variables - * @{ - */ - -/** - * @brief Default Active LTDC Layer in which drawing is made is LTDC Layer Background - */ -static uint32_t ActiveLayer = LTDC_ACTIVE_LAYER_BACKGROUND; - -/** - * @brief Current Drawing Layer properties variable - */ -static LCD_DrawPropTypeDef DrawProp[LTDC_MAX_LAYER_NUMBER]; -/** - * @} - */ - -/** @defgroup STM32469I-Discovery_LCD_Private_FunctionPrototypes LCD Private FunctionPrototypes - * @{ - */ -static void DrawChar(uint16_t Xpos, uint16_t Ypos, const uint8_t *c); -static void FillTriangle(uint16_t x1, uint16_t x2, uint16_t x3, uint16_t y1, uint16_t y2, uint16_t y3); -static void LL_FillBuffer(uint32_t LayerIndex, void *pDst, uint32_t xSize, uint32_t ySize, uint32_t OffLine, uint32_t ColorIndex); -static void LL_ConvertLineToARGB8888(void * pSrc, void *pDst, uint32_t xSize, uint32_t ColorMode); -/** - * @} - */ - -/** @defgroup STM32469I-Discovery_LCD_Exported_Functions LCD Exported Functions - * @{ - */ - -/** - * @brief Initializes the DSI LCD. - * @param None - * @retval LCD state - */ -uint8_t BSP_LCD_Init(void) -{ - return (BSP_LCD_InitEx(LCD_ORIENTATION_LANDSCAPE)); -} - -/** - * @brief Initializes the DSI LCD. - * The ititialization is done as below: - * - DSI PLL ititialization - * - DSI ititialization - * - LTDC ititialization - * - OTM8009A LCD Display IC Driver ititialization - * @param None - * @retval LCD state - */ -uint8_t BSP_LCD_InitEx(LCD_OrientationTypeDef orientation) -{ - DSI_PLLInitTypeDef dsiPllInit; - static RCC_PeriphCLKInitTypeDef PeriphClkInitStruct; - uint32_t LcdClock = 27429; /*!< LcdClk = 27429 kHz */ - uint32_t Clockratio = 0; - uint32_t laneByteClk_kHz = 0; - uint32_t VSA; /*!< Vertical start active time in units of lines */ - uint32_t VBP; /*!< Vertical Back Porch time in units of lines */ - uint32_t VFP; /*!< Vertical Front Porch time in units of lines */ - uint32_t VACT; /*!< Vertical Active time in units of lines = imageSize Y in pixels to display */ - uint32_t HSA; /*!< Horizontal start active time in units of lcdClk */ - uint32_t HBP; /*!< Horizontal Back Porch time in units of lcdClk */ - uint32_t HFP; /*!< Horizontal Front Porch time in units of lcdClk */ - uint32_t HACT; /*!< Horizontal Active time in units of lcdClk = imageSize X in pixels to display */ - - - /* Toggle Hardware Reset of the DSI LCD using - * its XRES signal (active low) */ - BSP_LCD_Reset(); - - /* Call first MSP Initialize only in case of first initialization - * This will set IP blocks LTDC, DSI and DMA2D - * - out of reset - * - clocked - * - NVIC IRQ related to IP blocks enabled - */ - BSP_LCD_MspInit(); - -/*************************DSI Initialization***********************************/ - - /* Base address of DSI Host/Wrapper registers to be set before calling De-Init */ - hdsi_eval.Instance = DSI; - - HAL_DSI_DeInit(&(hdsi_eval)); - -#if !defined(USE_STM32469I_DISCO_REVA) - dsiPllInit.PLLNDIV = 125; - dsiPllInit.PLLIDF = DSI_PLL_IN_DIV2; - dsiPllInit.PLLODF = DSI_PLL_OUT_DIV1; -#else - dsiPllInit.PLLNDIV = 100; - dsiPllInit.PLLIDF = DSI_PLL_IN_DIV5; - dsiPllInit.PLLODF = DSI_PLL_OUT_DIV1; -#endif - laneByteClk_kHz = 62500; /* 500 MHz / 8 = 62.5 MHz = 62500 kHz */ - - /* Set number of Lanes */ - hdsi_eval.Init.NumberOfLanes = DSI_TWO_DATA_LANES; - - /* TXEscapeCkdiv = f(LaneByteClk)/15.62 = 4 */ - hdsi_eval.Init.TXEscapeCkdiv = laneByteClk_kHz/15620; - - HAL_DSI_Init(&(hdsi_eval), &(dsiPllInit)); - Clockratio = laneByteClk_kHz/LcdClock; - /* Timing parameters for all Video modes - * Set Timing parameters of LTDC depending on its chosen orientation - */ - if(orientation == LCD_ORIENTATION_PORTRAIT) - { - VSA = OTM8009A_480X800_VSYNC; /* 12 */ - VBP = OTM8009A_480X800_VBP; /* 12 */ - VFP = OTM8009A_480X800_VFP; /* 12 */ - HSA = OTM8009A_480X800_HSYNC; /* 120 */ - HBP = OTM8009A_480X800_HBP; /* 120 */ - HFP = OTM8009A_480X800_HFP; /* 120 */ - lcd_x_size = OTM8009A_480X800_WIDTH; /* 480 */ - lcd_y_size = OTM8009A_480X800_HEIGHT; /* 800 */ - } - else - { - /* lcd_orientation == LCD_ORIENTATION_LANDSCAPE */ - VSA = OTM8009A_800X480_VSYNC; /* 12 */ - VBP = OTM8009A_800X480_VBP; /* 12 */ - VFP = OTM8009A_800X480_VFP; /* 12 */ - HSA = OTM8009A_800X480_HSYNC; /* 120 */ - HBP = OTM8009A_800X480_HBP; /* 120 */ - HFP = OTM8009A_800X480_HFP; /* 120 */ - lcd_x_size = OTM8009A_800X480_WIDTH; /* 800 */ - lcd_y_size = OTM8009A_800X480_HEIGHT; /* 480 */ - } - - HACT = lcd_x_size; - VACT = lcd_y_size; - - - hdsivideo_handle.VirtualChannelID = LCD_OTM8009A_ID; - hdsivideo_handle.ColorCoding = LCD_DSI_PIXEL_DATA_FMT_RBG888; - hdsivideo_handle.VSPolarity = DSI_VSYNC_ACTIVE_HIGH; - hdsivideo_handle.HSPolarity = DSI_HSYNC_ACTIVE_HIGH; - hdsivideo_handle.DEPolarity = DSI_DATA_ENABLE_ACTIVE_HIGH; - hdsivideo_handle.Mode = DSI_VID_MODE_BURST; /* Mode Video burst ie : one LgP per line */ - hdsivideo_handle.NullPacketSize = 0xFFF; - hdsivideo_handle.NumberOfChunks = 0; - hdsivideo_handle.PacketSize = HACT; /* Value depending on display orientation choice portrait/landscape */ - hdsivideo_handle.HorizontalSyncActive = HSA*Clockratio; - hdsivideo_handle.HorizontalBackPorch = HBP*Clockratio; - hdsivideo_handle.HorizontalLine = (HACT + HSA + HBP + HFP)*Clockratio; /* Value depending on display orientation choice portrait/landscape */ - hdsivideo_handle.VerticalSyncActive = VSA; - hdsivideo_handle.VerticalBackPorch = VBP; - hdsivideo_handle.VerticalFrontPorch = VFP; - hdsivideo_handle.VerticalActive = VACT; /* Value depending on display orientation choice portrait/landscape */ - - /* Enable or disable sending LP command while streaming is active in video mode */ - hdsivideo_handle.LPCommandEnable = DSI_LP_COMMAND_ENABLE; /* Enable sending commands in mode LP (Low Power) */ - - /* Largest packet size possible to transmit in LP mode in VSA, VBP, VFP regions */ - /* Only useful when sending LP packets is allowed while streaming is active in video mode */ - hdsivideo_handle.LPLargestPacketSize = 64; - - /* Largest packet size possible to transmit in LP mode in HFP region during VACT period */ - /* Only useful when sending LP packets is allowed while streaming is active in video mode */ - hdsivideo_handle.LPVACTLargestPacketSize = 64; - - - /* Specify for each region of the video frame, if the transmission of command in LP mode is allowed in this region */ - /* while streaming is active in video mode */ - hdsivideo_handle.LPHorizontalFrontPorchEnable = DSI_LP_HFP_ENABLE; /* Allow sending LP commands during HFP period */ - hdsivideo_handle.LPHorizontalBackPorchEnable = DSI_LP_HBP_ENABLE; /* Allow sending LP commands during HBP period */ - hdsivideo_handle.LPVerticalActiveEnable = DSI_LP_VACT_ENABLE; /* Allow sending LP commands during VACT period */ - hdsivideo_handle.LPVerticalFrontPorchEnable = DSI_LP_VFP_ENABLE; /* Allow sending LP commands during VFP period */ - hdsivideo_handle.LPVerticalBackPorchEnable = DSI_LP_VBP_ENABLE; /* Allow sending LP commands during VBP period */ - hdsivideo_handle.LPVerticalSyncActiveEnable = DSI_LP_VSYNC_ENABLE; /* Allow sending LP commands during VSync = VSA period */ - - /* Configure DSI Video mode timings with settings set above */ - HAL_DSI_ConfigVideoMode(&(hdsi_eval), &(hdsivideo_handle)); - - /* Enable the DSI host and wrapper : but LTDC is not started yet at this stage */ - HAL_DSI_Start(&(hdsi_eval)); -/*************************End DSI Initialization*******************************/ - - -/************************LTDC Initialization***********************************/ - - /* Timing Configuration */ - hltdc_eval.Init.HorizontalSync = (HSA - 1); - hltdc_eval.Init.AccumulatedHBP = (HSA + HBP - 1); - hltdc_eval.Init.AccumulatedActiveW = (lcd_x_size + HSA + HBP - 1); - hltdc_eval.Init.TotalWidth = (lcd_x_size + HSA + HBP + HFP - 1); - - /* Initialize the LCD pixel width and pixel height */ - hltdc_eval.LayerCfg->ImageWidth = lcd_x_size; - hltdc_eval.LayerCfg->ImageHeight = lcd_y_size; - - - /* LCD clock configuration */ - /* PLLSAI_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */ - /* PLLSAI_VCO Output = PLLSAI_VCO Input * PLLSAIN = 384 Mhz */ - /* PLLLCDCLK = PLLSAI_VCO Output/PLLSAIR = 384 MHz / 7 = 54.857 MHz */ - /* LTDC clock frequency = PLLLCDCLK / LTDC_PLLSAI_DIVR_2 = 54.857 MHz / 2 = 27.429 MHz */ - PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC; - PeriphClkInitStruct.PLLSAI.PLLSAIN = 384; - PeriphClkInitStruct.PLLSAI.PLLSAIR = 7; - PeriphClkInitStruct.PLLSAIDivR = RCC_PLLSAIDIVR_2; - HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct); - - /* Background value */ - hltdc_eval.Init.Backcolor.Blue = 0; - hltdc_eval.Init.Backcolor.Green = 0; - hltdc_eval.Init.Backcolor.Red = 0; - hltdc_eval.Init.PCPolarity = LTDC_PCPOLARITY_IPC; - hltdc_eval.Instance = LTDC; - - /* Get LTDC Configuration from DSI Configuration */ - HAL_LTDC_StructInitFromVideoConfig(&(hltdc_eval), &(hdsivideo_handle)); - - /* Initialize the LTDC */ - HAL_LTDC_Init(&hltdc_eval); - -#if !defined(DATA_IN_ExtSDRAM) - /* Initialize the SDRAM */ - BSP_SDRAM_Init(); -#endif /* DATA_IN_ExtSDRAM */ - - /* Initialize the font */ - BSP_LCD_SetFont(&LCD_DEFAULT_FONT); - -/************************End LTDC Initialization*******************************/ - - -/***********************OTM8009A Initialization********************************/ - - /* Initialize the OTM8009A LCD Display IC Driver (KoD LCD IC Driver) - * depending on configuration set in 'hdsivideo_handle'. - */ - OTM8009A_Init(hdsivideo_handle.ColorCoding, orientation); - -/***********************End OTM8009A Initialization****************************/ - - return LCD_OK; -} - -/** - * @brief BSP LCD Reset - * Hw reset the LCD DSI activating its XRES signal (active low for some time) - * and desactivating it later. - * This signal is only cabled on Discovery Rev B and beyond. - */ -void BSP_LCD_Reset(void) -{ -#if !defined(USE_STM32469I_DISCO_REVA) -/* EVAL Rev B and beyond : reset the LCD by activation of XRES (active low) connected to PH7 */ - GPIO_InitTypeDef gpio_init_structure; - - __HAL_RCC_GPIOH_CLK_ENABLE(); - - /* Configure the GPIO on PH7 */ - gpio_init_structure.Pin = GPIO_PIN_7; - gpio_init_structure.Mode = GPIO_MODE_OUTPUT_OD; - gpio_init_structure.Pull = GPIO_NOPULL; - gpio_init_structure.Speed = GPIO_SPEED_HIGH; - - HAL_GPIO_Init(GPIOH, &gpio_init_structure); - - /* Activate XRES active low */ - HAL_GPIO_WritePin(GPIOH, GPIO_PIN_7, GPIO_PIN_RESET); - - HAL_Delay(20); /* wait 20 ms */ - - /* Desactivate XRES */ - HAL_GPIO_WritePin(GPIOH, GPIO_PIN_7, GPIO_PIN_SET); - - /* Wait for 10ms after releasing XRES before sending commands */ - HAL_Delay(10); -#else - -#endif /* USE_STM32469I_DISCO_REVA == 0 */ -} - -/** - * @brief Gets the LCD X size. - * @retval Used LCD X size - */ -uint32_t BSP_LCD_GetXSize(void) -{ - return (lcd_x_size); -} - -/** - * @brief Gets the LCD Y size. - * @retval Used LCD Y size - */ -uint32_t BSP_LCD_GetYSize(void) -{ - return (lcd_y_size); -} - -/** - * @brief Set the LCD X size. - * @param imageWidthPixels : uint32_t image width in pixels unit - * @retval None - */ -void BSP_LCD_SetXSize(uint32_t imageWidthPixels) -{ - hltdc_eval.LayerCfg[ActiveLayer].ImageWidth = imageWidthPixels; -} - -/** - * @brief Set the LCD Y size. - * @param imageHeightPixels : uint32_t image height in lines unit - */ -void BSP_LCD_SetYSize(uint32_t imageHeightPixels) -{ - hltdc_eval.LayerCfg[ActiveLayer].ImageHeight = imageHeightPixels; -} - - -/** - * @brief Initializes the LCD layers. - * @param LayerIndex: Layer foreground or background - * @param FB_Address: Layer frame buffer - * @retval None - */ -void BSP_LCD_LayerDefaultInit(uint16_t LayerIndex, uint32_t FB_Address) -{ - LCD_LayerCfgTypeDef Layercfg; - - /* Layer Init */ - Layercfg.WindowX0 = 0; - Layercfg.WindowX1 = BSP_LCD_GetXSize(); - Layercfg.WindowY0 = 0; - Layercfg.WindowY1 = BSP_LCD_GetYSize(); - Layercfg.PixelFormat = LTDC_PIXEL_FORMAT_ARGB8888; - Layercfg.FBStartAdress = FB_Address; - Layercfg.Alpha = 255; - Layercfg.Alpha0 = 0; - Layercfg.Backcolor.Blue = 0; - Layercfg.Backcolor.Green = 0; - Layercfg.Backcolor.Red = 0; - Layercfg.BlendingFactor1 = LTDC_BLENDING_FACTOR1_PAxCA; - Layercfg.BlendingFactor2 = LTDC_BLENDING_FACTOR2_PAxCA; - Layercfg.ImageWidth = BSP_LCD_GetXSize(); - Layercfg.ImageHeight = BSP_LCD_GetYSize(); - - HAL_LTDC_ConfigLayer(&hltdc_eval, &Layercfg, LayerIndex); - - DrawProp[LayerIndex].BackColor = LCD_COLOR_WHITE; - DrawProp[LayerIndex].pFont = &Font24; - DrawProp[LayerIndex].TextColor = LCD_COLOR_BLACK; -} - - -/** - * @brief Selects the LCD Layer. - * @param LayerIndex: Layer foreground or background - */ -void BSP_LCD_SelectLayer(uint32_t LayerIndex) -{ - ActiveLayer = LayerIndex; -} - -/** - * @brief Sets an LCD Layer visible - * @param LayerIndex: Visible Layer - * @param State: New state of the specified layer - * This parameter can be one of the following values: - * @arg ENABLE - * @arg DISABLE - */ -void BSP_LCD_SetLayerVisible(uint32_t LayerIndex, FunctionalState State) -{ - if(State == ENABLE) - { - __HAL_LTDC_LAYER_ENABLE(&(hltdc_eval), LayerIndex); - } - else - { - __HAL_LTDC_LAYER_DISABLE(&(hltdc_eval), LayerIndex); - } - __HAL_LTDC_RELOAD_CONFIG(&(hltdc_eval)); - -} - -/** - * @brief Configures the transparency. - * @param LayerIndex: Layer foreground or background. - * @param Transparency: Transparency - * This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFF - */ -void BSP_LCD_SetTransparency(uint32_t LayerIndex, uint8_t Transparency) -{ - - HAL_LTDC_SetAlpha(&(hltdc_eval), Transparency, LayerIndex); - -} - -/** - * @brief Sets an LCD layer frame buffer address. - * @param LayerIndex: Layer foreground or background - * @param Address: New LCD frame buffer value - */ -void BSP_LCD_SetLayerAddress(uint32_t LayerIndex, uint32_t Address) -{ - - HAL_LTDC_SetAddress(&(hltdc_eval), Address, LayerIndex); - -} - -/** - * @brief Sets display window. - * @param LayerIndex: Layer index - * @param Xpos: LCD X position - * @param Ypos: LCD Y position - * @param Width: LCD window width - * @param Height: LCD window height - */ -void BSP_LCD_SetLayerWindow(uint16_t LayerIndex, uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height) -{ - /* Reconfigure the layer size */ - HAL_LTDC_SetWindowSize(&(hltdc_eval), Width, Height, LayerIndex); - - /* Reconfigure the layer position */ - HAL_LTDC_SetWindowPosition(&(hltdc_eval), Xpos, Ypos, LayerIndex); - -} - -/** - * @brief Configures and sets the color keying. - * @param LayerIndex: Layer foreground or background - * @param RGBValue: Color reference - */ -void BSP_LCD_SetColorKeying(uint32_t LayerIndex, uint32_t RGBValue) -{ - /* Configure and Enable the color Keying for LCD Layer */ - HAL_LTDC_ConfigColorKeying(&(hltdc_eval), RGBValue, LayerIndex); - HAL_LTDC_EnableColorKeying(&(hltdc_eval), LayerIndex); -} - -/** - * @brief Disables the color keying. - * @param LayerIndex: Layer foreground or background - */ -void BSP_LCD_ResetColorKeying(uint32_t LayerIndex) -{ - /* Disable the color Keying for LCD Layer */ - HAL_LTDC_DisableColorKeying(&(hltdc_eval), LayerIndex); -} - -/** - * @brief Sets the LCD text color. - * @param Color: Text color code ARGB(8-8-8-8) - */ -void BSP_LCD_SetTextColor(uint32_t Color) -{ - DrawProp[ActiveLayer].TextColor = Color; -} - -/** - * @brief Gets the LCD text color. - * @retval Used text color. - */ -uint32_t BSP_LCD_GetTextColor(void) -{ - return DrawProp[ActiveLayer].TextColor; -} - -/** - * @brief Sets the LCD background color. - * @param Color: Layer background color code ARGB(8-8-8-8) - */ -void BSP_LCD_SetBackColor(uint32_t Color) -{ - DrawProp[ActiveLayer].BackColor = Color; -} - -/** - * @brief Gets the LCD background color. - * @retval Used background color - */ -uint32_t BSP_LCD_GetBackColor(void) -{ - return DrawProp[ActiveLayer].BackColor; -} - -/** - * @brief Sets the LCD text font. - * @param fonts: Layer font to be used - */ -void BSP_LCD_SetFont(sFONT *fonts) -{ - DrawProp[ActiveLayer].pFont = fonts; -} - -/** - * @brief Gets the LCD text font. - * @retval Used layer font - */ -sFONT *BSP_LCD_GetFont(void) -{ - return DrawProp[ActiveLayer].pFont; -} - -/** - * @brief Reads an LCD pixel. - * @param Xpos: X position - * @param Ypos: Y position - * @retval RGB pixel color - */ -uint32_t BSP_LCD_ReadPixel(uint16_t Xpos, uint16_t Ypos) -{ - uint32_t ret = 0; - - if(hltdc_eval.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_ARGB8888) - { - /* Read data value from SDRAM memory */ - ret = *(__IO uint32_t*) (hltdc_eval.LayerCfg[ActiveLayer].FBStartAdress + (2*(Ypos*BSP_LCD_GetXSize() + Xpos))); - } - else if(hltdc_eval.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_RGB888) - { - /* Read data value from SDRAM memory */ - ret = (*(__IO uint32_t*) (hltdc_eval.LayerCfg[ActiveLayer].FBStartAdress + (2*(Ypos*BSP_LCD_GetXSize() + Xpos))) & 0x00FFFFFF); - } - else if((hltdc_eval.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_RGB565) || \ - (hltdc_eval.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_ARGB4444) || \ - (hltdc_eval.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_AL88)) - { - /* Read data value from SDRAM memory */ - ret = *(__IO uint16_t*) (hltdc_eval.LayerCfg[ActiveLayer].FBStartAdress + (2*(Ypos*BSP_LCD_GetXSize() + Xpos))); - } - else - { - /* Read data value from SDRAM memory */ - ret = *(__IO uint8_t*) (hltdc_eval.LayerCfg[ActiveLayer].FBStartAdress + (2*(Ypos*BSP_LCD_GetXSize() + Xpos))); - } - - return ret; -} - -/** - * @brief Clears the whole currently active layer of LTDC. - * @param Color: Color of the background - */ -void BSP_LCD_Clear(uint32_t Color) -{ - /* Clear the LCD */ - LL_FillBuffer(ActiveLayer, (uint32_t *)(hltdc_eval.LayerCfg[ActiveLayer].FBStartAdress), BSP_LCD_GetXSize(), BSP_LCD_GetYSize(), 0, Color); -} - -/** - * @brief Clears the selected line in currently active layer. - * @param Line: Line to be cleared - */ -void BSP_LCD_ClearStringLine(uint32_t Line) -{ - uint32_t color_backup = DrawProp[ActiveLayer].TextColor; - DrawProp[ActiveLayer].TextColor = DrawProp[ActiveLayer].BackColor; - - /* Draw rectangle with background color */ - BSP_LCD_FillRect(0, (Line * DrawProp[ActiveLayer].pFont->Height), BSP_LCD_GetXSize(), DrawProp[ActiveLayer].pFont->Height); - - DrawProp[ActiveLayer].TextColor = color_backup; - BSP_LCD_SetTextColor(DrawProp[ActiveLayer].TextColor); -} - -/** - * @brief Displays one character in currently active layer. - * @param Xpos: Start column address - * @param Ypos: Line where to display the character shape. - * @param Ascii: Character ascii code - * This parameter must be a number between Min_Data = 0x20 and Max_Data = 0x7E - */ -void BSP_LCD_DisplayChar(uint16_t Xpos, uint16_t Ypos, uint8_t Ascii) -{ - DrawChar(Xpos, Ypos, &DrawProp[ActiveLayer].pFont->table[(Ascii-' ') *\ - DrawProp[ActiveLayer].pFont->Height * ((DrawProp[ActiveLayer].pFont->Width + 7) / 8)]); -} - -/** - * @brief Displays characters in currently active layer. - * @param Xpos: X position (in pixel) - * @param Ypos: Y position (in pixel) - * @param Text: Pointer to string to display on LCD - * @param Mode: Display mode - * This parameter can be one of the following values: - * @arg CENTER_MODE - * @arg RIGHT_MODE - * @arg LEFT_MODE - */ -void BSP_LCD_DisplayStringAt(uint16_t Xpos, uint16_t Ypos, uint8_t *Text, Text_AlignModeTypdef Mode) -{ - uint16_t refcolumn = 1, i = 0; - uint32_t size = 0, xsize = 0; - uint8_t *ptr = Text; - - /* Get the text size */ - while (*ptr++) size ++ ; - - /* Characters number per line */ - xsize = (BSP_LCD_GetXSize()/DrawProp[ActiveLayer].pFont->Width); - - switch (Mode) - { - case CENTER_MODE: - { - refcolumn = Xpos + ((xsize - size)* DrawProp[ActiveLayer].pFont->Width) / 2; - break; - } - case LEFT_MODE: - { - refcolumn = Xpos; - break; - } - case RIGHT_MODE: - { - refcolumn = - Xpos + ((xsize - size)*DrawProp[ActiveLayer].pFont->Width); - break; - } - default: - { - refcolumn = Xpos; - break; - } - } - - /* Check that the Start column is located in the screen */ - if ((refcolumn < 1) || (refcolumn >= 0x8000)) - { - refcolumn = 1; - } - - /* Send the string character by character on LCD */ - while ((*Text != 0) & (((BSP_LCD_GetXSize() - (i*DrawProp[ActiveLayer].pFont->Width)) & 0xFFFF) >= DrawProp[ActiveLayer].pFont->Width)) - { - /* Display one character on LCD */ - BSP_LCD_DisplayChar(refcolumn, Ypos, *Text); - /* Decrement the column position by 16 */ - refcolumn += DrawProp[ActiveLayer].pFont->Width; - - /* Point on the next character */ - Text++; - i++; - } - -} - -/** - * @brief Displays a maximum of 60 characters on the LCD. - * @param Line: Line where to display the character shape - * @param ptr: Pointer to string to display on LCD - */ -void BSP_LCD_DisplayStringAtLine(uint16_t Line, uint8_t *ptr) -{ - BSP_LCD_DisplayStringAt(0, LINE(Line), ptr, LEFT_MODE); -} - -/** - * @brief Draws an horizontal line in currently active layer. - * @param Xpos: X position - * @param Ypos: Y position - * @param Length: Line length - */ -void BSP_LCD_DrawHLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length) -{ - uint32_t Xaddress = 0; - - /* Get the line address */ - Xaddress = (hltdc_eval.LayerCfg[ActiveLayer].FBStartAdress) + 4*(BSP_LCD_GetXSize()*Ypos + Xpos); - - /* Write line */ - LL_FillBuffer(ActiveLayer, (uint32_t *)Xaddress, Length, 1, 0, DrawProp[ActiveLayer].TextColor); -} - -/** - * @brief Draws a vertical line in currently active layer. - * @param Xpos: X position - * @param Ypos: Y position - * @param Length: Line length - */ -void BSP_LCD_DrawVLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length) -{ - uint32_t Xaddress = 0; - - /* Get the line address */ - Xaddress = (hltdc_eval.LayerCfg[ActiveLayer].FBStartAdress) + 4*(BSP_LCD_GetXSize()*Ypos + Xpos); - - /* Write line */ - LL_FillBuffer(ActiveLayer, (uint32_t *)Xaddress, 1, Length, (BSP_LCD_GetXSize() - 1), DrawProp[ActiveLayer].TextColor); -} - -/** - * @brief Draws an uni-line (between two points) in currently active layer. - * @param x1: Point 1 X position - * @param y1: Point 1 Y position - * @param x2: Point 2 X position - * @param y2: Point 2 Y position - */ -void BSP_LCD_DrawLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) -{ - int16_t deltax = 0, deltay = 0, x = 0, y = 0, xinc1 = 0, xinc2 = 0, - yinc1 = 0, yinc2 = 0, den = 0, num = 0, numadd = 0, numpixels = 0, - curpixel = 0; - - deltax = ABS(x2 - x1); /* The difference between the x's */ - deltay = ABS(y2 - y1); /* The difference between the y's */ - x = x1; /* Start x off at the first pixel */ - y = y1; /* Start y off at the first pixel */ - - if (x2 >= x1) /* The x-values are increasing */ - { - xinc1 = 1; - xinc2 = 1; - } - else /* The x-values are decreasing */ - { - xinc1 = -1; - xinc2 = -1; - } - - if (y2 >= y1) /* The y-values are increasing */ - { - yinc1 = 1; - yinc2 = 1; - } - else /* The y-values are decreasing */ - { - yinc1 = -1; - yinc2 = -1; - } - - if (deltax >= deltay) /* There is at least one x-value for every y-value */ - { - xinc1 = 0; /* Don't change the x when numerator >= denominator */ - yinc2 = 0; /* Don't change the y for every iteration */ - den = deltax; - num = deltax / 2; - numadd = deltay; - numpixels = deltax; /* There are more x-values than y-values */ - } - else /* There is at least one y-value for every x-value */ - { - xinc2 = 0; /* Don't change the x for every iteration */ - yinc1 = 0; /* Don't change the y when numerator >= denominator */ - den = deltay; - num = deltay / 2; - numadd = deltax; - numpixels = deltay; /* There are more y-values than x-values */ - } - - for (curpixel = 0; curpixel <= numpixels; curpixel++) - { - BSP_LCD_DrawPixel(x, y, DrawProp[ActiveLayer].TextColor); /* Draw the current pixel */ - num += numadd; /* Increase the numerator by the top of the fraction */ - if (num >= den) /* Check if numerator >= denominator */ - { - num -= den; /* Calculate the new numerator value */ - x += xinc1; /* Change the x as appropriate */ - y += yinc1; /* Change the y as appropriate */ - } - x += xinc2; /* Change the x as appropriate */ - y += yinc2; /* Change the y as appropriate */ - } -} - -/** - * @brief Draws a rectangle in currently active layer. - * @param Xpos: X position - * @param Ypos: Y position - * @param Width: Rectangle width - * @param Height: Rectangle height - */ -void BSP_LCD_DrawRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height) -{ - /* Draw horizontal lines */ - BSP_LCD_DrawHLine(Xpos, Ypos, Width); - BSP_LCD_DrawHLine(Xpos, (Ypos+ Height), Width); - - /* Draw vertical lines */ - BSP_LCD_DrawVLine(Xpos, Ypos, Height); - BSP_LCD_DrawVLine((Xpos + Width), Ypos, Height); -} - -/** - * @brief Draws a circle in currently active layer. - * @param Xpos: X position - * @param Ypos: Y position - * @param Radius: Circle radius - */ -void BSP_LCD_DrawCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius) -{ - int32_t D; /* Decision Variable */ - uint32_t CurX; /* Current X Value */ - uint32_t CurY; /* Current Y Value */ - - D = 3 - (Radius << 1); - CurX = 0; - CurY = Radius; - - while (CurX <= CurY) - { - BSP_LCD_DrawPixel((Xpos + CurX), (Ypos - CurY), DrawProp[ActiveLayer].TextColor); - - BSP_LCD_DrawPixel((Xpos - CurX), (Ypos - CurY), DrawProp[ActiveLayer].TextColor); - - BSP_LCD_DrawPixel((Xpos + CurY), (Ypos - CurX), DrawProp[ActiveLayer].TextColor); - - BSP_LCD_DrawPixel((Xpos - CurY), (Ypos - CurX), DrawProp[ActiveLayer].TextColor); - - BSP_LCD_DrawPixel((Xpos + CurX), (Ypos + CurY), DrawProp[ActiveLayer].TextColor); - - BSP_LCD_DrawPixel((Xpos - CurX), (Ypos + CurY), DrawProp[ActiveLayer].TextColor); - - BSP_LCD_DrawPixel((Xpos + CurY), (Ypos + CurX), DrawProp[ActiveLayer].TextColor); - - BSP_LCD_DrawPixel((Xpos - CurY), (Ypos + CurX), DrawProp[ActiveLayer].TextColor); - - if (D < 0) - { - D += (CurX << 2) + 6; - } - else - { - D += ((CurX - CurY) << 2) + 10; - CurY--; - } - CurX++; - } -} - -/** - * @brief Draws an poly-line (between many points) in currently active layer. - * @param Points: Pointer to the points array - * @param PointCount: Number of points - */ -void BSP_LCD_DrawPolygon(pPoint Points, uint16_t PointCount) -{ - int16_t X = 0, Y = 0; - - if(PointCount < 2) - { - return; - } - - BSP_LCD_DrawLine(Points->X, Points->Y, (Points+PointCount-1)->X, (Points+PointCount-1)->Y); - - while(--PointCount) - { - X = Points->X; - Y = Points->Y; - Points++; - BSP_LCD_DrawLine(X, Y, Points->X, Points->Y); - } -} - -/** - * @brief Draws an ellipse on LCD in currently active layer. - * @param Xpos: X position - * @param Ypos: Y position - * @param XRadius: Ellipse X radius - * @param YRadius: Ellipse Y radius - */ -void BSP_LCD_DrawEllipse(int Xpos, int Ypos, int XRadius, int YRadius) -{ - int x = 0, y = -YRadius, err = 2-2*XRadius, e2; - float K = 0, rad1 = 0, rad2 = 0; - - rad1 = XRadius; - rad2 = YRadius; - - K = (float)(rad2/rad1); - - do { - BSP_LCD_DrawPixel((Xpos-(uint16_t)(x/K)), (Ypos+y), DrawProp[ActiveLayer].TextColor); - BSP_LCD_DrawPixel((Xpos+(uint16_t)(x/K)), (Ypos+y), DrawProp[ActiveLayer].TextColor); - BSP_LCD_DrawPixel((Xpos+(uint16_t)(x/K)), (Ypos-y), DrawProp[ActiveLayer].TextColor); - BSP_LCD_DrawPixel((Xpos-(uint16_t)(x/K)), (Ypos-y), DrawProp[ActiveLayer].TextColor); - - e2 = err; - if (e2 <= x) { - err += ++x*2+1; - if (-y == x && e2 <= y) e2 = 0; - } - if (e2 > y) err += ++y*2+1; - } - while (y <= 0); -} - -/** - * @brief Draws a bitmap picture loaded in the internal Flash (32 bpp) in currently active layer. - * @param Xpos: Bmp X position in the LCD - * @param Ypos: Bmp Y position in the LCD - * @param pbmp: Pointer to Bmp picture address in the internal Flash - */ -void BSP_LCD_DrawBitmap(uint32_t Xpos, uint32_t Ypos, uint8_t *pbmp) -{ - uint32_t index = 0, width = 0, height = 0, bit_pixel = 0; - uint32_t Address; - uint32_t InputColorMode = 0; - - /* Get bitmap data address offset */ - index = *(__IO uint16_t *) (pbmp + 10); - index |= (*(__IO uint16_t *) (pbmp + 12)) << 16; - - /* Read bitmap width */ - width = *(uint16_t *) (pbmp + 18); - width |= (*(uint16_t *) (pbmp + 20)) << 16; - - /* Read bitmap height */ - height = *(uint16_t *) (pbmp + 22); - height |= (*(uint16_t *) (pbmp + 24)) << 16; - - /* Read bit/pixel */ - bit_pixel = *(uint16_t *) (pbmp + 28); - - /* Set the address */ - Address = hltdc_eval.LayerCfg[ActiveLayer].FBStartAdress + (((BSP_LCD_GetXSize()*Ypos) + Xpos)*(4)); - - /* Get the layer pixel format */ - if ((bit_pixel/8) == 4) - { - InputColorMode = CM_ARGB8888; - } - else if ((bit_pixel/8) == 2) - { - InputColorMode = CM_RGB565; - } - else - { - InputColorMode = CM_RGB888; - } - - /* Bypass the bitmap header */ - pbmp += (index + (width * (height - 1) * (bit_pixel/8))); - - /* Convert picture to ARGB8888 pixel format */ - for(index=0; index < height; index++) - { - /* Pixel format conversion */ - LL_ConvertLineToARGB8888((uint32_t *)pbmp, (uint32_t *)Address, width, InputColorMode); - - /* Increment the source and destination buffers */ - Address+= (BSP_LCD_GetXSize()*4); - pbmp -= width*(bit_pixel/8); - } -} - -/** - * @brief Draws a full rectangle in currently active layer. - * @param Xpos: X position - * @param Ypos: Y position - * @param Width: Rectangle width - * @param Height: Rectangle height - */ -void BSP_LCD_FillRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height) -{ - uint32_t Xaddress = 0; - - /* Set the text color */ - BSP_LCD_SetTextColor(DrawProp[ActiveLayer].TextColor); - - /* Get the rectangle start address */ - Xaddress = (hltdc_eval.LayerCfg[ActiveLayer].FBStartAdress) + 4*(BSP_LCD_GetXSize()*Ypos + Xpos); - - /* Fill the rectangle */ - LL_FillBuffer(ActiveLayer, (uint32_t *)Xaddress, Width, Height, (BSP_LCD_GetXSize() - Width), DrawProp[ActiveLayer].TextColor); -} - -/** - * @brief Draws a full circle in currently active layer. - * @param Xpos: X position - * @param Ypos: Y position - * @param Radius: Circle radius - */ -void BSP_LCD_FillCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius) -{ - int32_t D; /* Decision Variable */ - uint32_t CurX; /* Current X Value */ - uint32_t CurY; /* Current Y Value */ - - D = 3 - (Radius << 1); - - CurX = 0; - CurY = Radius; - - BSP_LCD_SetTextColor(DrawProp[ActiveLayer].TextColor); - - while (CurX <= CurY) - { - if(CurY > 0) - { - BSP_LCD_DrawHLine(Xpos - CurY, Ypos + CurX, 2*CurY); - BSP_LCD_DrawHLine(Xpos - CurY, Ypos - CurX, 2*CurY); - } - - if(CurX > 0) - { - BSP_LCD_DrawHLine(Xpos - CurX, Ypos - CurY, 2*CurX); - BSP_LCD_DrawHLine(Xpos - CurX, Ypos + CurY, 2*CurX); - } - if (D < 0) - { - D += (CurX << 2) + 6; - } - else - { - D += ((CurX - CurY) << 2) + 10; - CurY--; - } - CurX++; - } - - BSP_LCD_SetTextColor(DrawProp[ActiveLayer].TextColor); - BSP_LCD_DrawCircle(Xpos, Ypos, Radius); -} - -/** - * @brief Draws a full poly-line (between many points) in currently active layer. - * @param Points: Pointer to the points array - * @param PointCount: Number of points - */ -void BSP_LCD_FillPolygon(pPoint Points, uint16_t PointCount) -{ - int16_t X = 0, Y = 0, X2 = 0, Y2 = 0, X_center = 0, Y_center = 0, X_first = 0, Y_first = 0, pixelX = 0, pixelY = 0, counter = 0; - uint16_t IMAGE_LEFT = 0, IMAGE_RIGHT = 0, IMAGE_TOP = 0, IMAGE_BOTTOM = 0; - - IMAGE_LEFT = IMAGE_RIGHT = Points->X; - IMAGE_TOP= IMAGE_BOTTOM = Points->Y; - - for(counter = 1; counter < PointCount; counter++) - { - pixelX = POLY_X(counter); - if(pixelX < IMAGE_LEFT) - { - IMAGE_LEFT = pixelX; - } - if(pixelX > IMAGE_RIGHT) - { - IMAGE_RIGHT = pixelX; - } - - pixelY = POLY_Y(counter); - if(pixelY < IMAGE_TOP) - { - IMAGE_TOP = pixelY; - } - if(pixelY > IMAGE_BOTTOM) - { - IMAGE_BOTTOM = pixelY; - } - } - - if(PointCount < 2) - { - return; - } - - X_center = (IMAGE_LEFT + IMAGE_RIGHT)/2; - Y_center = (IMAGE_BOTTOM + IMAGE_TOP)/2; - - X_first = Points->X; - Y_first = Points->Y; - - while(--PointCount) - { - X = Points->X; - Y = Points->Y; - Points++; - X2 = Points->X; - Y2 = Points->Y; - - FillTriangle(X, X2, X_center, Y, Y2, Y_center); - FillTriangle(X, X_center, X2, Y, Y_center, Y2); - FillTriangle(X_center, X2, X, Y_center, Y2, Y); - } - - FillTriangle(X_first, X2, X_center, Y_first, Y2, Y_center); - FillTriangle(X_first, X_center, X2, Y_first, Y_center, Y2); - FillTriangle(X_center, X2, X_first, Y_center, Y2, Y_first); -} - -/** - * @brief Draws a full ellipse in currently active layer. - * @param Xpos: X position - * @param Ypos: Y position - * @param XRadius: Ellipse X radius - * @param YRadius: Ellipse Y radius - */ -void BSP_LCD_FillEllipse(int Xpos, int Ypos, int XRadius, int YRadius) -{ - int x = 0, y = -YRadius, err = 2-2*XRadius, e2; - float K = 0, rad1 = 0, rad2 = 0; - - rad1 = XRadius; - rad2 = YRadius; - - K = (float)(rad2/rad1); - - do - { - BSP_LCD_DrawHLine((Xpos-(uint16_t)(x/K)), (Ypos+y), (2*(uint16_t)(x/K) + 1)); - BSP_LCD_DrawHLine((Xpos-(uint16_t)(x/K)), (Ypos-y), (2*(uint16_t)(x/K) + 1)); - - e2 = err; - if (e2 <= x) - { - err += ++x*2+1; - if (-y == x && e2 <= y) e2 = 0; - } - if (e2 > y) err += ++y*2+1; - } - while (y <= 0); -} - -/** - * @brief Switch back on the display if was switched off by previous call of BSP_LCD_DisplayOff(). - * Exit DSI ULPM mode if was allowed and configured in Dsi Configuration. - */ -void BSP_LCD_DisplayOn(void) -{ - /* Send Display on DCS command to display */ - HAL_DSI_ShortWrite(&(hdsi_eval), - hdsivideo_handle.VirtualChannelID, - DSI_DCS_SHORT_PKT_WRITE_P1, - OTM8009A_CMD_DISPON, - 0x00); - -} - -/** - * @brief Switch Off the display. - * Enter DSI ULPM mode if was allowed and configured in Dsi Configuration. - */ -void BSP_LCD_DisplayOff(void) -{ - /* Send Display off DCS Command to display */ - HAL_DSI_ShortWrite(&(hdsi_eval), - hdsivideo_handle.VirtualChannelID, - DSI_DCS_SHORT_PKT_WRITE_P1, - OTM8009A_CMD_DISPOFF, - 0x00); - -} - -/** - * @brief DCS or Generic short/long write command - * @param NbParams: Number of parameters. It indicates the write command mode: - * If inferior to 2, a long write command is performed else short. - * @param pParams: Pointer to parameter values table. - * @retval HAL status - */ -void DSI_IO_WriteCmd(uint32_t NbrParams, uint8_t *pParams) -{ - if(NbrParams <= 1) - { - HAL_DSI_ShortWrite(&hdsi_eval, LCD_OTM8009A_ID, DSI_DCS_SHORT_PKT_WRITE_P1, pParams[0], pParams[1]); - } - else - { - HAL_DSI_LongWrite(&hdsi_eval, LCD_OTM8009A_ID, DSI_DCS_LONG_PKT_WRITE, NbrParams, pParams[NbrParams], pParams); - } -} - -/******************************************************************************* - LTDC, DMA2D and DSI BSP Routines -*******************************************************************************/ -/** - * @brief Handles DMA2D interrupt request. - * @note : Can be surcharged by application code implementation of the function. - */ -__weak void BSP_LCD_DMA2D_IRQHandler(void) -{ - HAL_DMA2D_IRQHandler(&hdma2d_eval); -} - -/** - * @brief Handles DSI interrupt request. - * @note : Can be surcharged by application code implementation of the function. - */ -__weak void BSP_LCD_DSI_IRQHandler(void) -{ - HAL_DSI_IRQHandler(&(hdsi_eval)); -} - - -/** - * @brief Handles LTDC interrupt request. - * @note : Can be surcharged by application code implementation of the function. - */ -__weak void BSP_LCD_LTDC_IRQHandler(void) -{ - HAL_LTDC_IRQHandler(&(hltdc_eval)); -} - -/** - * @brief De-Initializes the BSP LCD Msp - * Application can surcharge if needed this function implementation. - */ -__weak void BSP_LCD_MspDeInit(void) -{ - /** @brief Disable IRQ of LTDC IP */ - HAL_NVIC_DisableIRQ(LTDC_IRQn); - - /** @brief Disable IRQ of DMA2D IP */ - HAL_NVIC_DisableIRQ(DMA2D_IRQn); - - /** @brief Disable IRQ of DSI IP */ - HAL_NVIC_DisableIRQ(DSI_IRQn); - - /** @brief Force and let in reset state LTDC, DMA2D and DSI Host + Wrapper IPs */ - __HAL_RCC_LTDC_FORCE_RESET(); - __HAL_RCC_DMA2D_FORCE_RESET(); - __HAL_RCC_DSI_FORCE_RESET(); - - /** @brief Disable the LTDC, DMA2D and DSI Host and Wrapper clocks */ - __HAL_RCC_LTDC_CLK_DISABLE(); - __HAL_RCC_DMA2D_CLK_DISABLE(); - __HAL_RCC_DSI_CLK_DISABLE(); -} - -/** - * @brief Initialize the BSP LCD Msp. - * Application can surcharge if needed this function implementation - */ -__weak void BSP_LCD_MspInit(void) -{ - /** @brief Enable the LTDC clock */ - __HAL_RCC_LTDC_CLK_ENABLE(); - - /** @brief Toggle Sw reset of LTDC IP */ - __HAL_RCC_LTDC_FORCE_RESET(); - __HAL_RCC_LTDC_RELEASE_RESET(); - - /** @brief Enable the DMA2D clock */ - __HAL_RCC_DMA2D_CLK_ENABLE(); - - /** @brief Toggle Sw reset of DMA2D IP */ - __HAL_RCC_DMA2D_FORCE_RESET(); - __HAL_RCC_DMA2D_RELEASE_RESET(); - - /** @brief Enable DSI Host and wrapper clocks */ - __HAL_RCC_DSI_CLK_ENABLE(); - - /** @brief Soft Reset the DSI Host and wrapper */ - __HAL_RCC_DSI_FORCE_RESET(); - __HAL_RCC_DSI_RELEASE_RESET(); - - /** @brief NVIC configuration for LTDC interrupt that is now enabled */ - HAL_NVIC_SetPriority(LTDC_IRQn, 3, 0); - HAL_NVIC_EnableIRQ(LTDC_IRQn); - - /** @brief NVIC configuration for DMA2D interrupt that is now enabled */ - HAL_NVIC_SetPriority(DMA2D_IRQn, 3, 0); - HAL_NVIC_EnableIRQ(DMA2D_IRQn); - - /** @brief NVIC configuration for DSI interrupt that is now enabled */ - HAL_NVIC_SetPriority(DSI_IRQn, 3, 0); - HAL_NVIC_EnableIRQ(DSI_IRQn); -} - -/** - * @brief This function handles LTDC Error interrupt Handler. - * @note : Can be surcharged by application code implementation of the function. - */ - -__weak void BSP_LCD_LTDC_ER_IRQHandler(void) -{ - HAL_LTDC_IRQHandler(&(hltdc_eval)); -} - - -/** - * @brief Draws a pixel on LCD. - * @param Xpos: X position - * @param Ypos: Y position - * @param RGB_Code: Pixel color in ARGB mode (8-8-8-8) - */ -void BSP_LCD_DrawPixel(uint16_t Xpos, uint16_t Ypos, uint32_t RGB_Code) -{ - /* Write data value to all SDRAM memory */ - *(__IO uint32_t*) (hltdc_eval.LayerCfg[ActiveLayer].FBStartAdress + (4*(Ypos*BSP_LCD_GetXSize() + Xpos))) = RGB_Code; -} - - -/** - * @brief Draws a character on LCD. - * @param Xpos: Line where to display the character shape - * @param Ypos: Start column address - * @param c: Pointer to the character data - */ -static void DrawChar(uint16_t Xpos, uint16_t Ypos, const uint8_t *c) -{ - uint32_t i = 0, j = 0; - uint16_t height, width; - uint8_t offset; - uint8_t *pchar; - uint32_t line; - - height = DrawProp[ActiveLayer].pFont->Height; - width = DrawProp[ActiveLayer].pFont->Width; - - offset = 8 *((width + 7)/8) - width ; - - for(i = 0; i < height; i++) - { - pchar = ((uint8_t *)c + (width + 7)/8 * i); - - switch(((width + 7)/8)) - { - - case 1: - line = pchar[0]; - break; - - case 2: - line = (pchar[0]<< 8) | pchar[1]; - break; - - case 3: - default: - line = (pchar[0]<< 16) | (pchar[1]<< 8) | pchar[2]; - break; - } - - for (j = 0; j < width; j++) - { - if(line & (1 << (width- j + offset- 1))) - { - BSP_LCD_DrawPixel((Xpos + j), Ypos, DrawProp[ActiveLayer].TextColor); - } - else - { - BSP_LCD_DrawPixel((Xpos + j), Ypos, DrawProp[ActiveLayer].BackColor); - } - } - Ypos++; - } -} - -/** - * @brief Fills a triangle (between 3 points). - * @param x1: Point 1 X position - * @param y1: Point 1 Y position - * @param x2: Point 2 X position - * @param y2: Point 2 Y position - * @param x3: Point 3 X position - * @param y3: Point 3 Y position - */ -static void FillTriangle(uint16_t x1, uint16_t x2, uint16_t x3, uint16_t y1, uint16_t y2, uint16_t y3) -{ - int16_t deltax = 0, deltay = 0, x = 0, y = 0, xinc1 = 0, xinc2 = 0, - yinc1 = 0, yinc2 = 0, den = 0, num = 0, numadd = 0, numpixels = 0, - curpixel = 0; - - deltax = ABS(x2 - x1); /* The difference between the x's */ - deltay = ABS(y2 - y1); /* The difference between the y's */ - x = x1; /* Start x off at the first pixel */ - y = y1; /* Start y off at the first pixel */ - - if (x2 >= x1) /* The x-values are increasing */ - { - xinc1 = 1; - xinc2 = 1; - } - else /* The x-values are decreasing */ - { - xinc1 = -1; - xinc2 = -1; - } - - if (y2 >= y1) /* The y-values are increasing */ - { - yinc1 = 1; - yinc2 = 1; - } - else /* The y-values are decreasing */ - { - yinc1 = -1; - yinc2 = -1; - } - - if (deltax >= deltay) /* There is at least one x-value for every y-value */ - { - xinc1 = 0; /* Don't change the x when numerator >= denominator */ - yinc2 = 0; /* Don't change the y for every iteration */ - den = deltax; - num = deltax / 2; - numadd = deltay; - numpixels = deltax; /* There are more x-values than y-values */ - } - else /* There is at least one y-value for every x-value */ - { - xinc2 = 0; /* Don't change the x for every iteration */ - yinc1 = 0; /* Don't change the y when numerator >= denominator */ - den = deltay; - num = deltay / 2; - numadd = deltax; - numpixels = deltay; /* There are more y-values than x-values */ - } - - for (curpixel = 0; curpixel <= numpixels; curpixel++) - { - BSP_LCD_DrawLine(x, y, x3, y3); - - num += numadd; /* Increase the numerator by the top of the fraction */ - if (num >= den) /* Check if numerator >= denominator */ - { - num -= den; /* Calculate the new numerator value */ - x += xinc1; /* Change the x as appropriate */ - y += yinc1; /* Change the y as appropriate */ - } - x += xinc2; /* Change the x as appropriate */ - y += yinc2; /* Change the y as appropriate */ - } -} - -/** - * @brief Fills a buffer. - * @param LayerIndex: Layer index - * @param pDst: Pointer to destination buffer - * @param xSize: Buffer width - * @param ySize: Buffer height - * @param OffLine: Offset - * @param ColorIndex: Color index - */ -static void LL_FillBuffer(uint32_t LayerIndex, void *pDst, uint32_t xSize, uint32_t ySize, uint32_t OffLine, uint32_t ColorIndex) -{ - /* Register to memory mode with ARGB8888 as color Mode */ - hdma2d_eval.Init.Mode = DMA2D_R2M; - hdma2d_eval.Init.ColorMode = DMA2D_ARGB8888; - hdma2d_eval.Init.OutputOffset = OffLine; - - hdma2d_eval.Instance = DMA2D; - - /* DMA2D Initialization */ - if(HAL_DMA2D_Init(&hdma2d_eval) == HAL_OK) - { - if(HAL_DMA2D_ConfigLayer(&hdma2d_eval, LayerIndex) == HAL_OK) - { - if (HAL_DMA2D_Start(&hdma2d_eval, ColorIndex, (uint32_t)pDst, xSize, ySize) == HAL_OK) - { - /* Polling For DMA transfer */ - HAL_DMA2D_PollForTransfer(&hdma2d_eval, 10); - } - } - } -} - -/** - * @brief Converts a line to an ARGB8888 pixel format. - * @param pSrc: Pointer to source buffer - * @param pDst: Output color - * @param xSize: Buffer width - * @param ColorMode: Input color mode - */ -static void LL_ConvertLineToARGB8888(void *pSrc, void *pDst, uint32_t xSize, uint32_t ColorMode) -{ - /* Configure the DMA2D Mode, Color Mode and output offset */ - hdma2d_eval.Init.Mode = DMA2D_M2M_PFC; - hdma2d_eval.Init.ColorMode = DMA2D_ARGB8888; - hdma2d_eval.Init.OutputOffset = 0; - - /* Foreground Configuration */ - hdma2d_eval.LayerCfg[1].AlphaMode = DMA2D_NO_MODIF_ALPHA; - hdma2d_eval.LayerCfg[1].InputAlpha = 0xFF; - hdma2d_eval.LayerCfg[1].InputColorMode = ColorMode; - hdma2d_eval.LayerCfg[1].InputOffset = 0; - - hdma2d_eval.Instance = DMA2D; - - /* DMA2D Initialization */ - if(HAL_DMA2D_Init(&hdma2d_eval) == HAL_OK) - { - if(HAL_DMA2D_ConfigLayer(&hdma2d_eval, 1) == HAL_OK) - { - if (HAL_DMA2D_Start(&hdma2d_eval, (uint32_t)pSrc, (uint32_t)pDst, xSize, 1) == HAL_OK) - { - /* Polling For DMA transfer */ - HAL_DMA2D_PollForTransfer(&hdma2d_eval, 10); - } - } - } -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32469I-Discovery/stm32469i_discovery_lcd.h b/bsp/stm32f411RE/Libraries/BSP/STM32469I-Discovery/stm32469i_discovery_lcd.h deleted file mode 100644 index 2fb044ef2c..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32469I-Discovery/stm32469i_discovery_lcd.h +++ /dev/null @@ -1,411 +0,0 @@ -/** - ****************************************************************************** - * @file stm32469i_discovery_lcd.h - * @author MCD Application Team - * @version V1.0.1 - * @date 29-September-2015 - * @brief This file contains the common defines and functions prototypes for - * the stm32469i_discovery_lcd.c driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32469I_DISCOVERY_LCD_H -#define __STM32469I_DISCOVERY_LCD_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -/* Include LCD component Driver */ - -/* Include OTM8009A LCD Driver IC driver code */ -#include "../Components/otm8009a/otm8009a.h" - -/* Include SDRAM Driver */ -#include "stm32469i_discovery_sdram.h" -#include "stm32469i_discovery.h" -#include "../../../Utilities/Fonts/fonts.h" - -#include /* use of memset() */ - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32469I-Discovery - * @{ - */ - -/** @addtogroup STM32469I-Discovery_LCD STM32469I Discovery LCD - * @{ - */ - -/** @defgroup STM32469I-Discovery_LCD_Exported_Constants STM32469I Discovery LCD Exported Constants - * @{ - */ - -#define LCD_LayerCfgTypeDef LTDC_LayerCfgTypeDef -/** - * @brief LCD FB_StartAddress - */ -#define LCD_FB_START_ADDRESS ((uint32_t)0xC0000000) - -/** @brief Maximum number of LTDC layers - */ -#define LTDC_MAX_LAYER_NUMBER ((uint32_t) 2) - -/** @brief LTDC Background layer index - */ -#define LTDC_ACTIVE_LAYER_BACKGROUND ((uint32_t) 0) - -/** @brief LTDC Foreground layer index - */ -#define LTDC_ACTIVE_LAYER_FOREGROUND ((uint32_t) 1) - -/** @brief Number of LTDC layers - */ -#define LTDC_NB_OF_LAYERS ((uint32_t) 2) - -/** @brief LTDC Default used layer index - */ -#define LTDC_DEFAULT_ACTIVE_LAYER LTDC_ACTIVE_LAYER_FOREGROUND - -/** - * @brief LCD status structure definition - */ -#define LCD_OK 0x00 -#define LCD_ERROR 0x01 -#define LCD_TIMEOUT 0x02 - -/** - * @brief LCD Display OTM8009A ID - */ -#define LCD_OTM8009A_ID ((uint32_t) 0) - -/** - * @brief LCD color definitions values - * in ARGB8888 format. - */ - -/** @brief Blue value in ARGB8888 format - */ -#define LCD_COLOR_BLUE ((uint32_t) 0xFF0000FF) - -/** @brief Green value in ARGB8888 format - */ -#define LCD_COLOR_GREEN ((uint32_t) 0xFF00FF00) - -/** @brief Red value in ARGB8888 format - */ -#define LCD_COLOR_RED ((uint32_t) 0xFFFF0000) - -/** @brief Cyan value in ARGB8888 format - */ -#define LCD_COLOR_CYAN ((uint32_t) 0xFF00FFFF) - -/** @brief Magenta value in ARGB8888 format - */ -#define LCD_COLOR_MAGENTA ((uint32_t) 0xFFFF00FF) - -/** @brief Yellow value in ARGB8888 format - */ -#define LCD_COLOR_YELLOW ((uint32_t) 0xFFFFFF00) - -/** @brief Light Blue value in ARGB8888 format - */ -#define LCD_COLOR_LIGHTBLUE ((uint32_t) 0xFF8080FF) - -/** @brief Light Green value in ARGB8888 format - */ -#define LCD_COLOR_LIGHTGREEN ((uint32_t) 0xFF80FF80) - -/** @brief Light Red value in ARGB8888 format - */ -#define LCD_COLOR_LIGHTRED ((uint32_t) 0xFFFF8080) - -/** @brief Light Cyan value in ARGB8888 format - */ -#define LCD_COLOR_LIGHTCYAN ((uint32_t) 0xFF80FFFF) - -/** @brief Light Magenta value in ARGB8888 format - */ -#define LCD_COLOR_LIGHTMAGENTA ((uint32_t) 0xFFFF80FF) - -/** @brief Light Yellow value in ARGB8888 format - */ -#define LCD_COLOR_LIGHTYELLOW ((uint32_t) 0xFFFFFF80) - -/** @brief Dark Blue value in ARGB8888 format - */ -#define LCD_COLOR_DARKBLUE ((uint32_t) 0xFF000080) - -/** @brief Light Dark Green value in ARGB8888 format - */ -#define LCD_COLOR_DARKGREEN ((uint32_t) 0xFF008000) - -/** @brief Light Dark Red value in ARGB8888 format - */ -#define LCD_COLOR_DARKRED ((uint32_t) 0xFF800000) - -/** @brief Dark Cyan value in ARGB8888 format - */ -#define LCD_COLOR_DARKCYAN ((uint32_t) 0xFF008080) - -/** @brief Dark Magenta value in ARGB8888 format - */ -#define LCD_COLOR_DARKMAGENTA ((uint32_t) 0xFF800080) - -/** @brief Dark Yellow value in ARGB8888 format - */ -#define LCD_COLOR_DARKYELLOW ((uint32_t) 0xFF808000) - -/** @brief White value in ARGB8888 format - */ -#define LCD_COLOR_WHITE ((uint32_t) 0xFFFFFFFF) - -/** @brief Light Gray value in ARGB8888 format - */ -#define LCD_COLOR_LIGHTGRAY ((uint32_t) 0xFFD3D3D3) - -/** @brief Gray value in ARGB8888 format - */ -#define LCD_COLOR_GRAY ((uint32_t) 0xFF808080) - -/** @brief Dark Gray value in ARGB8888 format - */ -#define LCD_COLOR_DARKGRAY ((uint32_t) 0xFF404040) - -/** @brief Black value in ARGB8888 format - */ -#define LCD_COLOR_BLACK ((uint32_t) 0xFF000000) - -/** @brief Brown value in ARGB8888 format - */ -#define LCD_COLOR_BROWN ((uint32_t) 0xFFA52A2A) - -/** @brief Orange value in ARGB8888 format - */ -#define LCD_COLOR_ORANGE ((uint32_t) 0xFFFFA500) - -/** @brief Transparent value in ARGB8888 format - */ -#define LCD_COLOR_TRANSPARENT ((uint32_t) 0xFF000000) - -/** - * @brief LCD default font - */ -#define LCD_DEFAULT_FONT Font24 -/** - * @} - */ - -/** @defgroup STM32469I-Discovery_LCD_Exported_Types STM32469I Discovery LCD Exported Types - * @{ - */ - -/** -* @brief LCD Drawing main properties -*/ -typedef struct -{ - uint32_t TextColor; /*!< Specifies the color of text */ - uint32_t BackColor; /*!< Specifies the background color below the text */ - sFONT *pFont; /*!< Specifies the font used for the text */ - -} LCD_DrawPropTypeDef; - -/** - * @brief LCD Drawing point (pixel) geometric definition - */ -typedef struct -{ - int16_t X; /*!< geometric X position of drawing */ - int16_t Y; /*!< geometric Y position of drawing */ - -} Point; - -/** - * @brief Pointer on LCD Drawing point (pixel) geometric definition - */ -typedef Point * pPoint; - -/** - * @brief LCD drawing Line alignment mode definitions - */ -typedef enum -{ - CENTER_MODE = 0x01, /*!< Center mode */ - RIGHT_MODE = 0x02, /*!< Right mode */ - LEFT_MODE = 0x03 /*!< Left mode */ - -} Text_AlignModeTypdef; - - -/** - * @brief LCD_OrientationTypeDef - * Possible values of Display Orientation - */ -typedef enum -{ - LCD_ORIENTATION_PORTRAIT = 0x00, /*!< Portrait orientation choice of LCD screen */ - LCD_ORIENTATION_LANDSCAPE = 0x01, /*!< Landscape orientation choice of LCD screen */ - LCD_ORIENTATION_INVALID = 0x02 /*!< Invalid orientation choice of LCD screen */ -} LCD_OrientationTypeDef; - -/** - * @brief Possible values of - * pixel data format (ie color coding) transmitted on DSI Data lane in DSI packets - */ -typedef enum -{ - LCD_DSI_PIXEL_DATA_FMT_RBG888 = 0x00, /*!< DSI packet pixel format chosen is RGB888 : 24 bpp */ - LCD_DSI_PIXEL_DATA_FMT_RBG565 = 0x02, /*!< DSI packet pixel format chosen is RGB565 : 16 bpp */ - LCD_DSI_PIXEL_DATA_FMT_INVALID = 0x03 /*!< Invalid DSI packet pixel format */ - -} LCD_DsiPixelDataFmtTypeDef; - -/** - * @} - */ - -/** @defgroup STM32469I-Discovery_LCD_Exported_Macro STM32469I Discovery LCD Exported Macro - * @{ - */ - -/** @defgroup STM32469I-Discovery_LCD_Exported_Functions STM32469I Discovery LCD Exported Functions - * @{ - */ -void BSP_LCD_DMA2D_IRQHandler(void); -void BSP_LCD_DSI_IRQHandler(void); -void BSP_LCD_LTDC_IRQHandler(void); -void BSP_LCD_LTDC_ER_IRQHandler(void); - -uint8_t BSP_LCD_Init(void); -uint8_t BSP_LCD_InitEx(LCD_OrientationTypeDef orientation); - -void BSP_LCD_MspDeInit(void); -void BSP_LCD_MspInit(void); -void BSP_LCD_Reset(void); - -uint32_t BSP_LCD_GetXSize(void); -uint32_t BSP_LCD_GetYSize(void); -void BSP_LCD_SetXSize(uint32_t imageWidthPixels); -void BSP_LCD_SetYSize(uint32_t imageHeightPixels); - -void BSP_LCD_LayerDefaultInit(uint16_t LayerIndex, uint32_t FB_Address); -void BSP_LCD_SetTransparency(uint32_t LayerIndex, uint8_t Transparency); -void BSP_LCD_SetLayerAddress(uint32_t LayerIndex, uint32_t Address); -void BSP_LCD_SetColorKeying(uint32_t LayerIndex, uint32_t RGBValue); -void BSP_LCD_ResetColorKeying(uint32_t LayerIndex); -void BSP_LCD_SetLayerWindow(uint16_t LayerIndex, uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height); - -void BSP_LCD_SelectLayer(uint32_t LayerIndex); -void BSP_LCD_SetLayerVisible(uint32_t LayerIndex, FunctionalState State); - -void BSP_LCD_SetTextColor(uint32_t Color); -uint32_t BSP_LCD_GetTextColor(void); -void BSP_LCD_SetBackColor(uint32_t Color); -uint32_t BSP_LCD_GetBackColor(void); -void BSP_LCD_SetFont(sFONT *fonts); -sFONT *BSP_LCD_GetFont(void); - -uint32_t BSP_LCD_ReadPixel(uint16_t Xpos, uint16_t Ypos); -void BSP_LCD_DrawPixel(uint16_t Xpos, uint16_t Ypos, uint32_t pixel); -void BSP_LCD_Clear(uint32_t Color); -void BSP_LCD_ClearStringLine(uint32_t Line); -void BSP_LCD_DisplayStringAtLine(uint16_t Line, uint8_t *ptr); -void BSP_LCD_DisplayStringAt(uint16_t Xpos, uint16_t Ypos, uint8_t *Text, Text_AlignModeTypdef Mode); -void BSP_LCD_DisplayChar(uint16_t Xpos, uint16_t Ypos, uint8_t Ascii); - -void BSP_LCD_DrawHLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length); -void BSP_LCD_DrawVLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length); -void BSP_LCD_DrawLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2); -void BSP_LCD_DrawRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height); -void BSP_LCD_DrawCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius); -void BSP_LCD_DrawPolygon(pPoint Points, uint16_t PointCount); -void BSP_LCD_DrawEllipse(int Xpos, int Ypos, int XRadius, int YRadius); -void BSP_LCD_DrawBitmap(uint32_t Xpos, uint32_t Ypos, uint8_t *pbmp); - -void BSP_LCD_FillRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height); -void BSP_LCD_FillCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius); -void BSP_LCD_FillPolygon(pPoint Points, uint16_t PointCount); -void BSP_LCD_FillEllipse(int Xpos, int Ypos, int XRadius, int YRadius); - -void BSP_LCD_DisplayOff(void); -void BSP_LCD_DisplayOn(void); - -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_LCD_Exported_Variables STM32469I EVAL LCD Exported Variables - * @{ - */ - -/* @brief DMA2D handle variable */ -extern DMA2D_HandleTypeDef hdma2d_eval; - -/** - * @} - */ - -/** @defgroup STM32469I-Discovery_LCD_Exported_Variables STM32469I Discovery LCD Exported Variables - * @{ - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32469I_DISCOVERY_LCD_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32469I-Discovery/stm32469i_discovery_qspi.c b/bsp/stm32f411RE/Libraries/BSP/STM32469I-Discovery/stm32469i_discovery_qspi.c deleted file mode 100644 index c14c78f884..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32469I-Discovery/stm32469i_discovery_qspi.c +++ /dev/null @@ -1,783 +0,0 @@ -/** - ****************************************************************************** - * @file stm32469i_discovery_qspi.c - * @author MCD Application Team - * @version V1.0.1 - * @date 29-September-2015 - * @brief This file includes a standard driver for the N25Q128A QSPI - * memory mounted on STM32469I-Discovery board. - @verbatim - ============================================================================== - ##### How to use this driver ##### - ============================================================================== - [..] - (#) This driver is used to drive the N25Q128A QSPI external - memory mounted on STM32469I-Discovery board. - - (#) This driver need a specific component driver N25Q128A to be included with. - - (#) Initialization steps: - (++) Initialize the QPSI external memory using the BSP_QSPI_Init() function. This - function includes the MSP layer hardware resources initialization and the - QSPI interface with the external memory. - - (#) QSPI memory operations - (++) QSPI memory can be accessed with read/write operations once it is - initialized. - Read/write operation can be performed with AHB access using the functions - BSP_QSPI_Read()/BSP_QSPI_Write(). - (++) The function BSP_QSPI_GetInfo() returns the configuration of the QSPI memory. - (see the QSPI memory data sheet) - (++) Perform erase block operation using the function BSP_QSPI_Erase_Block() and by - specifying the block address. You can perform an erase operation of the whole - chip by calling the function BSP_QSPI_Erase_Chip(). - (++) The function BSP_QSPI_GetStatus() returns the current status of the QSPI memory. - (see the QSPI memory data sheet) - @endverbatim - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Includes ------------------------------------------------------------------*/ -#include "stm32469i_discovery_qspi.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32469I_Discovery - * @{ - */ - -/** @defgroup STM32469I_Discovery_QSPI STM32469I_Discovery QSPI - * @{ - */ - - -/* Private variables ---------------------------------------------------------*/ - - -/** @defgroup STM32469I_Discovery_QSPI_Private_Variables Private Variables - * @{ - */ -QSPI_HandleTypeDef QSPIHandle; - -/** - * @} - */ - - - -/* Private functions ---------------------------------------------------------*/ - -/** @defgroup STM32469I_Discovery_QSPI_Private_Functions QSPI Private Functions - * @{ - */ -static uint8_t QSPI_ResetMemory (QSPI_HandleTypeDef *hqspi); -static uint8_t QSPI_DummyCyclesCfg (QSPI_HandleTypeDef *hqspi); -static uint8_t QSPI_WriteEnable (QSPI_HandleTypeDef *hqspi); -static uint8_t QSPI_AutoPollingMemReady (QSPI_HandleTypeDef *hqspi, uint32_t Timeout); - - -/** - * @} - */ - -/** @defgroup STM32469I_Discovery_QSPI_Exported_Functions QSPI Exported Functions - * @{ - */ - -/** - * @brief Initializes the QSPI interface. - * @retval QSPI memory status - */ -uint8_t BSP_QSPI_Init(void) -{ - QSPIHandle.Instance = QUADSPI; - - /* Call the DeInit function to reset the driver */ - if (HAL_QSPI_DeInit(&QSPIHandle) != HAL_OK) - { - return QSPI_ERROR; - } - - /* System level initialization */ - BSP_QSPI_MspInit(&QSPIHandle, NULL); - - /* QSPI initialization */ - QSPIHandle.Init.ClockPrescaler = 1; /* QSPI Freq= 180 MHz / (1+1) = 90 MHz */ - QSPIHandle.Init.FifoThreshold = 1; - QSPIHandle.Init.SampleShifting = QSPI_SAMPLE_SHIFTING_HALFCYCLE; - QSPIHandle.Init.FlashSize = POSITION_VAL(N25Q128A_FLASH_SIZE) - 1; - QSPIHandle.Init.ChipSelectHighTime = QSPI_CS_HIGH_TIME_2_CYCLE; - QSPIHandle.Init.ClockMode = QSPI_CLOCK_MODE_0; - QSPIHandle.Init.FlashID = QSPI_FLASH_ID_1; - QSPIHandle.Init.DualFlash = QSPI_DUALFLASH_DISABLE; - - if (HAL_QSPI_Init(&QSPIHandle) != HAL_OK) - { - return QSPI_ERROR; - } - - /* QSPI memory reset */ - if (QSPI_ResetMemory(&QSPIHandle) != QSPI_OK) - { - return QSPI_NOT_SUPPORTED; - } - - - /* Configuration of the dummy cucles on QSPI memory side */ - if (QSPI_DummyCyclesCfg(&QSPIHandle) != QSPI_OK) - { - return QSPI_NOT_SUPPORTED; - } - - return QSPI_OK; -} - -/** - * @brief De-Initializes the QSPI interface. - * @retval QSPI memory status - */ -uint8_t BSP_QSPI_DeInit(void) -{ - QSPIHandle.Instance = QUADSPI; - - /* Call the DeInit function to reset the driver */ - if (HAL_QSPI_DeInit(&QSPIHandle) != HAL_OK) - { - return QSPI_ERROR; - } - - /* System level De-initialization */ - BSP_QSPI_MspDeInit(&QSPIHandle, NULL); - - return QSPI_OK; -} - -/** - * @brief Reads an amount of data from the QSPI memory. - * @param pData: Pointer to data to be read - * @param ReadAddr: Read start address - * @param Size: Size of data to read - * @retval QSPI memory status - */ -uint8_t BSP_QSPI_Read(uint8_t* pData, uint32_t ReadAddr, uint32_t Size) -{ - QSPI_CommandTypeDef s_command; - - /* Initialize the read command */ - s_command.InstructionMode = QSPI_INSTRUCTION_1_LINE; - s_command.Instruction = QUAD_INOUT_FAST_READ_CMD; - s_command.AddressMode = QSPI_ADDRESS_4_LINES; - s_command.AddressSize = QSPI_ADDRESS_24_BITS; - s_command.Address = ReadAddr; - s_command.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE; - s_command.DataMode = QSPI_DATA_4_LINES; - s_command.DummyCycles = N25Q128A_DUMMY_CYCLES_READ_QUAD; - s_command.NbData = Size; - s_command.DdrMode = QSPI_DDR_MODE_DISABLE; - s_command.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY; - s_command.SIOOMode = QSPI_SIOO_INST_EVERY_CMD; - - /* Configure the command */ - if (HAL_QSPI_Command(&QSPIHandle, &s_command, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - /* Reception of the data */ - if (HAL_QSPI_Receive(&QSPIHandle, pData, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - return QSPI_OK; -} - -/** - * @brief Writes an amount of data to the QSPI memory. - * @param pData: Pointer to data to be written - * @param WriteAddr: Write start address - * @param Size: Size of data to write - * @retval QSPI memory status - */ -uint8_t BSP_QSPI_Write(uint8_t* pData, uint32_t WriteAddr, uint32_t Size) -{ - QSPI_CommandTypeDef s_command; - uint32_t end_addr, current_size, current_addr; - - /* Calculation of the size between the write address and the end of the page */ - current_addr = 0; - - while (current_addr <= WriteAddr) - { - current_addr += N25Q128A_PAGE_SIZE; - } - current_size = current_addr - WriteAddr; - - /* Check if the size of the data is less than the remaining place in the page */ - if (current_size > Size) - { - current_size = Size; - } - - /* Initialize the address variables */ - current_addr = WriteAddr; - end_addr = WriteAddr + Size; - - /* Initialize the program command */ - s_command.InstructionMode = QSPI_INSTRUCTION_1_LINE; - s_command.Instruction = EXT_QUAD_IN_FAST_PROG_CMD; - s_command.AddressMode = QSPI_ADDRESS_4_LINES; - s_command.AddressSize = QSPI_ADDRESS_24_BITS; - s_command.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE; - s_command.DataMode = QSPI_DATA_4_LINES; - s_command.DummyCycles = 0; - s_command.DdrMode = QSPI_DDR_MODE_DISABLE; - s_command.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY; - s_command.SIOOMode = QSPI_SIOO_INST_EVERY_CMD; - - /* Perform the write page by page */ - do - { - s_command.Address = current_addr; - s_command.NbData = current_size; - - /* Enable write operations */ - if (QSPI_WriteEnable(&QSPIHandle) != QSPI_OK) - { - return QSPI_ERROR; - } - - /* Configure the command */ - if (HAL_QSPI_Command(&QSPIHandle, &s_command, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - /* Transmission of the data */ - if (HAL_QSPI_Transmit(&QSPIHandle, pData, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - /* Configure automatic polling mode to wait for end of program */ - if (QSPI_AutoPollingMemReady(&QSPIHandle, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != QSPI_OK) - { - return QSPI_ERROR; - } - - /* Update the address and size variables for next page programming */ - current_addr += current_size; - pData += current_size; - current_size = ((current_addr + N25Q128A_PAGE_SIZE) > end_addr) ? (end_addr - current_addr) : N25Q128A_PAGE_SIZE; - } while (current_addr < end_addr); - - return QSPI_OK; -} - -/** - * @brief Erases the specified block of the QSPI memory. - * @param BlockAddress: Block address to erase - * @retval QSPI memory status - */ -uint8_t BSP_QSPI_Erase_Block(uint32_t BlockAddress) -{ - QSPI_CommandTypeDef s_command; - - /* Initialize the erase command */ - s_command.InstructionMode = QSPI_INSTRUCTION_1_LINE; - s_command.Instruction = SUBSECTOR_ERASE_CMD; - s_command.AddressMode = QSPI_ADDRESS_1_LINE; - s_command.AddressSize = QSPI_ADDRESS_24_BITS; - s_command.Address = BlockAddress; - s_command.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE; - s_command.DataMode = QSPI_DATA_NONE; - s_command.DummyCycles = 0; - s_command.DdrMode = QSPI_DDR_MODE_DISABLE; - s_command.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY; - s_command.SIOOMode = QSPI_SIOO_INST_EVERY_CMD; - - /* Enable write operations */ - if (QSPI_WriteEnable(&QSPIHandle) != QSPI_OK) - { - return QSPI_ERROR; - } - - /* Send the command */ - if (HAL_QSPI_Command(&QSPIHandle, &s_command, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - /* Configure automatic polling mode to wait for end of erase */ - if (QSPI_AutoPollingMemReady(&QSPIHandle, N25Q128A_SUBSECTOR_ERASE_MAX_TIME) != QSPI_OK) - { - return QSPI_ERROR; - } - - return QSPI_OK; -} - -/** - * @brief Erases the entire QSPI memory. - * @retval QSPI memory status - */ -uint8_t BSP_QSPI_Erase_Chip(void) -{ - QSPI_CommandTypeDef s_command; - - /* Initialize the erase command */ - s_command.InstructionMode = QSPI_INSTRUCTION_1_LINE; - s_command.Instruction = BULK_ERASE_CMD; - s_command.AddressMode = QSPI_ADDRESS_NONE; - s_command.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE; - s_command.DataMode = QSPI_DATA_NONE; - s_command.DummyCycles = 0; - s_command.DdrMode = QSPI_DDR_MODE_DISABLE; - s_command.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY; - s_command.SIOOMode = QSPI_SIOO_INST_EVERY_CMD; - - /* Enable write operations */ - if (QSPI_WriteEnable(&QSPIHandle) != QSPI_OK) - { - return QSPI_ERROR; - } - - /* Send the command */ - if (HAL_QSPI_Command(&QSPIHandle, &s_command, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - /* Configure automatic polling mode to wait for end of erase */ - if (QSPI_AutoPollingMemReady(&QSPIHandle, N25Q128A_BULK_ERASE_MAX_TIME) != QSPI_OK) - { - return QSPI_ERROR; - } - - return QSPI_OK; -} - -/** - * @brief Reads current status of the QSPI memory. - * @retval QSPI memory status - */ -uint8_t BSP_QSPI_GetStatus(void) -{ - QSPI_CommandTypeDef s_command; - uint8_t reg; - - /* Initialize the read flag status register command */ - s_command.InstructionMode = QSPI_INSTRUCTION_1_LINE; - s_command.Instruction = READ_FLAG_STATUS_REG_CMD; - s_command.AddressMode = QSPI_ADDRESS_NONE; - s_command.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE; - s_command.DataMode = QSPI_DATA_1_LINE; - s_command.DummyCycles = 0; - s_command.NbData = 1; - s_command.DdrMode = QSPI_DDR_MODE_DISABLE; - s_command.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY; - s_command.SIOOMode = QSPI_SIOO_INST_EVERY_CMD; - - /* Configure the command */ - if (HAL_QSPI_Command(&QSPIHandle, &s_command, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - /* Reception of the data */ - if (HAL_QSPI_Receive(&QSPIHandle, ®, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - /* Check the value of the register */ - if ((reg & (N25Q128A_FSR_PRERR | N25Q128A_FSR_VPPERR | N25Q128A_FSR_PGERR | N25Q128A_FSR_ERERR)) != 0) - { - return QSPI_ERROR; - } - else if ((reg & (N25Q128A_FSR_PGSUS | N25Q128A_FSR_ERSUS)) != 0) - { - return QSPI_SUSPENDED; - } - else if ((reg & N25Q128A_FSR_READY) != 0) - { - return QSPI_OK; - } - else - { - return QSPI_BUSY; - } -} - -/** - * @brief Reads the configuration of the memory and fills QspiInfo struct - * @param pInfo pointer to Info structure - * @retval QSPI memory status - */ -uint8_t BSP_QSPI_GetInfo(QSPI_InfoTypeDef* pInfo) -{ - /* Configure the structure with the memory configuration */ - pInfo->FlashSize = N25Q128A_FLASH_SIZE; - pInfo->EraseSectorSize = N25Q128A_SUBSECTOR_SIZE; - pInfo->EraseSectorsNumber = (N25Q128A_FLASH_SIZE/N25Q128A_SUBSECTOR_SIZE); - pInfo->ProgPageSize = N25Q128A_PAGE_SIZE; - pInfo->ProgPagesNumber = (N25Q128A_FLASH_SIZE/N25Q128A_PAGE_SIZE); - - return QSPI_OK; -} - -/** - * @brief Configure the QSPI in memory-mapped mode - * @param None - * @retval QSPI memory status - */ -uint8_t BSP_QSPI_MemoryMappedMode(void) -{ - QSPI_CommandTypeDef s_command; - QSPI_MemoryMappedTypeDef s_mem_mapped_cfg; - - /* Configure the command for the read instruction */ - s_command.InstructionMode = QSPI_INSTRUCTION_1_LINE; - s_command.Instruction = QUAD_INOUT_FAST_READ_CMD; - s_command.AddressMode = QSPI_ADDRESS_4_LINES; - s_command.AddressSize = QSPI_ADDRESS_24_BITS; - s_command.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE; - s_command.DataMode = QSPI_DATA_4_LINES; - s_command.DummyCycles = N25Q128A_DUMMY_CYCLES_READ_QUAD; - s_command.DdrMode = QSPI_DDR_MODE_DISABLE; - s_command.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY; - s_command.SIOOMode = QSPI_SIOO_INST_EVERY_CMD; - - /* Configure the memory mapped mode */ - s_mem_mapped_cfg.TimeOutActivation = QSPI_TIMEOUT_COUNTER_ENABLE; - s_mem_mapped_cfg.TimeOutPeriod = 100; - - if (HAL_QSPI_MemoryMapped(&QSPIHandle, &s_command, &s_mem_mapped_cfg) != HAL_OK) - { - return QSPI_ERROR; - } - - return QSPI_OK; -} - -/** - * @} - */ - -/** @addtogroup STM32446E_Discovery_QSPI_Private_Functions - * @{ - */ - -/** - * @brief QSPI MSP Initialization - * This function configures the hardware resources used in this example: - * - Peripheral's clock enable - * - Peripheral's GPIO Configuration - * - NVIC configuration for QSPI interrupt - * @retval None - */ -__weak void BSP_QSPI_MspInit(QSPI_HandleTypeDef *hqspi, void *Params) -{ - GPIO_InitTypeDef gpio_init_structure; - - /*##-1- Enable peripherals and GPIO Clocks #################################*/ - /* Enable the QuadSPI memory interface clock */ - QSPI_CLK_ENABLE(); - /* Reset the QuadSPI memory interface */ - QSPI_FORCE_RESET(); - QSPI_RELEASE_RESET(); - /* Enable GPIO clocks */ - QSPI_CS_GPIO_CLK_ENABLE(); - QSPI_DX_CLK_GPIO_CLK_ENABLE(); - - /*##-2- Configure peripheral GPIO ##########################################*/ - /* QSPI CS GPIO pin configuration */ - gpio_init_structure.Pin = QSPI_CS_PIN; - gpio_init_structure.Mode = GPIO_MODE_AF_PP; - gpio_init_structure.Pull = GPIO_PULLUP; - gpio_init_structure.Speed = GPIO_SPEED_HIGH; - gpio_init_structure.Alternate = GPIO_AF10_QSPI; - HAL_GPIO_Init(QSPI_CS_GPIO_PORT, &gpio_init_structure); - - /* QSPI CLK GPIO pin configuration */ - gpio_init_structure.Pin = QSPI_CLK_PIN; - gpio_init_structure.Pull = GPIO_NOPULL; - gpio_init_structure.Alternate = GPIO_AF9_QSPI; - HAL_GPIO_Init(QSPI_CLK_GPIO_PORT, &gpio_init_structure); - - /* QSPI D0 and D1 GPIO pin configuration */ - gpio_init_structure.Pin = (QSPI_D0_PIN | QSPI_D1_PIN); - gpio_init_structure.Alternate = GPIO_AF10_QSPI; - HAL_GPIO_Init(QSPI_DX_GPIO_PORT, &gpio_init_structure); - - /* QSPI D2 and D3 GPIO pin configuration */ - gpio_init_structure.Pin = (QSPI_D2_PIN | QSPI_D3_PIN) ; - gpio_init_structure.Alternate = GPIO_AF9_QSPI; - HAL_GPIO_Init(QSPI_DX_GPIO_PORT, &gpio_init_structure); - - /*##-3- Configure the NVIC for QSPI #########################################*/ - /* NVIC configuration for QSPI interrupt */ - HAL_NVIC_SetPriority(QUADSPI_IRQn, 0x0F, 0); - HAL_NVIC_EnableIRQ(QUADSPI_IRQn); - -} - -/** - * @brief QSPI MSP De-Initialization - * This function frees the hardware resources used in this example: - * - Disable the Peripheral's clock - * - Revert GPIO and NVIC configuration to their default state - * @retval None - */ -__weak void BSP_QSPI_MspDeInit(QSPI_HandleTypeDef *hqspi, void *Params) -{ - /*##-1- Disable the NVIC for QSPI ###########################################*/ - HAL_NVIC_DisableIRQ(QUADSPI_IRQn); - - /*##-2- Disable peripherals and GPIO Clocks ################################*/ - /* De-Configure QSPI pins */ - HAL_GPIO_DeInit(QSPI_CS_GPIO_PORT, QSPI_CS_PIN); - HAL_GPIO_DeInit(QSPI_CLK_GPIO_PORT, QSPI_CLK_PIN); - HAL_GPIO_DeInit(QSPI_DX_GPIO_PORT, QSPI_D0_PIN); - HAL_GPIO_DeInit(QSPI_DX_GPIO_PORT, QSPI_D1_PIN); - HAL_GPIO_DeInit(QSPI_DX_GPIO_PORT, QSPI_D2_PIN); - HAL_GPIO_DeInit(QSPI_DX_GPIO_PORT, QSPI_D3_PIN); - - /*##-3- Reset peripherals ##################################################*/ - /* Reset the QuadSPI memory interface */ - QSPI_FORCE_RESET(); - QSPI_RELEASE_RESET(); - - /* Disable the QuadSPI memory interface clock */ - QSPI_CLK_DISABLE(); -} - -/** - * @brief This function reset the QSPI memory. - * @param hqspi: QSPI handle - * @retval None - */ -static uint8_t QSPI_ResetMemory(QSPI_HandleTypeDef *hqspi) -{ - QSPI_CommandTypeDef s_command; - - /* Initialize the reset enable command */ - s_command.InstructionMode = QSPI_INSTRUCTION_1_LINE; - s_command.Instruction = RESET_ENABLE_CMD; - s_command.AddressMode = QSPI_ADDRESS_NONE; - s_command.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE; - s_command.DataMode = QSPI_DATA_NONE; - s_command.DummyCycles = 0; - s_command.DdrMode = QSPI_DDR_MODE_DISABLE; - s_command.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY; - s_command.SIOOMode = QSPI_SIOO_INST_EVERY_CMD; - - /* Send the command */ - if (HAL_QSPI_Command(hqspi, &s_command, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - /* Send the reset memory command */ - s_command.Instruction = RESET_MEMORY_CMD; - if (HAL_QSPI_Command(hqspi, &s_command, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - /* Configure automatic polling mode to wait the memory is ready */ - if (QSPI_AutoPollingMemReady(hqspi, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != QSPI_OK) - { - return QSPI_ERROR; - } - - return QSPI_OK; -} - -/** - * @brief This function configure the dummy cycles on memory side. - * @param hqspi: QSPI handle - * @retval None - */ -static uint8_t QSPI_DummyCyclesCfg(QSPI_HandleTypeDef *hqspi) -{ - QSPI_CommandTypeDef s_command; - uint8_t reg; - - /* Initialize the read volatile configuration register command */ - s_command.InstructionMode = QSPI_INSTRUCTION_1_LINE; - s_command.Instruction = READ_VOL_CFG_REG_CMD; - s_command.AddressMode = QSPI_ADDRESS_NONE; - s_command.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE; - s_command.DataMode = QSPI_DATA_1_LINE; - s_command.DummyCycles = 0; - s_command.NbData = 1; - s_command.DdrMode = QSPI_DDR_MODE_DISABLE; - s_command.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY; - s_command.SIOOMode = QSPI_SIOO_INST_EVERY_CMD; - - /* Configure the command */ - if (HAL_QSPI_Command(hqspi, &s_command, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - /* Reception of the data */ - if (HAL_QSPI_Receive(hqspi, ®, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - /* Enable write operations */ - if (QSPI_WriteEnable(hqspi) != QSPI_OK) - { - return QSPI_ERROR; - } - - /* Update volatile configuration register (with new dummy cycles) */ - s_command.Instruction = WRITE_VOL_CFG_REG_CMD; - MODIFY_REG(reg, N25Q128A_VCR_NB_DUMMY, (N25Q128A_DUMMY_CYCLES_READ_QUAD << POSITION_VAL(N25Q128A_VCR_NB_DUMMY))); - - /* Configure the write volatile configuration register command */ - if (HAL_QSPI_Command(hqspi, &s_command, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - /* Transmission of the data */ - if (HAL_QSPI_Transmit(hqspi, ®, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - return QSPI_OK; -} - -/** - * @brief This function send a Write Enable and wait it is effective. - * @param hqspi: QSPI handle - * @retval None - */ -static uint8_t QSPI_WriteEnable(QSPI_HandleTypeDef *hqspi) -{ - QSPI_CommandTypeDef s_command; - QSPI_AutoPollingTypeDef s_config; - - /* Enable write operations */ - s_command.InstructionMode = QSPI_INSTRUCTION_1_LINE; - s_command.Instruction = WRITE_ENABLE_CMD; - s_command.AddressMode = QSPI_ADDRESS_NONE; - s_command.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE; - s_command.DataMode = QSPI_DATA_NONE; - s_command.DummyCycles = 0; - s_command.DdrMode = QSPI_DDR_MODE_DISABLE; - s_command.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY; - s_command.SIOOMode = QSPI_SIOO_INST_EVERY_CMD; - - if (HAL_QSPI_Command(hqspi, &s_command, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - /* Configure automatic polling mode to wait for write enabling */ - s_config.Match = N25Q128A_SR_WREN; - s_config.Mask = N25Q128A_SR_WREN; - s_config.MatchMode = QSPI_MATCH_MODE_AND; - s_config.StatusBytesSize = 1; - s_config.Interval = 0x10; - s_config.AutomaticStop = QSPI_AUTOMATIC_STOP_ENABLE; - - s_command.Instruction = READ_STATUS_REG_CMD; - s_command.DataMode = QSPI_DATA_1_LINE; - - if (HAL_QSPI_AutoPolling(hqspi, &s_command, &s_config, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - return QSPI_OK; -} - -/** - * @brief This function read the SR of the memory and wait the EOP. - * @param hqspi: QSPI handle - * @param Timeout: timeout value before returning an error - * @retval None - */ -static uint8_t QSPI_AutoPollingMemReady(QSPI_HandleTypeDef *hqspi, uint32_t Timeout) -{ - QSPI_CommandTypeDef s_command; - QSPI_AutoPollingTypeDef s_config; - - /* Configure automatic polling mode to wait for memory ready */ - s_command.InstructionMode = QSPI_INSTRUCTION_1_LINE; - s_command.Instruction = READ_STATUS_REG_CMD; - s_command.AddressMode = QSPI_ADDRESS_NONE; - s_command.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE; - s_command.DataMode = QSPI_DATA_1_LINE; - s_command.DummyCycles = 0; - s_command.DdrMode = QSPI_DDR_MODE_DISABLE; - s_command.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY; - s_command.SIOOMode = QSPI_SIOO_INST_EVERY_CMD; - - s_config.Match = 0; - s_config.Mask = N25Q128A_SR_WIP; - s_config.MatchMode = QSPI_MATCH_MODE_AND; - s_config.StatusBytesSize = 1; - s_config.Interval = 0x10; - s_config.AutomaticStop = QSPI_AUTOMATIC_STOP_ENABLE; - - if (HAL_QSPI_AutoPolling(hqspi, &s_command, &s_config, Timeout) != HAL_OK) - { - return QSPI_ERROR; - } - - return QSPI_OK; -} -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ - diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32469I-Discovery/stm32469i_discovery_qspi.h b/bsp/stm32f411RE/Libraries/BSP/STM32469I-Discovery/stm32469i_discovery_qspi.h deleted file mode 100644 index 800c57f5bc..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32469I-Discovery/stm32469i_discovery_qspi.h +++ /dev/null @@ -1,164 +0,0 @@ -/** - ****************************************************************************** - * @file stm32469i_discovery_qspi.h - * @author MCD Application Team - * @version V1.0.1 - * @date 29-September-2015 - * @brief This file contains the common defines and functions prototypes for - * the stm32469i_discovery_qspi.c driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32469I_Discovery - * @{ - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32469I_DISCOVERY_QSPI_H -#define __STM32469I_DISCOVERY_QSPI_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm32f4xx_hal.h" -#include "../Components/n25q128a/n25q128a.h" - - -/** @addtogroup STM32469I_Discovery_QSPI - * @{ - */ - - -/* Exported constants --------------------------------------------------------*/ -/** @defgroup STM32446E_Discovery_QSPI_Exported_Constants Exported Constants - * @{ - */ -/* QSPI Error codes */ -#define QSPI_OK ((uint8_t)0x00) -#define QSPI_ERROR ((uint8_t)0x01) -#define QSPI_BUSY ((uint8_t)0x02) -#define QSPI_NOT_SUPPORTED ((uint8_t)0x04) -#define QSPI_SUSPENDED ((uint8_t)0x08) - - -/* Definition for QSPI clock resources */ -#define QSPI_CLK_ENABLE() __HAL_RCC_QSPI_CLK_ENABLE() -#define QSPI_CLK_DISABLE() __HAL_RCC_QSPI_CLK_DISABLE() -#define QSPI_CS_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE() -#define QSPI_CS_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE() -#define QSPI_DX_CLK_GPIO_CLK_ENABLE() __HAL_RCC_GPIOF_CLK_ENABLE() -#define QSPI_DX_CLK_GPIO_CLK_DISABLE() __HAL_RCC_GPIOF_CLK_DISABLE() - -#define QSPI_FORCE_RESET() __HAL_RCC_QSPI_FORCE_RESET() -#define QSPI_RELEASE_RESET() __HAL_RCC_QSPI_RELEASE_RESET() - -/* Definition for QSPI Pins */ -#define QSPI_CS_PIN GPIO_PIN_6 -#define QSPI_CS_GPIO_PORT GPIOB -#define QSPI_CLK_PIN GPIO_PIN_10 -#define QSPI_CLK_GPIO_PORT GPIOF -#define QSPI_D0_PIN GPIO_PIN_8 -#define QSPI_D1_PIN GPIO_PIN_9 -#define QSPI_D2_PIN GPIO_PIN_7 -#define QSPI_D3_PIN GPIO_PIN_6 -#define QSPI_DX_GPIO_PORT GPIOF - - -/** - * @} - */ - -/* Exported types ------------------------------------------------------------*/ -/** @defgroup STM32446E_Discovery_QSPI_Exported_Types Exported Types - * @{ - */ -/** - * @brief QSPI Info - * */ -typedef struct { - uint32_t FlashSize; /*!< Size of the flash */ - uint32_t EraseSectorSize; /*!< Size of sectors for the erase operation */ - uint32_t EraseSectorsNumber; /*!< Number of sectors for the erase operation */ - uint32_t ProgPageSize; /*!< Size of pages for the program operation */ - uint32_t ProgPagesNumber; /*!< Number of pages for the program operation */ -} QSPI_InfoTypeDef; - -/** - * @} - */ - - -/* Exported functions --------------------------------------------------------*/ -/** @addtogroup STM32446E_Discovery_QSPI_Exported_Functions - * @{ - */ -uint8_t BSP_QSPI_Init (void); -uint8_t BSP_QSPI_DeInit (void); -uint8_t BSP_QSPI_Read (uint8_t* pData, uint32_t ReadAddr, uint32_t Size); -uint8_t BSP_QSPI_Write (uint8_t* pData, uint32_t WriteAddr, uint32_t Size); -uint8_t BSP_QSPI_Erase_Block(uint32_t BlockAddress); -uint8_t BSP_QSPI_Erase_Chip (void); -uint8_t BSP_QSPI_GetStatus (void); -uint8_t BSP_QSPI_GetInfo (QSPI_InfoTypeDef* pInfo); -uint8_t BSP_QSPI_MemoryMappedMode(void); - -/* These function can be modified in case the current settings (e.g. DMA stream) - need to be changed for specific application needs */ -void BSP_QSPI_MspInit(QSPI_HandleTypeDef *hqspi, void *Params); -void BSP_QSPI_MspDeInit(QSPI_HandleTypeDef *hqspi, void *Params); - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32469I_DISCOVERY_QSPI_H */ -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32469I-Discovery/stm32469i_discovery_sd.c b/bsp/stm32f411RE/Libraries/BSP/STM32469I-Discovery/stm32469i_discovery_sd.c deleted file mode 100644 index 679f8718f9..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32469I-Discovery/stm32469i_discovery_sd.c +++ /dev/null @@ -1,598 +0,0 @@ -/** - ****************************************************************************** - * @file stm32469i_discovery_sd.c - * @author MCD Application Team - * @version V1.0.1 - * @date 29-September-2015 - * @brief This file includes the uSD card driver mounted on STM32469I-Discovery - * board. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* File Info : ----------------------------------------------------------------- - User NOTES -1. How To use this driver: --------------------------- - - This driver is used to drive the micro SD external card mounted on STM32469I-Discovery - board. - - This driver does not need a specific component driver for the micro SD device - to be included with. - -2. Driver description: ---------------------- - + Initialization steps: - o Initialize the micro SD card using the BSP_SD_Init() function. This - function includes the MSP layer hardware resources initialization and the - SDIO interface configuration to interface with the external micro SD. It - also includes the micro SD initialization sequence. - o To check the SD card presence you can use the function BSP_SD_IsDetected() which - returns the detection status - o If SD presence detection interrupt mode is desired, you must configure the - SD detection interrupt mode by calling the function BSP_SD_ITConfig(). The interrupt - is generated as an external interrupt whenever the micro SD card is - plugged/unplugged in/from the discovery board. The SD detection interrupt - is handled by calling the function BSP_SD_DetectIT() which is called in the IRQ - handler file, the user callback is implemented in the function BSP_SD_DetectCallback(). - o The function BSP_SD_GetCardInfo() is used to get the micro SD card information - which is stored in the structure "HAL_SD_CardInfoTypedef". - - + Micro SD card operations - o The micro SD card can be accessed with read/write block(s) operations once - it is reay for access. The access cand be performed whether using the polling - mode by calling the functions BSP_SD_ReadBlocks()/BSP_SD_WriteBlocks(), or by DMA - transfer using the functions BSP_SD_ReadBlocks_DMA()/BSP_SD_WriteBlocks_DMA() - o The DMA transfer complete is used with interrupt mode. Once the SD transfer - is complete, the SD interrupt is handeled using the function BSP_SD_IRQHandler(), - the DMA Tx/Rx transfer complete are handeled using the functions - BSP_SD_DMA_Tx_IRQHandler()/BSP_SD_DMA_Rx_IRQHandler(). The corresponding user callbacks - are implemented by the user at application level. - o The SD erase block(s) is performed using the function BSP_SD_Erase() with specifying - the number of blocks to erase. - o The SD runtime status is returned when calling the function BSP_SD_GetStatus(). - -------------------------------------------------------------------------------*/ - -/* Includes ------------------------------------------------------------------*/ -#include "stm32469i_discovery_sd.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32469I-Discovery - * @{ - */ - -/** @defgroup STM32469I-Discovery_SD STM32469I-Discovery SD - * @{ - */ - - -/** @defgroup STM32469I-Discovery_SD_Private_TypesDefinitions STM32469I Discovery Sd Private TypesDef - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I-Discovery_SD_Private_Defines STM32469I Discovery Sd Private Defines - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I-Discovery_SD_Private_Macros STM32469I Discovery Sd Private Macro - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I-Discovery_SD_Private_Variables STM32469I Discovery Sd Private Variables - * @{ - */ -static SD_HandleTypeDef uSdHandle; -static SD_CardInfo uSdCardInfo; - -/** - * @} - */ - -/** @defgroup STM32469I-Discovery_SD_Private_FunctionPrototypes STM32469I Discovery Sd Private Prototypes - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I-Discovery_SD_Private_Functions STM32469I Discovery Sd Private Functions - * @{ - */ - -/** - * @brief Initializes the SD card device. - * @retval SD status - */ -uint8_t BSP_SD_Init(void) -{ - uint8_t sd_state = MSD_OK; - - /* PLLSAI is dedicated to LCD periph. Do not use it to get 48MHz*/ - - /* uSD device interface configuration */ - uSdHandle.Instance = SDIO; - - uSdHandle.Init.ClockEdge = SDIO_CLOCK_EDGE_RISING; - uSdHandle.Init.ClockBypass = SDIO_CLOCK_BYPASS_DISABLE; - uSdHandle.Init.ClockPowerSave = SDIO_CLOCK_POWER_SAVE_DISABLE; - uSdHandle.Init.BusWide = SDIO_BUS_WIDE_1B; - uSdHandle.Init.HardwareFlowControl = SDIO_HARDWARE_FLOW_CONTROL_ENABLE; - uSdHandle.Init.ClockDiv = SDIO_TRANSFER_CLK_DIV; - - /* Msp SD Detect pin initialization */ - BSP_SD_Detect_MspInit(&uSdHandle, NULL); - if(BSP_SD_IsDetected() != SD_PRESENT) /* Check if SD card is present */ - { - return MSD_ERROR_SD_NOT_PRESENT; - } - - /* Msp SD initialization */ - BSP_SD_MspInit(&uSdHandle, NULL); - - /* HAL SD initialization */ - if(HAL_SD_Init(&uSdHandle, &uSdCardInfo) != SD_OK) - { - sd_state = MSD_ERROR; - } - - /* Configure SD Bus width */ - if(sd_state == MSD_OK) - { - /* Enable wide operation */ - if(HAL_SD_WideBusOperation_Config(&uSdHandle, SDIO_BUS_WIDE_4B) != SD_OK) - { - sd_state = MSD_ERROR; - } - else - { - sd_state = MSD_OK; - } - } - return sd_state; -} - -/** - * @brief DeInitializes the SD card device. - * @retval SD status - */ -uint8_t BSP_SD_DeInit(void) -{ - uint8_t sd_state = MSD_OK; - - uSdHandle.Instance = SDIO; - - /* HAL SD deinitialization */ - if(HAL_SD_DeInit(&uSdHandle) != HAL_OK) - { - sd_state = MSD_ERROR; - } - - /* Msp SD deinitialization */ - uSdHandle.Instance = SDIO; - BSP_SD_MspDeInit(&uSdHandle, NULL); - - return sd_state; -} - -/** - * @brief Configures Interrupt mode for SD detection pin. - * @retval Returns 0 - */ -uint8_t BSP_SD_ITConfig(void) -{ - GPIO_InitTypeDef gpio_init_structure; - - /* Configure Interrupt mode for SD detection pin */ - gpio_init_structure.Pin = SD_DETECT_PIN; - gpio_init_structure.Pull = GPIO_PULLUP; - gpio_init_structure.Speed = GPIO_SPEED_FAST; - gpio_init_structure.Mode = GPIO_MODE_IT_RISING_FALLING; - HAL_GPIO_Init(SD_DETECT_GPIO_PORT, &gpio_init_structure); - - /* Enable and set SD detect EXTI Interrupt to the lowest priority */ - HAL_NVIC_SetPriority((IRQn_Type)(SD_DETECT_EXTI_IRQn), 0x0F, 0x00); - HAL_NVIC_EnableIRQ((IRQn_Type)(SD_DETECT_EXTI_IRQn)); - - return MSD_OK; -} - -/** - * @brief Detects if SD card is correctly plugged in the memory slot or not. - * @retval Returns if SD is detected or not - */ -uint8_t BSP_SD_IsDetected(void) -{ - __IO uint8_t status = SD_PRESENT; - - /* Check SD card detect pin */ - if (HAL_GPIO_ReadPin(SD_DETECT_GPIO_PORT, SD_DETECT_PIN) == GPIO_PIN_SET) - { - status = SD_NOT_PRESENT; - } - - return status; -} - - - -/** - * @brief Reads block(s) from a specified address in an SD card, in polling mode. - * @param pData: Pointer to the buffer that will contain the data to transmit - * @param ReadAddr: Address from where data is to be read - * @param BlockSize: SD card data block size, that should be 512 - * @param NumOfBlocks: Number of SD blocks to read - * @retval SD status - */ -uint8_t BSP_SD_ReadBlocks(uint32_t *pData, uint64_t ReadAddr, uint32_t BlockSize, uint32_t NumOfBlocks) -{ - if(HAL_SD_ReadBlocks(&uSdHandle, pData, ReadAddr, BlockSize, NumOfBlocks) != SD_OK) - { - return MSD_ERROR; - } - else - { - return MSD_OK; - } -} - -/** - * @brief Writes block(s) to a specified address in an SD card, in polling mode. - * @param pData: Pointer to the buffer that will contain the data to transmit - * @param WriteAddr: Address from where data is to be written - * @param BlockSize: SD card data block size, that should be 512 - * @param NumOfBlocks: Number of SD blocks to write - * @retval SD status - */ -uint8_t BSP_SD_WriteBlocks(uint32_t *pData, uint64_t WriteAddr, uint32_t BlockSize, uint32_t NumOfBlocks) -{ - if(HAL_SD_WriteBlocks(&uSdHandle, pData, WriteAddr, BlockSize, NumOfBlocks) != SD_OK) - { - return MSD_ERROR; - } - else - { - return MSD_OK; - } -} - -/** - * @brief Reads block(s) from a specified address in an SD card, in DMA mode. - * @param pData: Pointer to the buffer that will contain the data to transmit - * @param ReadAddr: Address from where data is to be read - * @param BlockSize: SD card data block size, that should be 512 - * @param NumOfBlocks: Number of SD blocks to read - * @retval SD status - */ -uint8_t BSP_SD_ReadBlocks_DMA(uint32_t *pData, uint64_t ReadAddr, uint32_t BlockSize, uint32_t NumOfBlocks) -{ - uint8_t sd_state = MSD_OK; - - /* Read block(s) in DMA transfer mode */ - if(HAL_SD_ReadBlocks_DMA(&uSdHandle, pData, ReadAddr, BlockSize, NumOfBlocks) != SD_OK) - { - sd_state = MSD_ERROR; - } - - /* Wait until transfer is complete */ - if(sd_state == MSD_OK) - { - if(HAL_SD_CheckReadOperation(&uSdHandle, (uint32_t)SD_DATATIMEOUT) != SD_OK) - { - sd_state = MSD_ERROR; - } - else - { - sd_state = MSD_OK; - } - } - - return sd_state; -} - -/** - * @brief Writes block(s) to a specified address in an SD card, in DMA mode. - * @param pData: Pointer to the buffer that will contain the data to transmit - * @param WriteAddr: Address from where data is to be written - * @param BlockSize: SD card data block size, that should be 512 - * @param NumOfBlocks: Number of SD blocks to write - * @retval SD status - */ -uint8_t BSP_SD_WriteBlocks_DMA(uint32_t *pData, uint64_t WriteAddr, uint32_t BlockSize, uint32_t NumOfBlocks) -{ - uint8_t sd_state = MSD_OK; - - /* Write block(s) in DMA transfer mode */ - if(HAL_SD_WriteBlocks_DMA(&uSdHandle, pData, WriteAddr, BlockSize, NumOfBlocks) != SD_OK) - { - sd_state = MSD_ERROR; - } - - /* Wait until transfer is complete */ - if(sd_state == MSD_OK) - { - if(HAL_SD_CheckWriteOperation(&uSdHandle, (uint32_t)SD_DATATIMEOUT) != SD_OK) - { - sd_state = MSD_ERROR; - } - else - { - sd_state = MSD_OK; - } - } - - return sd_state; -} - -/** - * @brief Erases the specified memory area of the given SD card. - * @param StartAddr: Start byte address - * @param EndAddr: End byte address - * @retval SD status - */ -uint8_t BSP_SD_Erase(uint64_t StartAddr, uint64_t EndAddr) -{ - if(HAL_SD_Erase(&uSdHandle, StartAddr, EndAddr) != SD_OK) - { - return MSD_ERROR; - } - else - { - return MSD_OK; - } -} - -/** - * @brief Initializes the SD MSP. - * @param hsd: SD handle - * @param Params : pointer on additional configuration parameters, can be NULL. - */ -__weak void BSP_SD_MspInit(SD_HandleTypeDef *hsd, void *Params) -{ - static DMA_HandleTypeDef dma_rx_handle; - static DMA_HandleTypeDef dma_tx_handle; - GPIO_InitTypeDef gpio_init_structure; - - /* Enable SDIO clock */ - __HAL_RCC_SDIO_CLK_ENABLE(); - - /* Enable DMA2 clocks */ - __DMAx_TxRx_CLK_ENABLE(); - - /* Enable GPIOs clock */ - __HAL_RCC_GPIOC_CLK_ENABLE(); - __HAL_RCC_GPIOD_CLK_ENABLE(); - - /* Common GPIO configuration */ - gpio_init_structure.Mode = GPIO_MODE_AF_PP; - gpio_init_structure.Pull = GPIO_PULLUP; - gpio_init_structure.Speed = GPIO_SPEED_HIGH; - gpio_init_structure.Alternate = GPIO_AF12_SDIO; - - /* GPIOC configuration */ - gpio_init_structure.Pin = GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12; - - HAL_GPIO_Init(GPIOC, &gpio_init_structure); - - /* GPIOD configuration */ - gpio_init_structure.Pin = GPIO_PIN_2; - HAL_GPIO_Init(GPIOD, &gpio_init_structure); - - /* NVIC configuration for SDIO interrupts */ - HAL_NVIC_SetPriority(SDIO_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(SDIO_IRQn); - - /* Configure DMA Rx parameters */ - dma_rx_handle.Init.Channel = SD_DMAx_Rx_CHANNEL; - dma_rx_handle.Init.Direction = DMA_PERIPH_TO_MEMORY; - dma_rx_handle.Init.PeriphInc = DMA_PINC_DISABLE; - dma_rx_handle.Init.MemInc = DMA_MINC_ENABLE; - dma_rx_handle.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; - dma_rx_handle.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; - dma_rx_handle.Init.Mode = DMA_PFCTRL; - dma_rx_handle.Init.Priority = DMA_PRIORITY_VERY_HIGH; - dma_rx_handle.Init.FIFOMode = DMA_FIFOMODE_ENABLE; - dma_rx_handle.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; - dma_rx_handle.Init.MemBurst = DMA_MBURST_INC4; - dma_rx_handle.Init.PeriphBurst = DMA_PBURST_INC4; - - dma_rx_handle.Instance = SD_DMAx_Rx_STREAM; - - /* Associate the DMA handle */ - __HAL_LINKDMA(hsd, hdmarx, dma_rx_handle); - - /* Deinitialize the stream for new transfer */ - HAL_DMA_DeInit(&dma_rx_handle); - - /* Configure the DMA stream */ - HAL_DMA_Init(&dma_rx_handle); - - /* Configure DMA Tx parameters */ - dma_tx_handle.Init.Channel = SD_DMAx_Tx_CHANNEL; - dma_tx_handle.Init.Direction = DMA_MEMORY_TO_PERIPH; - dma_tx_handle.Init.PeriphInc = DMA_PINC_DISABLE; - dma_tx_handle.Init.MemInc = DMA_MINC_ENABLE; - dma_tx_handle.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; - dma_tx_handle.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; - dma_tx_handle.Init.Mode = DMA_PFCTRL; - dma_tx_handle.Init.Priority = DMA_PRIORITY_VERY_HIGH; - dma_tx_handle.Init.FIFOMode = DMA_FIFOMODE_ENABLE; - dma_tx_handle.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; - dma_tx_handle.Init.MemBurst = DMA_MBURST_INC4; - dma_tx_handle.Init.PeriphBurst = DMA_PBURST_INC4; - - dma_tx_handle.Instance = SD_DMAx_Tx_STREAM; - - /* Associate the DMA handle */ - __HAL_LINKDMA(hsd, hdmatx, dma_tx_handle); - - /* Deinitialize the stream for new transfer */ - HAL_DMA_DeInit(&dma_tx_handle); - - /* Configure the DMA stream */ - HAL_DMA_Init(&dma_tx_handle); - - /* NVIC configuration for DMA transfer complete interrupt */ - HAL_NVIC_SetPriority(SD_DMAx_Rx_IRQn, 6, 0); - HAL_NVIC_EnableIRQ(SD_DMAx_Rx_IRQn); - - /* NVIC configuration for DMA transfer complete interrupt */ - HAL_NVIC_SetPriority(SD_DMAx_Tx_IRQn, 6, 0); - HAL_NVIC_EnableIRQ(SD_DMAx_Tx_IRQn); -} - -/** - * @brief Initializes the SD Detect pin MSP. - * @param hsd: SD handle - * @retval None - */ -__weak void BSP_SD_Detect_MspInit(SD_HandleTypeDef *hsd, void *Params) -{ - GPIO_InitTypeDef gpio_init_structure; - - SD_DETECT_GPIO_CLK_ENABLE(); - - /* GPIO configuration in input for uSD_Detect signal */ - gpio_init_structure.Pin = SD_DETECT_PIN; - gpio_init_structure.Mode = GPIO_MODE_INPUT; - gpio_init_structure.Pull = GPIO_PULLUP; - gpio_init_structure.Speed = GPIO_SPEED_HIGH; - HAL_GPIO_Init(SD_DETECT_GPIO_PORT, &gpio_init_structure); -} - -/** - * @brief DeInitializes the SD MSP. - * @param hsd: SD handle - * @param Params : pointer on additional configuration parameters, can be NULL. - */ -__weak void BSP_SD_MspDeInit(SD_HandleTypeDef *hsd, void *Params) -{ - static DMA_HandleTypeDef dma_rx_handle; - static DMA_HandleTypeDef dma_tx_handle; - - /* Disable NVIC for DMA transfer complete interrupts */ - HAL_NVIC_DisableIRQ(SD_DMAx_Rx_IRQn); - HAL_NVIC_DisableIRQ(SD_DMAx_Tx_IRQn); - - /* Deinitialize the stream for new transfer */ - dma_rx_handle.Instance = SD_DMAx_Rx_STREAM; - HAL_DMA_DeInit(&dma_rx_handle); - - /* Deinitialize the stream for new transfer */ - dma_tx_handle.Instance = SD_DMAx_Tx_STREAM; - HAL_DMA_DeInit(&dma_tx_handle); - - /* Disable NVIC for SDIO interrupts */ - HAL_NVIC_DisableIRQ(SDIO_IRQn); - - /* DeInit GPIO pins can be done in the application - (by surcharging this __weak function) */ - - /* Disable SDIO clock */ - __HAL_RCC_SDIO_CLK_DISABLE(); - - /* GPOI pins clock and DMA cloks can be shut down in the applic - by surcgarging this __weak function */ -} - -/** - * @brief Handles SD card interrupt request. - */ -void BSP_SD_IRQHandler(void) -{ - HAL_SD_IRQHandler(&uSdHandle); -} - -/** - * @brief Handles SD DMA Tx transfer interrupt request. - */ -void BSP_SD_DMA_Tx_IRQHandler(void) -{ - HAL_DMA_IRQHandler(uSdHandle.hdmatx); -} - -/** - * @brief Handles SD DMA Rx transfer interrupt request. - */ -void BSP_SD_DMA_Rx_IRQHandler(void) -{ - HAL_DMA_IRQHandler(uSdHandle.hdmarx); -} - -/** - * @brief Gets the current SD card data status. - * @retval Data transfer state. - * This value can be one of the following values: - * @arg SD_TRANSFER_OK: No data transfer is acting - * @arg SD_TRANSFER_BUSY: Data transfer is acting - * @arg SD_TRANSFER_ERROR: Data transfer error - */ -HAL_SD_TransferStateTypedef BSP_SD_GetStatus(void) -{ - return(HAL_SD_GetStatus(&uSdHandle)); -} - -/** - * @brief Get SD information about specific SD card. - * @param CardInfo: Pointer to HAL_SD_CardInfoTypedef structure - */ -void BSP_SD_GetCardInfo(HAL_SD_CardInfoTypedef *CardInfo) -{ - /* Get SD card Information */ - HAL_SD_Get_CardInfo(&uSdHandle, CardInfo); -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32469I-Discovery/stm32469i_discovery_sd.h b/bsp/stm32f411RE/Libraries/BSP/STM32469I-Discovery/stm32469i_discovery_sd.h deleted file mode 100644 index b9427c0354..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32469I-Discovery/stm32469i_discovery_sd.h +++ /dev/null @@ -1,159 +0,0 @@ -/** - ****************************************************************************** - * @file stm32469i_discovery_sd.h - * @author MCD Application Team - * @version V1.0.1 - * @date 29-September-2015 - * @brief This file contains the common defines and functions prototypes for - * the stm32469i_discovery_sd.c driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32469I_DISCOVERY_SD_H -#define __STM32469I_DISCOVERY_SD_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm32469i_discovery.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32469I-Discovery - * @{ - */ - -/** @defgroup STM32469I-Discovery_SD STM32469I-Discovery SD - * @{ - */ - -/** @defgroup STM32469I-Discovery_SD_Exported_Types SD Exported Types - * @{ - */ - -/** - * @brief SD Card information structure - */ -#define SD_CardInfo HAL_SD_CardInfoTypedef -/** - * @} - */ - -/** - * @brief SD status structure definition - */ -#define MSD_OK ((uint8_t)0x00) -#define MSD_ERROR ((uint8_t)0x01) -#define MSD_ERROR_SD_NOT_PRESENT ((uint8_t)0x02) - -/** @defgroup STM32469I-Discovery_SD_Exported_Constants SD Exported Constants - * @{ - */ -#define SD_PRESENT ((uint8_t)0x01) -#define SD_NOT_PRESENT ((uint8_t)0x00) - -#define SD_DATATIMEOUT ((uint32_t)100000000) - -/* DMA definitions for SD DMA transfer */ -#define __DMAx_TxRx_CLK_ENABLE __HAL_RCC_DMA2_CLK_ENABLE -#define SD_DMAx_Tx_CHANNEL DMA_CHANNEL_4 -#define SD_DMAx_Rx_CHANNEL DMA_CHANNEL_4 -#define SD_DMAx_Tx_STREAM DMA2_Stream6 -#define SD_DMAx_Rx_STREAM DMA2_Stream3 -#define SD_DMAx_Tx_IRQn DMA2_Stream6_IRQn -#define SD_DMAx_Rx_IRQn DMA2_Stream3_IRQn -#define SD_DMAx_Tx_IRQHandler DMA2_Stream6_IRQHandler -#define SD_DMAx_Rx_IRQHandler DMA2_Stream3_IRQHandler -#define SD_DetectIRQHandler() HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_8) -/** - * @} - */ - -/** @defgroup STM32469I-Discovery_SD_Exported_Macro STM32469I Discovery SD Exported Macro - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I-Discovery_SD_Exported_Functions STM32469I Discovery SD Exported Functions - * @{ - */ -uint8_t BSP_SD_Init(void); -uint8_t BSP_SD_DeInit(void); -uint8_t BSP_SD_ITConfig(void); - - -uint8_t BSP_SD_ReadBlocks(uint32_t *pData, uint64_t ReadAddr, uint32_t BlockSize, uint32_t NumOfBlocks); -uint8_t BSP_SD_WriteBlocks(uint32_t *pData, uint64_t WriteAddr, uint32_t BlockSize, uint32_t NumOfBlocks); -uint8_t BSP_SD_ReadBlocks_DMA(uint32_t *pData, uint64_t ReadAddr, uint32_t BlockSize, uint32_t NumOfBlocks); -uint8_t BSP_SD_WriteBlocks_DMA(uint32_t *pData, uint64_t WriteAddr, uint32_t BlockSize, uint32_t NumOfBlocks); -uint8_t BSP_SD_Erase(uint64_t StartAddr, uint64_t EndAddr); -void BSP_SD_IRQHandler(void); -void BSP_SD_DMA_Tx_IRQHandler(void); -void BSP_SD_DMA_Rx_IRQHandler(void); -HAL_SD_TransferStateTypedef BSP_SD_GetStatus(void); -void BSP_SD_GetCardInfo(HAL_SD_CardInfoTypedef *CardInfo); -uint8_t BSP_SD_IsDetected(void); - -/* These __weak function can be surcharged by application code in case the current settings (e.g. DMA stream) - need to be changed for specific needs */ -void BSP_SD_MspInit(SD_HandleTypeDef *hsd, void *Params); -void BSP_SD_Detect_MspInit(SD_HandleTypeDef *hsd, void *Params); -void BSP_SD_MspDeInit(SD_HandleTypeDef *hsd, void *Params); - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32469I_DISCOVERY_SD_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32469I-Discovery/stm32469i_discovery_sdram.c b/bsp/stm32f411RE/Libraries/BSP/STM32469I-Discovery/stm32469i_discovery_sdram.c deleted file mode 100644 index 4a5dbea8f6..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32469I-Discovery/stm32469i_discovery_sdram.c +++ /dev/null @@ -1,529 +0,0 @@ -/** - ****************************************************************************** - * @file stm32469i_discovery_sdram.c - * @author MCD Application Team - * @version V1.0.1 - * @date 29-September-2015 - * @brief This file includes the SDRAM driver for the MT48LC4M32B2B5-7 memory - * device mounted on STM32469I-Discovery board. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* File Info : ----------------------------------------------------------------- - User NOTES -1. How To use this driver: --------------------------- - - This driver is used to drive the MT48LC4M32B2B5-7 SDRAM external memory mounted - on STM32469I-Discovery board. - - This driver does not need a specific component driver for the SDRAM device - to be included with. - -2. Driver description: ---------------------- - + Initialization steps: - o Initialize the SDRAM external memory using the BSP_SDRAM_Init() function. This - function includes the MSP layer hardware resources initialization and the - FMC controller configuration to interface with the external SDRAM memory. - o It contains the SDRAM initialization sequence to program the SDRAM external - device using the function BSP_SDRAM_Initialization_sequence(). Note that this - sequence is standard for all SDRAM devices, but can include some differences - from a device to another. If it is the case, the right sequence should be - implemented separately. - - + SDRAM read/write operations - o SDRAM external memory can be accessed with read/write operations once it is - initialized. - Read/write operation can be performed with AHB access using the functions - BSP_SDRAM_ReadData()/BSP_SDRAM_WriteData(), or by DMA transfer using the functions - BSP_SDRAM_ReadData_DMA()/BSP_SDRAM_WriteData_DMA(). - o The AHB access is performed with 32-bit width transaction, the DMA transfer - configuration is fixed at single (no burst) word transfer (see the - BSP_SDRAM_MspInit() weak function). - o User can implement his own functions for read/write access with his desired - configurations. - o If interrupt mode is used for DMA transfer, the function BSP_SDRAM_DMA_IRQHandler() - is called in IRQ handler file, to serve the generated interrupt once the DMA - transfer is complete. - o You can send a command to the SDRAM device in runtime using the function - BSP_SDRAM_Sendcmd(), and giving the desired command as parameter chosen between - the predefined commands of the "FMC_SDRAM_CommandTypeDef" structure. - -------------------------------------------------------------------------------*/ - -/* Includes ------------------------------------------------------------------*/ -#include "stm32469i_discovery_sdram.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32469I-Discovery - * @{ - */ - -/** @defgroup STM32469I-Discovery_SDRAM SDRAM - * @{ - */ - -/** @defgroup STM32469I-Discovery_SDRAM_Private_Types_Definitions STM32469I Discovery SDRAM Private TypesDef - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I-Discovery_SDRAM_Private_Defines STM32469I Discovery SDRAM Private Defines - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I-Discovery_SDRAM_Private_Macros STM32469I Discovery SDRAM Private Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I-Discovery_SDRAM_Private_Variables STM32469I Discovery SDRAM Private Variables - * @{ - */ -static SDRAM_HandleTypeDef sdramHandle; -static FMC_SDRAM_TimingTypeDef Timing; -static FMC_SDRAM_CommandTypeDef Command; -/** - * @} - */ - -/** @defgroup STM32469I-Discovery_SDRAM_Private_Function_Prototypes STM32469I Discovery SDRAM Private Prototypes - * @{ - */ - -/** - * @} - */ - -/** @defgroup STM32469I-Discovery_SDRAM_Private_Functions STM32469I Discovery SDRAM Private Functions - * @{ - */ - -/** - * @} - */ - -/** @defgroup STM32469I_Discovery_SDRAM_Exported_Functions STM32469I Discovery SDRAM Exported Functions - * @{ - */ - -/** - * @brief Initializes the SDRAM device. - * @retval SDRAM status - */ -uint8_t BSP_SDRAM_Init(void) -{ - static uint8_t sdramstatus = SDRAM_ERROR; - - /* SDRAM device configuration */ - sdramHandle.Instance = FMC_SDRAM_DEVICE; - - /* Timing configuration for 90 MHz as SD clock frequency (System clock is up to 180 MHz) */ - Timing.LoadToActiveDelay = 2; - Timing.ExitSelfRefreshDelay = 7; - Timing.SelfRefreshTime = 4; - Timing.RowCycleDelay = 7; - Timing.WriteRecoveryTime = 2; - Timing.RPDelay = 2; - Timing.RCDDelay = 2; - - sdramHandle.Init.SDBank = FMC_SDRAM_BANK1; - sdramHandle.Init.ColumnBitsNumber = FMC_SDRAM_COLUMN_BITS_NUM_8; - sdramHandle.Init.RowBitsNumber = FMC_SDRAM_ROW_BITS_NUM_11; - sdramHandle.Init.MemoryDataWidth = SDRAM_MEMORY_WIDTH; - sdramHandle.Init.InternalBankNumber = FMC_SDRAM_INTERN_BANKS_NUM_4; - sdramHandle.Init.CASLatency = FMC_SDRAM_CAS_LATENCY_3; - sdramHandle.Init.WriteProtection = FMC_SDRAM_WRITE_PROTECTION_DISABLE; - sdramHandle.Init.SDClockPeriod = SDCLOCK_PERIOD; - sdramHandle.Init.ReadBurst = FMC_SDRAM_RBURST_ENABLE; - sdramHandle.Init.ReadPipeDelay = FMC_SDRAM_RPIPE_DELAY_0; - - /* SDRAM controller initialization */ - /* __weak function can be surcharged by the application code */ - BSP_SDRAM_MspInit(&sdramHandle, (void *)NULL); - if(HAL_SDRAM_Init(&sdramHandle, &Timing) != HAL_OK) - { - sdramstatus = SDRAM_ERROR; - } - else - { - sdramstatus = SDRAM_OK; - } - - /* SDRAM initialization sequence */ - BSP_SDRAM_Initialization_sequence(REFRESH_COUNT); - - return sdramstatus; -} - -/** - * @brief DeInitializes the SDRAM device. - * @retval SDRAM status : SDRAM_OK or SDRAM_ERROR. - */ -uint8_t BSP_SDRAM_DeInit(void) -{ - static uint8_t sdramstatus = SDRAM_ERROR; - - /* SDRAM device configuration */ - sdramHandle.Instance = FMC_SDRAM_DEVICE; - - if(HAL_SDRAM_DeInit(&sdramHandle) == HAL_OK) - { - sdramstatus = SDRAM_OK; - - /* SDRAM controller De-initialization */ - BSP_SDRAM_MspDeInit(&sdramHandle, (void *)NULL); - } - - return sdramstatus; -} - - -/** - * @brief Programs the SDRAM device. - * @param RefreshCount: SDRAM refresh counter value - */ -void BSP_SDRAM_Initialization_sequence(uint32_t RefreshCount) -{ - __IO uint32_t tmpmrd = 0; - - /* Step 1: Configure a clock configuration enable command */ - Command.CommandMode = FMC_SDRAM_CMD_CLK_ENABLE; - Command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1; - Command.AutoRefreshNumber = 1; - Command.ModeRegisterDefinition = 0; - - /* Send the command */ - HAL_SDRAM_SendCommand(&sdramHandle, &Command, SDRAM_TIMEOUT); - - /* Step 2: Insert 100 us minimum delay */ - /* Inserted delay is equal to 1 ms due to systick time base unit (ms) */ - HAL_Delay(1); - - /* Step 3: Configure a PALL (precharge all) command */ - Command.CommandMode = FMC_SDRAM_CMD_PALL; - Command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1; - Command.AutoRefreshNumber = 1; - Command.ModeRegisterDefinition = 0; - - /* Send the command */ - HAL_SDRAM_SendCommand(&sdramHandle, &Command, SDRAM_TIMEOUT); - - /* Step 4: Configure an Auto Refresh command */ - Command.CommandMode = FMC_SDRAM_CMD_AUTOREFRESH_MODE; - Command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1; - Command.AutoRefreshNumber = 8; - Command.ModeRegisterDefinition = 0; - - /* Send the command */ - HAL_SDRAM_SendCommand(&sdramHandle, &Command, SDRAM_TIMEOUT); - - /* Step 5: Program the external memory mode register */ - tmpmrd = (uint32_t)SDRAM_MODEREG_BURST_LENGTH_1 |\ - SDRAM_MODEREG_BURST_TYPE_SEQUENTIAL |\ - SDRAM_MODEREG_CAS_LATENCY_3 |\ - SDRAM_MODEREG_OPERATING_MODE_STANDARD |\ - SDRAM_MODEREG_WRITEBURST_MODE_SINGLE; - - Command.CommandMode = FMC_SDRAM_CMD_LOAD_MODE; - Command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1; - Command.AutoRefreshNumber = 1; - Command.ModeRegisterDefinition = tmpmrd; - - /* Send the command */ - HAL_SDRAM_SendCommand(&sdramHandle, &Command, SDRAM_TIMEOUT); - - /* Step 6: Set the refresh rate counter */ - /* Set the device refresh rate */ - HAL_SDRAM_ProgramRefreshRate(&sdramHandle, RefreshCount); -} - -/** - * @brief Reads an mount of data from the SDRAM memory in polling mode. - * @param uwStartAddress: Read start address - * @param pData: Pointer to data to be read - * @param uwDataSize: Size of read data from the memory - * @retval SDRAM status : SDRAM_OK or SDRAM_ERROR. - */ -uint8_t BSP_SDRAM_ReadData(uint32_t uwStartAddress, uint32_t *pData, uint32_t uwDataSize) -{ - if(HAL_SDRAM_Read_32b(&sdramHandle, (uint32_t *)uwStartAddress, pData, uwDataSize) != HAL_OK) - { - return SDRAM_ERROR; - } - else - { - return SDRAM_OK; - } -} - -/** - * @brief Reads an mount of data from the SDRAM memory in DMA mode. - * @param uwStartAddress: Read start address - * @param pData: Pointer to data to be read - * @param uwDataSize: Size of read data from the memory - * @retval SDRAM status : SDRAM_OK or SDRAM_ERROR. - */ -uint8_t BSP_SDRAM_ReadData_DMA(uint32_t uwStartAddress, uint32_t *pData, uint32_t uwDataSize) -{ - if(HAL_SDRAM_Read_DMA(&sdramHandle, (uint32_t *)uwStartAddress, pData, uwDataSize) != HAL_OK) - { - return SDRAM_ERROR; - } - else - { - return SDRAM_OK; - } -} - -/** - * @brief Writes an mount of data to the SDRAM memory in polling mode. - * @param uwStartAddress: Write start address - * @param pData: Pointer to data to be written - * @param uwDataSize: Size of written data from the memory - * @retval SDRAM status : SDRAM_OK or SDRAM_ERROR. - */ -uint8_t BSP_SDRAM_WriteData(uint32_t uwStartAddress, uint32_t *pData, uint32_t uwDataSize) -{ - if(HAL_SDRAM_Write_32b(&sdramHandle, (uint32_t *)uwStartAddress, pData, uwDataSize) != HAL_OK) - { - return SDRAM_ERROR; - } - else - { - return SDRAM_OK; - } -} - -/** - * @brief Writes an mount of data to the SDRAM memory in DMA mode. - * @param uwStartAddress: Write start address - * @param pData: Pointer to data to be written - * @param uwDataSize: Size of written data from the memory - * @retval SDRAM status : SDRAM_OK or SDRAM_ERROR. - */ -uint8_t BSP_SDRAM_WriteData_DMA(uint32_t uwStartAddress, uint32_t *pData, uint32_t uwDataSize) -{ - if(HAL_SDRAM_Write_DMA(&sdramHandle, (uint32_t *)uwStartAddress, pData, uwDataSize) != HAL_OK) - { - return SDRAM_ERROR; - } - else - { - return SDRAM_OK; - } -} - -/** - * @brief Sends command to the SDRAM bank. - * @param SdramCmd: Pointer to SDRAM command structure - * @retval HAL status : SDRAM_OK or SDRAM_ERROR. - */ -uint8_t BSP_SDRAM_Sendcmd(FMC_SDRAM_CommandTypeDef *SdramCmd) -{ - if(HAL_SDRAM_SendCommand(&sdramHandle, SdramCmd, SDRAM_TIMEOUT) != HAL_OK) - { - return SDRAM_ERROR; - } - else - { - return SDRAM_OK; - } -} - -/** - * @brief Handles SDRAM DMA transfer interrupt request. - */ -void BSP_SDRAM_DMA_IRQHandler(void) -{ - HAL_DMA_IRQHandler(sdramHandle.hdma); -} - -/** - * @brief Initializes SDRAM MSP. - * @note This function can be surcharged by application code. - * @param hsdram: pointer on SDRAM handle - * @param Params: pointer on additional configuration parameters, can be NULL. - */ -__weak void BSP_SDRAM_MspInit(SDRAM_HandleTypeDef *hsdram, void *Params) -{ - static DMA_HandleTypeDef dma_handle; - GPIO_InitTypeDef gpio_init_structure; - - if(hsdram != (SDRAM_HandleTypeDef *)NULL) - { - /* Enable FMC clock */ - __HAL_RCC_FMC_CLK_ENABLE(); - - /* Enable chosen DMAx clock */ - __DMAx_CLK_ENABLE(); - - /* Enable GPIOs clock */ - __HAL_RCC_GPIOC_CLK_ENABLE(); - __HAL_RCC_GPIOD_CLK_ENABLE(); - __HAL_RCC_GPIOE_CLK_ENABLE(); - __HAL_RCC_GPIOF_CLK_ENABLE(); - __HAL_RCC_GPIOG_CLK_ENABLE(); - __HAL_RCC_GPIOH_CLK_ENABLE(); - __HAL_RCC_GPIOI_CLK_ENABLE(); - - /* Common GPIO configuration */ - gpio_init_structure.Mode = GPIO_MODE_AF_PP; - gpio_init_structure.Pull = GPIO_PULLUP; - gpio_init_structure.Speed = GPIO_SPEED_FAST; - gpio_init_structure.Alternate = GPIO_AF12_FMC; - - /* GPIOC configuration : PC0 is SDNWE */ - gpio_init_structure.Pin = GPIO_PIN_0; - HAL_GPIO_Init(GPIOC, &gpio_init_structure); - - /* GPIOD configuration */ - gpio_init_structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_8| GPIO_PIN_9 | GPIO_PIN_10 |\ - GPIO_PIN_14 | GPIO_PIN_15; - - - HAL_GPIO_Init(GPIOD, &gpio_init_structure); - - /* GPIOE configuration */ - gpio_init_structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_7| GPIO_PIN_8 | GPIO_PIN_9 |\ - GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 |\ - GPIO_PIN_15; - - HAL_GPIO_Init(GPIOE, &gpio_init_structure); - - /* GPIOF configuration */ - gpio_init_structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2| GPIO_PIN_3 | GPIO_PIN_4 |\ - GPIO_PIN_5 | GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 |\ - GPIO_PIN_15; - - HAL_GPIO_Init(GPIOF, &gpio_init_structure); - - /* GPIOG configuration */ - gpio_init_structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_4| GPIO_PIN_5 | GPIO_PIN_8 |\ - GPIO_PIN_15; - HAL_GPIO_Init(GPIOG, &gpio_init_structure); - - /* GPIOH configuration */ - gpio_init_structure.Pin = GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_8 | GPIO_PIN_9 |\ - GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 |\ - GPIO_PIN_15; - HAL_GPIO_Init(GPIOH, &gpio_init_structure); - - /* GPIOI configuration */ - gpio_init_structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 |\ - GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7 | GPIO_PIN_9 | GPIO_PIN_10; - HAL_GPIO_Init(GPIOI, &gpio_init_structure); - - /* Configure common DMA parameters */ - dma_handle.Init.Channel = SDRAM_DMAx_CHANNEL; - dma_handle.Init.Direction = DMA_MEMORY_TO_MEMORY; - dma_handle.Init.PeriphInc = DMA_PINC_ENABLE; - dma_handle.Init.MemInc = DMA_MINC_ENABLE; - dma_handle.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; - dma_handle.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; - dma_handle.Init.Mode = DMA_NORMAL; - dma_handle.Init.Priority = DMA_PRIORITY_HIGH; - dma_handle.Init.FIFOMode = DMA_FIFOMODE_DISABLE; - dma_handle.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; - dma_handle.Init.MemBurst = DMA_MBURST_SINGLE; - dma_handle.Init.PeriphBurst = DMA_PBURST_SINGLE; - - dma_handle.Instance = SDRAM_DMAx_STREAM; - - /* Associate the DMA handle */ - __HAL_LINKDMA(hsdram, hdma, dma_handle); - - /* Deinitialize the stream for new transfer */ - HAL_DMA_DeInit(&dma_handle); - - /* Configure the DMA stream */ - HAL_DMA_Init(&dma_handle); - - /* NVIC configuration for DMA transfer complete interrupt */ - HAL_NVIC_SetPriority(SDRAM_DMAx_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(SDRAM_DMAx_IRQn); - - } /* of if(hsdram != (SDRAM_HandleTypeDef *)NULL) */ -} - -/** - * @brief DeInitializes SDRAM MSP. - * @note This function can be surcharged by application code. - * @param hsdram: pointer on SDRAM handle - * @param Params: pointer on additional configuration parameters, can be NULL. - */ -__weak void BSP_SDRAM_MspDeInit(SDRAM_HandleTypeDef *hsdram, void *Params) -{ - static DMA_HandleTypeDef dma_handle; - - if(hsdram != (SDRAM_HandleTypeDef *)NULL) - { - /* Disable NVIC configuration for DMA interrupt */ - HAL_NVIC_DisableIRQ(SDRAM_DMAx_IRQn); - - /* Deinitialize the stream for new transfer */ - dma_handle.Instance = SDRAM_DMAx_STREAM; - HAL_DMA_DeInit(&dma_handle); - - /* DeInit GPIO pins can be done in the application - (by surcharging this __weak function) */ - - /* GPIO pins clock, FMC clock and DMA clock can be shut down in the application - by surcharging this __weak function */ - - } /* of if(hsdram != (SDRAM_HandleTypeDef *)NULL) */ -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32469I-Discovery/stm32469i_discovery_sdram.h b/bsp/stm32f411RE/Libraries/BSP/STM32469I-Discovery/stm32469i_discovery_sdram.h deleted file mode 100644 index 4da7a8ec55..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32469I-Discovery/stm32469i_discovery_sdram.h +++ /dev/null @@ -1,163 +0,0 @@ -/** - ****************************************************************************** - * @file stm32469i_discovery_sdram.h - * @author MCD Application Team - * @version V1.0.1 - * @date 29-September-2015 - * @brief This file contains the common defines and functions prototypes for - * the stm32469i_discovery_sdram.c driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32469I_DISCOVERY_SDRAM_H -#define __STM32469I_DISCOVERY_SDRAM_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm32f4xx_hal.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32469I-Discovery - * @{ - */ - -/** @addtogroup STM32469I-Discovery_SDRAM - * @{ - */ - -/** @defgroup STM32469I-Discovery_SDRAM_Exported_Types STM32469I Discovery SDRAM Exported Types - * @{ - */ - -/** - * @brief SDRAM status structure definition - */ -#define SDRAM_OK ((uint8_t)0x00) -#define SDRAM_ERROR ((uint8_t)0x01) - -/** @defgroup STM32469I-Discovery_SDRAM_Exported_Constants STM32469I Discovery SDRAM Exported Constants - * @{ - */ -#define SDRAM_DEVICE_ADDR ((uint32_t)0xC0000000) - - /* SDRAM device size in MBytes */ - #define SDRAM_DEVICE_SIZE ((uint32_t)0x800000) - -#define SDRAM_MEMORY_WIDTH FMC_SDRAM_MEM_BUS_WIDTH_32 -#define SDCLOCK_PERIOD FMC_SDRAM_CLOCK_PERIOD_2 - -/* SDRAM refresh counter (90 MHz SD clock) */ -#define REFRESH_COUNT ((uint32_t)0x0569) -#define SDRAM_TIMEOUT ((uint32_t)0xFFFF) - -/* DMA definitions for SDRAM DMA transfer */ -#define __DMAx_CLK_ENABLE __HAL_RCC_DMA2_CLK_ENABLE -#define __DMAx_CLK_DISABLE __HAL_RCC_DMA2_CLK_DISABLE -#define SDRAM_DMAx_CHANNEL DMA_CHANNEL_0 -#define SDRAM_DMAx_STREAM DMA2_Stream0 -#define SDRAM_DMAx_IRQn DMA2_Stream0_IRQn -#define SDRAM_DMAx_IRQHandler DMA2_Stream0_IRQHandler -/** - * @} - */ - -/** - * @brief FMC SDRAM Mode definition register defines - */ -#define SDRAM_MODEREG_BURST_LENGTH_1 ((uint16_t)0x0000) -#define SDRAM_MODEREG_BURST_LENGTH_2 ((uint16_t)0x0001) -#define SDRAM_MODEREG_BURST_LENGTH_4 ((uint16_t)0x0002) -#define SDRAM_MODEREG_BURST_LENGTH_8 ((uint16_t)0x0004) -#define SDRAM_MODEREG_BURST_TYPE_SEQUENTIAL ((uint16_t)0x0000) -#define SDRAM_MODEREG_BURST_TYPE_INTERLEAVED ((uint16_t)0x0008) -#define SDRAM_MODEREG_CAS_LATENCY_2 ((uint16_t)0x0020) -#define SDRAM_MODEREG_CAS_LATENCY_3 ((uint16_t)0x0030) -#define SDRAM_MODEREG_OPERATING_MODE_STANDARD ((uint16_t)0x0000) -#define SDRAM_MODEREG_WRITEBURST_MODE_PROGRAMMED ((uint16_t)0x0000) -#define SDRAM_MODEREG_WRITEBURST_MODE_SINGLE ((uint16_t)0x0200) -/** - * @} - */ - -/** @defgroup STM32469I-Discovery_SDRAM_Exported_Macro STM32469I Discovery SDRAM Exported Macro - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I-Discovery_SDRAM_Exported_Functions STM32469I Discovery SDRAM Exported Functions - * @{ - */ -uint8_t BSP_SDRAM_Init(void); -uint8_t BSP_SDRAM_DeInit(void); -void BSP_SDRAM_Initialization_sequence(uint32_t RefreshCount); -uint8_t BSP_SDRAM_ReadData(uint32_t uwStartAddress, uint32_t *pData, uint32_t uwDataSize); -uint8_t BSP_SDRAM_ReadData_DMA(uint32_t uwStartAddress, uint32_t *pData, uint32_t uwDataSize); -uint8_t BSP_SDRAM_WriteData(uint32_t uwStartAddress, uint32_t *pData, uint32_t uwDataSize); -uint8_t BSP_SDRAM_WriteData_DMA(uint32_t uwStartAddress, uint32_t *pData, uint32_t uwDataSize); -uint8_t BSP_SDRAM_Sendcmd(FMC_SDRAM_CommandTypeDef *SdramCmd); -void BSP_SDRAM_DMA_IRQHandler(void); - -/* These function can be modified in case the current settings (e.g. DMA stream) - need to be changed for specific application needs */ -void BSP_SDRAM_MspInit(SDRAM_HandleTypeDef *hsdram, void *Params); -void BSP_SDRAM_MspDeInit(SDRAM_HandleTypeDef *hsdram, void *Params); - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32469I_DISCOVERY_SDRAM_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32469I-Discovery/stm32469i_discovery_ts.c b/bsp/stm32f411RE/Libraries/BSP/STM32469I-Discovery/stm32469i_discovery_ts.c deleted file mode 100644 index 6c5d86b829..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32469I-Discovery/stm32469i_discovery_ts.c +++ /dev/null @@ -1,475 +0,0 @@ -/** - ****************************************************************************** - * @file stm32469i_discovery_ts.c - * @author MCD Application Team - * @version V1.0.1 - * @date 29-September-2015 - * @brief This file provides a set of functions needed to manage the Touch - * Screen on STM32469I-Discovery board. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* File Info : ----------------------------------------------------------------- - User NOTES -1. How To use this driver: --------------------------- - - This driver is used to drive the touch screen module of the STM32469I-Discovery - board on the K.O.D Optica Technology 480x800 TFT-LCD mounted on - MB1189 board. The touch screen driver IC inside the K.O.D module KM-040TMP-02 - is a FT6206 by Focal Tech. - -2. Driver description: ---------------------- - + Initialization steps: - o Initialize the TS module using the BSP_TS_Init() function. This - function includes the MSP layer hardware resources initialization and the - communication layer configuration to start the TS use. The LCD size properties - (x and y) are passed as parameters. - o If TS interrupt mode is desired, you must configure the TS interrupt mode - by calling the function BSP_TS_ITConfig(). The TS interrupt mode is generated - as an external interrupt whenever a touch is detected. - The interrupt mode internally uses the IO functionalities driver driven by - the IO expander, to configure the IT line. - - + Touch screen use - o The touch screen state is captured whenever the function BSP_TS_GetState() is - used. This function returns information about the last LCD touch occurred - in the TS_StateTypeDef structure. - o If TS interrupt mode is used, the function BSP_TS_ITGetStatus() is needed to get - the interrupt status. To clear the IT pending bits, you should call the - function BSP_TS_ITClear(). - o The IT is handled using the corresponding external interrupt IRQ handler, - the user IT callback treatment is implemented on the same external interrupt - callback. - -------------------------------------------------------------------------------*/ - -/* Includes ------------------------------------------------------------------*/ -#include "stm32469i_discovery_ts.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32469I-Discovery - * @{ - */ - -/** @defgroup STM32469I-Discovery_TS STM32469I-Discovery TS - * @{ - */ - -/** @defgroup STM32469I-Discovery_TS_Private_Types_Definitions TS Private Types Definitions - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I-Discovery_TS_Private_Defines TS Private Types Defines - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I-Discovery_TS_Private_Macros TS Private Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I-Discovery_TS_Imported_Variables TS Imported Variables - * @{ - */ - /** - * @} - */ - -/** @defgroup STM32469I-Discovery_TS_Private_Variables TS Private Variables - * @{ - */ -static TS_DrvTypeDef *ts_driver; -static uint8_t ts_orientation; -static uint8_t I2C_Address = 0; - -/* Table for touchscreen event information display on LCD : table indexed on enum @ref TS_TouchEventTypeDef information */ -char * ts_event_string_tab[TOUCH_EVENT_NB_MAX] = { "None", - "Press down", - "Lift up", - "Contact" - }; - -/* Table for touchscreen gesture Id information display on LCD : table indexed on enum @ref TS_GestureIdTypeDef information */ -char * ts_gesture_id_string_tab[GEST_ID_NB_MAX] = { "None", - "Move Up", - "Move Right", - "Move Down", - "Move Left", - "Zoom In", - "Zoom Out" - }; - -/** - * @} - */ - -/** @defgroup STM32469I-Discovery_TS_Private_Function_Prototypes TS Private Function Prototypes - * @{ - */ - -/** - * @} - */ - -/** @defgroup STM32469I-Discovery_TS_Public_Functions TS Public Functions - * @{ - */ - -/** - * @brief Initializes and configures the touch screen functionalities and - * configures all necessary hardware resources (GPIOs, I2C, clocks..). - * @param ts_SizeX : Maximum X size of the TS area on LCD - * @param ts_SizeY : Maximum Y size of the TS area on LCD - * @retval TS_OK if all initializations are OK. Other value if error. - */ -uint8_t BSP_TS_Init(uint16_t ts_SizeX, uint16_t ts_SizeY) -{ - uint8_t ts_status = TS_OK; - - /* Note : I2C_Address is un-initialized here, but is not used at all in init function */ - /* but the prototype of Init() is like that in template and should be respected */ - - /* Initialize the communication channel to sensor (I2C) if necessary */ - /* that is initialization is done only once after a power up */ - ft6x06_ts_drv.Init(I2C_Address); - - /* Scan FT6x06 TouchScreen IC controller ID register by I2C Read */ - /* Verify this is a FT6x06, otherwise this is an error case */ - if(ft6x06_ts_drv.ReadID(TS_I2C_ADDRESS) == FT6206_ID_VALUE) - { - /* Found FT6206 : Initialize the TS driver structure */ - ts_driver = &ft6x06_ts_drv; - - I2C_Address = TS_I2C_ADDRESS; - - /* Get LCD chosen orientation */ - if(ts_SizeX < ts_SizeY) - { - ts_orientation = TS_SWAP_NONE; - } - else - { - ts_orientation = TS_SWAP_XY | TS_SWAP_Y; - } - - if(ts_status == TS_OK) - { - /* Software reset the TouchScreen */ - ts_driver->Reset(I2C_Address); - - /* Calibrate, Configure and Start the TouchScreen driver */ - ts_driver->Start(I2C_Address); - - } /* of if(ts_status == TS_OK) */ - } - else - { - ts_status = TS_DEVICE_NOT_FOUND; - } - - return (ts_status); -} - -/** - * @brief Configures and enables the touch screen interrupts both at GPIO level and - * in TouchScreen IC driver configuration. - * @retval TS_OK if all initializations are OK. - */ -uint8_t BSP_TS_ITConfig(void) -{ - uint8_t ts_status = TS_OK; - GPIO_InitTypeDef gpio_init_structure; - - /* Msp Init of GPIO used for TS_INT pin coming from TouchScreen driver IC FT6x06 */ - /* When touchscreen is operated in interrupt mode */ - BSP_TS_INT_MspInit(); - - /* Configure Interrupt mode for TS_INT pin falling edge : when a new touch is available */ - /* TS_INT pin is active on low level on new touch available */ - gpio_init_structure.Pin = TS_INT_PIN; - gpio_init_structure.Pull = GPIO_PULLUP; - gpio_init_structure.Speed = GPIO_SPEED_FAST; - gpio_init_structure.Mode = GPIO_MODE_IT_FALLING; - HAL_GPIO_Init(TS_INT_GPIO_PORT, &gpio_init_structure); - - /* Enable and set the TS_INT EXTI Interrupt to an intermediate priority */ - HAL_NVIC_SetPriority((IRQn_Type)(TS_INT_EXTI_IRQn), 0x05, 0x00); - HAL_NVIC_EnableIRQ((IRQn_Type)(TS_INT_EXTI_IRQn)); - - /* Enable the TS in interrupt mode */ - /* In that case the INT output of FT6206 when new touch is available */ - /* is active on low level and directed on EXTI */ - ts_driver->EnableIT(I2C_Address); - - return (ts_status); -} - -/** - * @brief Returns status and positions of the touch screen. - * @param TS_State: Pointer to touch screen current state structure - * @retval TS_OK if all initializations are OK. Other value if error. - */ -uint8_t BSP_TS_GetState(TS_StateTypeDef *TS_State) -{ - static uint32_t _x[TS_MAX_NB_TOUCH] = {0, 0}; - static uint32_t _y[TS_MAX_NB_TOUCH] = {0, 0}; - uint8_t ts_status = TS_OK; - uint16_t tmp; - uint16_t Raw_x[TS_MAX_NB_TOUCH]; - uint16_t Raw_y[TS_MAX_NB_TOUCH]; - uint16_t xDiff; - uint16_t yDiff; - uint32_t index; -#if (TS_MULTI_TOUCH_SUPPORTED == 1) - uint32_t weight = 0; - uint32_t area = 0; - uint32_t event = 0; -#endif /* TS_MULTI_TOUCH_SUPPORTED == 1 */ - - /* Check and update the number of touches active detected */ - TS_State->touchDetected = ts_driver->DetectTouch(I2C_Address); - if(TS_State->touchDetected) - { - for(index=0; index < TS_State->touchDetected; index++) - { - /* Get each touch coordinates */ - ts_driver->GetXY(I2C_Address, &(Raw_x[index]), &(Raw_y[index])); - - if(ts_orientation & TS_SWAP_XY) - { - tmp = Raw_x[index]; - Raw_x[index] = Raw_y[index]; - Raw_y[index] = tmp; - } - - if(ts_orientation & TS_SWAP_X) - { - Raw_x[index] = FT_6206_MAX_WIDTH - 1 - Raw_x[index]; - } - - if(ts_orientation & TS_SWAP_Y) - { - Raw_y[index] = FT_6206_MAX_HEIGHT - 1 - Raw_y[index]; - } - - xDiff = Raw_x[index] > _x[index]? (Raw_x[index] - _x[index]): (_x[index] - Raw_x[index]); - yDiff = Raw_y[index] > _y[index]? (Raw_y[index] - _y[index]): (_y[index] - Raw_y[index]); - - if ((xDiff + yDiff) > 5) - { - _x[index] = Raw_x[index]; - _y[index] = Raw_y[index]; - } - - - TS_State->touchX[index] = _x[index]; - TS_State->touchY[index] = _y[index]; - -#if (TS_MULTI_TOUCH_SUPPORTED == 1) - - /* Get touch info related to the current touch */ - ft6x06_TS_GetTouchInfo(I2C_Address, index, &weight, &area, &event); - - /* Update TS_State structure */ - TS_State->touchWeight[index] = weight; - TS_State->touchArea[index] = area; - - /* Remap touch event */ - switch(event) - { - case FT6206_TOUCH_EVT_FLAG_PRESS_DOWN : - TS_State->touchEventId[index] = TOUCH_EVENT_PRESS_DOWN; - break; - case FT6206_TOUCH_EVT_FLAG_LIFT_UP : - TS_State->touchEventId[index] = TOUCH_EVENT_LIFT_UP; - break; - case FT6206_TOUCH_EVT_FLAG_CONTACT : - TS_State->touchEventId[index] = TOUCH_EVENT_CONTACT; - break; - case FT6206_TOUCH_EVT_FLAG_NO_EVENT : - TS_State->touchEventId[index] = TOUCH_EVENT_NO_EVT; - break; - default : - ts_status = TS_ERROR; - break; - } /* of switch(event) */ - -#endif /* TS_MULTI_TOUCH_SUPPORTED == 1 */ - - } /* of for(index=0; index < TS_State->touchDetected; index++) */ - -#if (TS_MULTI_TOUCH_SUPPORTED == 1) - /* Get gesture Id */ - ts_status = BSP_TS_Get_GestureId(TS_State); -#endif /* TS_MULTI_TOUCH_SUPPORTED == 1 */ - - } /* end of if(TS_State->touchDetected != 0) */ - - return (ts_status); -} - -#if (TS_MULTI_TOUCH_SUPPORTED == 1) -/** - * @brief Update gesture Id following a touch detected. - * @param TS_State: Pointer to touch screen current state structure - * @retval TS_OK if all initializations are OK. Other value if error. - */ -uint8_t BSP_TS_Get_GestureId(TS_StateTypeDef *TS_State) -{ - uint32_t gestureId = 0; - uint8_t ts_status = TS_OK; - - /* Get gesture Id */ - ft6x06_TS_GetGestureID(I2C_Address, &gestureId); - - /* Remap gesture Id to a TS_GestureIdTypeDef value */ - switch(gestureId) - { - case FT6206_GEST_ID_NO_GESTURE : - TS_State->gestureId = GEST_ID_NO_GESTURE; - break; - case FT6206_GEST_ID_MOVE_UP : - TS_State->gestureId = GEST_ID_MOVE_UP; - break; - case FT6206_GEST_ID_MOVE_RIGHT : - TS_State->gestureId = GEST_ID_MOVE_RIGHT; - break; - case FT6206_GEST_ID_MOVE_DOWN : - TS_State->gestureId = GEST_ID_MOVE_DOWN; - break; - case FT6206_GEST_ID_MOVE_LEFT : - TS_State->gestureId = GEST_ID_MOVE_LEFT; - break; - case FT6206_GEST_ID_ZOOM_IN : - TS_State->gestureId = GEST_ID_ZOOM_IN; - break; - case FT6206_GEST_ID_ZOOM_OUT : - TS_State->gestureId = GEST_ID_ZOOM_OUT; - break; - default : - ts_status = TS_ERROR; - break; - } /* of switch(gestureId) */ - - return(ts_status); -} - - -/** @defgroup STM32469I-Discovery_TS_Private_Functions TS Private Functions - * @{ - */ - - -/** - * @brief Function used to reset all touch data before a new acquisition - * of touch information. - * @param TS_State: Pointer to touch screen current state structure - * @retval TS_OK if OK, TE_ERROR if problem found. - */ -uint8_t BSP_TS_ResetTouchData(TS_StateTypeDef *TS_State) -{ - uint8_t ts_status = TS_ERROR; - uint32_t index; - - if (TS_State != (TS_StateTypeDef *)NULL) - { - TS_State->gestureId = GEST_ID_NO_GESTURE; - TS_State->touchDetected = 0; - - for(index = 0; index < TS_MAX_NB_TOUCH; index++) - { - TS_State->touchX[index] = 0; - TS_State->touchY[index] = 0; - TS_State->touchArea[index] = 0; - TS_State->touchEventId[index] = TOUCH_EVENT_NO_EVT; - TS_State->touchWeight[index] = 0; - } - - ts_status = TS_OK; - - } /* of if (TS_State != (TS_StateTypeDef *)NULL) */ - - return (ts_status); -} -#endif /* TS_MULTI_TOUCH_SUPPORTED == 1 */ -/** - * @brief Initializes the TS_INT pin MSP. - * @param None - * @retval None - */ -__weak void BSP_TS_INT_MspInit(void) -{ - GPIO_InitTypeDef gpio_init_structure; - - TS_INT_GPIO_CLK_ENABLE(); - - /* GPIO configuration in input for TouchScreen interrupt signal on TS_INT pin */ - gpio_init_structure.Pin = TS_INT_PIN; - - gpio_init_structure.Mode = GPIO_MODE_INPUT; - gpio_init_structure.Pull = GPIO_PULLUP; - gpio_init_structure.Speed = GPIO_SPEED_HIGH; - HAL_GPIO_Init(TS_INT_GPIO_PORT, &gpio_init_structure); -} - - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32469I-Discovery/stm32469i_discovery_ts.h b/bsp/stm32f411RE/Libraries/BSP/STM32469I-Discovery/stm32469i_discovery_ts.h deleted file mode 100644 index 1c31d6452a..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32469I-Discovery/stm32469i_discovery_ts.h +++ /dev/null @@ -1,213 +0,0 @@ -/** - ****************************************************************************** - * @file stm32469i_discovery_ts.h - * @author MCD Application Team - * @version V1.0.1 - * @date 29-September-2015 - * @brief This file contains the common defines and functions prototypes for - * the stm32469i_discovery_ts.c driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32469I_DISCOVERY_TS_H -#define __STM32469I_DISCOVERY_TS_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm32469i_discovery.h" -#include "stm32469i_discovery_lcd.h" - -/* Include TouchScreen component driver */ -#include "../Components/ft6x06/ft6x06.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32469I-Discovery - * @{ - */ - -/** @defgroup STM32469I-Discovery_TS STM32469I-Discovery TS - * @{ - */ - - /** @defgroup STM32469I-Discovery_TS_Exported_Constants TS Exported Constants - * @{ - */ -/** @brief With FT6206 : maximum 2 touches detected simultaneously - */ -#define TS_MAX_NB_TOUCH ((uint32_t) FT6206_MAX_DETECTABLE_TOUCH) -#define TS_NO_IRQ_PENDING ((uint8_t) 0) -#define TS_IRQ_PENDING ((uint8_t) 1) - -#define TS_SWAP_NONE ((uint8_t) 0x01) -#define TS_SWAP_X ((uint8_t) 0x02) -#define TS_SWAP_Y ((uint8_t) 0x04) -#define TS_SWAP_XY ((uint8_t) 0x08) - - /** - * @} - */ - -/** @defgroup STM32469I-Discovery_TS_Exported_Types TS Exported Types - * @{ - */ -/** -* @brief TS_StateTypeDef -* Define TS State structure -*/ -typedef struct -{ - uint8_t touchDetected; /*!< Total number of active touches detected at last scan */ - uint16_t touchX[TS_MAX_NB_TOUCH]; /*!< Touch X[0], X[1] coordinates on 12 bits */ - uint16_t touchY[TS_MAX_NB_TOUCH]; /*!< Touch Y[0], Y[1] coordinates on 12 bits */ - -#if (TS_MULTI_TOUCH_SUPPORTED == 1) - uint8_t touchWeight[TS_MAX_NB_TOUCH]; /*!< Touch_Weight[0], Touch_Weight[1] : weight property of touches */ - uint8_t touchEventId[TS_MAX_NB_TOUCH]; /*!< Touch_EventId[0], Touch_EventId[1] : take value of type @ref TS_TouchEventTypeDef */ - uint8_t touchArea[TS_MAX_NB_TOUCH]; /*!< Touch_Area[0], Touch_Area[1] : touch area of each touch */ - uint32_t gestureId; /*!< type of gesture detected : take value of type @ref TS_GestureIdTypeDef */ -#endif /* TS_MULTI_TOUCH_SUPPORTED == 1 */ - -} TS_StateTypeDef; - -/** - * @brief TS_StatusTypeDef - * Define BSP_TS_xxx() functions possible return value, - * when status is returned by those functions. - */ -typedef enum -{ - TS_OK = 0x00, /*!< Touch Ok */ - TS_ERROR = 0x01, /*!< Touch Error */ - TS_TIMEOUT = 0x02, /*!< Touch Timeout */ - TS_DEVICE_NOT_FOUND = 0x03 /*!< Touchscreen device not found */ -} TS_StatusTypeDef; - -/** - * @brief TS_GestureIdTypeDef - * Define Possible managed gesture identification values returned by touch screen - * driver. - */ -typedef enum -{ - GEST_ID_NO_GESTURE = 0x00, /*!< Gesture not defined / recognized */ - GEST_ID_MOVE_UP = 0x01, /*!< Gesture Move Up */ - GEST_ID_MOVE_RIGHT = 0x02, /*!< Gesture Move Right */ - GEST_ID_MOVE_DOWN = 0x03, /*!< Gesture Move Down */ - GEST_ID_MOVE_LEFT = 0x04, /*!< Gesture Move Left */ - GEST_ID_ZOOM_IN = 0x05, /*!< Gesture Zoom In */ - GEST_ID_ZOOM_OUT = 0x06, /*!< Gesture Zoom Out */ - GEST_ID_NB_MAX = 0x07 /*!< max number of gesture id */ -} TS_GestureIdTypeDef; - -/** - * @brief TS_TouchEventTypeDef - * Define Possible touch events kind as returned values - * by touch screen IC Driver. - */ -typedef enum -{ - TOUCH_EVENT_NO_EVT = 0x00, /*!< Touch Event : undetermined */ - TOUCH_EVENT_PRESS_DOWN = 0x01, /*!< Touch Event Press Down */ - TOUCH_EVENT_LIFT_UP = 0x02, /*!< Touch Event Lift Up */ - TOUCH_EVENT_CONTACT = 0x03, /*!< Touch Event Contact */ - TOUCH_EVENT_NB_MAX = 0x04 /*!< max number of touch events kind */ -} TS_TouchEventTypeDef; - -/** - * @} - */ - -/** @defgroup STM32469I-Discovery_TS_Imported_Variables STM32469I Discovery TS Imported Variables - * @{ - */ -/** - * @brief Table for touchscreen event information display on LCD : - * table indexed on enum @ref TS_TouchEventTypeDef information - */ -extern char * ts_event_string_tab[TOUCH_EVENT_NB_MAX]; - -/** - * @brief Table for touchscreen gesture Id information display on LCD : table indexed - * on enum @ref TS_GestureIdTypeDef information - */ -extern char * ts_gesture_id_string_tab[GEST_ID_NB_MAX]; -/** - * @} - */ - -/** @defgroup STM32469I-Discovery_TS_Exported_Functions TS Exported Functions - * @{ - */ -uint8_t BSP_TS_Init(uint16_t ts_SizeX, uint16_t ts_SizeY); -uint8_t BSP_TS_GetState(TS_StateTypeDef *TS_State); - -#if (TS_MULTI_TOUCH_SUPPORTED == 1) -uint8_t BSP_TS_Get_GestureId(TS_StateTypeDef *TS_State); -uint8_t BSP_TS_ResetTouchData(TS_StateTypeDef *TS_State); -#endif /* TS_MULTI_TOUCH_SUPPORTED == 1 */ - -uint8_t BSP_TS_ITConfig(void); - - -/* These __weak function can be surcharged by application code in case the current settings - need to be changed for specific (example GPIO allocation) */ -void BSP_TS_INT_MspInit(void); - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32469I_DISCOVERY_TS_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/Release_Notes.html b/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/Release_Notes.html deleted file mode 100644 index 4c9ba44055..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/Release_Notes.html +++ /dev/null @@ -1,184 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - Release Notes for STM32469I_EVAL Evaluation Board Drivers - - - - - - - - - - -
-


-

-
- - - - - - -
- - - - - - - - - -
-

Back to Release page

-
-

Release -Notes for STM32469I_EVAL Evaluation Board Drivers

-

Copyright -2015 STMicroelectronics

-

-
-

 

- - - - - - -
- - -

Update History

V1.0.1 / 29-September-2015

-

Main -Changes

- - - -
  • stm32469i_eval_lcd.c update:
    • Add delay within BSP_LCD_Reset() function
  • stm32469i_eval_lcd.h update:
    • Replace "\" with "/"
-

V0.3.0 / 07-July-2015

-

Main -Changes

- - - -
  • stm32469i_eval update:
    • Add AUDIO_IO_DeInit() function
    • Update TS_I2C_ADDRESS
    • Update MULTI_TOUCH management
  • stm32469i_eval_audio update:
    • Remove CODEC_Reset() static function
    • Update BSP_AUDIO_OUT_Init() function to no more use CODEC_Reset() function
  • stm32469i_eval_lcd update:
    • update lcd_x_size and lcd_y_size declaration and definition
    • update BSP_LCD_GetXSize() and BSP_LCD_GetYSize() functions
  • stm32469i_eval_sd update
    • update BSP_SD_Init() function with appropriate hardware flow control configuration

V0.2.0 / 10-June-2015

-

Main -Changes

- - - -
  • Second Beta Release for STM32469I_EVAL board drivers.
  • stm32469i_eval_ts update:
    • Remove the dependency from the global var mfx_exti_received which is part of the application
    • Update BSP_TS_Init() and BSP_TS_GetState() functions
    • Update MULTI_TOUCH management
  • stm32469i_eval_lcd update:
    • Align eval lcd drivers to HAL DSI drivers
  • stm32469i_eval_qspi update:
    • Add BSP_QSPI_MemoryMappedMode function

V0.1.0 / 04-May-2015

-

Main -Changes

- - - -
    -
  • First Beta Release for STM32469I_EVAL board drivers.
  • -

License

- -
-
-Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met:
-
-
  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions -in binary form must reproduce the above copyright notice, this list of -conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of STMicroelectronics nor the names of its contributors may be used to endorse or promote products derived
    -
    -
-        from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- -
-
- - -
-
-

For -complete documentation on STM32 Microcontrollers -visit www.st.com/STM32

-
-

-
-
-

 

-
- - \ No newline at end of file diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval.c b/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval.c deleted file mode 100644 index b5e4089964..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval.c +++ /dev/null @@ -1,1309 +0,0 @@ -/** - ****************************************************************************** - * @file stm32469i_eval.c - * @author MCD Application Team - * @version V1.0.1 - * @date 29-September-2015 - * @brief This file provides a set of firmware functions to manage LEDs, - * push-buttons and COM ports available on STM32469I-EVAL evaluation - * board(MB1165) RevA/B from STMicroelectronics. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* File Info: ------------------------------------------------------------------ - User NOTE - - This driver requires the stm32469i_eval_io to manage the joystick - -------------------------------------------------------------------------------*/ - -/* Includes ------------------------------------------------------------------*/ -#include "stm32469i_eval.h" -#if defined(USE_IOEXPANDER) -#include "stm32469i_eval_io.h" -#endif /* USE_IOEXPANDER */ - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32469I_EVAL - * @{ - */ - -/** @defgroup STM32469I_EVAL_LOW_LEVEL STM32469I-EVAL LOW LEVEL - * @{ - */ - -/** @defgroup STM32469I_EVAL_LOW_LEVEL_Private_TypesDefinitions STM32469I Eval Low Level Private Typedef - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I_EVAL_LOW_LEVEL_Private_Defines LOW_LEVEL Private Defines - * @{ - */ -/** - * @brief STM32469I EVAL BSP Driver version number V1.0.1 - */ -#define __STM32469I_EVAL_BSP_VERSION_MAIN (0x01) /*!< [31:24] main version */ -#define __STM32469I_EVAL_BSP_VERSION_SUB1 (0x00) /*!< [23:16] sub1 version */ -#define __STM32469I_EVAL_BSP_VERSION_SUB2 (0x01) /*!< [15:8] sub2 version */ -#define __STM32469I_EVAL_BSP_VERSION_RC (0x00) /*!< [7:0] release candidate */ -#define __STM32469I_EVAL_BSP_VERSION ((__STM32469I_EVAL_BSP_VERSION_MAIN << 24)\ - |(__STM32469I_EVAL_BSP_VERSION_SUB1 << 16)\ - |(__STM32469I_EVAL_BSP_VERSION_SUB2 << 8 )\ - |(__STM32469I_EVAL_BSP_VERSION_RC)) -/** - * @} - */ - -/** @defgroup STM32469I_EVAL_LOW_LEVEL_Private_Macros LOW_LEVEL Private Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I_EVAL_LOW_LEVEL_Private_Variables LOW_LEVEL Private Variables - * @{ - */ -const uint32_t GPIO_PIN[LEDn] = {LED1_PIN, - LED2_PIN, - LED3_PIN, - LED4_PIN}; - -GPIO_TypeDef* BUTTON_PORT[BUTTONn] = {WAKEUP_BUTTON_GPIO_PORT, - TAMPER_BUTTON_GPIO_PORT, - KEY_BUTTON_GPIO_PORT}; - -const uint16_t BUTTON_PIN[BUTTONn] = {WAKEUP_BUTTON_PIN, - TAMPER_BUTTON_PIN, - KEY_BUTTON_PIN}; - -const uint16_t BUTTON_IRQn[BUTTONn] = {WAKEUP_BUTTON_EXTI_IRQn, - TAMPER_BUTTON_EXTI_IRQn, - KEY_BUTTON_EXTI_IRQn}; - -USART_TypeDef* COM_USART[COMn] = {EVAL_COM1}; - -GPIO_TypeDef* COM_TX_PORT[COMn] = {EVAL_COM1_TX_GPIO_PORT}; - -GPIO_TypeDef* COM_RX_PORT[COMn] = {EVAL_COM1_RX_GPIO_PORT}; - -const uint16_t COM_TX_PIN[COMn] = {EVAL_COM1_TX_PIN}; - -const uint16_t COM_RX_PIN[COMn] = {EVAL_COM1_RX_PIN}; - -const uint16_t COM_TX_AF[COMn] = {EVAL_COM1_TX_AF}; - -const uint16_t COM_RX_AF[COMn] = {EVAL_COM1_RX_AF}; - -static I2C_HandleTypeDef heval_I2c; - -/** - * @} - */ - -/** @defgroup STM32469I_EVAL_LOW_LEVEL_Private_FunctionPrototypes LOW_LEVEL Private FunctionPrototypes - * @{ - */ -static void I2Cx_MspInit(void); -static void I2Cx_Init(void); -static void I2Cx_Write(uint8_t Addr, uint8_t Reg, uint8_t Value); -static uint8_t I2Cx_Read(uint8_t Addr, uint8_t Reg); -static HAL_StatusTypeDef I2Cx_ReadMultiple(uint8_t Addr, uint16_t Reg, uint16_t MemAddSize, uint8_t *Buffer, uint16_t Length); -static HAL_StatusTypeDef I2Cx_WriteMultiple(uint8_t Addr, uint16_t Reg, uint16_t MemAddSize, uint8_t *Buffer, uint16_t Length); -static HAL_StatusTypeDef I2Cx_IsDeviceReady(uint16_t DevAddress, uint32_t Trials); -static void I2Cx_Error(uint8_t Addr); - -/* IOExpander IO functions */ -void IOE_Init(void); -void IOE_ITConfig(void); -void IOE_Delay(uint32_t Delay); -void IOE_Write(uint8_t Addr, uint8_t Reg, uint8_t Value); -uint8_t IOE_Read(uint8_t Addr, uint8_t Reg); -uint16_t IOE_ReadMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length); -void IOE_WriteMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length); - -#if defined(USE_IOEXPANDER) -/* MFX IO functions */ -void MFX_IO_Init(void); -void MFX_IO_DeInit(void); -void MFX_IO_ITConfig(void); -void MFX_IO_Delay(uint32_t Delay); -void MFX_IO_Write(uint16_t Addr, uint8_t Reg, uint8_t Value); -uint8_t MFX_IO_Read(uint16_t Addr, uint8_t Reg); -uint16_t MFX_IO_ReadMultiple(uint16_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length); -void MFX_IO_Wakeup(void); -void MFX_IO_EnableWakeupPin(void); -#endif /* USE_IOEXPANDER */ - -/* AUDIO IO functions */ -void AUDIO_IO_Init(void); -void AUDIO_IO_DeInit(void); -void AUDIO_IO_Write(uint8_t Addr, uint16_t Reg, uint16_t Value); -uint16_t AUDIO_IO_Read(uint8_t Addr, uint16_t Reg); -void AUDIO_IO_Delay(uint32_t Delay); - -/* CAMERA IO functions */ -void CAMERA_IO_Init(void); -void CAMERA_Delay(uint32_t Delay); -void CAMERA_IO_Write(uint8_t Addr, uint16_t Reg, uint16_t Value); -uint16_t CAMERA_IO_Read(uint8_t Addr, uint16_t Reg); - -/* I2C EEPROM IO function */ -void EEPROM_IO_Init(void); -HAL_StatusTypeDef EEPROM_IO_WriteData(uint16_t DevAddress, uint16_t MemAddress, uint8_t* pBuffer, uint32_t BufferSize); -HAL_StatusTypeDef EEPROM_IO_ReadData(uint16_t DevAddress, uint16_t MemAddress, uint8_t* pBuffer, uint32_t BufferSize); -HAL_StatusTypeDef EEPROM_IO_IsDeviceReady(uint16_t DevAddress, uint32_t Trials); - -/* TouchScreen (TS) IO functions */ -void TS_IO_Init(void); -void TS_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value); -uint8_t TS_IO_Read(uint8_t Addr, uint8_t Reg); -uint16_t TS_IO_ReadMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length); -void TS_IO_WriteMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length); -void TS_IO_Delay(uint32_t Delay); - -void OTM8009A_IO_Delay(uint32_t Delay); -/** - * @} - */ - -/** @defgroup STM32469I_EVAL_BSP_Public_Functions BSP Public Functions - * @{ - */ - - /** - * @brief This method returns the STM32469I EVAL BSP Driver revision - * @retval version: 0xXYZR (8bits for each decimal, R for RC) - */ -uint32_t BSP_GetVersion(void) -{ - return __STM32469I_EVAL_BSP_VERSION; -} - -/** - * @brief Configures LED GPIO. - * @param Led: LED to be configured. - * This parameter can be one of the following values: - * @arg LED1 - * @arg LED2 - * @arg LED3 - * @arg LED4 - * @retval None - */ -void BSP_LED_Init(Led_TypeDef Led) -{ -#if !defined(USE_STM32469I_EVAL_REVA) -/* Eval Rev B and beyond : leds are directly connected to MCU o PK3, 4, 5, 6 */ - GPIO_InitTypeDef gpio_init_structure; - - /* On RevB LED1, LED2, LED3 and LED4 are on GPIO */ - if (Led <= LED4) - { - /* Enable the GPIO_LED clock */ - LEDx_GPIO_CLK_ENABLE(); - - /* Configure the GPIO_LED pin */ - gpio_init_structure.Pin = GPIO_PIN[Led]; - gpio_init_structure.Mode = GPIO_MODE_OUTPUT_PP; - gpio_init_structure.Pull = GPIO_PULLUP; - gpio_init_structure.Speed = GPIO_SPEED_HIGH; - - HAL_GPIO_Init(LEDx_GPIO_PORT, &gpio_init_structure); - - /* By default, turn off LED by setting a high level on corresponding GPIO */ - HAL_GPIO_WritePin(LEDx_GPIO_PORT, GPIO_PIN[Led], GPIO_PIN_SET); - } -#else -#if defined(USE_IOEXPANDER) /* (USE_IOEXPANDER always defined for RevA) */ - /* Initialize the IO functionalities */ - BSP_IO_Init(); - - /* the output mode choices shall be extended to PushPull / PullUp*/ - BSP_IO_ConfigPin(GPIO_PIN[Led], IO_MODE_OUTPUT_PP_PU); - - BSP_IO_WritePin(GPIO_PIN[Led], BSP_IO_PIN_SET); -#endif /* USE_IOEXPANDER */ -#endif /* USE_STM32469I_EVAL_REVA */ -} - - -/** - * @brief DeInit LEDs. - * @param Led: LED to be configured. - * This parameter can be one of the following values: - * @arg LED1 - * @arg LED2 - * @arg LED3 - * @arg LED4 - * @note Led DeInit does not disable the GPIO clock nor disable the Mfx - * @retval None - */ -void BSP_LED_DeInit(Led_TypeDef Led) -{ -#if !defined(USE_STM32469I_EVAL_REVA) -/* Eval Rev B and beyond */ - GPIO_InitTypeDef gpio_init_structure; - - /* On RevB LED1 LED2 LED3 and LED4 are on GPIO PK3, 4, 5, 6 */ - if (Led <= LED4) - { - /* Turn off LED */ - HAL_GPIO_WritePin(LEDx_GPIO_PORT, GPIO_PIN[Led], GPIO_PIN_RESET); - /* DeInit the GPIO_LED pin */ - gpio_init_structure.Pin = GPIO_PIN[Led]; - HAL_GPIO_DeInit(LEDx_GPIO_PORT, gpio_init_structure.Pin); - } -#else -#if defined(USE_IOEXPANDER) /* (USE_IOEXPANDER always defined for RevA) */ - /* GPIO_PIN[Led] depends on the board revision: */ - /* - in case of RevA all leds are on IOEXPANDER (Mfx) */ - BSP_IO_ConfigPin(GPIO_PIN[Led], IO_MODE_OFF); -#endif /* USE_IOEXPANDER */ -#endif /* USE_STM32469I_EVAL_REVA */ -} -/** - * @brief Turns selected LED On. - * @param Led: LED to be set on - * This parameter can be one of the following values: - * @arg LED1 - * @arg LED2 - * @arg LED3 - * @arg LED4 - * @retval None - */ -void BSP_LED_On(Led_TypeDef Led) -{ -#if !defined(USE_STM32469I_EVAL_REVA) - /* Eval Rev B and beyond */ - /* On RevB LED1 LED2 LED3 and LED4 are on GPIO PK3, 4, 5, 6 */ - if (Led <= LED4) - { - HAL_GPIO_WritePin(LEDx_GPIO_PORT, GPIO_PIN[Led], GPIO_PIN_RESET); - } -#else -#if defined(USE_IOEXPANDER) /* (USE_IOEXPANDER always defined for RevA) */ - /* GPIO_PIN[Led] depends on the board revision: */ - /* - in case of RevA all leds are on IOEXPANDER (Mfx) */ - BSP_IO_WritePin(GPIO_PIN[Led], BSP_IO_PIN_RESET); -#endif /* USE_IOEXPANDER */ -#endif /* USE_STM32469I_EVAL_REVA */ - -} - -/** - * @brief Turns selected LED Off. - * @param Led: LED to be set off - * This parameter can be one of the following values: - * @arg LED1 - * @arg LED2 - * @arg LED3 - * @arg LED4 - * @retval None - */ -void BSP_LED_Off(Led_TypeDef Led) -{ -#if !defined(USE_STM32469I_EVAL_REVA) - /* Eval Rev B and beyond */ - /* On RevB LED1 LED2 LED3 and LED4 are on GPIO PK3, 4, 5, 6 */ - if (Led <= LED4) - { - HAL_GPIO_WritePin(LEDx_GPIO_PORT, GPIO_PIN[Led], GPIO_PIN_SET); - } -#else -#if defined(USE_IOEXPANDER) /* (USE_IOEXPANDER always defined for RevA) */ - /* GPIO_PIN[Led] depends on the board revision: */ - /* - in case of RevA all leds are on IOEXPANDER (Mfx) */ - BSP_IO_WritePin(GPIO_PIN[Led], BSP_IO_PIN_SET); -#endif /* USE_IOEXPANDER */ -#endif /* USE_STM32469I_EVAL_REVA */ -} - -/** - * @brief Toggles the selected LED. - * @param Led: LED to be toggled - * This parameter can be one of the following values: - * @arg LED1 - * @arg LED2 - * @arg LED3 - * @arg LED4 - * @retval None - */ -void BSP_LED_Toggle(Led_TypeDef Led) -{ -#if !defined(USE_STM32469I_EVAL_REVA) - /* Eval Rev B and beyond */ - /* On RevB LED1 LED2 LED3 and LED4 are on GPIO PK3, 4, 5, 6 */ - if (Led <= LED4) - { - HAL_GPIO_TogglePin(LEDx_GPIO_PORT, GPIO_PIN[Led]); - } -#else -#if defined(USE_IOEXPANDER) /* (USE_IOEXPANDER always defined for RevA) */ - /* GPIO_PIN[Led] depends on the board revision: */ - /* - in case of RevA all leds are on IOEXPANDER (Mfx) */ - BSP_IO_TogglePin(GPIO_PIN[Led]); -#endif /* USE_IOEXPANDER */ -#endif /* USE_STM32469I_EVAL_REVA */ -} - -/** - * @brief Configures button GPIO and EXTI Line. - * @param Button: Button to be configured - * This parameter can be one of the following values: - * @arg BUTTON_WAKEUP: Wakeup Push Button - * @arg BUTTON_TAMPER: Tamper Push Button - * @param Button_Mode: Button mode - * This parameter can be one of the following values: - * @arg BUTTON_MODE_GPIO: Button will be used as simple IO - * @arg BUTTON_MODE_EXTI: Button will be connected to EXTI line - * with interrupt generation capability - * @retval None - */ -void BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef Button_Mode) -{ - GPIO_InitTypeDef gpio_init_structure; - - /* Enable the BUTTON clock */ - BUTTONx_GPIO_CLK_ENABLE(Button); - - if(Button_Mode == BUTTON_MODE_GPIO) - { - /* Configure Button pin as input */ - gpio_init_structure.Pin = BUTTON_PIN[Button]; - gpio_init_structure.Mode = GPIO_MODE_INPUT; - gpio_init_structure.Pull = GPIO_NOPULL; - gpio_init_structure.Speed = GPIO_SPEED_FAST; - HAL_GPIO_Init(BUTTON_PORT[Button], &gpio_init_structure); - } - - if(Button_Mode == BUTTON_MODE_EXTI) - { - /* Configure Button pin as input with External interrupt */ - gpio_init_structure.Pin = BUTTON_PIN[Button]; - gpio_init_structure.Pull = GPIO_NOPULL; - gpio_init_structure.Speed = GPIO_SPEED_FAST; - - if(Button != BUTTON_WAKEUP) - { - gpio_init_structure.Mode = GPIO_MODE_IT_FALLING; - } - else - { - gpio_init_structure.Mode = GPIO_MODE_IT_RISING; - } - - HAL_GPIO_Init(BUTTON_PORT[Button], &gpio_init_structure); - - /* Enable and set Button EXTI Interrupt to the lowest priority */ - HAL_NVIC_SetPriority((IRQn_Type)(BUTTON_IRQn[Button]), 0x0F, 0x00); - HAL_NVIC_EnableIRQ((IRQn_Type)(BUTTON_IRQn[Button])); - } -} - -/** - * @brief Push Button DeInit. - * @param Button: Button to be configured - * This parameter can be one of the following values: - * @arg BUTTON_WAKEUP: Wakeup Push Button - * @arg BUTTON_TAMPER: Tamper Push Button - * @note PB DeInit does not disable the GPIO clock - * @retval None - */ -void BSP_PB_DeInit(Button_TypeDef Button) -{ - GPIO_InitTypeDef gpio_init_structure; - - gpio_init_structure.Pin = BUTTON_PIN[Button]; - HAL_NVIC_DisableIRQ((IRQn_Type)(BUTTON_IRQn[Button])); - HAL_GPIO_DeInit(BUTTON_PORT[Button], gpio_init_structure.Pin); -} - - -/** - * @brief Returns the selected button state. - * @param Button: Button to be checked - * This parameter can be one of the following values: - * @arg BUTTON_WAKEUP: Wakeup Push Button - * @arg BUTTON_TAMPER: Tamper Push Button - * @retval The Button GPIO pin value - */ -uint32_t BSP_PB_GetState(Button_TypeDef Button) -{ - return HAL_GPIO_ReadPin(BUTTON_PORT[Button], BUTTON_PIN[Button]); -} - -/** - * @brief Configures COM port. - * @param COM: COM port to be configured. - * This parameter can be one of the following values: - * @arg COM1 - * @arg COM2 - * @param huart: Pointer to a UART_HandleTypeDef structure that contains the - * configuration information for the specified USART peripheral. - * @retval None - */ -void BSP_COM_Init(COM_TypeDef COM, UART_HandleTypeDef *huart) -{ - GPIO_InitTypeDef gpio_init_structure; - - /* Enable GPIO clock of GPIO port supporting COM_TX and COM_RX pins */ - EVAL_COMx_TX_RX_GPIO_CLK_ENABLE(COM); - - /* Enable USART clock */ - EVAL_COMx_CLK_ENABLE(COM); - - /* Configure USART Tx as alternate function */ - gpio_init_structure.Pin = COM_TX_PIN[COM]; - gpio_init_structure.Mode = GPIO_MODE_AF_PP; - gpio_init_structure.Pull = GPIO_PULLUP; - gpio_init_structure.Speed = GPIO_SPEED_HIGH; - gpio_init_structure.Alternate = COM_TX_AF[COM]; - HAL_GPIO_Init(COM_TX_PORT[COM], &gpio_init_structure); - - /* Configure USART Rx as alternate function */ - gpio_init_structure.Pin = COM_RX_PIN[COM]; - HAL_GPIO_Init(COM_RX_PORT[COM], &gpio_init_structure); - - /* USART configuration */ - huart->Instance = COM_USART[COM]; - HAL_UART_Init(huart); -} - -/** - * @brief DeInit COM port. - * @param COM: COM port to be configured. - * This parameter can be one of the following values: - * @arg COM1 - * @arg COM2 - * @param huart: Pointer to a UART_HandleTypeDef structure that contains the - * configuration information for the specified USART peripheral. - * @retval None - */ -void BSP_COM_DeInit(COM_TypeDef COM, UART_HandleTypeDef *huart) -{ - /* USART configuration */ - huart->Instance = COM_USART[COM]; - HAL_UART_DeInit(huart); - - /* Enable USART clock */ - EVAL_COMx_CLK_DISABLE(COM); - - /* DeInit GPIO pins can be done in the application - (by surcharging this __weak function) */ - - /* GPOI pins clock, FMC clock and DMA clock can be shut down in the applic - by surcgarging this __weak function */ -} -#if defined(USE_IOEXPANDER) - -/** - * @brief Configures joystick GPIO and EXTI modes. - * @param Joy_Mode: Button mode. - * This parameter can be one of the following values: - * @arg JOY_MODE_GPIO: Joystick pins will be used as simple IOs - * @arg JOY_MODE_EXTI: Joystick pins will be connected to EXTI line - * with interrupt generation capability - * @retval IO_OK: if all initializations are OK. Other value if error. - */ -uint8_t BSP_JOY_Init(JOYMode_TypeDef Joy_Mode) -{ - uint8_t ret = 0; - - /* Initialize the IO functionalities */ - ret = BSP_IO_Init(); - - /* Configure joystick pins in IT mode */ - if(Joy_Mode == JOY_MODE_EXTI) - { - /* Configure IO interrupt acquisition mode */ - BSP_IO_ConfigPin(JOY_ALL_PINS, IO_MODE_IT_LOW_LEVEL_PU); - } - else - { - BSP_IO_ConfigPin(JOY_ALL_PINS, IO_MODE_INPUT_PU); - } - - return ret; -} - - -/** - * @brief DeInit joystick GPIOs. - * @note JOY DeInit does not disable the Mfx, just set the Mfx pins in Off mode - */ -void BSP_JOY_DeInit() -{ - BSP_IO_ConfigPin(JOY_ALL_PINS, IO_MODE_OFF); -} - -/** - * @brief Returns the current joystick status. - * @retval Code of the joystick key pressed - * This code can be one of the following values: - * @arg JOY_NONE - * @arg JOY_SEL - * @arg JOY_DOWN - * @arg JOY_LEFT - * @arg JOY_RIGHT - * @arg JOY_UP - */ -JOYState_TypeDef BSP_JOY_GetState(void) -{ - uint16_t pin_status = 0; - - /* Read the status joystick pins */ - pin_status = BSP_IO_ReadPin(JOY_ALL_PINS); - - /* Check the pressed keys */ - if((pin_status & JOY_NONE_PIN) == JOY_NONE) - { - return(JOYState_TypeDef) JOY_NONE; - } - else if(!(pin_status & JOY_SEL_PIN)) - { - return(JOYState_TypeDef) JOY_SEL; - } - else if(!(pin_status & JOY_DOWN_PIN)) - { - return(JOYState_TypeDef) JOY_DOWN; - } - else if(!(pin_status & JOY_LEFT_PIN)) - { - return(JOYState_TypeDef) JOY_LEFT; - } - else if(!(pin_status & JOY_RIGHT_PIN)) - { - return(JOYState_TypeDef) JOY_RIGHT; - } - else if(!(pin_status & JOY_UP_PIN)) - { - return(JOYState_TypeDef) JOY_UP; - } - else - { - return(JOYState_TypeDef) JOY_NONE; - } -} -#endif /* USE_IOEXPANDER */ - -/** - * @} - */ - -/** @defgroup STM32469I_EVAL_LOW_LEVEL_Private_Functions STM32469I_EVAL_LOW_LEVEL Private Functions - * @{ - */ - - -/******************************************************************************* - BUS OPERATIONS -*******************************************************************************/ - -/******************************* I2C Routines *********************************/ -/** - * @brief Initializes I2C MSP. - */ -static void I2Cx_MspInit(void) -{ - GPIO_InitTypeDef gpio_init_structure; - - /*** Configure the GPIOs ***/ - /* Enable GPIO clock */ - EVAL_I2Cx_SCL_SDA_GPIO_CLK_ENABLE(); - - /* Configure I2C Tx as alternate function */ - gpio_init_structure.Pin = EVAL_I2Cx_SCL_PIN; - gpio_init_structure.Mode = GPIO_MODE_AF_OD; - gpio_init_structure.Pull = GPIO_NOPULL; - gpio_init_structure.Speed = GPIO_SPEED_FAST; - gpio_init_structure.Alternate = EVAL_I2Cx_SCL_SDA_AF; - HAL_GPIO_Init(EVAL_I2Cx_SCL_SDA_GPIO_PORT, &gpio_init_structure); - - /* Configure I2C Rx as alternate function */ - gpio_init_structure.Pin = EVAL_I2Cx_SDA_PIN; - HAL_GPIO_Init(EVAL_I2Cx_SCL_SDA_GPIO_PORT, &gpio_init_structure); - - /*** Configure the I2C peripheral ***/ - /* Enable I2C clock */ - EVAL_I2Cx_CLK_ENABLE(); - - /* Force the I2C peripheral clock reset */ - EVAL_I2Cx_FORCE_RESET(); - - /* Release the I2C peripheral clock reset */ - EVAL_I2Cx_RELEASE_RESET(); - - /* Enable and set I2Cx Interrupt to a lower priority */ - HAL_NVIC_SetPriority(EVAL_I2Cx_EV_IRQn, 0x05, 0); - HAL_NVIC_EnableIRQ(EVAL_I2Cx_EV_IRQn); - - /* Enable and set I2Cx Interrupt to a lower priority */ - HAL_NVIC_SetPriority(EVAL_I2Cx_ER_IRQn, 0x05, 0); - HAL_NVIC_EnableIRQ(EVAL_I2Cx_ER_IRQn); -} - -/** - * @brief Initializes I2C HAL. - */ -static void I2Cx_Init(void) -{ - if(HAL_I2C_GetState(&heval_I2c) == HAL_I2C_STATE_RESET) - { - heval_I2c.Instance = I2C1; - heval_I2c.Init.ClockSpeed = I2C_SCL_FREQ_KHZ; - heval_I2c.Init.DutyCycle = I2C_DUTYCYCLE_2; - heval_I2c.Init.OwnAddress1 = 0; - heval_I2c.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT; - heval_I2c.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE; - heval_I2c.Init.OwnAddress2 = 0; - heval_I2c.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE; - heval_I2c.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE; - - /* Init the I2C */ - I2Cx_MspInit(); - HAL_I2C_Init(&heval_I2c); - } -} - -/** - * @brief Writes a single data. - * @param Addr: I2C address - * @param Reg: Register address - * @param Value: Data to be written - */ -static void I2Cx_Write(uint8_t Addr, uint8_t Reg, uint8_t Value) -{ - HAL_StatusTypeDef status = HAL_OK; - - status = HAL_I2C_Mem_Write(&heval_I2c, - Addr, - (uint16_t)Reg, - I2C_MEMADD_SIZE_8BIT, - &Value, - 1, - 100); - - /* Check the communication status */ - if(status != HAL_OK) - { - /* Execute user timeout callback */ - I2Cx_Error(Addr); - } -} - -/** - * @brief Reads a single data. - * @param Addr: I2C address - * @param Reg: Register address - * @retval Read data - */ -static uint8_t I2Cx_Read(uint8_t Addr, uint8_t Reg) -{ - HAL_StatusTypeDef status = HAL_OK; - uint8_t Value = 0; - - status = HAL_I2C_Mem_Read(&heval_I2c, - Addr, - Reg, - I2C_MEMADD_SIZE_8BIT, - &Value, - 1, - 1000); - - /* Check the communication status */ - if(status != HAL_OK) - { - /* Execute user timeout callback */ - I2Cx_Error(Addr); - } - return Value; -} - -/** - * @brief Reads multiple data. - * @param Addr: I2C address - * @param Reg: Reg address - * @param MemAddress: memory address - * @param Buffer: Pointer to data buffer - * @param Length: Length of the data - * @retval HAL status - */ -static HAL_StatusTypeDef I2Cx_ReadMultiple(uint8_t Addr, - uint16_t Reg, - uint16_t MemAddress, - uint8_t *Buffer, - uint16_t Length) -{ - HAL_StatusTypeDef status = HAL_OK; - - status = HAL_I2C_Mem_Read(&heval_I2c, - Addr, - (uint16_t)Reg, - MemAddress, - Buffer, - Length, - 1000); - - /* Check the communication status */ - if(status != HAL_OK) - { - /* I2C error occured */ - I2Cx_Error(Addr); - } - return status; -} - -/** - * @brief Writes a value in a register of the device through BUS in using DMA mode. - * @param Addr: Device address on BUS Bus. - * @param Reg: The target register address to write - * @param MemAddress: memory address - * @param Buffer: The target register value to be written - * @param Length: buffer size to be written - * @retval HAL status - */ -static HAL_StatusTypeDef I2Cx_WriteMultiple(uint8_t Addr, - uint16_t Reg, - uint16_t MemAddress, - uint8_t *Buffer, - uint16_t Length) -{ - HAL_StatusTypeDef status = HAL_OK; - - status = HAL_I2C_Mem_Write(&heval_I2c, - Addr, - (uint16_t)Reg, - MemAddress, - Buffer, - Length, - 1000); - - /* Check the communication status */ - if(status != HAL_OK) - { - /* Re-Initiaize the I2C Bus */ - I2Cx_Error(Addr); - } - return status; -} - -/** - * @brief Checks if target device is ready for communication. - * @note This function is used with Memory devices - * @param DevAddress: Target device address - * @param Trials: Number of trials - * @retval HAL status - */ -static HAL_StatusTypeDef I2Cx_IsDeviceReady(uint16_t DevAddress, uint32_t Trials) -{ - return (HAL_I2C_IsDeviceReady(&heval_I2c, DevAddress, Trials, 1000)); -} - -/** - * @brief Manages error callback by re-initializing I2C. - * @param Addr: I2C Address - * @retval None - */ -static void I2Cx_Error(uint8_t Addr) -{ - /* De-initialize the I2C comunication bus */ - HAL_I2C_DeInit(&heval_I2c); - - /* Re-Initiaize the I2C comunication bus */ - I2Cx_Init(); -} - -/** - * @} - */ - -/******************************************************************************* - LINK OPERATIONS -*******************************************************************************/ - -/********************************* LINK IOE ***********************************/ - -/** - * @brief Initializes IOE low level. - */ -void IOE_Init(void) -{ - I2Cx_Init(); -} - -/** - * @brief Configures IOE low level interrupt. - */ -void IOE_ITConfig(void) -{ - static uint8_t IOE_IT_Enabled = 0; - /* GPIO_InitTypeDef GPIO_InitStruct; */ - - if(IOE_IT_Enabled == 0) - { - IOE_IT_Enabled = 1; - - /* to be implemented */ - } -} - -/** - * @brief IOE writes single data. - * @param Addr: I2C address - * @param Reg: Register address - * @param Value: Data to be written - */ -void IOE_Write(uint8_t Addr, uint8_t Reg, uint8_t Value) -{ - I2Cx_Write(Addr, Reg, Value); -} - -/** - * @brief IOE reads single data. - * @param Addr: I2C address - * @param Reg: Register address - * @retval Read data - */ -uint8_t IOE_Read(uint8_t Addr, uint8_t Reg) -{ - return I2Cx_Read(Addr, Reg); -} - -/** - * @brief IOE reads multiple data. - * @param Addr: I2C address - * @param Reg: Register address - * @param Buffer: Pointer to data buffer - * @param Length: Length of the data - * @retval Number of read data - */ -uint16_t IOE_ReadMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length) -{ - return I2Cx_ReadMultiple(Addr, (uint16_t)Reg, I2C_MEMADD_SIZE_8BIT, Buffer, Length); -} - -/** - * @brief IOE writes multiple data. - * @param Addr: I2C address - * @param Reg: Register address - * @param Buffer: Pointer to data buffer - * @param Length: Length of the data - */ -void IOE_WriteMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length) -{ - I2Cx_WriteMultiple(Addr, (uint16_t)Reg, I2C_MEMADD_SIZE_8BIT, Buffer, Length); -} - -/** - * @brief IOE delay - * @param Delay: Delay in ms - */ -void IOE_Delay(uint32_t Delay) -{ - HAL_Delay(Delay); -} - -#if defined(USE_IOEXPANDER) - -/********************************* LINK MFX ***********************************/ - -/** - * @brief Initializes MFX low level. - */ -void MFX_IO_Init(void) -{ - I2Cx_Init(); -} - -/** - * @brief DeInitializes MFX low level. - */ -void MFX_IO_DeInit(void) -{ -} - -/** - * @brief Configures MFX low level interrupt. - */ -void MFX_IO_ITConfig(void) -{ - static uint8_t MFX_IO_IT_Enabled = 0; - GPIO_InitTypeDef gpio_init_structure; - - if(MFX_IO_IT_Enabled == 0) - { - MFX_IO_IT_Enabled = 1; - /* Enable the GPIO EXTI clock */ - __HAL_RCC_GPIOI_CLK_ENABLE(); - __HAL_RCC_SYSCFG_CLK_ENABLE(); - - gpio_init_structure.Pin = GPIO_PIN_8; - gpio_init_structure.Pull = GPIO_NOPULL; - gpio_init_structure.Speed = GPIO_SPEED_LOW; - gpio_init_structure.Mode = GPIO_MODE_IT_RISING; - HAL_GPIO_Init(GPIOI, &gpio_init_structure); - - /* Enable and set GPIO EXTI Interrupt to the lowest priority */ - HAL_NVIC_SetPriority((IRQn_Type)(EXTI9_5_IRQn), 0x0F, 0x0F); - HAL_NVIC_EnableIRQ((IRQn_Type)(EXTI9_5_IRQn)); - } -} - -/** - * @brief MFX writes single data. - * @param Addr: I2C address - * @param Reg: Register address - * @param Value: Data to be written - */ -void MFX_IO_Write(uint16_t Addr, uint8_t Reg, uint8_t Value) -{ - I2Cx_Write((uint8_t) Addr, Reg, Value); -} - -/** - * @brief MFX reads single data. - * @param Addr: I2C address - * @param Reg: Register address - * @retval Read data - */ -uint8_t MFX_IO_Read(uint16_t Addr, uint8_t Reg) -{ - return I2Cx_Read((uint8_t) Addr, Reg); -} - -/** - * @brief MFX reads multiple data. - * @param Addr: I2C address - * @param Reg: Register address - * @param Buffer: Pointer to data buffer - * @param Length: Length of the data - * @retval Number of read data - */ -uint16_t MFX_IO_ReadMultiple(uint16_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length) -{ - return I2Cx_ReadMultiple((uint8_t)Addr, (uint16_t)Reg, I2C_MEMADD_SIZE_8BIT, Buffer, Length); -} - -/** - * @brief MFX delay - * @param Delay: Delay in ms - */ -void MFX_IO_Delay(uint32_t Delay) -{ - HAL_Delay(Delay); -} - -/** - * @brief Used by Lx family but requested for MXF component compatibility. - */ -void MFX_IO_Wakeup(void) -{ -} - -/** - * @brief Used by Lx family but requested for MXF component compatibility. - */ -void MFX_IO_EnableWakeupPin(void) -{ -} - -#endif /* USE_IOEXPANDER */ - -/********************************* LINK AUDIO *********************************/ - -/** - * @brief Initializes Audio low level. - */ -void AUDIO_IO_Init(void) -{ - I2Cx_Init(); -} - -/** - * @brief DeInitializes Audio low level. - */ -void AUDIO_IO_DeInit(void) -{ - -} - -/** - * @brief Writes a single data. - * @param Addr: I2C address - * @param Reg: Reg address - * @param Value: Data to be written - */ -void AUDIO_IO_Write(uint8_t Addr, uint16_t Reg, uint16_t Value) -{ - uint16_t tmp = Value; - - Value = ((uint16_t)(tmp >> 8) & 0x00FF); - - Value |= ((uint16_t)(tmp << 8)& 0xFF00); - - I2Cx_WriteMultiple(Addr, Reg, I2C_MEMADD_SIZE_16BIT,(uint8_t*)&Value, 2); -} - -/** - * @brief Reads a single data. - * @param Addr: I2C address - * @param Reg: Reg address - * @retval Data to be read - */ -uint16_t AUDIO_IO_Read(uint8_t Addr, uint16_t Reg) -{ - uint16_t read_value = 0, tmp = 0; - - I2Cx_ReadMultiple(Addr, Reg, I2C_MEMADD_SIZE_16BIT, (uint8_t*)&read_value, 2); - - tmp = ((uint16_t)(read_value >> 8) & 0x00FF); - - tmp |= ((uint16_t)(read_value << 8)& 0xFF00); - - read_value = tmp; - - return read_value; -} - -/** - * @brief AUDIO Codec delay - * @param Delay: Delay in ms - */ -void AUDIO_IO_Delay(uint32_t Delay) -{ - HAL_Delay(Delay); -} - -/********************************* LINK CAMERA ********************************/ - -/** - * @brief Initializes Camera low level. - */ -void CAMERA_IO_Init(void) -{ - I2Cx_Init(); -} - -/** - * @brief Camera writes single data. - * @param Addr: I2C address - * @param Reg: Register address - * @param Value: Data to be written - */ -void CAMERA_IO_Write(uint8_t Addr, uint16_t Reg, uint16_t Value) -{ - uint16_t tmp = Value; - /* For S5K5CAG sensor, 16 bits accesses are used */ - Value = ((uint16_t)(tmp >> 8) & 0x00FF); - Value |= ((uint16_t)(tmp << 8)& 0xFF00); - I2Cx_WriteMultiple(Addr, Reg, I2C_MEMADD_SIZE_16BIT,(uint8_t*)&Value, 2); -} - -/** - * @brief Camera reads single data. - * @param Addr: I2C address - * @param Reg: Register address - * @retval Read data - */ -uint16_t CAMERA_IO_Read(uint8_t Addr, uint16_t Reg) -{ - uint16_t read_value = 0, tmp = 0; - /* For S5K5CAG sensor, 16 bits accesses are used */ - I2Cx_ReadMultiple(Addr, Reg, I2C_MEMADD_SIZE_16BIT, (uint8_t*)&read_value, 2); - tmp = ((uint16_t)(read_value >> 8) & 0x00FF); - tmp |= ((uint16_t)(read_value << 8)& 0xFF00); - read_value = tmp; - - return read_value; -} - -/** - * @brief Camera delay - * @param Delay: Delay in ms - */ -void CAMERA_Delay(uint32_t Delay) -{ - HAL_Delay(Delay); -} - -/******************************** LINK I2C EEPROM *****************************/ - -/** - * @brief Initializes peripherals used by the I2C EEPROM driver. - */ -void EEPROM_IO_Init(void) -{ - I2Cx_Init(); -} - -/** - * @brief Write data to I2C EEPROM driver in using DMA channel. - * @param DevAddress: Target device address - * @param MemAddress: Internal memory address - * @param pBuffer: Pointer to data buffer - * @param BufferSize: Amount of data to be sent - * @retval HAL status - */ -HAL_StatusTypeDef EEPROM_IO_WriteData(uint16_t DevAddress, uint16_t MemAddress, uint8_t* pBuffer, uint32_t BufferSize) -{ - return (I2Cx_WriteMultiple(DevAddress, MemAddress, I2C_MEMADD_SIZE_16BIT, pBuffer, BufferSize)); -} - -/** - * @brief Read data from I2C EEPROM driver in using DMA channel. - * @param DevAddress: Target device address - * @param MemAddress: Internal memory address - * @param pBuffer: Pointer to data buffer - * @param BufferSize: Amount of data to be read - * @retval HAL status - */ -HAL_StatusTypeDef EEPROM_IO_ReadData(uint16_t DevAddress, uint16_t MemAddress, uint8_t* pBuffer, uint32_t BufferSize) -{ - return (I2Cx_ReadMultiple(DevAddress, MemAddress, I2C_MEMADD_SIZE_16BIT, pBuffer, BufferSize)); -} - -/** - * @brief Checks if target device is ready for communication. - * @note This function is used with Memory devices - * @param DevAddress: Target device address - * @param Trials: Number of trials - * @retval HAL status - */ -HAL_StatusTypeDef EEPROM_IO_IsDeviceReady(uint16_t DevAddress, uint32_t Trials) -{ - return (I2Cx_IsDeviceReady(DevAddress, Trials)); -} - -/******************************** LINK TS (TouchScreen) *****************************/ - -/** - * @brief Initialize I2C communication - * channel from MCU to TouchScreen (TS). - */ -void TS_IO_Init(void) -{ - I2Cx_Init(); -} - -/** - * @brief Writes single data with I2C communication - * channel from MCU to TouchScreen. - * @param Addr: I2C address - * @param Reg: Register address - * @param Value: Data to be written - */ -void TS_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value) -{ - I2Cx_Write(Addr, Reg, Value); -} - -/** - * @brief Reads single data with I2C communication - * channel from TouchScreen. - * @param Addr: I2C address - * @param Reg: Register address - * @retval Read data - */ -uint8_t TS_IO_Read(uint8_t Addr, uint8_t Reg) -{ - return I2Cx_Read(Addr, Reg); -} - -/** - * @brief Reads multiple data with I2C communication - * channel from TouchScreen. - * @param Addr: I2C address - * @param Reg: Register address - * @param Buffer: Pointer to data buffer - * @param Length: Length of the data - * @retval Number of read data - */ -uint16_t TS_IO_ReadMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length) -{ - return I2Cx_ReadMultiple(Addr, (uint16_t)Reg, I2C_MEMADD_SIZE_8BIT, Buffer, Length); -} - -/** - * @brief Writes multiple data with I2C communication - * channel from MCU to TouchScreen. - * @param Addr: I2C address - * @param Reg: Register address - * @param Buffer: Pointer to data buffer - * @param Length: Length of the data - * @retval None - */ -void TS_IO_WriteMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length) -{ - I2Cx_WriteMultiple(Addr, (uint16_t)Reg, I2C_MEMADD_SIZE_8BIT, Buffer, Length); -} - -/** - * @brief Delay function used in TouchScreen low level driver. - * @param Delay: Delay in ms - * @retval None - */ -void TS_IO_Delay(uint32_t Delay) -{ - HAL_Delay(Delay); -} - -/**************************** LINK OTM8009A (Display driver) ******************/ -/** - * @brief OTM8009A delay - * @param Delay: Delay in ms - */ -void OTM8009A_IO_Delay(uint32_t Delay) -{ - HAL_Delay(Delay); -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval.h b/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval.h deleted file mode 100644 index 057668e6af..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval.h +++ /dev/null @@ -1,438 +0,0 @@ -/** - ****************************************************************************** - * @file stm32469i_eval.h - * @author MCD Application Team - * @version V1.0.1 - * @date 29-September-2015 - * @brief This file contains definitions for STM32469I-EVAL's LEDs, - * push-buttons and COM ports hardware resources. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32469I_EVAL_H -#define __STM32469I_EVAL_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* USE_STM32469I_EVAL_REVA must USE USE_IOEXPANDER */ -#if defined(USE_STM32469I_EVAL_REVA) -#ifndef USE_IOEXPANDER -#define USE_IOEXPANDER -#endif /* USE_IOEXPANDER */ -#endif /* USE_STM32469I_EVAL_REVA */ - - /* Includes ------------------------------------------------------------------*/ -#include "stm32f4xx_hal.h" - -/** @addtogroup BSP - * @{ - */ - - -/** @addtogroup STM32469I_EVAL - * @{ - */ - -/** @defgroup STM32469I_EVAL_LOW_LEVEL STM32469I-EVAL LOW LEVEL - * @{ - */ - -/** @defgroup STM32469I_EVAL_LOW_LEVEL_Exported_Types STM32469I EVAL Low Level Exported Types - * @{ - */ - -/** @brief Led_TypeDef - * STM32469I_EVAL board leds definitions. - */ -typedef enum -{ - LED1 = 0, - LED_GREEN = LED1, - LED2 = 1, - LED_ORANGE = LED2, - LED3 = 2, - LED_RED = LED3, - LED4 = 3, - LED_BLUE = LED4 - -} Led_TypeDef; - -/** @brief Button_TypeDef - * STM32469I_EVAL board Buttons definitions. - */ -typedef enum -{ - BUTTON_WAKEUP = 0, - BUTTON_TAMPER = 1, - BUTTON_KEY = 2 - -} Button_TypeDef; - -/** @brief ButtonMode_TypeDef - * STM32469I_EVAL board Buttons Modes definitions. - */ -typedef enum -{ - BUTTON_MODE_GPIO = 0, - BUTTON_MODE_EXTI = 1 - -} ButtonMode_TypeDef; - -#if defined(USE_IOEXPANDER) -/** @brief JOYMode_TypeDef - * STM32469I_EVAL board Joystick Mode definitions. - */ -typedef enum -{ - JOY_MODE_GPIO = 0, - JOY_MODE_EXTI = 1 - -} JOYMode_TypeDef; - -/** @brief JOYState_TypeDef - * STM32469I_EVAL board Joystick State definitions. - */ -typedef enum -{ - JOY_NONE = 0, - JOY_SEL = 1, - JOY_DOWN = 2, - JOY_LEFT = 3, - JOY_RIGHT = 4, - JOY_UP = 5 - -} JOYState_TypeDef; -#endif /* USE_IOEXPANDER */ - -/** @brief COM_TypeDef - * STM32469I_EVAL board COM ports. - */ -typedef enum -{ - COM1 = 0, - COM2 = 1 - -} COM_TypeDef; - -/** @brief EVAL_Status_TypeDef - * STM32469I_EVAL board Eval Status return possible values. - */ -typedef enum -{ - EVAL_OK = 0, - EVAL_ERROR = 1 - -} EVAL_Status_TypeDef; - -/** - * @} - */ - -/** @defgroup STM32469I_EVAL_LOW_LEVEL_Exported_Constants STM32469I EVAL Low Level Exported Constants - * @{ - */ - -/** - * @brief Define for STM32469I_EVAL board - */ -#if !defined (USE_STM32469I_EVAL) - #define USE_STM32469I_EVAL -#endif - -/** @addtogroup STM32469I_EVAL_LOW_LEVEL_LED STM32469I EVAL Low Level Led - * @{ - */ -/* Always four leds for all revisions of Eval boards */ -#define LEDn ((uint8_t)4) - -#if !defined(USE_STM32469I_EVAL_REVA) -/* Rev B board and beyond : 4 Leds are connected to MCU directly and not via MFX */ -/* PK3, PK4, PK5, PK6 are used */ -#define LEDx_GPIO_PORT GPIOK -#define LEDx_GPIO_CLK_ENABLE() __HAL_RCC_GPIOK_CLK_ENABLE() -#define LEDx_GPIO_CLK_DISABLE() __HAL_RCC_GPIOK_CLK_DISABLE() -#define LED1_PIN GPIO_PIN_3 -#define LED2_PIN GPIO_PIN_4 -#define LED3_PIN GPIO_PIN_5 -#define LED4_PIN GPIO_PIN_6 -#else -/* Eval Rev A board */ -#define LED1_PIN IO_PIN_16 -#define LED2_PIN IO_PIN_17 -#define LED3_PIN IO_PIN_18 -#define LED4_PIN IO_PIN_19 -#endif /* USE_STM32469I_EVAL_REVA */ -/** - * @} - */ - -/** - * @brief MFX_IRQOUt pin - */ -#define MFX_IRQOUT_PIN GPIO_PIN_8 -#define MFX_IRQOUT_GPIO_PORT GPIOI -#define MFX_IRQOUT_GPIO_CLK_ENABLE() __HAL_RCC_GPIOI_CLK_ENABLE() -#define MFX_IRQOUT_GPIO_CLK_DISABLE() __HAL_RCC_GPIOI_CLK_DISABLE() -#define MFX_IRQOUT_EXTI_IRQn EXTI9_5_IRQn -#define MFX_IRQOUT_EXTI_IRQnHandler EXTI9_5_IRQHandler - -/** @addtogroup STM32469I_EVAL_LOW_LEVEL_BUTTON STM32469I EVAL Low Level Button - * @{ - */ -/* Joystick pins are connected to IO Expander (accessible through I2C1 interface) */ -#define BUTTONn ((uint8_t)3) - -/** - * @brief Wakeup push-button - */ -#define WAKEUP_BUTTON_PIN GPIO_PIN_0 -#define WAKEUP_BUTTON_GPIO_PORT GPIOA -#define WAKEUP_BUTTON_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE() -#define WAKEUP_BUTTON_GPIO_CLK_DISABLE() __HAL_RCC_GPIOA_CLK_DISABLE() -#define WAKEUP_BUTTON_EXTI_IRQn EXTI0_IRQn - -/** - * @brief Tamper push-button - */ -#define TAMPER_BUTTON_PIN GPIO_PIN_13 -#define TAMPER_BUTTON_GPIO_PORT GPIOC -#define TAMPER_BUTTON_GPIO_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE() -#define TAMPER_BUTTON_GPIO_CLK_DISABLE() __HAL_RCC_GPIOC_CLK_DISABLE() -#define TAMPER_BUTTON_EXTI_IRQn EXTI15_10_IRQn - -/** - * @brief Key push-button - */ -#define KEY_BUTTON_PIN GPIO_PIN_13 -#define KEY_BUTTON_GPIO_PORT GPIOC -#define KEY_BUTTON_GPIO_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE() -#define KEY_BUTTON_GPIO_CLK_DISABLE() __HAL_RCC_GPIOC_CLK_DISABLE() -#define KEY_BUTTON_EXTI_IRQn EXTI15_10_IRQn - -#define BUTTONx_GPIO_CLK_ENABLE(__INDEX__) do { if((__INDEX__) == 0) {WAKEUP_BUTTON_GPIO_CLK_ENABLE();} else\ - if((__INDEX__) == 1) {TAMPER_BUTTON_GPIO_CLK_ENABLE();} else\ - {KEY_BUTTON_GPIO_CLK_ENABLE(); }} while(0) - -#define BUTTONx_GPIO_CLK_DISABLE(__INDEX__) (((__INDEX__) == 0) ? WAKEUP_BUTTON_GPIO_CLK_DISABLE() :\ - ((__INDEX__) == 1) ? TAMPER_BUTTON_GPIO_CLK_DISABLE() : KEY_BUTTON_GPIO_CLK_DISABLE()) -/** - * @} - */ - -/** @addtogroup STM32469I_EVAL_LOW_LEVEL_COM - * @{ - */ -#define COMn ((uint8_t)1) - -/** - * @brief Definition for COM port1, connected to USART1 - */ -#define EVAL_COM1 USART1 -#define EVAL_COM1_CLK_ENABLE() __HAL_RCC_USART1_CLK_ENABLE() -#define EVAL_COM1_CLK_DISABLE() __HAL_RCC_USART1_CLK_DISABLE() - -#define EVAL_COM1_TX_PIN GPIO_PIN_9 -#define EVAL_COM1_RX_PIN GPIO_PIN_10 -#define EVAL_COM1_TX_GPIO_PORT GPIOA -#define EVAL_COM1_RX_GPIO_PORT EVAL_COM1_TX_GPIO_PORT - -#define EVAL_COM1_TX_AF GPIO_AF7_USART1 -#define EVAL_COM1_RX_AF EVAL_COM1_TX_AF - -#define EVAL_COM1_TX_RX_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE() -#define EVAL_COM1_TX_RX_GPIO_CLK_DISABLE() __HAL_RCC_GPIOA_CLK_DISABLE() - -#define EVAL_COM1_IRQn USART1_IRQn - -#define EVAL_COMx_CLK_ENABLE(__INDEX__) do { if((__INDEX__) == 0) {EVAL_COM1_CLK_ENABLE();} } while(0) -#define EVAL_COMx_CLK_DISABLE(__INDEX__) (((__INDEX__) == 0) ? EVAL_COM1_CLK_DISABLE() : 0) - -#define EVAL_COMx_TX_RX_GPIO_CLK_ENABLE(__INDEX__) do { if((__INDEX__) == 0) {EVAL_COM1_TX_RX_GPIO_CLK_ENABLE();} } while(0) -#define EVAL_COMx_TX_RX_GPIO_CLK_DISABLE(__INDEX__) (((__INDEX__) == 0) ? EVAL_COM1_TX_RX_GPIO_CLK_DISABLE() : 0) - -/** - * @brief Joystick Pins definition - */ -#if defined(USE_IOEXPANDER) -#define JOY_SEL_PIN IO_PIN_0 -#define JOY_DOWN_PIN IO_PIN_1 -#define JOY_LEFT_PIN IO_PIN_2 -#define JOY_RIGHT_PIN IO_PIN_3 -#define JOY_UP_PIN IO_PIN_4 -#define JOY_NONE_PIN JOY_ALL_PINS -#define JOY_ALL_PINS (IO_PIN_0 | IO_PIN_1 | IO_PIN_2 | IO_PIN_3 | IO_PIN_4) -#endif /* USE_IOEXPANDER */ - -/** - * @brief Eval Pins definition - */ -#if defined(USE_IOEXPANDER) -#define XSDN_PIN IO_PIN_10 -#define MII_INT_PIN IO_PIN_13 -#define RSTI_PIN IO_PIN_11 -#define CAM_PLUG_PIN IO_PIN_12 -#define TS_INT_PIN IO_PIN_14 -#define AUDIO_INT_PIN IO_PIN_5 -#define OTG_FS1_OVER_CURRENT_PIN IO_PIN_6 -#define OTG_FS1_POWER_SWITCH_PIN IO_PIN_7 -#define OTG_FS2_OVER_CURRENT_PIN IO_PIN_8 -#define OTG_FS2_POWER_SWITCH_PIN IO_PIN_9 -#define SD_DETECT_PIN IO_PIN_15 -#endif /* USE_IOEXPANDER */ - -/* Exported constant IO ------------------------------------------------------*/ - -/** - * @brief TouchScreen FT6206 Slave I2C address - */ -#define TS_I2C_ADDRESS ((uint16_t)0x54) - -/** - * @brief MFX_I2C_ADDR 0 - */ -#define IO_I2C_ADDRESS ((uint16_t)0x84) - -/** - * @brief Camera I2C Slave address - */ -#define CAMERA_I2C_ADDRESS ((uint16_t)0x5A) - -/** - * @brief Audio I2C Slave address - */ -#define AUDIO_I2C_ADDRESS ((uint16_t)0x34) - -/** - * @brief EEPROM I2C Slave address 1 - */ -#define EEPROM_I2C_ADDRESS_A01 ((uint16_t)0xA0) - -/** - * @brief EEPROM I2C Slave address 2 - */ -#define EEPROM_I2C_ADDRESS_A02 ((uint16_t)0xA6) - -/** - * @brief I2C clock speed configuration (in Hz) - * WARNING: - * Make sure that this define is not already declared in other files - * It can be used in parallel by other modules. - */ -#ifndef I2C_SCL_FREQ_KHZ -#define I2C_SCL_FREQ_KHZ 400000 /*!< f(I2C_SCL) = 400 kHz */ -#endif /* I2C_SCL_FREQ_KHZ */ - -/** - * @brief User can use this section to tailor I2Cx/I2Cx instance used and associated - * resources. - * Definition for I2Cx clock resources - */ -#define EVAL_I2Cx I2C1 -#define EVAL_I2Cx_CLK_ENABLE() __HAL_RCC_I2C1_CLK_ENABLE() -#define EVAL_DMAx_CLK_ENABLE() __HAL_RCC_DMA1_CLK_ENABLE() -#define EVAL_I2Cx_SCL_SDA_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE() - -#define EVAL_I2Cx_FORCE_RESET() __HAL_RCC_I2C1_FORCE_RESET() -#define EVAL_I2Cx_RELEASE_RESET() __HAL_RCC_I2C1_RELEASE_RESET() - -/** @brief Definition for I2Cx Pins - */ -#define EVAL_I2Cx_SCL_PIN GPIO_PIN_8 /*!< PB8 */ -#define EVAL_I2Cx_SCL_SDA_GPIO_PORT GPIOB -#define EVAL_I2Cx_SCL_SDA_AF GPIO_AF4_I2C1 -#define EVAL_I2Cx_SDA_PIN GPIO_PIN_9 /*!< PB9 */ - -/** @brief Definition of I2C interrupt requests - */ -#define EVAL_I2Cx_EV_IRQn I2C1_EV_IRQn -#define EVAL_I2Cx_ER_IRQn I2C1_ER_IRQn - -/** - * @} - */ - -/** @defgroup STM32469I_EVAL_LOW_LEVEL_Exported_Macros STM32469I EVAL Low Level Exported Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I_EVAL_LOW_LEVEL_Exported_Functions STM32469I EVAL Low Level Exported Functions - * @{ - */ -uint32_t BSP_GetVersion(void); -void BSP_LED_Init(Led_TypeDef Led); -void BSP_LED_DeInit(Led_TypeDef Led); -void BSP_LED_On(Led_TypeDef Led); -void BSP_LED_Off(Led_TypeDef Led); -void BSP_LED_Toggle(Led_TypeDef Led); -void BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef Button_Mode); -void BSP_PB_DeInit(Button_TypeDef Button); -uint32_t BSP_PB_GetState(Button_TypeDef Button); -void BSP_COM_Init(COM_TypeDef COM, UART_HandleTypeDef *husart); -void BSP_COM_DeInit(COM_TypeDef COM, UART_HandleTypeDef *huart); -#if defined(USE_IOEXPANDER) -uint8_t BSP_JOY_Init(JOYMode_TypeDef Joy_Mode); -void BSP_JOY_DeInit(void); -JOYState_TypeDef BSP_JOY_GetState(void); -#endif /* USE_IOEXPANDER */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32469I_EVAL_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_audio.c b/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_audio.c deleted file mode 100644 index a460822425..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_audio.c +++ /dev/null @@ -1,1340 +0,0 @@ -/** - ****************************************************************************** - * @file stm32469i_eval_audio.c - * @author MCD Application Team - * @version V1.0.1 - * @date 29-September-2015 - * @brief This file provides the Audio driver for the STM32469I-EVAL evaluation board. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/*============================================================================== - User NOTES - -How To use this driver: ------------------------ - + This driver supports STM32F4xx devices on STM32469I-EVAL (MB1165) Evaluation boards. - + Call the function BSP_AUDIO_OUT_Init( - OutputDevice: physical output mode (OUTPUT_DEVICE_HEADPHONE1, - OUTPUT_DEVICE_HEADPHONE2 or OUTPUT_DEVICE_BOTH) - Volume : Initial volume to be set (0 is min (mute), 100 is max (100%) - AudioFreq : Audio frequency in Hz (8000, 16000, 22500, 32000...) - this parameter is relative to the audio file/stream type. - ) - This function configures all the hardware required for the audio application (codec, I2C, SAI, - GPIOs, DMA and interrupt if needed). This function returns AUDIO_OK if configuration is OK. - If the returned value is different from AUDIO_OK or the function is stuck then the communication with - the codec or the MFX has failed (try to un-plug the power or reset device in this case). - - OUTPUT_DEVICE_HEADPHONE1 : only headphones 1 will be set as output for the audio stream. - - OUTPUT_DEVICE_HEADPHONE2 : only headphones 2 will be set as output for the audio stream. - - OUTPUT_DEVICE_BOTH : both Headphones are used as outputs for the audio stream - at the same time. - Note. On STM32469I-EVAL SAI_DMA is configured in CIRCULAR mode. Due to this the application - does NOT need to call BSP_AUDIO_OUT_ChangeBuffer() to assure straming. - + Call the function BSP_EVAL_AUDIO_OUT_Play( - pBuffer: pointer to the audio data file address - Size : size of the buffer to be sent in Bytes - ) - to start playing (for the first time) from the audio file/stream. - + Call the function BSP_AUDIO_OUT_Pause() to pause playing - + Call the function BSP_AUDIO_OUT_Resume() to resume playing. - Note. After calling BSP_AUDIO_OUT_Pause() function for pause, only BSP_AUDIO_OUT_Resume() should be called - for resume (it is not allowed to call BSP_AUDIO_OUT_Play() in this case). - Note. This function should be called only when the audio file is played or paused (not stopped). - + For each mode, you may need to implement the relative callback functions into your code. - The Callback functions are named AUDIO_OUT_XXX_CallBack() and only their prototypes are declared in - the stm32469i_eval_audio.h file. (refer to the example for more details on the callbacks implementations) - + To Stop playing, to modify the volume level, the frequency, the audio frame slot, - the device output mode the mute or the stop, use the functions: BSP_AUDIO_OUT_SetVolume(), - AUDIO_OUT_SetFrequency(), BSP_AUDIO_OUT_SetAudioFrameSlot(), BSP_AUDIO_OUT_SetOutputMode(), - BSP_AUDIO_OUT_SetMute() and BSP_AUDIO_OUT_Stop(). - + The driver API and the callback functions are at the end of the stm32469i_eval_audio.h file. - -Driver architecture: --------------------- - + This driver provide the High Audio Layer: consists of the function API exported in the stm32469i_eval_audio.h file - (BSP_AUDIO_OUT_Init(), BSP_AUDIO_OUT_Play() ...) - + This driver provide also the Media Access Layer (MAL): which consists of functions allowing to access the media containing/ - providing the audio file/stream. These functions are also included as local functions into - the stm32469i_eval_audio_codec.c file (I2Sx_Init(), I2Sx_DeInit(), SAIx_Init() and SAIx_DeInit()) - -Known Limitations: ------------------- - 1- If the TDM Format used to paly in parallel 2 audio Stream (the first Stream is configured in codec SLOT0 and second - Stream in SLOT1) the Pause/Resume, volume and mute feature will control the both streams. - 2- Parsing of audio file is not implemented (in order to determine audio file properties: Mono/Stereo, Data size, - File size, Audio Frequency, Audio Data header size ...). The configuration is fixed for the given audio file. - 3- Supports only Stereo audio streaming. - 4- Supports only 16-bits audio data size. -==============================================================================*/ - -/* Includes ------------------------------------------------------------------*/ -#include "stm32469i_eval_audio.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32469I-EVAL - * @{ - */ - -/** @defgroup STM32469I-EVAL_AUDIO STM32469I-EVAL AUDIO - * @brief This file includes the low layer driver for wm8994 Audio Codec - * available on STM32469I-EVAL evaluation board(MB1165). - * @{ - */ - -/** @defgroup STM32469I-EVAL_AUDIO_Private_Types STM32469I Eval Audio Private Types - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_AUDIO_Private_Defines STM32469I Eval Audio Private Defines - * @brief Headphone1 (CN27 of STM32469I-EVAL board) is connected to the - * HEADPHONE output of wm8994 Audio Codec. - * Headphone2 (CN26 of STM32469I-EVAL board) is connected to the - * SPEAKER output of wm8994 Audio Codec. - * @{ - */ -#define OUTPUT_DEVICE_HEADPHONE1 OUTPUT_DEVICE_HEADPHONE -#define OUTPUT_DEVICE_HEADPHONE2 OUTPUT_DEVICE_SPEAKER /* Headphone2 is connected to Speaker output of the wm8994 codec */ -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_AUDIO_Private_Macros STM32469I Eval Audio Private macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_AUDIO_Private_Variables STM32469I Eval Audio Private Variables - * @{ - */ - -/* -Note: - these global variables are not compliant to naming rules (upper case without "_" ), - but we keep this naming for compatibility, in fact these variables (not static) - could have been used by the application, example the stm32f4xx_it.c: - void DMA2_Stream6_IRQHandler(void) - { HAL_DMA_IRQHandler(haudio_out_sai.hdmatx); } -*/ -AUDIO_DrvTypeDef *audio_drv; -SAI_HandleTypeDef haudio_out_sai; -I2S_HandleTypeDef haudio_in_i2s; -TIM_HandleTypeDef haudio_tim; - -PDMFilter_InitStruct Filter[2]; -uint8_t Channel_Demux[128] = { - 0x00, 0x01, 0x00, 0x01, 0x02, 0x03, 0x02, 0x03, - 0x00, 0x01, 0x00, 0x01, 0x02, 0x03, 0x02, 0x03, - 0x04, 0x05, 0x04, 0x05, 0x06, 0x07, 0x06, 0x07, - 0x04, 0x05, 0x04, 0x05, 0x06, 0x07, 0x06, 0x07, - 0x00, 0x01, 0x00, 0x01, 0x02, 0x03, 0x02, 0x03, - 0x00, 0x01, 0x00, 0x01, 0x02, 0x03, 0x02, 0x03, - 0x04, 0x05, 0x04, 0x05, 0x06, 0x07, 0x06, 0x07, - 0x04, 0x05, 0x04, 0x05, 0x06, 0x07, 0x06, 0x07, - 0x08, 0x09, 0x08, 0x09, 0x0a, 0x0b, 0x0a, 0x0b, - 0x08, 0x09, 0x08, 0x09, 0x0a, 0x0b, 0x0a, 0x0b, - 0x0c, 0x0d, 0x0c, 0x0d, 0x0e, 0x0f, 0x0e, 0x0f, - 0x0c, 0x0d, 0x0c, 0x0d, 0x0e, 0x0f, 0x0e, 0x0f, - 0x08, 0x09, 0x08, 0x09, 0x0a, 0x0b, 0x0a, 0x0b, - 0x08, 0x09, 0x08, 0x09, 0x0a, 0x0b, 0x0a, 0x0b, - 0x0c, 0x0d, 0x0c, 0x0d, 0x0e, 0x0f, 0x0e, 0x0f, - 0x0c, 0x0d, 0x0c, 0x0d, 0x0e, 0x0f, 0x0e, 0x0f -}; - -uint16_t __IO AudioInVolume = DEFAULT_AUDIO_IN_VOLUME; - -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_AUDIO_Private_Function_Prototypes STM32469I Eval Audio Private Prototypes - * @{ - */ -static void SAIx_Init(uint32_t AudioFreq); -static void SAIx_DeInit(void); -static void I2Sx_Init(uint32_t AudioFreq); -static void I2Sx_DeInit(void); -static void TIMx_IC_MspInit(TIM_HandleTypeDef *htim); -static void TIMx_IC_MspDeInit(TIM_HandleTypeDef *htim); -static void TIMx_Init(void); -static void TIMx_DeInit(void); -static void PDMDecoder_Init(uint32_t AudioFreq, uint32_t ChnlNbr); -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_AUDIO_out_Private_Functions STM32469I Eval AudioOut Private Functions - * @{ - */ - -/** - * @brief Configures the audio peripherals. - * @param OutputDevice: OUTPUT_DEVICE_HEADPHONE1, OUTPUT_DEVICE_HEADPHONE2, - * or OUTPUT_DEVICE_BOTH. - * @param Volume: Initial volume level (from 0 (Mute) to 100 (Max)) - * @param AudioFreq: Audio frequency used to play the audio stream. - * @note The I2S PLL input clock must be done in the user application. - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_Init(uint16_t OutputDevice, uint8_t Volume, uint32_t AudioFreq) -{ - uint8_t ret = AUDIO_ERROR; - uint32_t deviceid = 0x00; - - SAIx_DeInit(); - - /* PLL clock is set depending by the AudioFreq (44.1khz vs 48khz groups) */ - BSP_AUDIO_OUT_ClockConfig(&haudio_out_sai, AudioFreq, NULL); - - /* SAI data transfer preparation: - Prepare the Media to be used for the audio transfer from memory to SAI peripheral */ - haudio_out_sai.Instance = AUDIO_SAIx; - if(HAL_SAI_GetState(&haudio_out_sai) == HAL_SAI_STATE_RESET) - { - /* Init the SAI MSP: this __weak function can be redefined by the application*/ - BSP_AUDIO_OUT_MspInit(&haudio_out_sai, NULL); - } - SAIx_Init(AudioFreq); - - /* wm8994 codec initialization */ - deviceid = wm8994_drv.ReadID(AUDIO_I2C_ADDRESS); - - if((deviceid) == WM8994_ID) - { - /* Initialize the audio driver structure */ - audio_drv = &wm8994_drv; - ret = AUDIO_OK; - } - else - { - ret = AUDIO_ERROR; - } - - if(ret == AUDIO_OK) - { - /* Resets the audio codec. */ - audio_drv->Reset(AUDIO_I2C_ADDRESS); - /* Initialize the codec internal registers */ - audio_drv->Init(AUDIO_I2C_ADDRESS, OutputDevice, Volume, AudioFreq); - } - - return ret; -} - -/** - * @brief Starts playing audio stream from a data buffer for a determined size. - * @param pBuffer: Pointer to the buffer - * @param Size: Number of audio data BYTES. - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_Play(uint16_t* pBuffer, uint32_t Size) -{ - /* Call the audio Codec Play function */ - if(audio_drv->Play(AUDIO_I2C_ADDRESS, pBuffer, Size) != 0) - { - return AUDIO_ERROR; - } - else - { - /* Update the Media layer and enable it for play */ - HAL_SAI_Transmit_DMA(&haudio_out_sai, (uint8_t*) pBuffer, DMA_MAX(Size / AUDIODATA_SIZE)); - - return AUDIO_OK; - } -} - -/** - * @brief Sends n-Bytes on the SAI interface. - * @param pData: pointer on data address - * @param Size: number of data to be written - */ -void BSP_AUDIO_OUT_ChangeBuffer(uint16_t *pData, uint16_t Size) -{ - HAL_SAI_Transmit_DMA(&haudio_out_sai, (uint8_t*) pData, Size); -} - -/** - * @brief This function Pauses the audio file stream. In case - * of using DMA, the DMA Pause feature is used. - * @warning When calling BSP_AUDIO_OUT_Pause() function for pause, only - * BSP_AUDIO_OUT_Resume() function should be called for resume (use of BSP_AUDIO_OUT_Play() - * function for resume could lead to unexpected behavior). - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_Pause(void) -{ - /* Call the Audio Codec Pause/Resume function */ - if(audio_drv->Pause(AUDIO_I2C_ADDRESS) != 0) - { - return AUDIO_ERROR; - } - else - { - /* Call the Media layer pause function */ - HAL_SAI_DMAPause(&haudio_out_sai); - - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; - } -} - -/** - * @brief This function Resumes the audio file stream. - * @warning When calling BSP_AUDIO_OUT_Pause() function for pause, only - * BSP_AUDIO_OUT_Resume() function should be called for resume (use of BSP_AUDIO_OUT_Play() - * function for resume could lead to unexpected behavior). - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_Resume(void) -{ - /* Call the Audio Codec Pause/Resume function */ - if(audio_drv->Resume(AUDIO_I2C_ADDRESS) != 0) - { - return AUDIO_ERROR; - } - else - { - /* Call the Media layer pause/resume function */ - HAL_SAI_DMAResume(&haudio_out_sai); - - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; - } -} - -/** - * @brief Stops audio playing and Power down the Audio Codec. - * @param Option: could be one of the following parameters - * - CODEC_PDWN_SW: for software power off (by writing registers). - * Then no need to reconfigure the Codec after power on. - * - CODEC_PDWN_HW: completely shut down the codec (physically). - * Then need to reconfigure the Codec after power on. - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_Stop(uint32_t Option) -{ - /* Call the Media layer stop function */ - HAL_SAI_DMAStop(&haudio_out_sai); - - /* Call Audio Codec Stop function */ - if(audio_drv->Stop(AUDIO_I2C_ADDRESS, Option) != 0) - { - return AUDIO_ERROR; - } - else - { - if(Option == CODEC_PDWN_HW) - { - /* Wait at least 100us */ - HAL_Delay(1); - } - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; - } -} - -/** - * @brief Controls the current audio volume level. - * @param Volume: Volume level to be set in percentage from 0% to 100% (0 for - * Mute and 100 for Max volume level). - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_SetVolume(uint8_t Volume) -{ - /* Call the codec volume control function with converted volume value */ - if(audio_drv->SetVolume(AUDIO_I2C_ADDRESS, Volume) != 0) - { - return AUDIO_ERROR; - } - else - { - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; - } -} - -/** - * @brief Enables or disables the MUTE mode by software - * @param Cmd: Could be AUDIO_MUTE_ON to mute sound or AUDIO_MUTE_OFF to - * unmute the codec and restore previous volume level. - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_SetMute(uint32_t Cmd) -{ - /* Call the Codec Mute function */ - if(audio_drv->SetMute(AUDIO_I2C_ADDRESS, Cmd) != 0) - { - return AUDIO_ERROR; - } - else - { - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; - } -} - -/** - * @brief Switch dynamically (while audio file is played) the output target - * (speaker or headphone). - * @param Output: The audio output target: OUTPUT_DEVICE_HEADPHONE1, - * OUTPUT_DEVICE_HEADPHONE2 or OUTPUT_DEVICE_BOTH - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_SetOutputMode(uint8_t Output) -{ - /* Call the Codec output device function */ - if(audio_drv->SetOutputMode(AUDIO_I2C_ADDRESS, Output) != 0) - { - return AUDIO_ERROR; - } - else - { - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; - } -} - -/** - * @brief Updates the audio frequency. - * @param AudioFreq: Audio frequency used to play the audio stream. - * @note This API should be called after the BSP_AUDIO_OUT_Init() to adjust the - * audio frequency. - */ -void BSP_AUDIO_OUT_SetFrequency(uint32_t AudioFreq) -{ - /* PLL clock is set depending by the AudioFreq (44.1khz vs 48khz groups) */ - BSP_AUDIO_OUT_ClockConfig(&haudio_out_sai, AudioFreq, NULL); - - /* Disable SAI peripheral to allow access to SAI internal registers */ - __HAL_SAI_DISABLE(&haudio_out_sai); - - /* Update the SAI audio frequency configuration */ - haudio_out_sai.Init.AudioFrequency = AudioFreq; - HAL_SAI_Init(&haudio_out_sai); - - /* Enable SAI peripheral to generate MCLK */ - __HAL_SAI_ENABLE(&haudio_out_sai); -} - -/** - * @brief Updates the Audio frame slot configuration. - * @param AudioFrameSlot: specifies the audio Frame slot - * This parameter can be any value of @ref CODEC_AudioFrame_SLOT_TDMMode - * @note This API should be called after the BSP_AUDIO_OUT_Init() to adjust the - * audio frame slot. - */ -void BSP_AUDIO_OUT_SetAudioFrameSlot(uint32_t AudioFrameSlot) -{ - /* Disable SAI peripheral to allow access to SAI internal registers */ - __HAL_SAI_DISABLE(&haudio_out_sai); - - /* Update the SAI audio frame slot configuration */ - haudio_out_sai.SlotInit.SlotActive = AudioFrameSlot; - HAL_SAI_Init(&haudio_out_sai); - - /* Enable SAI peripheral to generate MCLK */ - __HAL_SAI_ENABLE(&haudio_out_sai); -} - -/** - * @brief Deinit the audio peripherals. - */ -void BSP_AUDIO_OUT_DeInit(void) -{ - SAIx_DeInit(); - /* DeInit the SAI MSP : this __weak function can be rewritten by the applic */ - BSP_AUDIO_OUT_MspDeInit(&haudio_out_sai, NULL); -} - -/** - * @brief Tx Transfer completed callbacks. - * @param hsai: SAI handle - */ -void HAL_SAI_TxCpltCallback(SAI_HandleTypeDef *hsai) -{ - /* Manage the remaining file size and new address offset: This function - should be coded by user (its prototype is already declared in stm32469i_eval_audio.h) */ - BSP_AUDIO_OUT_TransferComplete_CallBack(); -} - -/** - * @brief Tx Half Transfer completed callbacks. - * @param hsai: SAI handle - */ -void HAL_SAI_TxHalfCpltCallback(SAI_HandleTypeDef *hsai) -{ - /* Manage the remaining file size and new address offset: This function - should be coded by user (its prototype is already declared in stm32469i_eval_audio.h) */ - BSP_AUDIO_OUT_HalfTransfer_CallBack(); -} - -/** - * @brief SAI error callbacks. - * @param hsai: SAI handle - */ -void HAL_SAI_ErrorCallback(SAI_HandleTypeDef *hsai) -{ - BSP_AUDIO_OUT_Error_CallBack(); -} - -/** - * @brief Manages the DMA full Transfer complete event. - */ -__weak void BSP_AUDIO_OUT_TransferComplete_CallBack(void) -{ -} - -/** - * @brief Manages the DMA Half Transfer complete event. - */ -__weak void BSP_AUDIO_OUT_HalfTransfer_CallBack(void) -{ -} - -/** - * @brief Manages the DMA FIFO error event. - */ -__weak void BSP_AUDIO_OUT_Error_CallBack(void) -{ -} - -/** - * @brief Initializes BSP_AUDIO_OUT MSP. - * @param hsai: SAI handle - * @param Params : pointer on additional configuration parameters, can be NULL. - */ -__weak void BSP_AUDIO_OUT_MspInit(SAI_HandleTypeDef *hsai, void *Params) -{ - static DMA_HandleTypeDef hdma_sai_tx; - GPIO_InitTypeDef gpio_init_structure; - - /* Enable SAI clock */ - AUDIO_SAIx_CLK_ENABLE(); - - /* Enable GPIO clock */ - AUDIO_SAIx_MCLK_ENABLE(); - AUDIO_SAIx_SCK_SD_FS_ENABLE(); - - /* CODEC_SAI pins configuration: MCK pin -----------------------------------*/ - gpio_init_structure.Pin = AUDIO_SAIx_MCK_PIN; - gpio_init_structure.Mode = GPIO_MODE_AF_PP; - gpio_init_structure.Pull = GPIO_NOPULL; - gpio_init_structure.Speed = GPIO_SPEED_HIGH; - gpio_init_structure.Alternate = AUDIO_SAIx_MCLK_SCK_SD_FS_AF; - HAL_GPIO_Init(AUDIO_SAIx_MCLK_GPIO_PORT, &gpio_init_structure); - - /* CODEC_SAI pins configuration: FS, SCK, MCK and SD pins ------------------*/ - gpio_init_structure.Pin = AUDIO_SAIx_FS_PIN | AUDIO_SAIx_SCK_PIN | AUDIO_SAIx_SD_PIN; - gpio_init_structure.Mode = GPIO_MODE_AF_PP; - gpio_init_structure.Pull = GPIO_NOPULL; - gpio_init_structure.Speed = GPIO_SPEED_HIGH; - gpio_init_structure.Alternate = AUDIO_SAIx_MCLK_SCK_SD_FS_AF; - HAL_GPIO_Init(AUDIO_SAIx_SCK_SD_FS_GPIO_PORT, &gpio_init_structure); - - /* Enable the DMA clock */ - AUDIO_SAIx_DMAx_CLK_ENABLE(); - - if(hsai->Instance == AUDIO_SAIx) - { - /* Configure the hdma_saiTx handle parameters */ - hdma_sai_tx.Init.Channel = AUDIO_SAIx_DMAx_CHANNEL; - hdma_sai_tx.Init.Direction = DMA_MEMORY_TO_PERIPH; - hdma_sai_tx.Init.PeriphInc = DMA_PINC_DISABLE; - hdma_sai_tx.Init.MemInc = DMA_MINC_ENABLE; - hdma_sai_tx.Init.PeriphDataAlignment = AUDIO_SAIx_DMAx_PERIPH_DATA_SIZE; - hdma_sai_tx.Init.MemDataAlignment = AUDIO_SAIx_DMAx_MEM_DATA_SIZE; - hdma_sai_tx.Init.Mode = DMA_CIRCULAR; - hdma_sai_tx.Init.Priority = DMA_PRIORITY_HIGH; - hdma_sai_tx.Init.FIFOMode = DMA_FIFOMODE_ENABLE; - hdma_sai_tx.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; - hdma_sai_tx.Init.MemBurst = DMA_MBURST_SINGLE; - hdma_sai_tx.Init.PeriphBurst = DMA_PBURST_SINGLE; - - hdma_sai_tx.Instance = AUDIO_SAIx_DMAx_STREAM; - - /* Associate the DMA handle */ - __HAL_LINKDMA(hsai, hdmatx, hdma_sai_tx); - - /* Deinitialize the Stream for new transfer */ - HAL_DMA_DeInit(&hdma_sai_tx); - - /* Configure the DMA Stream */ - HAL_DMA_Init(&hdma_sai_tx); - } - - /* SAI DMA IRQ Channel configuration */ - HAL_NVIC_SetPriority(AUDIO_SAIx_DMAx_IRQ, AUDIO_OUT_IRQ_PREPRIO, 0); - HAL_NVIC_EnableIRQ(AUDIO_SAIx_DMAx_IRQ); -} -/** - * @brief Deinitializes BSP_AUDIO_OUT MSP. - * @param hsai: SAI handle - * @param Params : pointer on additional configuration parameters, can be NULL. - */ -__weak void BSP_AUDIO_OUT_MspDeInit(SAI_HandleTypeDef *hsai, void *Params) -{ - GPIO_InitTypeDef gpio_init_structure; - - /* SAI DMA IRQ Channel deactivation */ - HAL_NVIC_DisableIRQ(AUDIO_SAIx_DMAx_IRQ); - - if(hsai->Instance == AUDIO_SAIx) - { - /* Deinitialize the DMA stream */ - HAL_DMA_DeInit(hsai->hdmatx); - } - - /* Disable SAI peripheral */ - __HAL_SAI_DISABLE(hsai); - - /* Deactives CODEC_SAI pins FS, SCK, MCK and SD by putting them in input mode */ - gpio_init_structure.Pin = AUDIO_SAIx_MCK_PIN; - HAL_GPIO_DeInit(AUDIO_SAIx_MCLK_GPIO_PORT, gpio_init_structure.Pin); - - gpio_init_structure.Pin = AUDIO_SAIx_FS_PIN | AUDIO_SAIx_SCK_PIN | AUDIO_SAIx_SD_PIN; - HAL_GPIO_DeInit(AUDIO_SAIx_SCK_SD_FS_GPIO_PORT, gpio_init_structure.Pin); - - /* Disable SAI clock */ - AUDIO_SAIx_CLK_DISABLE(); - - /* GPIO pins clock and DMA clock can be shut down in the applic - by surcgarging this __weak function */ -} - -/** - * @brief Clock Config. - * @param hsai: might be required to set audio peripheral predivider if any. - * @param AudioFreq: Audio frequency used to play the audio stream. - * @note This API is called by BSP_AUDIO_OUT_Init() and BSP_AUDIO_OUT_SetFrequency() - * Being __weak it can be overwritten by the application - * @param Params : pointer on additional configuration parameters, can be NULL. - */ -__weak void BSP_AUDIO_OUT_ClockConfig(SAI_HandleTypeDef *hsai, uint32_t AudioFreq, void *Params) -{ - RCC_PeriphCLKInitTypeDef rcc_ex_clk_init_struct; - - HAL_RCCEx_GetPeriphCLKConfig(&rcc_ex_clk_init_struct); - - /* Set the PLL configuration according to the audio frequency */ - if((AudioFreq == AUDIO_FREQUENCY_11K) || (AudioFreq == AUDIO_FREQUENCY_22K) || (AudioFreq == AUDIO_FREQUENCY_44K)) - { - /* Configure PLLI2S prescalers */ - /* PLLI2S_VCO: VCO_429M - I2S_CLK(first level) = PLLI2S_VCO/PLLI2SQ = 429/2 = 214.5 Mhz - I2S_CLK_x = I2S_CLK(first level)/PLLI2SDIVQ = 214.5/19 = 11.289 Mhz */ - rcc_ex_clk_init_struct.PeriphClockSelection = RCC_PERIPHCLK_SAI_PLLI2S; - rcc_ex_clk_init_struct.PLLI2S.PLLI2SN = 429; - rcc_ex_clk_init_struct.PLLI2S.PLLI2SQ = 2; - rcc_ex_clk_init_struct.PLLI2SDivQ = 19; - - HAL_RCCEx_PeriphCLKConfig(&rcc_ex_clk_init_struct); - - } - else /* AUDIO_FREQUENCY_8K, AUDIO_FREQUENCY_16K, AUDIO_FREQUENCY_48K), AUDIO_FREQUENCY_96K */ - { - /* SAI clock config - PLLSAI_VCO: VCO_344M - I2S_CLK(first level) = PLLI2S_VCO/PLLI2SQ = 344/7 = 49.142 Mhz - I2S_CLK_x = SAI_CLK(first level)/PLLI2SDIVQ = 49.142/1 = 49.142 Mhz */ - rcc_ex_clk_init_struct.PeriphClockSelection = RCC_PERIPHCLK_SAI_PLLI2S; - rcc_ex_clk_init_struct.PLLI2S.PLLI2SN = 344; - rcc_ex_clk_init_struct.PLLI2S.PLLI2SQ = 7; - rcc_ex_clk_init_struct.PLLI2SDivQ = 1; - - HAL_RCCEx_PeriphCLKConfig(&rcc_ex_clk_init_struct); - } -} - -/******************************************************************************* - Static Functions -*******************************************************************************/ - -/** - * @brief Initializes the Audio Codec audio interface (SAI). - * @param AudioFreq: Audio frequency to be configured for the SAI peripheral. - * @note The default SlotActive configuration is set to CODEC_AUDIOFRAME_SLOT_0123 - * and user can update this configuration using - */ -static void SAIx_Init(uint32_t AudioFreq) -{ - /* Initialize the haudio_out_sai Instance parameter */ - haudio_out_sai.Instance = AUDIO_SAIx; - - /* Disable SAI peripheral to allow access to SAI internal registers */ - __HAL_SAI_DISABLE(&haudio_out_sai); - - /* Configure SAI_Block_x - LSBFirst: Disabled - DataSize: 16 */ - haudio_out_sai.Init.AudioFrequency = AudioFreq; - haudio_out_sai.Init.ClockSource = SAI_CLKSOURCE_PLLI2S; - haudio_out_sai.Init.AudioMode = SAI_MODEMASTER_TX; - haudio_out_sai.Init.NoDivider = SAI_MASTERDIVIDER_ENABLE; - haudio_out_sai.Init.Protocol = SAI_FREE_PROTOCOL; - haudio_out_sai.Init.DataSize = SAI_DATASIZE_16; - haudio_out_sai.Init.FirstBit = SAI_FIRSTBIT_MSB; - haudio_out_sai.Init.ClockStrobing = SAI_CLOCKSTROBING_RISINGEDGE; - haudio_out_sai.Init.Synchro = SAI_ASYNCHRONOUS; - haudio_out_sai.Init.OutputDrive = SAI_OUTPUTDRIVE_ENABLE; - haudio_out_sai.Init.FIFOThreshold = SAI_FIFOTHRESHOLD_1QF; - - /* Configure SAI_Block_x Frame - Frame Length: 64 - Frame active Length: 32 - FS Definition: Start frame + Channel Side identification - FS Polarity: FS active Low - FS Offset: FS asserted one bit before the first bit of slot 0 */ - haudio_out_sai.FrameInit.FrameLength = 64; - haudio_out_sai.FrameInit.ActiveFrameLength = 32; - haudio_out_sai.FrameInit.FSDefinition = SAI_FS_CHANNEL_IDENTIFICATION; - haudio_out_sai.FrameInit.FSPolarity = SAI_FS_ACTIVE_LOW; - haudio_out_sai.FrameInit.FSOffset = SAI_FS_BEFOREFIRSTBIT; - - /* Configure SAI Block_x Slot - Slot First Bit Offset: 0 - Slot Size : 16 - Slot Number: 4 - Slot Active: All slot actives */ - haudio_out_sai.SlotInit.FirstBitOffset = 0; - haudio_out_sai.SlotInit.SlotSize = SAI_SLOTSIZE_DATASIZE; - haudio_out_sai.SlotInit.SlotNumber = 4; - haudio_out_sai.SlotInit.SlotActive = CODEC_AUDIOFRAME_SLOT_0123; - - HAL_SAI_Init(&haudio_out_sai); - - /* Enable SAI peripheral to generate MCLK */ - __HAL_SAI_ENABLE(&haudio_out_sai); -} - -/** - * @brief Deinitializes the Audio Codec audio interface (SAI). - */ -static void SAIx_DeInit(void) -{ - /* Initialize the hAudioOutSai Instance parameter */ - haudio_out_sai.Instance = AUDIO_SAIx; - - /* Disable SAI peripheral */ - __HAL_SAI_DISABLE(&haudio_out_sai); - - HAL_SAI_DeInit(&haudio_out_sai); -} - -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_AUDIO_in_Exported_Functions STM32469I Eval AudioIn Exported functions - * @{ - */ - -/** - * @brief Initializes wave recording. - * @note This function assumes that the I2S input clock (through PLL_R in - * Devices RevA/Z and through dedicated PLLI2S_R in Devices RevB/Y) - * is already configured and ready to be used. - * @param AudioFreq: Audio frequency to be configured for the I2S peripheral. - * @param BitRes: Audio frequency to be configured for the I2S peripheral. - * @param ChnlNbr: Audio frequency to be configured for the I2S peripheral. - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_IN_Init(uint32_t AudioFreq, uint32_t BitRes, uint32_t ChnlNbr) -{ - RCC_PeriphCLKInitTypeDef rcc_ex_clk_init_struct; - - I2Sx_DeInit(); - - HAL_RCCEx_GetPeriphCLKConfig(&rcc_ex_clk_init_struct); - rcc_ex_clk_init_struct.PeriphClockSelection = RCC_PERIPHCLK_I2S; - rcc_ex_clk_init_struct.PLLI2S.PLLI2SN = 384; - rcc_ex_clk_init_struct.PLLI2S.PLLI2SR = 2; - HAL_RCCEx_PeriphCLKConfig(&rcc_ex_clk_init_struct); - - /* Configure the PDM library */ - PDMDecoder_Init(AudioFreq, ChnlNbr); - - /* Configure the I2S peripheral */ - haudio_in_i2s.Instance = AUDIO_I2Sx; - if(HAL_I2S_GetState(&haudio_in_i2s) == HAL_I2S_STATE_RESET) - { - /* Initialize the I2S Msp: this __weak function can be rewritten by the application */ - BSP_AUDIO_IN_MspInit(&haudio_in_i2s, NULL); - } - I2Sx_Init(AudioFreq); - - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; -} - -/** - * @brief Starts audio recording. - * @param pbuf: Main buffer pointer for the recorded data storing - * @param size: Current size of the recorded buffer - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_IN_Record(uint16_t* pbuf, uint32_t size) -{ - uint32_t ret = AUDIO_ERROR; - - /* Start the process receive DMA */ - HAL_I2S_Receive_DMA(&haudio_in_i2s, pbuf, size); - - /* Return AUDIO_OK when all operations are correctly done */ - ret = AUDIO_OK; - - return ret; -} - -/** - * @brief Stops audio recording. - * @param None - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_IN_Stop(void) -{ - uint32_t ret = AUDIO_ERROR; - - /* Call the Media layer pause function */ - HAL_I2S_DMAPause(&haudio_in_i2s); - - /* TIMx Peripheral clock disable */ - AUDIO_TIMx_CLK_DISABLE(); - - /* Return AUDIO_OK when all operations are correctly done */ - ret = AUDIO_OK; - - return ret; -} - -/** - * @brief Pauses the audio file stream. - * @param None - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_IN_Pause(void) -{ - /* Call the Media layer pause function */ - HAL_I2S_DMAPause(&haudio_in_i2s); - - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; -} - -/** - * @brief Resumes the audio file stream. - * @param None - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_IN_Resume(void) -{ - /* Call the Media layer pause/resume function */ - HAL_I2S_DMAResume(&haudio_in_i2s); - - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; -} - -/** - * @brief Controls the audio in volume level. - * @param Volume: Volume level to be set in percentage from 0% to 100% (0 for - * Mute and 100 for Max volume level). - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_IN_SetVolume(uint8_t Volume) -{ - /* Set the Global variable AudioInVolume */ - AudioInVolume = Volume; - - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; -} - -/** - * @brief Deinit the audio IN peripherals. - * @param None - * @retval None - */ -void BSP_AUDIO_IN_DeInit(void) -{ - I2Sx_DeInit(); - /* DeInit the I2S MSP : this __weak function can be rewritten by the applic */ - BSP_AUDIO_IN_MspDeInit(&haudio_in_i2s, NULL); - TIMx_DeInit(); -} - -/** - * @brief Converts audio format from PDM to PCM. - * @param PDMBuf: Pointer to data PDM buffer - * @param PCMBuf: Pointer to data PCM buffer - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_IN_PDMToPCM(uint16_t* PDMBuf, uint16_t* PCMBuf) -{ - uint8_t app_pdm[INTERNAL_BUFF_SIZE*2]; - uint8_t byte1 = 0, byte2 = 0; - uint32_t index = 0; - - /* PDM Demux */ - for(index = 0; index> 8)& 0xFF; - byte1 = (PDMBuf[index] & 0xFF); - app_pdm[(index*2)+1] = Channel_Demux[byte1 & CHANNEL_DEMUX_MASK] | Channel_Demux[byte2 & CHANNEL_DEMUX_MASK] << 4; - app_pdm[(index*2)] = Channel_Demux[(byte1 >> 1) & CHANNEL_DEMUX_MASK] | Channel_Demux[(byte2 >> 1) & CHANNEL_DEMUX_MASK] << 4; - } - - for(index = 0; index < DEFAULT_AUDIO_IN_CHANNEL_NBR; index++) - { - /* PDM to PCM filter */ - PDM_Filter_64_LSB((uint8_t*)&app_pdm[index], (uint16_t*)&(PCMBuf[index]), AudioInVolume , (PDMFilter_InitStruct *)&Filter[index]); - } - - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; -} - - /** - * @brief Rx Transfer completed callbacks. - * @param hi2s: I2S handle - * @retval None - */ -void HAL_I2S_RxCpltCallback(I2S_HandleTypeDef *hi2s) -{ - /* Call the record update function to get the next buffer to fill and its size (size is ignored) */ - BSP_AUDIO_IN_TransferComplete_CallBack(); -} - -/** - * @brief Rx Half Transfer completed callbacks. - * @param hi2s: I2S handle - * @retval None - */ -void HAL_I2S_RxHalfCpltCallback(I2S_HandleTypeDef *hi2s) -{ - /* Manage the remaining file size and new address offset: This function - should be coded by user (its prototype is already declared in stm32469i_eval_audio.h) */ - BSP_AUDIO_IN_HalfTransfer_CallBack(); -} - -/** - * @brief I2S error callbacks. - * @param hi2s: I2S handle - * @retval None - */ -void HAL_I2S_ErrorCallback(I2S_HandleTypeDef *hi2s) -{ - /* Manage the error generated on DMA FIFO: This function - should be coded by user (its prototype is already declared in stm32469i_eval_audio.h) */ - BSP_AUDIO_IN_Error_Callback(); -} - -/** - * @brief User callback when record buffer is filled. - * @param None - * @retval None - */ -__weak void BSP_AUDIO_IN_TransferComplete_CallBack(void) -{ - /* This function should be implemented by the user application. - It is called into this driver when the current buffer is filled - to prepare the next buffer pointer and its size. */ -} - -/** - * @brief Manages the DMA Half Transfer complete event. - * @param None - * @retval None - */ -__weak void BSP_AUDIO_IN_HalfTransfer_CallBack(void) -{ - /* This function should be implemented by the user application. - It is called into this driver when the current buffer is filled - to prepare the next buffer pointer and its size. */ -} - -/** - * @brief Audio IN Error callback function. - * @param None - * @retval None - */ -__weak void BSP_AUDIO_IN_Error_Callback(void) -{ - /* This function is called when an Interrupt due to transfer error on or peripheral - error occurs. */ -} - -/** - * @brief BSP AUDIO IN MSP Init. - * @param hi2s: I2S handle - * @param Params : pointer on additional configuration parameters, can be NULL. - */ -__weak void BSP_AUDIO_IN_MspInit(I2S_HandleTypeDef *hi2s, void *Params) -{ - static DMA_HandleTypeDef hdma_i2s_rx; - GPIO_InitTypeDef gpio_init_structure; - - /* Configure the Timer which clocks the MEMS */ - /* Moved inside MSP to allow applic to redefine the TIMx_MspInit */ - TIMx_Init(); - - /* Enable I2S clock */ - AUDIO_I2Sx_CLK_ENABLE(); - - /* Enable SCK and SD GPIO clock */ - AUDIO_I2Sx_SD_GPIO_CLK_ENABLE(); - AUDIO_I2Sx_SCK_GPIO_CLK_ENABLE(); - /* CODEC_I2S pins configuration: SCK and SD pins */ - gpio_init_structure.Pin = AUDIO_I2Sx_SCK_PIN; - gpio_init_structure.Mode = GPIO_MODE_AF_PP; - gpio_init_structure.Pull = GPIO_NOPULL; - gpio_init_structure.Speed = GPIO_SPEED_FAST; - gpio_init_structure.Alternate = AUDIO_I2Sx_SCK_AF; - HAL_GPIO_Init(AUDIO_I2Sx_SCK_GPIO_PORT, &gpio_init_structure); - - gpio_init_structure.Pin = AUDIO_I2Sx_SD_PIN; - gpio_init_structure.Alternate = AUDIO_I2Sx_SD_AF; - HAL_GPIO_Init(AUDIO_I2Sx_SD_GPIO_PORT, &gpio_init_structure); - - /* Enable the DMA clock */ - AUDIO_I2Sx_DMAx_CLK_ENABLE(); - - if(hi2s->Instance == AUDIO_I2Sx) - { - /* Configure the hdma_i2s_rx handle parameters */ - hdma_i2s_rx.Init.Channel = AUDIO_I2Sx_DMAx_CHANNEL; - hdma_i2s_rx.Init.Direction = DMA_PERIPH_TO_MEMORY; - hdma_i2s_rx.Init.PeriphInc = DMA_PINC_DISABLE; - hdma_i2s_rx.Init.MemInc = DMA_MINC_ENABLE; - hdma_i2s_rx.Init.PeriphDataAlignment = AUDIO_I2Sx_DMAx_PERIPH_DATA_SIZE; - hdma_i2s_rx.Init.MemDataAlignment = AUDIO_I2Sx_DMAx_MEM_DATA_SIZE; - hdma_i2s_rx.Init.Mode = DMA_CIRCULAR; - hdma_i2s_rx.Init.Priority = DMA_PRIORITY_HIGH; - hdma_i2s_rx.Init.FIFOMode = DMA_FIFOMODE_DISABLE; - hdma_i2s_rx.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; - hdma_i2s_rx.Init.MemBurst = DMA_MBURST_SINGLE; - hdma_i2s_rx.Init.PeriphBurst = DMA_MBURST_SINGLE; - - hdma_i2s_rx.Instance = AUDIO_I2Sx_DMAx_STREAM; - - /* Associate the DMA handle */ - __HAL_LINKDMA(hi2s, hdmarx, hdma_i2s_rx); - - /* Deinitialize the Stream for new transfer */ - HAL_DMA_DeInit(&hdma_i2s_rx); - - /* Configure the DMA Stream */ - HAL_DMA_Init(&hdma_i2s_rx); - } - - /* I2S DMA IRQ Channel configuration */ - HAL_NVIC_SetPriority(AUDIO_I2Sx_DMAx_IRQ, AUDIO_IN_IRQ_PREPRIO, 0); - HAL_NVIC_EnableIRQ(AUDIO_I2Sx_DMAx_IRQ); -} - -/** - * @brief DeInitializes BSP_AUDIO_IN MSP. - * @param hi2s: I2S handle - * @param Params : pointer on additional configuration parameters, can be NULL. - */ -__weak void BSP_AUDIO_IN_MspDeInit(I2S_HandleTypeDef *hi2s, void *Params) -{ - GPIO_InitTypeDef gpio_init_structure; - - /* I2S DMA IRQ Channel deactivation */ - HAL_NVIC_DisableIRQ(AUDIO_I2Sx_DMAx_IRQ); - - if(hi2s->Instance == AUDIO_I2Sx) - { - /* Deinitialize the Stream for new transfer */ - HAL_DMA_DeInit(hi2s->hdmarx); - } - - /* Disable I2S block */ - __HAL_I2S_DISABLE(hi2s); - - /* Disable pins: SCK and SD pins */ - gpio_init_structure.Pin = AUDIO_I2Sx_SCK_PIN; - HAL_GPIO_DeInit(AUDIO_I2Sx_SCK_GPIO_PORT, gpio_init_structure.Pin); - gpio_init_structure.Pin = AUDIO_I2Sx_SD_PIN; - HAL_GPIO_DeInit(AUDIO_I2Sx_SD_GPIO_PORT, gpio_init_structure.Pin); - - /* Disable I2S clock */ - AUDIO_I2Sx_CLK_DISABLE(); - - /* GPIO pins clock and DMA clock can be shut down in the applic - by surcgarging this __weak function */ -} - -/******************************************************************************* - Static Functions -*******************************************************************************/ - -/** - * @brief Initializes the PDM library. - * @param AudioFreq: Audio sampling frequency - * @param ChnlNbr: Number of audio channels (1: mono; 2: stereo) - * @retval None - */ -static void PDMDecoder_Init(uint32_t AudioFreq, uint32_t ChnlNbr) -{ - uint32_t i = 0; - - /* Enable CRC peripheral to unlock the PDM library */ - __HAL_RCC_CRC_CLK_ENABLE(); - - for(i = 0; i < ChnlNbr; i++) - { - /* Filter LP & HP Init */ - Filter[i].LP_HZ = AudioFreq/2; - Filter[i].HP_HZ = 10; - Filter[i].Fs = AudioFreq; - Filter[i].Out_MicChannels = ChnlNbr; - Filter[i].In_MicChannels = ChnlNbr; - PDM_Filter_Init((PDMFilter_InitStruct *)&Filter[i]); - } -} - -/** - * @brief Initializes the Audio Codec audio interface (I2S) - * @note This function assumes that the I2S input clock (through dedicated PLLI2S_R) - * is already configured and ready to be used. - * @param AudioFreq: Audio frequency to be configured for the I2S peripheral. - * @retval None - */ -static void I2Sx_Init(uint32_t AudioFreq) -{ - /* Initialize the haudio_in_i2s Instance parameter */ - haudio_in_i2s.Instance = AUDIO_I2Sx; - - /* Disable I2S block */ - __HAL_I2S_DISABLE(&haudio_in_i2s); - - /* I2S2 peripheral configuration */ - haudio_in_i2s.Init.AudioFreq = 4 * AudioFreq; - haudio_in_i2s.Init.ClockSource = I2S_CLOCK_PLL; - haudio_in_i2s.Init.CPOL = I2S_CPOL_LOW; - haudio_in_i2s.Init.DataFormat = I2S_DATAFORMAT_16B; - haudio_in_i2s.Init.MCLKOutput = I2S_MCLKOUTPUT_DISABLE; - haudio_in_i2s.Init.Mode = I2S_MODE_MASTER_RX; - haudio_in_i2s.Init.Standard = I2S_STANDARD_LSB; - - /* Init the I2S */ - HAL_I2S_Init(&haudio_in_i2s); - - /* Disable I2S block */ - __HAL_I2S_ENABLE(&haudio_in_i2s); - -} - -/** - * @brief Deinitializes the Audio Codec audio interface (I2S). - * @param None - * @retval None - */ -static void I2Sx_DeInit(void) -{ - /* Initialize the hAudioInI2s Instance parameter */ - haudio_in_i2s.Instance = AUDIO_I2Sx; - - /* Disable I2S block */ - __HAL_I2S_DISABLE(&haudio_in_i2s); - - /* DeInit the I2S */ - HAL_I2S_DeInit(&haudio_in_i2s); -} - - -/** - * @brief Initializes the TIM INput Capture MSP. - * @param htim: TIM handle - * @retval None - */ -static void TIMx_IC_MspInit(TIM_HandleTypeDef *htim) -{ - GPIO_InitTypeDef gpio_init_structure; - - /* Enable peripherals and GPIO Clocks --------------------------------------*/ - /* TIMx Peripheral clock enable */ - AUDIO_TIMx_CLK_ENABLE(); - - /* Enable GPIO Channels Clock */ - AUDIO_TIMx_GPIO_CLK_ENABLE(); - - /* Configure I/Os ----------------------------------------------------------*/ - /* Common configuration for all channels */ - gpio_init_structure.Mode = GPIO_MODE_AF_PP; - gpio_init_structure.Pull = GPIO_NOPULL; - gpio_init_structure.Speed = GPIO_SPEED_HIGH; - gpio_init_structure.Alternate = AUDIO_TIMx_AF; - - /* Configure TIM input channel */ - gpio_init_structure.Pin = AUDIO_TIMx_IN_GPIO_PIN; - HAL_GPIO_Init(AUDIO_TIMx_GPIO_PORT, &gpio_init_structure); - - /* Configure TIM output channel */ - gpio_init_structure.Pin = AUDIO_TIMx_OUT_GPIO_PIN; - HAL_GPIO_Init(AUDIO_TIMx_GPIO_PORT, &gpio_init_structure); - -} - -/** - * @brief Initializes the TIM INput Capture MSP. - * @param htim: TIM handle - * @retval None - */ -static void TIMx_IC_MspDeInit(TIM_HandleTypeDef *htim) -{ - /* Disable TIMx Peripheral clock */ - AUDIO_TIMx_CLK_DISABLE(); - - /* GPIO pins clock and DMA clock can be shut down in the applic - by surcgarging this __weak function */ -} - -/** - * @brief Configure TIM as a clock divider by 2. - * I2S_SCK is externally connected to TIMx input channel - * @param None - * @retval None - */ -static void TIMx_Init(void) -{ - TIM_IC_InitTypeDef s_ic_config; - TIM_OC_InitTypeDef s_oc_config; - TIM_ClockConfigTypeDef s_clk_source_config; - TIM_SlaveConfigTypeDef s_slave_config; - - /* Configure the TIM peripheral --------------------------------------------*/ - /* Set TIMx instance */ - haudio_tim.Instance = AUDIO_TIMx; - /* Timer Input Capture Configuration Structure declaration */ - /* Initialize TIMx peripheral as follow: - + Period = 0xFFFF - + Prescaler = 0 - + ClockDivision = 0 - + Counter direction = Up - */ - haudio_tim.Init.Period = 1; - haudio_tim.Init.Prescaler = 0; - haudio_tim.Init.ClockDivision = 0; - haudio_tim.Init.CounterMode = TIM_COUNTERMODE_UP; - - /* Initialize the TIMx peripheral with the structure above */ - TIMx_IC_MspInit(&haudio_tim); - HAL_TIM_IC_Init(&haudio_tim); - - /* Configure the Input Capture channel -------------------------------------*/ - /* Configure the Input Capture of channel 2 */ - s_ic_config.ICPolarity = TIM_ICPOLARITY_FALLING; - s_ic_config.ICSelection = TIM_ICSELECTION_DIRECTTI; - s_ic_config.ICPrescaler = TIM_ICPSC_DIV1; - s_ic_config.ICFilter = 0; - HAL_TIM_IC_ConfigChannel(&haudio_tim, &s_ic_config, AUDIO_TIMx_IN_CHANNEL); - - /* Select external clock mode 1 */ - s_clk_source_config.ClockSource = TIM_CLOCKSOURCE_ETRMODE1; - s_clk_source_config.ClockPolarity = TIM_CLOCKPOLARITY_NONINVERTED; - s_clk_source_config.ClockPrescaler = TIM_CLOCKPRESCALER_DIV1; - s_clk_source_config.ClockFilter = 0; - HAL_TIM_ConfigClockSource(&haudio_tim, &s_clk_source_config); - - /* Select Input Channel as input trigger */ - s_slave_config.InputTrigger = TIM_TS_TI1FP1; - s_slave_config.SlaveMode = TIM_SLAVEMODE_EXTERNAL1; - s_slave_config.TriggerPolarity = TIM_TRIGGERPOLARITY_NONINVERTED; - s_slave_config.TriggerPrescaler = TIM_CLOCKPRESCALER_DIV1; - s_slave_config.TriggerFilter = 0; - HAL_TIM_SlaveConfigSynchronization(&haudio_tim, &s_slave_config); - - /* Output Compare PWM Mode configuration: Channel2 */ - s_oc_config.OCMode = TIM_OCMODE_PWM1; - s_oc_config.OCIdleState = TIM_OCIDLESTATE_SET; - s_oc_config.Pulse = 1; - s_oc_config.OCPolarity = TIM_OCPOLARITY_HIGH; - s_oc_config.OCNPolarity = TIM_OCNPOLARITY_HIGH; - s_oc_config.OCFastMode = TIM_OCFAST_DISABLE; - s_oc_config.OCNIdleState = TIM_OCNIDLESTATE_SET; - - /* Initialize the TIM3 Channel2 with the structure above */ - HAL_TIM_PWM_ConfigChannel(&haudio_tim, &s_oc_config, AUDIO_TIMx_OUT_CHANNEL); - - /* Start the TIM3 Channel2 */ - HAL_TIM_PWM_Start(&haudio_tim, AUDIO_TIMx_OUT_CHANNEL); - - /* Start the TIM3 Channel1 */ - HAL_TIM_IC_Start(&haudio_tim, AUDIO_TIMx_IN_CHANNEL); -} - -/** - * @brief Configure TIM as a clock divider by 2. - * I2S_SCK is externally connected to TIMx input channel - * @param None - * @retval None - */ -static void TIMx_DeInit(void) -{ - haudio_tim.Instance = AUDIO_TIMx; - - /* Stop the TIM3 Channel2 */ - HAL_TIM_PWM_Stop(&haudio_tim, AUDIO_TIMx_OUT_CHANNEL); - /* Stop the TIM3 Channel1 */ - HAL_TIM_IC_Stop(&haudio_tim, AUDIO_TIMx_IN_CHANNEL); - - HAL_TIM_IC_DeInit(&haudio_tim); - - /* Initialize the TIMx peripheral with the structure above */ - TIMx_IC_MspDeInit(&haudio_tim); -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_audio.h b/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_audio.h deleted file mode 100644 index 666165af58..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_audio.h +++ /dev/null @@ -1,323 +0,0 @@ -/** - ****************************************************************************** - * @file stm32469i_eval_audio.h - * @author MCD Application Team - * @version V1.0.1 - * @date 29-September-2015 - * @brief This file contains the common defines and functions prototypes for - * the stm32469i_eval_audio.c driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32469I_EVAL_AUDIO_H -#define __STM32469I_EVAL_AUDIO_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -/* Include audio component Driver */ -#include "../Components/wm8994/wm8994.h" -#include "stm32469i_eval.h" -#include "../../../Middlewares/ST/STM32_Audio/Addons/PDM/pdm_filter.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32469I-EVAL - * @{ - */ - -/** @addtogroup STM32469I-EVAL_AUDIO - * @{ - */ - -/** @defgroup STM32469I-EVAL_AUDIO_Exported_Types STM32469I EVAL Audio Exported Types - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_AUDIO_Exported_Constants STM32469I EVAL Audio Exported Constants - * @{ - */ - -/*------------------------------------------------------------------------------ - USER SAI defines parameters - -----------------------------------------------------------------------------*/ -/** @defgroup CODEC_AudioFrame_SLOT_TDMMode STM32469I EVAL Audio Slot TDM mode - * @brief In W8994 codec the Audio frame contains 4 slots : TDM Mode - * TDM format : - * +------------------|------------------|--------------------|-------------------+ - * | CODEC_SLOT0 Left | CODEC_SLOT1 Left | CODEC_SLOT0 Right | CODEC_SLOT1 Right | - * +------------------------------------------------------------------------------+ - * @{ - */ -/* To have 2 separate audio stream in Both headphone and speaker the 4 slot must be activated */ -#define CODEC_AUDIOFRAME_SLOT_0123 SAI_SLOTACTIVE_0 | SAI_SLOTACTIVE_1 | SAI_SLOTACTIVE_2 | SAI_SLOTACTIVE_3 -/* To have an audio stream in headphone only SAI Slot 0 and Slot 2 must be activated */ -#define CODEC_AUDIOFRAME_SLOT_02 SAI_SLOTACTIVE_0 | SAI_SLOTACTIVE_2 -/* To have an audio stream in speaker only SAI Slot 1 and Slot 3 must be activated */ -#define CODEC_AUDIOFRAME_SLOT_13 SAI_SLOTACTIVE_1 | SAI_SLOTACTIVE_3 -/** - * @} - */ - -/* SAI peripheral configuration defines */ -#define AUDIO_SAIx SAI1_Block_A -#define AUDIO_SAIx_CLK_ENABLE() __HAL_RCC_SAI1_CLK_ENABLE() -#define AUDIO_SAIx_CLK_DISABLE() __HAL_RCC_SAI1_CLK_DISABLE() -#define AUDIO_SAIx_MCLK_SCK_SD_FS_AF GPIO_AF6_SAI1 - -#define AUDIO_SAIx_MCLK_ENABLE() __HAL_RCC_GPIOG_CLK_ENABLE() -#define AUDIO_SAIx_MCLK_DISABLE() __HAL_RCC_GPIOG_CLK_DISABLE() - -#define AUDIO_SAIx_MCK_PIN GPIO_PIN_7 -#define AUDIO_SAIx_MCLK_GPIO_PORT GPIOG - -#define AUDIO_SAIx_SCK_SD_FS_ENABLE() __HAL_RCC_GPIOE_CLK_ENABLE() -#define AUDIO_SAIx_SCK_SD_FS_DISABLE() __HAL_RCC_GPIOE_CLK_DISABLE() -#define AUDIO_SAIx_FS_PIN GPIO_PIN_4 -#define AUDIO_SAIx_SCK_PIN GPIO_PIN_5 -#define AUDIO_SAIx_SD_PIN GPIO_PIN_6 -#define AUDIO_SAIx_SCK_SD_FS_GPIO_PORT GPIOE - - -/* SAI DMA Stream definitions */ -#define AUDIO_SAIx_DMAx_CLK_ENABLE() __HAL_RCC_DMA2_CLK_ENABLE() -#define AUDIO_SAIx_DMAx_CLK_DISABLE() __HAL_RCC_DMA2_CLK_DISABLE() -#define AUDIO_SAIx_DMAx_STREAM DMA2_Stream3 -#define AUDIO_SAIx_DMAx_CHANNEL DMA_CHANNEL_0 -#define AUDIO_SAIx_DMAx_IRQ DMA2_Stream3_IRQn -#define AUDIO_SAIx_DMAx_PERIPH_DATA_SIZE DMA_PDATAALIGN_HALFWORD -#define AUDIO_SAIx_DMAx_MEM_DATA_SIZE DMA_MDATAALIGN_HALFWORD -#define DMA_MAX_SZE 0xFFFF - -#define AUDIO_SAIx_DMAx_IRQHandler DMA2_Stream3_IRQHandler - -/* Select the interrupt preemption priority for the DMA interrupt */ -#define AUDIO_OUT_IRQ_PREPRIO 5 /* Select the preemption priority level(0 is the highest) */ - -/*------------------------------------------------------------------------------ - AUDIO IN CONFIGURATION -------------------------------------------------------------------------------*/ -/* SPI Configuration defines */ -#define AUDIO_I2Sx SPI3 -#define AUDIO_I2Sx_CLK_ENABLE() __HAL_RCC_SPI3_CLK_ENABLE() -#define AUDIO_I2Sx_CLK_DISABLE() __HAL_RCC_SPI3_CLK_DISABLE() -#define AUDIO_I2Sx_SCK_PIN GPIO_PIN_3 -#define AUDIO_I2Sx_SCK_GPIO_PORT GPIOB -#define AUDIO_I2Sx_SCK_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE() -#define AUDIO_I2Sx_SCK_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE() -#define AUDIO_I2Sx_SCK_AF GPIO_AF6_SPI3 - -#define AUDIO_I2Sx_SD_PIN GPIO_PIN_6 -#define AUDIO_I2Sx_SD_GPIO_PORT GPIOD -#define AUDIO_I2Sx_SD_GPIO_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE() -#define AUDIO_I2Sx_SD_GPIO_CLK_DISABLE() __HAL_RCC_GPIOD_CLK_DISABLE() -#define AUDIO_I2Sx_SD_AF GPIO_AF5_I2S3ext - -/* I2S DMA Stream Rx definitions */ -#define AUDIO_I2Sx_DMAx_CLK_ENABLE() __HAL_RCC_DMA1_CLK_ENABLE() -#define AUDIO_I2Sx_DMAx_CLK_DISABLE() __HAL_RCC_DMA1_CLK_DISABLE() -#define AUDIO_I2Sx_DMAx_STREAM DMA1_Stream2 -#define AUDIO_I2Sx_DMAx_CHANNEL DMA_CHANNEL_0 -#define AUDIO_I2Sx_DMAx_IRQ DMA1_Stream2_IRQn -#define AUDIO_I2Sx_DMAx_PERIPH_DATA_SIZE DMA_PDATAALIGN_HALFWORD -#define AUDIO_I2Sx_DMAx_MEM_DATA_SIZE DMA_MDATAALIGN_HALFWORD - -#define AUDIO_I2Sx_DMAx_IRQHandler DMA1_Stream2_IRQHandler - -/* Select the interrupt preemption priority and subpriority for the IT/DMA interrupt */ -#define AUDIO_IN_IRQ_PREPRIO ((uint32_t)6) /* Select the preemption priority level(0 is the highest) */ - - -/* Two channels are used: - - one channel as input which is connected to I2S SCK in stereo mode - - one channel as output which divides the frequency on the input -*/ - -#define AUDIO_TIMx_CLK_ENABLE() __HAL_RCC_TIM3_CLK_ENABLE() -#define AUDIO_TIMx_CLK_DISABLE() __HAL_RCC_TIM3_CLK_DISABLE() -#define AUDIO_TIMx TIM3 -#define AUDIO_TIMx_IN_CHANNEL TIM_CHANNEL_1 -#define AUDIO_TIMx_OUT_CHANNEL TIM_CHANNEL_2 /* Select channel 2 as output */ -#define AUDIO_TIMx_GPIO_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE() -#define AUDIO_TIMx_GPIO_CLK_DISABLE() __HAL_RCC_GPIOC_CLK_DISABLE() -#define AUDIO_TIMx_GPIO_PORT GPIOC -#define AUDIO_TIMx_IN_GPIO_PIN GPIO_PIN_6 -#define AUDIO_TIMx_OUT_GPIO_PIN GPIO_PIN_7 -#define AUDIO_TIMx_AF GPIO_AF2_TIM3 - -/*------------------------------------------------------------------------------ - CONFIGURATION: Audio Driver Configuration parameters -------------------------------------------------------------------------------*/ - -#define AUDIODATA_SIZE 2 /* 16-bits audio data size */ - -/* Audio status definition */ -#define AUDIO_OK ((uint8_t)0) -#define AUDIO_ERROR ((uint8_t)1) -#define AUDIO_TIMEOUT ((uint8_t)2) - -/* AudioFreq * DataSize (2 bytes) * NumChannels (Stereo: 2) */ -#define DEFAULT_AUDIO_IN_FREQ I2S_AUDIOFREQ_16K -#define DEFAULT_AUDIO_IN_BIT_RESOLUTION ((uint8_t)16) -#define DEFAULT_AUDIO_IN_CHANNEL_NBR ((uint8_t)2) /* Mono = 1, Stereo = 2 */ -#define DEFAULT_AUDIO_IN_VOLUME ((uint16_t)64) - -/* PDM buffer input size */ -#define INTERNAL_BUFF_SIZE (128*DEFAULT_AUDIO_IN_FREQ/16000*DEFAULT_AUDIO_IN_CHANNEL_NBR) -/* PCM buffer output size */ -#define PCM_OUT_SIZE (DEFAULT_AUDIO_IN_FREQ/1000*DEFAULT_AUDIO_IN_CHANNEL_NBR) -#define CHANNEL_DEMUX_MASK ((uint8_t)0x55) - -/*------------------------------------------------------------------------------ - OPTIONAL Configuration defines parameters -------------------------------------------------------------------------------*/ - -/* Delay for the Codec to be correctly reset */ -#define CODEC_RESET_DELAY ((uint8_t)5) - -/*------------------------------------------------------------------------------ - OUTPUT DEVICES definition -------------------------------------------------------------------------------*/ - -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_AUDIO_Exported_Variables STM32469I-EVAL AUDIO Exported Variables - * @{ - */ -extern __IO uint16_t AudioInVolume; - /** - * @} - */ - -/** @defgroup STM32469I-EVAL_AUDIO_Exported_Macros STM32469I-EVAL AUDIO Exported Macros - * @{ - */ -#define DMA_MAX(x) (((x) <= DMA_MAX_SZE)? (x):DMA_MAX_SZE) -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_AUDIO_OUT_Exported_Functions STM32469I EVAL AudioOUT Exported Functions - * @{ - */ -uint8_t BSP_AUDIO_OUT_Init(uint16_t OutputDevice, uint8_t Volume, uint32_t AudioFreq); -uint8_t BSP_AUDIO_OUT_Play(uint16_t* pBuffer, uint32_t Size); -void BSP_AUDIO_OUT_ChangeBuffer(uint16_t *pData, uint16_t Size); -uint8_t BSP_AUDIO_OUT_Pause(void); -uint8_t BSP_AUDIO_OUT_Resume(void); -uint8_t BSP_AUDIO_OUT_Stop(uint32_t Option); -uint8_t BSP_AUDIO_OUT_SetVolume(uint8_t Volume); -void BSP_AUDIO_OUT_SetFrequency(uint32_t AudioFreq); -void BSP_AUDIO_OUT_SetAudioFrameSlot(uint32_t AudioFrameSlot); -uint8_t BSP_AUDIO_OUT_SetMute(uint32_t Cmd); -uint8_t BSP_AUDIO_OUT_SetOutputMode(uint8_t Output); -void BSP_AUDIO_OUT_DeInit(void); - -/* User Callbacks: user has to implement these functions in his code if they are needed. */ -/* This function is called when the requested data has been completely transferred.*/ -void BSP_AUDIO_OUT_TransferComplete_CallBack(void); - -/* This function is called when half of the requested buffer has been transferred. */ -void BSP_AUDIO_OUT_HalfTransfer_CallBack(void); - -/* This function is called when an Interrupt due to transfer error on or peripheral - error occurs. */ -void BSP_AUDIO_OUT_Error_CallBack(void); - -/* These function can be modified in case the current settings (e.g. DMA stream) - need to be changed for specific application needs */ -void BSP_AUDIO_OUT_ClockConfig(SAI_HandleTypeDef *hsai, uint32_t AudioFreq, void *Params); -void BSP_AUDIO_OUT_MspInit(SAI_HandleTypeDef *hsai, void *Params); -void BSP_AUDIO_OUT_MspDeInit(SAI_HandleTypeDef *hsai, void *Params); - -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_AUDIO_IN_Exported_Functions STM32469I EVAL AudioIN Exported Functions - * @{ - */ -uint8_t BSP_AUDIO_IN_Init(uint32_t AudioFreq, uint32_t BitRes, uint32_t ChnlNbr); -uint8_t BSP_AUDIO_IN_Record(uint16_t *pData, uint32_t Size); -uint8_t BSP_AUDIO_IN_Stop(void); -uint8_t BSP_AUDIO_IN_Pause(void); -uint8_t BSP_AUDIO_IN_Resume(void); -uint8_t BSP_AUDIO_IN_SetVolume(uint8_t Volume); -void BSP_AUDIO_IN_DeInit(void); -uint8_t BSP_AUDIO_IN_PDMToPCM(uint16_t* PDMBuf, uint16_t* PCMBuf); -/* User Callbacks: user has to implement these functions in his code if they are needed. */ -/* This function should be implemented by the user application. - It is called into this driver when the current buffer is filled to prepare the next - buffer pointer and its size. */ -void BSP_AUDIO_IN_TransferComplete_CallBack(void); -void BSP_AUDIO_IN_HalfTransfer_CallBack(void); - -/* This function is called when an Interrupt due to transfer error on or peripheral - error occurs. */ -void BSP_AUDIO_IN_Error_Callback(void); - -/* These function can be modified in case the current settings (e.g. DMA stream) - need to be changed for specific application needs */ -void BSP_AUDIO_IN_MspInit(I2S_HandleTypeDef *hi2s, void *Params); -void BSP_AUDIO_IN_MspDeInit(I2S_HandleTypeDef *hi2s, void *Params); - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32469I_EVAL_AUDIO_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_camera.c b/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_camera.c deleted file mode 100644 index 9832bbad6e..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_camera.c +++ /dev/null @@ -1,684 +0,0 @@ -/** - ****************************************************************************** - * @file stm32469i_eval_camera.c - * @author MCD Application Team - * @version V1.0.1 - * @date 29-September-2015 - * @brief This file includes the driver for Camera modules mounted on - * STM32469I-EVAL evaluation board. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* File Info: ------------------------------------------------------------------ - User NOTES -1. How to use this driver: --------------------------- - - This driver is used to drive the camera. - - The S5K5CAG component driver MUST be included with this driver. - -2. Driver description: ---------------------- - + Initialization steps: - o Initialize the camera using the BSP_CAMERA_Init() function. - o Start the camera capture/snapshot using the CAMERA_Start() function. - o Suspend, resume or stop the camera capture using the following functions: - - BSP_CAMERA_Suspend() - - BSP_CAMERA_Resume() - - BSP_CAMERA_Stop() - - + Options - o Increase or decrease on the fly the brightness and/or contrast - using the following function: - - BSP_CAMERA_ContrastBrightnessConfig - o Add a special effect on the fly using the following functions: - - BSP_CAMERA_BlackWhiteConfig() - - BSP_CAMERA_ColorEffectConfig() - -------------------------------------------------------------------------------*/ - -/* Includes ------------------------------------------------------------------*/ -#include "stm32469i_eval_camera.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32469I-EVAL - * @{ - */ - -/** @addtogroup STM32469I-EVAL_CAMERA - * @{ - */ - -/** @defgroup STM32469I-EVAL_CAMERA_Private_TypesDefinitions STM32469I Eval Camera Private TypesDef - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_CAMERA_Private_Defines STM32469I Eval Camera Private Defines - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_CAMERA_Private_Macros STM32469I Eval Camera Private Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_CAMERA_Imported_Variables STM32469I Eval Camera Imported Variables - * @{ - */ -/** - * @brief DMA2D handle variable - */ -extern DMA2D_HandleTypeDef hdma2d_eval; -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_CAMERA_Private_Variables STM32469I Eval Camera Private Variables - * @{ - */ -static DCMI_HandleTypeDef hDcmiEval; -CAMERA_DrvTypeDef *CameraDrv; - -/* Camera current resolution naming (QQVGA, VGA, ...) */ -uint32_t CameraCurrentResolution; - -/* Camera image rotation on LCD Displayed frame buffer */ -uint32_t CameraRotation = CAMERA_ROTATION_INVALID; - -static uint32_t CameraHwAddress; - -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_CAMERA_Private_FunctionPrototypes STM32469I Eval Camera Private Prototypes - * @{ - */ -static uint32_t GetSize(uint32_t Resolution); -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_CAMERA_Public_Functions STM32469I Eval Camera Public Functions - * @{ - */ - -/** - * @brief Set Camera image rotation on LCD Displayed frame buffer. - * @param rotation : uint32_t rotation of camera image in preview buffer sent to LCD - * need to be of type Camera_ImageRotationTypeDef - * @retval Camera status - */ -uint8_t BSP_CAMERA_SetRotation(uint32_t rotation) -{ - uint8_t status = CAMERA_ERROR; - - if(rotation < CAMERA_ROTATION_INVALID) - { - /* Set Camera image rotation on LCD Displayed frame buffer */ - CameraRotation = rotation; - status = CAMERA_OK; - } - - return status; -} - -/** - * @brief Get Camera image rotation on LCD Displayed frame buffer. - * @retval rotation : uint32_t value of type Camera_ImageRotationTypeDef - */ -uint32_t BSP_CAMERA_GetRotation(void) -{ - return(CameraRotation); -} - -/** - * @brief Initializes the camera. - * @param Resolution : camera sensor requested resolution (x, y) : standard resolution - * naming QQVGA, QVGA, VGA ... - * @retval Camera status - */ -uint8_t BSP_CAMERA_Init(uint32_t Resolution) -{ - DCMI_HandleTypeDef *phdcmi; - uint8_t status = CAMERA_ERROR; - - /* Get the DCMI handle structure */ - phdcmi = &hDcmiEval; - - /*** Configures the DCMI to interface with the camera module ***/ - /* DCMI configuration */ - phdcmi->Init.CaptureRate = DCMI_CR_ALL_FRAME; - phdcmi->Init.HSPolarity = DCMI_HSPOLARITY_HIGH; - phdcmi->Init.SynchroMode = DCMI_SYNCHRO_HARDWARE; - phdcmi->Init.VSPolarity = DCMI_VSPOLARITY_HIGH; - phdcmi->Init.ExtendedDataMode = DCMI_EXTEND_DATA_8B; - phdcmi->Init.PCKPolarity = DCMI_PCKPOLARITY_RISING; - - phdcmi->Instance = DCMI; - - /* Configure IO functionalities for CAMERA detect pin */ - BSP_IO_Init(); - /* Apply Camera Module hardware reset */ - BSP_CAMERA_HwReset(); - - /* Check if the CAMERA Module is plugged on board */ - if(BSP_IO_ReadPin(CAM_PLUG_PIN) == BSP_IO_PIN_SET) - { - status = CAMERA_NOT_DETECTED; - return status; /* Exit with error */ - } - - /* Read ID of Camera module via I2C */ - if (s5k5cag_ReadID(CAMERA_I2C_ADDRESS) == S5K5CAG_ID) - { - /* Initialize the camera driver structure */ - CameraDrv = &s5k5cag_drv; - CameraHwAddress = CAMERA_I2C_ADDRESS; - - /* DCMI Initialization */ - BSP_CAMERA_MspInit(&hDcmiEval, NULL); - HAL_DCMI_Init(phdcmi); - - /* Camera Module Initialization via I2C to the wanted 'Resolution' */ - CameraDrv->Init(CameraHwAddress, Resolution); - - CameraCurrentResolution = Resolution; - - /* Return CAMERA_OK status */ - status = CAMERA_OK; - } - else - { - /* Return CAMERA_NOT_SUPPORTED status */ - status = CAMERA_NOT_SUPPORTED; - } - - return status; -} - - -/** - * @brief DeInitializes the camera. - * @retval Camera status - */ -uint8_t BSP_CAMERA_DeInit(void) -{ - hDcmiEval.Instance = DCMI; - - HAL_DCMI_DeInit(&hDcmiEval); - BSP_CAMERA_MspDeInit(&hDcmiEval, NULL); - return CAMERA_OK; -} - -/** - * @brief Starts the camera capture in continuous mode. - * @param buff: pointer to the camera output buffer - */ -void BSP_CAMERA_ContinuousStart(uint8_t *buff) -{ - /* Start the camera capture */ - HAL_DCMI_Start_DMA(&hDcmiEval, DCMI_MODE_CONTINUOUS, (uint32_t)buff, GetSize(CameraCurrentResolution)); -} - -/** - * @brief Starts the camera capture in snapshot mode. - * @param buff: pointer to the camera output buffer - */ -void BSP_CAMERA_SnapshotStart(uint8_t *buff) -{ - /* Start the camera capture */ - HAL_DCMI_Start_DMA(&hDcmiEval, DCMI_MODE_SNAPSHOT, (uint32_t)buff, GetSize(CameraCurrentResolution)); -} - -/** - * @brief Suspend the CAMERA capture - */ -void BSP_CAMERA_Suspend(void) -{ - /* Disable the DMA */ - __HAL_DMA_DISABLE(hDcmiEval.DMA_Handle); - /* Disable the DCMI */ - __HAL_DCMI_DISABLE(&hDcmiEval); - -} - -/** - * @brief Resume the CAMERA capture - */ -void BSP_CAMERA_Resume(void) -{ - /* Enable the DCMI */ - __HAL_DCMI_ENABLE(&hDcmiEval); - /* Enable the DMA */ - __HAL_DMA_ENABLE(hDcmiEval.DMA_Handle); -} - -/** - * @brief Stop the CAMERA capture - * @retval Camera status - */ -uint8_t BSP_CAMERA_Stop(void) -{ - uint8_t status = CAMERA_ERROR; - - if(HAL_DCMI_Stop(&hDcmiEval) == HAL_OK) - { - status = CAMERA_OK; - } - - /* Set Camera in Power Down */ - BSP_CAMERA_PwrDown(); - - return status; -} - -/** - * @brief CANERA hardware reset - */ -void BSP_CAMERA_HwReset(void) -{ - /* Camera sensor RESET sequence */ - BSP_IO_ConfigPin(RSTI_PIN, IO_MODE_OUTPUT); - BSP_IO_ConfigPin(XSDN_PIN, IO_MODE_OUTPUT); - - /* Assert the camera STANDBY pin (active high) */ - BSP_IO_WritePin(XSDN_PIN, BSP_IO_PIN_SET); - - /* Assert the camera RSTI pin (active low) */ - BSP_IO_WritePin(RSTI_PIN, BSP_IO_PIN_RESET); - - HAL_Delay(100); /* RST and XSDN signals asserted during 100ms */ - - /* De-assert the camera STANDBY pin (active high) */ - BSP_IO_WritePin(XSDN_PIN, BSP_IO_PIN_RESET); - - HAL_Delay(3); /* RST de-asserted and XSDN asserted during 3ms */ - - /* De-assert the camera RSTI pin (active low) */ - BSP_IO_WritePin(RSTI_PIN, BSP_IO_PIN_SET); - - HAL_Delay(6); /* RST de-asserted during 3ms */ -} - -/** - * @brief CAMERA power down - */ -void BSP_CAMERA_PwrDown(void) -{ - /* Camera power down sequence */ - BSP_IO_ConfigPin(RSTI_PIN, IO_MODE_OUTPUT); - BSP_IO_ConfigPin(XSDN_PIN, IO_MODE_OUTPUT); - - /* De-assert the camera STANDBY pin (active high) */ - BSP_IO_WritePin(XSDN_PIN, BSP_IO_PIN_RESET); - - /* Assert the camera RSTI pin (active low) */ - BSP_IO_WritePin(RSTI_PIN, BSP_IO_PIN_RESET); -} - -/** - * @brief Configures the camera contrast and brightness. - * @param contrast_level: Contrast level - * This parameter can be one of the following values: - * @arg CAMERA_CONTRAST_LEVEL4: for contrast +2 - * @arg CAMERA_CONTRAST_LEVEL3: for contrast +1 - * @arg CAMERA_CONTRAST_LEVEL2: for contrast 0 - * @arg CAMERA_CONTRAST_LEVEL1: for contrast -1 - * @arg CAMERA_CONTRAST_LEVEL0: for contrast -2 - * @param brightness_level: Contrast level - * This parameter can be one of the following values: - * @arg CAMERA_BRIGHTNESS_LEVEL4: for brightness +2 - * @arg CAMERA_BRIGHTNESS_LEVEL3: for brightness +1 - * @arg CAMERA_BRIGHTNESS_LEVEL2: for brightness 0 - * @arg CAMERA_BRIGHTNESS_LEVEL1: for brightness -1 - * @arg CAMERA_BRIGHTNESS_LEVEL0: for brightness -2 - */ -void BSP_CAMERA_ContrastBrightnessConfig(uint32_t contrast_level, uint32_t brightness_level) -{ - if(CameraDrv->Config != NULL) - { - CameraDrv->Config(CameraHwAddress, CAMERA_CONTRAST_BRIGHTNESS, contrast_level, brightness_level); - } -} - -/** - * @brief Configures the camera white balance. - * @param Mode: black_white mode - * This parameter can be one of the following values: - * @arg CAMERA_BLACK_WHITE_BW - * @arg CAMERA_BLACK_WHITE_NEGATIVE - * @arg CAMERA_BLACK_WHITE_BW_NEGATIVE - * @arg CAMERA_BLACK_WHITE_NORMAL - */ -void BSP_CAMERA_BlackWhiteConfig(uint32_t Mode) -{ - if(CameraDrv->Config != NULL) - { - CameraDrv->Config(CameraHwAddress, CAMERA_BLACK_WHITE, Mode, 0); - } -} - -/** - * @brief Configures the camera color effect. - * @param Effect: Color effect - * This parameter can be one of the following values: - * @arg CAMERA_COLOR_EFFECT_NONE - * @arg CAMERA_COLOR_EFFECT_BLUE - * @arg CAMERA_COLOR_EFFECT_GREEN - * @arg CAMERA_COLOR_EFFECT_RED - * @arg CAMERA_COLOR_EFFECT_ANTIQUE - */ -void BSP_CAMERA_ColorEffectConfig(uint32_t Effect) -{ - if(CameraDrv->Config != NULL) - { - CameraDrv->Config(CameraHwAddress, CAMERA_COLOR_EFFECT, Effect, 0); - } -} - -/** - * @brief Handles DCMI interrupt request. - */ -void BSP_CAMERA_IRQHandler(void) -{ - HAL_DCMI_IRQHandler(&hDcmiEval); -} - -/** - * @brief Handles DMA interrupt request. - */ -void BSP_CAMERA_DMA_IRQHandler(void) -{ - HAL_DMA_IRQHandler(hDcmiEval.DMA_Handle); -} - -/** - * @brief Get the capture size in pixels unit. - * @param Resolution: the current resolution. - * @retval capture size in pixels unit. - */ -static uint32_t GetSize(uint32_t Resolution) -{ - uint32_t size = 0; - - /* Get capture size */ - switch (Resolution) - { - case CAMERA_R160x120: - { - size = 0x2580; - } - break; - case CAMERA_R320x240: - { - size = 0x9600; - } - break; - case CAMERA_R480x272: - { - size = 0xFF00; - } - break; - case CAMERA_R640x480: - { - size = 0x25800; - } - break; - default: - { - break; - } - } - - return size; -} - -/** - * @brief Initializes the DCMI MSP. - * @param hdcmi: HDMI handle - * @param Params : pointer on additional configuration parameters, can be NULL. - */ -__weak void BSP_CAMERA_MspInit(DCMI_HandleTypeDef *hdcmi, void *Params) -{ - static DMA_HandleTypeDef hdma_eval; - GPIO_InitTypeDef gpio_init_structure; - - /*** Enable peripherals and GPIO clocks ***/ - /* Enable DCMI clock */ - __HAL_RCC_DCMI_CLK_ENABLE(); - - /* Enable DMA2 clock */ - __HAL_RCC_DMA2_CLK_ENABLE(); - - /* Enable GPIO clocks */ - __HAL_RCC_GPIOA_CLK_ENABLE(); - __HAL_RCC_GPIOB_CLK_ENABLE(); - __HAL_RCC_GPIOC_CLK_ENABLE(); - __HAL_RCC_GPIOD_CLK_ENABLE(); - __HAL_RCC_GPIOE_CLK_ENABLE(); - - /*** Configure the GPIO ***/ - /* Configure DCMI GPIO as alternate function */ - gpio_init_structure.Pin = GPIO_PIN_4 | GPIO_PIN_6; - gpio_init_structure.Mode = GPIO_MODE_AF_PP; - gpio_init_structure.Pull = GPIO_PULLUP; - gpio_init_structure.Speed = GPIO_SPEED_HIGH; - gpio_init_structure.Alternate = GPIO_AF13_DCMI; - HAL_GPIO_Init(GPIOA, &gpio_init_structure); - - gpio_init_structure.Pin = GPIO_PIN_7; - gpio_init_structure.Mode = GPIO_MODE_AF_PP; - gpio_init_structure.Pull = GPIO_PULLUP; - gpio_init_structure.Speed = GPIO_SPEED_HIGH; - gpio_init_structure.Alternate = GPIO_AF13_DCMI; - HAL_GPIO_Init(GPIOB, &gpio_init_structure); - - gpio_init_structure.Pin = GPIO_PIN_6 | GPIO_PIN_7 | GPIO_PIN_8 |\ - GPIO_PIN_9 | GPIO_PIN_11; - gpio_init_structure.Mode = GPIO_MODE_AF_PP; - gpio_init_structure.Pull = GPIO_PULLUP; - gpio_init_structure.Speed = GPIO_SPEED_HIGH; - gpio_init_structure.Alternate = GPIO_AF13_DCMI; - HAL_GPIO_Init(GPIOC, &gpio_init_structure); - - gpio_init_structure.Pin = GPIO_PIN_3 | GPIO_PIN_6; - gpio_init_structure.Mode = GPIO_MODE_AF_PP; - gpio_init_structure.Pull = GPIO_PULLUP; - gpio_init_structure.Speed = GPIO_SPEED_HIGH; - gpio_init_structure.Alternate = GPIO_AF13_DCMI; - HAL_GPIO_Init(GPIOD, &gpio_init_structure); - - gpio_init_structure.Pin = GPIO_PIN_5 | GPIO_PIN_6; - gpio_init_structure.Mode = GPIO_MODE_AF_PP; - gpio_init_structure.Pull = GPIO_PULLUP; - gpio_init_structure.Speed = GPIO_SPEED_HIGH; - gpio_init_structure.Alternate = GPIO_AF13_DCMI; - HAL_GPIO_Init(GPIOE, &gpio_init_structure); - - /*** Configure the DMA ***/ - /* Set the parameters to be configured */ - hdma_eval.Init.Channel = DMA_CHANNEL_1; - hdma_eval.Init.Direction = DMA_PERIPH_TO_MEMORY; - hdma_eval.Init.PeriphInc = DMA_PINC_DISABLE; - hdma_eval.Init.MemInc = DMA_MINC_ENABLE; - hdma_eval.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; - hdma_eval.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; - hdma_eval.Init.Mode = DMA_CIRCULAR; - hdma_eval.Init.Priority = DMA_PRIORITY_HIGH; - hdma_eval.Init.FIFOMode = DMA_FIFOMODE_DISABLE; - hdma_eval.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; - hdma_eval.Init.MemBurst = DMA_MBURST_SINGLE; - hdma_eval.Init.PeriphBurst = DMA_PBURST_SINGLE; - - hdma_eval.Instance = DMA2_Stream1; - - /* Associate the initialized DMA handle to the DCMI handle */ - __HAL_LINKDMA(hdcmi, DMA_Handle, hdma_eval); - - /*** Configure the NVIC for DCMI and DMA ***/ - /* NVIC configuration for DCMI transfer complete interrupt */ - HAL_NVIC_SetPriority(DCMI_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(DCMI_IRQn); - - /* NVIC configuration for DMA2D transfer complete interrupt */ - HAL_NVIC_SetPriority(DMA2_Stream1_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(DMA2_Stream1_IRQn); - - /* Configure the DMA stream */ - HAL_DMA_Init(hdcmi->DMA_Handle); -} - -/** - * @brief DeInitializes the DCMI MSP. - * @param hdcmi: HDMI handle - * @param Params : pointer on additional configuration parameters, can be NULL. - */ -__weak void BSP_CAMERA_MspDeInit(DCMI_HandleTypeDef *hdcmi, void *Params) -{ - /* Disable NVIC for DCMI transfer complete interrupt */ - HAL_NVIC_DisableIRQ(DCMI_IRQn); - - /* Disable NVIC for DMA2 transfer complete interrupt */ - HAL_NVIC_DisableIRQ(DMA2_Stream1_IRQn); - - /* Configure the DMA stream */ - HAL_DMA_DeInit(hdcmi->DMA_Handle); - - /* Disable DCMI clock */ - __HAL_RCC_DCMI_CLK_DISABLE(); - - /* GPIO pins clock and DMA clock can be shut down in the application - by surcharging this __weak function */ -} - -/** - * @brief Line event callback - * @param hdcmi: pointer to the DCMI handle - */ -void HAL_DCMI_LineEventCallback(DCMI_HandleTypeDef *hdcmi) -{ - BSP_CAMERA_LineEventCallback(); -} - -/** - * @brief Line Event callback. - */ -__weak void BSP_CAMERA_LineEventCallback(void) -{ - /* NOTE : This function Should not be modified, when the callback is needed, - the HAL_DCMI_LineEventCallback could be implemented in the user file - */ -} - -/** - * @brief VSYNC event callback - * @param hdcmi: pointer to the DCMI handle - */ -void HAL_DCMI_VsyncEventCallback(DCMI_HandleTypeDef *hdcmi) -{ - BSP_CAMERA_VsyncEventCallback(); -} - -/** - * @brief VSYNC Event callback. - */ -__weak void BSP_CAMERA_VsyncEventCallback(void) -{ - /* NOTE : This function Should not be modified, when the callback is needed, - the HAL_DCMI_VsyncEventCallback could be implemented in the user file - */ -} - -/** - * @brief Frame event callback - * @param hdcmi: pointer to the DCMI handle - */ -void HAL_DCMI_FrameEventCallback(DCMI_HandleTypeDef *hdcmi) -{ - BSP_CAMERA_FrameEventCallback(); -} - -/** - * @brief Frame Event callback. - */ -__weak void BSP_CAMERA_FrameEventCallback(void) -{ - /* NOTE : This function Should not be modified, when the callback is needed, - the HAL_DCMI_FrameEventCallback could be implemented in the user file - */ -} - -/** - * @brief Error callback - * @param hdcmi: pointer to the DCMI handle - */ -void HAL_DCMI_ErrorCallback(DCMI_HandleTypeDef *hdcmi) -{ - BSP_CAMERA_ErrorCallback(); -} - -/** - * @brief Error callback. - */ -__weak void BSP_CAMERA_ErrorCallback(void) -{ - /* NOTE : This function Should not be modified, when the callback is needed, - the HAL_DCMI_ErrorCallback could be implemented in the user file - */ -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_camera.h b/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_camera.h deleted file mode 100644 index bb2a4f8c7c..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_camera.h +++ /dev/null @@ -1,178 +0,0 @@ -/** - ****************************************************************************** - * @file stm32469i_eval_camera.h - * @author MCD Application Team - * @version V1.0.1 - * @date 29-September-2015 - * @brief This file contains the common defines and functions prototypes for - * the stm32469i_eval_camera.c driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32469I_EVAL_CAMERA_H -#define __STM32469I_EVAL_CAMERA_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -/* Include Camera component Driver */ -#include "../Components/s5k5cag/s5k5cag.h" - -/* Include IO Driver */ -#include "stm32469i_eval_io.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32469I-EVAL - * @{ - */ - -/** @addtogroup STM32469I-EVAL_CAMERA - * @{ - */ - -/** @defgroup STM32469I-EVAL_CAMERA_Exported_Types STM32469I EVAL Camera Exported Types - * @{ - */ - -/** - * @brief Camera State structures definition - */ -typedef enum -{ - CAMERA_OK = 0x00, - CAMERA_ERROR = 0x01, - CAMERA_TIMEOUT = 0x02, - CAMERA_NOT_DETECTED = 0x03, - CAMERA_NOT_SUPPORTED = 0x04 - -} Camera_StatusTypeDef; - -/** - * @brief Camera Image rotation definition - * in frame buffer for LCD Display. - */ -typedef enum -{ - CAMERA_NO_ROTATION = 0x00, - CAMERA_ROTATION_90 = 0x01, - CAMERA_ROTATION_INVALID = 0x02 - -} Camera_RotationTypeDef; - -#define RESOLUTION_R160x120 CAMERA_R160x120 /* QQVGA Resolution */ -#define RESOLUTION_R320x240 CAMERA_R320x240 /* QVGA Resolution */ -#define RESOLUTION_R480x272 CAMERA_R480x272 /* 480x272 Resolution */ -#define RESOLUTION_R640x480 CAMERA_R640x480 /* VGA Resolution */ - -#define CAMERA_VGA_RES_X 640 -#define CAMERA_VGA_RES_Y 480 -#define CAMERA_480x272_RES_X 480 -#define CAMERA_480x272_RES_Y 272 -#define CAMERA_QVGA_RES_X 320 -#define CAMERA_QVGA_RES_Y 240 -#define CAMERA_QQVGA_RES_X 160 -#define CAMERA_QQVGA_RES_Y 120 - -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_CAMERA_Exported_Constants STM32469I-EVAL CAMERA Exported Constants - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_CAMERA_Exported_Functions STM32469I-EVAL CAMERA Exported Functions - * @{ - */ - -uint8_t BSP_CAMERA_SetRotation(uint32_t rotation); -uint32_t BSP_CAMERA_GetRotation(void); - -uint8_t BSP_CAMERA_Init(uint32_t Resolution); -uint8_t BSP_CAMERA_DeInit(void); -void BSP_CAMERA_ContinuousStart(uint8_t *buff); -void BSP_CAMERA_SnapshotStart(uint8_t *buff); -void BSP_CAMERA_Suspend(void); -void BSP_CAMERA_Resume(void); -uint8_t BSP_CAMERA_Stop(void); -void BSP_CAMERA_HwReset(void); -void BSP_CAMERA_PwrDown(void); -void BSP_CAMERA_LineEventCallback(void); -void BSP_CAMERA_VsyncEventCallback(void); -void BSP_CAMERA_FrameEventCallback(void); -void BSP_CAMERA_ErrorCallback(void); - -/* Camera features functions prototype */ -void BSP_CAMERA_ContrastBrightnessConfig(uint32_t contrast_level, uint32_t brightness_level); -void BSP_CAMERA_BlackWhiteConfig(uint32_t Mode); -void BSP_CAMERA_ColorEffectConfig(uint32_t Effect); - -/* To be called in DCMI_IRQHandler function */ -void BSP_CAMERA_IRQHandler(void); - -/* To be called in DMA2_Stream1_IRQHandler function */ -void BSP_CAMERA_DMA_IRQHandler(void); -/* These functions can be modified in case the current settings (e.g. DMA stream) - need to be changed for specific application needs */ -void BSP_CAMERA_MspInit(DCMI_HandleTypeDef *hdcmi, void *Params); -void BSP_CAMERA_MspDeInit(DCMI_HandleTypeDef *hdcmi, void *Params); - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32469I_EVAL_CAMERA_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_eeprom.c b/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_eeprom.c deleted file mode 100644 index 8842761e54..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_eeprom.c +++ /dev/null @@ -1,474 +0,0 @@ -/** - ****************************************************************************** - * @file stm32469i_eval_eeprom.c - * @author MCD Application Team - * @version V1.0.1 - * @date 29-September-2015 - * @brief This file provides a set of functions needed to manage an I2C M24LR64 - * EEPROM memory. - * To be able to use this driver, the switch EE_M24LR64 must be defined - * in your toolchain compiler preprocessor - * - * =================================================================== - * Notes: - * - This driver is intended for STM32F4xx families devices only. - * - The I2C EEPROM memory (M24LR64) is available on separate daughter - * board ANT7-M24LR-A, which is not provided with the STM32469I-EVAL - * board. - * To use this driver you have to connect the ANT7-M24LR-A to CN2 - * connector of STM32469I-EVAL board. - * =================================================================== - * - * It implements a high level communication layer for read and write - * from/to this memory. The needed STM32F4xx hardware resources (I2C and - * GPIO) are defined in stm32469i_eval.h file, and the initialization is - * performed in EEPROM_IO_Init() function declared in stm32469i_eval.c - * file. - * You can easily tailor this driver to any other development board, - * by just adapting the defines for hardware resources and - * EEPROM_IO_Init() function. - * - * @note In this driver, basic read and write functions (BSP_EEPROM_ReadBuffer() - * and BSP_EEPROM_WritePage()) use DMA mode to perform the data - * transfer to/from EEPROM memory. - * - * @note Regarding BSP_EEPROM_WritePage(), it is a optimized function to perform - * small write (less than 1 page) BUT The number of bytes (combined to write start address) must not - * cross the EEPROM page boundary. This function can only write into - * the boundaries of an EEPROM page. - * This function doesn't check on boundaries condition (in this driver - * the function BSP_EEPROM_WriteBuffer() which calls BSP_EEPROM_WritePage() is - * responsible of checking on Page boundaries). - * - * - * +-----------------------------------------------------------------+ - * | Pin assignment for M24LR64 EEPROM | - * +---------------------------------------+-----------+-------------+ - * | STM32F4xx I2C Pins | EEPROM | Pin | - * +---------------------------------------+-----------+-------------+ - * | . | E0(GND) | 1 (0V) | - * | . | AC0 | 2 | - * | . | AC1 | 3 | - * | . | VSS | 4 (0V) | - * | SDA | SDA | 5 | - * | SCL | SCL | 6 | - * | . | E1(GND) | 7 (0V) | - * | . | VDD | 8 (3.3V) | - * +---------------------------------------+-----------+-------------+ - * - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ -/* Includes ------------------------------------------------------------------*/ -#include "stm32469i_eval_eeprom.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32469I-EVAL - * @{ - */ - -/** @addtogroup STM32469I-EVAL_EEPROM - * @brief This file includes the I2C EEPROM driver of STM32469I-EVAL evaluation board. - * @{ - */ - -/** @defgroup STM32469I-EVAL_EEPROM_Private_Types STM32469I Eval Eeprom Private Types - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_EEPROM_Private_Defines STM32469I Eval Eeprom Private Defines - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_EEPROM_Private_Macros STM32469I Eval Eeprom Private Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_EEPROM_Private_Variables STM32469I Eval Eeprom Private Variables - * @{ - */ -__IO uint16_t EEPROMAddress = 0; -__IO uint32_t EEPROMTimeout = EEPROM_READ_TIMEOUT; -__IO uint16_t EEPROMDataRead; -__IO uint8_t EEPROMDataWrite; -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_EEPROM_Private_Function_Prototypes STM32469I Eval Eeprom Private Prototypes - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_EEPROM_Private_Functions STM32469I Eval Eeprom Private Functions - * @{ - */ - -/** - * @brief Initializes peripherals used by the I2C EEPROM driver. - * - * @note There are 2 different versions of M24LR64 (A01 & A02). - * Then try to connect on 1st one (EEPROM_I2C_ADDRESS_A01) - * and if problem, check the 2nd one (EEPROM_I2C_ADDRESS_A02) - * @retval EEPROM_OK (0) if operation is correctly performed, else return value - * different from EEPROM_OK (0) - */ -uint32_t BSP_EEPROM_Init(void) -{ - /* I2C Initialization */ - EEPROM_IO_Init(); - - /* Select the EEPROM address for A01 and check if OK */ - EEPROMAddress = EEPROM_I2C_ADDRESS_A01; - if(EEPROM_IO_IsDeviceReady(EEPROMAddress, EEPROM_MAX_TRIALS) != HAL_OK) - { - /* Select the EEPROM address for A02 and check if OK */ - EEPROMAddress = EEPROM_I2C_ADDRESS_A02; - if(EEPROM_IO_IsDeviceReady(EEPROMAddress, EEPROM_MAX_TRIALS) != HAL_OK) - { - return EEPROM_FAIL; - } - } - return EEPROM_OK; -} - -/** - * @brief DeInitializes the EEPROM. - * @retval EEPROM state - */ -uint8_t BSP_EEPROM_DeInit(void) -{ - /* I2C won't be disabled because common to other functionalities */ - return EEPROM_OK; -} - -/** - * @brief Reads a block of data from the EEPROM. - * @param pBuffer: pointer to the buffer that receives the data read from - * the EEPROM. - * @param ReadAddr: EEPROM's internal address to start reading from. - * @param NumByteToRead: pointer to the variable holding number of bytes to - * be read from the EEPROM. - * - * @note The variable pointed by NumByteToRead is reset to 0 when all the - * data are read from the EEPROM. Application should monitor this - * variable in order know when the transfer is complete. - * - * @retval EEPROM_OK (0) if operation is correctly performed, else return value - * different from EEPROM_OK (0) or the timeout user callback. - */ -uint32_t BSP_EEPROM_ReadBuffer(uint8_t* pBuffer, uint16_t ReadAddr, uint16_t* NumByteToRead) -{ - uint32_t buffersize = *NumByteToRead; - - /* Set the pointer to the Number of data to be read. This pointer will be used - by the DMA Transfer Completer interrupt Handler in order to reset the - variable to 0. User should check on this variable in order to know if the - DMA transfer has been complete or not. */ - EEPROMDataRead = *NumByteToRead; - - if(EEPROM_IO_ReadData(EEPROMAddress, ReadAddr, pBuffer, buffersize) != HAL_OK) - { - BSP_EEPROM_TIMEOUT_UserCallback(); - return EEPROM_FAIL; - } - - /* If all operations OK, return EEPROM_OK (0) */ - return EEPROM_OK; -} - -/** - * @brief Writes more than one byte to the EEPROM with a single WRITE cycle. - * - * @note The number of bytes (combined to write start address) must not - * cross the EEPROM page boundary. This function can only write into - * the boundaries of an EEPROM page. - * This function doesn't check on boundaries condition (in this driver - * the function BSP_EEPROM_WriteBuffer() which calls BSP_EEPROM_WritePage() is - * responsible of checking on Page boundaries). - * - * @param pBuffer: pointer to the buffer containing the data to be written to - * the EEPROM. - * @param WriteAddr: EEPROM's internal address to write to. - * @param NumByteToWrite: pointer to the variable holding number of bytes to - * be written into the EEPROM. - * - * @note The variable pointed by NumByteToWrite is reset to 0 when all the - * data are written to the EEPROM. Application should monitor this - * variable in order know when the transfer is complete. - * - * @note This function just configure the communication and enable the DMA - * channel to transfer data. Meanwhile, the user application may perform - * other tasks in parallel. - * - * @retval EEPROM_OK (0) if operation is correctly performed, else return value - * different from EEPROM_OK (0) or the timeout user callback. - */ -uint32_t BSP_EEPROM_WritePage(uint8_t* pBuffer, uint16_t WriteAddr, uint8_t* NumByteToWrite) -{ - uint32_t buffersize = *NumByteToWrite; - uint32_t status = EEPROM_OK; - - /* Set the pointer to the Number of data to be written. This pointer will be used - by the DMA Transfer Completer interrupt Handler in order to reset the - variable to 0. User should check on this variable in order to know if the - DMA transfer has been complete or not. */ - EEPROMDataWrite = *NumByteToWrite; - - if(EEPROM_IO_WriteData(EEPROMAddress, WriteAddr, pBuffer, buffersize) != HAL_OK) - { - BSP_EEPROM_TIMEOUT_UserCallback(); - status = EEPROM_FAIL; - } - - if(BSP_EEPROM_WaitEepromStandbyState() != EEPROM_OK) - { - return EEPROM_FAIL; - } - - /* If all operations OK, return EEPROM_OK (0) */ - return status; -} - -/** - * @brief Writes buffer of data to the I2C EEPROM. - * @param pBuffer: pointer to the buffer containing the data to be written - * to the EEPROM. - * @param WriteAddr: EEPROM's internal address to write to. - * @param NumByteToWrite: number of bytes to write to the EEPROM. - * @retval EEPROM_OK (0) if operation is correctly performed, else return value - * different from EEPROM_OK (0) or the timeout user callback. - */ -uint32_t BSP_EEPROM_WriteBuffer(uint8_t *pBuffer, uint16_t WriteAddr, uint16_t NumByteToWrite) -{ - uint16_t numofpage = 0, numofsingle = 0, count = 0; - uint16_t addr = 0; - uint8_t dataindex = 0; - uint32_t status = EEPROM_OK; - - addr = WriteAddr % EEPROM_PAGESIZE; - count = EEPROM_PAGESIZE - addr; - numofpage = NumByteToWrite / EEPROM_PAGESIZE; - numofsingle = NumByteToWrite % EEPROM_PAGESIZE; - - /* If WriteAddr is EEPROM_PAGESIZE aligned */ - if(addr == 0) - { - /* If NumByteToWrite < EEPROM_PAGESIZE */ - if(numofpage == 0) - { - /* Store the number of data to be written */ - dataindex = numofsingle; - /* Start writing data */ - status = BSP_EEPROM_WritePage(pBuffer, WriteAddr, (uint8_t*)(&dataindex)); - if(status != EEPROM_OK) - { - return status; - } - } - /* If NumByteToWrite > EEPROM_PAGESIZE */ - else - { - while(numofpage--) - { - /* Store the number of data to be written */ - dataindex = EEPROM_PAGESIZE; - status = BSP_EEPROM_WritePage(pBuffer, WriteAddr, (uint8_t*)(&dataindex)); - if(status != EEPROM_OK) - { - return status; - } - - WriteAddr += EEPROM_PAGESIZE; - pBuffer += EEPROM_PAGESIZE; - } - - if(numofsingle!=0) - { - /* Store the number of data to be written */ - dataindex = numofsingle; - status = BSP_EEPROM_WritePage(pBuffer, WriteAddr, (uint8_t*)(&dataindex)); - if(status != EEPROM_OK) - { - return status; - } - } - } - } - /* If WriteAddr is not EEPROM_PAGESIZE aligned */ - else - { - /* If NumByteToWrite < EEPROM_PAGESIZE */ - if(numofpage== 0) - { - /* If the number of data to be written is more than the remaining space - in the current page: */ - if(NumByteToWrite > count) - { - /* Store the number of data to be written */ - dataindex = count; - /* Write the data contained in same page */ - status = BSP_EEPROM_WritePage(pBuffer, WriteAddr, (uint8_t*)(&dataindex)); - if(status != EEPROM_OK) - { - return status; - } - - /* Store the number of data to be written */ - dataindex = (NumByteToWrite - count); - /* Write the remaining data in the following page */ - status = BSP_EEPROM_WritePage((uint8_t*)(pBuffer + count), (WriteAddr + count), (uint8_t*)(&dataindex)); - if(status != EEPROM_OK) - { - return status; - } - } - else - { - /* Store the number of data to be written */ - dataindex = numofsingle; - status = BSP_EEPROM_WritePage(pBuffer, WriteAddr, (uint8_t*)(&dataindex)); - if(status != EEPROM_OK) - { - return status; - } - } - } - /* If NumByteToWrite > EEPROM_PAGESIZE */ - else - { - NumByteToWrite -= count; - numofpage = NumByteToWrite / EEPROM_PAGESIZE; - numofsingle = NumByteToWrite % EEPROM_PAGESIZE; - - if(count != 0) - { - /* Store the number of data to be written */ - dataindex = count; - status = BSP_EEPROM_WritePage(pBuffer, WriteAddr, (uint8_t*)(&dataindex)); - if(status != EEPROM_OK) - { - return status; - } - WriteAddr += count; - pBuffer += count; - } - - while(numofpage--) - { - /* Store the number of data to be written */ - dataindex = EEPROM_PAGESIZE; - status = BSP_EEPROM_WritePage(pBuffer, WriteAddr, (uint8_t*)(&dataindex)); - if(status != EEPROM_OK) - { - return status; - } - WriteAddr += EEPROM_PAGESIZE; - pBuffer += EEPROM_PAGESIZE; - } - if(numofsingle != 0) - { - /* Store the number of data to be written */ - dataindex = numofsingle; - status = BSP_EEPROM_WritePage(pBuffer, WriteAddr, (uint8_t*)(&dataindex)); - if(status != EEPROM_OK) - { - return status; - } - } - } - } - - /* If all operations OK, return EEPROM_OK (0) */ - return EEPROM_OK; -} - -/** - * @brief Wait for EEPROM Standby state. - * - * @note This function allows to wait and check that EEPROM has finished the - * last operation. It is mostly used after Write operation: after receiving - * the buffer to be written, the EEPROM may need additional time to actually - * perform the write operation. During this time, it doesn't answer to - * I2C packets addressed to it. Once the write operation is complete - * the EEPROM responds to its address. - * - * @retval EEPROM_OK (0) if operation is correctly performed, else return value - * different from EEPROM_OK (0) or the timeout user callback. - */ -uint32_t BSP_EEPROM_WaitEepromStandbyState(void) -{ - /* Check if the maximum allowed number of trials has bee reached */ - if(EEPROM_IO_IsDeviceReady(EEPROMAddress, EEPROM_MAX_TRIALS) != HAL_OK) - { - /* If the maximum number of trials has been reached, exit the function */ - BSP_EEPROM_TIMEOUT_UserCallback(); - return EEPROM_TIMEOUT; - } - return EEPROM_OK; -} - -/** - * @brief Basic management of the timeout situation. - */ -__weak void BSP_EEPROM_TIMEOUT_UserCallback(void) -{ -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_eeprom.h b/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_eeprom.h deleted file mode 100644 index 8ae3e4fe0a..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_eeprom.h +++ /dev/null @@ -1,146 +0,0 @@ -/** - ****************************************************************************** - * @file stm32469i_eval_eeprom.h - * @author MCD Application Team - * @version V1.0.1 - * @date 29-September-2015 - * @brief This file contains all the functions prototypes for - * the stm32469i_eval_eeprom.c firmware driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32F469I_EVAL_EEPROM_H -#define __STM32F469I_EVAL_EEPROM_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm32469i_eval.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32469I-EVAL - * @{ - */ - -/** @addtogroup STM32469I-EVAL_EEPROM - * @brief This file includes the I2C EEPROM driver of STM32469I-EVAL evaluation board. - * @{ - */ - -/** @defgroup STM32469I-EVAL_EEPROM_Exported_Types STM32469I EVAL EEPROM Exported Types - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_EEPROM_Exported_Constants STM32469I-EVAL EEPROM Exported Constants - * @{ - */ -/* EEPROM hardware address and page size */ -#define EEPROM_PAGESIZE ((uint8_t)4) -#define EEPROM_MAX_SIZE ((uint16_t)0x2000) /* 64Kbit */ - -/* Maximum Timeout values for flags and events waiting loops. -This timeout is based on systick set to 1ms*/ -/* Timeout for read based if read all the EEPROM : EEPROM_MAX_SIZE * I2C_SPEED (640ms) */ -#define EEPROM_READ_TIMEOUT ((uint32_t)(1000)) -/* Timeout for write based on max write which is EEPROM_PAGESIZE bytes: EEPROM_PAGESIZE * I2C_SPEED (320us) */ -#define EEPROM_WRITE_TIMEOUT ((uint32_t)(10)) - -/* Maximum number of trials for EEPROM_WaitEepromStandbyState() function */ -#define EEPROM_MAX_TRIALS 3000 - -#define EEPROM_OK 0 -#define EEPROM_FAIL 1 -#define EEPROM_TIMEOUT 2 -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_EEPROM_Exported_Macros STM32469I-EVAL EEPROM Exported Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_EEPROM_Exported_Functions STM32469I-EVAL_EEPROM Exported Functions - * @{ - */ -uint32_t BSP_EEPROM_Init(void); -uint8_t BSP_EEPROM_DeInit(void); -uint32_t BSP_EEPROM_ReadBuffer(uint8_t* pBuffer, uint16_t ReadAddr, uint16_t* NumByteToRead); -uint32_t BSP_EEPROM_WritePage(uint8_t* pBuffer, uint16_t WriteAddr, uint8_t* NumByteToWrite); -uint32_t BSP_EEPROM_WriteBuffer(uint8_t* pBuffer, uint16_t WriteAddr, uint16_t NumByteToWrite); -uint32_t BSP_EEPROM_WaitEepromStandbyState(void); - -/* USER Callbacks: This function is declared as __weak in EEPROM driver and - should be implemented into user application. - BSP_EEPROM_TIMEOUT_UserCallback() function is called whenever a timeout condition - occure during communication (waiting on an event that doesn't occur, bus - errors, busy devices ...). */ -void BSP_EEPROM_TIMEOUT_UserCallback(void); - -/* Link function for I2C EEPROM peripheral */ -void EEPROM_IO_Init(void); -HAL_StatusTypeDef EEPROM_IO_WriteData(uint16_t DevAddress, uint16_t MemAddress, uint8_t *pBuffer, uint32_t BufferSize); -HAL_StatusTypeDef EEPROM_IO_ReadData(uint16_t DevAddress, uint16_t MemAddress, uint8_t *pBuffer, uint32_t BufferSize); -HAL_StatusTypeDef EEPROM_IO_IsDeviceReady(uint16_t DevAddress, uint32_t Trials); - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32469I_EVAL_EEPROM_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_io.c b/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_io.c deleted file mode 100644 index b969ed6243..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_io.c +++ /dev/null @@ -1,302 +0,0 @@ -/** - ****************************************************************************** - * @file stm32469i_eval_io.c - * @author MCD Application Team - * @version V1.0.1 - * @date 29-September-2015 - * @brief This file provides a set of functions needed to manage the IO pins - * on STM32469I-EVAL evaluation board. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* File Info : ----------------------------------------------------------------- - User NOTES -1. How To use this driver: --------------------------- - - This driver is used to drive the IO module of the STM32469I-EVAL evaluation - board. - - The MFXSTM32L152 IO expander device component driver must be included with this - driver in order to run the IO functionalities commanded by the IO expander - device mounted on the evaluation board. - -2. Driver description: ---------------------- - + Initialization steps: - o Initialize the IO module using the BSP_IO_Init() function. This - function includes the MSP layer hardware resources initialization and the - communication layer configuration to start the IO functionalities use. - - + IO functionalities use - o The IO pin mode is configured when calling the function BSP_IO_ConfigPin(), you - must specify the desired IO mode by choosing the "IO_ModeTypedef" parameter - predefined value. - o If an IO pin is used in interrupt mode, the function BSP_IO_ITGetStatus() is - needed to get the interrupt status. To clear the IT pending bits, you should - call the function BSP_IO_ITClearPin() with specifying the IO pending bit to clear. - o The IT is handled using the corresponding external interrupt IRQ handler, - the user IT callback treatment is implemented on the same external interrupt - callback. - o To get/set an IO pin combination state you can use the functions - BSP_IO_ReadPin()/BSP_IO_WritePin() or the function BSP_IO_TogglePin() to toggle the pin - state. - -------------------------------------------------------------------------------*/ - -/* Includes ------------------------------------------------------------------*/ -#include "stm32469i_eval_io.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32469I-EVAL - * @{ - */ - -/** @defgroup STM32469I-EVAL_IO STM32469I-EVAL IO - * @{ - */ - -/** @defgroup STM32469I-EVAL_IO_Private_Types_Definitions STM32469I-EVAL IO Private Types Definitions - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_IO_Private_Defines STM32469I-EVAL IO Private Defines - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_IO_Private_Macros STM32469I-EVAL IO Private Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_IO_Private_Variables STM32469I-EVAL IO Private Variables - * @{ - */ -static IO_DrvTypeDef *IoDrv = NULL; -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_IO_Private_Function_Prototypes STM32469I-EVAL IO Private Function Prototypes - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_IO_Private_Functions STM32469I-EVAL IO Private Functions - * @{ - */ - -/** - * @brief Initializes and configures the IO functionalities and configures all - * necessary hardware resources (GPIOs, clocks..). - * @note BSP_IO_Init() is using HAL_Delay() function to ensure that MFXSTM32L152 - * IO Expander is correctly reset. HAL_Delay() function provides accurate - * delay (in milliseconds) based on variable incremented in SysTick ISR. - * This implies that if BSP_IO_Init() is called from a peripheral ISR process, - * then the SysTick interrupt must have higher priority (numerically lower) - * than the peripheral interrupt. Otherwise the caller ISR process will be blocked. - * @retval IO_OK if all initializations are OK. Other value if error. - */ -uint8_t BSP_IO_Init(void) -{ - uint8_t ret = IO_ERROR; - uint8_t mfxstm32l152_id = 0; - HAL_Delay(1); - /* Read ID and verify the IO expander is ready */ - mfxstm32l152_id = mfxstm32l152_io_drv.ReadID(IO_I2C_ADDRESS); - if((mfxstm32l152_id == MFXSTM32L152_ID_1) || (mfxstm32l152_id == MFXSTM32L152_ID_2)) - { - /* Initialize the IO driver structure */ - IoDrv = &mfxstm32l152_io_drv; - ret = IO_OK; - } - - if(ret == IO_OK) - { - IoDrv->Init(IO_I2C_ADDRESS); - IoDrv->Start(IO_I2C_ADDRESS, IO_PIN_ALL); - } - return ret; -} - -/** - * @brief DeInit allows Mfx Inititialization to be executed again - * @note BSP_IO_Init() has no effect if the IoDrv is already initialized - * BSP_IO_DeInit() allows to erase the pointer such to allow init to be effective - * @retval IO_OK - */ -uint8_t BSP_IO_DeInit(void) -{ - IoDrv = NULL; - return IO_OK; -} - -/** - * @brief Gets the selected pins IT status. - * @param IoPin: Selected pins to check the status. - * This parameter can be any combination of the IO pins. - * @retval IO_OK if read status OK. Other value if error. - */ -uint32_t BSP_IO_ITGetStatus(uint32_t IoPin) -{ - /* Return the IO Pin IT status */ - return (IoDrv->ITStatus(IO_I2C_ADDRESS, IoPin)); -} - -/** - * @brief Clears all the IO IT pending bits. - */ -void BSP_IO_ITClear(void) -{ - /* Clear all IO IT pending bits */ - IoDrv->ClearIT(IO_I2C_ADDRESS, MFXSTM32L152_GPIO_PINS_ALL); -} - -/** - * @brief Clear only one or a selection of IO IT pending bits. - * @param IO_Pins_To_Clear : MFX IRQ status IO pin to clear (or combination of several IOs) - */ -void BSP_IO_ITClearPin(uint32_t IO_Pins_To_Clear) -{ - /* Clear only the selected list of IO IT pending bits */ - IoDrv->ClearIT(IO_I2C_ADDRESS, IO_Pins_To_Clear); -} - -/** - * @brief Configures the IO pin(s) according to IO mode structure value. - * @param IO_Pin: IO pin(s) to be configured. - * This parameter can be one of the following values: - * @arg MFXSTM32L152_GPIO_PIN_x: where x can be from 0 to 23. - * @param IO_Mode: IO pin mode to configure - * This parameter can be one of the following values: - * @arg IO_MODE_INPUT - * @arg IO_MODE_OUTPUT - * @arg IO_MODE_IT_RISING_EDGE - * @arg IO_MODE_IT_FALLING_EDGE - * @arg IO_MODE_IT_LOW_LEVEL - * @arg IO_MODE_IT_HIGH_LEVEL - * @arg IO_MODE_ANALOG - * @arg IO_MODE_OFF - * @arg IO_MODE_INPUT_PU, - * @arg IO_MODE_INPUT_PD, - * @arg IO_MODE_OUTPUT_OD, - * @arg IO_MODE_OUTPUT_OD_PU, - * @arg IO_MODE_OUTPUT_OD_PD, - * @arg IO_MODE_OUTPUT_PP, - * @arg IO_MODE_OUTPUT_PP_PU, - * @arg IO_MODE_OUTPUT_PP_PD, - * @arg IO_MODE_IT_RISING_EDGE_PU - * @arg IO_MODE_IT_FALLING_EDGE_PU - * @arg IO_MODE_IT_LOW_LEVEL_PU - * @arg IO_MODE_IT_HIGH_LEVEL_PU - * @arg IO_MODE_IT_RISING_EDGE_PD - * @arg IO_MODE_IT_FALLING_EDGE_PD - * @arg IO_MODE_IT_LOW_LEVEL_PD - * @arg IO_MODE_IT_HIGH_LEVEL_PD - * @retval IO_OK if all initializations are OK. Other value if error. - */ -uint8_t BSP_IO_ConfigPin(uint32_t IO_Pin, IO_ModeTypedef IO_Mode) -{ - /* Configure the selected IO pin(s) mode */ - IoDrv->Config(IO_I2C_ADDRESS, IO_Pin, IO_Mode); - - return IO_OK; -} - -/** - * @brief Sets the selected pins state. - * @param IO_Pin: Selected pins to write. - * This parameter can be any combination of the IO pins. - * @param PinState: New pins state to write - */ -void BSP_IO_WritePin(uint32_t IO_Pin, BSP_IO_PinStateTypeDef PinState) -{ - /* Set the Pin state */ - IoDrv->WritePin(IO_I2C_ADDRESS, IO_Pin, PinState); -} - -/** - * @brief Gets the selected pins current state. - * @param IO_Pin: Selected pins to read. - * This parameter can be any combination of the IO pins. - * @retval The current pins state - */ -uint32_t BSP_IO_ReadPin(uint32_t IO_Pin) -{ - return(IoDrv->ReadPin(IO_I2C_ADDRESS, IO_Pin)); -} - -/** - * @brief Toggles the selected pins state. - * @param IO_Pin: Selected pins to toggle. - * This parameter can be any combination of the IO pins. - * @note This function is only used to toggle one pin in the same time - */ -void BSP_IO_TogglePin(uint32_t IO_Pin) -{ - /* Toggle the current pin state */ - if(IoDrv->ReadPin(IO_I2C_ADDRESS, IO_Pin) != 0) /* Set */ - { - IoDrv->WritePin(IO_I2C_ADDRESS, IO_Pin, 0); /* Reset */ - } - else - { - IoDrv->WritePin(IO_I2C_ADDRESS, IO_Pin, 1); /* Set */ - } -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_io.h b/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_io.h deleted file mode 100644 index cf75362137..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_io.h +++ /dev/null @@ -1,159 +0,0 @@ -/** - ****************************************************************************** - * @file stm32469i_eval_io.h - * @author MCD Application Team - * @version V1.0.1 - * @date 29-September-2015 - * @brief This file contains the common defines and functions prototypes for - * the stm32469i_eval_io.c driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32469I_EVAL_IO_H -#define __STM32469I_EVAL_IO_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm32469i_eval.h" -/* Include IO component driver */ -#include "../Components/mfxstm32l152/mfxstm32l152.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32469I-EVAL - * @{ - */ - -/** @defgroup STM32469I-EVAL_IO STM32469I-EVAL IO - * @{ - */ - -/** @defgroup STM32469I-EVAL_IO_Exported_Types STM32469I-EVAL IO Exported Types - * @{ - */ - - -typedef enum -{ - BSP_IO_PIN_RESET = 0, - BSP_IO_PIN_SET = 1 -}BSP_IO_PinStateTypeDef; - -typedef enum -{ - IO_OK = 0, - IO_ERROR = 1, - IO_TIMEOUT = 2 -}IO_StatusTypeDef; -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_IO_Exported_Constants STM32469I-EVAL IO Exported Constants - * @{ - */ -#define IO_PIN_0 ((uint32_t)0x0001) -#define IO_PIN_1 ((uint32_t)0x0002) -#define IO_PIN_2 ((uint32_t)0x0004) -#define IO_PIN_3 ((uint32_t)0x0008) -#define IO_PIN_4 ((uint32_t)0x0010) -#define IO_PIN_5 ((uint32_t)0x0020) -#define IO_PIN_6 ((uint32_t)0x0040) -#define IO_PIN_7 ((uint32_t)0x0080) -#define IO_PIN_8 ((uint32_t)0x0100) -#define IO_PIN_9 ((uint32_t)0x0200) -#define IO_PIN_10 ((uint32_t)0x0400) -#define IO_PIN_11 ((uint32_t)0x0800) -#define IO_PIN_12 ((uint32_t)0x1000) -#define IO_PIN_13 ((uint32_t)0x2000) -#define IO_PIN_14 ((uint32_t)0x4000) -#define IO_PIN_15 ((uint32_t)0x8000) -#define IO_PIN_16 ((uint32_t)0x010000) -#define IO_PIN_17 ((uint32_t)0x020000) -#define IO_PIN_18 ((uint32_t)0x040000) -#define IO_PIN_19 ((uint32_t)0x080000) -#define IO_PIN_20 ((uint32_t)0x100000) -#define IO_PIN_21 ((uint32_t)0x200000) -#define IO_PIN_22 ((uint32_t)0x400000) -#define IO_PIN_23 ((uint32_t)0x800000) -#define IO_PIN_ALL ((uint32_t)0xFFFFFF) -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_IO_Exported_Macro STM32469I-EVAL IO Exported Macro - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_IO_Exported_Functions STM32469I-EVAL IO Exported Functions - * @{ - */ -uint8_t BSP_IO_Init(void); -uint8_t BSP_IO_DeInit(void); -uint32_t BSP_IO_ITGetStatus(uint32_t IO_Pin); -void BSP_IO_ITClear(void); -void BSP_IO_ITClearPin(uint32_t IO_Pins_To_Clear); -uint8_t BSP_IO_ConfigPin(uint32_t IO_Pin, IO_ModeTypedef IO_Mode); -void BSP_IO_WritePin(uint32_t IO_Pin, BSP_IO_PinStateTypeDef PinState); -uint32_t BSP_IO_ReadPin(uint32_t IO_Pin); -void BSP_IO_TogglePin(uint32_t IO_Pin); - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32469I_EVAL_IO_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_lcd.c b/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_lcd.c deleted file mode 100644 index e7ab39ce25..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_lcd.c +++ /dev/null @@ -1,1629 +0,0 @@ -/** - ****************************************************************************** - * @file stm32469i_eval_lcd.c - * @author MCD Application Team - * @version V1.0.1 - * @date 29-September-2015 - * @brief This file includes the driver for Liquid Crystal Display (LCD) module - * mounted on STM32469I-EVAL evaluation board. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* File Info: ------------------------------------------------------------------ - User NOTES -1. How To use this driver: --------------------------- - - This driver is used to drive directly in video mode a LCD TFT using the DSI interface. - The following IPs are implied : DSI Host IP block working - in conjunction to the LTDC controller. - - This driver is linked by construction to LCD KoD mounted on board MB1166. - -2. Driver description: ---------------------- - + Initialization steps: - o Initialize the LCD using the BSP_LCD_Init() function. - o Select the LCD layer to be used using the BSP_LCD_SelectLayer() function. - o Enable the LCD display using the BSP_LCD_DisplayOn() function. - - + Options - o Configure and enable the color keying functionality using the - BSP_LCD_SetColorKeying() function. - o Modify in the fly the transparency and/or the frame buffer address - using the following functions: - - BSP_LCD_SetTransparency() - - BSP_LCD_SetLayerAddress() - - + Display on LCD - o Clear the whole LCD using BSP_LCD_Clear() function or only one specified string - line using the BSP_LCD_ClearStringLine() function. - o Display a character on the specified line and column using the BSP_LCD_DisplayChar() - function or a complete string line using the BSP_LCD_DisplayStringAtLine() function. - o Display a string line on the specified position (x,y in pixel) and align mode - using the BSP_LCD_DisplayStringAtLine() function. - o Draw and fill a basic shapes (dot, line, rectangle, circle, ellipse, .. bitmap) - on LCD using the available set of functions. - -------------------------------------------------------------------------------*/ - -/* Includes ------------------------------------------------------------------*/ -#include "stm32469i_eval_lcd.h" -#include "../../../Utilities/Fonts/fonts.h" -#include "../../../Utilities/Fonts/font24.c" -#include "../../../Utilities/Fonts/font20.c" -#include "../../../Utilities/Fonts/font16.c" -#include "../../../Utilities/Fonts/font12.c" -#include "../../../Utilities/Fonts/font8.c" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32469I-EVAL - * @{ - */ - -/** @addtogroup STM32469I-EVAL_LCD - * @{ - */ - -/** @defgroup STM32469I-EVAL_LCD_Private_TypesDefinitions LCD Private TypesDefinitions - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_LCD_Private_Defines LCD Private Defines - * @{ - */ -static DSI_VidCfgTypeDef hdsivideo_handle; -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_LCD_Private_Macros LCD Private Macros - * @{ - */ -#define ABS(X) ((X) > 0 ? (X) : -(X)) - -#define POLY_X(Z) ((int32_t)((Points + (Z))->X)) -#define POLY_Y(Z) ((int32_t)((Points + (Z))->Y)) -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_LCD_Exported_Variables STM32469I EVAL LCD Exported Variables - * @{ - */ -DMA2D_HandleTypeDef hdma2d_eval; -LTDC_HandleTypeDef hltdc_eval; -DSI_HandleTypeDef hdsi_eval; -uint32_t lcd_x_size = OTM8009A_800X480_WIDTH; -uint32_t lcd_y_size = OTM8009A_800X480_HEIGHT; -/** - * @} - */ - - -/** @defgroup STM32469I-EVAL_LCD_Private_Variables LCD Private Variables - * @{ - */ - -/** - * @brief Default Active LTDC Layer in which drawing is made is LTDC Layer Background - */ -static uint32_t ActiveLayer = LTDC_ACTIVE_LAYER_BACKGROUND; - -/** - * @brief Current Drawing Layer properties variable - */ -static LCD_DrawPropTypeDef DrawProp[LTDC_MAX_LAYER_NUMBER]; -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_LCD_Private_FunctionPrototypes LCD Private FunctionPrototypes - * @{ - */ -static void DrawChar(uint16_t Xpos, uint16_t Ypos, const uint8_t *c); -static void FillTriangle(uint16_t x1, uint16_t x2, uint16_t x3, uint16_t y1, uint16_t y2, uint16_t y3); -static void LL_FillBuffer(uint32_t LayerIndex, void *pDst, uint32_t xSize, uint32_t ySize, uint32_t OffLine, uint32_t ColorIndex); -static void LL_ConvertLineToARGB8888(void * pSrc, void *pDst, uint32_t xSize, uint32_t ColorMode); -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_LCD_Exported_Functions LCD Exported Functions - * @{ - */ - -/** - * @brief Initializes the DSI LCD. - * @param None - * @retval LCD state - */ -uint8_t BSP_LCD_Init(void) -{ - return (BSP_LCD_InitEx(LCD_ORIENTATION_LANDSCAPE)); -} - -/** - * @brief Initializes the DSI LCD. - * The ititialization is done as below: - * - DSI PLL ititialization - * - DSI ititialization - * - LTDC ititialization - * - OTM8009A LCD Display IC Driver ititialization - * @param None - * @retval LCD state - */ -uint8_t BSP_LCD_InitEx(LCD_OrientationTypeDef orientation) -{ - DSI_PLLInitTypeDef dsiPllInit; - static RCC_PeriphCLKInitTypeDef PeriphClkInitStruct; - uint32_t LcdClock = 27429; /*!< LcdClk = 27429 kHz */ - uint32_t Clockratio = 0; - - uint32_t laneByteClk_kHz = 0; - uint32_t VSA; /*!< Vertical start active time in units of lines */ - uint32_t VBP; /*!< Vertical Back Porch time in units of lines */ - uint32_t VFP; /*!< Vertical Front Porch time in units of lines */ - uint32_t VACT; /*!< Vertical Active time in units of lines = imageSize Y in pixels to display */ - uint32_t HSA; /*!< Horizontal start active time in units of lcdClk */ - uint32_t HBP; /*!< Horizontal Back Porch time in units of lcdClk */ - uint32_t HFP; /*!< Horizontal Front Porch time in units of lcdClk */ - uint32_t HACT; /*!< Horizontal Active time in units of lcdClk = imageSize X in pixels to display */ - - - /* Toggle Hardware Reset of the DSI LCD using - * its XRES signal (active low) */ - BSP_LCD_Reset(); - - /* Call first MSP Initialize only in case of first initialization - * This will set IP blocks LTDC, DSI and DMA2D - * - out of reset - * - clocked - * - NVIC IRQ related to IP blocks enabled - */ - BSP_LCD_MspInit(); - -/*************************DSI Initialization***********************************/ - - /* Base address of DSI Host/Wrapper registers to be set before calling De-Init */ - hdsi_eval.Instance = DSI; - - HAL_DSI_DeInit(&(hdsi_eval)); - - dsiPllInit.PLLNDIV = 100; - dsiPllInit.PLLIDF = DSI_PLL_IN_DIV5; - dsiPllInit.PLLODF = DSI_PLL_OUT_DIV1; - laneByteClk_kHz = 62500; /* 500 MHz / 8 = 62.5 MHz = 62500 kHz */ - - /* Set number of Lanes */ - hdsi_eval.Init.NumberOfLanes = DSI_TWO_DATA_LANES; - - /* TXEscapeCkdiv = f(LaneByteClk)/15.62 = 4 */ - hdsi_eval.Init.TXEscapeCkdiv = laneByteClk_kHz/15620; - - HAL_DSI_Init(&(hdsi_eval), &(dsiPllInit)); - Clockratio = laneByteClk_kHz/LcdClock; - /* Timing parameters for all Video modes - * Set Timing parameters of LTDC depending on its chosen orientation - */ - if(orientation == LCD_ORIENTATION_PORTRAIT) - { - VSA = OTM8009A_480X800_VSYNC; /* 12 */ - VBP = OTM8009A_480X800_VBP; /* 12 */ - VFP = OTM8009A_480X800_VFP; /* 12 */ - HSA = OTM8009A_480X800_HSYNC; /* 120 */ - HBP = OTM8009A_480X800_HBP; /* 120 */ - HFP = OTM8009A_480X800_HFP; /* 120 */ - lcd_x_size = OTM8009A_480X800_WIDTH; /* 480 */ - lcd_y_size = OTM8009A_480X800_HEIGHT; /* 800 */ - } - else - { - /* lcd_orientation == LCD_ORIENTATION_LANDSCAPE */ - VSA = OTM8009A_800X480_VSYNC; /* 12 */ - VBP = OTM8009A_800X480_VBP; /* 12 */ - VFP = OTM8009A_800X480_VFP; /* 12 */ - HSA = OTM8009A_800X480_HSYNC; /* 120 */ - HBP = OTM8009A_800X480_HBP; /* 120 */ - HFP = OTM8009A_800X480_HFP; /* 120 */ - lcd_x_size = OTM8009A_800X480_WIDTH; /* 800 */ - lcd_y_size = OTM8009A_800X480_HEIGHT; /* 480 */ - } - - HACT = lcd_x_size; - VACT = lcd_y_size; - - - hdsivideo_handle.VirtualChannelID = LCD_OTM8009A_ID; - hdsivideo_handle.ColorCoding = LCD_DSI_PIXEL_DATA_FMT_RBG888; - hdsivideo_handle.VSPolarity = DSI_VSYNC_ACTIVE_HIGH; - hdsivideo_handle.HSPolarity = DSI_HSYNC_ACTIVE_HIGH; - hdsivideo_handle.DEPolarity = DSI_DATA_ENABLE_ACTIVE_HIGH; - hdsivideo_handle.Mode = DSI_VID_MODE_BURST; /* Mode Video burst ie : one LgP per line */ - hdsivideo_handle.NullPacketSize = 0xFFF; - hdsivideo_handle.NumberOfChunks = 0; - hdsivideo_handle.PacketSize = HACT; /* Value depending on display orientation choice portrait/landscape */ - hdsivideo_handle.HorizontalSyncActive = HSA*Clockratio; - hdsivideo_handle.HorizontalBackPorch = HBP*Clockratio; - hdsivideo_handle.HorizontalLine = (HACT + HSA + HBP + HFP)*Clockratio; /* Value depending on display orientation choice portrait/landscape */ - hdsivideo_handle.VerticalSyncActive = VSA; - hdsivideo_handle.VerticalBackPorch = VBP; - hdsivideo_handle.VerticalFrontPorch = VFP; - hdsivideo_handle.VerticalActive = VACT; /* Value depending on display orientation choice portrait/landscape */ - - /* Enable or disable sending LP command while streaming is active in video mode */ - hdsivideo_handle.LPCommandEnable = DSI_LP_COMMAND_ENABLE; /* Enable sending commands in mode LP (Low Power) */ - - /* Largest packet size possible to transmit in LP mode in VSA, VBP, VFP regions */ - /* Only useful when sending LP packets is allowed while streaming is active in video mode */ - hdsivideo_handle.LPLargestPacketSize = 64; - - /* Largest packet size possible to transmit in LP mode in HFP region during VACT period */ - /* Only useful when sending LP packets is allowed while streaming is active in video mode */ - hdsivideo_handle.LPVACTLargestPacketSize = 64; - - - /* Specify for each region of the video frame, if the transmission of command in LP mode is allowed in this region */ - /* while streaming is active in video mode */ - hdsivideo_handle.LPHorizontalFrontPorchEnable = DSI_LP_HFP_ENABLE; /* Allow sending LP commands during HFP period */ - hdsivideo_handle.LPHorizontalBackPorchEnable = DSI_LP_HBP_ENABLE; /* Allow sending LP commands during HBP period */ - hdsivideo_handle.LPVerticalActiveEnable = DSI_LP_VACT_ENABLE; /* Allow sending LP commands during VACT period */ - hdsivideo_handle.LPVerticalFrontPorchEnable = DSI_LP_VFP_ENABLE; /* Allow sending LP commands during VFP period */ - hdsivideo_handle.LPVerticalBackPorchEnable = DSI_LP_VBP_ENABLE; /* Allow sending LP commands during VBP period */ - hdsivideo_handle.LPVerticalSyncActiveEnable = DSI_LP_VSYNC_ENABLE; /* Allow sending LP commands during VSync = VSA period */ - - /* Configure DSI Video mode timings with settings set above */ - HAL_DSI_ConfigVideoMode(&(hdsi_eval), &(hdsivideo_handle)); - - /* Enable the DSI host and wrapper : but LTDC is not started yet at this stage */ - HAL_DSI_Start(&(hdsi_eval)); -/*************************End DSI Initialization*******************************/ - - -/************************LTDC Initialization***********************************/ - - /* Timing Configuration */ - hltdc_eval.Init.HorizontalSync = (HSA - 1); - hltdc_eval.Init.AccumulatedHBP = (HSA + HBP - 1); - hltdc_eval.Init.AccumulatedActiveW = (lcd_x_size + HSA + HBP - 1); - hltdc_eval.Init.TotalWidth = (lcd_x_size + HSA + HBP + HFP - 1); - - /* Initialize the LCD pixel width and pixel height */ - hltdc_eval.LayerCfg->ImageWidth = lcd_x_size; - hltdc_eval.LayerCfg->ImageHeight = lcd_y_size; - - - /* LCD clock configuration */ - /* PLLSAI_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */ - /* PLLSAI_VCO Output = PLLSAI_VCO Input * PLLSAIN = 384 Mhz */ - /* PLLLCDCLK = PLLSAI_VCO Output/PLLSAIR = 384 MHz / 7 = 54.857 MHz */ - /* LTDC clock frequency = PLLLCDCLK / LTDC_PLLSAI_DIVR_2 = 54.857 MHz / 2 = 27.429 MHz */ - PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC; - PeriphClkInitStruct.PLLSAI.PLLSAIN = 384; - PeriphClkInitStruct.PLLSAI.PLLSAIR = 7; - PeriphClkInitStruct.PLLSAIDivR = RCC_PLLSAIDIVR_2; - HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct); - - /* Background value */ - hltdc_eval.Init.Backcolor.Blue = 0; - hltdc_eval.Init.Backcolor.Green = 0; - hltdc_eval.Init.Backcolor.Red = 0; - hltdc_eval.Init.PCPolarity = LTDC_PCPOLARITY_IPC; - hltdc_eval.Instance = LTDC; - - /* Get LTDC Configuration from DSI Configuration */ - HAL_LTDC_StructInitFromVideoConfig(&(hltdc_eval), &(hdsivideo_handle)); - - /* Initialize the LTDC */ - HAL_LTDC_Init(&hltdc_eval); - -#if !defined(DATA_IN_ExtSDRAM) - /* Initialize the SDRAM */ - BSP_SDRAM_Init(); -#endif /* DATA_IN_ExtSDRAM */ - - /* Initialize the font */ - BSP_LCD_SetFont(&LCD_DEFAULT_FONT); - -/************************End LTDC Initialization*******************************/ - - -/***********************OTM8009A Initialization********************************/ - - /* Initialize the OTM8009A LCD Display IC Driver (KoD LCD IC Driver) - * depending on configuration set in 'hdsivideo_handle'. - */ - OTM8009A_Init(hdsivideo_handle.ColorCoding, orientation); - -/***********************End OTM8009A Initialization****************************/ - - return LCD_OK; -} - -/** - * @brief BSP LCD Reset - * Hw reset the LCD DSI activating its XRES signal (active low for some time) - * and desactivating it later. - * This signal is only cabled on Eval Rev B and beyond. - */ -void BSP_LCD_Reset(void) -{ -#if !defined(USE_STM32469I_EVAL_REVA) -/* EVAL Rev B and beyond : reset the LCD by activation of XRES (active low) connected to PK7 */ - GPIO_InitTypeDef gpio_init_structure; - - __HAL_RCC_GPIOK_CLK_ENABLE(); - - /* Configure the GPIO on PK7 */ - gpio_init_structure.Pin = GPIO_PIN_7; - gpio_init_structure.Mode = GPIO_MODE_OUTPUT_PP; - gpio_init_structure.Pull = GPIO_PULLUP; - gpio_init_structure.Speed = GPIO_SPEED_HIGH; - - HAL_GPIO_Init(GPIOK, &gpio_init_structure); - - /* Activate XRES active low */ - HAL_GPIO_WritePin(GPIOK, GPIO_PIN_7, GPIO_PIN_RESET); - - HAL_Delay(20); /* wait 20 ms */ - - /* Desactivate XRES */ - HAL_GPIO_WritePin(GPIOK, GPIO_PIN_7, GPIO_PIN_SET); - - /* Wait for 10ms after releasing XRES before sending commands */ - HAL_Delay(10); -#else - -#endif /* USE_STM32469I_EVAL_REVA == 0 */ -} - -/** - * @brief Gets the LCD X size. - * @retval Used LCD X size - */ -uint32_t BSP_LCD_GetXSize(void) -{ - return (lcd_x_size); -} - -/** - * @brief Gets the LCD Y size. - * @retval Used LCD Y size - */ -uint32_t BSP_LCD_GetYSize(void) -{ - return (lcd_y_size); -} - -/** - * @brief Set the LCD X size. - * @param imageWidthPixels : uint32_t image width in pixels unit - * @retval None - */ -void BSP_LCD_SetXSize(uint32_t imageWidthPixels) -{ - hltdc_eval.LayerCfg[ActiveLayer].ImageWidth = imageWidthPixels; -} - -/** - * @brief Set the LCD Y size. - * @param imageHeightPixels : uint32_t image height in lines unit - */ -void BSP_LCD_SetYSize(uint32_t imageHeightPixels) -{ - hltdc_eval.LayerCfg[ActiveLayer].ImageHeight = imageHeightPixels; -} - - -/** - * @brief Initializes the LCD layers. - * @param LayerIndex: Layer foreground or background - * @param FB_Address: Layer frame buffer - * @retval None - */ -void BSP_LCD_LayerDefaultInit(uint16_t LayerIndex, uint32_t FB_Address) -{ - LCD_LayerCfgTypeDef Layercfg; - - /* Layer Init */ - Layercfg.WindowX0 = 0; - Layercfg.WindowX1 = BSP_LCD_GetXSize(); - Layercfg.WindowY0 = 0; - Layercfg.WindowY1 = BSP_LCD_GetYSize(); - Layercfg.PixelFormat = LTDC_PIXEL_FORMAT_ARGB8888; - Layercfg.FBStartAdress = FB_Address; - Layercfg.Alpha = 255; - Layercfg.Alpha0 = 0; - Layercfg.Backcolor.Blue = 0; - Layercfg.Backcolor.Green = 0; - Layercfg.Backcolor.Red = 0; - Layercfg.BlendingFactor1 = LTDC_BLENDING_FACTOR1_PAxCA; - Layercfg.BlendingFactor2 = LTDC_BLENDING_FACTOR2_PAxCA; - Layercfg.ImageWidth = BSP_LCD_GetXSize(); - Layercfg.ImageHeight = BSP_LCD_GetYSize(); - - HAL_LTDC_ConfigLayer(&hltdc_eval, &Layercfg, LayerIndex); - - DrawProp[LayerIndex].BackColor = LCD_COLOR_WHITE; - DrawProp[LayerIndex].pFont = &Font24; - DrawProp[LayerIndex].TextColor = LCD_COLOR_BLACK; -} - - -/** - * @brief Selects the LCD Layer. - * @param LayerIndex: Layer foreground or background - */ -void BSP_LCD_SelectLayer(uint32_t LayerIndex) -{ - ActiveLayer = LayerIndex; -} - -/** - * @brief Sets an LCD Layer visible - * @param LayerIndex: Visible Layer - * @param State: New state of the specified layer - * This parameter can be one of the following values: - * @arg ENABLE - * @arg DISABLE - */ -void BSP_LCD_SetLayerVisible(uint32_t LayerIndex, FunctionalState State) -{ - if(State == ENABLE) - { - __HAL_LTDC_LAYER_ENABLE(&(hltdc_eval), LayerIndex); - } - else - { - __HAL_LTDC_LAYER_DISABLE(&(hltdc_eval), LayerIndex); - } - __HAL_LTDC_RELOAD_CONFIG(&(hltdc_eval)); - -} - -/** - * @brief Configures the transparency. - * @param LayerIndex: Layer foreground or background. - * @param Transparency: Transparency - * This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFF - */ -void BSP_LCD_SetTransparency(uint32_t LayerIndex, uint8_t Transparency) -{ - - HAL_LTDC_SetAlpha(&(hltdc_eval), Transparency, LayerIndex); - -} - -/** - * @brief Sets an LCD layer frame buffer address. - * @param LayerIndex: Layer foreground or background - * @param Address: New LCD frame buffer value - */ -void BSP_LCD_SetLayerAddress(uint32_t LayerIndex, uint32_t Address) -{ - - HAL_LTDC_SetAddress(&(hltdc_eval), Address, LayerIndex); - -} - -/** - * @brief Sets display window. - * @param LayerIndex: Layer index - * @param Xpos: LCD X position - * @param Ypos: LCD Y position - * @param Width: LCD window width - * @param Height: LCD window height - */ -void BSP_LCD_SetLayerWindow(uint16_t LayerIndex, uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height) -{ - /* Reconfigure the layer size */ - HAL_LTDC_SetWindowSize(&(hltdc_eval), Width, Height, LayerIndex); - - /* Reconfigure the layer position */ - HAL_LTDC_SetWindowPosition(&(hltdc_eval), Xpos, Ypos, LayerIndex); - -} - -/** - * @brief Configures and sets the color keying. - * @param LayerIndex: Layer foreground or background - * @param RGBValue: Color reference - */ -void BSP_LCD_SetColorKeying(uint32_t LayerIndex, uint32_t RGBValue) -{ - /* Configure and Enable the color Keying for LCD Layer */ - HAL_LTDC_ConfigColorKeying(&(hltdc_eval), RGBValue, LayerIndex); - HAL_LTDC_EnableColorKeying(&(hltdc_eval), LayerIndex); -} - -/** - * @brief Disables the color keying. - * @param LayerIndex: Layer foreground or background - */ -void BSP_LCD_ResetColorKeying(uint32_t LayerIndex) -{ - /* Disable the color Keying for LCD Layer */ - HAL_LTDC_DisableColorKeying(&(hltdc_eval), LayerIndex); -} - -/** - * @brief Sets the LCD text color. - * @param Color: Text color code ARGB(8-8-8-8) - */ -void BSP_LCD_SetTextColor(uint32_t Color) -{ - DrawProp[ActiveLayer].TextColor = Color; -} - -/** - * @brief Gets the LCD text color. - * @retval Used text color. - */ -uint32_t BSP_LCD_GetTextColor(void) -{ - return DrawProp[ActiveLayer].TextColor; -} - -/** - * @brief Sets the LCD background color. - * @param Color: Layer background color code ARGB(8-8-8-8) - */ -void BSP_LCD_SetBackColor(uint32_t Color) -{ - DrawProp[ActiveLayer].BackColor = Color; -} - -/** - * @brief Gets the LCD background color. - * @retval Used background color - */ -uint32_t BSP_LCD_GetBackColor(void) -{ - return DrawProp[ActiveLayer].BackColor; -} - -/** - * @brief Sets the LCD text font. - * @param fonts: Layer font to be used - */ -void BSP_LCD_SetFont(sFONT *fonts) -{ - DrawProp[ActiveLayer].pFont = fonts; -} - -/** - * @brief Gets the LCD text font. - * @retval Used layer font - */ -sFONT *BSP_LCD_GetFont(void) -{ - return DrawProp[ActiveLayer].pFont; -} - -/** - * @brief Reads an LCD pixel. - * @param Xpos: X position - * @param Ypos: Y position - * @retval RGB pixel color - */ -uint32_t BSP_LCD_ReadPixel(uint16_t Xpos, uint16_t Ypos) -{ - uint32_t ret = 0; - - if(hltdc_eval.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_ARGB8888) - { - /* Read data value from SDRAM memory */ - ret = *(__IO uint32_t*) (hltdc_eval.LayerCfg[ActiveLayer].FBStartAdress + (2*(Ypos*BSP_LCD_GetXSize() + Xpos))); - } - else if(hltdc_eval.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_RGB888) - { - /* Read data value from SDRAM memory */ - ret = (*(__IO uint32_t*) (hltdc_eval.LayerCfg[ActiveLayer].FBStartAdress + (2*(Ypos*BSP_LCD_GetXSize() + Xpos))) & 0x00FFFFFF); - } - else if((hltdc_eval.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_RGB565) || \ - (hltdc_eval.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_ARGB4444) || \ - (hltdc_eval.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_AL88)) - { - /* Read data value from SDRAM memory */ - ret = *(__IO uint16_t*) (hltdc_eval.LayerCfg[ActiveLayer].FBStartAdress + (2*(Ypos*BSP_LCD_GetXSize() + Xpos))); - } - else - { - /* Read data value from SDRAM memory */ - ret = *(__IO uint8_t*) (hltdc_eval.LayerCfg[ActiveLayer].FBStartAdress + (2*(Ypos*BSP_LCD_GetXSize() + Xpos))); - } - - return ret; -} - -/** - * @brief Clears the whole currently active layer of LTDC. - * @param Color: Color of the background - */ -void BSP_LCD_Clear(uint32_t Color) -{ - /* Clear the LCD */ - LL_FillBuffer(ActiveLayer, (uint32_t *)(hltdc_eval.LayerCfg[ActiveLayer].FBStartAdress), BSP_LCD_GetXSize(), BSP_LCD_GetYSize(), 0, Color); -} - -/** - * @brief Clears the selected line in currently active layer. - * @param Line: Line to be cleared - */ -void BSP_LCD_ClearStringLine(uint32_t Line) -{ - uint32_t color_backup = DrawProp[ActiveLayer].TextColor; - DrawProp[ActiveLayer].TextColor = DrawProp[ActiveLayer].BackColor; - - /* Draw rectangle with background color */ - BSP_LCD_FillRect(0, (Line * DrawProp[ActiveLayer].pFont->Height), BSP_LCD_GetXSize(), DrawProp[ActiveLayer].pFont->Height); - - DrawProp[ActiveLayer].TextColor = color_backup; - BSP_LCD_SetTextColor(DrawProp[ActiveLayer].TextColor); -} - -/** - * @brief Displays one character in currently active layer. - * @param Xpos: Start column address - * @param Ypos: Line where to display the character shape. - * @param Ascii: Character ascii code - * This parameter must be a number between Min_Data = 0x20 and Max_Data = 0x7E - */ -void BSP_LCD_DisplayChar(uint16_t Xpos, uint16_t Ypos, uint8_t Ascii) -{ - DrawChar(Xpos, Ypos, &DrawProp[ActiveLayer].pFont->table[(Ascii-' ') *\ - DrawProp[ActiveLayer].pFont->Height * ((DrawProp[ActiveLayer].pFont->Width + 7) / 8)]); -} - -/** - * @brief Displays characters in currently active layer. - * @param Xpos: X position (in pixel) - * @param Ypos: Y position (in pixel) - * @param Text: Pointer to string to display on LCD - * @param Mode: Display mode - * This parameter can be one of the following values: - * @arg CENTER_MODE - * @arg RIGHT_MODE - * @arg LEFT_MODE - */ -void BSP_LCD_DisplayStringAt(uint16_t Xpos, uint16_t Ypos, uint8_t *Text, Text_AlignModeTypdef Mode) -{ - uint16_t refcolumn = 1, i = 0; - uint32_t size = 0, xsize = 0; - uint8_t *ptr = Text; - - /* Get the text size */ - while (*ptr++) size ++ ; - - /* Characters number per line */ - xsize = (BSP_LCD_GetXSize()/DrawProp[ActiveLayer].pFont->Width); - - switch (Mode) - { - case CENTER_MODE: - { - refcolumn = Xpos + ((xsize - size)* DrawProp[ActiveLayer].pFont->Width) / 2; - break; - } - case LEFT_MODE: - { - refcolumn = Xpos; - break; - } - case RIGHT_MODE: - { - refcolumn = - Xpos + ((xsize - size)*DrawProp[ActiveLayer].pFont->Width); - break; - } - default: - { - refcolumn = Xpos; - break; - } - } - - /* Check that the Start column is located in the screen */ - if ((refcolumn < 1) || (refcolumn >= 0x8000)) - { - refcolumn = 1; - } - - /* Send the string character by character on LCD */ - while ((*Text != 0) & (((BSP_LCD_GetXSize() - (i*DrawProp[ActiveLayer].pFont->Width)) & 0xFFFF) >= DrawProp[ActiveLayer].pFont->Width)) - { - /* Display one character on LCD */ - BSP_LCD_DisplayChar(refcolumn, Ypos, *Text); - /* Decrement the column position by 16 */ - refcolumn += DrawProp[ActiveLayer].pFont->Width; - - /* Point on the next character */ - Text++; - i++; - } - -} - -/** - * @brief Displays a maximum of 60 characters on the LCD. - * @param Line: Line where to display the character shape - * @param ptr: Pointer to string to display on LCD - */ -void BSP_LCD_DisplayStringAtLine(uint16_t Line, uint8_t *ptr) -{ - BSP_LCD_DisplayStringAt(0, LINE(Line), ptr, LEFT_MODE); -} - -/** - * @brief Draws an horizontal line in currently active layer. - * @param Xpos: X position - * @param Ypos: Y position - * @param Length: Line length - */ -void BSP_LCD_DrawHLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length) -{ - uint32_t Xaddress = 0; - - /* Get the line address */ - Xaddress = (hltdc_eval.LayerCfg[ActiveLayer].FBStartAdress) + 4*(BSP_LCD_GetXSize()*Ypos + Xpos); - - /* Write line */ - LL_FillBuffer(ActiveLayer, (uint32_t *)Xaddress, Length, 1, 0, DrawProp[ActiveLayer].TextColor); -} - -/** - * @brief Draws a vertical line in currently active layer. - * @param Xpos: X position - * @param Ypos: Y position - * @param Length: Line length - */ -void BSP_LCD_DrawVLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length) -{ - uint32_t Xaddress = 0; - - /* Get the line address */ - Xaddress = (hltdc_eval.LayerCfg[ActiveLayer].FBStartAdress) + 4*(BSP_LCD_GetXSize()*Ypos + Xpos); - - /* Write line */ - LL_FillBuffer(ActiveLayer, (uint32_t *)Xaddress, 1, Length, (BSP_LCD_GetXSize() - 1), DrawProp[ActiveLayer].TextColor); -} - -/** - * @brief Draws an uni-line (between two points) in currently active layer. - * @param x1: Point 1 X position - * @param y1: Point 1 Y position - * @param x2: Point 2 X position - * @param y2: Point 2 Y position - */ -void BSP_LCD_DrawLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) -{ - int16_t deltax = 0, deltay = 0, x = 0, y = 0, xinc1 = 0, xinc2 = 0, - yinc1 = 0, yinc2 = 0, den = 0, num = 0, numadd = 0, numpixels = 0, - curpixel = 0; - - deltax = ABS(x2 - x1); /* The difference between the x's */ - deltay = ABS(y2 - y1); /* The difference between the y's */ - x = x1; /* Start x off at the first pixel */ - y = y1; /* Start y off at the first pixel */ - - if (x2 >= x1) /* The x-values are increasing */ - { - xinc1 = 1; - xinc2 = 1; - } - else /* The x-values are decreasing */ - { - xinc1 = -1; - xinc2 = -1; - } - - if (y2 >= y1) /* The y-values are increasing */ - { - yinc1 = 1; - yinc2 = 1; - } - else /* The y-values are decreasing */ - { - yinc1 = -1; - yinc2 = -1; - } - - if (deltax >= deltay) /* There is at least one x-value for every y-value */ - { - xinc1 = 0; /* Don't change the x when numerator >= denominator */ - yinc2 = 0; /* Don't change the y for every iteration */ - den = deltax; - num = deltax / 2; - numadd = deltay; - numpixels = deltax; /* There are more x-values than y-values */ - } - else /* There is at least one y-value for every x-value */ - { - xinc2 = 0; /* Don't change the x for every iteration */ - yinc1 = 0; /* Don't change the y when numerator >= denominator */ - den = deltay; - num = deltay / 2; - numadd = deltax; - numpixels = deltay; /* There are more y-values than x-values */ - } - - for (curpixel = 0; curpixel <= numpixels; curpixel++) - { - BSP_LCD_DrawPixel(x, y, DrawProp[ActiveLayer].TextColor); /* Draw the current pixel */ - num += numadd; /* Increase the numerator by the top of the fraction */ - if (num >= den) /* Check if numerator >= denominator */ - { - num -= den; /* Calculate the new numerator value */ - x += xinc1; /* Change the x as appropriate */ - y += yinc1; /* Change the y as appropriate */ - } - x += xinc2; /* Change the x as appropriate */ - y += yinc2; /* Change the y as appropriate */ - } -} - -/** - * @brief Draws a rectangle in currently active layer. - * @param Xpos: X position - * @param Ypos: Y position - * @param Width: Rectangle width - * @param Height: Rectangle height - */ -void BSP_LCD_DrawRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height) -{ - /* Draw horizontal lines */ - BSP_LCD_DrawHLine(Xpos, Ypos, Width); - BSP_LCD_DrawHLine(Xpos, (Ypos+ Height), Width); - - /* Draw vertical lines */ - BSP_LCD_DrawVLine(Xpos, Ypos, Height); - BSP_LCD_DrawVLine((Xpos + Width), Ypos, Height); -} - -/** - * @brief Draws a circle in currently active layer. - * @param Xpos: X position - * @param Ypos: Y position - * @param Radius: Circle radius - */ -void BSP_LCD_DrawCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius) -{ - int32_t D; /* Decision Variable */ - uint32_t CurX; /* Current X Value */ - uint32_t CurY; /* Current Y Value */ - - D = 3 - (Radius << 1); - CurX = 0; - CurY = Radius; - - while (CurX <= CurY) - { - BSP_LCD_DrawPixel((Xpos + CurX), (Ypos - CurY), DrawProp[ActiveLayer].TextColor); - - BSP_LCD_DrawPixel((Xpos - CurX), (Ypos - CurY), DrawProp[ActiveLayer].TextColor); - - BSP_LCD_DrawPixel((Xpos + CurY), (Ypos - CurX), DrawProp[ActiveLayer].TextColor); - - BSP_LCD_DrawPixel((Xpos - CurY), (Ypos - CurX), DrawProp[ActiveLayer].TextColor); - - BSP_LCD_DrawPixel((Xpos + CurX), (Ypos + CurY), DrawProp[ActiveLayer].TextColor); - - BSP_LCD_DrawPixel((Xpos - CurX), (Ypos + CurY), DrawProp[ActiveLayer].TextColor); - - BSP_LCD_DrawPixel((Xpos + CurY), (Ypos + CurX), DrawProp[ActiveLayer].TextColor); - - BSP_LCD_DrawPixel((Xpos - CurY), (Ypos + CurX), DrawProp[ActiveLayer].TextColor); - - if (D < 0) - { - D += (CurX << 2) + 6; - } - else - { - D += ((CurX - CurY) << 2) + 10; - CurY--; - } - CurX++; - } -} - -/** - * @brief Draws an poly-line (between many points) in currently active layer. - * @param Points: Pointer to the points array - * @param PointCount: Number of points - */ -void BSP_LCD_DrawPolygon(pPoint Points, uint16_t PointCount) -{ - int16_t X = 0, Y = 0; - - if(PointCount < 2) - { - return; - } - - BSP_LCD_DrawLine(Points->X, Points->Y, (Points+PointCount-1)->X, (Points+PointCount-1)->Y); - - while(--PointCount) - { - X = Points->X; - Y = Points->Y; - Points++; - BSP_LCD_DrawLine(X, Y, Points->X, Points->Y); - } -} - -/** - * @brief Draws an ellipse on LCD in currently active layer. - * @param Xpos: X position - * @param Ypos: Y position - * @param XRadius: Ellipse X radius - * @param YRadius: Ellipse Y radius - */ -void BSP_LCD_DrawEllipse(int Xpos, int Ypos, int XRadius, int YRadius) -{ - int x = 0, y = -YRadius, err = 2-2*XRadius, e2; - float K = 0, rad1 = 0, rad2 = 0; - - rad1 = XRadius; - rad2 = YRadius; - - K = (float)(rad2/rad1); - - do { - BSP_LCD_DrawPixel((Xpos-(uint16_t)(x/K)), (Ypos+y), DrawProp[ActiveLayer].TextColor); - BSP_LCD_DrawPixel((Xpos+(uint16_t)(x/K)), (Ypos+y), DrawProp[ActiveLayer].TextColor); - BSP_LCD_DrawPixel((Xpos+(uint16_t)(x/K)), (Ypos-y), DrawProp[ActiveLayer].TextColor); - BSP_LCD_DrawPixel((Xpos-(uint16_t)(x/K)), (Ypos-y), DrawProp[ActiveLayer].TextColor); - - e2 = err; - if (e2 <= x) { - err += ++x*2+1; - if (-y == x && e2 <= y) e2 = 0; - } - if (e2 > y) err += ++y*2+1; - } - while (y <= 0); -} - -/** - * @brief Draws a bitmap picture loaded in the internal Flash (32 bpp) in currently active layer. - * @param Xpos: Bmp X position in the LCD - * @param Ypos: Bmp Y position in the LCD - * @param pbmp: Pointer to Bmp picture address in the internal Flash - */ -void BSP_LCD_DrawBitmap(uint32_t Xpos, uint32_t Ypos, uint8_t *pbmp) -{ - uint32_t index = 0, width = 0, height = 0, bit_pixel = 0; - uint32_t Address; - uint32_t InputColorMode = 0; - - /* Get bitmap data address offset */ - index = *(__IO uint16_t *) (pbmp + 10); - index |= (*(__IO uint16_t *) (pbmp + 12)) << 16; - - /* Read bitmap width */ - width = *(uint16_t *) (pbmp + 18); - width |= (*(uint16_t *) (pbmp + 20)) << 16; - - /* Read bitmap height */ - height = *(uint16_t *) (pbmp + 22); - height |= (*(uint16_t *) (pbmp + 24)) << 16; - - /* Read bit/pixel */ - bit_pixel = *(uint16_t *) (pbmp + 28); - - /* Set the address */ - Address = hltdc_eval.LayerCfg[ActiveLayer].FBStartAdress + (((BSP_LCD_GetXSize()*Ypos) + Xpos)*(4)); - - /* Get the layer pixel format */ - if ((bit_pixel/8) == 4) - { - InputColorMode = CM_ARGB8888; - } - else if ((bit_pixel/8) == 2) - { - InputColorMode = CM_RGB565; - } - else - { - InputColorMode = CM_RGB888; - } - - /* Bypass the bitmap header */ - pbmp += (index + (width * (height - 1) * (bit_pixel/8))); - - /* Convert picture to ARGB8888 pixel format */ - for(index=0; index < height; index++) - { - /* Pixel format conversion */ - LL_ConvertLineToARGB8888((uint32_t *)pbmp, (uint32_t *)Address, width, InputColorMode); - - /* Increment the source and destination buffers */ - Address+= (BSP_LCD_GetXSize()*4); - pbmp -= width*(bit_pixel/8); - } -} - -/** - * @brief Draws a full rectangle in currently active layer. - * @param Xpos: X position - * @param Ypos: Y position - * @param Width: Rectangle width - * @param Height: Rectangle height - */ -void BSP_LCD_FillRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height) -{ - uint32_t Xaddress = 0; - - /* Set the text color */ - BSP_LCD_SetTextColor(DrawProp[ActiveLayer].TextColor); - - /* Get the rectangle start address */ - Xaddress = (hltdc_eval.LayerCfg[ActiveLayer].FBStartAdress) + 4*(BSP_LCD_GetXSize()*Ypos + Xpos); - - /* Fill the rectangle */ - LL_FillBuffer(ActiveLayer, (uint32_t *)Xaddress, Width, Height, (BSP_LCD_GetXSize() - Width), DrawProp[ActiveLayer].TextColor); -} - -/** - * @brief Draws a full circle in currently active layer. - * @param Xpos: X position - * @param Ypos: Y position - * @param Radius: Circle radius - */ -void BSP_LCD_FillCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius) -{ - int32_t D; /* Decision Variable */ - uint32_t CurX; /* Current X Value */ - uint32_t CurY; /* Current Y Value */ - - D = 3 - (Radius << 1); - - CurX = 0; - CurY = Radius; - - BSP_LCD_SetTextColor(DrawProp[ActiveLayer].TextColor); - - while (CurX <= CurY) - { - if(CurY > 0) - { - BSP_LCD_DrawHLine(Xpos - CurY, Ypos + CurX, 2*CurY); - BSP_LCD_DrawHLine(Xpos - CurY, Ypos - CurX, 2*CurY); - } - - if(CurX > 0) - { - BSP_LCD_DrawHLine(Xpos - CurX, Ypos - CurY, 2*CurX); - BSP_LCD_DrawHLine(Xpos - CurX, Ypos + CurY, 2*CurX); - } - if (D < 0) - { - D += (CurX << 2) + 6; - } - else - { - D += ((CurX - CurY) << 2) + 10; - CurY--; - } - CurX++; - } - - BSP_LCD_SetTextColor(DrawProp[ActiveLayer].TextColor); - BSP_LCD_DrawCircle(Xpos, Ypos, Radius); -} - -/** - * @brief Draws a full poly-line (between many points) in currently active layer. - * @param Points: Pointer to the points array - * @param PointCount: Number of points - */ -void BSP_LCD_FillPolygon(pPoint Points, uint16_t PointCount) -{ - int16_t X = 0, Y = 0, X2 = 0, Y2 = 0, X_center = 0, Y_center = 0, X_first = 0, Y_first = 0, pixelX = 0, pixelY = 0, counter = 0; - uint16_t IMAGE_LEFT = 0, IMAGE_RIGHT = 0, IMAGE_TOP = 0, IMAGE_BOTTOM = 0; - - IMAGE_LEFT = IMAGE_RIGHT = Points->X; - IMAGE_TOP= IMAGE_BOTTOM = Points->Y; - - for(counter = 1; counter < PointCount; counter++) - { - pixelX = POLY_X(counter); - if(pixelX < IMAGE_LEFT) - { - IMAGE_LEFT = pixelX; - } - if(pixelX > IMAGE_RIGHT) - { - IMAGE_RIGHT = pixelX; - } - - pixelY = POLY_Y(counter); - if(pixelY < IMAGE_TOP) - { - IMAGE_TOP = pixelY; - } - if(pixelY > IMAGE_BOTTOM) - { - IMAGE_BOTTOM = pixelY; - } - } - - if(PointCount < 2) - { - return; - } - - X_center = (IMAGE_LEFT + IMAGE_RIGHT)/2; - Y_center = (IMAGE_BOTTOM + IMAGE_TOP)/2; - - X_first = Points->X; - Y_first = Points->Y; - - while(--PointCount) - { - X = Points->X; - Y = Points->Y; - Points++; - X2 = Points->X; - Y2 = Points->Y; - - FillTriangle(X, X2, X_center, Y, Y2, Y_center); - FillTriangle(X, X_center, X2, Y, Y_center, Y2); - FillTriangle(X_center, X2, X, Y_center, Y2, Y); - } - - FillTriangle(X_first, X2, X_center, Y_first, Y2, Y_center); - FillTriangle(X_first, X_center, X2, Y_first, Y_center, Y2); - FillTriangle(X_center, X2, X_first, Y_center, Y2, Y_first); -} - -/** - * @brief Draws a full ellipse in currently active layer. - * @param Xpos: X position - * @param Ypos: Y position - * @param XRadius: Ellipse X radius - * @param YRadius: Ellipse Y radius - */ -void BSP_LCD_FillEllipse(int Xpos, int Ypos, int XRadius, int YRadius) -{ - int x = 0, y = -YRadius, err = 2-2*XRadius, e2; - float K = 0, rad1 = 0, rad2 = 0; - - rad1 = XRadius; - rad2 = YRadius; - - K = (float)(rad2/rad1); - - do - { - BSP_LCD_DrawHLine((Xpos-(uint16_t)(x/K)), (Ypos+y), (2*(uint16_t)(x/K) + 1)); - BSP_LCD_DrawHLine((Xpos-(uint16_t)(x/K)), (Ypos-y), (2*(uint16_t)(x/K) + 1)); - - e2 = err; - if (e2 <= x) - { - err += ++x*2+1; - if (-y == x && e2 <= y) e2 = 0; - } - if (e2 > y) err += ++y*2+1; - } - while (y <= 0); -} - -/** - * @brief Switch back on the display if was switched off by previous call of BSP_LCD_DisplayOff(). - * Exit DSI ULPM mode if was allowed and configured in Dsi Configuration. - */ -void BSP_LCD_DisplayOn(void) -{ - /* Send Display on DCS command to display */ - HAL_DSI_ShortWrite(&(hdsi_eval), - hdsivideo_handle.VirtualChannelID, - DSI_DCS_SHORT_PKT_WRITE_P1, - OTM8009A_CMD_DISPON, - 0x00); - -} - -/** - * @brief Switch Off the display. - * Enter DSI ULPM mode if was allowed and configured in Dsi Configuration. - */ -void BSP_LCD_DisplayOff(void) -{ - /* Send Display off DCS Command to display */ - HAL_DSI_ShortWrite(&(hdsi_eval), - hdsivideo_handle.VirtualChannelID, - DSI_DCS_SHORT_PKT_WRITE_P1, - OTM8009A_CMD_DISPOFF, - 0x00); - -} - -/** - * @brief DCS or Generic short/long write command - * @param NbParams: Number of parameters. It indicates the write command mode: - * If inferior to 2, a long write command is performed else short. - * @param pParams: Pointer to parameter values table. - * @retval HAL status - */ -void DSI_IO_WriteCmd(uint32_t NbrParams, uint8_t *pParams) -{ - if(NbrParams <= 1) - { - HAL_DSI_ShortWrite(&hdsi_eval, LCD_OTM8009A_ID, DSI_DCS_SHORT_PKT_WRITE_P1, pParams[0], pParams[1]); - } - else - { - HAL_DSI_LongWrite(&hdsi_eval, LCD_OTM8009A_ID, DSI_DCS_LONG_PKT_WRITE, NbrParams, pParams[NbrParams], pParams); - } -} - -/******************************************************************************* - LTDC, DMA2D and DSI BSP Routines -*******************************************************************************/ -/** - * @brief Handles DMA2D interrupt request. - * @note : Can be surcharged by application code implementation of the function. - */ -__weak void BSP_LCD_DMA2D_IRQHandler(void) -{ - HAL_DMA2D_IRQHandler(&hdma2d_eval); -} - -/** - * @brief Handles DSI interrupt request. - * @note : Can be surcharged by application code implementation of the function. - */ -__weak void BSP_LCD_DSI_IRQHandler(void) -{ - HAL_DSI_IRQHandler(&(hdsi_eval)); -} - - -/** - * @brief Handles LTDC interrupt request. - * @note : Can be surcharged by application code implementation of the function. - */ -__weak void BSP_LCD_LTDC_IRQHandler(void) -{ - HAL_LTDC_IRQHandler(&(hltdc_eval)); -} - -/** - * @brief De-Initializes the BSP LCD Msp - * Application can surcharge if needed this function implementation. - */ -__weak void BSP_LCD_MspDeInit(void) -{ - /** @brief Disable IRQ of LTDC IP */ - HAL_NVIC_DisableIRQ(LTDC_IRQn); - - /** @brief Disable IRQ of DMA2D IP */ - HAL_NVIC_DisableIRQ(DMA2D_IRQn); - - /** @brief Disable IRQ of DSI IP */ - HAL_NVIC_DisableIRQ(DSI_IRQn); - - /** @brief Force and let in reset state LTDC, DMA2D and DSI Host + Wrapper IPs */ - __HAL_RCC_LTDC_FORCE_RESET(); - __HAL_RCC_DMA2D_FORCE_RESET(); - __HAL_RCC_DSI_FORCE_RESET(); - - /** @brief Disable the LTDC, DMA2D and DSI Host and Wrapper clocks */ - __HAL_RCC_LTDC_CLK_DISABLE(); - __HAL_RCC_DMA2D_CLK_DISABLE(); - __HAL_RCC_DSI_CLK_DISABLE(); -} - -/** - * @brief Initialize the BSP LCD Msp. - * Application can surcharge if needed this function implementation - */ -__weak void BSP_LCD_MspInit(void) -{ - /** @brief Enable the LTDC clock */ - __HAL_RCC_LTDC_CLK_ENABLE(); - - /** @brief Toggle Sw reset of LTDC IP */ - __HAL_RCC_LTDC_FORCE_RESET(); - __HAL_RCC_LTDC_RELEASE_RESET(); - - /** @brief Enable the DMA2D clock */ - __HAL_RCC_DMA2D_CLK_ENABLE(); - - /** @brief Toggle Sw reset of DMA2D IP */ - __HAL_RCC_DMA2D_FORCE_RESET(); - __HAL_RCC_DMA2D_RELEASE_RESET(); - - /** @brief Enable DSI Host and wrapper clocks */ - __HAL_RCC_DSI_CLK_ENABLE(); - - /** @brief Soft Reset the DSI Host and wrapper */ - __HAL_RCC_DSI_FORCE_RESET(); - __HAL_RCC_DSI_RELEASE_RESET(); - - /** @brief NVIC configuration for LTDC interrupt that is now enabled */ - HAL_NVIC_SetPriority(LTDC_IRQn, 3, 0); - HAL_NVIC_EnableIRQ(LTDC_IRQn); - - /** @brief NVIC configuration for DMA2D interrupt that is now enabled */ - HAL_NVIC_SetPriority(DMA2D_IRQn, 3, 0); - HAL_NVIC_EnableIRQ(DMA2D_IRQn); - - /** @brief NVIC configuration for DSI interrupt that is now enabled */ - HAL_NVIC_SetPriority(DSI_IRQn, 3, 0); - HAL_NVIC_EnableIRQ(DSI_IRQn); -} - -/** - * @brief This function handles LTDC Error interrupt Handler. - * @note : Can be surcharged by application code implementation of the function. - */ - -__weak void BSP_LCD_LTDC_ER_IRQHandler(void) -{ - HAL_LTDC_IRQHandler(&(hltdc_eval)); -} - -/** - * @brief Draws a pixel on LCD. - * @param Xpos: X position - * @param Ypos: Y position - * @param RGB_Code: Pixel color in ARGB mode (8-8-8-8) - */ -void BSP_LCD_DrawPixel(uint16_t Xpos, uint16_t Ypos, uint32_t RGB_Code) -{ - /* Write data value to all SDRAM memory */ - *(__IO uint32_t*) (hltdc_eval.LayerCfg[ActiveLayer].FBStartAdress + (4*(Ypos*BSP_LCD_GetXSize() + Xpos))) = RGB_Code; -} - - -/** - * @brief Draws a character on LCD. - * @param Xpos: Line where to display the character shape - * @param Ypos: Start column address - * @param c: Pointer to the character data - */ -static void DrawChar(uint16_t Xpos, uint16_t Ypos, const uint8_t *c) -{ - uint32_t i = 0, j = 0; - uint16_t height, width; - uint8_t offset; - uint8_t *pchar; - uint32_t line; - - height = DrawProp[ActiveLayer].pFont->Height; - width = DrawProp[ActiveLayer].pFont->Width; - - offset = 8 *((width + 7)/8) - width ; - - for(i = 0; i < height; i++) - { - pchar = ((uint8_t *)c + (width + 7)/8 * i); - - switch(((width + 7)/8)) - { - - case 1: - line = pchar[0]; - break; - - case 2: - line = (pchar[0]<< 8) | pchar[1]; - break; - - case 3: - default: - line = (pchar[0]<< 16) | (pchar[1]<< 8) | pchar[2]; - break; - } - - for (j = 0; j < width; j++) - { - if(line & (1 << (width- j + offset- 1))) - { - BSP_LCD_DrawPixel((Xpos + j), Ypos, DrawProp[ActiveLayer].TextColor); - } - else - { - BSP_LCD_DrawPixel((Xpos + j), Ypos, DrawProp[ActiveLayer].BackColor); - } - } - Ypos++; - } -} - -/** - * @brief Fills a triangle (between 3 points). - * @param x1: Point 1 X position - * @param y1: Point 1 Y position - * @param x2: Point 2 X position - * @param y2: Point 2 Y position - * @param x3: Point 3 X position - * @param y3: Point 3 Y position - */ -static void FillTriangle(uint16_t x1, uint16_t x2, uint16_t x3, uint16_t y1, uint16_t y2, uint16_t y3) -{ - int16_t deltax = 0, deltay = 0, x = 0, y = 0, xinc1 = 0, xinc2 = 0, - yinc1 = 0, yinc2 = 0, den = 0, num = 0, numadd = 0, numpixels = 0, - curpixel = 0; - - deltax = ABS(x2 - x1); /* The difference between the x's */ - deltay = ABS(y2 - y1); /* The difference between the y's */ - x = x1; /* Start x off at the first pixel */ - y = y1; /* Start y off at the first pixel */ - - if (x2 >= x1) /* The x-values are increasing */ - { - xinc1 = 1; - xinc2 = 1; - } - else /* The x-values are decreasing */ - { - xinc1 = -1; - xinc2 = -1; - } - - if (y2 >= y1) /* The y-values are increasing */ - { - yinc1 = 1; - yinc2 = 1; - } - else /* The y-values are decreasing */ - { - yinc1 = -1; - yinc2 = -1; - } - - if (deltax >= deltay) /* There is at least one x-value for every y-value */ - { - xinc1 = 0; /* Don't change the x when numerator >= denominator */ - yinc2 = 0; /* Don't change the y for every iteration */ - den = deltax; - num = deltax / 2; - numadd = deltay; - numpixels = deltax; /* There are more x-values than y-values */ - } - else /* There is at least one y-value for every x-value */ - { - xinc2 = 0; /* Don't change the x for every iteration */ - yinc1 = 0; /* Don't change the y when numerator >= denominator */ - den = deltay; - num = deltay / 2; - numadd = deltax; - numpixels = deltay; /* There are more y-values than x-values */ - } - - for (curpixel = 0; curpixel <= numpixels; curpixel++) - { - BSP_LCD_DrawLine(x, y, x3, y3); - - num += numadd; /* Increase the numerator by the top of the fraction */ - if (num >= den) /* Check if numerator >= denominator */ - { - num -= den; /* Calculate the new numerator value */ - x += xinc1; /* Change the x as appropriate */ - y += yinc1; /* Change the y as appropriate */ - } - x += xinc2; /* Change the x as appropriate */ - y += yinc2; /* Change the y as appropriate */ - } -} - -/** - * @brief Fills a buffer. - * @param LayerIndex: Layer index - * @param pDst: Pointer to destination buffer - * @param xSize: Buffer width - * @param ySize: Buffer height - * @param OffLine: Offset - * @param ColorIndex: Color index - */ -static void LL_FillBuffer(uint32_t LayerIndex, void *pDst, uint32_t xSize, uint32_t ySize, uint32_t OffLine, uint32_t ColorIndex) -{ - /* Register to memory mode with ARGB8888 as color Mode */ - hdma2d_eval.Init.Mode = DMA2D_R2M; - hdma2d_eval.Init.ColorMode = DMA2D_ARGB8888; - hdma2d_eval.Init.OutputOffset = OffLine; - - hdma2d_eval.Instance = DMA2D; - - /* DMA2D Initialization */ - if(HAL_DMA2D_Init(&hdma2d_eval) == HAL_OK) - { - if(HAL_DMA2D_ConfigLayer(&hdma2d_eval, LayerIndex) == HAL_OK) - { - if (HAL_DMA2D_Start(&hdma2d_eval, ColorIndex, (uint32_t)pDst, xSize, ySize) == HAL_OK) - { - /* Polling For DMA transfer */ - HAL_DMA2D_PollForTransfer(&hdma2d_eval, 10); - } - } - } -} - -/** - * @brief Converts a line to an ARGB8888 pixel format. - * @param pSrc: Pointer to source buffer - * @param pDst: Output color - * @param xSize: Buffer width - * @param ColorMode: Input color mode - */ -static void LL_ConvertLineToARGB8888(void *pSrc, void *pDst, uint32_t xSize, uint32_t ColorMode) -{ - /* Configure the DMA2D Mode, Color Mode and output offset */ - hdma2d_eval.Init.Mode = DMA2D_M2M_PFC; - hdma2d_eval.Init.ColorMode = DMA2D_ARGB8888; - hdma2d_eval.Init.OutputOffset = 0; - - /* Foreground Configuration */ - hdma2d_eval.LayerCfg[1].AlphaMode = DMA2D_NO_MODIF_ALPHA; - hdma2d_eval.LayerCfg[1].InputAlpha = 0xFF; - hdma2d_eval.LayerCfg[1].InputColorMode = ColorMode; - hdma2d_eval.LayerCfg[1].InputOffset = 0; - - hdma2d_eval.Instance = DMA2D; - - /* DMA2D Initialization */ - if(HAL_DMA2D_Init(&hdma2d_eval) == HAL_OK) - { - if(HAL_DMA2D_ConfigLayer(&hdma2d_eval, 1) == HAL_OK) - { - if (HAL_DMA2D_Start(&hdma2d_eval, (uint32_t)pSrc, (uint32_t)pDst, xSize, 1) == HAL_OK) - { - /* Polling For DMA transfer */ - HAL_DMA2D_PollForTransfer(&hdma2d_eval, 10); - } - } - } -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_lcd.h b/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_lcd.h deleted file mode 100644 index e2653d6405..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_lcd.h +++ /dev/null @@ -1,405 +0,0 @@ -/** - ****************************************************************************** - * @file stm32469i_eval_lcd.h - * @author MCD Application Team - * @version V1.0.1 - * @date 29-September-2015 - * @brief This file contains the common defines and functions prototypes for - * the stm32469i_eval_lcd.c driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32469I_EVAL_LCD_H -#define __STM32469I_EVAL_LCD_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -/* Include LCD component Driver */ - -/* Include OTM8009A LCD Driver IC driver code */ -#include "../Components/otm8009a/otm8009a.h" - -/* Include SDRAM Driver */ -#include "stm32469i_eval_sdram.h" -#include "stm32469i_eval.h" - -#include "../../../Utilities/Fonts/fonts.h" - -#include /* use of memset() */ - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32469I-EVAL - * @{ - */ - -/** @addtogroup STM32469I-EVAL_LCD STM32469I EVAL LCD - * @{ - */ - -/** @defgroup STM32469I-EVAL_LCD_Exported_Constants STM32469I EVAL LCD Exported Constants - * @{ - */ - -#define LCD_LayerCfgTypeDef LTDC_LayerCfgTypeDef -/** - * @brief LCD FB_StartAddress - */ -#define LCD_FB_START_ADDRESS ((uint32_t)0xC0000000) - -/** @brief Maximum number of LTDC layers - */ -#define LTDC_MAX_LAYER_NUMBER ((uint32_t) 2) - -/** @brief LTDC Background layer index - */ -#define LTDC_ACTIVE_LAYER_BACKGROUND ((uint32_t) 0) - -/** @brief LTDC Foreground layer index - */ -#define LTDC_ACTIVE_LAYER_FOREGROUND ((uint32_t) 1) - -/** @brief Number of LTDC layers - */ -#define LTDC_NB_OF_LAYERS ((uint32_t) 2) - -/** @brief LTDC Default used layer index - */ -#define LTDC_DEFAULT_ACTIVE_LAYER LTDC_ACTIVE_LAYER_FOREGROUND - -/** - * @brief LCD status structure definition - */ -#define LCD_OK 0x00 -#define LCD_ERROR 0x01 -#define LCD_TIMEOUT 0x02 - -/** - * @brief LCD Display OTM8009A ID - */ -#define LCD_OTM8009A_ID ((uint32_t) 0) - -/** - * @brief LCD color definitions values - * in ARGB8888 format. - */ - -/** @brief Blue value in ARGB8888 format - */ -#define LCD_COLOR_BLUE ((uint32_t) 0xFF0000FF) - -/** @brief Green value in ARGB8888 format - */ -#define LCD_COLOR_GREEN ((uint32_t) 0xFF00FF00) - -/** @brief Red value in ARGB8888 format - */ -#define LCD_COLOR_RED ((uint32_t) 0xFFFF0000) - -/** @brief Cyan value in ARGB8888 format - */ -#define LCD_COLOR_CYAN ((uint32_t) 0xFF00FFFF) - -/** @brief Magenta value in ARGB8888 format - */ -#define LCD_COLOR_MAGENTA ((uint32_t) 0xFFFF00FF) - -/** @brief Yellow value in ARGB8888 format - */ -#define LCD_COLOR_YELLOW ((uint32_t) 0xFFFFFF00) - -/** @brief Light Blue value in ARGB8888 format - */ -#define LCD_COLOR_LIGHTBLUE ((uint32_t) 0xFF8080FF) - -/** @brief Light Green value in ARGB8888 format - */ -#define LCD_COLOR_LIGHTGREEN ((uint32_t) 0xFF80FF80) - -/** @brief Light Red value in ARGB8888 format - */ -#define LCD_COLOR_LIGHTRED ((uint32_t) 0xFFFF8080) - -/** @brief Light Cyan value in ARGB8888 format - */ -#define LCD_COLOR_LIGHTCYAN ((uint32_t) 0xFF80FFFF) - -/** @brief Light Magenta value in ARGB8888 format - */ -#define LCD_COLOR_LIGHTMAGENTA ((uint32_t) 0xFFFF80FF) - -/** @brief Light Yellow value in ARGB8888 format - */ -#define LCD_COLOR_LIGHTYELLOW ((uint32_t) 0xFFFFFF80) - -/** @brief Dark Blue value in ARGB8888 format - */ -#define LCD_COLOR_DARKBLUE ((uint32_t) 0xFF000080) - -/** @brief Light Dark Green value in ARGB8888 format - */ -#define LCD_COLOR_DARKGREEN ((uint32_t) 0xFF008000) - -/** @brief Light Dark Red value in ARGB8888 format - */ -#define LCD_COLOR_DARKRED ((uint32_t) 0xFF800000) - -/** @brief Dark Cyan value in ARGB8888 format - */ -#define LCD_COLOR_DARKCYAN ((uint32_t) 0xFF008080) - -/** @brief Dark Magenta value in ARGB8888 format - */ -#define LCD_COLOR_DARKMAGENTA ((uint32_t) 0xFF800080) - -/** @brief Dark Yellow value in ARGB8888 format - */ -#define LCD_COLOR_DARKYELLOW ((uint32_t) 0xFF808000) - -/** @brief White value in ARGB8888 format - */ -#define LCD_COLOR_WHITE ((uint32_t) 0xFFFFFFFF) - -/** @brief Light Gray value in ARGB8888 format - */ -#define LCD_COLOR_LIGHTGRAY ((uint32_t) 0xFFD3D3D3) - -/** @brief Gray value in ARGB8888 format - */ -#define LCD_COLOR_GRAY ((uint32_t) 0xFF808080) - -/** @brief Dark Gray value in ARGB8888 format - */ -#define LCD_COLOR_DARKGRAY ((uint32_t) 0xFF404040) - -/** @brief Black value in ARGB8888 format - */ -#define LCD_COLOR_BLACK ((uint32_t) 0xFF000000) - -/** @brief Brown value in ARGB8888 format - */ -#define LCD_COLOR_BROWN ((uint32_t) 0xFFA52A2A) - -/** @brief Orange value in ARGB8888 format - */ -#define LCD_COLOR_ORANGE ((uint32_t) 0xFFFFA500) - -/** @brief Transparent value in ARGB8888 format - */ -#define LCD_COLOR_TRANSPARENT ((uint32_t) 0xFF000000) - -/** - * @brief LCD default font - */ -#define LCD_DEFAULT_FONT Font24 -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_LCD_Exported_Types STM32469I EVAL LCD Exported Types - * @{ - */ - -/** -* @brief LCD Drawing main properties -*/ -typedef struct -{ - uint32_t TextColor; /*!< Specifies the color of text */ - uint32_t BackColor; /*!< Specifies the background color below the text */ - sFONT *pFont; /*!< Specifies the font used for the text */ - -} LCD_DrawPropTypeDef; - -/** - * @brief LCD Drawing point (pixel) geometric definition - */ -typedef struct -{ - int16_t X; /*!< geometric X position of drawing */ - int16_t Y; /*!< geometric Y position of drawing */ - -} Point; - -/** - * @brief Pointer on LCD Drawing point (pixel) geometric definition - */ -typedef Point * pPoint; - -/** - * @brief LCD drawing Line alignment mode definitions - */ -typedef enum -{ - CENTER_MODE = 0x01, /*!< Center mode */ - RIGHT_MODE = 0x02, /*!< Right mode */ - LEFT_MODE = 0x03 /*!< Left mode */ - -} Text_AlignModeTypdef; - - -/** - * @brief LCD_OrientationTypeDef - * Possible values of Display Orientation - */ -typedef enum -{ - LCD_ORIENTATION_PORTRAIT = 0x00, /*!< Portrait orientation choice of LCD screen */ - LCD_ORIENTATION_LANDSCAPE = 0x01, /*!< Landscape orientation choice of LCD screen */ - LCD_ORIENTATION_INVALID = 0x02 /*!< Invalid orientation choice of LCD screen */ -} LCD_OrientationTypeDef; - -/** - * @brief Possible values of - * pixel data format (ie color coding) transmitted on DSI Data lane in DSI packets - */ -typedef enum -{ - LCD_DSI_PIXEL_DATA_FMT_RBG888 = 0x00, /*!< DSI packet pixel format chosen is RGB888 : 24 bpp */ - LCD_DSI_PIXEL_DATA_FMT_RBG565 = 0x02, /*!< DSI packet pixel format chosen is RGB565 : 16 bpp */ - LCD_DSI_PIXEL_DATA_FMT_INVALID = 0x03 /*!< Invalid DSI packet pixel format */ - -} LCD_DsiPixelDataFmtTypeDef; - -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_LCD_Exported_Macro STM32469I EVAL LCD Exported Macro - * @{ - */ - -/** @defgroup STM32469I-EVAL_LCD_Exported_Functions STM32469I EVAL LCD Exported Functions - * @{ - */ - -void BSP_LCD_DMA2D_IRQHandler(void); -void BSP_LCD_DSI_IRQHandler(void); -void BSP_LCD_LTDC_IRQHandler(void); -void BSP_LCD_LTDC_ER_IRQHandler(void); - -uint8_t BSP_LCD_Init(void); -uint8_t BSP_LCD_InitEx(LCD_OrientationTypeDef orientation); - -void BSP_LCD_MspDeInit(void); -void BSP_LCD_MspInit(void); -void BSP_LCD_Reset(void); - -uint32_t BSP_LCD_GetXSize(void); -uint32_t BSP_LCD_GetYSize(void); -void BSP_LCD_SetXSize(uint32_t imageWidthPixels); -void BSP_LCD_SetYSize(uint32_t imageHeightPixels); - -void BSP_LCD_LayerDefaultInit(uint16_t LayerIndex, uint32_t FB_Address); -void BSP_LCD_SetTransparency(uint32_t LayerIndex, uint8_t Transparency); -void BSP_LCD_SetLayerAddress(uint32_t LayerIndex, uint32_t Address); -void BSP_LCD_SetColorKeying(uint32_t LayerIndex, uint32_t RGBValue); -void BSP_LCD_ResetColorKeying(uint32_t LayerIndex); -void BSP_LCD_SetLayerWindow(uint16_t LayerIndex, uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height); - -void BSP_LCD_SelectLayer(uint32_t LayerIndex); -void BSP_LCD_SetLayerVisible(uint32_t LayerIndex, FunctionalState State); - -void BSP_LCD_SetTextColor(uint32_t Color); -uint32_t BSP_LCD_GetTextColor(void); -void BSP_LCD_SetBackColor(uint32_t Color); -uint32_t BSP_LCD_GetBackColor(void); -void BSP_LCD_SetFont(sFONT *fonts); -sFONT *BSP_LCD_GetFont(void); - -uint32_t BSP_LCD_ReadPixel(uint16_t Xpos, uint16_t Ypos); -void BSP_LCD_DrawPixel(uint16_t Xpos, uint16_t Ypos, uint32_t pixel); -void BSP_LCD_Clear(uint32_t Color); -void BSP_LCD_ClearStringLine(uint32_t Line); -void BSP_LCD_DisplayStringAtLine(uint16_t Line, uint8_t *ptr); -void BSP_LCD_DisplayStringAt(uint16_t Xpos, uint16_t Ypos, uint8_t *Text, Text_AlignModeTypdef Mode); -void BSP_LCD_DisplayChar(uint16_t Xpos, uint16_t Ypos, uint8_t Ascii); - -void BSP_LCD_DrawHLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length); -void BSP_LCD_DrawVLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length); -void BSP_LCD_DrawLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2); -void BSP_LCD_DrawRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height); -void BSP_LCD_DrawCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius); -void BSP_LCD_DrawPolygon(pPoint Points, uint16_t PointCount); -void BSP_LCD_DrawEllipse(int Xpos, int Ypos, int XRadius, int YRadius); -void BSP_LCD_DrawBitmap(uint32_t Xpos, uint32_t Ypos, uint8_t *pbmp); - -void BSP_LCD_FillRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height); -void BSP_LCD_FillCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius); -void BSP_LCD_FillPolygon(pPoint Points, uint16_t PointCount); -void BSP_LCD_FillEllipse(int Xpos, int Ypos, int XRadius, int YRadius); - -void BSP_LCD_DisplayOff(void); -void BSP_LCD_DisplayOn(void); - -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_LCD_Exported_Variables STM32469I EVAL LCD Exported Variables - * @{ - */ - -/* @brief DMA2D handle variable */ -extern DMA2D_HandleTypeDef hdma2d_eval; - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32469I_EVAL_LCD_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_nor.c b/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_nor.c deleted file mode 100644 index b837084977..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_nor.c +++ /dev/null @@ -1,443 +0,0 @@ -/** - ****************************************************************************** - * @file stm32469i_eval_nor.c - * @author MCD Application Team - * @version V1.0.1 - * @date 29-September-2015 - * @brief This file includes a standard driver for the M29W256GL70ZA6E NOR flash memory - * device mounted on STM32469I-EVAL evaluation board. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* File Info : ----------------------------------------------------------------- - User NOTES -1. How To use this driver: --------------------------- - - This driver is used to drive the M29W128GL NOR flash external memory mounted - on STM32469I-EVAL evaluation board. - - This driver does not need a specific component driver for the NOR device - to be included with. - -2. Driver description: ---------------------- - + Initialization steps: - o Initialize the NOR external memory using the BSP_NOR_Init() function. This - function includes the MSP layer hardware resources initialization and the - FMC controller configuration to interface with the external NOR memory. - - + NOR flash operations - o NOR external memory can be accessed with read/write operations once it is - initialized. - Read/write operation can be performed with AHB access using the functions - BSP_NOR_ReadData()/BSP_NOR_WriteData(). The BSP_NOR_WriteData() performs write operation - of an amount of data by unit (halfword). You can also perform a program data - operation of an amount of data using the function BSP_NOR_ProgramData(). - o The function BSP_NOR_Read_ID() returns the chip IDs stored in the structure - "NOR_IDTypeDef". (see the NOR IDs in the memory data sheet) - o Perform erase block operation using the function BSP_NOR_Erase_Block() and by - specifying the block address. You can perform an erase operation of the whole - chip by calling the function BSP_NOR_Erase_Chip(). - o After other operations, the function BSP_NOR_ReturnToReadMode() allows the NOR - flash to return to read mode to perform read operations on it. - -------------------------------------------------------------------------------*/ - -/* Includes ------------------------------------------------------------------*/ -#include "stm32469i_eval_nor.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32469I-EVAL - * @{ - */ - -/** @defgroup STM32469I-EVAL_NOR STM32469I-EVAL NOR - * @{ - */ - -/* Private typedef -----------------------------------------------------------*/ - -/** @defgroup STM32469I-EVAL_NOR_Private_Types_Definitions STM32469I-EVAL NOR Private Types Definitions - * @{ - */ - -/* Private define ------------------------------------------------------------*/ - -/** @defgroup STM32469I-EVAL_NOR_Private_Defines STM32469I-EVAL NOR Private Defines - * @{ - */ - -/* Private macro -------------------------------------------------------------*/ - -/** @defgroup STM32469I-EVAL_NOR_Private_Macros STM32469I-EVAL NOR Private Macros - * @{ - */ -/** - * @} - */ - -/* Private variables ---------------------------------------------------------*/ - -/** @defgroup STM32469I-EVAL_NOR_Private_Variables STM32469I-EVAL NOR Private Variables - * @{ - */ -NOR_HandleTypeDef NorHandle; -static FMC_NORSRAM_TimingTypeDef Timing; - -/** - * @} - */ - -/* Private function prototypes -----------------------------------------------*/ - -/** @defgroup STM32469I-EVAL_NOR_Private_Function_Prototypes STM32469I-EVAL NOR Private Function Prototypes - * @{ - */ - - - -/** - * @} - */ - -/** - * @brief Initializes the NOR device. - * @retval NOR memory status - */ -uint8_t BSP_NOR_Init(void) -{ - NorHandle.Instance = FMC_NORSRAM_DEVICE; - NorHandle.Extended = FMC_NORSRAM_EXTENDED_DEVICE; - - /* NOR device configuration */ - Timing.AddressSetupTime = 8; - Timing.AddressHoldTime = 3; - Timing.DataSetupTime = 9; - Timing.BusTurnAroundDuration = 0; - Timing.CLKDivision = 2; - Timing.DataLatency = 2; - Timing.AccessMode = FMC_ACCESS_MODE_A; - - NorHandle.Init.NSBank = FMC_NORSRAM_BANK1; - NorHandle.Init.DataAddressMux = FMC_DATA_ADDRESS_MUX_DISABLE; - NorHandle.Init.MemoryType = FMC_MEMORY_TYPE_NOR; - NorHandle.Init.MemoryDataWidth = NOR_MEMORY_WIDTH; - NorHandle.Init.BurstAccessMode = NOR_BURSTACCESS; - NorHandle.Init.WaitSignalPolarity = FMC_WAIT_SIGNAL_POLARITY_LOW; - NorHandle.Init.WrapMode = FMC_WRAP_MODE_DISABLE; - NorHandle.Init.WaitSignalActive = FMC_WAIT_TIMING_BEFORE_WS; - NorHandle.Init.WriteOperation = FMC_WRITE_OPERATION_ENABLE; - NorHandle.Init.WaitSignal = FMC_WAIT_SIGNAL_ENABLE; - NorHandle.Init.ExtendedMode = FMC_EXTENDED_MODE_DISABLE; - NorHandle.Init.AsynchronousWait = FMC_ASYNCHRONOUS_WAIT_ENABLE; - NorHandle.Init.WriteBurst = NOR_WRITEBURST; - NorHandle.Init.ContinuousClock = CONTINUOUSCLOCK_FEATURE; - - /* NOR controller initialization */ - BSP_NOR_MspInit(&NorHandle, NULL); - - if(HAL_NOR_Init(&NorHandle, &Timing, &Timing) != HAL_OK) - { - return NOR_STATUS_ERROR; - } - else - { - return NOR_STATUS_OK; - } -} - -/** - * @brief DeInitializes the NOR device. - * @retval NOR memory status - */ -uint8_t BSP_NOR_DeInit(void) -{ - /* NOR controller initialization */ - BSP_NOR_MspDeInit(&NorHandle, NULL); - - if(HAL_NOR_DeInit(&NorHandle) != HAL_OK) - { - return NOR_STATUS_ERROR; - } - else - { - return NOR_STATUS_OK; - } -} - -/** - * @brief Reads an amount of data from the NOR device. - * @param uwStartAddress: Read start address - * @param pData: Pointer to data to be read - * @param uwDataSize: Size of data to read - * @retval NOR memory status - */ -uint8_t BSP_NOR_ReadData(uint32_t uwStartAddress, uint16_t* pData, uint32_t uwDataSize) -{ - if(HAL_NOR_ReadBuffer(&NorHandle, NOR_DEVICE_ADDR + uwStartAddress, pData, uwDataSize) != HAL_OK) - { - return NOR_STATUS_ERROR; - } - else - { - return NOR_STATUS_OK; - } -} - -/** - * @brief Returns the NOR memory to read mode. - */ -void BSP_NOR_ReturnToReadMode(void) -{ - HAL_NOR_ReturnToReadMode(&NorHandle); -} - -/** - * @brief Writes an amount of data to the NOR device. - * @param uwStartAddress: Write start address - * @param pData: Pointer to data to be written - * @param uwDataSize: Size of data to write - * @retval NOR memory status - */ -uint8_t BSP_NOR_WriteData(uint32_t uwStartAddress, uint16_t* pData, uint32_t uwDataSize) -{ - uint32_t index = uwDataSize; - - while(index > 0) - { - /* Write data to NOR */ - HAL_NOR_Program(&NorHandle, (uint32_t *)(NOR_DEVICE_ADDR + uwStartAddress), pData); - - /* Read NOR device status */ - if(HAL_NOR_GetStatus(&NorHandle, NOR_DEVICE_ADDR, PROGRAM_TIMEOUT) != HAL_NOR_STATUS_SUCCESS) - { - return NOR_STATUS_ERROR; - } - - /* Update the counters */ - index--; - uwStartAddress += 2; - pData++; - } - - return NOR_STATUS_OK; -} - -/** - * @brief Programs an amount of data to the NOR device. - * @param uwStartAddress: Write start address - * @param pData: Pointer to data to be written - * @param uwDataSize: Size of data to write - * @retval NOR memory status - */ -uint8_t BSP_NOR_ProgramData(uint32_t uwStartAddress, uint16_t* pData, uint32_t uwDataSize) -{ - /* Send NOR program buffer operation */ - HAL_NOR_ProgramBuffer(&NorHandle, uwStartAddress, pData, uwDataSize); - - /* Return the NOR memory status */ - if(HAL_NOR_GetStatus(&NorHandle, NOR_DEVICE_ADDR, PROGRAM_TIMEOUT) != HAL_NOR_STATUS_SUCCESS) - { - return NOR_STATUS_ERROR; - } - else - { - return NOR_STATUS_OK; - } -} - -/** - * @brief Erases the specified block of the NOR device. - * @param BlockAddress: Block address to erase - * @retval NOR memory status - */ -uint8_t BSP_NOR_Erase_Block(uint32_t BlockAddress) -{ - /* Send NOR erase block operation */ - HAL_NOR_Erase_Block(&NorHandle, BlockAddress, NOR_DEVICE_ADDR); - - /* Return the NOR memory status */ - if(HAL_NOR_GetStatus(&NorHandle, NOR_DEVICE_ADDR, BLOCKERASE_TIMEOUT) != HAL_NOR_STATUS_SUCCESS) - { - return NOR_STATUS_ERROR; - } - else - { - return NOR_STATUS_OK; - } -} - -/** - * @brief Erases the entire NOR chip. - * @retval NOR memory status - */ -uint8_t BSP_NOR_Erase_Chip(void) -{ - /* Send NOR Erase chip operation */ - HAL_NOR_Erase_Chip(&NorHandle, NOR_DEVICE_ADDR); - - /* Return the NOR memory status */ - if(HAL_NOR_GetStatus(&NorHandle, NOR_DEVICE_ADDR, CHIPERASE_TIMEOUT) != HAL_NOR_STATUS_SUCCESS) - { - return NOR_STATUS_ERROR; - } - else - { - return NOR_STATUS_OK; - } -} - -/** - * @brief Reads NOR flash IDs. - * @param pNOR_ID : Pointer to NOR ID structure - * @retval NOR memory status - */ -uint8_t BSP_NOR_Read_ID(NOR_IDTypeDef *pNOR_ID) -{ - if(HAL_NOR_Read_ID(&NorHandle, pNOR_ID) != HAL_OK) - { - return NOR_STATUS_ERROR; - } - else - { - return NOR_STATUS_OK; - } -} - -/** - * @brief Initializes the NOR MSP. - * @param hnor: pointer to nor structure - * @param Params : pointer on additional configuration parameters, can be NULL. - */ -__weak void BSP_NOR_MspInit(NOR_HandleTypeDef *hnor, void *Params) -{ - GPIO_InitTypeDef gpio_init_structure; - - /* Enable FMC clock */ - __HAL_RCC_FMC_CLK_ENABLE(); - - /* Enable GPIOs clock */ - __HAL_RCC_GPIOD_CLK_ENABLE(); - __HAL_RCC_GPIOE_CLK_ENABLE(); - __HAL_RCC_GPIOF_CLK_ENABLE(); - __HAL_RCC_GPIOG_CLK_ENABLE(); - - /* Common GPIO configuration */ - gpio_init_structure.Mode = GPIO_MODE_AF_PP; - gpio_init_structure.Pull = GPIO_PULLUP; - gpio_init_structure.Speed = GPIO_SPEED_HIGH; - gpio_init_structure.Alternate = GPIO_AF12_FMC; - - /* GPIOD configuration */ - gpio_init_structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 |\ - GPIO_PIN_7 | GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 |\ - GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15; - HAL_GPIO_Init(GPIOD, &gpio_init_structure); - - /* GPIOE configuration */ - gpio_init_structure.Pin = GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 |\ - GPIO_PIN_7 | GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 |\ - GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15; - HAL_GPIO_Init(GPIOE, &gpio_init_structure); - - /* GPIOF configuration */ - gpio_init_structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2| GPIO_PIN_3 | GPIO_PIN_4 |\ - GPIO_PIN_5 | GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15; - HAL_GPIO_Init(GPIOF, &gpio_init_structure); - - /* GPIOG configuration */ - gpio_init_structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2| GPIO_PIN_3 | GPIO_PIN_4 |\ - GPIO_PIN_5; - HAL_GPIO_Init(GPIOG, &gpio_init_structure); -} - -/** - * @brief DeInitializes the NOR MSP. - * @param hnor pointer to NOR structure - * @param Params : pointer on additional configuration parameters, can be NULL. - * @retval status - */ -__weak uint8_t BSP_NOR_MspDeInit(NOR_HandleTypeDef *hnor, void *Params) -{ - /* FMC won't be disabled because common to other functionalities */ - - /* Disable only NOR specific GPIOs */ - HAL_GPIO_DeInit(GPIOD, (GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7)); - - return HAL_OK; - -} - -/** - * @brief NOR BSP Wait for Ready/Busy signal. - * @param hnor: Pointer to NOR handle - * @param Timeout: Timeout duration - */ -void HAL_NOR_MspWait(NOR_HandleTypeDef *hnor, uint32_t Timeout) -{ - uint32_t timeout = Timeout; - - /* Polling on Ready/Busy signal */ - while((HAL_GPIO_ReadPin(NOR_READY_BUSY_GPIO, NOR_READY_BUSY_PIN) != NOR_BUSY_STATE) && (timeout > 0)) - { - timeout--; - } - - timeout = Timeout; - - /* Polling on Ready/Busy signal */ - while((HAL_GPIO_ReadPin(NOR_READY_BUSY_GPIO, NOR_READY_BUSY_PIN) != NOR_READY_STATE) && (timeout > 0)) - { - timeout--; - } -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_nor.h b/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_nor.h deleted file mode 100644 index 68bfb59cb8..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_nor.h +++ /dev/null @@ -1,151 +0,0 @@ -/** - ****************************************************************************** - * @file stm32469i_eval_nor.h - * @author MCD Application Team - * @version V1.0.1 - * @date 29-September-2015 - * @brief This file contains the common defines and functions prototypes for - * the stm32469i_eval_nor.c driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32469I_EVAL_NOR_H -#define __STM32469I_EVAL_NOR_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm32f4xx_hal.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32469I-EVAL - * @{ - */ - -/** @defgroup STM32469I-EVAL_NOR STM32469I-EVAL NOR - * @{ - */ - -/** @defgroup STM32469I-EVAL_NOR_Exported_Types NOR Exported Types - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_NOR_Exported_Constants NOR Exported Constants - * @{ - */ -/** - * @brief NOR status structure definition - */ -#define NOR_STATUS_OK ((uint8_t) 0x00) -#define NOR_STATUS_ERROR ((uint8_t) 0x01) -#define NOR_DEVICE_ADDR ((uint32_t)0x60000000) - -/* #define NOR_MEMORY_WIDTH FMC_NORSRAM_MEM_BUS_WIDTH_8 */ -#define NOR_MEMORY_WIDTH FMC_NORSRAM_MEM_BUS_WIDTH_16 - -#define NOR_BURSTACCESS FMC_BURST_ACCESS_MODE_DISABLE -/* #define NOR_BURSTACCESS FMC_BURST_ACCESS_MODE_ENABLE*/ - -#define NOR_WRITEBURST FMC_WRITE_BURST_DISABLE -/* #define NOR_WRITEBURST FMC_WRITE_BURST_ENABLE */ - -#define CONTINUOUSCLOCK_FEATURE FMC_CONTINUOUS_CLOCK_SYNC_ONLY -/* #define CONTINUOUSCLOCK_FEATURE FMC_CONTINUOUS_CLOCK_SYNC_ASYNC */ - -/* NOR operations Timeout definitions */ -#define BLOCKERASE_TIMEOUT ((uint32_t)0x00A00000) /* NOR block erase timeout */ -#define CHIPERASE_TIMEOUT ((uint32_t)0x30000000) /* NOR chip erase timeout */ -#define PROGRAM_TIMEOUT ((uint32_t)0x00004400) /* NOR program timeout */ - -/* NOR Ready/Busy signal GPIO definitions */ -#define NOR_READY_BUSY_PIN GPIO_PIN_6 -#define NOR_READY_BUSY_GPIO GPIOD -#define NOR_READY_STATE GPIO_PIN_SET -#define NOR_BUSY_STATE GPIO_PIN_RESET -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_NOR_Exported_Macro NOR Exported Macro - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_NOR_Exported_Functions NOR Exported Functions - * @{ - */ -uint8_t BSP_NOR_Init(void); -uint8_t BSP_NOR_DeInit(void); -uint8_t BSP_NOR_ReadData(uint32_t uwStartAddress, uint16_t *pData, uint32_t uwDataSize); -uint8_t BSP_NOR_WriteData(uint32_t uwStartAddress, uint16_t *pData, uint32_t uwDataSize); -uint8_t BSP_NOR_ProgramData(uint32_t uwStartAddress, uint16_t *pData, uint32_t uwDataSize); -uint8_t BSP_NOR_Erase_Block(uint32_t BlockAddress); -uint8_t BSP_NOR_Erase_Chip(void); -uint8_t BSP_NOR_Read_ID(NOR_IDTypeDef *pNOR_ID); -void BSP_NOR_ReturnToReadMode(void); - -/* These functions can be modified in case the current settings (e.g. DMA stream) - need to be changed for specific application needs */ -void BSP_NOR_MspInit(NOR_HandleTypeDef *hnor, void *Params); -uint8_t BSP_NOR_MspDeInit(NOR_HandleTypeDef *hnor, void *Params); -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32469I_EVAL_NOR_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_qspi.c b/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_qspi.c deleted file mode 100644 index a53283258e..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_qspi.c +++ /dev/null @@ -1,1118 +0,0 @@ -/** - ****************************************************************************** - * @file stm32469i_eval_qspi.c - * @author MCD Application Team - * @version V1.0.1 - * @date 29-September-2015 - * @brief This file includes a standard driver for the N25Q256A QSPI - * memory mounted on STM32469I-EVAL board. - @verbatim - ============================================================================== - ##### How to use this driver ##### - ============================================================================== - [..] - (#) This driver is used to drive the S25FL512SAGMFI01 and N25Q512A QSPI external - memory mounted on STM32469I-EVAL evaluation board. - - (#) This driver need a specific component driver (FL512SAGMFI01 and N25Q512A) to be included with. - - (#) Initialization steps: - (++) Initialize the QPSI external memory using the BSP_QSPI_Init() function. This - function includes the MSP layer hardware resources initialization and the - QSPI interface with the external memory. - - (#) QSPI memory operations - (++) QSPI memory can be accessed with read/write operations once it is - initialized. - Read/write operation can be performed with AHB access using the functions - BSP_QSPI_Read()/BSP_QSPI_Write(). - (++) The function BSP_QSPI_GetInfo() returns the configuration of the QSPI memory. - (see the QSPI memory data sheet) - (++) Perform erase block operation using the function BSP_QSPI_Erase_Block() and by - specifying the block address. You can perform an erase operation of the whole - chip by calling the function BSP_QSPI_Erase_Chip(). - (++) The function BSP_QSPI_GetStatus() returns the current status of the QSPI memory. - (see the QSPI memory data sheet) - @endverbatim - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Includes ------------------------------------------------------------------*/ -#include "stm32469i_eval_qspi.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32469I_EVAL - * @{ - */ - -/** @defgroup STM32469I_EVAL_QSPI STM32469I_EVAL QSPI - * @{ - */ - - -/* Private variables ---------------------------------------------------------*/ -#define JEDEC_MANUF_ID_MICRON ((uint8_t) 0x20) -#define JEDEC_MANUF_ID_SPANSION ((uint8_t) 0x01) -/** @defgroup STM32469I_EVAL_QSPI_Private_Variables Private Variables - * @{ - */ -QSPI_HandleTypeDef QSPIHandle; -QSPI_InfoTypeDef QspiInfo; - -/** - * @} - */ - - - -/* Private functions ---------------------------------------------------------*/ - -/** @defgroup STM32469I_EVAL_QSPI_Private_Functions QSPI Private Functions - * @{ - */ -static uint8_t QSPI_ResetMemory (QSPI_HandleTypeDef *hqspi); -static uint8_t QSPI_EnterFourBytesAddress(QSPI_HandleTypeDef *hqspi); -static uint8_t QSPI_DummyCyclesCfg (QSPI_HandleTypeDef *hqspi); -static uint8_t QSPI_WriteEnable (QSPI_HandleTypeDef *hqspi); -static uint8_t QSPI_AutoPollingMemReady (QSPI_HandleTypeDef *hqspi, uint32_t Timeout); -static uint8_t QSPI_ReadID (QSPI_InfoTypeDef *pqspi_info); - -/** - * @} - */ - -/** @defgroup STM32469I_EVAL_QSPI_Exported_Functions QSPI Exported Functions - * @{ - */ - -/** - * @brief Initializes the QSPI interface. - * @retval QSPI memory status - */ -uint8_t BSP_QSPI_Init(void) -{ - QSPIHandle.Instance = QUADSPI; - - /* Call the DeInit function to reset the driver */ - if (HAL_QSPI_DeInit(&QSPIHandle) != HAL_OK) - { - return QSPI_ERROR; - } - - /* System level initialization */ - BSP_QSPI_MspInit(&QSPIHandle, NULL); - - /* QSPI initialization */ - /* Init typedef is the same for both S25FL512S and N25Q512A memories, as they have the same FLASH size */ - QSPIHandle.Init.ClockPrescaler = 1; /* QSPI Freq= 180 MHz / (1+1) = 90 MHz */ - QSPIHandle.Init.FifoThreshold = 1; - QSPIHandle.Init.SampleShifting = QSPI_SAMPLE_SHIFTING_HALFCYCLE; - QSPIHandle.Init.FlashSize = POSITION_VAL(S25FL512S_FLASH_SIZE) - 1; /* same size on both memory types */ - QSPIHandle.Init.ChipSelectHighTime = QSPI_CS_HIGH_TIME_2_CYCLE; - QSPIHandle.Init.ClockMode = QSPI_CLOCK_MODE_0; - QSPIHandle.Init.FlashID = QSPI_FLASH_ID_1; - QSPIHandle.Init.DualFlash = QSPI_DUALFLASH_DISABLE; - - if (HAL_QSPI_Init(&QSPIHandle) != HAL_OK) - { - return QSPI_ERROR; - } - - /* Detect the memory ID */ - if (QSPI_ReadID(&QspiInfo) != QSPI_OK) - { - return QSPI_NOT_SUPPORTED; - } - - /* QSPI memory reset */ - if (QSPI_ResetMemory(&QSPIHandle) != QSPI_OK) - { - return QSPI_NOT_SUPPORTED; - } - - /* Set the QSPI memory in 4-bytes address mode */ - if (QSPI_EnterFourBytesAddress(&QSPIHandle) != QSPI_OK) - { - return QSPI_NOT_SUPPORTED; - } - - /* Configuration of the dummy cucles on QSPI memory side */ - if (QSPI_DummyCyclesCfg(&QSPIHandle) != QSPI_OK) - { - return QSPI_NOT_SUPPORTED; - } - - return QSPI_OK; -} - -/** - * @brief De-Initializes the QSPI interface. - * @retval QSPI memory status - */ -uint8_t BSP_QSPI_DeInit(void) -{ - QSPIHandle.Instance = QUADSPI; - - /* Call the DeInit function to reset the driver */ - if (HAL_QSPI_DeInit(&QSPIHandle) != HAL_OK) - { - return QSPI_ERROR; - } - - /* System level De-initialization */ - BSP_QSPI_MspDeInit(&QSPIHandle, NULL); - - return QSPI_OK; -} - -/** - * @brief Reads an amount of data from the QSPI memory. - * @param pData: Pointer to data to be read - * @param ReadAddr: Read start address - * @param Size: Size of data to read - * @retval QSPI memory status - */ -uint8_t BSP_QSPI_Read(uint8_t* pData, uint32_t ReadAddr, uint32_t Size) -{ - QSPI_CommandTypeDef s_command; - - /* Initialize the read command */ - s_command.InstructionMode = QSPI_INSTRUCTION_1_LINE; - s_command.Instruction = QUAD_OUT_FAST_READ_CMD; /* same value on both memory types */ - s_command.AddressMode = QSPI_ADDRESS_1_LINE; - s_command.AddressSize = QSPI_ADDRESS_32_BITS; - s_command.Address = ReadAddr; - s_command.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE; - s_command.DataMode = QSPI_DATA_4_LINES; - s_command.DummyCycles = QspiInfo.DummyCyclesRead; - s_command.NbData = Size; - s_command.DdrMode = QSPI_DDR_MODE_DISABLE; - s_command.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY; - s_command.SIOOMode = QSPI_SIOO_INST_EVERY_CMD; - - /* Configure the command */ - if (HAL_QSPI_Command(&QSPIHandle, &s_command, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - /* Reception of the data */ - if (HAL_QSPI_Receive(&QSPIHandle, pData, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - return QSPI_OK; -} - -/** - * @brief Writes an amount of data to the QSPI memory. - * @param pData: Pointer to data to be written - * @param WriteAddr: Write start address - * @param Size: Size of data to write - * @retval QSPI memory status - */ -uint8_t BSP_QSPI_Write(uint8_t* pData, uint32_t WriteAddr, uint32_t Size) -{ - QSPI_CommandTypeDef s_command; - uint32_t end_addr, current_size, current_addr; - - /* Calculation of the size between the write address and the end of the page */ - current_addr = 0; - - while (current_addr <= WriteAddr) - { - current_addr += QspiInfo.ProgPageSize; - } - current_size = current_addr - WriteAddr; - - /* Check if the size of the data is less than the remaining place in the page */ - if (current_size > Size) - { - current_size = Size; - } - - /* Initialize the adress variables */ - current_addr = WriteAddr; - end_addr = WriteAddr + Size; - - /* Initialize the program command */ - s_command.InstructionMode = QSPI_INSTRUCTION_1_LINE; - s_command.Instruction = QUAD_IN_FAST_PROG_CMD; /* same value on both memory types */ - s_command.AddressMode = QSPI_ADDRESS_1_LINE; - s_command.AddressSize = QSPI_ADDRESS_32_BITS; - s_command.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE; - s_command.DataMode = QSPI_DATA_4_LINES; - s_command.DummyCycles = 0; - s_command.DdrMode = QSPI_DDR_MODE_DISABLE; - s_command.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY; - s_command.SIOOMode = QSPI_SIOO_INST_EVERY_CMD; - - /* Perform the write page by page */ - do - { - s_command.Address = current_addr; - s_command.NbData = current_size; - - /* Enable write operations */ - if (QSPI_WriteEnable(&QSPIHandle) != QSPI_OK) - { - return QSPI_ERROR; - } - - /* Configure the command */ - if (HAL_QSPI_Command(&QSPIHandle, &s_command, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - /* Transmission of the data */ - if (HAL_QSPI_Transmit(&QSPIHandle, pData, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - /* Configure automatic polling mode to wait for end of program */ - if (QSPI_AutoPollingMemReady(&QSPIHandle, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != QSPI_OK) - { - return QSPI_ERROR; - } - - /* Update the address and size variables for next page programming */ - current_addr += current_size; - pData += current_size; - current_size = ((current_addr + QspiInfo.ProgPageSize) > end_addr) ? (end_addr - current_addr) : QspiInfo.ProgPageSize; - } while (current_addr < end_addr); - - return QSPI_OK; -} - -/** - * @brief Erases the specified block of the QSPI memory. - * @param BlockAddress: Block address to erase - * @retval QSPI memory status - */ -uint8_t BSP_QSPI_Erase_Block(uint32_t BlockAddress) -{ - QSPI_CommandTypeDef s_command; - - /* Initialize the erase command */ - s_command.InstructionMode = QSPI_INSTRUCTION_1_LINE; - s_command.Instruction = SECTOR_ERASE_CMD; /* same value on both memory types */ - s_command.AddressMode = QSPI_ADDRESS_1_LINE; - s_command.AddressSize = QSPI_ADDRESS_32_BITS; - s_command.Address = BlockAddress; - s_command.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE; - s_command.DataMode = QSPI_DATA_NONE; - s_command.DummyCycles = 0; - s_command.DdrMode = QSPI_DDR_MODE_DISABLE; - s_command.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY; - s_command.SIOOMode = QSPI_SIOO_INST_EVERY_CMD; - - /* Enable write operations */ - if (QSPI_WriteEnable(&QSPIHandle) != QSPI_OK) - { - return QSPI_ERROR; - } - - /* Send the command */ - if (HAL_QSPI_Command(&QSPIHandle, &s_command, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - /* Configure automatic polling mode to wait for end of erase */ - if (QSPI_AutoPollingMemReady(&QSPIHandle, QspiInfo.SectorEraseMaxTime) != QSPI_OK) - { - return QSPI_ERROR; - } - - return QSPI_OK; -} - -/** - * @brief Erases the entire QSPI memory. - * @retval QSPI memory status - */ -uint8_t BSP_QSPI_Erase_Chip(void) -{ - QSPI_CommandTypeDef s_command; - - /* Initialize the erase command */ - s_command.InstructionMode = QSPI_INSTRUCTION_1_LINE; - s_command.Instruction = BULK_ERASE_CMD; /* same value on both memory types */ - s_command.AddressMode = QSPI_ADDRESS_NONE; - s_command.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE; - s_command.DataMode = QSPI_DATA_NONE; - s_command.DummyCycles = 0; - s_command.DdrMode = QSPI_DDR_MODE_DISABLE; - s_command.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY; - s_command.SIOOMode = QSPI_SIOO_INST_EVERY_CMD; - - /* Enable write operations */ - if (QSPI_WriteEnable(&QSPIHandle) != QSPI_OK) - { - return QSPI_ERROR; - } - - /* Send the command */ - if (HAL_QSPI_Command(&QSPIHandle, &s_command, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - /* Configure automatic polling mode to wait for end of erase */ - if (QSPI_AutoPollingMemReady(&QSPIHandle, QspiInfo.BulkEraseMaxTime) != QSPI_OK) - { - return QSPI_ERROR; - } - - return QSPI_OK; -} - -/** - * @brief Reads current status of the QSPI memory. - * @retval QSPI memory status - */ -uint8_t BSP_QSPI_GetStatus(void) -{ - QSPI_CommandTypeDef s_command; - uint8_t reg1, reg2; - - if (QspiInfo.ManufID == QSPI_N25Q512A) - { - /* Initialize the read flag status register command */ - s_command.InstructionMode = QSPI_INSTRUCTION_1_LINE; - s_command.Instruction = READ_FLAG_STATUS_REG_CMD; /* same value on both memory types */ - s_command.AddressMode = QSPI_ADDRESS_NONE; - s_command.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE; - s_command.DataMode = QSPI_DATA_1_LINE; - s_command.DummyCycles = 0; - s_command.NbData = 1; - s_command.DdrMode = QSPI_DDR_MODE_DISABLE; - s_command.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY; - s_command.SIOOMode = QSPI_SIOO_INST_EVERY_CMD; - - /* Configure the command */ - if (HAL_QSPI_Command(&QSPIHandle, &s_command, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - /* Reception of the data */ - if (HAL_QSPI_Receive(&QSPIHandle, ®1, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - /* Check the value of the register */ - if ((reg1 & (N25Q512A_FSR_PRERR | N25Q512A_FSR_VPPERR | N25Q512A_FSR_PGERR | N25Q512A_FSR_ERERR)) != 0) - { - return QSPI_ERROR; - } - else if ((reg1 & (N25Q512A_FSR_PGSUS | N25Q512A_FSR_ERSUS)) != 0) - { - return QSPI_SUSPENDED; - } - else if ((reg1 & N25Q512A_FSR_READY) != 0) - { - return QSPI_OK; - } - else - { - return QSPI_BUSY; - } - } - else - { - /* Initialize the read flag status register1 command */ - s_command.InstructionMode = QSPI_INSTRUCTION_1_LINE; - s_command.Instruction = S25FL512S_READ_STATUS_REG1_CMD; - s_command.AddressMode = QSPI_ADDRESS_NONE; - s_command.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE; - s_command.DataMode = QSPI_DATA_1_LINE; - s_command.DummyCycles = 0; - s_command.NbData = 1; - s_command.DdrMode = QSPI_DDR_MODE_DISABLE; - s_command.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY; - s_command.SIOOMode = QSPI_SIOO_INST_EVERY_CMD; - - /* Configure the command */ - if (HAL_QSPI_Command(&QSPIHandle, &s_command, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - /* Reception of the data */ - if (HAL_QSPI_Receive(&QSPIHandle, ®1, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - - /* Initialize the read flag status register2 command */ - s_command.InstructionMode = QSPI_INSTRUCTION_1_LINE; - s_command.Instruction = S25FL512S_READ_STATUS_REG2_CMD; - s_command.AddressMode = QSPI_ADDRESS_NONE; - s_command.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE; - s_command.DataMode = QSPI_DATA_1_LINE; - s_command.DummyCycles = 0; - s_command.NbData = 1; - s_command.DdrMode = QSPI_DDR_MODE_DISABLE; - s_command.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY; - s_command.SIOOMode = QSPI_SIOO_INST_EVERY_CMD; - - /* Configure the command */ - if (HAL_QSPI_Command(&QSPIHandle, &s_command, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - /* Reception of the data */ - if (HAL_QSPI_Receive(&QSPIHandle, ®2, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - /* Check the value of the register */ - if ((reg1 & (S25FL512S_SR1_ERERR | S25FL512S_SR1_PGERR | S25FL512S_SR1_SRWD )) != 0) - { - return QSPI_ERROR; - } - if ((reg1 & (S25FL512S_SR1_BP0 | S25FL512S_SR1_BP1 | S25FL512S_SR1_BP2)) != 0) - { - return QSPI_PROTECTED; - } - - if ((reg2 & (S25FL512S_SR2_PS | S25FL512S_SR2_ES)) != 0) - { - return QSPI_SUSPENDED; - } - if ((reg1 & (S25FL512S_SR1_WIP | S25FL512S_SR1_WREN)) == 0) - { - return QSPI_OK; - } - else - { - return QSPI_BUSY; - } - } -} - -/** - * @brief Reads the configuration of the memory and fills QspiInfo struct - * @param pInfo pointer to Info structure - * @retval QSPI memory status - */ -uint8_t BSP_QSPI_GetInfo(QSPI_InfoTypeDef* pInfo) -{ - - if (QSPI_ReadID(pInfo) != QSPI_OK) - { - return QSPI_ERROR; - } - - return QSPI_OK; -} - -/** -* @brief Configure the QSPI in memory-mapped mode -* @param None -* @retval QSPI memory status -*/ -uint8_t BSP_QSPI_MemoryMappedMode(void) -{ - QSPI_CommandTypeDef s_command; - QSPI_MemoryMappedTypeDef s_mem_mapped_cfg; - - /* Configure the command for the read instruction */ - s_command.InstructionMode = QSPI_INSTRUCTION_1_LINE; - s_command.Instruction = QUAD_OUT_FAST_READ_CMD; - s_command.AddressMode = QSPI_ADDRESS_1_LINE; - s_command.AddressSize = QSPI_ADDRESS_32_BITS; - s_command.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE; - s_command.DataMode = QSPI_DATA_4_LINES; - s_command.DummyCycles = QspiInfo.DummyCyclesRead; - s_command.DdrMode = QSPI_DDR_MODE_DISABLE; - s_command.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY; - s_command.SIOOMode = QSPI_SIOO_INST_EVERY_CMD; - - /* Configure the memory mapped mode */ - s_mem_mapped_cfg.TimeOutActivation = QSPI_TIMEOUT_COUNTER_DISABLE; - s_mem_mapped_cfg.TimeOutPeriod = 0; //1; - - if (HAL_QSPI_MemoryMapped(&QSPIHandle, &s_command, &s_mem_mapped_cfg) != HAL_OK) - { - return QSPI_ERROR; - } - - return QSPI_OK; -} - -/** - * @} - */ - -/** @addtogroup STM32446E_EVAL_QSPI_Private_Functions - * @{ - */ - -/** - * @brief QSPI MSP Initialization - * This function configures the hardware resources used in this example: - * - Peripheral's clock enable - * - Peripheral's GPIO Configuration - * - NVIC configuration for QSPI interrupt - * @retval None - */ -__weak void BSP_QSPI_MspInit(QSPI_HandleTypeDef *hqspi, void *Params) -{ - GPIO_InitTypeDef gpio_init_structure; - - /*##-1- Enable peripherals and GPIO Clocks #################################*/ - /* Enable the QuadSPI memory interface clock */ - QSPI_CLK_ENABLE(); - /* Reset the QuadSPI memory interface */ - QSPI_FORCE_RESET(); - QSPI_RELEASE_RESET(); - /* Enable GPIO clocks */ - QSPI_CS_GPIO_CLK_ENABLE(); - QSPI_DX_CLK_GPIO_CLK_ENABLE(); - - /*##-2- Configure peripheral GPIO ##########################################*/ - /* QSPI CS GPIO pin configuration */ - gpio_init_structure.Pin = QSPI_CS_PIN; - gpio_init_structure.Mode = GPIO_MODE_AF_PP; - gpio_init_structure.Pull = GPIO_PULLUP; - gpio_init_structure.Speed = GPIO_SPEED_HIGH; - gpio_init_structure.Alternate = GPIO_AF10_QSPI; - HAL_GPIO_Init(QSPI_CS_GPIO_PORT, &gpio_init_structure); - - /* QSPI CLK GPIO pin configuration */ - gpio_init_structure.Pin = QSPI_CLK_PIN; - gpio_init_structure.Pull = GPIO_NOPULL; - gpio_init_structure.Alternate = GPIO_AF9_QSPI; - HAL_GPIO_Init(QSPI_CLK_GPIO_PORT, &gpio_init_structure); - - /* QSPI D0 and D1 GPIO pin configuration */ - gpio_init_structure.Pin = (QSPI_D0_PIN | QSPI_D1_PIN); - gpio_init_structure.Alternate = GPIO_AF10_QSPI; - HAL_GPIO_Init(QSPI_DX_GPIO_PORT, &gpio_init_structure); - - /* QSPI D2 and D3 GPIO pin configuration */ - gpio_init_structure.Pin = (QSPI_D2_PIN | QSPI_D3_PIN) ; - gpio_init_structure.Alternate = GPIO_AF9_QSPI; - HAL_GPIO_Init(QSPI_DX_GPIO_PORT, &gpio_init_structure); - - /*##-3- Configure the NVIC for QSPI #########################################*/ - /* NVIC configuration for QSPI interrupt */ - HAL_NVIC_SetPriority(QUADSPI_IRQn, 0x0F, 0); - HAL_NVIC_EnableIRQ(QUADSPI_IRQn); - -} - -/** - * @brief QSPI MSP De-Initialization - * This function frees the hardware resources used in this example: - * - Disable the Peripheral's clock - * - Revert GPIO and NVIC configuration to their default state - * @retval None - */ -__weak void BSP_QSPI_MspDeInit(QSPI_HandleTypeDef *hqspi, void *Params) -{ - /*##-1- Disable the NVIC for QSPI ###########################################*/ - HAL_NVIC_DisableIRQ(QUADSPI_IRQn); - - /*##-2- Disable peripherals and GPIO Clocks ################################*/ - /* De-Configure QSPI pins */ - HAL_GPIO_DeInit(QSPI_CS_GPIO_PORT, QSPI_CS_PIN); - HAL_GPIO_DeInit(QSPI_CLK_GPIO_PORT, QSPI_CLK_PIN); - HAL_GPIO_DeInit(QSPI_DX_GPIO_PORT, QSPI_D0_PIN); - HAL_GPIO_DeInit(QSPI_DX_GPIO_PORT, QSPI_D1_PIN); - HAL_GPIO_DeInit(QSPI_DX_GPIO_PORT, QSPI_D2_PIN); - HAL_GPIO_DeInit(QSPI_DX_GPIO_PORT, QSPI_D3_PIN); - - /*##-3- Reset peripherals ##################################################*/ - /* Reset the QuadSPI memory interface */ - QSPI_FORCE_RESET(); - QSPI_RELEASE_RESET(); - - /* Disable the QuadSPI memory interface clock */ - QSPI_CLK_DISABLE(); -} - -/** - * @brief This function reset the QSPI memory. - * @param hqspi: QSPI handle - * @retval None - */ -static uint8_t QSPI_ResetMemory(QSPI_HandleTypeDef *hqspi) -{ - QSPI_CommandTypeDef s_command; - uint32_t instruction1, instruction2; - - /* Command ID differs between N25Q512A and S25FL512S memories */ - if (QspiInfo.ManufID == QSPI_N25Q512A) - { - instruction1 = RESET_ENABLE_CMD; - instruction2 = RESET_MEMORY_CMD; - } - else - { - instruction1 = S25FL512S_MODE_BIT_RESET_CMD; - instruction2 = S25FL512S_SOFTWARE_RESET_CMD; - } - - /* Initialize the Mode Bit Reset command */ - s_command.InstructionMode = QSPI_INSTRUCTION_1_LINE; - s_command.Instruction = instruction1; - s_command.AddressMode = QSPI_ADDRESS_NONE; - s_command.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE; - s_command.DataMode = QSPI_DATA_NONE; - s_command.DummyCycles = 0; - s_command.DdrMode = QSPI_DDR_MODE_DISABLE; - s_command.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY; - s_command.SIOOMode = QSPI_SIOO_INST_EVERY_CMD; - - /* Send the command */ - if (HAL_QSPI_Command(&QSPIHandle, &s_command, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - /* Send the SW reset command */ - s_command.Instruction = instruction2; - if (HAL_QSPI_Command(&QSPIHandle, &s_command, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - /* Configure automatic polling mode to wait the memory is ready */ - if (QSPI_AutoPollingMemReady(&QSPIHandle, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != QSPI_OK) - { - return QSPI_ERROR; - } - return QSPI_OK; -} - -/** - * @brief This function set the QSPI memory in 4-byte address mode - * @param hqspi: QSPI handle - * @retval None - */ -static uint8_t QSPI_EnterFourBytesAddress(QSPI_HandleTypeDef *hqspi) -{ - QSPI_CommandTypeDef s_command; - uint8_t reg1; - - /* Command ID differs between N25Q512A and S25FL512S memories */ - if (QspiInfo.ManufID == QSPI_N25Q512A) - { - /* Initialize the command */ - s_command.InstructionMode = QSPI_INSTRUCTION_1_LINE; - s_command.Instruction = ENTER_4_BYTE_ADDR_MODE_CMD; - s_command.AddressMode = QSPI_ADDRESS_NONE; - s_command.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE; - s_command.DataMode = QSPI_DATA_NONE; - s_command.DummyCycles = 0; - s_command.DdrMode = QSPI_DDR_MODE_DISABLE; - s_command.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY; - s_command.SIOOMode = QSPI_SIOO_INST_EVERY_CMD; - - /* Enable write operations */ - if (QSPI_WriteEnable(hqspi) != QSPI_OK) - { - return QSPI_ERROR; - } - - /* Send the command */ - if (HAL_QSPI_Command(hqspi, &s_command, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - /* Configure automatic polling mode to wait the memory is ready */ - if (QSPI_AutoPollingMemReady(hqspi, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != QSPI_OK) - { - return QSPI_ERROR; - } - - return QSPI_OK; - } - else - { - /* Initialize the read bank register command */ - s_command.InstructionMode = QSPI_INSTRUCTION_1_LINE; - s_command.Instruction = S25FL512S_READ_BANK_REG_CMD; - s_command.AddressMode = QSPI_ADDRESS_NONE; - s_command.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE; - s_command.DataMode = QSPI_DATA_1_LINE; - s_command.DummyCycles = 0; - s_command.NbData = 1; - s_command.DdrMode = QSPI_DDR_MODE_DISABLE; - s_command.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY; - s_command.SIOOMode = QSPI_SIOO_INST_EVERY_CMD; - - /* Configure the command */ - if (HAL_QSPI_Command(&QSPIHandle, &s_command, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - /* Reception of the data */ - if (HAL_QSPI_Receive(&QSPIHandle, ®1, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - /* Enable write operations */ - if (QSPI_WriteEnable(&QSPIHandle) != QSPI_OK) - { - return QSPI_ERROR; - } - - /* Update Bank address register (with 4byte addressing bit) */ - s_command.Instruction = S25FL512S_WRITE_BANK_REG_CMD; - MODIFY_REG(reg1, S25FL512S_BA_EXTADD, S25FL512S_BA_EXTADD); - - /* Configure the write volatile configuration register command */ - if (HAL_QSPI_Command(&QSPIHandle, &s_command, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - /* Transmission of the data Status Register 1 */ - if (HAL_QSPI_Transmit(&QSPIHandle, ®1, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - return QSPI_OK; - } -} - -/** - * @brief This function configure the dummy cycles on memory side. - * @param hqspi: QSPI handle - * @retval None - */ -static uint8_t QSPI_DummyCyclesCfg(QSPI_HandleTypeDef *hqspi) -{ - QSPI_CommandTypeDef s_command; - uint8_t reg[2]; - /* Command ID differs between N25Q512A and S25FL512S memories */ - if (QspiInfo.ManufID == QSPI_N25Q512A) - { - /* Initialize the read volatile configuration register command */ - s_command.InstructionMode = QSPI_INSTRUCTION_1_LINE; - s_command.Instruction = READ_VOL_CFG_REG_CMD; - s_command.AddressMode = QSPI_ADDRESS_NONE; - s_command.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE; - s_command.DataMode = QSPI_DATA_1_LINE; - s_command.DummyCycles = 0; - s_command.NbData = 1; - s_command.DdrMode = QSPI_DDR_MODE_DISABLE; - s_command.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY; - s_command.SIOOMode = QSPI_SIOO_INST_EVERY_CMD; - - /* Configure the command */ - if (HAL_QSPI_Command(hqspi, &s_command, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - /* Reception of the data */ - if (HAL_QSPI_Receive(hqspi, ®[0], HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - /* Enable write operations */ - if (QSPI_WriteEnable(hqspi) != QSPI_OK) - { - return QSPI_ERROR; - } - - /* Update volatile configuration register (with new dummy cycles) */ - s_command.Instruction = WRITE_VOL_CFG_REG_CMD; - MODIFY_REG(reg[0], N25Q512A_VCR_NB_DUMMY, (N25Q512A_DUMMY_CYCLES_READ_QUAD << POSITION_VAL(N25Q512A_VCR_NB_DUMMY))); - - /* Configure the write volatile configuration register command */ - if (HAL_QSPI_Command(hqspi, &s_command, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - /* Transmission of the data */ - if (HAL_QSPI_Transmit(hqspi, ®[0], HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - } - else - { - /* Initialize the read configuration register command */ - s_command.InstructionMode = QSPI_INSTRUCTION_1_LINE; - s_command.Instruction = S25FL512S_READ_CONFIGURATION_REG1_CMD; - s_command.AddressMode = QSPI_ADDRESS_NONE; - s_command.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE; - s_command.DataMode = QSPI_DATA_1_LINE; - s_command.DummyCycles = 0; - s_command.NbData = 1; - s_command.DdrMode = QSPI_DDR_MODE_DISABLE; - s_command.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY; - s_command.SIOOMode = QSPI_SIOO_INST_EVERY_CMD; - - /* Configure the command */ - if (HAL_QSPI_Command(&QSPIHandle, &s_command, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - /* Reception of the data */ - if (HAL_QSPI_Receive(&QSPIHandle, ®[1], HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - /* Initialize the read status register1 command */ - s_command.InstructionMode = QSPI_INSTRUCTION_1_LINE; - s_command.Instruction = S25FL512S_READ_STATUS_REG1_CMD; - s_command.AddressMode = QSPI_ADDRESS_NONE; - s_command.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE; - s_command.DataMode = QSPI_DATA_1_LINE; - s_command.DummyCycles = 0; - s_command.NbData = 1; - s_command.DdrMode = QSPI_DDR_MODE_DISABLE; - s_command.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY; - s_command.SIOOMode = QSPI_SIOO_INST_EVERY_CMD; - - /* Configure the command */ - if (HAL_QSPI_Command(&QSPIHandle, &s_command, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - /* Reception of the data */ - if (HAL_QSPI_Receive(&QSPIHandle, ®[0], HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - /* Enable write operations */ - if (QSPI_WriteEnable(&QSPIHandle) != QSPI_OK) - { - return QSPI_ERROR; - } - - /* Update configuration register (with new Latency Code) */ - s_command.Instruction = S25FL512S_WRITE_STATUS_CMD_REG_CMD; - s_command.NbData = 2; - MODIFY_REG(reg[1], S25FL512S_CR1_LC_MASK, S25FL512S_CR1_LC1); - - /* Configure the write volatile configuration register command */ - if (HAL_QSPI_Command(&QSPIHandle, &s_command, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - /* Transmission of the data Status Register 1 */ - if (HAL_QSPI_Transmit(&QSPIHandle, reg, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - } - return QSPI_OK; -} - -/** - * @brief This function send a Write Enable and wait it is effective. - * @param hqspi: QSPI handle - * @retval None - */ -static uint8_t QSPI_WriteEnable(QSPI_HandleTypeDef *hqspi) -{ - QSPI_CommandTypeDef s_command; - QSPI_AutoPollingTypeDef sConfig; - - /* Enable write operations */ - s_command.InstructionMode = QSPI_INSTRUCTION_1_LINE; - s_command.Instruction = WRITE_ENABLE_CMD; /* equal on both memory types */ - s_command.AddressMode = QSPI_ADDRESS_NONE; - s_command.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE; - s_command.DataMode = QSPI_DATA_NONE; - s_command.DummyCycles = 0; - s_command.DdrMode = QSPI_DDR_MODE_DISABLE; - s_command.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY; - s_command.SIOOMode = QSPI_SIOO_INST_EVERY_CMD; - - if (HAL_QSPI_Command(&QSPIHandle, &s_command, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - /* Configure automatic polling mode to wait for write enabling */ - sConfig.Match = S25FL512S_SR1_WREN; - sConfig.Mask = S25FL512S_SR1_WREN; /* equal on both memory types */ - sConfig.MatchMode = QSPI_MATCH_MODE_AND; - sConfig.StatusBytesSize = 1; - sConfig.Interval = 0x10; - sConfig.AutomaticStop = QSPI_AUTOMATIC_STOP_ENABLE; - - s_command.Instruction = READ_STATUS_REG_CMD; /* equal on both memory types */ - s_command.DataMode = QSPI_DATA_1_LINE; - - if (HAL_QSPI_AutoPolling(&QSPIHandle, &s_command, &sConfig, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - return QSPI_OK; -} - -/** - * @brief This function read the SR of the memory and wait the EOP. - * @param hqspi: QSPI handle - * @param Timeout: timeout value before returning an error - * @retval None - */ -static uint8_t QSPI_AutoPollingMemReady(QSPI_HandleTypeDef *hqspi, uint32_t Timeout) -{ - QSPI_CommandTypeDef s_command; - QSPI_AutoPollingTypeDef sConfig; - - /* Configure automatic polling mode to wait for memory ready */ - s_command.InstructionMode = QSPI_INSTRUCTION_1_LINE; - s_command.Instruction = READ_STATUS_REG_CMD; /* same value on both memory types */ - s_command.AddressMode = QSPI_ADDRESS_NONE; - s_command.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE; - s_command.DataMode = QSPI_DATA_1_LINE; - s_command.DummyCycles = 0; - s_command.DdrMode = QSPI_DDR_MODE_DISABLE; - s_command.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY; - s_command.SIOOMode = QSPI_SIOO_INST_EVERY_CMD; - - sConfig.Match = 0; - sConfig.Mask = S25FL512S_SR1_WIP; /* same value on both memory types */ - sConfig.MatchMode = QSPI_MATCH_MODE_AND; - sConfig.StatusBytesSize = 1; - sConfig.Interval = 0x10; - sConfig.AutomaticStop = QSPI_AUTOMATIC_STOP_ENABLE; - - if (HAL_QSPI_AutoPolling(&QSPIHandle, &s_command, &sConfig, Timeout) != HAL_OK) - { - return QSPI_ERROR; - } - - return QSPI_OK; -} - -/** - * @brief This function reads the ID of the QSPI Memory and fills the info struct - * @param pqspi_info: pointer to the Info Typedef strcture - * @retval None - */ -static uint8_t QSPI_ReadID(QSPI_InfoTypeDef *pqspi_info) -{ - QSPI_CommandTypeDef s_command; - uint8_t reg[6]; - - /* Configure automatic polling mode to wait for memory ready */ - s_command.InstructionMode = QSPI_INSTRUCTION_1_LINE; - s_command.Instruction = READ_ID_CMD2; /* same value on both memory types */ - s_command.AddressMode = QSPI_ADDRESS_NONE; - s_command.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE; - s_command.DataMode = QSPI_DATA_1_LINE; - s_command.NbData = 6; - s_command.DummyCycles = 0; - s_command.DdrMode = QSPI_DDR_MODE_DISABLE; - s_command.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY; - s_command.SIOOMode = QSPI_SIOO_INST_EVERY_CMD; - - if (HAL_QSPI_Command(&QSPIHandle, &s_command, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - /* Reception of the data */ - if (HAL_QSPI_Receive(&QSPIHandle, reg, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) - { - return QSPI_ERROR; - } - - /* Check the received ID of the QSPI Memory */ - if (reg[0] == JEDEC_MANUF_ID_MICRON) - { - pqspi_info->ManufID = QSPI_N25Q512A; - pqspi_info->FlashSize = (reg[2]<<21) & 0xFFFFFFFF; - pqspi_info->EraseSectorSize = N25Q512A_SECTOR_SIZE; - pqspi_info->EraseSectorsNumber = (N25Q512A_FLASH_SIZE/N25Q512A_SECTOR_SIZE); - pqspi_info->ProgPageSize = N25Q512A_PAGE_SIZE; - pqspi_info->ProgPagesNumber = (N25Q512A_FLASH_SIZE/N25Q512A_PAGE_SIZE); - pqspi_info->DummyCyclesRead = 10; - pqspi_info->SectorEraseMaxTime = N25Q512A_SECTOR_ERASE_MAX_TIME; - pqspi_info->BulkEraseMaxTime = N25Q512A_BULK_ERASE_MAX_TIME; - } - if (reg[0] == JEDEC_MANUF_ID_SPANSION) - { - pqspi_info->ManufID = QSPI_S25FL512S; - pqspi_info->FlashSize = (reg[2]<<21) & 0xFFFFFFFF; - pqspi_info->EraseSectorSize = S25FL512S_SECTOR_SIZE; - pqspi_info->EraseSectorsNumber = (S25FL512S_FLASH_SIZE/S25FL512S_SECTOR_SIZE); - pqspi_info->ProgPageSize = S25FL512S_PAGE_SIZE; - pqspi_info->ProgPagesNumber = (S25FL512S_FLASH_SIZE/S25FL512S_PAGE_SIZE); - pqspi_info->DummyCyclesRead = 8; - pqspi_info->SectorEraseMaxTime = S25FL512S_SECTOR_ERASE_MAX_TIME; - pqspi_info->BulkEraseMaxTime = S25FL512S_BULK_ERASE_MAX_TIME; - } - - return QSPI_OK; - -} -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ - diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_qspi.h b/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_qspi.h deleted file mode 100644 index 469d426ed2..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_qspi.h +++ /dev/null @@ -1,172 +0,0 @@ -/** - ****************************************************************************** - * @file stm32469i_eval_qspi.h - * @author MCD Application Team - * @version V1.0.1 - * @date 29-September-2015 - * @brief This file contains the common defines and functions prototypes for - * the stm32469i_eval_qspi.c driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32469I_EVAL - * @{ - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32469I_EVAL_QSPI_H -#define __STM32469I_EVAL_QSPI_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm32f4xx_hal.h" -#include "../Components/s25fl512s/s25fl512s.h" -#include "../Components/n25q512a/n25q512a.h" - - -/** @addtogroup STM32469I_EVAL_QSPI - * @{ - */ - - -/* Exported constants --------------------------------------------------------*/ -/** @defgroup STM32446E_EVAL_QSPI_Exported_Constants Exported Constants - * @{ - */ -/* QSPI Error codes */ -#define QSPI_OK ((uint8_t)0x00) -#define QSPI_ERROR ((uint8_t)0x01) -#define QSPI_BUSY ((uint8_t)0x02) -#define QSPI_NOT_SUPPORTED ((uint8_t)0x04) -#define QSPI_SUSPENDED ((uint8_t)0x08) -#define QSPI_PROTECTED ((uint8_t)0x10) - -#define QSPI_S25FL512S ((uint8_t)0x20) -#define QSPI_N25Q512A ((uint8_t)0x40) - -/* Definition for QSPI clock resources */ -#define QSPI_CLK_ENABLE() __HAL_RCC_QSPI_CLK_ENABLE() -#define QSPI_CLK_DISABLE() __HAL_RCC_QSPI_CLK_DISABLE() -#define QSPI_CS_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE() -#define QSPI_CS_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE() -#define QSPI_DX_CLK_GPIO_CLK_ENABLE() __HAL_RCC_GPIOF_CLK_ENABLE() -#define QSPI_DX_CLK_GPIO_CLK_DISABLE() __HAL_RCC_GPIOF_CLK_DISABLE() - -#define QSPI_FORCE_RESET() __HAL_RCC_QSPI_FORCE_RESET() -#define QSPI_RELEASE_RESET() __HAL_RCC_QSPI_RELEASE_RESET() - -/* Definition for QSPI Pins */ -#define QSPI_CS_PIN GPIO_PIN_6 -#define QSPI_CS_GPIO_PORT GPIOB -#define QSPI_CLK_PIN GPIO_PIN_10 -#define QSPI_CLK_GPIO_PORT GPIOF -#define QSPI_D0_PIN GPIO_PIN_8 -#define QSPI_D1_PIN GPIO_PIN_9 -#define QSPI_D2_PIN GPIO_PIN_7 -#define QSPI_D3_PIN GPIO_PIN_6 -#define QSPI_DX_GPIO_PORT GPIOF - - -/** - * @} - */ - -/* Exported types ------------------------------------------------------------*/ -/** @defgroup STM32446E_EVAL_QSPI_Exported_Types Exported Types - * @{ - */ -/** - * @brief QSPI Info - * */ -typedef struct { - uint32_t FlashSize; /*!< Size of the flash */ - uint32_t EraseSectorSize; /*!< Size of sectors for the erase operation */ - uint32_t EraseSectorsNumber; /*!< Number of sectors for the erase operation */ - uint32_t ProgPageSize; /*!< Size of pages for the program operation */ - uint32_t ProgPagesNumber; /*!< Number of pages for the program operation */ - uint32_t DummyCyclesRead; /*!< Number of dummy read cycles */ - uint8_t ManufID; /*!< Manufacturor value */ - uint32_t SectorEraseMaxTime; /*!< Sector Erase max value */ - uint32_t BulkEraseMaxTime; /*!< Bulk Erase Max Time */ -} QSPI_InfoTypeDef; - -/** - * @} - */ - - -/* Exported functions --------------------------------------------------------*/ -/** @addtogroup STM32446E_EVAL_QSPI_Exported_Functions - * @{ - */ -uint8_t BSP_QSPI_Init (void); -uint8_t BSP_QSPI_DeInit (void); -uint8_t BSP_QSPI_Read (uint8_t* pData, uint32_t ReadAddr, uint32_t Size); -uint8_t BSP_QSPI_Write (uint8_t* pData, uint32_t WriteAddr, uint32_t Size); -uint8_t BSP_QSPI_Erase_Block(uint32_t BlockAddress); -uint8_t BSP_QSPI_Erase_Chip (void); -uint8_t BSP_QSPI_GetStatus (void); -uint8_t BSP_QSPI_GetInfo (QSPI_InfoTypeDef* pInfo); -uint8_t BSP_QSPI_MemoryMappedMode(void); - -/* These function can be modified in case the current settings (e.g. DMA stream) - need to be changed for specific application needs */ -void BSP_QSPI_MspInit(QSPI_HandleTypeDef *hqspi, void *Params); -void BSP_QSPI_MspDeInit(QSPI_HandleTypeDef *hqspi, void *Params); - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32446E_EVAL_QSPI_H */ -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_sd.c b/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_sd.c deleted file mode 100644 index 4babe3e647..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_sd.c +++ /dev/null @@ -1,597 +0,0 @@ -/** - ****************************************************************************** - * @file stm32469i_eval_sd.c - * @author MCD Application Team - * @version V1.0.1 - * @date 29-September-2015 - * @brief This file includes the uSD card driver mounted on STM32469I-EVAL - * evaluation board. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* File Info : ----------------------------------------------------------------- - User NOTES -1. How To use this driver: --------------------------- - - This driver is used to drive the micro SD external card mounted on STM32469I-EVAL - evaluation board. - - This driver does not need a specific component driver for the micro SD device - to be included with. - -2. Driver description: ---------------------- - + Initialization steps: - o Initialize the micro SD card using the BSP_SD_Init() function. This - function includes the MSP layer hardware resources initialization and the - SDIO interface configuration to interface with the external micro SD. It - also includes the micro SD initialization sequence. - o To check the SD card presence you can use the function BSP_SD_IsDetected() which - returns the detection status - o If SD presence detection interrupt mode is desired, you must configure the - SD detection interrupt mode by calling the function BSP_SD_ITConfig(). The interrupt - is generated as an external interrupt whenever the micro SD card is - plugged/unplugged in/from the evaluation board. The SD detection interrupt - is handeled by calling the function BSP_SD_DetectIT() which is called in the IRQ - handler file, the user callback is implemented in the function BSP_SD_DetectCallback(). - o The function BSP_SD_GetCardInfo() is used to get the micro SD card information - which is stored in the structure "HAL_SD_CardInfoTypedef". - - + Micro SD card operations - o The micro SD card can be accessed with read/write block(s) operations once - it is reay for access. The access cand be performed whether using the polling - mode by calling the functions BSP_SD_ReadBlocks()/BSP_SD_WriteBlocks(), or by DMA - transfer using the functions BSP_SD_ReadBlocks_DMA()/BSP_SD_WriteBlocks_DMA() - o The DMA transfer complete is used with interrupt mode. Once the SD transfer - is complete, the SD interrupt is handeled using the function BSP_SD_IRQHandler(), - the DMA Tx/Rx transfer complete are handeled using the functions - BSP_SD_DMA_Tx_IRQHandler()/BSP_SD_DMA_Rx_IRQHandler(). The corresponding user callbacks - are implemented by the user at application level. - o The SD erase block(s) is performed using the function BSP_SD_Erase() with specifying - the number of blocks to erase. - o The SD runtime status is returned when calling the function BSP_SD_GetStatus(). - -------------------------------------------------------------------------------*/ - -/* Includes ------------------------------------------------------------------*/ -#include "stm32469i_eval_sd.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32469I-EVAL - * @{ - */ - -/** @defgroup STM32469I-EVAL_SD STM32469I-EVAL SD - * @{ - */ - - -/** @defgroup STM32469I-EVAL_SD_Private_TypesDefinitions STM32469I Eval Sd Private TypesDef - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_SD_Private_Defines STM32469I Eval Sd Private Defines - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_SD_Private_Macros STM32469I Eval Sd Private Macro - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_SD_Private_Variables STM32469I Eval Sd Private Variables - * @{ - */ -static SD_HandleTypeDef uSdHandle; -static SD_CardInfo uSdCardInfo; -static uint8_t UseExtiModeDetection = 0; - -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_SD_Private_FunctionPrototypes STM32469I Eval Sd Private Prototypes - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_SD_Private_Functions STM32469I Eval Sd Private Functions - * @{ - */ - -/** - * @brief Initializes the SD card device. - * @retval SD status - */ -uint8_t BSP_SD_Init(void) -{ - uint8_t sd_state = MSD_OK; - - /* PLLSAI is dedicated to LCD periph. Do not use it to get 48MHz*/ - - /* uSD device interface configuration */ - uSdHandle.Instance = SDIO; - - uSdHandle.Init.ClockEdge = SDIO_CLOCK_EDGE_RISING; - uSdHandle.Init.ClockBypass = SDIO_CLOCK_BYPASS_DISABLE; - uSdHandle.Init.ClockPowerSave = SDIO_CLOCK_POWER_SAVE_DISABLE; - uSdHandle.Init.BusWide = SDIO_BUS_WIDE_1B; - uSdHandle.Init.HardwareFlowControl = SDIO_HARDWARE_FLOW_CONTROL_ENABLE; - uSdHandle.Init.ClockDiv = SDIO_TRANSFER_CLK_DIV; - - /* Configure IO functionalities for SD detect pin */ - BSP_IO_Init(); - - /* Check if the SD card is plugged in the slot */ - BSP_IO_ConfigPin(SD_DETECT_PIN, IO_MODE_INPUT_PU); - if(BSP_SD_IsDetected() != SD_PRESENT) - { - return MSD_ERROR_SD_NOT_PRESENT; - } - - /* Msp SD initialization */ - BSP_SD_MspInit(&uSdHandle, NULL); - - /* HAL SD initialization */ - if(HAL_SD_Init(&uSdHandle, &uSdCardInfo) != SD_OK) - { - sd_state = MSD_ERROR; - } - - /* Configure SD Bus width */ - if(sd_state == MSD_OK) - { - /* Enable wide operation */ - if(HAL_SD_WideBusOperation_Config(&uSdHandle, SDIO_BUS_WIDE_4B) != SD_OK) - { - sd_state = MSD_ERROR; - } - else - { - sd_state = MSD_OK; - } - } - return sd_state; -} - -/** - * @brief DeInitializes the SD card device. - * @retval SD status - */ -uint8_t BSP_SD_DeInit(void) -{ - uint8_t sd_state = MSD_OK; - - uSdHandle.Instance = SDIO; - - /* Set back Mfx pin to INPUT mode in case it was in exti */ - UseExtiModeDetection = 0; - BSP_IO_ConfigPin(SD_DETECT_PIN, IO_MODE_INPUT_PU); - - /* HAL SD deinitialization */ - if(HAL_SD_DeInit(&uSdHandle) != HAL_OK) - { - sd_state = MSD_ERROR; - } - - /* Msp SD deinitialization */ - uSdHandle.Instance = SDIO; - BSP_SD_MspDeInit(&uSdHandle, NULL); - - return sd_state; -} - -/** - * @brief Configures Interrupt mode for SD detection pin. - * @retval Returns 0 - */ -uint8_t BSP_SD_ITConfig(void) -{ - /* Configure Interrupt mode for SD detection pin */ - /* Note: disabling exti mode can be done calling SD_DeInit() */ - UseExtiModeDetection = 1; - BSP_SD_IsDetected(); - - return 0; -} - -/** - * @brief Detects if SD card is correctly plugged in the memory slot or not. - * @retval Returns if SD is detected or not - */ -uint8_t BSP_SD_IsDetected(void) -{ - __IO uint8_t status = SD_PRESENT; - - /* Check SD card detect pin */ - if((BSP_IO_ReadPin(SD_DETECT_PIN)&SD_DETECT_PIN) != SD_DETECT_PIN) - { - if (UseExtiModeDetection) - BSP_IO_ConfigPin(SD_DETECT_PIN, IO_MODE_IT_RISING_EDGE_PU); - - } - else - { - status = SD_NOT_PRESENT; - if (UseExtiModeDetection) - BSP_IO_ConfigPin(SD_DETECT_PIN, IO_MODE_IT_FALLING_EDGE_PU); - } - - return status; -} - - - -/** - * @brief Reads block(s) from a specified address in an SD card, in polling mode. - * @param pData: Pointer to the buffer that will contain the data to transmit - * @param ReadAddr: Address from where data is to be read - * @param BlockSize: SD card data block size, that should be 512 - * @param NumOfBlocks: Number of SD blocks to read - * @retval SD status - */ -uint8_t BSP_SD_ReadBlocks(uint32_t *pData, uint64_t ReadAddr, uint32_t BlockSize, uint32_t NumOfBlocks) -{ - if(HAL_SD_ReadBlocks(&uSdHandle, pData, ReadAddr, BlockSize, NumOfBlocks) != SD_OK) - { - return MSD_ERROR; - } - else - { - return MSD_OK; - } -} - -/** - * @brief Writes block(s) to a specified address in an SD card, in polling mode. - * @param pData: Pointer to the buffer that will contain the data to transmit - * @param WriteAddr: Address from where data is to be written - * @param BlockSize: SD card data block size, that should be 512 - * @param NumOfBlocks: Number of SD blocks to write - * @retval SD status - */ -uint8_t BSP_SD_WriteBlocks(uint32_t *pData, uint64_t WriteAddr, uint32_t BlockSize, uint32_t NumOfBlocks) -{ - if(HAL_SD_WriteBlocks(&uSdHandle, pData, WriteAddr, BlockSize, NumOfBlocks) != SD_OK) - { - return MSD_ERROR; - } - else - { - return MSD_OK; - } -} - -/** - * @brief Reads block(s) from a specified address in an SD card, in DMA mode. - * @param pData: Pointer to the buffer that will contain the data to transmit - * @param ReadAddr: Address from where data is to be read - * @param BlockSize: SD card data block size, that should be 512 - * @param NumOfBlocks: Number of SD blocks to read - * @retval SD status - */ -uint8_t BSP_SD_ReadBlocks_DMA(uint32_t *pData, uint64_t ReadAddr, uint32_t BlockSize, uint32_t NumOfBlocks) -{ - uint8_t sd_state = MSD_OK; - - /* Read block(s) in DMA transfer mode */ - if(HAL_SD_ReadBlocks_DMA(&uSdHandle, pData, ReadAddr, BlockSize, NumOfBlocks) != SD_OK) - { - sd_state = MSD_ERROR; - } - - /* Wait until transfer is complete */ - if(sd_state == MSD_OK) - { - if(HAL_SD_CheckReadOperation(&uSdHandle, (uint32_t)SD_DATATIMEOUT) != SD_OK) - { - sd_state = MSD_ERROR; - } - else - { - sd_state = MSD_OK; - } - } - - return sd_state; -} - -/** - * @brief Writes block(s) to a specified address in an SD card, in DMA mode. - * @param pData: Pointer to the buffer that will contain the data to transmit - * @param WriteAddr: Address from where data is to be written - * @param BlockSize: SD card data block size, that should be 512 - * @param NumOfBlocks: Number of SD blocks to write - * @retval SD status - */ -uint8_t BSP_SD_WriteBlocks_DMA(uint32_t *pData, uint64_t WriteAddr, uint32_t BlockSize, uint32_t NumOfBlocks) -{ - uint8_t sd_state = MSD_OK; - - /* Write block(s) in DMA transfer mode */ - if(HAL_SD_WriteBlocks_DMA(&uSdHandle, pData, WriteAddr, BlockSize, NumOfBlocks) != SD_OK) - { - sd_state = MSD_ERROR; - } - - /* Wait until transfer is complete */ - if(sd_state == MSD_OK) - { - if(HAL_SD_CheckWriteOperation(&uSdHandle, (uint32_t)SD_DATATIMEOUT) != SD_OK) - { - sd_state = MSD_ERROR; - } - else - { - sd_state = MSD_OK; - } - } - - return sd_state; -} - -/** - * @brief Erases the specified memory area of the given SD card. - * @param StartAddr: Start byte address - * @param EndAddr: End byte address - * @retval SD status - */ -uint8_t BSP_SD_Erase(uint64_t StartAddr, uint64_t EndAddr) -{ - if(HAL_SD_Erase(&uSdHandle, StartAddr, EndAddr) != SD_OK) - { - return MSD_ERROR; - } - else - { - return MSD_OK; - } -} - -/** - * @brief Initializes the SD MSP. - * @param hsd: SD handle - * @param Params : pointer on additional configuration parameters, can be NULL. - */ -__weak void BSP_SD_MspInit(SD_HandleTypeDef *hsd, void *Params) -{ - static DMA_HandleTypeDef dma_rx_handle; - static DMA_HandleTypeDef dma_tx_handle; - GPIO_InitTypeDef gpio_init_structure; - - /* SD pins are in conflict with Camera pins therefore Camera is power down */ - /* __weak function can be modified by the application */ - BSP_IO_ConfigPin(RSTI_PIN, IO_MODE_OUTPUT); - BSP_IO_ConfigPin(XSDN_PIN, IO_MODE_OUTPUT); - /* De-assert the camera STANDBY pin (active high) */ - BSP_IO_WritePin(XSDN_PIN, BSP_IO_PIN_RESET); - /* Assert the camera RSTI pin (active low) */ - BSP_IO_WritePin(RSTI_PIN, BSP_IO_PIN_RESET); - HAL_Delay(100); - - /* Enable SDIO clock */ - __HAL_RCC_SDIO_CLK_ENABLE(); - - /* Enable DMA2 clocks */ - __DMAx_TxRx_CLK_ENABLE(); - - /* Enable GPIOs clock */ - __HAL_RCC_GPIOC_CLK_ENABLE(); - __HAL_RCC_GPIOD_CLK_ENABLE(); - - /* Common GPIO configuration */ - gpio_init_structure.Mode = GPIO_MODE_AF_PP; - gpio_init_structure.Pull = GPIO_PULLUP; - gpio_init_structure.Speed = GPIO_SPEED_HIGH; - gpio_init_structure.Alternate = GPIO_AF12_SDIO; - - /* GPIOC configuration */ - gpio_init_structure.Pin = GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12; - - HAL_GPIO_Init(GPIOC, &gpio_init_structure); - - /* GPIOD configuration */ - gpio_init_structure.Pin = GPIO_PIN_2; - HAL_GPIO_Init(GPIOD, &gpio_init_structure); - - /* NVIC configuration for SDIO interrupts */ - HAL_NVIC_SetPriority(SDIO_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(SDIO_IRQn); - - /* Configure DMA Rx parameters */ - dma_rx_handle.Init.Channel = SD_DMAx_Rx_CHANNEL; - dma_rx_handle.Init.Direction = DMA_PERIPH_TO_MEMORY; - dma_rx_handle.Init.PeriphInc = DMA_PINC_DISABLE; - dma_rx_handle.Init.MemInc = DMA_MINC_ENABLE; - dma_rx_handle.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; - dma_rx_handle.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; - dma_rx_handle.Init.Mode = DMA_PFCTRL; - dma_rx_handle.Init.Priority = DMA_PRIORITY_VERY_HIGH; - dma_rx_handle.Init.FIFOMode = DMA_FIFOMODE_ENABLE; - dma_rx_handle.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; - dma_rx_handle.Init.MemBurst = DMA_MBURST_INC4; - dma_rx_handle.Init.PeriphBurst = DMA_PBURST_INC4; - - dma_rx_handle.Instance = SD_DMAx_Rx_STREAM; - - /* Associate the DMA handle */ - __HAL_LINKDMA(hsd, hdmarx, dma_rx_handle); - - /* Deinitialize the stream for new transfer */ - HAL_DMA_DeInit(&dma_rx_handle); - - /* Configure the DMA stream */ - HAL_DMA_Init(&dma_rx_handle); - - /* Configure DMA Tx parameters */ - dma_tx_handle.Init.Channel = SD_DMAx_Tx_CHANNEL; - dma_tx_handle.Init.Direction = DMA_MEMORY_TO_PERIPH; - dma_tx_handle.Init.PeriphInc = DMA_PINC_DISABLE; - dma_tx_handle.Init.MemInc = DMA_MINC_ENABLE; - dma_tx_handle.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; - dma_tx_handle.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; - dma_tx_handle.Init.Mode = DMA_PFCTRL; - dma_tx_handle.Init.Priority = DMA_PRIORITY_VERY_HIGH; - dma_tx_handle.Init.FIFOMode = DMA_FIFOMODE_ENABLE; - dma_tx_handle.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; - dma_tx_handle.Init.MemBurst = DMA_MBURST_INC4; - dma_tx_handle.Init.PeriphBurst = DMA_PBURST_INC4; - - dma_tx_handle.Instance = SD_DMAx_Tx_STREAM; - - /* Associate the DMA handle */ - __HAL_LINKDMA(hsd, hdmatx, dma_tx_handle); - - /* Deinitialize the stream for new transfer */ - HAL_DMA_DeInit(&dma_tx_handle); - - /* Configure the DMA stream */ - HAL_DMA_Init(&dma_tx_handle); - - /* NVIC configuration for DMA transfer complete interrupt */ - HAL_NVIC_SetPriority(SD_DMAx_Rx_IRQn, 6, 0); - HAL_NVIC_EnableIRQ(SD_DMAx_Rx_IRQn); - - /* NVIC configuration for DMA transfer complete interrupt */ - HAL_NVIC_SetPriority(SD_DMAx_Tx_IRQn, 6, 0); - HAL_NVIC_EnableIRQ(SD_DMAx_Tx_IRQn); -} - -/** - * @brief DeInitializes the SD MSP. - * @param hsd: SD handle - * @param Params : pointer on additional configuration parameters, can be NULL. - */ -__weak void BSP_SD_MspDeInit(SD_HandleTypeDef *hsd, void *Params) -{ - static DMA_HandleTypeDef dma_rx_handle; - static DMA_HandleTypeDef dma_tx_handle; - - /* Disable NVIC for DMA transfer complete interrupts */ - HAL_NVIC_DisableIRQ(SD_DMAx_Rx_IRQn); - HAL_NVIC_DisableIRQ(SD_DMAx_Tx_IRQn); - - /* Deinitialize the stream for new transfer */ - dma_rx_handle.Instance = SD_DMAx_Rx_STREAM; - HAL_DMA_DeInit(&dma_rx_handle); - - /* Deinitialize the stream for new transfer */ - dma_tx_handle.Instance = SD_DMAx_Tx_STREAM; - HAL_DMA_DeInit(&dma_tx_handle); - - /* Disable NVIC for SDIO interrupts */ - HAL_NVIC_DisableIRQ(SDIO_IRQn); - - /* DeInit GPIO pins can be done in the application - (by surcharging this __weak function) */ - - /* Disable SDIO clock */ - __HAL_RCC_SDIO_CLK_DISABLE(); - - /* GPOI pins clock and DMA cloks can be shut down in the applic - by surcgarging this __weak function */ -} - -/** - * @brief Handles SD card interrupt request. - */ -void BSP_SD_IRQHandler(void) -{ - HAL_SD_IRQHandler(&uSdHandle); -} - -/** - * @brief Handles SD DMA Tx transfer interrupt request. - */ -void BSP_SD_DMA_Tx_IRQHandler(void) -{ - HAL_DMA_IRQHandler(uSdHandle.hdmatx); -} - -/** - * @brief Handles SD DMA Rx transfer interrupt request. - */ -void BSP_SD_DMA_Rx_IRQHandler(void) -{ - HAL_DMA_IRQHandler(uSdHandle.hdmarx); -} - -/** - * @brief Gets the current SD card data status. - * @retval Data transfer state. - * This value can be one of the following values: - * @arg SD_TRANSFER_OK: No data transfer is acting - * @arg SD_TRANSFER_BUSY: Data transfer is acting - * @arg SD_TRANSFER_ERROR: Data transfer error - */ -HAL_SD_TransferStateTypedef BSP_SD_GetStatus(void) -{ - return(HAL_SD_GetStatus(&uSdHandle)); -} - -/** - * @brief Get SD information about specific SD card. - * @param CardInfo: Pointer to HAL_SD_CardInfoTypedef structure - */ -void BSP_SD_GetCardInfo(HAL_SD_CardInfoTypedef *CardInfo) -{ - /* Get SD card Information */ - HAL_SD_Get_CardInfo(&uSdHandle, CardInfo); -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_sd.h b/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_sd.h deleted file mode 100644 index a81d563e05..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_sd.h +++ /dev/null @@ -1,159 +0,0 @@ -/** - ****************************************************************************** - * @file stm32469i_eval_sd.h - * @author MCD Application Team - * @version V1.0.1 - * @date 29-September-2015 - * @brief This file contains the common defines and functions prototypes for - * the stm32469i_eval_sd.c driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32469I_EVAL_SD_H -#define __STM32469I_EVAL_SD_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm32469i_eval.h" -#include "stm32469i_eval_io.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32469I-EVAL - * @{ - */ - -/** @defgroup STM32469I-EVAL_SD STM32469I-EVAL SD - * @{ - */ - -/** @defgroup STM32469I-EVAL_SD_Exported_Types SD Exported Types - * @{ - */ - -/** - * @brief SD Card information structure - */ -#define SD_CardInfo HAL_SD_CardInfoTypedef -/** - * @} - */ - -/** - * @brief SD status structure definition - */ -#define MSD_OK ((uint8_t)0x00) -#define MSD_ERROR ((uint8_t)0x01) -#define MSD_ERROR_SD_NOT_PRESENT ((uint8_t)0x02) - -/** @defgroup STM32469I-EVAL_SD_Exported_Constants SD Exported Constants - * @{ - */ -#define SD_PRESENT ((uint8_t)0x01) -#define SD_NOT_PRESENT ((uint8_t)0x00) - -#define SD_DATATIMEOUT ((uint32_t)100000000) - -/* DMA definitions for SD DMA transfer */ -#define __DMAx_TxRx_CLK_ENABLE __HAL_RCC_DMA2_CLK_ENABLE -#define SD_DMAx_Tx_CHANNEL DMA_CHANNEL_4 -#define SD_DMAx_Rx_CHANNEL DMA_CHANNEL_4 -#define SD_DMAx_Tx_STREAM DMA2_Stream6 -#define SD_DMAx_Rx_STREAM DMA2_Stream3 -#define SD_DMAx_Tx_IRQn DMA2_Stream6_IRQn -#define SD_DMAx_Rx_IRQn DMA2_Stream3_IRQn -#define SD_DMAx_Tx_IRQHandler DMA2_Stream6_IRQHandler -#define SD_DMAx_Rx_IRQHandler DMA2_Stream3_IRQHandler -#define SD_DetectIRQHandler() HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_8) -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_SD_Exported_Macro STM32469I EVAL SD Exported Macro - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_SD_Exported_Functions STM32469I EVAL SD Exported Functions - * @{ - */ -uint8_t BSP_SD_Init(void); -uint8_t BSP_SD_DeInit(void); -uint8_t BSP_SD_ITConfig(void); -void BSP_SD_DetectIT(void); -void BSP_SD_DetectCallback(void); -uint8_t BSP_SD_ReadBlocks(uint32_t *pData, uint64_t ReadAddr, uint32_t BlockSize, uint32_t NumOfBlocks); -uint8_t BSP_SD_WriteBlocks(uint32_t *pData, uint64_t WriteAddr, uint32_t BlockSize, uint32_t NumOfBlocks); -uint8_t BSP_SD_ReadBlocks_DMA(uint32_t *pData, uint64_t ReadAddr, uint32_t BlockSize, uint32_t NumOfBlocks); -uint8_t BSP_SD_WriteBlocks_DMA(uint32_t *pData, uint64_t WriteAddr, uint32_t BlockSize, uint32_t NumOfBlocks); -uint8_t BSP_SD_Erase(uint64_t StartAddr, uint64_t EndAddr); -void BSP_SD_IRQHandler(void); -void BSP_SD_DMA_Tx_IRQHandler(void); -void BSP_SD_DMA_Rx_IRQHandler(void); -HAL_SD_TransferStateTypedef BSP_SD_GetStatus(void); -void BSP_SD_GetCardInfo(HAL_SD_CardInfoTypedef *CardInfo); -uint8_t BSP_SD_IsDetected(void); - -/* These function can be modified in case the current settings (e.g. DMA stream) - need to be changed for specific application needs */ -void BSP_SD_MspInit(SD_HandleTypeDef *hsd, void *Params); -void BSP_SD_MspDeInit(SD_HandleTypeDef *hsd, void *Params); - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32469I_EVAL_SD_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_sdram.c b/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_sdram.c deleted file mode 100644 index f0b412cadd..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_sdram.c +++ /dev/null @@ -1,524 +0,0 @@ -/** - ****************************************************************************** - * @file stm32469i_eval_sdram.c - * @author MCD Application Team - * @version V1.0.1 - * @date 29-September-2015 - * @brief This file includes the SDRAM driver for the MT48LC4M32B2B5-7 memory - * device mounted on STM32469I-EVAL evaluation board. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* File Info : ----------------------------------------------------------------- - User NOTES -1. How To use this driver: --------------------------- - - This driver is used to drive the MT48LC4M32B2B5-7 SDRAM external memory mounted - on STM32469I-EVAL evaluation board. - - This driver does not need a specific component driver for the SDRAM device - to be included with. - -2. Driver description: ---------------------- - + Initialization steps: - o Initialize the SDRAM external memory using the BSP_SDRAM_Init() function. This - function includes the MSP layer hardware resources initialization and the - FMC controller configuration to interface with the external SDRAM memory. - o It contains the SDRAM initialization sequence to program the SDRAM external - device using the function BSP_SDRAM_Initialization_sequence(). Note that this - sequence is standard for all SDRAM devices, but can include some differences - from a device to another. If it is the case, the right sequence should be - implemented separately. - - + SDRAM read/write operations - o SDRAM external memory can be accessed with read/write operations once it is - initialized. - Read/write operation can be performed with AHB access using the functions - BSP_SDRAM_ReadData()/BSP_SDRAM_WriteData(), or by DMA transfer using the functions - BSP_SDRAM_ReadData_DMA()/BSP_SDRAM_WriteData_DMA(). - o The AHB access is performed with 32-bit width transaction, the DMA transfer - configuration is fixed at single (no burst) word transfer (see the - BSP_SDRAM_MspInit() weak function). - o User can implement his own functions for read/write access with his desired - configurations. - o If interrupt mode is used for DMA transfer, the function BSP_SDRAM_DMA_IRQHandler() - is called in IRQ handler file, to serve the generated interrupt once the DMA - transfer is complete. - o You can send a command to the SDRAM device in runtime using the function - BSP_SDRAM_Sendcmd(), and giving the desired command as parameter chosen between - the predefined commands of the "FMC_SDRAM_CommandTypeDef" structure. - -------------------------------------------------------------------------------*/ - -/* Includes ------------------------------------------------------------------*/ -#include "stm32469i_eval_sdram.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32469I-EVAL - * @{ - */ - -/** @defgroup STM32469I-EVAL_SDRAM SDRAM - * @{ - */ - -/** @defgroup STM32469I-EVAL_SDRAM_Private_Types_Definitions STM32469I Eval SDRAM Private TypesDef - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_SDRAM_Private_Defines STM32469I Eval SDRAM Private Defines - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_SDRAM_Private_Macros STM32469I Eval SDRAM Private Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_SDRAM_Private_Variables STM32469I Eval SDRAM Private Variables - * @{ - */ -static SDRAM_HandleTypeDef sdramHandle; -static FMC_SDRAM_TimingTypeDef Timing; -static FMC_SDRAM_CommandTypeDef Command; -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_SDRAM_Private_Function_Prototypes STM32469I Eval SDRAM Private Prototypes - * @{ - */ - -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_SDRAM_Private_Functions STM32469I Eval SDRAM Private Functions - * @{ - */ - -/** - * @} - */ - -/** @defgroup STM32469I_EVAL_SDRAM_Exported_Functions STM32469I EVAL SDRAM Exported Functions - * @{ - */ - -/** - * @brief Initializes the SDRAM device. - * @retval SDRAM status - */ -uint8_t BSP_SDRAM_Init(void) -{ - static uint8_t sdramstatus = SDRAM_ERROR; - - /* SDRAM device configuration */ - sdramHandle.Instance = FMC_SDRAM_DEVICE; - - /* Timing configuration for 90 MHz as SD clock frequency (System clock is up to 180 MHz) */ - Timing.LoadToActiveDelay = 2; /* TMRD: 2 Clock cycles */ - Timing.ExitSelfRefreshDelay = 7; /* TXSR: min=70ns (7x11.11ns) */ - Timing.SelfRefreshTime = 4; /* TRAS: min=42ns (4x11.11ns) max=120k (ns) */ - Timing.RowCycleDelay = 7; /* TRC: min=70 (7x11.11ns) */ - Timing.WriteRecoveryTime = 2; /* TWR: min=1+ 7ns (1+1x11.11ns) */ - Timing.RPDelay = 2; /* TRP: 20ns => 2x11.11ns */ - Timing.RCDDelay = 2; /* TRCD: 20ns => 2x11.11ns */ - - sdramHandle.Init.SDBank = FMC_SDRAM_BANK1; - sdramHandle.Init.ColumnBitsNumber = FMC_SDRAM_COLUMN_BITS_NUM_8; - sdramHandle.Init.RowBitsNumber = FMC_SDRAM_ROW_BITS_NUM_11; - sdramHandle.Init.MemoryDataWidth = SDRAM_MEMORY_WIDTH; - sdramHandle.Init.InternalBankNumber = FMC_SDRAM_INTERN_BANKS_NUM_4; - sdramHandle.Init.CASLatency = FMC_SDRAM_CAS_LATENCY_3; - sdramHandle.Init.WriteProtection = FMC_SDRAM_WRITE_PROTECTION_DISABLE; - sdramHandle.Init.SDClockPeriod = SDCLOCK_PERIOD; - sdramHandle.Init.ReadBurst = FMC_SDRAM_RBURST_ENABLE; - sdramHandle.Init.ReadPipeDelay = FMC_SDRAM_RPIPE_DELAY_0; - - /* SDRAM controller initialization */ - /* __weak function can be surcharged by the application code */ - BSP_SDRAM_MspInit(&sdramHandle, (void *)NULL); - if(HAL_SDRAM_Init(&sdramHandle, &Timing) != HAL_OK) - { - sdramstatus = SDRAM_ERROR; - } - else - { - sdramstatus = SDRAM_OK; - } - - /* SDRAM initialization sequence */ - BSP_SDRAM_Initialization_sequence(REFRESH_COUNT); - - return sdramstatus; -} - -/** - * @brief DeInitializes the SDRAM device. - * @retval SDRAM status : SDRAM_OK or SDRAM_ERROR. - */ -uint8_t BSP_SDRAM_DeInit(void) -{ - static uint8_t sdramstatus = SDRAM_ERROR; - - /* SDRAM device configuration */ - sdramHandle.Instance = FMC_SDRAM_DEVICE; - - if(HAL_SDRAM_DeInit(&sdramHandle) == HAL_OK) - { - sdramstatus = SDRAM_OK; - - /* SDRAM controller De-initialization */ - BSP_SDRAM_MspDeInit(&sdramHandle, (void *)NULL); - } - - return sdramstatus; -} - - -/** - * @brief Programs the SDRAM device. - * @param RefreshCount: SDRAM refresh counter value - */ -void BSP_SDRAM_Initialization_sequence(uint32_t RefreshCount) -{ - __IO uint32_t tmpmrd = 0; - - /* Step 1: Configure a clock configuration enable command */ - Command.CommandMode = FMC_SDRAM_CMD_CLK_ENABLE; - Command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1; - Command.AutoRefreshNumber = 1; - Command.ModeRegisterDefinition = 0; - - /* Send the command */ - HAL_SDRAM_SendCommand(&sdramHandle, &Command, SDRAM_TIMEOUT); - - /* Step 2: Insert 100 us minimum delay */ - /* Inserted delay is equal to 1 ms due to systick time base unit (ms) */ - HAL_Delay(1); - - /* Step 3: Configure a PALL (precharge all) command */ - Command.CommandMode = FMC_SDRAM_CMD_PALL; - Command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1; - Command.AutoRefreshNumber = 1; - Command.ModeRegisterDefinition = 0; - - /* Send the command */ - HAL_SDRAM_SendCommand(&sdramHandle, &Command, SDRAM_TIMEOUT); - - /* Step 4: Configure an Auto Refresh command */ - Command.CommandMode = FMC_SDRAM_CMD_AUTOREFRESH_MODE; - Command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1; - Command.AutoRefreshNumber = 8; - Command.ModeRegisterDefinition = 0; - - /* Send the command */ - HAL_SDRAM_SendCommand(&sdramHandle, &Command, SDRAM_TIMEOUT); - - /* Step 5: Program the external memory mode register */ - tmpmrd = (uint32_t)SDRAM_MODEREG_BURST_LENGTH_1 |\ - SDRAM_MODEREG_BURST_TYPE_SEQUENTIAL |\ - SDRAM_MODEREG_CAS_LATENCY_3 |\ - SDRAM_MODEREG_OPERATING_MODE_STANDARD |\ - SDRAM_MODEREG_WRITEBURST_MODE_SINGLE; - - Command.CommandMode = FMC_SDRAM_CMD_LOAD_MODE; - Command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1; - Command.AutoRefreshNumber = 1; - Command.ModeRegisterDefinition = tmpmrd; - - /* Send the command */ - HAL_SDRAM_SendCommand(&sdramHandle, &Command, SDRAM_TIMEOUT); - - /* Step 6: Set the refresh rate counter */ - /* Set the device refresh rate */ - HAL_SDRAM_ProgramRefreshRate(&sdramHandle, RefreshCount); -} - -/** - * @brief Reads an mount of data from the SDRAM memory in polling mode. - * @param uwStartAddress: Read start address - * @param pData: Pointer to data to be read - * @param uwDataSize: Size of read data from the memory - * @retval SDRAM status : SDRAM_OK or SDRAM_ERROR. - */ -uint8_t BSP_SDRAM_ReadData(uint32_t uwStartAddress, uint32_t *pData, uint32_t uwDataSize) -{ - if(HAL_SDRAM_Read_32b(&sdramHandle, (uint32_t *)uwStartAddress, pData, uwDataSize) != HAL_OK) - { - return SDRAM_ERROR; - } - else - { - return SDRAM_OK; - } -} - -/** - * @brief Reads an mount of data from the SDRAM memory in DMA mode. - * @param uwStartAddress: Read start address - * @param pData: Pointer to data to be read - * @param uwDataSize: Size of read data from the memory - * @retval SDRAM status : SDRAM_OK or SDRAM_ERROR. - */ -uint8_t BSP_SDRAM_ReadData_DMA(uint32_t uwStartAddress, uint32_t *pData, uint32_t uwDataSize) -{ - if(HAL_SDRAM_Read_DMA(&sdramHandle, (uint32_t *)uwStartAddress, pData, uwDataSize) != HAL_OK) - { - return SDRAM_ERROR; - } - else - { - return SDRAM_OK; - } -} - -/** - * @brief Writes an mount of data to the SDRAM memory in polling mode. - * @param uwStartAddress: Write start address - * @param pData: Pointer to data to be written - * @param uwDataSize: Size of written data from the memory - * @retval SDRAM status : SDRAM_OK or SDRAM_ERROR. - */ -uint8_t BSP_SDRAM_WriteData(uint32_t uwStartAddress, uint32_t *pData, uint32_t uwDataSize) -{ - if(HAL_SDRAM_Write_32b(&sdramHandle, (uint32_t *)uwStartAddress, pData, uwDataSize) != HAL_OK) - { - return SDRAM_ERROR; - } - else - { - return SDRAM_OK; - } -} - -/** - * @brief Writes an mount of data to the SDRAM memory in DMA mode. - * @param uwStartAddress: Write start address - * @param pData: Pointer to data to be written - * @param uwDataSize: Size of written data from the memory - * @retval SDRAM status : SDRAM_OK or SDRAM_ERROR. - */ -uint8_t BSP_SDRAM_WriteData_DMA(uint32_t uwStartAddress, uint32_t *pData, uint32_t uwDataSize) -{ - if(HAL_SDRAM_Write_DMA(&sdramHandle, (uint32_t *)uwStartAddress, pData, uwDataSize) != HAL_OK) - { - return SDRAM_ERROR; - } - else - { - return SDRAM_OK; - } -} - -/** - * @brief Sends command to the SDRAM bank. - * @param SdramCmd: Pointer to SDRAM command structure - * @retval HAL status : SDRAM_OK or SDRAM_ERROR. - */ -uint8_t BSP_SDRAM_Sendcmd(FMC_SDRAM_CommandTypeDef *SdramCmd) -{ - if(HAL_SDRAM_SendCommand(&sdramHandle, SdramCmd, SDRAM_TIMEOUT) != HAL_OK) - { - return SDRAM_ERROR; - } - else - { - return SDRAM_OK; - } -} - -/** - * @brief Handles SDRAM DMA transfer interrupt request. - */ -void BSP_SDRAM_DMA_IRQHandler(void) -{ - HAL_DMA_IRQHandler(sdramHandle.hdma); -} - -/** - * @brief Initializes SDRAM MSP. - * @note This function can be surcharged by application code. - * @param hsdram: pointer on SDRAM handle - * @param Params: pointer on additional configuration parameters, can be NULL. - */ -__weak void BSP_SDRAM_MspInit(SDRAM_HandleTypeDef *hsdram, void *Params) -{ - static DMA_HandleTypeDef dma_handle; - GPIO_InitTypeDef gpio_init_structure; - - if(hsdram != (SDRAM_HandleTypeDef *)NULL) - { - /* Enable FMC clock */ - __HAL_RCC_FMC_CLK_ENABLE(); - - /* Enable chosen DMAx clock */ - __DMAx_CLK_ENABLE(); - - /* Enable GPIOs clock */ - __HAL_RCC_GPIOD_CLK_ENABLE(); - __HAL_RCC_GPIOE_CLK_ENABLE(); - __HAL_RCC_GPIOF_CLK_ENABLE(); - __HAL_RCC_GPIOG_CLK_ENABLE(); - __HAL_RCC_GPIOH_CLK_ENABLE(); - __HAL_RCC_GPIOI_CLK_ENABLE(); - - /* Common GPIO configuration */ - gpio_init_structure.Mode = GPIO_MODE_AF_PP; - gpio_init_structure.Pull = GPIO_PULLUP; - gpio_init_structure.Speed = GPIO_SPEED_FAST; - gpio_init_structure.Alternate = GPIO_AF12_FMC; - - /* GPIOD configuration */ - gpio_init_structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_8| GPIO_PIN_9 | GPIO_PIN_10 |\ - GPIO_PIN_14 | GPIO_PIN_15; - - - HAL_GPIO_Init(GPIOD, &gpio_init_structure); - - /* GPIOE configuration */ - gpio_init_structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_7| GPIO_PIN_8 | GPIO_PIN_9 |\ - GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 |\ - GPIO_PIN_15; - - HAL_GPIO_Init(GPIOE, &gpio_init_structure); - - /* GPIOF configuration */ - gpio_init_structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2| GPIO_PIN_3 | GPIO_PIN_4 |\ - GPIO_PIN_5 | GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 |\ - GPIO_PIN_15; - - HAL_GPIO_Init(GPIOF, &gpio_init_structure); - - /* GPIOG configuration */ - gpio_init_structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_4| GPIO_PIN_5 | GPIO_PIN_8 |\ - GPIO_PIN_15; - HAL_GPIO_Init(GPIOG, &gpio_init_structure); - - /* GPIOH configuration */ - gpio_init_structure.Pin = GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_5 | GPIO_PIN_8 | GPIO_PIN_9 |\ - GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 |\ - GPIO_PIN_15; - HAL_GPIO_Init(GPIOH, &gpio_init_structure); - - /* GPIOI configuration */ - gpio_init_structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 |\ - GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7 | GPIO_PIN_9 | GPIO_PIN_10; - HAL_GPIO_Init(GPIOI, &gpio_init_structure); - - /* Configure common DMA parameters */ - dma_handle.Init.Channel = SDRAM_DMAx_CHANNEL; - dma_handle.Init.Direction = DMA_MEMORY_TO_MEMORY; - dma_handle.Init.PeriphInc = DMA_PINC_ENABLE; - dma_handle.Init.MemInc = DMA_MINC_ENABLE; - dma_handle.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; - dma_handle.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; - dma_handle.Init.Mode = DMA_NORMAL; - dma_handle.Init.Priority = DMA_PRIORITY_HIGH; - dma_handle.Init.FIFOMode = DMA_FIFOMODE_DISABLE; - dma_handle.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; - dma_handle.Init.MemBurst = DMA_MBURST_SINGLE; - dma_handle.Init.PeriphBurst = DMA_PBURST_SINGLE; - - dma_handle.Instance = SDRAM_DMAx_STREAM; - - /* Associate the DMA handle */ - __HAL_LINKDMA(hsdram, hdma, dma_handle); - - /* Deinitialize the stream for new transfer */ - HAL_DMA_DeInit(&dma_handle); - - /* Configure the DMA stream */ - HAL_DMA_Init(&dma_handle); - - /* NVIC configuration for DMA transfer complete interrupt */ - HAL_NVIC_SetPriority(SDRAM_DMAx_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(SDRAM_DMAx_IRQn); - - } /* of if(hsdram != (SDRAM_HandleTypeDef *)NULL) */ -} - -/** - * @brief DeInitializes SDRAM MSP. - * @note This function can be surcharged by application code. - * @param hsdram: pointer on SDRAM handle - * @param Params: pointer on additional configuration parameters, can be NULL. - */ -__weak void BSP_SDRAM_MspDeInit(SDRAM_HandleTypeDef *hsdram, void *Params) -{ - static DMA_HandleTypeDef dma_handle; - - if(hsdram != (SDRAM_HandleTypeDef *)NULL) - { - /* Disable NVIC configuration for DMA interrupt */ - HAL_NVIC_DisableIRQ(SDRAM_DMAx_IRQn); - - /* Deinitialize the stream for new transfer */ - dma_handle.Instance = SDRAM_DMAx_STREAM; - HAL_DMA_DeInit(&dma_handle); - - /* DeInit GPIO pins can be done in the application - (by surcharging this __weak function) */ - - /* GPIO pins clock, FMC clock and DMA clock can be shut down in the application - by surcharging this __weak function */ - - } /* of if(hsdram != (SDRAM_HandleTypeDef *)NULL) */ -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_sdram.h b/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_sdram.h deleted file mode 100644 index 068fe001bf..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_sdram.h +++ /dev/null @@ -1,163 +0,0 @@ -/** - ****************************************************************************** - * @file stm32469i_eval_sdram.h - * @author MCD Application Team - * @version V1.0.1 - * @date 29-September-2015 - * @brief This file contains the common defines and functions prototypes for - * the stm32469i_eval_sdram.c driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32469I_EVAL_SDRAM_H -#define __STM32469I_EVAL_SDRAM_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm32f4xx_hal.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32469I-EVAL - * @{ - */ - -/** @addtogroup STM32469I-EVAL_SDRAM - * @{ - */ - -/** @defgroup STM32469I-EVAL_SDRAM_Exported_Types STM32469I EVAL SDRAM Exported Types - * @{ - */ - -/** - * @brief SDRAM status structure definition - */ -#define SDRAM_OK ((uint8_t)0x00) -#define SDRAM_ERROR ((uint8_t)0x01) - -/** @defgroup STM32469I-EVAL_SDRAM_Exported_Constants STM32469I EVAL SDRAM Exported Constants - * @{ - */ -#define SDRAM_DEVICE_ADDR ((uint32_t)0xC0000000) - - /* SDRAM device size in MBytes */ - #define SDRAM_DEVICE_SIZE ((uint32_t)0x800000) - -#define SDRAM_MEMORY_WIDTH FMC_SDRAM_MEM_BUS_WIDTH_32 -#define SDCLOCK_PERIOD FMC_SDRAM_CLOCK_PERIOD_2 - -/* SDRAM refresh counter (90 MHz SD clock) */ -#define REFRESH_COUNT ((uint32_t)0x0569) -#define SDRAM_TIMEOUT ((uint32_t)0xFFFF) - -/* DMA definitions for SDRAM DMA transfer */ -#define __DMAx_CLK_ENABLE __HAL_RCC_DMA2_CLK_ENABLE -#define __DMAx_CLK_DISABLE __HAL_RCC_DMA2_CLK_DISABLE -#define SDRAM_DMAx_CHANNEL DMA_CHANNEL_0 -#define SDRAM_DMAx_STREAM DMA2_Stream0 -#define SDRAM_DMAx_IRQn DMA2_Stream0_IRQn -#define SDRAM_DMAx_IRQHandler DMA2_Stream0_IRQHandler -/** - * @} - */ - -/** - * @brief FMC SDRAM Mode definition register defines - */ -#define SDRAM_MODEREG_BURST_LENGTH_1 ((uint16_t)0x0000) -#define SDRAM_MODEREG_BURST_LENGTH_2 ((uint16_t)0x0001) -#define SDRAM_MODEREG_BURST_LENGTH_4 ((uint16_t)0x0002) -#define SDRAM_MODEREG_BURST_LENGTH_8 ((uint16_t)0x0004) -#define SDRAM_MODEREG_BURST_TYPE_SEQUENTIAL ((uint16_t)0x0000) -#define SDRAM_MODEREG_BURST_TYPE_INTERLEAVED ((uint16_t)0x0008) -#define SDRAM_MODEREG_CAS_LATENCY_2 ((uint16_t)0x0020) -#define SDRAM_MODEREG_CAS_LATENCY_3 ((uint16_t)0x0030) -#define SDRAM_MODEREG_OPERATING_MODE_STANDARD ((uint16_t)0x0000) -#define SDRAM_MODEREG_WRITEBURST_MODE_PROGRAMMED ((uint16_t)0x0000) -#define SDRAM_MODEREG_WRITEBURST_MODE_SINGLE ((uint16_t)0x0200) -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_SDRAM_Exported_Macro STM32469I EVAL SDRAM Exported Macro - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_SDRAM_Exported_Functions STM32469I EVAL SDRAM Exported Functions - * @{ - */ -uint8_t BSP_SDRAM_Init(void); -uint8_t BSP_SDRAM_DeInit(void); -void BSP_SDRAM_Initialization_sequence(uint32_t RefreshCount); -uint8_t BSP_SDRAM_ReadData(uint32_t uwStartAddress, uint32_t *pData, uint32_t uwDataSize); -uint8_t BSP_SDRAM_ReadData_DMA(uint32_t uwStartAddress, uint32_t *pData, uint32_t uwDataSize); -uint8_t BSP_SDRAM_WriteData(uint32_t uwStartAddress, uint32_t *pData, uint32_t uwDataSize); -uint8_t BSP_SDRAM_WriteData_DMA(uint32_t uwStartAddress, uint32_t *pData, uint32_t uwDataSize); -uint8_t BSP_SDRAM_Sendcmd(FMC_SDRAM_CommandTypeDef *SdramCmd); -void BSP_SDRAM_DMA_IRQHandler(void); - -/* These function can be modified in case the current settings (e.g. DMA stream) - need to be changed for specific application needs */ -void BSP_SDRAM_MspInit(SDRAM_HandleTypeDef *hsdram, void *Params); -void BSP_SDRAM_MspDeInit(SDRAM_HandleTypeDef *hsdram, void *Params); - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32469I_EVAL_SDRAM_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_sram.c b/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_sram.c deleted file mode 100644 index e7c41da091..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_sram.c +++ /dev/null @@ -1,420 +0,0 @@ -/** - ****************************************************************************** - * @file stm32469i_eval_sram.c - * @author MCD Application Team - * @version V1.0.1 - * @date 29-September-2015 - * @brief This file includes the SRAM driver for the IS61WV102416BLL-10M memory - * device mounted on STM32469I-EVAL evaluation board. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* File Info : ----------------------------------------------------------------- - User NOTES -1. How To use this driver: --------------------------- - - This driver is used to drive the IS61WV102416BLL-10M SRAM external memory mounted - on STM32469I-EVAL evaluation board. - - This driver does not need a specific component driver for the SRAM device - to be included with. - -2. Driver description: ---------------------- - + Initialization steps: - o Initialize the SRAM external memory using the BSP_SRAM_Init() function. This - function includes the MSP layer hardware resources initialization and the - FMC controller configuration to interface with the external SRAM memory. - - + SRAM read/write operations - o SRAM external memory can be accessed with read/write operations once it is - initialized. - Read/write operation can be performed with AHB access using the functions - BSP_SRAM_ReadData()/BSP_SRAM_WriteData(), or by DMA transfer using the functions - BSP_SRAM_ReadData_DMA()/BSP_SRAM_WriteData_DMA(). - o The AHB access is performed with 16-bit width transaction, the DMA transfer - configuration is fixed at single (no burst) halfword transfer - (see the BSP_SRAM_MspInit() __weak function). This function BSP_SRAM_MspInit() - can be surcharged by application code above BSP. - o User can implement his own functions for read/write access with his desired - configurations. - o If interrupt mode is used for DMA transfer, the function BSP_SRAM_DMA_IRQHandler() - is called in IRQ handler file, to serve the generated interrupt once the DMA - transfer is complete. - -------------------------------------------------------------------------------*/ - -/* Includes ------------------------------------------------------------------*/ -#include "stm32469i_eval_sram.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32469I-EVAL - * @{ - */ - -/** @defgroup STM32469I-EVAL_SRAM STM32469I-EVAL SRAM - * @{ - */ - -/** @defgroup STM32469I-EVAL_SRAM_Private_Types_Definitions STM32469I-EVAL SRAM Private Types Definitions - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_SRAM_Private_Defines STM32469I-EVAL Private Defines - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_SRAM_Private_Macros STM32469I-EVAL Private Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_SRAM_Private_Variables STM32469I-EVAL Private Variables - * @{ - */ -static SRAM_HandleTypeDef sramHandle; -static FMC_NORSRAM_TimingTypeDef Timing; -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_SRAM_Private_Function_Prototypes STM32469I-EVAL Private Function Prototypes - * @{ - */ - -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_SRAM_Private_Functions STM32469I-EVAL Private Functions - * @{ - */ - -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_SRAM_Exported_Functions STM32469I-EVAL Exported Functions - * @{ - */ - -/** - * @brief Initializes the SRAM device. - * @retval SRAM status - */ -uint8_t BSP_SRAM_Init(void) -{ - sramHandle.Instance = FMC_NORSRAM_DEVICE; - sramHandle.Extended = FMC_NORSRAM_EXTENDED_DEVICE; - - /* SRAM device configuration */ - Timing.AddressSetupTime = 2; - Timing.AddressHoldTime = 1; - Timing.DataSetupTime = 2; - Timing.BusTurnAroundDuration = 1; - Timing.CLKDivision = 2; - Timing.DataLatency = 2; - Timing.AccessMode = FMC_ACCESS_MODE_A; - - sramHandle.Init.NSBank = FMC_NORSRAM_BANK2; - sramHandle.Init.DataAddressMux = FMC_DATA_ADDRESS_MUX_DISABLE; - sramHandle.Init.MemoryType = FMC_MEMORY_TYPE_SRAM; - sramHandle.Init.MemoryDataWidth = SRAM_MEMORY_WIDTH; - sramHandle.Init.BurstAccessMode = SRAM_BURSTACCESS; - sramHandle.Init.WaitSignalPolarity = FMC_WAIT_SIGNAL_POLARITY_LOW; - sramHandle.Init.WrapMode = FMC_WRAP_MODE_DISABLE; - sramHandle.Init.WaitSignalActive = FMC_WAIT_TIMING_BEFORE_WS; - sramHandle.Init.WriteOperation = FMC_WRITE_OPERATION_ENABLE; - sramHandle.Init.WaitSignal = FMC_WAIT_SIGNAL_DISABLE; - sramHandle.Init.ExtendedMode = FMC_EXTENDED_MODE_DISABLE; - sramHandle.Init.AsynchronousWait = FMC_ASYNCHRONOUS_WAIT_DISABLE; - sramHandle.Init.WriteBurst = SRAM_WRITEBURST; - sramHandle.Init.ContinuousClock = CONTINUOUSCLOCK_FEATURE; - - /* SRAM controller initialization */ - /* __weak function can be surcharged by the application code */ - BSP_SRAM_MspInit(&sramHandle, (void*)NULL); - if(HAL_SRAM_Init(&sramHandle, &Timing, &Timing) != HAL_OK) - { - return SRAM_ERROR; - } - else - { - return SRAM_OK; - } -} - -/** - * @brief DeInitializes the SRAM device. - * @retval SRAM status : SRAM_OK or SRAM_ERROR. - */ -uint8_t BSP_SRAM_DeInit(void) -{ - static uint8_t sramstatus = SRAM_ERROR; - - /* SRAM device configuration */ - sramHandle.Instance = FMC_NORSRAM_DEVICE; - - if(HAL_SRAM_DeInit(&sramHandle) == HAL_OK) - { - sramstatus = SRAM_OK; - - /* SRAM controller De-initialization */ - BSP_SRAM_MspDeInit(&sramHandle, (void *)NULL); - } - - return sramstatus; -} - -/** - * @brief Reads an amount of data from the SRAM device in polling mode. - * @param uwStartAddress: Read start address - * @param pData: Pointer to data to be read - * @param uwDataSize: Size of read data from the memory - * @retval SRAM status : SRAM_OK or SRAM_ERROR. - */ -uint8_t BSP_SRAM_ReadData(uint32_t uwStartAddress, uint16_t *pData, uint32_t uwDataSize) -{ - if(HAL_SRAM_Read_16b(&sramHandle, (uint32_t *)uwStartAddress, pData, uwDataSize) != HAL_OK) - { - return SRAM_ERROR; - } - else - { - return SRAM_OK; - } -} - -/** - * @brief Reads an amount of data from the SRAM device in DMA mode. - * @param uwStartAddress: Read start address - * @param pData: Pointer to data to be read - * @param uwDataSize: Size of read data from the memory - * @retval SRAM status : SRAM_OK or SRAM_ERROR. - */ -uint8_t BSP_SRAM_ReadData_DMA(uint32_t uwStartAddress, uint16_t *pData, uint32_t uwDataSize) -{ - if(HAL_SRAM_Read_DMA(&sramHandle, (uint32_t *)uwStartAddress, (uint32_t *)pData, uwDataSize) != HAL_OK) - { - return SRAM_ERROR; - } - else - { - return SRAM_OK; - } -} - -/** - * @brief Writes an amount of data from the SRAM device in polling mode. - * @param uwStartAddress: Write start address - * @param pData: Pointer to data to be written - * @param uwDataSize: Size of written data from the memory - * @retval SRAM status : SRAM_OK or SRAM_ERROR. - */ -uint8_t BSP_SRAM_WriteData(uint32_t uwStartAddress, uint16_t *pData, uint32_t uwDataSize) -{ - if(HAL_SRAM_Write_16b(&sramHandle, (uint32_t *)uwStartAddress, pData, uwDataSize) != HAL_OK) - { - return SRAM_ERROR; - } - else - { - return SRAM_OK; - } -} - -/** - * @brief Writes an amount of data from the SRAM device in DMA mode. - * @param uwStartAddress: Write start address - * @param pData: Pointer to data to be written - * @param uwDataSize: Size of written data from the memory - * @retval SRAM status : SRAM_OK or SRAM_ERROR. - */ -uint8_t BSP_SRAM_WriteData_DMA(uint32_t uwStartAddress, uint16_t *pData, uint32_t uwDataSize) -{ - if(HAL_SRAM_Write_DMA(&sramHandle, (uint32_t *)uwStartAddress, (uint32_t *)pData, uwDataSize) != HAL_OK) - { - return SRAM_ERROR; - } - else - { - return SRAM_OK; - } -} - -/** - * @brief Handles SRAM DMA transfer interrupt request. - */ -void BSP_SRAM_DMA_IRQHandler(void) -{ - HAL_DMA_IRQHandler(sramHandle.hdma); -} - -/** - * @brief Initializes SRAM MSP. - * @note This function can be surcharged by application code. - * @param hsram : pointer on SRAM handle - * @param Params : pointer on additional configuration parameters, can be NULL. - */ -__weak void BSP_SRAM_MspInit(SRAM_HandleTypeDef *hsram, void *Params) -{ - static DMA_HandleTypeDef dma_handle; - GPIO_InitTypeDef gpio_init_structure; - - if(hsram != (SRAM_HandleTypeDef *)NULL) - { - /* Enable FMC clock */ - __HAL_RCC_FMC_CLK_ENABLE(); - - /* Enable chosen DMAx clock */ - __SRAM_DMAx_CLK_ENABLE(); - - /* Enable GPIOs clock */ - __HAL_RCC_GPIOD_CLK_ENABLE(); - __HAL_RCC_GPIOE_CLK_ENABLE(); - __HAL_RCC_GPIOF_CLK_ENABLE(); - __HAL_RCC_GPIOG_CLK_ENABLE(); - - /* Common GPIO configuration */ - gpio_init_structure.Mode = GPIO_MODE_AF_PP; - gpio_init_structure.Pull = GPIO_PULLUP; - gpio_init_structure.Speed = GPIO_SPEED_HIGH; - gpio_init_structure.Alternate = GPIO_AF12_FMC; - - /* GPIOD configuration */ - gpio_init_structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_8 |\ - GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13 |\ - GPIO_PIN_14 | GPIO_PIN_15; - HAL_GPIO_Init(GPIOD, &gpio_init_structure); - - /* GPIOE configuration */ - gpio_init_structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_3| GPIO_PIN_4 | GPIO_PIN_7 |\ - GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12 |\ - GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15; - HAL_GPIO_Init(GPIOE, &gpio_init_structure); - - /* GPIOF configuration */ - gpio_init_structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2| GPIO_PIN_3 | GPIO_PIN_4 |\ - GPIO_PIN_5 | GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15; - HAL_GPIO_Init(GPIOF, &gpio_init_structure); - - /* GPIOG configuration */ - gpio_init_structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2| GPIO_PIN_3 | GPIO_PIN_4 |\ - GPIO_PIN_5 | GPIO_PIN_9; - HAL_GPIO_Init(GPIOG, &gpio_init_structure); - - /* Configure common DMA parameters */ - dma_handle.Init.Channel = SRAM_DMAx_CHANNEL; - dma_handle.Init.Direction = DMA_MEMORY_TO_MEMORY; - dma_handle.Init.PeriphInc = DMA_PINC_ENABLE; - dma_handle.Init.MemInc = DMA_MINC_ENABLE; - dma_handle.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD; - dma_handle.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD; - dma_handle.Init.Mode = DMA_NORMAL; - dma_handle.Init.Priority = DMA_PRIORITY_HIGH; - dma_handle.Init.FIFOMode = DMA_FIFOMODE_DISABLE; - dma_handle.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; - dma_handle.Init.MemBurst = DMA_MBURST_SINGLE; - dma_handle.Init.PeriphBurst = DMA_PBURST_SINGLE; - - dma_handle.Instance = SRAM_DMAx_STREAM; - - /* Associate the DMA handle */ - __HAL_LINKDMA(hsram, hdma, dma_handle); - - /* Deinitialize the Stream for new transfer */ - HAL_DMA_DeInit(&dma_handle); - - /* Configure the DMA Stream */ - HAL_DMA_Init(&dma_handle); - - /* NVIC configuration for DMA transfer complete interrupt */ - HAL_NVIC_SetPriority(SRAM_DMAx_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(SRAM_DMAx_IRQn); - - } /* of if(hsram != (SRAM_HandleTypeDef *)NULL) */ -} - -/** - * @brief DeInitializes SRAM MSP. - * @note This function can be surcharged by application code. - * @param hsram : pointer on SRAM handle - * @param Params: pointer on additional configuration parameters, can be NULL. - * @retval None - */ -__weak void BSP_SRAM_MspDeInit(SRAM_HandleTypeDef *hsram, void *Params) -{ - static DMA_HandleTypeDef dma_handle; - - if(hsram != (SRAM_HandleTypeDef *)NULL) - { - /* Disable NVIC configuration for DMA interrupt */ - HAL_NVIC_DisableIRQ(SRAM_DMAx_IRQn); - - /* Deinitialize the stream for new transfer */ - dma_handle.Instance = SRAM_DMAx_STREAM; - HAL_DMA_DeInit(&dma_handle); - - /* DeInit GPIO pins can be done in the application - (by surcharging this __weak function) */ - - /* GPIO pins clock, FMC clock and DMA clock can be shut down in the application - by surcharging this __weak function */ - - } /* of if(hsram != (SRAM_HandleTypeDef *)NULL) */ -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_sram.h b/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_sram.h deleted file mode 100644 index b590e5221e..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_sram.h +++ /dev/null @@ -1,143 +0,0 @@ -/** - ****************************************************************************** - * @file stm32469i_eval_sram.h - * @author MCD Application Team - * @version V1.0.1 - * @date 29-September-2015 - * @brief This file contains the common defines and functions prototypes for - * the stm32469i_eval_sram.c driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32469I_EVAL_SRAM_H -#define __STM32469I_EVAL_SRAM_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm32f4xx_hal.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32469I-EVAL - * @{ - */ - -/** @addtogroup STM32469I-EVAL_SRAM - * @{ - */ - -/** @defgroup STM32469I-EVAL_SRAM_Exported_Types STM32469I EVAL SRAM Exported Types - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_SRAM_Exported_Constants STM32469I EVAL SRAM Exported Constants - * @{ - */ - -#define SRAM_OK ((uint8_t)0x00) -#define SRAM_ERROR ((uint8_t)0x01) - -#define SRAM_DEVICE_ADDR ((uint32_t)0x64000000) - - /* SRAM device size in MBytes */ -#define SRAM_DEVICE_SIZE ((uint32_t)0x200000) - -#define SRAM_MEMORY_WIDTH FMC_NORSRAM_MEM_BUS_WIDTH_16 -#define SRAM_BURSTACCESS FMC_BURST_ACCESS_MODE_DISABLE -#define SRAM_WRITEBURST FMC_WRITE_BURST_DISABLE -#define CONTINUOUSCLOCK_FEATURE FMC_CONTINUOUS_CLOCK_SYNC_ONLY - -/* DMA definitions for SRAM DMA transfer */ -#define __SRAM_DMAx_CLK_ENABLE __HAL_RCC_DMA2_CLK_ENABLE -#define __SRAM_DMAx_CLK_DISABLE __HAL_RCC_DMA2_CLK_DISABLE -#define SRAM_DMAx_CHANNEL DMA_CHANNEL_0 -#define SRAM_DMAx_STREAM DMA2_Stream4 -#define SRAM_DMAx_IRQn DMA2_Stream4_IRQn -#define SRAM_DMAx_IRQHandler DMA2_Stream4_IRQHandler -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_SRAM_Exported_Macro STM32469I EVAL SRAM Exported Macro - * @{ - */ -/** - * @} - */ - -/** @addtogroup STM32469I-EVAL_SRAM_Exported_Functions - * @{ - */ -uint8_t BSP_SRAM_Init(void); -uint8_t BSP_SRAM_DeInit(void); -uint8_t BSP_SRAM_ReadData(uint32_t uwStartAddress, uint16_t *pData, uint32_t uwDataSize); -uint8_t BSP_SRAM_ReadData_DMA(uint32_t uwStartAddress, uint16_t *pData, uint32_t uwDataSize); -uint8_t BSP_SRAM_WriteData(uint32_t uwStartAddress, uint16_t *pData, uint32_t uwDataSize); -uint8_t BSP_SRAM_WriteData_DMA(uint32_t uwStartAddress, uint16_t *pData, uint32_t uwDataSize); -void BSP_SRAM_DMA_IRQHandler(void); - -/* These function can be modified in case the current settings (e.g. DMA stream) - need to be changed for specific application needs */ -void BSP_SRAM_MspInit(SRAM_HandleTypeDef *hsram, void *Params); -void BSP_SRAM_MspDeInit(SRAM_HandleTypeDef *hsram, void *Params); - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32469I_EVAL_SRAM_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_ts.c b/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_ts.c deleted file mode 100644 index 05c42500ff..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_ts.c +++ /dev/null @@ -1,489 +0,0 @@ -/** - ****************************************************************************** - * @file stm32469i_eval_ts.c - * @author MCD Application Team - * @version V1.0.1 - * @date 29-September-2015 - * @brief This file provides a set of functions needed to manage the Touch - * Screen on STM32469I-EVAL evaluation board. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* File Info : ----------------------------------------------------------------- - User NOTES -1. How To use this driver: --------------------------- - - This driver is used to drive the touch screen module of the STM32469I-EVAL - evaluation board on the K.O.D Optica Technology 480x800 TFT-LCD mounted on - MB1166 daughter board. The touch screen driver IC inside the K.O.D module KM-040TMP-02 - is a FT6206 by Focal Tech. - -2. Driver description: ---------------------- - + Initialization steps: - o Initialize the TS module using the BSP_TS_Init() function. This - function includes the MSP layer hardware resources initialization and the - communication layer configuration to start the TS use. The LCD size properties - (x and y) are passed as parameters. - o If TS interrupt mode is desired, you must configure the TS interrupt mode - by calling the function BSP_TS_ITConfig(). The TS interrupt mode is generated - as an external interrupt whenever a touch is detected. - The interrupt mode internally uses the IO functionalities driver driven by - the IO expander, to configure the IT line. - - + Touch screen use - o The touch screen state is captured whenever the function BSP_TS_GetState() is - used. This function returns information about the last LCD touch occurred - in the TS_StateTypeDef structure. - o If TS interrupt mode is used, the function BSP_TS_ITGetStatus() is needed to get - the interrupt status. To clear the IT pending bits, you should call the - function BSP_TS_ITClear(). - o The IT is handled using the corresponding external interrupt IRQ handler, - the user IT callback treatment is implemented on the same external interrupt - callback. - -------------------------------------------------------------------------------*/ - -/* Includes ------------------------------------------------------------------*/ -#include "stm32469i_eval.h" -#include "stm32469i_eval_ts.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32469I-EVAL - * @{ - */ - -/** @defgroup STM32469I-EVAL_TS STM32469I-EVAL TS - * @{ - */ - -/** @defgroup STM32469I-EVAL_TS_Private_Types_Definitions TS Private Types Definitions - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_TS_Private_Defines TS Private Types Defines - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_TS_Private_Macros TS Private Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_TS_Imported_Variables TS Imported Variables - * @{ - */ - /** - * @} - */ - -/** @defgroup STM32469I-EVAL_TS_Private_Variables TS Private Variables - * @{ - */ -static TS_DrvTypeDef *ts_driver; -static uint8_t ts_orientation; -static uint8_t I2C_Address = 0; - -/* Table for touchscreen event information display on LCD : table indexed on enum @ref TS_TouchEventTypeDef information */ -char * ts_event_string_tab[TOUCH_EVENT_NB_MAX] = { "None", - "Press down", - "Lift up", - "Contact" - }; - -/* Table for touchscreen gesture Id information display on LCD : table indexed on enum @ref TS_GestureIdTypeDef information */ -char * ts_gesture_id_string_tab[GEST_ID_NB_MAX] = { "None", - "Move Up", - "Move Right", - "Move Down", - "Move Left", - "Zoom In", - "Zoom Out" - }; - -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_TS_Private_Function_Prototypes TS Private Function Prototypes - * @{ - */ - -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_TS_Public_Functions TS Public Functions - * @{ - */ - -/** - * @brief Initializes and configures the touch screen functionalities and - * configures all necessary hardware resources (GPIOs, I2C, clocks..). - * @param ts_SizeX : Maximum X size of the TS area on LCD - * @param ts_SizeY : Maximum Y size of the TS area on LCD - * @retval TS_OK if all initializations are OK. Other value if error. - */ -uint8_t BSP_TS_Init(uint16_t ts_SizeX, uint16_t ts_SizeY) -{ - uint8_t ts_status = TS_OK; - - /* Note : I2C_Address is un-initialized here, but is not used at all in init function */ - /* but the prototype of Init() is like that in template and should be respected */ - - /* Initialize the communication channel to sensor (I2C) if necessary */ - /* that is initialization is done only once after a power up */ - ft6x06_ts_drv.Init(I2C_Address); - - /* Scan FT6x06 TouchScreen IC controller ID register by I2C Read */ - /* Verify this is a FT6x06, otherwise this is an error case */ - if(ft6x06_ts_drv.ReadID(TS_I2C_ADDRESS) == FT6206_ID_VALUE) - { - /* Found FT6206 : Initialize the TS driver structure */ - ts_driver = &ft6x06_ts_drv; - - I2C_Address = TS_I2C_ADDRESS; - - /* Get LCD chosen orientation */ - if(ts_SizeX < ts_SizeY) - { - ts_orientation = TS_SWAP_NONE; - } - else - { - ts_orientation = TS_SWAP_XY | TS_SWAP_Y; - } - - if(ts_status == TS_OK) - { - /* Software reset the TouchScreen */ - ts_driver->Reset(I2C_Address); - - /* Calibrate, Configure and Start the TouchScreen driver */ - ts_driver->Start(I2C_Address); - - } /* of if(ts_status == TS_OK) */ - } - else - { - ts_status = TS_DEVICE_NOT_FOUND; - } - - return (ts_status); -} - -/** - * @brief Configures and enables the touch screen interrupts. - * @retval TS_OK if all initializations are OK. Other value if error. - */ -uint8_t BSP_TS_ITConfig(void) -{ - uint8_t ts_status = TS_ERROR; - uint8_t io_status = IO_ERROR; - - /* Initialize the IO */ - io_status = BSP_IO_Init(); - if(io_status != IO_OK) - { - return (ts_status); - } - - /* Configure TS IT line IO : is active low on FT6206 (see data sheet) */ - /* Configure TS_INT_PIN (MFX_IO_14) low level to generate MFX_IRQ_OUT in EXTI on MCU */ - /* This will call HAL_GPIO_EXTI_Callback() that is setting variable 'mfx_exti_received' to 1b1' */ - io_status = BSP_IO_ConfigPin(TS_INT_PIN, IO_MODE_IT_LOW_LEVEL_PU); - if(io_status != IO_OK) - { - return (ts_status); - } - - /* Enable the TS in interrupt mode */ - /* In that case the INT output of FT6206 when new touch is available */ - /* is active low and directed on MFX IO14 */ - ts_driver->EnableIT(I2C_Address); - - /* If arrived here : set good status on exit */ - ts_status = TS_OK; - - return (ts_status); -} - -/** - * @brief Gets the touch screen interrupt status. - * @retval TS_IRQ_PENDING if touchscreen IRQ is pending, TS_NO_IRQ_PENDING when no IRQ TS is pending. - */ -uint8_t BSP_TS_ITGetStatus(void) -{ - uint8_t itStatus = TS_NO_IRQ_PENDING; /* By default no IRQ TS pending */ - uint32_t mfx_irq_status = 0; /* No MFX IRQ by default */ - - /* Check status of MFX_IO14 in particular which is the Touch Screen INT pin active low */ - mfx_irq_status = BSP_IO_ITGetStatus(TS_INT_PIN); - if(mfx_irq_status != 0) /* Note : returned mfx_irq_status = 0x4000 == (1<touchDetected = ts_driver->DetectTouch(I2C_Address); - if(TS_State->touchDetected) - { - for(index=0; index < TS_State->touchDetected; index++) - { - /* Get each touch coordinates */ - ts_driver->GetXY(I2C_Address, &(Raw_x[index]), &(Raw_y[index])); - - if(ts_orientation & TS_SWAP_XY) - { - tmp = Raw_x[index]; - Raw_x[index] = Raw_y[index]; - Raw_y[index] = tmp; - } - - if(ts_orientation & TS_SWAP_X) - { - Raw_x[index] = FT_6206_MAX_WIDTH - 1 - Raw_x[index]; - } - - if(ts_orientation & TS_SWAP_Y) - { - Raw_y[index] = FT_6206_MAX_HEIGHT - 1 - Raw_y[index]; - } - - xDiff = Raw_x[index] > _x[index]? (Raw_x[index] - _x[index]): (_x[index] - Raw_x[index]); - yDiff = Raw_y[index] > _y[index]? (Raw_y[index] - _y[index]): (_y[index] - Raw_y[index]); - - if ((xDiff + yDiff) > 5) - { - _x[index] = Raw_x[index]; - _y[index] = Raw_y[index]; - } - - - TS_State->touchX[index] = _x[index]; - TS_State->touchY[index] = _y[index]; - -#if (TS_MULTI_TOUCH_SUPPORTED == 1) - - /* Get touch info related to the current touch */ - ft6x06_TS_GetTouchInfo(I2C_Address, index, &weight, &area, &event); - - /* Update TS_State structure */ - TS_State->touchWeight[index] = weight; - TS_State->touchArea[index] = area; - - /* Remap touch event */ - switch(event) - { - case FT6206_TOUCH_EVT_FLAG_PRESS_DOWN : - TS_State->touchEventId[index] = TOUCH_EVENT_PRESS_DOWN; - break; - case FT6206_TOUCH_EVT_FLAG_LIFT_UP : - TS_State->touchEventId[index] = TOUCH_EVENT_LIFT_UP; - break; - case FT6206_TOUCH_EVT_FLAG_CONTACT : - TS_State->touchEventId[index] = TOUCH_EVENT_CONTACT; - break; - case FT6206_TOUCH_EVT_FLAG_NO_EVENT : - TS_State->touchEventId[index] = TOUCH_EVENT_NO_EVT; - break; - default : - ts_status = TS_ERROR; - break; - } /* of switch(event) */ - -#endif /* TS_MULTI_TOUCH_SUPPORTED == 1 */ - - } /* of for(index=0; index < TS_State->touchDetected; index++) */ - -#if (TS_MULTI_TOUCH_SUPPORTED == 1) - /* Get gesture Id */ - ts_status = BSP_TS_Get_GestureId(TS_State); -#endif /* TS_MULTI_TOUCH_SUPPORTED == 1 */ - - } /* end of if(TS_State->touchDetected != 0) */ - - return (ts_status); -} - -#if (TS_MULTI_TOUCH_SUPPORTED == 1) -/** - * @brief Update gesture Id following a touch detected. - * @param TS_State: Pointer to touch screen current state structure - * @retval TS_OK if all initializations are OK. Other value if error. - */ -uint8_t BSP_TS_Get_GestureId(TS_StateTypeDef *TS_State) -{ - uint32_t gestureId = 0; - uint8_t ts_status = TS_OK; - - /* Get gesture Id */ - ft6x06_TS_GetGestureID(I2C_Address, &gestureId); - - /* Remap gesture Id to a TS_GestureIdTypeDef value */ - switch(gestureId) - { - case FT6206_GEST_ID_NO_GESTURE : - TS_State->gestureId = GEST_ID_NO_GESTURE; - break; - case FT6206_GEST_ID_MOVE_UP : - TS_State->gestureId = GEST_ID_MOVE_UP; - break; - case FT6206_GEST_ID_MOVE_RIGHT : - TS_State->gestureId = GEST_ID_MOVE_RIGHT; - break; - case FT6206_GEST_ID_MOVE_DOWN : - TS_State->gestureId = GEST_ID_MOVE_DOWN; - break; - case FT6206_GEST_ID_MOVE_LEFT : - TS_State->gestureId = GEST_ID_MOVE_LEFT; - break; - case FT6206_GEST_ID_ZOOM_IN : - TS_State->gestureId = GEST_ID_ZOOM_IN; - break; - case FT6206_GEST_ID_ZOOM_OUT : - TS_State->gestureId = GEST_ID_ZOOM_OUT; - break; - default : - ts_status = TS_ERROR; - break; - } /* of switch(gestureId) */ - - return(ts_status); -} -#endif /* TS_MULTI_TOUCH_SUPPORTED == 1 */ - - -/** - * @brief Clears all touch screen interrupts. - */ -void BSP_TS_ITClear(void) -{ - /* Clear TS_INT_PIN IRQ in MFX */ - BSP_IO_ITClearPin(TS_INT_PIN); -} - - -/** @defgroup STM32469I-EVAL_TS_Private_Functions TS Private Functions - * @{ - */ - -#if (TS_MULTI_TOUCH_SUPPORTED == 1) -/** - * @brief Function used to reset all touch data before a new acquisition - * of touch information. - * @param TS_State: Pointer to touch screen current state structure - * @retval TS_OK if OK, TE_ERROR if problem found. - */ -uint8_t BSP_TS_ResetTouchData(TS_StateTypeDef *TS_State) -{ - uint8_t ts_status = TS_ERROR; - uint32_t index; - - if (TS_State != (TS_StateTypeDef *)NULL) - { - TS_State->gestureId = GEST_ID_NO_GESTURE; - TS_State->touchDetected = 0; - - for(index = 0; index < TS_MAX_NB_TOUCH; index++) - { - TS_State->touchX[index] = 0; - TS_State->touchY[index] = 0; - TS_State->touchArea[index] = 0; - TS_State->touchEventId[index] = TOUCH_EVENT_NO_EVT; - TS_State->touchWeight[index] = 0; - } - - ts_status = TS_OK; - - } /* of if (TS_State != (TS_StateTypeDef *)NULL) */ - - return (ts_status); -} -#endif /* TS_MULTI_TOUCH_SUPPORTED == 1 */ -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_ts.h b/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_ts.h deleted file mode 100644 index 80d5cc726d..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32469I_EVAL/stm32469i_eval_ts.h +++ /dev/null @@ -1,212 +0,0 @@ -/** - ****************************************************************************** - * @file stm32469i_eval_ts.h - * @author MCD Application Team - * @version V1.0.1 - * @date 29-September-2015 - * @brief This file contains the common defines and functions prototypes for - * the stm32469i_eval_ts.c driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32469I_EVAL_TS_H -#define __STM32469I_EVAL_TS_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm32469i_eval.h" -#include "stm32469i_eval_lcd.h" -#include "stm32469i_eval_io.h" - -/* Include TouchScreen component driver */ -#include "../Components/ft6x06/ft6x06.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32469I-EVAL - * @{ - */ - -/** @defgroup STM32469I-EVAL_TS STM32469I-EVAL TS - * @{ - */ - - /** @defgroup STM32469I-EVAL_TS_Exported_Constants TS Exported Constants - * @{ - */ -/** @brief With FT6206 : maximum 2 touches detected simultaneously - */ -#define TS_MAX_NB_TOUCH ((uint32_t) FT6206_MAX_DETECTABLE_TOUCH) - -#define TS_NO_IRQ_PENDING ((uint8_t) 0) -#define TS_IRQ_PENDING ((uint8_t) 1) - -#define TS_SWAP_NONE ((uint8_t) 0x01) -#define TS_SWAP_X ((uint8_t) 0x02) -#define TS_SWAP_Y ((uint8_t) 0x04) -#define TS_SWAP_XY ((uint8_t) 0x08) - - /** - * @} - */ - -/** @defgroup STM32469I-EVAL_TS_Exported_Types TS Exported Types - * @{ - */ -/** -* @brief TS_StateTypeDef -* Define TS State structure -*/ -typedef struct -{ - uint8_t touchDetected; /*!< Total number of active touches detected at last scan */ - uint16_t touchX[TS_MAX_NB_TOUCH]; /*!< Touch X[0], X[1] coordinates on 12 bits */ - uint16_t touchY[TS_MAX_NB_TOUCH]; /*!< Touch Y[0], Y[1] coordinates on 12 bits */ - -#if (TS_MULTI_TOUCH_SUPPORTED == 1) - uint8_t touchWeight[TS_MAX_NB_TOUCH]; /*!< Touch_Weight[0], Touch_Weight[1] : weight property of touches */ - uint8_t touchEventId[TS_MAX_NB_TOUCH]; /*!< Touch_EventId[0], Touch_EventId[1] : take value of type @ref TS_TouchEventTypeDef */ - uint8_t touchArea[TS_MAX_NB_TOUCH]; /*!< Touch_Area[0], Touch_Area[1] : touch area of each touch */ - uint32_t gestureId; /*!< type of gesture detected : take value of type @ref TS_GestureIdTypeDef */ -#endif /* TS_MULTI_TOUCH_SUPPORTED == 1 */ - -} TS_StateTypeDef; - -/** - * @brief TS_StatusTypeDef - * Define BSP_TS_xxx() functions possible return value, - * when status is returned by those functions. - */ -typedef enum -{ - TS_OK = 0x00, /*!< Touch Ok */ - TS_ERROR = 0x01, /*!< Touch Error */ - TS_TIMEOUT = 0x02, /*!< Touch Timeout */ - TS_DEVICE_NOT_FOUND = 0x03 /*!< Touchscreen device not found */ -} TS_StatusTypeDef; - -/** - * @brief TS_GestureIdTypeDef - * Define Possible managed gesture identification values returned by touch screen - * driver. - */ -typedef enum -{ - GEST_ID_NO_GESTURE = 0x00, /*!< Gesture not defined / recognized */ - GEST_ID_MOVE_UP = 0x01, /*!< Gesture Move Up */ - GEST_ID_MOVE_RIGHT = 0x02, /*!< Gesture Move Right */ - GEST_ID_MOVE_DOWN = 0x03, /*!< Gesture Move Down */ - GEST_ID_MOVE_LEFT = 0x04, /*!< Gesture Move Left */ - GEST_ID_ZOOM_IN = 0x05, /*!< Gesture Zoom In */ - GEST_ID_ZOOM_OUT = 0x06, /*!< Gesture Zoom Out */ - GEST_ID_NB_MAX = 0x07 /*!< max number of gesture id */ -} TS_GestureIdTypeDef; - -/** - * @brief TS_TouchEventTypeDef - * Define Possible touch events kind as returned values - * by touch screen IC Driver. - */ -typedef enum -{ - TOUCH_EVENT_NO_EVT = 0x00, /*!< Touch Event : undetermined */ - TOUCH_EVENT_PRESS_DOWN = 0x01, /*!< Touch Event Press Down */ - TOUCH_EVENT_LIFT_UP = 0x02, /*!< Touch Event Lift Up */ - TOUCH_EVENT_CONTACT = 0x03, /*!< Touch Event Contact */ - TOUCH_EVENT_NB_MAX = 0x04 /*!< max number of touch events kind */ -} TS_TouchEventTypeDef; - -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_TS_Imported_Variables STM32469I EVAL TS Imported Variables - * @{ - */ -/** - * @brief Table for touchscreen event information display on LCD : - * table indexed on enum @ref TS_TouchEventTypeDef information - */ -extern char * ts_event_string_tab[TOUCH_EVENT_NB_MAX]; - -/** - * @brief Table for touchscreen gesture Id information display on LCD : table indexed - * on enum @ref TS_GestureIdTypeDef information - */ -extern char * ts_gesture_id_string_tab[GEST_ID_NB_MAX]; -/** - * @} - */ - -/** @defgroup STM32469I-EVAL_TS_Exported_Functions TS Exported Functions - * @{ - */ -uint8_t BSP_TS_Init(uint16_t ts_SizeX, uint16_t ts_SizeY); -uint8_t BSP_TS_GetState(TS_StateTypeDef *TS_State); - -#if (TS_MULTI_TOUCH_SUPPORTED == 1) -uint8_t BSP_TS_Get_GestureId(TS_StateTypeDef *TS_State); -uint8_t BSP_TS_ResetTouchData(TS_StateTypeDef *TS_State); -#endif /* TS_MULTI_TOUCH_SUPPORTED == 1 */ - -uint8_t BSP_TS_ITConfig(void); -uint8_t BSP_TS_ITGetStatus(void); -void BSP_TS_ITClear(void); - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32469I_EVAL_TS_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/Release_Notes.html b/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/Release_Notes.html deleted file mode 100644 index 469f3bdc5e..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/Release_Notes.html +++ /dev/null @@ -1,813 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - Release Notes for STM324x9I_EVAL Evaluation Board Drivers - - - - - - - - - - -
-


-

-
- - - - - - -
- - - - - - - - - -
-

Back to Release page

-
-

Release -Notes for STM324x9I_EVAL Evaluation Board Drivers

-

Copyright -2015 STMicroelectronics

-

-
-

 

- - - - - - -
- - -

Update History

-

V2.2.1 / 07-October-2015

Main -Changes

- - - - - -
  • stm324x9i_eval.c/.h
    • Rework LCD initialization to ensure refresh rate of 60Hz.
      • Add new API "BSP_LCD_InitEx(uint32_t PclkConfig)" to propoerly manage LTCD pixel clock configuration.
      • Update "BSP_LCD_Init" to call new API BSP_LCD_InitEx().
      • Add LCD_MAX_PCLK/LCD_MIN_PCLK defines.
      • Add BSP_LCD_InitEx() function prototype.
    • Update VBP and HBP values used to calculate AccumulatedActiveH and AccumulatedActiveW for AMPIRE 480x272
  • stm324x9i_eval_ts.c: 
    • Update BSP_TS_GetState() to return correct values of Touch Screen status and positions.

V2.2.0 / 14-August-2015

Main -Changes

- - - - - -
  • stm324x9i_eval.c
    • Add AUDIO_IO_DeInit() function to align with Common V4.0.0
  • stm324x9i _eval_audio.c
    • Remove CODEC_Reset() function 

V2.1.0 / 26-June-2015

Main -Changes

- - - - - -
  • stm324x9i_eval.c/.h
    • Update to support new 5.7" VGA LCD (AM640480FTNQW-T07H-A)
      • Update I2Cx_ReadMultiple() API  to considers  the multiple read of the exc7200 touch screen position
      • Add BSP_TS3510_IsDetected() API to detect which LCD is mounted on the board
      • In header file, add new defines for ts3510 and exc7200 touch screen components I2C addresses
  • stm324x9i _eval_ts.c/.h
    • Update to support new 5.7" VGA LCD (AM640480FTNQW-T07H-A)
      • Update BSP_TS_Init() API to initialize the connected LCD device
      • Update BSP_TS_GetState() API to calculate the (x,y) position for the mounted LCD device
      • In header file, update to include the new touch screen component driver (exc7200)
  • stm324x9i _eval_sdram.c/.h
    • Update -BSP_SDRAM_Init() API to set the right column bits number configuration -according to the IS42S32800(ISSI) component available on -the board 

V2.0.4 / 03-March-2015

Main -Changes

- - - - - -
  • stm324x9i_eval.c/.h
    • Align to STM32F4xx HAL Driver V1.3.0 for __HAL_RCC_PPP_CLK_ENABLE()
  • stm324x9i _eval_audio.c/.h
    • BSP_AUDIO_OUT_Play()/BSP_AUDIO_OUT_ChangeBuffer() add cast uint8_t on -data pointer: update according to the HAL SAI  driver update -to support companding mode which works only with data type on 8-bits.
  • stm324x9i _eval_lcd.c
    • BSP_LCD_Init() update to check if DATA_IN_ExtSDRAM is enabled or not to avoid the re-initialization for SDRAM interface.

V2.0.3 / 10-December-2014

- - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
  • stm324x9i_eval.c/.h
  • -
      -
    • Change I2C_SPEED used define by BSP_I2C_SPEED
    • -
    -
  • stm324x9i_eval_camera.c
  • -
      -
    • BSP_CAMERA_Init(): -Update the Initialization and Stop APIs to set and reset the STANDBY -pin (to avoid conflict with SDCard detect pin)
      -
    • -
    -
  • stm324x9i_eval_camera.h, -stm324x9i_eval_audio.h, stm324x9i_eval_eeprom.h, stm324x9i_eval_io.h, -stm324x9i_eval_ts.h and stm324x9i_eval_lcd.c/.h
    -
  • -
      -
    • Change "\" by "/" in the include path to fix compilation issue under Linux
    • -
    -
  • stm324x9i_eval_nor.c/.h
    -
  • -
      -
    • Change NOR status definition NOR_OK and NOR_ERROR by NOR_STATUS_OK and NOR_STATUS_ERROR, respectively
      -
    • -
    -
  • stm324x9i_eval_sdram.c
  • -
      -
    • BSP_SDRAM_Initialization_sequence(): Fix wrong configuration of the burst length
    • -
    -
  • Miscellaneous comments update
  • -
- -

V2.0.2 / 19-June-2014

- - - - - - - - - - - - - - - - - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
  • stm324x9i_eval.c/.h
  • -
      -
    • Add protection for double initialization of IO_Init within LCD_IO_Init()
    • -
    -
      -
    • Enhance BSP_PB_Init() function by removing the call of __SYSCFG_CLK_ENABLE() already enabled in the HAL_GPIO_Init()
    • -
    -
  • stm324x9i _eval_audio.c/.h
  • -
      -
    • Add note that only the audio stereo format is supported
    • -
    -
  • stm324x9i_eval_sd.c/.h
  • -
      -
    • Ensure -compatibility with the updated version of FatFs sd_diskio driver (i.e. -FatFs R0.10 ST modified 20140422) supporting SDIO/SPI to interface uSD
    • -
    -
  • stm324x9i_eval_lcd.c/.h
  • -
      -
    • Update LCD clock configuration of 5.7" screen to avoid flicker effect within BSP_LCD_Init()
    • -
    -
      -
    • Comments clean up and typo corrections
    • -
    -
- - -

V2.0.1 / 26-February-2014

- - - - - - - - - - - - - - - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
  • stm324x9i_eval_sd.c/.h
  • -
      -
    • Update SD_DATATIMEOUT value
    • -
    - -
  • stm324x9i_eval_eeprom.c/.h
  • -
      -
    • Update usage of BSP_EEPROM_TIMEOUT_UserCallback() function
    • -
    -
- - -

V2.0.0 / 18-February-2014

- - - - - - - - - - - - - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
  • Major update -based on STM32Cube specification: drivers architecture and APIs -modified vs. V1.0.3, and thus the 2 versions are not compatible.
    -
  • This version has to be used only with STM32CubeF4 based development
  • -
-
    - - -
-

V1.0.3 / 13-November-2013

-

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - -
    -
  • stm324x9i_eval_ioe8.c/.h
    • Enhance the Touch panel detection in IOE_TS_GetState() function : Add a check on FIFO Threshold value before reading X and Y position
    -
-

Known -Limitations

- -
    -
  • stm324x9i_eval_audio_codec.c/.h
    • If -2 audio streams are played in TDM format (the first stream is -configured in codec SLOT0 and second stream in codec SLOT1) the -Pause/Resume, Volume Control and Mute action will apply on both streams.
    -
- -

V1.0.2 / 08-November-2013

-

Main -Changes

- - - -
    -
  • stm324x9i_eval_lcd.c
    • Update  BUFFER_OFFSET define -value from 0x130000 to 0x12C000 and comment to explain how to compute this value
    • LCD_DeInit() function: remove SDRAM pins configuration, this is done in SDRAM driver
    • LCD_Init() function: in case where AMPIRE 640x480 LCD is used, add a call to LCD_I2C_Config() to initialize I2C for touch panel usage
    • Update and optimize LCD_Clear() function
    • Update and optimize putPixel() function: -write directly to the SDRAM instead of the use of LCD_DrawLine() function
    • GetPosition() function: add more comments in the header about the format of the data returned by this function
    • GetPosition() function: remove the I2C configuration (it's already done in LCD_Init() function)
    • LCD_CheckDevice() function: replace LCD_I2C_Config() by -IOE_Config()
    • LCD_I2C_Config() function: add a test, if I2C is already configured, then there is no need to reconfigure it again
    -
- - - - - - - - - - - - - - - - - - - - - - -
    -
  • stm324x9i_eval_ioe8.c/.h
    • Remove EXTI line configuration macros 
    • Remove -VERIFY_WRITTENDATA macro, and remove verify written data block from I2C_WriteDeviceRegister() function
    -
- - - - - - -
    -
  • stm324x9i_eval_ioe16.c/.h
    • Remove -VERIFY_WRITTENDATA macro, and remove verify written data block from IOE16_I2C_WriteDeviceRegister() function
    -
-
    -
  • stm324x9i_eval_audio_codec.c/.h
    • In Audio_MAL_IRQHandler() Remove -local variables pAddr and Size and replace them by existing global variables -CurrentPos and AudioRemSize
    -
-

Known -Limitations

- -
    -
  • stm324x9i_eval_audio_codec.c/.h
    • If -2 audio streams are played in TDM format (the first stream is -configured in codec SLOT0 and second stream in codec SLOT1) the -Pause/Resume, Volume Control and Mute action will apply on both streams.
    -
-

V1.0.1 / 11-October-2013

-

Main -Changes

- - - -
    -
  • stm324x9i_eval_lcd.c
    • Update -LCD_DisplayOff() function : Remove GPIO PA8 and PC6 configuration in -low level, as we don't need to configure any more these GPIO w/ -STM32x9I-EVAL Boards RevB
    • Add comments for LCD_GetPosition() and  LCD_CheckDevice function  
  • stm324x9i_eval_ioe8.c/.h
    • Update IOE_TS_GetState() function : Enhance the TS detection algorithm
    • Update IOE_TS_Config() -function : Update IOE FIFO threshold register value to 0x01 -instead of 0x0F and update touch screen operation mode register value -to 0x01 instead of 0x03
    • Add condition in IOE_GPIO_Config() and IOE_I2C_Config() functions to prevent I2C and its GPIOs reconfiguration
    • Update I2C_ReadDataBuffer() function: remove check at "I2C_FLAG_BUSY" in the beginning of the function
  • stm324x9i_eval_ioe16.c/.h
    • Add condition in IOE16_GPIO_Config() and IOE16_I2C_Config() functions to prevent I2C and its GPIOs reconfiguration
    -
-

Known -Limitations

- -
    -
  • stm324x9i_eval_audio_codec.c/.h
    • If -2 audio streams are played in TDM format (the first stream is -configured in codec SLOT0 and second stream in codec SLOT1) the -Pause/Resume, Volume Control and Mute action will apply on both streams.
    -
-

V1.0.0 / 19-September-2013

-

Main -Changes

- - - -
    -
  • First official release for STM324x9I_EVAL board drivers.
  • -
-

Known -Limitations

- -
    -
  • stm324x9i_eval_audio_codec.c/.h
    • If -2 audio streams are played in TDM format (the first stream is -configured in codec SLOT0 and second stream in codec SLOT1) the -Pause/Resume, Volume Control and Mute action will apply on both streams.
    -
-

License

- -
-
-Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met:
-
-
  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions -in binary form must reproduce the above copyright notice, this list of -conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of STMicroelectronics nor the names of its contributors may be used to endorse or promote products derived
    -
    -
-        from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- -
-
- - -
-
-

For -complete documentation on STM32 Microcontrollers -visit www.st.com/STM32

-
-

-
-
-

 

-
- - \ No newline at end of file diff --git a/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval.c b/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval.c deleted file mode 100644 index 66dcd60f6a..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval.c +++ /dev/null @@ -1,978 +0,0 @@ -/** - ****************************************************************************** - * @file stm324x9i_eval.c - * @author MCD Application Team - * @version V2.2.1 - * @date 07-October-2015 - * @brief This file provides a set of firmware functions to manage LEDs, - * push-buttons and COM ports available on STM324x9I-EVAL evaluation - * board(MB1045) RevB from STMicroelectronics. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* File Info: ------------------------------------------------------------------ - User NOTE - - This driver requires the stm324x9i_eval_io to manage the joystick - -------------------------------------------------------------------------------*/ - -/* Includes ------------------------------------------------------------------*/ -#include "stm324x9i_eval.h" -#include "stm324x9i_eval_io.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM324x9I_EVAL - * @{ - */ - -/** @defgroup STM324x9I_EVAL_LOW_LEVEL - * @{ - */ - -/** @defgroup STM324x9I_EVAL_LOW_LEVEL_Private_TypesDefinitions - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_LOW_LEVEL_Private_Defines - * @{ - */ -/** - * @brief STM324x9I EVAL BSP Driver version number V2.2.1 - */ -#define __STM324x9I_EVAL_BSP_VERSION_MAIN (0x02) /*!< [31:24] main version */ -#define __STM324x9I_EVAL_BSP_VERSION_SUB1 (0x02) /*!< [23:16] sub1 version */ -#define __STM324x9I_EVAL_BSP_VERSION_SUB2 (0x01) /*!< [15:8] sub2 version */ -#define __STM324x9I_EVAL_BSP_VERSION_RC (0x00) /*!< [7:0] release candidate */ -#define __STM324x9I_EVAL_BSP_VERSION ((__STM324x9I_EVAL_BSP_VERSION_MAIN << 24)\ - |(__STM324x9I_EVAL_BSP_VERSION_SUB1 << 16)\ - |(__STM324x9I_EVAL_BSP_VERSION_SUB2 << 8 )\ - |(__STM324x9I_EVAL_BSP_VERSION_RC)) -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_LOW_LEVEL_Private_Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_LOW_LEVEL_Private_Variables - * @{ - */ -GPIO_TypeDef* GPIO_PORT[LEDn] = {LED1_GPIO_PORT, - LED2_GPIO_PORT, - LED3_GPIO_PORT, - LED4_GPIO_PORT}; - -const uint16_t GPIO_PIN[LEDn] = {LED1_PIN, - LED2_PIN, - LED3_PIN, - LED4_PIN}; - -GPIO_TypeDef* BUTTON_PORT[BUTTONn] = {WAKEUP_BUTTON_GPIO_PORT, - TAMPER_BUTTON_GPIO_PORT, - KEY_BUTTON_GPIO_PORT}; - -const uint16_t BUTTON_PIN[BUTTONn] = {WAKEUP_BUTTON_PIN, - TAMPER_BUTTON_PIN, - KEY_BUTTON_PIN}; - -const uint16_t BUTTON_IRQn[BUTTONn] = {WAKEUP_BUTTON_EXTI_IRQn, - TAMPER_BUTTON_EXTI_IRQn, - KEY_BUTTON_EXTI_IRQn}; - -USART_TypeDef* COM_USART[COMn] = {EVAL_COM1}; - -GPIO_TypeDef* COM_TX_PORT[COMn] = {EVAL_COM1_TX_GPIO_PORT}; - -GPIO_TypeDef* COM_RX_PORT[COMn] = {EVAL_COM1_RX_GPIO_PORT}; - -const uint16_t COM_TX_PIN[COMn] = {EVAL_COM1_TX_PIN}; - -const uint16_t COM_RX_PIN[COMn] = {EVAL_COM1_RX_PIN}; - -const uint16_t COM_TX_AF[COMn] = {EVAL_COM1_TX_AF}; - -const uint16_t COM_RX_AF[COMn] = {EVAL_COM1_RX_AF}; - -static I2C_HandleTypeDef heval_I2c; - -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_LOW_LEVEL_Private_FunctionPrototypes - * @{ - */ -static void I2Cx_MspInit(void); -static void I2Cx_Init(void); -static void I2Cx_ITConfig(void); -static void I2Cx_Write(uint8_t Addr, uint8_t Reg, uint8_t Value); -static uint8_t I2Cx_Read(uint8_t Addr, uint8_t Reg); -static HAL_StatusTypeDef I2Cx_ReadMultiple(uint8_t Addr, uint16_t Reg, uint16_t MemAddSize, uint8_t *Buffer, uint16_t Length); -static HAL_StatusTypeDef I2Cx_WriteMultiple(uint8_t Addr, uint16_t Reg, uint16_t MemAddSize, uint8_t *Buffer, uint16_t Length); -static HAL_StatusTypeDef I2Cx_IsDeviceReady(uint16_t DevAddress, uint32_t Trials); -static void I2Cx_Error(uint8_t Addr); - -/* IOExpander IO functions */ -void IOE_Init(void); -void IOE_ITConfig(void); -void IOE_Delay(uint32_t Delay); -void IOE_Write(uint8_t Addr, uint8_t Reg, uint8_t Value); -uint8_t IOE_Read(uint8_t Addr, uint8_t Reg); -uint16_t IOE_ReadMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length); -void IOE_WriteMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length); - -/* AUDIO IO functions */ -void AUDIO_IO_Init(void); -void AUDIO_IO_DeInit(void); -void AUDIO_IO_Write(uint8_t Addr, uint16_t Reg, uint16_t Value); -uint16_t AUDIO_IO_Read(uint8_t Addr, uint16_t Reg); -void AUDIO_IO_Delay(uint32_t Delay); - -/* CAMERA IO functions */ -void CAMERA_IO_Init(void); -void CAMERA_Delay(uint32_t Delay); -void CAMERA_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value); -uint8_t CAMERA_IO_Read(uint8_t Addr, uint8_t Reg); - -/* I2C EEPROM IO function */ -void EEPROM_IO_Init(void); -HAL_StatusTypeDef EEPROM_IO_WriteData(uint16_t DevAddress, uint16_t MemAddress, uint8_t* pBuffer, uint32_t BufferSize); -HAL_StatusTypeDef EEPROM_IO_ReadData(uint16_t DevAddress, uint16_t MemAddress, uint8_t* pBuffer, uint32_t BufferSize); -HAL_StatusTypeDef EEPROM_IO_IsDeviceReady(uint16_t DevAddress, uint32_t Trials); -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_LOW_LEVEL_Private_Functions - * @{ - */ - - /** - * @brief This method returns the STM324x9I EVAL BSP Driver revision - * @param None - * @retval version: 0xXYZR (8bits for each decimal, R for RC) - */ -uint32_t BSP_GetVersion(void) -{ - return __STM324x9I_EVAL_BSP_VERSION; -} - -/** - * @brief Configures LED GPIO. - * @param Led: LED to be configured. - * This parameter can be one of the following values: - * @arg LED1 - * @arg LED2 - * @arg LED3 - * @arg LED4 - * @retval None - */ -void BSP_LED_Init(Led_TypeDef Led) -{ - GPIO_InitTypeDef GPIO_InitStruct; - - /* Enable the GPIO_LED clock */ - LEDx_GPIO_CLK_ENABLE(Led); - - /* Configure the GPIO_LED pin */ - GPIO_InitStruct.Pin = GPIO_PIN[Led]; - GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStruct.Pull = GPIO_PULLUP; - GPIO_InitStruct.Speed = GPIO_SPEED_FAST; - - HAL_GPIO_Init(GPIO_PORT[Led], &GPIO_InitStruct); - - HAL_GPIO_WritePin(GPIO_PORT[Led], GPIO_PIN[Led], GPIO_PIN_SET); -} - -/** - * @brief Turns selected LED On. - * @param Led: LED to be set on - * This parameter can be one of the following values: - * @arg LED1 - * @arg LED2 - * @arg LED3 - * @arg LED4 - * @retval None - */ -void BSP_LED_On(Led_TypeDef Led) -{ - HAL_GPIO_WritePin(GPIO_PORT[Led], GPIO_PIN[Led], GPIO_PIN_RESET); -} - -/** - * @brief Turns selected LED Off. - * @param Led: LED to be set off - * This parameter can be one of the following values: - * @arg LED1 - * @arg LED2 - * @arg LED3 - * @arg LED4 - * @retval None - */ -void BSP_LED_Off(Led_TypeDef Led) -{ - HAL_GPIO_WritePin(GPIO_PORT[Led], GPIO_PIN[Led], GPIO_PIN_SET); -} - -/** - * @brief Toggles the selected LED. - * @param Led: LED to be toggled - * This parameter can be one of the following values: - * @arg LED1 - * @arg LED2 - * @arg LED3 - * @arg LED4 - * @retval None - */ -void BSP_LED_Toggle(Led_TypeDef Led) -{ - HAL_GPIO_TogglePin(GPIO_PORT[Led], GPIO_PIN[Led]); -} - -/** - * @brief Configures button GPIO and EXTI Line. - * @param Button: Button to be configured - * This parameter can be one of the following values: - * @arg BUTTON_WAKEUP: Wakeup Push Button - * @arg BUTTON_TAMPER: Tamper Push Button - * @param Button_Mode: Button mode - * This parameter can be one of the following values: - * @arg BUTTON_MODE_GPIO: Button will be used as simple IO - * @arg BUTTON_MODE_EXTI: Button will be connected to EXTI line - * with interrupt generation capability - * @retval None - */ -void BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef Button_Mode) -{ - GPIO_InitTypeDef GPIO_InitStruct; - - /* Enable the BUTTON clock */ - BUTTONx_GPIO_CLK_ENABLE(Button); - - if(Button_Mode == BUTTON_MODE_GPIO) - { - /* Configure Button pin as input */ - GPIO_InitStruct.Pin = BUTTON_PIN[Button]; - GPIO_InitStruct.Mode = GPIO_MODE_INPUT; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FAST; - HAL_GPIO_Init(BUTTON_PORT[Button], &GPIO_InitStruct); - } - - if(Button_Mode == BUTTON_MODE_EXTI) - { - /* Configure Button pin as input with External interrupt */ - GPIO_InitStruct.Pin = BUTTON_PIN[Button]; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FAST; - - if(Button != BUTTON_WAKEUP) - { - GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING; - } - else - { - GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; - } - - HAL_GPIO_Init(BUTTON_PORT[Button], &GPIO_InitStruct); - - /* Enable and set Button EXTI Interrupt to the lowest priority */ - HAL_NVIC_SetPriority((IRQn_Type)(BUTTON_IRQn[Button]), 0x0F, 0x00); - HAL_NVIC_EnableIRQ((IRQn_Type)(BUTTON_IRQn[Button])); - } -} - -/** - * @brief Returns the selected button state. - * @param Button: Button to be checked - * This parameter can be one of the following values: - * @arg BUTTON_WAKEUP: Wakeup Push Button - * @arg BUTTON_TAMPER: Tamper Push Button - * @arg BUTTON_KEY: Key Push Button - * @retval The Button GPIO pin value - */ -uint32_t BSP_PB_GetState(Button_TypeDef Button) -{ - return HAL_GPIO_ReadPin(BUTTON_PORT[Button], BUTTON_PIN[Button]); -} - -/** - * @brief Configures COM port. - * @param COM: COM port to be configured. - * This parameter can be one of the following values: - * @arg COM1 - * @arg COM2 - * @param huart: Pointer to a UART_HandleTypeDef structure that contains the - * configuration information for the specified USART peripheral. - * @retval None - */ -void BSP_COM_Init(COM_TypeDef COM, UART_HandleTypeDef *huart) -{ - GPIO_InitTypeDef GPIO_InitStruct; - - /* Enable GPIO clock */ - EVAL_COMx_TX_GPIO_CLK_ENABLE(COM); - EVAL_COMx_RX_GPIO_CLK_ENABLE(COM); - - /* Enable USART clock */ - EVAL_COMx_CLK_ENABLE(COM); - - /* Configure USART Tx as alternate function */ - GPIO_InitStruct.Pin = COM_TX_PIN[COM]; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Speed = GPIO_SPEED_FAST; - GPIO_InitStruct.Pull = GPIO_PULLUP; - GPIO_InitStruct.Alternate = COM_TX_AF[COM]; - HAL_GPIO_Init(COM_TX_PORT[COM], &GPIO_InitStruct); - - /* Configure USART Rx as alternate function */ - GPIO_InitStruct.Pin = COM_RX_PIN[COM]; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Alternate = COM_RX_AF[COM]; - HAL_GPIO_Init(COM_RX_PORT[COM], &GPIO_InitStruct); - - /* USART configuration */ - huart->Instance = COM_USART[COM]; - HAL_UART_Init(huart); -} - -/** - * @brief Configures joystick GPIO and EXTI modes. - * @param Joy_Mode: Button mode. - * This parameter can be one of the following values: - * @arg JOY_MODE_GPIO: Joystick pins will be used as simple IOs - * @arg JOY_MODE_EXTI: Joystick pins will be connected to EXTI line - * with interrupt generation capability - * @retval IO_OK: if all initializations are OK. Other value if error. - */ -uint8_t BSP_JOY_Init(JOYMode_TypeDef Joy_Mode) -{ - uint8_t ret = 0; - - /* Initialize the IO functionalities */ - ret = BSP_IO_Init(); - - /* Configure joystick pins in IT mode */ - if(Joy_Mode == JOY_MODE_EXTI) - { - /* Configure IO interrupt acquisition mode */ - BSP_IO_ConfigPin(JOY_ALL_PINS, IO_MODE_IT_FALLING_EDGE); - } - - return ret; -} - -/** - * @brief Returns the current joystick status. - * @param None - * @retval Code of the joystick key pressed - * This code can be one of the following values: - * @arg JOY_NONE - * @arg JOY_SEL - * @arg JOY_DOWN - * @arg JOY_LEFT - * @arg JOY_RIGHT - * @arg JOY_UP - */ -JOYState_TypeDef BSP_JOY_GetState(void) -{ - uint16_t tmp = 0; - - /* Read the status joystick pins */ - tmp = BSP_IO_ReadPin(JOY_ALL_PINS); - - /* Check the pressed keys */ - if((tmp & JOY_NONE_PIN) == JOY_NONE) - { - return(JOYState_TypeDef) JOY_NONE; - } - else if(!(tmp & JOY_SEL_PIN)) - { - return(JOYState_TypeDef) JOY_SEL; - } - else if(!(tmp & JOY_DOWN_PIN)) - { - return(JOYState_TypeDef) JOY_DOWN; - } - else if(!(tmp & JOY_LEFT_PIN)) - { - return(JOYState_TypeDef) JOY_LEFT; - } - else if(!(tmp & JOY_RIGHT_PIN)) - { - return(JOYState_TypeDef) JOY_RIGHT; - } - else if(!(tmp & JOY_UP_PIN)) - { - return(JOYState_TypeDef) JOY_UP; - } - else - { - return(JOYState_TypeDef) JOY_NONE; - } -} - -/** - * @brief Check TS3510 touch screen presence - * @param None - * @retval Return 0 if TS3510 is detected, return 1 if not detected - */ -uint8_t BSP_TS3510_IsDetected(void) -{ - HAL_StatusTypeDef status = HAL_OK; - uint32_t error = 0; - uint8_t a_buffer; - - uint8_t tmp_buffer[2] = {0x81, 0x08}; - - /* Prepare for LCD read data */ - IOE_WriteMultiple(TS3510_I2C_ADDRESS, 0x8A, tmp_buffer, 2); - - status = HAL_I2C_Mem_Read(&heval_I2c, TS3510_I2C_ADDRESS, 0x8A, I2C_MEMADD_SIZE_8BIT, &a_buffer, 1, 1000); - - /* Check the communication status */ - if(status != HAL_OK) - { - error = (uint32_t)HAL_I2C_GetError(&heval_I2c); - - /* I2C error occured */ - I2Cx_Error(TS3510_I2C_ADDRESS); - - if(error == HAL_I2C_ERROR_AF) - { - return 1; - } - } - return 0; -} -/******************************************************************************* - BUS OPERATIONS -*******************************************************************************/ - -/******************************* I2C Routines *********************************/ -/** - * @brief Initializes I2C MSP. - * @param None - * @retval None - */ -static void I2Cx_MspInit(void) -{ - GPIO_InitTypeDef GPIO_InitStruct; - - /*** Configure the GPIOs ***/ - /* Enable GPIO clock */ - EVAL_I2Cx_SCL_SDA_GPIO_CLK_ENABLE(); - - /* Configure I2C Tx as alternate function */ - GPIO_InitStruct.Pin = EVAL_I2Cx_SCL_PIN; - GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FAST; - GPIO_InitStruct.Alternate = EVAL_I2Cx_SCL_SDA_AF; - HAL_GPIO_Init(EVAL_I2Cx_SCL_SDA_GPIO_PORT, &GPIO_InitStruct); - - /* Configure I2C Rx as alternate function */ - GPIO_InitStruct.Pin = EVAL_I2Cx_SDA_PIN; - HAL_GPIO_Init(EVAL_I2Cx_SCL_SDA_GPIO_PORT, &GPIO_InitStruct); - - /*** Configure the I2C peripheral ***/ - /* Enable I2C clock */ - EVAL_I2Cx_CLK_ENABLE(); - - /* Force the I2C peripheral clock reset */ - EVAL_I2Cx_FORCE_RESET(); - - /* Release the I2C peripheral clock reset */ - EVAL_I2Cx_RELEASE_RESET(); - - /* Enable and set I2Cx Interrupt to a lower priority */ - HAL_NVIC_SetPriority(EVAL_I2Cx_EV_IRQn, 0x05, 0); - HAL_NVIC_EnableIRQ(EVAL_I2Cx_EV_IRQn); - - /* Enable and set I2Cx Interrupt to a lower priority */ - HAL_NVIC_SetPriority(EVAL_I2Cx_ER_IRQn, 0x05, 0); - HAL_NVIC_EnableIRQ(EVAL_I2Cx_ER_IRQn); -} - -/** - * @brief Initializes I2C HAL. - * @param None - * @retval None - */ -static void I2Cx_Init(void) -{ - if(HAL_I2C_GetState(&heval_I2c) == HAL_I2C_STATE_RESET) - { - heval_I2c.Instance = I2C1; - heval_I2c.Init.ClockSpeed = BSP_I2C_SPEED; - heval_I2c.Init.DutyCycle = I2C_DUTYCYCLE_2; - heval_I2c.Init.OwnAddress1 = 0; - heval_I2c.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT; - heval_I2c.Init.DualAddressMode = I2C_DUALADDRESS_DISABLED; - heval_I2c.Init.OwnAddress2 = 0; - heval_I2c.Init.GeneralCallMode = I2C_GENERALCALL_DISABLED; - heval_I2c.Init.NoStretchMode = I2C_NOSTRETCH_DISABLED; - - /* Init the I2C */ - I2Cx_MspInit(); - HAL_I2C_Init(&heval_I2c); - } -} - -/** - * @brief Configures I2C Interrupt. - * @param None - * @retval None - */ -static void I2Cx_ITConfig(void) -{ - static uint8_t I2C_IT_Enabled = 0; - GPIO_InitTypeDef GPIO_InitStruct; - - if(I2C_IT_Enabled == 0) - { - I2C_IT_Enabled = 1; - /* Enable the GPIO EXTI clock */ - __GPIOI_CLK_ENABLE(); - __SYSCFG_CLK_ENABLE(); - - GPIO_InitStruct.Pin = GPIO_PIN_8; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_LOW; - GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING; - HAL_GPIO_Init(GPIOI, &GPIO_InitStruct); - - /* Enable and set GPIO EXTI Interrupt to the lowest priority */ - HAL_NVIC_SetPriority((IRQn_Type)(EXTI9_5_IRQn), 0x0F, 0x0F); - HAL_NVIC_EnableIRQ((IRQn_Type)(EXTI9_5_IRQn)); - } -} - -/** - * @brief Writes a single data. - * @param Addr: I2C address - * @param Reg: Register address - * @param Value: Data to be written - * @retval None - */ -static void I2Cx_Write(uint8_t Addr, uint8_t Reg, uint8_t Value) -{ - HAL_StatusTypeDef status = HAL_OK; - - status = HAL_I2C_Mem_Write(&heval_I2c, Addr, (uint16_t)Reg, I2C_MEMADD_SIZE_8BIT, &Value, 1, 100); - - /* Check the communication status */ - if(status != HAL_OK) - { - /* Execute user timeout callback */ - I2Cx_Error(Addr); - } -} - -/** - * @brief Reads a single data. - * @param Addr: I2C address - * @param Reg: Register address - * @retval Read data - */ -static uint8_t I2Cx_Read(uint8_t Addr, uint8_t Reg) -{ - HAL_StatusTypeDef status = HAL_OK; - uint8_t Value = 0; - - status = HAL_I2C_Mem_Read(&heval_I2c, Addr, Reg, I2C_MEMADD_SIZE_8BIT, &Value, 1, 1000); - - /* Check the communication status */ - if(status != HAL_OK) - { - /* Execute user timeout callback */ - I2Cx_Error(Addr); - } - return Value; -} - -/** - * @brief Reads multiple data. - * @param Addr: I2C address - * @param Reg: Reg address - * @param Buffer: Pointer to data buffer - * @param Length: Length of the data - * @retval Number of read data - */ -static HAL_StatusTypeDef I2Cx_ReadMultiple(uint8_t Addr, uint16_t Reg, uint16_t MemAddress, uint8_t *Buffer, uint16_t Length) -{ - HAL_StatusTypeDef status = HAL_OK; - - if(Addr == EXC7200_I2C_ADDRESS) - { - status = HAL_I2C_Master_Receive(&heval_I2c, Addr, Buffer, Length, 1000); - } - else - { - status = HAL_I2C_Mem_Read(&heval_I2c, Addr, (uint16_t)Reg, MemAddress, Buffer, Length, 1000); - } - - /* Check the communication status */ - if(status != HAL_OK) - { - /* I2C error occured */ - I2Cx_Error(Addr); - } - return status; -} - -/** - * @brief Writes a value in a register of the device through BUS in using DMA mode. - * @param Addr: Device address on BUS Bus. - * @param Reg: The target register address to write - * @param pBuffer: The target register value to be written - * @param Length: buffer size to be written - * @retval HAL status - */ -static HAL_StatusTypeDef I2Cx_WriteMultiple(uint8_t Addr, uint16_t Reg, uint16_t MemAddress, uint8_t *Buffer, uint16_t Length) -{ - HAL_StatusTypeDef status = HAL_OK; - - status = HAL_I2C_Mem_Write(&heval_I2c, Addr, (uint16_t)Reg, MemAddress, Buffer, Length, 1000); - - /* Check the communication status */ - if(status != HAL_OK) - { - /* Re-Initialize the I2C Bus */ - I2Cx_Error(Addr); - } - return status; -} - -/** - * @brief Checks if target device is ready for communication. - * @note This function is used with Memory devices - * @param DevAddress: Target device address - * @param Trials: Number of trials - * @retval HAL status - */ -static HAL_StatusTypeDef I2Cx_IsDeviceReady(uint16_t DevAddress, uint32_t Trials) -{ - return (HAL_I2C_IsDeviceReady(&heval_I2c, DevAddress, Trials, 1000)); -} - -/** - * @brief Manages error callback by re-initializing I2C. - * @param Addr: I2C Address - * @retval None - */ -static void I2Cx_Error(uint8_t Addr) -{ - /* De-initialize the I2C communication bus */ - HAL_I2C_DeInit(&heval_I2c); - - /* Re-Initialize the I2C communication bus */ - I2Cx_Init(); -} - -/******************************************************************************* - LINK OPERATIONS -*******************************************************************************/ - -/********************************* LINK IOE ***********************************/ - -/** - * @brief Initializes IOE low level. - * @param None - * @retval None - */ -void IOE_Init(void) -{ - I2Cx_Init(); -} - -/** - * @brief Configures IOE low level interrupt. - * @param None - * @retval None - */ -void IOE_ITConfig(void) -{ - I2Cx_ITConfig(); -} - -/** - * @brief IOE writes single data. - * @param Addr: I2C address - * @param Reg: Register address - * @param Value: Data to be written - * @retval None - */ -void IOE_Write(uint8_t Addr, uint8_t Reg, uint8_t Value) -{ - I2Cx_Write(Addr, Reg, Value); -} - -/** - * @brief IOE reads single data. - * @param Addr: I2C address - * @param Reg: Register address - * @retval Read data - */ -uint8_t IOE_Read(uint8_t Addr, uint8_t Reg) -{ - return I2Cx_Read(Addr, Reg); -} - -/** - * @brief IOE reads multiple data. - * @param Addr: I2C address - * @param Reg: Register address - * @param Buffer: Pointer to data buffer - * @param Length: Length of the data - * @retval Number of read data - */ -uint16_t IOE_ReadMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length) -{ - return I2Cx_ReadMultiple(Addr, (uint16_t)Reg, I2C_MEMADD_SIZE_8BIT, Buffer, Length); -} - -/** - * @brief IOE writes multiple data. - * @param Addr: I2C address - * @param Reg: Register address - * @param Buffer: Pointer to data buffer - * @param Length: Length of the data - * @retval None - */ -void IOE_WriteMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length) -{ - I2Cx_WriteMultiple(Addr, (uint16_t)Reg, I2C_MEMADD_SIZE_8BIT, Buffer, Length); -} - -/** - * @brief IOE delay - * @param Delay: Delay in ms - * @retval None - */ -void IOE_Delay(uint32_t Delay) -{ - HAL_Delay(Delay); -} - -/********************************* LINK AUDIO *********************************/ - -/** - * @brief Initializes Audio low level. - * @param None - * @retval None - */ -void AUDIO_IO_Init(void) -{ - I2Cx_Init(); -} - -/** - * @brief DeInitializes Audio low level. - */ -void AUDIO_IO_DeInit(void) -{ - -} - -/** - * @brief Writes a single data. - * @param Addr: I2C address - * @param Reg: Reg address - * @param Value: Data to be written - * @retval None - */ -void AUDIO_IO_Write(uint8_t Addr, uint16_t Reg, uint16_t Value) -{ - uint16_t tmp = Value; - - Value = ((uint16_t)(tmp >> 8) & 0x00FF); - - Value |= ((uint16_t)(tmp << 8)& 0xFF00); - - I2Cx_WriteMultiple(Addr, Reg, I2C_MEMADD_SIZE_16BIT,(uint8_t*)&Value, 2); -} - -/** - * @brief Reads a single data. - * @param Addr: I2C address - * @param Reg: Reg address - * @retval Data to be read - */ -uint16_t AUDIO_IO_Read(uint8_t Addr, uint16_t Reg) -{ - uint16_t Read_Value = 0, tmp = 0; - - I2Cx_ReadMultiple(Addr, Reg, I2C_MEMADD_SIZE_16BIT, (uint8_t*)&Read_Value, 2); - - tmp = ((uint16_t)(Read_Value >> 8) & 0x00FF); - - tmp |= ((uint16_t)(Read_Value << 8)& 0xFF00); - - Read_Value = tmp; - - return Read_Value; -} - -/** - * @brief AUDIO Codec delay - * @param Delay: Delay in ms - * @retval None - */ -void AUDIO_IO_Delay(uint32_t Delay) -{ - HAL_Delay(Delay); -} - -/********************************* LINK CAMERA ********************************/ - -/** - * @brief Initializes Camera low level. - * @param None - * @retval None - */ -void CAMERA_IO_Init(void) -{ - I2Cx_Init(); -} - -/** - * @brief Camera writes single data. - * @param Addr: I2C address - * @param Reg: Register address - * @param Value: Data to be written - * @retval None - */ -void CAMERA_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value) -{ - I2Cx_Write(Addr, Reg, Value); -} - -/** - * @brief Camera reads single data. - * @param Addr: I2C address - * @param Reg: Register address - * @retval Read data - */ -uint8_t CAMERA_IO_Read(uint8_t Addr, uint8_t Reg) -{ - return I2Cx_Read(Addr, Reg); -} - -/** - * @brief Camera delay - * @param Delay: Delay in ms - * @retval None - */ -void CAMERA_Delay(uint32_t Delay) -{ - HAL_Delay(Delay); -} - -/******************************** LINK I2C EEPROM *****************************/ - -/** - * @brief Initializes peripherals used by the I2C EEPROM driver. - * @param None - * @retval None - */ -void EEPROM_IO_Init(void) -{ - I2Cx_Init(); -} - -/** - * @brief Write data to I2C EEPROM driver in using DMA channel. - * @param DevAddress: Target device address - * @param MemAddress: Internal memory address - * @param pBuffer: Pointer to data buffer - * @param BufferSize: Amount of data to be sent - * @retval HAL status - */ -HAL_StatusTypeDef EEPROM_IO_WriteData(uint16_t DevAddress, uint16_t MemAddress, uint8_t* pBuffer, uint32_t BufferSize) -{ - return (I2Cx_WriteMultiple(DevAddress, MemAddress, I2C_MEMADD_SIZE_16BIT, pBuffer, BufferSize)); -} - -/** - * @brief Read data from I2C EEPROM driver in using DMA channel. - * @param DevAddress: Target device address - * @param MemAddress: Internal memory address - * @param pBuffer: Pointer to data buffer - * @param BufferSize: Amount of data to be read - * @retval HAL status - */ -HAL_StatusTypeDef EEPROM_IO_ReadData(uint16_t DevAddress, uint16_t MemAddress, uint8_t* pBuffer, uint32_t BufferSize) -{ - return (I2Cx_ReadMultiple(DevAddress, MemAddress, I2C_MEMADD_SIZE_16BIT, pBuffer, BufferSize)); -} - -/** - * @brief Checks if target device is ready for communication. - * @note This function is used with Memory devices - * @param DevAddress: Target device address - * @param Trials: Number of trials - * @retval HAL status - */ -HAL_StatusTypeDef EEPROM_IO_IsDeviceReady(uint16_t DevAddress, uint32_t Trials) -{ - return (I2Cx_IsDeviceReady(DevAddress, Trials)); -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval.h b/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval.h deleted file mode 100644 index 27044da604..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval.h +++ /dev/null @@ -1,366 +0,0 @@ -/** - ****************************************************************************** - * @file stm324x9i_eval.h - * @author MCD Application Team - * @version V2.2.1 - * @date 07-October-2015 - * @brief This file contains definitions for STM324x9I_EVAL's LEDs, - * push-buttons and COM ports hardware resources. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM324X9I_EVAL_H -#define __STM324X9I_EVAL_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm32f4xx_hal.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM324x9I_EVAL - * @{ - */ - -/** @addtogroup STM324x9I_EVAL_LOW_LEVEL - * @{ - */ - -/** @defgroup STM324x9I_EVAL_LOW_LEVEL_Exported_Types - * @{ - */ -typedef enum -{ - LED1 = 0, - LED2 = 1, - LED3 = 2, - LED4 = 3 -}Led_TypeDef; - -typedef enum -{ - BUTTON_WAKEUP = 0, - BUTTON_TAMPER = 1, - BUTTON_KEY = 2 -}Button_TypeDef; - -typedef enum -{ - BUTTON_MODE_GPIO = 0, - BUTTON_MODE_EXTI = 1 -}ButtonMode_TypeDef; - -typedef enum -{ - JOY_MODE_GPIO = 0, - JOY_MODE_EXTI = 1 -}JOYMode_TypeDef; - -typedef enum -{ - JOY_NONE = 0, - JOY_SEL = 1, - JOY_DOWN = 2, - JOY_LEFT = 3, - JOY_RIGHT = 4, - JOY_UP = 5 -}JOYState_TypeDef; - -typedef enum -{ - COM1 = 0, - COM2 = 1 -}COM_TypeDef; -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_LOW_LEVEL_Exported_Constants - * @{ - */ - -/** - * @brief Define for STM324x9I_EVAL board - */ -#if !defined (USE_STM324x9I_EVAL) - #define USE_STM324x9I_EVAL -#endif - -/** @addtogroup STM324x9I_EVAL_LOW_LEVEL_LED - * @{ - */ -#define LEDn 4 - -#define LED1_PIN GPIO_PIN_6 -#define LED1_GPIO_PORT GPIOG -#define LED1_GPIO_CLK_ENABLE() __GPIOG_CLK_ENABLE() -#define LED1_GPIO_CLK_DISABLE() __GPIOG_CLK_DISABLE() - - -#define LED2_PIN GPIO_PIN_7 -#define LED2_GPIO_PORT GPIOG -#define LED2_GPIO_CLK_ENABLE() __GPIOG_CLK_ENABLE() -#define LED2_GPIO_CLK_DISABLE() __GPIOG_CLK_DISABLE() - -#define LED3_PIN GPIO_PIN_10 -#define LED3_GPIO_PORT GPIOG -#define LED3_GPIO_CLK_ENABLE() __GPIOG_CLK_ENABLE() -#define LED3_GPIO_CLK_DISABLE() __GPIOG_CLK_DISABLE() - -#define LED4_PIN GPIO_PIN_12 -#define LED4_GPIO_PORT GPIOG -#define LED4_GPIO_CLK_ENABLE() __GPIOG_CLK_ENABLE() -#define LED4_GPIO_CLK_DISABLE() __GPIOG_CLK_DISABLE() - -#define LEDx_GPIO_CLK_ENABLE(__INDEX__) do{if((__INDEX__) == 0) LED1_GPIO_CLK_ENABLE(); else \ - if((__INDEX__) == 1) LED2_GPIO_CLK_ENABLE(); else \ - if((__INDEX__) == 2) LED3_GPIO_CLK_ENABLE(); else \ - if((__INDEX__) == 3) LED4_GPIO_CLK_ENABLE(); \ - }while(0) - -#define LEDx_GPIO_CLK_DISABLE(__INDEX__) do{if((__INDEX__) == 0) LED1_GPIO_CLK_DISABLE(); else \ - if((__INDEX__) == 1) LED2_GPIO_CLK_DISABLE(); else \ - if((__INDEX__) == 2) LED3_GPIO_CLK_DISABLE(); else \ - if((__INDEX__) == 3) LED4_GPIO_CLK_DISABLE(); \ - }while(0) - -/** - * @} - */ - -/** @addtogroup STM324x9I_EVAL_LOW_LEVEL_BUTTON - * @{ - */ -/* Joystick pins are connected to IO Expander (accessible through I2C1 interface) */ -#define BUTTONn 3 - -/** - * @brief Wakeup push-button - */ -#define WAKEUP_BUTTON_PIN GPIO_PIN_0 -#define WAKEUP_BUTTON_GPIO_PORT GPIOA -#define WAKEUP_BUTTON_GPIO_CLK_ENABLE() __GPIOA_CLK_ENABLE() -#define WAKEUP_BUTTON_GPIO_CLK_DISABLE() __GPIOA_CLK_DISABLE() -#define WAKEUP_BUTTON_EXTI_IRQn EXTI0_IRQn - -/** - * @brief Tamper push-button - */ -#define TAMPER_BUTTON_PIN GPIO_PIN_13 -#define TAMPER_BUTTON_GPIO_PORT GPIOC -#define TAMPER_BUTTON_GPIO_CLK_ENABLE() __GPIOC_CLK_ENABLE() -#define TAMPER_BUTTON_GPIO_CLK_DISABLE() __GPIOC_CLK_DISABLE() -#define TAMPER_BUTTON_EXTI_IRQn EXTI15_10_IRQn - -/** - * @brief Key push-button - */ -#define KEY_BUTTON_PIN GPIO_PIN_13 -#define KEY_BUTTON_GPIO_PORT GPIOC -#define KEY_BUTTON_GPIO_CLK_ENABLE() __GPIOC_CLK_ENABLE() -#define KEY_BUTTON_GPIO_CLK_DISABLE() __GPIOC_CLK_DISABLE() -#define KEY_BUTTON_EXTI_IRQn EXTI15_10_IRQn - -#define BUTTONx_GPIO_CLK_ENABLE(__INDEX__) do{if((__INDEX__) == 0) WAKEUP_BUTTON_GPIO_CLK_ENABLE(); else \ - if((__INDEX__) == 1) TAMPER_BUTTON_GPIO_CLK_ENABLE(); else \ - if ((__INDEX__) == 2) KEY_BUTTON_GPIO_CLK_ENABLE(); \ - }while(0) -#define BUTTONx_GPIO_CLK_DISABLE(__INDEX__) do{if((__INDEX__) == 0) WAKEUP_BUTTON_GPIO_CLK_DISABLE(); else \ - if((__INDEX__) == 1) TAMPER_BUTTON_GPIO_CLK_DISABLE(); else \ - if ((__INDEX__) == 2) KEY_BUTTON_GPIO_CLK_DISABLE(); \ - }while(0) -/** - * @} - */ - -/** @addtogroup STM324x9I_EVAL_LOW_LEVEL_COM - * @{ - */ -#define COMn 1 - -/** - * @brief Definition for COM port1, connected to USART1 - */ -#define EVAL_COM1 USART1 -#define EVAL_COM1_CLK_ENABLE() __USART1_CLK_ENABLE() -#define EVAL_COM1_CLK_DISABLE() __USART1_CLK_DISABLE() - -#define EVAL_COM1_TX_PIN GPIO_PIN_9 -#define EVAL_COM1_TX_GPIO_PORT GPIOA -#define EVAL_COM1_TX_GPIO_CLK_ENABLE() __GPIOA_CLK_ENABLE() -#define EVAL_COM1_TX_GPIO_CLK_DISABLE() __GPIOA_CLK_DISABLE() -#define EVAL_COM1_TX_AF GPIO_AF7_USART1 - -#define EVAL_COM1_RX_PIN GPIO_PIN_10 -#define EVAL_COM1_RX_GPIO_PORT GPIOA -#define EVAL_COM1_RX_GPIO_CLK_ENABLE() __GPIOA_CLK_ENABLE() -#define EVAL_COM1_RX_GPIO_CLK_DISABLE() __GPIOA_CLK_DISABLE() -#define EVAL_COM1_RX_AF GPIO_AF7_USART1 - -#define EVAL_COM1_IRQn USART1_IRQn - -#define EVAL_COMx_CLK_ENABLE(__INDEX__) do{if((__INDEX__) == 0) EVAL_COM1_CLK_ENABLE(); \ - }while(0) -#define EVAL_COMx_CLK_DISABLE(__INDEX__) do{if((__INDEX__) == 0) EVAL_COM1_CLK_DISABLE(); \ - }while(0) - -#define EVAL_COMx_TX_GPIO_CLK_ENABLE(__INDEX__) do{if((__INDEX__) == 0) EVAL_COM1_TX_GPIO_CLK_ENABLE(); \ - }while(0) -#define EVAL_COMx_TX_GPIO_CLK_DISABLE(__INDEX__) do{if((__INDEX__) == 0) EVAL_COM1_TX_GPIO_CLK_DISABLE(); \ - }while(0) - -#define EVAL_COMx_RX_GPIO_CLK_ENABLE(__INDEX__) do{if((__INDEX__) == 0) EVAL_COM1_RX_GPIO_CLK_ENABLE(); \ - }while(0) -#define EVAL_COMx_RX_GPIO_CLK_DISABLE(__INDEX__) do{if((__INDEX__) == 0) EVAL_COM1_RX_GPIO_CLK_DISABLE(); \ - }while(0) - -/** - * @brief Joystick Pins definition - */ -#define JOY_SEL_PIN IO_PIN_14 -#define JOY_DOWN_PIN IO_PIN_13 -#define JOY_LEFT_PIN IO_PIN_12 -#define JOY_RIGHT_PIN IO_PIN_11 -#define JOY_UP_PIN IO_PIN_10 -#define JOY_NONE_PIN JOY_ALL_PINS -#define JOY_ALL_PINS (IO_PIN_10 | IO_PIN_11 | IO_PIN_12 | IO_PIN_13 | IO_PIN_14) - -/** - * @brief Eval Pins definition - */ -#define XSDN_PIN IO_PIN_0 -#define MII_INT_PIN IO_PIN_1 -#define RSTI_PIN IO_PIN_2 -#define CAM_PLUG_PIN IO_PIN_3 -#define LCD_INT_PIN IO_PIN_4 -#define AUDIO_INT_PIN IO_PIN_5 -#define OTG_FS1_OVER_CURRENT_PIN IO_PIN_6 -#define OTG_FS1_POWER_SWITCH_PIN IO_PIN_7 -#define OTG_FS2_OVER_CURRENT_PIN IO_PIN_8 -#define OTG_FS2_POWER_SWITCH_PIN IO_PIN_9 -#define SD_DETECT_PIN IO_PIN_15 - -/* Exported constant IO ------------------------------------------------------*/ -#define IO_I2C_ADDRESS 0x84 -#define TS_I2C_ADDRESS 0x82 -#define TS3510_I2C_ADDRESS 0x80 -#define EXC7200_I2C_ADDRESS 0x08 -#define CAMERA_I2C_ADDRESS 0x60 -#define AUDIO_I2C_ADDRESS 0x34 -#define EEPROM_I2C_ADDRESS_A01 0xA0 -#define EEPROM_I2C_ADDRESS_A02 0xA6 -/* I2C clock speed configuration (in Hz) - WARNING: - Make sure that this define is not already declared in other files (ie. - stm324x9I_eval.h file). It can be used in parallel by other modules. */ -#ifndef BSP_I2C_SPEED - #define BSP_I2C_SPEED 100000 -#endif /* BSP_I2C_SPEED */ - -/* User can use this section to tailor I2Cx/I2Cx instance used and associated - resources */ -/* Definition for I2Cx clock resources */ -#define EVAL_I2Cx I2C1 -#define EVAL_I2Cx_CLK_ENABLE() __I2C1_CLK_ENABLE() -#define EVAL_DMAx_CLK_ENABLE() __DMA1_CLK_ENABLE() -#define EVAL_I2Cx_SCL_SDA_GPIO_CLK_ENABLE() __GPIOB_CLK_ENABLE() - -#define EVAL_I2Cx_FORCE_RESET() __I2C1_FORCE_RESET() -#define EVAL_I2Cx_RELEASE_RESET() __I2C1_RELEASE_RESET() - -/* Definition for I2Cx Pins */ -#define EVAL_I2Cx_SCL_PIN GPIO_PIN_6 -#define EVAL_I2Cx_SCL_SDA_GPIO_PORT GPIOB -#define EVAL_I2Cx_SCL_SDA_AF GPIO_AF4_I2C1 -#define EVAL_I2Cx_SDA_PIN GPIO_PIN_9 - -/* I2C interrupt requests */ -#define EVAL_I2Cx_EV_IRQn I2C1_EV_IRQn -#define EVAL_I2Cx_ER_IRQn I2C1_ER_IRQn - -/** - * @} - */ - -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_LOW_LEVEL_Exported_Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_LOW_LEVEL_Exported_Functions - * @{ - */ -uint32_t BSP_GetVersion(void); -void BSP_LED_Init(Led_TypeDef Led); -void BSP_LED_On(Led_TypeDef Led); -void BSP_LED_Off(Led_TypeDef Led); -void BSP_LED_Toggle(Led_TypeDef Led); -void BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef Button_Mode); -uint32_t BSP_PB_GetState(Button_TypeDef Button); -void BSP_COM_Init(COM_TypeDef COM, UART_HandleTypeDef *husart); -uint8_t BSP_JOY_Init(JOYMode_TypeDef Joy_Mode); -JOYState_TypeDef BSP_JOY_GetState(void); -uint8_t BSP_TS3510_IsDetected(void); - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM324X9I_EVAL_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval_audio.c b/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval_audio.c deleted file mode 100644 index e592065971..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval_audio.c +++ /dev/null @@ -1,1157 +0,0 @@ -/** - ****************************************************************************** - * @file stm324x9i_eval_audio.c - * @author MCD Application Team - * @version V2.2.1 - * @date 07-October-2015 - * @brief This file provides the Audio driver for the STM324x9I-EVAL evaluation board. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/*============================================================================== - User NOTES - -How To use this driver: ------------------------ - + This driver supports STM32F4xx devices on STM324x9I-EVAL (MB1045) Evaluation boards. - + Call the function BSP_AUDIO_OUT_Init( - OutputDevice: physical output mode (OUTPUT_DEVICE_SPEAKER, - OUTPUT_DEVICE_HEADPHONE or OUTPUT_DEVICE_BOTH) - Volume : Initial volume to be set (0 is min (mute), 100 is max (100%) - AudioFreq : Audio frequency in Hz (8000, 16000, 22500, 32000...) - this parameter is relative to the audio file/stream type. - ) - This function configures all the hardware required for the audio application (codec, I2C, SAI, - GPIOs, DMA and interrupt if needed). This function returns AUDIO_OK if configuration is OK. - If the returned value is different from AUDIO_OK or the function is stuck then the communication with - the codec or the IOExpander has failed (try to un-plug the power or reset device in this case). - - OUTPUT_DEVICE_SPEAKER : only speaker will be set as output for the audio stream. - - OUTPUT_DEVICE_HEADPHONE: only headphones will be set as output for the audio stream. - - OUTPUT_DEVICE_BOTH : both Speaker and Headphone are used as outputs for the audio stream - at the same time. - + Call the function BSP_EVAL_AUDIO_OUT_Play( - pBuffer: pointer to the audio data file address - Size : size of the buffer to be sent in Bytes - ) - to start playing (for the first time) from the audio file/stream. - + Call the function BSP_AUDIO_OUT_Pause() to pause playing - + Call the function BSP_AUDIO_OUT_Resume() to resume playing. - Note. After calling BSP_AUDIO_OUT_Pause() function for pause, only BSP_AUDIO_OUT_Resume() should be called - for resume (it is not allowed to call BSP_AUDIO_OUT_Play() in this case). - Note. This function should be called only when the audio file is played or paused (not stopped). - + For each mode, you may need to implement the relative callback functions into your code. - The Callback functions are named AUDIO_OUT_XXX_CallBack() and only their prototypes are declared in - the stm324x9i_eval_audio.h file. (refer to the example for more details on the callbacks implementations) - + To Stop playing, to modify the volume level, the frequency, the audio frame slot, - the device output mode the mute or the stop, use the functions: BSP_AUDIO_OUT_SetVolume(), - AUDIO_OUT_SetFrequency(), BSP_AUDIO_OUT_SetAudioFrameSlot(), BSP_AUDIO_OUT_SetOutputMode(), - BSP_AUDIO_OUT_SetMute() and BSP_AUDIO_OUT_Stop(). - + The driver API and the callback functions are at the end of the stm324x9i_eval_audio.h file. - -Driver architecture: --------------------- - + This driver provide the High Audio Layer: consists of the function API exported in the stm324x9i_eval_audio.h file - (BSP_AUDIO_OUT_Init(), BSP_AUDIO_OUT_Play() ...) - + This driver provide also the Media Access Layer (MAL): which consists of functions allowing to access the media containing/ - providing the audio file/stream. These functions are also included as local functions into - the stm324x9i_eval_audio_codec.c file (SAIx_MspInit() and SAIx_Init()) - -Known Limitations: ------------------- - 1- If the TDM Format used to paly in parallel 2 audio Stream (the first Stream is configured in codec SLOT0 and second - Stream in SLOT1) the Pause/Resume, volume and mute feature will control the both streams. - 2- Parsing of audio file is not implemented (in order to determine audio file properties: Mono/Stereo, Data size, - File size, Audio Frequency, Audio Data header size ...). The configuration is fixed for the given audio file. - 3- Supports only Stereo audio streaming. - 4- Supports only 16-bits audio data size. -==============================================================================*/ - -/* Includes ------------------------------------------------------------------*/ -#include "stm324x9i_eval_audio.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM324x9I_EVAL - * @{ - */ - -/** @defgroup STM324x9I_EVAL_AUDIO - * @brief This file includes the low layer driver for wm8994 Audio Codec - * available on STM324x9I-EVAL evaluation board(MB1045). - * @{ - */ - -/** @defgroup STM324x9I_EVAL_AUDIO_Private_Types - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_AUDIO_Private_Defines - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_AUDIO_Private_Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_AUDIO_Private_Variables - * @{ - */ -AUDIO_DrvTypeDef *audio_drv; -SAI_HandleTypeDef haudio_out_sai; -I2S_HandleTypeDef haudio_in_i2s; -TIM_HandleTypeDef haudio_tim; - -PDMFilter_InitStruct Filter[2]; -uint8_t Channel_Demux[128] = { - 0x00, 0x01, 0x00, 0x01, 0x02, 0x03, 0x02, 0x03, - 0x00, 0x01, 0x00, 0x01, 0x02, 0x03, 0x02, 0x03, - 0x04, 0x05, 0x04, 0x05, 0x06, 0x07, 0x06, 0x07, - 0x04, 0x05, 0x04, 0x05, 0x06, 0x07, 0x06, 0x07, - 0x00, 0x01, 0x00, 0x01, 0x02, 0x03, 0x02, 0x03, - 0x00, 0x01, 0x00, 0x01, 0x02, 0x03, 0x02, 0x03, - 0x04, 0x05, 0x04, 0x05, 0x06, 0x07, 0x06, 0x07, - 0x04, 0x05, 0x04, 0x05, 0x06, 0x07, 0x06, 0x07, - 0x08, 0x09, 0x08, 0x09, 0x0a, 0x0b, 0x0a, 0x0b, - 0x08, 0x09, 0x08, 0x09, 0x0a, 0x0b, 0x0a, 0x0b, - 0x0c, 0x0d, 0x0c, 0x0d, 0x0e, 0x0f, 0x0e, 0x0f, - 0x0c, 0x0d, 0x0c, 0x0d, 0x0e, 0x0f, 0x0e, 0x0f, - 0x08, 0x09, 0x08, 0x09, 0x0a, 0x0b, 0x0a, 0x0b, - 0x08, 0x09, 0x08, 0x09, 0x0a, 0x0b, 0x0a, 0x0b, - 0x0c, 0x0d, 0x0c, 0x0d, 0x0e, 0x0f, 0x0e, 0x0f, - 0x0c, 0x0d, 0x0c, 0x0d, 0x0e, 0x0f, 0x0e, 0x0f -}; - -uint16_t __IO AudioInVolume = DEFAULT_AUDIO_IN_VOLUME; - -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_AUDIO_Private_Function_Prototypes - * @{ - */ -static void SAIx_MspInit(void); -static void SAIx_Init(uint32_t AudioFreq); -static void I2Sx_MspInit(void); -static void I2Sx_Init(uint32_t AudioFreq); -static void TIMx_IC_MspInit(TIM_HandleTypeDef *htim); -static void TIMx_Init(void); -static void PDMDecoder_Init(uint32_t AudioFreq, uint32_t ChnlNbr); -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_AUDIO_out_Private_Functions - * @{ - */ - -/** - * @brief Configures the audio peripherals. - * @param OutputDevice: OUTPUT_DEVICE_SPEAKER, OUTPUT_DEVICE_HEADPHONE, - * or OUTPUT_DEVICE_BOTH. - * @param Volume: Initial volume level (from 0 (Mute) to 100 (Max)) - * @param AudioFreq: Audio frequency used to play the audio stream. - * @note The I2S PLL input clock must be done in the user application. - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_Init(uint16_t OutputDevice, uint8_t Volume, uint32_t AudioFreq) -{ - uint8_t ret = AUDIO_ERROR; - uint32_t deviceid = 0x00; - RCC_PeriphCLKInitTypeDef RCC_ExCLKInitStruct; - - HAL_RCCEx_GetPeriphCLKConfig(&RCC_ExCLKInitStruct); - if((AudioFreq == AUDIO_FREQUENCY_11K) || (AudioFreq == AUDIO_FREQUENCY_22K) || (AudioFreq == AUDIO_FREQUENCY_44K)) - { - /* Configure PLLSAI prescalers */ - /* PLLI2S_VCO: VCO_429M - SAI_CLK(first level) = PLLI2S_VCO/PLLI2SQ = 429/2 = 214.5 Mhz - SAI_CLK_x = SAI_CLK(first level)/PLLI2SDIVQ = 214.5/19 = 11.289 Mhz */ - RCC_ExCLKInitStruct.PeriphClockSelection = RCC_PERIPHCLK_SAI_PLLI2S; - RCC_ExCLKInitStruct.PLLI2S.PLLI2SN = 429; - RCC_ExCLKInitStruct.PLLI2S.PLLI2SQ = 2; - RCC_ExCLKInitStruct.PLLI2SDivQ = 19; - HAL_RCCEx_PeriphCLKConfig(&RCC_ExCLKInitStruct); - } - else /* AUDIO_FREQUENCY_8K, AUDIO_FREQUENCY_16K, AUDIO_FREQUENCY_48K), AUDIO_FREQUENCY_96K */ - { - /* SAI clock config - PLLI2S_VCO: VCO_344M - SAI_CLK(first level) = PLLI2S_VCO/PLLI2SQ = 344/7 = 49.142 Mhz - SAI_CLK_x = SAI_CLK(first level)/PLLI2SDIVQ = 49.142/1 = 49.142 Mhz */ - RCC_ExCLKInitStruct.PeriphClockSelection = RCC_PERIPHCLK_SAI_PLLI2S; - RCC_ExCLKInitStruct.PLLI2S.PLLI2SN = 344; - RCC_ExCLKInitStruct.PLLI2S.PLLI2SQ = 7; - RCC_ExCLKInitStruct.PLLI2SDivQ = 1; - HAL_RCCEx_PeriphCLKConfig(&RCC_ExCLKInitStruct); - } - - /* SAI data transfer preparation: - Prepare the Media to be used for the audio transfer from memory to SAI peripheral */ - SAIx_Init(AudioFreq); - - /* wm8994 codec initialization */ - deviceid = wm8994_drv.ReadID(AUDIO_I2C_ADDRESS); - - if((deviceid) == WM8994_ID) - { - /* Initialize the audio driver structure */ - audio_drv = &wm8994_drv; - ret = AUDIO_OK; - } - else - { - ret = AUDIO_ERROR; - } - - if(ret == AUDIO_OK) - { - /* Initialize the codec internal registers */ - audio_drv->Init(AUDIO_I2C_ADDRESS, OutputDevice, Volume, AudioFreq); - } - - return ret; -} - -/** - * @brief Starts playing audio stream from a data buffer for a determined size. - * @param pBuffer: Pointer to the buffer - * @param Size: Number of audio data BYTES. - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_Play(uint16_t* pBuffer, uint32_t Size) -{ - /* Call the audio Codec Play function */ - if(audio_drv->Play(AUDIO_I2C_ADDRESS, pBuffer, Size) != 0) - { - return AUDIO_ERROR; - } - else - { - /* Update the Media layer and enable it for play */ - HAL_SAI_Transmit_DMA(&haudio_out_sai, (uint8_t*)pBuffer, DMA_MAX(Size / AUDIODATA_SIZE)); - - return AUDIO_OK; - } -} - -/** - * @brief Sends n-Bytes on the SAI interface. - * @param pData: pointer on data address - * @param Size: number of data to be written - * @retval None - */ -void BSP_AUDIO_OUT_ChangeBuffer(uint16_t *pData, uint16_t Size) -{ - HAL_SAI_Transmit_DMA(&haudio_out_sai, (uint8_t*)pData, Size); -} - -/** - * @brief This function Pauses the audio file stream. In case - * of using DMA, the DMA Pause feature is used. - * @WARNING When calling BSP_AUDIO_OUT_Pause() function for pause, only - * BSP_AUDIO_OUT_Resume() function should be called for resume (use of BSP_AUDIO_OUT_Play() - * function for resume could lead to unexpected behavior). - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_Pause(void) -{ - /* Call the Audio Codec Pause/Resume function */ - if(audio_drv->Pause(AUDIO_I2C_ADDRESS) != 0) - { - return AUDIO_ERROR; - } - else - { - /* Call the Media layer pause function */ - HAL_SAI_DMAPause(&haudio_out_sai); - - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; - } -} - -/** - * @brief This function Resumes the audio file stream. - * @WARNING When calling BSP_AUDIO_OUT_Pause() function for pause, only - * BSP_AUDIO_OUT_Resume() function should be called for resume (use of BSP_AUDIO_OUT_Play() - * function for resume could lead to unexpected behavior). - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_Resume(void) -{ - /* Call the Audio Codec Pause/Resume function */ - if(audio_drv->Resume(AUDIO_I2C_ADDRESS) != 0) - { - return AUDIO_ERROR; - } - else - { - /* Call the Media layer pause/resume function */ - HAL_SAI_DMAResume(&haudio_out_sai); - - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; - } -} - -/** - * @brief Stops audio playing and Power down the Audio Codec. - * @param Option: could be one of the following parameters - * - CODEC_PDWN_SW: for software power off (by writing registers). - * Then no need to reconfigure the Codec after power on. - * - CODEC_PDWN_HW: completely shut down the codec (physically). - * Then need to reconfigure the Codec after power on. - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_Stop(uint32_t Option) -{ - /* Call the Media layer stop function */ - HAL_SAI_DMAStop(&haudio_out_sai); - - /* Call Audio Codec Stop function */ - if(audio_drv->Stop(AUDIO_I2C_ADDRESS, Option) != 0) - { - return AUDIO_ERROR; - } - else - { - if(Option == CODEC_PDWN_HW) - { - /* Wait at least 100us */ - HAL_Delay(1); - } - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; - } -} - -/** - * @brief Controls the current audio volume level. - * @param Volume: Volume level to be set in percentage from 0% to 100% (0 for - * Mute and 100 for Max volume level). - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_SetVolume(uint8_t Volume) -{ - /* Call the codec volume control function with converted volume value */ - if(audio_drv->SetVolume(AUDIO_I2C_ADDRESS, Volume) != 0) - { - return AUDIO_ERROR; - } - else - { - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; - } -} - -/** - * @brief Enables or disables the MUTE mode by software - * @param Cmd: Could be AUDIO_MUTE_ON to mute sound or AUDIO_MUTE_OFF to - * unmute the codec and restore previous volume level. - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_SetMute(uint32_t Cmd) -{ - /* Call the Codec Mute function */ - if(audio_drv->SetMute(AUDIO_I2C_ADDRESS, Cmd) != 0) - { - return AUDIO_ERROR; - } - else - { - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; - } -} - -/** - * @brief Switch dynamically (while audio file is played) the output target - * (speaker or headphone). - * @param Output: The audio output target: OUTPUT_DEVICE_SPEAKER, - * OUTPUT_DEVICE_HEADPHONE or OUTPUT_DEVICE_BOTH - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_SetOutputMode(uint8_t Output) -{ - /* Call the Codec output device function */ - if(audio_drv->SetOutputMode(AUDIO_I2C_ADDRESS, Output) != 0) - { - return AUDIO_ERROR; - } - else - { - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; - } -} - -/** - * @brief Updates the audio frequency. - * @param AudioFreq: Audio frequency used to play the audio stream. - * @note This API should be called after the BSP_AUDIO_OUT_Init() to adjust the - * audio frequency. - * @retval None - */ -void BSP_AUDIO_OUT_SetFrequency(uint32_t AudioFreq) -{ - RCC_PeriphCLKInitTypeDef RCC_ExCLKInitStruct; - - HAL_RCCEx_GetPeriphCLKConfig(&RCC_ExCLKInitStruct); - - /* Update the PLL configuration according to the new frequency */ - if((AudioFreq == AUDIO_FREQUENCY_11K) || (AudioFreq == AUDIO_FREQUENCY_22K) || (AudioFreq == AUDIO_FREQUENCY_44K)) - { - /* Configure PLLSAI prescalers */ - /* PLLSAI_VCO: VCO_429M - SAI_CLK(first level) = PLLI2S_VCO/PLLI2SQ = 429/2 = 214.5 Mhz - SAI_CLK_x = SAI_CLK(first level)/PLLI2SDIVQ = 214.5/19 = 11.289 Mhz */ - RCC_ExCLKInitStruct.PeriphClockSelection = RCC_PERIPHCLK_SAI_PLLI2S; - RCC_ExCLKInitStruct.PLLI2S.PLLI2SN = 429; - RCC_ExCLKInitStruct.PLLI2S.PLLI2SQ = 2; - RCC_ExCLKInitStruct.PLLI2SDivQ = 19; - HAL_RCCEx_PeriphCLKConfig(&RCC_ExCLKInitStruct); - } - else /* AUDIO_FREQUENCY_8K, AUDIO_FREQUENCY_16K, AUDIO_FREQUENCY_48K), AUDIO_FREQUENCY_96K */ - { - /* SAI clock config - PLLI2S_VCO: VCO_344M - SAI_CLK(first level) = PLLI2S_VCO/PLLI2SQ = 344/7 = 49.142 Mhz - SAI_CLK_x = SAI_CLK(first level)/PLLI2SDIVQ = 49.142/1 = 49.142 Mhz */ - RCC_ExCLKInitStruct.PeriphClockSelection = RCC_PERIPHCLK_SAI_PLLI2S; - RCC_ExCLKInitStruct.PLLI2S.PLLI2SN = 344; - RCC_ExCLKInitStruct.PLLI2S.PLLI2SQ = 7; - RCC_ExCLKInitStruct.PLLI2SDivQ = 1; - HAL_RCCEx_PeriphCLKConfig(&RCC_ExCLKInitStruct); - } - /* Disable SAI peripheral to allow access to SAI internal registers */ - __HAL_SAI_DISABLE(&haudio_out_sai); - - /* Update the SAI audio frequency configuration */ - haudio_out_sai.Init.AudioFrequency = AudioFreq; - HAL_SAI_Init(&haudio_out_sai); - - /* Enable SAI peripheral to generate MCLK */ - __HAL_SAI_ENABLE(&haudio_out_sai); -} - -/** - * @brief Updates the Audio frame slot configuration. - * @param AudioFrameSlot: specifies the audio Frame slot - * This parameter can be any value of @ref CODEC_AudioFrame_SLOT_TDMMode - * @note This API should be called after the BSP_AUDIO_OUT_Init() to adjust the - * audio frame slot. - * @retval None - */ -void BSP_AUDIO_OUT_SetAudioFrameSlot(uint32_t AudioFrameSlot) -{ - /* Disable SAI peripheral to allow access to SAI internal registers */ - __HAL_SAI_DISABLE(&haudio_out_sai); - - /* Update the SAI audio frame slot configuration */ - haudio_out_sai.SlotInit.SlotActive = AudioFrameSlot; - HAL_SAI_Init(&haudio_out_sai); - - /* Enable SAI peripheral to generate MCLK */ - __HAL_SAI_ENABLE(&haudio_out_sai); -} - -/** - * @brief Tx Transfer completed callbacks. - * @param hsai: SAI handle - * @retval None - */ -void HAL_SAI_TxCpltCallback(SAI_HandleTypeDef *hsai) -{ - /* Manage the remaining file size and new address offset: This function - should be coded by user (its prototype is already declared in stm324x9i_eval_audio.h) */ - BSP_AUDIO_OUT_TransferComplete_CallBack(); -} - -/** - * @brief Tx Half Transfer completed callbacks. - * @param hsai: SAI handle - * @retval None - */ -void HAL_SAI_TxHalfCpltCallback(SAI_HandleTypeDef *hsai) -{ - /* Manage the remaining file size and new address offset: This function - should be coded by user (its prototype is already declared in stm324x9i_eval_audio.h) */ - BSP_AUDIO_OUT_HalfTransfer_CallBack(); -} - -/** - * @brief SAI error callbacks. - * @param hsai: SAI handle - * @retval None - */ -void HAL_SAI_ErrorCallback(SAI_HandleTypeDef *hsai) -{ - BSP_AUDIO_OUT_Error_CallBack(); -} - -/** - * @brief Manages the DMA full Transfer complete event. - * @param None - * @retval None - */ -__weak void BSP_AUDIO_OUT_TransferComplete_CallBack(void) -{ -} - -/** - * @brief Manages the DMA Half Transfer complete event. - * @param None - * @retval None - */ -__weak void BSP_AUDIO_OUT_HalfTransfer_CallBack(void) -{ -} - -/** - * @brief Manages the DMA FIFO error event. - * @param None - * @retval None - */ -__weak void BSP_AUDIO_OUT_Error_CallBack(void) -{ -} - -/******************************************************************************* - Static Functions -*******************************************************************************/ - -/** - * @brief Initializes SAI MSP. - * @param None - * @retval None - */ -static void SAIx_MspInit(void) -{ - static DMA_HandleTypeDef hdma_saiTx; - GPIO_InitTypeDef GPIO_InitStruct; - SAI_HandleTypeDef *hsai = &haudio_out_sai; - - /* Enable SAI clock */ - AUDIO_SAIx_CLK_ENABLE(); - - /* Enable GPIO clock */ - AUDIO_SAIx_MCLK_SCK_SD_FS_ENABLE(); - - /* CODEC_SAI pins configuration: FS, SCK, MCK and SD pins ------------------*/ - GPIO_InitStruct.Pin = AUDIO_SAIx_FS_PIN | AUDIO_SAIx_SCK_PIN | AUDIO_SAIx_SD_PIN | AUDIO_SAIx_MCK_PIN; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; - GPIO_InitStruct.Alternate = AUDIO_SAIx_MCLK_SCK_SD_FS_AF; - HAL_GPIO_Init(AUDIO_SAIx_MCLK_SCK_SD_FS_GPIO_PORT, &GPIO_InitStruct); - - /* Enable the DMA clock */ - AUDIO_SAIx_DMAx_CLK_ENABLE(); - - if(hsai->Instance == AUDIO_SAIx) - { - /* Configure the hdma_saiTx handle parameters */ - hdma_saiTx.Init.Channel = AUDIO_SAIx_DMAx_CHANNEL; - hdma_saiTx.Init.Direction = DMA_MEMORY_TO_PERIPH; - hdma_saiTx.Init.PeriphInc = DMA_PINC_DISABLE; - hdma_saiTx.Init.MemInc = DMA_MINC_ENABLE; - hdma_saiTx.Init.PeriphDataAlignment = AUDIO_SAIx_DMAx_PERIPH_DATA_SIZE; - hdma_saiTx.Init.MemDataAlignment = AUDIO_SAIx_DMAx_MEM_DATA_SIZE; - hdma_saiTx.Init.Mode = DMA_NORMAL; - hdma_saiTx.Init.Priority = DMA_PRIORITY_HIGH; - hdma_saiTx.Init.FIFOMode = DMA_FIFOMODE_ENABLE; - hdma_saiTx.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; - hdma_saiTx.Init.MemBurst = DMA_MBURST_SINGLE; - hdma_saiTx.Init.PeriphBurst = DMA_PBURST_SINGLE; - - hdma_saiTx.Instance = AUDIO_SAIx_DMAx_STREAM; - - /* Associate the DMA handle */ - __HAL_LINKDMA(hsai, hdmatx, hdma_saiTx); - - /* Deinitialize the Stream for new transfer */ - HAL_DMA_DeInit(&hdma_saiTx); - - /* Configure the DMA Stream */ - HAL_DMA_Init(&hdma_saiTx); - } - - /* SAI DMA IRQ Channel configuration */ - HAL_NVIC_SetPriority(AUDIO_SAIx_DMAx_IRQ, AUDIO_OUT_IRQ_PREPRIO, 0); - HAL_NVIC_EnableIRQ(AUDIO_SAIx_DMAx_IRQ); -} - -/** - * @brief Initializes the Audio Codec audio interface (SAI). - * @param AudioFreq: Audio frequency to be configured for the SAI peripheral. - * @note The default SlotActive configuration is set to CODEC_AUDIOFRAME_SLOT_0123 - * and user can update this configuration using - * @retval None - */ -static void SAIx_Init(uint32_t AudioFreq) -{ - /* Initialize the haudio_out_sai Instance parameter */ - haudio_out_sai.Instance = AUDIO_SAIx; - - /* Disable SAI peripheral to allow access to SAI internal registers */ - __HAL_SAI_DISABLE(&haudio_out_sai); - - /* Configure SAI_Block_x - LSBFirst: Disabled - DataSize: 16 */ - haudio_out_sai.Init.AudioFrequency = AudioFreq; - haudio_out_sai.Init.ClockSource = SAI_CLKSOURCE_PLLI2S; - haudio_out_sai.Init.AudioMode = SAI_MODEMASTER_TX; - haudio_out_sai.Init.NoDivider = SAI_MASTERDIVIDER_ENABLED; - haudio_out_sai.Init.Protocol = SAI_FREE_PROTOCOL; - haudio_out_sai.Init.DataSize = SAI_DATASIZE_16; - haudio_out_sai.Init.FirstBit = SAI_FIRSTBIT_MSB; - haudio_out_sai.Init.ClockStrobing = SAI_CLOCKSTROBING_RISINGEDGE; - haudio_out_sai.Init.Synchro = SAI_ASYNCHRONOUS; - haudio_out_sai.Init.OutputDrive = SAI_OUTPUTDRIVE_ENABLED; - haudio_out_sai.Init.FIFOThreshold = SAI_FIFOTHRESHOLD_1QF; - - /* Configure SAI_Block_x Frame - Frame Length: 64 - Frame active Length: 32 - FS Definition: Start frame + Channel Side identification - FS Polarity: FS active Low - FS Offset: FS asserted one bit before the first bit of slot 0 */ - haudio_out_sai.FrameInit.FrameLength = 64; - haudio_out_sai.FrameInit.ActiveFrameLength = 32; - haudio_out_sai.FrameInit.FSDefinition = SAI_FS_CHANNEL_IDENTIFICATION; - haudio_out_sai.FrameInit.FSPolarity = SAI_FS_ACTIVE_LOW; - haudio_out_sai.FrameInit.FSOffset = SAI_FS_BEFOREFIRSTBIT; - - /* Configure SAI Block_x Slot - Slot First Bit Offset: 0 - Slot Size : 16 - Slot Number: 4 - Slot Active: All slot actives */ - haudio_out_sai.SlotInit.FirstBitOffset = 0; - haudio_out_sai.SlotInit.SlotSize = SAI_SLOTSIZE_DATASIZE; - haudio_out_sai.SlotInit.SlotNumber = 4; - haudio_out_sai.SlotInit.SlotActive = CODEC_AUDIOFRAME_SLOT_0123; - if(HAL_SAI_GetState(&haudio_out_sai) == HAL_SAI_STATE_RESET) - { - /* Init the SAI */ - SAIx_MspInit(); - } - HAL_SAI_Init(&haudio_out_sai); - - /* Enable SAI peripheral to generate MCLK */ - __HAL_SAI_ENABLE(&haudio_out_sai); -} - -/** @defgroup STM324x9I_EVAL_AUDIO_out_Private_Functions - * @{ - */ - -/** - * @brief Initializes wave recording. - * @note This function assumes that the I2S input clock (through PLL_R in - * Devices RevA/Z and through dedicated PLLI2S_R in Devices RevB/Y) - * is already configured and ready to be used. - * @param AudioFreq: Audio frequency to be configured for the I2S peripheral. - * @param BitRes: Audio frequency to be configured for the I2S peripheral. - * @param ChnlNbr: Audio frequency to be configured for the I2S peripheral. - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_IN_Init(uint32_t AudioFreq, uint32_t BitRes, uint32_t ChnlNbr) -{ - RCC_PeriphCLKInitTypeDef RCC_ExCLKInitStruct; - - HAL_RCCEx_GetPeriphCLKConfig(&RCC_ExCLKInitStruct); - RCC_ExCLKInitStruct.PeriphClockSelection = RCC_PERIPHCLK_I2S; - RCC_ExCLKInitStruct.PLLI2S.PLLI2SN = 384; - RCC_ExCLKInitStruct.PLLI2S.PLLI2SR = 2; - HAL_RCCEx_PeriphCLKConfig(&RCC_ExCLKInitStruct); - - /* Configure the PDM library */ - PDMDecoder_Init(AudioFreq, ChnlNbr); - - /* Configure the Timer which clocks the MEMS */ - TIMx_Init(); - - /* Configure the I2S peripheral */ - I2Sx_Init(AudioFreq); - - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; -} - -/** - * @brief Starts audio recording. - * @param pbuf: Main buffer pointer for the recorded data storing - * @param size: Current size of the recorded buffer - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_IN_Record(uint16_t* pbuf, uint32_t size) -{ - uint32_t ret = AUDIO_ERROR; - - /* Start the process receive DMA */ - HAL_I2S_Receive_DMA(&haudio_in_i2s, pbuf, size); - - /* Return AUDIO_OK when all operations are correctly done */ - ret = AUDIO_OK; - - return ret; -} - -/** - * @brief Stops audio recording. - * @param None - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_IN_Stop(void) -{ - uint32_t ret = AUDIO_ERROR; - - /* Call the Media layer pause function */ - HAL_I2S_DMAPause(&haudio_in_i2s); - - /* TIMx Peripheral clock disable */ - AUDIO_TIMx_CLK_DISABLE(); - - /* Return AUDIO_OK when all operations are correctly done */ - ret = AUDIO_OK; - - return ret; -} - -/** - * @brief Pauses the audio file stream. - * @param None - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_IN_Pause(void) -{ - /* Call the Media layer pause function */ - HAL_I2S_DMAPause(&haudio_in_i2s); - - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; -} - -/** - * @brief Resumes the audio file stream. - * @param None - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_IN_Resume(void) -{ - /* Call the Media layer pause/resume function */ - HAL_I2S_DMAResume(&haudio_in_i2s); - - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; -} - -/** - * @brief Controls the audio in volume level. - * @param Volume: Volume level to be set in percentage from 0% to 100% (0 for - * Mute and 100 for Max volume level). - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_IN_SetVolume(uint8_t Volume) -{ - /* Set the Global variable AudioInVolume */ - AudioInVolume = Volume; - - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; -} - -/** - * @brief Converts audio format from PDM to PCM. - * @param PDMBuf: Pointer to data PDM buffer - * @param PCMBuf: Pointer to data PCM buffer - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_IN_PDMToPCM(uint16_t* PDMBuf, uint16_t* PCMBuf) -{ - uint8_t AppPDM[INTERNAL_BUFF_SIZE*2]; - uint8_t byte1 = 0, byte2 = 0; - uint32_t index = 0; - - /* PDM Demux */ - for(index = 0; index> 8)& 0xFF; - byte1 = (PDMBuf[index] & 0xFF); - AppPDM[(index*2)+1] = Channel_Demux[byte1 & CHANNEL_DEMUX_MASK] | Channel_Demux[byte2 & CHANNEL_DEMUX_MASK] << 4; - AppPDM[(index*2)] = Channel_Demux[(byte1 >> 1) & CHANNEL_DEMUX_MASK] | Channel_Demux[(byte2 >> 1) & CHANNEL_DEMUX_MASK] << 4; - } - - for(index = 0; index < DEFAULT_AUDIO_IN_CHANNEL_NBR; index++) - { - /* PDM to PCM filter */ - PDM_Filter_64_LSB((uint8_t*)&AppPDM[index], (uint16_t*)&(PCMBuf[index]), AudioInVolume , (PDMFilter_InitStruct *)&Filter[index]); - } - - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; -} - - /** - * @brief Rx Transfer completed callbacks. - * @param hi2s: I2S handle - * @retval None - */ -void HAL_I2S_RxCpltCallback(I2S_HandleTypeDef *hi2s) -{ - /* Call the record update function to get the next buffer to fill and its size (size is ignored) */ - BSP_AUDIO_IN_TransferComplete_CallBack(); -} - -/** - * @brief Rx Half Transfer completed callbacks. - * @param hi2s: I2S handle - * @retval None - */ -void HAL_I2S_RxHalfCpltCallback(I2S_HandleTypeDef *hi2s) -{ - /* Manage the remaining file size and new address offset: This function - should be coded by user (its prototype is already declared in stm324x9i_eval_audio.h) */ - BSP_AUDIO_IN_HalfTransfer_CallBack(); -} - -/** - * @brief I2S error callbacks. - * @param hi2s: I2S handle - * @retval None - */ -void HAL_I2S_ErrorCallback(I2S_HandleTypeDef *hi2s) -{ - /* Manage the error generated on DMA FIFO: This function - should be coded by user (its prototype is already declared in stm324x9i_eval_audio.h) */ - BSP_AUDIO_IN_Error_Callback(); -} - -/** - * @brief User callback when record buffer is filled. - * @param None - * @retval None - */ -__weak void BSP_AUDIO_IN_TransferComplete_CallBack(void) -{ - /* This function should be implemented by the user application. - It is called into this driver when the current buffer is filled - to prepare the next buffer pointer and its size. */ -} - -/** - * @brief Manages the DMA Half Transfer complete event. - * @param None - * @retval None - */ -__weak void BSP_AUDIO_IN_HalfTransfer_CallBack(void) -{ - /* This function should be implemented by the user application. - It is called into this driver when the current buffer is filled - to prepare the next buffer pointer and its size. */ -} - -/** - * @brief Audio IN Error callback function. - * @param None - * @retval None - */ -__weak void BSP_AUDIO_IN_Error_Callback(void) -{ - /* This function is called when an Interrupt due to transfer error on or peripheral - error occurs. */ -} - -/******************************************************************************* - Static Functions -*******************************************************************************/ - -/** - * @brief Initializes the PDM library. - * @param AudioFreq: Audio sampling frequency - * @param ChnlNbr: Number of audio channels (1: mono; 2: stereo) - * @retval None - */ -static void PDMDecoder_Init(uint32_t AudioFreq, uint32_t ChnlNbr) -{ - uint32_t i = 0; - - /* Enable CRC peripheral to unlock the PDM library */ - __CRC_CLK_ENABLE(); - - for(i = 0; i < ChnlNbr; i++) - { - /* Filter LP & HP Init */ - Filter[i].LP_HZ = AudioFreq/2; - Filter[i].HP_HZ = 10; - Filter[i].Fs = AudioFreq; - Filter[i].Out_MicChannels = ChnlNbr; - Filter[i].In_MicChannels = ChnlNbr; - PDM_Filter_Init((PDMFilter_InitStruct *)&Filter[i]); - } -} - -/** - * @brief AUDIO IN I2S MSP Init. - * @param hi2s: I2S handle - * @retval None - */ -static void I2Sx_MspInit(void) -{ - static DMA_HandleTypeDef hdma_i2sRx; - GPIO_InitTypeDef GPIO_InitStruct; - I2S_HandleTypeDef *hi2s = &haudio_in_i2s; - - /* Enable I2S clock */ - AUDIO_I2Sx_CLK_ENABLE(); - - /* Enable SCK and SD GPIO clock */ - AUDIO_I2Sx_SD_GPIO_CLK_ENABLE(); - AUDIO_I2Sx_SCK_GPIO_CLK_ENABLE(); - /* CODEC_I2S pins configuration: WS, SCK and SD pins */ - GPIO_InitStruct.Pin = AUDIO_I2Sx_SCK_PIN; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FAST; - GPIO_InitStruct.Alternate = AUDIO_I2Sx_SCK_AF; - HAL_GPIO_Init(AUDIO_I2Sx_SCK_GPIO_PORT, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = AUDIO_I2Sx_SD_PIN; - GPIO_InitStruct.Alternate = AUDIO_I2Sx_SD_AF; - HAL_GPIO_Init(AUDIO_I2Sx_SD_GPIO_PORT, &GPIO_InitStruct); - - /* Enable the DMA clock */ - AUDIO_I2Sx_DMAx_CLK_ENABLE(); - - if(hi2s->Instance == AUDIO_I2Sx) - { - /* Configure the hdma_i2sRx handle parameters */ - hdma_i2sRx.Init.Channel = AUDIO_I2Sx_DMAx_CHANNEL; - hdma_i2sRx.Init.Direction = DMA_PERIPH_TO_MEMORY; - hdma_i2sRx.Init.PeriphInc = DMA_PINC_DISABLE; - hdma_i2sRx.Init.MemInc = DMA_MINC_ENABLE; - hdma_i2sRx.Init.PeriphDataAlignment = AUDIO_I2Sx_DMAx_PERIPH_DATA_SIZE; - hdma_i2sRx.Init.MemDataAlignment = AUDIO_I2Sx_DMAx_MEM_DATA_SIZE; - hdma_i2sRx.Init.Mode = DMA_CIRCULAR; - hdma_i2sRx.Init.Priority = DMA_PRIORITY_HIGH; - hdma_i2sRx.Init.FIFOMode = DMA_FIFOMODE_DISABLE; - hdma_i2sRx.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; - hdma_i2sRx.Init.MemBurst = DMA_MBURST_SINGLE; - hdma_i2sRx.Init.PeriphBurst = DMA_MBURST_SINGLE; - - hdma_i2sRx.Instance = AUDIO_I2Sx_DMAx_STREAM; - - /* Associate the DMA handle */ - __HAL_LINKDMA(hi2s, hdmarx, hdma_i2sRx); - - /* Deinitialize the Stream for new transfer */ - HAL_DMA_DeInit(&hdma_i2sRx); - - /* Configure the DMA Stream */ - HAL_DMA_Init(&hdma_i2sRx); - } - - /* I2S DMA IRQ Channel configuration */ - HAL_NVIC_SetPriority(AUDIO_I2Sx_DMAx_IRQ, AUDIO_IN_IRQ_PREPRIO, 0); - HAL_NVIC_EnableIRQ(AUDIO_I2Sx_DMAx_IRQ); -} - -/** - * @brief Initializes the Audio Codec audio interface (I2S) - * @note This function assumes that the I2S input clock (through PLL_R in - * Devices RevA/Z and through dedicated PLLI2S_R in Devices RevB/Y) - * is already configured and ready to be used. - * @param AudioFreq: Audio frequency to be configured for the I2S peripheral. - * @retval None - */ -static void I2Sx_Init(uint32_t AudioFreq) -{ - /* Initialize the haudio_in_i2s Instance parameter */ - haudio_in_i2s.Instance = AUDIO_I2Sx; - - /* Disable I2S block */ - __HAL_I2S_DISABLE(&haudio_in_i2s); - - /* I2S2 peripheral configuration */ - haudio_in_i2s.Init.AudioFreq = 4 * AudioFreq; - haudio_in_i2s.Init.ClockSource = I2S_CLOCK_PLL; - haudio_in_i2s.Init.CPOL = I2S_CPOL_HIGH; - haudio_in_i2s.Init.DataFormat = I2S_DATAFORMAT_16B; - haudio_in_i2s.Init.MCLKOutput = I2S_MCLKOUTPUT_DISABLE; - haudio_in_i2s.Init.Mode = I2S_MODE_MASTER_RX; - haudio_in_i2s.Init.Standard = I2S_STANDARD_LSB; - if(HAL_I2S_GetState(&haudio_in_i2s) == HAL_I2S_STATE_RESET) - { - /* Initialize the I2S peripheral with the structure above */ - I2Sx_MspInit(); - } - - /* Init the I2S */ - HAL_I2S_Init(&haudio_in_i2s); -} - -/** - * @brief Initializes the TIM INput Capture MSP. - * @param htim: TIM handle - * @retval None - */ -static void TIMx_IC_MspInit(TIM_HandleTypeDef *htim) -{ - GPIO_InitTypeDef GPIO_InitStruct; - - /* Enable peripherals and GPIO Clocks --------------------------------------*/ - /* TIMx Peripheral clock enable */ - AUDIO_TIMx_CLK_ENABLE(); - - /* Enable GPIO Channels Clock */ - AUDIO_TIMx_GPIO_CLK_ENABLE(); - - /* Configure I/Os ----------------------------------------------------------*/ - /* Common configuration for all channels */ - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; - GPIO_InitStruct.Alternate = AUDIO_TIMx_AF; - - /* Configure TIM input channel */ - GPIO_InitStruct.Pin = AUDIO_TIMx_IN_GPIO_PIN; - HAL_GPIO_Init(AUDIO_TIMx_GPIO, &GPIO_InitStruct); - - /* Configure TIM output channel */ - GPIO_InitStruct.Pin = AUDIO_TIMx_OUT_GPIO_PIN; - HAL_GPIO_Init(AUDIO_TIMx_GPIO, &GPIO_InitStruct); -} - -/** - * @brief Configure TIM as a clock divider by 2. - * I2S_SCK is externally connected to TIMx input channel - * @param None - * @retval None - */ -static void TIMx_Init(void) -{ - TIM_IC_InitTypeDef sICConfig; - TIM_OC_InitTypeDef sOCConfig; - TIM_ClockConfigTypeDef sCLKSourceConfig; - TIM_SlaveConfigTypeDef sSlaveConfig; - - /* Configure the TIM peripheral --------------------------------------------*/ - /* Set TIMx instance */ - haudio_tim.Instance = AUDIO_TIMx; - /* Timer Input Capture Configuration Structure declaration */ - /* Initialize TIMx peripheral as follow: - + Period = 0xFFFF - + Prescaler = 0 - + ClockDivision = 0 - + Counter direction = Up - */ - haudio_tim.Init.Period = 1; - haudio_tim.Init.Prescaler = 0; - haudio_tim.Init.ClockDivision = 0; - haudio_tim.Init.CounterMode = TIM_COUNTERMODE_UP; - - /* Initialize the TIMx peripheral with the structure above */ - TIMx_IC_MspInit(&haudio_tim); - HAL_TIM_IC_Init(&haudio_tim); - - /* Configure the Input Capture channel -------------------------------------*/ - /* Configure the Input Capture of channel 2 */ - sICConfig.ICPolarity = TIM_ICPOLARITY_FALLING; - sICConfig.ICSelection = TIM_ICSELECTION_DIRECTTI; - sICConfig.ICPrescaler = TIM_ICPSC_DIV1; - sICConfig.ICFilter = 0; - HAL_TIM_IC_ConfigChannel(&haudio_tim, &sICConfig, AUDIO_TIMx_IN_CHANNEL); - - /* Select external clock mode 1 */ - sCLKSourceConfig.ClockSource = TIM_CLOCKSOURCE_ETRMODE1; - sCLKSourceConfig.ClockPolarity = TIM_CLOCKPOLARITY_NONINVERTED; - sCLKSourceConfig.ClockPrescaler = TIM_CLOCKPRESCALER_DIV1; - sCLKSourceConfig.ClockFilter = 0; - HAL_TIM_ConfigClockSource(&haudio_tim, &sCLKSourceConfig); - - /* Select Input Channel as input trigger */ - sSlaveConfig.InputTrigger = TIM_TS_TI1FP1; - sSlaveConfig.SlaveMode = TIM_SLAVEMODE_EXTERNAL1; - sSlaveConfig.TriggerPolarity = TIM_TRIGGERPOLARITY_NONINVERTED; - sSlaveConfig.TriggerPrescaler = TIM_CLOCKPRESCALER_DIV1; - sSlaveConfig.TriggerFilter = 0; - HAL_TIM_SlaveConfigSynchronization(&haudio_tim, &sSlaveConfig); - - /* Output Compare PWM Mode configuration: Channel2 */ - sOCConfig.OCMode = TIM_OCMODE_PWM1; - sOCConfig.OCIdleState = TIM_OCIDLESTATE_SET; - sOCConfig.Pulse = 1; - sOCConfig.OCPolarity = TIM_OCPOLARITY_HIGH; - sOCConfig.OCNPolarity = TIM_OCNPOLARITY_HIGH; - sOCConfig.OCFastMode = TIM_OCFAST_DISABLE; - sOCConfig.OCNIdleState = TIM_OCNIDLESTATE_SET; - - /* Initialize the TIM3 Channel2 with the structure above */ - HAL_TIM_PWM_ConfigChannel(&haudio_tim, &sOCConfig, AUDIO_TIMx_OUT_CHANNEL); - - /* Start the TIM3 Channel2 */ - HAL_TIM_PWM_Start(&haudio_tim, AUDIO_TIMx_OUT_CHANNEL); - - /* Start the TIM3 Channel1 */ - HAL_TIM_IC_Start(&haudio_tim, AUDIO_TIMx_IN_CHANNEL); -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval_audio.h b/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval_audio.h deleted file mode 100644 index 3c85a54f1e..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval_audio.h +++ /dev/null @@ -1,293 +0,0 @@ -/** - ****************************************************************************** - * @file stm324x9i_eval_audio.h - * @author MCD Application Team - * @version V2.2.1 - * @date 07-October-2015 - * @brief This file contains the common defines and functions prototypes for - * the stm324x9i_eval_audio.c driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM324x9I_EVAL_AUDIO_H -#define __STM324x9I_EVAL_AUDIO_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -/* Include audio component Driver */ -#include "../Components/wm8994/wm8994.h" -#include "stm324x9i_eval.h" -#include "../../../Middlewares/ST/STM32_Audio/Addons/PDM/pdm_filter.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM324x9I_EVAL - * @{ - */ - -/** @defgroup STM324x9I_EVAL_AUDIO - * @{ - */ - -/** @defgroup STM324x9I_EVAL_AUDIO_Exported_Types - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_AUDIO_Exported_Constants - * @{ - */ - -/*------------------------------------------------------------------------------ - USER SAI defines parameters - -----------------------------------------------------------------------------*/ -/** @defgroup CODEC_AudioFrame_SLOT_TDMMode - * @brief In W8994 codec the Audio frame contains 4 slots : TDM Mode - * TDM format : - * +------------------|------------------|--------------------|-------------------+ - * | CODEC_SLOT0 Left | CODEC_SLOT1 Left | CODEC_SLOT0 Right | CODEC_SLOT1 Right | - * +------------------------------------------------------------------------------+ - * @{ - */ -/* To have 2 separate audio stream in Both headphone and speaker the 4 slot must be activated */ -#define CODEC_AUDIOFRAME_SLOT_0123 SAI_SLOTACTIVE_0 | SAI_SLOTACTIVE_1 | SAI_SLOTACTIVE_2 | SAI_SLOTACTIVE_3 -/* To have an audio stream in headphone only SAI Slot 0 and Slot 2 must be activated */ -#define CODEC_AUDIOFRAME_SLOT_02 SAI_SLOTACTIVE_0 | SAI_SLOTACTIVE_2 -/* To have an audio stream in speaker only SAI Slot 1 and Slot 3 must be activated */ -#define CODEC_AUDIOFRAME_SLOT_13 SAI_SLOTACTIVE_1 | SAI_SLOTACTIVE_3 -/** - * @} - */ - -/* SAI peripheral configuration defines */ -#define AUDIO_SAIx SAI1_Block_B -#define AUDIO_SAIx_CLK_ENABLE() __SAI1_CLK_ENABLE() -#define AUDIO_SAIx_MCLK_SCK_SD_FS_AF GPIO_AF6_SAI1 - -#define AUDIO_SAIx_MCLK_SCK_SD_FS_ENABLE() __GPIOF_CLK_ENABLE() -#define AUDIO_SAIx_FS_PIN GPIO_PIN_9 -#define AUDIO_SAIx_SCK_PIN GPIO_PIN_8 -#define AUDIO_SAIx_SD_PIN GPIO_PIN_6 -#define AUDIO_SAIx_MCK_PIN GPIO_PIN_7 -#define AUDIO_SAIx_MCLK_SCK_SD_FS_GPIO_PORT GPIOF - - -/* SAI DMA Stream definitions */ -#define AUDIO_SAIx_DMAx_CLK_ENABLE() __DMA2_CLK_ENABLE() -#define AUDIO_SAIx_DMAx_STREAM DMA2_Stream5 -#define AUDIO_SAIx_DMAx_CHANNEL DMA_CHANNEL_0 -#define AUDIO_SAIx_DMAx_IRQ DMA2_Stream5_IRQn -#define AUDIO_SAIx_DMAx_PERIPH_DATA_SIZE DMA_PDATAALIGN_HALFWORD -#define AUDIO_SAIx_DMAx_MEM_DATA_SIZE DMA_MDATAALIGN_HALFWORD -#define DMA_MAX_SZE 0xFFFF - -#define AUDIO_SAIx_DMAx_IRQHandler DMA2_Stream5_IRQHandler - -/* Select the interrupt preemption priority for the DMA interrupt */ -#define AUDIO_OUT_IRQ_PREPRIO 5 /* Select the preemption priority level(0 is the highest) */ - -/*------------------------------------------------------------------------------ - AUDIO IN CONFIGURATION -------------------------------------------------------------------------------*/ -/* SPI Configuration defines */ -#define AUDIO_I2Sx SPI3 -#define AUDIO_I2Sx_CLK_ENABLE() __SPI3_CLK_ENABLE() -#define AUDIO_I2Sx_SCK_PIN GPIO_PIN_3 -#define AUDIO_I2Sx_SCK_GPIO_PORT GPIOB -#define AUDIO_I2Sx_SCK_GPIO_CLK_ENABLE() __GPIOB_CLK_ENABLE() -#define AUDIO_I2Sx_SCK_AF GPIO_AF6_SPI3 - -#define AUDIO_I2Sx_SD_PIN GPIO_PIN_6 -#define AUDIO_I2Sx_SD_GPIO_PORT GPIOD -#define AUDIO_I2Sx_SD_GPIO_CLK_ENABLE() __GPIOD_CLK_ENABLE() -#define AUDIO_I2Sx_SD_AF GPIO_AF5_I2S3ext - -/* I2S DMA Stream Rx definitions */ -#define AUDIO_I2Sx_DMAx_CLK_ENABLE() __DMA1_CLK_ENABLE() -#define AUDIO_I2Sx_DMAx_STREAM DMA1_Stream2 -#define AUDIO_I2Sx_DMAx_CHANNEL DMA_CHANNEL_0 -#define AUDIO_I2Sx_DMAx_IRQ DMA1_Stream2_IRQn -#define AUDIO_I2Sx_DMAx_PERIPH_DATA_SIZE DMA_PDATAALIGN_HALFWORD -#define AUDIO_I2Sx_DMAx_MEM_DATA_SIZE DMA_MDATAALIGN_HALFWORD - -#define AUDIO_I2Sx_DMAx_IRQHandler DMA1_Stream2_IRQHandler - -/* Select the interrupt preemption priority and subpriority for the IT/DMA interrupt */ -#define AUDIO_IN_IRQ_PREPRIO 6 /* Select the preemption priority level(0 is the highest) */ - - -/* Two channels are used: - - one channel as input which is connected to I2S SCK in stereo mode - - one channel as output which divides the frequency on the input -*/ - -#define AUDIO_TIMx_CLK_ENABLE() __TIM3_CLK_ENABLE() -#define AUDIO_TIMx_CLK_DISABLE() __TIM3_CLK_DISABLE() -#define AUDIO_TIMx TIM3 -#define AUDIO_TIMx_IN_CHANNEL TIM_CHANNEL_1 -#define AUDIO_TIMx_OUT_CHANNEL TIM_CHANNEL_2 /* Select channel 2 as output */ -#define AUDIO_TIMx_GPIO_CLK_ENABLE() __GPIOC_CLK_ENABLE() -#define AUDIO_TIMx_GPIO GPIOC -#define AUDIO_TIMx_IN_GPIO_PIN GPIO_PIN_6 -#define AUDIO_TIMx_OUT_GPIO_PIN GPIO_PIN_7 -#define AUDIO_TIMx_AF GPIO_AF2_TIM3 - -/*------------------------------------------------------------------------------ - CONFIGURATION: Audio Driver Configuration parameters -------------------------------------------------------------------------------*/ - -#define AUDIODATA_SIZE 2 /* 16-bits audio data size */ - -/* Audio status definition */ -#define AUDIO_OK 0 -#define AUDIO_ERROR 1 -#define AUDIO_TIMEOUT 2 - -/* AudioFreq * DataSize (2 bytes) * NumChannels (Stereo: 2) */ -#define DEFAULT_AUDIO_IN_FREQ I2S_AUDIOFREQ_16K -#define DEFAULT_AUDIO_IN_BIT_RESOLUTION 16 -#define DEFAULT_AUDIO_IN_CHANNEL_NBR 2 /* Mono = 1, Stereo = 2 */ -#define DEFAULT_AUDIO_IN_VOLUME 64 - -/* PDM buffer input size */ -#define INTERNAL_BUFF_SIZE 128*DEFAULT_AUDIO_IN_FREQ/16000*DEFAULT_AUDIO_IN_CHANNEL_NBR -/* PCM buffer output size */ -#define PCM_OUT_SIZE DEFAULT_AUDIO_IN_FREQ/1000*2 -#define CHANNEL_DEMUX_MASK 0x55 - -/*------------------------------------------------------------------------------ - OPTIONAL Configuration defines parameters -------------------------------------------------------------------------------*/ - -/* Delay for the Codec to be correctly reset */ -#define CODEC_RESET_DELAY 5 - -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_AUDIO_Exported_Variables - * @{ - */ -extern __IO uint16_t AudioInVolume; - /** - * @} - */ - -/** @defgroup STM324x9I_EVAL_AUDIO_Exported_Macros - * @{ - */ -#define DMA_MAX(x) (((x) <= DMA_MAX_SZE)? (x):DMA_MAX_SZE) -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_AUDIO_OUT_Exported_Functions - * @{ - */ -uint8_t BSP_AUDIO_OUT_Init(uint16_t OutputDevice, uint8_t Volume, uint32_t AudioFreq); -uint8_t BSP_AUDIO_OUT_Play(uint16_t* pBuffer, uint32_t Size); -void BSP_AUDIO_OUT_ChangeBuffer(uint16_t *pData, uint16_t Size); -uint8_t BSP_AUDIO_OUT_Pause(void); -uint8_t BSP_AUDIO_OUT_Resume(void); -uint8_t BSP_AUDIO_OUT_Stop(uint32_t Option); -uint8_t BSP_AUDIO_OUT_SetVolume(uint8_t Volume); -void BSP_AUDIO_OUT_SetFrequency(uint32_t AudioFreq); -void BSP_AUDIO_OUT_SetAudioFrameSlot(uint32_t AudioFrameSlot); -uint8_t BSP_AUDIO_OUT_SetMute(uint32_t Cmd); -uint8_t BSP_AUDIO_OUT_SetOutputMode(uint8_t Output); - -/* User Callbacks: user has to implement these functions in his code if they are needed. */ -/* This function is called when the requested data has been completely transferred.*/ -void BSP_AUDIO_OUT_TransferComplete_CallBack(void); - -/* This function is called when half of the requested buffer has been transferred. */ -void BSP_AUDIO_OUT_HalfTransfer_CallBack(void); - -/* This function is called when an Interrupt due to transfer error on or peripheral - error occurs. */ -void BSP_AUDIO_OUT_Error_CallBack(void); - -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_AUDIO_IN_Exported_Functions - * @{ - */ -uint8_t BSP_AUDIO_IN_Init(uint32_t AudioFreq, uint32_t BitRes, uint32_t ChnlNbr); -uint8_t BSP_AUDIO_IN_Record(uint16_t *pData, uint32_t Size); -uint8_t BSP_AUDIO_IN_Stop(void); -uint8_t BSP_AUDIO_IN_Pause(void); -uint8_t BSP_AUDIO_IN_Resume(void); -uint8_t BSP_AUDIO_IN_SetVolume(uint8_t Volume); -uint8_t BSP_AUDIO_IN_PDMToPCM(uint16_t* PDMBuf, uint16_t* PCMBuf); -/* User Callbacks: user has to implement these functions in his code if they are needed. */ -/* This function should be implemented by the user application. - It is called into this driver when the current buffer is filled to prepare the next - buffer pointer and its size. */ -void BSP_AUDIO_IN_TransferComplete_CallBack(void); -void BSP_AUDIO_IN_HalfTransfer_CallBack(void); - -/* This function is called when an Interrupt due to transfer error on or peripheral - error occurs. */ -void BSP_AUDIO_IN_Error_Callback(void); - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM324x9I_EVAL_AUDIO_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval_camera.c b/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval_camera.c deleted file mode 100644 index f010984d00..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval_camera.c +++ /dev/null @@ -1,592 +0,0 @@ -/** - ****************************************************************************** - * @file stm324x9i_eval_camera.c - * @author MCD Application Team - * @version V2.2.1 - * @date 07-October-2015 - * @brief This file includes the driver for Camera modules mounted on - * STM324x9I-EVAL evaluation board. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* File Info: ------------------------------------------------------------------ - User NOTES -1. How to use this driver: --------------------------- - - This driver is used to drive the camera. - - The OV2640 component driver MUST be included with this driver. - -2. Driver description: ---------------------- - + Initialization steps: - o Initialize the camera using the BSP_CAMERA_Init() function. - o Start the camera capture/snapshot using the CAMERA_Start() function. - o Suspend, resume or stop the camera capture using the following functions: - - BSP_CAMERA_Suspend() - - BSP_CAMERA_Resume() - - BSP_CAMERA_Stop() - - + Options - o Increase or decrease on the fly the brightness and/or contrast - using the following function: - - BSP_CAMERA_ContrastBrightnessConfig - o Add a special effect on the fly using the following functions: - - BSP_CAMERA_BlackWhiteConfig() - - BSP_CAMERA_ColorEffectConfig() - -------------------------------------------------------------------------------*/ - -/* Includes ------------------------------------------------------------------*/ -#include "stm324x9i_eval_camera.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM324x9I_EVAL - * @{ - */ - -/** @addtogroup STM324x9I_EVAL_CAMERA - * @{ - */ - -/** @defgroup STM324x9I_EVAL_CAMERA_Private_TypesDefinitions - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_CAMERA_Private_Defines - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_CAMERA_Private_Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_CAMERA_Private_Variables - * @{ - */ -static DCMI_HandleTypeDef hdcmi_eval; - CAMERA_DrvTypeDef *camera_drv; -uint32_t current_resolution; -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_CAMERA_Private_FunctionPrototypes - * @{ - */ -static void DCMI_MspInit(void); -static uint32_t GetSize(uint32_t resolution); -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_CAMERA_Private_Functions - * @{ - */ - -/** - * @brief Initializes the camera. - * @param Camera: Pointer to the camera configuration structure - * @retval Camera status - */ -uint8_t BSP_CAMERA_Init(uint32_t Resolution) -{ - DCMI_HandleTypeDef *phdcmi; - - uint8_t ret = CAMERA_ERROR; - - /* Get the DCMI handle structure */ - phdcmi = &hdcmi_eval; - - /*** Configures the DCMI to interface with the camera module ***/ - /* DCMI configuration */ - phdcmi->Init.CaptureRate = DCMI_CR_ALL_FRAME; - phdcmi->Init.HSPolarity = DCMI_HSPOLARITY_LOW; - phdcmi->Init.SynchroMode = DCMI_SYNCHRO_HARDWARE; - phdcmi->Init.VSPolarity = DCMI_VSPOLARITY_LOW; - phdcmi->Init.ExtendedDataMode = DCMI_EXTEND_DATA_8B; - phdcmi->Init.PCKPolarity = DCMI_PCKPOLARITY_RISING; - phdcmi->Instance = DCMI; - - /* Configure IO functionalities for camera detect pin */ - BSP_IO_Init(); - - /* Set the camera STANDBY pin */ - BSP_IO_ConfigPin(XSDN_PIN, IO_MODE_OUTPUT); - BSP_IO_WritePin(XSDN_PIN, SET); - - /* Check if the camera is plugged */ - if(BSP_IO_ReadPin(CAM_PLUG_PIN)) - { - return CAMERA_ERROR; - } - - /* DCMI Initialization */ - DCMI_MspInit(); - HAL_DCMI_Init(phdcmi); - - if(ov2640_ReadID(CAMERA_I2C_ADDRESS) == OV2640_ID) - { - /* Initialize the camera driver structure */ - camera_drv = &ov2640_drv; - - /* Camera Init */ - camera_drv->Init(CAMERA_I2C_ADDRESS, Resolution); - - /* Return CAMERA_OK status */ - ret = CAMERA_OK; - } - - current_resolution = Resolution; - - return ret; -} - -/** - * @brief Starts the camera capture in continuous mode. - * @param buff: pointer to the camera output buffer - * @retval None - */ -void BSP_CAMERA_ContinuousStart(uint8_t *buff) -{ - /* Start the camera capture */ - HAL_DCMI_Start_DMA(&hdcmi_eval, DCMI_MODE_CONTINUOUS, (uint32_t)buff, GetSize(current_resolution)); -} - -/** - * @brief Starts the camera capture in snapshot mode. - * @param buff: pointer to the camera output buffer - * @retval None - */ -void BSP_CAMERA_SnapshotStart(uint8_t *buff) -{ - /* Start the camera capture */ - HAL_DCMI_Start_DMA(&hdcmi_eval, DCMI_MODE_SNAPSHOT, (uint32_t)buff, GetSize(current_resolution)); -} - -/** - * @brief Suspend the CAMERA capture - * @param None - * @retval None - */ -void BSP_CAMERA_Suspend(void) -{ - /* Disable the DMA */ - __HAL_DMA_DISABLE(hdcmi_eval.DMA_Handle); - /* Disable the DCMI */ - __HAL_DCMI_DISABLE(&hdcmi_eval); - -} - -/** - * @brief Resume the CAMERA capture - * @param None - * @retval None - */ -void BSP_CAMERA_Resume(void) -{ - /* Enable the DCMI */ - __HAL_DCMI_ENABLE(&hdcmi_eval); - /* Enable the DMA */ - __HAL_DMA_ENABLE(hdcmi_eval.DMA_Handle); -} - -/** - * @brief Stop the CAMERA capture - * @param None - * @retval Camera status - */ -uint8_t BSP_CAMERA_Stop(void) -{ - DCMI_HandleTypeDef *phdcmi; - - uint8_t ret = CAMERA_ERROR; - - /* Get the DCMI handle structure */ - phdcmi = &hdcmi_eval; - - if(HAL_DCMI_Stop(phdcmi) == HAL_OK) - { - ret = CAMERA_OK; - } - - /* Initialize IO */ - BSP_IO_Init(); - - /* Reset the camera STANDBY pin */ - BSP_IO_ConfigPin(XSDN_PIN, IO_MODE_OUTPUT); - BSP_IO_WritePin(XSDN_PIN, RESET); - - return ret; -} - -/** - * @brief Configures the camera contrast and brightness. - * @param contrast_level: Contrast level - * This parameter can be one of the following values: - * @arg CAMERA_CONTRAST_LEVEL4: for contrast +2 - * @arg CAMERA_CONTRAST_LEVEL3: for contrast +1 - * @arg CAMERA_CONTRAST_LEVEL2: for contrast 0 - * @arg CAMERA_CONTRAST_LEVEL1: for contrast -1 - * @arg CAMERA_CONTRAST_LEVEL0: for contrast -2 - * @param brightness_level: Contrast level - * This parameter can be one of the following values: - * @arg CAMERA_BRIGHTNESS_LEVEL4: for brightness +2 - * @arg CAMERA_BRIGHTNESS_LEVEL3: for brightness +1 - * @arg CAMERA_BRIGHTNESS_LEVEL2: for brightness 0 - * @arg CAMERA_BRIGHTNESS_LEVEL1: for brightness -1 - * @arg CAMERA_BRIGHTNESS_LEVEL0: for brightness -2 - * @retval None - */ -void BSP_CAMERA_ContrastBrightnessConfig(uint32_t contrast_level, uint32_t brightness_level) -{ - if(camera_drv->Config != NULL) - { - camera_drv->Config(CAMERA_I2C_ADDRESS, CAMERA_CONTRAST_BRIGHTNESS, contrast_level, brightness_level); - } -} - -/** - * @brief Configures the camera white balance. - * @param Mode: black_white mode - * This parameter can be one of the following values: - * @arg CAMERA_BLACK_WHITE_BW - * @arg CAMERA_BLACK_WHITE_NEGATIVE - * @arg CAMERA_BLACK_WHITE_BW_NEGATIVE - * @arg CAMERA_BLACK_WHITE_NORMAL - * @retval None - */ -void BSP_CAMERA_BlackWhiteConfig(uint32_t Mode) -{ - if(camera_drv->Config != NULL) - { - camera_drv->Config(CAMERA_I2C_ADDRESS, CAMERA_BLACK_WHITE, Mode, 0); - } -} - -/** - * @brief Configures the camera color effect. - * @param Effect: Color effect - * This parameter can be one of the following values: - * @arg CAMERA_COLOR_EFFECT_ANTIQUE - * @arg CAMERA_COLOR_EFFECT_BLUE - * @arg CAMERA_COLOR_EFFECT_GREEN - * @arg CAMERA_COLOR_EFFECT_RED - * @retval None - */ -void BSP_CAMERA_ColorEffectConfig(uint32_t Effect) -{ - if(camera_drv->Config != NULL) - { - camera_drv->Config(CAMERA_I2C_ADDRESS, CAMERA_COLOR_EFFECT, Effect, 0); - } -} - -/** - * @brief Handles DCMI interrupt request. - * @param None - * @retval None - */ -void BSP_CAMERA_IRQHandler(void) -{ - HAL_DCMI_IRQHandler(&hdcmi_eval); -} - -/** - * @brief Handles DMA interrupt request. - * @param None - * @retval None - */ -void BSP_CAMERA_DMA_IRQHandler(void) -{ - HAL_DMA_IRQHandler(hdcmi_eval.DMA_Handle); -} - -/** - * @brief Get the capture size. - * @param current_resolution: the current resolution. - * @retval capture size. - */ -static uint32_t GetSize(uint32_t resolution) -{ - uint32_t size = 0; - - /* Get capture size */ - switch (resolution) - { - case CAMERA_R160x120: - { - size = 0x2580; - } - break; - case CAMERA_R320x240: - { - size = 0x9600; - } - break; - case CAMERA_R480x272: - { - size = 0xFF00; - } - break; - case CAMERA_R640x480: - { - size = 0x25800; - } - break; - default: - { - break; - } - } - - return size; -} - -/** - * @brief Initializes the DCMI MSP. - * @param None - * @retval None - */ -static void DCMI_MspInit(void) -{ - static DMA_HandleTypeDef hdma_eval; - GPIO_InitTypeDef GPIO_Init_Structure; - DCMI_HandleTypeDef *hdcmi = &hdcmi_eval; - - /*** Enable peripherals and GPIO clocks ***/ - /* Enable DCMI clock */ - __DCMI_CLK_ENABLE(); - - /* Enable DMA2 clock */ - __DMA2_CLK_ENABLE(); - - /* Enable GPIO clocks */ - __GPIOA_CLK_ENABLE(); - __GPIOB_CLK_ENABLE(); - __GPIOC_CLK_ENABLE(); - __GPIOD_CLK_ENABLE(); - __GPIOE_CLK_ENABLE(); - - /*** Configure the GPIO ***/ - /* Configure DCMI GPIO as alternate function */ - GPIO_Init_Structure.Pin = GPIO_PIN_4; - GPIO_Init_Structure.Mode = GPIO_MODE_AF_PP; - GPIO_Init_Structure.Pull = GPIO_PULLUP; - GPIO_Init_Structure.Speed = GPIO_SPEED_HIGH; - GPIO_Init_Structure.Alternate = GPIO_AF13_DCMI; - HAL_GPIO_Init(GPIOA, &GPIO_Init_Structure); - - GPIO_Init_Structure.Pin = GPIO_PIN_7 | GPIO_PIN_8; - GPIO_Init_Structure.Mode = GPIO_MODE_AF_PP; - GPIO_Init_Structure.Pull = GPIO_PULLUP; - GPIO_Init_Structure.Speed = GPIO_SPEED_HIGH; - GPIO_Init_Structure.Alternate = GPIO_AF13_DCMI; - HAL_GPIO_Init(GPIOB, &GPIO_Init_Structure); - - GPIO_Init_Structure.Pin = GPIO_PIN_6 | GPIO_PIN_7 | GPIO_PIN_8 |\ - GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 |\ - GPIO_PIN_12; - GPIO_Init_Structure.Mode = GPIO_MODE_AF_PP; - GPIO_Init_Structure.Pull = GPIO_PULLUP; - GPIO_Init_Structure.Speed = GPIO_SPEED_HIGH; - GPIO_Init_Structure.Alternate = GPIO_AF13_DCMI; - HAL_GPIO_Init(GPIOC, &GPIO_Init_Structure); - - GPIO_Init_Structure.Pin = GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_6; - GPIO_Init_Structure.Mode = GPIO_MODE_AF_PP; - GPIO_Init_Structure.Pull = GPIO_PULLUP; - GPIO_Init_Structure.Speed = GPIO_SPEED_HIGH; - GPIO_Init_Structure.Alternate = GPIO_AF13_DCMI; - HAL_GPIO_Init(GPIOD, &GPIO_Init_Structure); - - GPIO_Init_Structure.Pin = GPIO_PIN_6; - GPIO_Init_Structure.Mode = GPIO_MODE_AF_PP; - GPIO_Init_Structure.Pull = GPIO_PULLUP; - GPIO_Init_Structure.Speed = GPIO_SPEED_HIGH; - GPIO_Init_Structure.Alternate = GPIO_AF13_DCMI; - HAL_GPIO_Init(GPIOE, &GPIO_Init_Structure); - - GPIO_Init_Structure.Pin = GPIO_PIN_6; - GPIO_Init_Structure.Mode = GPIO_MODE_AF_PP; - GPIO_Init_Structure.Pull = GPIO_PULLUP; - GPIO_Init_Structure.Speed = GPIO_SPEED_HIGH; - GPIO_Init_Structure.Alternate = GPIO_AF13_DCMI; - HAL_GPIO_Init(GPIOA, &GPIO_Init_Structure); - - /*** Configure the DMA ***/ - /* Set the parameters to be configured */ - hdma_eval.Init.Channel = DMA_CHANNEL_1; - hdma_eval.Init.Direction = DMA_PERIPH_TO_MEMORY; - hdma_eval.Init.PeriphInc = DMA_PINC_DISABLE; - hdma_eval.Init.MemInc = DMA_MINC_ENABLE; - hdma_eval.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; - hdma_eval.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; - hdma_eval.Init.Mode = DMA_CIRCULAR; - hdma_eval.Init.Priority = DMA_PRIORITY_HIGH; - hdma_eval.Init.FIFOMode = DMA_FIFOMODE_DISABLE; - hdma_eval.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; - hdma_eval.Init.MemBurst = DMA_MBURST_SINGLE; - hdma_eval.Init.PeriphBurst = DMA_PBURST_SINGLE; - - hdma_eval.Instance = DMA2_Stream1; - - /* Associate the initialized DMA handle to the DCMI handle */ - __HAL_LINKDMA(hdcmi, DMA_Handle, hdma_eval); - - /*** Configure the NVIC for DCMI and DMA ***/ - /* NVIC configuration for DCMI transfer complete interrupt */ - HAL_NVIC_SetPriority(DCMI_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(DCMI_IRQn); - - /* NVIC configuration for DMA2D transfer complete interrupt */ - HAL_NVIC_SetPriority(DMA2_Stream1_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(DMA2_Stream1_IRQn); - - /* Configure the DMA stream */ - HAL_DMA_Init(hdcmi->DMA_Handle); -} - -/** - * @brief Line event callback - * @param hdcmi: pointer to the DCMI handle - * @retval None - */ -void HAL_DCMI_LineEventCallback(DCMI_HandleTypeDef *hdcmi) -{ - BSP_CAMERA_LineEventCallback(); -} - -/** - * @brief Line Event callback. - * @param None - * @retval None - */ -__weak void BSP_CAMERA_LineEventCallback(void) -{ - /* NOTE : This function Should not be modified, when the callback is needed, - the HAL_DCMI_LineEventCallback could be implemented in the user file - */ -} - -/** - * @brief VSYNC event callback - * @param hdcmi: pointer to the DCMI handle - * @retval None - */ -void HAL_DCMI_VsyncEventCallback(DCMI_HandleTypeDef *hdcmi) -{ - BSP_CAMERA_VsyncEventCallback(); -} - -/** - * @brief VSYNC Event callback. - * @param None - * @retval None - */ -__weak void BSP_CAMERA_VsyncEventCallback(void) -{ - /* NOTE : This function Should not be modified, when the callback is needed, - the HAL_DCMI_VsyncEventCallback could be implemented in the user file - */ -} - -/** - * @brief Frame event callback - * @param hdcmi: pointer to the DCMI handle - * @retval None - */ -void HAL_DCMI_FrameEventCallback(DCMI_HandleTypeDef *hdcmi) -{ - BSP_CAMERA_FrameEventCallback(); -} - -/** - * @brief Frame Event callback. - * @param None - * @retval None - */ -__weak void BSP_CAMERA_FrameEventCallback(void) -{ - /* NOTE : This function Should not be modified, when the callback is needed, - the HAL_DCMI_FrameEventCallback could be implemented in the user file - */ -} - -/** - * @brief Error callback - * @param hdcmi: pointer to the DCMI handle - * @retval None - */ -void HAL_DCMI_ErrorCallback(DCMI_HandleTypeDef *hdcmi) -{ - BSP_CAMERA_ErrorCallback(); -} - -/** - * @brief Error callback. - * @param None - * @retval None - */ -__weak void BSP_CAMERA_ErrorCallback(void) -{ - /* NOTE : This function Should not be modified, when the callback is needed, - the HAL_DCMI_ErrorCallback could be implemented in the user file - */ -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval_camera.h b/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval_camera.h deleted file mode 100644 index 4e52ce9551..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval_camera.h +++ /dev/null @@ -1,141 +0,0 @@ -/** - ****************************************************************************** - * @file stm324x9i_eval_camera.h - * @author MCD Application Team - * @version V2.2.1 - * @date 07-October-2015 - * @brief This file contains the common defines and functions prototypes for - * the stm324x9i_eval_camera.c driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM324x9I_EVAL_CAMERA_H -#define __STM324x9I_EVAL_CAMERA_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -/* Include Camera component Driver */ -#include "../Components/ov2640/ov2640.h" - -/* Include IO Driver */ -#include "stm324x9i_eval_io.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM324x9I_EVAL - * @{ - */ - -/** @addtogroup STM324x9I_EVAL_CAMERA - * @{ - */ - -/** @defgroup STM324x9I_EVAL_CAMERA_Exported_Types - * @{ - */ - -/** - * @brief Camera State structures definition - */ -typedef enum -{ - CAMERA_OK = 0x00, - CAMERA_ERROR = 0x01, - CAMERA_TIMEOUT = 0x02 -}Camera_StatusTypeDef; - -#define RESOLUTION_R160x120 CAMERA_R160x120 /* QQVGA Resolution */ -#define RESOLUTION_R320x240 CAMERA_R320x240 /* QVGA Resolution */ -#define RESOLUTION_R480x272 CAMERA_R480x272 /* 480x272 Resolution */ -#define RESOLUTION_R640x480 CAMERA_R640x480 /* VGA Resolution */ -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_CAMERA_Exported_Constants - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_CAMERA_Exported_Functions - * @{ - */ -uint8_t BSP_CAMERA_Init(uint32_t Resolution); -void BSP_CAMERA_ContinuousStart(uint8_t *buff); -void BSP_CAMERA_SnapshotStart(uint8_t *buff); -void BSP_CAMERA_Suspend(void); -void BSP_CAMERA_Resume(void); -uint8_t BSP_CAMERA_Stop(void); -void BSP_CAMERA_LineEventCallback(void); -void BSP_CAMERA_VsyncEventCallback(void); -void BSP_CAMERA_FrameEventCallback(void); -void BSP_CAMERA_ErrorCallback(void); - -/* Camera features functions prototype */ -void BSP_CAMERA_ContrastBrightnessConfig(uint32_t contrast_level, uint32_t brightness_level); -void BSP_CAMERA_BlackWhiteConfig(uint32_t Mode); -void BSP_CAMERA_ColorEffectConfig(uint32_t Effect); - -/* To be called in DCMI_IRQHandler function */ -void BSP_CAMERA_IRQHandler(void); -/* To be called in DMA2_Stream1_IRQHandler function */ -void BSP_CAMERA_DMA_IRQHandler(void); - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM324x9I_EVAL_CAMERA_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval_eeprom.c b/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval_eeprom.c deleted file mode 100644 index 00326874fa..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval_eeprom.c +++ /dev/null @@ -1,468 +0,0 @@ -/** - ****************************************************************************** - * @file stm324x9i_eval_eeprom.c - * @author MCD Application Team - * @version V2.2.1 - * @date 07-October-2015 - * @brief This file provides a set of functions needed to manage an I2C M24LR64 - * EEPROM memory. - * To be able to use this driver, the switch EE_M24LR64 must be defined - * in your toolchain compiler preprocessor - * - * =================================================================== - * Notes: - * - This driver is intended for STM32F4xx families devices only. - * - The I2C EEPROM memory (M24LR64) is available on separate daughter - * board ANT7-M24LR-A, which is not provided with the STM324x9I_EVAL - * board. - * To use this driver you have to connect the ANT7-M24LR-A to CN3 - * connector of STM324x9I_EVAL board. - * =================================================================== - * - * It implements a high level communication layer for read and write - * from/to this memory. The needed STM32F4xx hardware resources (I2C and - * GPIO) are defined in stm324x9i_eval.h file, and the initialization is - * performed in EEPROM_IO_Init() function declared in stm324x9i_eval.c - * file. - * You can easily tailor this driver to any other development board, - * by just adapting the defines for hardware resources and - * EEPROM_IO_Init() function. - * - * @note In this driver, basic read and write functions (BSP_EEPROM_ReadBuffer() - * and BSP_EEPROM_WritePage()) use DMA mode to perform the data - * transfer to/from EEPROM memory. - * - * @note Regarding BSP_EEPROM_WritePage(), it is a optimized function to perform - * small write (less than 1 page) BUT The number of bytes (combined to write start address) must not - * cross the EEPROM page boundary. This function can only write into - * the boundaries of an EEPROM page. - * This function doesn't check on boundaries condition (in this driver - * the function BSP_EEPROM_WriteBuffer() which calls BSP_EEPROM_WritePage() is - * responsible of checking on Page boundaries). - * - * - * +-----------------------------------------------------------------+ - * | Pin assignment for M24LR64 EEPROM | - * +---------------------------------------+-----------+-------------+ - * | STM32F4xx I2C Pins | EEPROM | Pin | - * +---------------------------------------+-----------+-------------+ - * | . | E0(GND) | 1 (0V) | - * | . | AC0 | 2 | - * | . | AC1 | 3 | - * | . | VSS | 4 (0V) | - * | SDA | SDA | 5 | - * | SCL | SCL | 6 | - * | . | E1(GND) | 7 (0V) | - * | . | VDD | 8 (3.3V) | - * +---------------------------------------+-----------+-------------+ - * - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ -/* Includes ------------------------------------------------------------------*/ -#include "stm324x9i_eval_eeprom.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM324x9I_EVAL - * @{ - */ - -/** @addtogroup STM324x9I_EVAL_EEPROM - * @brief This file includes the I2C EEPROM driver of STM324x9I-EVAL evaluation board. - * @{ - */ - -/** @defgroup STM324x9I_EVAL_EEPROM_Private_Types - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_EEPROM_Private_Defines - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_EEPROM_Private_Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_EEPROM_Private_Variables - * @{ - */ -__IO uint16_t EEPROMAddress = 0; -__IO uint32_t EEPROMTimeout = EEPROM_READ_TIMEOUT; -__IO uint16_t EEPROMDataRead; -__IO uint8_t EEPROMDataWrite; -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_EEPROM_Private_Function_Prototypes - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_EEPROM_Private_Functions - * @{ - */ - -/** - * @brief Initializes peripherals used by the I2C EEPROM driver. - * @param None - * - * @note There are 2 different versions of M24LR64 (A01 & A02). - * Then try to connect on 1st one (EEPROM_I2C_ADDRESS_A01) - * and if problem, check the 2nd one (EEPROM_I2C_ADDRESS_A02) - * @retval EEPROM_OK (0) if operation is correctly performed, else return value - * different from EEPROM_OK (0) - */ -uint32_t BSP_EEPROM_Init(void) -{ - /* I2C Initialization */ - EEPROM_IO_Init(); - - /* Select the EEPROM address for A01 and check if OK */ - EEPROMAddress = EEPROM_I2C_ADDRESS_A01; - if(EEPROM_IO_IsDeviceReady(EEPROMAddress, EEPROM_MAX_TRIALS) != HAL_OK) - { - /* Select the EEPROM address for A02 and check if OK */ - EEPROMAddress = EEPROM_I2C_ADDRESS_A02; - if(EEPROM_IO_IsDeviceReady(EEPROMAddress, EEPROM_MAX_TRIALS) != HAL_OK) - { - return EEPROM_FAIL; - } - } - return EEPROM_OK; -} - -/** - * @brief Reads a block of data from the EEPROM. - * @param pBuffer: pointer to the buffer that receives the data read from - * the EEPROM. - * @param ReadAddr: EEPROM's internal address to start reading from. - * @param NumByteToRead: pointer to the variable holding number of bytes to - * be read from the EEPROM. - * - * @note The variable pointed by NumByteToRead is reset to 0 when all the - * data are read from the EEPROM. Application should monitor this - * variable in order know when the transfer is complete. - * - * @retval EEPROM_OK (0) if operation is correctly performed, else return value - * different from EEPROM_OK (0) or the timeout user callback. - */ -uint32_t BSP_EEPROM_ReadBuffer(uint8_t* pBuffer, uint16_t ReadAddr, uint16_t* NumByteToRead) -{ - uint32_t buffersize = *NumByteToRead; - - /* Set the pointer to the Number of data to be read. This pointer will be used - by the DMA Transfer Completer interrupt Handler in order to reset the - variable to 0. User should check on this variable in order to know if the - DMA transfer has been complete or not. */ - EEPROMDataRead = *NumByteToRead; - - if(EEPROM_IO_ReadData(EEPROMAddress, ReadAddr, pBuffer, buffersize) != HAL_OK) - { - BSP_EEPROM_TIMEOUT_UserCallback(); - return EEPROM_FAIL; - } - - /* If all operations OK, return EEPROM_OK (0) */ - return EEPROM_OK; -} - -/** - * @brief Writes more than one byte to the EEPROM with a single WRITE cycle. - * - * @note The number of bytes (combined to write start address) must not - * cross the EEPROM page boundary. This function can only write into - * the boundaries of an EEPROM page. - * This function doesn't check on boundaries condition (in this driver - * the function BSP_EEPROM_WriteBuffer() which calls BSP_EEPROM_WritePage() is - * responsible of checking on Page boundaries). - * - * @param pBuffer: pointer to the buffer containing the data to be written to - * the EEPROM. - * @param WriteAddr: EEPROM's internal address to write to. - * @param NumByteToWrite: pointer to the variable holding number of bytes to - * be written into the EEPROM. - * - * @note The variable pointed by NumByteToWrite is reset to 0 when all the - * data are written to the EEPROM. Application should monitor this - * variable in order know when the transfer is complete. - * - * @note This function just configure the communication and enable the DMA - * channel to transfer data. Meanwhile, the user application may perform - * other tasks in parallel. - * - * @retval EEPROM_OK (0) if operation is correctly performed, else return value - * different from EEPROM_OK (0) or the timeout user callback. - */ -uint32_t BSP_EEPROM_WritePage(uint8_t* pBuffer, uint16_t WriteAddr, uint8_t* NumByteToWrite) -{ - uint32_t buffersize = *NumByteToWrite; - uint32_t status = EEPROM_OK; - - /* Set the pointer to the Number of data to be written. This pointer will be used - by the DMA Transfer Completer interrupt Handler in order to reset the - variable to 0. User should check on this variable in order to know if the - DMA transfer has been complete or not. */ - EEPROMDataWrite = *NumByteToWrite; - - if(EEPROM_IO_WriteData(EEPROMAddress, WriteAddr, pBuffer, buffersize) != HAL_OK) - { - BSP_EEPROM_TIMEOUT_UserCallback(); - status = EEPROM_FAIL; - } - - if(BSP_EEPROM_WaitEepromStandbyState() != EEPROM_OK) - { - return EEPROM_FAIL; - } - - /* If all operations OK, return EEPROM_OK (0) */ - return status; -} - -/** - * @brief Writes buffer of data to the I2C EEPROM. - * @param pBuffer: pointer to the buffer containing the data to be written - * to the EEPROM. - * @param WriteAddr: EEPROM's internal address to write to. - * @param NumByteToWrite: number of bytes to write to the EEPROM. - * @retval EEPROM_OK (0) if operation is correctly performed, else return value - * different from EEPROM_OK (0) or the timeout user callback. - */ -uint32_t BSP_EEPROM_WriteBuffer(uint8_t *pBuffer, uint16_t WriteAddr, uint16_t NumByteToWrite) -{ - uint16_t numofpage = 0, numofsingle = 0, count = 0; - uint16_t addr = 0; - uint8_t dataindex = 0; - uint32_t status = EEPROM_OK; - - addr = WriteAddr % EEPROM_PAGESIZE; - count = EEPROM_PAGESIZE - addr; - numofpage = NumByteToWrite / EEPROM_PAGESIZE; - numofsingle = NumByteToWrite % EEPROM_PAGESIZE; - - /* If WriteAddr is EEPROM_PAGESIZE aligned */ - if(addr == 0) - { - /* If NumByteToWrite < EEPROM_PAGESIZE */ - if(numofpage == 0) - { - /* Store the number of data to be written */ - dataindex = numofsingle; - /* Start writing data */ - status = BSP_EEPROM_WritePage(pBuffer, WriteAddr, (uint8_t*)(&dataindex)); - if(status != EEPROM_OK) - { - return status; - } - } - /* If NumByteToWrite > EEPROM_PAGESIZE */ - else - { - while(numofpage--) - { - /* Store the number of data to be written */ - dataindex = EEPROM_PAGESIZE; - status = BSP_EEPROM_WritePage(pBuffer, WriteAddr, (uint8_t*)(&dataindex)); - if(status != EEPROM_OK) - { - return status; - } - - WriteAddr += EEPROM_PAGESIZE; - pBuffer += EEPROM_PAGESIZE; - } - - if(numofsingle!=0) - { - /* Store the number of data to be written */ - dataindex = numofsingle; - status = BSP_EEPROM_WritePage(pBuffer, WriteAddr, (uint8_t*)(&dataindex)); - if(status != EEPROM_OK) - { - return status; - } - } - } - } - /* If WriteAddr is not EEPROM_PAGESIZE aligned */ - else - { - /* If NumByteToWrite < EEPROM_PAGESIZE */ - if(numofpage== 0) - { - /* If the number of data to be written is more than the remaining space - in the current page: */ - if(NumByteToWrite > count) - { - /* Store the number of data to be written */ - dataindex = count; - /* Write the data contained in same page */ - status = BSP_EEPROM_WritePage(pBuffer, WriteAddr, (uint8_t*)(&dataindex)); - if(status != EEPROM_OK) - { - return status; - } - - /* Store the number of data to be written */ - dataindex = (NumByteToWrite - count); - /* Write the remaining data in the following page */ - status = BSP_EEPROM_WritePage((uint8_t*)(pBuffer + count), (WriteAddr + count), (uint8_t*)(&dataindex)); - if(status != EEPROM_OK) - { - return status; - } - } - else - { - /* Store the number of data to be written */ - dataindex = numofsingle; - status = BSP_EEPROM_WritePage(pBuffer, WriteAddr, (uint8_t*)(&dataindex)); - if(status != EEPROM_OK) - { - return status; - } - } - } - /* If NumByteToWrite > EEPROM_PAGESIZE */ - else - { - NumByteToWrite -= count; - numofpage = NumByteToWrite / EEPROM_PAGESIZE; - numofsingle = NumByteToWrite % EEPROM_PAGESIZE; - - if(count != 0) - { - /* Store the number of data to be written */ - dataindex = count; - status = BSP_EEPROM_WritePage(pBuffer, WriteAddr, (uint8_t*)(&dataindex)); - if(status != EEPROM_OK) - { - return status; - } - WriteAddr += count; - pBuffer += count; - } - - while(numofpage--) - { - /* Store the number of data to be written */ - dataindex = EEPROM_PAGESIZE; - status = BSP_EEPROM_WritePage(pBuffer, WriteAddr, (uint8_t*)(&dataindex)); - if(status != EEPROM_OK) - { - return status; - } - WriteAddr += EEPROM_PAGESIZE; - pBuffer += EEPROM_PAGESIZE; - } - if(numofsingle != 0) - { - /* Store the number of data to be written */ - dataindex = numofsingle; - status = BSP_EEPROM_WritePage(pBuffer, WriteAddr, (uint8_t*)(&dataindex)); - if(status != EEPROM_OK) - { - return status; - } - } - } - } - - /* If all operations OK, return EEPROM_OK (0) */ - return EEPROM_OK; -} - -/** - * @brief Wait for EEPROM Standby state. - * - * @note This function allows to wait and check that EEPROM has finished the - * last operation. It is mostly used after Write operation: after receiving - * the buffer to be written, the EEPROM may need additional time to actually - * perform the write operation. During this time, it doesn't answer to - * I2C packets addressed to it. Once the write operation is complete - * the EEPROM responds to its address. - * - * @param None - * @retval EEPROM_OK (0) if operation is correctly performed, else return value - * different from EEPROM_OK (0) or the timeout user callback. - */ -uint32_t BSP_EEPROM_WaitEepromStandbyState(void) -{ - /* Check if the maximum allowed number of trials has bee reached */ - if(EEPROM_IO_IsDeviceReady(EEPROMAddress, EEPROM_MAX_TRIALS) != HAL_OK) - { - /* If the maximum number of trials has been reached, exit the function */ - BSP_EEPROM_TIMEOUT_UserCallback(); - return EEPROM_TIMEOUT; - } - return EEPROM_OK; -} - -/** - * @brief Basic management of the timeout situation. - * @param None - * @retval None - */ -__weak void BSP_EEPROM_TIMEOUT_UserCallback(void) -{ -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval_eeprom.h b/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval_eeprom.h deleted file mode 100644 index 8f1a42da6f..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval_eeprom.h +++ /dev/null @@ -1,145 +0,0 @@ -/** - ****************************************************************************** - * @file stm324x9i_eval_eeprom.h - * @author MCD Application Team - * @version V2.2.1 - * @date 07-October-2015 - * @brief This file contains all the functions prototypes for - * the stm324x9i_eval_eeprom.c firmware driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32F4x9I_EVAL_EEPROM_H -#define __STM32F4x9I_EVAL_EEPROM_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm324x9i_eval.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM324x9I_EVAL - * @{ - */ - -/** @addtogroup STM324x9I_EVAL_EEPROM - * @brief This file includes the I2C EEPROM driver of STM324x9I-EVAL evaluation board. - * @{ - */ - -/** @defgroup STM324x9I_EVAL_EEPROM_Exported_Types - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_EEPROM_Exported_Constants - * @{ - */ -/* EEPROM hardware address and page size */ -#define EEPROM_PAGESIZE 4 -#define EEPROM_MAX_SIZE 0x2000 /* 64Kbit */ - -/* Maximum Timeout values for flags and events waiting loops. -This timeout is based on systick set to 1ms*/ -/* Timeout for read based if read all the EEPROM : EEPROM_MAX_SIZE * BSP_I2C_SPEED (640ms) */ -#define EEPROM_READ_TIMEOUT ((uint32_t)(1000)) -/* Timeout for write based on max write which is EEPROM_PAGESIZE bytes: EEPROM_PAGESIZE * BSP_I2C_SPEED (320us) */ -#define EEPROM_WRITE_TIMEOUT ((uint32_t)(10)) - -/* Maximum number of trials for EEPROM_WaitEepromStandbyState() function */ -#define EEPROM_MAX_TRIALS 3000 - -#define EEPROM_OK 0 -#define EEPROM_FAIL 1 -#define EEPROM_TIMEOUT 2 -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_EEPROM_Exported_Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_EEPROM_Exported_Functions - * @{ - */ -uint32_t BSP_EEPROM_Init(void); -uint32_t BSP_EEPROM_ReadBuffer(uint8_t* pBuffer, uint16_t ReadAddr, uint16_t* NumByteToRead); -uint32_t BSP_EEPROM_WritePage(uint8_t* pBuffer, uint16_t WriteAddr, uint8_t* NumByteToWrite); -uint32_t BSP_EEPROM_WriteBuffer(uint8_t* pBuffer, uint16_t WriteAddr, uint16_t NumByteToWrite); -uint32_t BSP_EEPROM_WaitEepromStandbyState(void); - -/* USER Callbacks: This function is declared as __weak in EEPROM driver and - should be implemented into user application. - BSP_EEPROM_TIMEOUT_UserCallback() function is called whenever a timeout condition - occurs during communication (waiting on an event that doesn't occur, bus - errors, busy devices ...). */ -void BSP_EEPROM_TIMEOUT_UserCallback(void); - -/* Link function for I2C EEPROM peripheral */ -void EEPROM_IO_Init(void); -HAL_StatusTypeDef EEPROM_IO_WriteData(uint16_t DevAddress, uint16_t MemAddress, uint8_t *pBuffer, uint32_t BufferSize); -HAL_StatusTypeDef EEPROM_IO_ReadData(uint16_t DevAddress, uint16_t MemAddress, uint8_t *pBuffer, uint32_t BufferSize); -HAL_StatusTypeDef EEPROM_IO_IsDeviceReady(uint16_t DevAddress, uint32_t Trials); - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM324x9I_EVAL_EEPROM_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval_io.c b/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval_io.c deleted file mode 100644 index 0cafebb306..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval_io.c +++ /dev/null @@ -1,262 +0,0 @@ -/** - ****************************************************************************** - * @file stm324x9i_eval_io.c - * @author MCD Application Team - * @version V2.2.1 - * @date 07-October-2015 - * @brief This file provides a set of functions needed to manage the IO pins - * on STM324x9I-EVAL evaluation board. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* File Info : ----------------------------------------------------------------- - User NOTES -1. How To use this driver: --------------------------- - - This driver is used to drive the IO module of the STM324x9I-EVAL evaluation - board. - - The STMPE1600 IO expander device component driver must be included with this - driver in order to run the IO functionalities commanded by the IO expander - device mounted on the evaluation board. - -2. Driver description: ---------------------- - + Initialization steps: - o Initialize the IO module using the BSP_IO_Init() function. This - function includes the MSP layer hardware resources initialization and the - communication layer configuration to start the IO functionalities use. - - + IO functionalities use - o The IO pin mode is configured when calling the function BSP_IO_ConfigPin(), you - must specify the desired IO mode by choosing the "IO_ModeTypedef" parameter - predefined value. - o If an IO pin is used in interrupt mode, the function BSP_IO_ITGetStatus() is - needed to get the interrupt status. To clear the IT pending bits, you should - call the function BSP_IO_ITClear() with specifying the IO pending bit to clear. - o The IT is handled using the corresponding external interrupt IRQ handler, - the user IT callback treatment is implemented on the same external interrupt - callback. - o To get/set an IO pin combination state you can use the functions - BSP_IO_ReadPin()/BSP_IO_WritePin() or the function BSP_IO_TogglePin() to toggle the pin - state. - -------------------------------------------------------------------------------*/ - -/* Includes ------------------------------------------------------------------*/ -#include "stm324x9i_eval_io.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM324x9I_EVAL - * @{ - */ - -/** @defgroup STM324x9I_EVAL_IO - * @{ - */ - -/** @defgroup STM324x9I_EVAL_IO_Private_Types_Definitions - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_IO_Private_Defines - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_IO_Private_Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_IO_Private_Variables - * @{ - */ -static IO_DrvTypeDef *io_driver; -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_IO_Private_Function_Prototypes - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_IO_Private_Functions - * @{ - */ - -/** - * @brief Initializes and configures the IO functionalities and configures all - * necessary hardware resources (GPIOs, clocks..). - * @note BSP_IO_Init() is using HAL_Delay() function to ensure that stmpe1600 - * IO Expander is correctly reset. HAL_Delay() function provides accurate - * delay (in milliseconds) based on variable incremented in SysTick ISR. - * This implies that if BSP_IO_Init() is called from a peripheral ISR process, - * then the SysTick interrupt must have higher priority (numerically lower) - * than the peripheral interrupt. Otherwise the caller ISR process will be blocked. - * @param None - * @retval IO_OK if all initializations are OK. Other value if error. - */ -uint8_t BSP_IO_Init(void) -{ - uint8_t ret = IO_ERROR; - - /* Read ID and verify the IO expander is ready */ - if(stmpe1600_io_drv.ReadID(IO_I2C_ADDRESS) == STMPE1600_ID) - { - /* Initialize the IO driver structure */ - io_driver = &stmpe1600_io_drv; - ret = IO_OK; - } - - if(ret == IO_OK) - { - io_driver->Init(IO_I2C_ADDRESS); - io_driver->Start(IO_I2C_ADDRESS, IO_PIN_ALL); - } - return ret; -} - -/** - * @brief Gets the selected pins IT status. - * @param IO_Pin: Selected pins to check the status. - * This parameter can be any combination of the IO pins. - * @retval IO_OK if read status OK. Other value if error. - */ -uint8_t BSP_IO_ITGetStatus(uint16_t IO_Pin) -{ - /* Return the IO Pin IT status */ - return (io_driver->ITStatus(IO_I2C_ADDRESS, IO_Pin)); -} - -/** - * @brief Clears all the IO IT pending bits. - * @param None - * @retval None - */ -void BSP_IO_ITClear(void) -{ - /* Clear all IO IT pending bits */ - io_driver->ClearIT(IO_I2C_ADDRESS, STMPE1600_PIN_ALL); -} - -/** - * @brief Configures the IO pin(s) according to IO mode structure value. - * @param IO_Pin: IO pin(s) to be configured. - * This parameter can be one of the following values: - * @arg STMPE1600_PIN_x: where x can be from 0 to 15. - * @param IO_Mode: IO pin mode to configure - * This parameter can be one of the following values: - * @arg IO_MODE_INPUT - * @arg IO_MODE_OUTPUT - * @arg IO_MODE_IT_RISING_EDGE - * @arg IO_MODE_IT_FALLING_EDGE - * @retval IO_OK if all initializations are OK. Other value if error. - */ -uint8_t BSP_IO_ConfigPin(uint16_t IO_Pin, IO_ModeTypedef IO_Mode) -{ - /* Configure the selected IO pin(s) mode */ - io_driver->Config(IO_I2C_ADDRESS, (uint16_t )IO_Pin, IO_Mode); - - return IO_OK; -} - -/** - * @brief Sets the selected pins state. - * @param IO_Pin: Selected pins to write. - * This parameter can be any combination of the IO pins. - * @param PinState: New pins state to write - * @retval None - */ -void BSP_IO_WritePin(uint16_t IO_Pin, uint8_t PinState) -{ - /* Set the Pin state */ - io_driver->WritePin(IO_I2C_ADDRESS, IO_Pin, PinState); -} - -/** - * @brief Gets the selected pins current state. - * @param IO_Pin: Selected pins to read. - * This parameter can be any combination of the IO pins. - * @retval The current pins state - */ -uint16_t BSP_IO_ReadPin(uint16_t IO_Pin) -{ - return(io_driver->ReadPin(IO_I2C_ADDRESS, IO_Pin)); -} - -/** - * @brief Toggles the selected pins state. - * @param IO_Pin: Selected pins to toggle. - * This parameter can be any combination of the IO pins. - * @retval None - */ -void BSP_IO_TogglePin(uint16_t IO_Pin) -{ - /* Toggle the current pin state */ - if(io_driver->ReadPin(IO_I2C_ADDRESS, IO_Pin) == 1) /* Set */ - { - io_driver->WritePin(IO_I2C_ADDRESS, IO_Pin, 0); /* Reset */ - } - else - { - io_driver->WritePin(IO_I2C_ADDRESS, IO_Pin, 1); /* Set */ - } -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval_io.h b/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval_io.h deleted file mode 100644 index a9e33131fd..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval_io.h +++ /dev/null @@ -1,149 +0,0 @@ -/** - ****************************************************************************** - * @file stm324x9i_eval_io.h - * @author MCD Application Team - * @version V2.2.1 - * @date 07-October-2015 - * @brief This file contains the common defines and functions prototypes for - * the stm324x9i_eval_io.c driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM324x9I_EVAL_IO_H -#define __STM324x9I_EVAL_IO_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm324x9i_eval.h" -/* Include IO component driver */ -#include "../Components/stmpe1600/stmpe1600.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM324x9I_EVAL - * @{ - */ - -/** @defgroup STM324x9I_EVAL_IO - * @{ - */ - -/** @defgroup STM324x9I_EVAL_IO_Exported_Types - * @{ - */ -typedef struct -{ - uint16_t TouchDetected; - uint16_t x; - uint16_t y; - uint16_t z; -}IO_StateTypeDef; - -typedef enum -{ - IO_OK = 0, - IO_ERROR = 1, - IO_TIMEOUT = 2 -}IO_StatusTypeDef; -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_IO_Exported_Constants - * @{ - */ -#define IO_PIN_0 0x0001 -#define IO_PIN_1 0x0002 -#define IO_PIN_2 0x0004 -#define IO_PIN_3 0x0008 -#define IO_PIN_4 0x0010 -#define IO_PIN_5 0x0020 -#define IO_PIN_6 0x0040 -#define IO_PIN_7 0x0080 -#define IO_PIN_8 0x0100 -#define IO_PIN_9 0x0200 -#define IO_PIN_10 0x0400 -#define IO_PIN_11 0x0800 -#define IO_PIN_12 0x1000 -#define IO_PIN_13 0x2000 -#define IO_PIN_14 0x4000 -#define IO_PIN_15 0x8000 -#define IO_PIN_ALL 0xFFFF -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_IO_Exported_Macro - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_IO_Exported_Functions - * @{ - */ -uint8_t BSP_IO_Init(void); -uint8_t BSP_IO_ITGetStatus(uint16_t IO_Pin); -void BSP_IO_ITClear(void); -uint8_t BSP_IO_ConfigPin(uint16_t IO_Pin, IO_ModeTypedef IO_Mode); -void BSP_IO_WritePin(uint16_t IO_Pin, uint8_t PinState); -uint16_t BSP_IO_ReadPin(uint16_t IO_Pin); -void BSP_IO_TogglePin(uint16_t IO_Pin); - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM324x9I_EVAL_IO_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval_lcd.c b/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval_lcd.c deleted file mode 100644 index 4f04c562fe..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval_lcd.c +++ /dev/null @@ -1,1436 +0,0 @@ -/** - ****************************************************************************** - * @file stm324x9i_eval_lcd.c - * @author MCD Application Team - * @version V2.2.1 - * @date 07-October-2015 - * @brief This file includes the driver for Liquid Crystal Display (LCD) module - * mounted on STM324x9I-EVAL evaluation board. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* File Info: ------------------------------------------------------------------ - User NOTES -1. How To use this driver: --------------------------- - - This driver is used to drive directly an LCD TFT using the LTDC controller. - - This driver selects dynamically the mounted LCD, AMPIRE 640x480 LCD mounted - on MB1063 or AMPIRE 480x272 LCD mounted on MB1046 daughter board, - and uses the adequate timing and setting for the specified LCD using - device ID of the STMPE811 mounted on MB1046 daughter board. - -2. Driver description: ---------------------- - + Initialization steps: - o Initialize the LCD using the BSP_LCD_Init() function. - o Apply the Layer configuration using the BSP_LCD_LayerDefaultInit() function. - o Select the LCD layer to be used using the BSP_LCD_SelectLayer() function. - o Enable the LCD display using the BSP_LCD_DisplayOn() function. - - + Options - o Configure and enable the color keying functionality using the - BSP_LCD_SetColorKeying() function. - o Modify in the fly the transparency and/or the frame buffer address - using the following functions: - - BSP_LCD_SetTransparency() - - BSP_LCD_SetLayerAddress() - - + Display on LCD - o Clear the hole LCD using BSP_LCD_Clear() function or only one specified string - line using the BSP_LCD_ClearStringLine() function. - o Display a character on the specified line and column using the BSP_LCD_DisplayChar() - function or a complete string line using the BSP_LCD_DisplayStringAtLine() function. - o Display a string line on the specified position (x,y in pixel) and align mode - using the BSP_LCD_DisplayStringAtLine() function. - o Draw and fill a basic shapes (dot, line, rectangle, circle, ellipse, .. bitmap) - on LCD using the available set of functions. - -------------------------------------------------------------------------------*/ - -/* Includes ------------------------------------------------------------------*/ -#include "stm324x9i_eval_lcd.h" -#include "../../../Utilities/Fonts/fonts.h" -#include "../../../Utilities/Fonts/font24.c" -#include "../../../Utilities/Fonts/font20.c" -#include "../../../Utilities/Fonts/font16.c" -#include "../../../Utilities/Fonts/font12.c" -#include "../../../Utilities/Fonts/font8.c" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM324x9I_EVAL - * @{ - */ - -/** @addtogroup STM324x9I_EVAL_LCD - * @{ - */ - -/** @defgroup STM324x9I_EVAL_LCD_Private_TypesDefinitions - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_LCD_Private_Defines - * @{ - */ -#define POLY_X(Z) ((int32_t)((Points + Z)->X)) -#define POLY_Y(Z) ((int32_t)((Points + Z)->Y)) -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_LCD_Private_Macros - * @{ - */ -#define ABS(X) ((X) > 0 ? (X) : -(X)) -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_LCD_Private_Variables - * @{ - */ -static LTDC_HandleTypeDef hltdc_eval; -static DMA2D_HandleTypeDef hdma2d_eval; -static uint32_t PCLK_profile = LCD_MAX_PCLK; - -/* Default LCD configuration with LCD Layer 1 */ -static uint32_t ActiveLayer = 0; -static LCD_DrawPropTypeDef DrawProp[MAX_LAYER_NUMBER]; -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_LCD_Private_FunctionPrototypes - * @{ - */ -static void MspInit(void); -static void DrawChar(uint16_t Xpos, uint16_t Ypos, const uint8_t *c); -static void FillTriangle(uint16_t x1, uint16_t x2, uint16_t x3, uint16_t y1, uint16_t y2, uint16_t y3); -static void LL_FillBuffer(uint32_t LayerIndex, void *pDst, uint32_t xSize, uint32_t ySize, uint32_t OffLine, uint32_t ColorIndex); -static void LL_ConvertLineToARGB8888(void * pSrc, void *pDst, uint32_t xSize, uint32_t ColorMode); -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_LCD_Private_Functions - * @{ - */ -/** - * @brief Initializes the LCD. - * @param None - * @retval LCD state - */ -uint8_t BSP_LCD_Init(void) -{ - return (BSP_LCD_InitEx(LCD_MAX_PCLK)); -} - -/** - * @brief Initializes the LCD. - * @param PclkConfig : pixel clock profile - * @retval LCD state - */ -uint8_t BSP_LCD_InitEx(uint32_t PclkConfig) -{ - PCLK_profile = PclkConfig; - - /* Select the used LCD */ - /* The AMPIRE 480x272 does not contain an ID register then we check the availability - of AMPIRE 480x640 LCD using device ID of the STMPE811 mounted on MB1046 daughter board */ - if(stmpe811_ts_drv.ReadID(TS_I2C_ADDRESS) == STMPE811_ID) - { - /* The AMPIRE LCD 480x272 is selected */ - /* Timing Configuration */ - hltdc_eval.Init.HorizontalSync = (AMPIRE480272_HSYNC - 1); - hltdc_eval.Init.VerticalSync = (AMPIRE480272_VSYNC - 1); - hltdc_eval.Init.AccumulatedHBP = (AMPIRE480272_HSYNC + AMPIRE480272_HBP - 1); - hltdc_eval.Init.AccumulatedVBP = (AMPIRE480272_VSYNC + AMPIRE480272_VBP - 1); - hltdc_eval.Init.AccumulatedActiveH = (AMPIRE480272_HEIGHT + AMPIRE480272_VSYNC + AMPIRE480272_VBP - 1); - hltdc_eval.Init.AccumulatedActiveW = (AMPIRE480272_WIDTH + AMPIRE480272_HSYNC + AMPIRE480272_HBP - 1); - hltdc_eval.Init.TotalHeigh = (AMPIRE480272_HEIGHT + AMPIRE480272_VSYNC + AMPIRE480272_VBP + AMPIRE480272_VFP - 1); - hltdc_eval.Init.TotalWidth = (AMPIRE480272_WIDTH + AMPIRE480272_HSYNC + AMPIRE480272_HBP + AMPIRE480272_HFP - 1); - - /* Initialize the LCD pixel width and pixel height */ - hltdc_eval.LayerCfg->ImageWidth = AMPIRE480272_WIDTH; - hltdc_eval.LayerCfg->ImageHeight = AMPIRE480272_HEIGHT; - } - else - { - /* The LCD AMPIRE 640x480 is selected */ - /* Timing configuration */ - hltdc_eval.Init.HorizontalSync = (AMPIRE640480_HSYNC - 1); - hltdc_eval.Init.VerticalSync = (AMPIRE640480_VSYNC - 1); - hltdc_eval.Init.AccumulatedHBP = (AMPIRE640480_HSYNC + AMPIRE640480_HBP - 1); - hltdc_eval.Init.AccumulatedVBP = (AMPIRE640480_VSYNC + AMPIRE640480_VBP - 1); - hltdc_eval.Init.AccumulatedActiveH = (AMPIRE640480_HEIGHT + AMPIRE640480_VSYNC + AMPIRE640480_VBP - 1); - hltdc_eval.Init.AccumulatedActiveW = (AMPIRE640480_WIDTH + AMPIRE640480_HSYNC + AMPIRE640480_HBP - 1); - hltdc_eval.Init.TotalHeigh = (AMPIRE640480_HEIGHT + AMPIRE640480_VSYNC + AMPIRE640480_VBP + AMPIRE640480_VFP - 1); - hltdc_eval.Init.TotalWidth = (AMPIRE640480_WIDTH + AMPIRE640480_HSYNC + AMPIRE640480_HBP + AMPIRE640480_HFP - 1); - - /* Initialize the LCD pixel width and pixel height */ - hltdc_eval.LayerCfg->ImageWidth = AMPIRE640480_WIDTH; - hltdc_eval.LayerCfg->ImageHeight = AMPIRE640480_HEIGHT; - } - - /* Background value */ - hltdc_eval.Init.Backcolor.Blue = 0; - hltdc_eval.Init.Backcolor.Green = 0; - hltdc_eval.Init.Backcolor.Red = 0; - - /* Polarity */ - hltdc_eval.Init.HSPolarity = LTDC_HSPOLARITY_AL; - hltdc_eval.Init.VSPolarity = LTDC_VSPOLARITY_AL; - hltdc_eval.Init.DEPolarity = LTDC_DEPOLARITY_AL; - hltdc_eval.Init.PCPolarity = LTDC_PCPOLARITY_IPC; - hltdc_eval.Instance = LTDC; - - /* LCD clock configuration */ - BSP_LCD_ClockConfig(&hltdc_eval, &PCLK_profile); - - MspInit(); - HAL_LTDC_Init(&hltdc_eval); - -#if !defined(DATA_IN_ExtSDRAM) - /* Initialize the SDRAM */ - BSP_SDRAM_Init(); -#endif /* DATA_IN_ExtSDRAM */ - - /* Initialize the font */ - BSP_LCD_SetFont(&LCD_DEFAULT_FONT); - - return LCD_OK; -} - -/** - * @brief Gets the LCD X size. - * @param None - * @retval Used LCD X size - */ -uint32_t BSP_LCD_GetXSize(void) -{ - return hltdc_eval.LayerCfg[ActiveLayer].ImageWidth; -} - -/** - * @brief Gets the LCD Y size. - * @param None - * @retval Used LCD Y size - */ -uint32_t BSP_LCD_GetYSize(void) -{ - return hltdc_eval.LayerCfg[ActiveLayer].ImageHeight; -} - -/** - * @brief Initializes the LCD layers. - * @param LayerIndex: Layer foreground or background - * @param FB_Address: Layer frame buffer - * @retval None - */ -void BSP_LCD_LayerDefaultInit(uint16_t LayerIndex, uint32_t FB_Address) -{ - LCD_LayerCfgTypeDef Layercfg; - - /* Layer Init */ - Layercfg.WindowX0 = 0; - Layercfg.WindowX1 = BSP_LCD_GetXSize(); - Layercfg.WindowY0 = 0; - Layercfg.WindowY1 = BSP_LCD_GetYSize(); - Layercfg.PixelFormat = LTDC_PIXEL_FORMAT_ARGB8888; - Layercfg.FBStartAdress = FB_Address; - Layercfg.Alpha = 255; - Layercfg.Alpha0 = 0; - Layercfg.Backcolor.Blue = 0; - Layercfg.Backcolor.Green = 0; - Layercfg.Backcolor.Red = 0; - Layercfg.BlendingFactor1 = LTDC_BLENDING_FACTOR1_PAxCA; - Layercfg.BlendingFactor2 = LTDC_BLENDING_FACTOR2_PAxCA; - Layercfg.ImageWidth = BSP_LCD_GetXSize(); - Layercfg.ImageHeight = BSP_LCD_GetYSize(); - - HAL_LTDC_ConfigLayer(&hltdc_eval, &Layercfg, LayerIndex); - - DrawProp[LayerIndex].BackColor = LCD_COLOR_WHITE; - DrawProp[LayerIndex].pFont = &Font24; - DrawProp[LayerIndex].TextColor = LCD_COLOR_BLACK; -} - -/** - * @brief Selects the LCD Layer. - * @param LayerIndex: Layer foreground or background - * @retval None - */ -void BSP_LCD_SelectLayer(uint32_t LayerIndex) -{ - ActiveLayer = LayerIndex; -} - -/** - * @brief Sets an LCD Layer visible - * @param LayerIndex: Visible Layer - * @param State: New state of the specified layer - * This parameter can be one of the following values: - * @arg ENABLE - * @arg DISABLE - * @retval None - */ -void BSP_LCD_SetLayerVisible(uint32_t LayerIndex, FunctionalState State) -{ - if(State == ENABLE) - { - __HAL_LTDC_LAYER_ENABLE(&hltdc_eval, LayerIndex); - } - else - { - __HAL_LTDC_LAYER_DISABLE(&hltdc_eval, LayerIndex); - } - __HAL_LTDC_RELOAD_CONFIG(&hltdc_eval); -} - -/** - * @brief Configures the transparency. - * @param LayerIndex: Layer foreground or background. - * @param Transparency: Transparency - * This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFF - * @retval None - */ -void BSP_LCD_SetTransparency(uint32_t LayerIndex, uint8_t Transparency) -{ - HAL_LTDC_SetAlpha(&hltdc_eval, Transparency, LayerIndex); -} - -/** - * @brief Sets an LCD layer frame buffer address. - * @param LayerIndex: Layer foreground or background - * @param Address: New LCD frame buffer value - * @retval None - */ -void BSP_LCD_SetLayerAddress(uint32_t LayerIndex, uint32_t Address) -{ - HAL_LTDC_SetAddress(&hltdc_eval, Address, LayerIndex); -} - -/** - * @brief Sets display window. - * @param LayerIndex: Layer index - * @param Xpos: LCD X position - * @param Ypos: LCD Y position - * @param Width: LCD window width - * @param Height: LCD window height - * @retval None - */ -void BSP_LCD_SetLayerWindow(uint16_t LayerIndex, uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height) -{ - /* Reconfigure the layer size */ - HAL_LTDC_SetWindowSize(&hltdc_eval, Width, Height, LayerIndex); - - /* Reconfigure the layer position */ - HAL_LTDC_SetWindowPosition(&hltdc_eval, Xpos, Ypos, LayerIndex); -} - -/** - * @brief Configures and sets the color keying. - * @param LayerIndex: Layer foreground or background - * @param RGBValue: Color reference - * @retval None - */ -void BSP_LCD_SetColorKeying(uint32_t LayerIndex, uint32_t RGBValue) -{ - /* Configure and Enable the color Keying for LCD Layer */ - HAL_LTDC_ConfigColorKeying(&hltdc_eval, RGBValue, LayerIndex); - HAL_LTDC_EnableColorKeying(&hltdc_eval, LayerIndex); -} - -/** - * @brief Disables the color keying. - * @param LayerIndex: Layer foreground or background - * @retval None - */ -void BSP_LCD_ResetColorKeying(uint32_t LayerIndex) -{ - /* Disable the color Keying for LCD Layer */ - HAL_LTDC_DisableColorKeying(&hltdc_eval, LayerIndex); -} - -/** - * @brief Sets the LCD text color. - * @param Color: Text color code ARGB(8-8-8-8) - * @retval None - */ -void BSP_LCD_SetTextColor(uint32_t Color) -{ - DrawProp[ActiveLayer].TextColor = Color; -} - -/** - * @brief Gets the LCD text color. - * @param None - * @retval Used text color. - */ -uint32_t BSP_LCD_GetTextColor(void) -{ - return DrawProp[ActiveLayer].TextColor; -} - -/** - * @brief Sets the LCD background color. - * @param Color: Layer background color code ARGB(8-8-8-8) - * @retval None - */ -void BSP_LCD_SetBackColor(uint32_t Color) -{ - DrawProp[ActiveLayer].BackColor = Color; -} - -/** - * @brief Gets the LCD background color. - * @param None - * @retval Used background color - */ -uint32_t BSP_LCD_GetBackColor(void) -{ - return DrawProp[ActiveLayer].BackColor; -} - -/** - * @brief Sets the LCD text font. - * @param fonts: Layer font to be used - * @retval None - */ -void BSP_LCD_SetFont(sFONT *fonts) -{ - DrawProp[ActiveLayer].pFont = fonts; -} - -/** - * @brief Gets the LCD text font. - * @param None - * @retval Used layer font - */ -sFONT *BSP_LCD_GetFont(void) -{ - return DrawProp[ActiveLayer].pFont; -} - -/** - * @brief Reads an LCD pixel. - * @param Xpos: X position - * @param Ypos: Y position - * @retval RGB pixel color - */ -uint32_t BSP_LCD_ReadPixel(uint16_t Xpos, uint16_t Ypos) -{ - uint32_t ret = 0; - - if(hltdc_eval.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_ARGB8888) - { - /* Read data value from SDRAM memory */ - ret = *(__IO uint32_t*) (hltdc_eval.LayerCfg[ActiveLayer].FBStartAdress + (2*(Ypos*BSP_LCD_GetXSize() + Xpos))); - } - else if(hltdc_eval.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_RGB888) - { - /* Read data value from SDRAM memory */ - ret = (*(__IO uint32_t*) (hltdc_eval.LayerCfg[ActiveLayer].FBStartAdress + (2*(Ypos*BSP_LCD_GetXSize() + Xpos))) & 0x00FFFFFF); - } - else if((hltdc_eval.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_RGB565) || \ - (hltdc_eval.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_ARGB4444) || \ - (hltdc_eval.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_AL88)) - { - /* Read data value from SDRAM memory */ - ret = *(__IO uint16_t*) (hltdc_eval.LayerCfg[ActiveLayer].FBStartAdress + (2*(Ypos*BSP_LCD_GetXSize() + Xpos))); - } - else - { - /* Read data value from SDRAM memory */ - ret = *(__IO uint8_t*) (hltdc_eval.LayerCfg[ActiveLayer].FBStartAdress + (2*(Ypos*BSP_LCD_GetXSize() + Xpos))); - } - - return ret; -} - -/** - * @brief Clears the hole LCD. - * @param Color: Color of the background - * @retval None - */ -void BSP_LCD_Clear(uint32_t Color) -{ - /* Clear the LCD */ - LL_FillBuffer(ActiveLayer, (uint32_t *)(hltdc_eval.LayerCfg[ActiveLayer].FBStartAdress), BSP_LCD_GetXSize(), BSP_LCD_GetYSize(), 0, Color); -} - -/** - * @brief Clears the selected line. - * @param Line: Line to be cleared - * @retval None - */ -void BSP_LCD_ClearStringLine(uint32_t Line) -{ - uint32_t color_backup = DrawProp[ActiveLayer].TextColor; - DrawProp[ActiveLayer].TextColor = DrawProp[ActiveLayer].BackColor; - - /* Draw rectangle with background color */ - BSP_LCD_FillRect(0, (Line * DrawProp[ActiveLayer].pFont->Height), BSP_LCD_GetXSize(), DrawProp[ActiveLayer].pFont->Height); - - DrawProp[ActiveLayer].TextColor = color_backup; - BSP_LCD_SetTextColor(DrawProp[ActiveLayer].TextColor); -} - -/** - * @brief Displays one character. - * @param Xpos: Start column address - * @param Ypos: Line where to display the character shape. - * @param Ascii: Character ascii code - * This parameter must be a number between Min_Data = 0x20 and Max_Data = 0x7E - * @retval None - */ -void BSP_LCD_DisplayChar(uint16_t Xpos, uint16_t Ypos, uint8_t Ascii) -{ - DrawChar(Xpos, Ypos, &DrawProp[ActiveLayer].pFont->table[(Ascii-' ') *\ - DrawProp[ActiveLayer].pFont->Height * ((DrawProp[ActiveLayer].pFont->Width + 7) / 8)]); -} - -/** - * @brief Displays characters on the LCD. - * @param Xpos: X position (in pixel) - * @param Ypos: Y position (in pixel) - * @param Text: Pointer to string to display on LCD - * @param Mode: Display mode - * This parameter can be one of the following values: - * @arg CENTER_MODE - * @arg RIGHT_MODE - * @arg LEFT_MODE - * @retval None - */ -void BSP_LCD_DisplayStringAt(uint16_t Xpos, uint16_t Ypos, uint8_t *Text, Text_AlignModeTypdef Mode) -{ - uint16_t refcolumn = 1, i = 0; - uint32_t size = 0, xsize = 0; - uint8_t *ptr = Text; - - /* Get the text size */ - while (*ptr++) size ++ ; - - /* Characters number per line */ - xsize = (BSP_LCD_GetXSize()/DrawProp[ActiveLayer].pFont->Width); - - switch (Mode) - { - case CENTER_MODE: - { - refcolumn = Xpos + ((xsize - size)* DrawProp[ActiveLayer].pFont->Width) / 2; - break; - } - case LEFT_MODE: - { - refcolumn = Xpos; - break; - } - case RIGHT_MODE: - { - refcolumn = - Xpos + ((xsize - size)*DrawProp[ActiveLayer].pFont->Width); - break; - } - default: - { - refcolumn = Xpos; - break; - } - } - - /* Send the string character by character on LCD */ - while ((*Text != 0) & (((BSP_LCD_GetXSize() - (i*DrawProp[ActiveLayer].pFont->Width)) & 0xFFFF) >= DrawProp[ActiveLayer].pFont->Width)) - { - /* Display one character on LCD */ - BSP_LCD_DisplayChar(refcolumn, Ypos, *Text); - /* Decrement the column position by 16 */ - refcolumn += DrawProp[ActiveLayer].pFont->Width; - /* Point on the next character */ - Text++; - i++; - } -} - -/** - * @brief Displays a maximum of 60 characters on the LCD. - * @param Line: Line where to display the character shape - * @param ptr: Pointer to string to display on LCD - * @retval None - */ -void BSP_LCD_DisplayStringAtLine(uint16_t Line, uint8_t *ptr) -{ - BSP_LCD_DisplayStringAt(0, LINE(Line), ptr, LEFT_MODE); -} - -/** - * @brief Draws an horizontal line. - * @param Xpos: X position - * @param Ypos: Y position - * @param Length: Line length - * @retval None - */ -void BSP_LCD_DrawHLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length) -{ - uint32_t Xaddress = 0; - - /* Get the line address */ - Xaddress = (hltdc_eval.LayerCfg[ActiveLayer].FBStartAdress) + 4*(BSP_LCD_GetXSize()*Ypos + Xpos); - - /* Write line */ - LL_FillBuffer(ActiveLayer, (uint32_t *)Xaddress, Length, 1, 0, DrawProp[ActiveLayer].TextColor); -} - -/** - * @brief Draws a vertical line. - * @param Xpos: X position - * @param Ypos: Y position - * @param Length: Line length - * @retval None - */ -void BSP_LCD_DrawVLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length) -{ - uint32_t Xaddress = 0; - - /* Get the line address */ - Xaddress = (hltdc_eval.LayerCfg[ActiveLayer].FBStartAdress) + 4*(BSP_LCD_GetXSize()*Ypos + Xpos); - - /* Write line */ - LL_FillBuffer(ActiveLayer, (uint32_t *)Xaddress, 1, Length, (BSP_LCD_GetXSize() - 1), DrawProp[ActiveLayer].TextColor); -} - -/** - * @brief Draws an uni-line (between two points). - * @param x1: Point 1 X position - * @param y1: Point 1 Y position - * @param x2: Point 2 X position - * @param y2: Point 2 Y position - * @retval None - */ -void BSP_LCD_DrawLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) -{ - int16_t deltax = 0, deltay = 0, x = 0, y = 0, xinc1 = 0, xinc2 = 0, - yinc1 = 0, yinc2 = 0, den = 0, num = 0, numadd = 0, numpixels = 0, - curpixel = 0; - - deltax = ABS(x2 - x1); /* The difference between the x's */ - deltay = ABS(y2 - y1); /* The difference between the y's */ - x = x1; /* Start x off at the first pixel */ - y = y1; /* Start y off at the first pixel */ - - if (x2 >= x1) /* The x-values are increasing */ - { - xinc1 = 1; - xinc2 = 1; - } - else /* The x-values are decreasing */ - { - xinc1 = -1; - xinc2 = -1; - } - - if (y2 >= y1) /* The y-values are increasing */ - { - yinc1 = 1; - yinc2 = 1; - } - else /* The y-values are decreasing */ - { - yinc1 = -1; - yinc2 = -1; - } - - if (deltax >= deltay) /* There is at least one x-value for every y-value */ - { - xinc1 = 0; /* Don't change the x when numerator >= denominator */ - yinc2 = 0; /* Don't change the y for every iteration */ - den = deltax; - num = deltax / 2; - numadd = deltay; - numpixels = deltax; /* There are more x-values than y-values */ - } - else /* There is at least one y-value for every x-value */ - { - xinc2 = 0; /* Don't change the x for every iteration */ - yinc1 = 0; /* Don't change the y when numerator >= denominator */ - den = deltay; - num = deltay / 2; - numadd = deltax; - numpixels = deltay; /* There are more y-values than x-values */ - } - - for (curpixel = 0; curpixel <= numpixels; curpixel++) - { - BSP_LCD_DrawPixel(x, y, DrawProp[ActiveLayer].TextColor); /* Draw the current pixel */ - num += numadd; /* Increase the numerator by the top of the fraction */ - if (num >= den) /* Check if numerator >= denominator */ - { - num -= den; /* Calculate the new numerator value */ - x += xinc1; /* Change the x as appropriate */ - y += yinc1; /* Change the y as appropriate */ - } - x += xinc2; /* Change the x as appropriate */ - y += yinc2; /* Change the y as appropriate */ - } -} - -/** - * @brief Draws a rectangle. - * @param Xpos: X position - * @param Ypos: Y position - * @param Width: Rectangle width - * @param Height: Rectangle height - * @retval None - */ -void BSP_LCD_DrawRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height) -{ - /* Draw horizontal lines */ - BSP_LCD_DrawHLine(Xpos, Ypos, Width); - BSP_LCD_DrawHLine(Xpos, (Ypos+ Height), Width); - - /* Draw vertical lines */ - BSP_LCD_DrawVLine(Xpos, Ypos, Height); - BSP_LCD_DrawVLine((Xpos + Width), Ypos, Height); -} - -/** - * @brief Draws a circle. - * @param Xpos: X position - * @param Ypos: Y position - * @param Radius: Circle radius - * @retval None - */ -void BSP_LCD_DrawCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius) -{ - int32_t D; /* Decision Variable */ - uint32_t CurX; /* Current X Value */ - uint32_t CurY; /* Current Y Value */ - - D = 3 - (Radius << 1); - CurX = 0; - CurY = Radius; - - while (CurX <= CurY) - { - BSP_LCD_DrawPixel((Xpos + CurX), (Ypos - CurY), DrawProp[ActiveLayer].TextColor); - - BSP_LCD_DrawPixel((Xpos - CurX), (Ypos - CurY), DrawProp[ActiveLayer].TextColor); - - BSP_LCD_DrawPixel((Xpos + CurY), (Ypos - CurX), DrawProp[ActiveLayer].TextColor); - - BSP_LCD_DrawPixel((Xpos - CurY), (Ypos - CurX), DrawProp[ActiveLayer].TextColor); - - BSP_LCD_DrawPixel((Xpos + CurX), (Ypos + CurY), DrawProp[ActiveLayer].TextColor); - - BSP_LCD_DrawPixel((Xpos - CurX), (Ypos + CurY), DrawProp[ActiveLayer].TextColor); - - BSP_LCD_DrawPixel((Xpos + CurY), (Ypos + CurX), DrawProp[ActiveLayer].TextColor); - - BSP_LCD_DrawPixel((Xpos - CurY), (Ypos + CurX), DrawProp[ActiveLayer].TextColor); - - if (D < 0) - { - D += (CurX << 2) + 6; - } - else - { - D += ((CurX - CurY) << 2) + 10; - CurY--; - } - CurX++; - } -} - -/** - * @brief Draws an poly-line (between many points). - * @param Points: Pointer to the points array - * @param PointCount: Number of points - * @retval None - */ -void BSP_LCD_DrawPolygon(pPoint Points, uint16_t PointCount) -{ - int16_t X = 0, Y = 0; - - if(PointCount < 2) - { - return; - } - - BSP_LCD_DrawLine(Points->X, Points->Y, (Points+PointCount-1)->X, (Points+PointCount-1)->Y); - - while(--PointCount) - { - X = Points->X; - Y = Points->Y; - Points++; - BSP_LCD_DrawLine(X, Y, Points->X, Points->Y); - } -} - -/** - * @brief Draws an ellipse on LCD. - * @param Xpos: X position - * @param Ypos: Y position - * @param XRadius: Ellipse X radius - * @param YRadius: Ellipse Y radius - * @retval None - */ -void BSP_LCD_DrawEllipse(int Xpos, int Ypos, int XRadius, int YRadius) -{ - int x = 0, y = -YRadius, err = 2-2*XRadius, e2; - float K = 0, rad1 = 0, rad2 = 0; - - rad1 = XRadius; - rad2 = YRadius; - - K = (float)(rad2/rad1); - - do { - BSP_LCD_DrawPixel((Xpos-(uint16_t)(x/K)), (Ypos+y), DrawProp[ActiveLayer].TextColor); - BSP_LCD_DrawPixel((Xpos+(uint16_t)(x/K)), (Ypos+y), DrawProp[ActiveLayer].TextColor); - BSP_LCD_DrawPixel((Xpos+(uint16_t)(x/K)), (Ypos-y), DrawProp[ActiveLayer].TextColor); - BSP_LCD_DrawPixel((Xpos-(uint16_t)(x/K)), (Ypos-y), DrawProp[ActiveLayer].TextColor); - - e2 = err; - if (e2 <= x) { - err += ++x*2+1; - if (-y == x && e2 <= y) e2 = 0; - } - if (e2 > y) err += ++y*2+1; - } - while (y <= 0); -} - -/** - * @brief Draws a bitmap picture loaded in the internal Flash (32 bpp). - * @param Xpos: Bmp X position in the LCD - * @param Ypos: Bmp Y position in the LCD - * @param pbmp: Pointer to Bmp picture address in the internal Flash - * @retval None - */ -void BSP_LCD_DrawBitmap(uint32_t Xpos, uint32_t Ypos, uint8_t *pbmp) -{ - uint32_t index = 0, width = 0, height = 0, bit_pixel = 0; - uint32_t Address; - uint32_t InputColorMode = 0; - - /* Get bitmap data address offset */ - index = *(__IO uint16_t *) (pbmp + 10); - index |= (*(__IO uint16_t *) (pbmp + 12)) << 16; - - /* Read bitmap width */ - width = *(uint16_t *) (pbmp + 18); - width |= (*(uint16_t *) (pbmp + 20)) << 16; - - /* Read bitmap height */ - height = *(uint16_t *) (pbmp + 22); - height |= (*(uint16_t *) (pbmp + 24)) << 16; - - /* Read bit/pixel */ - bit_pixel = *(uint16_t *) (pbmp + 28); - - /* Set the address */ - Address = hltdc_eval.LayerCfg[ActiveLayer].FBStartAdress + (((BSP_LCD_GetXSize()*Ypos) + Xpos)*(4)); - - /* Get the layer pixel format */ - if ((bit_pixel/8) == 4) - { - InputColorMode = CM_ARGB8888; - } - else if ((bit_pixel/8) == 2) - { - InputColorMode = CM_RGB565; - } - else - { - InputColorMode = CM_RGB888; - } - - /* Bypass the bitmap header */ - pbmp += (index + (width * (height - 1) * (bit_pixel/8))); - - /* Convert picture to ARGB8888 pixel format */ - for(index=0; index < height; index++) - { - /* Pixel format conversion */ - LL_ConvertLineToARGB8888((uint32_t *)pbmp, (uint32_t *)Address, width, InputColorMode); - - /* Increment the source and destination buffers */ - Address+= (BSP_LCD_GetXSize()*4); - pbmp -= width*(bit_pixel/8); - } -} - -/** - * @brief Draws a full rectangle. - * @param Xpos: X position - * @param Ypos: Y position - * @param Width: Rectangle width - * @param Height: Rectangle height - * @retval None - */ -void BSP_LCD_FillRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height) -{ - uint32_t Xaddress = 0; - - /* Set the text color */ - BSP_LCD_SetTextColor(DrawProp[ActiveLayer].TextColor); - - /* Get the rectangle start address */ - Xaddress = (hltdc_eval.LayerCfg[ActiveLayer].FBStartAdress) + 4*(BSP_LCD_GetXSize()*Ypos + Xpos); - - /* Fill the rectangle */ - LL_FillBuffer(ActiveLayer, (uint32_t *)Xaddress, Width, Height, (BSP_LCD_GetXSize() - Width), DrawProp[ActiveLayer].TextColor); -} - -/** - * @brief Draws a full circle. - * @param Xpos: X position - * @param Ypos: Y position - * @param Radius: Circle radius - * @retval None - */ -void BSP_LCD_FillCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius) -{ - int32_t D; /* Decision Variable */ - uint32_t CurX; /* Current X Value */ - uint32_t CurY; /* Current Y Value */ - - D = 3 - (Radius << 1); - - CurX = 0; - CurY = Radius; - - BSP_LCD_SetTextColor(DrawProp[ActiveLayer].TextColor); - - while (CurX <= CurY) - { - if(CurY > 0) - { - BSP_LCD_DrawHLine(Xpos - CurY, Ypos + CurX, 2*CurY); - BSP_LCD_DrawHLine(Xpos - CurY, Ypos - CurX, 2*CurY); - } - - if(CurX > 0) - { - BSP_LCD_DrawHLine(Xpos - CurX, Ypos - CurY, 2*CurX); - BSP_LCD_DrawHLine(Xpos - CurX, Ypos + CurY, 2*CurX); - } - if (D < 0) - { - D += (CurX << 2) + 6; - } - else - { - D += ((CurX - CurY) << 2) + 10; - CurY--; - } - CurX++; - } - - BSP_LCD_SetTextColor(DrawProp[ActiveLayer].TextColor); - BSP_LCD_DrawCircle(Xpos, Ypos, Radius); -} - -/** - * @brief Draws a full poly-line (between many points). - * @param Points: Pointer to the points array - * @param PointCount: Number of points - * @retval None - */ -void BSP_LCD_FillPolygon(pPoint Points, uint16_t PointCount) -{ - int16_t X = 0, Y = 0, X2 = 0, Y2 = 0, X_center = 0, Y_center = 0, X_first = 0, Y_first = 0, pixelX = 0, pixelY = 0, counter = 0; - uint16_t IMAGE_LEFT = 0, IMAGE_RIGHT = 0, IMAGE_TOP = 0, IMAGE_BOTTOM = 0; - - IMAGE_LEFT = IMAGE_RIGHT = Points->X; - IMAGE_TOP= IMAGE_BOTTOM = Points->Y; - - for(counter = 1; counter < PointCount; counter++) - { - pixelX = POLY_X(counter); - if(pixelX < IMAGE_LEFT) - { - IMAGE_LEFT = pixelX; - } - if(pixelX > IMAGE_RIGHT) - { - IMAGE_RIGHT = pixelX; - } - - pixelY = POLY_Y(counter); - if(pixelY < IMAGE_TOP) - { - IMAGE_TOP = pixelY; - } - if(pixelY > IMAGE_BOTTOM) - { - IMAGE_BOTTOM = pixelY; - } - } - - if(PointCount < 2) - { - return; - } - - X_center = (IMAGE_LEFT + IMAGE_RIGHT)/2; - Y_center = (IMAGE_BOTTOM + IMAGE_TOP)/2; - - X_first = Points->X; - Y_first = Points->Y; - - while(--PointCount) - { - X = Points->X; - Y = Points->Y; - Points++; - X2 = Points->X; - Y2 = Points->Y; - - FillTriangle(X, X2, X_center, Y, Y2, Y_center); - FillTriangle(X, X_center, X2, Y, Y_center, Y2); - FillTriangle(X_center, X2, X, Y_center, Y2, Y); - } - - FillTriangle(X_first, X2, X_center, Y_first, Y2, Y_center); - FillTriangle(X_first, X_center, X2, Y_first, Y_center, Y2); - FillTriangle(X_center, X2, X_first, Y_center, Y2, Y_first); -} - -/** - * @brief Draws a full ellipse. - * @param Xpos: X position - * @param Ypos: Y position - * @param XRadius: Ellipse X radius - * @param YRadius: Ellipse Y radius - * @retval None - */ -void BSP_LCD_FillEllipse(int Xpos, int Ypos, int XRadius, int YRadius) -{ - int x = 0, y = -YRadius, err = 2-2*XRadius, e2; - float K = 0, rad1 = 0, rad2 = 0; - - rad1 = XRadius; - rad2 = YRadius; - - K = (float)(rad2/rad1); - - do - { - BSP_LCD_DrawHLine((Xpos-(uint16_t)(x/K)), (Ypos+y), (2*(uint16_t)(x/K) + 1)); - BSP_LCD_DrawHLine((Xpos-(uint16_t)(x/K)), (Ypos-y), (2*(uint16_t)(x/K) + 1)); - - e2 = err; - if (e2 <= x) - { - err += ++x*2+1; - if (-y == x && e2 <= y) e2 = 0; - } - if (e2 > y) err += ++y*2+1; - } - while (y <= 0); -} - -/** - * @brief Enables the display. - * @param None - * @retval None - */ -void BSP_LCD_DisplayOn(void) -{ - /* Display On */ - __HAL_LTDC_ENABLE(&hltdc_eval); -} - -/** - * @brief Disables the display. - * @param None - * @retval None - */ -void BSP_LCD_DisplayOff(void) -{ - /* Display Off */ - __HAL_LTDC_DISABLE(&hltdc_eval); -} - -/******************************************************************************* - LTDC and DMA2D BSP Routines -*******************************************************************************/ - -/** - * @brief Initializes the LTDC MSP. - * @param None - * @retval None - */ -static void MspInit(void) -{ - GPIO_InitTypeDef GPIO_Init_Structure; - - /* Enable the LTDC and DMA2D clocks */ - __LTDC_CLK_ENABLE(); - __DMA2D_CLK_ENABLE(); - - /* Enable GPIOs clock */ - __GPIOI_CLK_ENABLE(); - __GPIOJ_CLK_ENABLE(); - __GPIOK_CLK_ENABLE(); - - /*** LTDC Pins configuration ***/ - /* GPIOI configuration */ - GPIO_Init_Structure.Pin = GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15; - GPIO_Init_Structure.Mode = GPIO_MODE_AF_PP; - GPIO_Init_Structure.Pull = GPIO_NOPULL; - GPIO_Init_Structure.Speed = GPIO_SPEED_FAST; - GPIO_Init_Structure.Alternate = GPIO_AF14_LTDC; - HAL_GPIO_Init(GPIOI, &GPIO_Init_Structure); - - /* GPIOJ configuration */ - GPIO_Init_Structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | \ - GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7 | \ - GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 | \ - GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15; - GPIO_Init_Structure.Mode = GPIO_MODE_AF_PP; - GPIO_Init_Structure.Pull = GPIO_NOPULL; - GPIO_Init_Structure.Speed = GPIO_SPEED_FAST; - GPIO_Init_Structure.Alternate = GPIO_AF14_LTDC; - HAL_GPIO_Init(GPIOJ, &GPIO_Init_Structure); - - /* GPIOK configuration */ - GPIO_Init_Structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | \ - GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7; - GPIO_Init_Structure.Mode = GPIO_MODE_AF_PP; - GPIO_Init_Structure.Pull = GPIO_NOPULL; - GPIO_Init_Structure.Speed = GPIO_SPEED_FAST; - GPIO_Init_Structure.Alternate = GPIO_AF14_LTDC; - HAL_GPIO_Init(GPIOK, &GPIO_Init_Structure); -} - -/** - * @brief Clock Config. - * @param hltdc: LTDC handle - * @note This API is called by BSP_LCD_Init() - * Being __weak it can be overwritten by the application - * @retval None - */ -__weak void BSP_LCD_ClockConfig(LTDC_HandleTypeDef *hltdc, void *Params) -{ - static RCC_PeriphCLKInitTypeDef periph_clk_init_struct; - - if(stmpe811_ts_drv.ReadID(TS_I2C_ADDRESS) == STMPE811_ID) - { - /* AMPIRE480272 LCD clock configuration */ - /* PLLSAI_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */ - /* PLLSAI_VCO Output = PLLSAI_VCO Input * PLLSAIN = 192 Mhz */ - /* PLLLCDCLK = PLLSAI_VCO Output/PLLSAIR = 192/5 = 38.4 Mhz */ - /* LTDC clock frequency = PLLLCDCLK / LTDC_PLLSAI_DIVR_4 = 38.4/4 = 9.6Mhz */ - periph_clk_init_struct.PeriphClockSelection = RCC_PERIPHCLK_LTDC; - periph_clk_init_struct.PLLSAI.PLLSAIN = 192; - periph_clk_init_struct.PLLSAI.PLLSAIR = AMPIRE480272_FREQUENCY_DIVIDER; - periph_clk_init_struct.PLLSAIDivR = RCC_PLLSAIDIVR_4; - HAL_RCCEx_PeriphCLKConfig(&periph_clk_init_struct); - } - else - { - /* The programmed LTDC pixel clock depends on the vertical refresh rate of the panel 60Hz => 25.16MHz and - the LCD/SDRAM bandwidth affected by the several access on the bus and the number of used layers. - */ - if(*(uint32_t *)Params == LCD_MAX_PCLK) - { - /* In case of single layer the bandwidth is arround 160MBytesPerSec ==> theorical PCLK of 40MHz */ - /* AMPIRE640480 typical PCLK is 25.16 MHz so the PLLSAI is configured to provide this clock */ - /* AMPIRE640480 LCD clock configuration */ - /* PLLSAI_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */ - /* PLLSAI_VCO Output = PLLSAI_VCO Input * PLLSAIN = 151 Mhz */ - /* PLLLCDCLK = PLLSAI_VCO Output/PLLSAIR = 151/3 = 50.3 Mhz */ - /* LTDC clock frequency = PLLLCDCLK / LTDC_PLLSAI_DIVR_2 = 50.3/2 = 25.16 Mhz */ - periph_clk_init_struct.PLLSAI.PLLSAIN = 151; - } - else - { - /* In case of double layers the bandwidth is arround 72MBytesPerSec => 18MHz (<25,16MHz) */ - /* so the PLLSAI is configured to provide this clock */ - /* AMPIRE640480 LCD clock configuration */ - /* PLLSAI_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */ - /* PLLSAI_VCO Output = PLLSAI_VCO Input * PLLSAIN = 108 Mhz */ - /* PLLLCDCLK = PLLSAI_VCO Output/PLLSAIR = 108/3 = 36 Mhz */ - /* LTDC clock frequency = PLLLCDCLK / LTDC_PLLSAI_DIVR_2 = 36/2 = 18 Mhz */ - periph_clk_init_struct.PLLSAI.PLLSAIN = 108; - } - periph_clk_init_struct.PeriphClockSelection = RCC_PERIPHCLK_LTDC; - periph_clk_init_struct.PLLSAI.PLLSAIR = 3; - periph_clk_init_struct.PLLSAIDivR = RCC_PLLSAIDIVR_2; - HAL_RCCEx_PeriphCLKConfig(&periph_clk_init_struct); - } -} -/******************************************************************************* - Static Functions -*******************************************************************************/ - -/** - * @brief Draws a pixel on LCD. - * @param Xpos: X position - * @param Ypos: Y position - * @param RGB_Code: Pixel color in ARGB mode (8-8-8-8) - * @retval None - */ -void BSP_LCD_DrawPixel(uint16_t Xpos, uint16_t Ypos, uint32_t RGB_Code) -{ - /* Write data value to all SDRAM memory */ - *(__IO uint32_t*) (hltdc_eval.LayerCfg[ActiveLayer].FBStartAdress + (4*(Ypos*BSP_LCD_GetXSize() + Xpos))) = RGB_Code; -} - -/** - * @brief Draws a character on LCD. - * @param Xpos: Line where to display the character shape - * @param Ypos: Start column address - * @param c: Pointer to the character data - * @retval None - */ -static void DrawChar(uint16_t Xpos, uint16_t Ypos, const uint8_t *c) -{ - uint32_t i = 0, j = 0; - uint16_t height, width; - uint8_t offset; - uint8_t *pchar; - uint32_t line; - - height = DrawProp[ActiveLayer].pFont->Height; - width = DrawProp[ActiveLayer].pFont->Width; - - offset = 8 *((width + 7)/8) - width ; - - for(i = 0; i < height; i++) - { - pchar = ((uint8_t *)c + (width + 7)/8 * i); - - switch(((width + 7)/8)) - { - - case 1: - line = pchar[0]; - break; - - case 2: - line = (pchar[0]<< 8) | pchar[1]; - break; - - case 3: - default: - line = (pchar[0]<< 16) | (pchar[1]<< 8) | pchar[2]; - break; - } - - for (j = 0; j < width; j++) - { - if(line & (1 << (width- j + offset- 1))) - { - BSP_LCD_DrawPixel((Xpos + j), Ypos, DrawProp[ActiveLayer].TextColor); - } - else - { - BSP_LCD_DrawPixel((Xpos + j), Ypos, DrawProp[ActiveLayer].BackColor); - } - } - Ypos++; - } -} - -/** - * @brief Fills a triangle (between 3 points). - * @param Points: Pointer to the points array - * @param x1: Point 1 X position - * @param y1: Point 1 Y position - * @param x2: Point 2 X position - * @param y2: Point 2 Y position - * @param x3: Point 3 X position - * @param y3: Point 3 Y position - * @retval None - */ -static void FillTriangle(uint16_t x1, uint16_t x2, uint16_t x3, uint16_t y1, uint16_t y2, uint16_t y3) -{ - int16_t deltax = 0, deltay = 0, x = 0, y = 0, xinc1 = 0, xinc2 = 0, - yinc1 = 0, yinc2 = 0, den = 0, num = 0, numadd = 0, numpixels = 0, - curpixel = 0; - - deltax = ABS(x2 - x1); /* The difference between the x's */ - deltay = ABS(y2 - y1); /* The difference between the y's */ - x = x1; /* Start x off at the first pixel */ - y = y1; /* Start y off at the first pixel */ - - if (x2 >= x1) /* The x-values are increasing */ - { - xinc1 = 1; - xinc2 = 1; - } - else /* The x-values are decreasing */ - { - xinc1 = -1; - xinc2 = -1; - } - - if (y2 >= y1) /* The y-values are increasing */ - { - yinc1 = 1; - yinc2 = 1; - } - else /* The y-values are decreasing */ - { - yinc1 = -1; - yinc2 = -1; - } - - if (deltax >= deltay) /* There is at least one x-value for every y-value */ - { - xinc1 = 0; /* Don't change the x when numerator >= denominator */ - yinc2 = 0; /* Don't change the y for every iteration */ - den = deltax; - num = deltax / 2; - numadd = deltay; - numpixels = deltax; /* There are more x-values than y-values */ - } - else /* There is at least one y-value for every x-value */ - { - xinc2 = 0; /* Don't change the x for every iteration */ - yinc1 = 0; /* Don't change the y when numerator >= denominator */ - den = deltay; - num = deltay / 2; - numadd = deltax; - numpixels = deltay; /* There are more y-values than x-values */ - } - - for (curpixel = 0; curpixel <= numpixels; curpixel++) - { - BSP_LCD_DrawLine(x, y, x3, y3); - - num += numadd; /* Increase the numerator by the top of the fraction */ - if (num >= den) /* Check if numerator >= denominator */ - { - num -= den; /* Calculate the new numerator value */ - x += xinc1; /* Change the x as appropriate */ - y += yinc1; /* Change the y as appropriate */ - } - x += xinc2; /* Change the x as appropriate */ - y += yinc2; /* Change the y as appropriate */ - } -} - -/** - * @brief Fills a buffer. - * @param LayerIndex: Layer index - * @param pDst: Pointer to destination buffer - * @param xSize: Buffer width - * @param ySize: Buffer height - * @param OffLine: Offset - * @param ColorIndex: Color index - * @retval None - */ -static void LL_FillBuffer(uint32_t LayerIndex, void *pDst, uint32_t xSize, uint32_t ySize, uint32_t OffLine, uint32_t ColorIndex) -{ - /* Register to memory mode with ARGB8888 as color Mode */ - hdma2d_eval.Init.Mode = DMA2D_R2M; - hdma2d_eval.Init.ColorMode = DMA2D_ARGB8888; - hdma2d_eval.Init.OutputOffset = OffLine; - - hdma2d_eval.Instance = DMA2D; - - /* DMA2D Initialization */ - if(HAL_DMA2D_Init(&hdma2d_eval) == HAL_OK) - { - if(HAL_DMA2D_ConfigLayer(&hdma2d_eval, LayerIndex) == HAL_OK) - { - if (HAL_DMA2D_Start(&hdma2d_eval, ColorIndex, (uint32_t)pDst, xSize, ySize) == HAL_OK) - { - /* Polling For DMA transfer */ - HAL_DMA2D_PollForTransfer(&hdma2d_eval, 10); - } - } - } -} - -/** - * @brief Converts a line to an ARGB8888 pixel format. - * @param pSrc: Pointer to source buffer - * @param pDst: Output color - * @param xSize: Buffer width - * @param ColorMode: Input color mode - * @retval None - */ -static void LL_ConvertLineToARGB8888(void *pSrc, void *pDst, uint32_t xSize, uint32_t ColorMode) -{ - /* Configure the DMA2D Mode, Color Mode and output offset */ - hdma2d_eval.Init.Mode = DMA2D_M2M_PFC; - hdma2d_eval.Init.ColorMode = DMA2D_ARGB8888; - hdma2d_eval.Init.OutputOffset = 0; - - /* Foreground Configuration */ - hdma2d_eval.LayerCfg[1].AlphaMode = DMA2D_NO_MODIF_ALPHA; - hdma2d_eval.LayerCfg[1].InputAlpha = 0xFF; - hdma2d_eval.LayerCfg[1].InputColorMode = ColorMode; - hdma2d_eval.LayerCfg[1].InputOffset = 0; - - hdma2d_eval.Instance = DMA2D; - - /* DMA2D Initialization */ - if(HAL_DMA2D_Init(&hdma2d_eval) == HAL_OK) - { - if(HAL_DMA2D_ConfigLayer(&hdma2d_eval, 1) == HAL_OK) - { - if (HAL_DMA2D_Start(&hdma2d_eval, (uint32_t)pSrc, (uint32_t)pDst, xSize, 1) == HAL_OK) - { - /* Polling For DMA transfer */ - HAL_DMA2D_PollForTransfer(&hdma2d_eval, 10); - } - } - } -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval_lcd.h b/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval_lcd.h deleted file mode 100644 index 235e13a2a2..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval_lcd.h +++ /dev/null @@ -1,244 +0,0 @@ -/** - ****************************************************************************** - * @file stm324x9i_eval_lcd.h - * @author MCD Application Team - * @version V2.2.1 - * @date 07-October-2015 - * @brief This file contains the common defines and functions prototypes for - * the stm324x9i_eval_lcd.c driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM324x9I_EVAL_LCD_H -#define __STM324x9I_EVAL_LCD_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -/* Include LCD component Driver */ -/* LCD integrated within MB1063 */ -#include "../Components/ampire640480/ampire640480.h" -/* LCD integrated within MB1046 */ -#include "../Components/ampire480272/ampire480272.h" - -/* Include IOExpander(STMPE811) component Driver */ -#include "../Components/stmpe811/stmpe811.h" - -/* Include SDRAM Driver */ -#include "stm324x9i_eval_sdram.h" - -#include "stm324x9i_eval.h" -#include "../../../Utilities/Fonts/fonts.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM324x9I_EVAL - * @{ - */ - -/** @addtogroup STM324x9I_EVAL_LCD - * @{ - */ - -/** @defgroup STM324x9I_EVAL_LCD_Exported_Types - * @{ - */ -typedef struct -{ - uint32_t TextColor; - uint32_t BackColor; - sFONT *pFont; -}LCD_DrawPropTypeDef; - -typedef struct -{ - int16_t X; - int16_t Y; -}Point, * pPoint; - -/** - * @brief Line mode structures definition - */ -typedef enum -{ - CENTER_MODE = 0x01, /* Center mode */ - RIGHT_MODE = 0x02, /* Right mode */ - LEFT_MODE = 0x03 /* Left mode */ -}Text_AlignModeTypdef; - -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_LCD_Exported_Constants - * @{ - */ -#define MAX_LAYER_NUMBER 2 - -#define LCD_LayerCfgTypeDef LTDC_LayerCfgTypeDef - -/** - * @brief LCD status structure definition - */ -#define LCD_OK 0x00 -#define LCD_ERROR 0x01 -#define LCD_TIMEOUT 0x02 - -/** - * @brief LCD FB_StartAddress - */ -#define LCD_FB_START_ADDRESS ((uint32_t)0xC0000000) - -/* The programmed LTDC pixel clock depends on the vertical refresh rate of the panel 60Hz => 25.16MHz and - the LCD/SDRAM bandwidth affected by the several access on the bus and the number of used layers. - when only one layer is enabled "LCD_MAX_PCLK" can be used and when two layers are enabled simultaneously - or/and there is several access on the bus "LCD_MIN_PCLK" parameter is recommended */ -#define LCD_MAX_PCLK ((uint8_t)0x00) -#define LCD_MIN_PCLK ((uint8_t)0x01) - -/** - * @brief LCD color - */ -#define LCD_COLOR_BLUE 0xFF0000FF -#define LCD_COLOR_GREEN 0xFF00FF00 -#define LCD_COLOR_RED 0xFFFF0000 -#define LCD_COLOR_CYAN 0xFF00FFFF -#define LCD_COLOR_MAGENTA 0xFFFF00FF -#define LCD_COLOR_YELLOW 0xFFFFFF00 -#define LCD_COLOR_LIGHTBLUE 0xFF8080FF -#define LCD_COLOR_LIGHTGREEN 0xFF80FF80 -#define LCD_COLOR_LIGHTRED 0xFFFF8080 -#define LCD_COLOR_LIGHTCYAN 0xFF80FFFF -#define LCD_COLOR_LIGHTMAGENTA 0xFFFF80FF -#define LCD_COLOR_LIGHTYELLOW 0xFFFFFF80 -#define LCD_COLOR_DARKBLUE 0xFF000080 -#define LCD_COLOR_DARKGREEN 0xFF008000 -#define LCD_COLOR_DARKRED 0xFF800000 -#define LCD_COLOR_DARKCYAN 0xFF008080 -#define LCD_COLOR_DARKMAGENTA 0xFF800080 -#define LCD_COLOR_DARKYELLOW 0xFF808000 -#define LCD_COLOR_WHITE 0xFFFFFFFF -#define LCD_COLOR_LIGHTGRAY 0xFFD3D3D3 -#define LCD_COLOR_GRAY 0xFF808080 -#define LCD_COLOR_DARKGRAY 0xFF404040 -#define LCD_COLOR_BLACK 0xFF000000 -#define LCD_COLOR_BROWN 0xFFA52A2A -#define LCD_COLOR_ORANGE 0xFFFFA500 -#define LCD_COLOR_TRANSPARENT 0xFF000000 - -/** - * @brief LCD default font - */ -#define LCD_DEFAULT_FONT Font24 -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_LCD_Exported_Functions - * @{ - */ -uint8_t BSP_LCD_Init(void); -uint8_t BSP_LCD_InitEx(uint32_t PclkConfig); - -uint32_t BSP_LCD_GetXSize(void); -uint32_t BSP_LCD_GetYSize(void); - -/* Functions using the LTDC controller */ -void BSP_LCD_LayerDefaultInit(uint16_t LayerIndex, uint32_t FrameBuffer); -void BSP_LCD_SetTransparency(uint32_t LayerIndex, uint8_t Transparency); -void BSP_LCD_SetLayerAddress(uint32_t LayerIndex, uint32_t Address); -void BSP_LCD_SetColorKeying(uint32_t LayerIndex, uint32_t RGBValue); -void BSP_LCD_ResetColorKeying(uint32_t LayerIndex); -void BSP_LCD_SetLayerWindow(uint16_t LayerIndex, uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height); - -void BSP_LCD_SelectLayer(uint32_t LayerIndex); -void BSP_LCD_SetLayerVisible(uint32_t LayerIndex, FunctionalState State); - -void BSP_LCD_SetTextColor(uint32_t Color); -uint32_t BSP_LCD_GetTextColor(void); -void BSP_LCD_SetBackColor(uint32_t Color); -uint32_t BSP_LCD_GetBackColor(void); -void BSP_LCD_SetFont(sFONT *fonts); -sFONT *BSP_LCD_GetFont(void); - -uint32_t BSP_LCD_ReadPixel(uint16_t Xpos, uint16_t Ypos); -void BSP_LCD_DrawPixel(uint16_t Xpos, uint16_t Ypos, uint32_t pixel); -void BSP_LCD_Clear(uint32_t Color); -void BSP_LCD_ClearStringLine(uint32_t Line); -void BSP_LCD_DisplayStringAtLine(uint16_t Line, uint8_t *ptr); -void BSP_LCD_DisplayStringAt(uint16_t Xpos, uint16_t Ypos, uint8_t *Text, Text_AlignModeTypdef Mode); -void BSP_LCD_DisplayChar(uint16_t Xpos, uint16_t Ypos, uint8_t Ascii); - -void BSP_LCD_DrawHLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length); -void BSP_LCD_DrawVLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length); -void BSP_LCD_DrawLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2); -void BSP_LCD_DrawRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height); -void BSP_LCD_DrawCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius); -void BSP_LCD_DrawPolygon(pPoint Points, uint16_t PointCount); -void BSP_LCD_DrawEllipse(int Xpos, int Ypos, int XRadius, int YRadius); -void BSP_LCD_DrawBitmap(uint32_t Xpos, uint32_t Ypos, uint8_t *pbmp); - -void BSP_LCD_FillRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height); -void BSP_LCD_FillCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius); -void BSP_LCD_FillPolygon(pPoint Points, uint16_t PointCount); -void BSP_LCD_FillEllipse(int Xpos, int Ypos, int XRadius, int YRadius); - -void BSP_LCD_DisplayOff(void); -void BSP_LCD_DisplayOn(void); - -void BSP_LCD_ClockConfig(LTDC_HandleTypeDef *hltdc, void *Params); -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM324x9I_EVAL_LCD_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval_nor.c b/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval_nor.c deleted file mode 100644 index 600632d7ba..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval_nor.c +++ /dev/null @@ -1,411 +0,0 @@ -/** - ****************************************************************************** - * @file stm324x9i_eval_nor.c - * @author MCD Application Team - * @version V2.2.1 - * @date 07-October-2015 - * @brief This file includes a standard driver for the M29W256GL70ZA6E NOR flash memory - * device mounted on STM324x9I-EVAL evaluation board. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* File Info : ----------------------------------------------------------------- - User NOTES -1. How To use this driver: --------------------------- - - This driver is used to drive the M29W128GL NOR flash external memory mounted - on STM324x9I-EVAL evaluation board. - - This driver does not need a specific component driver for the NOR device - to be included with. - -2. Driver description: ---------------------- - + Initialization steps: - o Initialize the NOR external memory using the BSP_NOR_Init() function. This - function includes the MSP layer hardware resources initialization and the - FMC controller configuration to interface with the external NOR memory. - - + NOR flash operations - o NOR external memory can be accessed with read/write operations once it is - initialized. - Read/write operation can be performed with AHB access using the functions - BSP_NOR_ReadData()/BSP_NOR_WriteData(). The BSP_NOR_WriteData() performs write operation - of an amount of data by unit (halfword). You can also perform a program data - operation of an amount of data using the function BSP_NOR_ProgramData(). - o The function BSP_NOR_Read_ID() returns the chip IDs stored in the structure - "NOR_IDTypeDef". (see the NOR IDs in the memory data sheet) - o Perform erase block operation using the function BSP_NOR_Erase_Block() and by - specifying the block address. You can perform an erase operation of the whole - chip by calling the function BSP_NOR_Erase_Chip(). - o After other operations, the function BSP_NOR_ReturnToReadMode() allows the NOR - flash to return to read mode to perform read operations on it. - -------------------------------------------------------------------------------*/ - -/* Includes ------------------------------------------------------------------*/ -#include "stm324x9i_eval_nor.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM324x9I_EVAL - * @{ - */ - -/** @defgroup STM324x9I_EVAL_NOR - * @{ - */ - -/* Private typedef -----------------------------------------------------------*/ - -/** @defgroup STM324x9I_EVAL_NOR_Private_Types_Definitions - * @{ - */ - -/* Private define ------------------------------------------------------------*/ - -/** @defgroup STM324x9I_EVAL_NOR_Private_Defines - * @{ - */ - -/* Private macro -------------------------------------------------------------*/ - -/** @defgroup STM324x9I_EVAL_NOR_Private_Macros - * @{ - */ - -/* Private variables ---------------------------------------------------------*/ - -/** @defgroup STM324x9I_EVAL_NOR_Private_Variables - * @{ - */ -static NOR_HandleTypeDef norHandle; -static FMC_NORSRAM_TimingTypeDef Timing; - -/** - * @} - */ - -/* Private function prototypes -----------------------------------------------*/ - -/** @defgroup STM324x9I_EVAL_NOR_Private_Function_Prototypes - * @{ - */ - -/* Private functions ---------------------------------------------------------*/ - -/** @defgroup STM324x9I_EVAL_NOR_Private_Functions - * @{ - */ -static void NOR_MspInit(void); - -/** - * @} - */ - -/** - * @brief Initializes the NOR device. - * @param None - * @retval NOR memory status - */ -uint8_t BSP_NOR_Init(void) -{ - norHandle.Instance = FMC_NORSRAM_DEVICE; - norHandle.Extended = FMC_NORSRAM_EXTENDED_DEVICE; - - /* NOR device configuration */ - Timing.AddressSetupTime = 4; - Timing.AddressHoldTime = 3; - Timing.DataSetupTime = 7; - Timing.BusTurnAroundDuration = 1; - Timing.CLKDivision = 2; - Timing.DataLatency = 2; - Timing.AccessMode = FMC_ACCESS_MODE_A; - - norHandle.Init.NSBank = FMC_NORSRAM_BANK1; - norHandle.Init.DataAddressMux = FMC_DATA_ADDRESS_MUX_DISABLE; - norHandle.Init.MemoryType = FMC_MEMORY_TYPE_NOR; - norHandle.Init.MemoryDataWidth = NOR_MEMORY_WIDTH; - norHandle.Init.BurstAccessMode = NOR_BURSTACCESS; - norHandle.Init.WaitSignalPolarity = FMC_WAIT_SIGNAL_POLARITY_LOW; - norHandle.Init.WrapMode = FMC_WRAP_MODE_DISABLE; - norHandle.Init.WaitSignalActive = FMC_WAIT_TIMING_BEFORE_WS; - norHandle.Init.WriteOperation = FMC_WRITE_OPERATION_ENABLE; - norHandle.Init.WaitSignal = FMC_WAIT_SIGNAL_ENABLE; - norHandle.Init.ExtendedMode = FMC_EXTENDED_MODE_DISABLE; - norHandle.Init.AsynchronousWait = FMC_ASYNCHRONOUS_WAIT_ENABLE; - norHandle.Init.WriteBurst = NOR_WRITEBURST; - norHandle.Init.ContinuousClock = CONTINUOUSCLOCK_FEATURE; - - /* NOR controller initialization */ - NOR_MspInit(); - - if(HAL_NOR_Init(&norHandle, &Timing, &Timing) != HAL_OK) - { - return NOR_STATUS_ERROR; - } - else - { - return NOR_STATUS_OK; - } -} - -/** - * @brief Reads an amount of data from the NOR device. - * @param uwStartAddress: Read start address - * @param pData: Pointer to data to be read - * @param uwDataSize: Size of data to read - * @retval NOR memory status - */ -uint8_t BSP_NOR_ReadData(uint32_t uwStartAddress, uint16_t* pData, uint32_t uwDataSize) -{ - if(HAL_NOR_ReadBuffer(&norHandle, NOR_DEVICE_ADDR + uwStartAddress, pData, uwDataSize) != HAL_OK) - { - return NOR_STATUS_ERROR; - } - else - { - return NOR_STATUS_OK; - } -} - -/** - * @brief Returns the NOR memory to read mode. - * @param None - * @retval None - */ -void BSP_NOR_ReturnToReadMode(void) -{ - HAL_NOR_ReturnToReadMode(&norHandle); -} - -/** - * @brief Writes an amount of data to the NOR device. - * @param uwStartAddress: Write start address - * @param pData: Pointer to data to be written - * @param uwDataSize: Size of data to write - * @retval NOR memory status - */ -uint8_t BSP_NOR_WriteData(uint32_t uwStartAddress, uint16_t* pData, uint32_t uwDataSize) -{ - uint32_t index = uwDataSize; - - while(index > 0) - { - /* Write data to NOR */ - HAL_NOR_Program(&norHandle, (uint32_t *)(NOR_DEVICE_ADDR + uwStartAddress), pData); - - /* Read NOR device status */ - if(HAL_NOR_GetStatus(&norHandle, NOR_DEVICE_ADDR, PROGRAM_TIMEOUT) != NOR_SUCCESS) - { - return NOR_STATUS_ERROR; - } - - /* Update the counters */ - index--; - uwStartAddress += 2; - pData++; - } - - return NOR_STATUS_OK; -} - -/** - * @brief Programs an amount of data to the NOR device. - * @param uwStartAddress: Write start address - * @param pData: Pointer to data to be written - * @param uwDataSize: Size of data to write - * @retval NOR memory status - */ -uint8_t BSP_NOR_ProgramData(uint32_t uwStartAddress, uint16_t* pData, uint32_t uwDataSize) -{ - /* Send NOR program buffer operation */ - HAL_NOR_ProgramBuffer(&norHandle, uwStartAddress, pData, uwDataSize); - - /* Return the NOR memory status */ - if(HAL_NOR_GetStatus(&norHandle, NOR_DEVICE_ADDR, PROGRAM_TIMEOUT) != NOR_SUCCESS) - { - return NOR_STATUS_ERROR; - } - else - { - return NOR_STATUS_OK; - } -} - -/** - * @brief Erases the specified block of the NOR device. - * @param BlockAddress: Block address to erase - * @retval NOR memory status - */ -uint8_t BSP_NOR_Erase_Block(uint32_t BlockAddress) -{ - /* Send NOR erase block operation */ - HAL_NOR_Erase_Block(&norHandle, BlockAddress, NOR_DEVICE_ADDR); - - /* Return the NOR memory status */ - if(HAL_NOR_GetStatus(&norHandle, NOR_DEVICE_ADDR, BLOCKERASE_TIMEOUT) != NOR_SUCCESS) - { - return NOR_STATUS_ERROR; - } - else - { - return NOR_STATUS_OK; - } -} - -/** - * @brief Erases the entire NOR chip. - * @param None - * @retval NOR memory status - */ -uint8_t BSP_NOR_Erase_Chip(void) -{ - /* Send NOR Erase chip operation */ - HAL_NOR_Erase_Chip(&norHandle, NOR_DEVICE_ADDR); - - /* Return the NOR memory status */ - if(HAL_NOR_GetStatus(&norHandle, NOR_DEVICE_ADDR, CHIPERASE_TIMEOUT) != NOR_SUCCESS) - { - return NOR_STATUS_ERROR; - } - else - { - return NOR_STATUS_OK; - } -} - -/** - * @brief Reads NOR flash IDs. - * @param pNOR_ID : Pointer to NOR ID structure - * @retval NOR memory status - */ -uint8_t BSP_NOR_Read_ID(NOR_IDTypeDef *pNOR_ID) -{ - if(HAL_NOR_Read_ID(&norHandle, pNOR_ID) != HAL_OK) - { - return NOR_STATUS_ERROR; - } - else - { - return NOR_STATUS_OK; - } -} - -/** - * @brief Initializes the NOR MSP. - * @param None - * @retval None - */ -static void NOR_MspInit(void) -{ - GPIO_InitTypeDef GPIO_Init_Structure; - - /* Enable FMC clock */ - __FMC_CLK_ENABLE(); - - /* Enable GPIOs clock */ - __GPIOD_CLK_ENABLE(); - __GPIOE_CLK_ENABLE(); - __GPIOF_CLK_ENABLE(); - __GPIOG_CLK_ENABLE(); - - /* Common GPIO configuration */ - GPIO_Init_Structure.Mode = GPIO_MODE_AF_PP; - GPIO_Init_Structure.Pull = GPIO_PULLUP; - GPIO_Init_Structure.Speed = GPIO_SPEED_HIGH; - GPIO_Init_Structure.Alternate = GPIO_AF12_FMC; - - /* GPIOD configuration */ - GPIO_Init_Structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 |\ - GPIO_PIN_7 | GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 |\ - GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15; - HAL_GPIO_Init(GPIOD, &GPIO_Init_Structure); - - /* GPIOE configuration */ - GPIO_Init_Structure.Pin = GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 |\ - GPIO_PIN_7 | GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 |\ - GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15; - HAL_GPIO_Init(GPIOE, &GPIO_Init_Structure); - - /* GPIOF configuration */ - GPIO_Init_Structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2| GPIO_PIN_3 | GPIO_PIN_4 |\ - GPIO_PIN_5 | GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15; - HAL_GPIO_Init(GPIOF, &GPIO_Init_Structure); - - /* GPIOG configuration */ - GPIO_Init_Structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2| GPIO_PIN_3 | GPIO_PIN_4 |\ - GPIO_PIN_5; - HAL_GPIO_Init(GPIOG, &GPIO_Init_Structure); -} - -/** - * @brief NOR BSP Wait for Ready/Busy signal. - * @param hnor: Pointer to NOR handle - * @param Timeout: Timeout duration - * @retval None - */ -void HAL_NOR_MspWait(NOR_HandleTypeDef *hnor, uint32_t Timeout) -{ - uint32_t timeout = Timeout; - - /* Polling on Ready/Busy signal */ - while((HAL_GPIO_ReadPin(NOR_READY_BUSY_GPIO, NOR_READY_BUSY_PIN) != NOR_BUSY_STATE) && (timeout > 0)) - { - timeout--; - } - - timeout = Timeout; - - /* Polling on Ready/Busy signal */ - while((HAL_GPIO_ReadPin(NOR_READY_BUSY_GPIO, NOR_READY_BUSY_PIN) != NOR_READY_STATE) && (timeout > 0)) - { - timeout--; - } -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval_nor.h b/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval_nor.h deleted file mode 100644 index bfddc048eb..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval_nor.h +++ /dev/null @@ -1,147 +0,0 @@ -/** - ****************************************************************************** - * @file stm324x9i_eval_nor.h - * @author MCD Application Team - * @version V2.2.1 - * @date 07-October-2015 - * @brief This file contains the common defines and functions prototypes for - * the stm324x9i_eval_nor.c driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM324x9I_EVAL_NOR_H -#define __STM324x9I_EVAL_NOR_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm32f4xx_hal.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM324x9I_EVAL - * @{ - */ - -/** @defgroup STM324x9I_EVAL_NOR - * @{ - */ - -/** @defgroup STM324x9I_EVAL_NOR_Exported_Types - * @{ - */ -/** - * @} - */ - -/** - * @brief NOR status structure definition - */ -#define NOR_STATUS_OK 0x00 -#define NOR_STATUS_ERROR 0x01 - -/** @defgroup STM324x9I_EVAL_NOR_Exported_Constants - * @{ - */ -#define NOR_DEVICE_ADDR ((uint32_t)0x60000000) - -/* #define NOR_MEMORY_WIDTH FMC_NORSRAM_MEM_BUS_WIDTH_8 */ -#define NOR_MEMORY_WIDTH FMC_NORSRAM_MEM_BUS_WIDTH_16 - -#define NOR_BURSTACCESS FMC_BURST_ACCESS_MODE_DISABLE -/* #define NOR_BURSTACCESS FMC_BURST_ACCESS_MODE_ENABLE*/ - -#define NOR_WRITEBURST FMC_WRITE_BURST_DISABLE -/* #define NOR_WRITEBURST FMC_WRITE_BURST_ENABLE */ - -#define CONTINUOUSCLOCK_FEATURE FMC_CONTINUOUS_CLOCK_SYNC_ONLY -/* #define CONTINUOUSCLOCK_FEATURE FMC_CONTINUOUS_CLOCK_SYNC_ASYNC */ - -/* NOR operations Timeout definitions */ -#define BLOCKERASE_TIMEOUT ((uint32_t)0x00A00000) /* NOR block erase timeout */ -#define CHIPERASE_TIMEOUT ((uint32_t)0x30000000) /* NOR chip erase timeout */ -#define PROGRAM_TIMEOUT ((uint32_t)0x00004400) /* NOR program timeout */ - -/* NOR Ready/Busy signal GPIO definitions */ -#define NOR_READY_BUSY_PIN GPIO_PIN_6 -#define NOR_READY_BUSY_GPIO GPIOD -#define NOR_READY_STATE GPIO_PIN_SET -#define NOR_BUSY_STATE GPIO_PIN_RESET -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_NOR_Exported_Macro - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_NOR_Exported_Functions - * @{ - */ -uint8_t BSP_NOR_Init(void); -uint8_t BSP_NOR_ReadData(uint32_t uwStartAddress, uint16_t *pData, uint32_t uwDataSize); -uint8_t BSP_NOR_WriteData(uint32_t uwStartAddress, uint16_t *pData, uint32_t uwDataSize); -uint8_t BSP_NOR_ProgramData(uint32_t uwStartAddress, uint16_t *pData, uint32_t uwDataSize); -uint8_t BSP_NOR_Erase_Block(uint32_t BlockAddress); -uint8_t BSP_NOR_Erase_Chip(void); -uint8_t BSP_NOR_Read_ID(NOR_IDTypeDef *pNOR_ID); -void BSP_NOR_ReturnToReadMode(void); - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM324x9I_EVAL_NOR_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval_sd.c b/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval_sd.c deleted file mode 100644 index 893aa9e8f2..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval_sd.c +++ /dev/null @@ -1,547 +0,0 @@ -/** - ****************************************************************************** - * @file stm324x9i_eval_sd.c - * @author MCD Application Team - * @version V2.2.1 - * @date 07-October-2015 - * @brief This file includes the uSD card driver mounted on STM324x9I-EVAL - * evaluation board. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* File Info : ----------------------------------------------------------------- - User NOTES -1. How To use this driver: --------------------------- - - This driver is used to drive the micro SD external card mounted on STM324x9I-EVAL - evaluation board. - - This driver does not need a specific component driver for the micro SD device - to be included with. - -2. Driver description: ---------------------- - + Initialization steps: - o Initialize the micro SD card using the BSP_SD_Init() function. This - function includes the MSP layer hardware resources initialization and the - SDIO interface configuration to interface with the external micro SD. It - also includes the micro SD initialization sequence. - o To check the SD card presence you can use the function BSP_SD_IsDetected() which - returns the detection status - o If SD presence detection interrupt mode is desired, you must configure the - SD detection interrupt mode by calling the function BSP_SD_ITConfig(). The interrupt - is generated as an external interrupt whenever the micro SD card is - plugged/unplugged in/from the evaluation board. The SD detection interrupt - is handled by calling the function BSP_SD_DetectIT() which is called in the IRQ - handler file, the user callback is implemented in the function BSP_SD_DetectCallback(). - o The function BSP_SD_GetCardInfo() is used to get the micro SD card information - which is stored in the structure "HAL_SD_CardInfoTypedef". - - + Micro SD card operations - o The micro SD card can be accessed with read/write block(s) operations once - it is ready for access. The access can be performed whether using the polling - mode by calling the functions BSP_SD_ReadBlocks()/BSP_SD_WriteBlocks(), or by DMA - transfer using the functions BSP_SD_ReadBlocks_DMA()/BSP_SD_WriteBlocks_DMA() - o The DMA transfer complete is used with interrupt mode. Once the SD transfer - is complete, the SD interrupt is handled using the function BSP_SD_IRQHandler(), - the DMA Tx/Rx transfer complete are handled using the functions - BSP_SD_DMA_Tx_IRQHandler()/BSP_SD_DMA_Rx_IRQHandler(). The corresponding user callbacks - are implemented by the user at application level. - o The SD erase block(s) is performed using the function BSP_SD_Erase() with specifying - the number of blocks to erase. - o The SD runtime status is returned when calling the function BSP_SD_GetStatus(). - -------------------------------------------------------------------------------*/ - -/* Includes ------------------------------------------------------------------*/ -#include "stm324x9i_eval_sd.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM324x9I_EVAL - * @{ - */ - -/** @defgroup STM324x9I_EVAL_SD - * @{ - */ - - -/** @defgroup STM324x9I_EVAL_SD_Private_TypesDefinitions - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_SD_Private_Defines - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_SD_Private_Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_SD_Private_Variables - * @{ - */ -static SD_HandleTypeDef uSdHandle; -static SD_CardInfo uSdCardInfo; -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_SD_Private_FunctionPrototypes - * @{ - */ -static void SD_MspInit(void); -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_SD_Private_Functions - * @{ - */ - -/** - * @brief Initializes the SD card device. - * @param None - * @retval SD status - */ -uint8_t BSP_SD_Init(void) -{ - uint8_t SD_state = MSD_OK; - - /* uSD device interface configuration */ - uSdHandle.Instance = SDIO; - - uSdHandle.Init.ClockEdge = SDIO_CLOCK_EDGE_RISING; - uSdHandle.Init.ClockBypass = SDIO_CLOCK_BYPASS_DISABLE; - uSdHandle.Init.ClockPowerSave = SDIO_CLOCK_POWER_SAVE_DISABLE; - uSdHandle.Init.BusWide = SDIO_BUS_WIDE_1B; - uSdHandle.Init.HardwareFlowControl = SDIO_HARDWARE_FLOW_CONTROL_DISABLE; - uSdHandle.Init.ClockDiv = SDIO_TRANSFER_CLK_DIV; - - /* Configure IO functionalities for SD detect pin */ - BSP_IO_Init(); - - /* Check if the SD card is plugged in the slot */ - if(BSP_SD_IsDetected() != SD_PRESENT) - { - return MSD_ERROR; - } - - /* HAL SD initialization */ - SD_MspInit(); - if(HAL_SD_Init(&uSdHandle, &uSdCardInfo) != SD_OK) - { - SD_state = MSD_ERROR; - } - - /* Configure SD Bus width */ - if(SD_state == MSD_OK) - { - /* Enable wide operation */ - if(HAL_SD_WideBusOperation_Config(&uSdHandle, SDIO_BUS_WIDE_4B) != SD_OK) - { - SD_state = MSD_ERROR; - } - else - { - SD_state = MSD_OK; - } - } - - return SD_state; -} - -/** - * @brief Configures Interrupt mode for SD detection pin. - * @param None - * @retval Returns 0 - */ -uint8_t BSP_SD_ITConfig(void) -{ - /* Configure Interrupt mode for SD detection pin */ - BSP_IO_ConfigPin(SD_DETECT_PIN, IO_MODE_IT_FALLING_EDGE); - - return 0; -} - -/** - * @brief Detects if SD card is correctly plugged in the memory slot or not. - * @param None - * @retval Returns if SD is detected or not - */ -uint8_t BSP_SD_IsDetected(void) -{ - __IO uint8_t status = SD_PRESENT; - - /* Check SD card detect pin */ - if(BSP_IO_ReadPin(SD_DETECT_PIN)) - { - status = SD_NOT_PRESENT; - } - - return status; -} - -/** @brief SD detect IT treatment. - * @param None - * @retval None - */ -void BSP_SD_DetectIT(void) -{ - /* Clear all pending bits */ - BSP_IO_ITClear(); - - /* To re-enable IT */ - BSP_SD_ITConfig(); - - /* SD detect IT callback */ - BSP_SD_DetectCallback(); -} - -/** @brief SD detect IT detection callback - * @param None - * @retval None - */ -__weak void BSP_SD_DetectCallback(void) -{ - /* NOTE: This function Should not be modified, when the callback is needed, - the BSP_SD_DetectCallback could be implemented in the user file - */ -} - -/** - * @brief Reads block(s) from a specified address in an SD card, in polling mode. - * @param pData: Pointer to the buffer that will contain the data to transmit - * @param ReadAddr: Address from where data is to be read - * @param BlockSize: SD card data block size, that should be 512 - * @param NumOfBlocks: Number of SD blocks to read - * @retval SD status - */ -uint8_t BSP_SD_ReadBlocks(uint32_t *pData, uint64_t ReadAddr, uint32_t BlockSize, uint32_t NumOfBlocks) -{ - if(HAL_SD_ReadBlocks(&uSdHandle, pData, ReadAddr, BlockSize, NumOfBlocks) != SD_OK) - { - return MSD_ERROR; - } - else - { - return MSD_OK; - } -} - -/** - * @brief Writes block(s) to a specified address in an SD card, in polling mode. - * @param pData: Pointer to the buffer that will contain the data to transmit - * @param WriteAddr: Address from where data is to be written - * @param BlockSize: SD card data block size, that should be 512 - * @param NumOfBlocks: Number of SD blocks to write - * @retval SD status - */ -uint8_t BSP_SD_WriteBlocks(uint32_t *pData, uint64_t WriteAddr, uint32_t BlockSize, uint32_t NumOfBlocks) -{ - if(HAL_SD_WriteBlocks(&uSdHandle, pData, WriteAddr, BlockSize, NumOfBlocks) != SD_OK) - { - return MSD_ERROR; - } - else - { - return MSD_OK; - } -} - -/** - * @brief Reads block(s) from a specified address in an SD card, in DMA mode. - * @param pData: Pointer to the buffer that will contain the data to transmit - * @param ReadAddr: Address from where data is to be read - * @param BlockSize: SD card data block size, that should be 512 - * @param NumOfBlocks: Number of SD blocks to read - * @retval SD status - */ -uint8_t BSP_SD_ReadBlocks_DMA(uint32_t *pData, uint64_t ReadAddr, uint32_t BlockSize, uint32_t NumOfBlocks) -{ - uint8_t SD_state = MSD_OK; - - /* Read block(s) in DMA transfer mode */ - if(HAL_SD_ReadBlocks_DMA(&uSdHandle, pData, ReadAddr, BlockSize, NumOfBlocks) != SD_OK) - { - SD_state = MSD_ERROR; - } - - /* Wait until transfer is complete */ - if(SD_state == MSD_OK) - { - if(HAL_SD_CheckReadOperation(&uSdHandle, (uint32_t)SD_DATATIMEOUT) != SD_OK) - { - SD_state = MSD_ERROR; - } - else - { - SD_state = MSD_OK; - } - } - - return SD_state; -} - -/** - * @brief Writes block(s) to a specified address in an SD card, in DMA mode. - * @param pData: Pointer to the buffer that will contain the data to transmit - * @param WriteAddr: Address from where data is to be written - * @param BlockSize: SD card data block size, that should be 512 - * @param NumOfBlocks: Number of SD blocks to write - * @retval SD status - */ -uint8_t BSP_SD_WriteBlocks_DMA(uint32_t *pData, uint64_t WriteAddr, uint32_t BlockSize, uint32_t NumOfBlocks) -{ - uint8_t SD_state = MSD_OK; - - /* Write block(s) in DMA transfer mode */ - if(HAL_SD_WriteBlocks_DMA(&uSdHandle, pData, WriteAddr, BlockSize, NumOfBlocks) != SD_OK) - { - SD_state = MSD_ERROR; - } - - /* Wait until transfer is complete */ - if(SD_state == MSD_OK) - { - if(HAL_SD_CheckWriteOperation(&uSdHandle, (uint32_t)SD_DATATIMEOUT) != SD_OK) - { - SD_state = MSD_ERROR; - } - else - { - SD_state = MSD_OK; - } - } - - return SD_state; -} - -/** - * @brief Erases the specified memory area of the given SD card. - * @param StartAddr: Start byte address - * @param EndAddr: End byte address - * @retval SD status - */ -uint8_t BSP_SD_Erase(uint64_t StartAddr, uint64_t EndAddr) -{ - if(HAL_SD_Erase(&uSdHandle, StartAddr, EndAddr) != SD_OK) - { - return MSD_ERROR; - } - else - { - return MSD_OK; - } -} - -/** - * @brief Initializes the SD MSP. - * @param None - * @retval None - */ -static void SD_MspInit(void) -{ - static DMA_HandleTypeDef dmaRxHandle; - static DMA_HandleTypeDef dmaTxHandle; - GPIO_InitTypeDef GPIO_Init_Structure; - SD_HandleTypeDef *hsd = &uSdHandle; - - /* Enable SDIO clock */ - __SDIO_CLK_ENABLE(); - - /* Enable DMA2 clocks */ - __DMAx_TxRx_CLK_ENABLE(); - - /* Enable GPIOs clock */ - __GPIOC_CLK_ENABLE(); - __GPIOD_CLK_ENABLE(); - - /* Common GPIO configuration */ - GPIO_Init_Structure.Mode = GPIO_MODE_AF_PP; - GPIO_Init_Structure.Pull = GPIO_PULLUP; - GPIO_Init_Structure.Speed = GPIO_SPEED_HIGH; - GPIO_Init_Structure.Alternate = GPIO_AF12_SDIO; - - /* GPIOC configuration */ - GPIO_Init_Structure.Pin = GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12; - - HAL_GPIO_Init(GPIOC, &GPIO_Init_Structure); - - /* GPIOD configuration */ - GPIO_Init_Structure.Pin = GPIO_PIN_2; - HAL_GPIO_Init(GPIOD, &GPIO_Init_Structure); - - /* NVIC configuration for SDIO interrupts */ - HAL_NVIC_SetPriority(SDIO_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(SDIO_IRQn); - - /* Configure DMA Rx parameters */ - dmaRxHandle.Init.Channel = SD_DMAx_Rx_CHANNEL; - dmaRxHandle.Init.Direction = DMA_PERIPH_TO_MEMORY; - dmaRxHandle.Init.PeriphInc = DMA_PINC_DISABLE; - dmaRxHandle.Init.MemInc = DMA_MINC_ENABLE; - dmaRxHandle.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; - dmaRxHandle.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; - dmaRxHandle.Init.Mode = DMA_PFCTRL; - dmaRxHandle.Init.Priority = DMA_PRIORITY_VERY_HIGH; - dmaRxHandle.Init.FIFOMode = DMA_FIFOMODE_ENABLE; - dmaRxHandle.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; - dmaRxHandle.Init.MemBurst = DMA_MBURST_INC4; - dmaRxHandle.Init.PeriphBurst = DMA_PBURST_INC4; - - dmaRxHandle.Instance = SD_DMAx_Rx_STREAM; - - /* Associate the DMA handle */ - __HAL_LINKDMA(hsd, hdmarx, dmaRxHandle); - - /* Deinitialize the stream for new transfer */ - HAL_DMA_DeInit(&dmaRxHandle); - - /* Configure the DMA stream */ - HAL_DMA_Init(&dmaRxHandle); - - /* Configure DMA Tx parameters */ - dmaTxHandle.Init.Channel = SD_DMAx_Tx_CHANNEL; - dmaTxHandle.Init.Direction = DMA_MEMORY_TO_PERIPH; - dmaTxHandle.Init.PeriphInc = DMA_PINC_DISABLE; - dmaTxHandle.Init.MemInc = DMA_MINC_ENABLE; - dmaTxHandle.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; - dmaTxHandle.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; - dmaTxHandle.Init.Mode = DMA_PFCTRL; - dmaTxHandle.Init.Priority = DMA_PRIORITY_VERY_HIGH; - dmaTxHandle.Init.FIFOMode = DMA_FIFOMODE_ENABLE; - dmaTxHandle.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; - dmaTxHandle.Init.MemBurst = DMA_MBURST_INC4; - dmaTxHandle.Init.PeriphBurst = DMA_PBURST_INC4; - - dmaTxHandle.Instance = SD_DMAx_Tx_STREAM; - - /* Associate the DMA handle */ - __HAL_LINKDMA(hsd, hdmatx, dmaTxHandle); - - /* Deinitialize the stream for new transfer */ - HAL_DMA_DeInit(&dmaTxHandle); - - /* Configure the DMA stream */ - HAL_DMA_Init(&dmaTxHandle); - - /* NVIC configuration for DMA transfer complete interrupt */ - HAL_NVIC_SetPriority(SD_DMAx_Rx_IRQn, 6, 0); - HAL_NVIC_EnableIRQ(SD_DMAx_Rx_IRQn); - - /* NVIC configuration for DMA transfer complete interrupt */ - HAL_NVIC_SetPriority(SD_DMAx_Tx_IRQn, 6, 0); - HAL_NVIC_EnableIRQ(SD_DMAx_Tx_IRQn); -} - -/** - * @brief Handles SD card interrupt request. - * @param None - * @retval None - */ -void BSP_SD_IRQHandler(void) -{ - HAL_SD_IRQHandler(&uSdHandle); -} - -/** - * @brief Handles SD DMA Tx transfer interrupt request. - * @param None - * @retval None - */ -void BSP_SD_DMA_Tx_IRQHandler(void) -{ - HAL_DMA_IRQHandler(uSdHandle.hdmatx); -} - -/** - * @brief Handles SD DMA Rx transfer interrupt request. - * @param None - * @retval None - */ -void BSP_SD_DMA_Rx_IRQHandler(void) -{ - HAL_DMA_IRQHandler(uSdHandle.hdmarx); -} - -/** - * @brief Gets the current SD card data status. - * @param None - * @retval Data transfer state. - * This value can be one of the following values: - * @arg SD_TRANSFER_OK: No data transfer is acting - * @arg SD_TRANSFER_BUSY: Data transfer is acting - * @arg SD_TRANSFER_ERROR: Data transfer error - */ -HAL_SD_TransferStateTypedef BSP_SD_GetStatus(void) -{ - return(HAL_SD_GetStatus(&uSdHandle)); -} - -/** - * @brief Get SD information about specific SD card. - * @param CardInfo: Pointer to HAL_SD_CardInfoTypedef structure - * @retval None - */ -void BSP_SD_GetCardInfo(HAL_SD_CardInfoTypedef *CardInfo) -{ - /* Get SD card Information */ - HAL_SD_Get_CardInfo(&uSdHandle, CardInfo); -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval_sd.h b/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval_sd.h deleted file mode 100644 index e2b040f517..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval_sd.h +++ /dev/null @@ -1,152 +0,0 @@ -/** - ****************************************************************************** - * @file stm324x9i_eval_sd.h - * @author MCD Application Team - * @version V2.2.1 - * @date 07-October-2015 - * @brief This file contains the common defines and functions prototypes for - * the stm324x9i_eval_sd.c driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM324x9I_EVAL_SD_H -#define __STM324x9I_EVAL_SD_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm32f4xx_hal.h" -#include "stm324x9i_eval_io.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM324x9I_EVAL - * @{ - */ - -/** @defgroup STM324x9I_EVAL_SD - * @{ - */ - -/** @defgroup STM324x9I_EVAL_SD_Exported_Types - * @{ - */ - -/** - * @brief SD Card information structure - */ -#define SD_CardInfo HAL_SD_CardInfoTypedef -/** - * @} - */ - -/** - * @brief SD status structure definition - */ -#define MSD_OK 0x00 -#define MSD_ERROR 0x01 - -/** @defgroup STM324x9I_EVAL_SD_Exported_Constants - * @{ - */ -#define SD_PRESENT ((uint8_t)0x01) -#define SD_NOT_PRESENT ((uint8_t)0x00) - -#define SD_DATATIMEOUT ((uint32_t)100000000) - -/* DMA definitions for SD DMA transfer */ -#define __DMAx_TxRx_CLK_ENABLE __DMA2_CLK_ENABLE -#define SD_DMAx_Tx_CHANNEL DMA_CHANNEL_4 -#define SD_DMAx_Rx_CHANNEL DMA_CHANNEL_4 -#define SD_DMAx_Tx_STREAM DMA2_Stream6 -#define SD_DMAx_Rx_STREAM DMA2_Stream3 -#define SD_DMAx_Tx_IRQn DMA2_Stream6_IRQn -#define SD_DMAx_Rx_IRQn DMA2_Stream3_IRQn -#define SD_DMAx_Tx_IRQHandler DMA2_Stream6_IRQHandler -#define SD_DMAx_Rx_IRQHandler DMA2_Stream3_IRQHandler -#define SD_DetectIRQHandler() HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_8) -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_SD_Exported_Macro - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_SD_Exported_Functions - * @{ - */ -uint8_t BSP_SD_Init(void); -uint8_t BSP_SD_ITConfig(void); -void BSP_SD_DetectIT(void); -void BSP_SD_DetectCallback(void); -uint8_t BSP_SD_ReadBlocks(uint32_t *pData, uint64_t ReadAddr, uint32_t BlockSize, uint32_t NumOfBlocks); -uint8_t BSP_SD_WriteBlocks(uint32_t *pData, uint64_t WriteAddr, uint32_t BlockSize, uint32_t NumOfBlocks); -uint8_t BSP_SD_ReadBlocks_DMA(uint32_t *pData, uint64_t ReadAddr, uint32_t BlockSize, uint32_t NumOfBlocks); -uint8_t BSP_SD_WriteBlocks_DMA(uint32_t *pData, uint64_t WriteAddr, uint32_t BlockSize, uint32_t NumOfBlocks); -uint8_t BSP_SD_Erase(uint64_t StartAddr, uint64_t EndAddr); -void BSP_SD_IRQHandler(void); -void BSP_SD_DMA_Tx_IRQHandler(void); -void BSP_SD_DMA_Rx_IRQHandler(void); -HAL_SD_TransferStateTypedef BSP_SD_GetStatus(void); -void BSP_SD_GetCardInfo(HAL_SD_CardInfoTypedef *CardInfo); -uint8_t BSP_SD_IsDetected(void); - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM324x9I_EVAL_SD_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval_sdram.c b/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval_sdram.c deleted file mode 100644 index 6951c89f0a..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval_sdram.c +++ /dev/null @@ -1,463 +0,0 @@ -/** - ****************************************************************************** - * @file stm324x9i_eval_sdram.c - * @author MCD Application Team - * @version V2.2.1 - * @date 07-October-2015 - * @brief This file includes the SDRAM driver for the MT48LC4M32B2B5-7 memory - * device mounted on STM324x9I-EVAL evaluation board. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* File Info : ----------------------------------------------------------------- - User NOTES -1. How To use this driver: --------------------------- - - This driver is used to drive the MT48LC4M32B2B5-7 SDRAM external memory mounted - on STM324x9I-EVAL evaluation board. - - This driver does not need a specific component driver for the SDRAM device - to be included with. - -2. Driver description: ---------------------- - + Initialization steps: - o Initialize the SDRAM external memory using the BSP_SDRAM_Init() function. This - function includes the MSP layer hardware resources initialization and the - FMC controller configuration to interface with the external SDRAM memory. - o It contains the SDRAM initialization sequence to program the SDRAM external - device using the function BSP_SDRAM_Initialization_sequence(). Note that this - sequence is standard for all SDRAM devices, but can include some differences - from a device to another. If it is the case, the right sequence should be - implemented separately. - - + SDRAM read/write operations - o SDRAM external memory can be accessed with read/write operations once it is - initialized. - Read/write operation can be performed with AHB access using the functions - BSP_SDRAM_ReadData()/BSP_SDRAM_WriteData(), or by DMA transfer using the functions - BSP_SDRAM_ReadData_DMA()/BSP_SDRAM_WriteData_DMA(). - o The AHB access is performed with 32-bit width transaction, the DMA transfer - configuration is fixed at single (no burst) word transfer (see the - SDRAM_MspInit() static function). - o User can implement his own functions for read/write access with his desired - configurations. - o If interrupt mode is used for DMA transfer, the function BSP_SDRAM_DMA_IRQHandler() - is called in IRQ handler file, to serve the generated interrupt once the DMA - transfer is complete. - o You can send a command to the SDRAM device in runtime using the function - BSP_SDRAM_Sendcmd(), and giving the desired command as parameter chosen between - the predefined commands of the "FMC_SDRAM_CommandTypeDef" structure. - -------------------------------------------------------------------------------*/ - -/* Includes ------------------------------------------------------------------*/ -#include "stm324x9i_eval_sdram.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM324x9I_EVAL - * @{ - */ - -/** @defgroup STM324x9I_EVAL_SDRAM - * @{ - */ - -/** @defgroup STM324x9I_EVAL_SDRAM_Private_Types_Definitions - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_SDRAM_Private_Defines - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_SDRAM_Private_Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_SDRAM_Private_Variables - * @{ - */ -static SDRAM_HandleTypeDef sdramHandle; -static FMC_SDRAM_TimingTypeDef Timing; -static FMC_SDRAM_CommandTypeDef Command; -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_SDRAM_Private_Function_Prototypes - * @{ - */ -static void SDRAM_MspInit(void); -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_SDRAM_Private_Functions - * @{ - */ - -/** - * @brief Initializes the SDRAM device. - * @param None - * @retval SDRAM status - */ -uint8_t BSP_SDRAM_Init(void) -{ - static uint8_t sdramstatus = SDRAM_ERROR; - /* SDRAM device configuration */ - sdramHandle.Instance = FMC_SDRAM_DEVICE; - - /* Timing configuration for 90Mhz as SD clock frequency (System clock is up to 180Mhz */ - Timing.LoadToActiveDelay = 2; - Timing.ExitSelfRefreshDelay = 7; - Timing.SelfRefreshTime = 4; - Timing.RowCycleDelay = 7; - Timing.WriteRecoveryTime = 2; - Timing.RPDelay = 2; - Timing.RCDDelay = 2; - - sdramHandle.Init.SDBank = FMC_SDRAM_BANK1; - sdramHandle.Init.ColumnBitsNumber = FMC_SDRAM_COLUMN_BITS_NUM_9; - sdramHandle.Init.RowBitsNumber = FMC_SDRAM_ROW_BITS_NUM_12; - sdramHandle.Init.MemoryDataWidth = SDRAM_MEMORY_WIDTH; - sdramHandle.Init.InternalBankNumber = FMC_SDRAM_INTERN_BANKS_NUM_4; - sdramHandle.Init.CASLatency = FMC_SDRAM_CAS_LATENCY_3; - sdramHandle.Init.WriteProtection = FMC_SDRAM_WRITE_PROTECTION_DISABLE; - sdramHandle.Init.SDClockPeriod = SDCLOCK_PERIOD; - sdramHandle.Init.ReadBurst = FMC_SDRAM_RBURST_ENABLE; - sdramHandle.Init.ReadPipeDelay = FMC_SDRAM_RPIPE_DELAY_0; - - /* SDRAM controller initialization */ - SDRAM_MspInit(); - if(HAL_SDRAM_Init(&sdramHandle, &Timing) != HAL_OK) - { - sdramstatus = SDRAM_ERROR; - } - else - { - sdramstatus = SDRAM_OK; - } - - /* SDRAM initialization sequence */ - BSP_SDRAM_Initialization_sequence(REFRESH_COUNT); - - return sdramstatus; -} - -/** - * @brief Programs the SDRAM device. - * @param RefreshCount: SDRAM refresh counter value - * @retval None - */ -void BSP_SDRAM_Initialization_sequence(uint32_t RefreshCount) -{ - __IO uint32_t tmpmrd = 0; - - /* Step 1: Configure a clock configuration enable command */ - Command.CommandMode = FMC_SDRAM_CMD_CLK_ENABLE; - Command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1; - Command.AutoRefreshNumber = 1; - Command.ModeRegisterDefinition = 0; - - /* Send the command */ - HAL_SDRAM_SendCommand(&sdramHandle, &Command, SDRAM_TIMEOUT); - - /* Step 2: Insert 100 us minimum delay */ - /* Inserted delay is equal to 1 ms due to systick time base unit (ms) */ - HAL_Delay(1); - - /* Step 3: Configure a PALL (precharge all) command */ - Command.CommandMode = FMC_SDRAM_CMD_PALL; - Command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1; - Command.AutoRefreshNumber = 1; - Command.ModeRegisterDefinition = 0; - - /* Send the command */ - HAL_SDRAM_SendCommand(&sdramHandle, &Command, SDRAM_TIMEOUT); - - /* Step 4: Configure an Auto Refresh command */ - Command.CommandMode = FMC_SDRAM_CMD_AUTOREFRESH_MODE; - Command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1; - Command.AutoRefreshNumber = 8; - Command.ModeRegisterDefinition = 0; - - /* Send the command */ - HAL_SDRAM_SendCommand(&sdramHandle, &Command, SDRAM_TIMEOUT); - - /* Step 5: Program the external memory mode register */ - tmpmrd = (uint32_t)SDRAM_MODEREG_BURST_LENGTH_1 |\ - SDRAM_MODEREG_BURST_TYPE_SEQUENTIAL |\ - SDRAM_MODEREG_CAS_LATENCY_3 |\ - SDRAM_MODEREG_OPERATING_MODE_STANDARD |\ - SDRAM_MODEREG_WRITEBURST_MODE_SINGLE; - - Command.CommandMode = FMC_SDRAM_CMD_LOAD_MODE; - Command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1; - Command.AutoRefreshNumber = 1; - Command.ModeRegisterDefinition = tmpmrd; - - /* Send the command */ - HAL_SDRAM_SendCommand(&sdramHandle, &Command, SDRAM_TIMEOUT); - - /* Step 6: Set the refresh rate counter */ - /* Set the device refresh rate */ - HAL_SDRAM_ProgramRefreshRate(&sdramHandle, RefreshCount); -} - -/** - * @brief Reads an mount of data from the SDRAM memory in polling mode. - * @param uwStartAddress: Read start address - * @param pData: Pointer to data to be read - * @param uwDataSize: Size of read data from the memory - * @retval SDRAM status - */ -uint8_t BSP_SDRAM_ReadData(uint32_t uwStartAddress, uint32_t *pData, uint32_t uwDataSize) -{ - if(HAL_SDRAM_Read_32b(&sdramHandle, (uint32_t *)uwStartAddress, pData, uwDataSize) != HAL_OK) - { - return SDRAM_ERROR; - } - else - { - return SDRAM_OK; - } -} - -/** - * @brief Reads an mount of data from the SDRAM memory in DMA mode. - * @param uwStartAddress: Read start address - * @param pData: Pointer to data to be read - * @param uwDataSize: Size of read data from the memory - * @retval SDRAM status - */ -uint8_t BSP_SDRAM_ReadData_DMA(uint32_t uwStartAddress, uint32_t *pData, uint32_t uwDataSize) -{ - if(HAL_SDRAM_Read_DMA(&sdramHandle, (uint32_t *)uwStartAddress, pData, uwDataSize) != HAL_OK) - { - return SDRAM_ERROR; - } - else - { - return SDRAM_OK; - } -} - -/** - * @brief Writes an mount of data to the SDRAM memory in polling mode. - * @param uwStartAddress: Write start address - * @param pData: Pointer to data to be written - * @param uwDataSize: Size of written data from the memory - * @retval SDRAM status - */ -uint8_t BSP_SDRAM_WriteData(uint32_t uwStartAddress, uint32_t *pData, uint32_t uwDataSize) -{ - if(HAL_SDRAM_Write_32b(&sdramHandle, (uint32_t *)uwStartAddress, pData, uwDataSize) != HAL_OK) - { - return SDRAM_ERROR; - } - else - { - return SDRAM_OK; - } -} - -/** - * @brief Writes an mount of data to the SDRAM memory in DMA mode. - * @param uwStartAddress: Write start address - * @param pData: Pointer to data to be written - * @param uwDataSize: Size of written data from the memory - * @retval SDRAM status - */ -uint8_t BSP_SDRAM_WriteData_DMA(uint32_t uwStartAddress, uint32_t *pData, uint32_t uwDataSize) -{ - if(HAL_SDRAM_Write_DMA(&sdramHandle, (uint32_t *)uwStartAddress, pData, uwDataSize) != HAL_OK) - { - return SDRAM_ERROR; - } - else - { - return SDRAM_OK; - } -} - -/** - * @brief Sends command to the SDRAM bank. - * @param SdramCmd: Pointer to SDRAM command structure - * @retval HAL status - */ -uint8_t BSP_SDRAM_Sendcmd(FMC_SDRAM_CommandTypeDef *SdramCmd) -{ - if(HAL_SDRAM_SendCommand(&sdramHandle, SdramCmd, SDRAM_TIMEOUT) != HAL_OK) - { - return SDRAM_ERROR; - } - else - { - return SDRAM_OK; - } -} - -/** - * @brief Handles SDRAM DMA transfer interrupt request. - * @param None - * @retval None - */ -void BSP_SDRAM_DMA_IRQHandler(void) -{ - HAL_DMA_IRQHandler(sdramHandle.hdma); -} - -/** - * @brief Initializes SDRAM MSP. - * @param None - * @retval None - */ -static void SDRAM_MspInit(void) -{ - static DMA_HandleTypeDef dmaHandle; - GPIO_InitTypeDef GPIO_Init_Structure; - SDRAM_HandleTypeDef *hsdram = &sdramHandle; - - /* Enable FMC clock */ - __FMC_CLK_ENABLE(); - - /* Enable chosen DMAx clock */ - __DMAx_CLK_ENABLE(); - - /* Enable GPIOs clock */ - __GPIOD_CLK_ENABLE(); - __GPIOE_CLK_ENABLE(); - __GPIOF_CLK_ENABLE(); - __GPIOG_CLK_ENABLE(); - __GPIOH_CLK_ENABLE(); - __GPIOI_CLK_ENABLE(); - - /* Common GPIO configuration */ - GPIO_Init_Structure.Mode = GPIO_MODE_AF_PP; - GPIO_Init_Structure.Pull = GPIO_PULLUP; - GPIO_Init_Structure.Speed = GPIO_SPEED_FAST; - GPIO_Init_Structure.Alternate = GPIO_AF12_FMC; - - /* GPIOD configuration */ - GPIO_Init_Structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_8| GPIO_PIN_9 | GPIO_PIN_10 |\ - GPIO_PIN_14 | GPIO_PIN_15; - - - HAL_GPIO_Init(GPIOD, &GPIO_Init_Structure); - - /* GPIOE configuration */ - GPIO_Init_Structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_7| GPIO_PIN_8 | GPIO_PIN_9 |\ - GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 |\ - GPIO_PIN_15; - - HAL_GPIO_Init(GPIOE, &GPIO_Init_Structure); - - /* GPIOF configuration */ - GPIO_Init_Structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2| GPIO_PIN_3 | GPIO_PIN_4 |\ - GPIO_PIN_5 | GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 |\ - GPIO_PIN_15; - - HAL_GPIO_Init(GPIOF, &GPIO_Init_Structure); - - /* GPIOG configuration */ - GPIO_Init_Structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_4| GPIO_PIN_5 | GPIO_PIN_8 |\ - GPIO_PIN_15; - HAL_GPIO_Init(GPIOG, &GPIO_Init_Structure); - - /* GPIOH configuration */ - GPIO_Init_Structure.Pin = GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_5 | GPIO_PIN_8 | GPIO_PIN_9 |\ - GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 |\ - GPIO_PIN_15; - HAL_GPIO_Init(GPIOH, &GPIO_Init_Structure); - - /* GPIOI configuration */ - GPIO_Init_Structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 |\ - GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7 | GPIO_PIN_9 | GPIO_PIN_10; - HAL_GPIO_Init(GPIOI, &GPIO_Init_Structure); - - /* Configure common DMA parameters */ - dmaHandle.Init.Channel = SDRAM_DMAx_CHANNEL; - dmaHandle.Init.Direction = DMA_MEMORY_TO_MEMORY; - dmaHandle.Init.PeriphInc = DMA_PINC_ENABLE; - dmaHandle.Init.MemInc = DMA_MINC_ENABLE; - dmaHandle.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; - dmaHandle.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; - dmaHandle.Init.Mode = DMA_NORMAL; - dmaHandle.Init.Priority = DMA_PRIORITY_HIGH; - dmaHandle.Init.FIFOMode = DMA_FIFOMODE_DISABLE; - dmaHandle.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; - dmaHandle.Init.MemBurst = DMA_MBURST_SINGLE; - dmaHandle.Init.PeriphBurst = DMA_PBURST_SINGLE; - - dmaHandle.Instance = SDRAM_DMAx_STREAM; - - /* Associate the DMA handle */ - __HAL_LINKDMA(hsdram, hdma, dmaHandle); - - /* Deinitialize the stream for new transfer */ - HAL_DMA_DeInit(&dmaHandle); - - /* Configure the DMA stream */ - HAL_DMA_Init(&dmaHandle); - - /* NVIC configuration for DMA transfer complete interrupt */ - HAL_NVIC_SetPriority(SDRAM_DMAx_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(SDRAM_DMAx_IRQn); -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval_sdram.h b/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval_sdram.h deleted file mode 100644 index 7ccb037739..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval_sdram.h +++ /dev/null @@ -1,158 +0,0 @@ -/** - ****************************************************************************** - * @file stm324x9i_eval_sdram.h - * @author MCD Application Team - * @version V2.2.1 - * @date 07-October-2015 - * @brief This file contains the common defines and functions prototypes for - * the stm324x9i_eval_sdram.c driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM324x9I_EVAL_SDRAM_H -#define __STM324x9I_EVAL_SDRAM_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm32f4xx_hal.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM324x9I_EVAL - * @{ - */ - -/** @defgroup STM324x9I_EVAL_SDRAM - * @{ - */ - -/** @defgroup STM324x9I_EVAL_SDRAM_Exported_Types - * @{ - */ - -/** - * @brief SDRAM status structure definition - */ -#define SDRAM_OK 0x00 -#define SDRAM_ERROR 0x01 - -/** @defgroup STM324x9I_EVAL_SDRAM_Exported_Constants - * @{ - */ -#define SDRAM_DEVICE_ADDR ((uint32_t)0xC0000000) -#define SDRAM_DEVICE_SIZE ((uint32_t)0x800000) /* SDRAM device size in MBytes */ - -/* #define SDRAM_MEMORY_WIDTH FMC_SDRAM_MEM_BUS_WIDTH_8 */ -/* #define SDRAM_MEMORY_WIDTH FMC_SDRAM_MEM_BUS_WIDTH_16 */ -#define SDRAM_MEMORY_WIDTH FMC_SDRAM_MEM_BUS_WIDTH_32 - -#define SDCLOCK_PERIOD FMC_SDRAM_CLOCK_PERIOD_2 -/* #define SDCLOCK_PERIOD FMC_SDRAM_CLOCK_PERIOD_3 */ - -#define REFRESH_COUNT ((uint32_t)0x0569) /* SDRAM refresh counter (90Mhz SD clock) */ - -#define SDRAM_TIMEOUT ((uint32_t)0xFFFF) - -/* DMA definitions for SDRAM DMA transfer */ -#define __DMAx_CLK_ENABLE __DMA2_CLK_ENABLE -#define SDRAM_DMAx_CHANNEL DMA_CHANNEL_0 -#define SDRAM_DMAx_STREAM DMA2_Stream0 -#define SDRAM_DMAx_IRQn DMA2_Stream0_IRQn -#define SDRAM_DMAx_IRQHandler DMA2_Stream0_IRQHandler -/** - * @} - */ - -/** - * @brief FMC SDRAM Mode definition register defines - */ -#define SDRAM_MODEREG_BURST_LENGTH_1 ((uint16_t)0x0000) -#define SDRAM_MODEREG_BURST_LENGTH_2 ((uint16_t)0x0001) -#define SDRAM_MODEREG_BURST_LENGTH_4 ((uint16_t)0x0002) -#define SDRAM_MODEREG_BURST_LENGTH_8 ((uint16_t)0x0004) -#define SDRAM_MODEREG_BURST_TYPE_SEQUENTIAL ((uint16_t)0x0000) -#define SDRAM_MODEREG_BURST_TYPE_INTERLEAVED ((uint16_t)0x0008) -#define SDRAM_MODEREG_CAS_LATENCY_2 ((uint16_t)0x0020) -#define SDRAM_MODEREG_CAS_LATENCY_3 ((uint16_t)0x0030) -#define SDRAM_MODEREG_OPERATING_MODE_STANDARD ((uint16_t)0x0000) -#define SDRAM_MODEREG_WRITEBURST_MODE_PROGRAMMED ((uint16_t)0x0000) -#define SDRAM_MODEREG_WRITEBURST_MODE_SINGLE ((uint16_t)0x0200) -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_SDRAM_Exported_Macro - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_SDRAM_Exported_Functions - * @{ - */ -uint8_t BSP_SDRAM_Init(void); -void BSP_SDRAM_Initialization_sequence(uint32_t RefreshCount); -uint8_t BSP_SDRAM_ReadData(uint32_t uwStartAddress, uint32_t *pData, uint32_t uwDataSize); -uint8_t BSP_SDRAM_ReadData_DMA(uint32_t uwStartAddress, uint32_t *pData, uint32_t uwDataSize); -uint8_t BSP_SDRAM_WriteData(uint32_t uwStartAddress, uint32_t *pData, uint32_t uwDataSize); -uint8_t BSP_SDRAM_WriteData_DMA(uint32_t uwStartAddress, uint32_t *pData, uint32_t uwDataSize); -uint8_t BSP_SDRAM_Sendcmd(FMC_SDRAM_CommandTypeDef *SdramCmd); -void BSP_SDRAM_DMA_IRQHandler(void); - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM324x9I_EVAL_SDRAM_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval_sram.c b/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval_sram.c deleted file mode 100644 index c0fa4714de..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval_sram.c +++ /dev/null @@ -1,358 +0,0 @@ -/** - ****************************************************************************** - * @file stm324x9i_eval_sram.c - * @author MCD Application Team - * @version V2.2.1 - * @date 07-October-2015 - * @brief This file includes the SRAM driver for the IS61WV102416BLL-10M memory - * device mounted on STM324x9I-EVAL evaluation board. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* File Info : ----------------------------------------------------------------- - User NOTES -1. How To use this driver: --------------------------- - - This driver is used to drive the IS61WV102416BLL-10M SRAM external memory mounted - on STM324x9I-EVAL evaluation board. - - This driver does not need a specific component driver for the SRAM device - to be included with. - -2. Driver description: ---------------------- - + Initialization steps: - o Initialize the SRAM external memory using the BSP_SRAM_Init() function. This - function includes the MSP layer hardware resources initialization and the - FMC controller configuration to interface with the external SRAM memory. - - + SRAM read/write operations - o SRAM external memory can be accessed with read/write operations once it is - initialized. - Read/write operation can be performed with AHB access using the functions - BSP_SRAM_ReadData()/BSP_SRAM_WriteData(), or by DMA transfer using the functions - BSP_SRAM_ReadData_DMA()/BSP_SRAM_WriteData_DMA(). - o The AHB access is performed with 16-bit width transaction, the DMA transfer - configuration is fixed at single (no burst) halfword transfer - (see the SRAM_MspInit() static function). - o User can implement his own functions for read/write access with his desired - configurations. - o If interrupt mode is used for DMA transfer, the function BSP_SRAM_DMA_IRQHandler() - is called in IRQ handler file, to serve the generated interrupt once the DMA - transfer is complete. - -------------------------------------------------------------------------------*/ - -/* Includes ------------------------------------------------------------------*/ -#include "stm324x9i_eval_sram.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM324x9I_EVAL - * @{ - */ - -/** @defgroup STM324x9I_EVAL_SRAM - * @{ - */ - -/** @defgroup STM324x9I_EVAL_SRAM_Private_Types_Definitions - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_SRAM_Private_Defines - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_SRAM_Private_Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_SRAM_Private_Variables - * @{ - */ -static SRAM_HandleTypeDef sramHandle; -static FMC_NORSRAM_TimingTypeDef Timing; -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_SRAM_Private_Function_Prototypes - * @{ - */ -static void SRAM_MspInit(void); -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_SRAM_Private_Functions - * @{ - */ - -/** - * @brief Initializes the SRAM device. - * @param None - * @retval SRAM status - */ -uint8_t BSP_SRAM_Init(void) -{ - sramHandle.Instance = FMC_NORSRAM_DEVICE; - sramHandle.Extended = FMC_NORSRAM_EXTENDED_DEVICE; - - /* SRAM device configuration */ - Timing.AddressSetupTime = 2; - Timing.AddressHoldTime = 1; - Timing.DataSetupTime = 2; - Timing.BusTurnAroundDuration = 1; - Timing.CLKDivision = 2; - Timing.DataLatency = 2; - Timing.AccessMode = FMC_ACCESS_MODE_A; - - sramHandle.Init.NSBank = FMC_NORSRAM_BANK2; - sramHandle.Init.DataAddressMux = FMC_DATA_ADDRESS_MUX_DISABLE; - sramHandle.Init.MemoryType = FMC_MEMORY_TYPE_SRAM; - sramHandle.Init.MemoryDataWidth = SRAM_MEMORY_WIDTH; - sramHandle.Init.BurstAccessMode = SRAM_BURSTACCESS; - sramHandle.Init.WaitSignalPolarity = FMC_WAIT_SIGNAL_POLARITY_LOW; - sramHandle.Init.WrapMode = FMC_WRAP_MODE_DISABLE; - sramHandle.Init.WaitSignalActive = FMC_WAIT_TIMING_BEFORE_WS; - sramHandle.Init.WriteOperation = FMC_WRITE_OPERATION_ENABLE; - sramHandle.Init.WaitSignal = FMC_WAIT_SIGNAL_DISABLE; - sramHandle.Init.ExtendedMode = FMC_EXTENDED_MODE_DISABLE; - sramHandle.Init.AsynchronousWait = FMC_ASYNCHRONOUS_WAIT_DISABLE; - sramHandle.Init.WriteBurst = SRAM_WRITEBURST; - sramHandle.Init.ContinuousClock = CONTINUOUSCLOCK_FEATURE; - - /* SRAM controller initialization */ - SRAM_MspInit(); - if(HAL_SRAM_Init(&sramHandle, &Timing, &Timing) != HAL_OK) - { - return SRAM_ERROR; - } - else - { - return SRAM_OK; - } -} - -/** - * @brief Reads an amount of data from the SRAM device in polling mode. - * @param uwStartAddress: Read start address - * @param pData: Pointer to data to be read - * @param uwDataSize: Size of read data from the memory - * @retval SRAM status - */ -uint8_t BSP_SRAM_ReadData(uint32_t uwStartAddress, uint16_t *pData, uint32_t uwDataSize) -{ - if(HAL_SRAM_Read_16b(&sramHandle, (uint32_t *)uwStartAddress, pData, uwDataSize) != HAL_OK) - { - return SRAM_ERROR; - } - else - { - return SRAM_OK; - } -} - -/** - * @brief Reads an amount of data from the SRAM device in DMA mode. - * @param uwStartAddress: Read start address - * @param pData: Pointer to data to be read - * @param uwDataSize: Size of read data from the memory - * @retval SRAM status - */ -uint8_t BSP_SRAM_ReadData_DMA(uint32_t uwStartAddress, uint16_t *pData, uint32_t uwDataSize) -{ - if(HAL_SRAM_Read_DMA(&sramHandle, (uint32_t *)uwStartAddress, (uint32_t *)pData, uwDataSize) != HAL_OK) - { - return SRAM_ERROR; - } - else - { - return SRAM_OK; - } -} - -/** - * @brief Writes an amount of data from the SRAM device in polling mode. - * @param uwStartAddress: Write start address - * @param pData: Pointer to data to be written - * @param uwDataSize: Size of written data from the memory - * @retval SRAM status - */ -uint8_t BSP_SRAM_WriteData(uint32_t uwStartAddress, uint16_t *pData, uint32_t uwDataSize) -{ - if(HAL_SRAM_Write_16b(&sramHandle, (uint32_t *)uwStartAddress, pData, uwDataSize) != HAL_OK) - { - return SRAM_ERROR; - } - else - { - return SRAM_OK; - } -} - -/** - * @brief Writes an amount of data from the SRAM device in DMA mode. - * @param uwStartAddress: Write start address - * @param pData: Pointer to data to be written - * @param uwDataSize: Size of written data from the memory - * @retval SRAM status - */ -uint8_t BSP_SRAM_WriteData_DMA(uint32_t uwStartAddress, uint16_t *pData, uint32_t uwDataSize) -{ - if(HAL_SRAM_Write_DMA(&sramHandle, (uint32_t *)uwStartAddress, (uint32_t *)pData, uwDataSize) != HAL_OK) - { - return SRAM_ERROR; - } - else - { - return SRAM_OK; - } -} - -/** - * @brief Handles SRAM DMA transfer interrupt request. - * @param None - * @retval None - */ -void BSP_SRAM_DMA_IRQHandler(void) -{ - HAL_DMA_IRQHandler(sramHandle.hdma); -} - -/** - * @brief Initializes SRAM MSP. - * @param None - * @retval None - */ -static void SRAM_MspInit(void) -{ - static DMA_HandleTypeDef dmaHandle; - GPIO_InitTypeDef GPIO_Init_Structure; - SRAM_HandleTypeDef *hsram = &sramHandle; - - /* Enable FMC clock */ - __FMC_CLK_ENABLE(); - - /* Enable chosen DMAx clock */ - __SRAM_DMAx_CLK_ENABLE(); - - /* Enable GPIOs clock */ - __GPIOD_CLK_ENABLE(); - __GPIOE_CLK_ENABLE(); - __GPIOF_CLK_ENABLE(); - __GPIOG_CLK_ENABLE(); - - /* Common GPIO configuration */ - GPIO_Init_Structure.Mode = GPIO_MODE_AF_PP; - GPIO_Init_Structure.Pull = GPIO_PULLUP; - GPIO_Init_Structure.Speed = GPIO_SPEED_HIGH; - GPIO_Init_Structure.Alternate = GPIO_AF12_FMC; - - /* GPIOD configuration */ - GPIO_Init_Structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_8 |\ - GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13 |\ - GPIO_PIN_14 | GPIO_PIN_15; - HAL_GPIO_Init(GPIOD, &GPIO_Init_Structure); - - /* GPIOE configuration */ - GPIO_Init_Structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_3| GPIO_PIN_4 | GPIO_PIN_7 |\ - GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12 |\ - GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15; - HAL_GPIO_Init(GPIOE, &GPIO_Init_Structure); - - /* GPIOF configuration */ - GPIO_Init_Structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2| GPIO_PIN_3 | GPIO_PIN_4 |\ - GPIO_PIN_5 | GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15; - HAL_GPIO_Init(GPIOF, &GPIO_Init_Structure); - - /* GPIOG configuration */ - GPIO_Init_Structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2| GPIO_PIN_3 | GPIO_PIN_4 |\ - GPIO_PIN_5 | GPIO_PIN_9; - HAL_GPIO_Init(GPIOG, &GPIO_Init_Structure); - - /* Configure common DMA parameters */ - dmaHandle.Init.Channel = SRAM_DMAx_CHANNEL; - dmaHandle.Init.Direction = DMA_MEMORY_TO_MEMORY; - dmaHandle.Init.PeriphInc = DMA_PINC_ENABLE; - dmaHandle.Init.MemInc = DMA_MINC_ENABLE; - dmaHandle.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD; - dmaHandle.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD; - dmaHandle.Init.Mode = DMA_NORMAL; - dmaHandle.Init.Priority = DMA_PRIORITY_HIGH; - dmaHandle.Init.FIFOMode = DMA_FIFOMODE_DISABLE; - dmaHandle.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; - dmaHandle.Init.MemBurst = DMA_MBURST_SINGLE; - dmaHandle.Init.PeriphBurst = DMA_PBURST_SINGLE; - - dmaHandle.Instance = SRAM_DMAx_STREAM; - - /* Associate the DMA handle */ - __HAL_LINKDMA(hsram, hdma, dmaHandle); - - /* Deinitialize the Stream for new transfer */ - HAL_DMA_DeInit(&dmaHandle); - - /* Configure the DMA Stream */ - HAL_DMA_Init(&dmaHandle); - - /* NVIC configuration for DMA transfer complete interrupt */ - HAL_NVIC_SetPriority(SRAM_DMAx_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(SRAM_DMAx_IRQn); -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval_sram.h b/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval_sram.h deleted file mode 100644 index 06c7f0e0b8..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval_sram.h +++ /dev/null @@ -1,144 +0,0 @@ -/** - ****************************************************************************** - * @file stm324x9i_eval_sram.h - * @author MCD Application Team - * @version V2.2.1 - * @date 07-October-2015 - * @brief This file contains the common defines and functions prototypes for - * the stm324x9i_eval_sram.c driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM324x9I_EVAL_SRAM_H -#define __STM324x9I_EVAL_SRAM_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm32f4xx_hal.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM324x9I_EVAL - * @{ - */ - -/** @defgroup STM324x9I_EVAL_SRAM - * @{ - */ - -/** @defgroup STM324x9I_EVAL_SRAM_Exported_Types - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_SRAM_Exported_Constants - * @{ - */ - -/** - * @brief SRAM status structure definition - */ -#define SRAM_OK 0x00 -#define SRAM_ERROR 0x01 - -#define SRAM_DEVICE_ADDR ((uint32_t)0x64000000) -#define SRAM_DEVICE_SIZE ((uint32_t)0x200000) /* SRAM device size in MBytes */ - -/* #define SRAM_MEMORY_WIDTH FMC_NORSRAM_MEM_BUS_WIDTH_8 */ -#define SRAM_MEMORY_WIDTH FMC_NORSRAM_MEM_BUS_WIDTH_16 - -#define SRAM_BURSTACCESS FMC_BURST_ACCESS_MODE_DISABLE -/* #define SRAM_BURSTACCESS FMC_BURST_ACCESS_MODE_ENABLE*/ - -#define SRAM_WRITEBURST FMC_WRITE_BURST_DISABLE -/* #define SRAM_WRITEBURST FMC_WRITE_BURST_ENABLE */ - -#define CONTINUOUSCLOCK_FEATURE FMC_CONTINUOUS_CLOCK_SYNC_ONLY -/* #define CONTINUOUSCLOCK_FEATURE FMC_CONTINUOUS_CLOCK_SYNC_ASYNC */ - -/* DMA definitions for SRAM DMA transfer */ -#define __SRAM_DMAx_CLK_ENABLE __DMA2_CLK_ENABLE -#define SRAM_DMAx_CHANNEL DMA_CHANNEL_0 -#define SRAM_DMAx_STREAM DMA2_Stream0 -#define SRAM_DMAx_IRQn DMA2_Stream0_IRQn -#define SRAM_DMAx_IRQHandler DMA2_Stream0_IRQHandler -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_SRAM_Exported_Macro - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_SRAM_Exported_Functions - * @{ - */ -uint8_t BSP_SRAM_Init(void); -uint8_t BSP_SRAM_ReadData(uint32_t uwStartAddress, uint16_t *pData, uint32_t uwDataSize); -uint8_t BSP_SRAM_ReadData_DMA(uint32_t uwStartAddress, uint16_t *pData, uint32_t uwDataSize); -uint8_t BSP_SRAM_WriteData(uint32_t uwStartAddress, uint16_t *pData, uint32_t uwDataSize); -uint8_t BSP_SRAM_WriteData_DMA(uint32_t uwStartAddress, uint16_t *pData, uint32_t uwDataSize); -void BSP_SRAM_DMA_IRQHandler(void); - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - - -#ifdef __cplusplus -} -#endif - -#endif /* __STM324x9I_EVAL_SRAM_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval_ts.c b/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval_ts.c deleted file mode 100644 index ce1bd88a8f..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval_ts.c +++ /dev/null @@ -1,307 +0,0 @@ -/** - ****************************************************************************** - * @file stm324x9i_eval_ts.c - * @author MCD Application Team - * @version V2.2.1 - * @date 07-October-2015 - * @brief This file provides a set of functions needed to manage the Touch - * Screen on STM324x9I-EVAL evaluation board. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* File Info : ----------------------------------------------------------------- - User NOTES -1. How To use this driver: --------------------------- - - This driver is used to drive the touch screen module of the STM324x9I-EVAL - evaluation board on the AMPIRE 640x480 LCD mounted on MB1063 or AMPIRE - 480x272 LCD mounted on MB1046 daughter board. - - If the AMPIRE 640x480 LCD is used, the TS3510 or EXC7200 component driver - must be included according to the touch screen driver present on this board. - - If the AMPIRE 480x272 LCD is used, the STMPE811 IO expander device component - driver must be included in order to run the TS module commanded by the IO - expander device, the STMPE1600 IO expander device component driver must be - also included in case of interrupt mode use of the TS. - -2. Driver description: ---------------------- - + Initialization steps: - o Initialize the TS module using the BSP_TS_Init() function. This - function includes the MSP layer hardware resources initialization and the - communication layer configuration to start the TS use. The LCD size properties - (x and y) are passed as parameters. - o If TS interrupt mode is desired, you must configure the TS interrupt mode - by calling the function BSP_TS_ITConfig(). The TS interrupt mode is generated - as an external interrupt whenever a touch is detected. - The interrupt mode internally uses the IO functionalities driver driven by - the IO expander, to configure the IT line. - - + Touch screen use - o The touch screen state is captured whenever the function BSP_TS_GetState() is - used. This function returns information about the last LCD touch occurred - in the TS_StateTypeDef structure. - o If TS interrupt mode is used, the function BSP_TS_ITGetStatus() is needed to get - the interrupt status. To clear the IT pending bits, you should call the - function BSP_TS_ITClear(). - o The IT is handled using the corresponding external interrupt IRQ handler, - the user IT callback treatment is implemented on the same external interrupt - callback. - -------------------------------------------------------------------------------*/ - -/* Includes ------------------------------------------------------------------*/ -#include "stm324x9i_eval_ts.h" -#include "stm324x9i_eval_io.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM324x9I_EVAL - * @{ - */ - -/** @defgroup STM324x9I_EVAL_TS - * @{ - */ - -/** @defgroup STM324x9I_EVAL_TS_Private_Types_Definitions - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_TS_Private_Defines - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_TS_Private_Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_TS_Private_Variables - * @{ - */ -static TS_DrvTypeDef *ts_driver; -static uint16_t ts_x_boundary, ts_y_boundary; -static uint8_t ts_orientation; -static uint8_t I2C_Address; -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_TS_Private_Function_Prototypes - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_TS_Private_Functions - * @{ - */ - -/** - * @brief Initializes and configures the touch screen functionalities and - * configures all necessary hardware resources (GPIOs, clocks..). - * @param xSize: Maximum X size of the TS area on LCD - * ySize: Maximum Y size of the TS area on LCD - * @retval TS_OK if all initializations are OK. Other value if error. - */ -uint8_t BSP_TS_Init(uint16_t xSize, uint16_t ySize) -{ - uint8_t status = TS_OK; - ts_x_boundary = xSize; - ts_y_boundary = ySize; - - /* Read ID and verify if the IO expander is ready */ - if(stmpe811_ts_drv.ReadID(TS_I2C_ADDRESS) == STMPE811_ID) - { - /* Initialize the TS driver structure */ - ts_driver = &stmpe811_ts_drv; - I2C_Address = TS_I2C_ADDRESS; - ts_orientation = TS_SWAP_Y; - } - else - { - IOE_Init(); - - /* Check TS3510 touch screen driver presence to determine if TS3510 or - * EXC7200 driver will be used */ - if(BSP_TS3510_IsDetected() == 0) - { - /* Initialize the TS driver structure */ - ts_driver = &ts3510_ts_drv; - I2C_Address = TS3510_I2C_ADDRESS; - } - else - { - /* Initialize the TS driver structure */ - ts_driver = &exc7200_ts_drv; - I2C_Address = EXC7200_I2C_ADDRESS; - } - ts_orientation = TS_SWAP_NONE; - } - - /* Initialize the TS driver */ - ts_driver->Init(I2C_Address); - ts_driver->Start(I2C_Address); - - return status; -} - -/** - * @brief DeInitializes the TouchScreen. - * @param None - * @retval TS state - */ -uint8_t BSP_TS_DeInit(void) -{ - /* Actually ts_driver does not provide a DeInit function */ - return TS_OK; -} - -/** - * @brief Configures and enables the touch screen interrupts. - * @param None - * @retval TS_OK if all initializations are OK. Other value if error. - */ -uint8_t BSP_TS_ITConfig(void) -{ - /* Initialize the IO */ - BSP_IO_Init(); - - /* Configure TS IT line IO */ - BSP_IO_ConfigPin(TS_INT_PIN, IO_MODE_IT_FALLING_EDGE); - - /* Enable the TS ITs */ - ts_driver->EnableIT(I2C_Address); - - return TS_OK; -} - -/** - * @brief Gets the touch screen interrupt status. - * @param None - * @retval TS_OK if all initializations are OK. Other value if error. - */ -uint8_t BSP_TS_ITGetStatus(void) -{ - /* Return the TS IT status */ - return (ts_driver->GetITStatus(I2C_Address)); -} - -/** - * @brief Returns status and positions of the touch screen. - * @param TS_State: Pointer to touch screen current state structure - * @retval TS_OK if all initializations are OK. Other value if error. - */ -uint8_t BSP_TS_GetState(TS_StateTypeDef *TS_State) -{ - static uint32_t _x = 0, _y = 0; - uint16_t xDiff, yDiff , x , y; - uint16_t swap; - - TS_State->TouchDetected = ts_driver->DetectTouch(I2C_Address); - - if(TS_State->TouchDetected) - { - ts_driver->GetXY(I2C_Address, &x, &y); - - if(ts_orientation & TS_SWAP_X) - { - x = 4096 - x; - } - - if(ts_orientation & TS_SWAP_Y) - { - y = 4096 - y; - } - - if(ts_orientation & TS_SWAP_XY) - { - swap = y; - y = x; - x = swap; - } - - xDiff = x > _x? (x - _x): (_x - x); - yDiff = y > _y? (y - _y): (_y - y); - - if (xDiff + yDiff > 5) - { - _x = x; - _y = y; - } - - TS_State->x = (ts_x_boundary * _x) >> 12; - TS_State->y = (ts_y_boundary * _y) >> 12; - } - return TS_OK; -} - -/** - * @brief Clears all touch screen interrupts. - * @param None - * @retval None - */ -void BSP_TS_ITClear(void) -{ - /* Clear all IO IT pin */ - BSP_IO_ITClear(); - - /* Clear TS IT pending bits */ - ts_driver->ClearIT(I2C_Address); -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval_ts.h b/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval_ts.h deleted file mode 100644 index 1e6ea78b3a..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM324x9I_EVAL/stm324x9i_eval_ts.h +++ /dev/null @@ -1,141 +0,0 @@ -/** - ****************************************************************************** - * @file stm324x9i_eval_ts.h - * @author MCD Application Team - * @version V2.2.1 - * @date 07-October-2015 - * @brief This file contains the common defines and functions prototypes for - * the stm324x9i_eval_ts.c driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM324x9I_EVAL_TS_H -#define __STM324x9I_EVAL_TS_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm324x9i_eval.h" -/* Include IOExpander(STMPE811) component Driver */ -#include "../Components/stmpe811/stmpe811.h" -/* Include TouchScreen component drivers */ -#include "../Components/ts3510/ts3510.h" -#include "../Components/exc7200/exc7200.h" -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM324x9I_EVAL - * @{ - */ - -/** @defgroup STM324x9I_EVAL_TS - * @{ - */ - -/** @defgroup STM324x9I_EVAL_TS_Exported_Types - * @{ - */ -typedef struct -{ - uint16_t TouchDetected; - uint16_t x; - uint16_t y; - uint16_t z; -}TS_StateTypeDef; -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_TS_Exported_Constants - * @{ - */ -#define TS_SWAP_NONE 0x00 -#define TS_SWAP_X 0x01 -#define TS_SWAP_Y 0x02 -#define TS_SWAP_XY 0x04 - -typedef enum -{ - TS_OK = 0x00, - TS_ERROR = 0x01, - TS_TIMEOUT = 0x02 -}TS_StatusTypeDef; - -/* Interrupt sources pins definition */ -#define TS_INT_PIN 0x0010 -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_TS_Exported_Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324x9I_EVAL_TS_Exported_Functions - * @{ - */ -uint8_t BSP_TS_Init(uint16_t xSize, uint16_t ySize); -uint8_t BSP_TS_DeInit(void); -uint8_t BSP_TS_GetState(TS_StateTypeDef *TS_State); -uint8_t BSP_TS_ITConfig(void); -uint8_t BSP_TS_ITGetStatus(void); -void BSP_TS_ITClear(void); - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - - -#ifdef __cplusplus -} -#endif - -#endif /* __STM324x9I_EVAL_TS_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM324xG_EVAL/Release_Notes.html b/bsp/stm32f411RE/Libraries/BSP/STM324xG_EVAL/Release_Notes.html deleted file mode 100644 index 56193abe06..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM324xG_EVAL/Release_Notes.html +++ /dev/null @@ -1,768 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - Release Notes for STM324xG_EVAL Evaluation Board Drivers - - - - - - - - - - -
-


-

-
- - - - - - -
- - - - - - - - - -
-

Back to Release page

-
-

Release -Notes for STM324xG_EVAL Evaluation Board Drivers

-

Copyright -2015 STMicroelectronics

-

-
-

 

- - - - - - -
- - -

Update History

-

V2.1.0 / 14-August-2015

Main -Changes

- - - - - -
  • stm324xg_eval.c
    • Add AUDIO_IO_DeInit function to align with latest audio codecs.

V2.0.5 / 02-March-2015

Main -Changes

- - - - - -
  • stm324xg_eval.c/.h
    • Align to STM32F4xx HAL Driver V1.3.0 for -__HAL_RCC_PPP_CLK_ENABLE() .

V2.0.4 / 10-December-2014

- - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- - - - - - - - - - - - - - - -
    -
  • stm324xg_eval.c/.h
    -
  • -
      -
    • Change I2C_SPEED used define by BSP_I2C_SPEED
    • -
    -
  • stm324xg_eval_eeprom.c/.h
  • -
      -
    • Change BSP_EEPROM_WaitEepromStandbyState() and BSP_EEPROM_WritePage() to be declared as static APIs
    • -
    -
  • stm324xg_eval_camera.h, stm324xg_eval_audio.h, stm324xg_eval_io.h, stm324xg_eval_ts.h and stm324xg_eval_lcd.c/.h
    -
  • -
      -
    • Change "\" by "/" in the include path to fix compilation issue under Linux
    • -
    -
  • Miscellaneous comments update
  • -
- -

V2.0.3 / 26-June-2014

- - - - - - - - - - - - - - - - - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- - - - - - - - - - - -
    -
  • stm324xg_eval_audio.c/.h
    • BSP_AUDIO_OUT_Play(): uses the buffer size in byte instead of half-word
    -
- -

V2.0.2 / 19-June-2014

- - - - - - - - - - - - - - - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- - - - - - - - - -
    -
  • stm324xg_eval.c/.h
  • -
      -
    • Add protection for double initialization of IO_Init within LCD_IO_Init()
    • -
    -
      -
    • Enhance BSP_PB_Init() function by removing the call of __SYSCFG_CLK_ENABLE() already enabled in the HAL_GPIO_Init()
    • -
    -
  • stm324xg_eval_audio.c/.h
  • -
      -
    • Add note that only the audio stereo format is supported
    • -
    -
  • stm324xg_eval_sd.c/.h
  • -
      -
    • Ensure -compatibility with the updated version of FatFs sd_diskio driver (i.e. -FatFs R0.10 ST modified 20140422) supporting SDIO/SPI to interface uSD
    • -
    -
      -
    • Comments clean up and typo corrections
    • -
    -
- -

V2.0.1 / 26-February-2014

- - - - - - - - - - - - - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- - - - - - - -
    - -
  • stm324xg_eval_sd.c/.h
  • -
      -
    • Update SD_DATATIMEOUT value
    • -
    -
  • stm324xg_eval_eeprom.c/.h
  • -
      -
    • Update usage of BSP_EEPROM_TIMEOUT_UserCallback() function
    • -
    -
- -

V2.0.0 / 18-February-2014

- - - - - - - - - - - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- - - - - -
    -
  • Major update -based on STM32Cube specification: drivers architecture and APIs -modified vs. V1.1.1, and thus the 2 versions are not compatible.
    -
  • -
  • This version has to be used only with STM32CubeF4 based development
  • -
-

V1.1.1 / 11-January-2013

- - - - -

Main -Changes

- - - - - -
  • stm324xg_eval_ioe.c
    • Update the MEMS pins configuration in IOE_Config() function.
    • Update I2C communication sequence in I2C_ReadDataBuffer() function to ensure efficient and robust I2C transfer.
  • stm324xg_eval_lcd.c
    • Replace STM324xG_LCD_Init() function by LCD_Init() function and add a legacy for old LCD Initialization function name for compatibility purpose. 
-

V1.1.0 / 21-December-2012

- - - - -

Main -Changes

- - - - - -
    -
  • stm3224xg_eval_sdio_sd.h/.c
    • Support SDHC memory cards with capacity greater than 4 GB
      -
    • Transmit -and receive functions: swap the order of state machine and DMA -configuration, to fix marginal limitation where the card sent data to -the SDIO interface while the DMA is not ready to transfer them
    • Support SDHS (High Speed) memory cards, add new function SD_HighSpeed()
      -
  • stm324xg_eval_ioe.c
    • Configuration clean up and corrections
    • Touch screen (TSC) Interrupt mode enhancement
    • Update Read/Write low layer functions to ensure efficient and robust I2C transfer
      -
      • Update legacy functions I2C_WriteDeviceRegister(), I2C_ReadDeviceRegister() and I2C_ReadDataBuffer() to use   polling mode instead of DMA
      • Add three new functions I2C_DMA_WriteDeviceRegister(), I2C_DMA_ReadDeviceRegister() and I2C_DMA_ReadDataBuffer(), for DMA based I2C transfer
        -
  • stm324xg_eval.c
    -
    • SD_LowLevel_Init(): Set the GPIO clock to 50MHz to support High Speed mode
  • stm324xg_eval_i2c_ee.c
    -
    • Enable I2C DMA request only after the enable of the DMA stream, to avoid DMA FIFO error generation
      -
  • stm324xg_eval_fsmc_sram.c
    • Change memory type to SRAM instead of PSRAM (PSRAM is available only on STM324xG-EVAL RevA) and update timing values
    -
-

V1.0.2 / 09-March-2012

-

Main -Changes

- -
  • All source files: license disclaimer text update and add link to the License file on ST Internet.
  • stm324xg_eval_lcd.c
    • Enhance Gamma Curve settings for ILI9320 controller 
  • stm324xg_eval.c and stm324xg_eval_ioe.c
    • Swap -the order of I2C IOs and alternate function (AF) -configuration: AF configuration should be done before to configure the -IOs.
  • stm324xg_eval_sdio_sd.c
    • In SD_WaitWriteOperation() and SD_WaitReadOperation() functions: reset StopCondition flag after sending CMD12

V1.0.1 / 28-December-2011

Main -Changes

-
  • All source files: update disclaimer to add reference to the new license agreement
  • stm324xg_eval_lcd.c
    • Remove “static” from TextColor and BackColor variables declaration (need to be changed from other application modules) 
  • stm324xg_eval_ioe.h
    • Add -conditional compilation on the default DMA stream(s) used for I2C1 Tx -and Rx transfers, to allow user to change them from application level.
  • stm322xg_eval_sdio_sd.h
    • SD_CardInfo structure, define CardCapacity variable as 64-bit long (instead of 32-bit)  to support SDHC memory cards with capacity greater than 4 GB.
  • stm324xg_eval_fsmc_sram.c
    • Add IOs config of missing FSMC address lines (FSMC_A21, FSMC_A22 and FSMC_A23).

V1.0.0 / 30-September-2011

Main -Changes

- -
  • First official release for STM3240_41_G_EVAL board RevB drivers
  • stm322xg_eval_lcd.c: increase FSMC AddressSetupTime value from 4 to 5 to be compliant with some LCD access timing

V1.0.0RC1 / 26-September-2011

Main -Changes

- -
  • Official version (V1.0.0) Release Candidate1 for STM3240_41_G_EVAL board RevB drivers

License

-
-
-Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met:
-
-
  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions -in binary form must reproduce the above copyright notice, this list of -conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of STMicroelectronics nor the names of its contributors may be used to endorse or promote products derived
    -
    -
-        from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- -
-
- - -
-
-

For -complete documentation on STM32 Microcontrollers -visit www.st.com/STM32

-
-

-
-
-

 

-
- - \ No newline at end of file diff --git a/bsp/stm32f411RE/Libraries/BSP/STM324xG_EVAL/stm324xg_eval.c b/bsp/stm32f411RE/Libraries/BSP/STM324xG_EVAL/stm324xg_eval.c deleted file mode 100644 index f074e85242..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM324xG_EVAL/stm324xg_eval.c +++ /dev/null @@ -1,1108 +0,0 @@ -/** - ****************************************************************************** - * @file stm324xg_eval.c - * @author MCD Application Team - * @version V2.1.0 - * @date 14-August-2015 - * @brief This file provides a set of firmware functions to manage LEDs, - * push-buttons and COM ports available on STM324xG-EVAL evaluation - * board(MB786) RevB from STMicroelectronics. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* File Info: ------------------------------------------------------------------ - User NOTE - - This driver requires the stm324xG_eval_io.c driver to manage the joystick - -------------------------------------------------------------------------------*/ - -/* Includes ------------------------------------------------------------------*/ -#include "stm324xg_eval.h" -#include "stm324xg_eval_io.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM324xG_EVAL - * @{ - */ - -/** @defgroup STM324xG_EVAL_LOW_LEVEL - * @{ - */ - -/** @defgroup STM324xG_EVAL_LOW_LEVEL_Private_TypesDefinitions - * @{ - */ -typedef struct -{ - __IO uint16_t REG; - __IO uint16_t RAM; -}LCD_CONTROLLER_TypeDef; -/** - * @} - */ - -/** @defgroup STM324xG_EVAL_LOW_LEVEL_Private_Defines - * @{ - */ - -/** - * @brief STM324xG EVAL BSP Driver version number V2.1.0 - */ -#define __STM324xG_EVAL_BSP_VERSION_MAIN (0x02) /*!< [31:24] main version */ -#define __STM324xG_EVAL_BSP_VERSION_SUB1 (0x01) /*!< [23:16] sub1 version */ -#define __STM324xG_EVAL_BSP_VERSION_SUB2 (0x00) /*!< [15:8] sub2 version */ -#define __STM324xG_EVAL_BSP_VERSION_RC (0x00) /*!< [7:0] release candidate */ -#define __STM324xG_EVAL_BSP_VERSION ((__STM324xG_EVAL_BSP_VERSION_MAIN << 24)\ - |(__STM324xG_EVAL_BSP_VERSION_SUB1 << 16)\ - |(__STM324xG_EVAL_BSP_VERSION_SUB2 << 8 )\ - |(__STM324xG_EVAL_BSP_VERSION_RC)) - -#define FMC_BANK3_BASE ((uint32_t)(0x60000000 | 0x08000000)) -#define FMC_BANK3 ((LCD_CONTROLLER_TypeDef *) FMC_BANK3_BASE) - -#define I2C_TIMEOUT 100 /*Instance = COM_USART[COM]; - HAL_UART_Init(huart); -} - -/** - * @brief Configures joystick GPIO and EXTI modes. - * @param Joy_Mode: Button mode. - * This parameter can be one of the following values: - * @arg JOY_MODE_GPIO: Joystick pins will be used as simple IOs - * @arg JOY_MODE_EXTI: Joystick pins will be connected to EXTI line - * with interrupt generation capability - * @retval IO_OK: if all initializations are OK. Other value if error. - */ -uint8_t BSP_JOY_Init(JOYMode_TypeDef Joy_Mode) -{ - uint8_t ret = 0; - - /* Initialize the IO functionalities */ - ret = BSP_IO_Init(); - - /* Configure joystick pins in IT mode */ - if(Joy_Mode == JOY_MODE_EXTI) - { - /* Configure joystick pins in IT mode */ - BSP_IO_ConfigPin(JOY_ALL_PINS, IO_MODE_IT_FALLING_EDGE); - } - - return ret; -} - -/** - * @brief Returns the current joystick status. - * @param None - * @retval Code of the joystick key pressed - * This code can be one of the following values: - * @arg JOY_NONE - * @arg JOY_SEL - * @arg JOY_DOWN - * @arg JOY_LEFT - * @arg JOY_RIGHT - * @arg JOY_UP - */ -JOYState_TypeDef BSP_JOY_GetState(void) -{ - uint8_t tmp = 0; - - /* Read the status joystick pins */ - tmp = (uint8_t)BSP_IO_ReadPin(JOY_ALL_PINS); - - /* Check the pressed keys */ - if((tmp & JOY_NONE_PIN) == JOY_NONE) - { - return(JOYState_TypeDef) JOY_NONE; - } - else if(!(tmp & JOY_SEL_PIN)) - { - return(JOYState_TypeDef) JOY_SEL; - } - else if(!(tmp & JOY_DOWN_PIN)) - { - return(JOYState_TypeDef) JOY_DOWN; - } - else if(!(tmp & JOY_LEFT_PIN)) - { - return(JOYState_TypeDef) JOY_LEFT; - } - else if(!(tmp & JOY_RIGHT_PIN)) - { - return(JOYState_TypeDef) JOY_RIGHT; - } - else if(!(tmp & JOY_UP_PIN)) - { - return(JOYState_TypeDef) JOY_UP; - } - else - { - return(JOYState_TypeDef) JOY_NONE; - } -} - -/******************************************************************************* - BUS OPERATIONS -*******************************************************************************/ - -/**************************** I2C Routines ************************************/ - -/** - * @brief Initializes I2C MSP. - * @param None - * @retval None - */ -static void I2Cx_MspInit(void) -{ - GPIO_InitTypeDef GPIO_InitStruct; - - /*** Configure the GPIOs ***/ - /* Enable GPIO clock */ - EVAL_I2Cx_SCL_SDA_GPIO_CLK_ENABLE(); - - /* Configure I2C Tx as alternate function */ - GPIO_InitStruct.Pin = EVAL_I2Cx_SCL_PIN; - GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FAST; - GPIO_InitStruct.Alternate = EVAL_I2Cx_SCL_SDA_AF; - HAL_GPIO_Init(EVAL_I2Cx_SCL_SDA_GPIO_PORT, &GPIO_InitStruct); - - /* Configure I2C Rx as alternate function */ - GPIO_InitStruct.Pin = EVAL_I2Cx_SDA_PIN; - HAL_GPIO_Init(EVAL_I2Cx_SCL_SDA_GPIO_PORT, &GPIO_InitStruct); - - /*** Configure the I2C peripheral ***/ - /* Enable I2C clock */ - EVAL_I2Cx_CLK_ENABLE(); - - /* Force the I2C peripheral clock reset */ - EVAL_I2Cx_FORCE_RESET(); - - /* Release the I2C peripheral clock reset */ - EVAL_I2Cx_RELEASE_RESET(); - - /* Set priority and enable I2Cx event Interrupt */ - HAL_NVIC_SetPriority(EVAL_I2Cx_EV_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(EVAL_I2Cx_EV_IRQn); - - /* Set priority and enable I2Cx error Interrupt */ - HAL_NVIC_SetPriority(EVAL_I2Cx_ER_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(EVAL_I2Cx_ER_IRQn); -} - -/** - * @brief Initializes I2C HAL. - * @param None - * @retval None - */ -static void I2Cx_Init(void) -{ - if(HAL_I2C_GetState(&heval_I2c) == HAL_I2C_STATE_RESET) - { - heval_I2c.Instance = EVAL_I2Cx; - heval_I2c.Init.ClockSpeed = BSP_I2C_SPEED; - heval_I2c.Init.DutyCycle = I2C_DUTYCYCLE_2; - heval_I2c.Init.OwnAddress1 = 0; - heval_I2c.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT; - heval_I2c.Init.DualAddressMode = I2C_DUALADDRESS_DISABLED; - heval_I2c.Init.OwnAddress2 = 0; - heval_I2c.Init.GeneralCallMode = I2C_GENERALCALL_DISABLED; - heval_I2c.Init.NoStretchMode = I2C_NOSTRETCH_DISABLED; - - /* Init the I2C */ - I2Cx_MspInit(); - HAL_I2C_Init(&heval_I2c); - } -} - -/** - * @brief Configures I2C Interrupt. - * @param None - * @retval None - */ -static void I2Cx_ITConfig(void) -{ - static uint8_t I2C_IT_Enabled = 0; - GPIO_InitTypeDef GPIO_InitStruct; - - if(I2C_IT_Enabled == 0) - { - I2C_IT_Enabled = 1; - - /* Enable the GPIO EXTI clock */ - __GPIOI_CLK_ENABLE(); - __SYSCFG_CLK_ENABLE(); - - GPIO_InitStruct.Pin = GPIO_PIN_2; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FAST; - GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING; - HAL_GPIO_Init(GPIOI, &GPIO_InitStruct); - - /* Set priority and Enable GPIO EXTI Interrupt */ - HAL_NVIC_SetPriority((IRQn_Type)(EXTI2_IRQn), 5, 0); - HAL_NVIC_EnableIRQ((IRQn_Type)(EXTI2_IRQn)); - } -} - -/** - * @brief Reads a single data. - * @param Addr: I2C address - * @param Reg: Reg address - * @retval Data to be read - */ -static uint8_t I2Cx_Read(uint8_t Addr, uint8_t Reg) -{ - HAL_StatusTypeDef status = HAL_OK; - uint8_t Value = 0; - - status = HAL_I2C_Mem_Read(&heval_I2c, Addr, Reg, I2C_MEMADD_SIZE_8BIT, &Value, 1, I2C_TIMEOUT); - - /* Check the communication status */ - if(status != HAL_OK) - { - /* Execute user timeout callback */ - I2Cx_Error(Addr); - } - - return Value; -} - -/** - * @brief Writes a single data. - * @param Addr: I2C address - * @param Reg: Reg address - * @param Value: Data to be written - * @retval None - */ -static void I2Cx_Write(uint8_t Addr, uint8_t Reg, uint8_t Value) -{ - HAL_StatusTypeDef status = HAL_OK; - - status = HAL_I2C_Mem_Write(&heval_I2c, Addr, (uint16_t)Reg, I2C_MEMADD_SIZE_8BIT, &Value, 1, I2C_TIMEOUT); - - /* Check the communication status */ - if(status != HAL_OK) - { - /* I2C error occured */ - I2Cx_Error(Addr); - } -} - -/** - * @brief Reads multiple data. - * @param Addr: I2C address - * @param Reg: Reg address - * @param Buffer: Pointer to data buffer - * @param Length: Length of the data - * @retval Number of read data - */ -static HAL_StatusTypeDef I2Cx_ReadMultiple(uint8_t Addr, uint16_t Reg, uint16_t MemAddress, uint8_t *Buffer, uint16_t Length) -{ - HAL_StatusTypeDef status = HAL_OK; - - status = HAL_I2C_Mem_Read(&heval_I2c, Addr, (uint16_t)Reg, MemAddress, Buffer, Length, I2C_TIMEOUT); - - /* Check the communication status */ - if(status != HAL_OK) - { - /* I2C error occured */ - I2Cx_Error(Addr); - } - return status; -} - -/** - * @brief Write a value in a register of the device through BUS in using DMA mode - * @param Addr: Device address on BUS Bus. - * @param Reg: The target register address to write - * @param pBuffer: The target register value to be written - * @param Length: buffer size to be written - * @retval HAL status - */ -static HAL_StatusTypeDef I2Cx_WriteMultiple(uint8_t Addr, uint16_t Reg, uint16_t MemAddress, uint8_t *Buffer, uint16_t Length) -{ - HAL_StatusTypeDef status = HAL_OK; - - status = HAL_I2C_Mem_Write(&heval_I2c, Addr, (uint16_t)Reg, MemAddress, Buffer, Length, I2C_TIMEOUT); - - /* Check the communication status */ - if(status != HAL_OK) - { - /* Re-Initiaize the I2C Bus */ - I2Cx_Error(Addr); - } - return status; -} - -/** - * @brief Checks if target device is ready for communication. - * @note This function is used with Memory devices - * @param DevAddress: Target device address - * @param Trials: Number of trials - * @retval HAL status - */ -static HAL_StatusTypeDef I2Cx_IsDeviceReady(uint16_t DevAddress, uint32_t Trials) -{ - return (HAL_I2C_IsDeviceReady(&heval_I2c, DevAddress, Trials, I2C_TIMEOUT)); -} - -/** - * @brief Manages error callback by re-initializing I2C. - * @param Addr: I2C Address - * @retval None - */ -static void I2Cx_Error(uint8_t Addr) -{ - /* De-initialize the IOE comunication BUS */ - HAL_I2C_DeInit(&heval_I2c); - - /* Re-Initiaize the IOE comunication BUS */ - I2Cx_Init(); -} - -/*************************** FSMC Routines ************************************/ -/** - * @brief Initializes FSMC_BANK3 MSP. - * @param None - * @retval None - */ -static void FSMC_BANK3_MspInit(void) -{ - GPIO_InitTypeDef GPIO_Init_Structure; - - /* Enable FSMC clock */ - __FSMC_CLK_ENABLE(); - - /* Enable GPIOs clock */ - __GPIOD_CLK_ENABLE(); - __GPIOE_CLK_ENABLE(); - __GPIOF_CLK_ENABLE(); - __GPIOG_CLK_ENABLE(); - - /* Common GPIO configuration */ - GPIO_Init_Structure.Mode = GPIO_MODE_AF_PP; - GPIO_Init_Structure.Pull = GPIO_PULLUP; - GPIO_Init_Structure.Speed = GPIO_SPEED_HIGH; - GPIO_Init_Structure.Alternate = GPIO_AF12_FSMC; - - /* GPIOD configuration */ - GPIO_Init_Structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_8 |\ - GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13 |\ - GPIO_PIN_14 | GPIO_PIN_15; - - HAL_GPIO_Init(GPIOD, &GPIO_Init_Structure); - - /* GPIOE configuration */ - GPIO_Init_Structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_3| GPIO_PIN_4 | GPIO_PIN_7 |\ - GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12 |\ - GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15; - HAL_GPIO_Init(GPIOE, &GPIO_Init_Structure); - - /* GPIOF configuration */ - GPIO_Init_Structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2| GPIO_PIN_3 | GPIO_PIN_4 |\ - GPIO_PIN_5 | GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15; - HAL_GPIO_Init(GPIOF, &GPIO_Init_Structure); - - /* GPIOG configuration */ - GPIO_Init_Structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2| GPIO_PIN_3 | GPIO_PIN_4 |\ - GPIO_PIN_5 | GPIO_PIN_10; - - HAL_GPIO_Init(GPIOG, &GPIO_Init_Structure); -} - -/** - * @brief Initializes LCD IO. - * @param None - * @retval None - */ -static void FSMC_BANK3_Init(void) -{ - SRAM_HandleTypeDef hsram; - FSMC_NORSRAM_TimingTypeDef SRAM_Timing; - - /*** Configure the SRAM Bank 3 ***/ - /* Configure IPs */ - hsram.Instance = FMC_NORSRAM_DEVICE; - hsram.Extended = FMC_NORSRAM_EXTENDED_DEVICE; - - SRAM_Timing.AddressSetupTime = 5; - SRAM_Timing.AddressHoldTime = 1; - SRAM_Timing.DataSetupTime = 9; - SRAM_Timing.BusTurnAroundDuration = 0; - SRAM_Timing.CLKDivision = 2; - SRAM_Timing.DataLatency = 2; - SRAM_Timing.AccessMode = FSMC_ACCESS_MODE_A; - - hsram.Init.NSBank = FSMC_NORSRAM_BANK3; - hsram.Init.DataAddressMux = FSMC_DATA_ADDRESS_MUX_DISABLE; - hsram.Init.MemoryType = FSMC_MEMORY_TYPE_SRAM; - hsram.Init.MemoryDataWidth = FSMC_NORSRAM_MEM_BUS_WIDTH_16; - hsram.Init.BurstAccessMode = FSMC_BURST_ACCESS_MODE_DISABLE; - hsram.Init.WaitSignalPolarity = FSMC_WAIT_SIGNAL_POLARITY_LOW; - hsram.Init.WrapMode = FSMC_WRAP_MODE_DISABLE; - hsram.Init.WaitSignalActive = FSMC_WAIT_TIMING_BEFORE_WS; - hsram.Init.WriteOperation = FSMC_WRITE_OPERATION_ENABLE; - hsram.Init.WaitSignal = FSMC_WAIT_SIGNAL_DISABLE; - hsram.Init.ExtendedMode = FSMC_EXTENDED_MODE_DISABLE; - hsram.Init.AsynchronousWait = FSMC_ASYNCHRONOUS_WAIT_DISABLE; - hsram.Init.WriteBurst = FSMC_WRITE_BURST_DISABLE; - - /* Initialize the SRAM controller */ - FSMC_BANK3_MspInit(); - HAL_SRAM_Init(&hsram, &SRAM_Timing, &SRAM_Timing); -} - -/** - * @brief Writes register value. - * @param Data: Data to be written - * @retval None - */ -static void FSMC_BANK3_WriteData(uint16_t Data) -{ - /* Write 16-bit Reg */ - FMC_BANK3->RAM = Data; -} - -/** - * @brief Writes register address. - * @param Reg: Register to be written - * @retval None - */ -static void FSMC_BANK3_WriteReg(uint8_t Reg) -{ - /* Write 16-bit Index, then write register */ - FMC_BANK3->REG = Reg; -} - -/** - * @brief Reads register value. - * @param None - * @retval Read value - */ -static uint16_t FSMC_BANK3_ReadData(void) -{ - return FMC_BANK3->RAM; -} - -/******************************************************************************* - LINK OPERATIONS -*******************************************************************************/ - -/***************************** LINK IOE ***************************************/ - -/** - * @brief Initializes IOE low level. - * @param None - * @retval None - */ -void IOE_Init(void) -{ - I2Cx_Init(); -} - -/** - * @brief Configures IOE low level Interrupt. - * @param None - * @retval None - */ -void IOE_ITConfig(void) -{ - I2Cx_ITConfig(); -} - -/** - * @brief IOE writes single data. - * @param Addr: I2C address - * @param Reg: Reg address - * @param Value: Data to be written - * @retval None - */ -void IOE_Write(uint8_t Addr, uint8_t Reg, uint8_t Value) -{ - I2Cx_Write(Addr, Reg, Value); -} - -/** - * @brief IOE reads single data. - * @param Addr: I2C address - * @param Reg: Reg address - * @retval Read data - */ -uint8_t IOE_Read(uint8_t Addr, uint8_t Reg) -{ - return I2Cx_Read(Addr, Reg); -} - -/** - * @brief IOE reads multiple data. - * @param Addr: I2C address - * @param Reg: Reg address - * @param Buffer: Pointer to data buffer - * @param Length: Length of the data - * @retval Number of read data - */ -uint16_t IOE_ReadMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length) -{ - return I2Cx_ReadMultiple(Addr, Reg, I2C_MEMADD_SIZE_8BIT, Buffer, Length); -} - -/** - * @brief IOE delay. - * @param Delay: Delay in ms - * @retval None - */ -void IOE_Delay(uint32_t Delay) -{ - HAL_Delay(Delay); -} - -/********************************* LINK LCD ***********************************/ - -/** - * @brief Initializes LCD low level. - * @param None - * @retval None - */ -void LCD_IO_Init(void) -{ - if(Is_LCD_IO_Initialized == 0) - { - Is_LCD_IO_Initialized = 1; - FSMC_BANK3_Init(); - } -} - -/** - * @brief Writes data on LCD data register. - * @param Data: Data to be written - * @retval None - */ -void LCD_IO_WriteData(uint16_t Data) -{ - /* Write 16-bit Reg */ - FSMC_BANK3_WriteData(Data); -} - -/** - * @brief Writes register on LCD register. - * @param Reg: Register to be written - * @retval None - */ -void LCD_IO_WriteReg(uint8_t Reg) -{ - /* Write 16-bit Index, then Write Reg */ - FSMC_BANK3_WriteReg(Reg); -} - -/** - * @brief Reads data from LCD data register. - * @param None - * @retval Read data. - */ -uint16_t LCD_IO_ReadData(void) -{ - return FSMC_BANK3_ReadData(); -} - -/********************************* LINK AUDIO *********************************/ -/** - * @brief Initializes Audio low level. - * @param None - * @retval None - */ -void AUDIO_IO_Init(void) -{ - I2Cx_Init(); -} - -/** - * @brief DeInitializes Audio low level. - */ -void AUDIO_IO_DeInit(void) -{ - -} - -/** - * @brief Writes a single data. - * @param Addr: I2C address - * @param Reg: Reg address - * @param Value: Data to be written - * @retval None - */ -void AUDIO_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value) -{ - I2Cx_Write(Addr, Reg, Value); -} - -/** - * @brief Reads a single data. - * @param Addr: I2C address - * @param Reg: Reg address - * @retval Data to be read - */ -uint8_t AUDIO_IO_Read(uint8_t Addr, uint8_t Reg) -{ - return I2Cx_Read(Addr, Reg); -} - -/***************************** LINK CAMERA ************************************/ - -/** - * @brief Initializes Camera low level. - * @param None - * @retval None - */ -void CAMERA_IO_Init(void) -{ - I2Cx_Init(); -} - -/** - * @brief Camera writes single data. - * @param Addr: I2C address - * @param Reg: Reg address - * @param Value: Data to be written - * @retval None - */ -void CAMERA_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value) -{ - I2Cx_Write(Addr, Reg, Value); -} - -/** - * @brief Camera reads single data. - * @param Addr: I2C address - * @param Reg: Reg address - * @retval Read data - */ -uint8_t CAMERA_IO_Read(uint8_t Addr, uint8_t Reg) -{ - return I2Cx_Read(Addr, Reg); -} - -/** - * @brief Camera delay. - * @param Delay: Delay in ms - * @retval None - */ -void CAMERA_Delay(uint32_t Delay) -{ - HAL_Delay(Delay); -} - -/******************************** LINK I2C EEPROM *****************************/ - -/** - * @brief Initializes peripherals used by the I2C EEPROM driver. - * @param None - * @retval None - */ -void EEPROM_IO_Init(void) -{ - I2Cx_Init(); -} - -/** - * @brief Write data to I2C EEPROM driver in using DMA channel - * @param DevAddress: Target device address - * @param MemAddress: Internal memory address - * @param pBuffer: Pointer to data buffer - * @param BufferSize: Amount of data to be sent - * @retval HAL status - */ -HAL_StatusTypeDef EEPROM_IO_WriteData(uint16_t DevAddress, uint16_t MemAddress, uint8_t* pBuffer, uint32_t BufferSize) -{ - return (I2Cx_WriteMultiple(DevAddress, MemAddress, I2C_MEMADD_SIZE_16BIT, pBuffer, BufferSize)); -} - -/** - * @brief Reads data from I2C EEPROM driver in using DMA channel. - * @param DevAddress: Target device address - * @param MemAddress: Internal memory address - * @param pBuffer: Pointer to data buffer - * @param BufferSize: Amount of data to be read - * @retval HAL status - */ -HAL_StatusTypeDef EEPROM_IO_ReadData(uint16_t DevAddress, uint16_t MemAddress, uint8_t* pBuffer, uint32_t BufferSize) -{ - return (I2Cx_ReadMultiple(DevAddress, MemAddress, I2C_MEMADD_SIZE_16BIT, pBuffer, BufferSize)); -} - -/** - * @brief Checks if target device is ready for communication. - * @note This function is used with Memory devices - * @param DevAddress: Target device address - * @param Trials: Number of trials - * @retval HAL status - */ -HAL_StatusTypeDef EEPROM_IO_IsDeviceReady(uint16_t DevAddress, uint32_t Trials) -{ - return (I2Cx_IsDeviceReady(DevAddress, Trials)); -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM324xG_EVAL/stm324xg_eval.h b/bsp/stm32f411RE/Libraries/BSP/STM324xG_EVAL/stm324xg_eval.h deleted file mode 100644 index 0c1fcd4827..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM324xG_EVAL/stm324xg_eval.h +++ /dev/null @@ -1,355 +0,0 @@ -/** - ****************************************************************************** - * @file stm324xg_eval.h - * @author MCD Application Team - * @version V2.1.0 - * @date 14-August-2015 - * @brief This file contains definitions for STM324xG_EVAL's LEDs, - * push-buttons and COM ports hardware resources. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM324xG_EVAL_H -#define __STM324xG_EVAL_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm32f4xx_hal.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM324xG_EVAL - * @{ - */ - -/** @addtogroup STM324xG_EVAL_LOW_LEVEL - * @{ - */ - -/** @defgroup STM324xG_EVAL_LOW_LEVEL_Exported_Types - * @{ - */ -typedef enum -{ - LED1 = 0, - LED2 = 1, - LED3 = 2, - LED4 = 3 -}Led_TypeDef; - -typedef enum -{ - BUTTON_WAKEUP = 0, - BUTTON_TAMPER = 1, - BUTTON_KEY = 2, - BUTTON_RIGHT = 3, - BUTTON_LEFT = 4, - BUTTON_UP = 5, - BUTTON_DOWN = 6, - BUTTON_SEL = 7 -}Button_TypeDef; - -typedef enum -{ - BUTTON_MODE_GPIO = 0, - BUTTON_MODE_EXTI = 1 -}ButtonMode_TypeDef; - -typedef enum -{ - JOY_MODE_GPIO = 0, - JOY_MODE_EXTI = 1 -}JOYMode_TypeDef; - -typedef enum -{ - JOY_NONE = 0, - JOY_SEL = 1, - JOY_DOWN = 2, - JOY_LEFT = 3, - JOY_RIGHT = 4, - JOY_UP = 5 -}JOYState_TypeDef; - -typedef enum -{ - COM1 = 0, - COM2 = 1 -}COM_TypeDef; -/** - * @} - */ - -/** @defgroup STM324xG_EVAL_LOW_LEVEL_Exported_Constants - * @{ - */ - -/** - * @brief Define for STM324xG_EVAL board - */ -#if !defined (USE_STM324xG_EVAL) - #define USE_STM324xG_EVAL -#endif - -/** @addtogroup STM324xG_EVAL_LOW_LEVEL_LED - * @{ - */ -#define LEDn 4 - -#define LED1_PIN GPIO_PIN_6 -#define LED1_GPIO_PORT GPIOG -#define LED1_GPIO_CLK_ENABLE() __GPIOG_CLK_ENABLE() -#define LED1_GPIO_CLK_DISABLE() __GPIOG_CLK_DISABLE() - -#define LED2_PIN GPIO_PIN_8 -#define LED2_GPIO_PORT GPIOG -#define LED2_GPIO_CLK_ENABLE() __GPIOG_CLK_ENABLE() -#define LED2_GPIO_CLK_DISABLE() __GPIOG_CLK_DISABLE() - -#define LED3_PIN GPIO_PIN_9 -#define LED3_GPIO_PORT GPIOI -#define LED3_GPIO_CLK_ENABLE() __GPIOI_CLK_ENABLE() -#define LED3_GPIO_CLK_DISABLE() __GPIOI_CLK_DISABLE() - -#define LED4_PIN GPIO_PIN_7 -#define LED4_GPIO_PORT GPIOC -#define LED4_GPIO_CLK RCC_AHB1Periph_GPIOC -#define LED4_GPIO_CLK_ENABLE() __GPIOC_CLK_ENABLE() -#define LED4_GPIO_CLK_DISABLE() __GPIOC_CLK_DISABLE() - -#define LEDx_GPIO_CLK_ENABLE(__INDEX__) do{if((__INDEX__) == 0) LED1_GPIO_CLK_ENABLE(); else \ - if((__INDEX__) == 1) LED2_GPIO_CLK_ENABLE(); else \ - if((__INDEX__) == 2) LED3_GPIO_CLK_ENABLE(); else \ - if((__INDEX__) == 3) LED4_GPIO_CLK_ENABLE(); \ - }while(0) -#define LEDx_GPIO_CLK_DISABLE(__INDEX__) do{if((__INDEX__) == 0) LED1_GPIO_CLK_DISABLE(); else \ - if((__INDEX__) == 1) LED2_GPIO_CLK_DISABLE(); else \ - if((__INDEX__) == 2) LED3_GPIO_CLK_DISABLE(); else \ - if((__INDEX__) == 3) LED4_GPIO_CLK_DISABLE(); \ - }while(0) -/** - * @} - */ - -/** @addtogroup STM324xG_EVAL_LOW_LEVEL_BUTTON - * @{ - */ -/* Joystick pins are connected to IO Expander (accessible through I2C1 interface) */ -#define BUTTONn 3 - -/** - * @brief Wakeup push-button - */ -#define WAKEUP_BUTTON_PIN GPIO_PIN_0 -#define WAKEUP_BUTTON_GPIO_PORT GPIOA -#define WAKEUP_BUTTON_GPIO_CLK_ENABLE() __GPIOA_CLK_ENABLE() -#define WAKEUP_BUTTON_GPIO_CLK_DISABLE() __GPIOA_CLK_DISABLE() -#define WAKEUP_BUTTON_EXTI_IRQn EXTI0_IRQn - -/** - * @brief Tamper push-button - */ -#define TAMPER_BUTTON_PIN GPIO_PIN_13 -#define TAMPER_BUTTON_GPIO_PORT GPIOC -#define TAMPER_BUTTON_GPIO_CLK_ENABLE() __GPIOC_CLK_ENABLE() -#define TAMPER_BUTTON_GPIO_CLK_DISABLE() __GPIOC_CLK_DISABLE() -#define TAMPER_BUTTON_EXTI_IRQn EXTI15_10_IRQn - -/** - * @brief Key push-button - */ -#define KEY_BUTTON_PIN GPIO_PIN_15 -#define KEY_BUTTON_GPIO_PORT GPIOG -#define KEY_BUTTON_GPIO_CLK_ENABLE() __GPIOG_CLK_ENABLE() -#define KEY_BUTTON_GPIO_CLK_DISABLE() __GPIOG_CLK_DISABLE() -#define KEY_BUTTON_EXTI_IRQn EXTI15_10_IRQn - -#define BUTTONx_GPIO_CLK_ENABLE(__INDEX__) do{if((__INDEX__) == 0) WAKEUP_BUTTON_GPIO_CLK_ENABLE(); else \ - if((__INDEX__) == 1) TAMPER_BUTTON_GPIO_CLK_ENABLE(); else \ - if((__INDEX__) == 2) KEY_BUTTON_GPIO_CLK_ENABLE(); \ - }while(0) -#define BUTTONx_GPIO_CLK_DISABLE(__INDEX__) do{if((__INDEX__) == 0) WAKEUP_BUTTON_GPIO_CLK_DISABLE(); else \ - if((__INDEX__) == 1) TAMPER_BUTTON_GPIO_CLK_DISABLE(); else \ - if ((__INDEX__) == 2) KEY_BUTTON_GPIO_CLK_DISABLE(); \ - }while(0) -/** - * @} - */ - -/** @addtogroup STM324xG_EVAL_LOW_LEVEL_COM - * @{ - */ -#define COMn 1 - -/** - * @brief Definition for COM port1, connected to USART3 - */ -#define EVAL_COM1 USART3 -#define EVAL_COM1_CLK_ENABLE() __USART3_CLK_ENABLE() -#define EVAL_COM1_CLK_DISABLE() __USART3_CLK_DISABLE() - -#define EVAL_COM1_TX_PIN GPIO_PIN_10 -#define EVAL_COM1_TX_GPIO_PORT GPIOC -#define EVAL_COM1_TX_GPIO_CLK_ENABLE() __GPIOC_CLK_ENABLE() -#define EVAL_COM1_TX_GPIO_CLK_DISABLE() __GPIOC_CLK_DISABLE() -#define EVAL_COM1_TX_AF GPIO_AF7_USART3 - -#define EVAL_COM1_RX_PIN GPIO_PIN_11 -#define EVAL_COM1_RX_GPIO_PORT GPIOC -#define EVAL_COM1_RX_GPIO_CLK_ENABLE() __GPIOC_CLK_ENABLE() -#define EVAL_COM1_RX_GPIO_CLK_DISABLE() __GPIOC_CLK_DISABLE() -#define EVAL_COM1_RX_AF GPIO_AF7_USART3 - -#define EVAL_COM1_IRQn USART3_IRQn - -#define EVAL_COMx_CLK_ENABLE(__INDEX__) do{if((__INDEX__) == 0) EVAL_COM1_CLK_ENABLE(); \ - }while(0) -#define EVAL_COMx_CLK_DISABLE(__INDEX__) do{if((__INDEX__) == 0) EVAL_COM1_CLK_DISABLE(); \ - }while(0) - -#define EVAL_COMx_TX_GPIO_CLK_ENABLE(__INDEX__) do{if((__INDEX__) == 0) EVAL_COM1_TX_GPIO_CLK_ENABLE(); \ - }while(0) -#define EVAL_COMx_TX_GPIO_CLK_DISABLE(__INDEX__) do{if((__INDEX__) == 0) EVAL_COM1_TX_GPIO_CLK_DISABLE(); \ - }while(0) - -#define EVAL_COMx_RX_GPIO_CLK_ENABLE(__INDEX__) do{if((__INDEX__) == 0) EVAL_COM1_RX_GPIO_CLK_ENABLE(); \ - }while(0) -#define EVAL_COMx_RX_GPIO_CLK_DISABLE(__INDEX__) do{if((__INDEX__) == 0) EVAL_COM1_RX_GPIO_CLK_DISABLE(); \ - }while(0) - -/** - * @brief Joystick Pins definition - */ -#define JOY_SEL_PIN IO_PIN_7 -#define JOY_DOWN_PIN IO_PIN_6 -#define JOY_LEFT_PIN IO_PIN_5 -#define JOY_RIGHT_PIN IO_PIN_4 -#define JOY_UP_PIN IO_PIN_3 -#define JOY_NONE_PIN JOY_ALL_PINS -#define JOY_ALL_PINS (IO_PIN_3 | IO_PIN_4 | IO_PIN_5 | IO_PIN_6 | IO_PIN_7) - -/* Exported constantIO -------------------------------------------------------*/ -/* I2C clock speed configuration (in Hz) - WARNING: - Make sure that this define is not already declared in other files (ie. - stm324xg_eval.h file). It can be used in parallel by other modules. */ -#ifndef BSP_I2C_SPEED - #define BSP_I2C_SPEED 100000 -#endif /* BSP_I2C_SPEED */ - -#define IO_I2C_ADDRESS 0x88 -#define TS_I2C_ADDRESS 0x82 -#define CAMERA_I2C_ADDRESS 0x60 -#define AUDIO_I2C_ADDRESS 0x94 -/* For M24C64 devices, E0, E1 and E2 pins are all used for device - address selection (no need for additional address lines). According to the - Hardware connection on the board (on STM324xG-EVAL board E0 = E1 = E2 = 0) */ -#define EEPROM_I2C_ADDRESS 0xA0 - -/* User can use this section to tailor I2Cx/I2Cx instance used and associated - resources */ -/* Definition for I2Cx clock resources */ -#define EVAL_I2Cx I2C1 -#define EVAL_I2Cx_CLK_ENABLE() __I2C1_CLK_ENABLE() -#define EVAL_DMAx_CLK_ENABLE() __DMA1_CLK_ENABLE() -#define EVAL_I2Cx_SCL_SDA_GPIO_CLK_ENABLE() __GPIOB_CLK_ENABLE() - -#define EVAL_I2Cx_FORCE_RESET() __I2C1_FORCE_RESET() -#define EVAL_I2Cx_RELEASE_RESET() __I2C1_RELEASE_RESET() - -/* Definition for I2Cx Pins */ -#define EVAL_I2Cx_SCL_PIN GPIO_PIN_6 -#define EVAL_I2Cx_SCL_SDA_GPIO_PORT GPIOB -#define EVAL_I2Cx_SCL_SDA_AF GPIO_AF4_I2C1 -#define EVAL_I2Cx_SDA_PIN GPIO_PIN_9 - -/* I2C interrupt requests */ -#define EVAL_I2Cx_EV_IRQn I2C1_EV_IRQn -#define EVAL_I2Cx_ER_IRQn I2C1_ER_IRQn - -/** - * @} - */ - -/** - * @} - */ - -/** @defgroup STM324xG_EVAL_LOW_LEVEL_Exported_Macros - * @{ - */ -/** - * @} - */ - - -/** @defgroup STM324xG_EVAL_LOW_LEVEL_Exported_Functions - * @{ - */ -uint32_t BSP_GetVersion(void); -void BSP_LED_Init(Led_TypeDef Led); -void BSP_LED_On(Led_TypeDef Led); -void BSP_LED_Off(Led_TypeDef Led); -void BSP_LED_Toggle(Led_TypeDef Led); -void BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef Button_Mode); -uint32_t BSP_PB_GetState(Button_TypeDef Button); -void BSP_COM_Init(COM_TypeDef COM, UART_HandleTypeDef *huart); -uint8_t BSP_JOY_Init(JOYMode_TypeDef Joy_Mode); -JOYState_TypeDef BSP_JOY_GetState(void); - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM324xG_EVAL_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM324xG_EVAL/stm324xg_eval_audio.c b/bsp/stm32f411RE/Libraries/BSP/STM324xG_EVAL/stm324xg_eval_audio.c deleted file mode 100644 index 78d5f88b09..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM324xG_EVAL/stm324xg_eval_audio.c +++ /dev/null @@ -1,679 +0,0 @@ -/** - ****************************************************************************** - * @file stm324xg_eval_audio.c - * @author MCD Application Team - * @version V2.1.0 - * @date 14-August-2015 - * @brief This file provides the Audio driver for the STM324xG-EVAL evaluation - * board. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/*============================================================================== - User NOTES -How To use this driver: ------------------------ - + This driver supports STM32F4xx devices on STM324xG-EVAL Evaluation board. - + Call the function BSP_AUDIO_OUT_Init( - OutputDevice: physical output mode (OUTPUT_DEVICE_SPEAKER, - OUTPUT_DEVICE_HEADPHONE, OUTPUT_DEVICE_AUTO or - OUTPUT_DEVICE_BOTH) - Volume: initial volume to be set (0 is min (mute), 100 is max (100%) - AudioFreq: Audio frequency in Hz (8000, 16000, 22500, 32000 ...) - this parameter is relative to the audio file/stream type. - ) - This function configures all the hardware required for the audio application (codec, I2C, I2S, - GPIOs, DMA and interrupt if needed). This function returns 0 if configuration is OK. - If the returned value is different from 0 or the function is stuck then the communication with - the codec or the IOExpander has failed (try to un-plug the power or reset device in this case). - - OUTPUT_DEVICE_SPEAKER: only speaker will be set as output for the audio stream. - - OUTPUT_DEVICE_HEADPHONE: only headphones will be set as output for the audio stream. - - OUTPUT_DEVICE_AUTO: Selection of output device is made through external switch (implemented - into the audio jack on the evaluation board). When the Headphone is connected it is used - as output. When the headphone is disconnected from the audio jack, the output is - automatically switched to Speaker. - - OUTPUT_DEVICE_BOTH: both Speaker and Headphone are used as outputs for the audio stream - at the same time. - + Call the function BSP_AUDIO_OUT_Play( - pBuffer: pointer to the audio data file address - Size: size of the buffer to be sent in Bytes - ) - to start playing (for the first time) from the audio file/stream. - + Call the function BSP_AUDIO_OUT_Pause() to pause playing - + Call the function BSP_AUDIO_OUT_Resume() to resume playing. - Note. After calling BSP_AUDIO_OUT_Pause() function for pause, only BSP_AUDIO_OUT_Resume() should be called - for resume (it is not allowed to call BSP_AUDIO_OUT_Play() in this case). - Note. This function should be called only when the audio file is played or paused (not stopped). - + For each mode, you may need to implement the relative callback functions into your code. - The Callback functions are named AUDIO_OUT_XXX_CallBack() and only their prototypes are declared in - the stm324xg_eval_audio.h file. (refer to the example for more details on the callbacks implementations) - + To Stop playing, to modify the volume level or to mute, use the functions - BSP_AUDIO_OUT_Stop(), BSP_AUDIO_OUT_SetVolume(), AUDIO_OUT_SetFrequency() BSP_AUDIO_OUT_SetOutputMode and BSP_AUDIO_OUT_SetMute(). - + The driver API and the callback functions are at the end of the stm324xg_eval_audio.h file. - -Driver architecture: - ------------------- - + This driver provide the High Audio Layer: consists of the function API exported in the stm324xg_eval_audio.h file - (BSP_AUDIO_OUT_Init(), BSP_AUDIO_OUT_Play() ...) - + This driver provide also the Media Access Layer (MAL): which consists of functions allowing to access the media containing/ - providing the audio file/stream. These functions are also included as local functions into - the stm324xg_eval_audio_codec.c file (I2Sx_MspInit() and I2Sx_Init()) - - Known Limitations: -------------------- - 1- When using the Speaker, if the audio file quality is not high enough, the speaker output - may produce high and uncomfortable noise level. To avoid this issue, to use speaker - output properly, try to increase audio file sampling rate (typically higher than 48KHz). - This operation will lead to larger file size. - 2- Communication with the audio codec (through I2C) may be corrupted if it is interrupted by some - user interrupt routines (in this case, interrupts could be disabled just before the start of - communication then re-enabled when it is over). Note that this communication is only done at - the configuration phase (BSP_AUDIO_OUT_Init() or BSP_AUDIO_OUT_Stop()) and when Volume control modification is - performed (BSP_AUDIO_OUT_SetVolume() or AUDIO_OUT_Mute() or BSP_AUDIO_OUT_SetOutputMode()). - When the audio data is played, no communication is required with the audio codec. - 3- Parsing of audio file is not implemented (in order to determine audio file properties: Mono/Stereo, Data size, - File size, Audio Frequency, Audio Data header size ...). The configuration is fixed for the given audio file. - 4- Supports only Stereo audio streaming. To play mono audio streams, each data should be sent twice - on the I2S or should be duplicated on the source buffer. Or convert the stream in stereo before playing. - 5- Supports only 16-bits audio data size. -==============================================================================*/ - -/* Includes ------------------------------------------------------------------*/ -#include "stm324xg_eval_audio.h" -#include "stm324xg_eval_io.h" /* IOExpander driver is included in order to allow - CS43L22 codec reset pin managment on the evaluation board */ -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM324xG_EVAL - * @{ - */ - -/** @defgroup STM324xG_EVAL_AUDIO - * @brief This file includes the low layer audio driver available on STM324xG-EVAL - * evaluation board. - * @{ - */ - -/** @defgroup STM324xG_EVAL_AUDIO_Private_Types - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324xG_EVAL_AUDIO_Private_Defines - * @{ - */ -/* These PLL parameters are valide when the f(VCO clock) = 1Mhz */ -const uint32_t I2SFreq[8] = {8000, 11025, 16000, 22050, 32000, 44100, 48000, 96000}; -const uint32_t I2SPLLN[8] = {256, 429, 213, 429, 426, 271, 258, 344}; -const uint32_t I2SPLLR[8] = {5, 4, 4, 4, 4, 6, 3, 1}; -/** - * @} - */ - -/** @defgroup STM324xG_EVAL_AUDIO_Private_Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324xG_EVAL_AUDIO_Private_Variables - * @{ - */ -AUDIO_DrvTypeDef *audio_drv; -I2S_HandleTypeDef haudio_i2s; -/** - * @} - */ - -/** @defgroup STM324xG_EVAL_AUDIO_Private_Function_Prototypes - * @{ - */ -static void CODEC_Reset(void); -static void I2Sx_MspInit(void); -static void I2Sx_Init(uint32_t AudioFreq); -/** - * @} - */ - -/** @defgroup STM324xG_EVAL_AUDIO_Private_Functions - * @{ - */ - -/** - * @brief Configures the audio peripherals. - * @param OutputDevice: OUTPUT_DEVICE_SPEAKER, OUTPUT_DEVICE_HEADPHONE, - * OUTPUT_DEVICE_BOTH or OUTPUT_DEVICE_AUTO . - * @param Volume: Initial volume level (from 0 (Mute) to 100 (Max)) - * @param AudioFreq: Audio frequency used to play the audio stream. - * @note This function configure also that the I2S PLL input clock. - * @retval 0 if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_Init(uint16_t OutputDevice, uint8_t Volume, uint32_t AudioFreq) -{ - uint8_t ret = AUDIO_ERROR; - uint32_t deviceid = 0x00; - RCC_PeriphCLKInitTypeDef RCC_ExCLKInitStruct; - uint8_t index = 0, freqindex = 0xFF; - - for(index = 0; index < 8; index++) - { - if(I2SFreq[index] == AudioFreq) - { - freqindex = index; - } - } - HAL_RCCEx_GetPeriphCLKConfig(&RCC_ExCLKInitStruct); - if(freqindex != 0xFF) - { - /* I2S clock config - PLLI2S_VCO = f(VCO clock) = f(PLLI2S clock input) × (PLLI2SN/PLLM) - I2SCLK = f(PLLI2S clock output) = f(VCO clock) / PLLI2SR */ - RCC_ExCLKInitStruct.PeriphClockSelection = RCC_PERIPHCLK_I2S; - RCC_ExCLKInitStruct.PLLI2S.PLLI2SN = I2SPLLN[freqindex]; - RCC_ExCLKInitStruct.PLLI2S.PLLI2SR = I2SPLLR[freqindex]; - HAL_RCCEx_PeriphCLKConfig(&RCC_ExCLKInitStruct); - } - else /* Default PLL I2S configuration */ - { - /* I2S clock config - PLLI2S_VCO = f(VCO clock) = f(PLLI2S clock input) × (PLLI2SN/PLLM) - I2SCLK = f(PLLI2S clock output) = f(VCO clock) / PLLI2SR */ - RCC_ExCLKInitStruct.PeriphClockSelection = RCC_PERIPHCLK_I2S; - RCC_ExCLKInitStruct.PLLI2S.PLLI2SN = 258; - RCC_ExCLKInitStruct.PLLI2S.PLLI2SR = 3; - HAL_RCCEx_PeriphCLKConfig(&RCC_ExCLKInitStruct); - } - - /* Reset the Codec Registers */ - CODEC_Reset(); - - deviceid = cs43l22_drv.ReadID(AUDIO_I2C_ADDRESS); - - if((deviceid & CS43L22_ID_MASK) == CS43L22_ID) - { - /* Initialize the audio driver structure */ - audio_drv = &cs43l22_drv; - ret = AUDIO_OK; - } - else - { - ret = AUDIO_ERROR; - } - - if(ret == AUDIO_OK) - { - audio_drv->Init(AUDIO_I2C_ADDRESS, OutputDevice, Volume, AudioFreq); - /* I2S data transfer preparation: - Prepare the Media to be used for the audio transfer from memory to I2S peripheral */ - /* Configure the I2S peripheral */ - I2Sx_Init(AudioFreq); - } - - return ret; -} - -/** - * @brief Starts playing audio stream from a data buffer for a determined size. - * @param pBuffer: Pointer to the buffer - * @param Size: Number of audio data BYTES. - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_Play(uint16_t* pBuffer, uint32_t Size) -{ - /* Call the audio Codec Play function */ - if(audio_drv->Play(AUDIO_I2C_ADDRESS, pBuffer, Size) != 0) - { - return AUDIO_ERROR; - } - else - { - /* Update the Media layer and enable it for play */ - HAL_I2S_Transmit_DMA(&haudio_i2s, pBuffer, DMA_MAX(Size/AUDIODATA_SIZE)); - return AUDIO_OK; - } -} - -/** - * @brief Sends n-Bytes on the I2S interface. - * @param pData: Pointer to data address - * @param Size: Number of data to be written. - * @retval None - */ -void BSP_AUDIO_OUT_ChangeBuffer(uint16_t *pData, uint16_t Size) -{ - HAL_I2S_Transmit_DMA(&haudio_i2s, pData, Size); -} - -/** - * @brief Pauses the audio file stream. - * In case of using DMA, the DMA Pause feature is used. - * @WARNING When calling BSP_AUDIO_OUT_Pause() function for pause, only - * BSP_AUDIO_OUT_Resume() function should be called for resume (use of BSP_AUDIO_OUT_Play() - * function for resume could lead to unexpected behavior). - * @param None - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_Pause(void) -{ - /* Call the Audio Codec Pause/Resume function */ - if(audio_drv->Pause(AUDIO_I2C_ADDRESS) != 0) - { - return AUDIO_ERROR; - } - else - { - /* Call the Media layer pause function */ - HAL_I2S_DMAPause(&haudio_i2s); - - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; - } -} - -/** - * @brief Resumes the audio file stream. - * @WARNING When calling BSP_AUDIO_OUT_Pause() function for pause, only - * BSP_AUDIO_OUT_Resume() function should be called for resume (use of BSP_AUDIO_OUT_Play() - * function for resume could lead to unexpected behavior). - * @param None - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_Resume(void) -{ - /* Call the Audio Codec Pause/Resume function */ - if(audio_drv->Resume(AUDIO_I2C_ADDRESS) != 0) - { - return AUDIO_ERROR; - } - else - { - /* Call the Media layer pause/resume function */ - HAL_I2S_DMAResume(&haudio_i2s); - - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; - } -} - -/** - * @brief Stops audio playing and Power down the Audio Codec. - * @param Option: could be one of the following parameters - * - CODEC_PDWN_SW: for software power off (by writing registers). - * Then no need to reconfigure the Codec after power on. - * - CODEC_PDWN_HW: completely shut down the codec (physically). - * Then need to reconfigure the Codec after power on. - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_Stop(uint32_t Option) -{ - /* Call the Media layer stop function */ - HAL_I2S_DMAStop(&haudio_i2s); - - /* Call Audio Codec Stop function */ - if(audio_drv->Stop(AUDIO_I2C_ADDRESS, Option) != 0) - { - return AUDIO_ERROR; - } - else - { - if(Option == CODEC_PDWN_HW) - { - /* Wait at least 1ms */ - HAL_Delay(1); - - /* Reset the pin */ - BSP_IO_WritePin(AUDIO_RESET_PIN, RESET); - } - - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; - } -} - -/** - * @brief Controls the current audio volume level. - * @param Volume: Volume level to be set in percentage from 0% to 100% (0 for - * Mute and 100 for Max volume level). - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_SetVolume(uint8_t Volume) -{ - /* Call the codec volume control function with converted volume value */ - if(audio_drv->SetVolume(AUDIO_I2C_ADDRESS, Volume) != 0) - { - return AUDIO_ERROR; - } - else - { - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; - } -} - -/** - * @brief Enables or disables the MUTE mode by software - * @param Cmd: could be AUDIO_MUTE_ON to mute sound or AUDIO_MUTE_OFF to - * unmute the codec and restore previous volume level. - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_SetMute(uint32_t Cmd) -{ - /* Call the Codec Mute function */ - if(audio_drv->SetMute(AUDIO_I2C_ADDRESS, Cmd) != 0) - { - return AUDIO_ERROR; - } - else - { - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; - } -} - -/** - * @brief Switch dynamically (while audio file is played) the output target - * (speaker or headphone). - * @note This function modifies a global variable of the audio codec driver: OutputDev. - * @param Output: specifies the audio output target: OUTPUT_DEVICE_SPEAKER, - * OUTPUT_DEVICE_HEADPHONE, OUTPUT_DEVICE_BOTH or OUTPUT_DEVICE_AUTO - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_SetOutputMode(uint8_t Output) -{ - /* Call the Codec output Device function */ - if(audio_drv->SetOutputMode(AUDIO_I2C_ADDRESS, Output) != 0) - { - return AUDIO_ERROR; - } - else - { - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; - } -} - -/** - * @brief Updates the audio frequency. - * @param AudioFreq: Audio frequency used to play the audio stream. - * @retval AUDIO_OK if correct communication, else wrong communication - */ -void BSP_AUDIO_OUT_SetFrequency(uint32_t AudioFreq) -{ - RCC_PeriphCLKInitTypeDef RCC_ExCLKInitStruct; - uint8_t index = 0, freqindex = 0xFF; - - for(index = 0; index < 8; index++) - { - if(I2SFreq[index] == AudioFreq) - { - freqindex = index; - } - } - HAL_RCCEx_GetPeriphCLKConfig(&RCC_ExCLKInitStruct); - if(freqindex != 0xFF) - { - /* I2S clock config - PLLI2S_VCO = f(VCO clock) = f(PLLI2S clock input) × (PLLI2SN/PLLM) - I2SCLK = f(PLLI2S clock output) = f(VCO clock) / PLLI2SR */ - RCC_ExCLKInitStruct.PeriphClockSelection = RCC_PERIPHCLK_I2S; - RCC_ExCLKInitStruct.PLLI2S.PLLI2SN = I2SPLLN[freqindex]; - RCC_ExCLKInitStruct.PLLI2S.PLLI2SR = I2SPLLR[freqindex]; - HAL_RCCEx_PeriphCLKConfig(&RCC_ExCLKInitStruct); - } - else /* Default PLL I2S configuration */ - { - /* I2S clock config - PLLI2S_VCO = f(VCO clock) = f(PLLI2S clock input) × (PLLI2SN/PLLM) - I2SCLK = f(PLLI2S clock output) = f(VCO clock) / PLLI2SR */ - RCC_ExCLKInitStruct.PeriphClockSelection = RCC_PERIPHCLK_I2S; - RCC_ExCLKInitStruct.PLLI2S.PLLI2SN = 258; - RCC_ExCLKInitStruct.PLLI2S.PLLI2SR = 3; - HAL_RCCEx_PeriphCLKConfig(&RCC_ExCLKInitStruct); - } - /* Update the I2S audio frequency configuration */ - I2Sx_Init(AudioFreq); -} - -/** - * @brief Tx Transfer completed callbacks - * @param hi2s: I2S handle - * @retval None - */ -void HAL_I2S_TxCpltCallback(I2S_HandleTypeDef *hi2s) -{ - /* Manage the remaining file size and new address offset: This function - should be coded by user (its prototype is already declared in stm324xg_eval_audio.h) */ - BSP_AUDIO_OUT_TransferComplete_CallBack(); -} - -/** - * @brief Tx Transfer Half completed callbacks - * @param hi2s: I2S handle - * @retval None - */ -void HAL_I2S_TxHalfCpltCallback(I2S_HandleTypeDef *hi2s) -{ - /* Manage the remaining file size and new address offset: This function - should be coded by user (its prototype is already declared in stm324xg_eval_audio.h) */ - BSP_AUDIO_OUT_HalfTransfer_CallBack(); -} - -/** - * @brief I2S error callbacks. - * @param hi2s: I2S handle - * @retval None - */ -void HAL_I2S_ErrorCallback(I2S_HandleTypeDef *hi2s) -{ - BSP_AUDIO_OUT_Error_CallBack(); -} - -/** - * @brief Manages the DMA full Transfer complete event. - * @param None - * @retval None - */ -__weak void BSP_AUDIO_OUT_TransferComplete_CallBack(void) -{ -} - -/** - * @brief Manages the DMA Half Transfer complete event. - * @param None - * @retval None - */ -__weak void BSP_AUDIO_OUT_HalfTransfer_CallBack(void) -{ -} - -/** - * @brief Manages the DMA FIFO error event. - * @param None - * @retval None - */ -__weak void BSP_AUDIO_OUT_Error_CallBack(void) -{ -} - -/******************************************************************************* - Static Functions -*******************************************************************************/ - -/** - * @brief Initializes I2C MSP. - * @param None - * @retval None - */ -static void I2Sx_MspInit(void) -{ - static DMA_HandleTypeDef hdma_i2sTx; - GPIO_InitTypeDef GPIO_InitStruct; - I2S_HandleTypeDef *hi2s = &haudio_i2s; - - /* Enable I2S clock */ - AUDIO_I2Sx_CLK_ENABLE(); - - /* Enable SCK, SD and WS GPIO clock */ - AUDIO_I2Sx_SCK_SD_WS_CLK_ENABLE(); - - /* CODEC_I2S pins configuration: WS, SCK and SD pins */ - GPIO_InitStruct.Pin = AUDIO_I2Sx_SCK_PIN; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FAST; - GPIO_InitStruct.Alternate = AUDIO_I2Sx_SCK_SD_WS_AF; - HAL_GPIO_Init(AUDIO_I2Sx_SCK_SD_WS_GPIO_PORT, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = AUDIO_I2Sx_SD_PIN; - HAL_GPIO_Init(AUDIO_I2Sx_SCK_SD_WS_GPIO_PORT, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = AUDIO_I2Sx_WS_PIN; - HAL_GPIO_Init(AUDIO_I2Sx_SCK_SD_WS_GPIO_PORT, &GPIO_InitStruct); - - /* Enable MCK GPIO clock */ - AUDIO_I2Sx_MCK_CLK_ENABLE(); - - /* CODEC_I2S pins configuration: MCK pin */ - GPIO_InitStruct.Pin = AUDIO_I2Sx_MCK_PIN; - HAL_GPIO_Init(AUDIO_I2Sx_MCK_GPIO_PORT, &GPIO_InitStruct); - - /* Enable the DMA clock */ - AUDIO_I2Sx_DMAx_CLK_ENABLE(); - - if(hi2s->Instance == AUDIO_I2Sx) - { - /* Configure the hdma_i2sTx handle parameters */ - hdma_i2sTx.Init.Channel = AUDIO_I2Sx_DMAx_CHANNEL; - hdma_i2sTx.Init.Direction = DMA_MEMORY_TO_PERIPH; - hdma_i2sTx.Init.PeriphInc = DMA_PINC_DISABLE; - hdma_i2sTx.Init.MemInc = DMA_MINC_ENABLE; - hdma_i2sTx.Init.PeriphDataAlignment = AUDIO_I2Sx_DMAx_PERIPH_DATA_SIZE; - hdma_i2sTx.Init.MemDataAlignment = AUDIO_I2Sx_DMAx_MEM_DATA_SIZE; - hdma_i2sTx.Init.Mode = DMA_NORMAL; - hdma_i2sTx.Init.Priority = DMA_PRIORITY_HIGH; - hdma_i2sTx.Init.FIFOMode = DMA_FIFOMODE_ENABLE; - hdma_i2sTx.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; - hdma_i2sTx.Init.MemBurst = DMA_MBURST_SINGLE; - hdma_i2sTx.Init.PeriphBurst = DMA_PBURST_SINGLE; - - hdma_i2sTx.Instance = AUDIO_I2Sx_DMAx_STREAM; - - /* Associate the DMA handle */ - __HAL_LINKDMA(hi2s, hdmatx, hdma_i2sTx); - - /* Deinitialize the Stream for new transfer */ - HAL_DMA_DeInit(&hdma_i2sTx); - - /* Configure the DMA Stream */ - HAL_DMA_Init(&hdma_i2sTx); - } - - /* I2S DMA IRQ Channel configuration */ - HAL_NVIC_SetPriority(AUDIO_I2Sx_DMAx_IRQ, AUDIO_IRQ_PREPRIO, 0); - HAL_NVIC_EnableIRQ(AUDIO_I2Sx_DMAx_IRQ); -} - -/** - * @brief Initializes the Audio Codec audio interface (I2S). - * @param AudioFreq: Audio frequency to be configured for the I2S peripheral. - * @retval None - */ -static void I2Sx_Init(uint32_t AudioFreq) -{ - /* Initialize the haudio_i2s Instance parameter */ - haudio_i2s.Instance = AUDIO_I2Sx; - - /* Disable I2S block */ - __HAL_I2S_DISABLE(&haudio_i2s); - - haudio_i2s.Init.Mode = I2S_MODE_MASTER_TX; - haudio_i2s.Init.Standard = I2S_STANDARD; - haudio_i2s.Init.DataFormat = I2S_DATAFORMAT_16B; - haudio_i2s.Init.AudioFreq = AudioFreq; - haudio_i2s.Init.CPOL = I2S_CPOL_LOW; - haudio_i2s.Init.MCLKOutput = I2S_MCLKOUTPUT_ENABLE; - - if(HAL_I2S_GetState(&haudio_i2s) == HAL_I2S_STATE_RESET) - { - I2Sx_MspInit(); - } - /* Init the I2S */ - HAL_I2S_Init(&haudio_i2s); -} - -/** - * @brief Resets the audio codec. It restores the default configuration of the - * codec (this function shall be called before initializing the codec). - * @note This function calls an external driver function: The IO Expander driver. - * @param None - * @retval None - */ -static void CODEC_Reset(void) -{ - /* Configure the IO Expander (to use the Codec Reset pin mapped on the IOExpander) */ - BSP_IO_Init(); - - BSP_IO_ConfigPin(AUDIO_RESET_PIN, IO_MODE_OUTPUT); - - /* Power Down the codec */ - BSP_IO_WritePin(AUDIO_RESET_PIN, RESET); - - /* Wait for a delay to insure registers erasing */ - HAL_Delay(CODEC_RESET_DELAY); - - /* Power on the codec */ - BSP_IO_WritePin(AUDIO_RESET_PIN, SET); - - /* Wait for a delay to insure registers erasing */ - HAL_Delay(CODEC_RESET_DELAY); -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM324xG_EVAL/stm324xg_eval_audio.h b/bsp/stm32f411RE/Libraries/BSP/STM324xG_EVAL/stm324xg_eval_audio.h deleted file mode 100644 index 8e14f16863..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM324xG_EVAL/stm324xg_eval_audio.h +++ /dev/null @@ -1,178 +0,0 @@ -/** - ****************************************************************************** - * @file stm324xg_eval_audio.h - * @author MCD Application Team - * @version V2.1.0 - * @date 14-August-2015 - * @brief This file contains the common defines and functions prototypes for - * the stm324xg_eval_audio.c driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM324xG_EVAL_AUDIO_H -#define __STM324xG_EVAL_AUDIO_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "../Components/cs43l22/cs43l22.h" -#include "stm324xg_eval.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM324xG_EVAL - * @{ - */ - -/** @defgroup STM324xG_EVAL_AUDIO - * @{ - */ - -/** @defgroup STM324xG_EVAL_AUDIO_Exported_Types - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324xG_EVAL_AUDIO_Exported_Constants - * @{ - */ -/* Audio Reset Pin definition */ -#define AUDIO_RESET_PIN IO_PIN_2 - -/* I2S peripheral configuration defines */ -#define AUDIO_I2Sx SPI2 -#define AUDIO_I2Sx_CLK_ENABLE() __SPI2_CLK_ENABLE() -#define AUDIO_I2Sx_SCK_SD_WS_AF GPIO_AF5_SPI2 -#define AUDIO_I2Sx_SCK_SD_WS_CLK_ENABLE() __GPIOI_CLK_ENABLE() -#define AUDIO_I2Sx_MCK_CLK_ENABLE() __GPIOC_CLK_ENABLE() -#define AUDIO_I2Sx_WS_PIN GPIO_PIN_0 -#define AUDIO_I2Sx_SCK_PIN GPIO_PIN_1 -#define AUDIO_I2Sx_SD_PIN GPIO_PIN_3 -#define AUDIO_I2Sx_MCK_PIN GPIO_PIN_6 -#define AUDIO_I2Sx_SCK_SD_WS_GPIO_PORT GPIOI -#define AUDIO_I2Sx_MCK_GPIO_PORT GPIOC - -/* I2S DMA Stream definitions */ -#define AUDIO_I2Sx_DMAx_CLK_ENABLE() __DMA1_CLK_ENABLE() -#define AUDIO_I2Sx_DMAx_STREAM DMA1_Stream4 -#define AUDIO_I2Sx_DMAx_CHANNEL DMA_CHANNEL_0 -#define AUDIO_I2Sx_DMAx_IRQ DMA1_Stream4_IRQn -#define AUDIO_I2Sx_DMAx_PERIPH_DATA_SIZE DMA_PDATAALIGN_HALFWORD -#define AUDIO_I2Sx_DMAx_MEM_DATA_SIZE DMA_MDATAALIGN_HALFWORD -#define DMA_MAX_SZE 0xFFFF - -#define AUDIO_I2Sx_DMAx_IRQHandler DMA1_Stream4_IRQHandler - -/*------------------------------------------------------------------------------ - CONFIGURATION: Audio Driver Configuration parameters -------------------------------------------------------------------------------*/ -/* Select the interrupt preemption priority for the DMA interrupt */ -#define AUDIO_IRQ_PREPRIO 5 /* Select the preemption priority level(0 is the highest) */ - -#define AUDIODATA_SIZE 2 /* 16-bits audio data size */ - -/* Audio status definition */ -#define AUDIO_OK 0x00 -#define AUDIO_ERROR 0x01 -#define AUDIO_TIMEOUT 0x02 - -/*------------------------------------------------------------------------------ - OPTIONAL Configuration defines parameters -------------------------------------------------------------------------------*/ -/* Delay for the Codec to be correctly reset */ -#define CODEC_RESET_DELAY 5 - -/** - * @} - */ - -/** @defgroup STM324xG_EVAL_AUDIO_Exported_Macros - * @{ - */ -#define DMA_MAX(x) (((x) <= DMA_MAX_SZE)? (x):DMA_MAX_SZE) -/** - * @} - */ - -/** @defgroup STM324xG_EVAL_AUDIO_Exported_Functions - * @{ - */ -uint8_t BSP_AUDIO_OUT_Init(uint16_t OutputDevice, uint8_t Volume, uint32_t AudioFreq); -uint8_t BSP_AUDIO_OUT_Play(uint16_t *pBuffer, uint32_t Size); -void BSP_AUDIO_OUT_ChangeBuffer(uint16_t *pData, uint16_t Size); -uint8_t BSP_AUDIO_OUT_Pause(void); -uint8_t BSP_AUDIO_OUT_Resume(void); -uint8_t BSP_AUDIO_OUT_Stop(uint32_t Option); -uint8_t BSP_AUDIO_OUT_SetVolume(uint8_t Volume); -void BSP_AUDIO_OUT_SetFrequency(uint32_t AudioFreq); -uint8_t BSP_AUDIO_OUT_SetMute(uint32_t Cmd); -uint8_t BSP_AUDIO_OUT_SetOutputMode(uint8_t Output); - -/* User Callbacks: user has to implement these functions in his code if they are needed. */ -/* This function is called when the requested data has been completely transferred.*/ -void BSP_AUDIO_OUT_TransferComplete_CallBack(void); - -/* This function is called when half of the requested buffer has been transferred. */ -void BSP_AUDIO_OUT_HalfTransfer_CallBack(void); - -/* This function is called when an Interrupt due to transfer error on or peripheral - error occurs. */ -void BSP_AUDIO_OUT_Error_CallBack(void); - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM324xG_EVAL_AUDIO_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM324xG_EVAL/stm324xg_eval_camera.c b/bsp/stm32f411RE/Libraries/BSP/STM324xG_EVAL/stm324xg_eval_camera.c deleted file mode 100644 index 889cb95e24..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM324xG_EVAL/stm324xg_eval_camera.c +++ /dev/null @@ -1,537 +0,0 @@ -/** - ****************************************************************************** - * @file stm324xg_eval_camera.c - * @author MCD Application Team - * @version V2.1.0 - * @date 14-August-2015 - * @brief This file includes the driver for Camera module mounted on - * STM324xG-EVAL evaluation board(MB786). - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* File Info: ------------------------------------------------------------------ - User NOTES -1. How to use this driver: --------------------------- - - This driver is used to drive the Camera. - - The OV2640 component driver MUST be included with this driver. - -2. Driver description: ---------------------- - + Initialization steps: - o Initialize the Camera using the BSP_CAMERA_Init() function. - o Start the Camera capture or snapshot using CAMERA_Start() function. - o Suspend, resume or stop the Camera capture using the following functions: - - BSP_CAMERA_Suspend() - - BSP_CAMERA_Resume() - - BSP_CAMERA_Stop() - - + Options - o Increase or decrease on the fly the brightness and/or contrast - using the following function: - - BSP_CAMERA_ContrastBrightnessConfig - o Add a special effect on the fly using the following functions: - - BSP_CAMERA_BlackWhiteConfig() - - BSP_CAMERA_ColorEffectConfig() - -------------------------------------------------------------------------------*/ - -/* Includes ------------------------------------------------------------------*/ -#include "stm324xg_eval_camera.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM324xG_EVAL - * @{ - */ - -/** @addtogroup STM324xG_EVAL_CAMERA - * @{ - */ - -/** @defgroup STM324xG_EVAL_CAMERA_Private_TypesDefinitions - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324xG_EVAL_CAMERA_Private_Defines - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324xG_EVAL_CAMERA_Private_Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324xG_EVAL_CAMERA_Private_Variables - * @{ - */ -static DCMI_HandleTypeDef hdcmi_eval; -CAMERA_DrvTypeDef *camera_drv; -uint32_t current_resolution; -/** - * @} - */ - -/** @defgroup STM324xG_EVAL_CAMERA_Private_FunctionPrototypes - * @{ - */ -static void DCMI_MspInit(void); -static uint32_t GetSize(uint32_t resolution); -/** - * @} - */ - -/** @defgroup STM324xG_EVAL_CAMERA_Private_Functions - * @{ - */ - -/** - * @brief Initializes the Camera. - * @param Camera: Pointer to the Camera configuration structure - * @retval Camera status - */ -uint8_t BSP_CAMERA_Init(uint32_t Resolution) -{ - DCMI_HandleTypeDef *phdcmi; - uint8_t ret = CAMERA_ERROR; - - /* Get the DCMI handle structure */ - phdcmi = &hdcmi_eval; - - /*** Configures the DCMI to interface with the Camera module ***/ - /* DCMI configuration */ - phdcmi->Init.CaptureRate = DCMI_CR_ALL_FRAME; - phdcmi->Init.HSPolarity = DCMI_HSPOLARITY_LOW; - phdcmi->Init.SynchroMode = DCMI_SYNCHRO_HARDWARE; - phdcmi->Init.VSPolarity = DCMI_VSPOLARITY_LOW; - phdcmi->Init.ExtendedDataMode = DCMI_EXTEND_DATA_8B; - phdcmi->Init.PCKPolarity = DCMI_PCKPOLARITY_RISING; - phdcmi->Instance = DCMI; - - /* DCMI Initialization */ - DCMI_MspInit(); - HAL_DCMI_Init(phdcmi); - - if(ov2640_drv.ReadID(CAMERA_I2C_ADDRESS) == OV2640_ID) - { - /* Initialize the Camera driver structure */ - camera_drv = &ov2640_drv; - - /* Camera Init */ - camera_drv->Init(CAMERA_I2C_ADDRESS, Resolution); - - /* Return CAMERA_OK status */ - ret = CAMERA_OK; - } - - current_resolution = Resolution; - - return ret; -} - -/** - * @brief Starts the Camera capture in continuous mode. - * @param buff: pointer to the Camera output buffer - * @retval None - */ -void BSP_CAMERA_ContinuousStart(uint8_t *buff) -{ - /* Start the Camera capture */ - HAL_DCMI_Start_DMA(&hdcmi_eval, DCMI_MODE_CONTINUOUS, (uint32_t)buff, GetSize(current_resolution)); -} - -/** - * @brief Starts the Camera capture in snapshot mode. - * @param buff: pointer to the Camera output buffer - * @retval None - */ -void BSP_CAMERA_SnapshotStart(uint8_t *buff) -{ - /* Start the Camera capture */ - HAL_DCMI_Start_DMA(&hdcmi_eval, DCMI_MODE_SNAPSHOT, (uint32_t)buff, GetSize(current_resolution)); -} - -/** - * @brief Suspends the Camera capture. - * @param None - * @retval None - */ -void BSP_CAMERA_Suspend(void) -{ - /* Disable the DMA */ - __HAL_DMA_DISABLE(hdcmi_eval.DMA_Handle); - /* Disable the DCMI */ - __HAL_DCMI_DISABLE(&hdcmi_eval); -} - -/** - * @brief Resumes the Camera capture. - * @param None - * @retval None - */ -void BSP_CAMERA_Resume(void) -{ - /* Enable the DCMI */ - __HAL_DCMI_ENABLE(&hdcmi_eval); - /* Enable the DMA */ - __HAL_DMA_ENABLE(hdcmi_eval.DMA_Handle); -} - -/** - * @brief Stops the Camera capture. - * @param None - * @retval Camera status - */ -uint8_t BSP_CAMERA_Stop(void) -{ - DCMI_HandleTypeDef *phdcmi; - - uint8_t ret = CAMERA_ERROR; - - /* Get the DCMI handle structure */ - phdcmi = &hdcmi_eval; - - if(HAL_DCMI_Stop(phdcmi) == HAL_OK) - { - ret = CAMERA_OK; - } - - return ret; -} - -/** - * @brief Configures the Camera contrast and brightness. - * @param contrast_level: Contrast level - * This parameter can be one of the following values: - * @arg CAMERA_CONTRAST_LEVEL4: for contrast +2 - * @arg CAMERA_CONTRAST_LEVEL3: for contrast +1 - * @arg CAMERA_CONTRAST_LEVEL2: for contrast 0 - * @arg CAMERA_CONTRAST_LEVEL1: for contrast -1 - * @arg CAMERA_CONTRAST_LEVEL0: for contrast -2 - * @param brightness_level: Brightness level - * This parameter can be one of the following values: - * @arg CAMERA_BRIGHTNESS_LEVEL4: for brightness +2 - * @arg CAMERA_BRIGHTNESS_LEVEL3: for brightness +1 - * @arg CAMERA_BRIGHTNESS_LEVEL2: for brightness 0 - * @arg CAMERA_BRIGHTNESS_LEVEL1: for brightness -1 - * @arg CAMERA_BRIGHTNESS_LEVEL0: for brightness -2 - * @retval None - */ -void BSP_CAMERA_ContrastBrightnessConfig(uint32_t contrast_level, uint32_t brightness_level) -{ - if(camera_drv->Config != NULL) - { - camera_drv->Config(CAMERA_I2C_ADDRESS, CAMERA_CONTRAST_BRIGHTNESS, contrast_level, brightness_level); - } -} - -/** - * @brief Configures the Camera white balance. - * @param Mode: black_white mode - * This parameter can be one of the following values: - * @arg CAMERA_BLACK_WHITE_BW - * @arg CAMERA_BLACK_WHITE_NEGATIVE - * @arg CAMERA_BLACK_WHITE_BW_NEGATIVE - * @arg CAMERA_BLACK_WHITE_NORMAL - * @retval None - */ -void BSP_CAMERA_BlackWhiteConfig(uint32_t Mode) -{ - if(camera_drv->Config != NULL) - { - camera_drv->Config(CAMERA_I2C_ADDRESS, CAMERA_BLACK_WHITE, Mode, 0); - } -} - -/** - * @brief Configures the Camera color effect. - * @param Effect: Color effect - * This parameter can be one of the following values: - * @arg CAMERA_COLOR_EFFECT_ANTIQUE - * @arg CAMERA_COLOR_EFFECT_BLUE - * @arg CAMERA_COLOR_EFFECT_GREEN - * @arg CAMERA_COLOR_EFFECT_RED - * @retval None - */ -void BSP_CAMERA_ColorEffectConfig(uint32_t Effect) -{ - if(camera_drv->Config != NULL) - { - camera_drv->Config(CAMERA_I2C_ADDRESS, CAMERA_COLOR_EFFECT, Effect, 0); - } -} - -/** - * @brief Handles DCMI interrupt request. - * @param None - * @retval None - */ -void BSP_CAMERA_IRQHandler(void) -{ - HAL_DCMI_IRQHandler(&hdcmi_eval); -} - -/** - * @brief Handles DMA interrupt request. - * @param None - * @retval None - */ -void BSP_CAMERA_DMA_IRQHandler(void) -{ - HAL_DMA_IRQHandler(hdcmi_eval.DMA_Handle); -} - -/** - * @brief Get the capture size. - * @param current_resolution: the current resolution. - * @retval cpature size - */ -static uint32_t GetSize(uint32_t resolution) -{ - uint32_t size = 0; - - /* Get capture size */ - switch (resolution) - { - case CAMERA_R160x120: - { - size = 0x2580; - } - break; - case CAMERA_R320x240: - { - size = 0x9600; - } - break; - default: - { - break; - } - } - - return size; -} - -/** - * @brief Initializes the DCMI MSP. - * @param None - * @retval None - */ -static void DCMI_MspInit(void) -{ - static DMA_HandleTypeDef hdma; - GPIO_InitTypeDef GPIO_Init_Structure; - DCMI_HandleTypeDef *hdcmi = &hdcmi_eval; - - /*** Enable peripherals and GPIO clocks ***/ - /* Enable DCMI clock */ - __DCMI_CLK_ENABLE(); - - /* Enable DMA2 clock */ - __DMA2_CLK_ENABLE(); - - /* Enable GPIO clocks */ - __GPIOA_CLK_ENABLE(); - __GPIOH_CLK_ENABLE(); - __GPIOI_CLK_ENABLE(); - - /*** Configure the GPIO ***/ - /* Configure DCMI GPIO as alternate function */ - GPIO_Init_Structure.Pin = GPIO_PIN_6; - GPIO_Init_Structure.Mode = GPIO_MODE_AF_PP; - GPIO_Init_Structure.Pull = GPIO_PULLUP; - GPIO_Init_Structure.Speed = GPIO_SPEED_HIGH; - GPIO_Init_Structure.Alternate = GPIO_AF13_DCMI; - HAL_GPIO_Init(GPIOA, &GPIO_Init_Structure); - - GPIO_Init_Structure.Pin = GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 |\ - GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_14; - GPIO_Init_Structure.Mode = GPIO_MODE_AF_PP; - GPIO_Init_Structure.Pull = GPIO_PULLUP; - GPIO_Init_Structure.Speed = GPIO_SPEED_HIGH; - GPIO_Init_Structure.Alternate = GPIO_AF13_DCMI; - HAL_GPIO_Init(GPIOH, &GPIO_Init_Structure); - - GPIO_Init_Structure.Pin = GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 |\ - GPIO_PIN_7; - GPIO_Init_Structure.Mode = GPIO_MODE_AF_PP; - GPIO_Init_Structure.Pull = GPIO_PULLUP; - GPIO_Init_Structure.Speed = GPIO_SPEED_HIGH; - GPIO_Init_Structure.Alternate = GPIO_AF13_DCMI; - HAL_GPIO_Init(GPIOI, &GPIO_Init_Structure); - - /*** Configure the DMA streams ***/ - /* Configure the DMA handler for Transmission process */ - hdma.Init.Channel = DMA_CHANNEL_1; - hdma.Init.Direction = DMA_PERIPH_TO_MEMORY; - hdma.Init.PeriphInc = DMA_PINC_DISABLE; - hdma.Init.MemInc = DMA_MINC_ENABLE; - hdma.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; - hdma.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; - hdma.Init.Mode = DMA_CIRCULAR; - hdma.Init.Priority = DMA_PRIORITY_HIGH; - hdma.Init.FIFOMode = DMA_FIFOMODE_DISABLE; - hdma.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; - hdma.Init.MemBurst = DMA_MBURST_SINGLE; - hdma.Init.PeriphBurst = DMA_PBURST_SINGLE; - - hdma.Instance = DMA2_Stream1; - - /* Associate the initialized DMA handle to the DCMI handle */ - __HAL_LINKDMA(hdcmi, DMA_Handle, hdma); - - /*** Configure the NVIC for DCMI and DMA ***/ - /* NVIC configuration for DCMI transfer complete interrupt */ - HAL_NVIC_SetPriority(DCMI_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(DCMI_IRQn); - - /* NVIC configuration for DMA2 transfer complete interrupt */ - HAL_NVIC_SetPriority(DMA2_Stream1_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(DMA2_Stream1_IRQn); - - /* Configure the DMA stream */ - HAL_DMA_Init(hdcmi->DMA_Handle); -} - -/** - * @brief Line event callback - * @param hdcmi: pointer to the DCMI handle - * @retval None - */ -void HAL_DCMI_LineEventCallback(DCMI_HandleTypeDef *hdcmi) -{ - BSP_CAMERA_LineEventCallback(); -} - -/** - * @brief Line Event callback. - * @param None - * @retval None - */ -__weak void BSP_CAMERA_LineEventCallback(void) -{ - /* NOTE : This function Should not be modified, when the callback is needed, - the HAL_DCMI_LineEventCallback could be implemented in the user file - */ -} - -/** - * @brief VSYNC event callback - * @param hdcmi: pointer to the DCMI handle - * @retval None - */ -void HAL_DCMI_VsyncEventCallback(DCMI_HandleTypeDef *hdcmi) -{ - BSP_CAMERA_VsyncEventCallback(); -} - -/** - * @brief VSYNC Event callback. - * @param None - * @retval None - */ -__weak void BSP_CAMERA_VsyncEventCallback(void) -{ - /* NOTE : This function Should not be modified, when the callback is needed, - the HAL_DCMI_VsyncEventCallback could be implemented in the user file - */ -} - -/** - * @brief Frame event callback - * @param hdcmi: pointer to the DCMI handle - * @retval None - */ -void HAL_DCMI_FrameEventCallback(DCMI_HandleTypeDef *hdcmi) -{ - BSP_CAMERA_FrameEventCallback(); -} - -/** - * @brief Frame Event callback. - * @param None - * @retval None - */ -__weak void BSP_CAMERA_FrameEventCallback(void) -{ - /* NOTE : This function Should not be modified, when the callback is needed, - the HAL_DCMI_FrameEventCallback could be implemented in the user file - */ -} - -/** - * @brief Error callback - * @param hdcmi: pointer to the DCMI handle - * @retval None - */ -void HAL_DCMI_ErrorCallback(DCMI_HandleTypeDef *hdcmi) -{ - BSP_CAMERA_ErrorCallback(); -} - -/** - * @brief Error callback. - * @param None - * @retval None - */ -__weak void BSP_CAMERA_ErrorCallback(void) -{ - /* NOTE : This function Should not be modified, when the callback is needed, - the HAL_DCMI_ErrorCallback could be implemented in the user file - */ -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM324xG_EVAL/stm324xg_eval_camera.h b/bsp/stm32f411RE/Libraries/BSP/STM324xG_EVAL/stm324xg_eval_camera.h deleted file mode 100644 index 4984551f6f..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM324xG_EVAL/stm324xg_eval_camera.h +++ /dev/null @@ -1,141 +0,0 @@ -/** - ****************************************************************************** - * @file stm324xg_eval_camera.h - * @author MCD Application Team - * @version V2.1.0 - * @date 14-August-2015 - * @brief This file contains all the functions prototypes for the - * stm324xg_eval_camera.c driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM324xG_EVAL_CAMERA_H -#define __STM324xG_EVAL_CAMERA_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm324xg_eval.h" -#include "stm324xg_eval_io.h" - -/* Include Camera component Driver */ -#include "../Components/ov2640/ov2640.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM324xG_EVAL - * @{ - */ - -/** @addtogroup STM324xG_EVAL_CAMERA - * @{ - */ - -/** @defgroup STM324xG_EVAL_CAMERA_Exported_Types - * @{ - */ - -/** - * @brief Camera status structure definition - */ -typedef enum -{ - CAMERA_OK = 0x00, - CAMERA_ERROR = 0x01, - CAMERA_TIMEOUT = 0x02 -}Camera_StatusTypeDef; - -#define RESOLUTION_R160x120 CAMERA_R160x120 /* QQVGA Resolution */ -#define RESOLUTION_R320x240 CAMERA_R320x240 /* QVGA Resolution */ - -/** - * @} - */ - -/** @defgroup STM324xG_EVAL_CAMERA_Exported_Constants - * @{ - */ -#define CAMERA_I2C_ADDRESS 0x60 -/** - * @} - */ - -/** @defgroup STM324xG_EVAL_CAMERA_Exported_Functions - * @{ - */ -uint8_t BSP_CAMERA_Init(uint32_t Resolution); -void BSP_CAMERA_ContinuousStart(uint8_t *buff); -void BSP_CAMERA_SnapshotStart(uint8_t *buff); -void BSP_CAMERA_Suspend(void); -void BSP_CAMERA_Resume(void); -uint8_t BSP_CAMERA_Stop(void); -void BSP_CAMERA_LineEventCallback(void); -void BSP_CAMERA_VsyncEventCallback(void); -void BSP_CAMERA_FrameEventCallback(void); -void BSP_CAMERA_ErrorCallback(void); - -/* Camera features functions prototype */ -void BSP_CAMERA_ContrastBrightnessConfig(uint32_t contrast_level, uint32_t brightness_level); -void BSP_CAMERA_BlackWhiteConfig(uint32_t Mode); -void BSP_CAMERA_ColorEffectConfig(uint32_t Effect); - -/* To be called in DCMI_IRQHandler function */ -void BSP_CAMERA_IRQHandler(void); -/* To be called in DMA2_Stream1_IRQHandler function */ -void BSP_CAMERA_DMA_IRQHandler(void); - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM324xG_EVAL_CAMERA_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM324xG_EVAL/stm324xg_eval_eeprom.c b/bsp/stm32f411RE/Libraries/BSP/STM324xG_EVAL/stm324xg_eval_eeprom.c deleted file mode 100644 index d5ef05247e..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM324xG_EVAL/stm324xg_eval_eeprom.c +++ /dev/null @@ -1,434 +0,0 @@ -/** - ****************************************************************************** - * @file stm324xg_eval_eeprom.c - * @author MCD Application Team - * @version V2.1.0 - * @date 14-August-2015 - * @brief This file provides a set of functions needed to manage an I2C M24C64 - * EEPROM memory. - * - * =================================================================== - * Notes: - * - This driver is intended for STM32F4xx families devices only. - * - The I2C EEPROM memory (M24C64) is available on STM324xG-EVAL - * - To use this driver you have to connect the eeprom jumper (JP24). - * =================================================================== - * - * It implements a high level communication layer for read and write - * from/to this memory. The needed STM32F4xx hardware resources (I2C and - * GPIO) are defined in stm32f4xg_eval.h file, and the initialization is - * performed in EEPROM_IO_Init() function declared in stm32f4xg_eval.c - * file. - * You can easily tailor this driver to any other development board, - * by just adapting the defines for hardware resources and - * EEPROM_IO_Init() function. - * - * @note In this driver, basic read and write functions (BSP_EEPROM_ReadBuffer() - * and EEPROM_WritePage()) use Polling mode to perform the data transfer - * to/from EEPROM memory. - * - * +-----------------------------------------------------------------+ - * | Pin assignment for M24C64 EEPROM | - * +---------------------------------------+-----------+-------------+ - * | STM32F4xx I2C Pins | EEPROM | Pin | - * +---------------------------------------+-----------+-------------+ - * | . | E0 | 1 (0V) | - * | . | E1 | 2 (0V) | - * | . | E2 | 3 (0V) | - * | . | VSS(GND)| 4 (0V) | - * | SDA | SDA | 5 | - * | SCL | SCL | 6 | - * | JP24 | /WS | 7 | - * | . | VDD | 8 (3.3V) | - * +---------------------------------------+-----------+-------------+ - * - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ -/* Includes ------------------------------------------------------------------*/ -#include "stm324xg_eval_eeprom.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM324xG_EVAL - * @{ - */ - -/** @addtogroup STM324xG_EVAL_EEPROM - * @brief This file includes the I2C EEPROM driver of STM32F4xG-EVAL evaluation board. - * @{ - */ - -/** @defgroup STM32F4xG_EVAL_EEPROM_Private_Types - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F4xG_EVAL_EEPROM_Private_Defines - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F4xG_EVAL_EEPROM_Private_Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F4xG_EVAL_EEPROM_Private_Variables - * @{ - */ -__IO uint32_t EEPROMTimeout = EEPROM_READ_TIMEOUT; -__IO uint16_t EEPROMDataRead; -__IO uint8_t EEPROMDataWrite; -/** - * @} - */ - -/** @defgroup STM32F4xG_EVAL_EEPROM_Private_Function_Prototypes - * @{ - */ -static uint32_t EEPROM_WritePage(uint8_t* pBuffer, uint16_t WriteAddr, uint8_t* NumByteToWrite); -static uint32_t EEPROM_WaitEepromStandbyState(void); -/** - * @} - */ - -/** @defgroup STM32F4xG_EVAL_EEPROM_Private_Functions - * @{ - */ - -/** - * @brief Initializes peripherals used by the I2C EEPROM driver. - * @param None - * @retval EEPROM_OK (0) if operation is correctly performed, else return value - * different from EEPROM_OK (0) - */ -uint32_t BSP_EEPROM_Init(void) -{ - /* I2C Initialization */ - EEPROM_IO_Init(); - - /* Select the EEPROM address and check if OK */ - if(EEPROM_IO_IsDeviceReady(EEPROM_I2C_ADDRESS, EEPROM_MAX_TRIALS) != HAL_OK) - { - return EEPROM_FAIL; - } - return EEPROM_OK; -} - -/** - * @brief Reads a block of data from the EEPROM. - * @param pBuffer: pointer to the buffer that receives the data read from - * the EEPROM. - * @param ReadAddr: EEPROM's internal address to start reading from. - * @param NumByteToRead: pointer to the variable holding number of bytes to - * be read from the EEPROM. - * - * @note The variable pointed by NumByteToRead is reset to 0 when all the - * data are read from the EEPROM. Application should monitor this - * variable in order know when the transfer is complete. - * - * @retval EEPROM_OK (0) if operation is correctly performed, else return value - * different from EEPROM_OK (0) or the timeout user callback. - */ -uint32_t BSP_EEPROM_ReadBuffer(uint8_t* pBuffer, uint16_t ReadAddr, uint16_t* NumByteToRead) -{ - uint32_t buffersize = *NumByteToRead; - - /* Set the pointer to the Number of data to be read */ - EEPROMDataRead = *NumByteToRead; - - if(EEPROM_IO_ReadData(EEPROM_I2C_ADDRESS, ReadAddr, pBuffer, buffersize) != HAL_OK) - { - BSP_EEPROM_TIMEOUT_UserCallback(); - return EEPROM_FAIL; - } - - /* If all operations OK, return EEPROM_OK (0) */ - return EEPROM_OK; -} - -/** - * @brief Writes buffer of data to the I2C EEPROM. - * @param pBuffer: pointer to the buffer containing the data to be written - * to the EEPROM. - * @param WriteAddr: EEPROM's internal address to write to. - * @param NumByteToWrite: number of bytes to write to the EEPROM. - * @retval EEPROM_OK (0) if operation is correctly performed, else return value - * different from EEPROM_OK (0) or the timeout user callback. - */ -uint32_t BSP_EEPROM_WriteBuffer(uint8_t* pBuffer, uint16_t WriteAddr, uint16_t NumByteToWrite) -{ - uint8_t numofpage = 0, numofsingle = 0, count = 0; - uint16_t addr = 0; - uint8_t dataindex = 0; - uint32_t status = EEPROM_OK; - - addr = WriteAddr % EEPROM_PAGESIZE; - count = EEPROM_PAGESIZE - addr; - numofpage = NumByteToWrite / EEPROM_PAGESIZE; - numofsingle = NumByteToWrite % EEPROM_PAGESIZE; - - /* If WriteAddr is EEPROM_PAGESIZE aligned */ - if(addr == 0) - { - /* If NumByteToWrite < EEPROM_PAGESIZE */ - if(numofpage == 0) - { - /* Store the number of data to be written */ - dataindex = numofsingle; - /* Start writing data */ - status = EEPROM_WritePage(pBuffer, WriteAddr, (uint8_t*)(&dataindex)); - if(status != EEPROM_OK) - { - return status; - } - } - /* If NumByteToWrite > EEPROM_PAGESIZE */ - else - { - while(numofpage--) - { - /* Store the number of data to be written */ - dataindex = EEPROM_PAGESIZE; - status = EEPROM_WritePage(pBuffer, WriteAddr, (uint8_t*)(&dataindex)); - if(status != EEPROM_OK) - { - return status; - } - - WriteAddr += EEPROM_PAGESIZE; - pBuffer += EEPROM_PAGESIZE; - } - - if(numofsingle!=0) - { - /* Store the number of data to be written */ - dataindex = numofsingle; - status = EEPROM_WritePage(pBuffer, WriteAddr, (uint8_t*)(&dataindex)); - if(status != EEPROM_OK) - { - return status; - } - } - } - } - /* If WriteAddr is not EEPROM_PAGESIZE aligned */ - else - { - /* If NumByteToWrite < EEPROM_PAGESIZE */ - if(numofpage == 0) - { - /* If the number of data to be written is more than the remaining space - in the current page: */ - if(NumByteToWrite > count) - { - /* Store the number of data to be written */ - dataindex = count; - /* Write the data contained in same page */ - status = EEPROM_WritePage(pBuffer, WriteAddr, (uint8_t*)(&dataindex)); - if(status != EEPROM_OK) - { - return status; - } - - /* Store the number of data to be written */ - dataindex = (NumByteToWrite - count); - /* Write the remaining data in the following page */ - status = EEPROM_WritePage((uint8_t*)(pBuffer + count), (WriteAddr + count), (uint8_t*)(&dataindex)); - if(status != EEPROM_OK) - { - return status; - } - } - else - { - /* Store the number of data to be written */ - dataindex = numofsingle; - status = EEPROM_WritePage(pBuffer, WriteAddr, (uint8_t*)(&dataindex)); - if(status != EEPROM_OK) - { - return status; - } - } - } - /* If NumByteToWrite > EEPROM_PAGESIZE */ - else - { - NumByteToWrite -= count; - numofpage = NumByteToWrite / EEPROM_PAGESIZE; - numofsingle = NumByteToWrite % EEPROM_PAGESIZE; - - if(count != 0) - { - /* Store the number of data to be written */ - dataindex = count; - status = EEPROM_WritePage(pBuffer, WriteAddr, (uint8_t*)(&dataindex)); - if(status != EEPROM_OK) - { - return status; - } - WriteAddr += count; - pBuffer += count; - } - - while(numofpage--) - { - /* Store the number of data to be written */ - dataindex = EEPROM_PAGESIZE; - status = EEPROM_WritePage(pBuffer, WriteAddr, (uint8_t*)(&dataindex)); - if(status != EEPROM_OK) - { - return status; - } - WriteAddr += EEPROM_PAGESIZE; - pBuffer += EEPROM_PAGESIZE; - } - if(numofsingle != 0) - { - /* Store the number of data to be written */ - dataindex = numofsingle; - status = EEPROM_WritePage(pBuffer, WriteAddr, (uint8_t*)(&dataindex)); - if(status != EEPROM_OK) - { - return status; - } - } - } - } - - /* If all operations OK, return EEPROM_OK (0) */ - return EEPROM_OK; -} - -/** - * @brief Writes more than one byte to the EEPROM with a single WRITE cycle. - * - * @note The number of bytes (combined to write start address) must not - * cross the EEPROM page boundary. This function can only write into - * the boundaries of an EEPROM page. - * This function doesn't check on boundaries condition (in this driver - * the function BSP_EEPROM_WriteBuffer() which calls EEPROM_WritePage() is - * responsible of checking on Page boundaries). - * - * @param pBuffer: pointer to the buffer containing the data to be written to - * the EEPROM. - * @param WriteAddr: EEPROM's internal address to write to. - * @param NumByteToWrite: pointer to the variable holding number of bytes to - * be written into the EEPROM. - * - * @note The variable pointed by NumByteToWrite is reset to 0 when all the - * data are written to the EEPROM. Application should monitor this - * variable in order know when the transfer is complete. - * - * @retval EEPROM_OK (0) if operation is correctly performed, else return value - * different from EEPROM_OK (0) or the timeout user callback. - */ -static uint32_t EEPROM_WritePage(uint8_t* pBuffer, uint16_t WriteAddr, uint8_t* NumByteToWrite) -{ - uint32_t buffersize = *NumByteToWrite; - uint32_t status = EEPROM_OK; - - /* Set the pointer to the Number of data to be written */ - EEPROMDataWrite = *NumByteToWrite; - if(EEPROM_IO_WriteData(EEPROM_I2C_ADDRESS, WriteAddr, pBuffer, buffersize) != HAL_OK) - { - BSP_EEPROM_TIMEOUT_UserCallback(); - status = EEPROM_FAIL; - } - - while(EEPROM_WaitEepromStandbyState() != EEPROM_OK) - { - return EEPROM_FAIL; - } - - /* If all operations OK, return EEPROM_OK (0) */ - return status; -} - -/** - * @brief Waits for EEPROM Standby state. - * - * @note This function allows to wait and check that EEPROM has finished the - * last operation. It is mostly used after Write operation: after receiving - * the buffer to be written, the EEPROM may need additional time to actually - * perform the write operation. During this time, it doesn't answer to - * I2C packets addressed to it. Once the write operation is complete - * the EEPROM responds to its address. - * - * @param None - * @retval EEPROM_OK (0) if operation is correctly performed, else return value - * different from EEPROM_OK (0) or the timeout user callback. - */ -static uint32_t EEPROM_WaitEepromStandbyState(void) -{ - /* Check if the maximum allowed number of trials has bee reached */ - if(EEPROM_IO_IsDeviceReady(EEPROM_I2C_ADDRESS, EEPROM_MAX_TRIALS) != HAL_OK) - { - /* If the maximum number of trials has been reached, exit the function */ - BSP_EEPROM_TIMEOUT_UserCallback(); - return EEPROM_TIMEOUT; - } - return EEPROM_OK; -} - -/** - * @brief Basic management of the timeout situation. - * @param None - * @retval None - */ -__weak void BSP_EEPROM_TIMEOUT_UserCallback(void) -{ -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM324xG_EVAL/stm324xg_eval_eeprom.h b/bsp/stm32f411RE/Libraries/BSP/STM324xG_EVAL/stm324xg_eval_eeprom.h deleted file mode 100644 index 6b9ae967b5..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM324xG_EVAL/stm324xg_eval_eeprom.h +++ /dev/null @@ -1,142 +0,0 @@ -/** - ****************************************************************************** - * @file stm324xg_eval_eeprom.h - * @author MCD Application Team - * @version V2.1.0 - * @date 14-August-2015 - * @brief This file contains all the functions prototypes for - * the stm32f4xg_eval_eeprom.c firmware driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32F4xG_EVAL_EEPROM_H -#define __STM32F4xG_EVAL_EEPROM_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm324xg_eval.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM324xG_EVAL - * @{ - */ - -/** @addtogroup STM324xG_EVAL_EEPROM - * @brief This file includes the I2C EEPROM driver of STM32F4xG-EVAL evaluation board. - * @{ - */ - -/** @defgroup STM324xG_EVAL_EEPROM_Exported_Types - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324xG_EVAL_EEPROM_Exported_Constants - * @{ - */ -/* EEPROM hardware address and page size */ -#define EEPROM_PAGESIZE 32 -#define EEPROM_MAX_SIZE 0x2000 /* 64Kbit*/ -/* Maximum Timeout values for flags and events waiting loops: This timeout is based - on systick set to 1ms. - Timeout for read based if read all the EEPROM: EEPROM_MAX_SIZE * BSP_I2C_SPEED (640ms) */ -#define EEPROM_READ_TIMEOUT ((uint32_t)(1000)) -/* Timeout for write based on max write which is EEPROM_PAGESIZE bytes: EEPROM_PAGESIZE * BSP_I2C_SPEED (320us)*/ -#define EEPROM_WRITE_TIMEOUT ((uint32_t)(1000)) - -/* Maximum number of trials for EEPROM_WaitEepromStandbyState() function */ -#define EEPROM_MAX_TRIALS 3000 - -#define EEPROM_OK 0 -#define EEPROM_FAIL 1 -#define EEPROM_TIMEOUT 2 -/** - * @} - */ - -/** @defgroup STM324xG_EVAL_EEPROM_Exported_Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324xG_EVAL_EEPROM_Exported_Functions - * @{ - */ -uint32_t BSP_EEPROM_Init(void); -uint32_t BSP_EEPROM_ReadBuffer(uint8_t *pBuffer, uint16_t ReadAddr, uint16_t *NumByteToRead); -uint32_t BSP_EEPROM_WriteBuffer(uint8_t *pBuffer, uint16_t WriteAddr, uint16_t NumByteToWrite); - -/* USER Callbacks: This function is declared as __weak in EEPROM driver and - should be implemented into user application. - BSP_EEPROM_TIMEOUT_UserCallback() function is called whenever a timeout condition - occurs during communication (waiting on an event that doesn't occur, bus - errors, busy devices ...). */ -void BSP_EEPROM_TIMEOUT_UserCallback(void); - -/* Link function for I2C EEPROM peripheral */ -void EEPROM_IO_Init(void); -HAL_StatusTypeDef EEPROM_IO_WriteData(uint16_t DevAddress, uint16_t MemAddress, uint8_t* pBuffer, uint32_t BufferSize); -HAL_StatusTypeDef EEPROM_IO_ReadData(uint16_t DevAddress, uint16_t MemAddress, uint8_t* pBuffer, uint32_t BufferSize); -HAL_StatusTypeDef EEPROM_IO_IsDeviceReady(uint16_t DevAddress, uint32_t Trials); - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32F4xG_EVAL_EEPROM_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM324xG_EVAL/stm324xg_eval_io.c b/bsp/stm32f411RE/Libraries/BSP/STM324xG_EVAL/stm324xg_eval_io.c deleted file mode 100644 index 75c4013d59..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM324xG_EVAL/stm324xg_eval_io.c +++ /dev/null @@ -1,260 +0,0 @@ -/** - ****************************************************************************** - * @file stm324xg_eval_io.c - * @author MCD Application Team - * @version V2.1.0 - * @date 14-August-2015 - * @brief This file provides a set of functions needed to manage the IO pins - * on STM324xG-EVAL evaluation board. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* File Info : ----------------------------------------------------------------- - User NOTES -1. How To use this driver: --------------------------- - - This driver is used to drive the IO module of the STM324xG-EVAL evaluation - board. - - The STMPE811 IO expander device component driver must be included with this - driver in order to run the IO functionalities commanded by the IO expander - device mounted on the evaluation board. - -2. Driver description: ---------------------- - + Initialization steps: - o Initialize the IO module using the BSP_IO_Init() function. This - function includes the MSP layer hardware resources initialization and the - communication layer configuration to start the IO functionalities use. - - + IO functionalities use - o The IO pin mode is configured when calling the function BSP_IO_ConfigPin(), you - must specify the desired IO mode by choosing the "IO_ModeTypedef" parameter - predefined value. - o If an IO pin is used in interrupt mode, the function BSP_IO_ITGetStatus() is - needed to get the interrupt status. To clear the IT pending bits, you should - call the function BSP_IO_ITClear() with specifying the IO pending bit to clear. - o The IT is handled using the corresponding external interrupt IRQ handler, - the user IT callback treatment is implemented on the same external interrupt - callback. - o To get/set an IO pin combination state you can use the functions - BSP_IO_ReadPin()/BSP_IO_WritePin() or the function BSP_IO_TogglePin() to toggle the pin - state. - -------------------------------------------------------------------------------*/ - -/* Includes ------------------------------------------------------------------*/ -#include "stm324xg_eval_io.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM324xG_EVAL - * @{ - */ - -/** @defgroup STM324xG_EVAL_IO - * @{ - */ - -/** @defgroup STM324xG_EVAL_IO_Private_Types_Definitions - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324xG_EVAL_IO_Private_Defines - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324xG_EVAL_IO_Private_Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324xG_EVAL_IO_Private_Variables - * @{ - */ -static IO_DrvTypeDef *io_driver; -/** - * @} - */ - -/** @defgroup STM324xG_EVAL_IO_Private_Function_Prototypes - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324xG_EVAL_IO_Private_Functions - * @{ - */ - -/** - * @brief Initializes and configures the IO functionalities and configures all - * necessary hardware resources (GPIOs, clocks..). - * @note BSP_IO_Init() is using HAL_Delay() function to ensure that stmpe811 - * IO Expander is correctly reset. HAL_Delay() function provides accurate - * delay (in milliseconds) based on variable incremented in SysTick ISR. - * This implies that if BSP_IO_Init() is called from a peripheral ISR process, - * then the SysTick interrupt must have higher priority (numerically lower) - * than the peripheral interrupt. Otherwise the caller ISR process will be blocked. - * @param None - * @retval IO_OK: if all initializations are OK. Other value if error. - */ -uint8_t BSP_IO_Init(void) -{ - uint8_t ret = IO_ERROR; - - if(stmpe811_io_drv.ReadID(IO_I2C_ADDRESS) == STMPE811_ID) - { - /* Initialize the IO driver structure */ - io_driver = &stmpe811_io_drv; - - io_driver->Init(IO_I2C_ADDRESS); - io_driver->Start(IO_I2C_ADDRESS, IO_PIN_ALL); - - ret = IO_OK; - } - - return ret; -} - -/** - * @brief Gets the selected pins IT status. - * @param: IO_Pin: Selected pins to check the status. - * This parameter can be any combination of the IO pins. - * @retval IO_OK: if read status OK. Other value if error. - */ -uint8_t BSP_IO_ITGetStatus(uint16_t IO_Pin) -{ - /* Return the IO Pin IT status */ - return (io_driver->ITStatus(IO_I2C_ADDRESS, IO_Pin)); -} - -/** - * @brief Clears the selected IO IT pending bit. - * @param: IO_Pin: Selected pins to check the status. - * This parameter can be any combination of the IO pins. - * @retval None - */ -void BSP_IO_ITClear(uint16_t IO_Pin) -{ - io_driver->ClearIT(IO_I2C_ADDRESS, IO_Pin); -} - -/** - * @brief Configures the IO pin(s) according to IO mode structure value. - * @param IO_Pin: Output pin to be set or reset. - * This parameter can be one of the following values: - * @arg STMPE811_PIN_x: where x can be from 0 to 7 - * @param IO_Mode: IO pin mode to configure - * This parameter can be one of the following values: - * @arg IO_MODE_INPUT - * @arg IO_MODE_OUTPUT - * @arg IO_MODE_IT_RISING_EDGE - * @arg IO_MODE_IT_FALLING_EDGE - * @arg IO_MODE_IT_LOW_LEVEL - * @arg IO_MODE_IT_HIGH_LEVEL - * @retval IO_OK: if all initializations are OK. Other value if error. - */ -uint8_t BSP_IO_ConfigPin(uint16_t IO_Pin, IO_ModeTypedef IO_Mode) -{ - /* Configure the selected IO pin(s) mode */ - io_driver->Config(IO_I2C_ADDRESS, IO_Pin, IO_Mode); - - return IO_OK; -} - -/** - * @brief Sets the selected pins state. - * @param: IO_Pin: Selected pins to write. - * This parameter can be any combination of the IO pins. - * @param: PinState: New pins state to write - * @retval None - */ -void BSP_IO_WritePin(uint16_t IO_Pin, uint8_t PinState) -{ - io_driver->WritePin(IO_I2C_ADDRESS, IO_Pin, PinState); -} - -/** - * @brief Gets the selected pins current state. - * @param: IO_Pin: Selected pins to read. - * This parameter can be any combination of the IO pins. - * @retval The current pins state - */ -uint16_t BSP_IO_ReadPin(uint16_t IO_Pin) -{ - return(io_driver->ReadPin(IO_I2C_ADDRESS, IO_Pin)); -} - -/** - * @brief Toggles the selected pins state - * @param: IO_Pin: Selected pins to toggle. - * This parameter can be any combination of the IO pins. - * @retval None - */ -void BSP_IO_TogglePin(uint16_t IO_Pin) -{ - if(io_driver->ReadPin(IO_I2C_ADDRESS, IO_Pin) == 1) /* Set */ - { - io_driver->WritePin(IO_I2C_ADDRESS, IO_Pin, 0); /* Reset */ - } - else - { - io_driver->WritePin(IO_I2C_ADDRESS, IO_Pin, 1); /* Set */ - } -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM324xG_EVAL/stm324xg_eval_io.h b/bsp/stm32f411RE/Libraries/BSP/STM324xG_EVAL/stm324xg_eval_io.h deleted file mode 100644 index dffdcb7047..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM324xG_EVAL/stm324xg_eval_io.h +++ /dev/null @@ -1,133 +0,0 @@ -/** - ****************************************************************************** - * @file stm324xg_eval_io.h - * @author MCD Application Team - * @version V2.1.0 - * @date 14-August-2015 - * @brief This file contains the common defines and functions prototypes for - * the stm324xg_eval_io.c driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM324xG_EVAL_IO_H -#define __STM324xG_EVAL_IO_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm324xg_eval.h" -/* Include IO component driver */ -#include "../Components/stmpe811/stmpe811.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM324xG_EVAL - * @{ - */ - -/** @defgroup STM324xG_EVAL_IO - * @{ - */ - -/** @defgroup STM324xG_EVAL_IO_Exported_Types - * @{ - */ -typedef enum -{ - IO_OK = 0x00, - IO_ERROR = 0x01, - IO_TIMEOUT = 0x02 -}IO_StatusTypeDef; -/** - * @} - */ - -/** @defgroup STM324xG_EVAL_IO_Exported_Constants - * @{ - */ -#define IO_PIN_0 0x01 -#define IO_PIN_1 0x02 -#define IO_PIN_2 0x04 -#define IO_PIN_3 0x08 -#define IO_PIN_4 0x10 -#define IO_PIN_5 0x20 -#define IO_PIN_6 0x40 -#define IO_PIN_7 0x80 -#define IO_PIN_ALL 0xFF -/** - * @} - */ - -/** @defgroup STM324xG_EVAL_IO_Exported_Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324xG_EVAL_IO_Exported_Functions - * @{ - */ -uint8_t BSP_IO_Init(void); -void BSP_IO_ITClear(uint16_t IO_Pin); -uint8_t BSP_IO_ITGetStatus(uint16_t IO_Pin); -uint8_t BSP_IO_ConfigPin(uint16_t IO_Pin, IO_ModeTypedef IO_Mode); -void BSP_IO_WritePin(uint16_t IO_Pin, uint8_t PinState); -uint16_t BSP_IO_ReadPin(uint16_t IO_Pin); -void BSP_IO_TogglePin(uint16_t IO_Pin); - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM324xG_EVAL_IO_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM324xG_EVAL/stm324xg_eval_lcd.c b/bsp/stm32f411RE/Libraries/BSP/STM324xG_EVAL/stm324xg_eval_lcd.c deleted file mode 100644 index 96ae33c9b6..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM324xG_EVAL/stm324xg_eval_lcd.c +++ /dev/null @@ -1,1069 +0,0 @@ -/** - ****************************************************************************** - * @file stm324xg_eval_lcd.c - * @author MCD Application Team - * @version V2.1.0 - * @date 14-August-2015 - * @brief This file includes the driver for Liquid Crystal Display (LCD) module - * mounted on STM324xG-EVAL evaluation board. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* File Info : ----------------------------------------------------------------- - User NOTES -1. How To use this driver: --------------------------- - - This driver is used to drive indirectly an LCD TFT. - - This driver supports the ILI9325 LCD mounted on MB785 daughter board - - The ILI9325 component driver MUST be included with this driver. - -2. Driver description: ---------------------- - + Initialization steps: - o Initialize the LCD using the BSP_LCD_Init() function. - - + Display on LCD - o Clear the hole LCD using yhe BSP_LCD_Clear() function or only one specified - string line using the BSP_LCD_ClearStringLine() function. - o Display a character on the specified line and column using the BSP_LCD_DisplayChar() - function or a complete string line using the BSP_LCD_DisplayStringAtLine() function. - o Display a string line on the specified position (x,y in pixel) and align mode - using the BSP_LCD_DisplayStringAtLine() function. - o Draw and fill basic shapes (dot, line, rectangle, circle, ellipse, .. bitmap, raw picture) - on LCD using a set of functions. - -------------------------------------------------------------------------------*/ - -/* Includes ------------------------------------------------------------------*/ -#include "stm324xg_eval_lcd.h" -#include "../../../Utilities/Fonts/fonts.h" -#include "../../../Utilities/Fonts/font24.c" -#include "../../../Utilities/Fonts/font20.c" -#include "../../../Utilities/Fonts/font16.c" -#include "../../../Utilities/Fonts/font12.c" -#include "../../../Utilities/Fonts/font8.c" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM324xG_EVAL - * @{ - */ - -/** @addtogroup STM324xG_EVAL_LCD - * @{ - */ - -/** @defgroup STM324xG_EVAL_LCD_Private_TypesDefinitions - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324xG_EVAL_LCD_Private_Defines - * @{ - */ -#define POLY_X(Z) ((int32_t)((Points + (Z))->X)) -#define POLY_Y(Z) ((int32_t)((Points + (Z))->Y)) -/** - * @} - */ - -/** @defgroup STM324xG_EVAL_LCD_Private_Macros - * @{ - */ -#define ABS(X) ((X) > 0 ? (X) : -(X)) -/** - * @} - */ - -/** @defgroup STM324xG_EVAL_LCD_Private_Variables - * @{ - */ -LCD_DrawPropTypeDef DrawProp; -static LCD_DrvTypeDef *lcd_drv; -/** - * @} - */ - -/** @defgroup STM324xG_EVAL_LCD_Private_FunctionPrototypes - * @{ - */ -static void DrawChar(uint16_t Xpos, uint16_t Ypos, const uint8_t *c); -static void SetDisplayWindow(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height); -static void FillTriangle(uint16_t x1, uint16_t x2, uint16_t x3, uint16_t y1, uint16_t y2, uint16_t y3); -/** - * @} - */ - -/** @defgroup STM324xG_EVAL_LCD_Private_Functions - * @{ - */ - -/** - * @brief Initializes the LCD. - * @param None - * @retval LCD state - */ -uint8_t BSP_LCD_Init(void) -{ - uint8_t ret = LCD_ERROR; - - /* Default value for draw propriety */ - DrawProp.BackColor = 0xFFFF; - DrawProp.pFont = &Font24; - DrawProp.TextColor = 0x0000; - - if(ili9325_drv.ReadID() == ILI9325_ID) - { - lcd_drv = &ili9325_drv; - - /* LCD Init */ - lcd_drv->Init(); - - /* Initialize the font */ - BSP_LCD_SetFont(&LCD_DEFAULT_FONT); - - ret = LCD_OK; - } - - return ret; -} - -/** - * @brief Gets the LCD X size. - * @param None - * @retval Used LCD X size - */ -uint32_t BSP_LCD_GetXSize(void) -{ - return(lcd_drv->GetLcdPixelWidth()); -} - -/** - * @brief Gets the LCD Y size. - * @param None - * @retval Used LCD Y size - */ -uint32_t BSP_LCD_GetYSize(void) -{ - return(lcd_drv->GetLcdPixelHeight()); -} - -/** - * @brief Gets the LCD text color. - * @param None - * @retval Used text color. - */ -uint16_t BSP_LCD_GetTextColor(void) -{ - return DrawProp.TextColor; -} - -/** - * @brief Gets the LCD background color. - * @param None - * @retval Used background color - */ -uint16_t BSP_LCD_GetBackColor(void) -{ - return DrawProp.BackColor; -} - -/** - * @brief Sets the LCD text color. - * @param Color: Text color code RGB(5-6-5) - * @retval None - */ -void BSP_LCD_SetTextColor(uint16_t Color) -{ - DrawProp.TextColor = Color; -} - -/** - * @brief Sets the LCD background color. - * @param Color: Background color code RGB(5-6-5) - * @retval None - */ -void BSP_LCD_SetBackColor(uint16_t Color) -{ - DrawProp.BackColor = Color; -} - -/** - * @brief Sets the LCD text font. - * @param fonts: Font to be used - * @retval None - */ -void BSP_LCD_SetFont(sFONT *fonts) -{ - DrawProp.pFont = fonts; -} - -/** - * @brief Gets the LCD text font. - * @param None - * @retval Used font - */ -sFONT *BSP_LCD_GetFont(void) -{ - return DrawProp.pFont; -} - -/** - * @brief Clears the hole LCD. - * @param Color: Color of the background - * @retval None - */ -void BSP_LCD_Clear(uint16_t Color) -{ - uint32_t counter = 0; - uint32_t color_backup = DrawProp.TextColor; - DrawProp.TextColor = Color; - - for(counter = 0; counter < BSP_LCD_GetYSize(); counter++) - { - BSP_LCD_DrawHLine(0, counter, BSP_LCD_GetXSize()); - } - DrawProp.TextColor = color_backup; - BSP_LCD_SetTextColor(DrawProp.TextColor); -} - -/** - * @brief Clears the selected line. - * @param Line: Line to be cleared - * This parameter can be one of the following values: - * @arg 0..9: if the Current fonts is Font16x24 - * @arg 0..19: if the Current fonts is Font12x12 or Font8x12 - * @arg 0..29: if the Current fonts is Font8x8 - * @retval None - */ -void BSP_LCD_ClearStringLine(uint16_t Line) -{ - uint32_t color_backup = DrawProp.TextColor; - DrawProp.TextColor = DrawProp.BackColor;; - - /* Draw a rectangle with background color */ - BSP_LCD_FillRect(0, (Line * DrawProp.pFont->Height), BSP_LCD_GetXSize(), DrawProp.pFont->Height); - - DrawProp.TextColor = color_backup; - BSP_LCD_SetTextColor(DrawProp.TextColor); -} - -/** - * @brief Displays one character. - * @param Xpos: Start column address - * @param Ypos: Line where to display the character shape. - * @param Ascii: Character ascii code - * This parameter must be a number between Min_Data = 0x20 and Max_Data = 0x7E - * @retval None - */ -void BSP_LCD_DisplayChar(uint16_t Xpos, uint16_t Ypos, uint8_t Ascii) -{ - DrawChar(Xpos, Ypos, &DrawProp.pFont->table[(Ascii-' ') *\ - DrawProp.pFont->Height * ((DrawProp.pFont->Width + 7) / 8)]); -} - -/** - * @brief Displays characters on the LCD. - * @param Xpos: X position (in pixel) - * @param Ypos: Y position (in pixel) - * @param Text: Pointer to string to display on LCD - * @param Mode: Display mode - * This parameter can be one of the following values: - * @arg CENTER_MODE - * @arg RIGHT_MODE - * @arg LEFT_MODE - * @retval None - */ -void BSP_LCD_DisplayStringAt(uint16_t Xpos, uint16_t Ypos, uint8_t *Text, Line_ModeTypdef Mode) -{ - uint16_t refcolumn = 1, i = 0; - uint32_t size = 0, xsize = 0; - uint8_t *ptr = Text; - - /* Get the text size */ - while (*ptr++) size ++ ; - - /* Characters number per line */ - xsize = (BSP_LCD_GetXSize()/DrawProp.pFont->Width); - - switch (Mode) - { - case CENTER_MODE: - { - refcolumn = Xpos + ((xsize - size)* DrawProp.pFont->Width) / 2; - break; - } - case LEFT_MODE: - { - refcolumn = Xpos; - break; - } - case RIGHT_MODE: - { - refcolumn = - Xpos + ((xsize - size)*DrawProp.pFont->Width); - break; - } - default: - { - refcolumn = Xpos; - break; - } - } - - /* Send the string character by character on lCD */ - while ((*Text != 0) & (((BSP_LCD_GetXSize() - (i*DrawProp.pFont->Width)) & 0xFFFF) >= DrawProp.pFont->Width)) - { - /* Display one character on LCD */ - BSP_LCD_DisplayChar(refcolumn, Ypos, *Text); - /* Decrement the column position by 16 */ - refcolumn += DrawProp.pFont->Width; - /* Point on the next character */ - Text++; - i++; - } -} - -/** - * @brief Displays a character on the LCD. - * @param Line: Line where to display the character shape - * This parameter can be one of the following values: - * @arg 0..9: if the Current fonts is Font16x24 - * @arg 0..19: if the Current fonts is Font12x12 or Font8x12 - * @arg 0..29: if the Current fonts is Font8x8 - * @param ptr: Pointer to string to display on LCD - * @retval None - */ -void BSP_LCD_DisplayStringAtLine(uint16_t Line, uint8_t *ptr) -{ - BSP_LCD_DisplayStringAt(0, LINE(Line), ptr, LEFT_MODE); -} - -/** - * @brief Reads an LCD pixel. - * @param Xpos: X position - * @param Ypos: Y position - * @retval RGB pixel color - */ -uint16_t BSP_LCD_ReadPixel(uint16_t Xpos, uint16_t Ypos) -{ - uint16_t ret = 0; - - if(lcd_drv->ReadPixel != NULL) - { - ret = lcd_drv->ReadPixel(Xpos, Ypos); - } - - return ret; -} - -/** - * @brief Draws a pixel on LCD. - * @param Xpos: X position - * @param Ypos: Y position - * @param RGB_Code: Pixel color in RGB mode (5-6-5) - * @retval None - */ -void BSP_LCD_DrawPixel(uint16_t Xpos, uint16_t Ypos, uint16_t RGB_Code) -{ - if(lcd_drv->WritePixel != NULL) - { - lcd_drv->WritePixel(Xpos, Ypos, RGB_Code); - } -} - -/** - * @brief Draws an horizontal line. - * @param Xpos: X position - * @param Ypos: Y position - * @param Length: Line length - * @retval None - */ -void BSP_LCD_DrawHLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length) -{ - uint32_t index = 0; - - if(lcd_drv->DrawHLine != NULL) - { - lcd_drv->DrawHLine(DrawProp.TextColor, Xpos, Ypos, Length); - } - else - { - for(index = 0; index < Length; index++) - { - BSP_LCD_DrawPixel((Xpos + index), Ypos, DrawProp.TextColor); - } - } -} - -/** - * @brief Draws a vertical line. - * @param Xpos: X position - * @param Ypos: Y position - * @param Length: Line length - * @retval None - */ -void BSP_LCD_DrawVLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length) -{ - uint32_t index = 0; - - if(lcd_drv->DrawVLine != NULL) - { - lcd_drv->DrawVLine(DrawProp.TextColor, Xpos, Ypos, Length); - } - else - { - for(index = 0; index < Length; index++) - { - BSP_LCD_DrawPixel(Xpos, Ypos + index, DrawProp.TextColor); - } - } -} - -/** - * @brief Draws an uni-line (between two points). - * @param x1: Point 1 X position - * @param y1: Point 1 Y position - * @param x2: Point 2 X position - * @param y2: Point 2 Y position - * @retval None - */ -void BSP_LCD_DrawLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) -{ - int16_t deltax = 0, deltay = 0, x = 0, y = 0, xinc1 = 0, xinc2 = 0, - yinc1 = 0, yinc2 = 0, den = 0, num = 0, numadd = 0, numpixels = 0, - curpixel = 0; - - deltax = ABS(x2 - x1); /* The difference between the x's */ - deltay = ABS(y2 - y1); /* The difference between the y's */ - x = x1; /* Start x off at the first pixel */ - y = y1; /* Start y off at the first pixel */ - - if (x2 >= x1) /* The x-values are increasing */ - { - xinc1 = 1; - xinc2 = 1; - } - else /* The x-values are decreasing */ - { - xinc1 = -1; - xinc2 = -1; - } - - if (y2 >= y1) /* The y-values are increasing */ - { - yinc1 = 1; - yinc2 = 1; - } - else /* The y-values are decreasing */ - { - yinc1 = -1; - yinc2 = -1; - } - - if (deltax >= deltay) /* There is at least one x-value for every y-value */ - { - xinc1 = 0; /* Don't change the x when numerator >= denominator */ - yinc2 = 0; /* Don't change the y for every iteration */ - den = deltax; - num = deltax / 2; - numadd = deltay; - numpixels = deltax; /* There are more x-values than y-values */ - } - else /* There is at least one y-value for every x-value */ - { - xinc2 = 0; /* Don't change the x for every iteration */ - yinc1 = 0; /* Don't change the y when numerator >= denominator */ - den = deltay; - num = deltay / 2; - numadd = deltax; - numpixels = deltay; /* There are more y-values than x-values */ - } - - for (curpixel = 0; curpixel <= numpixels; curpixel++) - { - BSP_LCD_DrawPixel(x, y, DrawProp.TextColor); /* Draw the current pixel */ - num += numadd; /* Increase the numerator by the top of the fraction */ - if (num >= den) /* Check if numerator >= denominator */ - { - num -= den; /* Calculate the new numerator value */ - x += xinc1; /* Change the x as appropriate */ - y += yinc1; /* Change the y as appropriate */ - } - x += xinc2; /* Change the x as appropriate */ - y += yinc2; /* Change the y as appropriate */ - } -} - -/** - * @brief Draws a rectangle. - * @param Xpos: X position - * @param Ypos: Y position - * @param Width: Rectangle width - * @param Height: Rectangle height - * @retval None - */ -void BSP_LCD_DrawRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height) -{ - /* Draw horizontal lines */ - BSP_LCD_DrawHLine(Xpos, Ypos, Width); - BSP_LCD_DrawHLine(Xpos, (Ypos+ Height), Width); - - /* Draw vertical lines */ - BSP_LCD_DrawVLine(Xpos, Ypos, Height); - BSP_LCD_DrawVLine((Xpos + Width), Ypos, Height); -} - -/** - * @brief Draws a circle. - * @param Xpos: X position - * @param Ypos: Y position - * @param Radius: Circle radius - * @retval None - */ -void BSP_LCD_DrawCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius) -{ - int32_t D; /* Decision Variable */ - uint32_t CurX; /* Current X Value */ - uint32_t CurY; /* Current Y Value */ - - D = 3 - (Radius << 1); - CurX = 0; - CurY = Radius; - - while (CurX <= CurY) - { - BSP_LCD_DrawPixel((Xpos + CurX), (Ypos - CurY), DrawProp.TextColor); - - BSP_LCD_DrawPixel((Xpos - CurX), (Ypos - CurY), DrawProp.TextColor); - - BSP_LCD_DrawPixel((Xpos + CurY), (Ypos - CurX), DrawProp.TextColor); - - BSP_LCD_DrawPixel((Xpos - CurY), (Ypos - CurX), DrawProp.TextColor); - - BSP_LCD_DrawPixel((Xpos + CurX), (Ypos + CurY), DrawProp.TextColor); - - BSP_LCD_DrawPixel((Xpos - CurX), (Ypos + CurY), DrawProp.TextColor); - - BSP_LCD_DrawPixel((Xpos + CurY), (Ypos + CurX), DrawProp.TextColor); - - BSP_LCD_DrawPixel((Xpos - CurY), (Ypos + CurX), DrawProp.TextColor); - - /* Initialize the font */ - BSP_LCD_SetFont(&LCD_DEFAULT_FONT); - - if (D < 0) - { - D += (CurX << 2) + 6; - } - else - { - D += ((CurX - CurY) << 2) + 10; - CurY--; - } - CurX++; - } -} - -/** - * @brief Draws an poly-line (between many points). - * @param Points: Pointer to the points array - * @param PointCount: Number of points - * @retval None - */ -void BSP_LCD_DrawPolygon(pPoint Points, uint16_t PointCount) -{ - int16_t X = 0, Y = 0; - - if(PointCount < 2) - { - return; - } - - BSP_LCD_DrawLine(Points->X, Points->Y, (Points+PointCount-1)->X, (Points+PointCount-1)->Y); - - while(--PointCount) - { - X = Points->X; - Y = Points->Y; - Points++; - BSP_LCD_DrawLine(X, Y, Points->X, Points->Y); - } - -} - -/** - * @brief Draws an ellipse on LCD. - * @param Xpos: X position - * @param Ypos: Y position - * @param XRadius: Ellipse X radius - * @param YRadius: Ellipse Y radius - * @retval None - */ -void BSP_LCD_DrawEllipse(int Xpos, int Ypos, int XRadius, int YRadius) -{ - int x = 0, y = -YRadius, err = 2-2*XRadius, e2; - float K = 0, rad1 = 0, rad2 = 0; - - rad1 = XRadius; - rad2 = YRadius; - - K = (float)(rad2/rad1); - - do { - BSP_LCD_DrawPixel((Xpos-(uint16_t)(x/K)), (Ypos+y), DrawProp.TextColor); - BSP_LCD_DrawPixel((Xpos+(uint16_t)(x/K)), (Ypos+y), DrawProp.TextColor); - BSP_LCD_DrawPixel((Xpos+(uint16_t)(x/K)), (Ypos-y), DrawProp.TextColor); - BSP_LCD_DrawPixel((Xpos-(uint16_t)(x/K)), (Ypos-y), DrawProp.TextColor); - - e2 = err; - if (e2 <= x) { - err += ++x*2+1; - if (-y == x && e2 <= y) e2 = 0; - } - if (e2 > y) err += ++y*2+1; - } - while (y <= 0); -} - -/** - * @brief Draws a bitmap picture (16 bpp). - * @param Xpos: Bmp X position in the LCD - * @param Ypos: Bmp Y position in the LCD - * @param pbmp: Pointer to Bmp picture address. - * @retval None - */ -void BSP_LCD_DrawBitmap(uint16_t Xpos, uint16_t Ypos, uint8_t *pbmp) -{ - uint32_t height = 0; - uint32_t width = 0; - - - /* Read bitmap width */ - width = *(uint16_t *) (pbmp + 18); - width |= (*(uint16_t *) (pbmp + 20)) << 16; - - /* Read bitmap height */ - height = *(uint16_t *) (pbmp + 22); - height |= (*(uint16_t *) (pbmp + 24)) << 16; - - SetDisplayWindow(Xpos, Ypos, width, height); - - if(lcd_drv->DrawBitmap != NULL) - { - lcd_drv->DrawBitmap(Xpos, Ypos, pbmp); - } - SetDisplayWindow(0, 0, BSP_LCD_GetXSize(), BSP_LCD_GetYSize()); -} - -/** - * @brief Draws RGB Image (16 bpp). - * @param Xpos: X position in the LCD - * @param Ypos: Y position in the LCD - * @param Xsize: X size in the LCD - * @param Ysize: Y size in the LCD - * @param pdata: Pointer to the RGB Image address. - * @retval None - */ -void BSP_LCD_DrawRGBImage(uint16_t Xpos, uint16_t Ypos, uint16_t Xsize, uint16_t Ysize, uint8_t *pdata) -{ - - SetDisplayWindow(Xpos, Ypos, Xsize, Ysize); - - if(lcd_drv->DrawRGBImage != NULL) - { - lcd_drv->DrawRGBImage(Xpos, Ypos, Xsize, Ysize, pdata); - } - SetDisplayWindow(0, 0, BSP_LCD_GetXSize(), BSP_LCD_GetYSize()); -} - -/** - * @brief Draws a full rectangle. - * @param Xpos: X position - * @param Ypos: Y position - * @param Width: Rectangle width - * @param Height: Rectangle height - * @retval None - */ -void BSP_LCD_FillRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height) -{ - BSP_LCD_SetTextColor(DrawProp.TextColor); - do - { - BSP_LCD_DrawHLine(Xpos, Ypos++, Width); - } - while(Height--); -} - -/** - * @brief Draws a full circle. - * @param Xpos: X position - * @param Ypos: Y position - * @param Radius: Circle radius - * @retval None - */ -void BSP_LCD_FillCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius) -{ - int32_t D; /* Decision Variable */ - uint32_t CurX; /* Current X Value */ - uint32_t CurY; /* Current Y Value */ - - D = 3 - (Radius << 1); - - CurX = 0; - CurY = Radius; - - BSP_LCD_SetTextColor(DrawProp.TextColor); - - while (CurX <= CurY) - { - if(CurY > 0) - { - BSP_LCD_DrawHLine(Xpos - CurY, Ypos + CurX, 2*CurY); - BSP_LCD_DrawHLine(Xpos - CurY, Ypos - CurX, 2*CurY); - } - - if(CurX > 0) - { - BSP_LCD_DrawHLine(Xpos - CurX, Ypos - CurY, 2*CurX); - BSP_LCD_DrawHLine(Xpos - CurX, Ypos + CurY, 2*CurX); - } - if (D < 0) - { - D += (CurX << 2) + 6; - } - else - { - D += ((CurX - CurY) << 2) + 10; - CurY--; - } - CurX++; - } - - BSP_LCD_SetTextColor(DrawProp.TextColor); - BSP_LCD_DrawCircle(Xpos, Ypos, Radius); -} - -/** - * @brief Draws a full poly-line (between many points). - * @param Points: Pointer to the points array - * @param PointCount: Number of points - * @retval None - */ -void BSP_LCD_FillPolygon(pPoint Points, uint16_t PointCount) -{ - - int16_t X = 0, Y = 0, X2 = 0, Y2 = 0, X_center = 0, Y_center = 0, X_first = 0, Y_first = 0, pixelX = 0, pixelY = 0, counter = 0; - uint16_t IMAGE_LEFT = 0, IMAGE_RIGHT = 0, IMAGE_TOP = 0, IMAGE_BOTTOM = 0; - - IMAGE_LEFT = IMAGE_RIGHT = Points->X; - IMAGE_TOP= IMAGE_BOTTOM = Points->Y; - - for(counter = 1; counter < PointCount; counter++) - { - pixelX = POLY_X(counter); - if(pixelX < IMAGE_LEFT) - { - IMAGE_LEFT = pixelX; - } - if(pixelX > IMAGE_RIGHT) - { - IMAGE_RIGHT = pixelX; - } - - pixelY = POLY_Y(counter); - if(pixelY < IMAGE_TOP) - { - IMAGE_TOP = pixelY; - } - if(pixelY > IMAGE_BOTTOM) - { - IMAGE_BOTTOM = pixelY; - } - } - - if(PointCount < 2) - { - return; - } - - X_center = (IMAGE_LEFT + IMAGE_RIGHT)/2; - Y_center = (IMAGE_BOTTOM + IMAGE_TOP)/2; - - X_first = Points->X; - Y_first = Points->Y; - - while(--PointCount) - { - X = Points->X; - Y = Points->Y; - Points++; - X2 = Points->X; - Y2 = Points->Y; - - FillTriangle(X, X2, X_center, Y, Y2, Y_center); - FillTriangle(X, X_center, X2, Y, Y_center, Y2); - FillTriangle(X_center, X2, X, Y_center, Y2, Y); - } - - FillTriangle(X_first, X2, X_center, Y_first, Y2, Y_center); - FillTriangle(X_first, X_center, X2, Y_first, Y_center, Y2); - FillTriangle(X_center, X2, X_first, Y_center, Y2, Y_first); -} - -/** - * @brief Draws a full ellipse. - * @param Xpos: X position - * @param Ypos: Y position - * @param XRadius: Ellipse X radius - * @param YRadius: Ellipse Y radius - * @retval None - */ -void BSP_LCD_FillEllipse(int Xpos, int Ypos, int XRadius, int YRadius) -{ - int x = 0, y = -YRadius, err = 2-2*XRadius, e2; - float K = 0, rad1 = 0, rad2 = 0; - - rad1 = XRadius; - rad2 = YRadius; - - K = (float)(rad2/rad1); - - do - { - BSP_LCD_DrawHLine((Xpos-(uint16_t)(x/K)), (Ypos+y), (2*(uint16_t)(x/K) + 1)); - BSP_LCD_DrawHLine((Xpos-(uint16_t)(x/K)), (Ypos-y), (2*(uint16_t)(x/K) + 1)); - - e2 = err; - if (e2 <= x) - { - err += ++x*2+1; - if (-y == x && e2 <= y) e2 = 0; - } - if (e2 > y) err += ++y*2+1; - } - while (y <= 0); -} - -/** - * @brief Enables the display. - * @param None - * @retval None - */ -void BSP_LCD_DisplayOn(void) -{ - lcd_drv->DisplayOn(); -} - -/** - * @brief Disables the display. - * @param None - * @retval None - */ -void BSP_LCD_DisplayOff(void) -{ - lcd_drv->DisplayOff(); -} - -/****************************************************************************** - Static Function -*******************************************************************************/ - -/** - * @brief Draws a character on LCD. - * @param Xpos: Line where to display the character shape - * @param Ypos: Start column address - * @param c: Pointer to the character data - * @retval None - */ -static void DrawChar(uint16_t Xpos, uint16_t Ypos, const uint8_t *c) -{ - uint32_t i = 0, j = 0; - uint16_t height, width; - uint8_t offset; - uint8_t *pchar; - uint32_t line; - - height = DrawProp.pFont->Height; - width = DrawProp.pFont->Width; - - offset = 8 *((width + 7)/8) - width ; - - for(i = 0; i < height; i++) - { - pchar = ((uint8_t *)c + (width + 7)/8 * i); - - switch(((width + 7)/8)) - { - case 1: - line = pchar[0]; - break; - - case 2: - line = (pchar[0]<< 8) | pchar[1]; - break; - - case 3: - default: - line = (pchar[0]<< 16) | (pchar[1]<< 8) | pchar[2]; - break; - } - - for (j = 0; j < width; j++) - { - if(line & (1 << (width- j + offset- 1))) - { - BSP_LCD_DrawPixel((Xpos + j), Ypos, DrawProp.TextColor); - } - else - { - BSP_LCD_DrawPixel((Xpos + j), Ypos, DrawProp.BackColor); - } - } - Ypos++; - } -} - -/** - * @brief Sets display window. - * @param LayerIndex: layer index - * @param Xpos: LCD X position - * @param Ypos: LCD Y position - * @param Width: LCD window width - * @param Height: LCD window height - * @retval None - */ -static void SetDisplayWindow(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height) -{ - if(lcd_drv->SetDisplayWindow != NULL) - { - lcd_drv->SetDisplayWindow(Xpos, Ypos, Width, Height); - } -} - -/** - * @brief Fills a triangle (between 3 points). - * @param Points: Pointer to the points array - * @param x1: Point 1 X position - * @param y1: Point 1 Y position - * @param x2: Point 2 X position - * @param y2: Point 2 Y position - * @param x3: Point 3 X position - * @param y3: Point 3 Y position - * @retval None - */ -static void FillTriangle(uint16_t x1, uint16_t x2, uint16_t x3, uint16_t y1, uint16_t y2, uint16_t y3) -{ - int16_t deltax = 0, deltay = 0, x = 0, y = 0, xinc1 = 0, xinc2 = 0, - yinc1 = 0, yinc2 = 0, den = 0, num = 0, numadd = 0, numpixels = 0, - curpixel = 0; - - deltax = ABS(x2 - x1); /* The difference between the x's */ - deltay = ABS(y2 - y1); /* The difference between the y's */ - x = x1; /* Start x off at the first pixel */ - y = y1; /* Start y off at the first pixel */ - - if (x2 >= x1) /* The x-values are increasing */ - { - xinc1 = 1; - xinc2 = 1; - } - else /* The x-values are decreasing */ - { - xinc1 = -1; - xinc2 = -1; - } - - if (y2 >= y1) /* The y-values are increasing */ - { - yinc1 = 1; - yinc2 = 1; - } - else /* The y-values are decreasing */ - { - yinc1 = -1; - yinc2 = -1; - } - - if (deltax >= deltay) /* There is at least one x-value for every y-value */ - { - xinc1 = 0; /* Don't change the x when numerator >= denominator */ - yinc2 = 0; /* Don't change the y for every iteration */ - den = deltax; - num = deltax / 2; - numadd = deltay; - numpixels = deltax; /* There are more x-values than y-values */ - } - else /* There is at least one y-value for every x-value */ - { - xinc2 = 0; /* Don't change the x for every iteration */ - yinc1 = 0; /* Don't change the y when numerator >= denominator */ - den = deltay; - num = deltay / 2; - numadd = deltax; - numpixels = deltay; /* There are more y-values than x-values */ - } - - for (curpixel = 0; curpixel <= numpixels; curpixel++) - { - BSP_LCD_DrawLine(x, y, x3, y3); - - num += numadd; /* Increase the numerator by the top of the fraction */ - if (num >= den) /* Check if numerator >= denominator */ - { - num -= den; /* Calculate the new numerator value */ - x += xinc1; /* Change the x as appropriate */ - y += yinc1; /* Change the y as appropriate */ - } - x += xinc2; /* Change the x as appropriate */ - y += yinc2; /* Change the y as appropriate */ - } -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM324xG_EVAL/stm324xg_eval_lcd.h b/bsp/stm32f411RE/Libraries/BSP/STM324xG_EVAL/stm324xg_eval_lcd.h deleted file mode 100644 index 2b11da0784..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM324xG_EVAL/stm324xg_eval_lcd.h +++ /dev/null @@ -1,202 +0,0 @@ -/** - ****************************************************************************** - * @file stm324xg_eval_lcd.h - * @author MCD Application Team - * @version V2.1.0 - * @date 14-August-2015 - * @brief This file contains the common defines and functions prototypes for - * the stm324xg_eval_lcd.c driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM324XG_EVAL_LCD_H -#define __STM324XG_EVAL_LCD_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm324xg_eval.h" -#include "../Components/ili9325/ili9325.h" -#include "../../../Utilities/Fonts/fonts.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM324xG_EVAL - * @{ - */ - -/** @addtogroup STM324xG_EVAL_LCD - * @{ - */ - -/** @defgroup STM324xG_EVAL_LCD_Exported_Types - * @{ - */ -typedef struct -{ - uint32_t TextColor; - uint32_t BackColor; - sFONT *pFont; -}LCD_DrawPropTypeDef; -/** - * @} - */ - -/** @defgroup STM324xG_EVAL_LCD_Exported_Constants - * @{ - */ -/** - * @brief LCD status structure definition - */ -#define LCD_OK 0x00 -#define LCD_ERROR 0x01 -#define LCD_TIMEOUT 0x02 - -typedef struct -{ - int16_t X; - int16_t Y; -}Point, * pPoint; - -/** - * @brief Line mode structures definition - */ -typedef enum -{ - CENTER_MODE = 0x01, /* Center mode */ - RIGHT_MODE = 0x02, /* Right mode */ - LEFT_MODE = 0x03 /* Left mode */ -}Line_ModeTypdef; - -/** - * @brief LCD color - */ -#define LCD_COLOR_BLUE 0x001F -#define LCD_COLOR_GREEN 0x07E0 -#define LCD_COLOR_RED 0xF800 -#define LCD_COLOR_CYAN 0x07FF -#define LCD_COLOR_MAGENTA 0xF81F -#define LCD_COLOR_YELLOW 0xFFE0 -#define LCD_COLOR_LIGHTBLUE 0x841F -#define LCD_COLOR_LIGHTGREEN 0x87F0 -#define LCD_COLOR_LIGHTRED 0xFC10 -#define LCD_COLOR_LIGHTCYAN 0x87FF -#define LCD_COLOR_LIGHTMAGENTA 0xFC1F -#define LCD_COLOR_LIGHTYELLOW 0xFFF0 -#define LCD_COLOR_DARKBLUE 0x0010 -#define LCD_COLOR_DARKGREEN 0x0400 -#define LCD_COLOR_DARKRED 0x8000 -#define LCD_COLOR_DARKCYAN 0x0410 -#define LCD_COLOR_DARKMAGENTA 0x8010 -#define LCD_COLOR_DARKYELLOW 0x8400 -#define LCD_COLOR_WHITE 0xFFFF -#define LCD_COLOR_LIGHTGRAY 0xD69A -#define LCD_COLOR_GRAY 0x8410 -#define LCD_COLOR_DARKGRAY 0x4208 -#define LCD_COLOR_BLACK 0x0000 -#define LCD_COLOR_BROWN 0xA145 -#define LCD_COLOR_ORANGE 0xFD20 - -/** - * @brief LCD default font - */ -#define LCD_DEFAULT_FONT Font24 - -/** - * @} - */ - -/** @defgroup STM324xG_EVAL_LCD_Exported_Functions - * @{ - */ -uint8_t BSP_LCD_Init(void); -uint32_t BSP_LCD_GetXSize(void); -uint32_t BSP_LCD_GetYSize(void); - -uint16_t BSP_LCD_GetTextColor(void); -uint16_t BSP_LCD_GetBackColor(void); -void BSP_LCD_SetTextColor(__IO uint16_t Color); -void BSP_LCD_SetBackColor(__IO uint16_t Color); -void BSP_LCD_SetFont(sFONT *fonts); -sFONT *BSP_LCD_GetFont(void); - -void BSP_LCD_Clear(uint16_t Color); -void BSP_LCD_ClearStringLine(uint16_t Line); -void BSP_LCD_DisplayStringAtLine(uint16_t Line, uint8_t *ptr); -void BSP_LCD_DisplayStringAt(uint16_t Xpos, uint16_t Ypos, uint8_t *Text, Line_ModeTypdef Mode); -void BSP_LCD_DisplayChar(uint16_t Xpos, uint16_t Ypos, uint8_t Ascii); - -uint16_t BSP_LCD_ReadPixel(uint16_t Xpos, uint16_t Ypos); -void BSP_LCD_DrawPixel(uint16_t Xpos, uint16_t Ypos, uint16_t RGB_Code); -void BSP_LCD_DrawHLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length); -void BSP_LCD_DrawVLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length); -void BSP_LCD_DrawLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2); -void BSP_LCD_DrawRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height); -void BSP_LCD_DrawCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius); -void BSP_LCD_DrawPolygon(pPoint Points, uint16_t PointCount); -void BSP_LCD_DrawEllipse(int Xpos, int Ypos, int XRadius, int YRadius); -void BSP_LCD_DrawBitmap(uint16_t Xpos, uint16_t Ypos, uint8_t *pbmp); -void BSP_LCD_DrawRGBImage(uint16_t Xpos, uint16_t Ypos, uint16_t Xsize, uint16_t Ysize, uint8_t *pbmp); -void BSP_LCD_FillRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height); -void BSP_LCD_FillCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius); -void BSP_LCD_FillPolygon(pPoint Points, uint16_t PointCount); -void BSP_LCD_FillEllipse(int Xpos, int Ypos, int XRadius, int YRadius); - -void BSP_LCD_DisplayOff(void); -void BSP_LCD_DisplayOn(void); - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM324XG_EVAL_LCD_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM324xG_EVAL/stm324xg_eval_sd.c b/bsp/stm32f411RE/Libraries/BSP/STM324xG_EVAL/stm324xg_eval_sd.c deleted file mode 100644 index 1ca2a327b0..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM324xG_EVAL/stm324xg_eval_sd.c +++ /dev/null @@ -1,558 +0,0 @@ -/** - ****************************************************************************** - * @file stm324xg_eval_sd.c - * @author MCD Application Team - * @version V2.1.0 - * @date 14-August-2015 - * @brief This file includes the uSD card driver mounted on STM324xG-EVAL - * evaluation board. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* File Info : ----------------------------------------------------------------- - User NOTES -1. How To use this driver: --------------------------- - - This driver is used to drive the micro SD external card mounted on STM324xG-EVAL - evaluation board. - - This driver does not need a specific component driver for the micro SD device - to be included with. - -2. Driver description: ---------------------- - + Initialization steps: - o Initialize the micro SD card using the BSP_SD_Init() function. This - function includes the MSP layer hardware resources initialization and the - SDIO interface configuration to interface with the external micro SD. It - also includes the micro SD initialization sequence. - o To check the SD card presence you can use the function BSP_SD_IsDetected() which - returns the detection status - o If SD presence detection interrupt mode is desired, you must configure the - SD detection interrupt mode by calling the function BSP_SD_ITConfig(). The interrupt - is generated as an external interrupt whenever the micro SD card is - plugged/unplugged in/from the evaluation board. The SD detection interrupt - is handeled by calling the function BSP_SD_DetectIT() which is called in the IRQ - handler file, the user callback is implemented in the function BSP_SD_DetectCallback(). - o The function BSP_SD_GetCardInfo() is used to get the micro SD card information - which is stored in the structure "HAL_SD_CardInfoTypedef". - - + Micro SD card operations - o The micro SD card can be accessed with read/write block(s) operations once - it is reay for access. The access cand be performed whether using the polling - mode by calling the functions BSP_SD_ReadBlocks()/BSP_SD_WriteBlocks(), or by DMA - transfer using the functions BSP_SD_ReadBlocks_DMA()/BSP_SD_WriteBlocks_DMA() - o The DMA transfer complete is used with interrupt mode. Once the SD transfer - is complete, the SD interrupt is handeled using the function BSP_SD_IRQHandler(), - the DMA Tx/Rx transfer complete are handeled using the functions - BSP_SD_DMA_Tx_IRQHandler()/BSP_SD_DMA_Rx_IRQHandler(). The corresponding user callbacks - are implemented by the user at application level. - o The SD erase block(s) is performed using the function BSP_SD_Erase() with specifying - the number of blocks to erase. - o The SD runtime status is returned when calling the function BSP_SD_GetStatus(). - -------------------------------------------------------------------------------*/ - -/* Includes ------------------------------------------------------------------*/ -#include "stm324xg_eval_sd.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM324xG_EVAL - * @{ - */ - -/** @defgroup STM324xG_EVAL_SD - * @{ - */ - -/** @defgroup STM324xG_EVAL_SD_Private_Types_Definitions - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324xG_EVAL_SD_Private_Defines - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324xG_EVAL_SD_Private_Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324xG_EVAL_SD_Private_Variables - * @{ - */ -static SD_HandleTypeDef uSdHandle; -static SD_CardInfo uSdCardInfo; -/** - * @} - */ - -/** @defgroup STM324xG_EVAL_SD_Private_Function_Prototypes - * @{ - */ -static void SD_MspInit(void); -/** - * @} - */ - -/** @defgroup STM324xG_EVAL_SD_Private_Functions - * @{ - */ - -/** - * @brief Initializes the SD card device. - * @param None - * @retval SD status. - */ -uint8_t BSP_SD_Init(void) -{ - uint8_t SD_state = MSD_OK; - - /* uSD device interface configuration */ - uSdHandle.Instance = SDIO; - - uSdHandle.Init.ClockEdge = SDIO_CLOCK_EDGE_RISING; - uSdHandle.Init.ClockBypass = SDIO_CLOCK_BYPASS_DISABLE; - uSdHandle.Init.ClockPowerSave = SDIO_CLOCK_POWER_SAVE_DISABLE; - uSdHandle.Init.BusWide = SDIO_BUS_WIDE_1B; - uSdHandle.Init.HardwareFlowControl = SDIO_HARDWARE_FLOW_CONTROL_DISABLE; - uSdHandle.Init.ClockDiv = SDIO_TRANSFER_CLK_DIV; - - /* Check if the SD card is plugged in the slot */ - if(BSP_SD_IsDetected() != SD_PRESENT) - { - return MSD_ERROR; - } - - /* HAL SD initialization */ - SD_MspInit(); - if(HAL_SD_Init(&uSdHandle, &uSdCardInfo) != SD_OK) - { - SD_state = MSD_ERROR; - } - - /* Configure SD Bus width */ - if(SD_state == MSD_OK) - { - /* Enable wide operation */ - if(HAL_SD_WideBusOperation_Config(&uSdHandle, SDIO_BUS_WIDE_4B) != SD_OK) - { - SD_state = MSD_ERROR; - } - else - { - SD_state = MSD_OK; - } - } - - return SD_state; -} - -/** - * @brief Configures Interrupt mode for SD detection pin. - * @param None - * @retval Returns 0 - */ -uint8_t BSP_SD_ITConfig(void) -{ - GPIO_InitTypeDef GPIO_Init_Structure; - - /* Configure Interrupt mode for SD detection pin */ - GPIO_Init_Structure.Mode = GPIO_MODE_IT_RISING_FALLING; - GPIO_Init_Structure.Pull = GPIO_PULLUP; - GPIO_Init_Structure.Speed = GPIO_SPEED_HIGH; - GPIO_Init_Structure.Pin = SD_DETECT_PIN; - HAL_GPIO_Init(SD_DETECT_GPIO_PORT, &GPIO_Init_Structure); - - /* NVIC configuration for SDIO interrupts */ - HAL_NVIC_SetPriority(SD_DETECT_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(SD_DETECT_IRQn); - - return 0; -} - -/** - * @brief Detects if SD card is correctly plugged in the memory slot or not. - * @param None - * @retval Returns if SD is detected or not - */ -uint8_t BSP_SD_IsDetected(void) -{ - __IO uint8_t status = SD_PRESENT; - - /* Check SD card detect pin */ - if(HAL_GPIO_ReadPin(SD_DETECT_GPIO_PORT, SD_DETECT_PIN) != GPIO_PIN_RESET) - { - status = SD_NOT_PRESENT; - } - - return status; -} - -/** @brief SD detect IT treatment - * @param None - * @retval None - */ -void BSP_SD_DetectIT(void) -{ - /* SD detect IT callback */ - BSP_SD_DetectCallback(); - -} - - -/** @brief SD detect IT detection callback - * @param None - * @retval None - */ -__weak void BSP_SD_DetectCallback(void) -{ - /* NOTE: This function Should not be modified, when the callback is needed, - the BSP_SD_DetectCallback could be implemented in the user file - */ - -} - -/** - * @brief Reads block(s) from a specified address in an SD card, in polling mode. - * @param pData: Pointer to the buffer that will contain the data to transmit - * @param ReadAddr: Address from where data is to be read - * @param BlockSize: SD card data block size, that should be 512 - * @param NumOfBlocks: Number of SD blocks to read - * @retval SD status - */ -uint8_t BSP_SD_ReadBlocks(uint32_t *pData, uint64_t ReadAddr, uint32_t BlockSize, uint32_t NumOfBlocks) -{ - if(HAL_SD_ReadBlocks(&uSdHandle, pData, ReadAddr, BlockSize, NumOfBlocks) != SD_OK) - { - return MSD_ERROR; - } - else - { - return MSD_OK; - } -} - -/** - * @brief Writes block(s) to a specified address in an SD card, in polling mode. - * @param pData: Pointer to the buffer that will contain the data to transmit - * @param WriteAddr: Address from where data is to be written - * @param BlockSize: SD card data block size, that should be 512 - * @param NumOfBlocks: Number of SD blocks to write - * @retval SD status - */ -uint8_t BSP_SD_WriteBlocks(uint32_t *pData, uint64_t WriteAddr, uint32_t BlockSize, uint32_t NumOfBlocks) -{ - if(HAL_SD_WriteBlocks(&uSdHandle, pData, WriteAddr, BlockSize, NumOfBlocks) != SD_OK) - { - return MSD_ERROR; - } - else - { - return MSD_OK; - } -} - -/** - * @brief Reads block(s) from a specified address in an SD card, in DMA mode. - * @param pData: Pointer to the buffer that will contain the data to transmit - * @param ReadAddr: Address from where data is to be read - * @param BlockSize: SD card data block size, that should be 512 - * @param NumOfBlocks: Number of SD blocks to read - * @retval SD status - */ -uint8_t BSP_SD_ReadBlocks_DMA(uint32_t *pData, uint64_t ReadAddr, uint32_t BlockSize, uint32_t NumOfBlocks) -{ - uint8_t SD_state = MSD_OK; - - /* Read block(s) in DMA transfer mode */ - if(HAL_SD_ReadBlocks_DMA(&uSdHandle, pData, ReadAddr, BlockSize, NumOfBlocks) != SD_OK) - { - SD_state = MSD_ERROR; - } - - /* Wait until transfer is complete */ - if(SD_state == MSD_OK) - { - if(HAL_SD_CheckReadOperation(&uSdHandle, (uint32_t)SD_DATATIMEOUT) != SD_OK) - { - SD_state = MSD_ERROR; - } - else - { - SD_state = MSD_OK; - } - } - - return SD_state; -} - -/** - * @brief Writes block(s) to a specified address in an SD card, in DMA mode. - * @param pData: Pointer to the buffer that will contain the data to transmit - * @param WriteAddr: Address from where data is to be written - * @param BlockSize: SD card data block size, that should be 512 - * @param NumOfBlocks: Number of SD blocks to write - * @retval SD status - */ -uint8_t BSP_SD_WriteBlocks_DMA(uint32_t *pData, uint64_t WriteAddr, uint32_t BlockSize, uint32_t NumOfBlocks) -{ - uint8_t SD_state = MSD_OK; - - /* Write block(s) in DMA transfer mode */ - if(HAL_SD_WriteBlocks_DMA(&uSdHandle, pData, WriteAddr, BlockSize, NumOfBlocks) != SD_OK) - { - SD_state = MSD_ERROR; - } - - /* Wait until transfer is complete */ - if(SD_state == MSD_OK) - { - if(HAL_SD_CheckWriteOperation(&uSdHandle, (uint32_t)SD_DATATIMEOUT) != SD_OK) - { - SD_state = MSD_ERROR; - } - else - { - SD_state = MSD_OK; - } - } - - return SD_state; -} - -/** - * @brief Erases the specified memory area of the given SD card. - * @param StartAddr: Start byte address - * @param EndAddr: End byte address - * @retval SD status - */ -uint8_t BSP_SD_Erase(uint64_t StartAddr, uint64_t EndAddr) -{ - if(HAL_SD_Erase(&uSdHandle, StartAddr, EndAddr) != SD_OK) - { - return MSD_ERROR; - } - else - { - return MSD_OK; - } -} - -/** - * @brief Initializes the SD MSP. - * @param None - * @retval None - */ -static void SD_MspInit(void) -{ - static DMA_HandleTypeDef dmaRxHandle; - static DMA_HandleTypeDef dmaTxHandle; - GPIO_InitTypeDef GPIO_Init_Structure; - SD_HandleTypeDef *hsd = &uSdHandle; - - /* Enable SDIO clock */ - __SDIO_CLK_ENABLE(); - - /* Enable DMA2 clocks */ - __DMAx_TxRx_CLK_ENABLE(); - - /* Enable GPIOs clock */ - __GPIOC_CLK_ENABLE(); - __GPIOD_CLK_ENABLE(); - __SD_DETECT_GPIO_CLK_ENABLE(); - - /* Common GPIO configuration */ - GPIO_Init_Structure.Mode = GPIO_MODE_AF_PP; - GPIO_Init_Structure.Pull = GPIO_PULLUP; - GPIO_Init_Structure.Speed = GPIO_SPEED_HIGH; - GPIO_Init_Structure.Alternate = GPIO_AF12_SDIO; - - /* GPIOC configuration */ - GPIO_Init_Structure.Pin = GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12; - - HAL_GPIO_Init(GPIOC, &GPIO_Init_Structure); - - /* GPIOD configuration */ - GPIO_Init_Structure.Pin = GPIO_PIN_2; - HAL_GPIO_Init(GPIOD, &GPIO_Init_Structure); - - /* SD Card detect pin configuration */ - GPIO_Init_Structure.Mode = GPIO_MODE_INPUT; - GPIO_Init_Structure.Pull = GPIO_PULLUP; - GPIO_Init_Structure.Speed = GPIO_SPEED_HIGH; - GPIO_Init_Structure.Pin = SD_DETECT_PIN; - HAL_GPIO_Init(SD_DETECT_GPIO_PORT, &GPIO_Init_Structure); - - /* NVIC configuration for SDIO interrupts */ - HAL_NVIC_SetPriority(SDIO_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(SDIO_IRQn); - - /* Configure DMA Rx parameters */ - dmaRxHandle.Init.Channel = SD_DMAx_Rx_CHANNEL; - dmaRxHandle.Init.Direction = DMA_PERIPH_TO_MEMORY; - dmaRxHandle.Init.PeriphInc = DMA_PINC_DISABLE; - dmaRxHandle.Init.MemInc = DMA_MINC_ENABLE; - dmaRxHandle.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; - dmaRxHandle.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; - dmaRxHandle.Init.Mode = DMA_PFCTRL; - dmaRxHandle.Init.Priority = DMA_PRIORITY_VERY_HIGH; - dmaRxHandle.Init.FIFOMode = DMA_FIFOMODE_ENABLE; - dmaRxHandle.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; - dmaRxHandle.Init.MemBurst = DMA_MBURST_INC4; - dmaRxHandle.Init.PeriphBurst = DMA_PBURST_INC4; - - dmaRxHandle.Instance = SD_DMAx_Rx_STREAM; - - /* Associate the DMA handle */ - __HAL_LINKDMA(hsd, hdmarx, dmaRxHandle); - - /* Deinitialize the stream for new transfer */ - HAL_DMA_DeInit(&dmaRxHandle); - - /* Configure the DMA stream */ - HAL_DMA_Init(&dmaRxHandle); - - /* Configure DMA Tx parameters */ - dmaTxHandle.Init.Channel = SD_DMAx_Tx_CHANNEL; - dmaTxHandle.Init.Direction = DMA_MEMORY_TO_PERIPH; - dmaTxHandle.Init.PeriphInc = DMA_PINC_DISABLE; - dmaTxHandle.Init.MemInc = DMA_MINC_ENABLE; - dmaTxHandle.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; - dmaTxHandle.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; - dmaTxHandle.Init.Mode = DMA_PFCTRL; - dmaTxHandle.Init.Priority = DMA_PRIORITY_VERY_HIGH; - dmaTxHandle.Init.FIFOMode = DMA_FIFOMODE_ENABLE; - dmaTxHandle.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; - dmaTxHandle.Init.MemBurst = DMA_MBURST_INC4; - dmaTxHandle.Init.PeriphBurst = DMA_PBURST_INC4; - - dmaTxHandle.Instance = SD_DMAx_Tx_STREAM; - - /* Associate the DMA handle */ - __HAL_LINKDMA(hsd, hdmatx, dmaTxHandle); - - /* Deinitialize the stream for new transfer */ - HAL_DMA_DeInit(&dmaTxHandle); - - /* Configure the DMA stream */ - HAL_DMA_Init(&dmaTxHandle); - - /* NVIC configuration for DMA transfer complete interrupt */ - HAL_NVIC_SetPriority(SD_DMAx_Rx_IRQn, 6, 0); - HAL_NVIC_EnableIRQ(SD_DMAx_Rx_IRQn); - - /* NVIC configuration for DMA transfer complete interrupt */ - HAL_NVIC_SetPriority(SD_DMAx_Tx_IRQn, 6, 0); - HAL_NVIC_EnableIRQ(SD_DMAx_Tx_IRQn); -} - -/** - * @brief Handles SD card interrupt request. - * @param None - * @retval None - */ -void BSP_SD_IRQHandler(void) -{ - HAL_SD_IRQHandler(&uSdHandle); -} - -/** - * @brief Handles SD DMA Tx transfer interrupt request. - * @param None - * @retval None - */ -void BSP_SD_DMA_Tx_IRQHandler(void) -{ - HAL_DMA_IRQHandler(uSdHandle.hdmatx); -} - -/** - * @brief Handles SD DMA Rx transfer interrupt request. - * @param None - * @retval None - */ -void BSP_SD_DMA_Rx_IRQHandler(void) -{ - HAL_DMA_IRQHandler(uSdHandle.hdmarx); -} - -/** - * @brief Gets the current SD card data status. - * @param None - * @retval Data transfer state. - * This value can be one of the following values: - * @arg SD_TRANSFER_OK: No data transfer is acting - * @arg SD_TRANSFER_BUSY: Data transfer is acting - * @arg SD_TRANSFER_ERROR: Data transfer error - */ -HAL_SD_TransferStateTypedef BSP_SD_GetStatus(void) -{ - return(HAL_SD_GetStatus(&uSdHandle)); -} - -/** - * @brief Get SD information about specific SD card. - * @param CardInfo: Pointer to HAL_SD_CardInfoTypedef structure - * @retval None - */ -void BSP_SD_GetCardInfo(HAL_SD_CardInfoTypedef *CardInfo) -{ - /* Get SD card Information */ - HAL_SD_Get_CardInfo(&uSdHandle, CardInfo); -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM324xG_EVAL/stm324xg_eval_sd.h b/bsp/stm32f411RE/Libraries/BSP/STM324xG_EVAL/stm324xg_eval_sd.h deleted file mode 100644 index bf47db1ae5..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM324xG_EVAL/stm324xg_eval_sd.h +++ /dev/null @@ -1,152 +0,0 @@ -/** - ****************************************************************************** - * @file stm324xg_eval_sd.h - * @author MCD Application Team - * @version V2.1.0 - * @date 14-August-2015 - * @brief This file contains the common defines and functions prototypes for - * the stm324xg_eval_sd.c driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM324xG_EVAL_SD_H -#define __STM324xG_EVAL_SD_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm32f4xx_hal.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM324xG_EVAL - * @{ - */ - -/** @defgroup STM324xG_EVAL_SD - * @{ - */ - -/** @defgroup STM324xG_EVAL_SD_Exported_Types - * @{ - */ - -/** - * @brief SD Card information structure - */ -#define SD_CardInfo HAL_SD_CardInfoTypedef - -/** - * @brief SD status structure definition - */ -#define MSD_OK 0x00 -#define MSD_ERROR 0x01 - - -/** @defgroup STM324xG_EVAL_SD_Exported_Constants - * @{ - */ -#define SD_DETECT_PIN GPIO_PIN_13 -#define SD_DETECT_GPIO_PORT GPIOH -#define __SD_DETECT_GPIO_CLK_ENABLE() __GPIOH_CLK_ENABLE() -#define SD_DETECT_IRQn EXTI15_10_IRQn - -#define SD_DATATIMEOUT ((uint32_t)100000000) - -#define SD_PRESENT ((uint8_t)0x01) -#define SD_NOT_PRESENT ((uint8_t)0x00) - -/* DMA definitions for SD DMA transfer */ -#define __DMAx_TxRx_CLK_ENABLE __DMA2_CLK_ENABLE -#define SD_DMAx_Tx_CHANNEL DMA_CHANNEL_4 -#define SD_DMAx_Rx_CHANNEL DMA_CHANNEL_4 -#define SD_DMAx_Tx_STREAM DMA2_Stream6 -#define SD_DMAx_Rx_STREAM DMA2_Stream3 -#define SD_DMAx_Tx_IRQn DMA2_Stream6_IRQn -#define SD_DMAx_Rx_IRQn DMA2_Stream3_IRQn -#define SD_DMAx_Tx_IRQHandler DMA2_Stream6_IRQHandler -#define SD_DMAx_Rx_IRQHandler DMA2_Stream3_IRQHandler -#define SD_DetectIRQHandler() HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_13) - -/** - * @} - */ - -/** @defgroup STM324xG_EVAL_SD_Exported_Macro - * @{ - */ - -/** @defgroup STM324xG_EVAL_SD_Exported_Functions - * @{ - */ -uint8_t BSP_SD_Init(void); -uint8_t BSP_SD_ITConfig(void); -void BSP_SD_DetectIT(void); -void BSP_SD_DetectCallback(void); -uint8_t BSP_SD_ReadBlocks(uint32_t *pData, uint64_t ReadAddr, uint32_t BlockSize, uint32_t NumOfBlocks); -uint8_t BSP_SD_WriteBlocks(uint32_t *pData, uint64_t WriteAddr, uint32_t BlockSize, uint32_t NumOfBlocks); -uint8_t BSP_SD_ReadBlocks_DMA(uint32_t *pData, uint64_t ReadAddr, uint32_t BlockSize, uint32_t NumOfBlocks); -uint8_t BSP_SD_WriteBlocks_DMA(uint32_t *pData, uint64_t WriteAddr, uint32_t BlockSize, uint32_t NumOfBlocks); -uint8_t BSP_SD_Erase(uint64_t StartAddr, uint64_t EndAddr); -void BSP_SD_IRQHandler(void); -void BSP_SD_DMA_Tx_IRQHandler(void); -void BSP_SD_DMA_Rx_IRQHandler(void); -HAL_SD_TransferStateTypedef BSP_SD_GetStatus(void); -void BSP_SD_GetCardInfo(HAL_SD_CardInfoTypedef *CardInfo); -uint8_t BSP_SD_IsDetected(void); - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM324xG_EVAL_SD_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM324xG_EVAL/stm324xg_eval_sram.c b/bsp/stm32f411RE/Libraries/BSP/STM324xG_EVAL/stm324xg_eval_sram.c deleted file mode 100644 index 9248b9baee..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM324xG_EVAL/stm324xg_eval_sram.c +++ /dev/null @@ -1,360 +0,0 @@ -/** - ****************************************************************************** - * @file stm324xg_eval_sram.c - * @author MCD Application Team - * @version V2.1.0 - * @date 14-August-2015 - * @brief This file includes the SRAM driver for the IS61WV102416BLL-10MLI memory - * device mounted on STM324xG-EVAL evaluation board. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* File Info : ----------------------------------------------------------------- - User NOTES -1. How To use this driver: --------------------------- - - This driver is used to drive the IS61WV102416BLL-10MLI SRAM external memory mounted - on STM324xG-EVAL evaluation board. - - This driver does not need a specific component driver for the SRAM device - to be included with. - -2. Driver description: ---------------------- - + Initialization steps: - o Initialize the SRAM external memory using the BSP_SRAM_Init() function. This - function includes the MSP layer hardware resources initialization and the - FMC controller configuration to interface with the external SRAM memory. - - + SRAM read/write operations - o SRAM external memory can be accessed with read/write operations once it is - initialized. - Read/write operation can be performed with AHB access using the functions - BSP_SRAM_ReadData()/BSP_SRAM_WriteData(), or by DMA transfer using the functions - BSP_SRAM_ReadData_DMA()/BSP_SRAM_WriteData_DMA(). - o The AHB access is performed with 16-bit width transaction, the DMA transfer - configuration is fixed at single (no burst) halfword transfer - (see the SRAM_MspInit() static function). - o User can implement his own functions for read/write access with his desired - configurations. - o If interrupt mode is used for DMA transfer, the function BSP_SRAM_DMA_IRQHandler() - is called in IRQ handler file, to serve the generated interrupt once the DMA - transfer is complete. - -------------------------------------------------------------------------------*/ - -/* Includes ------------------------------------------------------------------*/ -#include "stm324xg_eval_sram.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM324xG_EVAL - * @{ - */ - -/** @defgroup STM324xG_EVAL_SRAM - * @{ - */ - -/** @defgroup STM324xG_EVAL_SRAM_Private_Types_Definitions - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324xG_EVAL_SRAM_Private_Defines - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324xG_EVAL_SRAM_Private_Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup stm324xg_eval_sram_Private_Variables - * @{ - */ -static SRAM_HandleTypeDef sramHandle; -static FMC_NORSRAM_TimingTypeDef Timing; -/** - * @} - */ - -/** @defgroup STM324xG_EVAL_SRAM_Private_Function_Prototypes - * @{ - */ -static void SRAM_MspInit(void); -/** - * @} - */ - -/** @defgroup STM324xG_EVAL_SRAM_Private_Functions - * @{ - */ - -/** - * @brief Initializes the SRAM device. - * @param None - * @retval SRAM status - */ -uint8_t BSP_SRAM_Init(void) -{ - sramHandle.Instance = FMC_NORSRAM_DEVICE; - sramHandle.Extended = FMC_NORSRAM_EXTENDED_DEVICE; - - /* SRAM device configuration */ - Timing.AddressSetupTime = 2; - Timing.AddressHoldTime = 1; - Timing.DataSetupTime = 2; - Timing.BusTurnAroundDuration = 1; - Timing.CLKDivision = 2; - Timing.DataLatency = 2; - Timing.AccessMode = FSMC_ACCESS_MODE_A; - - sramHandle.Init.NSBank = FSMC_NORSRAM_BANK2; - sramHandle.Init.DataAddressMux = FSMC_DATA_ADDRESS_MUX_DISABLE; - sramHandle.Init.MemoryType = FSMC_MEMORY_TYPE_SRAM; - sramHandle.Init.MemoryDataWidth = SRAM_MEMORY_WIDTH; - sramHandle.Init.BurstAccessMode = SRAM_BURSTACCESS; - sramHandle.Init.WaitSignalPolarity = FSMC_WAIT_SIGNAL_POLARITY_LOW; - sramHandle.Init.WrapMode = FSMC_WRAP_MODE_DISABLE; - sramHandle.Init.WaitSignalActive = FSMC_WAIT_TIMING_BEFORE_WS; - sramHandle.Init.WriteOperation = FSMC_WRITE_OPERATION_ENABLE; - sramHandle.Init.WaitSignal = FSMC_WAIT_SIGNAL_DISABLE; - sramHandle.Init.ExtendedMode = FSMC_EXTENDED_MODE_DISABLE; - sramHandle.Init.AsynchronousWait = FSMC_ASYNCHRONOUS_WAIT_DISABLE; - sramHandle.Init.WriteBurst = SRAM_WRITEBURST; - - /* SRAM controller initialization */ - SRAM_MspInit(); - if(HAL_SRAM_Init(&sramHandle, &Timing, &Timing) != HAL_OK) - { - return SRAM_ERROR; - } - else - { - return SRAM_OK; - } -} - -/** - * @brief Reads an amount of data from the SRAM device in polling mode. - * @param uwStartAddress : Read start address - * @param pData: Pointer to data to be read - * @param uwDataSize: Size of read data from the memory - * @retval SRAM status - */ -uint8_t BSP_SRAM_ReadData(uint32_t uwStartAddress, uint16_t *pData, uint32_t uwDataSize) -{ - if(HAL_SRAM_Read_16b(&sramHandle, (uint32_t *)uwStartAddress, pData, uwDataSize) != HAL_OK) - { - return SRAM_ERROR; - } - else - { - return SRAM_OK; - } -} - -/** - * @brief Reads an amount of data from the SRAM device in DMA mode. - * @param uwStartAddress : Read start address - * @param pData: Pointer to data to be read - * @param uwDataSize: Size of read data from the memory - * @retval SRAM status - */ -uint8_t BSP_SRAM_ReadData_DMA(uint32_t uwStartAddress, uint16_t *pData, uint32_t uwDataSize) -{ - if(HAL_SRAM_Read_DMA(&sramHandle, (uint32_t *)uwStartAddress, (uint32_t *)pData, uwDataSize) != HAL_OK) - { - return SRAM_ERROR; - } - else - { - return SRAM_OK; - } -} - -/** - * @brief Writes an amount of data from the SRAM device in polling mode. - * @param uwStartAddress: Write start address - * @param pData: Pointer to data to be written - * @param uwDataSize: Size of written data from the memory - * @retval SRAM status - */ -uint8_t BSP_SRAM_WriteData(uint32_t uwStartAddress, uint16_t *pData, uint32_t uwDataSize) -{ - if(HAL_SRAM_Write_16b(&sramHandle, (uint32_t *)uwStartAddress, pData, uwDataSize) != HAL_OK) - { - return SRAM_ERROR; - } - else - { - return SRAM_OK; - } -} - -/** - * @brief Writes an amount of data from the SRAM device in DMA mode. - * @param uwStartAddress: Write start address - * @param pData: Pointer to data to be written - * @param uwDataSize: Size of written data from the memory - * @retval SRAM status - */ -uint8_t BSP_SRAM_WriteData_DMA(uint32_t uwStartAddress, uint16_t *pData, uint32_t uwDataSize) -{ - if(HAL_SRAM_Write_DMA(&sramHandle, (uint32_t *)uwStartAddress, (uint32_t *)pData, uwDataSize) != HAL_OK) - { - return SRAM_ERROR; - } - else - { - return SRAM_OK; - } -} - -/** - * @brief Handles SRAM DMA transfer interrupt request. - * @param None - * @retval None - */ -void BSP_SRAM_DMA_IRQHandler(void) -{ - HAL_DMA_IRQHandler(sramHandle.hdma); -} - -/** - * @brief Initializes SRAM MSP. - * @param hsram: SRAM handle - * @retval None - */ -static void SRAM_MspInit(void) -{ - static DMA_HandleTypeDef dmaHandle; - GPIO_InitTypeDef GPIO_Init_Structure; - SRAM_HandleTypeDef *hsram = &sramHandle; - - /* Enable FMC clock */ - __FSMC_CLK_ENABLE(); - - /* Enable chosen DMAx clock */ - __SRAM_DMAx_CLK_ENABLE(); - - /* Enable GPIOs clock */ - __GPIOD_CLK_ENABLE(); - __GPIOE_CLK_ENABLE(); - __GPIOF_CLK_ENABLE(); - __GPIOG_CLK_ENABLE(); - - /* Common GPIO configuration */ - GPIO_Init_Structure.Mode = GPIO_MODE_AF_PP; - GPIO_Init_Structure.Pull = GPIO_PULLUP; - GPIO_Init_Structure.Speed = GPIO_SPEED_HIGH; - GPIO_Init_Structure.Alternate = GPIO_AF12_FSMC; - - /* GPIOD configuration */ - GPIO_Init_Structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_8 |\ - GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13 |\ - GPIO_PIN_14 | GPIO_PIN_15; - - HAL_GPIO_Init(GPIOD, &GPIO_Init_Structure); - - /* GPIOE configuration */ - GPIO_Init_Structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_3| GPIO_PIN_4 | GPIO_PIN_7 |\ - GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12 |\ - GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15; - HAL_GPIO_Init(GPIOE, &GPIO_Init_Structure); - - /* GPIOF configuration */ - GPIO_Init_Structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2| GPIO_PIN_3 | GPIO_PIN_4 |\ - GPIO_PIN_5 | GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15; - HAL_GPIO_Init(GPIOF, &GPIO_Init_Structure); - - /* GPIOG configuration */ - GPIO_Init_Structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2| GPIO_PIN_3 | GPIO_PIN_4 |\ - GPIO_PIN_5 | GPIO_PIN_9; - - HAL_GPIO_Init(GPIOG, &GPIO_Init_Structure); - - - /* Configure common DMA parameters */ - dmaHandle.Init.Channel = SRAM_DMAx_CHANNEL; - dmaHandle.Init.Direction = DMA_MEMORY_TO_MEMORY; - dmaHandle.Init.PeriphInc = DMA_PINC_ENABLE; - dmaHandle.Init.MemInc = DMA_MINC_ENABLE; - dmaHandle.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD; - dmaHandle.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD; - dmaHandle.Init.Mode = DMA_NORMAL; - dmaHandle.Init.Priority = DMA_PRIORITY_HIGH; - dmaHandle.Init.FIFOMode = DMA_FIFOMODE_DISABLE; - dmaHandle.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; - dmaHandle.Init.MemBurst = DMA_MBURST_INC8; - dmaHandle.Init.PeriphBurst = DMA_PBURST_INC8; - - dmaHandle.Instance = SRAM_DMAx_STREAM; - - /* Associate the DMA handle */ - __HAL_LINKDMA(hsram, hdma, dmaHandle); - - /* Deinitialize the stream for new transfer */ - HAL_DMA_DeInit(&dmaHandle); - - /* Configure the DMA stream */ - HAL_DMA_Init(&dmaHandle); - - /* NVIC configuration for DMA transfer complete interrupt */ - HAL_NVIC_SetPriority(SRAM_DMAx_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(SRAM_DMAx_IRQn); -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM324xG_EVAL/stm324xg_eval_sram.h b/bsp/stm32f411RE/Libraries/BSP/STM324xG_EVAL/stm324xg_eval_sram.h deleted file mode 100644 index c7ba40100c..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM324xG_EVAL/stm324xg_eval_sram.h +++ /dev/null @@ -1,140 +0,0 @@ -/** - ****************************************************************************** - * @file stm324xg_eval_sram.h - * @author MCD Application Team - * @version V2.1.0 - * @date 14-August-2015 - * @brief This file contains the common defines and functions prototypes for - * the stm324xg_eval_sram.c driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM324xG_EVAL_SRAM_H -#define __STM324xG_EVAL_SRAM_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm32f4xx_hal.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM324xG_EVAL - * @{ - */ - -/** @defgroup STM324xG_EVAL_SRAM - * @{ - */ - -/** @defgroup STM324xG_EVAL_SRAM_Exported_Types - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324xG_EVAL_SRAM_Exported_Constants - * @{ - */ - -/** - * @brief SD status structure definition - */ -#define SRAM_OK 0x00 -#define SRAM_ERROR 0x01 - -#define SRAM_DEVICE_ADDR ((uint32_t)0x64000000) -#define SRAM_DEVICE_SIZE ((uint32_t)0x200000) /* SRAM device size in MBytes */ - -/* #define SRAM_MEMORY_WIDTH FSMC_NORSRAM_MEM_BUS_WIDTH_8 */ -#define SRAM_MEMORY_WIDTH FSMC_NORSRAM_MEM_BUS_WIDTH_16 - -#define SRAM_BURSTACCESS FSMC_BURST_ACCESS_MODE_DISABLE -/* #define SRAM_BURSTACCESS FSMC_BURST_ACCESS_MODE_ENABLE */ - -#define SRAM_WRITEBURST FSMC_WRITE_BURST_DISABLE -/* #define SRAM_WRITEBURST FSMC_WRITE_BURST_ENABLE */ - -/* DMA definitions for SRAM DMA transfer */ -#define __SRAM_DMAx_CLK_ENABLE __DMA2_CLK_ENABLE -#define SRAM_DMAx_CHANNEL DMA_CHANNEL_0 -#define SRAM_DMAx_STREAM DMA2_Stream0 -#define SRAM_DMAx_IRQn DMA2_Stream0_IRQn -#define SRAM_DMAx_IRQHandler DMA2_Stream0_IRQHandler -/** - * @} - */ - -/** @defgroup STM324xG_EVAL_SRAM_Exported_Macro - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324xG_EVAL_SRAM_Exported_Functions - * @{ - */ -uint8_t BSP_SRAM_Init(void); -uint8_t BSP_SRAM_ReadData(uint32_t uwStartAddress, uint16_t *pData, uint32_t uwDataSize); -uint8_t BSP_SRAM_ReadData_DMA(uint32_t uwStartAddress, uint16_t *pData, uint32_t uwDataSize); -uint8_t BSP_SRAM_WriteData(uint32_t uwStartAddress, uint16_t *pData, uint32_t uwDataSize); -uint8_t BSP_SRAM_WriteData_DMA(uint32_t uwStartAddress, uint16_t *pData, uint32_t uwDataSize); -void BSP_SRAM_DMA_IRQHandler(void); - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM324xG_EVAL_SRAM_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM324xG_EVAL/stm324xg_eval_ts.c b/bsp/stm32f411RE/Libraries/BSP/STM324xG_EVAL/stm324xg_eval_ts.c deleted file mode 100644 index 02353b3cb8..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM324xG_EVAL/stm324xg_eval_ts.c +++ /dev/null @@ -1,263 +0,0 @@ -/** - ****************************************************************************** - * @file stm324xg_eval_ts.c - * @author MCD Application Team - * @version V2.1.0 - * @date 14-August-2015 - * @brief This file provides a set of functions needed to manage the touch - * screen on STM324xG-EVAL evaluation board. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* File Info : ----------------------------------------------------------------- - User NOTES -1. How To use this driver: --------------------------- - - This driver is used to drive the touch screen module of the STM324xG-EVAL - evaluation board on the ILI9325 LCD mounted on MB785 daughter board . - - The STMPE811 IO expander device component driver must be included with this - driver in order to run the TS module commanded by the IO expander device - mounted on the evaluation board. - -2. Driver description: ---------------------- - + Initialization steps: - o Initialize the TS module using the BSP_TS_Init() function. This - function includes the MSP layer hardware resources initialization and the - communication layer configuration to start the TS use. The LCD size properties - (x and y) are passed as parameters. - o If TS interrupt mode is desired, you must configure the TS interrupt mode - by calling the function BSP_TS_ITConfig(). The TS interrupt mode is generated - as an external interrupt whenever a touch is detected. - - + Touch screen use - o The touch screen state is captured whenever the function BSP_TS_GetState() is - used. This function returns information about the last LCD touch occurred - in the TS_StateTypeDef structure. - o If TS interrupt mode is used, the function BSP_TS_ITGetStatus() is needed to get - the interrupt status. To clear the IT pending bits, you should call the - function BSP_TS_ITClear(). - o The IT is handled using the corresponding external interrupt IRQ handler, - the user IT callback treatment is implemented on the same external interrupt - callback. - -------------------------------------------------------------------------------*/ - -/* Includes ------------------------------------------------------------------*/ -#include "stm324xg_eval_ts.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM324xG_EVAL - * @{ - */ - -/** @defgroup STM324xG_EVAL_TS - * @{ - */ - -/** @defgroup STM324xG_EVAL_TS_Private_Types_Definitions - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324xG_EVAL_TS_Private_Defines - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324xG_EVAL_TS_Private_Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324xG_EVAL_TS_Private_Variables - * @{ - */ -static TS_DrvTypeDef *ts_driver; -static uint16_t ts_x_boundary, ts_y_boundary; -static uint8_t ts_orientation; -/** - * @} - */ - -/** @defgroup STM324xG_EVAL_TS_Private_Function_Prototypes - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324xG_EVAL_TS_Private_Functions - * @{ - */ - -/** - * @brief Initializes and configures the touch screen functionalities and - * configures all necessary hardware resources (GPIOs, clocks..). - * @param xSize: Maximum X size of the TS area on LCD - * ySize: Maximum Y size of the TS area on LCD - * @retval TS_OK if all initializations are OK. Other value if error. - */ -uint8_t BSP_TS_Init(uint16_t xSize, uint16_t ySize) -{ - uint8_t ret = TS_ERROR; - - if(stmpe811_ts_drv.ReadID(TS_I2C_ADDRESS) == STMPE811_ID) - { - /* Initialize the TS driver structure */ - ts_driver = &stmpe811_ts_drv; - - /* Initialize x and y positions boundaries */ - ts_x_boundary = xSize; - ts_y_boundary = ySize; - ts_orientation = TS_SWAP_XY; - ret = TS_OK; - } - - if(ret == TS_OK) - { - /* Initialize the LL TS Driver */ - ts_driver->Init(TS_I2C_ADDRESS); - ts_driver->Start(TS_I2C_ADDRESS); - } - - return ret; -} - -/** - * @brief Configures and enables the touch screen interrupts. - * @param None - * @retval TS_OK if all initializations are OK. Other value if error. - */ -uint8_t BSP_TS_ITConfig(void) -{ - /* Call component driver to enable TS ITs */ - ts_driver->EnableIT(TS_I2C_ADDRESS); - - return TS_OK; -} - -/** - * @brief Gets the touch screen interrupt status. - * @param None - * @retval TS_OK if all initializations are OK. Other value if error. - */ -uint8_t BSP_TS_ITGetStatus(void) -{ - /* Call component driver to enable TS ITs */ - return (ts_driver->GetITStatus(TS_I2C_ADDRESS)); -} - -/** - * @brief Returns status and positions of the touch screen. - * @param TS_State: Pointer to touch screen current state structure - * @retval TS_OK if all initializations are OK. Other value if error. - */ -uint8_t BSP_TS_GetState(TS_StateTypeDef *TS_State) -{ - static uint32_t _x = 0, _y = 0; - uint16_t xDiff, yDiff , x , y; - uint16_t swap; - - TS_State->TouchDetected = ts_driver->DetectTouch(TS_I2C_ADDRESS); - - if(TS_State->TouchDetected) - { - ts_driver->GetXY(TS_I2C_ADDRESS, &x, &y); - - if(ts_orientation & TS_SWAP_X) - { - x = 4096 - x; - } - - if(ts_orientation & TS_SWAP_Y) - { - y = 4096 - y; - } - - if(ts_orientation & TS_SWAP_XY) - { - swap = y; - y = x; - x = swap; - } - - xDiff = x > _x? (x - _x): (_x - x); - yDiff = y > _y? (y - _y): (_y - y); - - if (xDiff + yDiff > 5) - { - _x = x; - _y = y; - } - - TS_State->x = (ts_x_boundary * _x) >> 12; - TS_State->y = (ts_y_boundary * _y) >> 12; - } - - return TS_OK; -} - -/** - * @brief Clears all touch screen interrupts. - * @param None - * @retval None - */ -void BSP_TS_ITClear(void) -{ - ts_driver->ClearIT(TS_I2C_ADDRESS); -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM324xG_EVAL/stm324xg_eval_ts.h b/bsp/stm32f411RE/Libraries/BSP/STM324xG_EVAL/stm324xg_eval_ts.h deleted file mode 100644 index b08bc25b2d..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM324xG_EVAL/stm324xg_eval_ts.h +++ /dev/null @@ -1,134 +0,0 @@ -/** - ****************************************************************************** - * @file stm324xg_eval_ts.h - * @author MCD Application Team - * @version V2.1.0 - * @date 14-August-2015 - * @brief This file contains the common defines and functions prototypes for - * the stm324xg_eval_ts.c driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM324xG_EVAL_TS_H -#define __STM324xG_EVAL_TS_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm324xg_eval.h" -/* Include IOExpander(STMPE811) component Driver */ -#include "../Components/stmpe811/stmpe811.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM324xG_EVAL - * @{ - */ - -/** @defgroup STM324xG_EVAL_TS - * @{ - */ - -/** @defgroup STM324xG_EVAL_TS_Exported_Types - * @{ - */ -typedef struct -{ - uint16_t TouchDetected; - uint16_t x; - uint16_t y; - uint16_t z; -}TS_StateTypeDef; -/** - * @} - */ - -/** @defgroup STM324xG_EVAL_TS_Exported_Constants - * @{ - */ -#define TS_SWAP_NONE 0x00 -#define TS_SWAP_X 0x01 -#define TS_SWAP_Y 0x02 -#define TS_SWAP_XY 0x04 - -typedef enum -{ - TS_OK = 0x00, - TS_ERROR = 0x01, - TS_TIMEOUT = 0x02 -}TS_StatusTypeDef; -/** - * @} - */ - -/** @defgroup STM324xG_EVAL_TS_Exported_Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM324xG_EVAL_TS_Exported_Functions - * @{ - */ -uint8_t BSP_TS_Init(uint16_t xSize, uint16_t ySize); -uint8_t BSP_TS_GetState(TS_StateTypeDef *TS_State); -uint8_t BSP_TS_ITConfig(void); -uint8_t BSP_TS_ITGetStatus(void); -void BSP_TS_ITClear(void); - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM324xG_EVAL_TS_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32F4-Discovery/Release_Notes.html b/bsp/stm32f411RE/Libraries/BSP/STM32F4-Discovery/Release_Notes.html deleted file mode 100644 index 674c36df71..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32F4-Discovery/Release_Notes.html +++ /dev/null @@ -1,615 +0,0 @@ - - - - - - - - - - - - - - - - - - - - Release Notes for STM32F4-Discovery Board Drivers - - - - - - - - - - -
-


-

-
- - - - - - -
- - - - - - - - - -
-

Back to Release page

-
-

Release -Notes for STM32F4-Discovery Board Drivers

-

Copyright -2015 STMicroelectronics

-

-
-

 

- - - - - - -

Update History

-

V2.1.0 / 14-August-2015

Main -Changes

- - - - - -
  • stm32f4_discovery.c
    • Add AUDIO_IO_DeInit() function to align with BSP Components Common drivers V4.0.0

V2.0.4 / 02-March-2015

Main -Changes

- - - - - -
  • stm32f4_discovery.c/.h
    • Align to STM32F4xx HAL Driver V1.3.0 for -__HAL_RCC_PPP_CLK_ENABLE() .

V2.0.3 / 10-December-2014

- - - - - - - - - - - - - - - - - - - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- - - - - - - - - - - - - -
    -
  • stm32f4_discovery_accelerometer.h
  • -
      -
    • Change "\" by "/" in the include path to fix compilation issue under Linux
    • -
    -
  • stm32f4_discovery_audio.c/.h
    -
  • -
      -
    • BSP_AUDIO_OUT_Init(): Fix limitation on the I2S clock configuration
      -
    • -
    -
      -
    • Change "\" by "/" in the include path to fix compilation issue under Linux
    • -
    -
  • stm32f4_discovery.c/.h
    -
  • -
      -
    • Change I2C_SPEED used define by BSP_I2C_SPEED
    • -
    -
  • Miscellaneous comments update
  • -
- -

V2.0.2 / 26-June-2014

- - - - - - - - - - - - - - - - - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- - - - - - - - - - - -
    -
  • stm32f4_discovery_audio.c/.h
    • -
    • BSP_AUDIO_OUT_Play(): uses the buffer size in byte instead of half-word
    • -
    • BSP_AUDIO_IN_PDMToPCM(): duplicates samples to make stereo audio stream (since a single microphone in mounted on STM32F4-Discovery)
    • -
    • I2S2_Init(): configures the I2S to clock the microphone at 1.024 MHz as required instead of 2.048MHz
      -
    • -
    -
- -

V2.0.1 / 19-June-2014

- - - - - - - - - - - - - - - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- - - - - - - - - -
    -
  • stm32f4_discovery.c/.h
  • -
      -
    • Enhance BSP_PB_Init() function by removing the call of __SYSCFG_CLK_ENABLE() already enabled in the HAL_GPIO_Init()
    • -
    -
  • stm32f4_discovery_audio.c/.h
  • -
      -
    • Add note that only the audio stereo format is supported
    • -
    -
  • Comments clean up and typo corrections
    -
  • -
- -

V2.0.0 / 18-February-2014

- - - - - - - - - - - - - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- - - - - - - -
    -
  • Major update -based on STM32Cube specification: drivers architecture and APIs -modified vs. V1.1.2, and thus the 2 versions are not compatible.
    -
  • This version has to be used only with STM32CubeF4 based development
  • -
-

V1.1.2 / 17-April-2012

Main -Changes

-
  • All source files: license disclaimer text update and add link to the License file on ST Internet.

V1.1.1 / 30-December-2011

Main -Changes

-
  • PDM Library moved from Utilities\STM32F4-Discovery to Utilities\STM32_Audio\Addons\PDM folder
  • All source files: update disclaimer to add reference to the new license agreement
  • stm32f4_discovery_audio_codec.c 
    • Audio_MAL_Init() function: DMA configuration changed as below
      • DMA_FIFOMode_Disable changed to DMA_FIFOMode_Enable
      • DMA_FIFOThreshold_1QuarterFull changed to DMA_FIFOThreshold_HalfFull

V1.1.0 / 28-October-2011

-

Main -Changes

- -
  • Add PDM audio software decoding Library drivers, used to decode and reconstruct the audio signal produced by MP45DT02 MEMS microphone from STMicroelectronics. For more details about this Library, please refer to document "PDM audio software decoding on STM32 microcontrollers (AN3998)".
  • stm32f4_discovery_audio_codec.c/.h: update to use DMA instead of Interrupt in I2S communication with the external codec.

V1.0.0 / 19-September-2011

-

Main -Changes

- -
  • First official version of the STM32F4-Discovery Board Drivers

License

-
-
-Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met:
-
-
  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions -in binary form must reproduce the above copyright notice, this list of -conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of STMicroelectronics nor the names of its contributors may be used to endorse or promote products derived
    -
    -
-        from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- -
-
- - -
-
-
For -complete documentation on STM32 Microcontrollers -visit www.st.com/STM32
-
-

-
-
-

 

-
- - \ No newline at end of file diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32F4-Discovery/stm32f4_discovery.c b/bsp/stm32f411RE/Libraries/BSP/STM32F4-Discovery/stm32f4_discovery.c deleted file mode 100644 index dd3700b3c9..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32F4-Discovery/stm32f4_discovery.c +++ /dev/null @@ -1,731 +0,0 @@ -/** - ****************************************************************************** - * @file stm32f4_discovery.c - * @author MCD Application Team - * @version V2.1.0 - * @date 14-August-2015 - * @brief This file provides set of firmware functions to manage Leds and - * push-button available on STM32F4-Discovery Kit from STMicroelectronics. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2014 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ -/* Includes ------------------------------------------------------------------*/ -#include "stm32f4_discovery.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32F4_DISCOVERY - * @{ - */ - -/** @defgroup STM32F4_DISCOVERY_LOW_LEVEL - * @brief This file provides set of firmware functions to manage Leds and push-button - * available on STM32F4-Discovery Kit from STMicroelectronics. - * @{ - */ - -/** @defgroup STM32F4_DISCOVERY_LOW_LEVEL_Private_TypesDefinitions - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F4_DISCOVERY_LOW_LEVEL_Private_Defines - * @{ - */ - - /** - * @brief STM32F4 DISCO BSP Driver version number V2.1.0 - */ -#define __STM32F4_DISCO_BSP_VERSION_MAIN (0x02) /*!< [31:24] main version */ -#define __STM32F4_DISCO_BSP_VERSION_SUB1 (0x01) /*!< [23:16] sub1 version */ -#define __STM32F4_DISCO_BSP_VERSION_SUB2 (0x00) /*!< [15:8] sub2 version */ -#define __STM32F4_DISCO_BSP_VERSION_RC (0x00) /*!< [7:0] release candidate */ -#define __STM32F4_DISCO_BSP_VERSION ((__STM32F4_DISCO_BSP_VERSION_MAIN << 24)\ - |(__STM32F4_DISCO_BSP_VERSION_SUB1 << 16)\ - |(__STM32F4_DISCO_BSP_VERSION_SUB2 << 8 )\ - |(__STM32F4_DISCO_BSP_VERSION_RC)) -/** - * @} - */ - - -/** @defgroup STM32F4_DISCOVERY_LOW_LEVEL_Private_Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F4_DISCOVERY_LOW_LEVEL_Private_Variables - * @{ - */ -GPIO_TypeDef* GPIO_PORT[LEDn] = {LED4_GPIO_PORT, - LED3_GPIO_PORT, - LED5_GPIO_PORT, - LED6_GPIO_PORT}; -const uint16_t GPIO_PIN[LEDn] = {LED4_PIN, - LED3_PIN, - LED5_PIN, - LED6_PIN}; - -GPIO_TypeDef* BUTTON_PORT[BUTTONn] = {KEY_BUTTON_GPIO_PORT}; -const uint16_t BUTTON_PIN[BUTTONn] = {KEY_BUTTON_PIN}; -const uint8_t BUTTON_IRQn[BUTTONn] = {KEY_BUTTON_EXTI_IRQn}; - -uint32_t I2cxTimeout = I2Cx_TIMEOUT_MAX; /* 0x01) - { - WriteAddr |= (uint8_t)MULTIPLEBYTE_CMD; - } - /* Set chip select Low at the start of the transmission */ - ACCELERO_CS_LOW(); - - /* Send the Address of the indexed register */ - SPIx_WriteRead(WriteAddr); - - /* Send the data that will be written into the device (MSB First) */ - while(NumByteToWrite >= 0x01) - { - SPIx_WriteRead(*pBuffer); - NumByteToWrite--; - pBuffer++; - } - - /* Set chip select High at the end of the transmission */ - ACCELERO_CS_HIGH(); -} - -/** - * @brief Reads a block of data from the Accelerometer. - * @param pBuffer: pointer to the buffer that receives the data read from the Accelerometer. - * @param ReadAddr: Accelerometer's internal address to read from. - * @param NumByteToRead: number of bytes to read from the Accelerometer. - * @retval None - */ -void ACCELERO_IO_Read(uint8_t *pBuffer, uint8_t ReadAddr, uint16_t NumByteToRead) -{ - if(NumByteToRead > 0x01) - { - ReadAddr |= (uint8_t)(READWRITE_CMD | MULTIPLEBYTE_CMD); - } - else - { - ReadAddr |= (uint8_t)READWRITE_CMD; - } - /* Set chip select Low at the start of the transmission */ - ACCELERO_CS_LOW(); - - /* Send the Address of the indexed register */ - SPIx_WriteRead(ReadAddr); - - /* Receive the data that will be read from the device (MSB First) */ - while(NumByteToRead > 0x00) - { - /* Send dummy byte (0x00) to generate the SPI clock to ACCELEROMETER (Slave device) */ - *pBuffer = SPIx_WriteRead(DUMMY_BYTE); - NumByteToRead--; - pBuffer++; - } - - /* Set chip select High at the end of the transmission */ - ACCELERO_CS_HIGH(); -} - -/********************************* LINK AUDIO *********************************/ - -/** - * @brief Initializes Audio low level. - * @param None - * @retval None - */ -void AUDIO_IO_Init(void) -{ - GPIO_InitTypeDef GPIO_InitStruct; - - /* Enable Reset GPIO Clock */ - AUDIO_RESET_GPIO_CLK_ENABLE(); - - /* Audio reset pin configuration */ - GPIO_InitStruct.Pin = AUDIO_RESET_PIN; - GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStruct.Speed = GPIO_SPEED_FAST; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(AUDIO_RESET_GPIO, &GPIO_InitStruct); - - I2Cx_Init(); - - /* Power Down the codec */ - HAL_GPIO_WritePin(AUDIO_RESET_GPIO, AUDIO_RESET_PIN, GPIO_PIN_RESET); - - /* Wait for a delay to insure registers erasing */ - HAL_Delay(5); - - /* Power on the codec */ - HAL_GPIO_WritePin(AUDIO_RESET_GPIO, AUDIO_RESET_PIN, GPIO_PIN_SET); - - /* Wait for a delay to insure registers erasing */ - HAL_Delay(5); -} - -/** - * @brief DeInitializes Audio low level. - * @param None - * @retval None - */ -void AUDIO_IO_DeInit(void) -{ - -} - -/** - * @brief Writes a single data. - * @param Addr: I2C address - * @param Reg: Reg address - * @param Value: Data to be written - * @retval None - */ -void AUDIO_IO_Write (uint8_t Addr, uint8_t Reg, uint8_t Value) -{ - I2Cx_WriteData(Addr, Reg, Value); -} - -/** - * @brief Reads a single data. - * @param Addr: I2C address - * @param Reg: Reg address - * @retval Data to be read - */ -uint8_t AUDIO_IO_Read(uint8_t Addr, uint8_t Reg) -{ - return I2Cx_ReadData(Addr, Reg); -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32F4-Discovery/stm32f4_discovery.h b/bsp/stm32f411RE/Libraries/BSP/STM32F4-Discovery/stm32f4_discovery.h deleted file mode 100644 index 41456fc32d..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32F4-Discovery/stm32f4_discovery.h +++ /dev/null @@ -1,303 +0,0 @@ -/** - ****************************************************************************** - * @file stm32f4_discovery.h - * @author MCD Application Team - * @version V2.1.0 - * @date 14-August-2015 - * @brief This file contains definitions for STM32F4-Discovery Kit's Leds and - * push-button hardware resources. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2014 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32F4_DISCOVERY_H -#define __STM32F4_DISCOVERY_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm32f4xx_hal.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32F4_DISCOVERY - * @{ - */ - -/** @addtogroup STM32F4_DISCOVERY_LOW_LEVEL - * @{ - */ - -/** @defgroup STM32F4_DISCOVERY_LOW_LEVEL_Exported_Types - * @{ - */ -typedef enum -{ - LED4 = 0, - LED3 = 1, - LED5 = 2, - LED6 = 3 -} Led_TypeDef; - -typedef enum -{ - BUTTON_KEY = 0, -} Button_TypeDef; - -typedef enum -{ - BUTTON_MODE_GPIO = 0, - BUTTON_MODE_EXTI = 1 -} ButtonMode_TypeDef; -/** - * @} - */ - -/** @defgroup STM32F4_DISCOVERY_LOW_LEVEL_Exported_Constants - * @{ - */ - -/** -* @brief Define for STM32F4_DISCOVERY board -*/ -#if !defined (USE_STM32F4_DISCO) - #define USE_STM32F4_DISCO -#endif - -/** @addtogroup STM32F4_DISCOVERY_LOW_LEVEL_LED - * @{ - */ -#define LEDn 4 - -#define LED4_PIN GPIO_PIN_12 -#define LED4_GPIO_PORT GPIOD -#define LED4_GPIO_CLK_ENABLE() __GPIOD_CLK_ENABLE() -#define LED4_GPIO_CLK_DISABLE() __GPIOD_CLK_DISABLE() - -#define LED3_PIN GPIO_PIN_13 -#define LED3_GPIO_PORT GPIOD -#define LED3_GPIO_CLK_ENABLE() __GPIOD_CLK_ENABLE() -#define LED3_GPIO_CLK_DISABLE() __GPIOD_CLK_DISABLE() - -#define LED5_PIN GPIO_PIN_14 -#define LED5_GPIO_PORT GPIOD -#define LED5_GPIO_CLK_ENABLE() __GPIOD_CLK_ENABLE() -#define LED5_GPIO_CLK_DISABLE() __GPIOD_CLK_DISABLE() - -#define LED6_PIN GPIO_PIN_15 -#define LED6_GPIO_PORT GPIOD -#define LED6_GPIO_CLK_ENABLE() __GPIOD_CLK_ENABLE() -#define LED6_GPIO_CLK_DISABLE() __GPIOD_CLK_DISABLE() - -#define LEDx_GPIO_CLK_ENABLE(__INDEX__) do{if((__INDEX__) == 0) LED4_GPIO_CLK_ENABLE(); else \ - if((__INDEX__) == 1) LED3_GPIO_CLK_ENABLE(); else \ - if((__INDEX__) == 2) LED5_GPIO_CLK_ENABLE(); else \ - if((__INDEX__) == 3) LED6_GPIO_CLK_ENABLE(); \ - }while(0) - -#define LEDx_GPIO_CLK_DISABLE(__INDEX__) do{if((__INDEX__) == 0) LED4_GPIO_CLK_DISABLE(); else \ - if((__INDEX__) == 1) LED3_GPIO_CLK_DISABLE(); else \ - if((__INDEX__) == 2) LED5_GPIO_CLK_DISABLE(); else \ - if((__INDEX__) == 3) LED6_GPIO_CLK_DISABLE(); \ - }while(0) -/** - * @} - */ - -/** @addtogroup STM32F4_DISCOVERY_LOW_LEVEL_BUTTON - * @{ - */ -#define BUTTONn 1 - -/** - * @brief Wakeup push-button - */ -#define KEY_BUTTON_PIN GPIO_PIN_0 -#define KEY_BUTTON_GPIO_PORT GPIOA -#define KEY_BUTTON_GPIO_CLK_ENABLE() __GPIOA_CLK_ENABLE() -#define KEY_BUTTON_GPIO_CLK_DISABLE() __GPIOA_CLK_DISABLE() -#define KEY_BUTTON_EXTI_IRQn EXTI0_IRQn - -#define BUTTONx_GPIO_CLK_ENABLE(__INDEX__) do{if((__INDEX__) == 0) KEY_BUTTON_GPIO_CLK_ENABLE(); \ - }while(0) - -#define BUTTONx_GPIO_CLK_DISABLE(__INDEX__) do{if((__INDEX__) == 0) KEY_BUTTON_GPIO_CLK_DISABLE(); \ - }while(0) -/** - * @} - */ - -/** @addtogroup STM32F4_DISCOVERY_LOW_LEVEL_BUS - * @{ - */ - -/*############################### SPI1 #######################################*/ -#define DISCOVERY_SPIx SPI1 -#define DISCOVERY_SPIx_CLK_ENABLE() __SPI1_CLK_ENABLE() -#define DISCOVERY_SPIx_GPIO_PORT GPIOA /* GPIOA */ -#define DISCOVERY_SPIx_AF GPIO_AF5_SPI1 -#define DISCOVERY_SPIx_GPIO_CLK_ENABLE() __GPIOA_CLK_ENABLE() -#define DISCOVERY_SPIx_GPIO_CLK_DISABLE() __GPIOA_CLK_DISABLE() -#define DISCOVERY_SPIx_SCK_PIN GPIO_PIN_5 /* PA.05 */ -#define DISCOVERY_SPIx_MISO_PIN GPIO_PIN_6 /* PA.06 */ -#define DISCOVERY_SPIx_MOSI_PIN GPIO_PIN_7 /* PA.07 */ - -/* Maximum Timeout values for flags waiting loops. These timeouts are not based - on accurate values, they just guarantee that the application will not remain - stuck if the SPI communication is corrupted. - You may modify these timeout values depending on CPU frequency and application - conditions (interrupts routines ...). */ -#define SPIx_TIMEOUT_MAX 0x1000 /*
© COPYRIGHT(c) 2014 STMicroelectronics
- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Includes ------------------------------------------------------------------*/ -#include "stm32f4_discovery_accelerometer.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32F4_DISCOVERY - * @{ - */ - -/** @addtogroup STM32F4_DISCOVERY_ACCELEROMETER - * @brief This file includes the motion sensor driver for ACCELEROMETER motion sensor - * devices. - * @{ - */ - -/** @defgroup STM32F4_DISCOVERY_ACCELEROMETER_Private_TypesDefinitions - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F4_DISCOVERY_ACCELEROMETER_Private_Defines - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F4_DISCOVERY_ACCELEROMETER_Private_Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F4_DISCOVERY_ACCELEROMETER_Private_Variables - * @{ - */ -static ACCELERO_DrvTypeDef *AcceleroDrv; -/** - * @} - */ - -/** @defgroup STM32F4_DISCOVERY_ACCELEROMETER_Private_FunctionPrototypes - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F4_DISCOVERY_ACCELEROMETER_Private_Functions - * @{ - */ - -/** - * @brief Setx Accelerometer Initialization. - * @param None - * @retval ACCELERO_OK if no problem during initialization - */ -uint8_t BSP_ACCELERO_Init(void) -{ - uint8_t ret = ACCELERO_ERROR; - uint16_t ctrl = 0x0000; - LIS302DL_InitTypeDef lis302dl_initstruct; - LIS302DL_FilterConfigTypeDef lis302dl_filter = {0,0,0}; - LIS3DSH_InitTypeDef l1s3dsh_InitStruct; - - if(Lis302dlDrv.ReadID() == I_AM_LIS302DL) - { - /* Initialize the accelerometer driver structure */ - AcceleroDrv = &Lis302dlDrv; - - /* Set configuration of LIS302DL MEMS Accelerometer *********************/ - lis302dl_initstruct.Power_Mode = LIS302DL_LOWPOWERMODE_ACTIVE; - lis302dl_initstruct.Output_DataRate = LIS302DL_DATARATE_100; - lis302dl_initstruct.Axes_Enable = LIS302DL_XYZ_ENABLE; - lis302dl_initstruct.Full_Scale = LIS302DL_FULLSCALE_2_3; - lis302dl_initstruct.Self_Test = LIS302DL_SELFTEST_NORMAL; - - /* Configure MEMS: data rate, power mode, full scale, self test and axes */ - ctrl = (uint16_t) (lis302dl_initstruct.Output_DataRate | lis302dl_initstruct.Power_Mode | \ - lis302dl_initstruct.Full_Scale | lis302dl_initstruct.Self_Test | \ - lis302dl_initstruct.Axes_Enable); - - /* Configure the accelerometer main parameters */ - AcceleroDrv->Init(ctrl); - - /* MEMS High Pass Filter configuration */ - lis302dl_filter.HighPassFilter_Data_Selection = LIS302DL_FILTEREDDATASELECTION_OUTPUTREGISTER; - lis302dl_filter.HighPassFilter_CutOff_Frequency = LIS302DL_HIGHPASSFILTER_LEVEL_1; - lis302dl_filter.HighPassFilter_Interrupt = LIS302DL_HIGHPASSFILTERINTERRUPT_1_2; - - /* Configure MEMS high pass filter cut-off level, interrupt and data selection bits */ - ctrl = (uint8_t)(lis302dl_filter.HighPassFilter_Data_Selection | \ - lis302dl_filter.HighPassFilter_CutOff_Frequency | \ - lis302dl_filter.HighPassFilter_Interrupt); - - /* Configure the accelerometer LPF main parameters */ - AcceleroDrv->FilterConfig(ctrl); - - ret = ACCELERO_OK; - } - else if(Lis3dshDrv.ReadID() == I_AM_LIS3DSH) - { - /* Initialize the accelerometer driver structure */ - AcceleroDrv = &Lis3dshDrv; - - /* Set configuration of LIS3DSH MEMS Accelerometer **********************/ - l1s3dsh_InitStruct.Output_DataRate = LIS3DSH_DATARATE_100; - l1s3dsh_InitStruct.Axes_Enable = LIS3DSH_XYZ_ENABLE; - l1s3dsh_InitStruct.SPI_Wire = LIS3DSH_SERIALINTERFACE_4WIRE; - l1s3dsh_InitStruct.Self_Test = LIS3DSH_SELFTEST_NORMAL; - l1s3dsh_InitStruct.Full_Scale = LIS3DSH_FULLSCALE_2; - l1s3dsh_InitStruct.Filter_BW = LIS3DSH_FILTER_BW_800; - - /* Configure MEMS: power mode(ODR) and axes enable */ - ctrl = (uint16_t) (l1s3dsh_InitStruct.Output_DataRate | \ - l1s3dsh_InitStruct.Axes_Enable); - - /* Configure MEMS: full scale and self test */ - ctrl |= (uint16_t) ((l1s3dsh_InitStruct.SPI_Wire | \ - l1s3dsh_InitStruct.Self_Test | \ - l1s3dsh_InitStruct.Full_Scale | \ - l1s3dsh_InitStruct.Filter_BW) << 8); - - /* Configure the accelerometer main parameters */ - AcceleroDrv->Init(ctrl); - - ret = ACCELERO_OK; - } - - else - { - ret = ACCELERO_ERROR; - } - return ret; -} - -/** - * @brief Read ID of Accelerometer component. - * @param None - * @retval ID - */ -uint8_t BSP_ACCELERO_ReadID(void) -{ - uint8_t id = 0x00; - - if(AcceleroDrv->ReadID != NULL) - { - id = AcceleroDrv->ReadID(); - } - return id; -} - -/** - * @brief Reboot memory content of Accelerometer. - * @param None - * @retval None - */ -void BSP_ACCELERO_Reset(void) -{ - if(AcceleroDrv->Reset != NULL) - { - AcceleroDrv->Reset(); - } -} - -/** - * @brief Configure Accelerometer click IT. - * @param None - * @retval None - */ -void BSP_ACCELERO_Click_ITConfig(void) -{ - if(AcceleroDrv->ConfigIT != NULL) - { - AcceleroDrv->ConfigIT(); - } -} - -/** - * @brief Clear Accelerometer click IT. - * @param None - * @retval None - */ -void BSP_ACCELERO_Click_ITClear(void) -{ - if(AcceleroDrv->ClearIT != NULL) - { - AcceleroDrv->ClearIT(); - } -} - -/** - * @brief Get XYZ axes acceleration. - * @param pDataXYZ: Pointer to 3 angular acceleration axes. - * pDataXYZ[0] = X axis, pDataXYZ[1] = Y axis, pDataXYZ[2] = Z axis - * @retval None - */ -void BSP_ACCELERO_GetXYZ(int16_t *pDataXYZ) -{ - int16_t SwitchXY = 0; - - if(AcceleroDrv->GetXYZ != NULL) - { - AcceleroDrv->GetXYZ(pDataXYZ); - - /* Switch X and Y Axes in case of LIS302DL MEMS */ - if(AcceleroDrv == &Lis302dlDrv) - { - SwitchXY = pDataXYZ[0]; - pDataXYZ[0] = pDataXYZ[1]; - /* Invert Y Axis to be compliant with LIS3DSH MEMS */ - pDataXYZ[1] = -SwitchXY; - } - } -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32F4-Discovery/stm32f4_discovery_accelerometer.h b/bsp/stm32f411RE/Libraries/BSP/STM32F4-Discovery/stm32f4_discovery_accelerometer.h deleted file mode 100644 index 084be40cd6..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32F4-Discovery/stm32f4_discovery_accelerometer.h +++ /dev/null @@ -1,112 +0,0 @@ -/** - ****************************************************************************** - * @file stm32f4_discovery_accelerometer.h - * @author MCD Application Team - * @version V2.1.0 - * @date 14-August-2015 - * @brief This file contains all the functions prototypes for the - * stm32f4_discovery_accelerometer.c firmware driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2014 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32F4_DISCOVERY_ACCELEROMETER_H -#define __STM32F4_DISCOVERY_ACCELEROMETER_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm32f4_discovery.h" - -/* Include Accelerometer component drivers */ -#include "../Components/lis302dl/lis302dl.h" -#include "../Components/lis3dsh/lis3dsh.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32F4_DISCOVERY - * @{ - */ - -/** @addtogroup STM32F4_DISCOVERY_ACCELEROMETER - * @{ - */ - -/** @defgroup STM32F4_DISCOVERY_ACCELEROMETER_Exported_Types - * @{ - */ -typedef enum -{ - ACCELERO_OK = 0, - ACCELERO_ERROR = 1, - ACCELERO_TIMEOUT = 2 -}ACCELERO_StatusTypeDef; -/** - * @} - */ - -/** @defgroup STM32F4_DISCOVERY_ACCELEROMETER_Exported_Functions - * @{ - */ -/* Accelerometer functions */ -uint8_t BSP_ACCELERO_Init(void); -uint8_t BSP_ACCELERO_ReadID(void); -void BSP_ACCELERO_Reset(void); -void BSP_ACCELERO_Click_ITConfig(void); -void BSP_ACCELERO_Click_ITClear(void); -void BSP_ACCELERO_GetXYZ(int16_t *pDataXYZ); - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32F4_DISCOVERY_ACCELEROMETER_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32F4-Discovery/stm32f4_discovery_audio.c b/bsp/stm32f411RE/Libraries/BSP/STM32F4-Discovery/stm32f4_discovery_audio.c deleted file mode 100644 index 287e30d4ae..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32F4-Discovery/stm32f4_discovery_audio.c +++ /dev/null @@ -1,1055 +0,0 @@ -/** - ****************************************************************************** - * @file stm32f4_discovery_audio.c - * @author MCD Application Team - * @version V2.1.0 - * @date 14-August-2015 - * @brief This file provides the Audio driver for the STM32F4-Discovery - * board. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2014 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/*============================================================================== - User NOTES -1. How To use this driver: --------------------------- - - This driver supports STM32F4xx devices on STM32F4-Discovery Kit: - a) to play an audio file (all functions names start by BSP_AUDIO_OUT_xxx) - b) to record an audio file through MP45DT02, ST MEMS (all functions names start by AUDIO_IN_xxx) - -a) PLAY A FILE: -============== - + Call the function BSP_AUDIO_OUT_Init( - OutputDevice: physical output mode (OUTPUT_DEVICE_SPEAKER, - OUTPUT_DEVICE_HEADPHONE, OUTPUT_DEVICE_AUTO or - OUTPUT_DEVICE_BOTH) - Volume: initial volume to be set (0 is min (mute), 100 is max (100%) - AudioFreq: Audio frequency in Hz (8000, 16000, 22500, 32000 ...) - this parameter is relative to the audio file/stream type. - ) - This function configures all the hardware required for the audio application (codec, I2C, I2S, - GPIOs, DMA and interrupt if needed). This function returns 0 if configuration is OK. - If the returned value is different from 0 or the function is stuck then the communication with - the codec (try to un-plug the power or reset device in this case). - - OUTPUT_DEVICE_SPEAKER: only speaker will be set as output for the audio stream. - - OUTPUT_DEVICE_HEADPHONE: only headphones will be set as output for the audio stream. - - OUTPUT_DEVICE_AUTO: Selection of output device is made through external switch (implemented - into the audio jack on the discovery board). When the Headphone is connected it is used - as output. When the headphone is disconnected from the audio jack, the output is - automatically switched to Speaker. - - OUTPUT_DEVICE_BOTH: both Speaker and Headphone are used as outputs for the audio stream - at the same time. - + Call the function BSP_AUDIO_OUT_Play( - pBuffer: pointer to the audio data file address - Size: size of the buffer to be sent in Bytes - ) - to start playing (for the first time) from the audio file/stream. - + Call the function BSP_AUDIO_OUT_Pause() to pause playing - + Call the function BSP_AUDIO_OUT_Resume() to resume playing. - Note. After calling BSP_AUDIO_OUT_Pause() function for pause, only BSP_AUDIO_OUT_Resume() should be called - for resume (it is not allowed to call BSP_AUDIO_OUT_Play() in this case). - Note. This function should be called only when the audio file is played or paused (not stopped). - + For each mode, you may need to implement the relative callback functions into your code. - The Callback functions are named BSP_AUDIO_OUT_XXXCallBack() and only their prototypes are declared in - the stm32f4_discovery_audio.h file. (refer to the example for more details on the callbacks implementations) - + To Stop playing, to modify the volume level, the frequency or to mute, use the functions - BSP_AUDIO_OUT_Stop(), BSP_AUDIO_OUT_SetVolume(), AUDIO_OUT_SetFrequency() BSP_AUDIO_OUT_SetOutputMode and BSP_AUDIO_OUT_SetMute(). - + The driver API and the callback functions are at the end of the stm32f4_discovery_audio.h file. - -Driver architecture: --------------------- - + This driver provide the High Audio Layer: consists of the function API exported in the stm32f4_discovery_audio.h file - (BSP_AUDIO_OUT_Init(), BSP_AUDIO_OUT_Play() ...) - + This driver provide also the Media Access Layer (MAL): which consists of functions allowing to access the media containing/ - providing the audio file/stream. These functions are also included as local functions into - the stm32f4_discovery_audio.c file (I2S3_Init()...) - -Known Limitations: -------------------- - 1- When using the Speaker, if the audio file quality is not high enough, the speaker output - may produce high and uncomfortable noise level. To avoid this issue, to use speaker - output properly, try to increase audio file sampling rate (typically higher than 48KHz). - This operation will lead to larger file size. - 2- Communication with the audio codec (through I2C) may be corrupted if it is interrupted by some - user interrupt routines (in this case, interrupts could be disabled just before the start of - communication then re-enabled when it is over). Note that this communication is only done at - the configuration phase (BSP_AUDIO_OUT_Init() or BSP_AUDIO_OUT_Stop()) and when Volume control modification is - performed (BSP_AUDIO_OUT_SetVolume() or BSP_AUDIO_OUT_SetMute()or BSP_AUDIO_OUT_SetOutputMode()). - When the audio data is played, no communication is required with the audio codec. - 3- Parsing of audio file is not implemented (in order to determine audio file properties: Mono/Stereo, Data size, - File size, Audio Frequency, Audio Data header size ...). The configuration is fixed for the given audio file. - 4- Supports only Stereo audio streaming. To play mono audio streams, each data should be sent twice - on the I2S or should be duplicated on the source buffer. Or convert the stream in stereo before playing. - 5- Supports only 16-bits audio data size. - -b) RECORD A FILE: -================ - + Call the function BSP_AUDIO_IN_Init( - AudioFreq: Audio frequency in Hz (8000, 16000, 22500, 32000 ...) - ) - This function configures all the hardware required for the audio application (I2S, - GPIOs, DMA and interrupt if needed). This function returns 0 if configuration is OK. - - + Call the function BSP_AUDIO_IN_Record( - pbuf Main buffer pointer for the recorded data storing - size Current size of the recorded buffer - ) - to start recording from the microphone. - - + User needs to implement user callbacks to retrieve data saved in the record buffer - (AUDIO_IN_RxHalfCpltCallback/BSP_AUDIO_IN_ReceiveComplete_CallBack) - - + Call the function AUDIO_IN_STOP() to stop recording - -==============================================================================*/ - -/* Includes ------------------------------------------------------------------*/ -#include "stm32f4_discovery_audio.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32F4_DISCOVERY - * @{ - */ - -/** @addtogroup STM32F4_DISCOVERY_AUDIO - * @brief This file includes the low layer audio driver available on STM32F4-Discovery - * discovery board. - * @{ - */ - -/** @defgroup STM32F4_DISCOVERY_AUDIO_Private_Types - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F4_DISCOVERY_AUDIO_Private_Defines - * @{ - */ -/* These PLL parameters are valid when the f(VCO clock) = 1Mhz */ -const uint32_t I2SFreq[8] = {8000, 11025, 16000, 22050, 32000, 44100, 48000, 96000}; -const uint32_t I2SPLLN[8] = {256, 429, 213, 429, 426, 271, 258, 344}; -const uint32_t I2SPLLR[8] = {5, 4, 4, 4, 4, 6, 3, 1}; -/** - * @} - */ - -/** @defgroup STM32F4_DISCOVERY_AUDIO_Private_Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F4_DISCOVERY_AUDIO_Private_Variables - * @{ - */ -/*##### PLAY #####*/ -static AUDIO_DrvTypeDef *pAudioDrv; -I2S_HandleTypeDef hAudioOutI2s; - -/*### RECORDER ###*/ -I2S_HandleTypeDef hAudioInI2s; - -PDMFilter_InitStruct Filter[DEFAULT_AUDIO_IN_CHANNEL_NBR]; -__IO uint16_t AudioInVolume = DEFAULT_AUDIO_IN_VOLUME; -/** - * @} - */ - -/** @defgroup STM32F4_DISCOVERY_AUDIO_Private_Function_Prototypes - * @{ - */ -static void I2S3_MspInit(void); -static void I2S3_Init(uint32_t AudioFreq); - -static void I2S2_MspInit(void); -static void I2S2_Init(uint32_t AudioFreq); -static void PDMDecoder_Init(uint32_t AudioFreq, uint32_t ChnlNbr); -/** - * @} - */ - -/** @defgroup STM32F4_DISCOVERY_AUDIO_OUT_Private_Functions - * @{ - */ - -/** - * @brief Configures the audio peripherals. - * @param OutputDevice: OUTPUT_DEVICE_SPEAKER, OUTPUT_DEVICE_HEADPHONE, - * OUTPUT_DEVICE_BOTH or OUTPUT_DEVICE_AUTO . - * @param Volume: Initial volume level (from 0 (Mute) to 100 (Max)) - * @param AudioFreq: Audio frequency used to play the audio stream. - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_Init(uint16_t OutputDevice, uint8_t Volume, uint32_t AudioFreq) -{ - uint8_t ret = AUDIO_ERROR; - uint32_t deviceid = 0x00; - RCC_PeriphCLKInitTypeDef rccclkinit; - uint8_t index = 0, freqindex = 0xFF; - - for(index = 0; index < 8; index++) - { - if(I2SFreq[index] == AudioFreq) - { - freqindex = index; - } - } - /* Enable PLLI2S clock */ - HAL_RCCEx_GetPeriphCLKConfig(&rccclkinit); - /* PLLI2S_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */ - if ((freqindex & 0x7) == 0) - { - /* I2S clock config - PLLI2S_VCO = f(VCO clock) = f(PLLI2S clock input) × (PLLI2SN/PLLM) - I2SCLK = f(PLLI2S clock output) = f(VCO clock) / PLLI2SR */ - rccclkinit.PeriphClockSelection = RCC_PERIPHCLK_I2S; - rccclkinit.PLLI2S.PLLI2SN = I2SPLLN[freqindex]; - rccclkinit.PLLI2S.PLLI2SR = I2SPLLR[freqindex]; - HAL_RCCEx_PeriphCLKConfig(&rccclkinit); - } - else - { - /* I2S clock config - PLLI2S_VCO = f(VCO clock) = f(PLLI2S clock input) × (PLLI2SN/PLLM) - I2SCLK = f(PLLI2S clock output) = f(VCO clock) / PLLI2SR */ - rccclkinit.PeriphClockSelection = RCC_PERIPHCLK_I2S; - rccclkinit.PLLI2S.PLLI2SN = 258; - rccclkinit.PLLI2S.PLLI2SR = 3; - HAL_RCCEx_PeriphCLKConfig(&rccclkinit); - } - - deviceid = cs43l22_drv.ReadID(AUDIO_I2C_ADDRESS); - - if((deviceid & CS43L22_ID_MASK) == CS43L22_ID) - { - /* Initialize the audio driver structure */ - pAudioDrv = &cs43l22_drv; - ret = AUDIO_OK; - } - else - { - ret = AUDIO_ERROR; - } - - if(ret == AUDIO_OK) - { - pAudioDrv->Init(AUDIO_I2C_ADDRESS, OutputDevice, Volume, AudioFreq); - /* I2S data transfer preparation: - Prepare the Media to be used for the audio transfer from memory to I2S peripheral */ - /* Configure the I2S peripheral */ - I2S3_Init(AudioFreq); - } - - return ret; -} - -/** - * @brief Starts playing audio stream from a data buffer for a determined size. - * @param pBuffer: Pointer to the buffer - * @param Size: Number of audio data BYTES. - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_Play(uint16_t* pBuffer, uint32_t Size) -{ - /* Call the audio Codec Play function */ - if(pAudioDrv->Play(AUDIO_I2C_ADDRESS, pBuffer, Size) != 0) - { - return AUDIO_ERROR; - } - else - { - /* Update the Media layer and enable it for play */ - HAL_I2S_Transmit_DMA(&hAudioOutI2s, pBuffer, DMA_MAX(Size/AUDIODATA_SIZE)); - - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; - } -} - -/** - * @brief Sends n-Bytes on the I2S interface. - * @param pData: Pointer to data address - * @param Size: Number of data to be written - * @retval None - */ -void BSP_AUDIO_OUT_ChangeBuffer(uint16_t *pData, uint16_t Size) -{ - HAL_I2S_Transmit_DMA(&hAudioOutI2s, pData, Size); -} - -/** - * @brief Pauses the audio file stream. In case of using DMA, the DMA Pause - * feature is used. - * @WARNING When calling BSP_AUDIO_OUT_Pause() function for pause, only the - * BSP_AUDIO_OUT_Resume() function should be called for resume (use of BSP_AUDIO_OUT_Play() - * function for resume could lead to unexpected behavior). - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_Pause(void) -{ - /* Call the Audio Codec Pause/Resume function */ - if(pAudioDrv->Pause(AUDIO_I2C_ADDRESS) != 0) - { - return AUDIO_ERROR; - } - else - { - /* Call the Media layer pause function */ - HAL_I2S_DMAPause(&hAudioOutI2s); - - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; - } -} - -/** - * @brief Resumes the audio file streaming. - * @WARNING When calling BSP_AUDIO_OUT_Pause() function for pause, only - * BSP_AUDIO_OUT_Resume() function should be called for resume (use of BSP_AUDIO_OUT_Play() - * function for resume could lead to unexpected behavior). - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_Resume(void) -{ - /* Call the Audio Codec Pause/Resume function */ - if(pAudioDrv->Resume(AUDIO_I2C_ADDRESS) != 0) - { - return AUDIO_ERROR; - } - else - { - /* Call the Media layer resume function */ - HAL_I2S_DMAResume(&hAudioOutI2s); - - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; - } -} - -/** - * @brief Stops audio playing and Power down the Audio Codec. - * @param Option: could be one of the following parameters - * - CODEC_PDWN_HW: completely shut down the codec (physically). - * Then need to reconfigure the Codec after power on. - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_Stop(uint32_t Option) -{ - /* Call DMA Stop to disable DMA stream before stopping codec */ - HAL_I2S_DMAStop(&hAudioOutI2s); - - /* Call Audio Codec Stop function */ - if(pAudioDrv->Stop(AUDIO_I2C_ADDRESS, Option) != 0) - { - return AUDIO_ERROR; - } - else - { - if(Option == CODEC_PDWN_HW) - { - /* Wait at least 1ms */ - HAL_Delay(1); - - /* Reset the pin */ - HAL_GPIO_WritePin(AUDIO_RESET_GPIO, AUDIO_RESET_PIN, GPIO_PIN_RESET); - } - - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; - } -} - -/** - * @brief Controls the current audio volume level. - * @param Volume: Volume level to be set in percentage from 0% to 100% (0 for - * Mute and 100 for Max volume level). - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_SetVolume(uint8_t Volume) -{ - /* Call the codec volume control function with converted volume value */ - if(pAudioDrv->SetVolume(AUDIO_I2C_ADDRESS, Volume) != 0) - { - return AUDIO_ERROR; - } - else - { - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; - } -} - -/** - * @brief Enables or disables the MUTE mode by software - * @param Cmd: could be AUDIO_MUTE_ON to mute sound or AUDIO_MUTE_OFF to - * unmute the codec and restore previous volume level. - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_SetMute(uint32_t Cmd) -{ - /* Call the Codec Mute function */ - if(pAudioDrv->SetMute(AUDIO_I2C_ADDRESS, Cmd) != 0) - { - return AUDIO_ERROR; - } - else - { - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; - } -} - -/** - * @brief Switch dynamically (while audio file is played) the output target - * (speaker or headphone). - * @note This function modifies a global variable of the audio codec driver: OutputDev. - * @param Output: specifies the audio output target: OUTPUT_DEVICE_SPEAKER, - * OUTPUT_DEVICE_HEADPHONE, OUTPUT_DEVICE_BOTH or OUTPUT_DEVICE_AUTO - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_SetOutputMode(uint8_t Output) -{ - /* Call the Codec output Device function */ - if(pAudioDrv->SetOutputMode(AUDIO_I2C_ADDRESS, Output) != 0) - { - return AUDIO_ERROR; - } - else - { - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; - } -} - -/** - * @brief Update the audio frequency. - * @param AudioFreq: Audio frequency used to play the audio stream. - * @retval None - * @note This API should be called after the BSP_AUDIO_OUT_Init() to adjust the - * audio frequency. - */ -void BSP_AUDIO_OUT_SetFrequency(uint32_t AudioFreq) -{ - RCC_PeriphCLKInitTypeDef rccclkinit; - - /* Enable PLLI2S clock */ - HAL_RCCEx_GetPeriphCLKConfig(&rccclkinit); - /* PLLI2S_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */ - if ((AudioFreq & 0x7) == 0) - { - /* Audio frequency multiple of 8 (8/16/32/48/96/192) */ - /* PLLI2S_VCO Output = PLLI2S_VCO Input * PLLI2SN = 192 Mhz */ - /* I2SCLK = PLLI2S_VCO Output/PLLI2SR = 192/6 = 32 Mhz */ - rccclkinit.PeriphClockSelection = RCC_PERIPHCLK_I2S; - rccclkinit.PLLI2S.PLLI2SN = 192; - rccclkinit.PLLI2S.PLLI2SR = 6; - HAL_RCCEx_PeriphCLKConfig(&rccclkinit); - } - else - { - /* Other Frequency (11.025/22.500/44.100) */ - /* PLLI2S_VCO Output = PLLI2S_VCO Input * PLLI2SN = 290 Mhz */ - /* I2SCLK = PLLI2S_VCO Output/PLLI2SR = 290/2 = 145 Mhz */ - rccclkinit.PeriphClockSelection = RCC_PERIPHCLK_I2S; - rccclkinit.PLLI2S.PLLI2SN = 290; - rccclkinit.PLLI2S.PLLI2SR = 2; - HAL_RCCEx_PeriphCLKConfig(&rccclkinit); - } - - /* Update the I2S audio frequency configuration */ - I2S3_Init(AudioFreq); -} - -/** - * @brief Tx Transfer completed callbacks. - * @param hi2s: I2S handle - * @retval None - */ -void HAL_I2S_TxCpltCallback(I2S_HandleTypeDef *hi2s) -{ - if(hi2s->Instance == I2S3) - { - /* Call the user function which will manage directly transfer complete */ - BSP_AUDIO_OUT_TransferComplete_CallBack(); - } -} - -/** - * @brief Tx Half Transfer completed callbacks. - * @param hi2s: I2S handle - * @retval None - */ -void HAL_I2S_TxHalfCpltCallback(I2S_HandleTypeDef *hi2s) -{ - if(hi2s->Instance == I2S3) - { - /* Manage the remaining file size and new address offset: This function should - be coded by user (its prototype is already declared in stm32f4_discovery_audio.h) */ - BSP_AUDIO_OUT_HalfTransfer_CallBack(); - } -} - -/** - * @brief Manages the DMA full Transfer complete event. - * @param None - * @retval None - */ -__weak void BSP_AUDIO_OUT_TransferComplete_CallBack(void) -{ -} - -/** - * @brief Manages the DMA Half Transfer complete event. - * @param None - * @retval None - */ -__weak void BSP_AUDIO_OUT_HalfTransfer_CallBack(void) -{ -} - -/** - * @brief Manages the DMA FIFO error event. - * @param None - * @retval None - */ -__weak void BSP_AUDIO_OUT_Error_CallBack(void) -{ -} - -/******************************************************************************* - Static Functions -*******************************************************************************/ - -/** - * @brief AUDIO OUT I2S MSP Init. - * @param None - * @retval None - */ -static void I2S3_MspInit(void) -{ - static DMA_HandleTypeDef hdma_i2sTx; - GPIO_InitTypeDef GPIO_InitStruct; - I2S_HandleTypeDef *hi2s = &hAudioOutI2s; - - /* Enable I2S3 clock */ - I2S3_CLK_ENABLE(); - - /*** Configure the GPIOs ***/ - /* Enable I2S GPIO clocks */ - I2S3_SCK_SD_CLK_ENABLE(); - I2S3_WS_CLK_ENABLE(); - - /* I2S3 pins configuration: WS, SCK and SD pins ----------------------------*/ - GPIO_InitStruct.Pin = I2S3_SCK_PIN | I2S3_SD_PIN; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FAST; - GPIO_InitStruct.Alternate = I2S3_SCK_SD_WS_AF; - HAL_GPIO_Init(I2S3_SCK_SD_GPIO_PORT, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = I2S3_WS_PIN ; - HAL_GPIO_Init(I2S3_WS_GPIO_PORT, &GPIO_InitStruct); - - /* I2S3 pins configuration: MCK pin */ - I2S3_MCK_CLK_ENABLE(); - GPIO_InitStruct.Pin = I2S3_MCK_PIN; - HAL_GPIO_Init(I2S3_MCK_GPIO_PORT, &GPIO_InitStruct); - - /* Enable the I2S DMA clock */ - I2S3_DMAx_CLK_ENABLE(); - - if(hi2s->Instance == I2S3) - { - /* Configure the hdma_i2sTx handle parameters */ - hdma_i2sTx.Init.Channel = I2S3_DMAx_CHANNEL; - hdma_i2sTx.Init.Direction = DMA_MEMORY_TO_PERIPH; - hdma_i2sTx.Init.PeriphInc = DMA_PINC_DISABLE; - hdma_i2sTx.Init.MemInc = DMA_MINC_ENABLE; - hdma_i2sTx.Init.PeriphDataAlignment = I2S3_DMAx_PERIPH_DATA_SIZE; - hdma_i2sTx.Init.MemDataAlignment = I2S3_DMAx_MEM_DATA_SIZE; - hdma_i2sTx.Init.Mode = DMA_NORMAL; - hdma_i2sTx.Init.Priority = DMA_PRIORITY_HIGH; - hdma_i2sTx.Init.FIFOMode = DMA_FIFOMODE_ENABLE; - hdma_i2sTx.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; - hdma_i2sTx.Init.MemBurst = DMA_MBURST_SINGLE; - hdma_i2sTx.Init.PeriphBurst = DMA_PBURST_SINGLE; - - hdma_i2sTx.Instance = I2S3_DMAx_STREAM; - - /* Associate the DMA handle */ - __HAL_LINKDMA(hi2s, hdmatx, hdma_i2sTx); - - /* Deinitialize the Stream for new transfer */ - HAL_DMA_DeInit(&hdma_i2sTx); - - /* Configure the DMA Stream */ - HAL_DMA_Init(&hdma_i2sTx); - } - - /* I2S DMA IRQ Channel configuration */ - HAL_NVIC_SetPriority(I2S3_DMAx_IRQ, AUDIO_OUT_IRQ_PREPRIO, 0); - HAL_NVIC_EnableIRQ(I2S3_DMAx_IRQ); -} - -/** - * @brief Initializes the Audio Codec audio interface (I2S). - * @param AudioFreq: Audio frequency to be configured for the I2S peripheral. - * @retval None - */ -static void I2S3_Init(uint32_t AudioFreq) -{ - /* Initialize the hAudioOutI2s Instance parameter */ - hAudioOutI2s.Instance = I2S3; - - /* Disable I2S block */ - __HAL_I2S_DISABLE(&hAudioOutI2s); - - /* I2S3 peripheral configuration */ - hAudioOutI2s.Init.AudioFreq = AudioFreq; - hAudioOutI2s.Init.ClockSource = I2S_CLOCK_PLL; - hAudioOutI2s.Init.CPOL = I2S_CPOL_LOW; - hAudioOutI2s.Init.DataFormat = I2S_DATAFORMAT_16B; - hAudioOutI2s.Init.MCLKOutput = I2S_MCLKOUTPUT_ENABLE; - hAudioOutI2s.Init.Mode = I2S_MODE_MASTER_TX; - hAudioOutI2s.Init.Standard = I2S_STANDARD; - /* Initialize the I2S peripheral with the structure above */ - if(HAL_I2S_GetState(&hAudioOutI2s) == HAL_I2S_STATE_RESET) - { - I2S3_MspInit(); - } - - HAL_I2S_Init(&hAudioOutI2s); -} - -/** - * @} - */ - -/** @defgroup STM32F4_DISCOVERY_AUDIO_IN_Private_Functions - * @{ - */ - -/** - * @brief Initializes wave recording. - * @param AudioFreq: Audio frequency to be configured for the I2S peripheral. - * @param BitRes: Audio frequency to be configured for the I2S peripheral. - * @param ChnlNbr: Audio frequency to be configured for the I2S peripheral. - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_IN_Init(uint32_t AudioFreq, uint32_t BitRes, uint32_t ChnlNbr) -{ - RCC_PeriphCLKInitTypeDef rccclkinit; - - /*Enable PLLI2S clock*/ - HAL_RCCEx_GetPeriphCLKConfig(&rccclkinit); - /* PLLI2S_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */ - if ((AudioFreq & 0x7) == 0) - { - /* Audio frequency multiple of 8 (8/16/32/48/96/192)*/ - /* PLLI2S_VCO Output = PLLI2S_VCO Input * PLLI2SN = 192 Mhz */ - /* I2SCLK = PLLI2S_VCO Output/PLLI2SR = 192/6 = 32 Mhz */ - rccclkinit.PeriphClockSelection = RCC_PERIPHCLK_I2S; - rccclkinit.PLLI2S.PLLI2SN = 192; - rccclkinit.PLLI2S.PLLI2SR = 6; - HAL_RCCEx_PeriphCLKConfig(&rccclkinit); - } - else - { - /* Other Frequency (11.025/22.500/44.100) */ - /* PLLI2S_VCO Output = PLLI2S_VCO Input * PLLI2SN = 290 Mhz */ - /* I2SCLK = PLLI2S_VCO Output/PLLI2SR = 290/2 = 145 Mhz */ - rccclkinit.PeriphClockSelection = RCC_PERIPHCLK_I2S; - rccclkinit.PLLI2S.PLLI2SN = 290; - rccclkinit.PLLI2S.PLLI2SR = 2; - HAL_RCCEx_PeriphCLKConfig(&rccclkinit); - } - - /* Configure the PDM library */ - PDMDecoder_Init(AudioFreq, ChnlNbr); - - /* Configure the I2S2 */ - I2S2_Init(AudioFreq); - - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; -} - -/** - * @brief Starts audio recording. - * @param pbuf: Main buffer pointer for the recorded data storing - * @param size: Current size of the recorded buffer - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_IN_Record(uint16_t* pbuf, uint32_t size) -{ - uint32_t ret = AUDIO_ERROR; - - /* Start the process receive DMA */ - HAL_I2S_Receive_DMA(&hAudioInI2s, pbuf, size); - - /* Return AUDIO_OK when all operations are correctly done */ - ret = AUDIO_OK; - - return ret; -} - -/** - * @brief Stops audio recording. - * @param None - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_IN_Stop(void) -{ - uint32_t ret = AUDIO_ERROR; - - /* Call the Media layer pause function */ - HAL_I2S_DMAStop(&hAudioInI2s); - - /* Return AUDIO_OK when all operations are correctly done */ - ret = AUDIO_OK; - - return ret; -} - -/** - * @brief Pauses the audio file stream. - * @param None - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_IN_Pause(void) -{ - /* Call the Media layer pause function */ - HAL_I2S_DMAPause(&hAudioInI2s); - - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; -} - -/** - * @brief Resumes the audio file stream. - * @param None - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_IN_Resume(void) -{ - /* Call the Media layer pause/resume function */ - HAL_I2S_DMAResume(&hAudioInI2s); - - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; -} - -/** - * @brief Controls the audio in volume level. - * @param Volume: Volume level to be set in percentage from 0% to 100% (0 for - * Mute and 100 for Max volume level). - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_IN_SetVolume(uint8_t Volume) -{ - /* Set the Global variable AudioInVolume */ - AudioInVolume = Volume; - - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; -} - -/** - * @brief Converts audio format from PDM to PCM. - * @param PDMBuf: Pointer to data PDM buffer - * @param PCMBuf: Pointer to data PCM buffer - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_IN_PDMToPCM(uint16_t *PDMBuf, uint16_t *PCMBuf) -{ - uint16_t AppPDM[INTERNAL_BUFF_SIZE/2]; - uint32_t index = 0; - - /* PDM Demux */ - for(index = 0; indexInstance == I2S2) - { - /* Configure the hdma_i2sRx handle parameters */ - hdma_i2sRx.Init.Channel = I2S2_DMAx_CHANNEL; - hdma_i2sRx.Init.Direction = DMA_PERIPH_TO_MEMORY; - hdma_i2sRx.Init.PeriphInc = DMA_PINC_DISABLE; - hdma_i2sRx.Init.MemInc = DMA_MINC_ENABLE; - hdma_i2sRx.Init.PeriphDataAlignment = I2S2_DMAx_PERIPH_DATA_SIZE; - hdma_i2sRx.Init.MemDataAlignment = I2S2_DMAx_MEM_DATA_SIZE; - hdma_i2sRx.Init.Mode = DMA_CIRCULAR; - hdma_i2sRx.Init.Priority = DMA_PRIORITY_HIGH; - hdma_i2sRx.Init.FIFOMode = DMA_FIFOMODE_DISABLE; - hdma_i2sRx.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; - hdma_i2sRx.Init.MemBurst = DMA_MBURST_SINGLE; - hdma_i2sRx.Init.PeriphBurst = DMA_MBURST_SINGLE; - - hdma_i2sRx.Instance = I2S2_DMAx_STREAM; - - /* Associate the DMA handle */ - __HAL_LINKDMA(hi2s, hdmarx, hdma_i2sRx); - - /* Deinitialize the Stream for new transfer */ - HAL_DMA_DeInit(&hdma_i2sRx); - - /* Configure the DMA Stream */ - HAL_DMA_Init(&hdma_i2sRx); - } - - /* I2S DMA IRQ Channel configuration */ - HAL_NVIC_SetPriority(I2S2_DMAx_IRQ, AUDIO_IN_IRQ_PREPRIO, 0); - HAL_NVIC_EnableIRQ(I2S2_DMAx_IRQ); -} - -/** - * @brief Initializes the Audio Codec audio interface (I2S) - * @note This function assumes that the I2S input clock (through PLL_R in - * Devices RevA/Z and through dedicated PLLI2S_R in Devices RevB/Y) - * is already configured and ready to be used. - * @param AudioFreq: Audio frequency to be configured for the I2S peripheral. - * @retval None - */ -static void I2S2_Init(uint32_t AudioFreq) -{ - /* Initialize the hAudioInI2s Instance parameter */ - hAudioInI2s.Instance = I2S2; - - /* Disable I2S block */ - __HAL_I2S_DISABLE(&hAudioInI2s); - - /* I2S2 peripheral configuration */ - hAudioInI2s.Init.AudioFreq = 2 * AudioFreq; - hAudioInI2s.Init.ClockSource = I2S_CLOCK_PLL; - hAudioInI2s.Init.CPOL = I2S_CPOL_HIGH; - hAudioInI2s.Init.DataFormat = I2S_DATAFORMAT_16B; - hAudioInI2s.Init.MCLKOutput = I2S_MCLKOUTPUT_DISABLE; - hAudioInI2s.Init.Mode = I2S_MODE_MASTER_RX; - hAudioInI2s.Init.Standard = I2S_STANDARD_LSB; - - /* Initialize the I2S peripheral with the structure above */ - if(HAL_I2S_GetState(&hAudioInI2s) == HAL_I2S_STATE_RESET) - { - I2S2_MspInit(); - } - - HAL_I2S_Init(&hAudioInI2s); -} - -/** - * @} - */ - -/** @defgroup STM32F4_DISCOVERY_AUDIO_IN_OUT_Private_Functions - * @{ - */ - -/** - * @brief I2S error callbacks. - * @param hi2s: I2S handle - * @retval None - */ -void HAL_I2S_ErrorCallback(I2S_HandleTypeDef *hi2s) -{ - /* Manage the error generated on DMA FIFO: This function - should be coded by user (its prototype is already declared in stm32f4_discovery_audio.h) */ - if(hi2s->Instance == I2S3) - { - BSP_AUDIO_OUT_Error_CallBack(); - } - if(hi2s->Instance == I2S2) - { - BSP_AUDIO_IN_Error_Callback(); - } -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32F4-Discovery/stm32f4_discovery_audio.h b/bsp/stm32f411RE/Libraries/BSP/STM32F4-Discovery/stm32f4_discovery_audio.h deleted file mode 100644 index 6b3fadb982..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32F4-Discovery/stm32f4_discovery_audio.h +++ /dev/null @@ -1,258 +0,0 @@ -/** - ****************************************************************************** - * @file stm32f4_discovery_audio.h - * @author MCD Application Team - * @version V2.1.0 - * @date 14-August-2015 - * @brief This file contains the common defines and functions prototypes for - * stm32f4_discovery_audio.c driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2014 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32F4_DISCOVERY_AUDIO_H -#define __STM32F4_DISCOVERY_AUDIO_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -/* Include audio component Driver */ -#include "../Components/cs43l22/cs43l22.h" - -#include "stm32f4_discovery.h" -#include "../../../Middlewares/ST/STM32_Audio/Addons/PDM/pdm_filter.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32F4_DISCOVERY - * @{ - */ - -/** @defgroup STM32F4_DISCOVERY_AUDIO - * @{ - */ - - -/** @defgroup STM32F4_DISCOVERY_AUDIO_Exported_Types - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F4_DISCOVERY_AUDIO_OUT_Exported_Constants - * @{ - */ - -/*------------------------------------------------------------------------------ - AUDIO OUT CONFIGURATION -------------------------------------------------------------------------------*/ - -/* I2S peripheral configuration defines */ -#define I2S3 SPI3 -#define I2S3_CLK_ENABLE() __SPI3_CLK_ENABLE() -#define I2S3_SCK_SD_WS_AF GPIO_AF6_SPI3 -#define I2S3_SCK_SD_CLK_ENABLE() __GPIOC_CLK_ENABLE() -#define I2S3_MCK_CLK_ENABLE() __GPIOC_CLK_ENABLE() -#define I2S3_WS_CLK_ENABLE() __GPIOA_CLK_ENABLE() -#define I2S3_WS_PIN GPIO_PIN_4 -#define I2S3_SCK_PIN GPIO_PIN_10 -#define I2S3_SD_PIN GPIO_PIN_12 -#define I2S3_MCK_PIN GPIO_PIN_7 -#define I2S3_SCK_SD_GPIO_PORT GPIOC -#define I2S3_WS_GPIO_PORT GPIOA -#define I2S3_MCK_GPIO_PORT GPIOC - -/* I2S DMA Stream definitions */ -#define I2S3_DMAx_CLK_ENABLE() __DMA1_CLK_ENABLE() -#define I2S3_DMAx_STREAM DMA1_Stream7 -#define I2S3_DMAx_CHANNEL DMA_CHANNEL_0 -#define I2S3_DMAx_IRQ DMA1_Stream7_IRQn -#define I2S3_DMAx_PERIPH_DATA_SIZE DMA_PDATAALIGN_HALFWORD -#define I2S3_DMAx_MEM_DATA_SIZE DMA_MDATAALIGN_HALFWORD -#define DMA_MAX_SZE 0xFFFF - -#define I2S3_IRQHandler DMA1_Stream7_IRQHandler - -/* Select the interrupt preemption priority and subpriority for the DMA interrupt */ -#define AUDIO_OUT_IRQ_PREPRIO 5 /* Select the preemption priority level(0 is the highest) */ - -/*------------------------------------------------------------------------------ - AUDIO IN CONFIGURATION -------------------------------------------------------------------------------*/ -/* SPI Configuration defines */ -#define I2S2 SPI2 -#define I2S2_CLK_ENABLE() __SPI2_CLK_ENABLE() -#define I2S2_SCK_PIN GPIO_PIN_10 -#define I2S2_SCK_GPIO_PORT GPIOB -#define I2S2_SCK_GPIO_CLK_ENABLE() __GPIOB_CLK_ENABLE() -#define I2S2_SCK_AF GPIO_AF5_SPI2 - -#define I2S2_MOSI_PIN GPIO_PIN_3 -#define I2S2_MOSI_GPIO_PORT GPIOC -#define I2S2_MOSI_GPIO_CLK_ENABLE() __GPIOC_CLK_ENABLE() -#define I2S2_MOSI_AF GPIO_AF5_SPI2 - -/* I2S DMA Stream Rx definitions */ -#define I2S2_DMAx_CLK_ENABLE() __DMA1_CLK_ENABLE() -#define I2S2_DMAx_STREAM DMA1_Stream3 -#define I2S2_DMAx_CHANNEL DMA_CHANNEL_0 -#define I2S2_DMAx_IRQ DMA1_Stream3_IRQn -#define I2S2_DMAx_PERIPH_DATA_SIZE DMA_PDATAALIGN_HALFWORD -#define I2S2_DMAx_MEM_DATA_SIZE DMA_MDATAALIGN_HALFWORD - -#define I2S2_IRQHandler DMA1_Stream3_IRQHandler - -/* Select the interrupt preemption priority and subpriority for the IT/DMA interrupt */ -#define AUDIO_IN_IRQ_PREPRIO 6 /* Select the preemption priority level(0 is the highest) */ - -/*------------------------------------------------------------------------------ - CONFIGURATION: Audio Driver Configuration parameters -------------------------------------------------------------------------------*/ - -#define AUDIODATA_SIZE 2 /* 16-bits audio data size */ - -/* Audio status definition */ -#define AUDIO_OK 0 -#define AUDIO_ERROR 1 -#define AUDIO_TIMEOUT 2 - -/* AudioFreq * DataSize (2 bytes) * NumChannels (Stereo: 2) */ -#define DEFAULT_AUDIO_IN_FREQ I2S_AUDIOFREQ_16K -#define DEFAULT_AUDIO_IN_BIT_RESOLUTION 16 -#define DEFAULT_AUDIO_IN_CHANNEL_NBR 1 /* Mono = 1, Stereo = 2 */ -#define DEFAULT_AUDIO_IN_VOLUME 64 - -/* PDM buffer input size */ -#define INTERNAL_BUFF_SIZE 128*DEFAULT_AUDIO_IN_FREQ/16000*DEFAULT_AUDIO_IN_CHANNEL_NBR -/* PCM buffer output size */ -#define PCM_OUT_SIZE DEFAULT_AUDIO_IN_FREQ/1000 -#define CHANNEL_DEMUX_MASK 0x55 - -/*------------------------------------------------------------------------------ - OPTIONAL Configuration defines parameters -------------------------------------------------------------------------------*/ - -/** - * @} - */ - -/** @defgroup STM32F4_DISCOVERY_AUDIO_Exported_Variables - * @{ - */ -extern __IO uint16_t AudioInVolume; -/** - * @} - */ - -/** @defgroup STM32F4_DISCOVERY_AUDIO_Exported_Macros AUDIO_Exported_Macros - * @{ - */ -#define DMA_MAX(_X_) (((_X_) <= DMA_MAX_SZE)? (_X_):DMA_MAX_SZE) -/** - * @} - */ - -/** @defgroup STM32F4_DISCOVERY_AUDIO_OUT_Exported_Functions - * @{ - */ -uint8_t BSP_AUDIO_OUT_Init(uint16_t OutputDevice, uint8_t Volume, uint32_t AudioFreq); -uint8_t BSP_AUDIO_OUT_Play(uint16_t* pBuffer, uint32_t Size); -void BSP_AUDIO_OUT_ChangeBuffer(uint16_t *pData, uint16_t Size); -uint8_t BSP_AUDIO_OUT_Pause(void); -uint8_t BSP_AUDIO_OUT_Resume(void); -uint8_t BSP_AUDIO_OUT_Stop(uint32_t Option); -uint8_t BSP_AUDIO_OUT_SetVolume(uint8_t Volume); -void BSP_AUDIO_OUT_SetFrequency(uint32_t AudioFreq); -uint8_t BSP_AUDIO_OUT_SetMute(uint32_t Cmd); -uint8_t BSP_AUDIO_OUT_SetOutputMode(uint8_t Output); - -/* User Callbacks: user has to implement these functions in his code if they are needed. */ -/* This function is called when the requested data has been completely transferred. */ -void BSP_AUDIO_OUT_TransferComplete_CallBack(void); - -/* This function is called when half of the requested buffer has been transferred. */ -void BSP_AUDIO_OUT_HalfTransfer_CallBack(void); - -/* This function is called when an Interrupt due to transfer error on or peripheral - error occurs. */ -void BSP_AUDIO_OUT_Error_CallBack(void); -/** - * @} - */ - -/** @defgroup STM32F4_DISCOVERY_AUDIO_IN_Exported_Functions - * @{ - */ -uint8_t BSP_AUDIO_IN_Init(uint32_t AudioFreq, uint32_t BitRes, uint32_t ChnlNbr); -uint8_t BSP_AUDIO_IN_Record(uint16_t *pData, uint32_t Size); -uint8_t BSP_AUDIO_IN_Stop(void); -uint8_t BSP_AUDIO_IN_Pause(void); -uint8_t BSP_AUDIO_IN_Resume(void); -uint8_t BSP_AUDIO_IN_SetVolume(uint8_t Volume); -uint8_t BSP_AUDIO_IN_PDMToPCM(uint16_t *PDMBuf, uint16_t *PCMBuf); -/* User Callbacks: user has to implement these functions in his code if they are needed. */ -/* This function should be implemented by the user application. - It is called into this driver when the current buffer is filled to prepare the next - buffer pointer and its size. */ -void BSP_AUDIO_IN_TransferComplete_CallBack(void); -void BSP_AUDIO_IN_HalfTransfer_CallBack(void); - -/* This function is called when an Interrupt due to transfer error on or peripheral - error occurs. */ -void BSP_AUDIO_IN_Error_Callback(void); - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32F4_DISCOVERY_AUDIO_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32F401-Discovery/Release_Notes.html b/bsp/stm32f411RE/Libraries/BSP/STM32F401-Discovery/Release_Notes.html deleted file mode 100644 index e61e3ca96c..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32F401-Discovery/Release_Notes.html +++ /dev/null @@ -1,621 +0,0 @@ - - - - - - - - - - - - - - - - - - - - Release Notes for STM32F401-Discovery Board Drivers - - - - - - - - - - -
-


-

-
- - - - - - -
- - - - - - - - - -
-

Back to Release page

-
-

Release -Notes for STM32F401-Discovery Board Drivers

-

-Copyright © 2015 STMicroelectronics -

- -

-

-
-

 

- - - - - - -

Update History

-

V2.2.0 / 14-August-2015

Main -Changes

- - - - - -
  • stm32f401_discovery.c
    • Add AUDIO_IO_DeInit() function to align with BSP Components Common drivers V4.0.0

V2.1.3 / 02-March-2015

Main -Changes

- - - - - -
  • stm32f401_discovery.c/.h
    • Align to STM32F4xx HAL Driver V1.3.0 for -__HAL_RCC_PPP_CLK_ENABLE() .

V2.1.2 / 10-December-2014

- - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- - - - - - - - - - - - - - - -
    -
  • stm32f401_discovery_accelerometer.h, stm32f401_discovery_audio.h and stm32f401_discovery_gyroscope.h:
    • Change "\" by "/" in the include path to fix compilation issue under Linux
    -
- -

V2.1.1 / 26-June-2014

- - - - - - - - - - - - - - - - - - - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- - - - - - - - - - - - - -
    -
  • stm32f401_discovery_audio.c/.h
    • BSP_AUDIO_OUT_Play(): uses the buffer size in byte instead of half-word
    • BSP_AUDIO_IN_PDMToPCM(): duplicates samples to make stereo audio stream (since a single microphone in mounted on STM32F401-Discovery)
    • I2S2_Init(): configures the I2S to clock the microphone at 1.024 MHz as required instead of 2.048MHz
    -
- - -

V2.1.0 / 19-June-2014

- - - - - - - - - - - - - - - - - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- - - - - - - - - - - -
    -
  • stm32f401_discovery.c/.h
  • -
      -
    • Enhance BSP_PB_Init() function by removing the call of __SYSCFG_CLK_ENABLE() already enabled in the HAL_GPIO_Init()
    • -
    -
  • stm32f401_discovery_audio.c/.h
  • -
      -
    • Add note that only the audio stereo format is supported
    • -
    -
  • stm32f401_discovery_gyroscope.c/.h
  • -
      -
    • Update BSP_GYRO_Init() to support new L3GD20 device ID (I_AM_L3GD20_TR)
    • -
    -
  • Comments clean up and typo corrections
  • -
- -

V2.0.0 / 18-February-2014

- - - - - - - - - - - - - - - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- - - - - - - - - -
    -
  • Major update -based on STM32Cube specification: drivers architecture and APIs -modified vs. V1.0.1, and thus the 2 versions are not compatible.
    -
  • This version has to be used only with STM32CubeF4 based development
  • -
-

V1.0.1 / 14-November-2013

-

Main -Changes

- -
  • stm32f429i_discovery_l3gd20.c -: Set SPI baudrate to 5.25 MHz to fit Gyroscope timing characteristics -(Gyroscope l3gd20 SPI interface max baud rate is 10MHz for write/read)

V1.0.0 / 11-September-2013

-

Main -Changes

- -
  • First official version of the STM32F401-Discovery Board Drivers

License

-
-
-Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met:
-
-
  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions -in binary form must reproduce the above copyright notice, this list of -conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of STMicroelectronics nor the names of its contributors may be used to endorse or promote products derived
    -
    -
-        from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- -
-
- - -
-
-
For -complete documentation on STM32 Microcontrollers -visit www.st.com/STM32
-
-

-
-
-

 

-
- - \ No newline at end of file diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32F401-Discovery/stm32f401_discovery.c b/bsp/stm32f411RE/Libraries/BSP/STM32F401-Discovery/stm32f401_discovery.c deleted file mode 100644 index 0fcd402dd5..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32F401-Discovery/stm32f401_discovery.c +++ /dev/null @@ -1,779 +0,0 @@ -/** - ****************************************************************************** - * @file stm32f401_discovery.c - * @author MCD Application Team - * @version V2.2.0 - * @date 14-August-2015 - * @brief This file provides set of firmware functions to manage LEDs and - * push-button available on STM32F401-Discovery Kit from STMicroelectronics. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2014 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Includes ------------------------------------------------------------------*/ -#include "stm32f401_discovery.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32F401_DISCOVERY - * @{ - */ - -/** @addtogroup STM32F401_DISCOVERY_LOW_LEVEL - * @brief This file provides set of firmware functions to manage Leds and push-button - * available on STM32F401-Discovery Kit from STMicroelectronics. - * @{ - */ - -/** @defgroup STM32F401_DISCOVERY_LOW_LEVEL_Private_TypesDefinitions - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F401_DISCOVERY_LOW_LEVEL_Private_Defines - * @{ - */ - -/** - * @brief STM32F401 DISCO BSP Driver version number V2.2.0 - */ -#define __STM32F401_DISCO_BSP_VERSION_MAIN (0x02) /*!< [31:24] main version */ -#define __STM32F401_DISCO_BSP_VERSION_SUB1 (0x02) /*!< [23:16] sub1 version */ -#define __STM32F401_DISCO_BSP_VERSION_SUB2 (0x00) /*!< [15:8] sub2 version */ -#define __STM32F401_DISCO_BSP_VERSION_RC (0x00) /*!< [7:0] release candidate */ -#define __STM32F401_DISCO_BSP_VERSION ((__STM32F401_DISCO_BSP_VERSION_MAIN << 24)\ - |(__STM32F401_DISCO_BSP_VERSION_SUB1 << 16)\ - |(__STM32F401_DISCO_BSP_VERSION_SUB2 << 8 )\ - |(__STM32F401_DISCO_BSP_VERSION_RC)) -/** - * @} - */ - -/** @defgroup STM32F401_DISCOVERY_LOW_LEVEL_Private_Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F401_DISCOVERY_LOW_LEVEL_Private_Variables - * @{ - */ -GPIO_TypeDef* GPIO_PORT[LEDn] = {LED4_GPIO_PORT, - LED3_GPIO_PORT, - LED5_GPIO_PORT, - LED6_GPIO_PORT}; - -const uint16_t GPIO_PIN[LEDn] = {LED4_PIN, - LED3_PIN, - LED5_PIN, - LED6_PIN}; - -GPIO_TypeDef* BUTTON_PORT[BUTTONn] = {KEY_BUTTON_GPIO_PORT}; -const uint16_t BUTTON_PIN[BUTTONn] = {KEY_BUTTON_PIN}; -const uint8_t BUTTON_IRQn[BUTTONn] = {KEY_BUTTON_EXTI_IRQn}; - -uint32_t I2cxTimeout = I2Cx_TIMEOUT_MAX; /* 0x01) - { - WriteAddr |= (uint8_t)MULTIPLEBYTE_CMD; - } - /* Set chip select Low at the start of the transmission */ - GYRO_CS_LOW(); - - /* Send the Address of the indexed register */ - SPIx_WriteRead(WriteAddr); - - /* Send the data that will be written into the device (MSB First) */ - while(NumByteToWrite >= 0x01) - { - SPIx_WriteRead(*pBuffer); - NumByteToWrite--; - pBuffer++; - } - - /* Set chip select High at the end of the transmission */ - GYRO_CS_HIGH(); -} - -/** - * @brief Reads a block of data from the GYRO. - * @param pBuffer: pointer to the buffer that receives the data read from the GYRO. - * @param ReadAddr: GYRO's internal address to read from. - * @param NumByteToRead: Number of bytes to read from the GYRO. - * @retval None - */ -void GYRO_IO_Read(uint8_t* pBuffer, uint8_t ReadAddr, uint16_t NumByteToRead) -{ - if(NumByteToRead > 0x01) - { - ReadAddr |= (uint8_t)(READWRITE_CMD | MULTIPLEBYTE_CMD); - } - else - { - ReadAddr |= (uint8_t)READWRITE_CMD; - } - - /* Set chip select Low at the start of the transmission */ - GYRO_CS_LOW(); - - /* Send the Address of the indexed register */ - SPIx_WriteRead(ReadAddr); - - /* Receive the data that will be read from the device (MSB First) */ - while(NumByteToRead > 0x00) - { - /* Send dummy byte (0x00) to generate the SPI clock to GYRO (Slave device) */ - *pBuffer = SPIx_WriteRead(DUMMY_BYTE); - NumByteToRead--; - pBuffer++; - } - - /* Set chip select High at the end of the transmission */ - GYRO_CS_HIGH(); -} - -/********************************* LINK AUDIO *********************************/ - -/** - * @brief Initializes Audio low level. - * @param None - * @retval None - */ -void AUDIO_IO_Init(void) -{ - GPIO_InitTypeDef GPIO_InitStruct; - - /* Enable Reset GPIO Clock */ - AUDIO_RESET_GPIO_CLK_ENABLE(); - - /* Audio reset pin configuration -------------------------------------------*/ - GPIO_InitStruct.Pin = AUDIO_RESET_PIN; - GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStruct.Speed = GPIO_SPEED_FAST; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(AUDIO_RESET_GPIO, &GPIO_InitStruct); - - I2Cx_Init(); - - /* Power Down the codec */ - CODEC_AUDIO_POWER_OFF(); - - /* Wait for a delay to insure registers erasing */ - HAL_Delay(5); - - /* Power on the codec */ - CODEC_AUDIO_POWER_ON(); - - /* Wait for a delay to insure registers erasing */ - HAL_Delay(5); -} - -/** - * @brief DeInitializes Audio low level. - * @param None - * @retval None - */ -void AUDIO_IO_DeInit(void) -{ - -} - -/** - * @brief Writes a single data. - * @param Addr: I2C address - * @param Reg: Reg address - * @param Value: Data to be written - * @retval None - */ -void AUDIO_IO_Write (uint8_t Addr, uint8_t Reg, uint8_t Value) -{ - I2Cx_WriteData(Addr, Reg, Value); -} - -/** - * @brief Reads a single data. - * @param Addr: I2C address - * @param Reg: Reg address - * @retval Data to be read - */ -uint8_t AUDIO_IO_Read (uint8_t Addr, uint8_t Reg) -{ - return I2Cx_ReadData(Addr, Reg); -} - -/****************************** LINK ACCELEROMETER ****************************/ - -/** - * @brief Configures COMPASS / ACCELERO I2C interface. - * @param None - * @retval None - */ -void COMPASSACCELERO_IO_Init(void) -{ - GPIO_InitTypeDef GPIO_InitStructure; - - /* Enable DRDY clock */ - ACCELERO_DRDY_GPIO_CLK_ENABLE(); - - /* MEMS DRDY pin configuration */ - GPIO_InitStructure.Pin = ACCELERO_DRDY_PIN; - GPIO_InitStructure.Mode = GPIO_MODE_INPUT; - GPIO_InitStructure.Pull = GPIO_NOPULL; - GPIO_InitStructure.Speed = GPIO_SPEED_FAST; - HAL_GPIO_Init(ACCELERO_DRDY_GPIO_PORT, &GPIO_InitStructure); - - I2Cx_Init(); -} - -/** - * @brief Configures COMPASS / ACCELERO click IT. - * @param None - * @retval None - */ -void COMPASSACCELERO_IO_ITConfig(void) -{ - GPIO_InitTypeDef GPIO_InitStructure; - - /* Enable INT1 and INT2 GPIO clock */ - ACCELERO_INT_GPIO_CLK_ENABLE(); - - /* Configure GPIO PINs to detect Interrupts */ - GPIO_InitStructure.Pin = ACCELERO_INT1_PIN | ACCELERO_INT2_PIN; - GPIO_InitStructure.Mode = GPIO_MODE_IT_RISING; - GPIO_InitStructure.Speed = GPIO_SPEED_FAST; - GPIO_InitStructure.Pull = GPIO_NOPULL; - HAL_GPIO_Init(ACCELERO_INT_GPIO_PORT, &GPIO_InitStructure); - - /* Enable and set COMPASS / ACCELERO Interrupt to the highest priority */ - HAL_NVIC_SetPriority(ACCELERO_INT1_EXTI_IRQn, 0x00, 0x00); - HAL_NVIC_EnableIRQ(ACCELERO_INT1_EXTI_IRQn); -} - -/** - * @brief Writes one byte to the COMPASS / ACCELERO. - * @param DeviceAddr: the slave address to be programmed - * @param RegisterAddr: the COMPASS / ACCELERO register to be written - * @param Value: Data to be written - * @retval None - */ -void COMPASSACCELERO_IO_Write(uint16_t DeviceAddr, uint8_t RegisterAddr, uint8_t Value) -{ - /* Call I2Cx Read data bus function */ - I2Cx_WriteData(DeviceAddr, RegisterAddr, Value); -} - -/** - * @brief Reads a block of data from the COMPASS / ACCELERO. - * @param DeviceAddr: the slave address to be programmed(ACC_I2C_ADDRESS or MAG_I2C_ADDRESS). - * @param RegisterAddr: the COMPASS / ACCELERO internal address register to read from - * @retval COMPASS / ACCELERO register value - */ -uint8_t COMPASSACCELERO_IO_Read(uint16_t DeviceAddr, uint8_t RegisterAddr) -{ - /* Call I2Cx Read data bus function */ - return I2Cx_ReadData(DeviceAddr, RegisterAddr); -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32F401-Discovery/stm32f401_discovery.h b/bsp/stm32f411RE/Libraries/BSP/STM32F401-Discovery/stm32f401_discovery.h deleted file mode 100644 index 67d39101e3..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32F401-Discovery/stm32f401_discovery.h +++ /dev/null @@ -1,313 +0,0 @@ -/** - ****************************************************************************** - * @file stm32f401_discovery.h - * @author MCD Application Team - * @version V2.2.0 - * @date 14-August-2015 - * @brief This file contains definitions for STM32F401-Discovery Kit's Leds and - * push-button hardware resources. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2014 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32F401_DISCOVERY_H -#define __STM32F401_DISCOVERY_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm32f4xx_hal.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32F401_DISCOVERY - * @{ - */ - -/** @addtogroup STM32F401_DISCOVERY_LOW_LEVEL - * @{ - */ - -/** @defgroup STM32F401_DISCOVERY_LOW_LEVEL_Exported_Types - * @{ - */ -typedef enum -{ - LED4 = 0, - LED3 = 1, - LED5 = 2, - LED6 = 3 -}Led_TypeDef; - -typedef enum -{ - BUTTON_KEY = 0, -}Button_TypeDef; - -typedef enum -{ - BUTTON_MODE_GPIO = 0, - BUTTON_MODE_EXTI = 1 -}ButtonMode_TypeDef; -/** - * @} - */ - -/** @defgroup STM32F401_DISCOVERY_LOW_LEVEL_Exported_Constants - * @{ - */ - -/** - * @brief Define for STM32F401_DISCOVERY board - */ -#if !defined (USE_STM32F401_DISCO) - #define USE_STM32F401_DISCO -#endif - -/** @addtogroup STM32F401_DISCOVERY_LOW_LEVEL_LED - * @{ - */ -#define LEDn 4 - -#define LED4_PIN GPIO_PIN_12 -#define LED4_GPIO_PORT GPIOD -#define LED4_GPIO_CLK_ENABLE() __GPIOD_CLK_ENABLE() -#define LED4_GPIO_CLK_DISABLE() __GPIOD_CLK_DISABLE() - - -#define LED3_PIN GPIO_PIN_13 -#define LED3_GPIO_PORT GPIOD -#define LED3_GPIO_CLK_ENABLE() __GPIOD_CLK_ENABLE() -#define LED3_GPIO_CLK_DISABLE() __GPIOD_CLK_DISABLE() - - -#define LED5_PIN GPIO_PIN_14 -#define LED5_GPIO_PORT GPIOD -#define LED5_GPIO_CLK_ENABLE() __GPIOD_CLK_ENABLE() -#define LED5_GPIO_CLK_DISABLE() __GPIOD_CLK_DISABLE() - - -#define LED6_PIN GPIO_PIN_15 -#define LED6_GPIO_PORT GPIOD -#define LED6_GPIO_CLK_ENABLE() __GPIOD_CLK_ENABLE() -#define LED6_GPIO_CLK_DISABLE() __GPIOD_CLK_DISABLE() - -#define LEDx_GPIO_CLK_ENABLE(__INDEX__) do{if((__INDEX__) == 0) LED4_GPIO_CLK_ENABLE(); else \ - if((__INDEX__) == 1) LED3_GPIO_CLK_ENABLE(); else \ - if((__INDEX__) == 2) LED5_GPIO_CLK_ENABLE(); else \ - if((__INDEX__) == 3) LED6_GPIO_CLK_ENABLE(); \ - }while(0) - -#define LEDx_GPIO_CLK_DISABLE(__INDEX__) do{if((__INDEX__) == 0) LED4_GPIO_CLK_DISABLE(); else \ - if((__INDEX__) == 1) LED3_GPIO_CLK_DISABLE(); else \ - if((__INDEX__) == 2) LED5_GPIO_CLK_DISABLE(); else \ - if((__INDEX__) == 3) LED6_GPIO_CLK_DISABLE(); \ - }while(0) -/** - * @} - */ - -/** @addtogroup STM32F401_DISCOVERY_LOW_LEVEL_BUTTON - * @{ - */ -#define BUTTONn 1 - -/** - * @brief Wakeup push-button - */ -#define KEY_BUTTON_PIN GPIO_PIN_0 -#define KEY_BUTTON_GPIO_PORT GPIOA -#define KEY_BUTTON_GPIO_CLK_ENABLE() __GPIOA_CLK_ENABLE() -#define KEY_BUTTON_GPIO_CLK_DISABLE() __GPIOA_CLK_DISABLE() -#define KEY_BUTTON_EXTI_IRQn EXTI0_IRQn - -#define BUTTONx_GPIO_CLK_ENABLE(__INDEX__) do{if((__INDEX__) == 0) KEY_BUTTON_GPIO_CLK_ENABLE(); \ - }while(0) -#define BUTTONx_GPIO_CLK_DISABLE(__INDEX__) do{if((__INDEX__) == 0) KEY_BUTTON_GPIO_CLK_DISABLE(); \ - }while(0) -/** - * @} - */ - -/** @addtogroup STM32F401_DISCOVERY_LOW_LEVEL_BUS - * @{ - */ - -/*############################### I2Cx #######################################*/ -#define DISCOVERY_I2Cx I2C1 -#define DISCOVERY_I2Cx_CLOCK_ENABLE() __I2C1_CLK_ENABLE() -#define DISCOVERY_I2Cx_GPIO_PORT GPIOB /* GPIOB */ -#define DISCOVERY_I2Cx_SCL_PIN GPIO_PIN_6 /* PB.06 */ -#define DISCOVERY_I2Cx_SDA_PIN GPIO_PIN_9 /* PB.09 */ -#define DISCOVERY_I2Cx_GPIO_CLK_ENABLE() __GPIOB_CLK_ENABLE() -#define DISCOVERY_I2Cx_GPIO_CLK_DISABLE() __GPIOB_CLK_DISABLE() -#define DISCOVERY_I2Cx_AF GPIO_AF4_I2C1 - -#define DISCOVERY_I2Cx_FORCE_RESET() __I2C1_FORCE_RESET() -#define DISCOVERY_I2Cx_RELEASE_RESET() __I2C1_RELEASE_RESET() - -/* I2C interrupt requests */ -#define DISCOVERY_I2Cx_EV_IRQn I2C1_EV_IRQn -#define DISCOVERY_I2Cx_ER_IRQn I2C1_ER_IRQn - -/* I2C speed and timeout max */ -#define I2Cx_TIMEOUT_MAX 0xA000 /*
© COPYRIGHT(c) 2014 STMicroelectronics
- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Includes ------------------------------------------------------------------*/ -#include "stm32f401_discovery_accelerometer.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32F401_DISCOVERY - * @{ - */ - -/** @addtogroup STM32F401_DISCOVERY_ACCELEROMETER - * @{ - */ - -/** @defgroup STM32F401_DISCOVERY_ACCELEROMETER_Private_TypesDefinitions - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F401_DISCOVERY_ACCELEROMETER_Private_Defines - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F401_DISCOVERY_ACCELEROMETER_Private_Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F401_DISCOVERY_ACCELEROMETER_Private_Variables - * @{ - */ -static ACCELERO_DrvTypeDef *AccelerometerDrv; -/** - * @} - */ - -/** @defgroup STM32F401_DISCOVERY_ACCELEROMETER_Private_FunctionPrototypes - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F401_DISCOVERY_ACCELEROMETER_Private_Functions - * @{ - */ - -/** - * @brief Set Accelerometer Initialization. - * @param None - * @retval ACCELERO_OK if no problem during initialization - */ -uint8_t BSP_ACCELERO_Init(void) -{ - uint8_t ret = ACCELERO_ERROR; - uint16_t ctrl = 0x0000; - ACCELERO_InitTypeDef LSM303DLHC_InitStructure; - ACCELERO_FilterConfigTypeDef LSM303DLHC_FilterStructure = {0,0,0,0}; - - if(Lsm303dlhcDrv.ReadID() == I_AM_LMS303DLHC) - { - /* Initialize the Accelerometer driver structure */ - AccelerometerDrv = &Lsm303dlhcDrv; - - /* MEMS configuration ----------------------------------------------------*/ - /* Fill the Accelerometer structure */ - LSM303DLHC_InitStructure.Power_Mode = LSM303DLHC_NORMAL_MODE; - LSM303DLHC_InitStructure.AccOutput_DataRate = LSM303DLHC_ODR_50_HZ; - LSM303DLHC_InitStructure.Axes_Enable = LSM303DLHC_AXES_ENABLE; - LSM303DLHC_InitStructure.AccFull_Scale = LSM303DLHC_FULLSCALE_2G; - LSM303DLHC_InitStructure.BlockData_Update = LSM303DLHC_BlockUpdate_Continous; - LSM303DLHC_InitStructure.Endianness = LSM303DLHC_BLE_LSB; - LSM303DLHC_InitStructure.High_Resolution = LSM303DLHC_HR_ENABLE; - - /* Configure MEMS: data rate, power mode, full scale and axes */ - ctrl |= (LSM303DLHC_InitStructure.Power_Mode | LSM303DLHC_InitStructure.AccOutput_DataRate | \ - LSM303DLHC_InitStructure.Axes_Enable); - - ctrl |= ((LSM303DLHC_InitStructure.BlockData_Update | LSM303DLHC_InitStructure.Endianness | \ - LSM303DLHC_InitStructure.AccFull_Scale | LSM303DLHC_InitStructure.High_Resolution) << 8); - - /* Configure the Accelerometer main parameters */ - AccelerometerDrv->Init(ctrl); - - /* Fill the Accelerometer LPF structure */ - LSM303DLHC_FilterStructure.HighPassFilter_Mode_Selection =LSM303DLHC_HPM_NORMAL_MODE; - LSM303DLHC_FilterStructure.HighPassFilter_CutOff_Frequency = LSM303DLHC_HPFCF_16; - LSM303DLHC_FilterStructure.HighPassFilter_AOI1 = LSM303DLHC_HPF_AOI1_DISABLE; - LSM303DLHC_FilterStructure.HighPassFilter_AOI2 = LSM303DLHC_HPF_AOI2_DISABLE; - - /* Configure MEMS: mode, cutoff frquency, Filter status, Click, AOI1 and AOI2 */ - ctrl = (uint8_t) (LSM303DLHC_FilterStructure.HighPassFilter_Mode_Selection |\ - LSM303DLHC_FilterStructure.HighPassFilter_CutOff_Frequency|\ - LSM303DLHC_FilterStructure.HighPassFilter_AOI1|\ - LSM303DLHC_FilterStructure.HighPassFilter_AOI2); - - /* Configure the Accelerometer LPF main parameters */ - AccelerometerDrv->FilterConfig(ctrl); - - ret = ACCELERO_OK; - } - else - { - ret = ACCELERO_ERROR; - } - - return ret; -} - -/** - * @brief Reboot memory content of Accelerometer. - * @param None - * @retval None - */ -void BSP_ACCELERO_Reset(void) -{ - if(AccelerometerDrv->Reset != NULL) - { - AccelerometerDrv->Reset(); - } -} - -/** - * @brief Configure Accelerometer click IT. - * @param None - * @retval None - */ -void BSP_ACCELERO_Click_ITConfig(void) -{ - if(AccelerometerDrv->ConfigIT!= NULL) - { - AccelerometerDrv->ConfigIT(); - } -} - -/** - * @brief Get XYZ axes acceleration. - * @param pDataXYZ: Pointer to 3 angular acceleration axes. - * pDataXYZ[0] = X axis, pDataXYZ[1] = Y axis, pDataXYZ[2] = Z axis - * @retval None - */ -void BSP_ACCELERO_GetXYZ(int16_t *pDataXYZ) -{ - int16_t SwitchXY = 0; - - if(AccelerometerDrv->GetXYZ!= NULL) - { - AccelerometerDrv->GetXYZ(pDataXYZ); - - /* Switch X and Y Axes in case of LSM303DLHC MEMS */ - if(AccelerometerDrv == &Lsm303dlhcDrv) - { - SwitchXY = pDataXYZ[0]; - pDataXYZ[0] = pDataXYZ[1]; - - /* Invert Y Axis to be conpliant with LIS3DSH */ - pDataXYZ[1] = -SwitchXY; - } - } -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32F401-Discovery/stm32f401_discovery_accelerometer.h b/bsp/stm32f411RE/Libraries/BSP/STM32F401-Discovery/stm32f401_discovery_accelerometer.h deleted file mode 100644 index f428763097..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32F401-Discovery/stm32f401_discovery_accelerometer.h +++ /dev/null @@ -1,118 +0,0 @@ -/** - ****************************************************************************** - * @file stm32f401_discovery_accelerometer.h - * @author MCD Application Team - * @version V2.2.0 - * @date 14-August-2015 - * @brief This file contains all the functions prototypes for the - * stm32f401_discovery_accelerometer.c firmware driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2014 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32F401_DISCOVERY_ACCELEROMETER_H -#define __STM32F401_DISCOVERY_ACCELEROMETER_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm32f401_discovery.h" - -/* Include Accelerometer component driver */ -#include "../Components/lsm303dlhc/lsm303dlhc.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32F401_DISCOVERY - * @{ - */ - -/** @addtogroup STM32F401_DISCOVERY_ACCELEROMETER - * @{ - */ - -/** @defgroup STM32F401_DISCOVERY_ACCELEROMETER_Exported_Types - * @{ - */ -typedef enum -{ - ACCELERO_OK = 0, - ACCELERO_ERROR = 1, - ACCELERO_TIMEOUT = 2 -}ACCELERO_StatusTypeDef; - -/** - * @} - */ - -/** @defgroup STM32F401_DISCOVERY_ACCELEROMETER_Exported_Constants - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F401_DISCOVERY_ACCELEROMETER_Exported_Functions - * @{ - */ -/* Accelerometer functions */ -uint8_t BSP_ACCELERO_Init(void); -void BSP_ACCELERO_Reset(void); -void BSP_ACCELERO_Click_ITConfig(void); -void BSP_ACCELERO_GetXYZ(int16_t *pDataXYZ); - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32F401_DISCOVERY_ACCELEROMETER_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32F401-Discovery/stm32f401_discovery_audio.c b/bsp/stm32f411RE/Libraries/BSP/STM32F401-Discovery/stm32f401_discovery_audio.c deleted file mode 100644 index 6c7b3e8ff3..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32F401-Discovery/stm32f401_discovery_audio.c +++ /dev/null @@ -1,1044 +0,0 @@ -/** - ****************************************************************************** - * @file stm32f401_discovery_audio.c - * @author MCD Application Team - * @version V2.2.0 - * @date 14-August-2015 - * @brief This file provides the Audio driver for the STM32F401-Discovery - * board. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2014 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/*============================================================================== - User NOTES -1. How To use this driver: --------------------------- - - This driver supports STM32F401xx devices on STM32F401-Discovery Kit: - a) to play an audio file (all functions names start by BSP_AUDIO_OUT_xxx) - b) to record an audio file through MP45DT02, ST MEMS (all functions names start by AUDIO_IN_xxx) - -a) PLAY A FILE: -============== - + Call the function BSP_AUDIO_OUT_Init( - OutputDevice: physical output mode (OUTPUT_DEVICE_SPEAKER, - OUTPUT_DEVICE_HEADPHONE, OUTPUT_DEVICE_AUTO or - OUTPUT_DEVICE_BOTH) - Volume: initial volume to be set (0 is min (mute), 100 is max (100%) - AudioFreq: Audio frequency in Hz (8000, 16000, 22500, 32000 ...) - this parameter is relative to the audio file/stream type. - ) - This function configures all the hardware required for the audio application (codec, I2C, I2S, - GPIOs, DMA and interrupt if needed). This function returns 0 if configuration is OK. - If the returned value is different from 0 or the function is stuck then the communication with - the codec (try to un-plug the power or reset device in this case). - - OUTPUT_DEVICE_SPEAKER: only speaker will be set as output for the audio stream. - - OUTPUT_DEVICE_HEADPHONE: only headphones will be set as output for the audio stream. - - OUTPUT_DEVICE_AUTO: Selection of output device is made through external switch (implemented - into the audio jack on the discovery board). When the Headphone is connected it is used - as output. When the headphone is disconnected from the audio jack, the output is - automatically switched to Speaker. - - OUTPUT_DEVICE_BOTH: both Speaker and Headphone are used as outputs for the audio stream - at the same time. - + Call the function BSP_AUDIO_OUT_Play( - pBuffer: pointer to the audio data file address - Size: size of the buffer to be sent in Bytes - ) - to start playing (for the first time) from the audio file/stream. - + Call the function BSP_AUDIO_OUT_Pause() to pause playing - + Call the function BSP_AUDIO_OUT_Resume() to resume playing. - Note. After calling BSP_AUDIO_OUT_Pause() function for pause, only BSP_AUDIO_OUT_Resume() should be called - for resume (it is not allowed to call BSP_AUDIO_OUT_Play() in this case). - Note. This function should be called only when the audio file is played or paused (not stopped). - + For each mode, you may need to implement the relative callback functions into your code. - The Callback functions are named BSP_AUDIO_OUT_XXXCallBack() and only their prototypes are declared in - the stm32f401_discovery_audio.h file. (refer to the example for more details on the callbacks implementations) - + To Stop playing, to modify the volume level, the frequency or to mute, use the functions - BSP_AUDIO_OUT_Stop(), BSP_AUDIO_OUT_SetVolume(), AUDIO_OUT_SetFrequency() BSP_AUDIO_OUT_SetOutputMode and BSP_AUDIO_OUT_SetMute(). - + The driver API and the callback functions are at the end of the stm32f401_discovery_audio.h file. - -Driver architecture: --------------------- - + This driver provide the High Audio Layer: consists of the function API exported in the stm32f401_discovery_audio.h file - (BSP_AUDIO_OUT_Init(), BSP_AUDIO_OUT_Play() ...) - + This driver provide also the Media Access Layer (MAL): which consists of functions allowing to access the media containing/ - providing the audio file/stream. These functions are also included as local functions into - the stm32f401_discovery_audio.c file (I2S3_Init()...) - -Known Limitations: -------------------- - 1- When using the Speaker, if the audio file quality is not high enough, the speaker output - may produce high and uncomfortable noise level. To avoid this issue, to use speaker - output properly, try to increase audio file sampling rate (typically higher than 48KHz). - This operation will lead to larger file size. - 2- Communication with the audio codec (through I2C) may be corrupted if it is interrupted by some - user interrupt routines (in this case, interrupts could be disabled just before the start of - communication then re-enabled when it is over). Note that this communication is only done at - the configuration phase (BSP_AUDIO_OUT_Init() or BSP_AUDIO_OUT_Stop()) and when Volume control modification is - performed (BSP_AUDIO_OUT_SetVolume() or BSP_AUDIO_OUT_SetMute()or BSP_AUDIO_OUT_SetOutputMode()). - When the audio data is played, no communication is required with the audio codec. - 3- Parsing of audio file is not implemented (in order to determine audio file properties: Mono/Stereo, Data size, - File size, Audio Frequency, Audio Data header size ...). The configuration is fixed for the given audio file. - 4- Supports only Stereo audio streaming. To play mono audio streams, each data should be sent twice - on the I2S or should be duplicated on the source buffer. Or convert the stream in stereo before playing. - 5- Supports only 16-bits audio data size. - -b) RECORD A FILE: -================ - + Call the function BSP_AUDIO_IN_Init( - AudioFreq: Audio frequency in Hz (8000, 16000, 22500, 32000 ...) - ) - This function configures all the hardware required for the audio application (I2S, - GPIOs, DMA and interrupt if needed). This function returns 0 if configuration is OK. - - + Call the function BSP_AUDIO_IN_Record( - pbuf Main buffer pointer for the recorded data storing - size Current size of the recorded buffer - ) - to start recording from the microphone. - - + User needs to implement user callbacks to retrieve data saved in the record buffer - (AUDIO_IN_RxHalfCpltCallback/BSP_AUDIO_IN_ReceiveComplete_CallBack) - - + Call the function AUDIO_IN_STOP() to stop recording - -==============================================================================*/ - -/* Includes ------------------------------------------------------------------*/ -#include "stm32f401_discovery_audio.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32F401_DISCOVERY - * @{ - */ - -/** @addtogroup STM32F401_DISCOVERY_AUDIO - * @brief This file includes the low layer audio driver available on STM32F401-Discovery - * discovery board. - * @{ - */ - -/** @defgroup STM32F401_DISCOVERY_AUDIO_Private_Types - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F401_DISCOVERY_AUDIO_Private_Defines - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F401_DISCOVERY_AUDIO_Private_Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F401_DISCOVERY_AUDIO_Private_Variables - * @{ - */ -/*##### PLAY #####*/ -static AUDIO_DrvTypeDef *pAudioDrv; -I2S_HandleTypeDef hAudioOutI2s; - -/*### RECORDER ###*/ -I2S_HandleTypeDef hAudioInI2s; - -PDMFilter_InitStruct Filter[DEFAULT_AUDIO_IN_CHANNEL_NBR]; -uint16_t __IO AudioInVolume = DEFAULT_AUDIO_IN_VOLUME; - -/** - * @} - */ - -/** @defgroup STM32F401_DISCOVERY_AUDIO_Private_Function_Prototypes - * @{ - */ -static void I2S3_MspInit(void); -static void I2S3_Init(uint32_t AudioFreq); - -static void I2S2_MspInit(void); -static void I2S2_Init(uint32_t AudioFreq); -static void PDMDecoder_Init(uint32_t AudioFreq, uint32_t ChnlNbr); -/** - * @} - */ - -/** @defgroup STM32F401_DISCOVERY_AUDIO_OUT_Private_Functions - * @{ - */ - -/** - * @brief Configure the audio peripherals. - * @param OutputDevice: OUTPUT_DEVICE_SPEAKER, OUTPUT_DEVICE_HEADPHONE, - * OUTPUT_DEVICE_BOTH or OUTPUT_DEVICE_AUTO . - * @param Volume: Initial volume level (from 0 (Mute) to 100 (Max)) - * @param AudioFreq: Audio frequency used to play the audio stream. - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_Init(uint16_t OutputDevice, uint8_t Volume, uint32_t AudioFreq) -{ - uint8_t ret = AUDIO_ERROR; - uint32_t deviceid = 0x00; - RCC_PeriphCLKInitTypeDef rccclkinit; - - /* Enable PLLI2S clock */ - HAL_RCCEx_GetPeriphCLKConfig(&rccclkinit); - /* PLLI2S_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */ - if((AudioFreq & 0x7) == 0) - { - /* Audio frequency multiple of 8 (8/16/32/48/96/192)*/ - /* PLLI2S_VCO Output = PLLI2S_VCO Input * PLLI2SN = 192 Mhz */ - /* I2SCLK = PLLI2S_VCO Output/PLLI2SR = 192/6 = 32 Mhz */ - rccclkinit.PeriphClockSelection = RCC_PERIPHCLK_I2S; - rccclkinit.PLLI2S.PLLI2SN = 192; - rccclkinit.PLLI2S.PLLI2SR = 6; - HAL_RCCEx_PeriphCLKConfig(&rccclkinit); - } - else - { - /* Other Frequency (11.025/22.500/44.100) */ - /* PLLI2S_VCO Output = PLLI2S_VCO Input * PLLI2SN = 290 Mhz */ - /* I2SCLK = PLLI2S_VCO Output/PLLI2SR = 290/2 = 145 Mhz */ - rccclkinit.PeriphClockSelection = RCC_PERIPHCLK_I2S; - rccclkinit.PLLI2S.PLLI2SN = 290; - rccclkinit.PLLI2S.PLLI2SR = 2; - HAL_RCCEx_PeriphCLKConfig(&rccclkinit); - } - - deviceid = cs43l22_drv.ReadID(AUDIO_I2C_ADDRESS); - - if((deviceid & CS43L22_ID_MASK) == CS43L22_ID) - { - /* Initialize the audio driver structure */ - pAudioDrv = &cs43l22_drv; - ret = AUDIO_OK; - } - else - { - ret = AUDIO_ERROR; - } - - if(ret == AUDIO_OK) - { - pAudioDrv->Init(AUDIO_I2C_ADDRESS, OutputDevice, Volume, AudioFreq); - /* I2S data transfer preparation: - Prepare the Media to be used for the audio transfer from memory to I2S peripheral */ - /* Configure the I2S peripheral */ - I2S3_Init(AudioFreq); - } - - return ret; -} - -/** - * @brief Starts playing audio stream from a data buffer for a determined size. - * @param pBuffer: Pointer to the buffer - * @param Size: Number of audio data BYTES. - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_Play(uint16_t* pBuffer, uint32_t Size) -{ - /* Call the audio Codec Play function */ - if(pAudioDrv->Play(AUDIO_I2C_ADDRESS, pBuffer, Size) != 0) - { - return AUDIO_ERROR; - } - else - { - /* Update the Media layer and enable it for play */ - HAL_I2S_Transmit_DMA(&hAudioOutI2s, pBuffer, DMA_MAX(Size/AUDIODATA_SIZE)); - - return AUDIO_OK; - } -} - -/** - * @brief Sends n-Bytes on the I2S interface. - * @param pData: Pointer to data address - * @param Size: Number of data to be written - * @retval None - */ -void BSP_AUDIO_OUT_ChangeBuffer(uint16_t *pData, uint16_t Size) -{ - HAL_I2S_Transmit_DMA(&hAudioOutI2s, pData, Size); -} - -/** - * @brief This function Pauses the audio file stream. In case - * of using DMA, the DMA Pause feature is used. - * @WARNING When calling BSP_AUDIO_OUT_Pause() function for pause, only - * BSP_AUDIO_OUT_Resume() function should be called for resume (use of BSP_AUDIO_OUT_Play() - * function for resume could lead to unexpected behavior). - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_Pause(void) -{ - /* Call the Audio Codec Pause/Resume function */ - if(pAudioDrv->Pause(AUDIO_I2C_ADDRESS) != 0) - { - return AUDIO_ERROR; - } - else - { - /* Call the Media layer pause function */ - HAL_I2S_DMAPause(&hAudioOutI2s); - - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; - } -} - -/** - * @brief This function Resumes the audio file stream. - * @WARNING When calling BSP_AUDIO_OUT_Pause() function for pause, only - * BSP_AUDIO_OUT_Resume() function should be called for resume (use of BSP_AUDIO_OUT_Play() - * function for resume could lead to unexpected behavior). - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_Resume(void) -{ - /* Call the Audio Codec Pause/Resume function */ - if(pAudioDrv->Resume(AUDIO_I2C_ADDRESS) != 0) - { - return AUDIO_ERROR; - } - else - { - /* Call the Media layer resume function */ - HAL_I2S_DMAResume(&hAudioOutI2s); - - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; - } -} - -/** - * @brief Stops audio playing and Power down the Audio Codec. - * @param Option: could be one of the following parameters - * - CODEC_PDWN_HW: completely shut down the codec (physically). - * Then need to reconfigure the Codec after power on. - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_Stop(uint32_t Option) -{ - /* Call DMA Stop to disable DMA stream before stopping codec */ - HAL_I2S_DMAStop(&hAudioOutI2s); - - /* Call Audio Codec Stop function */ - if(pAudioDrv->Stop(AUDIO_I2C_ADDRESS, Option) != 0) - { - return AUDIO_ERROR; - } - else - { - if(Option == CODEC_PDWN_HW) - { - /* Wait at least 100us */ - HAL_Delay(1); - - /* Reset the pin */ - HAL_GPIO_WritePin(AUDIO_RESET_GPIO, AUDIO_RESET_PIN, GPIO_PIN_RESET); - } - - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; - } -} - -/** - * @brief Controls the current audio volume level. - * @param Volume: Volume level to be set in percentage from 0% to 100% (0 for - * Mute and 100 for Max volume level). - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_SetVolume(uint8_t Volume) -{ - /* Call the codec volume control function with converted volume value */ - if(pAudioDrv->SetVolume(AUDIO_I2C_ADDRESS, Volume) != 0) - { - return AUDIO_ERROR; - } - else - { - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; - } -} - -/** - * @brief Enables or disables the MUTE mode by software - * @param Cmd: could be AUDIO_MUTE_ON to mute sound or AUDIO_MUTE_OFF to - * unmute the codec and restore previous volume level. - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_SetMute(uint32_t Cmd) -{ - /* Call the Codec Mute function */ - if(pAudioDrv->SetMute(AUDIO_I2C_ADDRESS, Cmd) != 0) - { - return AUDIO_ERROR; - } - else - { - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; - } -} - -/** - * @brief Switch dynamically (while audio file is played) the output target - * (speaker or headphone). - * @note This function modifies a global variable of the audio codec driver: OutputDev. - * @param Output: specifies the audio output target: OUTPUT_DEVICE_SPEAKER, - * OUTPUT_DEVICE_HEADPHONE, OUTPUT_DEVICE_BOTH or OUTPUT_DEVICE_AUTO - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_SetOutputMode(uint8_t Output) -{ - /* Call the Codec output Device function */ - if(pAudioDrv->SetOutputMode(AUDIO_I2C_ADDRESS, Output) != 0) - { - return AUDIO_ERROR; - } - else - { - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; - } -} - -/** - * @brief Update the audio frequency. - * @param AudioFreq: Audio frequency used to play the audio stream. - * @retval None - * @note This API should be called after the BSP_AUDIO_OUT_Init() to adjust the - * audio frequency. - */ -void BSP_AUDIO_OUT_SetFrequency(uint32_t AudioFreq) -{ - RCC_PeriphCLKInitTypeDef rccclkinit; - - /* Enable PLLI2S clock */ - HAL_RCCEx_GetPeriphCLKConfig(&rccclkinit); - /* PLLI2S_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */ - if ((AudioFreq & 0x7) == 0) - { - /* Audio frequency multiple of 8 (8/16/32/48/96/192)*/ - /* PLLI2S_VCO Output = PLLI2S_VCO Input * PLLI2SN = 192 Mhz */ - /* I2SCLK = PLLI2S_VCO Output/PLLI2SR = 192/6 = 32 Mhz */ - rccclkinit.PeriphClockSelection = RCC_PERIPHCLK_I2S; - rccclkinit.PLLI2S.PLLI2SN = 192; - rccclkinit.PLLI2S.PLLI2SR = 6; - HAL_RCCEx_PeriphCLKConfig(&rccclkinit); - } - else - { - /* Other Frequency (11.025/22.500/44.100) */ - /* PLLI2S_VCO Output = PLLI2S_VCO Input * PLLI2SN = 290 Mhz */ - /* I2SCLK = PLLI2S_VCO Output/PLLI2SR = 290/2 = 145 Mhz */ - rccclkinit.PeriphClockSelection = RCC_PERIPHCLK_I2S; - rccclkinit.PLLI2S.PLLI2SN = 290; - rccclkinit.PLLI2S.PLLI2SR = 2; - HAL_RCCEx_PeriphCLKConfig(&rccclkinit); - } - - /* Update the I2S audio frequency configuration */ - I2S3_Init(AudioFreq); -} - -/** - * @brief Tx Transfer completed callbacks. - * @param hi2s: I2S handle - * @retval None - */ -void HAL_I2S_TxCpltCallback(I2S_HandleTypeDef *hi2s) -{ - if(hi2s->Instance == I2S3) - { - /* Call the user function which will manage directly transfer complete */ - BSP_AUDIO_OUT_TransferComplete_CallBack(); - } -} - -/** - * @brief Tx Half Transfer completed callbacks. - * @param hi2s: I2S handle - * @retval None - */ -void HAL_I2S_TxHalfCpltCallback(I2S_HandleTypeDef *hi2s) -{ - if(hi2s->Instance == I2S3) - { - /* Manage the remaining file size and new address offset: This function - should be coded by user (its prototype is already declared in stm32f401_discovery_audio.h) */ - BSP_AUDIO_OUT_HalfTransfer_CallBack(); - } -} - -/** - * @brief Manages the DMA full Transfer complete event. - * @param None - * @retval None - */ -__weak void BSP_AUDIO_OUT_TransferComplete_CallBack(void) -{ -} - -/** - * @brief Manages the DMA Half Transfer complete event. - * @param None - * @retval None - */ -__weak void BSP_AUDIO_OUT_HalfTransfer_CallBack(void) -{ -} - -/** - * @brief Manages the DMA FIFO error event. - * @param None - * @retval None - */ -__weak void BSP_AUDIO_OUT_Error_CallBack(void) -{ -} - -/******************************************************************************* - Static Functions -*******************************************************************************/ - -/** - * @brief AUDIO OUT I2S MSP Init. - * @param None - * @retval None - */ -static void I2S3_MspInit(void) -{ - static DMA_HandleTypeDef hdma_i2sTx; - GPIO_InitTypeDef GPIO_InitStruct; - I2S_HandleTypeDef *hi2s = &hAudioOutI2s; - - /* Enable I2S3 clock */ - I2S3_CLK_ENABLE(); - - /*** Configure the GPIOs ***/ - /* Enable I2S GPIO clocks */ - I2S3_SCK_SD_CLK_ENABLE(); - I2S3_WS_CLK_ENABLE(); - - /* I2S3 pins configuration: WS, SCK and SD pins ----------------------------*/ - GPIO_InitStruct.Pin = I2S3_SCK_PIN | I2S3_SD_PIN; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FAST; - GPIO_InitStruct.Alternate = I2S3_SCK_SD_WS_AF; - HAL_GPIO_Init(I2S3_SCK_SD_GPIO_PORT, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = I2S3_WS_PIN ; - HAL_GPIO_Init(I2S3_WS_GPIO_PORT, &GPIO_InitStruct); - - /* I2S3 pins configuration: MCK pin */ - I2S3_MCK_CLK_ENABLE(); - GPIO_InitStruct.Pin = I2S3_MCK_PIN; - HAL_GPIO_Init(I2S3_MCK_GPIO_PORT, &GPIO_InitStruct); - - /* Enable the I2S DMA clock */ - I2S3_DMAx_CLK_ENABLE(); - - if(hi2s->Instance == I2S3) - { - /* Configure the hdma_i2sTx handle parameters */ - hdma_i2sTx.Init.Channel = I2S3_DMAx_CHANNEL; - hdma_i2sTx.Init.Direction = DMA_MEMORY_TO_PERIPH; - hdma_i2sTx.Init.PeriphInc = DMA_PINC_DISABLE; - hdma_i2sTx.Init.MemInc = DMA_MINC_ENABLE; - hdma_i2sTx.Init.PeriphDataAlignment = I2S3_DMAx_PERIPH_DATA_SIZE; - hdma_i2sTx.Init.MemDataAlignment = I2S3_DMAx_MEM_DATA_SIZE; - hdma_i2sTx.Init.Mode = DMA_NORMAL; - hdma_i2sTx.Init.Priority = DMA_PRIORITY_HIGH; - hdma_i2sTx.Init.FIFOMode = DMA_FIFOMODE_ENABLE; - hdma_i2sTx.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; - hdma_i2sTx.Init.MemBurst = DMA_MBURST_SINGLE; - hdma_i2sTx.Init.PeriphBurst = DMA_PBURST_SINGLE; - - hdma_i2sTx.Instance = I2S3_DMAx_STREAM; - - /* Associate the DMA handle */ - __HAL_LINKDMA(hi2s, hdmatx, hdma_i2sTx); - - /* Deinitialize the Stream for new transfer */ - HAL_DMA_DeInit(&hdma_i2sTx); - - /* Configure the DMA Stream */ - HAL_DMA_Init(&hdma_i2sTx); - } - - /* I2S DMA IRQ Channel configuration */ - HAL_NVIC_SetPriority(I2S3_DMAx_IRQ, AUDIO_OUT_IRQ_PREPRIO, 0); - HAL_NVIC_EnableIRQ(I2S3_DMAx_IRQ); -} - -/** - * @brief Initializes the Audio Codec audio interface (I2S) - * @param AudioFreq: Audio frequency to be configured for the I2S peripheral. - * @retval None - */ -static void I2S3_Init(uint32_t AudioFreq) -{ - /* Initialize the hAudioOutI2s Instance parameter */ - hAudioOutI2s.Instance = I2S3; - - /* Disable I2S block */ - __HAL_I2S_DISABLE(&hAudioOutI2s); - - /* I2S3 peripheral configuration */ - hAudioOutI2s.Init.AudioFreq = AudioFreq; - hAudioOutI2s.Init.ClockSource = I2S_CLOCK_PLL; - hAudioOutI2s.Init.CPOL = I2S_CPOL_LOW; - hAudioOutI2s.Init.DataFormat = I2S_DATAFORMAT_16B; - hAudioOutI2s.Init.MCLKOutput = I2S_MCLKOUTPUT_ENABLE; - hAudioOutI2s.Init.Mode = I2S_MODE_MASTER_TX; - hAudioOutI2s.Init.Standard = I2S_STANDARD; - - /* Initialize the I2S peripheral with the structure above */ - if(HAL_I2S_GetState(&hAudioOutI2s) == HAL_I2S_STATE_RESET) - { - I2S3_MspInit(); - } - - HAL_I2S_Init(&hAudioOutI2s); -} - -/** - * @} - */ - -/** @defgroup STM32F401_DISCOVERY_AUDIO_IN_Private_Functions - * @{ - */ - -/** - * @brief Initializes wave recording. - * @param AudioFreq: Audio frequency to be configured for the I2S peripheral. - * @param BitRes: Audio frequency to be configured for the I2S peripheral. - * @param ChnlNbr: Audio frequency to be configured for the I2S peripheral. - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_IN_Init(uint32_t AudioFreq, uint32_t BitRes, uint32_t ChnlNbr) -{ - RCC_PeriphCLKInitTypeDef rccclkinit; - - /* Enable PLLI2S clock */ - HAL_RCCEx_GetPeriphCLKConfig(&rccclkinit); - /* PLLI2S_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */ - if ((AudioFreq & 0x7) == 0) - { - /* Audio frequency multiple of 8 (8/16/32/48/96/192)*/ - /* PLLI2S_VCO Output = PLLI2S_VCO Input * PLLI2SN = 192 Mhz */ - /* I2SCLK = PLLI2S_VCO Output/PLLI2SR = 192/6 = 32 Mhz */ - rccclkinit.PeriphClockSelection = RCC_PERIPHCLK_I2S; - rccclkinit.PLLI2S.PLLI2SN = 192; - rccclkinit.PLLI2S.PLLI2SR = 6; - HAL_RCCEx_PeriphCLKConfig(&rccclkinit); - } - else - { - /* Other Frequency (11.025/22.500/44.100) */ - /* PLLI2S_VCO Output = PLLI2S_VCO Input * PLLI2SN = 290 Mhz */ - /* I2SCLK = PLLI2S_VCO Output/PLLI2SR = 290/2 = 145 Mhz */ - rccclkinit.PeriphClockSelection = RCC_PERIPHCLK_I2S; - rccclkinit.PLLI2S.PLLI2SN = 290; - rccclkinit.PLLI2S.PLLI2SR = 2; - HAL_RCCEx_PeriphCLKConfig(&rccclkinit); - } - - /* Configure the PDM library */ - PDMDecoder_Init(AudioFreq, ChnlNbr); - - /* Configure the I2S2 */ - I2S2_Init(AudioFreq); - - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; -} - -/** - * @brief Starts audio recording. - * @param pbuf: Main buffer pointer for the recorded data storing - * @param size: Current size of the recorded buffer - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_IN_Record(uint16_t* pbuf, uint32_t size) -{ - uint32_t ret = AUDIO_ERROR; - - /* Start the process receive DMA */ - HAL_I2S_Receive_DMA(&hAudioInI2s, pbuf, size); - - /* Return AUDIO_OK when all operations are correctly done */ - ret = AUDIO_OK; - - return ret; -} - -/** - * @brief Stops audio recording. - * @param None - * @retval None - */ -uint8_t BSP_AUDIO_IN_Stop(void) -{ - uint32_t ret = AUDIO_ERROR; - - /* Call the Media layer pause function */ - HAL_I2S_DMAStop(&hAudioInI2s); - - /* Return AUDIO_OK when all operations are correctly done */ - ret = AUDIO_OK; - - return ret; -} - -/** - * @brief Pauses the audio file stream. - * @param None - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_IN_Pause(void) -{ - /* Call the Media layer pause function */ - HAL_I2S_DMAPause(&hAudioInI2s); - - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; -} - -/** - * @brief Resumes the audio file stream. - * @param None - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_IN_Resume(void) -{ - /* Call the Media layer pause/resume function */ - HAL_I2S_DMAResume(&hAudioInI2s); - - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; -} - -/** - * @brief Controls the audio in volume level. - * @param Volume: Volume level to be set in percentage from 0% to 100% (0 for - * Mute and 100 for Max volume level). - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_IN_SetVolume(uint8_t Volume) -{ - /* Set the Global variable AudioInVolume */ - AudioInVolume = Volume; - - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; -} - -/** - * @brief Converts audio format from PDM to PCM. - * @param PDMBuf: Pointer to data PDM buffer - * @param PCMBuf: Pointer to data PCM buffer - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_IN_PDMToPCM(uint16_t *PDMBuf, uint16_t *PCMBuf) -{ - uint16_t AppPDM[INTERNAL_BUFF_SIZE/2]; - uint32_t index = 0; - - /* PDM Demux */ - for(index = 0; indexInstance == I2S2) - { - /* Configure the hdma_i2sRx handle parameters */ - hdma_i2sRx.Init.Channel = I2S2_DMAx_CHANNEL; - hdma_i2sRx.Init.Direction = DMA_PERIPH_TO_MEMORY; - hdma_i2sRx.Init.PeriphInc = DMA_PINC_DISABLE; - hdma_i2sRx.Init.MemInc = DMA_MINC_ENABLE; - hdma_i2sRx.Init.PeriphDataAlignment = I2S2_DMAx_PERIPH_DATA_SIZE; - hdma_i2sRx.Init.MemDataAlignment = I2S2_DMAx_MEM_DATA_SIZE; - hdma_i2sRx.Init.Mode = DMA_CIRCULAR; - hdma_i2sRx.Init.Priority = DMA_PRIORITY_HIGH; - hdma_i2sRx.Init.FIFOMode = DMA_FIFOMODE_DISABLE; - hdma_i2sRx.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; - hdma_i2sRx.Init.MemBurst = DMA_MBURST_SINGLE; - hdma_i2sRx.Init.PeriphBurst = DMA_MBURST_SINGLE; - - hdma_i2sRx.Instance = I2S2_DMAx_STREAM; - - /* Associate the DMA handle */ - __HAL_LINKDMA(hi2s, hdmarx, hdma_i2sRx); - - /* Deinitialize the Stream for new transfer */ - HAL_DMA_DeInit(&hdma_i2sRx); - - /* Configure the DMA Stream */ - HAL_DMA_Init(&hdma_i2sRx); - } - - /* I2S DMA IRQ Channel configuration */ - HAL_NVIC_SetPriority(I2S2_DMAx_IRQ, AUDIO_IN_IRQ_PREPRIO, 0); - HAL_NVIC_EnableIRQ(I2S2_DMAx_IRQ); -} - -/** - * @brief Initializes the Audio Codec audio interface (I2S) - * @note This function assumes that the I2S input clock (through PLL_R in - * Devices RevA/Z and through dedicated PLLI2S_R in Devices RevB/Y) - * is already configured and ready to be used. - * @param AudioFreq: Audio frequency to be configured for the I2S peripheral. - * @retval None - */ -static void I2S2_Init(uint32_t AudioFreq) -{ - /* Initialize the hAudioInI2s Instance parameter */ - hAudioInI2s.Instance = I2S2; - - /* Disable I2S block */ - __HAL_I2S_DISABLE(&hAudioInI2s); - - /* I2S2 peripheral configuration */ - hAudioInI2s.Init.AudioFreq = 2 * AudioFreq; - hAudioInI2s.Init.ClockSource = I2S_CLOCK_PLL; - hAudioInI2s.Init.CPOL = I2S_CPOL_HIGH; - hAudioInI2s.Init.DataFormat = I2S_DATAFORMAT_16B; - hAudioInI2s.Init.MCLKOutput = I2S_MCLKOUTPUT_DISABLE; - hAudioInI2s.Init.Mode = I2S_MODE_MASTER_RX; - hAudioInI2s.Init.Standard = I2S_STANDARD_LSB; - - /* Initialize the I2S peripheral with the structure above */ - if(HAL_I2S_GetState(&hAudioInI2s) == HAL_I2S_STATE_RESET) - { - I2S2_MspInit(); - } - - HAL_I2S_Init(&hAudioInI2s); -} -/** - * @} - */ - -/** @defgroup STM32F401_DISCOVERY_AUDIO_IN_OUT_Private_Functions - * @{ - */ - -/** - * @brief I2S error callbacks. - * @param hi2s: I2S handle - * @retval None - */ -void HAL_I2S_ErrorCallback(I2S_HandleTypeDef *hi2s) -{ - /* Manage the error generated on DMA FIFO: This function - should be coded by user (its prototype is already declared in stm32f401_discovery_audio.h) */ - if(hi2s->Instance == I2S3) - { - BSP_AUDIO_OUT_Error_CallBack(); - } - if(hi2s->Instance == I2S2) - { - BSP_AUDIO_IN_Error_Callback(); - } -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32F401-Discovery/stm32f401_discovery_audio.h b/bsp/stm32f411RE/Libraries/BSP/STM32F401-Discovery/stm32f401_discovery_audio.h deleted file mode 100644 index 677f5593d7..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32F401-Discovery/stm32f401_discovery_audio.h +++ /dev/null @@ -1,257 +0,0 @@ -/** - ****************************************************************************** - * @file stm32f401_discovery_audio.h - * @author MCD Application Team - * @version V2.2.0 - * @date 14-August-2015 - * @brief This file contains the common defines and functions prototypes for - * stm32f401_discovery_audio.c driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2014 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32F401_DISCOVERY_AUDIO_H -#define __STM32F401_DISCOVERY_AUDIO_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -/* Include audio component Driver */ -#include "../Components/cs43l22/cs43l22.h" -#include "stm32f401_discovery.h" -#include "../../../Middlewares/ST/STM32_Audio/Addons/PDM/pdm_filter.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32F401_DISCOVERY - * @{ - */ - -/** @defgroup STM32F401_DISCOVERY_AUDIO - * @{ - */ - -/** @defgroup STM32F401_DISCOVERY_AUDIO_Exported_Types - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F401_DISCOVERY_AUDIO_OUT_Exported_Constants - * @{ - */ - -/*------------------------------------------------------------------------------ - AUDIO OUT CONFIGURATION -------------------------------------------------------------------------------*/ - -/* I2S peripheral configuration defines */ -#define I2S3 SPI3 -#define I2S3_CLK_ENABLE() __SPI3_CLK_ENABLE() -#define I2S3_SCK_SD_WS_AF GPIO_AF6_SPI3 -#define I2S3_SCK_SD_CLK_ENABLE() __GPIOC_CLK_ENABLE() -#define I2S3_MCK_CLK_ENABLE() __GPIOC_CLK_ENABLE() -#define I2S3_WS_CLK_ENABLE() __GPIOA_CLK_ENABLE() -#define I2S3_WS_PIN GPIO_PIN_4 -#define I2S3_SCK_PIN GPIO_PIN_10 -#define I2S3_SD_PIN GPIO_PIN_12 -#define I2S3_MCK_PIN GPIO_PIN_7 -#define I2S3_SCK_SD_GPIO_PORT GPIOC -#define I2S3_WS_GPIO_PORT GPIOA -#define I2S3_MCK_GPIO_PORT GPIOC - -/* I2S DMA Stream definitions */ -#define I2S3_DMAx_CLK_ENABLE() __DMA1_CLK_ENABLE() -#define I2S3_DMAx_STREAM DMA1_Stream7 -#define I2S3_DMAx_CHANNEL DMA_CHANNEL_0 -#define I2S3_DMAx_IRQ DMA1_Stream7_IRQn -#define I2S3_DMAx_PERIPH_DATA_SIZE DMA_PDATAALIGN_HALFWORD -#define I2S3_DMAx_MEM_DATA_SIZE DMA_MDATAALIGN_HALFWORD -#define DMA_MAX_SZE 0xFFFF - -#define I2S3_IRQHandler DMA1_Stream7_IRQHandler - -/* Select the interrupt preemption priority and subpriority for the DMA interrupt */ -#define AUDIO_OUT_IRQ_PREPRIO 5 /* Select the preemption priority level(0 is the highest) */ - -/*------------------------------------------------------------------------------ - AUDIO IN CONFIGURATION -------------------------------------------------------------------------------*/ -/* SPI Configuration defines */ -#define I2S2 SPI2 -#define I2S2_CLK_ENABLE() __SPI2_CLK_ENABLE() -#define I2S2_SCK_PIN GPIO_PIN_10 -#define I2S2_SCK_GPIO_PORT GPIOB -#define I2S2_SCK_GPIO_CLK_ENABLE() __GPIOB_CLK_ENABLE() -#define I2S2_SCK_AF GPIO_AF5_SPI2 - -#define I2S2_MOSI_PIN GPIO_PIN_3 -#define I2S2_MOSI_GPIO_PORT GPIOC -#define I2S2_MOSI_GPIO_CLK_ENABLE() __GPIOC_CLK_ENABLE() -#define I2S2_MOSI_AF GPIO_AF5_SPI2 - -/* I2S DMA Stream Rx definitions */ -#define I2S2_DMAx_CLK_ENABLE() __DMA1_CLK_ENABLE() -#define I2S2_DMAx_STREAM DMA1_Stream3 -#define I2S2_DMAx_CHANNEL DMA_CHANNEL_0 -#define I2S2_DMAx_IRQ DMA1_Stream3_IRQn -#define I2S2_DMAx_PERIPH_DATA_SIZE DMA_PDATAALIGN_HALFWORD -#define I2S2_DMAx_MEM_DATA_SIZE DMA_MDATAALIGN_HALFWORD - -#define I2S2_IRQHandler DMA1_Stream3_IRQHandler - -/* Select the interrupt preemption priority and subpriority for the IT/DMA interrupt */ -#define AUDIO_IN_IRQ_PREPRIO 6 /* Select the preemption priority level(0 is the highest) */ - -/*------------------------------------------------------------------------------ - CONFIGURATION: Audio Driver Configuration parameters -------------------------------------------------------------------------------*/ - -#define AUDIODATA_SIZE 2 /* 16-bits audio data size */ - -/* Audio status definition */ -#define AUDIO_OK 0 -#define AUDIO_ERROR 1 -#define AUDIO_TIMEOUT 2 - -/* AudioFreq * DataSize (2 bytes) * NumChannels (Stereo: 2) */ -#define DEFAULT_AUDIO_IN_FREQ I2S_AUDIOFREQ_16K -#define DEFAULT_AUDIO_IN_BIT_RESOLUTION 16 -#define DEFAULT_AUDIO_IN_CHANNEL_NBR 1 /* Mono = 1, Stereo = 2 */ -#define DEFAULT_AUDIO_IN_VOLUME 64 - -/* PDM buffer input size */ -#define INTERNAL_BUFF_SIZE 128*DEFAULT_AUDIO_IN_FREQ/16000*DEFAULT_AUDIO_IN_CHANNEL_NBR -/* PCM buffer output size */ -#define PCM_OUT_SIZE DEFAULT_AUDIO_IN_FREQ/1000 -#define CHANNEL_DEMUX_MASK 0x55 - -/*------------------------------------------------------------------------------ - OPTIONAL Configuration defines parameters -------------------------------------------------------------------------------*/ - -/** - * @} - */ - -/** @defgroup STM32F401_DISCOVERY_AUDIO_Exported_Variables - * @{ - */ -extern __IO uint16_t AudioInVolume; -/** - * @} - */ - -/** @defgroup STM32F401_DISCOVERY_AUDIO_Exported_Macros - * @{ - */ -#define DMA_MAX(_X_) (((_X_) <= DMA_MAX_SZE)? (_X_):DMA_MAX_SZE) -/** - * @} - */ - -/** @defgroup STM32F401_DISCOVERY_AUDIO_OUT_Exported_Functions - * @{ - */ -uint8_t BSP_AUDIO_OUT_Init(uint16_t OutputDevice, uint8_t Volume, uint32_t AudioFreq); -uint8_t BSP_AUDIO_OUT_Play(uint16_t *pBuffer, uint32_t Size); -void BSP_AUDIO_OUT_ChangeBuffer(uint16_t *pData, uint16_t Size); -uint8_t BSP_AUDIO_OUT_Pause(void); -uint8_t BSP_AUDIO_OUT_Resume(void); -uint8_t BSP_AUDIO_OUT_Stop(uint32_t Option); -uint8_t BSP_AUDIO_OUT_SetVolume(uint8_t Volume); -void BSP_AUDIO_OUT_SetFrequency(uint32_t AudioFreq); -uint8_t BSP_AUDIO_OUT_SetMute(uint32_t Cmd); -uint8_t BSP_AUDIO_OUT_SetOutputMode(uint8_t Output); - -/* User Callbacks: user has to implement these functions in his code if they are needed. */ -/* This function is called when the requested data has been completely transferred. */ -void BSP_AUDIO_OUT_TransferComplete_CallBack(void); - -/* This function is called when half of the requested buffer has been transferred. */ -void BSP_AUDIO_OUT_HalfTransfer_CallBack(void); - -/* This function is called when an Interrupt due to transfer error on or peripheral - error occurs. */ -void BSP_AUDIO_OUT_Error_CallBack(void); - -/** - * @} - */ - -/** @defgroup STM32F401_DISCOVERY_AUDIO_IN_Exported_Functions - * @{ - */ -uint8_t BSP_AUDIO_IN_Init(uint32_t AudioFreq, uint32_t BitRes, uint32_t ChnlNbr); -uint8_t BSP_AUDIO_IN_Record(uint16_t *pData, uint32_t Size); -uint8_t BSP_AUDIO_IN_Stop(void); -uint8_t BSP_AUDIO_IN_Pause(void); -uint8_t BSP_AUDIO_IN_Resume(void); -uint8_t BSP_AUDIO_IN_SetVolume(uint8_t Volume); -uint8_t BSP_AUDIO_IN_PDMToPCM(uint16_t *PDMBuf, uint16_t *PCMBuf); -/* User Callbacks: user has to implement these functions in his code if they are needed. */ -/* This function should be implemented by the user application. - It is called into this driver when the current buffer is filled to prepare the next - buffer pointer and its size. */ -void BSP_AUDIO_IN_TransferComplete_CallBack(void); -void BSP_AUDIO_IN_HalfTransfer_CallBack(void); - -/* This function is called when an Interrupt due to transfer error on or peripheral - error occurs. */ -void BSP_AUDIO_IN_Error_Callback(void); - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32F401_DISCOVERY_AUDIO_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32F401-Discovery/stm32f401_discovery_gyroscope.c b/bsp/stm32f411RE/Libraries/BSP/STM32F401-Discovery/stm32f401_discovery_gyroscope.c deleted file mode 100644 index 70ffec662e..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32F401-Discovery/stm32f401_discovery_gyroscope.c +++ /dev/null @@ -1,259 +0,0 @@ -/** - ****************************************************************************** - * @file stm32f401_discovery_gyroscope.c - * @author MCD Application Team - * @version V2.2.0 - * @date 14-August-2015 - * @brief This file provides a set of functions needed to manage the - * MEMS gyroscope available on STM32F401-Discovery Kit. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2014 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ -/* Includes ------------------------------------------------------------------*/ -#include "stm32f401_discovery_gyroscope.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32F401_DISCOVERY - * @{ - */ - -/** @addtogroup STM32F401_DISCOVERY_GYROSCOPE - * @{ - */ - - -/** @defgroup STM32F401_DISCOVERY_GYROSCOPE_Private_TypesDefinitions - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F401_DISCOVERY_GYROSCOPE_Private_Defines - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F401_DISCOVERY_GYROSCOPE_Private_Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F401_DISCOVERY_GYROSCOPE_Private_Variables - * @{ - */ -static GYRO_DrvTypeDef *GyroscopeDrv; -/** - * @} - */ - -/** @defgroup STM32F401_DISCOVERY_GYROSCOPE_Private_FunctionPrototypes - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F401_DISCOVERY_GYROSCOPE_Private_Functions - * @{ - */ - -/** - * @brief Set Gyroscope Initialization. - * @param None - * @retval GYRO_OK if no problem during initialization - */ -uint8_t BSP_GYRO_Init(void) -{ - uint8_t ret = GYRO_ERROR; - uint16_t ctrl = 0x0000; - GYRO_InitTypeDef L3GD20_InitStructure; - GYRO_FilterConfigTypeDef L3GD20_FilterStructure = {0,0}; - - if((L3gd20Drv.ReadID() == I_AM_L3GD20) || (L3gd20Drv.ReadID() == I_AM_L3GD20_TR)) - { - /* Initialize the Gyroscope driver structure */ - GyroscopeDrv = &L3gd20Drv; - - /* MEMS configuration ----------------------------------------------------*/ - /* Fill the Gyroscope structure */ - L3GD20_InitStructure.Power_Mode = L3GD20_MODE_ACTIVE; - L3GD20_InitStructure.Output_DataRate = L3GD20_OUTPUT_DATARATE_1; - L3GD20_InitStructure.Axes_Enable = L3GD20_AXES_ENABLE; - L3GD20_InitStructure.Band_Width = L3GD20_BANDWIDTH_4; - L3GD20_InitStructure.BlockData_Update = L3GD20_BlockDataUpdate_Continous; - L3GD20_InitStructure.Endianness = L3GD20_BLE_LSB; - L3GD20_InitStructure.Full_Scale = L3GD20_FULLSCALE_500; - - /* Configure MEMS: data rate, power mode, full scale and axes */ - ctrl = (uint16_t) (L3GD20_InitStructure.Power_Mode | L3GD20_InitStructure.Output_DataRate | \ - L3GD20_InitStructure.Axes_Enable | L3GD20_InitStructure.Band_Width); - - ctrl |= (uint16_t) ((L3GD20_InitStructure.BlockData_Update | L3GD20_InitStructure.Endianness | \ - L3GD20_InitStructure.Full_Scale) << 8); - - /* Configure the Gyroscope main parameters */ - GyroscopeDrv->Init(ctrl); - - L3GD20_FilterStructure.HighPassFilter_Mode_Selection =L3GD20_HPM_NORMAL_MODE_RES; - L3GD20_FilterStructure.HighPassFilter_CutOff_Frequency = L3GD20_HPFCF_0; - - ctrl = (uint8_t) ((L3GD20_FilterStructure.HighPassFilter_Mode_Selection |\ - L3GD20_FilterStructure.HighPassFilter_CutOff_Frequency)); - - /* Configure the Gyroscope main parameters */ - GyroscopeDrv->FilterConfig(ctrl) ; - - GyroscopeDrv->FilterCmd(L3GD20_HIGHPASSFILTER_ENABLE); - - ret = GYRO_OK; - } - return ret; -} - -/** - * @brief Read ID of Gyroscope component. - * @param None - * @retval ID - */ -uint8_t BSP_GYRO_ReadID(void) -{ - uint8_t id = 0x00; - - if(GyroscopeDrv->ReadID != NULL) - { - id = GyroscopeDrv->ReadID(); - } - return id; -} - -/** - * @brief Reboot memory content of Gyroscope. - * @param None - * @retval None - */ -void BSP_GYRO_Reset(void) -{ - if(GyroscopeDrv->Reset != NULL) - { - GyroscopeDrv->Reset(); - } -} - -/** - * @brief Configures INT1 interrupt. - * @param pIntConfig: pointer to a L3GD20_InterruptConfig_TypeDef - * structure that contains the configuration setting for the L3GD20 Interrupt. - * @retval None - */ -void BSP_GYRO_ITConfig(GYRO_InterruptConfigTypeDef *pIntConfig) -{ - uint16_t interruptconfig = 0x0000; - - if(GyroscopeDrv->ConfigIT != NULL) - { - /* Configure latch Interrupt request and axe interrupts */ - interruptconfig |= ((uint8_t)(pIntConfig->Latch_Request| \ - pIntConfig->Interrupt_Axes) << 8); - - interruptconfig |= (uint8_t)(pIntConfig->Interrupt_ActiveEdge); - - GyroscopeDrv->ConfigIT(interruptconfig); - } -} - -/** - * @brief Enables INT1 or INT2 interrupt. - * @param IntPin: Interrupt pin - * This parameter can be: - * @arg L3GD20_INT1 - * @arg L3GD20_INT2 - * @retval None - */ -void BSP_GYRO_EnableIT(uint8_t IntPin) -{ - if(GyroscopeDrv->EnableIT != NULL) - { - GyroscopeDrv->EnableIT(IntPin); - } -} - -/** - * @brief Disables INT1 or INT2 interrupt. - * @param IntPin: Interrupt pin - * This parameter can be: - * @arg L3GD20_INT1 - * @arg L3GD20_INT2 - * @retval None - */ -void BSP_GYRO_DisableIT(uint8_t IntPin) -{ - if(GyroscopeDrv->DisableIT != NULL) - { - GyroscopeDrv->DisableIT(IntPin); - } -} - -/** - * @brief Get XYZ angular acceleration. - * @param pfData: pointer on floating array - * @retval None - */ -void BSP_GYRO_GetXYZ(float *pfData) -{ - if(GyroscopeDrv->GetXYZ!= NULL) - { - GyroscopeDrv->GetXYZ(pfData); - } -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32F401-Discovery/stm32f401_discovery_gyroscope.h b/bsp/stm32f411RE/Libraries/BSP/STM32F401-Discovery/stm32f401_discovery_gyroscope.h deleted file mode 100644 index 79cdc96470..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32F401-Discovery/stm32f401_discovery_gyroscope.h +++ /dev/null @@ -1,127 +0,0 @@ -/** - ****************************************************************************** - * @file stm32f401_discovery_gyroscope.h - * @author MCD Application Team - * @version V2.2.0 - * @date 14-August-2015 - * @brief This file contains definitions for stm32f401_discovery_gyroscope.c - * firmware driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2014 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32F401_DISCOVERY_GYROSCOPE_H -#define __STM32F401_DISCOVERY_GYROSCOPE_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm32f401_discovery.h" - - /* Include Gyroscope component driver */ -#include "../Components/l3gd20/l3gd20.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32F401_DISCOVERY - * @{ - */ - -/** @addtogroup STM32F401_DISCOVERY_GYROSCOPE - * @{ - */ - -/** @defgroup STM32F401_DISCOVERY_GYROSCOPE_Exported_Types - * @{ - */ -typedef enum -{ - GYRO_OK = 0, - GYRO_ERROR = 1, - GYRO_TIMEOUT = 2 -}GYRO_StatusTypeDef; -/** - * @} - */ - -/** @defgroup STM32F401_DISCOVERY_GYROSCOPE_Exported_Constants - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F401_DISCOVERY_GYROSCOPE_Exported_Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F401_DISCOVERY_GYROSCOPE_Exported_Functions - * @{ - */ -/* Gyroscope Functions */ -uint8_t BSP_GYRO_Init(void); -void BSP_GYRO_Reset(void); -uint8_t BSP_GYRO_ReadID(void); -void BSP_GYRO_ITConfig(GYRO_InterruptConfigTypeDef *pIntConfigStruct); -void BSP_GYRO_EnableIT(uint8_t IntPin); -void BSP_GYRO_DisableIT(uint8_t IntPin); -void BSP_GYRO_GetXYZ(float *pfData); - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus - } -#endif - -#endif /* __STM32F401_DISCOVERY_GYROSCOPE_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32F411E-Discovery/Release_Notes.html b/bsp/stm32f411RE/Libraries/BSP/STM32F411E-Discovery/Release_Notes.html deleted file mode 100644 index 80b080bdac..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32F411E-Discovery/Release_Notes.html +++ /dev/null @@ -1,156 +0,0 @@ - - - - - - - - - - - - - - - - - - - - Release Notes for STM32F401-Discovery Board Drivers - - - - - - - - - - -
-


-

-
- - - - - - -
- - - - - - - - - -
-

Back to Release page

-
-

Release -Notes for STM32F411E-Discovery Board Drivers

-

-Copyright © 2015 STMicroelectronics -

- -

-

-
-

 

- - - - - - -

Update History

V1.0.0 / 12-November-2015

-

Main -Changes

- -
  • First official version of the STM32F411E-Discovery Board Drivers

License

-
-
-Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met:
-
-
  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions -in binary form must reproduce the above copyright notice, this list of -conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of STMicroelectronics nor the names of its contributors may be used to endorse or promote products derived
    -
    -
-        from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- -
-
- - -
-
-
For -complete documentation on STM32 Microcontrollers -visit www.st.com/STM32
-
-

-
-
-

 

-
- - \ No newline at end of file diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32F411E-Discovery/stm32f411e_discovery.c b/bsp/stm32f411RE/Libraries/BSP/STM32F411E-Discovery/stm32f411e_discovery.c deleted file mode 100644 index 33ce8b1073..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32F411E-Discovery/stm32f411e_discovery.c +++ /dev/null @@ -1,779 +0,0 @@ -/** - ****************************************************************************** - * @file stm32f411e_discovery.c - * @author MCD Application Team - * @version V1.0.0 - * @date 12-November-2015 - * @brief This file provides set of firmware functions to manage LEDs and - * push-button available on STM32F411-Discovery Kit from STMicroelectronics. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Includes ------------------------------------------------------------------*/ -#include "stm32f411e_discovery.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32F411E_discovery - * @{ - */ - -/** @addtogroup STM32F411E_discovery_LOW_LEVEL - * @brief This file provides set of firmware functions to manage Leds and push-button - * available on STM32F411-Discovery Kit from STMicroelectronics. - * @{ - */ - -/** @defgroup STM32F411E_discovery_LOW_LEVEL_Private_TypesDefinitions - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F411E_discovery_LOW_LEVEL_Private_Defines - * @{ - */ - -/** - * @brief STM32F411E DISCO BSP Driver version number V1.0.0 - */ -#define __STM32F411E_DISCO_BSP_VERSION_MAIN (0x01) /*!< [31:24] main version */ -#define __STM32F411E_DISCO_BSP_VERSION_SUB1 (0x00) /*!< [23:16] sub1 version */ -#define __STM32F411E_DISCO_BSP_VERSION_SUB2 (0x00) /*!< [15:8] sub2 version */ -#define __STM32F411E_DISCO_BSP_VERSION_RC (0x00) /*!< [7:0] release candidate */ -#define __STM32F411E_DISCO_BSP_VERSION ((__STM32F411E_DISCO_BSP_VERSION_MAIN << 24)\ - |(__STM32F411E_DISCO_BSP_VERSION_SUB1 << 16)\ - |(__STM32F411E_DISCO_BSP_VERSION_SUB2 << 8 )\ - |(__STM32F411E_DISCO_BSP_VERSION_RC)) -/** - * @} - */ - -/** @defgroup STM32F411E_discovery_LOW_LEVEL_Private_Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F411E_discovery_LOW_LEVEL_Private_Variables - * @{ - */ -GPIO_TypeDef* GPIO_PORT[LEDn] = {LED4_GPIO_PORT, - LED3_GPIO_PORT, - LED5_GPIO_PORT, - LED6_GPIO_PORT}; - -const uint16_t GPIO_PIN[LEDn] = {LED4_PIN, - LED3_PIN, - LED5_PIN, - LED6_PIN}; - -GPIO_TypeDef* BUTTON_PORT[BUTTONn] = {KEY_BUTTON_GPIO_PORT}; -const uint16_t BUTTON_PIN[BUTTONn] = {KEY_BUTTON_PIN}; -const uint8_t BUTTON_IRQn[BUTTONn] = {KEY_BUTTON_EXTI_IRQn}; - -uint32_t I2cxTimeout = I2Cx_TIMEOUT_MAX; /* 0x01) - { - WriteAddr |= (uint8_t)MULTIPLEBYTE_CMD; - } - /* Set chip select Low at the start of the transmission */ - GYRO_CS_LOW(); - - /* Send the Address of the indexed register */ - SPIx_WriteRead(WriteAddr); - - /* Send the data that will be written into the device (MSB First) */ - while(NumByteToWrite >= 0x01) - { - SPIx_WriteRead(*pBuffer); - NumByteToWrite--; - pBuffer++; - } - - /* Set chip select High at the end of the transmission */ - GYRO_CS_HIGH(); -} - -/** - * @brief Reads a block of data from the GYRO. - * @param pBuffer: pointer to the buffer that receives the data read from the GYRO. - * @param ReadAddr: GYRO's internal address to read from. - * @param NumByteToRead: Number of bytes to read from the GYRO. - * @retval None - */ -void GYRO_IO_Read(uint8_t* pBuffer, uint8_t ReadAddr, uint16_t NumByteToRead) -{ - if(NumByteToRead > 0x01) - { - ReadAddr |= (uint8_t)(READWRITE_CMD | MULTIPLEBYTE_CMD); - } - else - { - ReadAddr |= (uint8_t)READWRITE_CMD; - } - - /* Set chip select Low at the start of the transmission */ - GYRO_CS_LOW(); - - /* Send the Address of the indexed register */ - SPIx_WriteRead(ReadAddr); - - /* Receive the data that will be read from the device (MSB First) */ - while(NumByteToRead > 0x00) - { - /* Send dummy byte (0x00) to generate the SPI clock to GYRO (Slave device) */ - *pBuffer = SPIx_WriteRead(DUMMY_BYTE); - NumByteToRead--; - pBuffer++; - } - - /* Set chip select High at the end of the transmission */ - GYRO_CS_HIGH(); -} - -/********************************* LINK AUDIO *********************************/ - -/** - * @brief Initializes Audio low level. - * @param None - * @retval None - */ -void AUDIO_IO_Init(void) -{ - GPIO_InitTypeDef GPIO_InitStruct; - - /* Enable Reset GPIO Clock */ - AUDIO_RESET_GPIO_CLK_ENABLE(); - - /* Audio reset pin configuration -------------------------------------------*/ - GPIO_InitStruct.Pin = AUDIO_RESET_PIN; - GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStruct.Speed = GPIO_SPEED_FAST; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(AUDIO_RESET_GPIO, &GPIO_InitStruct); - - I2Cx_Init(); - - /* Power Down the codec */ - CODEC_AUDIO_POWER_OFF(); - - /* Wait for a delay to insure registers erasing */ - HAL_Delay(5); - - /* Power on the codec */ - CODEC_AUDIO_POWER_ON(); - - /* Wait for a delay to insure registers erasing */ - HAL_Delay(5); -} - -/** - * @brief DeInitializes Audio low level. - * @param None - * @retval None - */ -void AUDIO_IO_DeInit(void) -{ - -} - -/** - * @brief Writes a single data. - * @param Addr: I2C address - * @param Reg: Reg address - * @param Value: Data to be written - * @retval None - */ -void AUDIO_IO_Write (uint8_t Addr, uint8_t Reg, uint8_t Value) -{ - I2Cx_WriteData(Addr, Reg, Value); -} - -/** - * @brief Reads a single data. - * @param Addr: I2C address - * @param Reg: Reg address - * @retval Data to be read - */ -uint8_t AUDIO_IO_Read (uint8_t Addr, uint8_t Reg) -{ - return I2Cx_ReadData(Addr, Reg); -} - -/****************************** LINK ACCELEROMETER ****************************/ - -/** - * @brief Configures COMPASS / ACCELERO I2C interface. - * @param None - * @retval None - */ -void COMPASSACCELERO_IO_Init(void) -{ - GPIO_InitTypeDef GPIO_InitStructure; - - /* Enable DRDY clock */ - ACCELERO_DRDY_GPIO_CLK_ENABLE(); - - /* MEMS DRDY pin configuration */ - GPIO_InitStructure.Pin = ACCELERO_DRDY_PIN; - GPIO_InitStructure.Mode = GPIO_MODE_INPUT; - GPIO_InitStructure.Pull = GPIO_NOPULL; - GPIO_InitStructure.Speed = GPIO_SPEED_FAST; - HAL_GPIO_Init(ACCELERO_DRDY_GPIO_PORT, &GPIO_InitStructure); - - I2Cx_Init(); -} - -/** - * @brief Configures COMPASS / ACCELERO click IT. - * @param None - * @retval None - */ -void COMPASSACCELERO_IO_ITConfig(void) -{ - GPIO_InitTypeDef GPIO_InitStructure; - - /* Enable INT1 and INT2 GPIO clock */ - ACCELERO_INT_GPIO_CLK_ENABLE(); - - /* Configure GPIO PINs to detect Interrupts */ - GPIO_InitStructure.Pin = ACCELERO_INT1_PIN | ACCELERO_INT2_PIN; - GPIO_InitStructure.Mode = GPIO_MODE_IT_RISING; - GPIO_InitStructure.Speed = GPIO_SPEED_FAST; - GPIO_InitStructure.Pull = GPIO_NOPULL; - HAL_GPIO_Init(ACCELERO_INT_GPIO_PORT, &GPIO_InitStructure); - - /* Enable and set COMPASS / ACCELERO Interrupt to the highest priority */ - HAL_NVIC_SetPriority(ACCELERO_INT1_EXTI_IRQn, 0x00, 0x00); - HAL_NVIC_EnableIRQ(ACCELERO_INT1_EXTI_IRQn); -} - -/** - * @brief Writes one byte to the COMPASS / ACCELERO. - * @param DeviceAddr: the slave address to be programmed - * @param RegisterAddr: the COMPASS / ACCELERO register to be written - * @param Value: Data to be written - * @retval None - */ -void COMPASSACCELERO_IO_Write(uint16_t DeviceAddr, uint8_t RegisterAddr, uint8_t Value) -{ - /* Call I2Cx Read data bus function */ - I2Cx_WriteData(DeviceAddr, RegisterAddr, Value); -} - -/** - * @brief Reads a block of data from the COMPASS / ACCELERO. - * @param DeviceAddr: the slave address to be programmed(ACC_I2C_ADDRESS or MAG_I2C_ADDRESS). - * @param RegisterAddr: the COMPASS / ACCELERO internal address register to read from - * @retval COMPASS / ACCELERO register value - */ -uint8_t COMPASSACCELERO_IO_Read(uint16_t DeviceAddr, uint8_t RegisterAddr) -{ - /* Call I2Cx Read data bus function */ - return I2Cx_ReadData(DeviceAddr, RegisterAddr); -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32F411E-Discovery/stm32f411e_discovery.h b/bsp/stm32f411RE/Libraries/BSP/STM32F411E-Discovery/stm32f411e_discovery.h deleted file mode 100644 index 6a750dcbcd..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32F411E-Discovery/stm32f411e_discovery.h +++ /dev/null @@ -1,313 +0,0 @@ -/** - ****************************************************************************** - * @file stm32f4011e_discovery.h - * @author MCD Application Team - * @version V1.0.0 - * @date 12-November-2015 - * @brief This file contains definitions for STM32F401-Discovery Kit's Leds and - * push-button hardware resources. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32F411E_DISCOVERY_H -#define __STM32F411E_DISCOVERY_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm32f4xx_hal.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32F411E_DISCOVERY - * @{ - */ - -/** @addtogroup __STM32F411E_DISCOVERY_HLOW_LEVEL - * @{ - */ - -/** @defgroup __STM32F411E_DISCOVERY_HLOW_LEVEL_Exported_Types - * @{ - */ -typedef enum -{ - LED4 = 0, - LED3 = 1, - LED5 = 2, - LED6 = 3 -}Led_TypeDef; - -typedef enum -{ - BUTTON_KEY = 0, -}Button_TypeDef; - -typedef enum -{ - BUTTON_MODE_GPIO = 0, - BUTTON_MODE_EXTI = 1 -}ButtonMode_TypeDef; -/** - * @} - */ - -/** @defgroup __STM32F411E_DISCOVERY_HLOW_LEVEL_Exported_Constants - * @{ - */ - -/** - * @brief Define for STM32F411E_DISCOVERY board - */ -#if !defined (USE_STM32F411E_DISCO) - #define USE_STM32F411E_DISCO -#endif - -/** @addtogroup __STM32F411E_DISCOVERY_HLOW_LEVEL_LED - * @{ - */ -#define LEDn 4 - -#define LED4_PIN GPIO_PIN_12 -#define LED4_GPIO_PORT GPIOD -#define LED4_GPIO_CLK_ENABLE() __GPIOD_CLK_ENABLE() -#define LED4_GPIO_CLK_DISABLE() __GPIOD_CLK_DISABLE() - - -#define LED3_PIN GPIO_PIN_13 -#define LED3_GPIO_PORT GPIOD -#define LED3_GPIO_CLK_ENABLE() __GPIOD_CLK_ENABLE() -#define LED3_GPIO_CLK_DISABLE() __GPIOD_CLK_DISABLE() - - -#define LED5_PIN GPIO_PIN_14 -#define LED5_GPIO_PORT GPIOD -#define LED5_GPIO_CLK_ENABLE() __GPIOD_CLK_ENABLE() -#define LED5_GPIO_CLK_DISABLE() __GPIOD_CLK_DISABLE() - - -#define LED6_PIN GPIO_PIN_15 -#define LED6_GPIO_PORT GPIOD -#define LED6_GPIO_CLK_ENABLE() __GPIOD_CLK_ENABLE() -#define LED6_GPIO_CLK_DISABLE() __GPIOD_CLK_DISABLE() - -#define LEDx_GPIO_CLK_ENABLE(__INDEX__) do{if((__INDEX__) == 0) LED4_GPIO_CLK_ENABLE(); else \ - if((__INDEX__) == 1) LED3_GPIO_CLK_ENABLE(); else \ - if((__INDEX__) == 2) LED5_GPIO_CLK_ENABLE(); else \ - if((__INDEX__) == 3) LED6_GPIO_CLK_ENABLE(); \ - }while(0) - -#define LEDx_GPIO_CLK_DISABLE(__INDEX__) do{if((__INDEX__) == 0) LED4_GPIO_CLK_DISABLE(); else \ - if((__INDEX__) == 1) LED3_GPIO_CLK_DISABLE(); else \ - if((__INDEX__) == 2) LED5_GPIO_CLK_DISABLE(); else \ - if((__INDEX__) == 3) LED6_GPIO_CLK_DISABLE(); \ - }while(0) -/** - * @} - */ - -/** @addtogroup __STM32F411E_DISCOVERY_HLOW_LEVEL_BUTTON - * @{ - */ -#define BUTTONn 1 - -/** - * @brief Wakeup push-button - */ -#define KEY_BUTTON_PIN GPIO_PIN_0 -#define KEY_BUTTON_GPIO_PORT GPIOA -#define KEY_BUTTON_GPIO_CLK_ENABLE() __GPIOA_CLK_ENABLE() -#define KEY_BUTTON_GPIO_CLK_DISABLE() __GPIOA_CLK_DISABLE() -#define KEY_BUTTON_EXTI_IRQn EXTI0_IRQn - -#define BUTTONx_GPIO_CLK_ENABLE(__INDEX__) do{if((__INDEX__) == 0) KEY_BUTTON_GPIO_CLK_ENABLE(); \ - }while(0) -#define BUTTONx_GPIO_CLK_DISABLE(__INDEX__) do{if((__INDEX__) == 0) KEY_BUTTON_GPIO_CLK_DISABLE(); \ - }while(0) -/** - * @} - */ - -/** @addtogroup __STM32F411E_DISCOVERY_HLOW_LEVEL_BUS - * @{ - */ - -/*############################### I2Cx #######################################*/ -#define DISCOVERY_I2Cx I2C1 -#define DISCOVERY_I2Cx_CLOCK_ENABLE() __I2C1_CLK_ENABLE() -#define DISCOVERY_I2Cx_GPIO_PORT GPIOB /* GPIOB */ -#define DISCOVERY_I2Cx_SCL_PIN GPIO_PIN_6 /* PB.06 */ -#define DISCOVERY_I2Cx_SDA_PIN GPIO_PIN_9 /* PB.09 */ -#define DISCOVERY_I2Cx_GPIO_CLK_ENABLE() __GPIOB_CLK_ENABLE() -#define DISCOVERY_I2Cx_GPIO_CLK_DISABLE() __GPIOB_CLK_DISABLE() -#define DISCOVERY_I2Cx_AF GPIO_AF4_I2C1 - -#define DISCOVERY_I2Cx_FORCE_RESET() __I2C1_FORCE_RESET() -#define DISCOVERY_I2Cx_RELEASE_RESET() __I2C1_RELEASE_RESET() - -/* I2C interrupt requests */ -#define DISCOVERY_I2Cx_EV_IRQn I2C1_EV_IRQn -#define DISCOVERY_I2Cx_ER_IRQn I2C1_ER_IRQn - -/* I2C speed and timeout max */ -#define I2Cx_TIMEOUT_MAX 0xA000 /*
© COPYRIGHT(c) 2015 STMicroelectronics
- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Includes ------------------------------------------------------------------*/ -#include "stm32f411e_discovery_accelerometer.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32F411E_DISCOVERY - * @{ - */ - -/** @addtogroup STM32F411E_DISCOVERY_ACCELEROMETER - * @{ - */ - -/** @defgroup STM32F411E_DISCOVERY_ACCELEROMETER_Private_TypesDefinitions - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F411E_DISCOVERY_ACCELEROMETER_Private_Defines - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F411E_DISCOVERY_ACCELEROMETER_Private_Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F411E_DISCOVERY_ACCELEROMETER_Private_Variables - * @{ - */ -static ACCELERO_DrvTypeDef *AccelerometerDrv; -/** - * @} - */ - -/** @defgroup STM32F411E_DISCOVERY_ACCELEROMETER_Private_FunctionPrototypes - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F411E_DISCOVERY_ACCELEROMETER_Private_Functions - * @{ - */ - -/** - * @brief Set Accelerometer Initialization. - * @param None - * @retval ACCELERO_OK if no problem during initialization - */ -uint8_t BSP_ACCELERO_Init(void) -{ - uint8_t ret = ACCELERO_ERROR; - uint16_t ctrl = 0x0000; - ACCELERO_InitTypeDef LSM303DLHC_InitStructure; - ACCELERO_FilterConfigTypeDef LSM303DLHC_FilterStructure = {0,0,0,0}; - - if(Lsm303dlhcDrv.ReadID() == I_AM_LMS303DLHC) - { - /* Initialize the Accelerometer driver structure */ - AccelerometerDrv = &Lsm303dlhcDrv; - - /* MEMS configuration ----------------------------------------------------*/ - /* Fill the Accelerometer structure */ - LSM303DLHC_InitStructure.Power_Mode = LSM303DLHC_NORMAL_MODE; - LSM303DLHC_InitStructure.AccOutput_DataRate = LSM303DLHC_ODR_50_HZ; - LSM303DLHC_InitStructure.Axes_Enable = LSM303DLHC_AXES_ENABLE; - LSM303DLHC_InitStructure.AccFull_Scale = LSM303DLHC_FULLSCALE_2G; - LSM303DLHC_InitStructure.BlockData_Update = LSM303DLHC_BlockUpdate_Continous; - LSM303DLHC_InitStructure.Endianness = LSM303DLHC_BLE_LSB; - LSM303DLHC_InitStructure.High_Resolution = LSM303DLHC_HR_ENABLE; - - /* Configure MEMS: data rate, power mode, full scale and axes */ - ctrl |= (LSM303DLHC_InitStructure.Power_Mode | LSM303DLHC_InitStructure.AccOutput_DataRate | \ - LSM303DLHC_InitStructure.Axes_Enable); - - ctrl |= ((LSM303DLHC_InitStructure.BlockData_Update | LSM303DLHC_InitStructure.Endianness | \ - LSM303DLHC_InitStructure.AccFull_Scale | LSM303DLHC_InitStructure.High_Resolution) << 8); - - /* Configure the Accelerometer main parameters */ - AccelerometerDrv->Init(ctrl); - - /* Fill the Accelerometer LPF structure */ - LSM303DLHC_FilterStructure.HighPassFilter_Mode_Selection =LSM303DLHC_HPM_NORMAL_MODE; - LSM303DLHC_FilterStructure.HighPassFilter_CutOff_Frequency = LSM303DLHC_HPFCF_16; - LSM303DLHC_FilterStructure.HighPassFilter_AOI1 = LSM303DLHC_HPF_AOI1_DISABLE; - LSM303DLHC_FilterStructure.HighPassFilter_AOI2 = LSM303DLHC_HPF_AOI2_DISABLE; - - /* Configure MEMS: mode, cutoff frquency, Filter status, Click, AOI1 and AOI2 */ - ctrl = (uint8_t) (LSM303DLHC_FilterStructure.HighPassFilter_Mode_Selection |\ - LSM303DLHC_FilterStructure.HighPassFilter_CutOff_Frequency|\ - LSM303DLHC_FilterStructure.HighPassFilter_AOI1|\ - LSM303DLHC_FilterStructure.HighPassFilter_AOI2); - - /* Configure the Accelerometer LPF main parameters */ - AccelerometerDrv->FilterConfig(ctrl); - - ret = ACCELERO_OK; - } - else - { - ret = ACCELERO_ERROR; - } - - return ret; -} - -/** - * @brief Reboot memory content of Accelerometer. - * @param None - * @retval None - */ -void BSP_ACCELERO_Reset(void) -{ - if(AccelerometerDrv->Reset != NULL) - { - AccelerometerDrv->Reset(); - } -} - -/** - * @brief Configure Accelerometer click IT. - * @param None - * @retval None - */ -void BSP_ACCELERO_Click_ITConfig(void) -{ - if(AccelerometerDrv->ConfigIT!= NULL) - { - AccelerometerDrv->ConfigIT(); - } -} - -/** - * @brief Get XYZ axes acceleration. - * @param pDataXYZ: Pointer to 3 angular acceleration axes. - * pDataXYZ[0] = X axis, pDataXYZ[1] = Y axis, pDataXYZ[2] = Z axis - * @retval None - */ -void BSP_ACCELERO_GetXYZ(int16_t *pDataXYZ) -{ - int16_t SwitchXY = 0; - - if(AccelerometerDrv->GetXYZ!= NULL) - { - AccelerometerDrv->GetXYZ(pDataXYZ); - - /* Switch X and Y Axes in case of LSM303DLHC MEMS */ - if(AccelerometerDrv == &Lsm303dlhcDrv) - { - SwitchXY = pDataXYZ[0]; - pDataXYZ[0] = pDataXYZ[1]; - - /* Invert Y Axis to be conpliant with LIS3DSH */ - pDataXYZ[1] = -SwitchXY; - } - } -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32F411E-Discovery/stm32f411e_discovery_accelerometer.h b/bsp/stm32f411RE/Libraries/BSP/STM32F411E-Discovery/stm32f411e_discovery_accelerometer.h deleted file mode 100644 index bac072b81b..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32F411E-Discovery/stm32f411e_discovery_accelerometer.h +++ /dev/null @@ -1,118 +0,0 @@ -/** - ****************************************************************************** - * @file stm32f411e_discovery_accelerometer.h - * @author MCD Application Team - * @version V1.0.0 - * @date 12-November-2015 - * @brief This file contains all the functions prototypes for the - * stm32f411e_discovery_accelerometer.c firmware driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32F411E_DISCOVERY_ACCELEROMETER_H -#define __STM32F411E_DISCOVERY_ACCELEROMETER_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm32f411e_discovery.h" - -/* Include Accelerometer component driver */ -#include "../Components/lsm303dlhc/lsm303dlhc.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32F411E_DISCOVERY - * @{ - */ - -/** @addtogroup STM32F411E_DISCOVERY_ACCELEROMETER - * @{ - */ - -/** @defgroup STM32F411E_DISCOVERY_ACCELEROMETER_Exported_Types - * @{ - */ -typedef enum -{ - ACCELERO_OK = 0, - ACCELERO_ERROR = 1, - ACCELERO_TIMEOUT = 2 -}ACCELERO_StatusTypeDef; - -/** - * @} - */ - -/** @defgroup STM32F411E_DISCOVERY_ACCELEROMETER_Exported_Constants - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F411E_DISCOVERY_ACCELEROMETER_Exported_Functions - * @{ - */ -/* Accelerometer functions */ -uint8_t BSP_ACCELERO_Init(void); -void BSP_ACCELERO_Reset(void); -void BSP_ACCELERO_Click_ITConfig(void); -void BSP_ACCELERO_GetXYZ(int16_t *pDataXYZ); - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32F411E_DISCOVERY_ACCELEROMETER_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32F411E-Discovery/stm32f411e_discovery_audio.c b/bsp/stm32f411RE/Libraries/BSP/STM32F411E-Discovery/stm32f411e_discovery_audio.c deleted file mode 100644 index 4cee9d4f55..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32F411E-Discovery/stm32f411e_discovery_audio.c +++ /dev/null @@ -1,1044 +0,0 @@ -/** - ****************************************************************************** - * @file stm32f411e_discovery_audio.c - * @author MCD Application Team - * @version V1.0.0 - * @date 12-November-2015 - * @brief This file provides the Audio driver for the STM32F411E-Discovery - * board. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/*============================================================================== - User NOTES -1. How To use this driver: --------------------------- - - This driver supports STM32F411xx devices on STM32F411E-Discovery Kit: - a) to play an audio file (all functions names start by BSP_AUDIO_OUT_xxx) - b) to record an audio file through MP45DT02, ST MEMS (all functions names start by AUDIO_IN_xxx) - -a) PLAY A FILE: -============== - + Call the function BSP_AUDIO_OUT_Init( - OutputDevice: physical output mode (OUTPUT_DEVICE_SPEAKER, - OUTPUT_DEVICE_HEADPHONE, OUTPUT_DEVICE_AUTO or - OUTPUT_DEVICE_BOTH) - Volume: initial volume to be set (0 is min (mute), 100 is max (100%) - AudioFreq: Audio frequency in Hz (8000, 16000, 22500, 32000 ...) - this parameter is relative to the audio file/stream type. - ) - This function configures all the hardware required for the audio application (codec, I2C, I2S, - GPIOs, DMA and interrupt if needed). This function returns 0 if configuration is OK. - If the returned value is different from 0 or the function is stuck then the communication with - the codec (try to un-plug the power or reset device in this case). - - OUTPUT_DEVICE_SPEAKER: only speaker will be set as output for the audio stream. - - OUTPUT_DEVICE_HEADPHONE: only headphones will be set as output for the audio stream. - - OUTPUT_DEVICE_AUTO: Selection of output device is made through external switch (implemented - into the audio jack on the discovery board). When the Headphone is connected it is used - as output. When the headphone is disconnected from the audio jack, the output is - automatically switched to Speaker. - - OUTPUT_DEVICE_BOTH: both Speaker and Headphone are used as outputs for the audio stream - at the same time. - + Call the function BSP_AUDIO_OUT_Play( - pBuffer: pointer to the audio data file address - Size: size of the buffer to be sent in Bytes - ) - to start playing (for the first time) from the audio file/stream. - + Call the function BSP_AUDIO_OUT_Pause() to pause playing - + Call the function BSP_AUDIO_OUT_Resume() to resume playing. - Note. After calling BSP_AUDIO_OUT_Pause() function for pause, only BSP_AUDIO_OUT_Resume() should be called - for resume (it is not allowed to call BSP_AUDIO_OUT_Play() in this case). - Note. This function should be called only when the audio file is played or paused (not stopped). - + For each mode, you may need to implement the relative callback functions into your code. - The Callback functions are named BSP_AUDIO_OUT_XXXCallBack() and only their prototypes are declared in - the stm32f411e_discovery_audio.h file. (refer to the example for more details on the callbacks implementations) - + To Stop playing, to modify the volume level, the frequency or to mute, use the functions - BSP_AUDIO_OUT_Stop(), BSP_AUDIO_OUT_SetVolume(), AUDIO_OUT_SetFrequency() BSP_AUDIO_OUT_SetOutputMode and BSP_AUDIO_OUT_SetMute(). - + The driver API and the callback functions are at the end of the stm32f411e_discovery_audio.h file. - -Driver architecture: --------------------- - + This driver provide the High Audio Layer: consists of the function API exported in the stm32f411e_discovery_audio.h file - (BSP_AUDIO_OUT_Init(), BSP_AUDIO_OUT_Play() ...) - + This driver provide also the Media Access Layer (MAL): which consists of functions allowing to access the media containing/ - providing the audio file/stream. These functions are also included as local functions into - the stm32f411e_discovery_audio.c file (I2S3_Init()...) - -Known Limitations: -------------------- - 1- When using the Speaker, if the audio file quality is not high enough, the speaker output - may produce high and uncomfortable noise level. To avoid this issue, to use speaker - output properly, try to increase audio file sampling rate (typically higher than 48KHz). - This operation will lead to larger file size. - 2- Communication with the audio codec (through I2C) may be corrupted if it is interrupted by some - user interrupt routines (in this case, interrupts could be disabled just before the start of - communication then re-enabled when it is over). Note that this communication is only done at - the configuration phase (BSP_AUDIO_OUT_Init() or BSP_AUDIO_OUT_Stop()) and when Volume control modification is - performed (BSP_AUDIO_OUT_SetVolume() or BSP_AUDIO_OUT_SetMute()or BSP_AUDIO_OUT_SetOutputMode()). - When the audio data is played, no communication is required with the audio codec. - 3- Parsing of audio file is not implemented (in order to determine audio file properties: Mono/Stereo, Data size, - File size, Audio Frequency, Audio Data header size ...). The configuration is fixed for the given audio file. - 4- Supports only Stereo audio streaming. To play mono audio streams, each data should be sent twice - on the I2S or should be duplicated on the source buffer. Or convert the stream in stereo before playing. - 5- Supports only 16-bits audio data size. - -b) RECORD A FILE: -================ - + Call the function BSP_AUDIO_IN_Init( - AudioFreq: Audio frequency in Hz (8000, 16000, 22500, 32000 ...) - ) - This function configures all the hardware required for the audio application (I2S, - GPIOs, DMA and interrupt if needed). This function returns 0 if configuration is OK. - - + Call the function BSP_AUDIO_IN_Record( - pbuf Main buffer pointer for the recorded data storing - size Current size of the recorded buffer - ) - to start recording from the microphone. - - + User needs to implement user callbacks to retrieve data saved in the record buffer - (AUDIO_IN_RxHalfCpltCallback/BSP_AUDIO_IN_ReceiveComplete_CallBack) - - + Call the function AUDIO_IN_STOP() to stop recording - -==============================================================================*/ - -/* Includes ------------------------------------------------------------------*/ -#include "stm32f411e_discovery_audio.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32F411E_DISCOVERY - * @{ - */ - -/** @addtogroup STM32F411E_DISCOVERY_AUDIO - * @brief This file includes the low layer audio driver available on STM32F411E-Discovery - * discovery board. - * @{ - */ - -/** @defgroup STM32F411E_DISCOVERY_AUDIO_Private_Types - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F411E_DISCOVERY_AUDIO_Private_Defines - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F411E_DISCOVERY_AUDIO_Private_Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F411E_DISCOVERY_AUDIO_Private_Variables - * @{ - */ -/*##### PLAY #####*/ -static AUDIO_DrvTypeDef *pAudioDrv; -I2S_HandleTypeDef hAudioOutI2s; - -/*### RECORDER ###*/ -I2S_HandleTypeDef hAudioInI2s; - -PDMFilter_InitStruct Filter[DEFAULT_AUDIO_IN_CHANNEL_NBR]; -uint16_t __IO AudioInVolume = DEFAULT_AUDIO_IN_VOLUME; - -/** - * @} - */ - -/** @defgroup STM32F411E_DISCOVERY_AUDIO_Private_Function_Prototypes - * @{ - */ -static void I2S3_MspInit(void); -static void I2S3_Init(uint32_t AudioFreq); - -static void I2S2_MspInit(void); -static void I2S2_Init(uint32_t AudioFreq); -static void PDMDecoder_Init(uint32_t AudioFreq, uint32_t ChnlNbr); -/** - * @} - */ - -/** @defgroup STM32F411E_DISCOVERY_AUDIO_OUT_Private_Functions - * @{ - */ - -/** - * @brief Configure the audio peripherals. - * @param OutputDevice: OUTPUT_DEVICE_SPEAKER, OUTPUT_DEVICE_HEADPHONE, - * OUTPUT_DEVICE_BOTH or OUTPUT_DEVICE_AUTO . - * @param Volume: Initial volume level (from 0 (Mute) to 100 (Max)) - * @param AudioFreq: Audio frequency used to play the audio stream. - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_Init(uint16_t OutputDevice, uint8_t Volume, uint32_t AudioFreq) -{ - uint8_t ret = AUDIO_ERROR; - uint32_t deviceid = 0x00; - RCC_PeriphCLKInitTypeDef rccclkinit; - - /* Enable PLLI2S clock */ - HAL_RCCEx_GetPeriphCLKConfig(&rccclkinit); - /* PLLI2S_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */ - if((AudioFreq & 0x7) == 0) - { - /* Audio frequency multiple of 8 (8/16/32/48/96/192)*/ - /* PLLI2S_VCO Output = PLLI2S_VCO Input * PLLI2SN = 192 Mhz */ - /* I2SCLK = PLLI2S_VCO Output/PLLI2SR = 192/6 = 32 Mhz */ - rccclkinit.PeriphClockSelection = RCC_PERIPHCLK_I2S; - rccclkinit.PLLI2S.PLLI2SN = 192; - rccclkinit.PLLI2S.PLLI2SR = 6; - HAL_RCCEx_PeriphCLKConfig(&rccclkinit); - } - else - { - /* Other Frequency (11.025/22.500/44.100) */ - /* PLLI2S_VCO Output = PLLI2S_VCO Input * PLLI2SN = 290 Mhz */ - /* I2SCLK = PLLI2S_VCO Output/PLLI2SR = 290/2 = 145 Mhz */ - rccclkinit.PeriphClockSelection = RCC_PERIPHCLK_I2S; - rccclkinit.PLLI2S.PLLI2SN = 290; - rccclkinit.PLLI2S.PLLI2SR = 2; - HAL_RCCEx_PeriphCLKConfig(&rccclkinit); - } - - deviceid = cs43l22_drv.ReadID(AUDIO_I2C_ADDRESS); - - if((deviceid & CS43L22_ID_MASK) == CS43L22_ID) - { - /* Initialize the audio driver structure */ - pAudioDrv = &cs43l22_drv; - ret = AUDIO_OK; - } - else - { - ret = AUDIO_ERROR; - } - - if(ret == AUDIO_OK) - { - pAudioDrv->Init(AUDIO_I2C_ADDRESS, OutputDevice, Volume, AudioFreq); - /* I2S data transfer preparation: - Prepare the Media to be used for the audio transfer from memory to I2S peripheral */ - /* Configure the I2S peripheral */ - I2S3_Init(AudioFreq); - } - - return ret; -} - -/** - * @brief Starts playing audio stream from a data buffer for a determined size. - * @param pBuffer: Pointer to the buffer - * @param Size: Number of audio data BYTES. - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_Play(uint16_t* pBuffer, uint32_t Size) -{ - /* Call the audio Codec Play function */ - if(pAudioDrv->Play(AUDIO_I2C_ADDRESS, pBuffer, Size) != 0) - { - return AUDIO_ERROR; - } - else - { - /* Update the Media layer and enable it for play */ - HAL_I2S_Transmit_DMA(&hAudioOutI2s, pBuffer, DMA_MAX(Size/AUDIODATA_SIZE)); - - return AUDIO_OK; - } -} - -/** - * @brief Sends n-Bytes on the I2S interface. - * @param pData: Pointer to data address - * @param Size: Number of data to be written - * @retval None - */ -void BSP_AUDIO_OUT_ChangeBuffer(uint16_t *pData, uint16_t Size) -{ - HAL_I2S_Transmit_DMA(&hAudioOutI2s, pData, Size); -} - -/** - * @brief This function Pauses the audio file stream. In case - * of using DMA, the DMA Pause feature is used. - * @WARNING When calling BSP_AUDIO_OUT_Pause() function for pause, only - * BSP_AUDIO_OUT_Resume() function should be called for resume (use of BSP_AUDIO_OUT_Play() - * function for resume could lead to unexpected behavior). - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_Pause(void) -{ - /* Call the Audio Codec Pause/Resume function */ - if(pAudioDrv->Pause(AUDIO_I2C_ADDRESS) != 0) - { - return AUDIO_ERROR; - } - else - { - /* Call the Media layer pause function */ - HAL_I2S_DMAPause(&hAudioOutI2s); - - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; - } -} - -/** - * @brief This function Resumes the audio file stream. - * @WARNING When calling BSP_AUDIO_OUT_Pause() function for pause, only - * BSP_AUDIO_OUT_Resume() function should be called for resume (use of BSP_AUDIO_OUT_Play() - * function for resume could lead to unexpected behavior). - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_Resume(void) -{ - /* Call the Audio Codec Pause/Resume function */ - if(pAudioDrv->Resume(AUDIO_I2C_ADDRESS) != 0) - { - return AUDIO_ERROR; - } - else - { - /* Call the Media layer resume function */ - HAL_I2S_DMAResume(&hAudioOutI2s); - - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; - } -} - -/** - * @brief Stops audio playing and Power down the Audio Codec. - * @param Option: could be one of the following parameters - * - CODEC_PDWN_HW: completely shut down the codec (physically). - * Then need to reconfigure the Codec after power on. - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_Stop(uint32_t Option) -{ - /* Call DMA Stop to disable DMA stream before stopping codec */ - HAL_I2S_DMAStop(&hAudioOutI2s); - - /* Call Audio Codec Stop function */ - if(pAudioDrv->Stop(AUDIO_I2C_ADDRESS, Option) != 0) - { - return AUDIO_ERROR; - } - else - { - if(Option == CODEC_PDWN_HW) - { - /* Wait at least 100us */ - HAL_Delay(1); - - /* Reset the pin */ - HAL_GPIO_WritePin(AUDIO_RESET_GPIO, AUDIO_RESET_PIN, GPIO_PIN_RESET); - } - - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; - } -} - -/** - * @brief Controls the current audio volume level. - * @param Volume: Volume level to be set in percentage from 0% to 100% (0 for - * Mute and 100 for Max volume level). - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_SetVolume(uint8_t Volume) -{ - /* Call the codec volume control function with converted volume value */ - if(pAudioDrv->SetVolume(AUDIO_I2C_ADDRESS, Volume) != 0) - { - return AUDIO_ERROR; - } - else - { - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; - } -} - -/** - * @brief Enables or disables the MUTE mode by software - * @param Cmd: could be AUDIO_MUTE_ON to mute sound or AUDIO_MUTE_OFF to - * unmute the codec and restore previous volume level. - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_SetMute(uint32_t Cmd) -{ - /* Call the Codec Mute function */ - if(pAudioDrv->SetMute(AUDIO_I2C_ADDRESS, Cmd) != 0) - { - return AUDIO_ERROR; - } - else - { - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; - } -} - -/** - * @brief Switch dynamically (while audio file is played) the output target - * (speaker or headphone). - * @note This function modifies a global variable of the audio codec driver: OutputDev. - * @param Output: specifies the audio output target: OUTPUT_DEVICE_SPEAKER, - * OUTPUT_DEVICE_HEADPHONE, OUTPUT_DEVICE_BOTH or OUTPUT_DEVICE_AUTO - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_OUT_SetOutputMode(uint8_t Output) -{ - /* Call the Codec output Device function */ - if(pAudioDrv->SetOutputMode(AUDIO_I2C_ADDRESS, Output) != 0) - { - return AUDIO_ERROR; - } - else - { - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; - } -} - -/** - * @brief Update the audio frequency. - * @param AudioFreq: Audio frequency used to play the audio stream. - * @retval None - * @note This API should be called after the BSP_AUDIO_OUT_Init() to adjust the - * audio frequency. - */ -void BSP_AUDIO_OUT_SetFrequency(uint32_t AudioFreq) -{ - RCC_PeriphCLKInitTypeDef rccclkinit; - - /* Enable PLLI2S clock */ - HAL_RCCEx_GetPeriphCLKConfig(&rccclkinit); - /* PLLI2S_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */ - if ((AudioFreq & 0x7) == 0) - { - /* Audio frequency multiple of 8 (8/16/32/48/96/192)*/ - /* PLLI2S_VCO Output = PLLI2S_VCO Input * PLLI2SN = 192 Mhz */ - /* I2SCLK = PLLI2S_VCO Output/PLLI2SR = 192/6 = 32 Mhz */ - rccclkinit.PeriphClockSelection = RCC_PERIPHCLK_I2S; - rccclkinit.PLLI2S.PLLI2SN = 192; - rccclkinit.PLLI2S.PLLI2SR = 6; - HAL_RCCEx_PeriphCLKConfig(&rccclkinit); - } - else - { - /* Other Frequency (11.025/22.500/44.100) */ - /* PLLI2S_VCO Output = PLLI2S_VCO Input * PLLI2SN = 290 Mhz */ - /* I2SCLK = PLLI2S_VCO Output/PLLI2SR = 290/2 = 145 Mhz */ - rccclkinit.PeriphClockSelection = RCC_PERIPHCLK_I2S; - rccclkinit.PLLI2S.PLLI2SN = 290; - rccclkinit.PLLI2S.PLLI2SR = 2; - HAL_RCCEx_PeriphCLKConfig(&rccclkinit); - } - - /* Update the I2S audio frequency configuration */ - I2S3_Init(AudioFreq); -} - -/** - * @brief Tx Transfer completed callbacks. - * @param hi2s: I2S handle - * @retval None - */ -void HAL_I2S_TxCpltCallback(I2S_HandleTypeDef *hi2s) -{ - if(hi2s->Instance == I2S3) - { - /* Call the user function which will manage directly transfer complete */ - BSP_AUDIO_OUT_TransferComplete_CallBack(); - } -} - -/** - * @brief Tx Half Transfer completed callbacks. - * @param hi2s: I2S handle - * @retval None - */ -void HAL_I2S_TxHalfCpltCallback(I2S_HandleTypeDef *hi2s) -{ - if(hi2s->Instance == I2S3) - { - /* Manage the remaining file size and new address offset: This function - should be coded by user (its prototype is already declared in stm32f411e_discovery_audio.h) */ - BSP_AUDIO_OUT_HalfTransfer_CallBack(); - } -} - -/** - * @brief Manages the DMA full Transfer complete event. - * @param None - * @retval None - */ -__weak void BSP_AUDIO_OUT_TransferComplete_CallBack(void) -{ -} - -/** - * @brief Manages the DMA Half Transfer complete event. - * @param None - * @retval None - */ -__weak void BSP_AUDIO_OUT_HalfTransfer_CallBack(void) -{ -} - -/** - * @brief Manages the DMA FIFO error event. - * @param None - * @retval None - */ -__weak void BSP_AUDIO_OUT_Error_CallBack(void) -{ -} - -/******************************************************************************* - Static Functions -*******************************************************************************/ - -/** - * @brief AUDIO OUT I2S MSP Init. - * @param None - * @retval None - */ -static void I2S3_MspInit(void) -{ - static DMA_HandleTypeDef hdma_i2sTx; - GPIO_InitTypeDef GPIO_InitStruct; - I2S_HandleTypeDef *hi2s = &hAudioOutI2s; - - /* Enable I2S3 clock */ - I2S3_CLK_ENABLE(); - - /*** Configure the GPIOs ***/ - /* Enable I2S GPIO clocks */ - I2S3_SCK_SD_CLK_ENABLE(); - I2S3_WS_CLK_ENABLE(); - - /* I2S3 pins configuration: WS, SCK and SD pins ----------------------------*/ - GPIO_InitStruct.Pin = I2S3_SCK_PIN | I2S3_SD_PIN; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FAST; - GPIO_InitStruct.Alternate = I2S3_SCK_SD_WS_AF; - HAL_GPIO_Init(I2S3_SCK_SD_GPIO_PORT, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = I2S3_WS_PIN ; - HAL_GPIO_Init(I2S3_WS_GPIO_PORT, &GPIO_InitStruct); - - /* I2S3 pins configuration: MCK pin */ - I2S3_MCK_CLK_ENABLE(); - GPIO_InitStruct.Pin = I2S3_MCK_PIN; - HAL_GPIO_Init(I2S3_MCK_GPIO_PORT, &GPIO_InitStruct); - - /* Enable the I2S DMA clock */ - I2S3_DMAx_CLK_ENABLE(); - - if(hi2s->Instance == I2S3) - { - /* Configure the hdma_i2sTx handle parameters */ - hdma_i2sTx.Init.Channel = I2S3_DMAx_CHANNEL; - hdma_i2sTx.Init.Direction = DMA_MEMORY_TO_PERIPH; - hdma_i2sTx.Init.PeriphInc = DMA_PINC_DISABLE; - hdma_i2sTx.Init.MemInc = DMA_MINC_ENABLE; - hdma_i2sTx.Init.PeriphDataAlignment = I2S3_DMAx_PERIPH_DATA_SIZE; - hdma_i2sTx.Init.MemDataAlignment = I2S3_DMAx_MEM_DATA_SIZE; - hdma_i2sTx.Init.Mode = DMA_NORMAL; - hdma_i2sTx.Init.Priority = DMA_PRIORITY_HIGH; - hdma_i2sTx.Init.FIFOMode = DMA_FIFOMODE_ENABLE; - hdma_i2sTx.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; - hdma_i2sTx.Init.MemBurst = DMA_MBURST_SINGLE; - hdma_i2sTx.Init.PeriphBurst = DMA_PBURST_SINGLE; - - hdma_i2sTx.Instance = I2S3_DMAx_STREAM; - - /* Associate the DMA handle */ - __HAL_LINKDMA(hi2s, hdmatx, hdma_i2sTx); - - /* Deinitialize the Stream for new transfer */ - HAL_DMA_DeInit(&hdma_i2sTx); - - /* Configure the DMA Stream */ - HAL_DMA_Init(&hdma_i2sTx); - } - - /* I2S DMA IRQ Channel configuration */ - HAL_NVIC_SetPriority(I2S3_DMAx_IRQ, AUDIO_OUT_IRQ_PREPRIO, 0); - HAL_NVIC_EnableIRQ(I2S3_DMAx_IRQ); -} - -/** - * @brief Initializes the Audio Codec audio interface (I2S) - * @param AudioFreq: Audio frequency to be configured for the I2S peripheral. - * @retval None - */ -static void I2S3_Init(uint32_t AudioFreq) -{ - /* Initialize the hAudioOutI2s Instance parameter */ - hAudioOutI2s.Instance = I2S3; - - /* Disable I2S block */ - __HAL_I2S_DISABLE(&hAudioOutI2s); - - /* I2S3 peripheral configuration */ - hAudioOutI2s.Init.AudioFreq = AudioFreq; - hAudioOutI2s.Init.ClockSource = I2S_CLOCK_PLL; - hAudioOutI2s.Init.CPOL = I2S_CPOL_LOW; - hAudioOutI2s.Init.DataFormat = I2S_DATAFORMAT_16B; - hAudioOutI2s.Init.MCLKOutput = I2S_MCLKOUTPUT_ENABLE; - hAudioOutI2s.Init.Mode = I2S_MODE_MASTER_TX; - hAudioOutI2s.Init.Standard = I2S_STANDARD; - - /* Initialize the I2S peripheral with the structure above */ - if(HAL_I2S_GetState(&hAudioOutI2s) == HAL_I2S_STATE_RESET) - { - I2S3_MspInit(); - } - - HAL_I2S_Init(&hAudioOutI2s); -} - -/** - * @} - */ - -/** @defgroup STM32F411E_DISCOVERY_AUDIO_IN_Private_Functions - * @{ - */ - -/** - * @brief Initializes wave recording. - * @param AudioFreq: Audio frequency to be configured for the I2S peripheral. - * @param BitRes: Audio frequency to be configured for the I2S peripheral. - * @param ChnlNbr: Audio frequency to be configured for the I2S peripheral. - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_IN_Init(uint32_t AudioFreq, uint32_t BitRes, uint32_t ChnlNbr) -{ - RCC_PeriphCLKInitTypeDef rccclkinit; - - /* Enable PLLI2S clock */ - HAL_RCCEx_GetPeriphCLKConfig(&rccclkinit); - /* PLLI2S_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */ - if ((AudioFreq & 0x7) == 0) - { - /* Audio frequency multiple of 8 (8/16/32/48/96/192)*/ - /* PLLI2S_VCO Output = PLLI2S_VCO Input * PLLI2SN = 192 Mhz */ - /* I2SCLK = PLLI2S_VCO Output/PLLI2SR = 192/6 = 32 Mhz */ - rccclkinit.PeriphClockSelection = RCC_PERIPHCLK_I2S; - rccclkinit.PLLI2S.PLLI2SN = 192; - rccclkinit.PLLI2S.PLLI2SR = 6; - HAL_RCCEx_PeriphCLKConfig(&rccclkinit); - } - else - { - /* Other Frequency (11.025/22.500/44.100) */ - /* PLLI2S_VCO Output = PLLI2S_VCO Input * PLLI2SN = 290 Mhz */ - /* I2SCLK = PLLI2S_VCO Output/PLLI2SR = 290/2 = 145 Mhz */ - rccclkinit.PeriphClockSelection = RCC_PERIPHCLK_I2S; - rccclkinit.PLLI2S.PLLI2SN = 290; - rccclkinit.PLLI2S.PLLI2SR = 2; - HAL_RCCEx_PeriphCLKConfig(&rccclkinit); - } - - /* Configure the PDM library */ - PDMDecoder_Init(AudioFreq, ChnlNbr); - - /* Configure the I2S2 */ - I2S2_Init(AudioFreq); - - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; -} - -/** - * @brief Starts audio recording. - * @param pbuf: Main buffer pointer for the recorded data storing - * @param size: Current size of the recorded buffer - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_IN_Record(uint16_t* pbuf, uint32_t size) -{ - uint32_t ret = AUDIO_ERROR; - - /* Start the process receive DMA */ - HAL_I2S_Receive_DMA(&hAudioInI2s, pbuf, size); - - /* Return AUDIO_OK when all operations are correctly done */ - ret = AUDIO_OK; - - return ret; -} - -/** - * @brief Stops audio recording. - * @param None - * @retval None - */ -uint8_t BSP_AUDIO_IN_Stop(void) -{ - uint32_t ret = AUDIO_ERROR; - - /* Call the Media layer pause function */ - HAL_I2S_DMAStop(&hAudioInI2s); - - /* Return AUDIO_OK when all operations are correctly done */ - ret = AUDIO_OK; - - return ret; -} - -/** - * @brief Pauses the audio file stream. - * @param None - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_IN_Pause(void) -{ - /* Call the Media layer pause function */ - HAL_I2S_DMAPause(&hAudioInI2s); - - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; -} - -/** - * @brief Resumes the audio file stream. - * @param None - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_IN_Resume(void) -{ - /* Call the Media layer pause/resume function */ - HAL_I2S_DMAResume(&hAudioInI2s); - - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; -} - -/** - * @brief Controls the audio in volume level. - * @param Volume: Volume level to be set in percentage from 0% to 100% (0 for - * Mute and 100 for Max volume level). - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_IN_SetVolume(uint8_t Volume) -{ - /* Set the Global variable AudioInVolume */ - AudioInVolume = Volume; - - /* Return AUDIO_OK when all operations are correctly done */ - return AUDIO_OK; -} - -/** - * @brief Converts audio format from PDM to PCM. - * @param PDMBuf: Pointer to data PDM buffer - * @param PCMBuf: Pointer to data PCM buffer - * @retval AUDIO_OK if correct communication, else wrong communication - */ -uint8_t BSP_AUDIO_IN_PDMToPCM(uint16_t *PDMBuf, uint16_t *PCMBuf) -{ - uint16_t AppPDM[INTERNAL_BUFF_SIZE/2]; - uint32_t index = 0; - - /* PDM Demux */ - for(index = 0; indexInstance == I2S2) - { - /* Configure the hdma_i2sRx handle parameters */ - hdma_i2sRx.Init.Channel = I2S2_DMAx_CHANNEL; - hdma_i2sRx.Init.Direction = DMA_PERIPH_TO_MEMORY; - hdma_i2sRx.Init.PeriphInc = DMA_PINC_DISABLE; - hdma_i2sRx.Init.MemInc = DMA_MINC_ENABLE; - hdma_i2sRx.Init.PeriphDataAlignment = I2S2_DMAx_PERIPH_DATA_SIZE; - hdma_i2sRx.Init.MemDataAlignment = I2S2_DMAx_MEM_DATA_SIZE; - hdma_i2sRx.Init.Mode = DMA_CIRCULAR; - hdma_i2sRx.Init.Priority = DMA_PRIORITY_HIGH; - hdma_i2sRx.Init.FIFOMode = DMA_FIFOMODE_DISABLE; - hdma_i2sRx.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; - hdma_i2sRx.Init.MemBurst = DMA_MBURST_SINGLE; - hdma_i2sRx.Init.PeriphBurst = DMA_MBURST_SINGLE; - - hdma_i2sRx.Instance = I2S2_DMAx_STREAM; - - /* Associate the DMA handle */ - __HAL_LINKDMA(hi2s, hdmarx, hdma_i2sRx); - - /* Deinitialize the Stream for new transfer */ - HAL_DMA_DeInit(&hdma_i2sRx); - - /* Configure the DMA Stream */ - HAL_DMA_Init(&hdma_i2sRx); - } - - /* I2S DMA IRQ Channel configuration */ - HAL_NVIC_SetPriority(I2S2_DMAx_IRQ, AUDIO_IN_IRQ_PREPRIO, 0); - HAL_NVIC_EnableIRQ(I2S2_DMAx_IRQ); -} - -/** - * @brief Initializes the Audio Codec audio interface (I2S) - * @note This function assumes that the I2S input clock (through PLL_R in - * Devices RevA/Z and through dedicated PLLI2S_R in Devices RevB/Y) - * is already configured and ready to be used. - * @param AudioFreq: Audio frequency to be configured for the I2S peripheral. - * @retval None - */ -static void I2S2_Init(uint32_t AudioFreq) -{ - /* Initialize the hAudioInI2s Instance parameter */ - hAudioInI2s.Instance = I2S2; - - /* Disable I2S block */ - __HAL_I2S_DISABLE(&hAudioInI2s); - - /* I2S2 peripheral configuration */ - hAudioInI2s.Init.AudioFreq = 2 * AudioFreq; - hAudioInI2s.Init.ClockSource = I2S_CLOCK_PLL; - hAudioInI2s.Init.CPOL = I2S_CPOL_HIGH; - hAudioInI2s.Init.DataFormat = I2S_DATAFORMAT_16B; - hAudioInI2s.Init.MCLKOutput = I2S_MCLKOUTPUT_DISABLE; - hAudioInI2s.Init.Mode = I2S_MODE_MASTER_RX; - hAudioInI2s.Init.Standard = I2S_STANDARD_LSB; - - /* Initialize the I2S peripheral with the structure above */ - if(HAL_I2S_GetState(&hAudioInI2s) == HAL_I2S_STATE_RESET) - { - I2S2_MspInit(); - } - - HAL_I2S_Init(&hAudioInI2s); -} -/** - * @} - */ - -/** @defgroup STM32F411E_DISCOVERY_AUDIO_IN_OUT_Private_Functions - * @{ - */ - -/** - * @brief I2S error callbacks. - * @param hi2s: I2S handle - * @retval None - */ -void HAL_I2S_ErrorCallback(I2S_HandleTypeDef *hi2s) -{ - /* Manage the error generated on DMA FIFO: This function - should be coded by user (its prototype is already declared in stm32f411e_discovery_audio.h) */ - if(hi2s->Instance == I2S3) - { - BSP_AUDIO_OUT_Error_CallBack(); - } - if(hi2s->Instance == I2S2) - { - BSP_AUDIO_IN_Error_Callback(); - } -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32F411E-Discovery/stm32f411e_discovery_audio.h b/bsp/stm32f411RE/Libraries/BSP/STM32F411E-Discovery/stm32f411e_discovery_audio.h deleted file mode 100644 index 166297c2ab..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32F411E-Discovery/stm32f411e_discovery_audio.h +++ /dev/null @@ -1,257 +0,0 @@ -/** - ****************************************************************************** - * @file stm32f411e_discovery_audio.h - * @author MCD Application Team - * @version V1.0.0 - * @date 12-November-2015 - * @brief This file contains the common defines and functions prototypes for - * stm32f411e_discovery_audio.c driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32F411E_DISCOVERY_AUDIO_H -#define __STM32F411E_DISCOVERY_AUDIO_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -/* Include audio component Driver */ -#include "../Components/cs43l22/cs43l22.h" -#include "stm32f411e_discovery.h" -#include "../../../Middlewares/ST/STM32_Audio/Addons/PDM/pdm_filter.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32F411E_DISCOVERY - * @{ - */ - -/** @defgroup STM32F411E_DISCOVERY_AUDIO - * @{ - */ - -/** @defgroup STM32F411E_DISCOVERY_AUDIO_Exported_Types - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F411E_DISCOVERY_AUDIO_OUT_Exported_Constants - * @{ - */ - -/*------------------------------------------------------------------------------ - AUDIO OUT CONFIGURATION -------------------------------------------------------------------------------*/ - -/* I2S peripheral configuration defines */ -#define I2S3 SPI3 -#define I2S3_CLK_ENABLE() __SPI3_CLK_ENABLE() -#define I2S3_SCK_SD_WS_AF GPIO_AF6_SPI3 -#define I2S3_SCK_SD_CLK_ENABLE() __GPIOC_CLK_ENABLE() -#define I2S3_MCK_CLK_ENABLE() __GPIOC_CLK_ENABLE() -#define I2S3_WS_CLK_ENABLE() __GPIOA_CLK_ENABLE() -#define I2S3_WS_PIN GPIO_PIN_4 -#define I2S3_SCK_PIN GPIO_PIN_10 -#define I2S3_SD_PIN GPIO_PIN_12 -#define I2S3_MCK_PIN GPIO_PIN_7 -#define I2S3_SCK_SD_GPIO_PORT GPIOC -#define I2S3_WS_GPIO_PORT GPIOA -#define I2S3_MCK_GPIO_PORT GPIOC - -/* I2S DMA Stream definitions */ -#define I2S3_DMAx_CLK_ENABLE() __DMA1_CLK_ENABLE() -#define I2S3_DMAx_STREAM DMA1_Stream7 -#define I2S3_DMAx_CHANNEL DMA_CHANNEL_0 -#define I2S3_DMAx_IRQ DMA1_Stream7_IRQn -#define I2S3_DMAx_PERIPH_DATA_SIZE DMA_PDATAALIGN_HALFWORD -#define I2S3_DMAx_MEM_DATA_SIZE DMA_MDATAALIGN_HALFWORD -#define DMA_MAX_SZE 0xFFFF - -#define I2S3_IRQHandler DMA1_Stream7_IRQHandler - -/* Select the interrupt preemption priority and subpriority for the DMA interrupt */ -#define AUDIO_OUT_IRQ_PREPRIO 5 /* Select the preemption priority level(0 is the highest) */ - -/*------------------------------------------------------------------------------ - AUDIO IN CONFIGURATION -------------------------------------------------------------------------------*/ -/* SPI Configuration defines */ -#define I2S2 SPI2 -#define I2S2_CLK_ENABLE() __SPI2_CLK_ENABLE() -#define I2S2_SCK_PIN GPIO_PIN_10 -#define I2S2_SCK_GPIO_PORT GPIOB -#define I2S2_SCK_GPIO_CLK_ENABLE() __GPIOB_CLK_ENABLE() -#define I2S2_SCK_AF GPIO_AF5_SPI2 - -#define I2S2_MOSI_PIN GPIO_PIN_3 -#define I2S2_MOSI_GPIO_PORT GPIOC -#define I2S2_MOSI_GPIO_CLK_ENABLE() __GPIOC_CLK_ENABLE() -#define I2S2_MOSI_AF GPIO_AF5_SPI2 - -/* I2S DMA Stream Rx definitions */ -#define I2S2_DMAx_CLK_ENABLE() __DMA1_CLK_ENABLE() -#define I2S2_DMAx_STREAM DMA1_Stream3 -#define I2S2_DMAx_CHANNEL DMA_CHANNEL_0 -#define I2S2_DMAx_IRQ DMA1_Stream3_IRQn -#define I2S2_DMAx_PERIPH_DATA_SIZE DMA_PDATAALIGN_HALFWORD -#define I2S2_DMAx_MEM_DATA_SIZE DMA_MDATAALIGN_HALFWORD - -#define I2S2_IRQHandler DMA1_Stream3_IRQHandler - -/* Select the interrupt preemption priority and subpriority for the IT/DMA interrupt */ -#define AUDIO_IN_IRQ_PREPRIO 6 /* Select the preemption priority level(0 is the highest) */ - -/*------------------------------------------------------------------------------ - CONFIGURATION: Audio Driver Configuration parameters -------------------------------------------------------------------------------*/ - -#define AUDIODATA_SIZE 2 /* 16-bits audio data size */ - -/* Audio status definition */ -#define AUDIO_OK 0 -#define AUDIO_ERROR 1 -#define AUDIO_TIMEOUT 2 - -/* AudioFreq * DataSize (2 bytes) * NumChannels (Stereo: 2) */ -#define DEFAULT_AUDIO_IN_FREQ I2S_AUDIOFREQ_16K -#define DEFAULT_AUDIO_IN_BIT_RESOLUTION 16 -#define DEFAULT_AUDIO_IN_CHANNEL_NBR 1 /* Mono = 1, Stereo = 2 */ -#define DEFAULT_AUDIO_IN_VOLUME 64 - -/* PDM buffer input size */ -#define INTERNAL_BUFF_SIZE 128*DEFAULT_AUDIO_IN_FREQ/16000*DEFAULT_AUDIO_IN_CHANNEL_NBR -/* PCM buffer output size */ -#define PCM_OUT_SIZE DEFAULT_AUDIO_IN_FREQ/1000 -#define CHANNEL_DEMUX_MASK 0x55 - -/*------------------------------------------------------------------------------ - OPTIONAL Configuration defines parameters -------------------------------------------------------------------------------*/ - -/** - * @} - */ - -/** @defgroup STM32F411E_DISCOVERY_AUDIO_Exported_Variables - * @{ - */ -extern __IO uint16_t AudioInVolume; -/** - * @} - */ - -/** @defgroup STM32F411E_DISCOVERY_AUDIO_Exported_Macros - * @{ - */ -#define DMA_MAX(_X_) (((_X_) <= DMA_MAX_SZE)? (_X_):DMA_MAX_SZE) -/** - * @} - */ - -/** @defgroup STM32F411E_DISCOVERY_AUDIO_OUT_Exported_Functions - * @{ - */ -uint8_t BSP_AUDIO_OUT_Init(uint16_t OutputDevice, uint8_t Volume, uint32_t AudioFreq); -uint8_t BSP_AUDIO_OUT_Play(uint16_t *pBuffer, uint32_t Size); -void BSP_AUDIO_OUT_ChangeBuffer(uint16_t *pData, uint16_t Size); -uint8_t BSP_AUDIO_OUT_Pause(void); -uint8_t BSP_AUDIO_OUT_Resume(void); -uint8_t BSP_AUDIO_OUT_Stop(uint32_t Option); -uint8_t BSP_AUDIO_OUT_SetVolume(uint8_t Volume); -void BSP_AUDIO_OUT_SetFrequency(uint32_t AudioFreq); -uint8_t BSP_AUDIO_OUT_SetMute(uint32_t Cmd); -uint8_t BSP_AUDIO_OUT_SetOutputMode(uint8_t Output); - -/* User Callbacks: user has to implement these functions in his code if they are needed. */ -/* This function is called when the requested data has been completely transferred. */ -void BSP_AUDIO_OUT_TransferComplete_CallBack(void); - -/* This function is called when half of the requested buffer has been transferred. */ -void BSP_AUDIO_OUT_HalfTransfer_CallBack(void); - -/* This function is called when an Interrupt due to transfer error on or peripheral - error occurs. */ -void BSP_AUDIO_OUT_Error_CallBack(void); - -/** - * @} - */ - -/** @defgroup STM32F411E_DISCOVERY_AUDIO_IN_Exported_Functions - * @{ - */ -uint8_t BSP_AUDIO_IN_Init(uint32_t AudioFreq, uint32_t BitRes, uint32_t ChnlNbr); -uint8_t BSP_AUDIO_IN_Record(uint16_t *pData, uint32_t Size); -uint8_t BSP_AUDIO_IN_Stop(void); -uint8_t BSP_AUDIO_IN_Pause(void); -uint8_t BSP_AUDIO_IN_Resume(void); -uint8_t BSP_AUDIO_IN_SetVolume(uint8_t Volume); -uint8_t BSP_AUDIO_IN_PDMToPCM(uint16_t *PDMBuf, uint16_t *PCMBuf); -/* User Callbacks: user has to implement these functions in his code if they are needed. */ -/* This function should be implemented by the user application. - It is called into this driver when the current buffer is filled to prepare the next - buffer pointer and its size. */ -void BSP_AUDIO_IN_TransferComplete_CallBack(void); -void BSP_AUDIO_IN_HalfTransfer_CallBack(void); - -/* This function is called when an Interrupt due to transfer error on or peripheral - error occurs. */ -void BSP_AUDIO_IN_Error_Callback(void); - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32F411E_DISCOVERY_AUDIO_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32F411E-Discovery/stm32f411e_discovery_gyroscope.c b/bsp/stm32f411RE/Libraries/BSP/STM32F411E-Discovery/stm32f411e_discovery_gyroscope.c deleted file mode 100644 index 36105d8898..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32F411E-Discovery/stm32f411e_discovery_gyroscope.c +++ /dev/null @@ -1,259 +0,0 @@ -/** - ****************************************************************************** - * @file stm32f411e_discovery_gyroscope.c - * @author MCD Application Team - * @version V1.0.0 - * @date 12-November-2015 - * @brief This file provides a set of functions needed to manage the - * MEMS gyroscope available on STM32F411E-Discovery Kit. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ -/* Includes ------------------------------------------------------------------*/ -#include "stm32f411e_discovery_gyroscope.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32F411E_DISCOVERY - * @{ - */ - -/** @addtogroup STM32F411E_DISCOVERY_GYROSCOPE - * @{ - */ - - -/** @defgroup STM32F411E_DISCOVERY_GYROSCOPE_Private_TypesDefinitions - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F411E_DISCOVERY_GYROSCOPE_Private_Defines - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F411E_DISCOVERY_GYROSCOPE_Private_Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F411E_DISCOVERY_GYROSCOPE_Private_Variables - * @{ - */ -static GYRO_DrvTypeDef *GyroscopeDrv; -/** - * @} - */ - -/** @defgroup STM32F411E_DISCOVERY_GYROSCOPE_Private_FunctionPrototypes - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F411E_DISCOVERY_GYROSCOPE_Private_Functions - * @{ - */ - -/** - * @brief Set Gyroscope Initialization. - * @param None - * @retval GYRO_OK if no problem during initialization - */ -uint8_t BSP_GYRO_Init(void) -{ - uint8_t ret = GYRO_ERROR; - uint16_t ctrl = 0x0000; - GYRO_InitTypeDef L3GD20_InitStructure; - GYRO_FilterConfigTypeDef L3GD20_FilterStructure = {0,0}; - - if((L3gd20Drv.ReadID() == I_AM_L3GD20) || (L3gd20Drv.ReadID() == I_AM_L3GD20_TR)) - { - /* Initialize the Gyroscope driver structure */ - GyroscopeDrv = &L3gd20Drv; - - /* MEMS configuration ----------------------------------------------------*/ - /* Fill the Gyroscope structure */ - L3GD20_InitStructure.Power_Mode = L3GD20_MODE_ACTIVE; - L3GD20_InitStructure.Output_DataRate = L3GD20_OUTPUT_DATARATE_1; - L3GD20_InitStructure.Axes_Enable = L3GD20_AXES_ENABLE; - L3GD20_InitStructure.Band_Width = L3GD20_BANDWIDTH_4; - L3GD20_InitStructure.BlockData_Update = L3GD20_BlockDataUpdate_Continous; - L3GD20_InitStructure.Endianness = L3GD20_BLE_LSB; - L3GD20_InitStructure.Full_Scale = L3GD20_FULLSCALE_500; - - /* Configure MEMS: data rate, power mode, full scale and axes */ - ctrl = (uint16_t) (L3GD20_InitStructure.Power_Mode | L3GD20_InitStructure.Output_DataRate | \ - L3GD20_InitStructure.Axes_Enable | L3GD20_InitStructure.Band_Width); - - ctrl |= (uint16_t) ((L3GD20_InitStructure.BlockData_Update | L3GD20_InitStructure.Endianness | \ - L3GD20_InitStructure.Full_Scale) << 8); - - /* Configure the Gyroscope main parameters */ - GyroscopeDrv->Init(ctrl); - - L3GD20_FilterStructure.HighPassFilter_Mode_Selection =L3GD20_HPM_NORMAL_MODE_RES; - L3GD20_FilterStructure.HighPassFilter_CutOff_Frequency = L3GD20_HPFCF_0; - - ctrl = (uint8_t) ((L3GD20_FilterStructure.HighPassFilter_Mode_Selection |\ - L3GD20_FilterStructure.HighPassFilter_CutOff_Frequency)); - - /* Configure the Gyroscope main parameters */ - GyroscopeDrv->FilterConfig(ctrl) ; - - GyroscopeDrv->FilterCmd(L3GD20_HIGHPASSFILTER_ENABLE); - - ret = GYRO_OK; - } - return ret; -} - -/** - * @brief Read ID of Gyroscope component. - * @param None - * @retval ID - */ -uint8_t BSP_GYRO_ReadID(void) -{ - uint8_t id = 0x00; - - if(GyroscopeDrv->ReadID != NULL) - { - id = GyroscopeDrv->ReadID(); - } - return id; -} - -/** - * @brief Reboot memory content of Gyroscope. - * @param None - * @retval None - */ -void BSP_GYRO_Reset(void) -{ - if(GyroscopeDrv->Reset != NULL) - { - GyroscopeDrv->Reset(); - } -} - -/** - * @brief Configures INT1 interrupt. - * @param pIntConfig: pointer to a L3GD20_InterruptConfig_TypeDef - * structure that contains the configuration setting for the L3GD20 Interrupt. - * @retval None - */ -void BSP_GYRO_ITConfig(GYRO_InterruptConfigTypeDef *pIntConfig) -{ - uint16_t interruptconfig = 0x0000; - - if(GyroscopeDrv->ConfigIT != NULL) - { - /* Configure latch Interrupt request and axe interrupts */ - interruptconfig |= ((uint8_t)(pIntConfig->Latch_Request| \ - pIntConfig->Interrupt_Axes) << 8); - - interruptconfig |= (uint8_t)(pIntConfig->Interrupt_ActiveEdge); - - GyroscopeDrv->ConfigIT(interruptconfig); - } -} - -/** - * @brief Enables INT1 or INT2 interrupt. - * @param IntPin: Interrupt pin - * This parameter can be: - * @arg L3GD20_INT1 - * @arg L3GD20_INT2 - * @retval None - */ -void BSP_GYRO_EnableIT(uint8_t IntPin) -{ - if(GyroscopeDrv->EnableIT != NULL) - { - GyroscopeDrv->EnableIT(IntPin); - } -} - -/** - * @brief Disables INT1 or INT2 interrupt. - * @param IntPin: Interrupt pin - * This parameter can be: - * @arg L3GD20_INT1 - * @arg L3GD20_INT2 - * @retval None - */ -void BSP_GYRO_DisableIT(uint8_t IntPin) -{ - if(GyroscopeDrv->DisableIT != NULL) - { - GyroscopeDrv->DisableIT(IntPin); - } -} - -/** - * @brief Get XYZ angular acceleration. - * @param pfData: pointer on floating array - * @retval None - */ -void BSP_GYRO_GetXYZ(float *pfData) -{ - if(GyroscopeDrv->GetXYZ!= NULL) - { - GyroscopeDrv->GetXYZ(pfData); - } -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32F411E-Discovery/stm32f411e_discovery_gyroscope.h b/bsp/stm32f411RE/Libraries/BSP/STM32F411E-Discovery/stm32f411e_discovery_gyroscope.h deleted file mode 100644 index ed641346b0..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32F411E-Discovery/stm32f411e_discovery_gyroscope.h +++ /dev/null @@ -1,127 +0,0 @@ -/** - ****************************************************************************** - * @file stm32f411e_discovery_gyroscope.h - * @author MCD Application Team - * @version V1.0.0 - * @date 12-November-2015 - * @brief This file contains definitions for stm32f411e_discovery_gyroscope.c - * firmware driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32F411E_DISCOVERY_GYROSCOPE_H -#define __STM32F411E_DISCOVERY_GYROSCOPE_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm32f411e_discovery.h" - - /* Include Gyroscope component driver */ -#include "../Components/l3gd20/l3gd20.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32F411E_DISCOVERY - * @{ - */ - -/** @addtogroup STM32F411E_DISCOVERY_GYROSCOPE - * @{ - */ - -/** @defgroup STM32F411E_DISCOVERY_GYROSCOPE_Exported_Types - * @{ - */ -typedef enum -{ - GYRO_OK = 0, - GYRO_ERROR = 1, - GYRO_TIMEOUT = 2 -}GYRO_StatusTypeDef; -/** - * @} - */ - -/** @defgroup STM32F411E_DISCOVERY_GYROSCOPE_Exported_Constants - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F411E_DISCOVERY_GYROSCOPE_Exported_Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F411E_DISCOVERY_GYROSCOPE_Exported_Functions - * @{ - */ -/* Gyroscope Functions */ -uint8_t BSP_GYRO_Init(void); -void BSP_GYRO_Reset(void); -uint8_t BSP_GYRO_ReadID(void); -void BSP_GYRO_ITConfig(GYRO_InterruptConfigTypeDef *pIntConfigStruct); -void BSP_GYRO_EnableIT(uint8_t IntPin); -void BSP_GYRO_DisableIT(uint8_t IntPin); -void BSP_GYRO_GetXYZ(float *pfData); - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus - } -#endif - -#endif /* __STM32F411E_DISCOVERY_GYROSCOPE_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32F429I-Discovery/Release_Notes.html b/bsp/stm32f411RE/Libraries/BSP/STM32F429I-Discovery/Release_Notes.html deleted file mode 100644 index 94820e1ea1..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32F429I-Discovery/Release_Notes.html +++ /dev/null @@ -1,509 +0,0 @@ - - - - - - - - - - - - - - - - - - - - Release Notes for STM32F429 Discovery Board Drivers - - - - - - - - - - -
-


-

-
- - - - - - -
- - - - - - - - - -
-

Back to Release page

-
-

Release -Notes for STM32F429 Discovery Board Drivers

-

-Copyright © 2015 STMicroelectronics -

- -

-

-
-

 

- - - - - - -

Update History

-

V2.1.2 / 02-March-2015

Main -Changes

- - - - - -
  • stm32f429i_discovery.c/.h
    • Align to STM32F4xx HAL Driver V1.3.0 for -__HAL_RCC_PPP_CLK_ENABLE() .

V2.1.1 / 10-December-2014

- - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- - - - - - - - - - - - - - - -
    -
  • stm32f429i_discovery.c/.h
    -
  • -
      -
    • Change I2C_SPEED used define by BSP_I2C_SPEED
    • -
    -
  • stm32f429i_discovery_sdram.c
    -
  • -
      -
    • BSP_SDRAM_Initialization_sequence(): Fix wrong configuration of the burst length
      -
    • -
    -
  • stm32f429i_discovery_gyroscope.h, stm32f429i_discovery_io.h,stm32f429i_discovery_lcd.c/.h and stm32f429i_discovery_ts.h:
    -
  • -
      -
    • Change "\" by "/" in the include path to fix compilation issue under Linux
    • -
    -
  • Miscellaneous comments update
  • -
- -

V2.1.0 / 19-June-2014

- - - - - - - - - - - - - - - - - - - - - - - - -

Main -Changes

- - -
    -
  • stm32f429i_discovery.c/.h
  • -
      -
    • Add protection for double initialization of IO_Init within LCD_IO_Init()
    • -
    -
      -
    • Enhance BSP_PB_Init() function by removing the call of __SYSCFG_CLK_ENABLE() already enabled in the HAL_GPIO_Init()
    • -
    -
  • stm32f429i_discovery_gyroscope.c/.h
  • -
      -
    • Update BSP_GYRO_Init() to support new L3GD20 device ID (I_AM_L3GD20_TR)
    • -
    -
  • stm32f429i_discovery_ts.c/.h
  • -
      -
    • Correct -wrong TS configuration BSP_TS_ITConfig() and TS IT implementation, -BSP_TS_ITClear() related to the use of IO expander STMPE1600 device not -available on stm32f429i discovery board
    • -
    • Comments clean up and typo corrections
    • -
    -
  • stm32f429i_discovery_eeprom.c/.h
  • -
    • Update usage of BSP_EEPROM_TIMEOUT_UserCallback() function
    -
- -

V2.0.1 / 26-February-2014

- - - - - - - - - - - - - - - - - - - - - - -

Main -Changes

-
    -
  • stm32f429i_discovery_eeprom.c/.h
  • -
      -
    • Update usage of BSP_EEPROM_TIMEOUT_UserCallback() function
      -
    • -
    -
- -

V2.0.0 / 18-February-2014

- - - - - - - - - - - - - - - - - - - - - - -

Main -Changes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- - - - - - - - - -
    -
  • Major update -based on STM32Cube specification: drivers architecture and APIs -modified vs. V1.0.2, and thus the 2 versions are not compatible.
    -
  • This version has to be used only with STM32CubeF4 based development
  • -
-

V1.0.2 / 06-December-2013

- - -

Main -Changes

- - - -
    -
  • Update IO expander interrupt line on stm32f429i_discovery_ioe.h file.
  • -
-

V1.0.1 / 28-October-2013

-

Main -Changes

- -
  • stm32f429i_discovery_l3gd20.c, - stm32f429i_discovery_lcd.c
    • Set SPI - baudrate to 5.625 MHz to fit LCD and Gyroscope timing characteristics
      • ILI9341 LCD - SPI interface max baud rate is 10MHz for write and 6.66MHz for read
      •  Gyroscope - l3gd20 SPI interface max baud rate is 10MHz for write/read  
  • stm32f429i_discovery_lcd.c
    • Improve SPI - low level write routines (add check on BSY flag before to deselect the - LCD)
    • Remove the - __IO attribute from these function’s parameters: LCD_SetLayer(), - LCD_SetColors(), LCD_GetColors(), LCD_SetTextColor() and - LCD_SetBackColor()
  • stm32f429i_discovery_i2c_ee.c, - stm32f429i_discovery_i2c_ ioe.c
    • Add a test in - Init() function; if the I2C is already configured, then there is no need - to reconfigure it again
    • I2C_SPEED - define moved to stm32f429i_discovery.h file
  • stm32f429i_discovery_sdram.c
    • Update device - refresh counter value to fit with SDRAM timing characteristics
  • Miscellaneous robustness - improvement
  • Miscellaneous comments update

V1.0.0 / 20-September-2013

      Main -Changes
  • First official version of the STM32F429 Discovery Board Drivers

License

-
-
-Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met:
-
-
  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions -in binary form must reproduce the above copyright notice, this list of -conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of STMicroelectronics nor the names of its contributors may be used to endorse or promote products derived
    -
    -
-        from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- -
-
- - -
-
-
For -complete documentation on STM32 Microcontrollers -visit www.st.com/STM32
-

-
-
-

 

-
- - \ No newline at end of file diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32F429I-Discovery/stm32f429i_discovery.c b/bsp/stm32f411RE/Libraries/BSP/STM32F429I-Discovery/stm32f429i_discovery.c deleted file mode 100644 index 1d698cda74..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32F429I-Discovery/stm32f429i_discovery.c +++ /dev/null @@ -1,1166 +0,0 @@ -/** - ****************************************************************************** - * @file stm32f429i_discovery.c - * @author MCD Application Team - * @version V2.1.2 - * @date 02-March-2015 - * @brief This file provides set of firmware functions to manage Leds and - * push-button available on STM32F429I-Discovery Kit from STMicroelectronics. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Includes ------------------------------------------------------------------*/ -#include "stm32f429i_discovery.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32F429I_DISCOVERY - * @{ - */ - -/** @defgroup STM32F429I_DISCOVERY_LOW_LEVEL - * @brief This file provides set of firmware functions to manage Leds and push-button - * available on STM32F429I-Discovery Kit from STMicroelectronics. - * @{ - */ - -/** @defgroup STM32F429I_DISCOVERY_LOW_LEVEL_Private_TypesDefinitions - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F429I_DISCOVERY_LOW_LEVEL_Private_Defines - * @{ - */ - - /** - * @brief STM32F429I DISCO BSP Driver version number V2.1.0 - */ -#define __STM32F429I_DISCO_BSP_VERSION_MAIN (0x02) /*!< [31:24] main version */ -#define __STM32F429I_DISCO_BSP_VERSION_SUB1 (0x01) /*!< [23:16] sub1 version */ -#define __STM32F429I_DISCO_BSP_VERSION_SUB2 (0x02) /*!< [15:8] sub2 version */ -#define __STM32F429I_DISCO_BSP_VERSION_RC (0x00) /*!< [7:0] release candidate */ -#define __STM32F429I_DISCO_BSP_VERSION ((__STM32F429I_DISCO_BSP_VERSION_MAIN << 24)\ - |(__STM32F429I_DISCO_BSP_VERSION_SUB1 << 16)\ - |(__STM32F429I_DISCO_BSP_VERSION_SUB2 << 8 )\ - |(__STM32F429I_DISCO_BSP_VERSION_RC)) -/** - * @} - */ - -/** @defgroup STM32F429I_DISCOVERY_LOW_LEVEL_Private_Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F429I_DISCOVERY_LOW_LEVEL_Private_Variables - * @{ - */ -GPIO_TypeDef* GPIO_PORT[LEDn] = {LED3_GPIO_PORT, - LED4_GPIO_PORT}; - -const uint16_t GPIO_PIN[LEDn] = {LED3_PIN, - LED4_PIN}; - -GPIO_TypeDef* BUTTON_PORT[BUTTONn] = {KEY_BUTTON_GPIO_PORT}; -const uint16_t BUTTON_PIN[BUTTONn] = {KEY_BUTTON_PIN}; -const uint8_t BUTTON_IRQn[BUTTONn] = {KEY_BUTTON_EXTI_IRQn}; - -uint32_t I2cxTimeout = I2Cx_TIMEOUT_MAX; /*Instance == DISCOVERY_I2Cx) - { - /* Configure the GPIOs ---------------------------------------------------*/ - /* Enable GPIO clock */ - DISCOVERY_I2Cx_SDA_GPIO_CLK_ENABLE(); - DISCOVERY_I2Cx_SCL_GPIO_CLK_ENABLE(); - - /* Configure I2C Tx as alternate function */ - GPIO_InitStruct.Pin = DISCOVERY_I2Cx_SCL_PIN; - GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FAST; - GPIO_InitStruct.Alternate = DISCOVERY_I2Cx_SCL_SDA_AF; - HAL_GPIO_Init(DISCOVERY_I2Cx_SCL_GPIO_PORT, &GPIO_InitStruct); - - /* Configure I2C Rx as alternate function */ - GPIO_InitStruct.Pin = DISCOVERY_I2Cx_SDA_PIN; - HAL_GPIO_Init(DISCOVERY_I2Cx_SDA_GPIO_PORT, &GPIO_InitStruct); - - - /* Configure the Discovery I2Cx peripheral -------------------------------*/ - /* Enable I2C3 clock */ - DISCOVERY_I2Cx_CLOCK_ENABLE(); - - /* Force the I2C Peripheral Clock Reset */ - DISCOVERY_I2Cx_FORCE_RESET(); - - /* Release the I2C Peripheral Clock Reset */ - DISCOVERY_I2Cx_RELEASE_RESET(); - - /* Enable and set Discovery I2Cx Interrupt to the highest priority */ - HAL_NVIC_SetPriority(DISCOVERY_I2Cx_EV_IRQn, 0x00, 0); - HAL_NVIC_EnableIRQ(DISCOVERY_I2Cx_EV_IRQn); - - /* Enable and set Discovery I2Cx Interrupt to the highest priority */ - HAL_NVIC_SetPriority(DISCOVERY_I2Cx_ER_IRQn, 0x00, 0); - HAL_NVIC_EnableIRQ(DISCOVERY_I2Cx_ER_IRQn); - -#ifdef EE_M24LR64 - /* I2C DMA TX and RX channels configuration */ - /* Enable the DMA clock */ - EEPROM_I2C_DMA_CLK_ENABLE(); - - /* Configure the DMA stream for the EE I2C peripheral TX direction */ - /* Configure the DMA Stream */ - hdma_tx.Instance = EEPROM_I2C_DMA_STREAM_TX; - /* Set the parameters to be configured */ - hdma_tx.Init.Channel = EEPROM_I2C_DMA_CHANNEL; - hdma_tx.Init.Direction = DMA_MEMORY_TO_PERIPH; - hdma_tx.Init.PeriphInc = DMA_PINC_DISABLE; - hdma_tx.Init.MemInc = DMA_MINC_ENABLE; - hdma_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE; - hdma_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE; - hdma_tx.Init.Mode = DMA_NORMAL; - hdma_tx.Init.Priority = DMA_PRIORITY_VERY_HIGH; - hdma_tx.Init.FIFOMode = DMA_FIFOMODE_ENABLE; - hdma_tx.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; - hdma_tx.Init.MemBurst = DMA_MBURST_SINGLE; - hdma_tx.Init.PeriphBurst = DMA_PBURST_SINGLE; - - /* Associate the initilalized hdma_tx handle to the the pI2cHandle handle */ - __HAL_LINKDMA(pI2cHandle, hdmatx, hdma_tx); - - /* Configure the DMA Stream */ - HAL_DMA_Init(&hdma_tx); - - /* Configure and enable I2C DMA TX Channel interrupt */ - HAL_NVIC_SetPriority((IRQn_Type)(EEPROM_I2C_DMA_TX_IRQn), EEPROM_I2C_DMA_PREPRIO, 0); - HAL_NVIC_EnableIRQ((IRQn_Type)(EEPROM_I2C_DMA_TX_IRQn)); - - /* Configure the DMA stream for the EE I2C peripheral TX direction */ - /* Configure the DMA Stream */ - hdma_rx.Instance = EEPROM_I2C_DMA_STREAM_RX; - /* Set the parameters to be configured */ - hdma_rx.Init.Channel = EEPROM_I2C_DMA_CHANNEL; - hdma_rx.Init.Direction = DMA_PERIPH_TO_MEMORY; - hdma_rx.Init.PeriphInc = DMA_PINC_DISABLE; - hdma_rx.Init.MemInc = DMA_MINC_ENABLE; - hdma_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE; - hdma_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE; - hdma_rx.Init.Mode = DMA_NORMAL; - hdma_rx.Init.Priority = DMA_PRIORITY_VERY_HIGH; - hdma_rx.Init.FIFOMode = DMA_FIFOMODE_ENABLE; - hdma_rx.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; - hdma_rx.Init.MemBurst = DMA_MBURST_SINGLE; - hdma_rx.Init.PeriphBurst = DMA_PBURST_SINGLE; - - /* Associate the initilalized hdma_rx handle to the the pI2cHandle handle*/ - __HAL_LINKDMA(pI2cHandle, hdmarx, hdma_rx); - - /* Configure the DMA Stream */ - HAL_DMA_Init(&hdma_rx); - - /* Configure and enable I2C DMA RX Channel interrupt */ - HAL_NVIC_SetPriority((IRQn_Type)(EEPROM_I2C_DMA_RX_IRQn), EEPROM_I2C_DMA_PREPRIO, 0); - HAL_NVIC_EnableIRQ((IRQn_Type)(EEPROM_I2C_DMA_RX_IRQn)); -#endif /* EE_M24LR64 */ - } -} - -/** - * @brief I2Cx Bus initialization. - * @param None - * @retval None - */ -static void I2Cx_Init(void) -{ - if(HAL_I2C_GetState(&I2cHandle) == HAL_I2C_STATE_RESET) - { - I2cHandle.Instance = DISCOVERY_I2Cx; - I2cHandle.Init.ClockSpeed = BSP_I2C_SPEED; - I2cHandle.Init.DutyCycle = I2C_DUTYCYCLE_2; - I2cHandle.Init.OwnAddress1 = 0; - I2cHandle.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT; - I2cHandle.Init.DualAddressMode = I2C_DUALADDRESS_DISABLED; - I2cHandle.Init.OwnAddress2 = 0; - I2cHandle.Init.GeneralCallMode = I2C_GENERALCALL_DISABLED; - I2cHandle.Init.NoStretchMode = I2C_NOSTRETCH_DISABLED; - - /* Init the I2C */ - I2Cx_MspInit(&I2cHandle); - HAL_I2C_Init(&I2cHandle); - } -} - -/** - * @brief Configures Interruption pin for I2C communication. - * @param None - * @retval None - */ -static void I2Cx_ITConfig(void) -{ - GPIO_InitTypeDef GPIO_InitStruct; - - /* Enable the GPIO EXTI Clock */ - STMPE811_INT_CLK_ENABLE(); - - GPIO_InitStruct.Pin = STMPE811_INT_PIN; - GPIO_InitStruct.Pull = GPIO_PULLUP; - GPIO_InitStruct.Speed = GPIO_SPEED_LOW; - GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING; - HAL_GPIO_Init(STMPE811_INT_GPIO_PORT, &GPIO_InitStruct); - - /* Enable and set GPIO EXTI Interrupt to the highest priority */ - HAL_NVIC_SetPriority((IRQn_Type)(STMPE811_INT_EXTI), 0x00, 0x00); - HAL_NVIC_EnableIRQ((IRQn_Type)(STMPE811_INT_EXTI)); -} - -/** - * @brief Writes a value in a register of the device through BUS. - * @param Addr: Device address on BUS Bus. - * @param Reg: The target register address to write - * @param Value: The target register value to be written - * @retval None - */ -static void I2Cx_WriteData(uint8_t Addr, uint8_t Reg, uint8_t Value) - { - HAL_StatusTypeDef status = HAL_OK; - - status = HAL_I2C_Mem_Write(&I2cHandle, Addr, (uint16_t)Reg, I2C_MEMADD_SIZE_8BIT, &Value, 1, I2cxTimeout); - - /* Check the communication status */ - if(status != HAL_OK) - { - /* Re-Initialize the BUS */ - I2Cx_Error(); - } -} - -/** - * @brief Writes a value in a register of the device through BUS. - * @param Addr: Device address on BUS Bus. - * @param Reg: The target register address to write - * @param pBuffer: The target register value to be written - * @param Length: buffer size to be written - * @retval None - */ -static void I2Cx_WriteBuffer(uint8_t Addr, uint8_t Reg, uint8_t *pBuffer, uint16_t Length) - { - HAL_StatusTypeDef status = HAL_OK; - - status = HAL_I2C_Mem_Write(&I2cHandle, Addr, (uint16_t)Reg, I2C_MEMADD_SIZE_8BIT, pBuffer, Length, I2cxTimeout); - - /* Check the communication status */ - if(status != HAL_OK) - { - /* Re-Initialize the BUS */ - I2Cx_Error(); - } -} - -/** - * @brief Reads a register of the device through BUS. - * @param Addr: Device address on BUS Bus. - * @param Reg: The target register address to write - * @retval Data read at register address - */ -static uint8_t I2Cx_ReadData(uint8_t Addr, uint8_t Reg) -{ - HAL_StatusTypeDef status = HAL_OK; - uint8_t value = 0; - - status = HAL_I2C_Mem_Read(&I2cHandle, Addr, Reg, I2C_MEMADD_SIZE_8BIT, &value, 1, I2cxTimeout); - - /* Check the communication status */ - if(status != HAL_OK) - { - /* Re-Initialize the BUS */ - I2Cx_Error(); - - } - return value; -} - -/** - * @brief Reads multiple data on the BUS. - * @param Addr: I2C Address - * @param Reg: Reg Address - * @param pBuffer: pointer to read data buffer - * @param Length: length of the data - * @retval 0 if no problems to read multiple data - */ -static uint8_t I2Cx_ReadBuffer(uint8_t Addr, uint8_t Reg, uint8_t *pBuffer, uint16_t Length) -{ - HAL_StatusTypeDef status = HAL_OK; - - status = HAL_I2C_Mem_Read(&I2cHandle, Addr, (uint16_t)Reg, I2C_MEMADD_SIZE_8BIT, pBuffer, Length, I2cxTimeout); - - /* Check the communication status */ - if(status == HAL_OK) - { - return 0; - } - else - { - /* Re-Initialize the BUS */ - I2Cx_Error(); - - return 1; - } -} - -#ifdef EE_M24LR64 -/** - * @brief Writes a value in a register of the device through BUS in using DMA mode. - * @param Addr: Device address on BUS Bus. - * @param Reg: The target register address to write - * @param pBuffer: The target register value to be written - * @param Length: buffer size to be written - * @retval HAL status - */ -static HAL_StatusTypeDef I2Cx_WriteBufferDMA(uint8_t Addr, uint16_t Reg, uint8_t *pBuffer, uint16_t Length) - { - HAL_StatusTypeDef status = HAL_OK; - - status = HAL_I2C_Mem_Write_DMA(&I2cHandle, Addr, Reg, I2C_MEMADD_SIZE_16BIT, pBuffer, Length); - - /* Check the communication status */ - if(status != HAL_OK) - { - /* Re-Initialize the BUS */ - I2Cx_Error(); - } - - return status; -} - -/** - * @brief Reads multiple data on the BUS in using DMA mode. - * @param Addr: I2C Address - * @param Reg: Reg Address - * @param pBuffer: pointer to read data buffer - * @param Length: length of the data - * @retval HAL status - */ -static HAL_StatusTypeDef I2Cx_ReadBufferDMA(uint8_t Addr, uint16_t Reg, uint8_t *pBuffer, uint16_t Length) -{ - HAL_StatusTypeDef status = HAL_OK; - - status = HAL_I2C_Mem_Read_DMA(&I2cHandle, Addr, Reg, I2C_MEMADD_SIZE_16BIT, pBuffer, Length); - - /* Check the communication status */ - if(status != HAL_OK) - { - /* Re-Initialize the BUS */ - I2Cx_Error(); - } - - return status; -} - -/** -* @brief Checks if target device is ready for communication. -* @note This function is used with Memory devices -* @param DevAddress: Target device address -* @param Trials: Number of trials -* @retval HAL status -*/ -static HAL_StatusTypeDef I2Cx_IsDeviceReady(uint16_t DevAddress, uint32_t Trials) -{ - return (HAL_I2C_IsDeviceReady(&I2cHandle, DevAddress, Trials, I2cxTimeout)); -} -#endif /* EE_M24LR64 */ - -/** - * @brief I2Cx error treatment function - * @param None - * @retval None - */ -static void I2Cx_Error(void) -{ - /* De-initialize the SPI communication BUS */ - HAL_I2C_DeInit(&I2cHandle); - - /* Re-Initialize the SPI communication BUS */ - I2Cx_Init(); -} - -/******************************* SPI Routines *********************************/ - -/** - * @brief SPIx Bus initialization - * @param None - * @retval None - */ -static void SPIx_Init(void) -{ - if(HAL_SPI_GetState(&SpiHandle) == HAL_SPI_STATE_RESET) - { - /* SPI configuration -----------------------------------------------------*/ - SpiHandle.Instance = DISCOVERY_SPIx; - /* SPI baudrate is set to 5.6 MHz (PCLK2/SPI_BaudRatePrescaler = 90/16 = 5.625 MHz) - to verify these constraints: - - ILI9341 LCD SPI interface max baudrate is 10MHz for write and 6.66MHz for read - - l3gd20 SPI interface max baudrate is 10MHz for write/read - - PCLK2 frequency is set to 90 MHz - */ - SpiHandle.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_16; - - /* On STM32F429I-Discovery, LCD ID cannot be read then keep a common configuration */ - /* for LCD and GYRO (SPI_DIRECTION_2LINES) */ - /* Note: To read a register a LCD, SPI_DIRECTION_1LINE should be set */ - SpiHandle.Init.Direction = SPI_DIRECTION_2LINES; - SpiHandle.Init.CLKPhase = SPI_PHASE_1EDGE; - SpiHandle.Init.CLKPolarity = SPI_POLARITY_LOW; - SpiHandle.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLED; - SpiHandle.Init.CRCPolynomial = 7; - SpiHandle.Init.DataSize = SPI_DATASIZE_8BIT; - SpiHandle.Init.FirstBit = SPI_FIRSTBIT_MSB; - SpiHandle.Init.NSS = SPI_NSS_SOFT; - SpiHandle.Init.TIMode = SPI_TIMODE_DISABLED; - SpiHandle.Init.Mode = SPI_MODE_MASTER; - - SPIx_MspInit(&SpiHandle); - HAL_SPI_Init(&SpiHandle); - } -} - -/** - * @brief Reads 4 bytes from device. - * @param ReadSize: Number of bytes to read (max 4 bytes) - * @retval Value read on the SPI - */ -static uint32_t SPIx_Read(uint8_t ReadSize) -{ - HAL_StatusTypeDef status = HAL_OK; - uint32_t readvalue; - - status = HAL_SPI_Receive(&SpiHandle, (uint8_t*) &readvalue, ReadSize, SpixTimeout); - - /* Check the communication status */ - if(status != HAL_OK) - { - /* Re-Initialize the BUS */ - SPIx_Error(); - } - - return readvalue; -} - -/** - * @brief Writes a byte to device. - * @param Value: value to be written - * @retval None - */ -static void SPIx_Write(uint16_t Value) -{ - HAL_StatusTypeDef status = HAL_OK; - - status = HAL_SPI_Transmit(&SpiHandle, (uint8_t*) &Value, 1, SpixTimeout); - - /* Check the communication status */ - if(status != HAL_OK) - { - /* Re-Initialize the BUS */ - SPIx_Error(); - } -} - -/** - * @brief Sends a Byte through the SPI interface and return the Byte received - * from the SPI bus. - * @param Byte: Byte send. - * @retval The received byte value - */ -static uint8_t SPIx_WriteRead(uint8_t Byte) -{ - uint8_t receivedbyte = 0; - - /* Send a Byte through the SPI peripheral */ - /* Read byte from the SPI bus */ - if(HAL_SPI_TransmitReceive(&SpiHandle, (uint8_t*) &Byte, (uint8_t*) &receivedbyte, 1, SpixTimeout) != HAL_OK) - { - SPIx_Error(); - } - - return receivedbyte; -} - -/** - * @brief SPIx error treatment function. - * @param None - * @retval None - */ -static void SPIx_Error(void) -{ - /* De-initialize the SPI communication BUS */ - HAL_SPI_DeInit(&SpiHandle); - - /* Re- Initialize the SPI communication BUS */ - SPIx_Init(); -} - -/** - * @brief SPI MSP Init. - * @param hspi: SPI handle - * @retval None - */ -static void SPIx_MspInit(SPI_HandleTypeDef *hspi) -{ - GPIO_InitTypeDef GPIO_InitStructure; - - /* Enable SPIx clock */ - DISCOVERY_SPIx_CLK_ENABLE(); - - /* Enable DISCOVERY_SPI GPIO clock */ - DISCOVERY_SPIx_GPIO_CLK_ENABLE(); - - /* configure SPI SCK, MOSI and MISO */ - GPIO_InitStructure.Pin = (DISCOVERY_SPIx_SCK_PIN | DISCOVERY_SPIx_MOSI_PIN | DISCOVERY_SPIx_MISO_PIN); - GPIO_InitStructure.Mode = GPIO_MODE_AF_PP; - GPIO_InitStructure.Pull = GPIO_PULLDOWN; - GPIO_InitStructure.Speed = GPIO_SPEED_MEDIUM; - GPIO_InitStructure.Alternate = DISCOVERY_SPIx_AF; - HAL_GPIO_Init(DISCOVERY_SPIx_GPIO_PORT, &GPIO_InitStructure); -} - -/********************************* LINK LCD ***********************************/ - -/** - * @brief Configures the LCD_SPI interface. - * @param None - * @retval None - */ -void LCD_IO_Init(void) -{ - GPIO_InitTypeDef GPIO_InitStructure; - - if(Is_LCD_IO_Initialized == 0) - { - Is_LCD_IO_Initialized = 1; - - /* Configure NCS in Output Push-Pull mode */ - LCD_WRX_GPIO_CLK_ENABLE(); - GPIO_InitStructure.Pin = LCD_WRX_PIN; - GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStructure.Pull = GPIO_NOPULL; - GPIO_InitStructure.Speed = GPIO_SPEED_FAST; - HAL_GPIO_Init(LCD_WRX_GPIO_PORT, &GPIO_InitStructure); - - LCD_RDX_GPIO_CLK_ENABLE(); - GPIO_InitStructure.Pin = LCD_RDX_PIN; - GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStructure.Pull = GPIO_NOPULL; - GPIO_InitStructure.Speed = GPIO_SPEED_FAST; - HAL_GPIO_Init(LCD_RDX_GPIO_PORT, &GPIO_InitStructure); - - /* Configure the LCD Control pins ----------------------------------------*/ - LCD_NCS_GPIO_CLK_ENABLE(); - - /* Configure NCS in Output Push-Pull mode */ - GPIO_InitStructure.Pin = LCD_NCS_PIN; - GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStructure.Pull = GPIO_NOPULL; - GPIO_InitStructure.Speed = GPIO_SPEED_FAST; - HAL_GPIO_Init(LCD_NCS_GPIO_PORT, &GPIO_InitStructure); - - /* Set or Reset the control line */ - LCD_CS_LOW(); - LCD_CS_HIGH(); - - SPIx_Init(); - } -} - -/** - * @brief Writes register value. - * @param None - * @retval None - */ -void LCD_IO_WriteData(uint16_t RegValue) -{ - /* Set WRX to send data */ - LCD_WRX_HIGH(); - - /* Reset LCD control line(/CS) and Send data */ - LCD_CS_LOW(); - SPIx_Write(RegValue); - - /* Deselect: Chip Select high */ - LCD_CS_HIGH(); -} - -/** - * @brief Writes register address. - * @param None - * @retval None - */ -void LCD_IO_WriteReg(uint8_t Reg) -{ - /* Reset WRX to send command */ - LCD_WRX_LOW(); - - /* Reset LCD control line(/CS) and Send command */ - LCD_CS_LOW(); - SPIx_Write(Reg); - - /* Deselect: Chip Select high */ - LCD_CS_HIGH(); -} - -/** - * @brief Reads register value. - * @param RegValue Address of the register to read - * @param ReadSize Number of bytes to read - * @retval Content of the register value - */ -uint32_t LCD_IO_ReadData(uint16_t RegValue, uint8_t ReadSize) -{ - uint32_t readvalue = 0; - - /* Select: Chip Select low */ - LCD_CS_LOW(); - - /* Reset WRX to send command */ - LCD_WRX_LOW(); - - SPIx_Write(RegValue); - - readvalue = SPIx_Read(ReadSize); - - /* Set WRX to send data */ - LCD_WRX_HIGH(); - - /* Deselect: Chip Select high */ - LCD_CS_HIGH(); - - return readvalue; -} - -/** - * @brief Wait for loop in ms. - * @param Delay in ms. - * @retval None - */ -void LCD_Delay(uint32_t Delay) -{ - HAL_Delay(Delay); -} - -/******************************************************************************* - LINK OPERATIONS -*******************************************************************************/ - -/********************************* LINK IOE ***********************************/ - -/** - * @brief IOE Low Level Initialization. - * @param None - * @retval None - */ -void IOE_Init(void) -{ - I2Cx_Init(); -} - -/** - * @brief IOE Low Level Interrupt configuration. - * @param None - * @retval None - */ -void IOE_ITConfig(void) -{ - I2Cx_ITConfig(); -} - -/** - * @brief IOE Writes single data operation. - * @param Addr: I2C Address - * @param Reg: Reg Address - * @param Value: Data to be written - * @retval None - */ -void IOE_Write(uint8_t Addr, uint8_t Reg, uint8_t Value) -{ - I2Cx_WriteData(Addr, Reg, Value); -} - -/** - * @brief IOE Reads single data. - * @param Addr: I2C Address - * @param Reg: Reg Address - * @retval The read data - */ -uint8_t IOE_Read(uint8_t Addr, uint8_t Reg) -{ - return I2Cx_ReadData(Addr, Reg); -} - -/** - * @brief IOE Writes multiple data. - * @param Addr: I2C Address - * @param Reg: Reg Address - * @param pBuffer: pointer to data buffer - * @param Length: length of the data - * @retval None - */ -void IOE_WriteMultiple(uint8_t Addr, uint8_t Reg, uint8_t *pBuffer, uint16_t Length) -{ - I2Cx_WriteBuffer(Addr, Reg, pBuffer, Length); -} - -/** - * @brief IOE Reads multiple data. - * @param Addr: I2C Address - * @param Reg: Reg Address - * @param pBuffer: pointer to data buffer - * @param Length: length of the data - * @retval 0 if no problems to read multiple data - */ -uint16_t IOE_ReadMultiple(uint8_t Addr, uint8_t Reg, uint8_t *pBuffer, uint16_t Length) -{ - return I2Cx_ReadBuffer(Addr, Reg, pBuffer, Length); -} - -/** - * @brief IOE Delay. - * @param Delay in ms - * @retval None - */ -void IOE_Delay(uint32_t Delay) -{ - HAL_Delay(Delay); -} - -/********************************* LINK GYROSCOPE *****************************/ - -/** - * @brief Configures the Gyroscope SPI interface. - * @param None - * @retval None - */ -void GYRO_IO_Init(void) -{ - GPIO_InitTypeDef GPIO_InitStructure; - - /* Configure the Gyroscope Control pins ------------------------------------*/ - /* Enable CS GPIO clock and Configure GPIO PIN for Gyroscope Chip select */ - GYRO_CS_GPIO_CLK_ENABLE(); - GPIO_InitStructure.Pin = GYRO_CS_PIN; - GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStructure.Pull = GPIO_NOPULL; - GPIO_InitStructure.Speed = GPIO_SPEED_MEDIUM; - HAL_GPIO_Init(GYRO_CS_GPIO_PORT, &GPIO_InitStructure); - - /* Deselect: Chip Select high */ - GYRO_CS_HIGH(); - - /* Enable INT1, INT2 GPIO clock and Configure GPIO PINs to detect Interrupts */ - GYRO_INT_GPIO_CLK_ENABLE(); - GPIO_InitStructure.Pin = GYRO_INT1_PIN | GYRO_INT2_PIN; - GPIO_InitStructure.Mode = GPIO_MODE_INPUT; - GPIO_InitStructure.Speed = GPIO_SPEED_FAST; - GPIO_InitStructure.Pull= GPIO_NOPULL; - HAL_GPIO_Init(GYRO_INT_GPIO_PORT, &GPIO_InitStructure); - - SPIx_Init(); -} - -/** - * @brief Writes one byte to the Gyroscope. - * @param pBuffer: Pointer to the buffer containing the data to be written to the Gyroscope. - * @param WriteAdd: Gyroscope's internal address to write to. - * @param NumByteToWrite: Number of bytes to write. - * @retval None - */ -void GYRO_IO_Write(uint8_t* pBuffer, uint8_t WriteAddr, uint16_t NumByteToWrite) -{ - /* Configure the MS bit: - - When 0, the address will remain unchanged in multiple read/write commands. - - When 1, the address will be auto incremented in multiple read/write commands. - */ - if(NumByteToWrite > 0x01) - { - WriteAddr |= (uint8_t)MULTIPLEBYTE_CMD; - } - /* Set chip select Low at the start of the transmission */ - GYRO_CS_LOW(); - - /* Send the Address of the indexed register */ - SPIx_WriteRead(WriteAddr); - - /* Send the data that will be written into the device (MSB First) */ - while(NumByteToWrite >= 0x01) - { - SPIx_WriteRead(*pBuffer); - NumByteToWrite--; - pBuffer++; - } - - /* Set chip select High at the end of the transmission */ - GYRO_CS_HIGH(); -} - -/** - * @brief Reads a block of data from the Gyroscope. - * @param pBuffer: Pointer to the buffer that receives the data read from the Gyroscope. - * @param ReadAddr: Gyroscope's internal address to read from. - * @param NumByteToRead: Number of bytes to read from the Gyroscope. - * @retval None - */ -void GYRO_IO_Read(uint8_t* pBuffer, uint8_t ReadAddr, uint16_t NumByteToRead) -{ - if(NumByteToRead > 0x01) - { - ReadAddr |= (uint8_t)(READWRITE_CMD | MULTIPLEBYTE_CMD); - } - else - { - ReadAddr |= (uint8_t)READWRITE_CMD; - } - /* Set chip select Low at the start of the transmission */ - GYRO_CS_LOW(); - - /* Send the Address of the indexed register */ - SPIx_WriteRead(ReadAddr); - - /* Receive the data that will be read from the device (MSB First) */ - while(NumByteToRead > 0x00) - { - /* Send dummy byte (0x00) to generate the SPI clock to Gyroscope (Slave device) */ - *pBuffer = SPIx_WriteRead(DUMMY_BYTE); - NumByteToRead--; - pBuffer++; - } - - /* Set chip select High at the end of the transmission */ - GYRO_CS_HIGH(); -} - - -#ifdef EE_M24LR64 - -/******************************** LINK I2C EEPROM *****************************/ - -/** - * @brief Initializes peripherals used by the I2C EEPROM driver. - * @param None - * @retval None - */ -void EEPROM_IO_Init(void) -{ - I2Cx_Init(); -} - -/** - * @brief Writes data to I2C EEPROM driver in using DMA channel. - * @param DevAddress: Target device address - * @param MemAddress: Internal memory address - * @param pBuffer: Pointer to data buffer - * @param BufferSize: Amount of data to be sent - * @retval HAL status - */ -HAL_StatusTypeDef EEPROM_IO_WriteData(uint16_t DevAddress, uint16_t MemAddress, uint8_t* pBuffer, uint32_t BufferSize) -{ - return (I2Cx_WriteBufferDMA(DevAddress, MemAddress, pBuffer, BufferSize)); -} - -/** - * @brief Reads data from I2C EEPROM driver in using DMA channel. - * @param DevAddress: Target device address - * @param MemAddress: Internal memory address - * @param pBuffer: Pointer to data buffer - * @param BufferSize: Amount of data to be read - * @retval HAL status - */ -HAL_StatusTypeDef EEPROM_IO_ReadData(uint16_t DevAddress, uint16_t MemAddress, uint8_t* pBuffer, uint32_t BufferSize) -{ - return (I2Cx_ReadBufferDMA(DevAddress, MemAddress, pBuffer, BufferSize)); -} - -/** -* @brief Checks if target device is ready for communication. -* @note This function is used with Memory devices -* @param DevAddress: Target device address -* @param Trials: Number of trials -* @retval HAL status -*/ -HAL_StatusTypeDef EEPROM_IO_IsDeviceReady(uint16_t DevAddress, uint32_t Trials) -{ - return (I2Cx_IsDeviceReady(DevAddress, Trials)); -} -#endif /* EE_M24LR64 */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32F429I-Discovery/stm32f429i_discovery.h b/bsp/stm32f411RE/Libraries/BSP/STM32F429I-Discovery/stm32f429i_discovery.h deleted file mode 100644 index 5edf75cee2..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32F429I-Discovery/stm32f429i_discovery.h +++ /dev/null @@ -1,349 +0,0 @@ -/** - ****************************************************************************** - * @file stm32f429i_discovery.h - * @author MCD Application Team - * @version V2.1.2 - * @date 02-March-2015 - * @brief This file contains definitions for STM32F429I-Discovery Kit LEDs, - * push-buttons hardware resources. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32F429I_DISCOVERY_H -#define __STM32F429I_DISCOVERY_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm32f4xx_hal.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32F429I_DISCOVERY - * @{ - */ - -/** @addtogroup STM32F429I_DISCOVERY_LOW_LEVEL - * @{ - */ - -/** @defgroup STM32F429I_DISCOVERY_LOW_LEVEL_Exported_Types - * @{ - */ -typedef enum -{ - LED3 = 0, - LED4 = 1 -}Led_TypeDef; - -typedef enum -{ - BUTTON_KEY = 0, -}Button_TypeDef; - -typedef enum -{ - BUTTON_MODE_GPIO = 0, - BUTTON_MODE_EXTI = 1 -}ButtonMode_TypeDef; - -/** - * @} - */ - -/** @defgroup STM32F429I_DISCOVERY_LOW_LEVEL_Exported_Constants - * @{ - */ - -/** - * @brief Define for STM32F429I_DISCO board - */ -#if !defined (USE_STM32F429I_DISCO) - #define USE_STM32F429I_DISCO -#endif - -/** @addtogroup STM32F429I_DISCOVERY_LOW_LEVEL_LED - * @{ - */ -#define LEDn 2 - -#define LED3_PIN GPIO_PIN_13 -#define LED3_GPIO_PORT GPIOG -#define LED3_GPIO_CLK_ENABLE() __GPIOG_CLK_ENABLE() -#define LED3_GPIO_CLK_DISABLE() __GPIOG_CLK_DISABLE() - -#define LED4_PIN GPIO_PIN_14 -#define LED4_GPIO_PORT GPIOG -#define LED4_GPIO_CLK_ENABLE() __GPIOG_CLK_ENABLE() -#define LED4_GPIO_CLK_DISABLE() __GPIOG_CLK_DISABLE() - -#define LEDx_GPIO_CLK_ENABLE(__INDEX__) do{if((__INDEX__) == 0) LED3_GPIO_CLK_ENABLE(); else \ - if((__INDEX__) == 1) LED4_GPIO_CLK_ENABLE(); \ - }while(0) -#define LEDx_GPIO_CLK_DISABLE(__INDEX__) do{if((__INDEX__) == 0) LED3_GPIO_CLK_DISABLE(); else \ - if((__INDEX__) == 1) LED4_GPIO_CLK_DISABLE(); \ - }while(0) -/** - * @} - */ - -/** @addtogroup STM32F429I_DISCOVERY_LOW_LEVEL_BUTTON - * @{ - */ -#define BUTTONn 1 - -/** - * @brief Wakeup push-button - */ -#define KEY_BUTTON_PIN GPIO_PIN_0 -#define KEY_BUTTON_GPIO_PORT GPIOA -#define KEY_BUTTON_GPIO_CLK_ENABLE() __GPIOA_CLK_ENABLE() -#define KEY_BUTTON_GPIO_CLK_DISABLE() __GPIOA_CLK_DISABLE() -#define KEY_BUTTON_EXTI_IRQn EXTI0_IRQn - -#define BUTTONx_GPIO_CLK_ENABLE(__INDEX__) do{if((__INDEX__) == 0) KEY_BUTTON_GPIO_CLK_ENABLE(); \ - }while(0) -#define BUTTONx_GPIO_CLK_DISABLE(__INDEX__) do{if((__INDEX__) == 0) KEY_BUTTON_GPIO_CLK_DISABLE(); \ - }while(0) -/** - * @} - */ - -/** @addtogroup STM32F429I_DISCOVERY_LOW_LEVEL_BUS - * @{ - */ -/* Exported constanIO --------------------------------------------------------*/ -#define IO_I2C_ADDRESS 0x82 -#define TS_I2C_ADDRESS 0x82 - -#ifdef EE_M24LR64 -#define EEPROM_I2C_ADDRESS_A01 0xA0 -#define EEPROM_I2C_ADDRESS_A02 0xA6 -#endif /* EE_M24LR64 */ - -/*############################### I2Cx #######################################*/ -/* User can use this section to tailor I2Cx instance used and associated - resources */ -#define DISCOVERY_I2Cx I2C3 -#define DISCOVERY_I2Cx_CLOCK_ENABLE() __I2C3_CLK_ENABLE() -#define DISCOVERY_I2Cx_FORCE_RESET() __I2C3_FORCE_RESET() -#define DISCOVERY_I2Cx_RELEASE_RESET() __I2C3_RELEASE_RESET() -#define DISCOVERY_I2Cx_SDA_GPIO_CLK_ENABLE() __GPIOC_CLK_ENABLE() -#define DISCOVERY_I2Cx_SCL_GPIO_CLK_ENABLE() __GPIOA_CLK_ENABLE() -#define DISCOVERY_I2Cx_SDA_GPIO_CLK_DISABLE() __GPIOC_CLK_DISABLE() - -/* Definition for DISCO I2Cx Pins */ -#define DISCOVERY_I2Cx_SCL_PIN GPIO_PIN_8 -#define DISCOVERY_I2Cx_SCL_GPIO_PORT GPIOA -#define DISCOVERY_I2Cx_SCL_SDA_AF GPIO_AF4_I2C3 -#define DISCOVERY_I2Cx_SDA_PIN GPIO_PIN_9 -#define DISCOVERY_I2Cx_SDA_GPIO_PORT GPIOC - -/* Definition for IOE I2Cx's NVIC */ -#define DISCOVERY_I2Cx_EV_IRQn I2C3_EV_IRQn -#define DISCOVERY_I2Cx_ER_IRQn I2C3_ER_IRQn - -/* I2C clock speed configuration (in Hz) - WARNING: - Make sure that this define is not already declared in other files. - It can be used in parallel by other modules. */ -#ifndef BSP_I2C_SPEED - #define BSP_I2C_SPEED 100000 -#endif /* BSP_I2C_SPEED */ - -#define I2Cx_TIMEOUT_MAX 0x3000 /*
© COPYRIGHT(c) 2015 STMicroelectronics
- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ -/* Includes ------------------------------------------------------------------*/ -#include "stm32f429i_discovery_eeprom.h" - -#ifdef EE_M24LR64 - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32F429I_DISCOVERY - * @{ - */ - -/** @addtogroup STM32F429I_DISCOVERY_EEPROM - * @brief This file includes the I2C EEPROM driver of STM32F429I Discovery Kit. - * @{ - */ - -/** @defgroup STM32F429I_DISCOVERY EEPROM_Private_Types - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F429I_DISCOVERY_EEPROM_Private_Defines - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F429I_DISCOVERY_EEPROM_Private_Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F429I_DISCOVERY_EEPROM_Private_Variables - * @{ - */ -__IO uint16_t EEPROMAddress = 0; -__IO uint32_t EEPROMTimeout = EEPROM_READ_TIMEOUT; -__IO uint16_t EEPROMDataRead; -__IO uint8_t EEPROMDataWrite; - -/** - * @} - */ - -/** @defgroup STM32F429I_DISCOVERY_EEPROM_Private_Function_Prototypes - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F429I_DISCOVERY_EEPROM_Private_Functions - * @{ - */ - -/** - * @brief Initializes peripherals used by the I2C EEPROM driver. - * @param None - * @note There are 2 different versions of M24LR64 (A01 & A02). - * Then try to connect on 1st one (EEPROM_I2C_ADDRESS_A01) - * and if problem, check the 2nd one (EEPROM_I2C_ADDRESS_A02) - * @retval EEPROM_OK (0) if operation is correctly performed, else return value - * different from EEPROM_OK (0) - */ -uint32_t BSP_EEPROM_Init(void) -{ - /* I2C Initialization */ - EEPROM_IO_Init(); - - /*Select the EEPROM address for A01 and check if OK*/ - EEPROMAddress = EEPROM_I2C_ADDRESS_A01; - if (EEPROM_IO_IsDeviceReady(EEPROMAddress, EEPROM_MAX_TRIALS) != HAL_OK) - { - /*Select the EEPROM address for A02 and check if OK*/ - EEPROMAddress = EEPROM_I2C_ADDRESS_A02; - if (EEPROM_IO_IsDeviceReady(EEPROMAddress, EEPROM_MAX_TRIALS) != HAL_OK) - { - return EEPROM_FAIL; - } - } - return EEPROM_OK; -} - -/** - * @brief Reads a block of data from the EEPROM. - * @param pBuffer : pointer to the buffer that receives the data read from - * the EEPROM. - * @param ReadAddr : EEPROM's internal address to start reading from. - * @param NumByteToRead : pointer to the variable holding number of bytes to - * be read from the EEPROM. - * - * @note The variable pointed by NumByteToRead is reset to 0 when all the - * data are read from the EEPROM. Application should monitor this - * variable in order know when the transfer is complete. - * - * @retval EEPROM_OK (0) if operation is correctly performed, else return value - * different from EEPROM_OK (0) or the timeout user callback. - */ -uint32_t BSP_EEPROM_ReadBuffer(uint8_t *pBuffer, uint16_t ReadAddr, uint16_t *NumByteToRead) -{ - uint32_t buffersize = *NumByteToRead; - - /* Set the pointer to the Number of data to be read. This pointer will be used - by the DMA Transfer Completer interrupt Handler in order to reset the - variable to 0. User should check on this variable in order to know if the - DMA transfer has been complete or not. */ - EEPROMDataRead = *NumByteToRead; - - if (EEPROM_IO_ReadData(EEPROMAddress, ReadAddr, pBuffer, buffersize) != HAL_OK) - { - return EEPROM_FAIL; - } - - /* Wait transfer through DMA to be complete */ - EEPROMTimeout = HAL_GetTick() + EEPROM_READ_TIMEOUT; - while (EEPROMDataRead > 0) - { - if(HAL_GetTick() > EEPROMTimeout) - { - BSP_EEPROM_TIMEOUT_UserCallback(); - return EEPROM_TIMEOUT; - } - } - - /* If all operations OK, return EEPROM_OK (0) */ - return EEPROM_OK; -} - -/** - * @brief Writes more than one byte to the EEPROM with a single WRITE cycle. - * - * @note The number of bytes (combined to write start address) must not - * cross the EEPROM page boundary. This function can only write into - * the boundaries of an EEPROM page. - * This function doesn't check on boundaries condition (in this driver - * the function BSP_EEPROM_WriteBuffer() which calls BSP_EEPROM_WritePage() is - * responsible of checking on Page boundaries). - * - * @param pBuffer : pointer to the buffer containing the data to be written to - * the EEPROM. - * @param WriteAddr : EEPROM's internal address to write to. - * @param NumByteToWrite : pointer to the variable holding number of bytes to - * be written into the EEPROM. - * - * @note The variable pointed by NumByteToWrite is reset to 0 when all the - * data are written to the EEPROM. Application should monitor this - * variable in order know when the transfer is complete. - * - * @note This function just configure the communication and enable the DMA - * channel to transfer data. Meanwhile, the user application may perform - * other tasks in parallel. - * - * @retval EEPROM_OK (0) if operation is correctly performed, else return value - * different from EEPROM_OK (0) or the timeout user callback. - */ -uint32_t BSP_EEPROM_WritePage(uint8_t *pBuffer, uint16_t WriteAddr, uint8_t *NumByteToWrite) -{ - uint32_t buffersize = *NumByteToWrite; - uint32_t status = EEPROM_OK; - /* Set the pointer to the Number of data to be written. This pointer will be used - by the DMA Transfer Completer interrupt Handler in order to reset the - variable to 0. User should check on this variable in order to know if the - DMA transfer has been complete or not. */ - EEPROMDataWrite = *NumByteToWrite; - - if (EEPROM_IO_WriteData(EEPROMAddress, WriteAddr, pBuffer, buffersize) != HAL_OK) - { - status = EEPROM_FAIL; - } - - /* Wait transfer through DMA to be complete */ - EEPROMTimeout = HAL_GetTick() + EEPROM_WRITE_TIMEOUT; - while (EEPROMDataWrite > 0) - { - if(HAL_GetTick() > EEPROMTimeout) - { - BSP_EEPROM_TIMEOUT_UserCallback(); - return EEPROM_TIMEOUT; - } - } - - if (BSP_EEPROM_WaitEepromStandbyState() != EEPROM_OK) - { - return EEPROM_FAIL; - } - - /* If all operations OK, return EEPROM_OK (0) */ - return status; -} - -/** - * @brief Writes buffer of data to the I2C EEPROM. - * @param pBuffer : pointer to the buffer containing the data to be written - * to the EEPROM. - * @param WriteAddr : EEPROM's internal address to write to. - * @param NumByteToWrite : number of bytes to write to the EEPROM. - * @retval EEPROM_OK (0) if operation is correctly performed, else return value - * different from EEPROM_OK (0) or the timeout user callback. - */ -uint32_t BSP_EEPROM_WriteBuffer(uint8_t *pBuffer, uint16_t WriteAddr, uint16_t NumByteToWrite) -{ - uint16_t numofpage = 0, numofsingle = 0, count = 0; - uint16_t addr = 0; - uint8_t dataindex = 0; - uint32_t status = EEPROM_OK; - - addr = WriteAddr % EEPROM_PAGESIZE; - count = EEPROM_PAGESIZE - addr; - numofpage = NumByteToWrite / EEPROM_PAGESIZE; - numofsingle = NumByteToWrite % EEPROM_PAGESIZE; - - /* If WriteAddr is EEPROM_PAGESIZE aligned */ - if(addr == 0) - { - /* If NumByteToWrite < EEPROM_PAGESIZE */ - if(numofpage == 0) - { - /* Store the number of data to be written */ - dataindex = numofsingle; - /* Start writing data */ - status = BSP_EEPROM_WritePage(pBuffer, WriteAddr, (uint8_t*)(&dataindex)); - if (status != EEPROM_OK) - { - return status; - } - } - /* If NumByteToWrite > EEPROM_PAGESIZE */ - else - { - while(numofpage--) - { - /* Store the number of data to be written */ - dataindex = EEPROM_PAGESIZE; - status = BSP_EEPROM_WritePage(pBuffer, WriteAddr, (uint8_t*)(&dataindex)); - if (status != EEPROM_OK) - { - return status; - } - - WriteAddr += EEPROM_PAGESIZE; - pBuffer += EEPROM_PAGESIZE; - } - - if(numofsingle!=0) - { - /* Store the number of data to be written */ - dataindex = numofsingle; - status = BSP_EEPROM_WritePage(pBuffer, WriteAddr, (uint8_t*)(&dataindex)); - if (status != EEPROM_OK) - { - return status; - } - } - } - } - /* If WriteAddr is not EEPROM_PAGESIZE aligned */ - else - { - /* If NumByteToWrite < EEPROM_PAGESIZE */ - if(numofpage== 0) - { - /* If the number of data to be written is more than the remaining space - in the current page: */ - if (NumByteToWrite > count) - { - /* Store the number of data to be written */ - dataindex = count; - /* Write the data contained in same page */ - status = BSP_EEPROM_WritePage(pBuffer, WriteAddr, (uint8_t*)(&dataindex)); - if (status != EEPROM_OK) - { - return status; - } - - /* Store the number of data to be written */ - dataindex = (NumByteToWrite - count); - /* Write the remaining data in the following page */ - status = BSP_EEPROM_WritePage((uint8_t*)(pBuffer + count), (WriteAddr + count), (uint8_t*)(&dataindex)); - if (status != EEPROM_OK) - { - return status; - } - } - else - { - /* Store the number of data to be written */ - dataindex = numofsingle; - status = BSP_EEPROM_WritePage(pBuffer, WriteAddr, (uint8_t*)(&dataindex)); - if (status != EEPROM_OK) - { - return status; - } - } - } - /* If NumByteToWrite > EEPROM_PAGESIZE */ - else - { - NumByteToWrite -= count; - numofpage = NumByteToWrite / EEPROM_PAGESIZE; - numofsingle = NumByteToWrite % EEPROM_PAGESIZE; - - if(count != 0) - { - /* Store the number of data to be written */ - dataindex = count; - status = BSP_EEPROM_WritePage(pBuffer, WriteAddr, (uint8_t*)(&dataindex)); - if (status != EEPROM_OK) - { - return status; - } - WriteAddr += count; - pBuffer += count; - } - - while(numofpage--) - { - /* Store the number of data to be written */ - dataindex = EEPROM_PAGESIZE; - status = BSP_EEPROM_WritePage(pBuffer, WriteAddr, (uint8_t*)(&dataindex)); - if (status != EEPROM_OK) - { - return status; - } - WriteAddr += EEPROM_PAGESIZE; - pBuffer += EEPROM_PAGESIZE; - } - if(numofsingle != 0) - { - /* Store the number of data to be written */ - dataindex = numofsingle; - status = BSP_EEPROM_WritePage(pBuffer, WriteAddr, (uint8_t*)(&dataindex)); - if (status != EEPROM_OK) - { - return status; - } - } - } - } - - /* If all operations OK, return EEPROM_OK (0) */ - return EEPROM_OK; -} - -/** - * @brief Wait for EEPROM Standby state. - * - * @note This function allows to wait and check that EEPROM has finished the - * last operation. It is mostly used after Write operation: after receiving - * the buffer to be written, the EEPROM may need additional time to actually - * perform the write operation. During this time, it doesn't answer to - * I2C packets addressed to it. Once the write operation is complete - * the EEPROM responds to its address. - * - * @param None - * @retval EEPROM_OK (0) if operation is correctly performed, else return value - * different from EEPROM_OK (0) or the timeout user callback. - */ -uint32_t BSP_EEPROM_WaitEepromStandbyState(void) -{ - /* Check if the maximum allowed number of trials has bee reached */ - if (EEPROM_IO_IsDeviceReady(EEPROMAddress, EEPROM_MAX_TRIALS) != HAL_OK) - { - /* If the maximum number of trials has been reached, exit the function */ - BSP_EEPROM_TIMEOUT_UserCallback(); - return EEPROM_TIMEOUT; - } - return EEPROM_OK; -} - -/** - * @brief Memory Tx Transfer completed callbacks. - * @param hi2c: I2C handle - * @retval None - */ -void HAL_I2C_MemTxCpltCallback(I2C_HandleTypeDef *hi2c) -{ - EEPROMDataWrite = 0; -} - -/** - * @brief Memory Rx Transfer completed callbacks. - * @param hi2c: I2C handle - * @retval None - */ -void HAL_I2C_MemRxCpltCallback(I2C_HandleTypeDef *hi2c) -{ - EEPROMDataRead = 0; -} - -/** - * @brief Basic management of the timeout situation. - * @param None. - * @retval None. - */ -__weak void BSP_EEPROM_TIMEOUT_UserCallback(void) -{ -} - -#endif /* EE_M24LR64 */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32F429I-Discovery/stm32f429i_discovery_eeprom.h b/bsp/stm32f411RE/Libraries/BSP/STM32F429I-Discovery/stm32f429i_discovery_eeprom.h deleted file mode 100644 index bed52ae821..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32F429I-Discovery/stm32f429i_discovery_eeprom.h +++ /dev/null @@ -1,145 +0,0 @@ -/** - ****************************************************************************** - * @file stm32f429i_discovery_eeprom.h - * @author MCD Application Team - * @version V2.1.2 - * @date 02-March-2015 - * @brief This file contains all the functions prototypes for - * the stm32f429i_discovery_eeprom.c firmware driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32F429I_DISCOVERY_EEPROM_H -#define __STM32F429I_DISCOVERY_EEPROM_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm32f429i_discovery.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32F429I_DISCOVERY - * @{ - */ - -/** @addtogroup STM32F429I_DISCOVERY_EEPROM - * @{ - */ - -/** @defgroup STM32F429I_DISCOVERY_EEPROM_Exported_Types - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F429I_DISCOVERY_EEPROM_Exported_Constants - * @{ - */ -/* EEPROM hardware address and page size */ -#define EEPROM_PAGESIZE 4 -#define EEPROM_MAX_SIZE 0x2000 /* 64Kbit*/ - -/* Maximum Timeout values for flags and events waiting loops. -This timeout is based on systick set to 1ms*/ -/* Timeout for read based if read all the EEPROM : EEPROM_MAX_SIZE * BSP_I2C_SPEED (640ms)*/ -#define EEPROM_READ_TIMEOUT ((uint32_t)(1000)) -/* Timeout for write based on max write which is EEPROM_PAGESIZE bytes: EEPROM_PAGESIZE * BSP_I2C_SPEED (320us)*/ -#define EEPROM_WRITE_TIMEOUT ((uint32_t)(1)) - -/* Maximum number of trials for EEPROM_WaitEepromStandbyState() function */ -#define EEPROM_MAX_TRIALS 300 - -#define EEPROM_OK 0 -#define EEPROM_FAIL 1 -#define EEPROM_TIMEOUT 2 -/** - * @} - */ - -/** @defgroup STM32F429I_DISCOVERY_EEPROM_Exported_Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F429I_DISCOVERY_EEPROM_Exported_Functions - * @{ - */ -uint32_t BSP_EEPROM_Init(void); -uint32_t BSP_EEPROM_ReadBuffer(uint8_t *pBuffer, uint16_t ReadAddr, uint16_t *NumByteToRead); -uint32_t BSP_EEPROM_WritePage(uint8_t *pBuffer, uint16_t WriteAddr, uint8_t *NumByteToWrite); -uint32_t BSP_EEPROM_WriteBuffer(uint8_t *pBuffer, uint16_t WriteAddr, uint16_t NumByteToWrite); -uint32_t BSP_EEPROM_WaitEepromStandbyState(void); - -/* USER Callbacks: This function is declared as __weak in EEPROM driver and - should be implemented into user application. - BSP_EEPROM_TIMEOUT_UserCallback() function is called whenever a timeout condition - occurs during communication (waiting on an event that doesn't occur, bus - errors, busy devices ...). */ -void BSP_EEPROM_TIMEOUT_UserCallback(void); - - -/* Link function for I2C EEPROM peripheral */ -void EEPROM_IO_Init(void); -HAL_StatusTypeDef EEPROM_IO_WriteData(uint16_t DevAddress, uint16_t MemAddress, uint8_t *pBuffer, uint32_t BufferSize); -HAL_StatusTypeDef EEPROM_IO_ReadData(uint16_t DevAddress, uint16_t MemAddress, uint8_t *pBuffer, uint32_t BufferSize); -HAL_StatusTypeDef EEPROM_IO_IsDeviceReady(uint16_t DevAddress, uint32_t Trials); - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32F429I_DISCOVERY_EEPROM_H */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32F429I-Discovery/stm32f429i_discovery_gyroscope.c b/bsp/stm32f411RE/Libraries/BSP/STM32F429I-Discovery/stm32f429i_discovery_gyroscope.c deleted file mode 100644 index 73ea7a2c74..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32F429I-Discovery/stm32f429i_discovery_gyroscope.c +++ /dev/null @@ -1,263 +0,0 @@ -/** - ****************************************************************************** - * @file stm32f429i_discovery_gyroscope.c - * @author MCD Application Team - * @version V2.1.2 - * @date 02-March-2015 - * @brief This file provides a set of functions needed to manage the - * MEMS gyroscope available on STM32F429I-Discovery Kit. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ -/* Includes ------------------------------------------------------------------*/ -#include "stm32f429i_discovery_gyroscope.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32F429I_DISCOVERY - * @{ - */ - -/** @defgroup STM32F429I_DISCOVERY_GYROSCOPE - * @{ - */ - -/** @defgroup STM32F429I_DISCOVERY_GYROSCOPE_Private_TypesDefinitions - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F429I_DISCOVERY_GYROSCOPE_Private_Defines - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F429I_DISCOVERY_GYROSCOPE_Private_Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F429I_DISCOVERY_GYROSCOPE_Private_Variables - * @{ - */ -static GYRO_DrvTypeDef *GyroscopeDrv; - -/** - * @} - */ - -/** @defgroup STM32F429I_DISCOVERY_GYROSCOPE_Private_FunctionPrototypes - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F429I_DISCOVERY_GYROSCOPE_Private_Functions - * @{ - */ - -/** - * @brief Set Gyroscope Initialization. - * @param None - * @retval GYRO_OK if no problem during initialization - */ -uint8_t BSP_GYRO_Init(void) -{ - uint8_t ret = GYRO_ERROR; - uint16_t ctrl = 0x0000; - GYRO_InitTypeDef L3GD20_InitStructure; - GYRO_FilterConfigTypeDef L3GD20_FilterStructure={0,0}; - - if((L3gd20Drv.ReadID() == I_AM_L3GD20) || (L3gd20Drv.ReadID() == I_AM_L3GD20_TR)) - { - /* Initialize the Gyroscope driver structure */ - GyroscopeDrv = &L3gd20Drv; - - /* MEMS configuration ----------------------------------------------------*/ - /* Fill the Gyroscope structure */ - L3GD20_InitStructure.Power_Mode = L3GD20_MODE_ACTIVE; - L3GD20_InitStructure.Output_DataRate = L3GD20_OUTPUT_DATARATE_1; - L3GD20_InitStructure.Axes_Enable = L3GD20_AXES_ENABLE; - L3GD20_InitStructure.Band_Width = L3GD20_BANDWIDTH_4; - L3GD20_InitStructure.BlockData_Update = L3GD20_BlockDataUpdate_Continous; - L3GD20_InitStructure.Endianness = L3GD20_BLE_LSB; - L3GD20_InitStructure.Full_Scale = L3GD20_FULLSCALE_500; - - /* Configure MEMS: data rate, power mode, full scale and axes */ - ctrl = (uint16_t) (L3GD20_InitStructure.Power_Mode | L3GD20_InitStructure.Output_DataRate | \ - L3GD20_InitStructure.Axes_Enable | L3GD20_InitStructure.Band_Width); - - ctrl |= (uint16_t) ((L3GD20_InitStructure.BlockData_Update | L3GD20_InitStructure.Endianness | \ - L3GD20_InitStructure.Full_Scale) << 8); - - /* Configure the Gyroscope main parameters */ - GyroscopeDrv->Init(ctrl); - - L3GD20_FilterStructure.HighPassFilter_Mode_Selection = L3GD20_HPM_NORMAL_MODE_RES; - L3GD20_FilterStructure.HighPassFilter_CutOff_Frequency = L3GD20_HPFCF_0; - - ctrl = (uint8_t) ((L3GD20_FilterStructure.HighPassFilter_Mode_Selection |\ - L3GD20_FilterStructure.HighPassFilter_CutOff_Frequency)); - - /* Configure the Gyroscope main parameters */ - GyroscopeDrv->FilterConfig(ctrl) ; - - GyroscopeDrv->FilterCmd(L3GD20_HIGHPASSFILTER_ENABLE); - - ret = GYRO_OK; - } - else - { - ret = GYRO_ERROR; - } - return ret; -} - -/** - * @brief Read ID of Gyroscope component. - * @param None - * @retval ID - */ -uint8_t BSP_GYRO_ReadID(void) -{ - uint8_t id = 0x00; - - if(GyroscopeDrv->ReadID != NULL) - { - id = GyroscopeDrv->ReadID(); - } - return id; -} - -/** - * @brief Reboot memory content of Gyroscope. - * @param None - * @retval None - */ -void BSP_GYRO_Reset(void) -{ - if(GyroscopeDrv->Reset != NULL) - { - GyroscopeDrv->Reset(); - } -} - -/** - * @brief Configures INT1 interrupt. - * @param pIntConfig: pointer to a L3GD20_InterruptConfig_TypeDef - * structure that contains the configuration setting for the L3GD20 Interrupt. - * @retval None - */ -void BSP_GYRO_ITConfig(GYRO_InterruptConfigTypeDef *pIntConfig) -{ - uint16_t interruptconfig = 0x0000; - - if(GyroscopeDrv->ConfigIT != NULL) - { - /* Configure latch Interrupt request and axe interrupts */ - interruptconfig |= ((uint8_t)(pIntConfig->Latch_Request| \ - pIntConfig->Interrupt_Axes) << 8); - - interruptconfig |= (uint8_t)(pIntConfig->Interrupt_ActiveEdge); - - GyroscopeDrv->ConfigIT(interruptconfig); - } -} - -/** - * @brief Enables INT1 or INT2 interrupt. - * @param IntPin: Interrupt pin - * This parameter can be: - * @arg L3GD20_INT1 - * @arg L3GD20_INT2 - * @retval None - */ -void BSP_GYRO_EnableIT(uint8_t IntPin) -{ - if(GyroscopeDrv->EnableIT != NULL) - { - GyroscopeDrv->EnableIT(IntPin); - } -} - -/** - * @brief Disables INT1 or INT2 interrupt. - * @param IntPin: Interrupt pin - * This parameter can be: - * @arg L3GD20_INT1 - * @arg L3GD20_INT2 - * @retval None - */ -void BSP_GYRO_DisableIT(uint8_t IntPin) -{ - if(GyroscopeDrv->DisableIT != NULL) - { - GyroscopeDrv->DisableIT(IntPin); - } -} - -/** - * @brief Gets XYZ angular acceleration/ - * @param pfData: pointer on floating array - * @retval None - */ -void BSP_GYRO_GetXYZ(float *pfData) -{ - if(GyroscopeDrv->GetXYZ!= NULL) - { - GyroscopeDrv->GetXYZ(pfData); - } -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32F429I-Discovery/stm32f429i_discovery_gyroscope.h b/bsp/stm32f411RE/Libraries/BSP/STM32F429I-Discovery/stm32f429i_discovery_gyroscope.h deleted file mode 100644 index e0b769c1fd..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32F429I-Discovery/stm32f429i_discovery_gyroscope.h +++ /dev/null @@ -1,125 +0,0 @@ -/** - ****************************************************************************** - * @file stm32f429i_discovery_gyroscope.h - * @author MCD Application Team - * @version V2.1.2 - * @date 02-March-2015 - * @brief This file contains definitions for stm32f429i_discovery_gyroscope.c - * firmware driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32F429I_DISCOVERY_GYROSCOPE_H -#define __STM32F429I_DISCOVERY_GYROSCOPE_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm32f429i_discovery.h" -/* Include Gyroscope component driver */ -#include "../Components/l3gd20/l3gd20.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32F429I_DISCOVERY - * @{ - */ - -/** @addtogroup STM32F429I_DISCOVERY_GYROSCOPE - * @{ - */ - -/** @defgroup STM32F429I_DISCOVERY_GYROSCOPE_Exported_Types - * @{ - */ -typedef enum -{ - GYRO_OK = 0, - GYRO_ERROR = 1, - GYRO_TIMEOUT = 2 -}GYRO_StatusTypeDef; -/** - * @} - */ - -/** @defgroup STM32F429I_DISCOVERY_GYROSCOPE_Exported_Constants - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F429I_DISCOVERY_GYROSCOPE_Exported_Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F429I_DISCOVERY_GYROSCOPE_Exported_Functions - * @{ - */ -/* Gyroscope Functions */ -uint8_t BSP_GYRO_Init(void); -void BSP_GYRO_Reset(void); -uint8_t BSP_GYRO_ReadID(void); -void BSP_GYRO_ITConfig(GYRO_InterruptConfigTypeDef *pIntConfigStruct); -void BSP_GYRO_EnableIT(uint8_t IntPin); -void BSP_GYRO_DisableIT(uint8_t IntPin); -void BSP_GYRO_GetXYZ(float* pfData); - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32F429I_DISCOVERY_GYROSCOPE_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32F429I-Discovery/stm32f429i_discovery_io.c b/bsp/stm32f411RE/Libraries/BSP/STM32F429I-Discovery/stm32f429i_discovery_io.c deleted file mode 100644 index d046c02bd6..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32F429I-Discovery/stm32f429i_discovery_io.c +++ /dev/null @@ -1,231 +0,0 @@ -/** - ****************************************************************************** - * @file stm32f429i_discovery_io.c - * @author MCD Application Team - * @version V2.1.2 - * @date 02-March-2015 - * @brief This file provides a set of functions needed to manage the STMPE811 - * IO Expander device mounted on STM32F429I-Discovery Kit. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Includes ------------------------------------------------------------------*/ -#include "stm32f429i_discovery_io.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32F429I_DISCOVERY - * @{ - */ - -/** @defgroup STM32F429I_DISCOVERY_IO - * @{ - */ - -/** @defgroup STM32F429I_DISCOVERY_IO_Private_Types_Definitions - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F429I_DISCOVERY_IO_Private_Defines - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F429I_DISCOVERY_IO_Private_Macros - * @{ - */ -/** - * @} - */ - - -/** @defgroup STM32F429I_DISCOVERY_IO_Private_Variables - * @{ - */ -static IO_DrvTypeDef *IoDrv; - -/** - * @} - */ - - -/** @defgroup STM32F429I_DISCOVERY_IO_Private_Function_Prototypes - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F429I_DISCOVERY_IO_Private_Functions - * @{ - */ - -/** - * @brief Initializes and configures the IO functionalities and configures all - * necessary hardware resources (GPIOs, clocks..). - * @note BSP_IO_Init() is using HAL_Delay() function to ensure that stmpe811 - * IO Expander is correctly reset. HAL_Delay() function provides accurate - * delay (in milliseconds) based on variable incremented in SysTick ISR. - * This implies that if BSP_IO_Init() is called from a peripheral ISR process, - * then the SysTick interrupt must have higher priority (numerically lower) - * than the peripheral interrupt. Otherwise the caller ISR process will be blocked. - * @param None - * @retval IO_OK if all initializations done correctly. Other value if error. - */ -uint8_t BSP_IO_Init(void) -{ - uint8_t ret = IO_ERROR; - - /* Read ID and verify the IO expander is ready */ - if(stmpe811_io_drv.ReadID(IO_I2C_ADDRESS) == STMPE811_ID) - { - /* Initialize the IO driver structure */ - IoDrv = &stmpe811_io_drv; - ret = IO_OK; - } - - if(ret == IO_OK) - { - IoDrv->Init(IO_I2C_ADDRESS); - IoDrv->Start(IO_I2C_ADDRESS, IO_PIN_ALL); - } - return ret; -} - -/** - * @brief Gets the selected pins IT status. - * @param IoPin: The selected pins to check the status. - * This parameter could be any combination of the IO pins. - * @retval Status of IO Pin checked. - */ -uint8_t BSP_IO_ITGetStatus(uint16_t IoPin) -{ - /* Return the IO Pin IT status */ - return (IoDrv->ITStatus(IO_I2C_ADDRESS, IoPin)); -} - -/** - * @brief Clears all the IO IT pending bits - * @param None - * @retval None - */ -void BSP_IO_ITClear(void) -{ - /* Clear all IO IT pending bits */ - IoDrv->ClearIT(IO_I2C_ADDRESS, IO_PIN_ALL); -} - -/** - * @brief Configures the IO pin(s) according to IO mode structure value. - * @param IoPin: IO pin(s) to be configured. - * This parameter could be any combination of the following values: - * @arg STMPE811_PIN_x: where x can be from 0 to 7. - * @param IoMode: The IO pin mode to configure, could be one of the following values: - * @arg IO_MODE_INPUT - * @arg IO_MODE_OUTPUT - * @arg IO_MODE_IT_RISING_EDGE - * @arg IO_MODE_IT_FALLING_EDGE - * @arg IO_MODE_IT_LOW_LEVEL - * @arg IO_MODE_IT_HIGH_LEVEL - * @retval None - */ -void BSP_IO_ConfigPin(uint16_t IoPin, IO_ModeTypedef IoMode) -{ - /* Configure the selected IO pin(s) mode */ - IoDrv->Config(IO_I2C_ADDRESS, IoPin, IoMode); -} - -/** - * @brief Sets the selected pins state. - * @param IoPin: The selected pins to write. - * This parameter could be any combination of the IO pins. - * @param PinState: the new pins state to write - * @retval None - */ -void BSP_IO_WritePin(uint16_t IoPin, uint8_t PinState) -{ - /* Set the Pin state */ - IoDrv->WritePin(IO_I2C_ADDRESS, IoPin, PinState); -} - -/** - * @brief Gets the selected pins current state. - * @param IoPin: The selected pins to read. - * This parameter could be any combination of the IO pins. - * @retval The current pins state - */ -uint16_t BSP_IO_ReadPin(uint16_t IoPin) -{ - return(IoDrv->ReadPin(IO_I2C_ADDRESS, IoPin)); -} - -/** - * @brief Toggles the selected pins state. - * @param IoPin: The selected pins to toggle. - * This parameter could be any combination of the IO pins. - * @retval None - */ -void BSP_IO_TogglePin(uint16_t IoPin) -{ - /* Toggle the current pin state */ - if(IoDrv->ReadPin(IO_I2C_ADDRESS, IoPin) == 1 /* Set */) - { - IoDrv->WritePin(IO_I2C_ADDRESS, IoPin, 0 /* Reset */); - } - else - { - IoDrv->WritePin(IO_I2C_ADDRESS, IoPin, 1 /* Set */); - } -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32F429I-Discovery/stm32f429i_discovery_io.h b/bsp/stm32f411RE/Libraries/BSP/STM32F429I-Discovery/stm32f429i_discovery_io.h deleted file mode 100644 index b2cc3576c2..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32F429I-Discovery/stm32f429i_discovery_io.h +++ /dev/null @@ -1,133 +0,0 @@ -/** - ****************************************************************************** - * @file stm32f429i_discovery_io.h - * @author MCD Application Team - * @version V2.1.2 - * @date 02-March-2015 - * @brief This file contains all the functions prototypes for the - * stm32f429i_discovery_io.c driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32F429I_DISCOVERY_IO_H -#define __STM32F429I_DISCOVERY_IO_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm32f429i_discovery.h" -/* Include IO component driver */ -#include "../Components/stmpe811/stmpe811.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32F429I_DISCOVERY - * @{ - */ - -/** @defgroup STM32F429I_DISCOVERY_IO - * @{ - */ - -/** @defgroup STM32F429I_DISCOVERY_IO_Exported_Types - * @{ - */ -typedef enum -{ - IO_OK = 0, - IO_ERROR = 1, - IO_TIMEOUT = 2 -}IO_StatusTypeDef; -/** - * @} - */ - -/** @defgroup STM32F429I_DISCOVERY_IO_Exported_Constants - * @{ - */ -#define IO_PIN_0 0x01 -#define IO_PIN_1 0x02 -#define IO_PIN_2 0x04 -#define IO_PIN_3 0x08 -#define IO_PIN_4 0x10 -#define IO_PIN_5 0x20 -#define IO_PIN_6 0x40 -#define IO_PIN_7 0x80 -#define IO_PIN_ALL 0xFF -/** - * @} - */ - -/** @defgroup STM32F429I_DISCOVERY_IO_Exported_Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F429I_DISCOVERY_IO_Exported_Functions - * @{ - */ -uint8_t BSP_IO_Init(void); -uint8_t BSP_IO_ITGetStatus(uint16_t IoPin); -void BSP_IO_ITClear(void); -void BSP_IO_ConfigPin(uint16_t IoPin, IO_ModeTypedef IoMode); -void BSP_IO_WritePin(uint16_t IoPin, uint8_t PinState); -uint16_t BSP_IO_ReadPin(uint16_t IoPin); -void BSP_IO_TogglePin(uint16_t IoPin); - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32F429I_DISCOVERY_IO_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32F429I-Discovery/stm32f429i_discovery_lcd.c b/bsp/stm32f411RE/Libraries/BSP/STM32F429I-Discovery/stm32f429i_discovery_lcd.c deleted file mode 100644 index d1583e017e..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32F429I-Discovery/stm32f429i_discovery_lcd.c +++ /dev/null @@ -1,1405 +0,0 @@ -/** - ****************************************************************************** - * @file stm32f429i_discovery_lcd.c - * @author MCD Application Team - * @version V2.1.2 - * @date 02-March-2015 - * @brief This file includes the LCD driver for ILI9341 Liquid Crystal - * Display Modules of STM32F429I-Discovery kit (MB1075). - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* File Info : ----------------------------------------------------------------- - User NOTES -1. How To use this driver: --------------------------- - - This driver is used to drive directly an LCD TFT using LTDC controller. - - This driver select dynamically the mounted LCD, ILI9341 240x320 LCD mounted - on MB1075B discovery board, and use the adequate timing and setting for - the specified LCD using device ID of the ILI9341 mounted on MB1075B discovery board - -2. Driver description: ---------------------- - + Initialization steps : - o Initialize the LCD using the LCD_Init() function. - o Apply the Layer configuration using LCD_LayerDefaultInit() function - o Select the LCD layer to be used using LCD_SelectLayer() function. - o Enable the LCD display using LCD_DisplayOn() function. - - + Options - o Configure and enable the color keying functionality using LCD_SetColorKeying() - function. - o Modify in the fly the transparency and/or the frame buffer address - using the following functions : - - LCD_SetTransparency() - - LCD_SetLayerAddress() - - + Display on LCD - o Clear the hole LCD using LCD_Clear() function or only one specified string - line using LCD_ClearStringLine() function. - o Display a character on the specified line and column using LCD_DisplayChar() - function or a complete string line using LCD_DisplayStringAtLine() function. - o Display a string line on the specified position (x,y in pixel) and align mode - using LCD_DisplayStringAtLine() function. - o Draw and fill a basic shapes (dot, line, rectangle, circle, ellipse, .. bitmap) - on LCD using the available set of functions - -------------------------------------------------------------------------------*/ - -/* Includes ------------------------------------------------------------------*/ -#include "stm32f429i_discovery_lcd.h" -#include "../../../Utilities/Fonts/fonts.h" -#include "../../../Utilities/Fonts/font24.c" -#include "../../../Utilities/Fonts/font20.c" -#include "../../../Utilities/Fonts/font16.c" -#include "../../../Utilities/Fonts/font12.c" -#include "../../../Utilities/Fonts/font8.c" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32F429I_DISCOVERY - * @{ - */ - -/** @defgroup STM32F429I_DISCOVERY_LCD - * @brief This file includes the LCD driver for (ILI9341) - * @{ - */ - -/** @defgroup STM32F429I_DISCOVERY_LCD_Private_TypesDefinitions - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F429I_DISCOVERY_LCD_Private_Defines - * @{ - */ -#define POLY_X(Z) ((int32_t)((Points + Z)->X)) -#define POLY_Y(Z) ((int32_t)((Points + Z)->Y)) -/** - * @} - */ - -/** @defgroup STM32F429I_DISCOVERY_LCD_Private_Macros - * @{ - */ -#define ABS(X) ((X) > 0 ? (X) : -(X)) -/** - * @} - */ - -/** @defgroup STM32F429I_DISCOVERY_LCD_Private_Variables - * @{ - */ -static LTDC_HandleTypeDef LtdcHandler; -static DMA2D_HandleTypeDef Dma2dHandler; -static RCC_PeriphCLKInitTypeDef PeriphClkInitStruct; - -/* Default LCD configuration with LCD Layer 1 */ -static uint32_t ActiveLayer = 0; -static LCD_DrawPropTypeDef DrawProp[MAX_LAYER_NUMBER]; -LCD_DrvTypeDef *LcdDrv; -/** - * @} - */ - -/** @defgroup STM32F429I_DISCOVERY_LCD_Private_FunctionPrototypes - * @{ - */ -static void MspInit(void); -static void DrawChar(uint16_t Xpos, uint16_t Ypos, const uint8_t *c); -static void FillBuffer(uint32_t LayerIndex, void *pDst, uint32_t xSize, uint32_t ySize, uint32_t OffLine, uint32_t ColorIndex); -static void ConvertLineToARGB8888(void *pSrc, void *pDst, uint32_t xSize, uint32_t ColorMode); -/** - * @} - */ - -/** @defgroup STM32F429I_DISCOVERY_LCD_Private_Functions - * @{ - */ - -/** - * @brief Initializes the LCD. - * @param None - * @retval LCD state - */ -uint8_t BSP_LCD_Init(void) -{ - /* On STM32F429I-DISCO, it is not possible to read ILI9341 ID because */ - /* PIN EXTC is not connected to VDD and then LCD_READ_ID4 is not accessible. */ - /* In this case, ReadID function is bypassed.*/ - /*if(ili9341_drv.ReadID() == ILI9341_ID)*/ - - /* LTDC Configuration ----------------------------------------------------*/ - LtdcHandler.Instance = LTDC; - - /* Timing configuration (Typical configuration from ILI9341 datasheet) - HSYNC=10 (9+1) - HBP=20 (29-10+1) - ActiveW=240 (269-20-10+1) - HFP=10 (279-240-20-10+1) - - VSYNC=2 (1+1) - VBP=2 (3-2+1) - ActiveH=320 (323-2-2+1) - VFP=4 (327-320-2-2+1) - */ - - /* Configure horizontal synchronization width */ - LtdcHandler.Init.HorizontalSync = ILI9341_HSYNC; - /* Configure vertical synchronization height */ - LtdcHandler.Init.VerticalSync = ILI9341_VSYNC; - /* Configure accumulated horizontal back porch */ - LtdcHandler.Init.AccumulatedHBP = ILI9341_HBP; - /* Configure accumulated vertical back porch */ - LtdcHandler.Init.AccumulatedVBP = ILI9341_VBP; - /* Configure accumulated active width */ - LtdcHandler.Init.AccumulatedActiveW = 269; - /* Configure accumulated active height */ - LtdcHandler.Init.AccumulatedActiveH = 323; - /* Configure total width */ - LtdcHandler.Init.TotalWidth = 279; - /* Configure total height */ - LtdcHandler.Init.TotalHeigh = 327; - - /* Configure R,G,B component values for LCD background color */ - LtdcHandler.Init.Backcolor.Red= 0; - LtdcHandler.Init.Backcolor.Blue= 0; - LtdcHandler.Init.Backcolor.Green= 0; - - /* LCD clock configuration */ - /* PLLSAI_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */ - /* PLLSAI_VCO Output = PLLSAI_VCO Input * PLLSAIN = 192 Mhz */ - /* PLLLCDCLK = PLLSAI_VCO Output/PLLSAIR = 192/4 = 48 Mhz */ - /* LTDC clock frequency = PLLLCDCLK / LTDC_PLLSAI_DIVR_8 = 48/4 = 6Mhz */ - PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC; - PeriphClkInitStruct.PLLSAI.PLLSAIN = 192; - PeriphClkInitStruct.PLLSAI.PLLSAIR = 4; - PeriphClkInitStruct.PLLSAIDivR = RCC_PLLSAIDIVR_8; - HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct); - - /* Polarity */ - LtdcHandler.Init.HSPolarity = LTDC_HSPOLARITY_AL; - LtdcHandler.Init.VSPolarity = LTDC_VSPOLARITY_AL; - LtdcHandler.Init.DEPolarity = LTDC_DEPOLARITY_AL; - LtdcHandler.Init.PCPolarity = LTDC_PCPOLARITY_IPC; - - MspInit(); - HAL_LTDC_Init(&LtdcHandler); - - /* Select the device */ - LcdDrv = &ili9341_drv; - - /* LCD Init */ - LcdDrv->Init(); - - /* Initialize the SDRAM */ - BSP_SDRAM_Init(); - - /* Initialize the font */ - BSP_LCD_SetFont(&LCD_DEFAULT_FONT); - - return LCD_OK; -} - -/** - * @brief Gets the LCD X size. - * @param None - * @retval The used LCD X size - */ -uint32_t BSP_LCD_GetXSize(void) -{ - return LcdDrv->GetLcdPixelWidth(); -} - -/** - * @brief Gets the LCD Y size. - * @param None - * @retval The used LCD Y size - */ -uint32_t BSP_LCD_GetYSize(void) -{ - return LcdDrv->GetLcdPixelHeight(); -} - -/** - * @brief Initializes the LCD layers. - * @param LayerIndex: the layer foreground or background. - * @param FB_Address: the layer frame buffer. - * @retval None - */ -void BSP_LCD_LayerDefaultInit(uint16_t LayerIndex, uint32_t FB_Address) -{ - LCD_LayerCfgTypeDef Layercfg; - - /* Layer Init */ - Layercfg.WindowX0 = 0; - Layercfg.WindowX1 = BSP_LCD_GetXSize(); - Layercfg.WindowY0 = 0; - Layercfg.WindowY1 = BSP_LCD_GetYSize(); - Layercfg.PixelFormat = LTDC_PIXEL_FORMAT_ARGB8888; - Layercfg.FBStartAdress = FB_Address; - Layercfg.Alpha = 255; - Layercfg.Alpha0 = 0; - Layercfg.Backcolor.Blue = 0; - Layercfg.Backcolor.Green = 0; - Layercfg.Backcolor.Red = 0; - Layercfg.BlendingFactor1 = LTDC_BLENDING_FACTOR1_PAxCA; - Layercfg.BlendingFactor2 = LTDC_BLENDING_FACTOR2_PAxCA; - Layercfg.ImageWidth = BSP_LCD_GetXSize(); - Layercfg.ImageHeight = BSP_LCD_GetYSize(); - - HAL_LTDC_ConfigLayer(&LtdcHandler, &Layercfg, LayerIndex); - - DrawProp[LayerIndex].BackColor = LCD_COLOR_WHITE; - DrawProp[LayerIndex].pFont = &Font24; - DrawProp[LayerIndex].TextColor = LCD_COLOR_BLACK; - - /* Dithering activation */ - HAL_LTDC_EnableDither(&LtdcHandler); -} - -/** - * @brief Selects the LCD Layer. - * @param LayerIndex: the Layer foreground or background. - * @retval None - */ -void BSP_LCD_SelectLayer(uint32_t LayerIndex) -{ - ActiveLayer = LayerIndex; -} - -/** - * @brief Sets a LCD Layer visible. - * @param LayerIndex: the visible Layer. - * @param state: new state of the specified layer. - * This parameter can be: ENABLE or DISABLE. - * @retval None - */ -void BSP_LCD_SetLayerVisible(uint32_t LayerIndex, FunctionalState state) -{ - if(state == ENABLE) - { - __HAL_LTDC_LAYER_ENABLE(&LtdcHandler, LayerIndex); - } - else - { - __HAL_LTDC_LAYER_DISABLE(&LtdcHandler, LayerIndex); - } - __HAL_LTDC_RELOAD_CONFIG(&LtdcHandler); -} - -/** - * @brief Configures the Transparency. - * @param LayerIndex: the Layer foreground or background. - * @param Transparency: the Transparency, - * This parameter must range from 0x00 to 0xFF. - * @retval None - */ -void BSP_LCD_SetTransparency(uint32_t LayerIndex, uint8_t Transparency) -{ - HAL_LTDC_SetAlpha(&LtdcHandler, Transparency, LayerIndex); -} - -/** - * @brief Sets a LCD layer frame buffer address. - * @param LayerIndex: specifies the Layer foreground or background - * @param Address: new LCD frame buffer value - * @retval None - */ -void BSP_LCD_SetLayerAddress(uint32_t LayerIndex, uint32_t Address) -{ - HAL_LTDC_SetAddress(&LtdcHandler, Address, LayerIndex); -} - -/** - * @brief Sets the Display window. - * @param LayerIndex: layer index - * @param Xpos: LCD X position - * @param Ypos: LCD Y position - * @param Width: LCD window width - * @param Height: LCD window height - * @retval None - */ -void BSP_LCD_SetLayerWindow(uint16_t LayerIndex, uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height) -{ - /* reconfigure the layer size */ - HAL_LTDC_SetWindowSize(&LtdcHandler, Width, Height, LayerIndex); - - /* reconfigure the layer position */ - HAL_LTDC_SetWindowPosition(&LtdcHandler, Xpos, Ypos, LayerIndex); -} - -/** - * @brief Configures and sets the color Keying. - * @param LayerIndex: the Layer foreground or background - * @param RGBValue: the Color reference - * @retval None - */ -void BSP_LCD_SetColorKeying(uint32_t LayerIndex, uint32_t RGBValue) -{ - /* Configure and Enable the color Keying for LCD Layer */ - HAL_LTDC_ConfigColorKeying(&LtdcHandler, RGBValue, LayerIndex); - HAL_LTDC_EnableColorKeying(&LtdcHandler, LayerIndex); -} - -/** - * @brief Disables the color Keying. - * @param LayerIndex: the Layer foreground or background - * @retval None - */ -void BSP_LCD_ResetColorKeying(uint32_t LayerIndex) -{ - /* Disable the color Keying for LCD Layer */ - HAL_LTDC_DisableColorKeying(&LtdcHandler, LayerIndex); -} - -/** - * @brief Gets the LCD Text color. - * @param None - * @retval Text color - */ -uint32_t BSP_LCD_GetTextColor(void) -{ - return DrawProp[ActiveLayer].TextColor; -} - -/** - * @brief Gets the LCD Background color. - * @param None - * @retval Background color - */ -uint32_t BSP_LCD_GetBackColor(void) -{ - return DrawProp[ActiveLayer].BackColor; -} - -/** - * @brief Sets the Text color. - * @param Color: the Text color code ARGB(8-8-8-8) - * @retval None - */ -void BSP_LCD_SetTextColor(uint32_t Color) -{ - DrawProp[ActiveLayer].TextColor = Color; -} - -/** - * @brief Sets the Background color. - * @param Color: the layer Background color code ARGB(8-8-8-8) - * @retval None - */ -void BSP_LCD_SetBackColor(uint32_t Color) -{ - DrawProp[ActiveLayer].BackColor = Color; -} - -/** - * @brief Sets the Text Font. - * @param pFonts: the layer font to be used - * @retval None - */ -void BSP_LCD_SetFont(sFONT *pFonts) -{ - DrawProp[ActiveLayer].pFont = pFonts; -} - -/** - * @brief Gets the Text Font. - * @param None - * @retval Layer font - */ -sFONT *BSP_LCD_GetFont(void) -{ - return DrawProp[ActiveLayer].pFont; -} - -/** - * @brief Reads Pixel. - * @param Xpos: the X position - * @param Ypos: the Y position - * @retval RGB pixel color - */ -uint32_t BSP_LCD_ReadPixel(uint16_t Xpos, uint16_t Ypos) -{ - uint32_t ret = 0; - - if(LtdcHandler.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_ARGB8888) - { - /* Read data value from SDRAM memory */ - ret = *(__IO uint32_t*) (LtdcHandler.LayerCfg[ActiveLayer].FBStartAdress + (2*(Ypos*BSP_LCD_GetXSize() + Xpos))); - } - else if(LtdcHandler.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_RGB888) - { - /* Read data value from SDRAM memory */ - ret = (*(__IO uint32_t*) (LtdcHandler.LayerCfg[ActiveLayer].FBStartAdress + (2*(Ypos*BSP_LCD_GetXSize() + Xpos))) & 0x00FFFFFF); - } - else if((LtdcHandler.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_RGB565) || \ - (LtdcHandler.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_ARGB4444) || \ - (LtdcHandler.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_AL88)) - { - /* Read data value from SDRAM memory */ - ret = *(__IO uint16_t*) (LtdcHandler.LayerCfg[ActiveLayer].FBStartAdress + (2*(Ypos*BSP_LCD_GetXSize() + Xpos))); - } - else - { - /* Read data value from SDRAM memory */ - ret = *(__IO uint8_t*) (LtdcHandler.LayerCfg[ActiveLayer].FBStartAdress + (2*(Ypos*BSP_LCD_GetXSize() + Xpos))); - } - - return ret; -} - -/** - * @brief Clears the hole LCD. - * @param Color: the color of the background - * @retval None - */ -void BSP_LCD_Clear(uint32_t Color) -{ - /* Clear the LCD */ - FillBuffer(ActiveLayer, (uint32_t *)(LtdcHandler.LayerCfg[ActiveLayer].FBStartAdress), BSP_LCD_GetXSize(), BSP_LCD_GetYSize(), 0, Color); -} - -/** - * @brief Clears the selected line. - * @param Line: the line to be cleared - * @retval None - */ -void BSP_LCD_ClearStringLine(uint32_t Line) -{ - uint32_t colorbackup = DrawProp[ActiveLayer].TextColor; - DrawProp[ActiveLayer].TextColor = DrawProp[ActiveLayer].BackColor; - - /* Draw rectangle with background color */ - BSP_LCD_FillRect(0, (Line * DrawProp[ActiveLayer].pFont->Height), BSP_LCD_GetXSize(), DrawProp[ActiveLayer].pFont->Height); - - DrawProp[ActiveLayer].TextColor = colorbackup; - BSP_LCD_SetTextColor(DrawProp[ActiveLayer].TextColor); -} - -/** - * @brief Displays one character. - * @param Xpos: start column address - * @param Ypos: the Line where to display the character shape - * @param Ascii: character ascii code, must be between 0x20 and 0x7E - * @retval None - */ -void BSP_LCD_DisplayChar(uint16_t Xpos, uint16_t Ypos, uint8_t Ascii) -{ - DrawChar(Xpos, Ypos, &DrawProp[ActiveLayer].pFont->table[(Ascii-' ') *\ - DrawProp[ActiveLayer].pFont->Height * ((DrawProp[ActiveLayer].pFont->Width + 7) / 8)]); -} - -/** - * @brief Displays a maximum of 60 char on the LCD. - * @param X: pointer to x position (in pixel) - * @param Y: pointer to y position (in pixel) - * @param pText: pointer to string to display on LCD - * @param mode: The display mode - * This parameter can be one of the following values: - * @arg CENTER_MODE - * @arg RIGHT_MODE - * @arg LEFT_MODE - * @retval None - */ -void BSP_LCD_DisplayStringAt(uint16_t X, uint16_t Y, uint8_t *pText, Text_AlignModeTypdef mode) -{ - uint16_t refcolumn = 1, i = 0; - uint32_t size = 0, xsize = 0; - uint8_t *ptr = pText; - - /* Get the text size */ - while (*ptr++) size ++ ; - - /* Characters number per line */ - xsize = (BSP_LCD_GetXSize()/DrawProp[ActiveLayer].pFont->Width); - - switch (mode) - { - case CENTER_MODE: - { - refcolumn = X+ ((xsize - size)* DrawProp[ActiveLayer].pFont->Width) / 2; - break; - } - case LEFT_MODE: - { - refcolumn = X; - break; - } - case RIGHT_MODE: - { - refcolumn = X + ((xsize - size)*DrawProp[ActiveLayer].pFont->Width); - break; - } - default: - { - refcolumn = X; - break; - } - } - - /* Send the string character by character on LCD */ - while ((*pText != 0) & (((BSP_LCD_GetXSize() - (i*DrawProp[ActiveLayer].pFont->Width)) & 0xFFFF) >= DrawProp[ActiveLayer].pFont->Width)) - { - /* Display one character on LCD */ - BSP_LCD_DisplayChar(refcolumn, Y, *pText); - /* Decrement the column position by 16 */ - refcolumn += DrawProp[ActiveLayer].pFont->Width; - /* Point on the next character */ - pText++; - i++; - } -} - -/** - * @brief Displays a maximum of 20 char on the LCD. - * @param Line: the Line where to display the character shape - * @param ptr: pointer to string to display on LCD - * @retval None - */ -void BSP_LCD_DisplayStringAtLine(uint16_t Line, uint8_t *ptr) -{ - BSP_LCD_DisplayStringAt(0, LINE(Line), ptr, LEFT_MODE); -} - -/** - * @brief Displays an horizontal line. - * @param Xpos: the X position - * @param Ypos: the Y position - * @param Length: line length - * @retval None - */ -void BSP_LCD_DrawHLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length) -{ - uint32_t xaddress = 0; - - /* Get the line address */ - xaddress = (LtdcHandler.LayerCfg[ActiveLayer].FBStartAdress) + 4*(BSP_LCD_GetXSize()*Ypos + Xpos); - - /* Write line */ - FillBuffer(ActiveLayer, (uint32_t *)xaddress, Length, 1, 0, DrawProp[ActiveLayer].TextColor); -} - -/** - * @brief Displays a vertical line. - * @param Xpos: the X position - * @param Ypos: the Y position - * @param Length: line length - * @retval None - */ -void BSP_LCD_DrawVLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length) -{ - uint32_t xaddress = 0; - - /* Get the line address */ - xaddress = (LtdcHandler.LayerCfg[ActiveLayer].FBStartAdress) + 4*(BSP_LCD_GetXSize()*Ypos + Xpos); - - /* Write line */ - FillBuffer(ActiveLayer, (uint32_t *)xaddress, 1, Length, (BSP_LCD_GetXSize() - 1), DrawProp[ActiveLayer].TextColor); -} - -/** - * @brief Displays an uni-line (between two points). - * @param X1: the point 1 X position - * @param Y1: the point 1 Y position - * @param X2: the point 2 X position - * @param Y2: the point 2 Y position - * @retval None - */ -void BSP_LCD_DrawLine(uint16_t X1, uint16_t Y1, uint16_t X2, uint16_t Y2) -{ - int16_t deltax = 0, deltay = 0, x = 0, y = 0, xinc1 = 0, xinc2 = 0, - yinc1 = 0, yinc2 = 0, den = 0, num = 0, numadd = 0, numpixels = 0, - curpixel = 0; - - deltax = ABS(X2 - X1); /* The difference between the x's */ - deltay = ABS(Y2 - Y1); /* The difference between the y's */ - x = X1; /* Start x off at the first pixel */ - y = Y1; /* Start y off at the first pixel */ - - if (X2 >= X1) /* The x-values are increasing */ - { - xinc1 = 1; - xinc2 = 1; - } - else /* The x-values are decreasing */ - { - xinc1 = -1; - xinc2 = -1; - } - - if (Y2 >= Y1) /* The y-values are increasing */ - { - yinc1 = 1; - yinc2 = 1; - } - else /* The y-values are decreasing */ - { - yinc1 = -1; - yinc2 = -1; - } - - if (deltax >= deltay) /* There is at least one x-value for every y-value */ - { - xinc1 = 0; /* Don't change the x when numerator >= denominator */ - yinc2 = 0; /* Don't change the y for every iteration */ - den = deltax; - num = deltax / 2; - numadd = deltay; - numpixels = deltax; /* There are more x-values than y-values */ - } - else /* There is at least one y-value for every x-value */ - { - xinc2 = 0; /* Don't change the x for every iteration */ - yinc1 = 0; /* Don't change the y when numerator >= denominator */ - den = deltay; - num = deltay / 2; - numadd = deltax; - numpixels = deltay; /* There are more y-values than x-values */ - } - - for (curpixel = 0; curpixel <= numpixels; curpixel++) - { - BSP_LCD_DrawPixel(x, y, DrawProp[ActiveLayer].TextColor); /* Draw the current pixel */ - num += numadd; /* Increase the numerator by the top of the fraction */ - if (num >= den) /* Check if numerator >= denominator */ - { - num -= den; /* Calculate the new numerator value */ - x += xinc1; /* Change the x as appropriate */ - y += yinc1; /* Change the y as appropriate */ - } - x += xinc2; /* Change the x as appropriate */ - y += yinc2; /* Change the y as appropriate */ - } -} - -/** - * @brief Displays a rectangle. - * @param Xpos: the X position - * @param Ypos: the Y position - * @param Height: display rectangle height - * @param Width: display rectangle width - * @retval None - */ -void BSP_LCD_DrawRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height) -{ - /* Draw horizontal lines */ - BSP_LCD_DrawHLine(Xpos, Ypos, Width); - BSP_LCD_DrawHLine(Xpos, (Ypos+ Height), Width); - - /* Draw vertical lines */ - BSP_LCD_DrawVLine(Xpos, Ypos, Height); - BSP_LCD_DrawVLine((Xpos + Width), Ypos, Height); -} - -/** - * @brief Displays a circle. - * @param Xpos: the X position - * @param Ypos: the Y position - * @param Radius: the circle radius - * @retval None - */ -void BSP_LCD_DrawCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius) -{ - int32_t d;/* Decision Variable */ - uint32_t curx;/* Current X Value */ - uint32_t cury;/* Current Y Value */ - - d = 3 - (Radius << 1); - curx = 0; - cury = Radius; - - while (curx <= cury) - { - BSP_LCD_DrawPixel((Xpos + curx), (Ypos - cury), DrawProp[ActiveLayer].TextColor); - BSP_LCD_DrawPixel((Xpos - curx), (Ypos - cury), DrawProp[ActiveLayer].TextColor); - BSP_LCD_DrawPixel((Xpos + cury), (Ypos - curx), DrawProp[ActiveLayer].TextColor); - BSP_LCD_DrawPixel((Xpos - cury), (Ypos - curx), DrawProp[ActiveLayer].TextColor); - BSP_LCD_DrawPixel((Xpos + curx), (Ypos + cury), DrawProp[ActiveLayer].TextColor); - BSP_LCD_DrawPixel((Xpos - curx), (Ypos + cury), DrawProp[ActiveLayer].TextColor); - BSP_LCD_DrawPixel((Xpos + cury), (Ypos + curx), DrawProp[ActiveLayer].TextColor); - BSP_LCD_DrawPixel((Xpos - cury), (Ypos + curx), DrawProp[ActiveLayer].TextColor); - - if (d < 0) - { - d += (curx << 2) + 6; - } - else - { - d += ((curx - cury) << 2) + 10; - cury--; - } - curx++; - } -} - -/** - * @brief Displays an poly-line (between many points). - * @param Points: pointer to the points array - * @param PointCount: Number of points - * @retval None - */ -void BSP_LCD_DrawPolygon(pPoint Points, uint16_t PointCount) -{ - int16_t x = 0, y = 0; - - if(PointCount < 2) - { - return; - } - - BSP_LCD_DrawLine(Points->X, Points->Y, (Points+PointCount-1)->X, (Points+PointCount-1)->Y); - - while(--PointCount) - { - x = Points->X; - y = Points->Y; - Points++; - BSP_LCD_DrawLine(x, y, Points->X, Points->Y); - } -} - -/** - * @brief Displays an Ellipse. - * @param Xpos: the X position - * @param Ypos: the Y position - * @param XRadius: the X radius of ellipse - * @param YRadius: the Y radius of ellipse - * @retval None - */ -void BSP_LCD_DrawEllipse(int Xpos, int Ypos, int XRadius, int YRadius) -{ - int x = 0, y = -YRadius, err = 2-2*XRadius, e2; - float k = 0, rad1 = 0, rad2 = 0; - - rad1 = XRadius; - rad2 = YRadius; - - k = (float)(rad2/rad1); - - do { - BSP_LCD_DrawPixel((Xpos-(uint16_t)(x/k)), (Ypos+y), DrawProp[ActiveLayer].TextColor); - BSP_LCD_DrawPixel((Xpos+(uint16_t)(x/k)), (Ypos+y), DrawProp[ActiveLayer].TextColor); - BSP_LCD_DrawPixel((Xpos+(uint16_t)(x/k)), (Ypos-y), DrawProp[ActiveLayer].TextColor); - BSP_LCD_DrawPixel((Xpos-(uint16_t)(x/k)), (Ypos-y), DrawProp[ActiveLayer].TextColor); - - e2 = err; - if (e2 <= x) { - err += ++x*2+1; - if (-y == x && e2 <= y) e2 = 0; - } - if (e2 > y) err += ++y*2+1; - } - while (y <= 0); -} - -/** - * @brief Displays a bitmap picture loaded in the internal Flash (32 bpp). - * @param X: the bmp x position in the LCD - * @param Y: the bmp Y position in the LCD - * @param pBmp: Bmp picture address in the internal Flash - * @retval None - */ -void BSP_LCD_DrawBitmap(uint32_t X, uint32_t Y, uint8_t *pBmp) -{ - uint32_t index = 0, width = 0, height = 0, bitpixel = 0; - uint32_t address; - uint32_t inputcolormode = 0; - - /* Get bitmap data address offset */ - index = *(__IO uint16_t *) (pBmp + 10); - index |= (*(__IO uint16_t *) (pBmp + 12)) << 16; - - /* Read bitmap width */ - width = *(uint16_t *) (pBmp + 18); - width |= (*(uint16_t *) (pBmp + 20)) << 16; - - /* Read bitmap height */ - height = *(uint16_t *) (pBmp + 22); - height |= (*(uint16_t *) (pBmp + 24)) << 16; - - /* Read bit/pixel */ - bitpixel = *(uint16_t *) (pBmp + 28); - - /* Set Address */ - address = LtdcHandler.LayerCfg[ActiveLayer].FBStartAdress + (((BSP_LCD_GetXSize()*Y) + X)*(4)); - - /* Get the Layer pixel format */ - if ((bitpixel/8) == 4) - { - inputcolormode = CM_ARGB8888; - } - else if ((bitpixel/8) == 2) - { - inputcolormode = CM_RGB565; - } - else - { - inputcolormode = CM_RGB888; - } - - /* bypass the bitmap header */ - pBmp += (index + (width * (height - 1) * (bitpixel/8))); - - /* Convert picture to ARGB8888 pixel format */ - for(index=0; index < height; index++) - { - /* Pixel format conversion */ - ConvertLineToARGB8888((uint32_t *)pBmp, (uint32_t *)address, width, inputcolormode); - - /* Increment the source and destination buffers */ - address+= ((BSP_LCD_GetXSize() - width + width)*4); - pBmp -= width*(bitpixel/8); - } -} - -/** - * @brief Displays a full rectangle. - * @param Xpos: the X position - * @param Ypos: the Y position - * @param Height: rectangle height - * @param Width: rectangle width - * @retval None - */ -void BSP_LCD_FillRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height) -{ - uint32_t xaddress = 0; - - /* Set the text color */ - BSP_LCD_SetTextColor(DrawProp[ActiveLayer].TextColor); - - /* Get the rectangle start address */ - xaddress = (LtdcHandler.LayerCfg[ActiveLayer].FBStartAdress) + 4*(BSP_LCD_GetXSize()*Ypos + Xpos); - - /* Fill the rectangle */ - FillBuffer(ActiveLayer, (uint32_t *)xaddress, Width, Height, (BSP_LCD_GetXSize() - Width), DrawProp[ActiveLayer].TextColor); -} - -/** - * @brief Displays a full circle. - * @param Xpos: the X position - * @param Ypos: the Y position - * @param Radius: the circle radius - * @retval None - */ -void BSP_LCD_FillCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius) -{ - int32_t d; /* Decision Variable */ - uint32_t curx;/* Current X Value */ - uint32_t cury;/* Current Y Value */ - - d = 3 - (Radius << 1); - - curx = 0; - cury = Radius; - - BSP_LCD_SetTextColor(DrawProp[ActiveLayer].TextColor); - - while (curx <= cury) - { - if(cury > 0) - { - BSP_LCD_DrawHLine(Xpos - cury, Ypos + curx, 2*cury); - BSP_LCD_DrawHLine(Xpos - cury, Ypos - curx, 2*cury); - } - - if(curx > 0) - { - BSP_LCD_DrawHLine(Xpos - curx, Ypos - cury, 2*curx); - BSP_LCD_DrawHLine(Xpos - curx, Ypos + cury, 2*curx); - } - if (d < 0) - { - d += (curx << 2) + 6; - } - else - { - d += ((curx - cury) << 2) + 10; - cury--; - } - curx++; - } - - BSP_LCD_SetTextColor(DrawProp[ActiveLayer].TextColor); - BSP_LCD_DrawCircle(Xpos, Ypos, Radius); -} - -/** - * @brief Fill triangle. - * @param X1: the point 1 x position - * @param Y1: the point 1 y position - * @param X2: the point 2 x position - * @param Y2: the point 2 y position - * @param X3: the point 3 x position - * @param Y3: the point 3 y position - * @retval None - */ -void BSP_LCD_FillTriangle(uint16_t X1, uint16_t X2, uint16_t X3, uint16_t Y1, uint16_t Y2, uint16_t Y3) -{ - int16_t deltax = 0, deltay = 0, x = 0, y = 0, xinc1 = 0, xinc2 = 0, - yinc1 = 0, yinc2 = 0, den = 0, num = 0, numadd = 0, numpixels = 0, - curpixel = 0; - - deltax = ABS(X2 - X1); /* The difference between the x's */ - deltay = ABS(Y2 - Y1); /* The difference between the y's */ - x = X1; /* Start x off at the first pixel */ - y = Y1; /* Start y off at the first pixel */ - - if (X2 >= X1) /* The x-values are increasing */ - { - xinc1 = 1; - xinc2 = 1; - } - else /* The x-values are decreasing */ - { - xinc1 = -1; - xinc2 = -1; - } - - if (Y2 >= Y1) /* The y-values are increasing */ - { - yinc1 = 1; - yinc2 = 1; - } - else /* The y-values are decreasing */ - { - yinc1 = -1; - yinc2 = -1; - } - - if (deltax >= deltay) /* There is at least one x-value for every y-value */ - { - xinc1 = 0; /* Don't change the x when numerator >= denominator */ - yinc2 = 0; /* Don't change the y for every iteration */ - den = deltax; - num = deltax / 2; - numadd = deltay; - numpixels = deltax; /* There are more x-values than y-values */ - } - else /* There is at least one y-value for every x-value */ - { - xinc2 = 0; /* Don't change the x for every iteration */ - yinc1 = 0; /* Don't change the y when numerator >= denominator */ - den = deltay; - num = deltay / 2; - numadd = deltax; - numpixels = deltay; /* There are more y-values than x-values */ - } - - for (curpixel = 0; curpixel <= numpixels; curpixel++) - { - BSP_LCD_DrawLine(x, y, X3, Y3); - - num += numadd; /* Increase the numerator by the top of the fraction */ - if (num >= den) /* Check if numerator >= denominator */ - { - num -= den; /* Calculate the new numerator value */ - x += xinc1; /* Change the x as appropriate */ - y += yinc1; /* Change the y as appropriate */ - } - x += xinc2; /* Change the x as appropriate */ - y += yinc2; /* Change the y as appropriate */ - } -} - -/** - * @brief Displays a full poly-line (between many points). - * @param Points: pointer to the points array - * @param PointCount: Number of points - * @retval None - */ -void BSP_LCD_FillPolygon(pPoint Points, uint16_t PointCount) -{ - - int16_t x = 0, y = 0, x2 = 0, y2 = 0, xcenter = 0, ycenter = 0, xfirst = 0, yfirst = 0, pixelx = 0, pixely = 0, counter = 0; - uint16_t imageleft = 0, imageright = 0, imagetop = 0, imagebottom = 0; - - imageleft = imageright = Points->X; - imagetop= imagebottom = Points->Y; - - for(counter = 1; counter < PointCount; counter++) - { - pixelx = POLY_X(counter); - if(pixelx < imageleft) - { - imageleft = pixelx; - } - if(pixelx > imageright) - { - imageright = pixelx; - } - - pixely = POLY_Y(counter); - if(pixely < imagetop) - { - imagetop = pixely; - } - if(pixely > imagebottom) - { - imagebottom = pixely; - } - } - - if(PointCount < 2) - { - return; - } - - xcenter = (imageleft + imageright)/2; - ycenter = (imagebottom + imagetop)/2; - - xfirst = Points->X; - yfirst = Points->Y; - - while(--PointCount) - { - x = Points->X; - y = Points->Y; - Points++; - x2 = Points->X; - y2 = Points->Y; - - BSP_LCD_FillTriangle(x, x2, xcenter, y, y2, ycenter); - BSP_LCD_FillTriangle(x, xcenter, x2, y, ycenter, y2); - BSP_LCD_FillTriangle(xcenter, x2, x, ycenter, y2, y); - } - - BSP_LCD_FillTriangle(xfirst, x2, xcenter, yfirst, y2, ycenter); - BSP_LCD_FillTriangle(xfirst, xcenter, x2, yfirst, ycenter, y2); - BSP_LCD_FillTriangle(xcenter, x2, xfirst, ycenter, y2, yfirst); -} - -/** - * @brief Draw a full ellipse. - * @param Xpos: the X position - * @param Ypos: the Y position - * @param XRadius: X radius of ellipse - * @param YRadius: Y radius of ellipse. - * @retval None - */ -void BSP_LCD_FillEllipse(int Xpos, int Ypos, int XRadius, int YRadius) -{ - int x = 0, y = -YRadius, err = 2-2*XRadius, e2; - float K = 0, rad1 = 0, rad2 = 0; - - rad1 = XRadius; - rad2 = YRadius; - K = (float)(rad2/rad1); - - do - { - BSP_LCD_DrawHLine((Xpos-(uint16_t)(x/K)), (Ypos+y), (2*(uint16_t)(x/K) + 1)); - BSP_LCD_DrawHLine((Xpos-(uint16_t)(x/K)), (Ypos-y), (2*(uint16_t)(x/K) + 1)); - - e2 = err; - if (e2 <= x) - { - err += ++x*2+1; - if (-y == x && e2 <= y) e2 = 0; - } - if (e2 > y) err += ++y*2+1; - } - while (y <= 0); -} - -/** - * @brief Enables the Display. - * @param None - * @retval None - */ -void BSP_LCD_DisplayOn(void) -{ - if(LcdDrv->DisplayOn != NULL) - { - LcdDrv->DisplayOn(); - } -} - -/** - * @brief Disables the Display. - * @param None - * @retval None - */ -void BSP_LCD_DisplayOff(void) -{ - if(LcdDrv->DisplayOff != NULL) - { - LcdDrv->DisplayOff(); - } -} - -/******************************************************************************* - LTDC and DMA2D BSP Routines -*******************************************************************************/ - -/** - * @brief Initializes the LTDC MSP. - * @param None - * @retval None - */ -static void MspInit(void) -{ - GPIO_InitTypeDef GPIO_InitStructure; - - /* Enable the LTDC and DMA2D Clock */ - __LTDC_CLK_ENABLE(); - __DMA2D_CLK_ENABLE(); - - /* Enable GPIOs clock */ - __GPIOA_CLK_ENABLE(); - __GPIOB_CLK_ENABLE(); - __GPIOC_CLK_ENABLE(); - __GPIOD_CLK_ENABLE(); - __GPIOF_CLK_ENABLE(); - __GPIOG_CLK_ENABLE(); - - /* GPIOs Configuration */ - /* - +------------------------+-----------------------+----------------------------+ - + LCD pins assignment + - +------------------------+-----------------------+----------------------------+ - | LCD_TFT R2 <-> PC.10 | LCD_TFT G2 <-> PA.06 | LCD_TFT B2 <-> PD.06 | - | LCD_TFT R3 <-> PB.00 | LCD_TFT G3 <-> PG.10 | LCD_TFT B3 <-> PG.11 | - | LCD_TFT R4 <-> PA.11 | LCD_TFT G4 <-> PB.10 | LCD_TFT B4 <-> PG.12 | - | LCD_TFT R5 <-> PA.12 | LCD_TFT G5 <-> PB.11 | LCD_TFT B5 <-> PA.03 | - | LCD_TFT R6 <-> PB.01 | LCD_TFT G6 <-> PC.07 | LCD_TFT B6 <-> PB.08 | - | LCD_TFT R7 <-> PG.06 | LCD_TFT G7 <-> PD.03 | LCD_TFT B7 <-> PB.09 | - ------------------------------------------------------------------------------- - | LCD_TFT HSYNC <-> PC.06 | LCDTFT VSYNC <-> PA.04 | - | LCD_TFT CLK <-> PG.07 | LCD_TFT DE <-> PF.10 | - ----------------------------------------------------- - */ - - /* GPIOA configuration */ - GPIO_InitStructure.Pin = GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_6 | - GPIO_PIN_11 | GPIO_PIN_12; - GPIO_InitStructure.Mode = GPIO_MODE_AF_PP; - GPIO_InitStructure.Pull = GPIO_NOPULL; - GPIO_InitStructure.Speed = GPIO_SPEED_FAST; - GPIO_InitStructure.Alternate= GPIO_AF14_LTDC; - HAL_GPIO_Init(GPIOA, &GPIO_InitStructure); - - /* GPIOB configuration */ - GPIO_InitStructure.Pin = GPIO_PIN_8 | \ - GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11; - HAL_GPIO_Init(GPIOB, &GPIO_InitStructure); - - /* GPIOC configuration */ - GPIO_InitStructure.Pin = GPIO_PIN_6 | GPIO_PIN_7 | GPIO_PIN_10; - HAL_GPIO_Init(GPIOC, &GPIO_InitStructure); - - /* GPIOD configuration */ - GPIO_InitStructure.Pin = GPIO_PIN_3 | GPIO_PIN_6; - HAL_GPIO_Init(GPIOD, &GPIO_InitStructure); - - /* GPIOF configuration */ - GPIO_InitStructure.Pin = GPIO_PIN_10; - HAL_GPIO_Init(GPIOF, &GPIO_InitStructure); - - /* GPIOG configuration */ - GPIO_InitStructure.Pin = GPIO_PIN_6 | GPIO_PIN_7 | \ - GPIO_PIN_11; - HAL_GPIO_Init(GPIOG, &GPIO_InitStructure); - - /* GPIOB configuration */ - GPIO_InitStructure.Pin = GPIO_PIN_0 | GPIO_PIN_1; - GPIO_InitStructure.Alternate= GPIO_AF9_LTDC; - HAL_GPIO_Init(GPIOB, &GPIO_InitStructure); - - /* GPIOG configuration */ - GPIO_InitStructure.Pin = GPIO_PIN_10 | GPIO_PIN_12; - HAL_GPIO_Init(GPIOG, &GPIO_InitStructure); -} - -/******************************************************************************* - Static Functions -*******************************************************************************/ - -/** - * @brief Writes Pixel. - * @param Xpos: the X position - * @param Ypos: the Y position - * @param RGB_Code: the pixel color in ARGB mode (8-8-8-8) - * @retval None - */ -void BSP_LCD_DrawPixel(uint16_t Xpos, uint16_t Ypos, uint32_t RGB_Code) -{ - /* Write data value to all SDRAM memory */ - *(__IO uint32_t*) (LtdcHandler.LayerCfg[ActiveLayer].FBStartAdress + (4*(Ypos*BSP_LCD_GetXSize() + Xpos))) = RGB_Code; -} - -/** - * @brief Draws a character on LCD. - * @param Xpos: the Line where to display the character shape - * @param Ypos: start column address - * @param c: pointer to the character data - * @retval None - */ -static void DrawChar(uint16_t Xpos, uint16_t Ypos, const uint8_t *c) -{ - uint32_t i = 0, j = 0; - uint16_t height, width; - uint8_t offset; - uint8_t *pchar; - uint32_t line=0; - - height = DrawProp[ActiveLayer].pFont->Height; - width = DrawProp[ActiveLayer].pFont->Width; - - offset = 8 *((width + 7)/8) - width ; - - for(i = 0; i < height; i++) - { - pchar = ((uint8_t *)c + (width + 7)/8 * i); - - switch(((width + 7)/8)) - { - case 1: - line = pchar[0]; - break; - - case 2: - line = (pchar[0]<< 8) | pchar[1]; - break; - - case 3: - default: - line = (pchar[0]<< 16) | (pchar[1]<< 8) | pchar[2]; - break; - } - - for (j = 0; j < width; j++) - { - if(line & (1 << (width- j + offset- 1))) - { - BSP_LCD_DrawPixel((Xpos + j), Ypos, DrawProp[ActiveLayer].TextColor); - } - else - { - BSP_LCD_DrawPixel((Xpos + j), Ypos, DrawProp[ActiveLayer].BackColor); - } - } - Ypos++; - } -} - -/** - * @brief Fills buffer. - * @param LayerIndex: layer index - * @param pDst: output color - * @param xSize: buffer width - * @param ySize: buffer height - * @param OffLine: offset - * @param ColorIndex: color Index - * @retval None - */ -static void FillBuffer(uint32_t LayerIndex, void * pDst, uint32_t xSize, uint32_t ySize, uint32_t OffLine, uint32_t ColorIndex) -{ - - /* Register to memory mode with ARGB8888 as color Mode */ - Dma2dHandler.Init.Mode = DMA2D_R2M; - Dma2dHandler.Init.ColorMode = DMA2D_ARGB8888; - Dma2dHandler.Init.OutputOffset = OffLine; - - Dma2dHandler.Instance = DMA2D; - - /* DMA2D Initialization */ - if(HAL_DMA2D_Init(&Dma2dHandler) == HAL_OK) - { - if(HAL_DMA2D_ConfigLayer(&Dma2dHandler, LayerIndex) == HAL_OK) - { - if (HAL_DMA2D_Start(&Dma2dHandler, ColorIndex, (uint32_t)pDst, xSize, ySize) == HAL_OK) - { - /* Polling For DMA transfer */ - HAL_DMA2D_PollForTransfer(&Dma2dHandler, 10); - } - } - } -} - -/** - * @brief Converts Line to ARGB8888 pixel format. - * @param pSrc: pointer to source buffer - * @param pDst: output color - * @param xSize: buffer width - * @param ColorMode: input color mode - * @retval None - */ -static void ConvertLineToARGB8888(void * pSrc, void * pDst, uint32_t xSize, uint32_t ColorMode) -{ - /* Configure the DMA2D Mode, Color Mode and output offset */ - Dma2dHandler.Init.Mode = DMA2D_M2M_PFC; - Dma2dHandler.Init.ColorMode = DMA2D_ARGB8888; - Dma2dHandler.Init.OutputOffset = 0; - - /* Foreground Configuration */ - Dma2dHandler.LayerCfg[1].AlphaMode = DMA2D_NO_MODIF_ALPHA; - Dma2dHandler.LayerCfg[1].InputAlpha = 0xFF; - Dma2dHandler.LayerCfg[1].InputColorMode = ColorMode; - Dma2dHandler.LayerCfg[1].InputOffset = 0; - - Dma2dHandler.Instance = DMA2D; - - /* DMA2D Initialization */ - if(HAL_DMA2D_Init(&Dma2dHandler) == HAL_OK) - { - if(HAL_DMA2D_ConfigLayer(&Dma2dHandler, 1) == HAL_OK) - { - if (HAL_DMA2D_Start(&Dma2dHandler, (uint32_t)pSrc, (uint32_t)pDst, xSize, 1) == HAL_OK) - { - /* Polling For DMA transfer */ - HAL_DMA2D_PollForTransfer(&Dma2dHandler, 10); - } - } - } -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32F429I-Discovery/stm32f429i_discovery_lcd.h b/bsp/stm32f411RE/Libraries/BSP/STM32F429I-Discovery/stm32f429i_discovery_lcd.h deleted file mode 100644 index f8357666ba..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32F429I-Discovery/stm32f429i_discovery_lcd.h +++ /dev/null @@ -1,249 +0,0 @@ -/** - ****************************************************************************** - * @file stm32f429i_discovery_lcd.h - * @author MCD Application Team - * @version V2.1.2 - * @date 02-March-2015 - * @brief This file contains all the functions prototypes for the - * stm32f429i_discovery_lcd.c driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32F429I_DISCOVERY_LCD_H -#define __STM32F429I_DISCOVERY_LCD_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm32f429i_discovery.h" -/* Include SDRAM Driver */ -#include "stm32f429i_discovery_sdram.h" -#include "../../../Utilities/Fonts/fonts.h" -/* Include LCD component driver */ -#include "../Components/ili9341/ili9341.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32F429I_DISCOVERY - * @{ - */ - -/** @defgroup STM32F429I_DISCOVERY_LCD - * @{ - */ - -/** @defgroup STM32F429I_DISCOVERY_LCD_Exported_Types - * @{ - */ -typedef enum -{ - LCD_OK = 0, - LCD_ERROR = 1, - LCD_TIMEOUT = 2 -}LCD_StatusTypeDef; - -typedef struct -{ - uint32_t TextColor; - uint32_t BackColor; - sFONT *pFont; -}LCD_DrawPropTypeDef; - -typedef struct -{ - int16_t X; - int16_t Y; -} Point, * pPoint; - -/** - * @brief Line mode structures definition - */ -typedef enum -{ - CENTER_MODE = 0x01, /* center mode */ - RIGHT_MODE = 0x02, /* right mode */ - LEFT_MODE = 0x03, /* left mode */ -}Text_AlignModeTypdef; -/** - * @} - */ - -/** @defgroup STM32F429I_DISCOVERY_LCD_Exported_Constants - * @{ - */ -#define LCD_LayerCfgTypeDef LTDC_LayerCfgTypeDef - -/** - * @brief LCD status structure definition - */ -#define MAX_LAYER_NUMBER 2 -#define LCD_FRAME_BUFFER ((uint32_t)0xD0000000) -#define BUFFER_OFFSET ((uint32_t)0x50000) - -/** - * @brief LCD color - */ -#define LCD_COLOR_BLUE 0xFF0000FF -#define LCD_COLOR_GREEN 0xFF00FF00 -#define LCD_COLOR_RED 0xFFFF0000 -#define LCD_COLOR_CYAN 0xFF00FFFF -#define LCD_COLOR_MAGENTA 0xFFFF00FF -#define LCD_COLOR_YELLOW 0xFFFFFF00 -#define LCD_COLOR_LIGHTBLUE 0xFF8080FF -#define LCD_COLOR_LIGHTGREEN 0xFF80FF80 -#define LCD_COLOR_LIGHTRED 0xFFFF8080 -#define LCD_COLOR_LIGHTCYAN 0xFF80FFFF -#define LCD_COLOR_LIGHTMAGENTA 0xFFFF80FF -#define LCD_COLOR_LIGHTYELLOW 0xFFFFFF80 -#define LCD_COLOR_DARKBLUE 0xFF000080 -#define LCD_COLOR_DARKGREEN 0xFF008000 -#define LCD_COLOR_DARKRED 0xFF800000 -#define LCD_COLOR_DARKCYAN 0xFF008080 -#define LCD_COLOR_DARKMAGENTA 0xFF800080 -#define LCD_COLOR_DARKYELLOW 0xFF808000 -#define LCD_COLOR_WHITE 0xFFFFFFFF -#define LCD_COLOR_LIGHTGRAY 0xFFD3D3D3 -#define LCD_COLOR_GRAY 0xFF808080 -#define LCD_COLOR_DARKGRAY 0xFF404040 -#define LCD_COLOR_BLACK 0xFF000000 -#define LCD_COLOR_BROWN 0xFFA52A2A -#define LCD_COLOR_ORANGE 0xFFFFA500 -#define LCD_COLOR_TRANSPARENT 0xFF000000 -/** - * @brief LCD default font - */ -#define LCD_DEFAULT_FONT Font24 - -/** - * @brief LCD Layer - */ -#define LCD_BACKGROUND_LAYER 0x0000 -#define LCD_FOREGROUND_LAYER 0x0001 - -/** - * @} - */ - -/** @defgroup STM32F429I_DISCOVERY_LCD_Exported_Macros - * @{ - */ -/** - * @brief LCD Pixel format - */ -#define LCD_PIXEL_FORMAT_ARGB8888 LTDC_PIXEL_FORMAT_ARGB8888 -#define LCD_PIXEL_FORMAT_RGB888 LTDC_PIXEL_FORMAT_RGB888 -#define LCD_PIXEL_FORMAT_RGB565 LTDC_PIXEL_FORMAT_RGB565 -#define LCD_PIXEL_FORMAT_ARGB1555 LTDC_PIXEL_FORMAT_ARGB1555 -#define LCD_PIXEL_FORMAT_ARGB4444 LTDC_PIXEL_FORMAT_ARGB4444 -#define LCD_PIXEL_FORMAT_L8 LTDC_PIXEL_FORMAT_L8 -#define LCD_PIXEL_FORMAT_AL44 LTDC_PIXEL_FORMAT_AL44 -#define LCD_PIXEL_FORMAT_AL88 LTDC_PIXEL_FORMAT_AL88 -/** - * @} - */ - -/** @defgroup STM32F429I_DISCOVERY_LCD_Exported_Functions - * @{ - */ -uint8_t BSP_LCD_Init(void); -uint32_t BSP_LCD_GetXSize(void); -uint32_t BSP_LCD_GetYSize(void); - -/* functions using the LTDC controller */ -void BSP_LCD_LayerDefaultInit(uint16_t LayerIndex, uint32_t FrameBuffer); -void BSP_LCD_SetTransparency(uint32_t LayerIndex, uint8_t Transparency); -void BSP_LCD_SetLayerAddress(uint32_t LayerIndex, uint32_t Address); -void BSP_LCD_SetColorKeying(uint32_t LayerIndex, uint32_t RGBValue); -void BSP_LCD_ResetColorKeying(uint32_t LayerIndex); -void BSP_LCD_SetLayerWindow(uint16_t LayerIndex, uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height); -void BSP_LCD_SelectLayer(uint32_t LayerIndex); -void BSP_LCD_SetLayerVisible(uint32_t LayerIndex, FunctionalState state); - -void BSP_LCD_SetTextColor(uint32_t Color); -void BSP_LCD_SetBackColor(uint32_t Color); -uint32_t BSP_LCD_GetTextColor(void); -uint32_t BSP_LCD_GetBackColor(void); -void BSP_LCD_SetFont(sFONT *pFonts); -sFONT *BSP_LCD_GetFont(void); - -uint32_t BSP_LCD_ReadPixel(uint16_t Xpos, uint16_t Ypos); -void BSP_LCD_DrawPixel(uint16_t Xpos, uint16_t Ypos, uint32_t pixel); -void BSP_LCD_Clear(uint32_t Color); -void BSP_LCD_ClearStringLine(uint32_t Line); -void BSP_LCD_DisplayStringAtLine(uint16_t Line, uint8_t *ptr); -void BSP_LCD_DisplayStringAt(uint16_t X, uint16_t Y, uint8_t *pText, Text_AlignModeTypdef mode); -void BSP_LCD_DisplayChar(uint16_t Xpos, uint16_t Ypos, uint8_t Ascii); - -void BSP_LCD_DrawHLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length); -void BSP_LCD_DrawVLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length); -void BSP_LCD_DrawLine(uint16_t X1, uint16_t Y1, uint16_t X2, uint16_t Y2); -void BSP_LCD_DrawRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height); -void BSP_LCD_DrawCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius); -void BSP_LCD_DrawPolygon(pPoint Points, uint16_t PointCount); -void BSP_LCD_DrawEllipse(int Xpos, int Ypos, int XRadius, int YRadius); -void BSP_LCD_DrawBitmap(uint32_t X, uint32_t Y, uint8_t *pBmp); - -void BSP_LCD_FillRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height); -void BSP_LCD_FillCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius); -void BSP_LCD_FillTriangle(uint16_t X1, uint16_t X2, uint16_t X3, uint16_t Y1, uint16_t Y2, uint16_t Y3); -void BSP_LCD_FillPolygon(pPoint Points, uint16_t PointCount); -void BSP_LCD_FillEllipse(int Xpos, int Ypos, int XRadius, int YRadius); - -void BSP_LCD_DisplayOff(void); -void BSP_LCD_DisplayOn(void); - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32F429I_DISCOVERY_LCD_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32F429I-Discovery/stm32f429i_discovery_sdram.c b/bsp/stm32f411RE/Libraries/BSP/STM32F429I-Discovery/stm32f429i_discovery_sdram.c deleted file mode 100644 index 6b074dfb3e..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32F429I-Discovery/stm32f429i_discovery_sdram.c +++ /dev/null @@ -1,413 +0,0 @@ -/** - ****************************************************************************** - * @file stm32f429i_discovery_sdram.c - * @author MCD Application Team - * @version V2.1.2 - * @date 02-March-2015 - * @brief This file provides a set of functions needed to drive the - * IS42S16400J SDRAM memory mounted on STM32F429I-Discovery Kit. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Includes ------------------------------------------------------------------*/ -#include "stm32f429i_discovery_sdram.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32F429I_DISCOVERY - * @{ - */ - -/** @defgroup STM32F429I_DISCOVERY_SDRAM - * @{ -*/ - -/** @defgroup STM32F429I_DISCOVERY_SDRAM_Private_Types_Definitions - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F429I_DISCOVERY_SDRAM_Private_Defines - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F429I_DISCOVERY_SDRAM_Private_Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F429I_DISCOVERY_SDRAM_Private_Variables - * @{ - */ -static SDRAM_HandleTypeDef SdramHandle; -static FMC_SDRAM_TimingTypeDef Timing; -static FMC_SDRAM_CommandTypeDef Command; -/** - * @} - */ - -/** @defgroup STM32F429I_DISCOVERY_SDRAM_Private_Function_Prototypes - * @{ - */ -static void MspInit(void); -/** - * @} - */ - -/** @defgroup STM32F429I_DISCOVERY_SDRAM_Private_Functions - * @{ - */ - -/** - * @brief Initializes the SDRAM device. - * @param None - * @retval None - */ -void BSP_SDRAM_Init(void) -{ - /* SDRAM device configuration */ - SdramHandle.Instance = FMC_SDRAM_DEVICE; - - /* FMC Configuration -------------------------------------------------------*/ - /* FMC SDRAM Bank configuration */ - /* Timing configuration for 90 Mhz of SD clock frequency (180Mhz/2) */ - /* TMRD: 2 Clock cycles */ - Timing.LoadToActiveDelay = 2; - /* TXSR: min=70ns (7x11.11ns) */ - Timing.ExitSelfRefreshDelay = 7; - /* TRAS: min=42ns (4x11.11ns) max=120k (ns) */ - Timing.SelfRefreshTime = 4; - /* TRC: min=70 (7x11.11ns) */ - Timing.RowCycleDelay = 7; - /* TWR: min=1+ 7ns (1+1x11.11ns) */ - Timing.WriteRecoveryTime = 2; - /* TRP: 20ns => 2x11.11ns*/ - Timing.RPDelay = 2; - /* TRCD: 20ns => 2x11.11ns */ - Timing.RCDDelay = 2; - - /* FMC SDRAM control configuration */ - SdramHandle.Init.SDBank = FMC_SDRAM_BANK2; - /* Row addressing: [7:0] */ - SdramHandle.Init.ColumnBitsNumber = FMC_SDRAM_COLUMN_BITS_NUM_8; - /* Column addressing: [11:0] */ - SdramHandle.Init.RowBitsNumber = FMC_SDRAM_ROW_BITS_NUM_12; - SdramHandle.Init.MemoryDataWidth = SDRAM_MEMORY_WIDTH; - SdramHandle.Init.InternalBankNumber = FMC_SDRAM_INTERN_BANKS_NUM_4; - SdramHandle.Init.CASLatency = SDRAM_CAS_LATENCY; - SdramHandle.Init.WriteProtection = FMC_SDRAM_WRITE_PROTECTION_DISABLE; - SdramHandle.Init.SDClockPeriod = SDCLOCK_PERIOD; - SdramHandle.Init.ReadBurst = SDRAM_READBURST; - SdramHandle.Init.ReadPipeDelay = FMC_SDRAM_RPIPE_DELAY_1; - - /* SDRAM controller initialization */ - MspInit(); - HAL_SDRAM_Init(&SdramHandle, &Timing); - - /* SDRAM initialization sequence */ - BSP_SDRAM_Initialization_sequence(REFRESH_COUNT); -} - -/** - * @brief Programs the SDRAM device. - * @param RefreshCount: SDRAM refresh counter value - * @retval None - */ -void BSP_SDRAM_Initialization_sequence(uint32_t RefreshCount) -{ - __IO uint32_t tmpmrd =0; - - /* Step 1: Configure a clock configuration enable command */ - Command.CommandMode = FMC_SDRAM_CMD_CLK_ENABLE; - Command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK2; - Command.AutoRefreshNumber = 1; - Command.ModeRegisterDefinition = 0; - - /* Send the command */ - HAL_SDRAM_SendCommand(&SdramHandle, &Command, SDRAM_TIMEOUT); - - /* Step 2: Insert 100 us minimum delay */ - /* Inserted delay is equal to 1 ms due to systick time base unit (ms) */ - HAL_Delay(1); - - /* Step 3: Configure a PALL (precharge all) command */ - Command.CommandMode = FMC_SDRAM_CMD_PALL; - Command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK2; - Command.AutoRefreshNumber = 1; - Command.ModeRegisterDefinition = 0; - - /* Send the command */ - HAL_SDRAM_SendCommand(&SdramHandle, &Command, SDRAM_TIMEOUT); - - /* Step 4: Configure an Auto Refresh command */ - Command.CommandMode = FMC_SDRAM_CMD_AUTOREFRESH_MODE; - Command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK2; - Command.AutoRefreshNumber = 4; - Command.ModeRegisterDefinition = 0; - - /* Send the command */ - HAL_SDRAM_SendCommand(&SdramHandle, &Command, SDRAM_TIMEOUT); - - /* Step 5: Program the external memory mode register */ - tmpmrd = (uint32_t)SDRAM_MODEREG_BURST_LENGTH_1 | - SDRAM_MODEREG_BURST_TYPE_SEQUENTIAL | - SDRAM_MODEREG_CAS_LATENCY_3 | - SDRAM_MODEREG_OPERATING_MODE_STANDARD | - SDRAM_MODEREG_WRITEBURST_MODE_SINGLE; - - Command.CommandMode = FMC_SDRAM_CMD_LOAD_MODE; - Command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK2; - Command.AutoRefreshNumber = 1; - Command.ModeRegisterDefinition = tmpmrd; - - /* Send the command */ - HAL_SDRAM_SendCommand(&SdramHandle, &Command, SDRAM_TIMEOUT); - - /* Step 6: Set the refresh rate counter */ - /* Set the device refresh rate */ - HAL_SDRAM_ProgramRefreshRate(&SdramHandle, RefreshCount); -} - -/** - * @brief Reads an mount of data from the SDRAM memory in polling mode. - * @param uwStartAddress : Read start address - * @param pData : Pointer to data to be read - * @param uwDataSize: Size of read data from the memory - * @retval None - */ -void BSP_SDRAM_ReadData(uint32_t uwStartAddress, uint32_t *pData, uint32_t uwDataSize) -{ - HAL_SDRAM_Read_32b(&SdramHandle, (uint32_t *)uwStartAddress, pData, uwDataSize); -} - -/** - * @brief Reads an mount of data from the SDRAM memory in DMA mode. - * @param uwStartAddress : Read start address - * @param pData : Pointer to data to be read - * @param uwDataSize: Size of read data from the memory - * @retval None - */ -void BSP_SDRAM_ReadData_DMA(uint32_t uwStartAddress, uint32_t *pData, uint32_t uwDataSize) -{ - HAL_SDRAM_Read_DMA(&SdramHandle, (uint32_t *)uwStartAddress, pData, uwDataSize); -} - -/** - * @brief Writes an mount of data to the SDRAM memory in polling mode. - * @param uwStartAddress : Write start address - * @param pData : Pointer to data to be written - * @param uwDataSize: Size of written data from the memory - * @retval None - */ -void BSP_SDRAM_WriteData(uint32_t uwStartAddress, uint32_t *pData, uint32_t uwDataSize) -{ - /* Disable write protection */ - HAL_SDRAM_WriteProtection_Disable(&SdramHandle); - - /*Write 32-bit data buffer to SDRAM memory*/ - HAL_SDRAM_Write_32b(&SdramHandle, (uint32_t *)uwStartAddress, pData, uwDataSize); -} - -/** - * @brief Writes an mount of data to the SDRAM memory in DMA mode. - * @param uwStartAddress : Write start address - * @param pData : Pointer to data to be written - * @param uwDataSize: Size of written data from the memory - * @retval None - */ -void BSP_SDRAM_WriteData_DMA(uint32_t uwStartAddress, uint32_t *pData, uint32_t uwDataSize) -{ - HAL_SDRAM_Write_DMA(&SdramHandle, (uint32_t *)uwStartAddress, pData, uwDataSize); -} - -/** - * @brief Sends command to the SDRAM bank. - * @param SdramCmd: Pointer to SDRAM command structure - * @retval HAL status - */ -HAL_StatusTypeDef BSP_SDRAM_Sendcmd(FMC_SDRAM_CommandTypeDef *SdramCmd) -{ - return(HAL_SDRAM_SendCommand(&SdramHandle, SdramCmd, SDRAM_TIMEOUT)); -} - -/** - * @brief Handles SDRAM DMA transfer interrupt request. - * @param None - * @retval None - */ -void BSP_SDRAM_DMA_IRQHandler(void) -{ - HAL_DMA_IRQHandler(SdramHandle.hdma); -} - -/** - * @brief Initializes SDRAM MSP. - * @param None - * @retval None - */ -static void MspInit(void) -{ - static DMA_HandleTypeDef dmaHandle; - GPIO_InitTypeDef GPIO_InitStructure; - SDRAM_HandleTypeDef *hsdram = &SdramHandle; - - /* Enable FMC clock */ - __FMC_CLK_ENABLE(); - - /* Enable chosen DMAx clock */ - __DMAx_CLK_ENABLE(); - - /* Enable GPIOs clock */ - __GPIOB_CLK_ENABLE(); - __GPIOC_CLK_ENABLE(); - __GPIOD_CLK_ENABLE(); - __GPIOE_CLK_ENABLE(); - __GPIOF_CLK_ENABLE(); - __GPIOG_CLK_ENABLE(); - -/*-- GPIOs Configuration -----------------------------------------------------*/ -/* - +-------------------+--------------------+--------------------+--------------------+ - + SDRAM pins assignment + - +-------------------+--------------------+--------------------+--------------------+ - | PD0 <-> FMC_D2 | PE0 <-> FMC_NBL0 | PF0 <-> FMC_A0 | PG0 <-> FMC_A10 | - | PD1 <-> FMC_D3 | PE1 <-> FMC_NBL1 | PF1 <-> FMC_A1 | PG1 <-> FMC_A11 | - | PD8 <-> FMC_D13 | PE7 <-> FMC_D4 | PF2 <-> FMC_A2 | PG8 <-> FMC_SDCLK | - | PD9 <-> FMC_D14 | PE8 <-> FMC_D5 | PF3 <-> FMC_A3 | PG15 <-> FMC_NCAS | - | PD10 <-> FMC_D15 | PE9 <-> FMC_D6 | PF4 <-> FMC_A4 |--------------------+ - | PD14 <-> FMC_D0 | PE10 <-> FMC_D7 | PF5 <-> FMC_A5 | - | PD15 <-> FMC_D1 | PE11 <-> FMC_D8 | PF11 <-> FMC_NRAS | - +-------------------| PE12 <-> FMC_D9 | PF12 <-> FMC_A6 | - | PE13 <-> FMC_D10 | PF13 <-> FMC_A7 | - | PE14 <-> FMC_D11 | PF14 <-> FMC_A8 | - | PE15 <-> FMC_D12 | PF15 <-> FMC_A9 | - +-------------------+--------------------+--------------------+ - | PB5 <-> FMC_SDCKE1| - | PB6 <-> FMC_SDNE1 | - | PC0 <-> FMC_SDNWE | - +-------------------+ - -*/ - - /* Common GPIO configuration */ - GPIO_InitStructure.Mode = GPIO_MODE_AF_PP; - GPIO_InitStructure.Speed = GPIO_SPEED_FAST; - GPIO_InitStructure.Pull = GPIO_NOPULL; - GPIO_InitStructure.Alternate = GPIO_AF12_FMC; - - /* GPIOB configuration */ - GPIO_InitStructure.Pin = GPIO_PIN_5 | GPIO_PIN_6; - HAL_GPIO_Init(GPIOB, &GPIO_InitStructure); - - /* GPIOC configuration */ - GPIO_InitStructure.Pin = GPIO_PIN_0; - HAL_GPIO_Init(GPIOC, &GPIO_InitStructure); - - /* GPIOD configuration */ - GPIO_InitStructure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_8 | - GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_14 | - GPIO_PIN_15; - HAL_GPIO_Init(GPIOD, &GPIO_InitStructure); - - /* GPIOE configuration */ - GPIO_InitStructure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_7 | - GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | - GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13 | - GPIO_PIN_14 | GPIO_PIN_15; - HAL_GPIO_Init(GPIOE, &GPIO_InitStructure); - - /* GPIOF configuration */ - GPIO_InitStructure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | - GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5 | - GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13 | - GPIO_PIN_14 | GPIO_PIN_15; - HAL_GPIO_Init(GPIOF, &GPIO_InitStructure); - - /* GPIOG configuration */ - GPIO_InitStructure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_4 | - GPIO_PIN_5 | GPIO_PIN_8 | GPIO_PIN_15; - HAL_GPIO_Init(GPIOG, &GPIO_InitStructure); - - /* Configure common DMA parameters */ - dmaHandle.Init.Channel = SDRAM_DMAx_CHANNEL; - dmaHandle.Init.Direction = DMA_MEMORY_TO_MEMORY; - dmaHandle.Init.PeriphInc = DMA_PINC_ENABLE; - dmaHandle.Init.MemInc = DMA_MINC_ENABLE; - dmaHandle.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; - dmaHandle.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; - dmaHandle.Init.Mode = DMA_NORMAL; - dmaHandle.Init.Priority = DMA_PRIORITY_HIGH; - dmaHandle.Init.FIFOMode = DMA_FIFOMODE_DISABLE; - dmaHandle.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; - dmaHandle.Init.MemBurst = DMA_MBURST_SINGLE; - dmaHandle.Init.PeriphBurst = DMA_PBURST_SINGLE; - - dmaHandle.Instance = SDRAM_DMAx_STREAM; - - /* Associate the DMA handle */ - __HAL_LINKDMA(hsdram, hdma, dmaHandle); - - /* Deinitialize the stream for new transfer */ - HAL_DMA_DeInit(&dmaHandle); - - /* Configure the DMA stream */ - HAL_DMA_Init(&dmaHandle); - - /* NVIC configuration for DMA transfer complete interrupt */ - HAL_NVIC_SetPriority(SDRAM_DMAx_IRQn, 0, 0); - HAL_NVIC_EnableIRQ(SDRAM_DMAx_IRQn); -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32F429I-Discovery/stm32f429i_discovery_sdram.h b/bsp/stm32f411RE/Libraries/BSP/STM32F429I-Discovery/stm32f429i_discovery_sdram.h deleted file mode 100644 index c80027f7cc..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32F429I-Discovery/stm32f429i_discovery_sdram.h +++ /dev/null @@ -1,178 +0,0 @@ -/** - ****************************************************************************** - * @file stm32f429i_discovery_sdram.h - * @author MCD Application Team - * @version V2.1.2 - * @date 02-March-2015 - * @brief This file contains all the functions prototypes for the - * stm32f429i_discovery_sdram.c driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32F429I_DISCOVERY_SDRAM_H -#define __STM32F429I_DISCOVERY_SDRAM_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm32f429i_discovery.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32F429I_DISCOVERY - * @{ - */ - -/** @defgroup STM32F429I_DISCOVERY_SDRAM - * @{ - */ - -/** @defgroup STM32F429I_DISCOVERY_SDRAM_Exported_Types - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F429I_DISCOVERY_SDRAM_Exported_Constants - * @{ - */ -/** - * @brief FMC SDRAM Bank address - */ -#define SDRAM_DEVICE_ADDR ((uint32_t)0xD0000000) -#define SDRAM_DEVICE_SIZE ((uint32_t)0x800000) /* SDRAM device size in MBytes */ - -/** - * @brief FMC SDRAM Memory Width - */ -/* #define SDRAM_MEMORY_WIDTH FMC_SDRAM_MEM_BUS_WIDTH_8 */ -#define SDRAM_MEMORY_WIDTH FMC_SDRAM_MEM_BUS_WIDTH_16 - -/** - * @brief FMC SDRAM CAS Latency - */ -/* #define SDRAM_CAS_LATENCY FMC_SDRAM_CAS_LATENCY_2 */ -#define SDRAM_CAS_LATENCY FMC_SDRAM_CAS_LATENCY_3 - -/** - * @brief FMC SDRAM Memory clock period - */ -#define SDCLOCK_PERIOD FMC_SDRAM_CLOCK_PERIOD_2 /* Default configuration used with LCD */ -/* #define SDCLOCK_PERIOD FMC_SDRAM_CLOCK_PERIOD_3 */ - -/** - * @brief FMC SDRAM Memory Read Burst feature - */ -#define SDRAM_READBURST FMC_SDRAM_RBURST_DISABLE /* Default configuration used with LCD */ -/* #define SDRAM_READBURST FMC_SDRAM_RBURST_ENABLE */ - -/** - * @brief FMC SDRAM Bank Remap - */ -/* #define SDRAM_BANK_REMAP */ - -/* Set the refresh rate counter */ -/* (15.62 us x Freq) - 20 */ -#define REFRESH_COUNT ((uint32_t)1386) /* SDRAM refresh counter */ -#define SDRAM_TIMEOUT ((uint32_t)0xFFFF) - -/* DMA definitions for SDRAM DMA transfer */ -#define __DMAx_CLK_ENABLE __DMA2_CLK_ENABLE -#define SDRAM_DMAx_CHANNEL DMA_CHANNEL_0 -#define SDRAM_DMAx_STREAM DMA2_Stream0 -#define SDRAM_DMAx_IRQn DMA2_Stream0_IRQn -#define SDRAM_DMAx_IRQHandler DMA2_Stream0_IRQHandler - -/** - * @brief FMC SDRAM Mode definition register defines - */ -#define SDRAM_MODEREG_BURST_LENGTH_1 ((uint16_t)0x0000) -#define SDRAM_MODEREG_BURST_LENGTH_2 ((uint16_t)0x0001) -#define SDRAM_MODEREG_BURST_LENGTH_4 ((uint16_t)0x0002) -#define SDRAM_MODEREG_BURST_LENGTH_8 ((uint16_t)0x0004) -#define SDRAM_MODEREG_BURST_TYPE_SEQUENTIAL ((uint16_t)0x0000) -#define SDRAM_MODEREG_BURST_TYPE_INTERLEAVED ((uint16_t)0x0008) -#define SDRAM_MODEREG_CAS_LATENCY_2 ((uint16_t)0x0020) -#define SDRAM_MODEREG_CAS_LATENCY_3 ((uint16_t)0x0030) -#define SDRAM_MODEREG_OPERATING_MODE_STANDARD ((uint16_t)0x0000) -#define SDRAM_MODEREG_WRITEBURST_MODE_PROGRAMMED ((uint16_t)0x0000) -#define SDRAM_MODEREG_WRITEBURST_MODE_SINGLE ((uint16_t)0x0200) -/** - * @} - */ - -/** @defgroup STM32F429I_DISCOVERY_SDRAM_Exported_Macro - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F429I_DISCOVERY_SDRAM_Exported_Functions - * @{ - */ -void BSP_SDRAM_Init(void); -void BSP_SDRAM_Initialization_sequence(uint32_t RefreshCount); -void BSP_SDRAM_ReadData(uint32_t uwStartAddress, uint32_t* pData, uint32_t uwDataSize); -void BSP_SDRAM_ReadData_DMA(uint32_t uwStartAddress, uint32_t* pData, uint32_t uwDataSize); -void BSP_SDRAM_WriteData(uint32_t uwStartAddress, uint32_t* pData, uint32_t uwDataSize); -void BSP_SDRAM_WriteData_DMA(uint32_t uwStartAddress, uint32_t* pData, uint32_t uwDataSize); -HAL_StatusTypeDef BSP_SDRAM_Sendcmd(FMC_SDRAM_CommandTypeDef *SdramCmd); -void BSP_SDRAM_DMA_IRQHandler(void); - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32F429I_DISCOVERY_SDRAM_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32F429I-Discovery/stm32f429i_discovery_ts.c b/bsp/stm32f411RE/Libraries/BSP/STM32F429I-Discovery/stm32f429i_discovery_ts.c deleted file mode 100644 index 869325480c..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32F429I-Discovery/stm32f429i_discovery_ts.c +++ /dev/null @@ -1,260 +0,0 @@ -/** - ****************************************************************************** - * @file stm32f429i_discovery_ts.c - * @author MCD Application Team - * @version V2.1.2 - * @date 02-March-2015 - * @brief This file provides a set of functions needed to manage Touch - * screen available with STMPE811 IO Expander device mounted on - * STM32F429I-Discovery Kit. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Includes ------------------------------------------------------------------*/ -#include "stm32f429i_discovery_ts.h" -#include "stm32f429i_discovery_io.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32F429I_DISCOVERY - * @{ - */ - -/** @defgroup STM32F429I_DISCOVERY_TS - * @{ - */ - -/** @defgroup STM32F429I_DISCOVERY_TS_Private_Types_Definitions - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F429I_DISCOVERY_TS_Private_Defines - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F429I_DISCOVERY_TS_Private_Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F429I_DISCOVERY_TS_Private_Variables - * @{ - */ -static TS_DrvTypeDef *TsDrv; -static uint16_t TsXBoundary, TsYBoundary; -/** - * @} - */ - -/** @defgroup STM32F429I_DISCOVERY_TS_Private_Function_Prototypes - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F429I_DISCOVERY_TS_Private_Functions - * @{ - */ - -/** - * @brief Initializes and configures the touch screen functionalities and - * configures all necessary hardware resources (GPIOs, clocks..). - * @param XSize: The maximum X size of the TS area on LCD - * @param YSize: The maximum Y size of the TS area on LCD - * @retval TS_OK: if all initializations are OK. Other value if error. - */ -uint8_t BSP_TS_Init(uint16_t XSize, uint16_t YSize) -{ - uint8_t ret = TS_ERROR; - - /* Initialize x and y positions boundaries */ - TsXBoundary = XSize; - TsYBoundary = YSize; - - /* Read ID and verify if the IO expander is ready */ - if(stmpe811_ts_drv.ReadID(TS_I2C_ADDRESS) == STMPE811_ID) - { - /* Initialize the TS driver structure */ - TsDrv = &stmpe811_ts_drv; - - ret = TS_OK; - } - - if(ret == TS_OK) - { - /* Initialize the LL TS Driver */ - TsDrv->Init(TS_I2C_ADDRESS); - TsDrv->Start(TS_I2C_ADDRESS); - } - - return ret; -} - -/** - * @brief Configures and enables the touch screen interrupts. - * @param None - * @retval TS_OK: if ITconfig is OK. Other value if error. - */ -uint8_t BSP_TS_ITConfig(void) -{ - /* Enable the TS ITs */ - TsDrv->EnableIT(TS_I2C_ADDRESS); - - return TS_OK; -} - -/** - * @brief Gets the TS IT status. - * @param None - * @retval Interrupt status. - */ -uint8_t BSP_TS_ITGetStatus(void) -{ - /* Return the TS IT status */ - return (TsDrv->GetITStatus(TS_I2C_ADDRESS)); -} - -/** - * @brief Returns status and positions of the touch screen. - * @param TsState: Pointer to touch screen current state structure - * @retval None. - */ -void BSP_TS_GetState(TS_StateTypeDef* TsState) -{ - static uint32_t _x = 0, _y = 0; - uint16_t xDiff, yDiff , x , y, xr, yr; - - TsState->TouchDetected = TsDrv->DetectTouch(TS_I2C_ADDRESS); - - if(TsState->TouchDetected) - { - TsDrv->GetXY(TS_I2C_ADDRESS, &x, &y); - - /* Y value first correction */ - y -= 360; - - /* Y value second correction */ - yr = y / 11; - - /* Return y position value */ - if(yr <= 0) - { - yr = 0; - } - else if (yr > TsYBoundary) - { - yr = TsYBoundary - 1; - } - else - {} - y = yr; - - /* X value first correction */ - if(x <= 3000) - { - x = 3870 - x; - } - else - { - x = 3800 - x; - } - - /* X value second correction */ - xr = x / 15; - - /* Return X position value */ - if(xr <= 0) - { - xr = 0; - } - else if (xr > TsXBoundary) - { - xr = TsXBoundary - 1; - } - else - {} - - x = xr; - xDiff = x > _x? (x - _x): (_x - x); - yDiff = y > _y? (y - _y): (_y - y); - - if (xDiff + yDiff > 5) - { - _x = x; - _y = y; - } - - /* Update the X position */ - TsState->X = _x; - - /* Update the Y position */ - TsState->Y = _y; - } -} - -/** - * @brief Clears all touch screen interrupts. - * @param None - * @retval None - */ -void BSP_TS_ITClear(void) -{ - /* Clear TS IT pending bits */ - TsDrv->ClearIT(TS_I2C_ADDRESS); -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32F429I-Discovery/stm32f429i_discovery_ts.h b/bsp/stm32f411RE/Libraries/BSP/STM32F429I-Discovery/stm32f429i_discovery_ts.h deleted file mode 100644 index 9b896349ec..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32F429I-Discovery/stm32f429i_discovery_ts.h +++ /dev/null @@ -1,134 +0,0 @@ -/** - ****************************************************************************** - * @file stm32f429i_discovery_ts.h - * @author MCD Application Team - * @version V2.1.2 - * @date 02-March-2015 - * @brief This file contains all the functions prototypes for the - * stm32f429i_discovery_ts.c driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32F429I_DISCOVERY_TS_H -#define __STM32F429I_DISCOVERY_TS_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm32f429i_discovery.h" -/* Include TouchScreen component driver */ -#include "../Components/stmpe811/stmpe811.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32F429I_DISCOVERY - * @{ - */ - -/** @defgroup STM32F429I_DISCOVERY_TS - * @{ - */ - -/** @defgroup STM32F429I_DISCOVERY_TS_Exported_Types - * @{ - */ -typedef struct -{ - uint16_t TouchDetected; - uint16_t X; - uint16_t Y; - uint16_t Z; -}TS_StateTypeDef; -/** - * @} - */ - -/** @defgroup STM32F429I_DISCOVERY_TS_Exported_Constants - * @{ - */ -#define TS_SWAP_NONE 0x00 -#define TS_SWAP_X 0x01 -#define TS_SWAP_Y 0x02 -#define TS_SWAP_XY 0x04 - -typedef enum -{ - TS_OK = 0x00, - TS_ERROR = 0x01, - TS_TIMEOUT = 0x02 -}TS_StatusTypeDef; -/** - * @} - */ - -/** @defgroup STM32F429I_DISCOVERY_TS_Exported_Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F429I_DISCOVERY_TS_Exported_Functions - * @{ - */ -uint8_t BSP_TS_Init(uint16_t XSize, uint16_t YSize); -void BSP_TS_GetState(TS_StateTypeDef *TsState); -uint8_t BSP_TS_ITConfig(void); -uint8_t BSP_TS_ITGetStatus(void); -void BSP_TS_ITClear(void); - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32F429I_DISCOVERY_TS_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32F4xx-Nucleo/Release_Notes.html b/bsp/stm32f411RE/Libraries/BSP/STM32F4xx-Nucleo/Release_Notes.html deleted file mode 100644 index 5f58caa82a..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32F4xx-Nucleo/Release_Notes.html +++ /dev/null @@ -1,257 +0,0 @@ - - - - - - - - - - - - - - - - - - - - Release Notes for STM32F4xx-Nucleo Board Drivers - - - - - - - - - - -
-


-

-
- - - - - - -
- - - - - - - - - -
-

Back to Release page

-
-

Release -Notes for STM32F4xx-Nucleo Board Drivers

-

Copyright -2015 STMicroelectronics

- -

-

-
-

 

- - - - - - -

Update History

-

V1.2.3 / 13-November-2015

Main -Changes

- - - - - -
  • stm32f4xx_nucleo.c
    • Add SD_IO_CSSState(), SD_IO_WriteReadData() and SD_IO_WriteReadData() APIs for proper support of the Adafruit shield V2.0.1
    • Add new API for Button, LED and Joystick deinitialization: BSP_PB_DeInit(), BSP_LED_DeInit(), BSP_JOY_DeInit() 
    • Replace -static APIs SPIx_Read(), SD_IO_ReadByte(), SD_IO_WriteCmd(), -SD_IO_WaitResponse() and SD_IO_WriteDummy() by SD_IO_WriteReadData() API.
  • stm32f4xx_nucleo.h
    • Add new define "ADAFRUIT_TFT_JOY_SD_ID802" for the Adafruit TFT shield support.

V1.2.2 / 14-August-2015

Main -Changes

- - - - - -
  • stm32f4xx_nucleo.h
    • Add alias to BUTTON_USER for backward compatibility.

V1.2.1 / 02-March-2015

Main -Changes

- - - - - -
  • stm32f4xx_nucleo.c/.h
    • Align to STM32F4xx HAL Driver V1.3.0 for -__HAL_RCC_PPP_CLK_ENABLE() .

V1.2.0 / 26-December-2014
-

- - - - - - - -

Main -Changes

- - - - - - - -
    -
  • stm32f4xx_nucleo.c
  • -
      -
    • Add LCD_IO_WriteMultipleData() LCD IO function, needed for ST7735 BSP component driver.
    • -
    -
  • Note: This driver version V1.2.0 needs ST7735 BSP component driver V1.1.0 and later.
    -
  • -
- -

V1.1.1 / 10-December-2014
-

- - - - - -

Main -Changes

- - - - - -
    -
  • stm32f4xx_nucleo.c
  • -
      -
    • BSP_BP_Init(): Fix limitation on button pin configuration (change EXTI polarity from rising to falling)
      -
    • -
    -
- -

V1.1.0 / 19-June-2014

- - - -

Main -Changes

- - - -
    -
  • stm32f4xx_nucleo.c/.h
  • -
      -
    • Update -driver to support LCD, joystick and microSD available on Adafruit 1.8" -shield (reference ID 802) by adding the SPI and ADC IO link operations
    • -
    -
      -
    • Enhance BSP_PB_Init() function by removing the call of __SYSCFG_CLK_ENABLE() already enabled in the HAL_GPIO_Init()
    • -
    -
      -
    • Correct BSP_LED_Off() and BSP_LED_On() by inverting GPIO_PIN_RESET/ GPIO_PIN_SET values written on GPIO pins
    • -
    -
      -
    • Comments clean up and typo corrections
    • -
    -
- -

V1.0.0 / 18-February-2014

- -

Main -Changes

- -
  • First official release

License

-
-
-Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met:
-
-
  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions -in binary form must reproduce the above copyright notice, this list of -conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of STMicroelectronics nor the names of its contributors may be used to endorse or promote products derived
    -
    -
-        from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- -
-
- - -
-
-
For -complete documentation on STM32 Microcontrollers -visit www.st.com/STM32
-
-

-
-
-

 

-
- - \ No newline at end of file diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32F4xx-Nucleo/stm32f4xx_nucleo.c b/bsp/stm32f411RE/Libraries/BSP/STM32F4xx-Nucleo/stm32f4xx_nucleo.c deleted file mode 100644 index 7b240ecc38..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32F4xx-Nucleo/stm32f4xx_nucleo.c +++ /dev/null @@ -1,897 +0,0 @@ -/** - ****************************************************************************** - * @file stm32f4xx_nucleo.c - * @author MCD Application Team - * @version V1.2.3 - * @date 13-September-2015 - * @brief This file provides set of firmware functions to manage: - * - LEDs and push-button available on STM32F4XX-Nucleo Kit - * from STMicroelectronics - * - LCD, joystick and microSD available on Adafruit 1.8" TFT LCD - * shield (reference ID 802) - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Includes ------------------------------------------------------------------*/ -#include "stm32f4xx_nucleo.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32F4XX_NUCLEO - * @{ - */ - -/** @addtogroup STM32F4XX_NUCLEO_LOW_LEVEL - * @brief This file provides set of firmware functions to manage Leds and push-button - * available on STM32F4xx-Nucleo Kit from STMicroelectronics. - * @{ - */ - -/** @defgroup STM32F4XX_NUCLEO_LOW_LEVEL_Private_TypesDefinitions - * @{ - */ -/** - * @} - */ - - -/** @defgroup STM32F4XX_NUCLEO_LOW_LEVEL_Private_Defines - * @{ - */ - -/** - * @brief STM32F4xx NUCLEO BSP Driver version number V1.2.3 - */ -#define __STM32F4xx_NUCLEO_BSP_VERSION_MAIN (0x01) /*!< [31:24] main version */ -#define __STM32F4xx_NUCLEO_BSP_VERSION_SUB1 (0x02) /*!< [23:16] sub1 version */ -#define __STM32F4xx_NUCLEO_BSP_VERSION_SUB2 (0x03) /*!< [15:8] sub2 version */ -#define __STM32F4xx_NUCLEO_BSP_VERSION_RC (0x00) /*!< [7:0] release candidate */ -#define __STM32F4xx_NUCLEO_BSP_VERSION ((__STM32F4xx_NUCLEO_BSP_VERSION_MAIN << 24)\ - |(__STM32F4xx_NUCLEO_BSP_VERSION_SUB1 << 16)\ - |(__STM32F4xx_NUCLEO_BSP_VERSION_SUB2 << 8 )\ - |(__STM32F4xx_NUCLEO_BSP_VERSION_RC)) - -/** - * @brief LINK SD Card - */ -#define SD_DUMMY_BYTE 0xFF -#define SD_NO_RESPONSE_EXPECTED 0x80 - -/** - * @} - */ - -/** @defgroup STM32F4XX_NUCLEO_LOW_LEVEL_Private_Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F4XX_NUCLEO_LOW_LEVEL_Private_Variables - * @{ - */ -GPIO_TypeDef* GPIO_PORT[LEDn] = {LED2_GPIO_PORT}; - -const uint16_t GPIO_PIN[LEDn] = {LED2_PIN}; - -GPIO_TypeDef* BUTTON_PORT[BUTTONn] = {KEY_BUTTON_GPIO_PORT}; -const uint16_t BUTTON_PIN[BUTTONn] = {KEY_BUTTON_PIN}; -const uint8_t BUTTON_IRQn[BUTTONn] = {KEY_BUTTON_EXTI_IRQn}; - -/** - * @brief BUS variables - */ - -#ifdef ADAFRUIT_TFT_JOY_SD_ID802 -#ifdef HAL_SPI_MODULE_ENABLED -uint32_t SpixTimeout = NUCLEO_SPIx_TIMEOUT_MAX; /*SR) & SPI_FLAG_TXE) != SPI_FLAG_TXE) - { - } - /* Need to invert bytes for LCD*/ - *((__IO uint8_t*)&hnucleo_Spi.Instance->DR) = *(pData+1); - - while(((hnucleo_Spi.Instance->SR) & SPI_FLAG_TXE) != SPI_FLAG_TXE) - { - } - *((__IO uint8_t*)&hnucleo_Spi.Instance->DR) = *pData; - counter--; - pData += 2; - } - - /* Wait until the bus is ready before releasing Chip select */ - while(((hnucleo_Spi.Instance->SR) & SPI_FLAG_BSY) != RESET) - { - } - } - - /* Empty the Rx fifo */ - data = *(&hnucleo_Spi.Instance->DR); - - /* Deselect : Chip Select high */ - LCD_CS_HIGH(); -} - -/** - * @brief Wait for loop in ms. - * @param Delay in ms. - * @retval None - */ -void LCD_Delay(uint32_t Delay) -{ - HAL_Delay(Delay); -} -#endif /* HAL_SPI_MODULE_ENABLED */ - -/******************************* ADC driver ********************************/ -#ifdef HAL_ADC_MODULE_ENABLED - -/** - * @brief Initializes ADC MSP. - * @param None - * @retval None - */ -static void ADCx_MspInit(ADC_HandleTypeDef *hadc) -{ - GPIO_InitTypeDef GPIO_InitStruct; - - /*** Configure the GPIOs ***/ - /* Enable GPIO clock */ - NUCLEO_ADCx_GPIO_CLK_ENABLE(); - - /* Configure the selected ADC Channel as analog input */ - GPIO_InitStruct.Pin = NUCLEO_ADCx_GPIO_PIN ; - GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(NUCLEO_ADCx_GPIO_PORT, &GPIO_InitStruct); - - /*** Configure the ADC peripheral ***/ - /* Enable ADC clock */ - NUCLEO_ADCx_CLK_ENABLE(); -} - -/** - * @brief DeInitializes ADC MSP. - * @param None - * @note ADC DeInit does not disable the GPIO clock - * @retval None - */ -static void ADCx_MspDeInit(ADC_HandleTypeDef *hadc) -{ - GPIO_InitTypeDef GPIO_InitStruct; - - /*** DeInit the ADC peripheral ***/ - /* Disable ADC clock */ - NUCLEO_ADCx_CLK_DISABLE(); - - /* Configure the selected ADC Channel as analog input */ - GPIO_InitStruct.Pin = NUCLEO_ADCx_GPIO_PIN ; - HAL_GPIO_DeInit(NUCLEO_ADCx_GPIO_PORT, GPIO_InitStruct.Pin); - - /* Disable GPIO clock has to be done by the application*/ - /* NUCLEO_ADCx_GPIO_CLK_DISABLE(); */ -} - -/** - * @brief Initializes ADC HAL. - * @param None - * @retval None - */ -static void ADCx_Init(void) -{ - if(HAL_ADC_GetState(&hnucleo_Adc) == HAL_ADC_STATE_RESET) - { - /* ADC Config */ - hnucleo_Adc.Instance = NUCLEO_ADCx; - hnucleo_Adc.Init.ClockPrescaler = ADC_CLOCKPRESCALER_PCLK_DIV4; /* (must not exceed 36MHz) */ - hnucleo_Adc.Init.Resolution = ADC_RESOLUTION12b; - hnucleo_Adc.Init.DataAlign = ADC_DATAALIGN_RIGHT; - hnucleo_Adc.Init.ContinuousConvMode = DISABLE; - hnucleo_Adc.Init.DiscontinuousConvMode = DISABLE; - hnucleo_Adc.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE; - hnucleo_Adc.Init.EOCSelection = EOC_SINGLE_CONV; - hnucleo_Adc.Init.NbrOfConversion = 1; - hnucleo_Adc.Init.DMAContinuousRequests = DISABLE; - - ADCx_MspInit(&hnucleo_Adc); - HAL_ADC_Init(&hnucleo_Adc); - } -} - -/** - * @brief Initializes ADC HAL. - * @param None - * @retval None - */ -static void ADCx_DeInit(void) -{ - hnucleo_Adc.Instance = NUCLEO_ADCx; - - HAL_ADC_DeInit(&hnucleo_Adc); - ADCx_MspDeInit(&hnucleo_Adc); -} - -/******************************* LINK JOYSTICK ********************************/ - -/** - * @brief Configures joystick available on adafruit 1.8" TFT shield - * managed through ADC to detect motion. - * @param None - * @retval Joystickstatus (0=> success, 1=> fail) - */ -uint8_t BSP_JOY_Init(void) -{ - uint8_t status = HAL_ERROR; - - ADCx_Init(); - - /* Select the ADC Channel to be converted */ - sConfig.Channel = NUCLEO_ADCx_CHANNEL; - sConfig.SamplingTime = ADC_SAMPLETIME_3CYCLES; - sConfig.Rank = 1; - status = HAL_ADC_ConfigChannel(&hnucleo_Adc, &sConfig); - - /* Return Joystick initialization status */ - return status; -} - -/** - * @brief DeInit joystick GPIOs. - * @note JOY DeInit does not disable the Mfx, just set the Mfx pins in Off mode - * @retval None. - */ -void BSP_JOY_DeInit(void) -{ - ADCx_DeInit(); -} - -/** - * @brief Returns the Joystick key pressed. - * @note To know which Joystick key is pressed we need to detect the voltage - * level on each key output - * - None : 3.3 V / 4095 - * - SEL : 1.055 V / 1308 - * - DOWN : 0.71 V / 88 - * - LEFT : 3.0 V / 3720 - * - RIGHT : 0.595 V / 737 - * - UP : 1.65 V / 2046 - * @retval JOYState_TypeDef: Code of the Joystick key pressed. - */ -JOYState_TypeDef BSP_JOY_GetState(void) -{ - JOYState_TypeDef state; - uint16_t keyconvertedvalue = 0; - - /* Start the conversion process */ - HAL_ADC_Start(&hnucleo_Adc); - - /* Wait for the end of conversion */ - HAL_ADC_PollForConversion(&hnucleo_Adc, 10); - - /* Check if the continuous conversion of regular channel is finished */ - if(HAL_ADC_GetState(&hnucleo_Adc) == HAL_ADC_STATE_EOC_REG) - { - /* Get the converted value of regular channel */ - keyconvertedvalue = HAL_ADC_GetValue(&hnucleo_Adc); - } - - if((keyconvertedvalue > 2010) && (keyconvertedvalue < 2090)) - { - state = JOY_UP; - } - else if((keyconvertedvalue > 680) && (keyconvertedvalue < 780)) - { - state = JOY_RIGHT; - } - else if((keyconvertedvalue > 1270) && (keyconvertedvalue < 1350)) - { - state = JOY_SEL; - } - else if((keyconvertedvalue > 50) && (keyconvertedvalue < 130)) - { - state = JOY_DOWN; - } - else if((keyconvertedvalue > 3680) && (keyconvertedvalue < 3760)) - { - state = JOY_LEFT; - } - else - { - state = JOY_NONE; - } - - /* Loop while a key is pressed */ - if(state != JOY_NONE) - { - keyconvertedvalue = HAL_ADC_GetValue(&hnucleo_Adc); - } - /* Return the code of the Joystick key pressed */ - return state; -} -#endif /* HAL_ADC_MODULE_ENABLED */ - -#endif /* ADAFRUIT_TFT_JOY_SD_ID802 */ - - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32F4xx-Nucleo/stm32f4xx_nucleo.h b/bsp/stm32f411RE/Libraries/BSP/STM32F4xx-Nucleo/stm32f4xx_nucleo.h deleted file mode 100644 index 874dbf0be8..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32F4xx-Nucleo/stm32f4xx_nucleo.h +++ /dev/null @@ -1,304 +0,0 @@ -/** - ****************************************************************************** - * @file stm32f4xx_nucleo.h - * @author MCD Application Team - * @version V1.2.3 - * @date 13-November-2015 - * @brief This file contains definitions for: - * - LEDs and push-button available on STM32F4XX-Nucleo Kit - * from STMicroelectronics - * - LCD, joystick and microSD available on Adafruit 1.8" TFT LCD - * shield (reference ID 802) - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32F4XX_NUCLEO_H -#define __STM32F4XX_NUCLEO_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm32f4xx_hal.h" - -/* To be defined only if the board is provided with the related shield */ -/* https://www.adafruit.com/products/802 */ -#define ADAFRUIT_TFT_JOY_SD_ID802 - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32F4XX_NUCLEO - * @{ - */ - -/** @addtogroup STM32F4XX_NUCLEO_LOW_LEVEL - * @{ - */ - -/** @defgroup STM32F4XX_NUCLEO_LOW_LEVEL_Exported_Types - * @{ - */ -typedef enum -{ - LED2 = 0 -}Led_TypeDef; - -typedef enum -{ - BUTTON_USER = 0, - /* Alias */ - BUTTON_KEY = BUTTON_USER -} Button_TypeDef; - -typedef enum -{ - BUTTON_MODE_GPIO = 0, - BUTTON_MODE_EXTI = 1 -}ButtonMode_TypeDef; - -typedef enum -{ - JOY_NONE = 0, - JOY_SEL = 1, - JOY_DOWN = 2, - JOY_LEFT = 3, - JOY_RIGHT = 4, - JOY_UP = 5 -}JOYState_TypeDef; - -/** - * @} - */ - -/** @defgroup STM32F4XX_NUCLEO_LOW_LEVEL_Exported_Constants - * @{ - */ - -/** - * @brief Define for STM32F4XX_NUCLEO board - */ -#if !defined (USE_STM32F4XX_NUCLEO) - #define USE_STM32F4XX_NUCLEO -#endif - -/** @addtogroup STM32F4XX_NUCLEO_LOW_LEVEL_LED - * @{ - */ -#define LEDn 1 - -#define LED2_PIN GPIO_PIN_5 -#define LED2_GPIO_PORT GPIOA -#define LED2_GPIO_CLK_ENABLE() __GPIOA_CLK_ENABLE() -#define LED2_GPIO_CLK_DISABLE() __GPIOA_CLK_DISABLE() - -#define LEDx_GPIO_CLK_ENABLE(__INDEX__) LED2_GPIO_CLK_ENABLE() -#define LEDx_GPIO_CLK_DISABLE(__INDEX__) LED2_GPIO_CLK_DISABLE() -/** - * @} - */ - -/** @addtogroup STM32F4XX_NUCLEO_LOW_LEVEL_BUTTON - * @{ - */ -#define BUTTONn 1 - -/** - * @brief Key push-button - */ -#define USER_BUTTON_PIN GPIO_PIN_13 -#define USER_BUTTON_GPIO_PORT GPIOC -#define USER_BUTTON_GPIO_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE() -#define USER_BUTTON_GPIO_CLK_DISABLE() __HAL_RCC_GPIOC_CLK_DISABLE() -#define USER_BUTTON_EXTI_LINE GPIO_PIN_13 -#define USER_BUTTON_EXTI_IRQn EXTI15_10_IRQn - -#define BUTTONx_GPIO_CLK_ENABLE(__INDEX__) USER_BUTTON_GPIO_CLK_ENABLE() -#define BUTTONx_GPIO_CLK_DISABLE(__INDEX__) USER_BUTTON_GPIO_CLK_DISABLE() - -/* Aliases */ -#define KEY_BUTTON_PIN USER_BUTTON_PIN -#define KEY_BUTTON_GPIO_PORT USER_BUTTON_GPIO_PORT -#define KEY_BUTTON_GPIO_CLK_ENABLE() USER_BUTTON_GPIO_CLK_ENABLE() -#define KEY_BUTTON_GPIO_CLK_DISABLE() USER_BUTTON_GPIO_CLK_DISABLE() -#define KEY_BUTTON_EXTI_LINE USER_BUTTON_EXTI_LINE -#define KEY_BUTTON_EXTI_IRQn USER_BUTTON_EXTI_IRQn - -/** - * @} - */ - -/** @addtogroup STM32F4XX_NUCLEO_LOW_LEVEL_BUS - * @{ - */ -/*############################### SPI1 #######################################*/ -#ifdef HAL_SPI_MODULE_ENABLED - -#define NUCLEO_SPIx SPI1 -#define NUCLEO_SPIx_CLK_ENABLE() __HAL_RCC_SPI1_CLK_ENABLE() - -#define NUCLEO_SPIx_SCK_AF GPIO_AF5_SPI1 -#define NUCLEO_SPIx_SCK_GPIO_PORT GPIOA -#define NUCLEO_SPIx_SCK_PIN GPIO_PIN_5 -#define NUCLEO_SPIx_SCK_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE() -#define NUCLEO_SPIx_SCK_GPIO_CLK_DISABLE() __HAL_RCC_GPIOA_CLK_DISABLE() - -#define NUCLEO_SPIx_MISO_MOSI_AF GPIO_AF5_SPI1 -#define NUCLEO_SPIx_MISO_MOSI_GPIO_PORT GPIOA -#define NUCLEO_SPIx_MISO_MOSI_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE() -#define NUCLEO_SPIx_MISO_MOSI_GPIO_CLK_DISABLE() __HAL_RCC_GPIOA_CLK_DISABLE() -#define NUCLEO_SPIx_MISO_PIN GPIO_PIN_6 -#define NUCLEO_SPIx_MOSI_PIN GPIO_PIN_7 -/* Maximum Timeout values for flags waiting loops. These timeouts are not based - on accurate values, they just guarantee that the application will not remain - stuck if the SPI communication is corrupted. - You may modify these timeout values depending on CPU frequency and application - conditions (interrupts routines ...). */ -#define NUCLEO_SPIx_TIMEOUT_MAX 1000 - -/** - * @brief SD Control Lines management - */ -#define SD_CS_LOW() HAL_GPIO_WritePin(SD_CS_GPIO_PORT, SD_CS_PIN, GPIO_PIN_RESET) -#define SD_CS_HIGH() HAL_GPIO_WritePin(SD_CS_GPIO_PORT, SD_CS_PIN, GPIO_PIN_SET) - -/** - * @brief LCD Control Lines management - */ -#define LCD_CS_LOW() HAL_GPIO_WritePin(LCD_CS_GPIO_PORT, LCD_CS_PIN, GPIO_PIN_RESET) -#define LCD_CS_HIGH() HAL_GPIO_WritePin(LCD_CS_GPIO_PORT, LCD_CS_PIN, GPIO_PIN_SET) -#define LCD_DC_LOW() HAL_GPIO_WritePin(LCD_DC_GPIO_PORT, LCD_DC_PIN, GPIO_PIN_RESET) -#define LCD_DC_HIGH() HAL_GPIO_WritePin(LCD_DC_GPIO_PORT, LCD_DC_PIN, GPIO_PIN_SET) - -/** - * @brief SD Control Interface pins (shield D4) - */ -#define SD_CS_PIN GPIO_PIN_5 -#define SD_CS_GPIO_PORT GPIOB -#define SD_CS_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE() -#define SD_CS_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE() - -/** - * @brief LCD Control Interface pins (shield D10) - */ -#define LCD_CS_PIN GPIO_PIN_6 -#define LCD_CS_GPIO_PORT GPIOB -#define LCD_CS_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE() -#define LCD_CS_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE() - -/** - * @brief LCD Data/Command Interface pins (shield D8) - */ -#define LCD_DC_PIN GPIO_PIN_9 -#define LCD_DC_GPIO_PORT GPIOA -#define LCD_DC_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE() -#define LCD_DC_GPIO_CLK_DISABLE() __HAL_RCC_GPIOA_CLK_DISABLE() - -#endif /* HAL_SPI_MODULE_ENABLED */ - -/*################################ ADC1 ######################################*/ -/** - * @brief ADC Interface pins - * used to detect motion of Joystick available on Adafruit 1.8" TFT shield - */ - -#ifdef HAL_ADC_MODULE_ENABLED - -#define NUCLEO_ADCx ADC1 -#define NUCLEO_ADCx_CLK_ENABLE() __HAL_RCC_ADC1_CLK_ENABLE() -#define NUCLEO_ADCx_CLK_DISABLE() __HAL_RCC_ADC1_CLK_DISABLE() - -#define NUCLEO_ADCx_CHANNEL ADC_CHANNEL_8 - -#define NUCLEO_ADCx_GPIO_PORT GPIOB -#define NUCLEO_ADCx_GPIO_PIN GPIO_PIN_0 -#define NUCLEO_ADCx_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE() -#define NUCLEO_ADCx_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE() -#endif /* HAL_ADC_MODULE_ENABLED */ -/** - * @} - */ - -/** - * @} - */ - -/** @defgroup STM32F4XX_NUCLEO_LOW_LEVEL_Exported_Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F4XX_NUCLEO_LOW_LEVEL_Exported_Functions - * @{ - */ -uint32_t BSP_GetVersion(void); -void BSP_LED_Init(Led_TypeDef Led); -void BSP_LED_DeInit(Led_TypeDef Led); -void BSP_LED_On(Led_TypeDef Led); -void BSP_LED_Off(Led_TypeDef Led); -void BSP_LED_Toggle(Led_TypeDef Led); -void BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef ButtonMode); -void BSP_PB_DeInit(Button_TypeDef Button); -uint32_t BSP_PB_GetState(Button_TypeDef Button); -#ifdef HAL_ADC_MODULE_ENABLED -uint8_t BSP_JOY_Init(void); -JOYState_TypeDef BSP_JOY_GetState(void); -void BSP_JOY_DeInit(void); -#endif /* HAL_ADC_MODULE_ENABLED */ - - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32F4XX_NUCLEO_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32F4xx_Nucleo_144/Release_Notes.html b/bsp/stm32f411RE/Libraries/BSP/STM32F4xx_Nucleo_144/Release_Notes.html deleted file mode 100644 index 4e8e936573..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32F4xx_Nucleo_144/Release_Notes.html +++ /dev/null @@ -1,154 +0,0 @@ - - - - - - - - - - - - - - - - - - Release Notes for STM32F4xx-Nucleo Board Drivers - - - - - - - - - - -
-


-

-
- - - - - - -
- - - - - - - - - -
-

Back to Release page

-
-

Release -Notes for STM32F4xx_Nucleo_144 Board Drivers

-

Copyright -2015 STMicroelectronics

- -

-

-
-

 

- - - - - - -

Update History

V1.0.0 / 13-November-2015

- -

Main -Changes

- -
  • First official release

License

-
-
-Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met:
-
-
  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions -in binary form must reproduce the above copyright notice, this list of -conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of STMicroelectronics nor the names of its contributors may be used to endorse or promote products derived
    -
    -
-        from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- -
-
- - -
-
-
For -complete documentation on STM32 Microcontrollers -visit www.st.com/STM32
-
-

-
-
-

 

-
- - \ No newline at end of file diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32F4xx_Nucleo_144/stm32f4xx_nucleo_144.c b/bsp/stm32f411RE/Libraries/BSP/STM32F4xx_Nucleo_144/stm32f4xx_nucleo_144.c deleted file mode 100644 index 8a1bfc5608..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32F4xx_Nucleo_144/stm32f4xx_nucleo_144.c +++ /dev/null @@ -1,916 +0,0 @@ -/** - ****************************************************************************** - * @file stm32f4xx_nucleo_144.c - * @author MCD Application Team - * @version V1.0.0 - * @date 13-November-2015 - * @brief This file provides set of firmware functions to manage: - * - LEDs and push-button available on STM32F4XX-Nucleo-144 Kit - * from STMicroelectronics - * - LCD, joystick and microSD available on Adafruit 1.8" TFT LCD - * shield (reference ID 802) - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Includes ------------------------------------------------------------------*/ -#include "stm32f4xx_nucleo_144.h" - - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32F4XX_NUCLEO_144 - * @{ - */ - -/** @addtogroup STM32F4XX_NUCLEO_144_LOW_LEVEL - * @brief This file provides set of firmware functions to manage Leds and push-button - * available on STM32F4xx-Nucleo Kit from STMicroelectronics. - * @{ - */ - -/** @defgroup STM32F4XX_NUCLEO_144_LOW_LEVEL_Private_TypesDefinitions - * @{ - */ -/** - * @} - */ - - -/** @defgroup STM32F4XX_NUCLEO_144_LOW_LEVEL_Private_Defines - * @{ - */ - -/** - * @brief STM32F4xx NUCLEO BSP Driver version number V1.0.0 - */ -#define __STM32F4xx_NUCLEO_BSP_VERSION_MAIN (0x01) /*!< [31:24] main version */ -#define __STM32F4xx_NUCLEO_BSP_VERSION_SUB1 (0x00) /*!< [23:16] sub1 version */ -#define __STM32F4xx_NUCLEO_BSP_VERSION_SUB2 (0x00) /*!< [15:8] sub2 version */ -#define __STM32F4xx_NUCLEO_BSP_VERSION_RC (0x00) /*!< [7:0] release candidate */ -#define __STM32F4xx_NUCLEO_BSP_VERSION ((__STM32F4xx_NUCLEO_BSP_VERSION_MAIN << 24)\ - |(__STM32F4xx_NUCLEO_BSP_VERSION_SUB1 << 16)\ - |(__STM32F4xx_NUCLEO_BSP_VERSION_SUB2 << 8 )\ - |(__STM32F4xx_NUCLEO_BSP_VERSION_RC)) - -/** - * @brief LINK SD Card - */ -#define SD_DUMMY_BYTE 0xFF -#define SD_NO_RESPONSE_EXPECTED 0x80 - -/** - * @} - */ - -/** @defgroup STM32F4XX_NUCLEO_144_LOW_LEVEL_Private_Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F4XX_NUCLEO_144_LOW_LEVEL_Private_Variables - * @{ - */ -GPIO_TypeDef* GPIO_PORT[LEDn] = {LED1_GPIO_PORT, LED2_GPIO_PORT, LED3_GPIO_PORT}; - -const uint16_t GPIO_PIN[LEDn] = {LED1_PIN, LED2_PIN, LED3_PIN}; - -GPIO_TypeDef* BUTTON_PORT[BUTTONn] = {USER_BUTTON_GPIO_PORT}; -const uint16_t BUTTON_PIN[BUTTONn] = {USER_BUTTON_PIN}; -const uint8_t BUTTON_IRQn[BUTTONn] = {USER_BUTTON_EXTI_IRQn}; - -/** - * @brief BUS variables - */ - -#ifdef ADAFRUIT_TFT_JOY_SD_ID802 -#ifdef HAL_SPI_MODULE_ENABLED -uint32_t SpixTimeout = NUCLEO_SPIx_TIMEOUT_MAX; /*SR) & SPI_FLAG_TXE) != SPI_FLAG_TXE) - { - } - /* Need to invert bytes for LCD*/ - *((__IO uint8_t*)&hnucleo_Spi.Instance->DR) = *(pData+1); - - while(((hnucleo_Spi.Instance->SR) & SPI_FLAG_TXE) != SPI_FLAG_TXE) - { - } - *((__IO uint8_t*)&hnucleo_Spi.Instance->DR) = *pData; - counter--; - pData += 2; - } - - /* Wait until the bus is ready before releasing Chip select */ - while(((hnucleo_Spi.Instance->SR) & SPI_FLAG_BSY) != RESET) - { - } - } - - /* Empty the Rx fifo */ - data = *(&hnucleo_Spi.Instance->DR); - UNUSED(data); /* Remove GNU warning */ - - /* Deselect : Chip Select high */ - LCD_CS_HIGH(); -} - -/** - * @brief Wait for loop in ms. - * @param Delay in ms. - * @retval None - */ -void LCD_Delay(uint32_t Delay) -{ - HAL_Delay(Delay); -} -#endif /* HAL_SPI_MODULE_ENABLED */ - -/******************************* ADC driver ********************************/ -#ifdef HAL_ADC_MODULE_ENABLED - -/** - * @brief Initializes ADC MSP. - * @param None - * @retval None - */ -static void ADCx_MspInit(ADC_HandleTypeDef *hadc) -{ - GPIO_InitTypeDef GPIO_InitStruct; - - /*** Configure the GPIOs ***/ - /* Enable GPIO clock */ - NUCLEO_ADCx_GPIO_CLK_ENABLE(); - - /* Configure the selected ADC Channel as analog input */ - GPIO_InitStruct.Pin = NUCLEO_ADCx_GPIO_PIN ; - GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(NUCLEO_ADCx_GPIO_PORT, &GPIO_InitStruct); - - /*** Configure the ADC peripheral ***/ - /* Enable ADC clock */ - NUCLEO_ADCx_CLK_ENABLE(); -} - -/** - * @brief DeInitializes ADC MSP. - * @param None - * @note ADC DeInit does not disable the GPIO clock - * @retval None - */ -static void ADCx_MspDeInit(ADC_HandleTypeDef *hadc) -{ - GPIO_InitTypeDef GPIO_InitStruct; - - /*** DeInit the ADC peripheral ***/ - /* Disable ADC clock */ - NUCLEO_ADCx_CLK_DISABLE(); - - /* Configure the selected ADC Channel as analog input */ - GPIO_InitStruct.Pin = NUCLEO_ADCx_GPIO_PIN ; - HAL_GPIO_DeInit(NUCLEO_ADCx_GPIO_PORT, GPIO_InitStruct.Pin); - - /* Disable GPIO clock has to be done by the application*/ - /* NUCLEO_ADCx_GPIO_CLK_DISABLE(); */ -} - -/** - * @brief Initializes ADC HAL. - * @param None - * @retval None - */ -static void ADCx_Init(void) -{ - if(HAL_ADC_GetState(&hnucleo_Adc) == HAL_ADC_STATE_RESET) - { - /* ADC Config */ - hnucleo_Adc.Instance = NUCLEO_ADCx; - hnucleo_Adc.Init.ClockPrescaler = ADC_CLOCKPRESCALER_PCLK_DIV4; /* (must not exceed 36MHz) */ - hnucleo_Adc.Init.Resolution = ADC_RESOLUTION12b; - hnucleo_Adc.Init.DataAlign = ADC_DATAALIGN_RIGHT; - hnucleo_Adc.Init.ContinuousConvMode = DISABLE; - hnucleo_Adc.Init.DiscontinuousConvMode = DISABLE; - hnucleo_Adc.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE; - hnucleo_Adc.Init.EOCSelection = EOC_SINGLE_CONV; - hnucleo_Adc.Init.NbrOfConversion = 1; - hnucleo_Adc.Init.DMAContinuousRequests = DISABLE; - - ADCx_MspInit(&hnucleo_Adc); - HAL_ADC_Init(&hnucleo_Adc); - } -} - -/** - * @brief Initializes ADC HAL. - * @param None - * @retval None - */ -static void ADCx_DeInit(void) -{ - hnucleo_Adc.Instance = NUCLEO_ADCx; - - HAL_ADC_DeInit(&hnucleo_Adc); - ADCx_MspDeInit(&hnucleo_Adc); -} - -/******************************* LINK JOYSTICK ********************************/ - -/** - * @brief Configures joystick available on adafruit 1.8" TFT shield - * managed through ADC to detect motion. - * @param None - * @retval Joystickstatus (0=> success, 1=> fail) - */ -uint8_t BSP_JOY_Init(void) -{ - uint8_t status = HAL_ERROR; - - ADCx_Init(); - - /* Select the ADC Channel to be converted */ - sConfig.Channel = NUCLEO_ADCx_CHANNEL; - sConfig.SamplingTime = ADC_SAMPLETIME_3CYCLES; - sConfig.Rank = 1; - status = HAL_ADC_ConfigChannel(&hnucleo_Adc, &sConfig); - - /* Return Joystick initialization status */ - return status; -} - -/** - * @brief DeInit joystick GPIOs. - * @note JOY DeInit does not disable the Mfx, just set the Mfx pins in Off mode - * @retval None. - */ -void BSP_JOY_DeInit(void) -{ - ADCx_DeInit(); -} - -/** - * @brief Returns the Joystick key pressed. - * @note To know which Joystick key is pressed we need to detect the voltage - * level on each key output - * - None : 3.3 V / 4095 - * - SEL : 1.055 V / 1308 - * - DOWN : 0.71 V / 88 - * - LEFT : 3.0 V / 3720 - * - RIGHT : 0.595 V / 737 - * - UP : 1.65 V / 2046 - * @retval JOYState_TypeDef: Code of the Joystick key pressed. - */ -JOYState_TypeDef BSP_JOY_GetState(void) -{ - JOYState_TypeDef state; - uint16_t keyconvertedvalue = 0; - - /* Start the conversion process */ - HAL_ADC_Start(&hnucleo_Adc); - - /* Wait for the end of conversion */ - HAL_ADC_PollForConversion(&hnucleo_Adc, 10); - - /* Check if the continuous conversion of regular channel is finished */ - if(HAL_ADC_GetState(&hnucleo_Adc) == HAL_ADC_STATE_EOC_REG) - { - /* Get the converted value of regular channel */ - keyconvertedvalue = HAL_ADC_GetValue(&hnucleo_Adc); - } - - if((keyconvertedvalue > 2010) && (keyconvertedvalue < 2090)) - { - state = JOY_UP; - } - else if((keyconvertedvalue > 680) && (keyconvertedvalue < 780)) - { - state = JOY_RIGHT; - } - else if((keyconvertedvalue > 1270) && (keyconvertedvalue < 1350)) - { - state = JOY_SEL; - } - else if((keyconvertedvalue > 50) && (keyconvertedvalue < 130)) - { - state = JOY_DOWN; - } - else if((keyconvertedvalue > 3680) && (keyconvertedvalue < 3760)) - { - state = JOY_LEFT; - } - else - { - state = JOY_NONE; - } - - /* Loop while a key is pressed */ - if(state != JOY_NONE) - { - keyconvertedvalue = HAL_ADC_GetValue(&hnucleo_Adc); - } - /* Return the code of the Joystick key pressed */ - return state; -} -#endif /* HAL_ADC_MODULE_ENABLED */ - -#endif /* ADAFRUIT_TFT_JOY_SD_ID802 */ - - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32f411RE/Libraries/BSP/STM32F4xx_Nucleo_144/stm32f4xx_nucleo_144.h b/bsp/stm32f411RE/Libraries/BSP/STM32F4xx_Nucleo_144/stm32f4xx_nucleo_144.h deleted file mode 100644 index c44c39e814..0000000000 --- a/bsp/stm32f411RE/Libraries/BSP/STM32F4xx_Nucleo_144/stm32f4xx_nucleo_144.h +++ /dev/null @@ -1,357 +0,0 @@ -/** - ****************************************************************************** - * @file stm32f4xx_nucleo_144.h - * @author MCD Application Team - * @version V1.0.0 - * @date 13-November-2015 - * @brief This file contains definitions for: - * - LEDs and push-button available on STM32F4XX-Nucleo-144 Kit - * from STMicroelectronics - * - LCD, joystick and microSD available on Adafruit 1.8" TFT LCD - * shield (reference ID 802) - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32F4XX_NUCLEO_144_H -#define __STM32F4XX_NUCLEO_144_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm32f4xx_hal.h" - -/* To be defined only if the board is provided with the related shield */ -/* https://www.adafruit.com/products/802 */ -#ifndef ADAFRUIT_TFT_JOY_SD_ID802 -#define ADAFRUIT_TFT_JOY_SD_ID802 -#endif - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32F4XX_NUCLEO_144 - * @{ - */ - -/** @addtogroup STM32F4XX_NUCLEO_144_LOW_LEVEL - * @{ - */ - -/** @defgroup STM32F4XX_NUCLEO_144_LOW_LEVEL_Exported_Types - * @{ - */ -typedef enum -{ - LED1 = 0, - LED_GREEN = LED1, - LED2 = 1, - LED_BLUE = LED2, - LED3 = 2, - LED_RED = LED3 -}Led_TypeDef; - -typedef enum -{ - BUTTON_USER = 0, - /* Alias */ - BUTTON_KEY = BUTTON_USER -}Button_TypeDef; - -typedef enum -{ - BUTTON_MODE_GPIO = 0, - BUTTON_MODE_EXTI = 1 -}ButtonMode_TypeDef; - -typedef enum -{ - JOY_NONE = 0, - JOY_SEL = 1, - JOY_DOWN = 2, - JOY_LEFT = 3, - JOY_RIGHT = 4, - JOY_UP = 5 -}JOYState_TypeDef; - -/** - * @} - */ - -/** @defgroup STM32F4XX_NUCLEO_144_LOW_LEVEL_Exported_Constants - * @{ - */ - -/** - * @brief Define for STM32F4XX_NUCLEO_144 board - */ -#if !defined (USE_STM32F4XX_NUCLEO_144) - #define USE_STM32F4XX_NUCLEO_144 -#endif - -/** @addtogroup STM32F4XX_NUCLEO_144_LOW_LEVEL_LED - * @{ - */ -#define LEDn 3 - -#define LED1_PIN GPIO_PIN_0 -#define LED1_GPIO_PORT GPIOB -#define LED1_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE() -#define LED1_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE() - -#define LED2_PIN GPIO_PIN_7 -#define LED2_GPIO_PORT GPIOB -#define LED2_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE() -#define LED2_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE() - -#define LED3_PIN GPIO_PIN_14 -#define LED3_GPIO_PORT GPIOB -#define LED3_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE() -#define LED3_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE() - -#define LEDx_GPIO_CLK_ENABLE(__INDEX__) do { if((__INDEX__) == 0) {__HAL_RCC_GPIOB_CLK_ENABLE();} else\ - {__HAL_RCC_GPIOB_CLK_ENABLE(); }} while(0) -#define LEDx_GPIO_CLK_DISABLE(__INDEX__) do { if((__INDEX__) == 0) {__HAL_RCC_GPIOB_CLK_DISABLE();} else\ - {__HAL_RCC_GPIOB_CLK_DISABLE(); }} while(0) -/** - * @} - */ - -/** @addtogroup STM32F4XX_NUCLEO_144_LOW_LEVEL_BUTTON - * @{ - */ -#define BUTTONn 1 - -/** - * @brief Key push-button - */ -#define USER_BUTTON_PIN GPIO_PIN_13 -#define USER_BUTTON_GPIO_PORT GPIOC -#define USER_BUTTON_GPIO_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE() -#define USER_BUTTON_GPIO_CLK_DISABLE() __HAL_RCC_GPIOC_CLK_DISABLE() -#define USER_BUTTON_EXTI_LINE GPIO_PIN_13 -#define USER_BUTTON_EXTI_IRQn EXTI15_10_IRQn - -#define BUTTONx_GPIO_CLK_ENABLE(__INDEX__) USER_BUTTON_GPIO_CLK_ENABLE() -#define BUTTONx_GPIO_CLK_DISABLE(__INDEX__) USER_BUTTON_GPIO_CLK_DISABLE() - -/* Aliases */ -#define KEY_BUTTON_PIN USER_BUTTON_PIN -#define KEY_BUTTON_GPIO_PORT USER_BUTTON_GPIO_PORT -#define KEY_BUTTON_GPIO_CLK_ENABLE() USER_BUTTON_GPIO_CLK_ENABLE() -#define KEY_BUTTON_GPIO_CLK_DISABLE() USER_BUTTON_GPIO_CLK_DISABLE() -#define KEY_BUTTON_EXTI_LINE USER_BUTTON_EXTI_LINE -#define KEY_BUTTON_EXTI_IRQn USER_BUTTON_EXTI_IRQn - - -/** - * @brief Discovery Pins definition - * TODO : to be modified/reviewed - */ - - -#define OTG_FS1_OVER_CURRENT_PIN GPIO_PIN_7 -#define OTG_FS1_OVER_CURRENT_PORT GPIOG -#define OTG_FS1_OVER_CURRENT_PORT_CLK_ENABLE() __HAL_RCC_GPIOG_CLK_ENABLE() - -#define OTG_FS1_POWER_SWITCH_PIN GPIO_PIN_6 -#define OTG_FS1_POWER_SWITCH_PORT GPIOG -#define OTG_FS1_POWER_SWITCH_PORT_CLK_ENABLE() __HAL_RCC_GPIOG_CLK_ENABLE() - -/** - * @} - */ - -/** @addtogroup STM32F4XX_NUCLEO_144_LOW_LEVEL_BUS - * @{ - */ -/*############################### SPI_A #######################################*/ -#ifdef HAL_SPI_MODULE_ENABLED - -#define NUCLEO_SPIx SPI1 -#define NUCLEO_SPIx_CLK_ENABLE() __HAL_RCC_SPI1_CLK_ENABLE() - -#define NUCLEO_SPIx_SCK_AF GPIO_AF5_SPI1 -#define NUCLEO_SPIx_SCK_GPIO_PORT GPIOA -#define NUCLEO_SPIx_SCK_PIN GPIO_PIN_5 -#define NUCLEO_SPIx_SCK_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE() -#define NUCLEO_SPIx_SCK_GPIO_CLK_DISABLE() __HAL_RCC_GPIOA_CLK_DISABLE() - -#define NUCLEO_SPIx_MISO_MOSI_AF GPIO_AF5_SPI1 -#define NUCLEO_SPIx_MISO_MOSI_GPIO_PORT GPIOA -#define NUCLEO_SPIx_MISO_MOSI_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE() -#define NUCLEO_SPIx_MISO_MOSI_GPIO_CLK_DISABLE() __HAL_RCC_GPIOA_CLK_DISABLE() -#define NUCLEO_SPIx_MISO_PIN GPIO_PIN_6 -#define NUCLEO_SPIx_MOSI_PIN GPIO_PIN_7 -/* Maximum Timeout values for flags waiting loops. These timeout are not based - on accurate values, they just guarantee that the application will not remain - stuck if the SPI communication is corrupted. - You may modify these timeout values depending on CPU frequency and application - conditions (interrupts routines ...). */ -#define NUCLEO_SPIx_TIMEOUT_MAX 1000 - -#define NUCLEO_SPIx_CS_GPIO_PORT GPIOD -#define NUCLEO_SPIx_CS_PIN GPIO_PIN_14 -#define NUCLEO_SPIx_CS_GPIO_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE() -#define NUCLEO_SPIx_CS_GPIO_CLK_DISABLE() __HAL_RCC_GPIOD_CLK_DISABLE() - -#define SPIx__CS_LOW() HAL_GPIO_WritePin(NUCLEO_SPIx_CS_GPIO_PORT, NUCLEO_SPIx_CS_PIN, GPIO_PIN_RESET) -#define SPIx__CS_HIGH() HAL_GPIO_WritePin(NUCLEO_SPIx_CS_GPIO_PORT, NUCLEO_SPIx_CS_PIN, GPIO_PIN_SET) - -/** - * @brief SD Control Lines management - */ -#define SD_CS_LOW() HAL_GPIO_WritePin(SD_CS_GPIO_PORT, SD_CS_PIN, GPIO_PIN_RESET) -#define SD_CS_HIGH() HAL_GPIO_WritePin(SD_CS_GPIO_PORT, SD_CS_PIN, GPIO_PIN_SET) - -/** - * @brief LCD Control Lines management - */ -#define LCD_CS_LOW() HAL_GPIO_WritePin(LCD_CS_GPIO_PORT, LCD_CS_PIN, GPIO_PIN_RESET) -#define LCD_CS_HIGH() HAL_GPIO_WritePin(LCD_CS_GPIO_PORT, LCD_CS_PIN, GPIO_PIN_SET) -#define LCD_DC_LOW() HAL_GPIO_WritePin(LCD_DC_GPIO_PORT, LCD_DC_PIN, GPIO_PIN_RESET) -#define LCD_DC_HIGH() HAL_GPIO_WritePin(LCD_DC_GPIO_PORT, LCD_DC_PIN, GPIO_PIN_SET) - -/** - * @brief SD Control Interface pins (shield D4) - */ -#define SD_CS_PIN GPIO_PIN_14 -#define SD_CS_GPIO_PORT GPIOF -#define SD_CS_GPIO_CLK_ENABLE() __HAL_RCC_GPIOF_CLK_ENABLE() -#define SD_CS_GPIO_CLK_DISABLE() __HAL_RCC_GPIOF_CLK_DISABLE() - -/** - * @brief LCD Control Interface pins (shield D10) - */ -#define LCD_CS_PIN GPIO_PIN_14 -#define LCD_CS_GPIO_PORT GPIOD -#define LCD_CS_GPIO_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE() -#define LCD_CS_GPIO_CLK_DISABLE() __HAL_RCC_GPIOD_CLK_DISABLE() - -/** - * @brief LCD Data/Command Interface pins (shield D8) - */ -#define LCD_DC_PIN GPIO_PIN_12 -#define LCD_DC_GPIO_PORT GPIOF -#define LCD_DC_GPIO_CLK_ENABLE() __HAL_RCC_GPIOF_CLK_ENABLE() -#define LCD_DC_GPIO_CLK_DISABLE() __HAL_RCC_GPIOF_CLK_DISABLE() - -#endif /* HAL_SPI_MODULE_ENABLED */ - -/*################################ ADCx for Nucleo 144 board ######################################*/ -/** - * @brief ADCx Interface pins - * used to detect motion of Joystick available on Adafruit 1.8" TFT shield - */ - -/* For some Nucleo144 boards, Arduino UNO pin7 (A3) is connected to PF3 in others to PC01 */ -#if defined(ADC3) -#define NUCLEO_ADCx ADC3 -#define NUCLEO_ADCx_CLK_ENABLE() __HAL_RCC_ADC3_CLK_ENABLE() -#define NUCLEO_ADCx_CLK_DISABLE() __HAL_RCC_ADC3_CLK_DISABLE() - -#define NUCLEO_ADCx_CHANNEL ADC_CHANNEL_9 -#define NUCLEO_ADCx_GPIO_PORT GPIOF -#define NUCLEO_ADCx_GPIO_PIN GPIO_PIN_3 -#define NUCLEO_ADCx_GPIO_CLK_ENABLE() __HAL_RCC_GPIOF_CLK_ENABLE() -#define NUCLEO_ADCx_GPIO_CLK_DISABLE() __HAL_RCC_GPIOF_CLK_DISABLE() - -#else -#define NUCLEO_ADCx ADC1 -#define NUCLEO_ADCx_CLK_ENABLE() __HAL_RCC_ADC1_CLK_ENABLE() -#define NUCLEO_ADCx_CLK_DISABLE() __HAL_RCC_ADC1_CLK_DISABLE() -#define NUCLEO_ADCx_CHANNEL ADC_CHANNEL_11 - -#define NUCLEO_ADCx_GPIO_PORT GPIOC -#define NUCLEO_ADCx_GPIO_PIN GPIO_PIN_1 -#define NUCLEO_ADCx_GPIO_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE() -#define NUCLEO_ADCx_GPIO_CLK_DISABLE() __HAL_RCC_GPIOC_CLK_DISABLE() -#endif /* HAL_ADC_MODULE_ENABLED */ - -/** - * @} - */ - -/** - * @} - */ - -/** @defgroup STM32F4XX_NUCLEO_144_LOW_LEVEL_Exported_Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F4XX_NUCLEO_144_LOW_LEVEL_Exported_Functions - * @{ - */ -uint32_t BSP_GetVersion(void); -void BSP_LED_Init(Led_TypeDef Led); -void BSP_LED_DeInit(Led_TypeDef Led); -void BSP_LED_On(Led_TypeDef Led); -void BSP_LED_Off(Led_TypeDef Led); -void BSP_LED_Toggle(Led_TypeDef Led); -void BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef ButtonMode); -void BSP_PB_DeInit(Button_TypeDef Button); -uint32_t BSP_PB_GetState(Button_TypeDef Button); -#ifdef HAL_ADC_MODULE_ENABLED -uint8_t BSP_JOY_Init(void); -JOYState_TypeDef BSP_JOY_GetState(void); -void BSP_JOY_DeInit(void); -#endif /* HAL_ADC_MODULE_ENABLED */ - - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32F4XX_NUCLEO_144_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/