From 2fff65aed2477a503c72629d27e2a330d30c02d1 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Wed, 25 Jan 2017 22:23:13 +0100 Subject: o Seemingly working Mutexes. o Dropping the privileged/unprivileged split for now. --- .../STM32303C_EVAL/stm32303c_eval_i2c_ee_cpal.h | 231 +++++++++++++++++++++ 1 file changed, 231 insertions(+) create mode 100644 thirdparty/STM32_USB-FS-Device_Lib_V4.0.0/Utilities/STM32_EVAL/STM32303C_EVAL/stm32303c_eval_i2c_ee_cpal.h (limited to 'thirdparty/STM32_USB-FS-Device_Lib_V4.0.0/Utilities/STM32_EVAL/STM32303C_EVAL/stm32303c_eval_i2c_ee_cpal.h') diff --git a/thirdparty/STM32_USB-FS-Device_Lib_V4.0.0/Utilities/STM32_EVAL/STM32303C_EVAL/stm32303c_eval_i2c_ee_cpal.h b/thirdparty/STM32_USB-FS-Device_Lib_V4.0.0/Utilities/STM32_EVAL/STM32303C_EVAL/stm32303c_eval_i2c_ee_cpal.h new file mode 100644 index 0000000..32b14e9 --- /dev/null +++ b/thirdparty/STM32_USB-FS-Device_Lib_V4.0.0/Utilities/STM32_EVAL/STM32303C_EVAL/stm32303c_eval_i2c_ee_cpal.h @@ -0,0 +1,231 @@ +/** + ****************************************************************************** + * @file stm32303c_eval_i2c_ee_cpal.h + * @author MCD Application Team + * @version V1.0.1 + * @date 23-October-2012 + * @brief This file contains all the functions prototypes for + * the stm32303c_eval_i2c_ee_cpal.c firmware driver. + ****************************************************************************** + * @attention + * + *

© COPYRIGHT 2012 STMicroelectronics

+ * + * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.st.com/software_license_agreement_liberty_v2 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32303C_EVAL_I2C_EE_CPAL_H +#define __STM32303C_EVAL_I2C_EE_CPAL_H + +#ifdef __cplusplus + extern "C" { +#endif + + +/*=================================================================================== + User NOTES +===================================================================================== + +--------------------------------- + How To use the EEPROM Driver: +--------------------------------- +----- All EEPROM operations are controlled and monitored through a single + structure. This structure holds all necessary parameters to manage EEPROM + communication (pointer to CPAL I2C device structure, EEPROM address, + EEPROM page size, EEPROM memory addressing mode, EEPROM state). + +----- User should follow these steps to use this driver correctly : + + -1- STRUCTURE INITIALIZATION + Start by initializing the structure holding EEPROM Information. To perform + this action, the global variable sEEx_DevStructure declared in EEPROM driver + as sEE_InitTypeDef (sEE1_DevStructure for EEPROM connected with I2C1, + sEE2_DevStructure for EEPROM connected with I2C1 ...) must be used. + + sEE_InitTypeDef structure contains five parameters: + + *- CPAL_InitTypeDef* sEE_CPALStructure : Pointer on a CPAL Device structure + relative to the device instantiated + to communicate with EEPROM. + + *- uint32_t sEEAddress : Contains the EEPROM device Address. + + *- uint32_t sEEPageSize : Contains the page size of EEPROM Memory. + + *- uint8_t sEEMemoryAddrMode : Bit-field value specifying Memory Addressing Mode. + + *- __IO sEE_StateTypeDef sEEState : Holds the current State of the EEPROM device. + + To configure this structure, user must initialize only three parameters + (sEEAddress, sEEPageSize, sEEMemoryAddrMode). + + Example: + sEE1_DevStructure.sEEAddress = 0xA0; // set EEPROM address to 0xA0 + sEE1_DevStructure.sEEPageSize = 32; // set page size to 32 + sEE1_DevStructure.sEEMemoryAddrMode = sEE_OPT_16BIT_REG; // enable 16Bit memory addressing mode + + -2- DEVICE CONFIGURATION + Call the function sEE_StructInit() to initialize I2Cx CPAL device structure + relative to EEPROM than call sEE_Init() to configure the selected device + with the selected configuration. + + -3- READ / WRITE OPERATIONS + Call the function sEE_WriteBuffer() or sEE_ReadBuffer() to perform transfer operations. + These functions start data transfer and exit. sEE_WriteHandler() and sEE_ReadHandler() + handle the remainder of the communication. sEE_WriteHandler() must be called in + CPAL_I2C_TXTC_UserCallback() and sEE_ReadHandler() must be called in CPAL_I2C_RXTC_UserCallback(). + These two callbacks are implemented in "cpal_usercallback.c" file. + + Example of how to implement sEE_WriteHandler() in CPAL_I2C_TXTC_UserCallback(): + + 1** Comment "#define CPAL_I2C_TXTC_UserCallback (void)" in cpal_conf.h. + 2** Implement CPAL_I2C_TXTC_UserCallback in "cpal_usercallback.c" file. + + void CPAL_I2C_TXTC_UserCallback(CPAL_InitTypeDef* pDevInitStruct) + { + sEE_WriteHandler(pDevInitStruct->CPAL_Dev); + } + + User should monitor transfer by testing the value of sEEState parameter of + sEEx_DevStructure. When transfer is ongoing sEEState is equal to sEE_STATE_WRITING + or sEE_STATE_READING. After transfer complete this parameter is set to sEE_STATE_IDLE. + + Example of how to wait until EEPROM communication finishes: + + while(sEE_GetEepromState(&sEE_DevStructure) != sEE_STATE_IDLE) + { + //Application may perform other tasks while transfer operation is ongoing + } + + -4- DEVICE DEINITIALIZATION + When transfer operations are finished, you may call sEE_DeInit() to disable I2Cx device + and related resources (GPIO, DMA , IT and NVIC) relative to used EEPROM. + +*****************************END OF User Notes**********************************************/ + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f30x_i2c_cpal.h" + +/* Exported types ------------------------------------------------------------*/ + +/*========= sEE_State_Enum =========*/ +/* sEE global State enumeration contains the current state of EEPROM. + Before starting each operation this state is tested. After each operation + sEE_State is updated with the new value resulting from the relative operation.*/ + + typedef enum +{ + sEE_STATE_IDLE = 0x01, /*!