repo_name
stringlengths
5
122
path
stringlengths
3
232
text
stringlengths
6
1.05M
AustinShalit/sysid
sysid-application/src/main/native/include/sysid/analysis/Storage.h
// Copyright (c) FIRST and other WPILib contributors. // Open Source Software; you can modify and/or share it under the terms of // the WPILib BSD license file in the root directory of this project. #pragma once #include <vector> #include <units/time.h> namespace sysid { /** * Represents each data point after it is cleaned and various parameters are * calculated. */ struct PreparedData { units::second_t timestamp; double voltage; double position; double velocity; double nextVelocity = 0.0; units::second_t dt = 0_s; double acceleration = 0.0; double cos = 0.0; constexpr bool operator==(const PreparedData& rhs) const { return timestamp == rhs.timestamp && voltage == rhs.voltage && position == rhs.position && velocity == rhs.velocity && nextVelocity == rhs.nextVelocity && dt == rhs.dt && acceleration == rhs.acceleration && cos == rhs.cos; } }; /** * Storage used by the analysis manger. */ struct Storage { // Dataset for slow (aka quasistatic) test std::vector<PreparedData> slow; // Dataset for fast (aka dynamic) test std::vector<PreparedData> fast; }; } // namespace sysid
AustinShalit/sysid
sysid-application/src/main/native/include/sysid/Util.h
<gh_stars>0 // Copyright (c) FIRST and other WPILib contributors. // Open Source Software; you can modify and/or share it under the terms of // the WPILib BSD license file in the root directory of this project. #pragma once #include <string> #include <string_view> #include <vector> #include <wpi/fs.h> // The generated AppleScript by portable-file-dialogs for just *.json does not // work correctly because it is a uniform type identifier. This means that // "public." needs to be prepended to it. #ifdef __APPLE__ #define SYSID_PFD_JSON_EXT "*.public.json" #else #define SYSID_PFD_JSON_EXT "*.json" #endif #ifdef _WIN32 #define LAUNCH "gradlew" #else #define LAUNCH "./gradlew" #endif // Based on https://gcc.gnu.org/onlinedocs/cpp/Stringizing.html #define EXPAND_STRINGIZE(s) STRINGIZE(s) #define STRINGIZE(s) #s namespace sysid { static constexpr const char* kUnits[] = {"Meters", "Feet", "Inches", "Radians", "Rotations", "Degrees"}; /** * Displays a tooltip beside the widget that this method is called after with * the provided text. * * @param text The text to show in the tooltip. */ void CreateTooltip(const char* text); /** * Splits a string into a vector of strings. * * @param s The string to split. * @param c The delimiter. * * @return The split string. */ std::vector<std::string> Split(const std::string& s, char c); /** * Returns the abbreviation for the unit. * * @param unit The unit to return the abbreviation for. * * @return The abbreviation for the unit. */ std::string GetAbbreviation(std::string_view unit); /** * Saves a file with the provided contents to a specified location. * * @param contents The file contents. * @param location The file location. */ void SaveFile(std::string_view contents, const fs::path& path); } // namespace sysid
AustinShalit/sysid
sysid-projects/drive/src/main/include/Robot.h
<reponame>AustinShalit/sysid // Copyright (c) FIRST and other WPILib contributors. // Open Source Software; you can modify and/or share it under the terms of // the WPILib BSD license file in the root directory of this project. #pragma once #include <ctre/Phoenix.h> #include <functional> #include <memory> #include <vector> #include <frc/Encoder.h> #include <frc/SpeedController.h> #include <frc/TimedRobot.h> #include <frc/interfaces/Gyro.h> #include <rev/CANEncoder.h> #include <wpi/json.h> #include <wpi/raw_istream.h> #include "logging/SysIdDrivetrainLogger.h" class Robot : public frc::TimedRobot { public: Robot(); void RobotInit() override; void RobotPeriodic() override; void AutonomousInit() override; void AutonomousPeriodic() override; void TeleopInit() override; void TeleopPeriodic() override; void SimulationPeriodic() override; void DisabledInit() override; void DisabledPeriodic() override; void TestInit() override; void TestPeriodic() override; private: std::vector<std::unique_ptr<frc::SpeedController>> m_rightControllers; std::vector<std::unique_ptr<frc::SpeedController>> m_leftControllers; std::function<double()> m_leftPosition; std::function<double()> m_leftRate; std::function<double()> m_rightPosition; std::function<double()> m_rightRate; std::function<double()> m_gyroPosition; std::function<double()> m_gyroRate; wpi::json m_json; std::unique_ptr<CANCoder> m_leftCancoder; std::unique_ptr<rev::CANEncoder> m_leftCANEncoder; std::unique_ptr<rev::CANEncoder> m_rightCANEncoder; std::unique_ptr<frc::Encoder> m_leftEncoder; std::unique_ptr<CANCoder> m_rightCancoder; std::unique_ptr<frc::Encoder> m_rightEncoder; std::unique_ptr<frc::Gyro> m_gyro; std::unique_ptr<PigeonIMU> m_pigeon; SysIdDrivetrainLogger m_logger; };
AustinShalit/sysid
sysid-projects/analysis-test/src/main/include/Elevator.h
<reponame>AustinShalit/sysid<gh_stars>0 // Copyright (c) FIRST and other WPILib contributors. // Open Source Software; you can modify and/or share it under the terms of // the WPILib BSD license file in the root directory of this project. #pragma once #include <frc/AnalogGyro.h> #include <frc/Encoder.h> #include <frc/PWMVictorSPX.h> #include <frc/RobotController.h> #include <frc/SpeedControllerGroup.h> #include <frc/simulation/ElevatorSim.h> #include <frc/simulation/EncoderSim.h> #include <frc/smartdashboard/SmartDashboard.h> #include <frc/system/plant/LinearSystemId.h> #include <wpi/math> #include "Constants.h" #include "interface/SysIdGeneralMechanism.h" /** * Represents an elevator mechanism. */ class Elevator : public SysIdGeneralMechanism { public: Elevator() { // Set the distance per pulse for the flywheel encoders. We can simply use // the 1 divided by the resolution as that denotes one rotation of the // flywheel. m_encoder.SetDistancePerPulse(2 * wpi::math::pi / kEncoderResolution); m_encoder.Reset(); } void SetMotor(units::volt_t value) override { m_group.SetVoltage(value); } double GetPosition() override { return m_encoder.GetDistance(); } double GetVelocity() override { return m_encoder.GetRate() - m_initSpeed; } void SimulationPeriodic(); void ResetReadings() { m_elevatorSimulator.SetState(frc::MakeMatrix<2, 1>(0.0, 0.0)); m_encoderSim.SetRate(0); m_encoderSim.SetDistance(0); } void Periodic() { frc::SmartDashboard::PutNumber("Elevator Speed", m_encoder.GetRate()); frc::SmartDashboard::PutNumber("Elevator Position", m_encoder.GetDistance()); } void UpdateInitialSpeed() { m_initSpeed = m_encoder.GetRate(); } private: static constexpr int kEncoderResolution = 4096; double distance = 0; double m_initSpeed = 0; frc::PWMVictorSPX m_leader{Constants::Elevator::kLeaderPort}; frc::PWMVictorSPX m_follower{Constants::Elevator::kFollowerPort}; frc::SpeedControllerGroup m_group{m_leader, m_follower}; frc::Encoder m_encoder{Constants::Elevator::kEncoderPorts[0], Constants::Elevator::kEncoderPorts[1]}; // Simulation classes help us simulate our robot frc::sim::EncoderSim m_encoderSim{m_encoder}; frc::LinearSystem<2, 1, 1> m_elevatorSystem = frc::LinearSystemId::IdentifyPositionSystem<units::radians>( Constants::Elevator::kV, Constants::Elevator::kA); frc::sim::ElevatorSim m_elevatorSimulator{m_elevatorSystem, frc::DCMotor::Vex775Pro(4), 1000, 2_in, -Constants::Elevator::kHeight, Constants::Elevator::kHeight}; };
AustinShalit/sysid
sysid-application/src/main/native/include/sysid/view/Generator.h
<filename>sysid-application/src/main/native/include/sysid/view/Generator.h // Copyright (c) FIRST and other WPILib contributors. // Open Source Software; you can modify and/or share it under the terms of // the WPILib BSD license file in the root directory of this project. #pragma once #include <array> #include <memory> #include <string> #include <vector> #include <glass/View.h> #include <portable-file-dialogs.h> #include <wpi/EventLoopRunner.h> #include <wpi/Logger.h> #include <wpi/mutex.h> #include "sysid/deploy/DeploySession.h" #include "sysid/generation/ConfigManager.h" namespace sysid { // Options static constexpr const char* kMotorControllers[] = {"PWM", "TalonSRX", "VictorSPX", "TalonFX", "SPARK MAX (Brushless)", "SPARK MAX (Brushed)", "Venom"}; static constexpr const char* kEncoders[] = {"Built-In", "CANCoder / Alternate", "roboRIO"}; static constexpr const char* kGyros[] = {"Analog", "ADXRS450", "NavX", "Pigeon", "None"}; static constexpr const char* kNavXCtors[] = {"SerialPort.kUSB", "I2C", "SerialPort.kMXP", "SPI.kMXP"}; static constexpr const char* kADXRS450Ctors[] = {"SPI.kMXP", "kOnboardCS0"}; static constexpr const char* kCTREPeriods[] = {"1", "2", "5", "10", "25", "50", "100"}; /** * The generator GUI takes care of providing the user with a user interface to * select their project parameters and then deploying the robot program to a * roboRIO. */ class Generator : public glass::View { public: explicit Generator(wpi::Logger& logger); void Display() override; static constexpr const char* kAnalysisTypes[] = {"General Mechanism", "Drivetrain", "Romi"}; private: void GeneratorUI(); void SelectCTREVelocityPeriod(); void UpdateFromConfig(); // Configuration manager along with its settings -- used to generate the JSON // configuration. std::unique_ptr<ConfigManager> m_manager; ConfigSettings m_settings; // Persistent storage pointers for project generation. double* m_pUnitsPerRotation; std::string* m_pAnalysisType; // Indices for combo boxes. int m_analysisIdx = 0; int m_encoderIdx = 2; int m_gyroIdx = 2; int m_unitsIdx = 0; int m_periodIdx = 6; // Keeps track of the number of motor ports the user wants. size_t m_occupied = 1; // CTRE Pigeon-specific parameters. int m_gyroPort = 1; int m_gyroParam = 0; bool m_isTalon = false; // Whether the user is running Spark MAX in Brushed Mode. bool m_isSparkMaxBrushed = false; // Selectors for files std::unique_ptr<pfd::save_file> m_saveConfigSelector; std::unique_ptr<pfd::open_file> m_loadConfigSelector; // Logger wpi::Logger& m_logger; // The team number for the deploy process -- can also be a hostname or IP // address of a RoboRIO. This points to the same location in memory as the // "team" field in the Logger GUI. std::string* m_pTeam; // Create a separate logger for the deploy process. We can display all output // messages in the modal popup during the deploy. wpi::Logger m_deployLogger; // Create an event loop runner (runs a libuv event loop in a separate thread) // for the deploy process. wpi::EventLoopRunner m_deployRunner; // Represents the currently running or most recent deploy session. std::unique_ptr<DeploySession> m_deploySession; // Represents storage for a log message sent from the deploy event loop. struct DeployLogMessage { std::string message; unsigned int level; }; // A vector of log messages from the deploy event loop. std::vector<DeployLogMessage> m_deployLog; // Mutex for accessing the deploy log. Because the event loop runs on a // separate thread, this mutex must be locked when reading/writing to the log. wpi::mutex m_deployMutex; }; // namespace sysid } // namespace sysid
AustinShalit/sysid
sysid-library/src/main/include/generation/SysIdSetup.h
<reponame>AustinShalit/sysid // Copyright (c) FIRST and other WPILib contributors. // Open Source Software; you can modify and/or share it under the terms of // the WPILib BSD license file in the root directory of this project. #pragma once #include <ctre/Phoenix.h> #include <functional> #include <memory> #include <string_view> #include <vector> #include <frc/Encoder.h> #include <frc/SpeedController.h> #include <units/voltage.h> #include <wpi/json.h> #include <wpi/raw_istream.h> wpi::json GetConfigJson(); void AddMotorController( int port, std::string_view controller, bool inverted, std::vector<std::unique_ptr<frc::SpeedController>>* controllers); void SetMotorControllers( units::volt_t motorVoltage, const std::vector<std::unique_ptr<frc::SpeedController>>& controllers); void SetupEncoders(std::string_view encoderType, bool isEncoding, int period, double cpr, int numSamples, std::string_view controllerName, frc::SpeedController* controller, bool encoderInverted, const std::vector<int>& encoderPorts, std::unique_ptr<CANCoder>& cancoder, std::unique_ptr<frc::Encoder>& encoder, std::function<double()>& position, std::function<double()>& rate);
AustinShalit/sysid
sysid-projects/analysis-test/src/main/include/SimpleMotor.h
<filename>sysid-projects/analysis-test/src/main/include/SimpleMotor.h // Copyright (c) FIRST and other WPILib contributors. // Open Source Software; you can modify and/or share it under the terms of // the WPILib BSD license file in the root directory of this project. #pragma once #include <frc/AnalogGyro.h> #include <frc/Encoder.h> #include <frc/PWMVictorSPX.h> #include <frc/RobotController.h> #include <frc/SpeedControllerGroup.h> #include <frc/simulation/EncoderSim.h> #include <frc/simulation/FlywheelSim.h> #include <frc/smartdashboard/SmartDashboard.h> #include <frc/system/plant/LinearSystemId.h> #include <wpi/math> #include "Constants.h" #include "interface/SysIdGeneralMechanism.h" /** * Represents a flywheel mechanism. */ class SimpleMotor : public SysIdGeneralMechanism { public: SimpleMotor() { // Set the distance per pulse for the flywheel encoders. We can simply use // the 1 divided by the resolution as that denotes one rotation of the // flywheel. m_encoder.SetDistancePerPulse(2 * wpi::math::pi / kEncoderResolution); m_encoder.Reset(); } void SetMotor(units::volt_t value) override { m_group.SetVoltage(value); } double GetPosition() override { return m_encoder.GetDistance(); } double GetVelocity() override { return m_encoder.GetRate(); } void SimulationPeriodic(); void Periodic() { frc::SmartDashboard::PutNumber("Flywheel Speed", m_encoder.GetRate()); } private: static constexpr int kEncoderResolution = 4096; double distance = 0; frc::PWMVictorSPX m_leader{Constants::SimpleMotor::kLeaderPort}; frc::PWMVictorSPX m_follower{Constants::SimpleMotor::kFollowerPort}; frc::SpeedControllerGroup m_group{m_leader, m_follower}; frc::Encoder m_encoder{Constants::SimpleMotor::kEncoderPorts[0], Constants::SimpleMotor::kEncoderPorts[1]}; // Simulation classes help us simulate our robot frc::sim::EncoderSim m_encoderSim{m_encoder}; frc::LinearSystem<1, 1, 1> m_flywheelSystem = frc::LinearSystemId::IdentifyVelocitySystem<units::radians>( Constants::SimpleMotor::kV, Constants::SimpleMotor::kA); frc::sim::FlywheelSim m_flywheelSimulator{m_flywheelSystem, frc::DCMotor::Vex775Pro(2), 1.0}; };
AustinShalit/sysid
sysid-library/src/main/include/logging/SysIdDrivetrainLogger.h
<reponame>AustinShalit/sysid<filename>sysid-library/src/main/include/logging/SysIdDrivetrainLogger.h // Copyright (c) FIRST and other WPILib contributors. // Open Source Software; you can modify and/or share it under the terms of // the WPILib BSD license file in the root directory of this project. #pragma once #include <units/voltage.h> #include "logging/SysIdLogger.h" // TODO Set to proper number after telemetry data refactor class SysIdDrivetrainLogger : public SysIdLogger { public: /** * The users should their left motors to what this returns AFTER calling log. */ units::volt_t GetLeftMotorVoltage() const; /** * The users should set their right motors to what this returns AFTER calling * log. */ units::volt_t GetRightMotorVoltage() const; /** * Logs data for a drivetrain mechanism. * * Outputs data in form: timestamp, l voltage, r voltage, l position, r * position, l velocity, r velocity, angle, angular rate * * @param leftPosition the recorded rotations of the left shaft * @param rightPosition the recorded rotations of the right shaft * @param leftVelocity the recorded rotations per second of the left shaft * @param rightVelocity the recorded rotations per second or the right shaft * @param measuredAngle the recorded angle of they gyro * @param angularRate the recorded angular rate of the gyro in radians per * second */ void Log(double leftPosition, double rightPosition, double leftVelocity, double rightVelocity, double measuredAngle, double angularRate); void Reset() override; bool IsWrongMechanism() const override; private: units::volt_t m_primaryMotorVoltage = 0_V; units::volt_t m_secondaryMotorVoltage = 0_V; };
AustinShalit/sysid
sysid-application/src/main/native/include/sysid/view/AnalyzerPlot.h
// Copyright (c) FIRST and other WPILib contributors. // Open Source Software; you can modify and/or share it under the terms of // the WPILib BSD license file in the root directory of this project. #pragma once #include <array> #include <atomic> #include <string> #include <vector> #include <imgui.h> #include <implot.h> #include <units/time.h> #include <units/voltage.h> #include <wpi/Logger.h> #include <wpi/StringMap.h> #include <wpi/spinlock.h> #include "sysid/analysis/AnalysisManager.h" #include "sysid/analysis/AnalysisType.h" #include "sysid/analysis/FeedforwardAnalysis.h" namespace sysid { /** * Class that helps with plotting data in the analyzer view. */ class AnalyzerPlot { public: // The chart titles of the plots that we wil create. static constexpr const char* kChartTitles[] = { "Quasistatic Velocity vs. Velocity-Portion Voltage", "Dynamic Acceleration vs. Acceleration-Portion Voltage", "Quasistatic Velocity vs. Time", "Quasistatic Acceleration vs. Time", "Dynamic Velocity vs. Time", "Dynamic Acceleration vs. Time", "Timesteps vs. Time"}; // Size of plots when screenshotting static constexpr int kCombinedPlotSize = 300; /** * Constructs an instance of the analyzer plot helper and allocates memory for * all data vectors. */ explicit AnalyzerPlot(wpi::Logger& logger); /** * Sets the raw data to be displayed on the plots. * * @param rawData Raw data storage. * @param filteredData Filtered data storage. * @param ffGains List of feedforward gains (Ks, Kv, Ka, and optionally * either Kg or Kcos). * @param startTimes Array of dataset start times. * @param type Type of analysis. * @param abort Aborts analysis early if set to true from another * thread. */ void SetData(const Storage& rawData, const Storage& filteredData, const std::string& unit, const std::vector<double>& ff, const std::array<units::second_t, 4>& startTimes, AnalysisType type, std::atomic<bool>& abort); /** * Displays voltage-domain plots. * * @return Returns true if plots aren't in the loading state */ bool DisplayVoltageDomainPlots(ImVec2 plotSize = ImVec2(-1, 0)); /** * Displays time-domain plots. * * @return Returns true if plots aren't in the loading state */ bool DisplayTimeDomainPlots(ImVec2 plotSize = ImVec2(-1, 0)); void DisplayCombinedPlots(); bool LoadPlots(); void FitPlots(); double* GetRMSE() { return &m_RMSE; } private: // The maximum size of each vector (dataset to plot). static constexpr size_t kMaxSize = 2048; // Stores ImPlotPoint vectors for all of the data. wpi::StringMap<std::vector<ImPlotPoint>> m_filteredData; wpi::StringMap<std::vector<ImPlotPoint>> m_rawData; std::string m_velocityLabel; std::string m_accelerationLabel; // Stores points for the lines of best fit. ImPlotPoint m_KvFit[2]; ImPlotPoint m_KaFit[2]; // Stores points for simulated time-domain data. std::vector<std::vector<ImPlotPoint>> m_quasistaticSim; std::vector<std::vector<ImPlotPoint>> m_dynamicSim; double m_RMSE; // Stores differences in time deltas std::vector<std::vector<ImPlotPoint>> m_dt; std::vector<ImPlotPoint> m_dtMeanLine; // Thread safety wpi::spinlock m_mutex; // Logger wpi::Logger& m_logger; // Stores whether this was the first call to Plot() since setting data. std::array<bool, sizeof(kChartTitles) / sizeof(kChartTitles[0])> m_fitNextPlot{}; }; } // namespace sysid
Siminov/android-samples
Core-Library-Sample/iOS/Siminov/Core/Library/Sample/Model/Credential.h
<filename>Core-Library-Sample/iOS/Siminov/Core/Library/Sample/Model/Credential.h /// /// [SIMINOV FRAMEWORK] /// Copyright [2014-2016] [Siminov Software Solution LLP|<EMAIL>] /// /// Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 /// /// 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. /// #import <Foundation/Foundation.h> #import "SICDatabase.h" static NSString * const TABLE_NAME = @"CONNECT-CREDENTIAL"; static NSString * const ACCOUNT_ID = @"ACCOUNT_ID"; static NSString * const CREDENTIAL_TYPE = @"CREDENTIAL_TYPE"; static NSString * const TOKEN = @"TOKEN"; static NSString * const LOGGED = @"LOGGED"; static NSString * const CREDENTIAL_TYPE_SIMINOV = @"SIMINOV"; @interface Credential : SICDatabase { NSString *accountId; NSString *credentialType; NSString *token; NSString *logged; } -(NSString *)getAccountId; -(void)setAccountId: (NSString *)accountid; -(NSString *)getCredentialType; -(void)setCredentialType: (NSString *)credentialtype; -(NSString *)getToken; -(void)setToken: (NSString *)tokenValue; -(NSString *)getLogged; -(void)setLogged: (NSString *)log; -(BOOL)isLogged; @end
Siminov/android-samples
Core-Sample/iOS/Siminov/Core/Sample/Model/BookShopMapping.h
/// /// [SIMINOV FRAMEWORK] /// Copyright [2014-2016] [Siminov Software Solution LLP|<EMAIL>] /// /// Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 /// /// 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. /// #import "SICDatabase.h" #import "Book.h" #import "Shop.h" //Table Name static NSString * const BOOK_SHOP_MAPPING_TABLE_NAME = @"BOOK_SHOP_MAPPING"; @interface BookShopMapping : SICDatabase { //Variables Book *book; Shop *shop; } //Method Names -(Book *)getBook; -(void)setBook:(Book *)bk; -(Shop *)getShop; -(void)setShop:(Shop *)shop; @end
Siminov/android-samples
Core-Sample/iOS/Siminov/Core/Sample/Model/Lession.h
/// /// [SIMINOV FRAMEWORK] /// Copyright [2014-2016] [Siminov Software Solution LLP|<EMAIL>] /// /// Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 /// /// 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. /// #import <Foundation/Foundation.h> #import "Book.h" //Table Name static NSString * const LESSION_TABLE_NAME = @"LESSION"; //Column Names static NSString * const LESSION_BOOK_TITLE = @"TITLE"; static NSString * const LESSION_BRAND_NAME = @"NAME"; static NSString * const LESSION_DESCRIPTION = @"DESCRIPTION"; static NSString * const LESSION_LINK = @"LINK"; //Lessions /* * C Book Lessions */ static NSString * const C_FIRST_LESSION = @"C First Lession"; static NSString * const C_SECOND_LESSION = @"C Second Lession"; /* * C++ Lessions */ static NSString * const C_PLUS_FIRST_LESSION = @"C++ First Lession"; static NSString * const C_PLUS_SECOND_LESSION = @"C++ Second Lession"; /* * C# Lessions */ static NSString * const C_SHARP_FIRST_LESSION = @"C# First Lession"; static NSString * const C_SHARP_SECOND_LESSION = @"C# Second Lession"; /* * Java Lessions */ static NSString * const JAVA_FIRST_LESSION = @"Java First Lession"; static NSString * const JAVA_SECOND_LESSION = @"Java Second Lession"; //JavaScript Lessions static NSString * const JAVASCRIPT_FIRST_LESSION = @"JavaScript First Lession"; static NSString * const JAVASCRIPT_SECOND_LESSION = @"JavaScript Second Lession"; //Objective C Lessions static NSString * const OBJECTIVEC_FIRST_LESSION = @"Objective C First Lession"; static NSString * const OBJECTIVEC_SECOND_LESSION = @"Objective C Second Lession"; //Swift Lessions static NSString * const SWIFT_FIRST_LESSION = @"Swift First Lession"; static NSString * const SWIFT_SECOND_LESSION = @"Swift Second Lession"; @interface Lession : SICDatabase { //Variables Book *book; NSString *name; NSString *description; NSString *link; } //Methods -(Book *)getBook; -(void)setBook:(Book *)bk; -(NSString *)getName; -(void)setName: (NSString *)nme; -(NSString *)getDescription; -(void)setDescription: (NSString *)desc; -(NSString *)getLink; -(void)setLink: (NSString *)lin; @end
Siminov/android-samples
Core-Sample/iOS/Siminov/Core/Sample/Model/BookAndLessionJoin.h
/// /// [SIMINOV FRAMEWORK] /// Copyright [2014-2016] [Siminov Software Solution LLP|<EMAIL>] /// /// Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 /// /// 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. /// #import "SICDatabase.h" @interface BookAndLessionJoin : SICDatabase { NSString *author; NSString *name; } - (NSString *)getAuthor; - (void)setAuthor:(NSString *)aut; - (NSString *)getName; - (void)setName:(NSString *)nme; @end
Siminov/android-samples
Connect-Sample/iOS/Siminov/Connect/Sample/CredentialManager.h
<filename>Connect-Sample/iOS/Siminov/Connect/Sample/CredentialManager.h /// /// [SIMINOV FRAMEWORK] /// Copyright [2014-2016] [Siminov Software Solution LLP|<EMAIL>] /// /// Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 /// /// 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. /// #import <Foundation/Foundation.h> #import "Credential.h" @interface CredentialManager : NSObject + (CredentialManager *)getInstance; - (BOOL)isAnyActiveCredential; - (Credential *)getActiveCredential; - (NSEnumerator *)getCredentails; - (void)setActiveCredential:(Credential *)credential; @end
Siminov/android-samples
Connect-Sample/iOS/Siminov/Connect/Sample/Model/Book.h
<reponame>Siminov/android-samples<filename>Connect-Sample/iOS/Siminov/Connect/Sample/Model/Book.h<gh_stars>1-10 /// /// [SIMINOV FRAMEWORK] /// Copyright [2014-2016] [Siminov Software Solution LLP|<EMAIL>] /// /// Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 /// /// 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. /// #import <Foundation/Foundation.h> #import "SICDatabase.h" //Table Name static NSString * const BOOK_TABLE_NAME = @"BOOK"; //Column Names static NSString * const BOOK_TITLE = @"TITLE"; static NSString * const BOOK_DESCRIPTION = @"DESCRIPTION"; static NSString * const BOOK_AUTHOR = @"AUTHOR"; static NSString * const BOOK_LINK = @"LINK"; //Book Types static NSString * const BOOK_TYPE_C = @"C"; static NSString * const BOOK_TYPE_C_PLUS = @"C++"; static NSString * const BOOK_TYPE_C_SHARP = @"C#"; static NSString * const BOOK_TYPE_JAVA = @"Java"; static NSString * const BOOK_TYPE_JAVASCRIPT = @"JavaScript"; static NSString * const BOOK_TYPE_OBJECTIVEC = @"Objective C"; static NSString * const BOOK_TYPE_SWIFT = @"Swift"; @interface Book : SICDatabase { //Variables NSString *title; NSString *description; NSString *author; NSString *link; NSMutableArray *lessions; } //Methods -(NSString *)getTitle; -(void)setTitle:(NSString *)tit; -(NSString *)getDescription; -(void)setDescription: (NSString *)desc; -(NSString *)getAuthor; -(void)setAuthor: (NSString *)aut; -(NSString *)getLink; -(void)setLink: (NSString *)lin; -(NSEnumerator *)getLessions; -(void)setLessions: (NSEnumerator *)lessions; @end
Siminov/android-samples
Hybrid-Phonegap-Sample/iOS/hybrid-phonegap-sample/ViewController.h
<reponame>Siminov/android-samples<filename>Hybrid-Phonegap-Sample/iOS/hybrid-phonegap-sample/ViewController.h<gh_stars>1-10 // // ViewController.h // hybrid-phonegap-sample // // Created by user on 09/08/15. // Copyright (c) 2015 Siminov. All rights reserved. // #import <UIKit/UIKit.h> @interface ViewController : UIViewController<UIWebViewDelegate> /* *While holding down the Control key, click and drag the Web View from the View Controller Scene to the ViewController.h edit screen, placing it just below the @interface line. */ @property (weak, nonatomic) IBOutlet UIWebView *webView; @end
Siminov/android-samples
Connect-Sample/iOS/Siminov/Connect/Sample/Model/Credential.h
<gh_stars>1-10 /// /// [SIMINOV FRAMEWORK] /// Copyright [2014-2016] [Siminov Software Solution LLP|<EMAIL>] /// /// Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 /// /// 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. /// #import "SICDatabase.h" //Column Names static NSString * const ACCOUNT_ID = @"ACCOUNT_ID"; static NSString * const TOKEN = @"TOKEN"; static NSString * const ACTIVE = @"ACTIVE"; @interface Credential : SICDatabase { NSString *accountId; NSString *token; BOOL active; } - (NSString *)getAccountId; - (void)setAccountId:(NSString *) accountid; - (NSString *)getToken; - (void)setToken:(NSString *)tok; - (BOOL)getActive; - (BOOL)isActive; - (void)setActive:(BOOL)act; @end
Siminov/android-samples
Core-Sqlcipher-Sample/iOS/Siminov/Core/Sqlcipher/Sample/Model/Model.h
<filename>Core-Sqlcipher-Sample/iOS/Siminov/Core/Sqlcipher/Sample/Model/Model.h /// /// [SIMINOV FRAMEWORK] /// Copyright [2015] [Siminov Software Solution LLP|<EMAIL>] /// /// Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 /// /// 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. /// #import <UIKit/UIKit.h> #import "SICDatabase.h" //Table Name. static NSString * const TABLE_NAME = @"MODEL"; //Column Names. static NSString * const COLUMN_ONE = @"COLUMN_ONE"; static NSString * const COLUMN_TWO = @"COLUMN_TWO"; @interface Model : SICDatabase { NSString *columnOne; NSString *columnTwo; } - (NSString *)getColumnOne; - (void)setColumnOne:(NSString *)columnone; - (NSString *)getColumnTwo; - (void)setColumnTwo:(NSString *)columntwo; @end
Siminov/android-samples
Core-Sample/iOS/Siminov/Core/Sample/Model/Shop.h
/// /// [SIMINOV FRAMEWORK] /// Copyright [2014-2016] [Siminov Software Solution LLP|<EMAIL>] /// /// Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 /// /// 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. /// #import <Foundation/Foundation.h> #import "SICDatabase.h" //Table Name static NSString * const SHOP_TABLE_NAME = @"SHOP"; //Column Names static NSString * const SHOP_ID = @"SHOP_ID"; static NSString * const NAME = @"NAME"; static NSString * const ADDRESS = @"ADDRESS"; @interface Shop : SICDatabase { //Variables NSNumber *shopId; NSString *name; NSString *address; } //Methods -(NSNumber *)getShopId; -(void)setShopId:(NSNumber *)shop; -(NSString *)getName; -(void)setName:(NSString *)shopName; -(NSString *)getAddress; -(void)setAddress:(NSString *)shopAddress; @end
Siminov/android-samples
Connect-Sample/iOS/Siminov/Connect/Sample/Constants.h
/// /// [SIMINOV FRAMEWORK] /// Copyright [2014-2016] [Siminov Software Solution LLP|<EMAIL>] /// /// Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 /// /// 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. /// #import <Foundation/Foundation.h> /* * Books Constants */ static NSString *GET_BOOKS_WS_BOOKS = @"books"; static NSString *GET_BOOKS_WS_BOOK = @"book"; static NSString *GET_BOOKS_WS_BOOK_TITLE = @"name"; static NSString *GET_BOOKS_WS_BOOK_DESCRIPTION = @"description"; static NSString *GET_BOOKS_WS_BOOK_AUTHOR = @"author"; static NSString *GET_BOOKS_WS_BOOK_LINK = @"link"; /* * Lessions Constants */ static NSString *GET_LESSIONS_WS_LESSIONS = @"lessions"; static NSString *GET_LESSIONS_WS_LESSION = @"lession"; static NSString *GET_LESSIONS_WS_LESSION_NAME = @"name"; static NSString *GET_LESSIONS_WS_LESSION_DESCRIPTION = @"description"; static NSString *GET_LESSIONS_WS_LESSION_LINK = @"link"; /* * Sync Constants */ static NSString *SYNC_BOOKS = @"SYNC-BOOKS"; static NSString *SYNC_LESSIONS = @"SYNC-LESSIONS"; /* * Add Book Constants */ static NSString *ADD_BOOK_WS_BOOK = @"book"; static NSString *ADD_BOOK_WS_BOOK_TITLE = @"title"; static NSString *ADD_BOOK_WS_BOOK_DESCRIPTION = @"description"; static NSString *ADD_BOOK_WS_BOOK_AUTHOR = @"author"; static NSString *ADD_BOOK_WS_BOOK_LINK = @"link"; static NSString *ADD_BOOK_WS_LESSIONS = @"brands"; static NSString *ADD_BOOK_WS_LESSION = @"brand"; static NSString *ADD_BOOK_WS_LESSION_NAME = @"name"; static NSString *ADD_BOOK_WS_LESSION_DESCRIPTION = @"description"; static NSString *ADD_BOOK_WS_LESSION_LINK = @"link";
Siminov/android-samples
Hybrid-Native-Script-Sample/platforms/ios/HybridNativeScriptSample/SIHNativeScriptInterceptor.h
<reponame>Siminov/android-samples // // SIHReactInterceptor.h // hybridReactSample // // Created by user on 15/10/15. // Copyright © 2015 Facebook. All rights reserved. // #import <Foundation/Foundation.h> //#include "SICResourceManager.h" //#include "SIHResourceManager.h" //#include "SIHAdapterFactory.h" @interface SIHNativeScriptInterceptor : NSObject//<SIHIHandler> @end
Siminov/android-samples
Core-Sample/iOS/Siminov/Core/Sample/Model/Pricing.h
<filename>Core-Sample/iOS/Siminov/Core/Sample/Model/Pricing.h /// /// [SIMINOV FRAMEWORK] /// Copyright [2014-2016] [Siminov Software Solution LLP|<EMAIL>] /// /// Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 /// /// 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. /// #import "SICDatabase.h" @class Book; //Table Name static NSString * const PRICING_TABLE_NAME = @"PRICING"; //Column Names static NSString * const PRICE_ID = @"PRICE_ID"; static NSString * const PRICE = @"PRICE"; static NSString * const TAX = @"TAX"; static NSString * const DISCOUNT = @"DISCOUNT"; @interface Pricing : SICDatabase { //Variables NSNumber *priceId; NSNumber *price; NSNumber *tax; NSNumber *discount; Book *book; } //Methods -(NSNumber *)getPriceId; -(void)setPriceId:(NSNumber *)priceid; -(NSNumber *)getPrice; -(void)setPrice:(NSNumber *)prc; -(NSNumber *)getTax; -(void)setTax:(NSNumber *)tx; -(NSNumber *)getDiscount; -(void)setDiscount:(NSNumber *)disc; -(Book *)getBook; -(void)setBook:(Book *)bk; @end
jaccharrison/ece422_project4
main.c
#include <msp430.h> #include <cs.h> #include <lcd.h> void init_gpio(void); void init_clocks(void); void lcd_print_char(char); void lcd_return_home(void); int main(void) { WDTCTL = WDTPW | WDTHOLD; /* Stop watchdog timer */ init_gpio(); init_clocks(); /* Count out 15ms with a timer; on expiration, initialize LCD */ TA3CCR0 = LCD_WAIT1; TA3CCTL0 |= CCIE; /* Enable interrupt */ TA3CTL = (TASSEL__SMCLK | ID_1 | MC__UP); /* Enable TA3 in up mode */ _BIS_SR(GIE); LPM1; /* Enter LPM3 until LCD is ready for config */ init_lcd(TWO_LINES, SMALL_FONT); /* Begin LCD driver demo */ char *c = "Benjamin\nLewandowski"; char *mi = "A."; char *mn = "Alex"; lcd_print_str(c); lcd_set_cur(10, 1); lcd_print_str(mi); lcd_set_cur(3, 2); lcd_print_char('v'); lcd_place_str(mn, 10, 1); lcd_clr_screen(); for(;;); return 0; } /** * init_gpio * Configures I/O on the MSP430 such that: * - Pins in port 2 will be used to control the LCD as shown below: * MSP430: | PIN 6 | PIN 5 | PIN 4 | PIN 3 | PIN 2 | PIN 1 | PIN 0 | * LCD: | R/~W | RS | E | DB7 | DB6 | DB5 | DB4 | * - Pins 3.4 and 3.5 are setup for backchannel UART */ void init_gpio(void) { PM5CTL0 &= ~LOCKLPM5; /* Unlock GPIO pins */ /* I/O for 'advance' button */ P1DIR = 0; P1REN |= (BIT1 | BIT2); P1OUT |= (BIT1 | BIT2); /* I/O for the LCD display */ P2DIR = LCD_PINS; /* Sets pins 2.0-2.5 as outputs to control LCD */ P2OUT = 0; /* Clear output on P2 */ /* I/O for backchannel UART - select primary peripheral function */ P3SEL0 |= (BIT4 | BIT5); P3SEL1 &= ~(BIT4 | BIT5); } void init_clocks(void) { /* Sets the DCO Frequency to 8MHz */ CS_setDCOFreq(CS_DCORSEL_0, CS_DCOFSEL_6); /* Set MCLK to 8MHz - source DCO at 8MHz with divider of 1 */ CS_initClockSignal(CS_MCLK, CS_DCOCLK_SELECT, CS_CLOCK_DIVIDER_1); /* Set SMCLK to 4MHz - source DCO at 8MHz with divider of 2 */ CS_initClockSignal(CS_SMCLK, CS_DCOCLK_SELECT, CS_CLOCK_DIVIDER_2); /* Set ACLK to ~9.4kHz - source VLO with a divider of 1 */ CS_initClockSignal(CS_ACLK, CS_VLOCLK_SELECT, CS_CLOCK_DIVIDER_1); } /* Port 1 vector - used to advance through the demo */ #pragma vector = PORT1_VECTOR __interrupt void PORT1_ISR(void) { LPM1_EXIT; return; }
jaccharrison/ece422_project4
lcd.h
<reponame>jaccharrison/ece422_project4<filename>lcd.h /** * External LCD API * Contains functions for the initialization, configuration, and control of an * external HD44780U LCD display. Use of the LCD requires: * - Pins 2.0-2.7 */ #ifndef LCD_H #define LCD_H #include <msp430.h> /* Device header file */ /* Pin definitions */ #define LCD_PINS 0x3F /* Pins 2.0 - 2.6 */ #define LCD_DATA_PINS 0x0F /* Pins 2.0-2.3 */ #define LCD_E (BIT4) /* Pin 4 of LCD control pins */ #define LCD_RS (BIT5) /* Pin 5 of LCD control pins */ /* Wait times for initialization */ #define LCD_WAIT1 60100 /* ACLK cycles to wait for initial 15 ms delay */ #define LCD_WAIT2 16500 /* 4.1 ms second stage delay req'd during init */ #define LCD_WAIT3 6400 /* >= 100us third stage delay req'd during init */ /* LCD control bit patterns */ #define LCD_CLEAR_DISP 0x01 /* Clears display */ #define LCD_RETURN_HOME 0x02 /* Returns cursor to home position */ #define ONE_LINE 0x00 /* One line mode */ #define TWO_LINES 0x01 /* Two line mode */ #define SMALL_FONT 0x00 /* Smaller font */ #define BIG_FONT 0x01 /* Bigger font for 1 line mode only */ #define LCD_ENTRY_MODE_SET 0x04 /* Sets write mode */ #define LCD_ENTRY_INC 0x02 /* If set, moves cursor to the right after write */ #define LCD_ENTRY_SHIFT 0x01 /* If set, moves display instead of cursor */ #define LCD_DISP_CTL 0x08 /* Configure display control */ #define LCD_DISP_ON 0x04 /* Turns on LCD display */ #define LCD_DISP_CURSOR 0x02 /* Shows LCD cursor */ #define LCD_CURSOR_BLINK 0x01 /* Causes cursor to blink */ #define LCD_FUNC_SET 0x20 /* Function set */ #define LCD_INIT 0x03 /* 4-bit version of LCD_FUNC_SET | LCD_FUNC_8BIT */ #define LCD_FUNC_8BIT 0x10 /* If set, LCD inits into 8-bit mode */ #define LCD_FUNC_2LINE 0x80 /* If set, both LCD lines are enabled */ #define LCD_ALT_FONT 0x40 /* If set, LCD uses alternate font */ #define LCD_SET_4BIT 0x02 /* Control pattern to set 4-bit operation */ void init_lcd(int, int); /* LCD intialization function */ void lcd_print(char); /* Prints a single character on the LCD */ void lcd_print_str(char *); /* Prints a message on the LCD */ void lcd_place_str(char *, int, int); /* Prints a message at a given position */ void lcd_clr_screen(void); /* Clears the LCD screen */ void lcd_set_cur(int, int); /* Set new cursor position */ void lcd_return_home(void); /* Reset position to (upper) left corner */ #endif
jaccharrison/ece422_project4
drivers/lcd.c
p#include "lcd.h" #define LCD_4bit_tx(A) \ P2OUT &= 0xF0; P2OUT |= 0x0F & A; P2OUT |= LCD_E; P2OUT &= ~LCD_E; #define LCD_wait() TA3CCR0 |= CCIE; TA3CTL = (TASSEL_2 | MC_1); \ _BIS_SR(LPM1_bits); void LCD_txbyte(char); /* Internal function used to send data to the LCD */ /** * init_lcd * Initializes the microcontroller for use with an external HD44780U LCD * display on port 2. * * The following code should either be copied into the initialization function * below or included in an init_gpio function: * P2DIR = LCD_PINS; // Sets pins 2.0-2.5 as outputs to control LCD * * 15ms must have passed between LCD power-on and execution of this function. */ void init_lcd(void) { TA3CCR0 = 800; /* Send a sequence of instructions that forces re-init of the LCD */ LCD_4bit_tx(LCD_INIT); TA3CCR0 = LCD_WAIT2; TA3CCTL0 |= CCIE; /* Wait >= 4.1 ms */ TA3CTL = (TASSEL__SMCLK | ID_1 | MC__UP); _BIS_SR(GIE | LPM1_bits); /* Enter LPM3 until timer completes */ LCD_4bit_tx(LCD_INIT); TA3CCR0 = LCD_WAIT3; TA3CCTL0 |= CCIE; /* Wait for >= 100us */ TA3CTL = (TASSEL__SMCLK | ID_1 | MC__UP); _BIS_SR(GIE | LPM1_bits); /* Enter LPM3 until timer completes */ LCD_txbyte(LCD_FUNC_SET | LCD_FUNC_8BIT | LCD_SET_4BIT); /* Finalize 4-bit interface mode and set font set 1 display line */ LCD_txbyte(LCD_FUNC_SET); /* Set the display mode */ LCD_txbyte(0x0F); /* Clear the display */ LCD_txbyte(LCD_CLEAR_DISP); /* Set entry point to home */ LCD_txbyte(LCD_RETURN_HOME); /* Set cursor to move to the right after a character is written */ LCD_txbyte(LCD_ENTRY_MODE_SET | LCD_ENTRY_INC); LCD_wait(); } /** * LCD_txbyte * Internal utility function - the real way that any byte of data gets sent to * the LCD. This is only used by other functions in the external LCD API - it * is not part of the API. */ void LCD_txbyte(char c) { LCD_4bit_tx((c & 0xF0) >> 4); LCD_wait(); LCD_4bit_tx(c & 0x0F) LCD_wait(); return; } /** * lcd_print_char * Prints a single character on the LCD */ void lcd_print_char(char c) { P2OUT |= LCD_RS; LCD_txbyte(c); P2OUT &= ~LCD_RS; LCD_wait(); } /** * lcd_print_str * Prints a null-terminated string starting at the address pointed to by the * argument */ void lcd_print_str(char* c) { while (*c) { P2OUT |= LCD_RS; LCD_txbyte(*(c++)); P2OUT &= ~LCD_RS; LCD_wait(); } return; } /** * lcd_clr_screen * Clears the lcd screen */ void lcd_clr_screen(void) { LCD_txbyte(LCD_CLEAR_DISP); LCD_wait(); return; } /** * TIMER3_A1_VECTOR * Interrupt vector responsible for various timing delays */ #pragma vector = TIMER3_A0_VECTOR __interrupt void TIMER3_A0_ISR(void) { TA3CTL = 0; /* Turn off TA3 */ TA3R = 0; /* Clear counter */ _BIC_SR(LPM1_EXIT); /* Exit LPM3 */ return; }
jaccharrison/ece422_project4
drivers/lcd.h
/** * External LCD API * Contains functions for the initialization, configuration, and control of an * external HD44780U LCD display. Use of the LCD requires: * - Pins 2.0-2.7 */ #ifndef LCD_H #define LCD_H #include <msp430.h> /* Device header file */ /* Pin definitions */ #define LCD_PINS 0x3F /* Pins 2.0 - 2.6 */ #define LCD_DATA_PINS 0x0F /* Pins 2.0-2.3 */ #define LCD_E (BIT4) /* Pin 4 of LCD control pins */ #define LCD_RS (BIT5) /* Pin 5 of LCD control pins */ /* Wait times for initialization */ #define LCD_WAIT1 60100 /* ACLK cycles to wait for initial 15 ms delay */ #define LCD_WAIT2 16500 /* 4.1 ms second stage delay req'd during init */ #define LCD_WAIT3 400 /* >= 100us third stage delay req'd during init */ /* LCD control bit patterns */ #define LCD_CLEAR_DISP 0x01 /* Clears display */ #define LCD_RETURN_HOME 0x02 /* Returns cursor to home position */ #define LCD_ENTRY_MODE_SET 0x04 /* Sets write mode */ #define LCD_ENTRY_INC 0x02 /* If set, moves cursor to the right after write */ #define LCD_ENTRY_SHIFT 0x01 /* If set, moves display instead of cursor */ #define LCD_DISP_CTL 0x08 /* Configure display control */ #define LCD_DISP_ON 0x04 /* Turns on LCD display */ #define LCD_DISP_CURSOR 0x02 /* Shows LCD cursor */ #define LCD_CURSOR_BLINK 0x01 /* Causes cursor to blink */ #define LCD_FUNC_SET 0x20 /* Function set */ #define LCD_INIT 0x03 /* 4-bit version of LCD_FUNC_SET | LCD_FUNC_8BIT */ #define LCD_FUNC_8BIT 0x10 /* If set, LCD inits into 8-bit mode */ #define LCD_FUNC_2LINE 0x80 /* If set, both LCD lines are enabled */ #define LCD_ALT_FONT 0x40 /* If set, LCD uses alternate font */ #define LCD_SET_4BIT 0x02 /* Control pattern to set 4-bit operation */ void init_lcd(void); /* LCD intialization function */ void lcd_print(char); /* Prints a single character on the LCD */ void lcd_print_str(char*); /* Prints a message on the LCD */ void lcd_clr_screen(void); /* Clears the LCD screen */ #endif
jaccharrison/ece422_project4
lcd.c
<reponame>jaccharrison/ece422_project4<gh_stars>0 #include "lcd.h" #define LCD_4bit_tx(A) \ P2OUT &= 0xF0; P2OUT |= 0x0F & A; P2OUT |= LCD_E; P2OUT &= ~LCD_E #define LCD_wait() TA3CCTL0 |= CCIE; TA3CTL = (TASSEL_2 | MC_1); \ LPM1 void LCD_txbyte(char); /* Internal function used to send data to the LCD */ /** * init_lcd * Initializes the microcontroller for use with an external HD44780U LCD * display on port 2. * * The following code should either be copied into the initialization function * below or included in an init_gpio function: * P2DIR = LCD_PINS; // Sets pins 2.0-2.5 as outputs to control LCD * * 15ms must have passed between LCD power-on and execution of this function. */ void init_lcd(int lines, int font) { TA3CCR0 = 800; /* Send a sequence of instructions that forces re-init of the LCD */ LCD_4bit_tx(LCD_INIT); TA3CCR0 = LCD_WAIT2; TA3CCTL0 |= CCIE; /* Wait >= 4.1 ms */ TA3CTL = (TASSEL__SMCLK | ID_1 | MC__UP); LPM1; /* Enter LPM3 until timer completes */ LCD_4bit_tx(LCD_INIT); TA3CCR0 = LCD_WAIT3; TA3CCTL0 |= CCIE; /* Wait for >= 100us */ TA3CTL = (TASSEL__SMCLK | ID_1 | MC__UP); LPM1; /* Enter LPM3 until timer completes */ LCD_txbyte(LCD_FUNC_SET | LCD_FUNC_8BIT | LCD_SET_4BIT); /* Finalize 4-bit interface mode and set font set display lines */ LCD_txbyte(LCD_FUNC_SET + (lines << 3) + (font << 2)); /* Set the display mode */ LCD_txbyte(0x0F); /* Clear the display */ LCD_txbyte(LCD_CLEAR_DISP); /* Set entry point to home */ LCD_txbyte(LCD_RETURN_HOME); /* Set cursor to move to the right after a character is written */ LCD_txbyte(LCD_ENTRY_MODE_SET | LCD_ENTRY_INC); LCD_wait(); } /** * LCD_txbyte * Internal utility function - the real way that any byte of data gets sent to * the LCD. This is only used by other functions in the external LCD API - it * is not part of the API. */ void LCD_txbyte(char c) { LCD_4bit_tx((c & 0xF0) >> 4); LCD_wait(); LCD_4bit_tx(c & 0x0F); LCD_wait(); return; } /** * lcd_print_char * Prints a single character on the LCD */ void lcd_print_char(char c) { P2OUT |= LCD_RS; LCD_txbyte(c); P2OUT &= ~LCD_RS; LCD_wait(); } /** * lcd_print_str * Prints a null-terminated string starting at the address pointed to by the * argument which contains a maximum of one new line character */ void lcd_print_str(char *c) { while (*c) { P2OUT |= LCD_RS; if (*c == '\n') { P2OUT &= ~LCD_RS; LCD_wait(); lcd_set_cur(1, 2); /* Set cursor to second line */ P2OUT |= LCD_RS; c++; } LCD_txbyte(*(c++)); P2OUT &= ~LCD_RS; LCD_wait(); } return; } /** * lcd_place_str * Places a string at a given location on the LCD */ void lcd_place_str(char *c, int x, int y) { lcd_set_cur(x, y); lcd_print_str(c); } /** * lcd_set_cur * Sets a new cursor position for writing a string * Indexes starting with 1, top line is line 1, left column is column 1 */ void lcd_set_cur(int x, int y) { LCD_txbyte(0x80 + --x + --y * 0x40); } /** * lcd_clr_screen * Clears the lcd screen */ void lcd_clr_screen(void) { LCD_txbyte(LCD_CLEAR_DISP); LCD_wait(); return; } /** * lcd_return_home * Sets the curser position to (1, 1) */ void lcd_return_home(void) { lcd_set_cur(1, 1); } /** * TIMER3_A1_VECTOR * Interrupt vector responsible for various timing delays */ #pragma vector = TIMER3_A0_VECTOR __interrupt void TIMER3_A0_ISR(void) { TA3CTL = 0; /* Turn off TA3 */ TA3R = 0; /* Clear counter */ TA3CCTL0 = 0; /* Disable interrupts and clear pending interrupts */ LPM1_EXIT; /* Exit LPM3 */ return; }
AyahnaSyahid/a3plus
C/BagiPlano.c
<filename>C/BagiPlano.c // 29-April-2020 - Under COVID-19 #include <stdlib.h> #include <stdio.h> int iCalculate(int a, int b, int c, int d) { int ta = a ; // local a int pcount = 0, lcount = 0; // unused here int mn = c < d ? c : d; // minimum value of c vs d int mx = c > d ? c : d; // maximum value of c vs d if(ta < c) return 0; // nothing todo if a < c if(a < mn || b < mn) return 0; if(ta == 0) return 0; int rv = 0; // return value int rest[2] = { 0, 0 }; // holds res while(ta >= mn) { if(!ta) break; // //printf("1 ta : %d | rv : %d | %d | %d | %d\n", ta, rv, mn, mx, rest[0]); if(ta % mn < ta % mx) { ta -= mn; //printf("1 ta : %d | rv : %d | %d | %d | %d\n", ta, rv, mn, mx, rest[0]); pcount++; if(b < mx)return rv; rv += b / mx; if(b % mx >= mn) { rest[1] = b % mx; } } else { ta -= mx ; //printf("2 ta : %d | rv : %d | %d | %d | %d\n", ta, rv, mn, mx, rest[0]); lcount++; rv += b / mn; } rest[0] = pcount * mn; } //printf("R1 Running recurse with : %d %d %d %d\n", rest[0], rest[1], c, d); int rv1 = iCalculate(rest[0], rest[1], c, d); //printf("R2 Running recurse with : %d %d %d %d\n", rest[1], rest[0], c, d); int rv2 = iCalculate(rest[1], rest[0], c, d); rv += (rv1 > rv2 ? rv1 : rv2); return rv; } int help(const char name[]) { printf("\n\tUsage: %s pBahan lBahan pArea [lArea]\n\n", name); return 0; } int main(int argc, const char * argv[]){ // argument berisi 5 ; int r1, r2; if(argc < 4 ) return help(argv[0]); const char *a = argv[1], *b = argv[2], *c = argv[3], *d; d = argc > 4 ? argv[4] : argv[3]; // atoi(const * char) // --------- alfanumeric to integer ------------ r1 = iCalculate(atoi(a), atoi(b), atoi(c), atoi(d)); r2 = iCalculate(atoi(b), atoi(a), atoi(c), atoi(d)); printf("%d\n", r1 > r2 ? r1 : r2); }
tmatos/progres
erros.c
<filename>erros.c /* Progres - Simulador de circuitos combinacionais em Verilog (C) 2014, 2015 <NAME> Under the terms of the MIT license. */ #include <stdio.h> #include <stdlib.h> #include "erros.h" void* exibeMsgErro(char* msg, int linha, int coluna, char* esperado, char *encontrado) { if(linha > 0) { printf("%d:", linha); if(coluna > 0) printf("%d:", coluna); } if(msg) { printf(" erro: %s.", msg); if(esperado) { printf(" Esperava-se '%s', mas foi encontrado '%s'.", esperado, encontrado); } } printf("\n"); return NULL; } void erroFatalMemoria() { printf("\nERRO FATAL: Sem memoria para alocar.\n"); exit(-1); }
tmatos/progres
IDE/SinaisDrawPane.h
#ifndef SINAISDRAWPANE_H #define SINAISDRAWPANE_H #include "sinais.h" class SinaisDrawPane : public wxPanel { public: SinaisDrawPane(wxWindow* parent); void paintEvent(wxPaintEvent & evt); void paintNow(); void render(wxDC& dc); void setSinais(wxString filePath, bool isInput); bool isInputFile; bool estaEmEdicao; wxString waveFilePath; void mouseDoubleClick(wxMouseEvent& event); // eventos que podem ser uteis /* void mouseMoved(wxMouseEvent& event); void mouseDown(wxMouseEvent& event); void mouseWheelMoved(wxMouseEvent& event); void mouseReleased(wxMouseEvent& event); void rightClick(wxMouseEvent& event); void mouseLeftWindow(wxMouseEvent& event); void keyPressed(wxKeyEvent& event); void keyReleased(wxKeyEvent& event); */ private: Sinais* ondas; DECLARE_EVENT_TABLE() }; #endif // SINAISDRAWPANE_H
tmatos/progres
mem.c
/* Progres - Simulador de circuitos combinacionais em Verilog (C) 2014, 2015 <NAME> Under the terms of the MIT license. */ #include <stdlib.h> #include "erros.h" #include "mem.h" void* xmalloc(size_t t) { void* p = malloc(t); if(!p) erroFatalMemoria(); return p; } void* xrealloc(void* m, size_t t) { void* p = realloc(m, t); if(!p) erroFatalMemoria(); return p; } void* xcalloc(size_t n, size_t t) { void* p = calloc(n, t); if(!p) erroFatalMemoria(); return p; }
tmatos/progres
IDE/IDEMain.h
/*************************************************************** * Name: IDEMain.h * Purpose: Defines Application Frame * Author: <NAME> () * Created: 2014-06-12 * Copyright: <NAME> () * License: **************************************************************/ #ifndef IDEMAIN_H #define IDEMAIN_H #include "sinais.h" //(*Headers(IDEFrame) #include <wx/notebook.h> #include <wx/menu.h> #include <wx/textctrl.h> #include <wx/splitter.h> #include <wx/listbox.h> #include <wx/frame.h> #include <wx/statusbr.h> //*) class IDEFrame: public wxFrame { public: IDEFrame(wxWindow* parent,wxWindowID id = -1); virtual ~IDEFrame(); void carregaConfigs(); void CarregarArquivoVerilog(wxString arquivo); void SetTituloJanelaComArquivo(wxString nome); void AtualizaTudoParaNovaEntrada(wxString novoPathArquivoWaveIn); void SalvarArquivoAtual(); void FecharArquivoAtual(); int PerguntaSalvarArquivo(); private: //(*Handlers(IDEFrame) void OnQuit(wxCommandEvent& event); void OnAbout(wxCommandEvent& event); void OnMenuItemOpen(wxCommandEvent& event); void OnMenuItemAnalisarSelected(wxCommandEvent& event); void OnMenuItemNovoCircuitoSelected(wxCommandEvent& event); void OnMenuItemEntradaAbrirSelected(wxCommandEvent& event); void OnEditBoxText(wxCommandEvent& event); void OnListBoxErrosDClick(wxCommandEvent& event); void OnMenuItemSelecionarTudoSelected(wxCommandEvent& event); void OnMenuItemConfigSelected(wxCommandEvent& event); void OnMenuItemSave(wxCommandEvent& event); void OnMenuItemCloseSelected(wxCommandEvent& event); void OnMenuItemTesteSelected(wxCommandEvent& event); void OnMenuItemEntradaNovoSelected(wxCommandEvent& event); //*) //(*Identifiers(IDEFrame) static const long ID_TEXTCTRL_FONTE; static const long ID_NOTEBOOK1; static const long ID_LISTBOXERROS; static const long ID_SPLITTERWINDOW1; static const long ID_MENUITEM2; static const long ID_MENUITEM1; static const long idMenuOpen; static const long idMenuSave; static const long ID_MENUITEM8; static const long idMenuClose; static const long idMenuQuit; static const long ID_MENUITEM6; static const long ID_MENUITEM_TESTE; static const long ID_MENUITEM_ENTRADA_NOVO; static const long ID_MENUITEM_ENTRADA_ABRIR; static const long ID_MENUITEM4; static const long ID_MENUITEM7; static const long idMenuAbout; static const long ID_STATUSBAR1; //*) //(*Declarations(IDEFrame) wxMenu* MenuItem2; wxMenuItem* MenuItemSave; wxMenuItem* MenuItemClose; wxMenuItem* MenuItem5; wxMenuItem* MenuItemNovoCircuito; wxTextCtrl* EditBox; wxMenu* Menu3; wxMenuItem* MenuItem1; wxMenuItem* MenuItem4; wxMenu* MenuOpcoes; wxNotebook* bookFontes; wxMenu* Menu1; wxMenuItem* MenuItem3; wxMenuItem* MenuItemTeste; wxMenuItem* MenuItemConfig; wxMenuItem* MenuItemAnalisar; wxSplitterWindow* SplitterWindow1; wxMenu* Menu2; wxStatusBar* StatusBarPrincipal; wxMenuItem* MenuItemSelecionarTudo; wxListBox* ListBoxErros; wxMenu* Menu4; //*) wxString verilogFilePath; wxString waveinFilePath; wxString waveoutFilePath; wxString simuladorExePath; bool AbrirUltimoAoIniciar; wxString UltimoArquivoVerilog; wxString defaultWindowTitle; long textLenght; bool arquivoNaoSalvo; Sinais* ondas; DECLARE_EVENT_TABLE() }; #endif // IDEMAIN_H
tmatos/progres
IDE/memoria.c
#include <stdio.h> #include <stdlib.h> #include "memoria.h" void* xmalloc(size_t t) { void* p = malloc(t); if(!p) erroFatalMemoria(); return p; } void* xrealloc(void* m, size_t t) { void* p = realloc(m, t); if(!p) erroFatalMemoria(); return p; } void* xcalloc(size_t n, size_t t) { void* p = calloc(n, t); if(!p) erroFatalMemoria(); return p; } void* exibeMsgErro(char* msg, int linha, int coluna, char* esperado, char *encontrado) { // if(linha > 0) // { // printf("%d:", linha); // // if(coluna > 0) // printf("%d:", coluna); // } // // if(msg) // { // printf(" erro: %s.", msg); // // if(esperado) // { // printf(" Esperava-se '%s', mas foi encontrado '%s'.", esperado, encontrado); // } // } // // printf("\n"); return NULL; } void erroFatalMemoria() { // printf("\nERRO FATAL: Sem memoria para alocar.\n"); // exit(-1); }
tmatos/progres
IDE/inout.h
#ifndef INOUT_H #define INOUT_H #include "sinais.h" void salvarSinais(Sinais *sinaisSaida, FILE *arqSaida); Sinais* carregaEntradas(FILE *arquivo); extern "C" Sinais* carregaArquivoSinais(const char* path); #endif // INOUT_H
tmatos/progres
IDE/IDEConfig.h
<reponame>tmatos/progres<filename>IDE/IDEConfig.h #ifndef IDECONFIG_H #define IDECONFIG_H //(*Headers(IDEConfig) #include <wx/stattext.h> #include <wx/textctrl.h> #include <wx/checkbox.h> #include <wx/filedlg.h> #include <wx/button.h> #include <wx/dialog.h> //*) #include <wx/config.h> class IDEConfig: public wxDialog { public: IDEConfig(wxWindow* parent,wxWindowID id=wxID_ANY); virtual ~IDEConfig(); //(*Declarations(IDEConfig) wxTextCtrl* txtSimuladorPath; wxButton* btnSimuladorPath; wxStaticText* lblSimuladorPath; wxButton* btnSalvar; wxCheckBox* ChkAbrirUltimoAoIniciar; wxButton* btnCancelar; wxFileDialog* fileDiagSimuladorPath; //*) protected: //(*Identifiers(IDEConfig) static const long ID_BUTTON1; static const long ID_BUTTON2; static const long ID_STATICTEXT1; static const long ID_TEXTCTRL1; static const long ID_BUTTON3; static const long ID_CHECKBOX1; //*) private: //(*Handlers(IDEConfig) void OnbtnCancelarClick(wxCommandEvent& event); void OnbtnSimuladorPathClick(wxCommandEvent& event); void OnbtnSalvarClick(wxCommandEvent& event); void OnChkAbrirUltimoAoIniciarClick(wxCommandEvent& event); //*) wxString simuladorExePath; bool AbrirUltimoAoIniciar; wxConfig *config; DECLARE_EVENT_TABLE() }; #endif // IDECONFIG_H
tmatos/progres
IDE/memoria.h
<gh_stars>0 #ifndef MEMORIA_H #define MEMORIA_H #include <stdio.h> #include <stdlib.h> void* xmalloc(size_t t); void* xrealloc(void* m, size_t t); void* xcalloc(size_t n, size_t t); void* exibeMsgErro(char* msg, int linha, int coluna, char* esperado, char *encontrado); void erroFatalMemoria(); #endif // MEMORIA_H
tmatos/progres
IDE/EdicaoDeSinal.h
#ifndef EDICAODESINAL_H #define EDICAODESINAL_H //(*Headers(EdicaoDeSinal) #include <wx/textctrl.h> #include <wx/button.h> #include <wx/dialog.h> //*) class EdicaoDeSinal: public wxDialog { public: EdicaoDeSinal(wxWindow* parent,wxWindowID id=wxID_ANY,const wxPoint& pos=wxDefaultPosition,const wxSize& size=wxDefaultSize); virtual ~EdicaoDeSinal(); void setFile(wxString filePath); //(*Declarations(EdicaoDeSinal) wxTextCtrl* txtWaveIn; wxButton* btnSalvar; //*) protected: //(*Identifiers(EdicaoDeSinal) static const long ID_TEXTCTRL1; static const long idBtn_Salvar; //*) private: //(*Handlers(EdicaoDeSinal) void OnbtnDescartarClick(wxCommandEvent& event); void OnbtnSalvarClick(wxCommandEvent& event); //*) void OnClose(wxCloseEvent& event); wxString file; DECLARE_EVENT_TABLE() }; #endif // EDICAODESINAL_H
tmatos/progres
IDE/IDEApp.h
/*************************************************************** * Name: IDEApp.h * Purpose: Defines Application Class * Author: <NAME> () * Created: 2014-06-12 * Copyright: <NAME> () * License: **************************************************************/ #ifndef IDEAPP_H #define IDEAPP_H #include <wx/app.h> class IDEApp : public wxApp { public: virtual bool OnInit(); }; #endif // IDEAPP_H
polymurph/STM-Linux
stm32g474_blinky/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/RefLibs/src/HelperFunctions/HelperFunctions.c
<filename>stm32g474_blinky/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/RefLibs/src/HelperFunctions/HelperFunctions.c #include "mat_helper.c" #include "ref_helper.c"
polymurph/STM-Linux
stm32g474_blinky/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/RefLibs/src/ComplexMathFunctions/ComplexMathFunctions.c
#include "cmplx_conj.c" #include "cmplx_dot_prod.c" #include "cmplx_mag.c" #include "cmplx_mag_squared.c" #include "cmplx_mult_cmplx.c" #include "cmplx_mult_real.c"
polymurph/STM-Linux
stm32g474_blinky/Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_rtc.h
<gh_stars>10-100 /** ****************************************************************************** * @file stm32g4xx_hal_rtc.h * @author MCD Application Team * @brief Header file of RTC HAL module. ****************************************************************************** * @attention * * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2> * * This software component is licensed by ST under BSD 3-Clause license, * the "License"; You may not use this file except in compliance with the * License. You may obtain a copy of the License at: * opensource.org/licenses/BSD-3-Clause * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef STM32G4xx_HAL_RTC_H #define STM32G4xx_HAL_RTC_H #ifdef __cplusplus extern "C" { #endif /* Includes ------------------------------------------------------------------*/ #include "stm32g4xx_hal_def.h" /** @addtogroup STM32G4xx_HAL_Driver * @{ */ /** @defgroup RTC RTC * @{ */ /* Exported types ------------------------------------------------------------*/ /** @defgroup RTC_Exported_Types RTC Exported Types * @{ */ /** * @brief HAL State structures definition */ typedef enum { HAL_RTC_STATE_RESET = 0x00U, /*!< RTC not yet initialized or disabled */ HAL_RTC_STATE_READY = 0x01U, /*!< RTC initialized and ready for use */ HAL_RTC_STATE_BUSY = 0x02U, /*!< RTC process is ongoing */ HAL_RTC_STATE_TIMEOUT = 0x03U, /*!< RTC timeout state */ HAL_RTC_STATE_ERROR = 0x04U /*!< RTC error state */ } HAL_RTCStateTypeDef; /** * @brief RTC Configuration Structure definition */ typedef struct { uint32_t HourFormat; /*!< Specifies the RTC Hour Format. This parameter can be a value of @ref RTC_Hour_Formats */ uint32_t AsynchPrediv; /*!< Specifies the RTC Asynchronous Predivider value. This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x7F */ uint32_t SynchPrediv; /*!< Specifies the RTC Synchronous Predivider value. This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x7FFF */ uint32_t OutPut; /*!< Specifies which signal will be routed to the RTC output. This parameter can be a value of @ref RTCEx_Output_selection_Definitions */ uint32_t OutPutRemap; /*!< Specifies the remap for RTC output. This parameter can be a value of @ref RTC_Output_ALARM_OUT_Remap */ uint32_t OutPutPolarity; /*!< Specifies the polarity of the output signal. This parameter can be a value of @ref RTC_Output_Polarity_Definitions */ uint32_t OutPutType; /*!< Specifies the RTC Output Pin mode. This parameter can be a value of @ref RTC_Output_Type_ALARM_OUT */ uint32_t OutPutPullUp; /*!< Specifies the RTC Output Pull-Up mode. This parameter can be a value of @ref RTC_Output_PullUp_ALARM_OUT */ } RTC_InitTypeDef; /** * @brief RTC Time structure definition */ typedef struct { uint8_t Hours; /*!< Specifies the RTC Time Hour. This parameter must be a number between Min_Data = 0 and Max_Data = 12 if the RTC_HourFormat_12 is selected. This parameter must be a number between Min_Data = 0 and Max_Data = 23 if the RTC_HourFormat_24 is selected */ uint8_t Minutes; /*!< Specifies the RTC Time Minutes. This parameter must be a number between Min_Data = 0 and Max_Data = 59 */ uint8_t Seconds; /*!< Specifies the RTC Time Seconds. This parameter must be a number between Min_Data = 0 and Max_Data = 59 */ uint8_t TimeFormat; /*!< Specifies the RTC AM/PM Time. This parameter can be a value of @ref RTC_AM_PM_Definitions */ uint32_t SubSeconds; /*!< Specifies the RTC_SSR RTC Sub Second register content. This parameter corresponds to a time unit range between [0-1] Second with [1 Sec / SecondFraction +1] granularity */ uint32_t SecondFraction; /*!< Specifies the range or granularity of Sub Second register content corresponding to Synchronous pre-scaler factor value (PREDIV_S) This parameter corresponds to a time unit range between [0-1] Second with [1 Sec / SecondFraction +1] granularity. This field will be used only by HAL_RTC_GetTime function */ uint32_t DayLightSaving; /*!< Specifies RTC_DayLightSaveOperation: the value of hour adjustment. This parameter can be a value of @ref RTC_DayLightSaving_Definitions */ uint32_t StoreOperation; /*!< Specifies RTC_StoreOperation value to be written in the BKP bit in CR register to store the operation. This parameter can be a value of @ref RTC_StoreOperation_Definitions */ } RTC_TimeTypeDef; /** * @brief RTC Date structure definition */ typedef struct { uint8_t WeekDay; /*!< Specifies the RTC Date WeekDay. This parameter can be a value of @ref RTC_WeekDay_Definitions */ uint8_t Month; /*!< Specifies the RTC Date Month (in BCD format). This parameter can be a value of @ref RTC_Month_Date_Definitions */ uint8_t Date; /*!< Specifies the RTC Date. This parameter must be a number between Min_Data = 1 and Max_Data = 31 */ uint8_t Year; /*!< Specifies the RTC Date Year. This parameter must be a number between Min_Data = 0 and Max_Data = 99 */ } RTC_DateTypeDef; /** * @brief RTC Alarm structure definition */ typedef struct { RTC_TimeTypeDef AlarmTime; /*!< Specifies the RTC Alarm Time members */ uint32_t AlarmMask; /*!< Specifies the RTC Alarm Masks. This parameter can be a value of @ref RTC_AlarmMask_Definitions */ uint32_t AlarmSubSecondMask; /*!< Specifies the RTC Alarm SubSeconds Masks. This parameter can be a value of @ref RTC_Alarm_Sub_Seconds_Masks_Definitions */ uint32_t AlarmDateWeekDaySel; /*!< Specifies the RTC Alarm is on Date or WeekDay. This parameter can be a value of @ref RTC_AlarmDateWeekDay_Definitions */ uint8_t AlarmDateWeekDay; /*!< Specifies the RTC Alarm Date/WeekDay. If the Alarm Date is selected, this parameter must be set to a value in the 1-31 range. If the Alarm WeekDay is selected, this parameter can be a value of @ref RTC_WeekDay_Definitions */ uint32_t Alarm; /*!< Specifies the alarm . This parameter can be a value of @ref RTC_Alarms_Definitions */ } RTC_AlarmTypeDef; /** * @brief RTC Handle Structure definition */ #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1) typedef struct __RTC_HandleTypeDef #else typedef struct #endif /* (USE_HAL_RTC_REGISTER_CALLBACKS) */ { RTC_TypeDef *Instance; /*!< Legacy register base address. Not used anymore, the driver directly uses cmsis base address */ RTC_InitTypeDef Init; /*!< RTC required parameters */ HAL_LockTypeDef Lock; /*!< RTC locking object */ __IO HAL_RTCStateTypeDef State; /*!< Time communication state */ #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1) void (* AlarmAEventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Alarm A Event callback */ void (* AlarmBEventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Alarm B Event callback */ void (* TimeStampEventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC TimeStamp Event callback */ void (* WakeUpTimerEventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC WakeUpTimer Event callback */ void (* Tamper1EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Tamper 1 Event callback */ void (* Tamper2EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Tamper 2 Event callback */ #if (RTC_TAMP_NB == 3) void (* Tamper3EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Tamper 3 Event callback */ #endif /* RTC_TAMP_NB */ void (* InternalTamper1EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Internal Tamper 1 Event callback */ #ifdef RTC_TAMP_INT_2_SUPPORT void (* InternalTamper2EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Internal Tamper 2 Event callback */ #endif /* RTC_TAMP_INT_2_SUPPORT */ void (* InternalTamper3EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Internal Tamper 3 Event callback */ void (* InternalTamper4EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Internal Tamper 4 Event callback */ void (* InternalTamper5EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Internal Tamper 5 Event callback */ #ifdef RTC_TAMP_INT_6_SUPPORT void (* InternalTamper6EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Internal Tamper 6 Event callback */ #endif /* RTC_TAMP_INT_6_SUPPORT */ #ifdef RTC_TAMP_INT_7_SUPPORT void (* InternalTamper7EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Internal Tamper 7 Event callback */ #endif /* RTC_TAMP_INT_7_SUPPORT */ void (* MspInitCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Msp Init callback */ void (* MspDeInitCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Msp DeInit callback */ #endif /* (USE_HAL_RTC_REGISTER_CALLBACKS) */ } RTC_HandleTypeDef; #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1) /** * @brief HAL LPTIM Callback ID enumeration definition */ typedef enum { HAL_RTC_ALARM_A_EVENT_CB_ID = 0x00U, /*!< RTC Alarm A Event Callback ID */ HAL_RTC_ALARM_B_EVENT_CB_ID = 0x01U, /*!< RTC Alarm B Event Callback ID */ HAL_RTC_TIMESTAMP_EVENT_CB_ID = 0x02U, /*!< RTC TimeStamp Event Callback ID */ HAL_RTC_WAKEUPTIMER_EVENT_CB_ID = 0x03U, /*!< RTC WakeUp Timer Event Callback ID */ HAL_RTC_TAMPER1_EVENT_CB_ID = 0x04U, /*!< RTC Tamper 1 Callback ID */ HAL_RTC_TAMPER2_EVENT_CB_ID = 0x05U, /*!< RTC Tamper 2 Callback ID */ HAL_RTC_TAMPER3_EVENT_CB_ID = 0x06U, /*!< RTC Tamper 3 Callback ID */ HAL_RTC_INTERNAL_TAMPER1_EVENT_CB_ID = 0x07U, /*!< RTC Internal Tamper 1 Callback ID */ HAL_RTC_INTERNAL_TAMPER2_EVENT_CB_ID = 0x08U, /*!< RTC Internal Tamper 2 Callback ID */ HAL_RTC_INTERNAL_TAMPER3_EVENT_CB_ID = 0x09U, /*!< RTC Internal Tamper 3 Callback ID */ HAL_RTC_INTERNAL_TAMPER4_EVENT_CB_ID = 0x0AU, /*!< RTC Internal Tamper 4 Callback ID */ HAL_RTC_INTERNAL_TAMPER5_EVENT_CB_ID = 0x0BU, /*!< RTC Internal Tamper 5 Callback ID */ HAL_RTC_INTERNAL_TAMPER6_EVENT_CB_ID = 0x0CU, /*!< RTC Internal Tamper 6 Callback ID */ HAL_RTC_INTERNAL_TAMPER7_EVENT_CB_ID = 0x0DU, /*!< RTC Internal Tamper 7 Callback ID */ HAL_RTC_MSPINIT_CB_ID = 0x0EU, /*!< RTC Msp Init callback ID */ HAL_RTC_MSPDEINIT_CB_ID = 0x0FU /*!< RTC Msp DeInit callback ID */ } HAL_RTC_CallbackIDTypeDef; /** * @brief HAL RTC Callback pointer definition */ typedef void (*pRTC_CallbackTypeDef)(RTC_HandleTypeDef *hrtc); /*!< pointer to an RTC callback function */ #endif /* USE_HAL_RTC_REGISTER_CALLBACKS */ /** * @} */ /* Exported constants --------------------------------------------------------*/ /** @defgroup RTC_Exported_Constants RTC Exported Constants * @{ */ /** @defgroup RTC_Hour_Formats RTC Hour Formats * @{ */ #define RTC_HOURFORMAT_24 0x00000000U #define RTC_HOURFORMAT_12 RTC_CR_FMT /** * @} */ /** @defgroup RTCEx_Output_selection_Definitions RTCEx Output Selection Definition * @{ */ #define RTC_OUTPUT_DISABLE 0x00000000U #define RTC_OUTPUT_ALARMA RTC_CR_OSEL_0 #define RTC_OUTPUT_ALARMB RTC_CR_OSEL_1 #define RTC_OUTPUT_WAKEUP RTC_CR_OSEL #define RTC_OUTPUT_TAMPER RTC_CR_TAMPOE /** * @} */ /** @defgroup RTC_Output_Polarity_Definitions RTC Output Polarity Definitions * @{ */ #define RTC_OUTPUT_POLARITY_HIGH 0x00000000U #define RTC_OUTPUT_POLARITY_LOW RTC_CR_POL /** * @} */ /** @defgroup RTC_Output_Type_ALARM_OUT RTC Output Type ALARM OUT * @{ */ #define RTC_OUTPUT_TYPE_PUSHPULL 0x00000000U #define RTC_OUTPUT_TYPE_OPENDRAIN RTC_CR_TAMPALRM_TYPE /** * @} */ /** @defgroup RTC_Output_PullUp_ALARM_OUT RTC Output Pull-Up ALARM OUT * @{ */ #define RTC_OUTPUT_PULLUP_NONE 0x00000000U #define RTC_OUTPUT_PULLUP_ON RTC_CR_TAMPALRM_PU /** * @} */ /** @defgroup RTC_Output_ALARM_OUT_Remap RTC Output ALARM OUT Remap * @{ */ #define RTC_OUTPUT_REMAP_NONE 0x00000000U #define RTC_OUTPUT_REMAP_POS1 RTC_CR_OUT2EN /** * @} */ /** @defgroup RTC_AM_PM_Definitions RTC AM PM Definitions * @{ */ #define RTC_HOURFORMAT12_AM 0x0U #define RTC_HOURFORMAT12_PM 0x1U /** * @} */ /** @defgroup RTC_DayLightSaving_Definitions RTC DayLightSaving Definitions * @{ */ #define RTC_DAYLIGHTSAVING_SUB1H RTC_CR_SUB1H #define RTC_DAYLIGHTSAVING_ADD1H RTC_CR_ADD1H #define RTC_DAYLIGHTSAVING_NONE 0x00000000U /** * @} */ /** @defgroup RTC_StoreOperation_Definitions RTC StoreOperation Definitions * @{ */ #define RTC_STOREOPERATION_RESET 0x00000000U #define RTC_STOREOPERATION_SET RTC_CR_BKP /** * @} */ /** @defgroup RTC_Input_parameter_format_definitions RTC Input Parameter Format Definitions * @{ */ #define RTC_FORMAT_BIN 0x00000000U #define RTC_FORMAT_BCD 0x00000001U /** * @} */ /** @defgroup RTC_Month_Date_Definitions RTC Month Date Definitions * @{ */ /* Coded in BCD format */ #define RTC_MONTH_JANUARY ((uint8_t)0x01U) #define RTC_MONTH_FEBRUARY ((uint8_t)0x02U) #define RTC_MONTH_MARCH ((uint8_t)0x03U) #define RTC_MONTH_APRIL ((uint8_t)0x04U) #define RTC_MONTH_MAY ((uint8_t)0x05U) #define RTC_MONTH_JUNE ((uint8_t)0x06U) #define RTC_MONTH_JULY ((uint8_t)0x07U) #define RTC_MONTH_AUGUST ((uint8_t)0x08U) #define RTC_MONTH_SEPTEMBER ((uint8_t)0x09U) #define RTC_MONTH_OCTOBER ((uint8_t)0x10U) #define RTC_MONTH_NOVEMBER ((uint8_t)0x11U) #define RTC_MONTH_DECEMBER ((uint8_t)0x12U) /** * @} */ /** @defgroup RTC_WeekDay_Definitions RTC WeekDay Definitions * @{ */ #define RTC_WEEKDAY_MONDAY ((uint8_t)0x01U) #define RTC_WEEKDAY_TUESDAY ((uint8_t)0x02U) #define RTC_WEEKDAY_WEDNESDAY ((uint8_t)0x03U) #define RTC_WEEKDAY_THURSDAY ((uint8_t)0x04U) #define RTC_WEEKDAY_FRIDAY ((uint8_t)0x05U) #define RTC_WEEKDAY_SATURDAY ((uint8_t)0x06U) #define RTC_WEEKDAY_SUNDAY ((uint8_t)0x07U) /** * @} */ /** @defgroup RTC_AlarmDateWeekDay_Definitions RTC AlarmDateWeekDay Definitions * @{ */ #define RTC_ALARMDATEWEEKDAYSEL_DATE 0x00000000U #define RTC_ALARMDATEWEEKDAYSEL_WEEKDAY RTC_ALRMAR_WDSEL /** * @} */ /** @defgroup RTC_AlarmMask_Definitions RTC AlarmMask Definitions * @{ */ #define RTC_ALARMMASK_NONE 0x00000000U #define RTC_ALARMMASK_DATEWEEKDAY RTC_ALRMAR_MSK4 #define RTC_ALARMMASK_HOURS RTC_ALRMAR_MSK3 #define RTC_ALARMMASK_MINUTES RTC_ALRMAR_MSK2 #define RTC_ALARMMASK_SECONDS RTC_ALRMAR_MSK1 #define RTC_ALARMMASK_ALL (RTC_ALARMMASK_DATEWEEKDAY | RTC_ALARMMASK_HOURS | \ RTC_ALARMMASK_MINUTES | RTC_ALARMMASK_SECONDS) /** * @} */ /** @defgroup RTC_Alarms_Definitions RTC Alarms Definitions * @{ */ #define RTC_ALARM_A RTC_CR_ALRAE #define RTC_ALARM_B RTC_CR_ALRBE /** * @} */ /** @defgroup RTC_Alarm_Sub_Seconds_Masks_Definitions RTC Alarm Sub Seconds Masks Definitions * @{ */ #define RTC_ALARMSUBSECONDMASK_ALL 0x00000000U /*!< All Alarm SS fields are masked. There is no comparison on sub seconds for Alarm */ #define RTC_ALARMSUBSECONDMASK_SS14_1 RTC_ALRMASSR_MASKSS_0 /*!< SS[14:1] not used in Alarm comparison. Only SS[0] is compared. */ #define RTC_ALARMSUBSECONDMASK_SS14_2 RTC_ALRMASSR_MASKSS_1 /*!< SS[14:2] not used in Alarm comparison. Only SS[1:0] are compared */ #define RTC_ALARMSUBSECONDMASK_SS14_3 (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_1) /*!< SS[14:3] not used in Alarm comparison. Only SS[2:0] are compared */ #define RTC_ALARMSUBSECONDMASK_SS14_4 RTC_ALRMASSR_MASKSS_2 /*!< SS[14:4] not used in Alarm comparison. Only SS[3:0] are compared */ #define RTC_ALARMSUBSECONDMASK_SS14_5 (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_2) /*!< SS[14:5] not used in Alarm comparison. Only SS[4:0] are compared */ #define RTC_ALARMSUBSECONDMASK_SS14_6 (RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_2) /*!< SS[14:6] not used in Alarm comparison. Only SS[5:0] are compared */ #define RTC_ALARMSUBSECONDMASK_SS14_7 (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_2) /*!< SS[14:7] not used in Alarm comparison. Only SS[6:0] are compared */ #define RTC_ALARMSUBSECONDMASK_SS14_8 RTC_ALRMASSR_MASKSS_3 /*!< SS[14:8] not used in Alarm comparison. Only SS[7:0] are compared */ #define RTC_ALARMSUBSECONDMASK_SS14_9 (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_3) /*!< SS[14:9] not used in Alarm comparison. Only SS[8:0] are compared */ #define RTC_ALARMSUBSECONDMASK_SS14_10 (RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_3) /*!< SS[14:10] not used in Alarm comparison. Only SS[9:0] are compared */ #define RTC_ALARMSUBSECONDMASK_SS14_11 (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_3) /*!< SS[14:11] not used in Alarm comparison. Only SS[10:0] are compared */ #define RTC_ALARMSUBSECONDMASK_SS14_12 (RTC_ALRMASSR_MASKSS_2 | RTC_ALRMASSR_MASKSS_3) /*!< SS[14:12] not used in Alarm comparison.Only SS[11:0] are compared */ #define RTC_ALARMSUBSECONDMASK_SS14_13 (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_2 | RTC_ALRMASSR_MASKSS_3) /*!< SS[14:13] not used in Alarm comparison. Only SS[12:0] are compared */ #define RTC_ALARMSUBSECONDMASK_SS14 (RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_2 | RTC_ALRMASSR_MASKSS_3) /*!< SS[14] not used in Alarm comparison. Only SS[13:0] are compared */ #define RTC_ALARMSUBSECONDMASK_NONE RTC_ALRMASSR_MASKSS /*!< SS[14:0] are compared and must match to activate alarm. */ /** * @} */ /** @defgroup RTC_Interrupts_Definitions RTC Interrupts Definitions * @{ */ #define RTC_IT_TS RTC_CR_TSIE /*!< Enable Timestamp Interrupt */ #define RTC_IT_WUT RTC_CR_WUTIE /*!< Enable Wakeup timer Interrupt */ #define RTC_IT_ALRA RTC_CR_ALRAIE /*!< Enable Alarm A Interrupt */ #define RTC_IT_ALRB RTC_CR_ALRBIE /*!< Enable Alarm B Interrupt */ /** * @} */ /** @defgroup RTC_Flag_Mask RTC Flag Mask (5bits) describe in RTC_Flags_Definitions * @{ */ #define RTC_FLAG_MASK 0x001FU /*!< RTC flags mask (5bits) */ /** * @} */ /** @defgroup RTC_Flags_Definitions RTC Flags Definitions * Elements values convention: 000000XX000YYYYYb * - YYYYY : Interrupt flag position in the XX register (5bits) * - XX : Interrupt status register (2bits) * - 01: ICSR register * - 10: SR or SCR or MISR registers * @{ */ #define RTC_FLAG_RECALPF (0x00000100U | RTC_ICSR_RECALPF_Pos) /*!< Recalibration pending Flag */ #define RTC_FLAG_INITF (0x00000100U | RTC_ICSR_INITF_Pos) /*!< Initialization flag */ #define RTC_FLAG_RSF (0x00000100U | RTC_ICSR_RSF_Pos) /*!< Registers synchronization flag */ #define RTC_FLAG_INITS (0x00000100U | RTC_ICSR_INITS_Pos) /*!< Initialization status flag */ #define RTC_FLAG_SHPF (0x00000100U | RTC_ICSR_SHPF_Pos) /*!< Shift operation pending flag */ #define RTC_FLAG_WUTWF (0x00000100U | RTC_ICSR_WUTWF_Pos) /*!< Wakeup timer write flag */ #define RTC_FLAG_ALRBWF (0x00000100U | RTC_ICSR_ALRBWF_Pos) /*!< Alarm B write flag */ #define RTC_FLAG_ALRAWF (0x00000100U | RTC_ICSR_ALRAWF_Pos) /*!< Alarm A write flag */ #define RTC_FLAG_ITSF (0x00000200U | RTC_SR_ITSF_Pos) /*!< Internal Time-stamp flag */ #define RTC_FLAG_TSOVF (0x00000200U | RTC_SR_TSOVF_Pos) /*!< Time-stamp overflow flag */ #define RTC_FLAG_TSF (0x00000200U | RTC_SR_TSF_Pos) /*!< Time-stamp flag */ #define RTC_FLAG_WUTF (0x00000200U | RTC_SR_WUTF_Pos) /*!< Wakeup timer flag */ #define RTC_FLAG_ALRBF (0x00000200U | RTC_SR_ALRBF_Pos) /*!< Alarm B flag */ #define RTC_FLAG_ALRAF (0x00000200U | RTC_SR_ALRAF_Pos) /*!< Alarm A flag */ /** * @} */ /** @defgroup RTC_Clear_Flags_Definitions RTC Clear Flags Definitions * @{ */ #define RTC_CLEAR_ITSF RTC_SCR_CITSF /*!< Clear Internal Time-stamp flag */ #define RTC_CLEAR_TSOVF RTC_SCR_CTSOVF /*!< Clear Time-stamp overflow flag */ #define RTC_CLEAR_TSF RTC_SCR_CTSF /*!< Clear Time-stamp flag */ #define RTC_CLEAR_WUTF RTC_SCR_CWUTF /*!< Clear Wakeup timer flag */ #define RTC_CLEAR_ALRBF RTC_SCR_CALRBF /*!< Clear Alarm B flag */ #define RTC_CLEAR_ALRAF RTC_SCR_CALRAF /*!< Clear Alarm A flag */ /** * @} */ /** * @} */ /* Exported macros -----------------------------------------------------------*/ /** @defgroup RTC_Exported_Macros RTC Exported Macros * @{ */ /** @brief Reset RTC handle state * @param __HANDLE__ RTC handle. * @retval None */ #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1) #define __HAL_RTC_RESET_HANDLE_STATE(__HANDLE__) do{\ (__HANDLE__)->State = HAL_RTC_STATE_RESET;\ (__HANDLE__)->MspInitCallback = NULL;\ (__HANDLE__)->MspDeInitCallback = NULL;\ }while(0) #else #define __HAL_RTC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_RTC_STATE_RESET) #endif /* USE_HAL_RTC_REGISTER_CALLBACKS */ /** * @brief Disable the write protection for RTC registers. * @param __HANDLE__ specifies the RTC handle. * @retval None */ #define __HAL_RTC_WRITEPROTECTION_DISABLE(__HANDLE__) \ do{ \ RTC->WPR = 0xCAU; \ RTC->WPR = 0x53U; \ } while(0U) /** * @brief Enable the write protection for RTC registers. * @param __HANDLE__ specifies the RTC handle. * @retval None */ #define __HAL_RTC_WRITEPROTECTION_ENABLE(__HANDLE__) \ do{ \ RTC->WPR = 0xFFU; \ } while(0U) /** * @brief Add 1 hour (summer time change). * @param __HANDLE__ specifies the RTC handle. * @param __BKP__ Backup * This parameter can be: * @arg @ref RTC_STOREOPERATION_RESET * @arg @ref RTC_STOREOPERATION_SET * @retval None */ #define __HAL_RTC_DAYLIGHT_SAVING_TIME_ADD1H(__HANDLE__, __BKP__) \ do { \ __HAL_RTC_WRITEPROTECTION_DISABLE(__HANDLE__); \ SET_BIT(RTC->CR, RTC_CR_ADD1H); \ MODIFY_REG(RTC->CR, RTC_CR_BKP , (__BKP__)); \ __HAL_RTC_WRITEPROTECTION_ENABLE(__HANDLE__); \ } while(0); /** * @brief Subtract 1 hour (winter time change). * @param __HANDLE__ specifies the RTC handle. * @param __BKP__ Backup * This parameter can be: * @arg @ref RTC_STOREOPERATION_RESET * @arg @ref RTC_STOREOPERATION_SET * @retval None */ #define __HAL_RTC_DAYLIGHT_SAVING_TIME_SUB1H(__HANDLE__, __BKP__) \ do { \ __HAL_RTC_WRITEPROTECTION_DISABLE(__HANDLE__); \ SET_BIT(RTC->CR, RTC_CR_SUB1H); \ MODIFY_REG(RTC->CR, RTC_CR_BKP , (__BKP__)); \ __HAL_RTC_WRITEPROTECTION_ENABLE(__HANDLE__); \ } while(0); /** * @brief Enable the RTC ALARMA peripheral. * @param __HANDLE__ specifies the RTC handle. * @retval None */ #define __HAL_RTC_ALARMA_ENABLE(__HANDLE__) (RTC->CR |= (RTC_CR_ALRAE)) /** * @brief Disable the RTC ALARMA peripheral. * @param __HANDLE__ specifies the RTC handle. * @retval None */ #define __HAL_RTC_ALARMA_DISABLE(__HANDLE__) (RTC->CR &= ~(RTC_CR_ALRAE)) /** * @brief Enable the RTC ALARMB peripheral. * @param __HANDLE__ specifies the RTC handle. * @retval None */ #define __HAL_RTC_ALARMB_ENABLE(__HANDLE__) (RTC->CR |= (RTC_CR_ALRBE)) /** * @brief Disable the RTC ALARMB peripheral. * @param __HANDLE__ specifies the RTC handle. * @retval None */ #define __HAL_RTC_ALARMB_DISABLE(__HANDLE__) (RTC->CR &= ~(RTC_CR_ALRBE)) /** * @brief Enable the RTC Alarm interrupt. * @param __HANDLE__ specifies the RTC handle. * @param __INTERRUPT__ specifies the RTC Alarm interrupt sources to be enabled or disabled. * This parameter can be any combination of the following values: * @arg @ref RTC_IT_ALRA Alarm A interrupt * @arg @ref RTC_IT_ALRB Alarm B interrupt * @retval None */ #define __HAL_RTC_ALARM_ENABLE_IT(__HANDLE__, __INTERRUPT__) (RTC->CR |= (__INTERRUPT__)) /** * @brief Disable the RTC Alarm interrupt. * @param __HANDLE__ specifies the RTC handle. * @param __INTERRUPT__ specifies the RTC Alarm interrupt sources to be enabled or disabled. * This parameter can be any combination of the following values: * @arg @ref RTC_IT_ALRA Alarm A interrupt * @arg @ref RTC_IT_ALRB Alarm B interrupt * @retval None */ #define __HAL_RTC_ALARM_DISABLE_IT(__HANDLE__, __INTERRUPT__) (RTC->CR &= ~(__INTERRUPT__)) /** * @brief Check whether the specified RTC Alarm interrupt has occurred or not. * @param __HANDLE__ specifies the RTC handle. * @param __INTERRUPT__ specifies the RTC Alarm interrupt sources to check. * This parameter can be: * @arg @ref RTC_IT_ALRA Alarm A interrupt * @arg @ref RTC_IT_ALRB Alarm B interrupt * @retval None */ #define __HAL_RTC_ALARM_GET_IT(__HANDLE__, __INTERRUPT__) ((((RTC->MISR)& ((__INTERRUPT__)>> 12U)) != 0U) ? 1UL : 0UL) /** * @brief Check whether the specified RTC Alarm interrupt has been enabled or not. * @param __HANDLE__ specifies the RTC handle. * @param __INTERRUPT__ specifies the RTC Alarm interrupt sources to check. * This parameter can be: * @arg @ref RTC_IT_ALRA Alarm A interrupt * @arg @ref RTC_IT_ALRB Alarm B interrupt * @retval None */ #define __HAL_RTC_ALARM_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((RTC->CR) & (__INTERRUPT__)) != 0U) ? 1UL : 0UL) /** * @brief Get the selected RTC Alarms flag status. * @param __HANDLE__ specifies the RTC handle. * @param __FLAG__ specifies the RTC Alarm Flag sources to check. * This parameter can be: * @arg @ref RTC_FLAG_ALRAF * @arg @ref RTC_FLAG_ALRBF * @arg @ref RTC_FLAG_ALRAWF * @arg @ref RTC_FLAG_ALRBWF * @retval None */ #define __HAL_RTC_ALARM_GET_FLAG(__HANDLE__, __FLAG__) (__HAL_RTC_GET_FLAG((__HANDLE__), (__FLAG__))) /** * @brief Clear the RTC Alarms pending flags. * @param __HANDLE__ specifies the RTC handle. * @param __FLAG__ specifies the RTC Alarm Flag sources to clear. * This parameter can be: * @arg @ref RTC_FLAG_ALRAF * @arg @ref RTC_FLAG_ALRBF * @retval None */ #define __HAL_RTC_ALARM_CLEAR_FLAG(__HANDLE__, __FLAG__) (((__FLAG__) == RTC_FLAG_ALRAF) ? ((RTC->SCR = (RTC_CLEAR_ALRAF))) : \ (RTC->SCR = (RTC_CLEAR_ALRBF))) /** * @brief Enable interrupt on the RTC Alarm associated Exti line. * @retval None */ #define __HAL_RTC_ALARM_EXTI_ENABLE_IT() (EXTI->IMR1 |= RTC_EXTI_LINE_ALARM_EVENT) /** * @brief Disable interrupt on the RTC Alarm associated Exti line. * @retval None */ #define __HAL_RTC_ALARM_EXTI_DISABLE_IT() (EXTI->IMR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT)) /** * @brief Enable event on the RTC Alarm associated Exti line. * @retval None */ #define __HAL_RTC_ALARM_EXTI_ENABLE_EVENT() (EXTI->EMR1 |= RTC_EXTI_LINE_ALARM_EVENT) /** * @brief Disable event on the RTC Alarm associated Exti line. * @retval None */ #define __HAL_RTC_ALARM_EXTI_DISABLE_EVENT() (EXTI->EMR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT)) /** * @brief Enable falling edge trigger on the RTC Alarm associated Exti line. * @retval None */ #define __HAL_RTC_ALARM_EXTI_ENABLE_FALLING_EDGE() (EXTI->FTSR1 |= RTC_EXTI_LINE_ALARM_EVENT) /** * @brief Disable falling edge trigger on the RTC Alarm associated Exti line. * @retval None */ #define __HAL_RTC_ALARM_EXTI_DISABLE_FALLING_EDGE() (EXTI->FTSR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT)) /** * @brief Enable rising edge trigger on the RTC Alarm associated Exti line. * @retval None */ #define __HAL_RTC_ALARM_EXTI_ENABLE_RISING_EDGE() (EXTI->RTSR1 |= RTC_EXTI_LINE_ALARM_EVENT) /** * @brief Disable rising edge trigger on the RTC Alarm associated Exti line. * @retval None */ #define __HAL_RTC_ALARM_EXTI_DISABLE_RISING_EDGE() (EXTI->RTSR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT)) /** * @brief Enable rising & falling edge trigger on the RTC Alarm associated Exti line. * @retval None */ #define __HAL_RTC_ALARM_EXTI_ENABLE_RISING_FALLING_EDGE() do { \ __HAL_RTC_ALARM_EXTI_ENABLE_RISING_EDGE(); \ __HAL_RTC_ALARM_EXTI_ENABLE_FALLING_EDGE(); \ } while(0) /** * @brief Disable rising & falling edge trigger on the RTC Alarm associated Exti line. * @retval None */ #define __HAL_RTC_ALARM_EXTI_DISABLE_RISING_FALLING_EDGE() do { \ __HAL_RTC_ALARM_EXTI_DISABLE_RISING_EDGE(); \ __HAL_RTC_ALARM_EXTI_DISABLE_FALLING_EDGE(); \ } while(0) /** * @brief set rising edge interrupt on the RTC Alarm associated Exti line. * @retval None */ #define __HAL_RTC_ALARM_EXTI_RISING_IT() (EXTI->RTSR1 |= RTC_EXTI_LINE_ALARM_EVENT) /** * @brief set rising edge interrupt on the RTC Alarm associated Exti line. * @retval None */ #define __HAL_RTC_ALARM_EXTI_FALLING_IT() (EXTI->FSTR1 |= RTC_EXTI_LINE_ALARM_EVENT) /** * @brief clear interrupt on the RTC Alarm associated Exti line. * @retval None */ #define __HAL_RTC_ALARM_EXTI_CLEAR_IT() (EXTI->PR1 = RTC_EXTI_LINE_ALARM_EVENT) /** * @} */ /* Include RTC HAL Extended module */ #include "stm32g4xx_hal_rtc_ex.h" /* Exported functions --------------------------------------------------------*/ /** @defgroup RTC_Exported_Functions RTC Exported Functions * @{ */ /** @defgroup RTC_Exported_Functions_Group1 Initialization and de-initialization functions * @{ */ /* Initialization and de-initialization functions ****************************/ HAL_StatusTypeDef HAL_RTC_Init(RTC_HandleTypeDef *hrtc); HAL_StatusTypeDef HAL_RTC_DeInit(RTC_HandleTypeDef *hrtc); void HAL_RTC_MspInit(RTC_HandleTypeDef *hrtc); void HAL_RTC_MspDeInit(RTC_HandleTypeDef *hrtc); #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1) /* Callbacks Register/UnRegister functions ***********************************/ HAL_StatusTypeDef HAL_RTC_RegisterCallback(RTC_HandleTypeDef *hrtc, HAL_RTC_CallbackIDTypeDef CallbackID, pRTC_CallbackTypeDef pCallback); HAL_StatusTypeDef HAL_RTC_UnRegisterCallback(RTC_HandleTypeDef *hrtc, HAL_RTC_CallbackIDTypeDef CallbackID); #endif /* USE_HAL_RTC_REGISTER_CALLBACKS */ /** * @} */ /** @defgroup RTC_Exported_Functions_Group2 RTC Time and Date functions * @{ */ /* RTC Time and Date functions ************************************************/ HAL_StatusTypeDef HAL_RTC_SetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format); HAL_StatusTypeDef HAL_RTC_GetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format); HAL_StatusTypeDef HAL_RTC_SetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format); HAL_StatusTypeDef HAL_RTC_GetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format); /** * @} */ /** @defgroup RTC_Exported_Functions_Group3 RTC Alarm functions * @{ */ /* RTC Alarm functions ********************************************************/ HAL_StatusTypeDef HAL_RTC_SetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format); HAL_StatusTypeDef HAL_RTC_SetAlarm_IT(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format); HAL_StatusTypeDef HAL_RTC_DeactivateAlarm(RTC_HandleTypeDef *hrtc, uint32_t Alarm); HAL_StatusTypeDef HAL_RTC_GetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Alarm, uint32_t Format); void HAL_RTC_AlarmIRQHandler(RTC_HandleTypeDef *hrtc); HAL_StatusTypeDef HAL_RTC_PollForAlarmAEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout); void HAL_RTC_AlarmAEventCallback(RTC_HandleTypeDef *hrtc); /** * @} */ /** @defgroup RTC_Exported_Functions_Group4 Peripheral Control functions * @{ */ /* Peripheral Control functions ***********************************************/ HAL_StatusTypeDef HAL_RTC_WaitForSynchro(RTC_HandleTypeDef *hrtc); /** * @} */ /** @defgroup RTC_Exported_Functions_Group5 Peripheral State functions * @{ */ /* Peripheral State functions *************************************************/ HAL_RTCStateTypeDef HAL_RTC_GetState(RTC_HandleTypeDef *hrtc); /** * @} */ /** * @} */ /* Private types -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private constants ---------------------------------------------------------*/ /** @defgroup RTC_Private_Constants RTC Private Constants * @{ */ /* Masks Definition */ #define RTC_TR_RESERVED_MASK (RTC_TR_PM | RTC_TR_HT | RTC_TR_HU | \ RTC_TR_MNT | RTC_TR_MNU| RTC_TR_ST | \ RTC_TR_SU) #define RTC_DR_RESERVED_MASK (RTC_DR_YT | RTC_DR_YU | RTC_DR_WDU | \ RTC_DR_MT | RTC_DR_MU | RTC_DR_DT | \ RTC_DR_DU) #define RTC_INIT_MASK 0xFFFFFFFFU #define RTC_RSF_MASK (~(RTC_ICSR_INIT | RTC_ICSR_RSF)) #define RTC_TIMEOUT_VALUE 1000U /** * @} */ /* Private macros ------------------------------------------------------------*/ /** @defgroup RTC_Private_Macros RTC Private Macros * @{ */ /** @defgroup RTC_IS_RTC_Definitions RTC Private macros to check input parameters * @{ */ #define IS_RTC_OUTPUT(OUTPUT) (((OUTPUT) == RTC_OUTPUT_DISABLE) || \ ((OUTPUT) == RTC_OUTPUT_ALARMA) || \ ((OUTPUT) == RTC_OUTPUT_ALARMB) || \ ((OUTPUT) == RTC_OUTPUT_WAKEUP) || \ ((OUTPUT) == RTC_OUTPUT_TAMPER)) #define IS_RTC_HOUR_FORMAT(FORMAT) (((FORMAT) == RTC_HOURFORMAT_12) || \ ((FORMAT) == RTC_HOURFORMAT_24)) #define IS_RTC_OUTPUT_POL(POL) (((POL) == RTC_OUTPUT_POLARITY_HIGH) || \ ((POL) == RTC_OUTPUT_POLARITY_LOW)) #define IS_RTC_OUTPUT_TYPE(TYPE) (((TYPE) == RTC_OUTPUT_TYPE_OPENDRAIN) || \ ((TYPE) == RTC_OUTPUT_TYPE_PUSHPULL)) #define IS_RTC_OUTPUT_PULLUP(TYPE) (((TYPE) == RTC_OUTPUT_PULLUP_NONE) || \ ((TYPE) == RTC_OUTPUT_PULLUP_ON)) #define IS_RTC_OUTPUT_REMAP(REMAP) (((REMAP) == RTC_OUTPUT_REMAP_NONE) || \ ((REMAP) == RTC_OUTPUT_REMAP_POS1)) #define IS_RTC_HOURFORMAT12(PM) (((PM) == RTC_HOURFORMAT12_AM) || \ ((PM) == RTC_HOURFORMAT12_PM)) #define IS_RTC_DAYLIGHT_SAVING(SAVE) (((SAVE) == RTC_DAYLIGHTSAVING_SUB1H) || \ ((SAVE) == RTC_DAYLIGHTSAVING_ADD1H) || \ ((SAVE) == RTC_DAYLIGHTSAVING_NONE)) #define IS_RTC_STORE_OPERATION(OPERATION) (((OPERATION) == RTC_STOREOPERATION_RESET) || \ ((OPERATION) == RTC_STOREOPERATION_SET)) #define IS_RTC_FORMAT(FORMAT) (((FORMAT) == RTC_FORMAT_BIN) || \ ((FORMAT) == RTC_FORMAT_BCD)) #define IS_RTC_YEAR(YEAR) ((YEAR) <= 99u) #define IS_RTC_MONTH(MONTH) (((MONTH) >= 1u) && ((MONTH) <= 12u)) #define IS_RTC_DATE(DATE) (((DATE) >= 1u) && ((DATE) <= 31u)) #define IS_RTC_WEEKDAY(WEEKDAY) (((WEEKDAY) == RTC_WEEKDAY_MONDAY) || \ ((WEEKDAY) == RTC_WEEKDAY_TUESDAY) || \ ((WEEKDAY) == RTC_WEEKDAY_WEDNESDAY) || \ ((WEEKDAY) == RTC_WEEKDAY_THURSDAY) || \ ((WEEKDAY) == RTC_WEEKDAY_FRIDAY) || \ ((WEEKDAY) == RTC_WEEKDAY_SATURDAY) || \ ((WEEKDAY) == RTC_WEEKDAY_SUNDAY)) #define IS_RTC_ALARM_DATE_WEEKDAY_DATE(DATE) (((DATE) >0u) && ((DATE) <= 31u)) #define IS_RTC_ALARM_DATE_WEEKDAY_WEEKDAY(WEEKDAY) (((WEEKDAY) == RTC_WEEKDAY_MONDAY) || \ ((WEEKDAY) == RTC_WEEKDAY_TUESDAY) || \ ((WEEKDAY) == RTC_WEEKDAY_WEDNESDAY) || \ ((WEEKDAY) == RTC_WEEKDAY_THURSDAY) || \ ((WEEKDAY) == RTC_WEEKDAY_FRIDAY) || \ ((WEEKDAY) == RTC_WEEKDAY_SATURDAY) || \ ((WEEKDAY) == RTC_WEEKDAY_SUNDAY)) #define IS_RTC_ALARM_DATE_WEEKDAY_SEL(SEL) (((SEL) == RTC_ALARMDATEWEEKDAYSEL_DATE) || \ ((SEL) == RTC_ALARMDATEWEEKDAYSEL_WEEKDAY)) #define IS_RTC_ALARM_MASK(MASK) (((MASK) & ~(RTC_ALARMMASK_ALL)) == 0UL) #define IS_RTC_ALARM(ALARM) (((ALARM) == RTC_ALARM_A) || \ ((ALARM) == RTC_ALARM_B)) #define IS_RTC_ALARM_SUB_SECOND_VALUE(VALUE) ((VALUE) <= RTC_ALRMASSR_SS) #define IS_RTC_ALARM_SUB_SECOND_MASK(MASK) (((MASK) == 0UL) || \ (((MASK) >= RTC_ALARMSUBSECONDMASK_SS14_1) && ((MASK) <= RTC_ALARMSUBSECONDMASK_NONE))) #define IS_RTC_ASYNCH_PREDIV(PREDIV) ((PREDIV) <= (RTC_PRER_PREDIV_A >> RTC_PRER_PREDIV_A_Pos)) #define IS_RTC_SYNCH_PREDIV(PREDIV) ((PREDIV) <= (RTC_PRER_PREDIV_S >> RTC_PRER_PREDIV_S_Pos)) #define IS_RTC_HOUR12(HOUR) (((HOUR) > 0u) && ((HOUR) <= 12u)) #define IS_RTC_HOUR24(HOUR) ((HOUR) <= 23u) #define IS_RTC_MINUTES(MINUTES) ((MINUTES) <= 59u) #define IS_RTC_SECONDS(SECONDS) ((SECONDS) <= 59u) /** * @} */ /** * @} */ /* Private functions -------------------------------------------------------------*/ /** @defgroup RTC_Private_Functions RTC Private Functions * @{ */ HAL_StatusTypeDef RTC_EnterInitMode(RTC_HandleTypeDef *hrtc); HAL_StatusTypeDef RTC_ExitInitMode(RTC_HandleTypeDef *hrtc); uint8_t RTC_ByteToBcd2(uint8_t Value); uint8_t RTC_Bcd2ToByte(uint8_t Value); /** * @} */ /** * @} */ /** * @} */ #ifdef __cplusplus } #endif #endif /* STM32G4xx_HAL_RTC_H */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
polymurph/STM-Linux
stm32g474_blinky/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/RefLibs/src/MatrixFunctions/MatrixFunctions.c
#include "mat_add.c" #include "mat_cmplx_mult.c" #include "mat_inverse.c" #include "mat_mult.c" #include "mat_scale.c" #include "mat_sub.c" #include "mat_trans.c"
polymurph/STM-Linux
example_proj/G431_blinki/Core/Inc/app_main.h
<filename>example_proj/G431_blinki/Core/Inc/app_main.h #ifndef _APP_MAIN_H_ #define _APP_MAIN_H_ #ifdef __cplusplus extern "C" { #endif // __cplusplus int app_main(); #ifdef __cplusplus } #endif // __cplusplus #endif // _APP_MAIN_H_
polymurph/STM-Linux
stm32g474_blinky/Drivers/CMSIS/DSP/Source/FilteringFunctions/FilteringFunctions.c
<gh_stars>1000+ /* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: FilteringFunctions.c * Description: Combination of all filtering function source files. * * $Date: 18. March 2019 * $Revision: V1.0.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2019 ARM Limited or its affiliates. All rights reserved. * * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the License); you may * not use this file except in compliance with the License. * You may obtain a copy of the License at * * www.apache.org/licenses/LICENSE-2.0 * * 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. */ #include "arm_biquad_cascade_df1_32x64_init_q31.c" #include "arm_biquad_cascade_df1_32x64_q31.c" #include "arm_biquad_cascade_df1_f32.c" #include "arm_biquad_cascade_df1_fast_q15.c" #include "arm_biquad_cascade_df1_fast_q31.c" #include "arm_biquad_cascade_df1_init_f32.c" #include "arm_biquad_cascade_df1_init_q15.c" #include "arm_biquad_cascade_df1_init_q31.c" #include "arm_biquad_cascade_df1_q15.c" #include "arm_biquad_cascade_df1_q31.c" #include "arm_biquad_cascade_df2T_f32.c" #include "arm_biquad_cascade_df2T_f64.c" #include "arm_biquad_cascade_df2T_init_f32.c" #include "arm_biquad_cascade_df2T_init_f64.c" #include "arm_biquad_cascade_stereo_df2T_f32.c" #include "arm_biquad_cascade_stereo_df2T_init_f32.c" #include "arm_conv_f32.c" #include "arm_conv_fast_opt_q15.c" #include "arm_conv_fast_q15.c" #include "arm_conv_fast_q31.c" #include "arm_conv_opt_q15.c" #include "arm_conv_opt_q7.c" #include "arm_conv_partial_f32.c" #include "arm_conv_partial_fast_opt_q15.c" #include "arm_conv_partial_fast_q15.c" #include "arm_conv_partial_fast_q31.c" #include "arm_conv_partial_opt_q15.c" #include "arm_conv_partial_opt_q7.c" #include "arm_conv_partial_q15.c" #include "arm_conv_partial_q31.c" #include "arm_conv_partial_q7.c" #include "arm_conv_q15.c" #include "arm_conv_q31.c" #include "arm_conv_q7.c" #include "arm_correlate_f32.c" #include "arm_correlate_fast_opt_q15.c" #include "arm_correlate_fast_q15.c" #include "arm_correlate_fast_q31.c" #include "arm_correlate_opt_q15.c" #include "arm_correlate_opt_q7.c" #include "arm_correlate_q15.c" #include "arm_correlate_q31.c" #include "arm_correlate_q7.c" #include "arm_fir_decimate_f32.c" #include "arm_fir_decimate_fast_q15.c" #include "arm_fir_decimate_fast_q31.c" #include "arm_fir_decimate_init_f32.c" #include "arm_fir_decimate_init_q15.c" #include "arm_fir_decimate_init_q31.c" #include "arm_fir_decimate_q15.c" #include "arm_fir_decimate_q31.c" #include "arm_fir_f32.c" #include "arm_fir_fast_q15.c" #include "arm_fir_fast_q31.c" #include "arm_fir_init_f32.c" #include "arm_fir_init_q15.c" #include "arm_fir_init_q31.c" #include "arm_fir_init_q7.c" #include "arm_fir_interpolate_f32.c" #include "arm_fir_interpolate_init_f32.c" #include "arm_fir_interpolate_init_q15.c" #include "arm_fir_interpolate_init_q31.c" #include "arm_fir_interpolate_q15.c" #include "arm_fir_interpolate_q31.c" #include "arm_fir_lattice_f32.c" #include "arm_fir_lattice_init_f32.c" #include "arm_fir_lattice_init_q15.c" #include "arm_fir_lattice_init_q31.c" #include "arm_fir_lattice_q15.c" #include "arm_fir_lattice_q31.c" #include "arm_fir_q15.c" #include "arm_fir_q31.c" #include "arm_fir_q7.c" #include "arm_fir_sparse_f32.c" #include "arm_fir_sparse_init_f32.c" #include "arm_fir_sparse_init_q15.c" #include "arm_fir_sparse_init_q31.c" #include "arm_fir_sparse_init_q7.c" #include "arm_fir_sparse_q15.c" #include "arm_fir_sparse_q31.c" #include "arm_fir_sparse_q7.c" #include "arm_iir_lattice_f32.c" #include "arm_iir_lattice_init_f32.c" #include "arm_iir_lattice_init_q15.c" #include "arm_iir_lattice_init_q31.c" #include "arm_iir_lattice_q15.c" #include "arm_iir_lattice_q31.c" #include "arm_lms_f32.c" #include "arm_lms_init_f32.c" #include "arm_lms_init_q15.c" #include "arm_lms_init_q31.c" #include "arm_lms_norm_f32.c" #include "arm_lms_norm_init_f32.c" #include "arm_lms_norm_init_q15.c" #include "arm_lms_norm_init_q31.c" #include "arm_lms_norm_q15.c" #include "arm_lms_norm_q31.c" #include "arm_lms_q15.c" #include "arm_lms_q31.c"
polymurph/STM-Linux
stm32g474_blinky/Drivers/CMSIS/DSP/PythonWrapper/cmsisdsp_pkg/src/cmsismodule.c
<reponame>polymurph/STM-Linux /* ---------------------------------------------------------------------- * Project: CMSIS DSP Python Wrapper * Title: cmsismodule.c * Description: C code for the CMSIS-DSP Python wrapper * * $Date: 25. March 2019 * $Revision: V0.0.1 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the License); you may * not use this file except in compliance with the License. * You may obtain a copy of the License at * * www.apache.org/licenses/LICENSE-2.0 * * 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 NPY_NO_DEPRECATED_API NPY_1_15_API_VERSION #ifdef WIN #pragma warning( disable : 4013 ) #pragma warning( disable : 4244 ) #endif #include <Python.h> #define MAX(A,B) (A) < (B) ? (B) : (A) #define CAT1(A,B) A##B #define CAT(A,B) CAT1(A,B) #ifdef CMSISDSP #include "arm_math.h" #define MODNAME "cmsisdsp" #define MODINITNAME cmsisdsp #endif #include <numpy/arrayobject.h> #include <numpy/ndarraytypes.h> #if PY_MAJOR_VERSION >= 3 #define IS_PY3K #endif struct module_state { PyObject *error; }; #if PY_MAJOR_VERSION >= 3 #define GETSTATE(m) ((struct module_state*)PyModule_GetState(m)) #else #define GETSTATE(m) (&_state) static struct module_state _state; #endif static PyObject * error_out(PyObject *m) { struct module_state *st = GETSTATE(m); PyErr_SetString(st->error, "something bad happened"); return NULL; } #define MLTYPE(name,thenewfunc,deallocfunc,initfunc,methods)\ static PyTypeObject ml_##name##Type = { \ PyVarObject_HEAD_INIT(NULL, 0) \ .tp_name=MODNAME".##name", \ .tp_basicsize = sizeof(ml_##name##Object), \ .tp_itemsize = 0, \ .tp_dealloc = (destructor)deallocfunc, \ .tp_flags = Py_TPFLAGS_DEFAULT, \ .tp_doc = #name, \ .tp_init = (initproc)initfunc, \ .tp_new = (newfunc)thenewfunc, \ .tp_methods = methods \ }; #define MEMCPY(DST,SRC,NB,FORMAT) \ for(memCpyIndex = 0; memCpyIndex < (NB) ; memCpyIndex++)\ { \ (DST)[memCpyIndex] = (FORMAT)(SRC)[memCpyIndex]; \ } #define GETFIELD(NAME,FIELD,FORMAT) \ static PyObject * \ Method_##NAME##_##FIELD(ml_##NAME##Object *self, PyObject *ignored)\ { \ return(Py_BuildValue(FORMAT,self->instance->FIELD)); \ } #define GETFIELDARRAY(NAME,FIELD,FORMAT) \ static PyObject * \ Method_##NAME##_##FIELD(ml_##NAME##Object *self, PyObject *ignored)\ { \ return(specific_##NAME##_##FIELD(self->instance)); \ } #define INITARRAYFIELD(FIELD,FORMAT,SRCFORMAT,DSTFORMAT) \ if (FIELD) \ { \ PyArray_Descr *desct=PyArray_DescrFromType(FORMAT); \ PyArrayObject *FIELD##c = (PyArrayObject *)PyArray_FromAny(FIELD,desct,\ 1,0,NPY_ARRAY_C_CONTIGUOUS | NPY_ARRAY_ALIGNED | NPY_ARRAY_FORCECAST, \ NULL); \ if (FIELD##c) \ { \ uint32_t memCpyIndex; \ SRCFORMAT *f=(SRCFORMAT*)PyArray_DATA(FIELD##c); \ uint32_t n = PyArray_SIZE(FIELD##c); \ self->instance->FIELD =PyMem_Malloc(sizeof(DSTFORMAT)*n); \ MEMCPY(self->instance->FIELD ,f,n,DSTFORMAT); \ Py_DECREF(FIELD##c); \ } \ } #define GETCARRAY(PYVAR,CVAR,FORMAT,SRCFORMAT,DSTFORMAT) \ if (PYVAR) \ { \ PyArray_Descr *desct=PyArray_DescrFromType(FORMAT); \ PyArrayObject *PYVAR##c = (PyArrayObject *)PyArray_FromAny(PYVAR,desct,\ 1,0,NPY_ARRAY_C_CONTIGUOUS | NPY_ARRAY_ALIGNED | NPY_ARRAY_FORCECAST, \ NULL); \ if (PYVAR##c) \ { \ uint32_t memCpyIndex; \ SRCFORMAT *f=(SRCFORMAT*)PyArray_DATA(PYVAR##c); \ uint32_t n = PyArray_SIZE(PYVAR##c); \ CVAR =PyMem_Malloc(sizeof(DSTFORMAT)*n); \ MEMCPY(CVAR ,f,n,DSTFORMAT); \ Py_DECREF(PYVAR##c); \ } \ } #define GETARGUMENT(FIELD,FORMAT,SRCFORMAT,DSTFORMAT) \ uint32_t arraySize##FIELD=0; \ if (FIELD) \ { \ PyArray_Descr *desct=PyArray_DescrFromType(FORMAT); \ PyArrayObject *FIELD##c = (PyArrayObject *)PyArray_FromAny(FIELD,desct, \ 1,0,NPY_ARRAY_C_CONTIGUOUS | NPY_ARRAY_ALIGNED | NPY_ARRAY_FORCECAST, \ NULL); \ if (FIELD##c) \ { \ uint32_t memCpyIndex; \ SRCFORMAT *f=(SRCFORMAT*)PyArray_DATA(FIELD##c); \ arraySize##FIELD = PyArray_SIZE(FIELD##c); \ FIELD##_converted =PyMem_Malloc(sizeof(DSTFORMAT)*arraySize##FIELD);\ MEMCPY(FIELD##_converted ,f,arraySize##FIELD,DSTFORMAT); \ Py_DECREF(FIELD##c); \ } \ } #define FREEARGUMENT(FIELD) \ PyMem_Free(FIELD) #ifdef IS_PY3K #define ADDTYPE(name) \ if (PyType_Ready(&ml_##name##Type) < 0) \ return; \ \ Py_INCREF(&ml_##name##Type); \ PyModule_AddObject(module, #name, (PyObject *)&ml_##name##Type); #else #define ADDTYPE(name) \ if (PyType_Ready(&ml_##name##Type) < 0) \ return; \ \ Py_INCREF(&ml_##name##Type); \ PyModule_AddObject(module, #name, (PyObject *)&ml_##name##Type); #endif #define FLOATARRAY2(OBJ,NB1,NB2,DATA) \ npy_intp dims[2]; \ dims[0]=NB1; \ dims[1]=NB2; \ const int ND=2; \ PyObject *OBJ=PyArray_SimpleNewFromData(ND, dims, NPY_FLOAT, DATA); #define FLOATARRAY1(OBJ,NB1,DATA) \ npy_intp dims[1]; \ dims[0]=NB1; \ const int ND=1; \ PyObject *OBJ=PyArray_SimpleNewFromData(ND, dims, NPY_FLOAT, DATA); #define FLOAT64ARRAY1(OBJ,NB1,DATA) \ npy_intp dims[1]; \ dims[0]=NB1; \ const int ND=1; \ PyObject *OBJ=PyArray_SimpleNewFromData(ND, dims, NPY_DOUBLE, DATA); #define UINT32ARRAY1(OBJ,NB1,DATA) \ npy_intp dims[1]; \ dims[0]=NB1; \ const int ND=1; \ PyObject *OBJ=PyArray_SimpleNewFromData(ND, dims, NPY_UINT32, DATA); #define INT32ARRAY1(OBJ,NB1,DATA) \ npy_intp dims[1]; \ dims[0]=NB1; \ const int ND=1; \ PyObject *OBJ=PyArray_SimpleNewFromData(ND, dims, NPY_INT32, DATA); #define INT16ARRAY1(OBJ,NB1,DATA) \ npy_intp dims[1]; \ dims[0]=NB1; \ const int ND=1; \ PyObject *OBJ=PyArray_SimpleNewFromData(ND, dims, NPY_INT16, DATA); #define INT8ARRAY1(OBJ,NB1,DATA) \ npy_intp dims[1]; \ dims[0]=NB1; \ const int ND=1; \ PyObject *OBJ=PyArray_SimpleNewFromData(ND, dims, NPY_BYTE, DATA); #define MATRIXFROMNUMPY(EXT,TYP,SRCTYPE,NUMPYTYPE) \ arm_matrix_instance_##EXT *EXT##MatrixFromNumpy(PyObject *o) \ { \ arm_matrix_instance_##EXT *s; \ \ s=PyMem_Malloc(sizeof(arm_matrix_instance_##EXT)); \ s->pData=NULL; \ s->numRows=0; \ s->numCols=0; \ \ PyArray_Descr *desct=PyArray_DescrFromType(NUMPYTYPE); \ PyArrayObject *cdata = (PyArrayObject *)PyArray_FromAny(o,desct, \ 1,0,NPY_ARRAY_C_CONTIGUOUS | NPY_ARRAY_ALIGNED | NPY_ARRAY_FORCECAST, \ NULL); \ if (cdata) \ { \ uint32_t memCpyIndex; \ SRCTYPE *f=(SRCTYPE*)PyArray_DATA(cdata); \ s->numRows=PyArray_DIM(cdata,0); \ s->numCols=PyArray_DIM(cdata,1); \ uint32_t nb = PyArray_SIZE(cdata); \ s->pData = PyMem_Malloc(sizeof(TYP)*nb); \ MEMCPY(s->pData ,f,nb,TYP); \ Py_DECREF(cdata); \ } \ \ \ return(s); \ \ } MATRIXFROMNUMPY(f32,float32_t,double,NPY_DOUBLE); MATRIXFROMNUMPY(f64,float64_t,double,NPY_DOUBLE); MATRIXFROMNUMPY(q31,q31_t,int32_t,NPY_INT32); MATRIXFROMNUMPY(q15,q15_t,int16_t,NPY_INT16); #define CREATEMATRIX(EXT,TYP) \ arm_matrix_instance_##EXT *create##EXT##Matrix(uint32_t r,uint32_t c)\ { \ arm_matrix_instance_##EXT *s; \ \ s=PyMem_Malloc(sizeof(arm_matrix_instance_##EXT)); \ s->pData=PyMem_Malloc(sizeof(TYP)*r*c); \ s->numRows=r; \ s->numCols=c; \ return(s); \ } CREATEMATRIX(f32,float32_t); CREATEMATRIX(f64,float64_t); CREATEMATRIX(q31,q31_t); CREATEMATRIX(q15,q15_t); #define NUMPYARRAYFROMMATRIX(EXT,NUMPYTYPE_FROMC) \ PyObject *NumpyArrayFrom##EXT##Matrix(arm_matrix_instance_##EXT *mat) \ { \ npy_intp dims[2]; \ dims[0]=mat->numRows; \ dims[1]=mat->numCols; \ const int ND=2; \ PyObject *OBJ=PyArray_SimpleNewFromData(ND, dims, NUMPYTYPE_FROMC, mat->pData);\ return(OBJ); \ } NUMPYARRAYFROMMATRIX(f32,NPY_FLOAT); NUMPYARRAYFROMMATRIX(f64,NPY_DOUBLE); NUMPYARRAYFROMMATRIX(q31,NPY_INT32); NUMPYARRAYFROMMATRIX(q15,NPY_INT16); //#include "specific.h" #include "cmsismodule.h" #if 0 static PyObject *cmsisml_test(PyObject *obj, PyObject *args) { ml_arm_svm_linear_instance_f32Object *self=NULL; PyObject *svm, *vector=NULL; if (!PyArg_ParseTuple(args, "OO", &svm,&vector)) return NULL; self=(ml_arm_svm_linear_instance_f32Object*)svm; if (self) { if (self->instance) { int result; float32_t *input=NULL; GETCARRAY(vector,input,NPY_DOUBLE,double,float32_t); arm_svm_linear_predict_f32(self->instance,input,&result); /* printf("Dual\n"); for(int i = 0 ; i < self->instance->nbOfSupportVectors ; i++) { printf("%f\n",self->instance->dualCoefficients[i]); } printf("Vectors\n"); int k=0; for(int i = 0 ; i < self->instance->nbOfSupportVectors ; i++) { printf("Vector %d\n",i); for(int j = 0 ; j < self->instance->vectorDimension ; j++) { printf("%f\n",self->instance->supportVectors[k]); k++; } } printf("Classes\n"); for(int i = 0 ; i < 2 ; i++) { printf("%d\n",self->instance->classes[i]); } printf("Intercept %f\n",self->instance->intercept); */ PyMem_Free(input); return(Py_BuildValue("i",result)); } } return(Py_BuildValue("i",-1)); } #endif #ifdef IS_PY3K static int cmsisml_traverse(PyObject *m, visitproc visit, void *arg) { Py_VISIT(GETSTATE(m)->error); return 0; } static int cmsisml_clear(PyObject *m) { Py_CLEAR(GETSTATE(m)->error); return 0; } static struct PyModuleDef moduledef = { PyModuleDef_HEAD_INIT, MODNAME, NULL, sizeof(struct module_state), CMSISMLMethods, NULL, cmsisml_traverse, cmsisml_clear, NULL }; #define INITERROR return NULL PyMODINIT_FUNC CAT(PyInit_,MODINITNAME)(void) #else #define INITERROR return void CAT(init,MODINITNAME)(void) #endif { import_array(); #ifdef IS_PY3K PyObject *module = PyModule_Create(&moduledef); #else PyObject *module = Py_InitModule(MODNAME, CMSISMLMethods); #endif if (module == NULL) INITERROR; struct module_state *st = GETSTATE(module); st->error = PyErr_NewException(MODNAME".Error", NULL, NULL); if (st->error == NULL) { Py_DECREF(module); INITERROR; } typeRegistration(module); #ifdef IS_PY3K return module; #endif }
polymurph/STM-Linux
stm32g474_blinky/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/RefLibs/src/FilteringFunctions/fir_lattice.c
<gh_stars>10-100 #include "ref.h" void ref_fir_lattice_f32( const arm_fir_lattice_instance_f32 * S, float32_t * pSrc, float32_t * pDst, uint32_t blockSize) { float32_t *pState; /* State pointer */ const float32_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ float32_t *px; /* temporary state pointer */ const float32_t *pk; /* temporary coefficient pointer */ float32_t fcurr, fnext, gcurr, gnext; /* temporary variables */ uint32_t numStages = S->numStages; /* Length of the filter */ uint32_t blkCnt, stageCnt; /* temporary variables for counts */ pState = &S->pState[0]; blkCnt = blockSize; while (blkCnt > 0U) { /* f0(n) = x(n) */ fcurr = *pSrc++; /* Initialize coeff pointer */ pk = pCoeffs; /* Initialize state pointer */ px = pState; /* read g0(n-1) from state buffer */ gcurr = *px; /* for sample 1 processing */ /* f1(n) = f0(n) + K1 * g0(n-1) */ fnext = fcurr + ((*pk) * gcurr); /* g1(n) = f0(n) * K1 + g0(n-1) */ gnext = (fcurr * (*pk++)) + gcurr; /* save f0(n) in state buffer */ *px++ = fcurr; /* f1(n) is saved in fcurr for next stage processing */ fcurr = fnext; stageCnt = (numStages - 1U); /* stage loop */ while (stageCnt > 0U) { /* read g2(n) from state buffer */ gcurr = *px; /* save g1(n) in state buffer */ *px++ = gnext; /* Sample processing for K2, K3.... */ /* f2(n) = f1(n) + K2 * g1(n-1) */ fnext = fcurr + ((*pk) * gcurr); /* g2(n) = f1(n) * K2 + g1(n-1) */ gnext = (fcurr * (*pk++)) + gcurr; /* f1(n) is saved in fcurr1 for next stage processing */ fcurr = fnext; stageCnt--; } /* y(n) = fN(n) */ *pDst++ = fcurr; blkCnt--; } } void ref_fir_lattice_q31( const arm_fir_lattice_instance_q31 * S, q31_t * pSrc, q31_t * pDst, uint32_t blockSize) { q31_t *pState; /* State pointer */ const q31_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ q31_t *px; /* temporary state pointer */ const q31_t *pk; /* temporary coefficient pointer */ q31_t fcurr, fnext, gcurr, gnext; /* temporary variables */ uint32_t numStages = S->numStages; /* Length of the filter */ uint32_t blkCnt, stageCnt; /* temporary variables for counts */ pState = &S->pState[0]; blkCnt = blockSize; while (blkCnt > 0U) { /* f0(n) = x(n) */ fcurr = *pSrc++; /* Initialize coeff pointer */ pk = pCoeffs; /* Initialize state pointer */ px = pState; /* read g0(n-1) from state buffer */ gcurr = *px; /* for sample 1 processing */ /* f1(n) = f0(n) + K1 * g0(n-1) */ fnext = (q31_t) (((q63_t) gcurr * (*pk)) >> 31) + fcurr; /* g1(n) = f0(n) * K1 + g0(n-1) */ gnext = (q31_t) (((q63_t) fcurr * (*pk++)) >> 31) + gcurr; /* save g1(n) in state buffer */ *px++ = fcurr; /* f1(n) is saved in fcurr1 for next stage processing */ fcurr = fnext; stageCnt = (numStages - 1U); /* stage loop */ while (stageCnt > 0U) { /* read g2(n) from state buffer */ gcurr = *px; /* save g1(n) in state buffer */ *px++ = gnext; /* Sample processing for K2, K3.... */ /* f2(n) = f1(n) + K2 * g1(n-1) */ fnext = (q31_t) (((q63_t) gcurr * (*pk)) >> 31) + fcurr; /* g2(n) = f1(n) * K2 + g1(n-1) */ gnext = (q31_t) (((q63_t) fcurr * (*pk++)) >> 31) + gcurr; /* f1(n) is saved in fcurr1 for next stage processing */ fcurr = fnext; stageCnt--; } /* y(n) = fN(n) */ *pDst++ = fcurr; blkCnt--; } } void ref_fir_lattice_q15( const arm_fir_lattice_instance_q15 * S, q15_t * pSrc, q15_t * pDst, uint32_t blockSize) { q15_t *pState; /* State pointer */ const q15_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ q15_t *px; /* temporary state pointer */ const q15_t *pk; /* temporary coefficient pointer */ q31_t fcurnt, fnext, gcurnt, gnext; /* temporary variables */ uint32_t numStages = S->numStages; /* Length of the filter */ uint32_t blkCnt, stageCnt; /* temporary variables for counts */ pState = &S->pState[0]; blkCnt = blockSize; while (blkCnt > 0U) { /* f0(n) = x(n) */ fcurnt = *pSrc++; /* Initialize coeff pointer */ pk = (pCoeffs); /* Initialize state pointer */ px = pState; /* read g0(n-1) from state buffer */ gcurnt = *px; /* for sample 1 processing */ /* f1(n) = f0(n) + K1 * g0(n-1) */ fnext = ((gcurnt * (*pk)) >> 15U) + fcurnt; fnext = ref_sat_q15(fnext); /* g1(n) = f0(n) * K1 + g0(n-1) */ gnext = ((fcurnt * (*pk++)) >> 15U) + gcurnt; gnext = ref_sat_q15(gnext); /* save f0(n) in state buffer */ *px++ = (q15_t) fcurnt; /* f1(n) is saved in fcurnt for next stage processing */ fcurnt = fnext; stageCnt = (numStages - 1U); /* stage loop */ while (stageCnt > 0U) { /* read g1(n-1) from state buffer */ gcurnt = *px; /* save g0(n-1) in state buffer */ *px++ = (q15_t) gnext; /* Sample processing for K2, K3.... */ /* f2(n) = f1(n) + K2 * g1(n-1) */ fnext = ((gcurnt * (*pk)) >> 15U) + fcurnt; fnext = ref_sat_q15(fnext); /* g2(n) = f1(n) * K2 + g1(n-1) */ gnext = ((fcurnt * (*pk++)) >> 15U) + gcurnt; gnext = ref_sat_q15(gnext); /* f1(n) is saved in fcurnt for next stage processing */ fcurnt = fnext; stageCnt--; } /* y(n) = fN(n) */ *pDst++ = ref_sat_q15(fcurnt); blkCnt--; } }
polymurph/STM-Linux
stm32g474_blinky/Drivers/CMSIS/DSP/Source/TransformFunctions/arm_rfft_fast_init_f32.c
<filename>stm32g474_blinky/Drivers/CMSIS/DSP/Source/TransformFunctions/arm_rfft_fast_init_f32.c /* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_cfft_init_f32.c * Description: Split Radix Decimation in Frequency CFFT Floating point processing function * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the License); you may * not use this file except in compliance with the License. * You may obtain a copy of the License at * * www.apache.org/licenses/LICENSE-2.0 * * 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. */ #include "arm_math.h" #include "arm_common_tables.h" /** @ingroup groupTransforms */ /** @addtogroup RealFFT @{ */ #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F32_16) && defined(ARM_TABLE_BITREVIDX_FLT_16) && defined(ARM_TABLE_TWIDDLECOEF_F32_16) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F32_32)) /** @brief Initialization function for the 32pt floating-point real FFT. @param[in,out] S points to an arm_rfft_fast_instance_f32 structure @return execution status - \ref ARM_MATH_SUCCESS : Operation successful - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected */ arm_status arm_rfft_32_fast_init_f32( arm_rfft_fast_instance_f32 * S ) { arm_cfft_instance_f32 * Sint; if( !S ) return ARM_MATH_ARGUMENT_ERROR; Sint = &(S->Sint); Sint->fftLen = 16U; S->fftLenRFFT = 32U; Sint->bitRevLength = ARMBITREVINDEXTABLE_16_TABLE_LENGTH; Sint->pBitRevTable = (uint16_t *)armBitRevIndexTable16; Sint->pTwiddle = (float32_t *) twiddleCoef_16; S->pTwiddleRFFT = (float32_t *) twiddleCoef_rfft_32; return ARM_MATH_SUCCESS; } #endif #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F32_32) && defined(ARM_TABLE_BITREVIDX_FLT_32) && defined(ARM_TABLE_TWIDDLECOEF_F32_32) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F32_64)) /** @brief Initialization function for the 64pt floating-point real FFT. @param[in,out] S points to an arm_rfft_fast_instance_f32 structure @return execution status - \ref ARM_MATH_SUCCESS : Operation successful - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected */ arm_status arm_rfft_64_fast_init_f32( arm_rfft_fast_instance_f32 * S ) { arm_cfft_instance_f32 * Sint; if( !S ) return ARM_MATH_ARGUMENT_ERROR; Sint = &(S->Sint); Sint->fftLen = 32U; S->fftLenRFFT = 64U; Sint->bitRevLength = ARMBITREVINDEXTABLE_32_TABLE_LENGTH; Sint->pBitRevTable = (uint16_t *)armBitRevIndexTable32; Sint->pTwiddle = (float32_t *) twiddleCoef_32; S->pTwiddleRFFT = (float32_t *) twiddleCoef_rfft_64; return ARM_MATH_SUCCESS; } #endif #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F32_64) && defined(ARM_TABLE_BITREVIDX_FLT_64) && defined(ARM_TABLE_TWIDDLECOEF_F32_64) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F32_128)) /** @brief Initialization function for the 128pt floating-point real FFT. @param[in,out] S points to an arm_rfft_fast_instance_f32 structure @return execution status - \ref ARM_MATH_SUCCESS : Operation successful - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected */ arm_status arm_rfft_128_fast_init_f32( arm_rfft_fast_instance_f32 * S ) { arm_cfft_instance_f32 * Sint; if( !S ) return ARM_MATH_ARGUMENT_ERROR; Sint = &(S->Sint); Sint->fftLen = 64U; S->fftLenRFFT = 128U; Sint->bitRevLength = ARMBITREVINDEXTABLE_64_TABLE_LENGTH; Sint->pBitRevTable = (uint16_t *)armBitRevIndexTable64; Sint->pTwiddle = (float32_t *) twiddleCoef_64; S->pTwiddleRFFT = (float32_t *) twiddleCoef_rfft_128; return ARM_MATH_SUCCESS; } #endif #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F32_128) && defined(ARM_TABLE_BITREVIDX_FLT_128) && defined(ARM_TABLE_TWIDDLECOEF_F32_128) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F32_256)) /** @brief Initialization function for the 256pt floating-point real FFT. @param[in,out] S points to an arm_rfft_fast_instance_f32 structure @return execution status - \ref ARM_MATH_SUCCESS : Operation successful - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected */ arm_status arm_rfft_256_fast_init_f32( arm_rfft_fast_instance_f32 * S ) { arm_cfft_instance_f32 * Sint; if( !S ) return ARM_MATH_ARGUMENT_ERROR; Sint = &(S->Sint); Sint->fftLen = 128U; S->fftLenRFFT = 256U; Sint->bitRevLength = ARMBITREVINDEXTABLE_128_TABLE_LENGTH; Sint->pBitRevTable = (uint16_t *)armBitRevIndexTable128; Sint->pTwiddle = (float32_t *) twiddleCoef_128; S->pTwiddleRFFT = (float32_t *) twiddleCoef_rfft_256; return ARM_MATH_SUCCESS; } #endif #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F32_256) && defined(ARM_TABLE_BITREVIDX_FLT_256) && defined(ARM_TABLE_TWIDDLECOEF_F32_256) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F32_512)) /** @brief Initialization function for the 512pt floating-point real FFT. @param[in,out] S points to an arm_rfft_fast_instance_f32 structure @return execution status - \ref ARM_MATH_SUCCESS : Operation successful - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected */ arm_status arm_rfft_512_fast_init_f32( arm_rfft_fast_instance_f32 * S ) { arm_cfft_instance_f32 * Sint; if( !S ) return ARM_MATH_ARGUMENT_ERROR; Sint = &(S->Sint); Sint->fftLen = 256U; S->fftLenRFFT = 512U; Sint->bitRevLength = ARMBITREVINDEXTABLE_256_TABLE_LENGTH; Sint->pBitRevTable = (uint16_t *)armBitRevIndexTable256; Sint->pTwiddle = (float32_t *) twiddleCoef_256; S->pTwiddleRFFT = (float32_t *) twiddleCoef_rfft_512; return ARM_MATH_SUCCESS; } #endif #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F32_512) && defined(ARM_TABLE_BITREVIDX_FLT_512) && defined(ARM_TABLE_TWIDDLECOEF_F32_512) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F32_1024)) /** @brief Initialization function for the 1024pt floating-point real FFT. @param[in,out] S points to an arm_rfft_fast_instance_f32 structure @return execution status - \ref ARM_MATH_SUCCESS : Operation successful - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected */ arm_status arm_rfft_1024_fast_init_f32( arm_rfft_fast_instance_f32 * S ) { arm_cfft_instance_f32 * Sint; if( !S ) return ARM_MATH_ARGUMENT_ERROR; Sint = &(S->Sint); Sint->fftLen = 512U; S->fftLenRFFT = 1024U; Sint->bitRevLength = ARMBITREVINDEXTABLE_512_TABLE_LENGTH; Sint->pBitRevTable = (uint16_t *)armBitRevIndexTable512; Sint->pTwiddle = (float32_t *) twiddleCoef_512; S->pTwiddleRFFT = (float32_t *) twiddleCoef_rfft_1024; return ARM_MATH_SUCCESS; } #endif #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F32_1024) && defined(ARM_TABLE_BITREVIDX_FLT_1024) && defined(ARM_TABLE_TWIDDLECOEF_F32_1024) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F32_2048)) /** @brief Initialization function for the 2048pt floating-point real FFT. @param[in,out] S points to an arm_rfft_fast_instance_f32 structure @return execution status - \ref ARM_MATH_SUCCESS : Operation successful - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected */ arm_status arm_rfft_2048_fast_init_f32( arm_rfft_fast_instance_f32 * S ) { arm_cfft_instance_f32 * Sint; if( !S ) return ARM_MATH_ARGUMENT_ERROR; Sint = &(S->Sint); Sint->fftLen = 1024U; S->fftLenRFFT = 2048U; Sint->bitRevLength = ARMBITREVINDEXTABLE_1024_TABLE_LENGTH; Sint->pBitRevTable = (uint16_t *)armBitRevIndexTable1024; Sint->pTwiddle = (float32_t *) twiddleCoef_1024; S->pTwiddleRFFT = (float32_t *) twiddleCoef_rfft_2048; return ARM_MATH_SUCCESS; } #endif #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F32_2048) && defined(ARM_TABLE_BITREVIDX_FLT_2048) && defined(ARM_TABLE_TWIDDLECOEF_F32_2048) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F32_4096)) /** * @brief Initialization function for the 4096pt floating-point real FFT. * @param[in,out] S points to an arm_rfft_fast_instance_f32 structure @return execution status - \ref ARM_MATH_SUCCESS : Operation successful - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected */ arm_status arm_rfft_4096_fast_init_f32( arm_rfft_fast_instance_f32 * S ) { arm_cfft_instance_f32 * Sint; if( !S ) return ARM_MATH_ARGUMENT_ERROR; Sint = &(S->Sint); Sint->fftLen = 2048U; S->fftLenRFFT = 4096U; Sint->bitRevLength = ARMBITREVINDEXTABLE_2048_TABLE_LENGTH; Sint->pBitRevTable = (uint16_t *)armBitRevIndexTable2048; Sint->pTwiddle = (float32_t *) twiddleCoef_2048; S->pTwiddleRFFT = (float32_t *) twiddleCoef_rfft_4096; return ARM_MATH_SUCCESS; } #endif /** @brief Initialization function for the floating-point real FFT. @param[in,out] S points to an arm_rfft_fast_instance_f32 structure @param[in] fftLen length of the Real Sequence @return execution status - \ref ARM_MATH_SUCCESS : Operation successful - \ref ARM_MATH_ARGUMENT_ERROR : <code>fftLen</code> is not a supported length @par Description The parameter <code>fftLen</code> specifies the length of RFFT/CIFFT process. Supported FFT Lengths are 32, 64, 128, 256, 512, 1024, 2048, 4096. @par This Function also initializes Twiddle factor table pointer and Bit reversal table pointer. */ arm_status arm_rfft_fast_init_f32( arm_rfft_fast_instance_f32 * S, uint16_t fftLen) { typedef arm_status(*fft_init_ptr)( arm_rfft_fast_instance_f32 *); fft_init_ptr fptr = 0x0; switch (fftLen) { #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F32_2048) && defined(ARM_TABLE_BITREVIDX_FLT_2048) && defined(ARM_TABLE_TWIDDLECOEF_F32_2048) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F32_4096)) case 4096U: fptr = arm_rfft_4096_fast_init_f32; break; #endif #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F32_1024) && defined(ARM_TABLE_BITREVIDX_FLT_1024) && defined(ARM_TABLE_TWIDDLECOEF_F32_1024) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F32_2048)) case 2048U: fptr = arm_rfft_2048_fast_init_f32; break; #endif #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F32_512) && defined(ARM_TABLE_BITREVIDX_FLT_512) && defined(ARM_TABLE_TWIDDLECOEF_F32_512) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F32_1024)) case 1024U: fptr = arm_rfft_1024_fast_init_f32; break; #endif #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F32_256) && defined(ARM_TABLE_BITREVIDX_FLT_256) && defined(ARM_TABLE_TWIDDLECOEF_F32_256) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F32_512)) case 512U: fptr = arm_rfft_512_fast_init_f32; break; #endif #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F32_128) && defined(ARM_TABLE_BITREVIDX_FLT_128) && defined(ARM_TABLE_TWIDDLECOEF_F32_128) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F32_256)) case 256U: fptr = arm_rfft_256_fast_init_f32; break; #endif #if (defined(ARM_TABLE_TWIDDLECOEF_F32_64) && defined(ARM_TABLE_BITREVIDX_FLT_64) && defined(ARM_TABLE_TWIDDLECOEF_F32_64) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F32_128)) case 128U: fptr = arm_rfft_128_fast_init_f32; break; #endif #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F32_32) && defined(ARM_TABLE_BITREVIDX_FLT_32) && defined(ARM_TABLE_TWIDDLECOEF_F32_32) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F32_64)) case 64U: fptr = arm_rfft_64_fast_init_f32; break; #endif #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F32_16) && defined(ARM_TABLE_BITREVIDX_FLT_16) && defined(ARM_TABLE_TWIDDLECOEF_F32_16) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F32_32)) case 32U: fptr = arm_rfft_32_fast_init_f32; break; #endif default: return ARM_MATH_ARGUMENT_ERROR; } if( ! fptr ) return ARM_MATH_ARGUMENT_ERROR; return fptr( S ); } /** @} end of RealFFT group */
polymurph/STM-Linux
stm32g474_blinky/Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_fmac.h
<gh_stars>10-100 /** ****************************************************************************** * @file stm32g4xx_hal_fmac.h * @author MCD Application Team * @brief Header for stm32g4xx_hal_fmac.c module ****************************************************************************** * @attention * * <h2><center>&copy; Copyright (c) 2019 STMicroelectronics. * All rights reserved.</center></h2> * * This software component is licensed by ST under BSD 3-Clause license, * the "License"; You may not use this file except in compliance with the * License. You may obtain a copy of the License at: * opensource.org/licenses/BSD-3-Clause * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef STM32G4xx_HAL_FMAC_H #define STM32G4xx_HAL_FMAC_H #ifdef __cplusplus extern "C" { #endif /* Includes ------------------------------------------------------------------*/ #include "stm32g4xx_hal_def.h" /** @addtogroup STM32G4xx_HAL_Driver * @{ */ /** @addtogroup FMAC * @{ */ /* Exported types ------------------------------------------------------------*/ /** @defgroup FMAC_Exported_Types FMAC Exported Types * @{ */ /** * @brief FMAC HAL State Structure definition */ typedef enum { HAL_FMAC_STATE_RESET = 0x00U, /*!< FMAC not yet initialized or disabled */ HAL_FMAC_STATE_READY = 0x20U, /*!< FMAC initialized and ready for use */ HAL_FMAC_STATE_BUSY = 0x24U, /*!< FMAC internal process is ongoing */ HAL_FMAC_STATE_BUSY_RD = 0x25U, /*!< FMAC reading configuration is ongoing */ HAL_FMAC_STATE_BUSY_WR = 0x26U, /*!< FMAC writing configuration is ongoing */ HAL_FMAC_STATE_TIMEOUT = 0xA0U, /*!< FMAC in Timeout state */ HAL_FMAC_STATE_ERROR = 0xE0U /*!< FMAC in Error state */ } HAL_FMAC_StateTypeDef; /** * @brief FMAC Handle Structure definition */ #if (USE_HAL_FMAC_REGISTER_CALLBACKS == 1) typedef struct __FMAC_HandleTypeDef #else typedef struct #endif /* USE_HAL_FMAC_REGISTER_CALLBACKS */ { FMAC_TypeDef *Instance; /*!< Register base address */ uint32_t FilterParam; /*!< Filter configuration (operation and parameters). Set to 0 if no valid configuration was applied. */ uint8_t InputAccess; /*!< Access to the input buffer (internal memory area): DMA, IT, Polling, None. This parameter can be a value of @ref FMAC_Buffer_Access. */ uint8_t OutputAccess; /*!< Access to the output buffer (internal memory area): DMA, IT, Polling, None. This parameter can be a value of @ref FMAC_Buffer_Access. */ int16_t *pInput; /*!< Pointer to FMAC input data buffer */ uint16_t InputCurrentSize; /*!< Number of the input elements already written into FMAC */ uint16_t *pInputSize; /*!< Number of input elements to write (memory allocated to pInput). In case of early interruption of the filter operation, its value will be updated. */ int16_t *pOutput; /*!< Pointer to FMAC output data buffer */ uint16_t OutputCurrentSize; /*!< Number of the output elements already read from FMAC */ uint16_t *pOutputSize; /*!< Number of output elements to read (memory allocated to pOutput). In case of early interruption of the filter operation, its value will be updated. */ DMA_HandleTypeDef *hdmaIn; /*!< FMAC peripheral input data DMA handle parameters */ DMA_HandleTypeDef *hdmaOut; /*!< FMAC peripheral output data DMA handle parameters */ DMA_HandleTypeDef *hdmaPreload; /*!< FMAC peripheral preloaded data (X1, X2 and Y) DMA handle parameters */ #if (USE_HAL_FMAC_REGISTER_CALLBACKS == 1) void (* ErrorCallback)(struct __FMAC_HandleTypeDef *hfmac); /*!< FMAC error callback */ void (* HalfGetDataCallback)(struct __FMAC_HandleTypeDef *hfmac); /*!< FMAC get half data callback */ void (* GetDataCallback)(struct __FMAC_HandleTypeDef *hfmac); /*!< FMAC get data callback */ void (* HalfOutputDataReadyCallback)(struct __FMAC_HandleTypeDef *hfmac); /*!< FMAC half output data ready callback */ void (* OutputDataReadyCallback)(struct __FMAC_HandleTypeDef *hfmac); /*!< FMAC output data ready callback */ void (* FilterConfigCallback)(struct __FMAC_HandleTypeDef *hfmac); /*!< FMAC filter configuration callback */ void (* FilterPreloadCallback)(struct __FMAC_HandleTypeDef *hfmac); /*!< FMAC filter preload callback */ void (* MspInitCallback)(struct __FMAC_HandleTypeDef *hfmac); /*!< FMAC Msp Init callback */ void (* MspDeInitCallback)(struct __FMAC_HandleTypeDef *hfmac); /*!< FMAC Msp DeInit callback */ #endif /* (USE_HAL_FMAC_REGISTER_CALLBACKS) */ HAL_LockTypeDef Lock; /*!< FMAC locking object */ __IO HAL_FMAC_StateTypeDef State; /*!< FMAC state related to global handle management This parameter can be a value of @ref HAL_FMAC_StateTypeDef */ __IO HAL_FMAC_StateTypeDef RdState; /*!< FMAC state related to read operations (access to Y buffer) This parameter can be a value of @ref HAL_FMAC_StateTypeDef */ __IO HAL_FMAC_StateTypeDef WrState; /*!< FMAC state related to write operations (access to X1 buffer) This parameter can be a value of @ref HAL_FMAC_StateTypeDef */ __IO uint32_t ErrorCode; /*!< FMAC peripheral error code This parameter can be a value of @ref FMAC_Error_Code */ } FMAC_HandleTypeDef; #if (USE_HAL_FMAC_REGISTER_CALLBACKS == 1) /** * @brief FMAC Callback ID enumeration definition */ typedef enum { HAL_FMAC_ERROR_CB_ID = 0x00U, /*!< FMAC error callback ID */ HAL_FMAC_HALF_GET_DATA_CB_ID = 0x01U, /*!< FMAC get half data callback ID */ HAL_FMAC_GET_DATA_CB_ID = 0x02U, /*!< FMAC get data callback ID */ HAL_FMAC_HALF_OUTPUT_DATA_READY_CB_ID = 0x03U, /*!< FMAC half output data ready callback ID */ HAL_FMAC_OUTPUT_DATA_READY_CB_ID = 0x04U, /*!< FMAC output data ready callback ID */ HAL_FMAC_FILTER_CONFIG_CB_ID = 0x05U, /*!< FMAC filter configuration callback ID */ HAL_FMAC_FILTER_PRELOAD_CB_ID = 0x06U, /*!< FMAC filter preload callback ID */ HAL_FMAC_MSPINIT_CB_ID = 0x07U, /*!< FMAC MspInit callback ID */ HAL_FMAC_MSPDEINIT_CB_ID = 0x08U, /*!< FMAC MspDeInit callback ID */ } HAL_FMAC_CallbackIDTypeDef; /** * @brief HAL FMAC Callback pointer definition */ typedef void (*pFMAC_CallbackTypeDef)(FMAC_HandleTypeDef *hfmac); /*!< pointer to an FMAC callback function */ #endif /* USE_HAL_FMAC_REGISTER_CALLBACKS */ /** * @brief FMAC Filter Configuration Structure definition */ typedef struct { uint8_t InputBaseAddress; /*!< Base address of the input buffer (X1) within the internal memory (0x00 to 0xFF). Ignored if InputBufferSize is set to 0 (previous configuration kept). Note: the buffers can overlap or even coincide exactly. */ uint8_t InputBufferSize; /*!< Number of 16-bit words allocated to the input buffer (including the optional "headroom"). 0 if a previous configuration should be kept. */ uint32_t InputThreshold; /*!< Input threshold: the buffer full flag will be set if the number of free spaces in the buffer is lower than this threshold. This parameter can be a value of @ref FMAC_Data_Buffer_Threshold. */ uint8_t CoeffBaseAddress; /*!< Base address of the coefficient buffer (X2) within the internal memory (0x00 to 0xFF). Ignored if CoeffBufferSize is set to 0 (previous configuration kept). Note: the buffers can overlap or even coincide exactly. */ uint8_t CoeffBufferSize; /*!< Number of 16-bit words allocated to the coefficient buffer. 0 if a previous configuration should be kept. */ uint8_t OutputBaseAddress; /*!< Base address of the output buffer (Y) within the internal memory (0x00 to 0xFF). Ignored if OuputBufferSize is set to 0 (previous configuration kept). Note: the buffers can overlap or even coincide exactly. */ uint8_t OutputBufferSize; /*!< Number of 16-bit words allocated to the output buffer (including the optional "headroom"). 0 if a previous configuration should be kept. */ uint32_t OutputThreshold; /*!< Output threshold: the buffer empty flag will be set if the number of unread values in the buffer is lower than this threshold. This parameter can be a value of @ref FMAC_Data_Buffer_Threshold. */ int16_t *pCoeffA; /*!< [IIR only] Initialization of the coefficient vector A. If not needed, it should be set to NULL. */ uint8_t CoeffASize; /*!< Size of the coefficient vector A. */ int16_t *pCoeffB; /*!< Initialization of the coefficient vector B. If not needed (re-use of a previously loaded buffer), it should be set to NULL. */ uint8_t CoeffBSize; /*!< Size of the coefficient vector B. */ uint8_t InputAccess; /*!< Access to the input buffer (internal memory area): DMA, IT, Polling, None. This parameter can be a value of @ref FMAC_Buffer_Access. */ uint8_t OutputAccess; /*!< Access to the output buffer (internal memory area): DMA, IT, Polling, None. This parameter can be a value of @ref FMAC_Buffer_Access. */ uint32_t Clip; /*!< Enable or disable the clipping feature. If the q1.15 range is exceeded, wrapping is done when the clipping feature is disabled and saturation is done when the clipping feature is enabled. This parameter can be a value of @ref FMAC_Clip_State. */ uint32_t Filter; /*!< Filter type. This parameter can be a value of @ref FMAC_Functions (filter related values). */ uint8_t P; /*!< Parameter P (vector length, number of filter taps, etc.). */ uint8_t Q; /*!< Parameter Q (vector length, etc.). Ignored if not needed. */ uint8_t R; /*!< Parameter R (gain, etc.). Ignored if not needed. */ } FMAC_FilterConfigTypeDef; /** * @} */ /* Exported constants --------------------------------------------------------*/ /** @defgroup FMAC_Exported_Constants FMAC Exported Constants * @{ */ /** @defgroup FMAC_Error_Code FMAC Error code * @{ */ #define HAL_FMAC_ERROR_NONE 0x00000000U /*!< No error */ #define HAL_FMAC_ERROR_SAT 0x00000001U /*!< Saturation error */ #define HAL_FMAC_ERROR_UNFL 0x00000002U /*!< Underflow error */ #define HAL_FMAC_ERROR_OVFL 0x00000004U /*!< Overflow error */ #define HAL_FMAC_ERROR_DMA 0x00000008U /*!< DMA error */ #define HAL_FMAC_ERROR_RESET 0x00000010U /*!< Reset error */ #define HAL_FMAC_ERROR_PARAM 0x00000020U /*!< Parameter error */ #if (USE_HAL_FMAC_REGISTER_CALLBACKS == 1) #define HAL_FMAC_ERROR_INVALID_CALLBACK 0x00000040U /*!< Invalid Callback error */ #endif /* USE_HAL_FMAC_REGISTER_CALLBACKS */ #define HAL_FMAC_ERROR_TIMEOUT 0x00000080U /*!< Timeout error */ /** * @} */ /** @defgroup FMAC_Functions FMAC Functions * @{ */ #define FMAC_FUNC_LOAD_X1 (FMAC_PARAM_FUNC_0) /*!< Load X1 buffer */ #define FMAC_FUNC_LOAD_X2 (FMAC_PARAM_FUNC_1) /*!< Load X2 buffer */ #define FMAC_FUNC_LOAD_Y (FMAC_PARAM_FUNC_1 | FMAC_PARAM_FUNC_0) /*!< Load Y buffer */ #define FMAC_FUNC_CONVO_FIR (FMAC_PARAM_FUNC_3) /*!< Convolution (FIR filter) */ #define FMAC_FUNC_IIR_DIRECT_FORM_1 (FMAC_PARAM_FUNC_3 | FMAC_PARAM_FUNC_0) /*!< IIR filter (direct form 1) */ /** * @} */ /** @defgroup FMAC_Data_Buffer_Threshold FMAC Data Buffer Threshold * @{ * @note This parameter sets a watermark for buffer full (input) or buffer empty (output). */ #define FMAC_THRESHOLD_1 0x00000000U /*!< Input: Buffer full flag set if the number of free spaces in the buffer is less than 1. Output: Buffer empty flag set if the number of unread values in the buffer is less than 1. */ #define FMAC_THRESHOLD_2 0x01000000U /*!< Input: Buffer full flag set if the number of free spaces in the buffer is less than 2. Output: Buffer empty flag set if the number of unread values in the buffer is less than 2. */ #define FMAC_THRESHOLD_4 0x02000000U /*!< Input: Buffer full flag set if the number of free spaces in the buffer is less than 4. Output: Buffer empty flag set if the number of unread values in the buffer is less than 4. */ #define FMAC_THRESHOLD_8 0x03000000U /*!< Input: Buffer full flag set if the number of free spaces in the buffer is less than 8. Output: Buffer empty flag set if the number of unread values in the buffer is less than 8. */ #define FMAC_THRESHOLD_NO_VALUE 0xFFFFFFFFU /*!< The configured threshold value shouldn't be changed */ /** * @} */ /** @defgroup FMAC_Buffer_Access FMAC Buffer Access * @{ */ #define FMAC_BUFFER_ACCESS_NONE 0x00U /*!< Buffer handled by an external IP (ADC for instance) */ #define FMAC_BUFFER_ACCESS_DMA 0x01U /*!< Buffer accessed through DMA */ #define FMAC_BUFFER_ACCESS_POLLING 0x02U /*!< Buffer accessed through polling */ #define FMAC_BUFFER_ACCESS_IT 0x03U /*!< Buffer accessed through interruptions */ /** * @} */ /** @defgroup FMAC_Clip_State FMAC Clip State * @{ */ #define FMAC_CLIP_DISABLED 0x00000000U /*!< Clipping disabled */ #define FMAC_CLIP_ENABLED FMAC_CR_CLIPEN /*!< Clipping enabled */ /** * @} */ /** @defgroup FMAC_Flags FMAC status flags * @{ */ #define FMAC_FLAG_YEMPTY FMAC_SR_YEMPTY /*!< Y Buffer Empty Flag */ #define FMAC_FLAG_X1FULL FMAC_SR_X1FULL /*!< X1 Buffer Full Flag */ #define FMAC_FLAG_OVFL FMAC_SR_OVFL /*!< Overflow Error Flag */ #define FMAC_FLAG_UNFL FMAC_SR_UNFL /*!< Underflow Error Flag */ #define FMAC_FLAG_SAT FMAC_SR_SAT /*!< Saturation Error Flag (this helps in debugging a filter) */ /** * @} */ /** @defgroup FMAC_Interrupts_Enable FMAC Interrupts Enable bit * @{ */ #define FMAC_IT_RIEN FMAC_CR_RIEN /*!< Read Interrupt Enable */ #define FMAC_IT_WIEN FMAC_CR_WIEN /*!< Write Interrupt Enable */ #define FMAC_IT_OVFLIEN FMAC_CR_OVFLIEN /*!< Overflow Error Interrupt Enable */ #define FMAC_IT_UNFLIEN FMAC_CR_UNFLIEN /*!< Underflow Error Interrupt Enable */ #define FMAC_IT_SATIEN FMAC_CR_SATIEN /*!< Saturation Error Interrupt Enable (this helps in debugging a filter) */ /** * @} */ /** * @} */ /* External variables --------------------------------------------------------*/ /* Exported macros -----------------------------------------------------------*/ /** @defgroup FMAC_Exported_Macros FMAC Exported Macros * @{ */ /** @brief Reset FMAC handle state. * @param __HANDLE__ FMAC handle. * @retval None */ #if (USE_HAL_FMAC_REGISTER_CALLBACKS == 1) #define __HAL_FMAC_RESET_HANDLE_STATE(__HANDLE__) do{ \ (__HANDLE__)->State = HAL_FMAC_STATE_RESET; \ (__HANDLE__)->MspInitCallback = NULL; \ (__HANDLE__)->MspDeInitCallback = NULL; \ } while(0U) #else #define __HAL_FMAC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_FMAC_STATE_RESET) #endif /* USE_HAL_FMAC_REGISTER_CALLBACKS */ /** * @brief Enable the specified FMAC interrupt * @param __HANDLE__ FMAC handle. * @param __INTERRUPT__ FMAC Interrupt. * This parameter can be any combination of the following values: * @arg @ref FMAC_IT_RIEN Read interrupt enable * @arg @ref FMAC_IT_WIEN Write interrupt enable * @arg @ref FMAC_IT_OVFLIEN Overflow error interrupt enable * @arg @ref FMAC_IT_UNFLIEN Underflow error interrupt enable * @arg @ref FMAC_IT_SATIEN Saturation error interrupt enable (this helps in debugging a filter) * @retval None */ #define __HAL_FMAC_ENABLE_IT(__HANDLE__, __INTERRUPT__) \ (((__HANDLE__)->Instance->CR) |= (__INTERRUPT__)) /** * @brief Disable the FMAC interrupt * @param __HANDLE__ FMAC handle. * @param __INTERRUPT__ FMAC Interrupt. * This parameter can be any combination of the following values: * @arg @ref FMAC_IT_RIEN Read interrupt enable * @arg @ref FMAC_IT_WIEN Write interrupt enable * @arg @ref FMAC_IT_OVFLIEN Overflow error interrupt enable * @arg @ref FMAC_IT_UNFLIEN Underflow error interrupt enable * @arg @ref FMAC_IT_SATIEN Saturation error interrupt enable (this helps in debugging a filter) * @retval None */ #define __HAL_FMAC_DISABLE_IT(__HANDLE__, __INTERRUPT__) \ (((__HANDLE__)->Instance->CR) &= ~(__INTERRUPT__)) /** @brief Check whether the specified FMAC interrupt occurred or not. * @param __HANDLE__ FMAC handle. * @param __INTERRUPT__ FMAC interrupt to check. * This parameter can be any combination of the following values: * @arg @ref FMAC_FLAG_YEMPTY Y Buffer Empty Flag * @arg @ref FMAC_FLAG_X1FULL X1 Buffer Full Flag * @arg @ref FMAC_FLAG_OVFL Overflow Error Flag * @arg @ref FMAC_FLAG_UNFL Underflow Error Flag * @arg @ref FMAC_FLAG_SAT Saturation Error Flag * @retval SET (interrupt occurred) or RESET (interrupt did not occurred) */ #define __HAL_FMAC_GET_IT(__HANDLE__, __INTERRUPT__) \ (((__HANDLE__)->Instance->SR) &= ~(__INTERRUPT__)) /** @brief Clear specified FMAC interrupt status. Dummy macro as the interrupt status flags are read-only. * @param __HANDLE__ FMAC handle. * @param __INTERRUPT__ FMAC interrupt to clear. * @retval None */ #define __HAL_FMAC_CLEAR_IT(__HANDLE__, __INTERRUPT__) /* Dummy macro */ /** @brief Check whether the specified FMAC status flag is set or not. * @param __HANDLE__ FMAC handle. * @param __FLAG__ FMAC flag to check. * This parameter can be any combination of the following values: * @arg @ref FMAC_FLAG_YEMPTY Y Buffer Empty Flag * @arg @ref FMAC_FLAG_X1FULL X1 Buffer Full Flag * @arg @ref FMAC_FLAG_OVFL Overflow Error Flag * @arg @ref FMAC_FLAG_UNFL Underflow Error Flag * @arg @ref FMAC_FLAG_SAT Saturation error Flag * @retval SET (flag is set) or RESET (flag is reset) */ #define __HAL_FMAC_GET_FLAG(__HANDLE__, __FLAG__) \ ((((__HANDLE__)->Instance->SR) & (__FLAG__)) == (__FLAG__)) /** @brief Clear specified FMAC status flag. Dummy macro as no flag can be cleared. * @param __HANDLE__ FMAC handle. * @param __FLAG__ FMAC flag to clear. * @retval None */ #define __HAL_FMAC_CLEAR_FLAG(__HANDLE__, __FLAG__) /* Dummy macro */ /** @brief Check whether the specified FMAC interrupt is enabled or not. * @param __HANDLE__ FMAC handle. * @param __INTERRUPT__ FMAC interrupt to check. * This parameter can be one of the following values: * @arg @ref FMAC_IT_RIEN Read interrupt enable * @arg @ref FMAC_IT_WIEN Write interrupt enable * @arg @ref FMAC_IT_OVFLIEN Overflow error interrupt enable * @arg @ref FMAC_IT_UNFLIEN Underflow error interrupt enable * @arg @ref FMAC_IT_SATIEN Saturation error interrupt enable (this helps in debugging a filter) * @retval FlagStatus */ #define __HAL_FMAC_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) \ (((__HANDLE__)->Instance->CR) & (__INTERRUPT__)) /** * @} */ /** @addtogroup FMAC_Private_Macros * @{ */ /** * @brief Verify the FMAC function. * @param __FUNCTION__ ID of the function. * @retval SET (__FUNCTION__ is a valid value) or RESET (__FUNCTION__ is invalid) */ #define IS_FMAC_FUNCTION(__FUNCTION__) (((__FUNCTION__) == FMAC_FUNC_LOAD_X1) || \ ((__FUNCTION__) == FMAC_FUNC_LOAD_X2) || \ ((__FUNCTION__) == FMAC_FUNC_LOAD_Y) || \ ((__FUNCTION__) == FMAC_FUNC_CONVO_FIR) || \ ((__FUNCTION__) == FMAC_FUNC_IIR_DIRECT_FORM_1)) /** * @brief Verify the FMAC load function used for input data, output data or coefficients. * @param __FUNCTION__ ID of the load function. * @retval SET (__FUNCTION__ is a valid value) or RESET (__FUNCTION__ is invalid) */ #define IS_FMAC_LOAD_FUNCTION(__FUNCTION__) (((__FUNCTION__) == FMAC_FUNC_LOAD_X1) || \ ((__FUNCTION__) == FMAC_FUNC_LOAD_X2) || \ ((__FUNCTION__) == FMAC_FUNC_LOAD_Y)) /** * @brief Verify the FMAC load function used with N values as input or output data. * @param __FUNCTION__ ID of the load function. * @retval SET (__FUNCTION__ is a valid value) or RESET (__FUNCTION__ is invalid) */ #define IS_FMAC_N_LOAD_FUNCTION(__FUNCTION__) (((__FUNCTION__) == FMAC_FUNC_LOAD_X1) || \ ((__FUNCTION__) == FMAC_FUNC_LOAD_Y)) /** * @brief Verify the FMAC load function used with N + M values as coefficients. * @param __FUNCTION__ ID of the load function. * @retval SET (__FUNCTION__ is a valid value) or RESET (__FUNCTION__ is invalid) */ #define IS_FMAC_N_M_LOAD_FUNCTION(__FUNCTION__) ((__FUNCTION__) == FMAC_FUNC_LOAD_X2) /** * @brief Verify the FMAC filter function. * @param __FUNCTION__ ID of the filter function. * @retval SET (__FUNCTION__ is a valid value) or RESET (__FUNCTION__ is invalid) */ #define IS_FMAC_FILTER_FUNCTION(__FUNCTION__) (((__FUNCTION__) == FMAC_FUNC_CONVO_FIR) || \ ((__FUNCTION__) == FMAC_FUNC_IIR_DIRECT_FORM_1)) /** * @brief Verify the FMAC threshold. * @param __THRESHOLD__ Value of the threshold. * @retval SET (__THRESHOLD__ is a valid value) or RESET (__THRESHOLD__ is invalid) */ #define IS_FMAC_THRESHOLD(__THRESHOLD__) (((__THRESHOLD__) == FMAC_THRESHOLD_1) || \ ((__THRESHOLD__) == FMAC_THRESHOLD_2) || \ ((__THRESHOLD__) == FMAC_THRESHOLD_4) || \ ((__THRESHOLD__) == FMAC_THRESHOLD_NO_VALUE) || \ ((__THRESHOLD__) == FMAC_THRESHOLD_8)) /** * @brief Verify the FMAC filter parameter P. * @param __P__ Value of the filter parameter P. * @param __FUNCTION__ ID of the filter function. * @retval SET (__P__ is a valid value) or RESET (__P__ is invalid) */ #define IS_FMAC_PARAM_P(__FUNCTION__, __P__) ( (((__FUNCTION__) == FMAC_FUNC_CONVO_FIR) && \ (((__P__) >= 2U) && ((__P__) <= 127U))) || \ (((__FUNCTION__) == FMAC_FUNC_IIR_DIRECT_FORM_1) && \ (((__P__) >= 2U) && ((__P__) <= 64U))) ) /** * @brief Verify the FMAC filter parameter Q. * @param __Q__ Value of the filter parameter Q. * @param __FUNCTION__ ID of the filter function. * @retval SET (__Q__ is a valid value) or RESET (__Q__ is invalid) */ #define IS_FMAC_PARAM_Q(__FUNCTION__, __Q__) ( ((__FUNCTION__) == FMAC_FUNC_CONVO_FIR) || \ (((__FUNCTION__) == FMAC_FUNC_IIR_DIRECT_FORM_1) && \ (((__Q__) >= 1U) && ((__Q__) <= 63U))) ) /** * @brief Verify the FMAC filter parameter R. * @param __R__ Value of the filter parameter. * @param __FUNCTION__ ID of the filter function. * @retval SET (__R__ is a valid value) or RESET (__R__ is invalid) */ #define IS_FMAC_PARAM_R(__FUNCTION__, __R__) ( (((__FUNCTION__) == FMAC_FUNC_CONVO_FIR) || \ ((__FUNCTION__) == FMAC_FUNC_IIR_DIRECT_FORM_1)) && \ ((__R__) <= 7U)) /** * @brief Verify the FMAC buffer access. * @param __BUFFER_ACCESS__ Type of access. * @retval SET (__BUFFER_ACCESS__ is a valid value) or RESET (__BUFFER_ACCESS__ is invalid) */ #define IS_FMAC_BUFFER_ACCESS(__BUFFER_ACCESS__) (((__BUFFER_ACCESS__) == FMAC_BUFFER_ACCESS_NONE) || \ ((__BUFFER_ACCESS__) == FMAC_BUFFER_ACCESS_DMA) || \ ((__BUFFER_ACCESS__) == FMAC_BUFFER_ACCESS_POLLING) || \ ((__BUFFER_ACCESS__) == FMAC_BUFFER_ACCESS_IT)) /** * @brief Verify the FMAC clip feature. * @param __CLIP_STATE__ Clip state. * @retval SET (__CLIP_STATE__ is a valid value) or RESET (__CLIP_STATE__ is invalid) */ #define IS_FMAC_CLIP_STATE(__CLIP_STATE__) (((__CLIP_STATE__) == FMAC_CLIP_DISABLED) || \ ((__CLIP_STATE__) == FMAC_CLIP_ENABLED)) /** * @brief Check whether the threshold is applicable. * @param __SIZE__ Size of the matching buffer. * @param __WM__ Watermark value. * @param __ACCESS__ Access to the buffer (polling, it, dma, none). * @retval THRESHOLD */ #define IS_FMAC_THRESHOLD_APPLICABLE(__SIZE__, __WM__, __ACCESS__) (( (__SIZE__) >= (((__WM__) == FMAC_THRESHOLD_1)? 1U: \ ((__WM__) == FMAC_THRESHOLD_2)? 2U: \ ((__WM__) == FMAC_THRESHOLD_4)? 4U:8U))&& \ ((((__ACCESS__) == FMAC_BUFFER_ACCESS_DMA)&&((__WM__) == FMAC_THRESHOLD_1))|| \ ((__ACCESS__ )!= FMAC_BUFFER_ACCESS_DMA))) /** * @} */ /* Exported functions ------------------------------------------------------- */ /** @addtogroup FMAC_Exported_Functions * @{ */ /** @addtogroup FMAC_Exported_Functions_Group1 * @{ */ /* Initialization and de-initialization functions ****************************/ HAL_StatusTypeDef HAL_FMAC_Init(FMAC_HandleTypeDef *hfmac); HAL_StatusTypeDef HAL_FMAC_DeInit(FMAC_HandleTypeDef *hfmac); void HAL_FMAC_MspInit(FMAC_HandleTypeDef *hfmac); void HAL_FMAC_MspDeInit(FMAC_HandleTypeDef *hfmac); #if (USE_HAL_FMAC_REGISTER_CALLBACKS == 1) /* Callbacks Register/UnRegister functions ***********************************/ HAL_StatusTypeDef HAL_FMAC_RegisterCallback(FMAC_HandleTypeDef *hfmac, HAL_FMAC_CallbackIDTypeDef CallbackID, pFMAC_CallbackTypeDef pCallback); HAL_StatusTypeDef HAL_FMAC_UnRegisterCallback(FMAC_HandleTypeDef *hfmac, HAL_FMAC_CallbackIDTypeDef CallbackID); #endif /* USE_HAL_FMAC_REGISTER_CALLBACKS */ /** * @} */ /** @addtogroup FMAC_Exported_Functions_Group2 * @{ */ /* Peripheral Control functions ***********************************************/ HAL_StatusTypeDef HAL_FMAC_FilterConfig(FMAC_HandleTypeDef *hfmac, FMAC_FilterConfigTypeDef *pConfig); HAL_StatusTypeDef HAL_FMAC_FilterConfig_DMA(FMAC_HandleTypeDef *hfmac, FMAC_FilterConfigTypeDef *pConfig); HAL_StatusTypeDef HAL_FMAC_FilterPreload(FMAC_HandleTypeDef *hfmac, int16_t *pInput, uint8_t InputSize, int16_t *pOutput, uint8_t OutputSize); HAL_StatusTypeDef HAL_FMAC_FilterPreload_DMA(FMAC_HandleTypeDef *hfmac, int16_t *pInput, uint8_t InputSize, int16_t *pOutput, uint8_t OutputSize); HAL_StatusTypeDef HAL_FMAC_FilterStart(FMAC_HandleTypeDef *hfmac, int16_t *pOutput, uint16_t *pOutputSize); HAL_StatusTypeDef HAL_FMAC_AppendFilterData(FMAC_HandleTypeDef *hfmac, int16_t *pInput, uint16_t *pInputSize); HAL_StatusTypeDef HAL_FMAC_ConfigFilterOutputBuffer(FMAC_HandleTypeDef *hfmac, int16_t *pOutput, uint16_t *pOutputSize); HAL_StatusTypeDef HAL_FMAC_PollFilterData(FMAC_HandleTypeDef *hfmac, uint32_t Timeout); HAL_StatusTypeDef HAL_FMAC_FilterStop(FMAC_HandleTypeDef *hfmac); /** * @} */ /** @addtogroup FMAC_Exported_Functions_Group3 * @{ */ /* Callback functions *********************************************************/ void HAL_FMAC_ErrorCallback(FMAC_HandleTypeDef *hfmac); void HAL_FMAC_HalfGetDataCallback(FMAC_HandleTypeDef *hfmac); void HAL_FMAC_GetDataCallback(FMAC_HandleTypeDef *hfmac); void HAL_FMAC_HalfOutputDataReadyCallback(FMAC_HandleTypeDef *hfmac); void HAL_FMAC_OutputDataReadyCallback(FMAC_HandleTypeDef *hfmac); void HAL_FMAC_FilterConfigCallback(FMAC_HandleTypeDef *hfmac); void HAL_FMAC_FilterPreloadCallback(FMAC_HandleTypeDef *hfmac); /** * @} */ /** @addtogroup FMAC_Exported_Functions_Group4 * @{ */ /* IRQ handler management *****************************************************/ void HAL_FMAC_IRQHandler(FMAC_HandleTypeDef *hfmac); /** * @} */ /** @addtogroup FMAC_Exported_Functions_Group5 * @{ */ /* Peripheral State functions *************************************************/ HAL_FMAC_StateTypeDef HAL_FMAC_GetState(FMAC_HandleTypeDef *hfmac); uint32_t HAL_FMAC_GetError(FMAC_HandleTypeDef *hfmac); /** * @} */ /** * @} */ #ifdef __cplusplus } #endif #endif /* STM32G4xx_HAL_FMAC_H */ /** * @} */ /** * @} */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
polymurph/STM-Linux
stm32g474_blinky/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/RefLibs/src/FilteringFunctions/FilteringFunctions.c
#include "biquad.c" #include "conv.c" #include "correlate.c" #include "fir.c" #include "fir_decimate.c" #include "fir_interpolate.c" #include "fir_lattice.c" #include "fir_sparse.c" #include "iir_lattice.c" #include "lms.c"
polymurph/STM-Linux
stm32g474_blinky/Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_lpuart.h
/** ****************************************************************************** * @file stm32g4xx_ll_lpuart.h * @author MCD Application Team * @brief Header file of LPUART LL module. ****************************************************************************** * @attention * * <h2><center>&copy; Copyright (c) 2019 STMicroelectronics. * All rights reserved.</center></h2> * * This software component is licensed by ST under BSD 3-Clause license, * the "License"; You may not use this file except in compliance with the * License. You may obtain a copy of the License at: * opensource.org/licenses/BSD-3-Clause * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef STM32G4xx_LL_LPUART_H #define STM32G4xx_LL_LPUART_H #ifdef __cplusplus extern "C" { #endif /* Includes ------------------------------------------------------------------*/ #include "stm32g4xx.h" /** @addtogroup STM32G4xx_LL_Driver * @{ */ #if defined (LPUART1) /** @defgroup LPUART_LL LPUART * @{ */ /* Private types -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /** @defgroup LPUART_LL_Private_Variables LPUART Private Variables * @{ */ /* Array used to get the LPUART prescaler division decimal values versus @ref LPUART_LL_EC_PRESCALER values */ static const uint16_t LPUART_PRESCALER_TAB[] = { (uint16_t)1, (uint16_t)2, (uint16_t)4, (uint16_t)6, (uint16_t)8, (uint16_t)10, (uint16_t)12, (uint16_t)16, (uint16_t)32, (uint16_t)64, (uint16_t)128, (uint16_t)256 }; /** * @} */ /* Private constants ---------------------------------------------------------*/ /** @defgroup LPUART_LL_Private_Constants LPUART Private Constants * @{ */ /* Defines used in Baud Rate related macros and corresponding register setting computation */ #define LPUART_LPUARTDIV_FREQ_MUL 256U #define LPUART_BRR_MASK 0x000FFFFFU #define LPUART_BRR_MIN_VALUE 0x00000300U /** * @} */ /* Private macros ------------------------------------------------------------*/ #if defined(USE_FULL_LL_DRIVER) /** @defgroup LPUART_LL_Private_Macros LPUART Private Macros * @{ */ /** * @} */ #endif /*USE_FULL_LL_DRIVER*/ /* Exported types ------------------------------------------------------------*/ #if defined(USE_FULL_LL_DRIVER) /** @defgroup LPUART_LL_ES_INIT LPUART Exported Init structures * @{ */ /** * @brief LL LPUART Init Structure definition */ typedef struct { uint32_t PrescalerValue; /*!< Specifies the Prescaler to compute the communication baud rate. This parameter can be a value of @ref LPUART_LL_EC_PRESCALER. This feature can be modified afterwards using unitary function @ref LL_LPUART_SetPrescaler().*/ uint32_t BaudRate; /*!< This field defines expected LPUART communication baud rate. This feature can be modified afterwards using unitary function @ref LL_LPUART_SetBaudRate().*/ uint32_t DataWidth; /*!< Specifies the number of data bits transmitted or received in a frame. This parameter can be a value of @ref LPUART_LL_EC_DATAWIDTH. This feature can be modified afterwards using unitary function @ref LL_LPUART_SetDataWidth().*/ uint32_t StopBits; /*!< Specifies the number of stop bits transmitted. This parameter can be a value of @ref LPUART_LL_EC_STOPBITS. This feature can be modified afterwards using unitary function @ref LL_LPUART_SetStopBitsLength().*/ uint32_t Parity; /*!< Specifies the parity mode. This parameter can be a value of @ref LPUART_LL_EC_PARITY. This feature can be modified afterwards using unitary function @ref LL_LPUART_SetParity().*/ uint32_t TransferDirection; /*!< Specifies whether the Receive and/or Transmit mode is enabled or disabled. This parameter can be a value of @ref LPUART_LL_EC_DIRECTION. This feature can be modified afterwards using unitary function @ref LL_LPUART_SetTransferDirection().*/ uint32_t HardwareFlowControl; /*!< Specifies whether the hardware flow control mode is enabled or disabled. This parameter can be a value of @ref LPUART_LL_EC_HWCONTROL. This feature can be modified afterwards using unitary function @ref LL_LPUART_SetHWFlowCtrl().*/ } LL_LPUART_InitTypeDef; /** * @} */ #endif /* USE_FULL_LL_DRIVER */ /* Exported constants --------------------------------------------------------*/ /** @defgroup LPUART_LL_Exported_Constants LPUART Exported Constants * @{ */ /** @defgroup LPUART_LL_EC_CLEAR_FLAG Clear Flags Defines * @brief Flags defines which can be used with LL_LPUART_WriteReg function * @{ */ #define LL_LPUART_ICR_PECF USART_ICR_PECF /*!< Parity error flag */ #define LL_LPUART_ICR_FECF USART_ICR_FECF /*!< Framing error flag */ #define LL_LPUART_ICR_NCF USART_ICR_NECF /*!< Noise error detected flag */ #define LL_LPUART_ICR_ORECF USART_ICR_ORECF /*!< Overrun error flag */ #define LL_LPUART_ICR_IDLECF USART_ICR_IDLECF /*!< Idle line detected flag */ #define LL_LPUART_ICR_TXFECF USART_ICR_TXFECF /*!< TX FIFO Empty Clear flag */ #define LL_LPUART_ICR_TCCF USART_ICR_TCCF /*!< Transmission complete flag */ #define LL_LPUART_ICR_CTSCF USART_ICR_CTSCF /*!< CTS flag */ #define LL_LPUART_ICR_CMCF USART_ICR_CMCF /*!< Character match flag */ #define LL_LPUART_ICR_WUCF USART_ICR_WUCF /*!< Wakeup from Stop mode flag */ /** * @} */ /** @defgroup LPUART_LL_EC_GET_FLAG Get Flags Defines * @brief Flags defines which can be used with LL_LPUART_ReadReg function * @{ */ #define LL_LPUART_ISR_PE USART_ISR_PE /*!< Parity error flag */ #define LL_LPUART_ISR_FE USART_ISR_FE /*!< Framing error flag */ #define LL_LPUART_ISR_NE USART_ISR_NE /*!< Noise detected flag */ #define LL_LPUART_ISR_ORE USART_ISR_ORE /*!< Overrun error flag */ #define LL_LPUART_ISR_IDLE USART_ISR_IDLE /*!< Idle line detected flag */ #define LL_LPUART_ISR_RXNE_RXFNE USART_ISR_RXNE_RXFNE /*!< Read data register or RX FIFO not empty flag */ #define LL_LPUART_ISR_TC USART_ISR_TC /*!< Transmission complete flag */ #define LL_LPUART_ISR_TXE_TXFNF USART_ISR_TXE_TXFNF /*!< Transmit data register empty or TX FIFO Not Full flag*/ #define LL_LPUART_ISR_CTSIF USART_ISR_CTSIF /*!< CTS interrupt flag */ #define LL_LPUART_ISR_CTS USART_ISR_CTS /*!< CTS flag */ #define LL_LPUART_ISR_BUSY USART_ISR_BUSY /*!< Busy flag */ #define LL_LPUART_ISR_CMF USART_ISR_CMF /*!< Character match flag */ #define LL_LPUART_ISR_SBKF USART_ISR_SBKF /*!< Send break flag */ #define LL_LPUART_ISR_RWU USART_ISR_RWU /*!< Receiver wakeup from Mute mode flag */ #define LL_LPUART_ISR_WUF USART_ISR_WUF /*!< Wakeup from Stop mode flag */ #define LL_LPUART_ISR_TEACK USART_ISR_TEACK /*!< Transmit enable acknowledge flag */ #define LL_LPUART_ISR_REACK USART_ISR_REACK /*!< Receive enable acknowledge flag */ #define LL_LPUART_ISR_TXFE USART_ISR_TXFE /*!< TX FIFO empty flag */ #define LL_LPUART_ISR_RXFF USART_ISR_RXFF /*!< RX FIFO full flag */ #define LL_LPUART_ISR_RXFT USART_ISR_RXFT /*!< RX FIFO threshold flag */ #define LL_LPUART_ISR_TXFT USART_ISR_TXFT /*!< TX FIFO threshold flag */ /** * @} */ /** @defgroup LPUART_LL_EC_IT IT Defines * @brief IT defines which can be used with LL_LPUART_ReadReg and LL_LPUART_WriteReg functions * @{ */ #define LL_LPUART_CR1_IDLEIE USART_CR1_IDLEIE /*!< IDLE interrupt enable */ #define LL_LPUART_CR1_RXNEIE_RXFNEIE USART_CR1_RXNEIE_RXFNEIE /*!< Read data register and RXFIFO not empty interrupt enable */ #define LL_LPUART_CR1_TCIE USART_CR1_TCIE /*!< Transmission complete interrupt enable */ #define LL_LPUART_CR1_TXEIE_TXFNFIE USART_CR1_TXEIE_TXFNFIE /*!< Transmit data register empty and TX FIFO not full interrupt enable */ #define LL_LPUART_CR1_PEIE USART_CR1_PEIE /*!< Parity error */ #define LL_LPUART_CR1_CMIE USART_CR1_CMIE /*!< Character match interrupt enable */ #define LL_LPUART_CR1_TXFEIE USART_CR1_TXFEIE /*!< TX FIFO empty interrupt enable */ #define LL_LPUART_CR1_RXFFIE USART_CR1_RXFFIE /*!< RX FIFO full interrupt enable */ #define LL_LPUART_CR3_EIE USART_CR3_EIE /*!< Error interrupt enable */ #define LL_LPUART_CR3_CTSIE USART_CR3_CTSIE /*!< CTS interrupt enable */ #define LL_LPUART_CR3_WUFIE USART_CR3_WUFIE /*!< Wakeup from Stop mode interrupt enable */ #define LL_LPUART_CR3_TXFTIE USART_CR3_TXFTIE /*!< TX FIFO threshold interrupt enable */ #define LL_LPUART_CR3_RXFTIE USART_CR3_RXFTIE /*!< RX FIFO threshold interrupt enable */ /** * @} */ /** @defgroup LPUART_LL_EC_FIFOTHRESHOLD FIFO Threshold * @{ */ #define LL_LPUART_FIFOTHRESHOLD_1_8 0x00000000U /*!< FIFO reaches 1/8 of its depth */ #define LL_LPUART_FIFOTHRESHOLD_1_4 0x00000001U /*!< FIFO reaches 1/4 of its depth */ #define LL_LPUART_FIFOTHRESHOLD_1_2 0x00000002U /*!< FIFO reaches 1/2 of its depth */ #define LL_LPUART_FIFOTHRESHOLD_3_4 0x00000003U /*!< FIFO reaches 3/4 of its depth */ #define LL_LPUART_FIFOTHRESHOLD_7_8 0x00000004U /*!< FIFO reaches 7/8 of its depth */ #define LL_LPUART_FIFOTHRESHOLD_8_8 0x00000005U /*!< FIFO becomes empty for TX and full for RX */ /** * @} */ /** @defgroup LPUART_LL_EC_DIRECTION Direction * @{ */ #define LL_LPUART_DIRECTION_NONE 0x00000000U /*!< Transmitter and Receiver are disabled */ #define LL_LPUART_DIRECTION_RX USART_CR1_RE /*!< Transmitter is disabled and Receiver is enabled */ #define LL_LPUART_DIRECTION_TX USART_CR1_TE /*!< Transmitter is enabled and Receiver is disabled */ #define LL_LPUART_DIRECTION_TX_RX (USART_CR1_TE |USART_CR1_RE) /*!< Transmitter and Receiver are enabled */ /** * @} */ /** @defgroup LPUART_LL_EC_PARITY Parity Control * @{ */ #define LL_LPUART_PARITY_NONE 0x00000000U /*!< Parity control disabled */ #define LL_LPUART_PARITY_EVEN USART_CR1_PCE /*!< Parity control enabled and Even Parity is selected */ #define LL_LPUART_PARITY_ODD (USART_CR1_PCE | USART_CR1_PS) /*!< Parity control enabled and Odd Parity is selected */ /** * @} */ /** @defgroup LPUART_LL_EC_WAKEUP Wakeup * @{ */ #define LL_LPUART_WAKEUP_IDLELINE 0x00000000U /*!< LPUART wake up from Mute mode on Idle Line */ #define LL_LPUART_WAKEUP_ADDRESSMARK USART_CR1_WAKE /*!< LPUART wake up from Mute mode on Address Mark */ /** * @} */ /** @defgroup LPUART_LL_EC_DATAWIDTH Datawidth * @{ */ #define LL_LPUART_DATAWIDTH_7B USART_CR1_M1 /*!< 7 bits word length : Start bit, 7 data bits, n stop bits */ #define LL_LPUART_DATAWIDTH_8B 0x00000000U /*!< 8 bits word length : Start bit, 8 data bits, n stop bits */ #define LL_LPUART_DATAWIDTH_9B USART_CR1_M0 /*!< 9 bits word length : Start bit, 9 data bits, n stop bits */ /** * @} */ /** @defgroup LPUART_LL_EC_PRESCALER Clock Source Prescaler * @{ */ #define LL_LPUART_PRESCALER_DIV1 0x00000000U /*!< Input clock not divided */ #define LL_LPUART_PRESCALER_DIV2 (USART_PRESC_PRESCALER_0) /*!< Input clock divided by 2 */ #define LL_LPUART_PRESCALER_DIV4 (USART_PRESC_PRESCALER_1) /*!< Input clock divided by 4 */ #define LL_LPUART_PRESCALER_DIV6 (USART_PRESC_PRESCALER_1 | USART_PRESC_PRESCALER_0) /*!< Input clock divided by 6 */ #define LL_LPUART_PRESCALER_DIV8 (USART_PRESC_PRESCALER_2) /*!< Input clock divided by 8 */ #define LL_LPUART_PRESCALER_DIV10 (USART_PRESC_PRESCALER_2 | USART_PRESC_PRESCALER_0) /*!< Input clock divided by 10 */ #define LL_LPUART_PRESCALER_DIV12 (USART_PRESC_PRESCALER_2 | USART_PRESC_PRESCALER_1) /*!< Input clock divided by 12 */ #define LL_LPUART_PRESCALER_DIV16 (USART_PRESC_PRESCALER_2 | USART_PRESC_PRESCALER_1 | USART_PRESC_PRESCALER_0) /*!< Input clock divided by 16 */ #define LL_LPUART_PRESCALER_DIV32 (USART_PRESC_PRESCALER_3) /*!< Input clock divided by 32 */ #define LL_LPUART_PRESCALER_DIV64 (USART_PRESC_PRESCALER_3 | USART_PRESC_PRESCALER_0) /*!< Input clock divided by 64 */ #define LL_LPUART_PRESCALER_DIV128 (USART_PRESC_PRESCALER_3 | USART_PRESC_PRESCALER_1) /*!< Input clock divided by 128 */ #define LL_LPUART_PRESCALER_DIV256 (USART_PRESC_PRESCALER_3 | USART_PRESC_PRESCALER_1 | USART_PRESC_PRESCALER_0) /*!< Input clock divided by 256 */ /** * @} */ /** @defgroup LPUART_LL_EC_STOPBITS Stop Bits * @{ */ #define LL_LPUART_STOPBITS_1 0x00000000U /*!< 1 stop bit */ #define LL_LPUART_STOPBITS_2 USART_CR2_STOP_1 /*!< 2 stop bits */ /** * @} */ /** @defgroup LPUART_LL_EC_TXRX TX RX Pins Swap * @{ */ #define LL_LPUART_TXRX_STANDARD 0x00000000U /*!< TX/RX pins are used as defined in standard pinout */ #define LL_LPUART_TXRX_SWAPPED (USART_CR2_SWAP) /*!< TX and RX pins functions are swapped. */ /** * @} */ /** @defgroup LPUART_LL_EC_RXPIN_LEVEL RX Pin Active Level Inversion * @{ */ #define LL_LPUART_RXPIN_LEVEL_STANDARD 0x00000000U /*!< RX pin signal works using the standard logic levels */ #define LL_LPUART_RXPIN_LEVEL_INVERTED (USART_CR2_RXINV) /*!< RX pin signal values are inverted. */ /** * @} */ /** @defgroup LPUART_LL_EC_TXPIN_LEVEL TX Pin Active Level Inversion * @{ */ #define LL_LPUART_TXPIN_LEVEL_STANDARD 0x00000000U /*!< TX pin signal works using the standard logic levels */ #define LL_LPUART_TXPIN_LEVEL_INVERTED (USART_CR2_TXINV) /*!< TX pin signal values are inverted. */ /** * @} */ /** @defgroup LPUART_LL_EC_BINARY_LOGIC Binary Data Inversion * @{ */ #define LL_LPUART_BINARY_LOGIC_POSITIVE 0x00000000U /*!< Logical data from the data register are send/received in positive/direct logic. (1=H, 0=L) */ #define LL_LPUART_BINARY_LOGIC_NEGATIVE USART_CR2_DATAINV /*!< Logical data from the data register are send/received in negative/inverse logic. (1=L, 0=H). The parity bit is also inverted. */ /** * @} */ /** @defgroup LPUART_LL_EC_BITORDER Bit Order * @{ */ #define LL_LPUART_BITORDER_LSBFIRST 0x00000000U /*!< data is transmitted/received with data bit 0 first, following the start bit */ #define LL_LPUART_BITORDER_MSBFIRST USART_CR2_MSBFIRST /*!< data is transmitted/received with the MSB first, following the start bit */ /** * @} */ /** @defgroup LPUART_LL_EC_ADDRESS_DETECT Address Length Detection * @{ */ #define LL_LPUART_ADDRESS_DETECT_4B 0x00000000U /*!< 4-bit address detection method selected */ #define LL_LPUART_ADDRESS_DETECT_7B USART_CR2_ADDM7 /*!< 7-bit address detection (in 8-bit data mode) method selected */ /** * @} */ /** @defgroup LPUART_LL_EC_HWCONTROL Hardware Control * @{ */ #define LL_LPUART_HWCONTROL_NONE 0x00000000U /*!< CTS and RTS hardware flow control disabled */ #define LL_LPUART_HWCONTROL_RTS USART_CR3_RTSE /*!< RTS output enabled, data is only requested when there is space in the receive buffer */ #define LL_LPUART_HWCONTROL_CTS USART_CR3_CTSE /*!< CTS mode enabled, data is only transmitted when the nCTS input is asserted (tied to 0) */ #define LL_LPUART_HWCONTROL_RTS_CTS (USART_CR3_RTSE | USART_CR3_CTSE) /*!< CTS and RTS hardware flow control enabled */ /** * @} */ /** @defgroup LPUART_LL_EC_WAKEUP_ON Wakeup Activation * @{ */ #define LL_LPUART_WAKEUP_ON_ADDRESS 0x00000000U /*!< Wake up active on address match */ #define LL_LPUART_WAKEUP_ON_STARTBIT USART_CR3_WUS_1 /*!< Wake up active on Start bit detection */ #define LL_LPUART_WAKEUP_ON_RXNE (USART_CR3_WUS_0 | USART_CR3_WUS_1) /*!< Wake up active on RXNE */ /** * @} */ /** @defgroup LPUART_LL_EC_DE_POLARITY Driver Enable Polarity * @{ */ #define LL_LPUART_DE_POLARITY_HIGH 0x00000000U /*!< DE signal is active high */ #define LL_LPUART_DE_POLARITY_LOW USART_CR3_DEP /*!< DE signal is active low */ /** * @} */ /** @defgroup LPUART_LL_EC_DMA_REG_DATA DMA Register Data * @{ */ #define LL_LPUART_DMA_REG_DATA_TRANSMIT 0x00000000U /*!< Get address of data register used for transmission */ #define LL_LPUART_DMA_REG_DATA_RECEIVE 0x00000001U /*!< Get address of data register used for reception */ /** * @} */ /** * @} */ /* Exported macro ------------------------------------------------------------*/ /** @defgroup LPUART_LL_Exported_Macros LPUART Exported Macros * @{ */ /** @defgroup LPUART_LL_EM_WRITE_READ Common Write and read registers Macros * @{ */ /** * @brief Write a value in LPUART register * @param __INSTANCE__ LPUART Instance * @param __REG__ Register to be written * @param __VALUE__ Value to be written in the register * @retval None */ #define LL_LPUART_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__)) /** * @brief Read a value in LPUART register * @param __INSTANCE__ LPUART Instance * @param __REG__ Register to be read * @retval Register value */ #define LL_LPUART_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__) /** * @} */ /** @defgroup LPUART_LL_EM_Exported_Macros_Helper Helper Macros * @{ */ /** * @brief Compute LPUARTDIV value according to Peripheral Clock and * expected Baud Rate (20-bit value of LPUARTDIV is returned) * @param __PERIPHCLK__ Peripheral Clock frequency used for LPUART Instance * @param __PRESCALER__ This parameter can be one of the following values: * @arg @ref LL_LPUART_PRESCALER_DIV1 * @arg @ref LL_LPUART_PRESCALER_DIV2 * @arg @ref LL_LPUART_PRESCALER_DIV4 * @arg @ref LL_LPUART_PRESCALER_DIV6 * @arg @ref LL_LPUART_PRESCALER_DIV8 * @arg @ref LL_LPUART_PRESCALER_DIV10 * @arg @ref LL_LPUART_PRESCALER_DIV12 * @arg @ref LL_LPUART_PRESCALER_DIV16 * @arg @ref LL_LPUART_PRESCALER_DIV32 * @arg @ref LL_LPUART_PRESCALER_DIV64 * @arg @ref LL_LPUART_PRESCALER_DIV128 * @arg @ref LL_LPUART_PRESCALER_DIV256 * @param __BAUDRATE__ Baud Rate value to achieve * @retval LPUARTDIV value to be used for BRR register filling */ #define __LL_LPUART_DIV(__PERIPHCLK__, __PRESCALER__, __BAUDRATE__) (uint32_t)\ ((((((uint64_t)(__PERIPHCLK__)/(uint64_t)(LPUART_PRESCALER_TAB[(uint16_t)(__PRESCALER__)]))\ * LPUART_LPUARTDIV_FREQ_MUL) + (uint32_t)((__BAUDRATE__)/2U))/(__BAUDRATE__)) & LPUART_BRR_MASK) /** * @} */ /** * @} */ /* Exported functions --------------------------------------------------------*/ /** @defgroup LPUART_LL_Exported_Functions LPUART Exported Functions * @{ */ /** @defgroup LPUART_LL_EF_Configuration Configuration functions * @{ */ /** * @brief LPUART Enable * @rmtoll CR1 UE LL_LPUART_Enable * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_Enable(USART_TypeDef *LPUARTx) { SET_BIT(LPUARTx->CR1, USART_CR1_UE); } /** * @brief LPUART Disable * @note When LPUART is disabled, LPUART prescalers and outputs are stopped immediately, * and current operations are discarded. The configuration of the LPUART is kept, but all the status * flags, in the LPUARTx_ISR are set to their default values. * @note In order to go into low-power mode without generating errors on the line, * the TE bit must be reset before and the software must wait * for the TC bit in the LPUART_ISR to be set before resetting the UE bit. * The DMA requests are also reset when UE = 0 so the DMA channel must * be disabled before resetting the UE bit. * @rmtoll CR1 UE LL_LPUART_Disable * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_Disable(USART_TypeDef *LPUARTx) { CLEAR_BIT(LPUARTx->CR1, USART_CR1_UE); } /** * @brief Indicate if LPUART is enabled * @rmtoll CR1 UE LL_LPUART_IsEnabled * @param LPUARTx LPUART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_LPUART_IsEnabled(USART_TypeDef *LPUARTx) { return ((READ_BIT(LPUARTx->CR1, USART_CR1_UE) == (USART_CR1_UE)) ? 1UL : 0UL); } /** * @brief FIFO Mode Enable * @rmtoll CR1 FIFOEN LL_LPUART_EnableFIFO * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_EnableFIFO(USART_TypeDef *LPUARTx) { SET_BIT(LPUARTx->CR1, USART_CR1_FIFOEN); } /** * @brief FIFO Mode Disable * @rmtoll CR1 FIFOEN LL_LPUART_DisableFIFO * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_DisableFIFO(USART_TypeDef *LPUARTx) { CLEAR_BIT(LPUARTx->CR1, USART_CR1_FIFOEN); } /** * @brief Indicate if FIFO Mode is enabled * @rmtoll CR1 FIFOEN LL_LPUART_IsEnabledFIFO * @param LPUARTx LPUART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_LPUART_IsEnabledFIFO(USART_TypeDef *LPUARTx) { return ((READ_BIT(LPUARTx->CR1, USART_CR1_FIFOEN) == (USART_CR1_FIFOEN)) ? 1UL : 0UL); } /** * @brief Configure TX FIFO Threshold * @rmtoll CR3 TXFTCFG LL_LPUART_SetTXFIFOThreshold * @param LPUARTx LPUART Instance * @param Threshold This parameter can be one of the following values: * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_8 * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_4 * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_2 * @arg @ref LL_LPUART_FIFOTHRESHOLD_3_4 * @arg @ref LL_LPUART_FIFOTHRESHOLD_7_8 * @arg @ref LL_LPUART_FIFOTHRESHOLD_8_8 * @retval None */ __STATIC_INLINE void LL_LPUART_SetTXFIFOThreshold(USART_TypeDef *LPUARTx, uint32_t Threshold) { MODIFY_REG(LPUARTx->CR3, USART_CR3_TXFTCFG, Threshold << USART_CR3_TXFTCFG_Pos); } /** * @brief Return TX FIFO Threshold Configuration * @rmtoll CR3 TXFTCFG LL_LPUART_GetTXFIFOThreshold * @param LPUARTx LPUART Instance * @retval Returned value can be one of the following values: * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_8 * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_4 * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_2 * @arg @ref LL_LPUART_FIFOTHRESHOLD_3_4 * @arg @ref LL_LPUART_FIFOTHRESHOLD_7_8 * @arg @ref LL_LPUART_FIFOTHRESHOLD_8_8 */ __STATIC_INLINE uint32_t LL_LPUART_GetTXFIFOThreshold(USART_TypeDef *LPUARTx) { return (uint32_t)(READ_BIT(LPUARTx->CR3, USART_CR3_TXFTCFG) >> USART_CR3_TXFTCFG_Pos); } /** * @brief Configure RX FIFO Threshold * @rmtoll CR3 RXFTCFG LL_LPUART_SetRXFIFOThreshold * @param LPUARTx LPUART Instance * @param Threshold This parameter can be one of the following values: * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_8 * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_4 * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_2 * @arg @ref LL_LPUART_FIFOTHRESHOLD_3_4 * @arg @ref LL_LPUART_FIFOTHRESHOLD_7_8 * @arg @ref LL_LPUART_FIFOTHRESHOLD_8_8 * @retval None */ __STATIC_INLINE void LL_LPUART_SetRXFIFOThreshold(USART_TypeDef *LPUARTx, uint32_t Threshold) { MODIFY_REG(LPUARTx->CR3, USART_CR3_RXFTCFG, Threshold << USART_CR3_RXFTCFG_Pos); } /** * @brief Return RX FIFO Threshold Configuration * @rmtoll CR3 RXFTCFG LL_LPUART_GetRXFIFOThreshold * @param LPUARTx LPUART Instance * @retval Returned value can be one of the following values: * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_8 * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_4 * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_2 * @arg @ref LL_LPUART_FIFOTHRESHOLD_3_4 * @arg @ref LL_LPUART_FIFOTHRESHOLD_7_8 * @arg @ref LL_LPUART_FIFOTHRESHOLD_8_8 */ __STATIC_INLINE uint32_t LL_LPUART_GetRXFIFOThreshold(USART_TypeDef *LPUARTx) { return (uint32_t)(READ_BIT(LPUARTx->CR3, USART_CR3_RXFTCFG) >> USART_CR3_RXFTCFG_Pos); } /** * @brief Configure TX and RX FIFOs Threshold * @rmtoll CR3 TXFTCFG LL_LPUART_ConfigFIFOsThreshold\n * CR3 RXFTCFG LL_LPUART_ConfigFIFOsThreshold * @param LPUARTx LPUART Instance * @param TXThreshold This parameter can be one of the following values: * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_8 * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_4 * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_2 * @arg @ref LL_LPUART_FIFOTHRESHOLD_3_4 * @arg @ref LL_LPUART_FIFOTHRESHOLD_7_8 * @arg @ref LL_LPUART_FIFOTHRESHOLD_8_8 * @param RXThreshold This parameter can be one of the following values: * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_8 * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_4 * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_2 * @arg @ref LL_LPUART_FIFOTHRESHOLD_3_4 * @arg @ref LL_LPUART_FIFOTHRESHOLD_7_8 * @arg @ref LL_LPUART_FIFOTHRESHOLD_8_8 * @retval None */ __STATIC_INLINE void LL_LPUART_ConfigFIFOsThreshold(USART_TypeDef *LPUARTx, uint32_t TXThreshold, uint32_t RXThreshold) { MODIFY_REG(LPUARTx->CR3, USART_CR3_TXFTCFG | USART_CR3_RXFTCFG, (TXThreshold << USART_CR3_TXFTCFG_Pos) | \ (RXThreshold << USART_CR3_RXFTCFG_Pos)); } /** * @brief LPUART enabled in STOP Mode * @note When this function is enabled, LPUART is able to wake up the MCU from Stop mode, provided that * LPUART clock selection is HSI or LSE in RCC. * @rmtoll CR1 UESM LL_LPUART_EnableInStopMode * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_EnableInStopMode(USART_TypeDef *LPUARTx) { SET_BIT(LPUARTx->CR1, USART_CR1_UESM); } /** * @brief LPUART disabled in STOP Mode * @note When this function is disabled, LPUART is not able to wake up the MCU from Stop mode * @rmtoll CR1 UESM LL_LPUART_DisableInStopMode * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_DisableInStopMode(USART_TypeDef *LPUARTx) { CLEAR_BIT(LPUARTx->CR1, USART_CR1_UESM); } /** * @brief Indicate if LPUART is enabled in STOP Mode * (able to wake up MCU from Stop mode or not) * @rmtoll CR1 UESM LL_LPUART_IsEnabledInStopMode * @param LPUARTx LPUART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_LPUART_IsEnabledInStopMode(USART_TypeDef *LPUARTx) { return ((READ_BIT(LPUARTx->CR1, USART_CR1_UESM) == (USART_CR1_UESM)) ? 1UL : 0UL); } /** * @brief Receiver Enable (Receiver is enabled and begins searching for a start bit) * @rmtoll CR1 RE LL_LPUART_EnableDirectionRx * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_EnableDirectionRx(USART_TypeDef *LPUARTx) { SET_BIT(LPUARTx->CR1, USART_CR1_RE); } /** * @brief Receiver Disable * @rmtoll CR1 RE LL_LPUART_DisableDirectionRx * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_DisableDirectionRx(USART_TypeDef *LPUARTx) { CLEAR_BIT(LPUARTx->CR1, USART_CR1_RE); } /** * @brief Transmitter Enable * @rmtoll CR1 TE LL_LPUART_EnableDirectionTx * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_EnableDirectionTx(USART_TypeDef *LPUARTx) { SET_BIT(LPUARTx->CR1, USART_CR1_TE); } /** * @brief Transmitter Disable * @rmtoll CR1 TE LL_LPUART_DisableDirectionTx * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_DisableDirectionTx(USART_TypeDef *LPUARTx) { CLEAR_BIT(LPUARTx->CR1, USART_CR1_TE); } /** * @brief Configure simultaneously enabled/disabled states * of Transmitter and Receiver * @rmtoll CR1 RE LL_LPUART_SetTransferDirection\n * CR1 TE LL_LPUART_SetTransferDirection * @param LPUARTx LPUART Instance * @param TransferDirection This parameter can be one of the following values: * @arg @ref LL_LPUART_DIRECTION_NONE * @arg @ref LL_LPUART_DIRECTION_RX * @arg @ref LL_LPUART_DIRECTION_TX * @arg @ref LL_LPUART_DIRECTION_TX_RX * @retval None */ __STATIC_INLINE void LL_LPUART_SetTransferDirection(USART_TypeDef *LPUARTx, uint32_t TransferDirection) { MODIFY_REG(LPUARTx->CR1, USART_CR1_RE | USART_CR1_TE, TransferDirection); } /** * @brief Return enabled/disabled states of Transmitter and Receiver * @rmtoll CR1 RE LL_LPUART_GetTransferDirection\n * CR1 TE LL_LPUART_GetTransferDirection * @param LPUARTx LPUART Instance * @retval Returned value can be one of the following values: * @arg @ref LL_LPUART_DIRECTION_NONE * @arg @ref LL_LPUART_DIRECTION_RX * @arg @ref LL_LPUART_DIRECTION_TX * @arg @ref LL_LPUART_DIRECTION_TX_RX */ __STATIC_INLINE uint32_t LL_LPUART_GetTransferDirection(USART_TypeDef *LPUARTx) { return (uint32_t)(READ_BIT(LPUARTx->CR1, USART_CR1_RE | USART_CR1_TE)); } /** * @brief Configure Parity (enabled/disabled and parity mode if enabled) * @note This function selects if hardware parity control (generation and detection) is enabled or disabled. * When the parity control is enabled (Odd or Even), computed parity bit is inserted at the MSB position * (depending on data width) and parity is checked on the received data. * @rmtoll CR1 PS LL_LPUART_SetParity\n * CR1 PCE LL_LPUART_SetParity * @param LPUARTx LPUART Instance * @param Parity This parameter can be one of the following values: * @arg @ref LL_LPUART_PARITY_NONE * @arg @ref LL_LPUART_PARITY_EVEN * @arg @ref LL_LPUART_PARITY_ODD * @retval None */ __STATIC_INLINE void LL_LPUART_SetParity(USART_TypeDef *LPUARTx, uint32_t Parity) { MODIFY_REG(LPUARTx->CR1, USART_CR1_PS | USART_CR1_PCE, Parity); } /** * @brief Return Parity configuration (enabled/disabled and parity mode if enabled) * @rmtoll CR1 PS LL_LPUART_GetParity\n * CR1 PCE LL_LPUART_GetParity * @param LPUARTx LPUART Instance * @retval Returned value can be one of the following values: * @arg @ref LL_LPUART_PARITY_NONE * @arg @ref LL_LPUART_PARITY_EVEN * @arg @ref LL_LPUART_PARITY_ODD */ __STATIC_INLINE uint32_t LL_LPUART_GetParity(USART_TypeDef *LPUARTx) { return (uint32_t)(READ_BIT(LPUARTx->CR1, USART_CR1_PS | USART_CR1_PCE)); } /** * @brief Set Receiver Wake Up method from Mute mode. * @rmtoll CR1 WAKE LL_LPUART_SetWakeUpMethod * @param LPUARTx LPUART Instance * @param Method This parameter can be one of the following values: * @arg @ref LL_LPUART_WAKEUP_IDLELINE * @arg @ref LL_LPUART_WAKEUP_ADDRESSMARK * @retval None */ __STATIC_INLINE void LL_LPUART_SetWakeUpMethod(USART_TypeDef *LPUARTx, uint32_t Method) { MODIFY_REG(LPUARTx->CR1, USART_CR1_WAKE, Method); } /** * @brief Return Receiver Wake Up method from Mute mode * @rmtoll CR1 WAKE LL_LPUART_GetWakeUpMethod * @param LPUARTx LPUART Instance * @retval Returned value can be one of the following values: * @arg @ref LL_LPUART_WAKEUP_IDLELINE * @arg @ref LL_LPUART_WAKEUP_ADDRESSMARK */ __STATIC_INLINE uint32_t LL_LPUART_GetWakeUpMethod(USART_TypeDef *LPUARTx) { return (uint32_t)(READ_BIT(LPUARTx->CR1, USART_CR1_WAKE)); } /** * @brief Set Word length (nb of data bits, excluding start and stop bits) * @rmtoll CR1 M LL_LPUART_SetDataWidth * @param LPUARTx LPUART Instance * @param DataWidth This parameter can be one of the following values: * @arg @ref LL_LPUART_DATAWIDTH_7B * @arg @ref LL_LPUART_DATAWIDTH_8B * @arg @ref LL_LPUART_DATAWIDTH_9B * @retval None */ __STATIC_INLINE void LL_LPUART_SetDataWidth(USART_TypeDef *LPUARTx, uint32_t DataWidth) { MODIFY_REG(LPUARTx->CR1, USART_CR1_M, DataWidth); } /** * @brief Return Word length (i.e. nb of data bits, excluding start and stop bits) * @rmtoll CR1 M LL_LPUART_GetDataWidth * @param LPUARTx LPUART Instance * @retval Returned value can be one of the following values: * @arg @ref LL_LPUART_DATAWIDTH_7B * @arg @ref LL_LPUART_DATAWIDTH_8B * @arg @ref LL_LPUART_DATAWIDTH_9B */ __STATIC_INLINE uint32_t LL_LPUART_GetDataWidth(USART_TypeDef *LPUARTx) { return (uint32_t)(READ_BIT(LPUARTx->CR1, USART_CR1_M)); } /** * @brief Allow switch between Mute Mode and Active mode * @rmtoll CR1 MME LL_LPUART_EnableMuteMode * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_EnableMuteMode(USART_TypeDef *LPUARTx) { SET_BIT(LPUARTx->CR1, USART_CR1_MME); } /** * @brief Prevent Mute Mode use. Set Receiver in active mode permanently. * @rmtoll CR1 MME LL_LPUART_DisableMuteMode * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_DisableMuteMode(USART_TypeDef *LPUARTx) { CLEAR_BIT(LPUARTx->CR1, USART_CR1_MME); } /** * @brief Indicate if switch between Mute Mode and Active mode is allowed * @rmtoll CR1 MME LL_LPUART_IsEnabledMuteMode * @param LPUARTx LPUART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_LPUART_IsEnabledMuteMode(USART_TypeDef *LPUARTx) { return ((READ_BIT(LPUARTx->CR1, USART_CR1_MME) == (USART_CR1_MME)) ? 1UL : 0UL); } /** * @brief Configure Clock source prescaler for baudrate generator and oversampling * @rmtoll PRESC PRESCALER LL_LPUART_SetPrescaler * @param LPUARTx LPUART Instance * @param PrescalerValue This parameter can be one of the following values: * @arg @ref LL_LPUART_PRESCALER_DIV1 * @arg @ref LL_LPUART_PRESCALER_DIV2 * @arg @ref LL_LPUART_PRESCALER_DIV4 * @arg @ref LL_LPUART_PRESCALER_DIV6 * @arg @ref LL_LPUART_PRESCALER_DIV8 * @arg @ref LL_LPUART_PRESCALER_DIV10 * @arg @ref LL_LPUART_PRESCALER_DIV12 * @arg @ref LL_LPUART_PRESCALER_DIV16 * @arg @ref LL_LPUART_PRESCALER_DIV32 * @arg @ref LL_LPUART_PRESCALER_DIV64 * @arg @ref LL_LPUART_PRESCALER_DIV128 * @arg @ref LL_LPUART_PRESCALER_DIV256 * @retval None */ __STATIC_INLINE void LL_LPUART_SetPrescaler(USART_TypeDef *LPUARTx, uint32_t PrescalerValue) { MODIFY_REG(LPUARTx->PRESC, USART_PRESC_PRESCALER, (uint16_t)PrescalerValue); } /** * @brief Retrieve the Clock source prescaler for baudrate generator and oversampling * @rmtoll PRESC PRESCALER LL_LPUART_GetPrescaler * @param LPUARTx LPUART Instance * @retval Returned value can be one of the following values: * @arg @ref LL_LPUART_PRESCALER_DIV1 * @arg @ref LL_LPUART_PRESCALER_DIV2 * @arg @ref LL_LPUART_PRESCALER_DIV4 * @arg @ref LL_LPUART_PRESCALER_DIV6 * @arg @ref LL_LPUART_PRESCALER_DIV8 * @arg @ref LL_LPUART_PRESCALER_DIV10 * @arg @ref LL_LPUART_PRESCALER_DIV12 * @arg @ref LL_LPUART_PRESCALER_DIV16 * @arg @ref LL_LPUART_PRESCALER_DIV32 * @arg @ref LL_LPUART_PRESCALER_DIV64 * @arg @ref LL_LPUART_PRESCALER_DIV128 * @arg @ref LL_LPUART_PRESCALER_DIV256 */ __STATIC_INLINE uint32_t LL_LPUART_GetPrescaler(USART_TypeDef *LPUARTx) { return (uint32_t)(READ_BIT(LPUARTx->PRESC, USART_PRESC_PRESCALER)); } /** * @brief Set the length of the stop bits * @rmtoll CR2 STOP LL_LPUART_SetStopBitsLength * @param LPUARTx LPUART Instance * @param StopBits This parameter can be one of the following values: * @arg @ref LL_LPUART_STOPBITS_1 * @arg @ref LL_LPUART_STOPBITS_2 * @retval None */ __STATIC_INLINE void LL_LPUART_SetStopBitsLength(USART_TypeDef *LPUARTx, uint32_t StopBits) { MODIFY_REG(LPUARTx->CR2, USART_CR2_STOP, StopBits); } /** * @brief Retrieve the length of the stop bits * @rmtoll CR2 STOP LL_LPUART_GetStopBitsLength * @param LPUARTx LPUART Instance * @retval Returned value can be one of the following values: * @arg @ref LL_LPUART_STOPBITS_1 * @arg @ref LL_LPUART_STOPBITS_2 */ __STATIC_INLINE uint32_t LL_LPUART_GetStopBitsLength(USART_TypeDef *LPUARTx) { return (uint32_t)(READ_BIT(LPUARTx->CR2, USART_CR2_STOP)); } /** * @brief Configure Character frame format (Datawidth, Parity control, Stop Bits) * @note Call of this function is equivalent to following function call sequence : * - Data Width configuration using @ref LL_LPUART_SetDataWidth() function * - Parity Control and mode configuration using @ref LL_LPUART_SetParity() function * - Stop bits configuration using @ref LL_LPUART_SetStopBitsLength() function * @rmtoll CR1 PS LL_LPUART_ConfigCharacter\n * CR1 PCE LL_LPUART_ConfigCharacter\n * CR1 M LL_LPUART_ConfigCharacter\n * CR2 STOP LL_LPUART_ConfigCharacter * @param LPUARTx LPUART Instance * @param DataWidth This parameter can be one of the following values: * @arg @ref LL_LPUART_DATAWIDTH_7B * @arg @ref LL_LPUART_DATAWIDTH_8B * @arg @ref LL_LPUART_DATAWIDTH_9B * @param Parity This parameter can be one of the following values: * @arg @ref LL_LPUART_PARITY_NONE * @arg @ref LL_LPUART_PARITY_EVEN * @arg @ref LL_LPUART_PARITY_ODD * @param StopBits This parameter can be one of the following values: * @arg @ref LL_LPUART_STOPBITS_1 * @arg @ref LL_LPUART_STOPBITS_2 * @retval None */ __STATIC_INLINE void LL_LPUART_ConfigCharacter(USART_TypeDef *LPUARTx, uint32_t DataWidth, uint32_t Parity, uint32_t StopBits) { MODIFY_REG(LPUARTx->CR1, USART_CR1_PS | USART_CR1_PCE | USART_CR1_M, Parity | DataWidth); MODIFY_REG(LPUARTx->CR2, USART_CR2_STOP, StopBits); } /** * @brief Configure TX/RX pins swapping setting. * @rmtoll CR2 SWAP LL_LPUART_SetTXRXSwap * @param LPUARTx LPUART Instance * @param SwapConfig This parameter can be one of the following values: * @arg @ref LL_LPUART_TXRX_STANDARD * @arg @ref LL_LPUART_TXRX_SWAPPED * @retval None */ __STATIC_INLINE void LL_LPUART_SetTXRXSwap(USART_TypeDef *LPUARTx, uint32_t SwapConfig) { MODIFY_REG(LPUARTx->CR2, USART_CR2_SWAP, SwapConfig); } /** * @brief Retrieve TX/RX pins swapping configuration. * @rmtoll CR2 SWAP LL_LPUART_GetTXRXSwap * @param LPUARTx LPUART Instance * @retval Returned value can be one of the following values: * @arg @ref LL_LPUART_TXRX_STANDARD * @arg @ref LL_LPUART_TXRX_SWAPPED */ __STATIC_INLINE uint32_t LL_LPUART_GetTXRXSwap(USART_TypeDef *LPUARTx) { return (uint32_t)(READ_BIT(LPUARTx->CR2, USART_CR2_SWAP)); } /** * @brief Configure RX pin active level logic * @rmtoll CR2 RXINV LL_LPUART_SetRXPinLevel * @param LPUARTx LPUART Instance * @param PinInvMethod This parameter can be one of the following values: * @arg @ref LL_LPUART_RXPIN_LEVEL_STANDARD * @arg @ref LL_LPUART_RXPIN_LEVEL_INVERTED * @retval None */ __STATIC_INLINE void LL_LPUART_SetRXPinLevel(USART_TypeDef *LPUARTx, uint32_t PinInvMethod) { MODIFY_REG(LPUARTx->CR2, USART_CR2_RXINV, PinInvMethod); } /** * @brief Retrieve RX pin active level logic configuration * @rmtoll CR2 RXINV LL_LPUART_GetRXPinLevel * @param LPUARTx LPUART Instance * @retval Returned value can be one of the following values: * @arg @ref LL_LPUART_RXPIN_LEVEL_STANDARD * @arg @ref LL_LPUART_RXPIN_LEVEL_INVERTED */ __STATIC_INLINE uint32_t LL_LPUART_GetRXPinLevel(USART_TypeDef *LPUARTx) { return (uint32_t)(READ_BIT(LPUARTx->CR2, USART_CR2_RXINV)); } /** * @brief Configure TX pin active level logic * @rmtoll CR2 TXINV LL_LPUART_SetTXPinLevel * @param LPUARTx LPUART Instance * @param PinInvMethod This parameter can be one of the following values: * @arg @ref LL_LPUART_TXPIN_LEVEL_STANDARD * @arg @ref LL_LPUART_TXPIN_LEVEL_INVERTED * @retval None */ __STATIC_INLINE void LL_LPUART_SetTXPinLevel(USART_TypeDef *LPUARTx, uint32_t PinInvMethod) { MODIFY_REG(LPUARTx->CR2, USART_CR2_TXINV, PinInvMethod); } /** * @brief Retrieve TX pin active level logic configuration * @rmtoll CR2 TXINV LL_LPUART_GetTXPinLevel * @param LPUARTx LPUART Instance * @retval Returned value can be one of the following values: * @arg @ref LL_LPUART_TXPIN_LEVEL_STANDARD * @arg @ref LL_LPUART_TXPIN_LEVEL_INVERTED */ __STATIC_INLINE uint32_t LL_LPUART_GetTXPinLevel(USART_TypeDef *LPUARTx) { return (uint32_t)(READ_BIT(LPUARTx->CR2, USART_CR2_TXINV)); } /** * @brief Configure Binary data logic. * * @note Allow to define how Logical data from the data register are send/received : * either in positive/direct logic (1=H, 0=L) or in negative/inverse logic (1=L, 0=H) * @rmtoll CR2 DATAINV LL_LPUART_SetBinaryDataLogic * @param LPUARTx LPUART Instance * @param DataLogic This parameter can be one of the following values: * @arg @ref LL_LPUART_BINARY_LOGIC_POSITIVE * @arg @ref LL_LPUART_BINARY_LOGIC_NEGATIVE * @retval None */ __STATIC_INLINE void LL_LPUART_SetBinaryDataLogic(USART_TypeDef *LPUARTx, uint32_t DataLogic) { MODIFY_REG(LPUARTx->CR2, USART_CR2_DATAINV, DataLogic); } /** * @brief Retrieve Binary data configuration * @rmtoll CR2 DATAINV LL_LPUART_GetBinaryDataLogic * @param LPUARTx LPUART Instance * @retval Returned value can be one of the following values: * @arg @ref LL_LPUART_BINARY_LOGIC_POSITIVE * @arg @ref LL_LPUART_BINARY_LOGIC_NEGATIVE */ __STATIC_INLINE uint32_t LL_LPUART_GetBinaryDataLogic(USART_TypeDef *LPUARTx) { return (uint32_t)(READ_BIT(LPUARTx->CR2, USART_CR2_DATAINV)); } /** * @brief Configure transfer bit order (either Less or Most Significant Bit First) * @note MSB First means data is transmitted/received with the MSB first, following the start bit. * LSB First means data is transmitted/received with data bit 0 first, following the start bit. * @rmtoll CR2 MSBFIRST LL_LPUART_SetTransferBitOrder * @param LPUARTx LPUART Instance * @param BitOrder This parameter can be one of the following values: * @arg @ref LL_LPUART_BITORDER_LSBFIRST * @arg @ref LL_LPUART_BITORDER_MSBFIRST * @retval None */ __STATIC_INLINE void LL_LPUART_SetTransferBitOrder(USART_TypeDef *LPUARTx, uint32_t BitOrder) { MODIFY_REG(LPUARTx->CR2, USART_CR2_MSBFIRST, BitOrder); } /** * @brief Return transfer bit order (either Less or Most Significant Bit First) * @note MSB First means data is transmitted/received with the MSB first, following the start bit. * LSB First means data is transmitted/received with data bit 0 first, following the start bit. * @rmtoll CR2 MSBFIRST LL_LPUART_GetTransferBitOrder * @param LPUARTx LPUART Instance * @retval Returned value can be one of the following values: * @arg @ref LL_LPUART_BITORDER_LSBFIRST * @arg @ref LL_LPUART_BITORDER_MSBFIRST */ __STATIC_INLINE uint32_t LL_LPUART_GetTransferBitOrder(USART_TypeDef *LPUARTx) { return (uint32_t)(READ_BIT(LPUARTx->CR2, USART_CR2_MSBFIRST)); } /** * @brief Set Address of the LPUART node. * @note This is used in multiprocessor communication during Mute mode or Stop mode, * for wake up with address mark detection. * @note 4bits address node is used when 4-bit Address Detection is selected in ADDM7. * (b7-b4 should be set to 0) * 8bits address node is used when 7-bit Address Detection is selected in ADDM7. * (This is used in multiprocessor communication during Mute mode or Stop mode, * for wake up with 7-bit address mark detection. * The MSB of the character sent by the transmitter should be equal to 1. * It may also be used for character detection during normal reception, * Mute mode inactive (for example, end of block detection in ModBus protocol). * In this case, the whole received character (8-bit) is compared to the ADD[7:0] * value and CMF flag is set on match) * @rmtoll CR2 ADD LL_LPUART_ConfigNodeAddress\n * CR2 ADDM7 LL_LPUART_ConfigNodeAddress * @param LPUARTx LPUART Instance * @param AddressLen This parameter can be one of the following values: * @arg @ref LL_LPUART_ADDRESS_DETECT_4B * @arg @ref LL_LPUART_ADDRESS_DETECT_7B * @param NodeAddress 4 or 7 bit Address of the LPUART node. * @retval None */ __STATIC_INLINE void LL_LPUART_ConfigNodeAddress(USART_TypeDef *LPUARTx, uint32_t AddressLen, uint32_t NodeAddress) { MODIFY_REG(LPUARTx->CR2, USART_CR2_ADD | USART_CR2_ADDM7, (uint32_t)(AddressLen | (NodeAddress << USART_CR2_ADD_Pos))); } /** * @brief Return 8 bit Address of the LPUART node as set in ADD field of CR2. * @note If 4-bit Address Detection is selected in ADDM7, * only 4bits (b3-b0) of returned value are relevant (b31-b4 are not relevant) * If 7-bit Address Detection is selected in ADDM7, * only 8bits (b7-b0) of returned value are relevant (b31-b8 are not relevant) * @rmtoll CR2 ADD LL_LPUART_GetNodeAddress * @param LPUARTx LPUART Instance * @retval Address of the LPUART node (Value between Min_Data=0 and Max_Data=255) */ __STATIC_INLINE uint32_t LL_LPUART_GetNodeAddress(USART_TypeDef *LPUARTx) { return (uint32_t)(READ_BIT(LPUARTx->CR2, USART_CR2_ADD) >> USART_CR2_ADD_Pos); } /** * @brief Return Length of Node Address used in Address Detection mode (7-bit or 4-bit) * @rmtoll CR2 ADDM7 LL_LPUART_GetNodeAddressLen * @param LPUARTx LPUART Instance * @retval Returned value can be one of the following values: * @arg @ref LL_LPUART_ADDRESS_DETECT_4B * @arg @ref LL_LPUART_ADDRESS_DETECT_7B */ __STATIC_INLINE uint32_t LL_LPUART_GetNodeAddressLen(USART_TypeDef *LPUARTx) { return (uint32_t)(READ_BIT(LPUARTx->CR2, USART_CR2_ADDM7)); } /** * @brief Enable RTS HW Flow Control * @rmtoll CR3 RTSE LL_LPUART_EnableRTSHWFlowCtrl * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_EnableRTSHWFlowCtrl(USART_TypeDef *LPUARTx) { SET_BIT(LPUARTx->CR3, USART_CR3_RTSE); } /** * @brief Disable RTS HW Flow Control * @rmtoll CR3 RTSE LL_LPUART_DisableRTSHWFlowCtrl * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_DisableRTSHWFlowCtrl(USART_TypeDef *LPUARTx) { CLEAR_BIT(LPUARTx->CR3, USART_CR3_RTSE); } /** * @brief Enable CTS HW Flow Control * @rmtoll CR3 CTSE LL_LPUART_EnableCTSHWFlowCtrl * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_EnableCTSHWFlowCtrl(USART_TypeDef *LPUARTx) { SET_BIT(LPUARTx->CR3, USART_CR3_CTSE); } /** * @brief Disable CTS HW Flow Control * @rmtoll CR3 CTSE LL_LPUART_DisableCTSHWFlowCtrl * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_DisableCTSHWFlowCtrl(USART_TypeDef *LPUARTx) { CLEAR_BIT(LPUARTx->CR3, USART_CR3_CTSE); } /** * @brief Configure HW Flow Control mode (both CTS and RTS) * @rmtoll CR3 RTSE LL_LPUART_SetHWFlowCtrl\n * CR3 CTSE LL_LPUART_SetHWFlowCtrl * @param LPUARTx LPUART Instance * @param HardwareFlowControl This parameter can be one of the following values: * @arg @ref LL_LPUART_HWCONTROL_NONE * @arg @ref LL_LPUART_HWCONTROL_RTS * @arg @ref LL_LPUART_HWCONTROL_CTS * @arg @ref LL_LPUART_HWCONTROL_RTS_CTS * @retval None */ __STATIC_INLINE void LL_LPUART_SetHWFlowCtrl(USART_TypeDef *LPUARTx, uint32_t HardwareFlowControl) { MODIFY_REG(LPUARTx->CR3, USART_CR3_RTSE | USART_CR3_CTSE, HardwareFlowControl); } /** * @brief Return HW Flow Control configuration (both CTS and RTS) * @rmtoll CR3 RTSE LL_LPUART_GetHWFlowCtrl\n * CR3 CTSE LL_LPUART_GetHWFlowCtrl * @param LPUARTx LPUART Instance * @retval Returned value can be one of the following values: * @arg @ref LL_LPUART_HWCONTROL_NONE * @arg @ref LL_LPUART_HWCONTROL_RTS * @arg @ref LL_LPUART_HWCONTROL_CTS * @arg @ref LL_LPUART_HWCONTROL_RTS_CTS */ __STATIC_INLINE uint32_t LL_LPUART_GetHWFlowCtrl(USART_TypeDef *LPUARTx) { return (uint32_t)(READ_BIT(LPUARTx->CR3, USART_CR3_RTSE | USART_CR3_CTSE)); } /** * @brief Enable Overrun detection * @rmtoll CR3 OVRDIS LL_LPUART_EnableOverrunDetect * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_EnableOverrunDetect(USART_TypeDef *LPUARTx) { CLEAR_BIT(LPUARTx->CR3, USART_CR3_OVRDIS); } /** * @brief Disable Overrun detection * @rmtoll CR3 OVRDIS LL_LPUART_DisableOverrunDetect * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_DisableOverrunDetect(USART_TypeDef *LPUARTx) { SET_BIT(LPUARTx->CR3, USART_CR3_OVRDIS); } /** * @brief Indicate if Overrun detection is enabled * @rmtoll CR3 OVRDIS LL_LPUART_IsEnabledOverrunDetect * @param LPUARTx LPUART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_LPUART_IsEnabledOverrunDetect(USART_TypeDef *LPUARTx) { return ((READ_BIT(LPUARTx->CR3, USART_CR3_OVRDIS) != USART_CR3_OVRDIS) ? 1UL : 0UL); } /** * @brief Select event type for Wake UP Interrupt Flag (WUS[1:0] bits) * @rmtoll CR3 WUS LL_LPUART_SetWKUPType * @param LPUARTx LPUART Instance * @param Type This parameter can be one of the following values: * @arg @ref LL_LPUART_WAKEUP_ON_ADDRESS * @arg @ref LL_LPUART_WAKEUP_ON_STARTBIT * @arg @ref LL_LPUART_WAKEUP_ON_RXNE * @retval None */ __STATIC_INLINE void LL_LPUART_SetWKUPType(USART_TypeDef *LPUARTx, uint32_t Type) { MODIFY_REG(LPUARTx->CR3, USART_CR3_WUS, Type); } /** * @brief Return event type for Wake UP Interrupt Flag (WUS[1:0] bits) * @rmtoll CR3 WUS LL_LPUART_GetWKUPType * @param LPUARTx LPUART Instance * @retval Returned value can be one of the following values: * @arg @ref LL_LPUART_WAKEUP_ON_ADDRESS * @arg @ref LL_LPUART_WAKEUP_ON_STARTBIT * @arg @ref LL_LPUART_WAKEUP_ON_RXNE */ __STATIC_INLINE uint32_t LL_LPUART_GetWKUPType(USART_TypeDef *LPUARTx) { return (uint32_t)(READ_BIT(LPUARTx->CR3, USART_CR3_WUS)); } /** * @brief Configure LPUART BRR register for achieving expected Baud Rate value. * * @note Compute and set LPUARTDIV value in BRR Register (full BRR content) * according to used Peripheral Clock and expected Baud Rate values * @note Peripheral clock and Baud Rate values provided as function parameters should be valid * (Baud rate value != 0). * @note Provided that LPUARTx_BRR must be > = 0x300 and LPUART_BRR is 20-bit, * a care should be taken when generating high baud rates using high PeriphClk * values. PeriphClk must be in the range [3 x BaudRate, 4096 x BaudRate]. * @rmtoll BRR BRR LL_LPUART_SetBaudRate * @param LPUARTx LPUART Instance * @param PeriphClk Peripheral Clock * @param PrescalerValue This parameter can be one of the following values: * @arg @ref LL_LPUART_PRESCALER_DIV1 * @arg @ref LL_LPUART_PRESCALER_DIV2 * @arg @ref LL_LPUART_PRESCALER_DIV4 * @arg @ref LL_LPUART_PRESCALER_DIV6 * @arg @ref LL_LPUART_PRESCALER_DIV8 * @arg @ref LL_LPUART_PRESCALER_DIV10 * @arg @ref LL_LPUART_PRESCALER_DIV12 * @arg @ref LL_LPUART_PRESCALER_DIV16 * @arg @ref LL_LPUART_PRESCALER_DIV32 * @arg @ref LL_LPUART_PRESCALER_DIV64 * @arg @ref LL_LPUART_PRESCALER_DIV128 * @arg @ref LL_LPUART_PRESCALER_DIV256 * @param BaudRate Baud Rate * @retval None */ __STATIC_INLINE void LL_LPUART_SetBaudRate(USART_TypeDef *LPUARTx, uint32_t PeriphClk, uint32_t PrescalerValue, uint32_t BaudRate) { if (BaudRate != 0U) { LPUARTx->BRR = __LL_LPUART_DIV(PeriphClk, PrescalerValue, BaudRate); } } /** * @brief Return current Baud Rate value, according to LPUARTDIV present in BRR register * (full BRR content), and to used Peripheral Clock values * @note In case of non-initialized or invalid value stored in BRR register, value 0 will be returned. * @rmtoll BRR BRR LL_LPUART_GetBaudRate * @param LPUARTx LPUART Instance * @param PeriphClk Peripheral Clock * @param PrescalerValue This parameter can be one of the following values: * @arg @ref LL_LPUART_PRESCALER_DIV1 * @arg @ref LL_LPUART_PRESCALER_DIV2 * @arg @ref LL_LPUART_PRESCALER_DIV4 * @arg @ref LL_LPUART_PRESCALER_DIV6 * @arg @ref LL_LPUART_PRESCALER_DIV8 * @arg @ref LL_LPUART_PRESCALER_DIV10 * @arg @ref LL_LPUART_PRESCALER_DIV12 * @arg @ref LL_LPUART_PRESCALER_DIV16 * @arg @ref LL_LPUART_PRESCALER_DIV32 * @arg @ref LL_LPUART_PRESCALER_DIV64 * @arg @ref LL_LPUART_PRESCALER_DIV128 * @arg @ref LL_LPUART_PRESCALER_DIV256 * @retval Baud Rate */ __STATIC_INLINE uint32_t LL_LPUART_GetBaudRate(USART_TypeDef *LPUARTx, uint32_t PeriphClk, uint32_t PrescalerValue) { uint32_t lpuartdiv; uint32_t brrresult; uint32_t periphclkpresc = (uint32_t)(PeriphClk / (LPUART_PRESCALER_TAB[(uint16_t)PrescalerValue])); lpuartdiv = LPUARTx->BRR & LPUART_BRR_MASK; if (lpuartdiv >= LPUART_BRR_MIN_VALUE) { brrresult = (uint32_t)(((uint64_t)(periphclkpresc) * LPUART_LPUARTDIV_FREQ_MUL) / lpuartdiv); } else { brrresult = 0x0UL; } return (brrresult); } /** * @} */ /** @defgroup LPUART_LL_EF_Configuration_HalfDuplex Configuration functions related to Half Duplex feature * @{ */ /** * @brief Enable Single Wire Half-Duplex mode * @rmtoll CR3 HDSEL LL_LPUART_EnableHalfDuplex * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_EnableHalfDuplex(USART_TypeDef *LPUARTx) { SET_BIT(LPUARTx->CR3, USART_CR3_HDSEL); } /** * @brief Disable Single Wire Half-Duplex mode * @rmtoll CR3 HDSEL LL_LPUART_DisableHalfDuplex * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_DisableHalfDuplex(USART_TypeDef *LPUARTx) { CLEAR_BIT(LPUARTx->CR3, USART_CR3_HDSEL); } /** * @brief Indicate if Single Wire Half-Duplex mode is enabled * @rmtoll CR3 HDSEL LL_LPUART_IsEnabledHalfDuplex * @param LPUARTx LPUART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_LPUART_IsEnabledHalfDuplex(USART_TypeDef *LPUARTx) { return ((READ_BIT(LPUARTx->CR3, USART_CR3_HDSEL) == (USART_CR3_HDSEL)) ? 1UL : 0UL); } /** * @} */ /** @defgroup LPUART_LL_EF_Configuration_DE Configuration functions related to Driver Enable feature * @{ */ /** * @brief Set DEDT (Driver Enable De-Assertion Time), Time value expressed on 5 bits ([4:0] bits). * @rmtoll CR1 DEDT LL_LPUART_SetDEDeassertionTime * @param LPUARTx LPUART Instance * @param Time Value between Min_Data=0 and Max_Data=31 * @retval None */ __STATIC_INLINE void LL_LPUART_SetDEDeassertionTime(USART_TypeDef *LPUARTx, uint32_t Time) { MODIFY_REG(LPUARTx->CR1, USART_CR1_DEDT, Time << USART_CR1_DEDT_Pos); } /** * @brief Return DEDT (Driver Enable De-Assertion Time) * @rmtoll CR1 DEDT LL_LPUART_GetDEDeassertionTime * @param LPUARTx LPUART Instance * @retval Time value expressed on 5 bits ([4:0] bits) : c */ __STATIC_INLINE uint32_t LL_LPUART_GetDEDeassertionTime(USART_TypeDef *LPUARTx) { return (uint32_t)(READ_BIT(LPUARTx->CR1, USART_CR1_DEDT) >> USART_CR1_DEDT_Pos); } /** * @brief Set DEAT (Driver Enable Assertion Time), Time value expressed on 5 bits ([4:0] bits). * @rmtoll CR1 DEAT LL_LPUART_SetDEAssertionTime * @param LPUARTx LPUART Instance * @param Time Value between Min_Data=0 and Max_Data=31 * @retval None */ __STATIC_INLINE void LL_LPUART_SetDEAssertionTime(USART_TypeDef *LPUARTx, uint32_t Time) { MODIFY_REG(LPUARTx->CR1, USART_CR1_DEAT, Time << USART_CR1_DEAT_Pos); } /** * @brief Return DEAT (Driver Enable Assertion Time) * @rmtoll CR1 DEAT LL_LPUART_GetDEAssertionTime * @param LPUARTx LPUART Instance * @retval Time value expressed on 5 bits ([4:0] bits) : Time Value between Min_Data=0 and Max_Data=31 */ __STATIC_INLINE uint32_t LL_LPUART_GetDEAssertionTime(USART_TypeDef *LPUARTx) { return (uint32_t)(READ_BIT(LPUARTx->CR1, USART_CR1_DEAT) >> USART_CR1_DEAT_Pos); } /** * @brief Enable Driver Enable (DE) Mode * @rmtoll CR3 DEM LL_LPUART_EnableDEMode * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_EnableDEMode(USART_TypeDef *LPUARTx) { SET_BIT(LPUARTx->CR3, USART_CR3_DEM); } /** * @brief Disable Driver Enable (DE) Mode * @rmtoll CR3 DEM LL_LPUART_DisableDEMode * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_DisableDEMode(USART_TypeDef *LPUARTx) { CLEAR_BIT(LPUARTx->CR3, USART_CR3_DEM); } /** * @brief Indicate if Driver Enable (DE) Mode is enabled * @rmtoll CR3 DEM LL_LPUART_IsEnabledDEMode * @param LPUARTx LPUART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_LPUART_IsEnabledDEMode(USART_TypeDef *LPUARTx) { return ((READ_BIT(LPUARTx->CR3, USART_CR3_DEM) == (USART_CR3_DEM)) ? 1UL : 0UL); } /** * @brief Select Driver Enable Polarity * @rmtoll CR3 DEP LL_LPUART_SetDESignalPolarity * @param LPUARTx LPUART Instance * @param Polarity This parameter can be one of the following values: * @arg @ref LL_LPUART_DE_POLARITY_HIGH * @arg @ref LL_LPUART_DE_POLARITY_LOW * @retval None */ __STATIC_INLINE void LL_LPUART_SetDESignalPolarity(USART_TypeDef *LPUARTx, uint32_t Polarity) { MODIFY_REG(LPUARTx->CR3, USART_CR3_DEP, Polarity); } /** * @brief Return Driver Enable Polarity * @rmtoll CR3 DEP LL_LPUART_GetDESignalPolarity * @param LPUARTx LPUART Instance * @retval Returned value can be one of the following values: * @arg @ref LL_LPUART_DE_POLARITY_HIGH * @arg @ref LL_LPUART_DE_POLARITY_LOW */ __STATIC_INLINE uint32_t LL_LPUART_GetDESignalPolarity(USART_TypeDef *LPUARTx) { return (uint32_t)(READ_BIT(LPUARTx->CR3, USART_CR3_DEP)); } /** * @} */ /** @defgroup LPUART_LL_EF_FLAG_Management FLAG_Management * @{ */ /** * @brief Check if the LPUART Parity Error Flag is set or not * @rmtoll ISR PE LL_LPUART_IsActiveFlag_PE * @param LPUARTx LPUART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_PE(USART_TypeDef *LPUARTx) { return ((READ_BIT(LPUARTx->ISR, USART_ISR_PE) == (USART_ISR_PE)) ? 1UL : 0UL); } /** * @brief Check if the LPUART Framing Error Flag is set or not * @rmtoll ISR FE LL_LPUART_IsActiveFlag_FE * @param LPUARTx LPUART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_FE(USART_TypeDef *LPUARTx) { return ((READ_BIT(LPUARTx->ISR, USART_ISR_FE) == (USART_ISR_FE)) ? 1UL : 0UL); } /** * @brief Check if the LPUART Noise error detected Flag is set or not * @rmtoll ISR NE LL_LPUART_IsActiveFlag_NE * @param LPUARTx LPUART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_NE(USART_TypeDef *LPUARTx) { return ((READ_BIT(LPUARTx->ISR, USART_ISR_NE) == (USART_ISR_NE)) ? 1UL : 0UL); } /** * @brief Check if the LPUART OverRun Error Flag is set or not * @rmtoll ISR ORE LL_LPUART_IsActiveFlag_ORE * @param LPUARTx LPUART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_ORE(USART_TypeDef *LPUARTx) { return ((READ_BIT(LPUARTx->ISR, USART_ISR_ORE) == (USART_ISR_ORE)) ? 1UL : 0UL); } /** * @brief Check if the LPUART IDLE line detected Flag is set or not * @rmtoll ISR IDLE LL_LPUART_IsActiveFlag_IDLE * @param LPUARTx LPUART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_IDLE(USART_TypeDef *LPUARTx) { return ((READ_BIT(LPUARTx->ISR, USART_ISR_IDLE) == (USART_ISR_IDLE)) ? 1UL : 0UL); } /* Legacy define */ #define LL_LPUART_IsActiveFlag_RXNE LL_LPUART_IsActiveFlag_RXNE_RXFNE /** * @brief Check if the LPUART Read Data Register or LPUART RX FIFO Not Empty Flag is set or not * @rmtoll ISR RXNE_RXFNE LL_LPUART_IsActiveFlag_RXNE_RXFNE * @param LPUARTx LPUART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_RXNE_RXFNE(USART_TypeDef *LPUARTx) { return ((READ_BIT(LPUARTx->ISR, USART_ISR_RXNE_RXFNE) == (USART_ISR_RXNE_RXFNE)) ? 1UL : 0UL); } /** * @brief Check if the LPUART Transmission Complete Flag is set or not * @rmtoll ISR TC LL_LPUART_IsActiveFlag_TC * @param LPUARTx LPUART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_TC(USART_TypeDef *LPUARTx) { return ((READ_BIT(LPUARTx->ISR, USART_ISR_TC) == (USART_ISR_TC)) ? 1UL : 0UL); } /* Legacy define */ #define LL_LPUART_IsActiveFlag_TXE LL_LPUART_IsActiveFlag_TXE_TXFNF /** * @brief Check if the LPUART Transmit Data Register Empty or LPUART TX FIFO Not Full Flag is set or not * @rmtoll ISR TXE_TXFNF LL_LPUART_IsActiveFlag_TXE_TXFNF * @param LPUARTx LPUART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_TXE_TXFNF(USART_TypeDef *LPUARTx) { return ((READ_BIT(LPUARTx->ISR, USART_ISR_TXE_TXFNF) == (USART_ISR_TXE_TXFNF)) ? 1UL : 0UL); } /** * @brief Check if the LPUART CTS interrupt Flag is set or not * @rmtoll ISR CTSIF LL_LPUART_IsActiveFlag_nCTS * @param LPUARTx LPUART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_nCTS(USART_TypeDef *LPUARTx) { return ((READ_BIT(LPUARTx->ISR, USART_ISR_CTSIF) == (USART_ISR_CTSIF)) ? 1UL : 0UL); } /** * @brief Check if the LPUART CTS Flag is set or not * @rmtoll ISR CTS LL_LPUART_IsActiveFlag_CTS * @param LPUARTx LPUART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_CTS(USART_TypeDef *LPUARTx) { return ((READ_BIT(LPUARTx->ISR, USART_ISR_CTS) == (USART_ISR_CTS)) ? 1UL : 0UL); } /** * @brief Check if the LPUART Busy Flag is set or not * @rmtoll ISR BUSY LL_LPUART_IsActiveFlag_BUSY * @param LPUARTx LPUART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_BUSY(USART_TypeDef *LPUARTx) { return ((READ_BIT(LPUARTx->ISR, USART_ISR_BUSY) == (USART_ISR_BUSY)) ? 1UL : 0UL); } /** * @brief Check if the LPUART Character Match Flag is set or not * @rmtoll ISR CMF LL_LPUART_IsActiveFlag_CM * @param LPUARTx LPUART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_CM(USART_TypeDef *LPUARTx) { return ((READ_BIT(LPUARTx->ISR, USART_ISR_CMF) == (USART_ISR_CMF)) ? 1UL : 0UL); } /** * @brief Check if the LPUART Send Break Flag is set or not * @rmtoll ISR SBKF LL_LPUART_IsActiveFlag_SBK * @param LPUARTx LPUART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_SBK(USART_TypeDef *LPUARTx) { return ((READ_BIT(LPUARTx->ISR, USART_ISR_SBKF) == (USART_ISR_SBKF)) ? 1UL : 0UL); } /** * @brief Check if the LPUART Receive Wake Up from mute mode Flag is set or not * @rmtoll ISR RWU LL_LPUART_IsActiveFlag_RWU * @param LPUARTx LPUART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_RWU(USART_TypeDef *LPUARTx) { return ((READ_BIT(LPUARTx->ISR, USART_ISR_RWU) == (USART_ISR_RWU)) ? 1UL : 0UL); } /** * @brief Check if the LPUART Wake Up from stop mode Flag is set or not * @rmtoll ISR WUF LL_LPUART_IsActiveFlag_WKUP * @param LPUARTx LPUART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_WKUP(USART_TypeDef *LPUARTx) { return ((READ_BIT(LPUARTx->ISR, USART_ISR_WUF) == (USART_ISR_WUF)) ? 1UL : 0UL); } /** * @brief Check if the LPUART Transmit Enable Acknowledge Flag is set or not * @rmtoll ISR TEACK LL_LPUART_IsActiveFlag_TEACK * @param LPUARTx LPUART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_TEACK(USART_TypeDef *LPUARTx) { return ((READ_BIT(LPUARTx->ISR, USART_ISR_TEACK) == (USART_ISR_TEACK)) ? 1UL : 0UL); } /** * @brief Check if the LPUART Receive Enable Acknowledge Flag is set or not * @rmtoll ISR REACK LL_LPUART_IsActiveFlag_REACK * @param LPUARTx LPUART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_REACK(USART_TypeDef *LPUARTx) { return ((READ_BIT(LPUARTx->ISR, USART_ISR_REACK) == (USART_ISR_REACK)) ? 1UL : 0UL); } /** * @brief Check if the LPUART TX FIFO Empty Flag is set or not * @rmtoll ISR TXFE LL_LPUART_IsActiveFlag_TXFE * @param LPUARTx LPUART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_TXFE(USART_TypeDef *LPUARTx) { return ((READ_BIT(LPUARTx->ISR, USART_ISR_TXFE) == (USART_ISR_TXFE)) ? 1UL : 0UL); } /** * @brief Check if the LPUART RX FIFO Full Flag is set or not * @rmtoll ISR RXFF LL_LPUART_IsActiveFlag_RXFF * @param LPUARTx LPUART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_RXFF(USART_TypeDef *LPUARTx) { return ((READ_BIT(LPUARTx->ISR, USART_ISR_RXFF) == (USART_ISR_RXFF)) ? 1UL : 0UL); } /** * @brief Check if the LPUART TX FIFO Threshold Flag is set or not * @rmtoll ISR TXFT LL_LPUART_IsActiveFlag_TXFT * @param LPUARTx LPUART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_TXFT(USART_TypeDef *LPUARTx) { return ((READ_BIT(LPUARTx->ISR, USART_ISR_TXFT) == (USART_ISR_TXFT)) ? 1UL : 0UL); } /** * @brief Check if the LPUART RX FIFO Threshold Flag is set or not * @rmtoll ISR RXFT LL_LPUART_IsActiveFlag_RXFT * @param LPUARTx LPUART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_RXFT(USART_TypeDef *LPUARTx) { return ((READ_BIT(LPUARTx->ISR, USART_ISR_RXFT) == (USART_ISR_RXFT)) ? 1UL : 0UL); } /** * @brief Clear Parity Error Flag * @rmtoll ICR PECF LL_LPUART_ClearFlag_PE * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_ClearFlag_PE(USART_TypeDef *LPUARTx) { WRITE_REG(LPUARTx->ICR, USART_ICR_PECF); } /** * @brief Clear Framing Error Flag * @rmtoll ICR FECF LL_LPUART_ClearFlag_FE * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_ClearFlag_FE(USART_TypeDef *LPUARTx) { WRITE_REG(LPUARTx->ICR, USART_ICR_FECF); } /** * @brief Clear Noise detected Flag * @rmtoll ICR NECF LL_LPUART_ClearFlag_NE * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_ClearFlag_NE(USART_TypeDef *LPUARTx) { WRITE_REG(LPUARTx->ICR, USART_ICR_NECF); } /** * @brief Clear OverRun Error Flag * @rmtoll ICR ORECF LL_LPUART_ClearFlag_ORE * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_ClearFlag_ORE(USART_TypeDef *LPUARTx) { WRITE_REG(LPUARTx->ICR, USART_ICR_ORECF); } /** * @brief Clear IDLE line detected Flag * @rmtoll ICR IDLECF LL_LPUART_ClearFlag_IDLE * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_ClearFlag_IDLE(USART_TypeDef *LPUARTx) { WRITE_REG(LPUARTx->ICR, USART_ICR_IDLECF); } /** * @brief Clear TX FIFO Empty Flag * @rmtoll ICR TXFECF LL_LPUART_ClearFlag_TXFE * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_ClearFlag_TXFE(USART_TypeDef *LPUARTx) { WRITE_REG(LPUARTx->ICR, USART_ICR_TXFECF); } /** * @brief Clear Transmission Complete Flag * @rmtoll ICR TCCF LL_LPUART_ClearFlag_TC * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_ClearFlag_TC(USART_TypeDef *LPUARTx) { WRITE_REG(LPUARTx->ICR, USART_ICR_TCCF); } /** * @brief Clear CTS Interrupt Flag * @rmtoll ICR CTSCF LL_LPUART_ClearFlag_nCTS * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_ClearFlag_nCTS(USART_TypeDef *LPUARTx) { WRITE_REG(LPUARTx->ICR, USART_ICR_CTSCF); } /** * @brief Clear Character Match Flag * @rmtoll ICR CMCF LL_LPUART_ClearFlag_CM * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_ClearFlag_CM(USART_TypeDef *LPUARTx) { WRITE_REG(LPUARTx->ICR, USART_ICR_CMCF); } /** * @brief Clear Wake Up from stop mode Flag * @rmtoll ICR WUCF LL_LPUART_ClearFlag_WKUP * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_ClearFlag_WKUP(USART_TypeDef *LPUARTx) { WRITE_REG(LPUARTx->ICR, USART_ICR_WUCF); } /** * @} */ /** @defgroup LPUART_LL_EF_IT_Management IT_Management * @{ */ /** * @brief Enable IDLE Interrupt * @rmtoll CR1 IDLEIE LL_LPUART_EnableIT_IDLE * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_EnableIT_IDLE(USART_TypeDef *LPUARTx) { SET_BIT(LPUARTx->CR1, USART_CR1_IDLEIE); } /* Legacy define */ #define LL_LPUART_EnableIT_RXNE LL_LPUART_EnableIT_RXNE_RXFNE /** * @brief Enable RX Not Empty and RX FIFO Not Empty Interrupt * @rmtoll CR1 RXNEIE_RXFNEIE LL_LPUART_EnableIT_RXNE_RXFNE * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_EnableIT_RXNE_RXFNE(USART_TypeDef *LPUARTx) { SET_BIT(LPUARTx->CR1, USART_CR1_RXNEIE_RXFNEIE); } /** * @brief Enable Transmission Complete Interrupt * @rmtoll CR1 TCIE LL_LPUART_EnableIT_TC * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_EnableIT_TC(USART_TypeDef *LPUARTx) { SET_BIT(LPUARTx->CR1, USART_CR1_TCIE); } /* Legacy define */ #define LL_LPUART_EnableIT_TXE LL_LPUART_EnableIT_TXE_TXFNF /** * @brief Enable TX Empty and TX FIFO Not Full Interrupt * @rmtoll CR1 TXEIE_TXFNFIE LL_LPUART_EnableIT_TXE_TXFNF * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_EnableIT_TXE_TXFNF(USART_TypeDef *LPUARTx) { SET_BIT(LPUARTx->CR1, USART_CR1_TXEIE_TXFNFIE); } /** * @brief Enable Parity Error Interrupt * @rmtoll CR1 PEIE LL_LPUART_EnableIT_PE * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_EnableIT_PE(USART_TypeDef *LPUARTx) { SET_BIT(LPUARTx->CR1, USART_CR1_PEIE); } /** * @brief Enable Character Match Interrupt * @rmtoll CR1 CMIE LL_LPUART_EnableIT_CM * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_EnableIT_CM(USART_TypeDef *LPUARTx) { SET_BIT(LPUARTx->CR1, USART_CR1_CMIE); } /** * @brief Enable TX FIFO Empty Interrupt * @rmtoll CR1 TXFEIE LL_LPUART_EnableIT_TXFE * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_EnableIT_TXFE(USART_TypeDef *LPUARTx) { SET_BIT(LPUARTx->CR1, USART_CR1_TXFEIE); } /** * @brief Enable RX FIFO Full Interrupt * @rmtoll CR1 RXFFIE LL_LPUART_EnableIT_RXFF * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_EnableIT_RXFF(USART_TypeDef *LPUARTx) { SET_BIT(LPUARTx->CR1, USART_CR1_RXFFIE); } /** * @brief Enable Error Interrupt * @note When set, Error Interrupt Enable Bit is enabling interrupt generation in case of a framing * error, overrun error or noise flag (FE=1 or ORE=1 or NF=1 in the LPUARTx_ISR register). * - 0: Interrupt is inhibited * - 1: An interrupt is generated when FE=1 or ORE=1 or NF=1 in the LPUARTx_ISR register. * @rmtoll CR3 EIE LL_LPUART_EnableIT_ERROR * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_EnableIT_ERROR(USART_TypeDef *LPUARTx) { SET_BIT(LPUARTx->CR3, USART_CR3_EIE); } /** * @brief Enable CTS Interrupt * @rmtoll CR3 CTSIE LL_LPUART_EnableIT_CTS * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_EnableIT_CTS(USART_TypeDef *LPUARTx) { SET_BIT(LPUARTx->CR3, USART_CR3_CTSIE); } /** * @brief Enable Wake Up from Stop Mode Interrupt * @rmtoll CR3 WUFIE LL_LPUART_EnableIT_WKUP * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_EnableIT_WKUP(USART_TypeDef *LPUARTx) { SET_BIT(LPUARTx->CR3, USART_CR3_WUFIE); } /** * @brief Enable TX FIFO Threshold Interrupt * @rmtoll CR3 TXFTIE LL_LPUART_EnableIT_TXFT * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_EnableIT_TXFT(USART_TypeDef *LPUARTx) { SET_BIT(LPUARTx->CR3, USART_CR3_TXFTIE); } /** * @brief Enable RX FIFO Threshold Interrupt * @rmtoll CR3 RXFTIE LL_LPUART_EnableIT_RXFT * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_EnableIT_RXFT(USART_TypeDef *LPUARTx) { SET_BIT(LPUARTx->CR3, USART_CR3_RXFTIE); } /** * @brief Disable IDLE Interrupt * @rmtoll CR1 IDLEIE LL_LPUART_DisableIT_IDLE * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_DisableIT_IDLE(USART_TypeDef *LPUARTx) { CLEAR_BIT(LPUARTx->CR1, USART_CR1_IDLEIE); } /* Legacy define */ #define LL_LPUART_DisableIT_RXNE LL_LPUART_DisableIT_RXNE_RXFNE /** * @brief Disable RX Not Empty and RX FIFO Not Empty Interrupt * @rmtoll CR1 RXNEIE_RXFNEIE LL_LPUART_DisableIT_RXNE_RXFNE * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_DisableIT_RXNE_RXFNE(USART_TypeDef *LPUARTx) { CLEAR_BIT(LPUARTx->CR1, USART_CR1_RXNEIE_RXFNEIE); } /** * @brief Disable Transmission Complete Interrupt * @rmtoll CR1 TCIE LL_LPUART_DisableIT_TC * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_DisableIT_TC(USART_TypeDef *LPUARTx) { CLEAR_BIT(LPUARTx->CR1, USART_CR1_TCIE); } /* Legacy define */ #define LL_LPUART_DisableIT_TXE LL_LPUART_DisableIT_TXE_TXFNF /** * @brief Disable TX Empty and TX FIFO Not Full Interrupt * @rmtoll CR1 TXEIE_TXFNFIE LL_LPUART_DisableIT_TXE_TXFNF * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_DisableIT_TXE_TXFNF(USART_TypeDef *LPUARTx) { CLEAR_BIT(LPUARTx->CR1, USART_CR1_TXEIE_TXFNFIE); } /** * @brief Disable Parity Error Interrupt * @rmtoll CR1 PEIE LL_LPUART_DisableIT_PE * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_DisableIT_PE(USART_TypeDef *LPUARTx) { CLEAR_BIT(LPUARTx->CR1, USART_CR1_PEIE); } /** * @brief Disable Character Match Interrupt * @rmtoll CR1 CMIE LL_LPUART_DisableIT_CM * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_DisableIT_CM(USART_TypeDef *LPUARTx) { CLEAR_BIT(LPUARTx->CR1, USART_CR1_CMIE); } /** * @brief Disable TX FIFO Empty Interrupt * @rmtoll CR1 TXFEIE LL_LPUART_DisableIT_TXFE * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_DisableIT_TXFE(USART_TypeDef *LPUARTx) { CLEAR_BIT(LPUARTx->CR1, USART_CR1_TXFEIE); } /** * @brief Disable RX FIFO Full Interrupt * @rmtoll CR1 RXFFIE LL_LPUART_DisableIT_RXFF * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_DisableIT_RXFF(USART_TypeDef *LPUARTx) { CLEAR_BIT(LPUARTx->CR1, USART_CR1_RXFFIE); } /** * @brief Disable Error Interrupt * @note When set, Error Interrupt Enable Bit is enabling interrupt generation in case of a framing * error, overrun error or noise flag (FE=1 or ORE=1 or NF=1 in the LPUARTx_ISR register). * - 0: Interrupt is inhibited * - 1: An interrupt is generated when FE=1 or ORE=1 or NF=1 in the LPUARTx_ISR register. * @rmtoll CR3 EIE LL_LPUART_DisableIT_ERROR * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_DisableIT_ERROR(USART_TypeDef *LPUARTx) { CLEAR_BIT(LPUARTx->CR3, USART_CR3_EIE); } /** * @brief Disable CTS Interrupt * @rmtoll CR3 CTSIE LL_LPUART_DisableIT_CTS * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_DisableIT_CTS(USART_TypeDef *LPUARTx) { CLEAR_BIT(LPUARTx->CR3, USART_CR3_CTSIE); } /** * @brief Disable Wake Up from Stop Mode Interrupt * @rmtoll CR3 WUFIE LL_LPUART_DisableIT_WKUP * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_DisableIT_WKUP(USART_TypeDef *LPUARTx) { CLEAR_BIT(LPUARTx->CR3, USART_CR3_WUFIE); } /** * @brief Disable TX FIFO Threshold Interrupt * @rmtoll CR3 TXFTIE LL_LPUART_DisableIT_TXFT * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_DisableIT_TXFT(USART_TypeDef *LPUARTx) { CLEAR_BIT(LPUARTx->CR3, USART_CR3_TXFTIE); } /** * @brief Disable RX FIFO Threshold Interrupt * @rmtoll CR3 RXFTIE LL_LPUART_DisableIT_RXFT * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_DisableIT_RXFT(USART_TypeDef *LPUARTx) { CLEAR_BIT(LPUARTx->CR3, USART_CR3_RXFTIE); } /** * @brief Check if the LPUART IDLE Interrupt source is enabled or disabled. * @rmtoll CR1 IDLEIE LL_LPUART_IsEnabledIT_IDLE * @param LPUARTx LPUART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_IDLE(USART_TypeDef *LPUARTx) { return ((READ_BIT(LPUARTx->CR1, USART_CR1_IDLEIE) == (USART_CR1_IDLEIE)) ? 1UL : 0UL); } /* Legacy define */ #define LL_LPUART_IsEnabledIT_RXNE LL_LPUART_IsEnabledIT_RXNE_RXFNE /** * @brief Check if the LPUART RX Not Empty and LPUART RX FIFO Not Empty Interrupt is enabled or disabled. * @rmtoll CR1 RXNEIE_RXFNEIE LL_LPUART_IsEnabledIT_RXNE_RXFNE * @param LPUARTx LPUART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_RXNE_RXFNE(USART_TypeDef *LPUARTx) { return ((READ_BIT(LPUARTx->CR1, USART_CR1_RXNEIE_RXFNEIE) == (USART_CR1_RXNEIE_RXFNEIE)) ? 1UL : 0UL); } /** * @brief Check if the LPUART Transmission Complete Interrupt is enabled or disabled. * @rmtoll CR1 TCIE LL_LPUART_IsEnabledIT_TC * @param LPUARTx LPUART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_TC(USART_TypeDef *LPUARTx) { return ((READ_BIT(LPUARTx->CR1, USART_CR1_TCIE) == (USART_CR1_TCIE)) ? 1UL : 0UL); } /* Legacy define */ #define LL_LPUART_IsEnabledIT_TXE LL_LPUART_IsEnabledIT_TXE_TXFNF /** * @brief Check if the LPUART TX Empty and LPUART TX FIFO Not Full Interrupt is enabled or disabled * @rmtoll CR1 TXEIE_TXFNFIE LL_LPUART_IsEnabledIT_TXE_TXFNF * @param LPUARTx LPUART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_TXE_TXFNF(USART_TypeDef *LPUARTx) { return ((READ_BIT(LPUARTx->CR1, USART_CR1_TXEIE_TXFNFIE) == (USART_CR1_TXEIE_TXFNFIE)) ? 1UL : 0UL); } /** * @brief Check if the LPUART Parity Error Interrupt is enabled or disabled. * @rmtoll CR1 PEIE LL_LPUART_IsEnabledIT_PE * @param LPUARTx LPUART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_PE(USART_TypeDef *LPUARTx) { return ((READ_BIT(LPUARTx->CR1, USART_CR1_PEIE) == (USART_CR1_PEIE)) ? 1UL : 0UL); } /** * @brief Check if the LPUART Character Match Interrupt is enabled or disabled. * @rmtoll CR1 CMIE LL_LPUART_IsEnabledIT_CM * @param LPUARTx LPUART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_CM(USART_TypeDef *LPUARTx) { return ((READ_BIT(LPUARTx->CR1, USART_CR1_CMIE) == (USART_CR1_CMIE)) ? 1UL : 0UL); } /** * @brief Check if the LPUART TX FIFO Empty Interrupt is enabled or disabled * @rmtoll CR1 TXFEIE LL_LPUART_IsEnabledIT_TXFE * @param LPUARTx LPUART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_TXFE(USART_TypeDef *LPUARTx) { return ((READ_BIT(LPUARTx->CR1, USART_CR1_TXFEIE) == (USART_CR1_TXFEIE)) ? 1UL : 0UL); } /** * @brief Check if the LPUART RX FIFO Full Interrupt is enabled or disabled * @rmtoll CR1 RXFFIE LL_LPUART_IsEnabledIT_RXFF * @param LPUARTx LPUART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_RXFF(USART_TypeDef *LPUARTx) { return ((READ_BIT(LPUARTx->CR1, USART_CR1_RXFFIE) == (USART_CR1_RXFFIE)) ? 1UL : 0UL); } /** * @brief Check if the LPUART Error Interrupt is enabled or disabled. * @rmtoll CR3 EIE LL_LPUART_IsEnabledIT_ERROR * @param LPUARTx LPUART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_ERROR(USART_TypeDef *LPUARTx) { return ((READ_BIT(LPUARTx->CR3, USART_CR3_EIE) == (USART_CR3_EIE)) ? 1UL : 0UL); } /** * @brief Check if the LPUART CTS Interrupt is enabled or disabled. * @rmtoll CR3 CTSIE LL_LPUART_IsEnabledIT_CTS * @param LPUARTx LPUART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_CTS(USART_TypeDef *LPUARTx) { return ((READ_BIT(LPUARTx->CR3, USART_CR3_CTSIE) == (USART_CR3_CTSIE)) ? 1UL : 0UL); } /** * @brief Check if the LPUART Wake Up from Stop Mode Interrupt is enabled or disabled. * @rmtoll CR3 WUFIE LL_LPUART_IsEnabledIT_WKUP * @param LPUARTx LPUART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_WKUP(USART_TypeDef *LPUARTx) { return ((READ_BIT(LPUARTx->CR3, USART_CR3_WUFIE) == (USART_CR3_WUFIE)) ? 1UL : 0UL); } /** * @brief Check if LPUART TX FIFO Threshold Interrupt is enabled or disabled * @rmtoll CR3 TXFTIE LL_LPUART_IsEnabledIT_TXFT * @param LPUARTx LPUART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_TXFT(USART_TypeDef *LPUARTx) { return ((READ_BIT(LPUARTx->CR3, USART_CR3_TXFTIE) == (USART_CR3_TXFTIE)) ? 1UL : 0UL); } /** * @brief Check if LPUART RX FIFO Threshold Interrupt is enabled or disabled * @rmtoll CR3 RXFTIE LL_LPUART_IsEnabledIT_RXFT * @param LPUARTx LPUART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_RXFT(USART_TypeDef *LPUARTx) { return ((READ_BIT(LPUARTx->CR3, USART_CR3_RXFTIE) == (USART_CR3_RXFTIE)) ? 1UL : 0UL); } /** * @} */ /** @defgroup LPUART_LL_EF_DMA_Management DMA_Management * @{ */ /** * @brief Enable DMA Mode for reception * @rmtoll CR3 DMAR LL_LPUART_EnableDMAReq_RX * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_EnableDMAReq_RX(USART_TypeDef *LPUARTx) { SET_BIT(LPUARTx->CR3, USART_CR3_DMAR); } /** * @brief Disable DMA Mode for reception * @rmtoll CR3 DMAR LL_LPUART_DisableDMAReq_RX * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_DisableDMAReq_RX(USART_TypeDef *LPUARTx) { CLEAR_BIT(LPUARTx->CR3, USART_CR3_DMAR); } /** * @brief Check if DMA Mode is enabled for reception * @rmtoll CR3 DMAR LL_LPUART_IsEnabledDMAReq_RX * @param LPUARTx LPUART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_LPUART_IsEnabledDMAReq_RX(USART_TypeDef *LPUARTx) { return ((READ_BIT(LPUARTx->CR3, USART_CR3_DMAR) == (USART_CR3_DMAR)) ? 1UL : 0UL); } /** * @brief Enable DMA Mode for transmission * @rmtoll CR3 DMAT LL_LPUART_EnableDMAReq_TX * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_EnableDMAReq_TX(USART_TypeDef *LPUARTx) { SET_BIT(LPUARTx->CR3, USART_CR3_DMAT); } /** * @brief Disable DMA Mode for transmission * @rmtoll CR3 DMAT LL_LPUART_DisableDMAReq_TX * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_DisableDMAReq_TX(USART_TypeDef *LPUARTx) { CLEAR_BIT(LPUARTx->CR3, USART_CR3_DMAT); } /** * @brief Check if DMA Mode is enabled for transmission * @rmtoll CR3 DMAT LL_LPUART_IsEnabledDMAReq_TX * @param LPUARTx LPUART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_LPUART_IsEnabledDMAReq_TX(USART_TypeDef *LPUARTx) { return ((READ_BIT(LPUARTx->CR3, USART_CR3_DMAT) == (USART_CR3_DMAT)) ? 1UL : 0UL); } /** * @brief Enable DMA Disabling on Reception Error * @rmtoll CR3 DDRE LL_LPUART_EnableDMADeactOnRxErr * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_EnableDMADeactOnRxErr(USART_TypeDef *LPUARTx) { SET_BIT(LPUARTx->CR3, USART_CR3_DDRE); } /** * @brief Disable DMA Disabling on Reception Error * @rmtoll CR3 DDRE LL_LPUART_DisableDMADeactOnRxErr * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_DisableDMADeactOnRxErr(USART_TypeDef *LPUARTx) { CLEAR_BIT(LPUARTx->CR3, USART_CR3_DDRE); } /** * @brief Indicate if DMA Disabling on Reception Error is disabled * @rmtoll CR3 DDRE LL_LPUART_IsEnabledDMADeactOnRxErr * @param LPUARTx LPUART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_LPUART_IsEnabledDMADeactOnRxErr(USART_TypeDef *LPUARTx) { return ((READ_BIT(LPUARTx->CR3, USART_CR3_DDRE) == (USART_CR3_DDRE)) ? 1UL : 0UL); } /** * @brief Get the LPUART data register address used for DMA transfer * @rmtoll RDR RDR LL_LPUART_DMA_GetRegAddr\n * @rmtoll TDR TDR LL_LPUART_DMA_GetRegAddr * @param LPUARTx LPUART Instance * @param Direction This parameter can be one of the following values: * @arg @ref LL_LPUART_DMA_REG_DATA_TRANSMIT * @arg @ref LL_LPUART_DMA_REG_DATA_RECEIVE * @retval Address of data register */ __STATIC_INLINE uint32_t LL_LPUART_DMA_GetRegAddr(USART_TypeDef *LPUARTx, uint32_t Direction) { uint32_t data_reg_addr; if (Direction == LL_LPUART_DMA_REG_DATA_TRANSMIT) { /* return address of TDR register */ data_reg_addr = (uint32_t) &(LPUARTx->TDR); } else { /* return address of RDR register */ data_reg_addr = (uint32_t) &(LPUARTx->RDR); } return data_reg_addr; } /** * @} */ /** @defgroup LPUART_LL_EF_Data_Management Data_Management * @{ */ /** * @brief Read Receiver Data register (Receive Data value, 8 bits) * @rmtoll RDR RDR LL_LPUART_ReceiveData8 * @param LPUARTx LPUART Instance * @retval Time Value between Min_Data=0x00 and Max_Data=0xFF */ __STATIC_INLINE uint8_t LL_LPUART_ReceiveData8(USART_TypeDef *LPUARTx) { return (uint8_t)(READ_BIT(LPUARTx->RDR, USART_RDR_RDR) & 0xFFU); } /** * @brief Read Receiver Data register (Receive Data value, 9 bits) * @rmtoll RDR RDR LL_LPUART_ReceiveData9 * @param LPUARTx LPUART Instance * @retval Time Value between Min_Data=0x00 and Max_Data=0x1FF */ __STATIC_INLINE uint16_t LL_LPUART_ReceiveData9(USART_TypeDef *LPUARTx) { return (uint16_t)(READ_BIT(LPUARTx->RDR, USART_RDR_RDR)); } /** * @brief Write in Transmitter Data Register (Transmit Data value, 8 bits) * @rmtoll TDR TDR LL_LPUART_TransmitData8 * @param LPUARTx LPUART Instance * @param Value between Min_Data=0x00 and Max_Data=0xFF * @retval None */ __STATIC_INLINE void LL_LPUART_TransmitData8(USART_TypeDef *LPUARTx, uint8_t Value) { LPUARTx->TDR = Value; } /** * @brief Write in Transmitter Data Register (Transmit Data value, 9 bits) * @rmtoll TDR TDR LL_LPUART_TransmitData9 * @param LPUARTx LPUART Instance * @param Value between Min_Data=0x00 and Max_Data=0x1FF * @retval None */ __STATIC_INLINE void LL_LPUART_TransmitData9(USART_TypeDef *LPUARTx, uint16_t Value) { LPUARTx->TDR = Value & 0x1FFUL; } /** * @} */ /** @defgroup LPUART_LL_EF_Execution Execution * @{ */ /** * @brief Request Break sending * @rmtoll RQR SBKRQ LL_LPUART_RequestBreakSending * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_RequestBreakSending(USART_TypeDef *LPUARTx) { SET_BIT(LPUARTx->RQR, (uint16_t)USART_RQR_SBKRQ); } /** * @brief Put LPUART in mute mode and set the RWU flag * @rmtoll RQR MMRQ LL_LPUART_RequestEnterMuteMode * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_RequestEnterMuteMode(USART_TypeDef *LPUARTx) { SET_BIT(LPUARTx->RQR, (uint16_t)USART_RQR_MMRQ); } /** * @brief Request a Receive Data and FIFO flush * @note Allows to discard the received data without reading them, and avoid an overrun * condition. * @rmtoll RQR RXFRQ LL_LPUART_RequestRxDataFlush * @param LPUARTx LPUART Instance * @retval None */ __STATIC_INLINE void LL_LPUART_RequestRxDataFlush(USART_TypeDef *LPUARTx) { SET_BIT(LPUARTx->RQR, (uint16_t)USART_RQR_RXFRQ); } /** * @} */ #if defined(USE_FULL_LL_DRIVER) /** @defgroup LPUART_LL_EF_Init Initialization and de-initialization functions * @{ */ ErrorStatus LL_LPUART_DeInit(USART_TypeDef *LPUARTx); ErrorStatus LL_LPUART_Init(USART_TypeDef *LPUARTx, LL_LPUART_InitTypeDef *LPUART_InitStruct); void LL_LPUART_StructInit(LL_LPUART_InitTypeDef *LPUART_InitStruct); /** * @} */ #endif /* USE_FULL_LL_DRIVER */ /** * @} */ /** * @} */ #endif /* LPUART1 */ /** * @} */ #ifdef __cplusplus } #endif #endif /* STM32G4xx_LL_LPUART_H */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
polymurph/STM-Linux
stm32g474_blinky/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/src/all_tests.c
<reponame>polymurph/STM-Linux #include "jtest.h" #include "basic_math_test_group.h" #include "complex_math_test_group.h" #include "controller_test_group.h" #include "fast_math_test_group.h" #include "filtering_test_group.h" #include "matrix_test_group.h" #include "statistics_test_group.h" #include "support_test_group.h" #include "transform_test_group.h" #include "intrinsics_test_group.h" JTEST_DEFINE_GROUP(all_tests) { /* To skip a test, comment it out */ #if !defined(CUSTOMIZE_TESTS) || defined(ENABLE_BASICMATH_TESTS) JTEST_GROUP_CALL(basic_math_tests); #endif #if !defined(CUSTOMIZE_TESTS) || defined(ENABLE_COMPLEXMATH_TESTS) JTEST_GROUP_CALL(complex_math_tests); #endif #if !defined(CUSTOMIZE_TESTS) || defined(ENABLE_CONTROLLER_TESTS) JTEST_GROUP_CALL(controller_tests); #endif #if !defined(CUSTOMIZE_TESTS) || defined(ENABLE_FASTMATH_TESTS) JTEST_GROUP_CALL(fast_math_tests); #endif #if !defined(CUSTOMIZE_TESTS) || defined(ENABLE_FILTERING_TESTS) /* Biquad df2T_f32 will fail with Neon. The test must be updated. Neon implementation is requiring a different initialization. */ JTEST_GROUP_CALL(filtering_tests); #endif #if !defined(CUSTOMIZE_TESTS) || defined(ENABLE_MATRIX_TESTS) JTEST_GROUP_CALL(matrix_tests); #endif #if !defined(CUSTOMIZE_TESTS) || defined(ENABLE_STATISTICS_TESTS) JTEST_GROUP_CALL(statistics_tests); #endif() #if !defined(CUSTOMIZE_TESTS) || defined(ENABLE_SUPPORT_TESTS) JTEST_GROUP_CALL(support_tests); #endif #if !defined(CUSTOMIZE_TESTS) || defined(ENABLE_TRANSFORM_TESTS) JTEST_GROUP_CALL(transform_tests); #endif #if !defined(CUSTOMIZE_TESTS) || defined(ENABLE_INTRINSICS_TESTS) JTEST_GROUP_CALL(intrinsics_tests); #endif return; }
polymurph/STM-Linux
stm32g474_blinky/Drivers/CMSIS/DSP/Source/ControllerFunctions/arm_sin_cos_f32.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_sin_cos_f32.c * Description: Sine and Cosine calculation for floating-point values * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the License); you may * not use this file except in compliance with the License. * You may obtain a copy of the License at * * www.apache.org/licenses/LICENSE-2.0 * * 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. */ #include "arm_math.h" #include "arm_common_tables.h" /** @ingroup groupController */ /** @defgroup SinCos Sine Cosine Computes the trigonometric sine and cosine values using a combination of table lookup and linear interpolation. There are separate functions for Q31 and floating-point data types. The input to the floating-point version is in degrees while the fixed-point Q31 have a scaled input with the range [-1 0.9999] mapping to [-180 +180] degrees. The floating point function also allows values that are out of the usual range. When this happens, the function will take extra time to adjust the input value to the range of [-180 180]. The result is accurate to 5 digits after the decimal point. The implementation is based on table lookup using 360 values together with linear interpolation. The steps used are: -# Calculation of the nearest integer table index. -# Compute the fractional portion (fract) of the input. -# Fetch the value corresponding to \c index from sine table to \c y0 and also value from \c index+1 to \c y1. -# Sine value is computed as <code> *psinVal = y0 + (fract * (y1 - y0))</code>. -# Fetch the value corresponding to \c index from cosine table to \c y0 and also value from \c index+1 to \c y1. -# Cosine value is computed as <code> *pcosVal = y0 + (fract * (y1 - y0))</code>. */ /** @addtogroup SinCos @{ */ /** @brief Floating-point sin_cos function. @param[in] theta input value in degrees @param[out] pSinVal points to processed sine output @param[out] pCosVal points to processed cosine output @return none */ void arm_sin_cos_f32( float32_t theta, float32_t * pSinVal, float32_t * pCosVal) { float32_t fract, in; /* Temporary input, output variables */ uint16_t indexS, indexC; /* Index variable */ float32_t f1, f2, d1, d2; /* Two nearest output values */ float32_t Dn, Df; float32_t temp, findex; /* input x is in degrees */ /* Scale input, divide input by 360, for cosine add 0.25 (pi/2) to read sine table */ in = theta * 0.00277777777778f; if (in < 0.0f) { in = -in; } in = in - (int32_t)in; /* Calculate the nearest index */ findex = (float32_t)FAST_MATH_TABLE_SIZE * in; indexS = ((uint16_t)findex) & 0x1ff; indexC = (indexS + (FAST_MATH_TABLE_SIZE / 4)) & 0x1ff; /* Calculation of fractional value */ fract = findex - (float32_t) indexS; /* Read two nearest values of input value from the cos & sin tables */ f1 = sinTable_f32[indexC ]; f2 = sinTable_f32[indexC+1]; d1 = -sinTable_f32[indexS ]; d2 = -sinTable_f32[indexS+1]; temp = (1.0f - fract) * f1 + fract * f2; Dn = 0.0122718463030f; /* delta between the two points (fixed), in this case 2*pi/FAST_MATH_TABLE_SIZE */ Df = f2 - f1; /* delta between the values of the functions */ temp = Dn * (d1 + d2) - 2 * Df; temp = fract * temp + (3 * Df - (d2 + 2 * d1) * Dn); temp = fract * temp + d1 * Dn; /* Calculation of cosine value */ *pCosVal = fract * temp + f1; /* Read two nearest values of input value from the cos & sin tables */ f1 = sinTable_f32[indexS ]; f2 = sinTable_f32[indexS+1]; d1 = sinTable_f32[indexC ]; d2 = sinTable_f32[indexC+1]; temp = (1.0f - fract) * f1 + fract * f2; Df = f2 - f1; // delta between the values of the functions temp = Dn * (d1 + d2) - 2 * Df; temp = fract * temp + (3 * Df - (d2 + 2 * d1) * Dn); temp = fract * temp + d1 * Dn; /* Calculation of sine value */ *pSinVal = fract * temp + f1; if (theta < 0.0f) { *pSinVal = -*pSinVal; } } /** @} end of SinCos group */
polymurph/STM-Linux
stm32g474_blinky/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/inc/templates/test_templates.h
#ifndef _TEST_TEMPLATES_H_ #define _TEST_TEMPLATES_H_ /*--------------------------------------------------------------------------------*/ /* Includes */ /*--------------------------------------------------------------------------------*/ #include "template.h" #include <string.h> /* memcmp() */ #include <inttypes.h> /* PRIu32 */ #include "math_helper.h" /* arm_snr_f32() */ /*--------------------------------------------------------------------------------*/ /* Function Aliases for use in Templates. */ /*--------------------------------------------------------------------------------*/ #define ref_q31_t_to_float ref_q31_to_float #define ref_q15_t_to_float ref_q15_to_float #define ref_q7_t_to_float ref_q7_to_float #define ref_float_to_q31_t ref_float_to_q31 #define ref_float_to_q15_t ref_float_to_q15 #define ref_float_to_q7_t ref_float_to_q7 #define ref_float32_t_to_float ref_copy_f32 #define ref_float_to_float32_t ref_copy_f32 /*--------------------------------------------------------------------------------*/ /* Macros and Defines */ /*--------------------------------------------------------------------------------*/ /** * Call the function-under-test. */ #define TEST_CALL_FUT(fut, fut_args) \ JTEST_COUNT_CYCLES(TEMPLATE_CALL_FN(fut, fut_args)) /** * Call the reference-function. */ #define TEST_CALL_REF(ref, ref_args) \ TEMPLATE_CALL_FN(ref, ref_args) /** * Call the function-under-test and the reference-function. */ #define TEST_CALL_FUT_AND_REF(fut, fut_args, ref, ref_args) \ do { \ TEST_CALL_FUT(fut, fut_args); \ TEST_CALL_REF(ref, ref_args); \ } while (0) /** * This macro eats a variable number of arguments and evaluates to a null * statement. */ #define TEST_NULL_STATEMENT(...) (void) "TEST_NULL_STATEMENT" /** * A function name, Usable in any template where a fut or ref name is accepted, * that evaluates to a #TEST_NULL_STATEMENT(). */ #define TEST_NULL_FN TEST_NULL_STATEMENT /** * Assert that buffers A and B are byte-equivalent for a number of bytes. */ #define TEST_ASSERT_BUFFERS_EQUAL(buf_a, buf_b, bytes)\ do \ { \ if (memcmp(buf_a, buf_b, bytes) != 0) \ { \ return JTEST_TEST_FAILED; \ } \ } while (0) /** * Assert that the two entities are equal. */ #define TEST_ASSERT_EQUAL(a, b) \ do \ { \ if ((a) != (b)) \ { \ return JTEST_TEST_FAILED;\ } \ } while (0) /** * Convert elements to from src_type to float. */ #define TEST_CONVERT_TO_FLOAT(src_ptr, dst_ptr, block_size, src_type) \ do \ { \ ref_##src_type##_to_float( \ src_ptr, \ dst_ptr, \ block_size); \ } while (0) \ /** * Convert elements to from float to dst_type . */ #define TEST_CONVERT_FLOAT_TO(src_ptr, dst_ptr, block_size, dst_type) \ do \ { \ ref_float_to_##dst_type( \ src_ptr, \ dst_ptr, \ block_size); \ } while (0) \ /** * Assert that the SNR between a reference and test sample is above a given * threshold. */ #define TEST_ASSERT_SNR(ref_ptr, tst_ptr, block_size, threshold) \ do \ { \ float32_t snr = arm_snr_f32(ref_ptr, tst_ptr, block_size);\ if ( snr <= threshold) \ { \ JTEST_DUMP_STRF("SNR: %f\n", snr); \ return JTEST_TEST_FAILED; \ } \ } while (0) /** * Assert that the SNR between a reference and test sample is above a given * threshold. Special case for float64_t */ #define TEST_ASSERT_DBL_SNR(ref_ptr, tst_ptr, block_size, threshold)\ do \ { \ float64_t snr = arm_snr_f64(ref_ptr, tst_ptr, block_size); \ if ( snr <= threshold) \ { \ JTEST_DUMP_STRF("SNR: %f\n", snr); \ return JTEST_TEST_FAILED; \ } \ } while (0) /** * Compare test and reference elements by converting to float and * calculating an SNR. * * This macro is a merger of the #TEST_CONVERT_TO_FLOAT() and * #TEST_ASSERT_SNR() macros. */ #define TEST_CONVERT_AND_ASSERT_SNR(ref_dst_ptr, ref_src_ptr, \ tst_dst_ptr, tst_src_ptr, \ block_size, \ tst_src_type, \ threshold) \ do \ { \ TEST_CONVERT_TO_FLOAT(ref_src_ptr, \ ref_dst_ptr, \ block_size, \ tst_src_type); \ TEST_CONVERT_TO_FLOAT(tst_src_ptr, \ tst_dst_ptr, \ block_size, \ tst_src_type); \ TEST_ASSERT_SNR(ref_dst_ptr, \ tst_dst_ptr, \ block_size, \ threshold); \ } while (0) /** * Execute statements only if the combination of block size, function type * specifier, and input ARR_DESC_t are valid. * * @example An ARR_DESC_t that contains 64 bytes cant service a 32 element * block size if they are extracted in float32_t increments. * * 8 * 32 = 256 > 64. */ #define TEST_DO_VALID_BLOCKSIZE(block_size, fn_type_spec, \ input_arr_desc, body) \ do \ { \ if (block_size * sizeof(fn_type_spec) <= \ ARR_DESC_BYTES(input_arr_desc)) \ { \ JTEST_DUMP_STRF("Block Size: %"PRIu32"\n", block_size); \ body; \ } \ } while (0) \ /** * Template for tests that rely on one input buffer and a blocksize parameter. * * The buffer is an #ARR_DESC_t. It is iterated over and it's values are * passed to the function under test and reference functions through their * appropriate argument interfaces. The argument interfaces this template to * execute structurally similar functions. * */ #define TEST_TEMPLATE_BUF1_BLK(arr_desc_inputs, \ arr_desc_block_sizes, \ input_type, output_type, \ fut, fut_arg_interface, \ ref, ref_arg_interface, \ compare_interface) \ do \ { \ TEMPLATE_DO_ARR_DESC( \ input_idx, ARR_DESC_t *, input_ptr, arr_desc_inputs \ , \ TEMPLATE_DO_ARR_DESC( \ block_size_idx, uint32_t, block_size, arr_desc_block_sizes \ , \ void * input_data_ptr = input_ptr->data_ptr; \ \ TEST_DO_VALID_BLOCKSIZE( \ block_size, input_type, input_ptr \ , \ TEST_CALL_FUT_AND_REF( \ fut, fut_arg_interface( \ input_data_ptr, block_size), \ ref, ref_arg_interface( \ input_data_ptr, block_size)); \ \ compare_interface(block_size, output_type)))); \ \ return JTEST_TEST_PASSED; \ \ } while (0) /** * Template for tests that rely on an input buffer and an element. * * An element can is any thing which doesn't walk and talk like a * sequence. Examples include numbers, and structures. */ #define TEST_TEMPLATE_BUF1_ELT1(arr_desc_inputs, \ arr_desc_elts, \ input_type, elt_type, output_type, \ fut, fut_arg_interface, \ ref, ref_arg_interface, \ compare_interface) \ do \ { \ TEMPLATE_DO_ARR_DESC( \ input_idx, ARR_DESC_t *, input_ptr, arr_desc_inputs \ , \ TEMPLATE_DO_ARR_DESC( \ elt_idx, elt_type, elt, arr_desc_elts \ , \ void * input_data_ptr = input_ptr->data_ptr; \ TEST_CALL_FUT_AND_REF( \ fut, fut_arg_interface(input_data_ptr, elt), \ ref, ref_arg_interface(input_data_ptr, elt)); \ \ compare_interface(output_type))); \ return JTEST_TEST_PASSED; \ } while (0) /** * Template for tests that rely on an input buffer, an element, and a blocksize * parameter. */ #define TEST_TEMPLATE_BUF1_ELT1_BLK(arr_desc_inputs, \ arr_desc_elts, \ arr_desc_block_sizes, \ input_type, elt_type, output_type, \ fut, fut_arg_interface, \ ref, ref_arg_interface, \ compare_interface); \ do \ { \ TEMPLATE_DO_ARR_DESC( \ inut_idx, ARR_DESC_t *, input_ptr, arr_desc_inputs \ , \ TEMPLATE_DO_ARR_DESC( \ block_size_idx, uint32_t, block_size, \ arr_desc_block_sizes \ , \ TEMPLATE_DO_ARR_DESC( \ elt_idx, elt_type, elt, arr_desc_elts \ , \ void * input_data_ptr = input_ptr->data_ptr; \ TEST_DO_VALID_BLOCKSIZE( \ block_size, input_type, input_ptr, \ \ TEST_CALL_FUT_AND_REF( \ fut, fut_arg_interface( \ input_data_ptr, elt, block_size), \ ref, ref_arg_interface( \ input_data_ptr, elt, block_size)); \ compare_interface(block_size, output_type))))); \ return JTEST_TEST_PASSED; \ } while (0) /** * Template for tests that rely on an input buffer, two elements, and a blocksize * parameter. */ #define TEST_TEMPLATE_BUF1_ELT2_BLK(arr_desc_inputs, \ arr_desc_elt1s, \ arr_desc_elt2s, \ arr_desc_block_sizes, \ input_type, elt1_type, \ elt2_type, output_type, \ fut, fut_arg_interface, \ ref, ref_arg_interface, \ compare_interface) \ do \ { \ TEMPLATE_DO_ARR_DESC( \ inut_idx, ARR_DESC_t *, input_ptr, arr_desc_inputs \ , \ TEMPLATE_DO_ARR_DESC( \ block_size_idx, uint32_t, block_size, \ arr_desc_block_sizes \ , \ TEMPLATE_DO_ARR_DESC( \ elt1_idx, elt1_type, elt1, arr_desc_elt1s \ , \ TEMPLATE_DO_ARR_DESC( \ elt2_idx, elt2_type, elt2, arr_desc_elt2s \ , \ void * input_data_ptr = input_ptr->data_ptr; \ TEST_DO_VALID_BLOCKSIZE( \ block_size, input_type, input_ptr, \ TEST_CALL_FUT_AND_REF( \ fut, fut_arg_interface( \ input_data_ptr, elt1, elt2, block_size), \ ref, ref_arg_interface( \ input_data_ptr, elt1, elt2, block_size)); \ compare_interface(block_size, output_type)))))); \ return JTEST_TEST_PASSED; \ } while (0) /** * Template for tests that rely on two input buffers and a blocksize parameter. * * The two #ARR_DESC_t, input buffers are iterated through in parallel. The * length of the first #ARR_DESC_t determines the length of the iteration. */ #define TEST_TEMPLATE_BUF2_BLK(arr_desc_inputs_a, \ arr_desc_inputs_b, \ arr_desc_block_sizes, \ input_type, output_type, \ fut, fut_arg_interface, \ ref, ref_arg_interface, \ compare_interface) \ do \ { \ /* Iterate over two input arrays in parallel.*/ \ TEMPLATE_DO_ARR_DESC( \ input_idx, ARR_DESC_t *, input_ptr, arr_desc_inputs_a \ , \ TEMPLATE_DO_ARR_DESC( \ block_size_idx, uint32_t, block_size, arr_desc_block_sizes, \ void * input_a_ptr = input_ptr->data_ptr; \ void * input_b_ptr = ARR_DESC_ELT( \ ARR_DESC_t *, input_idx, \ &(arr_desc_inputs_b))->data_ptr; \ \ TEST_DO_VALID_BLOCKSIZE( \ block_size, input_type, input_ptr \ , \ TEST_CALL_FUT_AND_REF( \ fut, fut_arg_interface( \ input_a_ptr, input_b_ptr, block_size), \ ref, ref_arg_interface( \ input_a_ptr, input_b_ptr, block_size)); \ \ compare_interface(block_size, output_type)))); \ return JTEST_TEST_PASSED; \ } while (0) /** * Test template that uses a single element. */ #define TEST_TEMPLATE_ELT1(arr_desc_elts, \ elt_type, output_type, \ fut, fut_arg_interface, \ ref, ref_arg_interface, \ compare_interface) \ do \ { \ TEMPLATE_DO_ARR_DESC( \ elt_idx, elt_type, elt, arr_desc_elts \ , \ TEST_CALL_FUT_AND_REF( \ fut, fut_arg_interface( \ elt), \ ref, ref_arg_interface( \ elt)); \ /* Comparison interfaces typically accept */ \ /* a block_size. Pass a dummy value 1.*/ \ compare_interface(1, output_type)); \ return JTEST_TEST_PASSED; \ } while (0) /** * Test template that iterates over two sets of elements in parallel. * * The length of the first set determines the number of iteratsions. */ #define TEST_TEMPLATE_ELT2(arr_desc_elts_a, \ arr_desc_elts_b, \ elt_a_type, elt_b_type, output_type, \ fut, fut_arg_interface, \ ref, ref_arg_interface, \ compare_interface) \ do \ { \ TEMPLATE_DO_ARR_DESC( \ elt_a_idx, elt_a_type, elt_a, arr_desc_elts_a \ , \ elt_b_type * elt_b = ARR_DESC_ELT( \ elt_b_type, \ elt_a_idx, \ arr_desc_elts_b); \ \ TEST_CALL_FUT_AND_REF( \ fut, fut_arg_interface( \ elt_a, elt_b), \ ref, ref_arg_interface( \ elt_a, elt_b)); \ /* Comparison interfaces typically accept */ \ /* a block_size. Pass a dummy value 1.*/ \ compare_interface(1, output_type)); \ return JTEST_TEST_PASSED; \ } while (0) /** * Test template that uses an element and a block size. */ #define TEST_TEMPLATE_ELT1_BLK(arr_desc_elts, \ arr_desc_block_sizes, \ elt_type, output_type, \ fut, fut_arg_interface, \ ref, ref_arg_interface, \ compare_interface) \ do \ { \ TEMPLATE_DO_ARR_DESC( \ block_size_idx, uint32_t, block_size, \ arr_desc_block_sizes \ , \ TEMPLATE_DO_ARR_DESC( \ elt_idx, elt_type, elt, arr_desc_elts \ , \ JTEST_DUMP_STRF("Block Size: %d\n", \ (int)block_size); \ TEST_CALL_FUT_AND_REF( \ fut, fut_arg_interface( \ elt, block_size), \ ref, ref_arg_interface( \ elt, block_size)); \ compare_interface(block_size, output_type))); \ return JTEST_TEST_PASSED; \ } while (0) #endif /* _TEST_TEMPLATES_H_ */
polymurph/STM-Linux
stm32g474_blinky/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/RefLibs/src/SupportFunctions/SupportFunctions.c
<gh_stars>10-100 #include "copy.c" #include "fill.c" #include "fixed_to_fixed.c" #include "fixed_to_float.c" #include "float_to_fixed.c"
polymurph/STM-Linux
stm32g474_blinky/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/RefLibs/src/TransformFunctions/TransformFunctions.c
#include "cfft.c" #include "dct4.c" #include "rfft.c"
polymurph/STM-Linux
stm32g474_blinky/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/src/filtering_tests/filtering_test_group.c
<gh_stars>10-100 #include "jtest.h" #include "filtering_tests.h" JTEST_DEFINE_GROUP(filtering_tests) { /* To skip a test, comment it out. */ JTEST_GROUP_CALL(biquad_tests); JTEST_GROUP_CALL(conv_tests); JTEST_GROUP_CALL(correlate_tests); JTEST_GROUP_CALL(fir_tests); JTEST_GROUP_CALL(iir_tests); JTEST_GROUP_CALL(lms_tests); return; }
polymurph/STM-Linux
stm32g474_blinky/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/JTest/inc/jtest_cycle.h
#ifndef _JTEST_CYCLE_H_ #define _JTEST_CYCLE_H_ /*--------------------------------------------------------------------------------*/ /* Includes */ /*--------------------------------------------------------------------------------*/ #include "jtest_fw.h" /* JTEST_DUMP_STRF() */ #include "jtest_systick.h" #include "jtest_util.h" /* STR() */ /*--------------------------------------------------------------------------------*/ /* Declare Module Variables */ /*--------------------------------------------------------------------------------*/ extern const char * JTEST_CYCLE_STRF; /*--------------------------------------------------------------------------------*/ /* Macros and Defines */ /*--------------------------------------------------------------------------------*/ /** * Wrap the function call, fn_call, to count execution cycles and display the * results. */ /* skipp function name + param #define JTEST_COUNT_CYCLES(fn_call) \ do \ { \ uint32_t __jtest_cycle_end_count; \ \ JTEST_SYSTICK_RESET(SysTick); \ JTEST_SYSTICK_START(SysTick); \ \ fn_call; \ \ __jtest_cycle_end_count = \ JTEST_SYSTICK_VALUE(SysTick); \ \ JTEST_SYSTICK_RESET(SysTick); \ JTEST_DUMP_STRF(JTEST_CYCLE_STRF, \ STR(fn_call), \ (JTEST_SYSTICK_INITIAL_VALUE - \ __jtest_cycle_end_count)); \ } while (0) */ #ifndef ARMv7A #define JTEST_COUNT_CYCLES(fn_call) \ do \ { \ uint32_t __jtest_cycle_end_count; \ \ JTEST_SYSTICK_RESET(SysTick); \ JTEST_SYSTICK_START(SysTick); \ \ fn_call; \ \ __jtest_cycle_end_count = \ JTEST_SYSTICK_VALUE(SysTick); \ \ JTEST_SYSTICK_RESET(SysTick); \ JTEST_DUMP_STRF(JTEST_CYCLE_STRF, \ (JTEST_SYSTICK_INITIAL_VALUE - \ __jtest_cycle_end_count)); \ } while (0) #else /* TODO */ #define JTEST_COUNT_CYCLES(fn_call) \ do \ { \ fn_call; \ } while (0) #endif #endif /* _JTEST_CYCLE_H_ */
polymurph/STM-Linux
stm32g474_blinky/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/RefLibs/src/StatisticsFunctions/StatisticsFunctions.c
<gh_stars>10-100 #include "max.c" #include "mean.c" #include "min.c" #include "power.c" #include "rms.c" #include "std.c" #include "var.c"
polymurph/STM-Linux
stm32g474_blinky/Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_gpio_ex.h
<gh_stars>10-100 /** ****************************************************************************** * @file stm32g4xx_hal_gpio_ex.h * @author MCD Application Team * @brief Header file of GPIO HAL Extended module. ****************************************************************************** * @attention * * <h2><center>&copy; Copyright (c) 2019 STMicroelectronics. * All rights reserved.</center></h2> * * This software component is licensed by ST under BSD 3-Clause license, * the "License"; You may not use this file except in compliance with the * License. You may obtain a copy of the License at: * opensource.org/licenses/BSD-3-Clause * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef STM32G4xx_HAL_GPIO_EX_H #define STM32G4xx_HAL_GPIO_EX_H #ifdef __cplusplus extern "C" { #endif /* Includes ------------------------------------------------------------------*/ #include "stm32g4xx_hal_def.h" /** @addtogroup STM32G4xx_HAL_Driver * @{ */ /** @defgroup GPIOEx GPIOEx * @brief GPIO Extended HAL module driver * @{ */ /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /** @defgroup GPIOEx_Exported_Constants GPIOEx Exported Constants * @{ */ /** @defgroup GPIOEx_Alternate_function_selection GPIOEx Alternate function selection * @{ */ /** * @brief AF 0 selection */ #define GPIO_AF0_RTC_50Hz ((uint8_t)0x00) /* RTC_50Hz Alternate Function mapping */ #define GPIO_AF0_MCO ((uint8_t)0x00) /* MCO (MCO1 and MCO2) Alternate Function mapping */ #define GPIO_AF0_SWJ ((uint8_t)0x00) /* SWJ (SWD and JTAG) Alternate Function mapping */ #define GPIO_AF0_TRACE ((uint8_t)0x00) /* TRACE Alternate Function mapping */ /** * @brief AF 1 selection */ #define GPIO_AF1_TIM2 ((uint8_t)0x01) /* TIM2 Alternate Function mapping */ #if defined(TIM5) #define GPIO_AF1_TIM5 ((uint8_t)0x01) /* TIM5 Alternate Function mapping */ #endif /* TIM5 */ #define GPIO_AF1_TIM16 ((uint8_t)0x01) /* TIM16 Alternate Function mapping */ #define GPIO_AF1_TIM17 ((uint8_t)0x01) /* TIM17 Alternate Function mapping */ #define GPIO_AF1_TIM17_COMP1 ((uint8_t)0x01) /* TIM17/COMP1 Break in Alternate Function mapping */ #define GPIO_AF1_TIM15 ((uint8_t)0x01) /* TIM15 Alternate Function mapping */ #define GPIO_AF1_LPTIM1 ((uint8_t)0x01) /* LPTIM1 Alternate Function mapping */ #define GPIO_AF1_IR ((uint8_t)0x01) /* IR Alternate Function mapping */ /** * @brief AF 2 selection */ #define GPIO_AF2_TIM1 ((uint8_t)0x02) /* TIM1 Alternate Function mapping */ #define GPIO_AF2_TIM2 ((uint8_t)0x02) /* TIM2 Alternate Function mapping */ #define GPIO_AF2_TIM3 ((uint8_t)0x02) /* TIM3 Alternate Function mapping */ #define GPIO_AF2_TIM4 ((uint8_t)0x02) /* TIM4 Alternate Function mapping */ #if defined(TIM5) #define GPIO_AF2_TIM5 ((uint8_t)0x02) /* TIM5 Alternate Function mapping */ #endif /* TIM5 */ #define GPIO_AF2_TIM8 ((uint8_t)0x02) /* TIM8 Alternate Function mapping */ #define GPIO_AF2_TIM15 ((uint8_t)0x02) /* TIM15 Alternate Function mapping */ #define GPIO_AF2_TIM16 ((uint8_t)0x02) /* TIM16 Alternate Function mapping */ #if defined(TIM20) #define GPIO_AF2_TIM20 ((uint8_t)0x02) /* TIM20 Alternate Function mapping */ #endif /* TIM20 */ #define GPIO_AF2_TIM1_COMP1 ((uint8_t)0x02) /* TIM1/COMP1 Break in Alternate Function mapping */ #define GPIO_AF2_TIM15_COMP1 ((uint8_t)0x02) /* TIM15/COMP1 Break in Alternate Function mapping */ #define GPIO_AF2_TIM16_COMP1 ((uint8_t)0x02) /* TIM16/COMP1 Break in Alternate Function mapping */ #if defined(TIM20) #define GPIO_AF2_TIM20_COMP1 ((uint8_t)0x02) /* TIM20/COMP1 Break in Alternate Function mapping */ #define GPIO_AF2_TIM20_COMP2 ((uint8_t)0x02) /* TIM20/COMP2 Break in Alternate Function mapping */ #endif /* TIM20 */ #define GPIO_AF2_I2C3 ((uint8_t)0x02) /* I2C3 Alternate Function mapping */ #define GPIO_AF2_COMP1 ((uint8_t)0x02) /* COMP1 Alternate Function mapping */ /** * @brief AF 3 selection */ #define GPIO_AF3_TIM15 ((uint8_t)0x03) /* TIM15 Alternate Function mapping */ #if defined(TIM20) #define GPIO_AF3_TIM20 ((uint8_t)0x03) /* TIM20 Alternate Function mapping */ #endif /* TIM20 */ #define GPIO_AF3_UCPD1 ((uint8_t)0x03) /* UCPD1 Alternate Function mapping */ #define GPIO_AF3_I2C3 ((uint8_t)0x03) /* I2C3 Alternate Function mapping */ #if defined(I2C4) #define GPIO_AF3_I2C4 ((uint8_t)0x03) /* I2C4 Alternate Function mapping */ #endif /* I2C4 */ #if defined(HRTIM1) #define GPIO_AF3_HRTIM1 ((uint8_t)0x03) /* HRTIM1 Alternate Function mapping */ #endif /* HRTIM1 */ #if defined(QUADSPI) #define GPIO_AF3_QUADSPI ((uint8_t)0x03) /* QUADSPI Alternate Function mapping */ #endif /* QUADSPI */ #define GPIO_AF3_TIM8 ((uint8_t)0x03) /* TIM8 Alternate Function mapping */ #define GPIO_AF3_SAI1 ((uint8_t)0x03) /* SAI1 Alternate Function mapping */ #define GPIO_AF3_COMP3 ((uint8_t)0x03) /* COMP3 Alternate Function mapping */ /** * @brief AF 4 selection */ #define GPIO_AF4_TIM1 ((uint8_t)0x04) /* TIM1 Alternate Function mapping */ #define GPIO_AF4_TIM8 ((uint8_t)0x04) /* TIM8 Alternate Function mapping */ #define GPIO_AF4_TIM16 ((uint8_t)0x04) /* TIM16 Alternate Function mapping */ #define GPIO_AF4_TIM17 ((uint8_t)0x04) /* TIM17 Alternate Function mapping */ #define GPIO_AF4_TIM8_COMP1 ((uint8_t)0x04) /* TIM8/COMP1 Break in Alternate Function mapping */ #define GPIO_AF4_I2C1 ((uint8_t)0x04) /* I2C1 Alternate Function mapping */ #define GPIO_AF4_I2C2 ((uint8_t)0x04) /* I2C2 Alternate Function mapping */ #define GPIO_AF4_I2C3 ((uint8_t)0x04) /* I2C3 Alternate Function mapping */ #if defined(I2C4) #define GPIO_AF4_I2C4 ((uint8_t)0x04) /* I2C4 Alternate Function mapping */ #endif /* I2C4 */ /** * @brief AF 5 selection */ #define GPIO_AF5_SPI1 ((uint8_t)0x05) /* SPI1 Alternate Function mapping */ #define GPIO_AF5_SPI2 ((uint8_t)0x05) /* SPI2 Alternate Function mapping */ #if defined(SPI4) #define GPIO_AF5_SPI4 ((uint8_t)0x05) /* SPI4 Alternate Function mapping */ #endif /* SPI4 */ #define GPIO_AF5_IR ((uint8_t)0x05) /* IR Alternate Function mapping */ #define GPIO_AF5_TIM8 ((uint8_t)0x05) /* TIM8 Alternate Function mapping */ #define GPIO_AF5_TIM8_COMP1 ((uint8_t)0x05) /* TIM8/COMP1 Break in Alternate Function mapping */ #define GPIO_AF5_UART4 ((uint8_t)0x05) /* UART4 Alternate Function mapping */ #if defined(UART5) #define GPIO_AF5_UART5 ((uint8_t)0x05) /* UART5 Alternate Function mapping */ #endif /* UART5 */ #define GPIO_AF5_I2S2ext ((uint8_t)0x05) /* I2S2ext_SD Alternate Function mapping */ /** * @brief AF 6 selection */ #define GPIO_AF6_SPI2 ((uint8_t)0x06) /* SPI2 Alternate Function mapping */ #define GPIO_AF6_SPI3 ((uint8_t)0x06) /* SPI3 Alternate Function mapping */ #define GPIO_AF6_TIM1 ((uint8_t)0x06) /* TIM1 Alternate Function mapping */ #if defined(TIM5) #define GPIO_AF6_TIM5 ((uint8_t)0x06) /* TIM5 Alternate Function mapping */ #endif /* TIM5 */ #define GPIO_AF6_TIM8 ((uint8_t)0x06) /* TIM8 Alternate Function mapping */ #if defined(TIM20) #define GPIO_AF6_TIM20 ((uint8_t)0x06) /* TIM20 Alternate Function mapping */ #endif /* TIM20 */ #define GPIO_AF6_TIM1_COMP1 ((uint8_t)0x06) /* TIM1/COMP1 Break in Alternate Function mapping */ #define GPIO_AF6_TIM1_COMP2 ((uint8_t)0x06) /* TIM1/COMP2 Break in Alternate Function mapping */ #define GPIO_AF6_TIM8_COMP2 ((uint8_t)0x06) /* TIM8/COMP2 Break in Alternate Function mapping */ #define GPIO_AF6_IR ((uint8_t)0x06) /* IR Alternate Function mapping */ #define GPIO_AF6_I2S3ext ((uint8_t)0x06) /* I2S3ext_SD Alternate Function mapping */ /** * @brief AF 7 selection */ #define GPIO_AF7_USART1 ((uint8_t)0x07) /* USART1 Alternate Function mapping */ #define GPIO_AF7_USART2 ((uint8_t)0x07) /* USART2 Alternate Function mapping */ #define GPIO_AF7_USART3 ((uint8_t)0x07) /* USART3 Alternate Function mapping */ #if defined(COMP5) #define GPIO_AF7_COMP5 ((uint8_t)0x07) /* COMP5 Alternate Function mapping */ #endif /* COMP5 */ #if defined(COMP6) #define GPIO_AF7_COMP6 ((uint8_t)0x07) /* COMP6 Alternate Function mapping */ #endif /* COMP6 */ #if defined(COMP7) #define GPIO_AF7_COMP7 ((uint8_t)0x07) /* COMP7 Alternate Function mapping */ #endif /* COMP7 */ /** * @brief AF 8 selection */ #define GPIO_AF8_COMP1 ((uint8_t)0x08) /* COMP1 Alternate Function mapping */ #define GPIO_AF8_COMP2 ((uint8_t)0x08) /* COMP2 Alternate Function mapping */ #define GPIO_AF8_COMP3 ((uint8_t)0x08) /* COMP3 Alternate Function mapping */ #define GPIO_AF8_COMP4 ((uint8_t)0x08) /* COMP4 Alternate Function mapping */ #if defined(COMP5) #define GPIO_AF8_COMP5 ((uint8_t)0x08) /* COMP5 Alternate Function mapping */ #endif /* COMP5 */ #if defined(COMP6) #define GPIO_AF8_COMP6 ((uint8_t)0x08) /* COMP6 Alternate Function mapping */ #endif /* COMP6 */ #if defined(COMP7) #define GPIO_AF8_COMP7 ((uint8_t)0x08) /* COMP7 Alternate Function mapping */ #endif /* COMP7 */ #define GPIO_AF8_I2C3 ((uint8_t)0x08) /* I2C3 Alternate Function mapping */ #if defined(I2C4) #define GPIO_AF8_I2C4 ((uint8_t)0x08) /* I2C4 Alternate Function mapping */ #endif /* I2C4 */ #define GPIO_AF8_LPUART1 ((uint8_t)0x08) /* LPUART1 Alternate Function mapping */ #define GPIO_AF8_UART4 ((uint8_t)0x08) /* UART4 Alternate Function mapping */ #if defined(UART5) #define GPIO_AF8_UART5 ((uint8_t)0x08) /* UART5 Alternate Function mapping */ #endif /* UART5 */ /** * @brief AF 9 selection */ #define GPIO_AF9_TIM1 ((uint8_t)0x09) /* TIM1 Alternate Function mapping */ #define GPIO_AF9_TIM8 ((uint8_t)0x09) /* TIM8 Alternate Function mapping */ #define GPIO_AF9_TIM15 ((uint8_t)0x09) /* TIM15 Alternate Function mapping */ #define GPIO_AF9_TIM1_COMP1 ((uint8_t)0x09) /* TIM1/COMP1 Break in Alternate Function mapping */ #define GPIO_AF9_TIM8_COMP1 ((uint8_t)0x09) /* TIM8/COMP1 Break in Alternate Function mapping */ #define GPIO_AF9_TIM15_COMP1 ((uint8_t)0x09) /* TIM15/COMP1 Break in Alternate Function mapping */ #define GPIO_AF9_FDCAN1 ((uint8_t)0x09) /* FDCAN1 Alternate Function mapping */ #if defined(FDCAN2) #define GPIO_AF9_FDCAN2 ((uint8_t)0x09) /* FDCAN2 Alternate Function mapping */ #endif /* FDCAN2 */ /** * @brief AF 10 selection */ #define GPIO_AF10_TIM2 ((uint8_t)0x0A) /* TIM2 Alternate Function mapping */ #define GPIO_AF10_TIM3 ((uint8_t)0x0A) /* TIM3 Alternate Function mapping */ #define GPIO_AF10_TIM4 ((uint8_t)0x0A) /* TIM4 Alternate Function mapping */ #define GPIO_AF10_TIM8 ((uint8_t)0x0A) /* TIM8 Alternate Function mapping */ #define GPIO_AF10_TIM17 ((uint8_t)0x0A) /* TIM17 Alternate Function mapping */ #define GPIO_AF10_TIM8_COMP2 ((uint8_t)0x0A) /* TIM8/COMP2 Break in Alternate Function mapping */ #define GPIO_AF10_TIM17_COMP1 ((uint8_t)0x0A) /* TIM17/COMP1 Break in Alternate Function mapping */ #if defined(QUADSPI) #define GPIO_AF10_QUADSPI ((uint8_t)0x0A) /* OctoSPI Manager Port 1 Alternate Function mapping */ #endif /* QUADSPI */ /** * @brief AF 11 selection */ #define GPIO_AF11_FDCAN1 ((uint8_t)0x0B) /* FDCAN1 Alternate Function mapping */ #if defined(FDCAN3) #define GPIO_AF11_FDCAN3 ((uint8_t)0x0B) /* FDCAN3 Alternate Function mapping */ #endif /* FDCAN3 */ #define GPIO_AF11_TIM1 ((uint8_t)0x0B) /* TIM1 Alternate Function mapping */ #define GPIO_AF11_TIM8 ((uint8_t)0x0B) /* TIM8 Alternate Function mapping */ #define GPIO_AF11_TIM8_COMP1 ((uint8_t)0x0B) /* TIM8/COMP1 Break in Alternate Function mapping */ #define GPIO_AF11_LPTIM1 ((uint8_t)0x0B) /* LPTIM1 Alternate Function mapping */ /** * @brief AF 12 selection */ #define GPIO_AF12_LPUART1 ((uint8_t)0x0C) /* LPUART1 Alternate Function mapping */ #define GPIO_AF12_TIM1 ((uint8_t)0x0C) /* TIM1 Alternate Function mapping */ #define GPIO_AF12_TIM1_COMP1 ((uint8_t)0x0C) /* TIM1/COMP1 Break in Alternate Function mapping */ #define GPIO_AF12_TIM1_COMP2 ((uint8_t)0x0C) /* TIM1/COMP2 Break in Alternate Function mapping */ #if defined(HRTIM1) #define GPIO_AF12_HRTIM1 ((uint8_t)0x0C) /* HRTIM1 Alternate Function mapping */ #endif /* HRTIM1 */ #if defined(FMC_BANK1) #define GPIO_AF12_FMC ((uint8_t)0x0C) /* FMC Alternate Function mapping */ #endif /* FMC_BANK1 */ #define GPIO_AF12_SAI1 ((uint8_t)0x0C) /* SAI1 Alternate Function mapping */ /** * @brief AF 13 selection */ #if defined(HRTIM1) #define GPIO_AF13_HRTIM1 ((uint8_t)0x0D) /* HRTIM1 Alternate Function mapping */ #endif /* HRTIM1 */ #define GPIO_AF13_SAI1 ((uint8_t)0x0D) /* SAI1 Alternate Function mapping */ /** * @brief AF 14 selection */ #define GPIO_AF14_TIM2 ((uint8_t)0x0E) /* TIM2 Alternate Function mapping */ #define GPIO_AF14_TIM15 ((uint8_t)0x0E) /* TIM15 Alternate Function mapping */ #define GPIO_AF14_UCPD1 ((uint8_t)0x0E) /* UCPD1 Alternate Function mapping */ #define GPIO_AF14_SAI1 ((uint8_t)0x0E) /* SAI1 Alternate Function mapping */ #define GPIO_AF14_UART4 ((uint8_t)0x0E) /* UART4 Alternate Function mapping */ #if defined(UART5) #define GPIO_AF14_UART5 ((uint8_t)0x0E) /* UART5 Alternate Function mapping */ #endif /* UART5 */ /** * @brief AF 15 selection */ #define GPIO_AF15_EVENTOUT ((uint8_t)0x0F) /* EVENTOUT Alternate Function mapping */ #define IS_GPIO_AF(AF) ((AF) <= (uint8_t)0x0F) /** * @} */ /** * @} */ /* Exported macro ------------------------------------------------------------*/ /** @defgroup GPIOEx_Exported_Macros GPIOEx Exported Macros * @{ */ /** @defgroup GPIOEx_Get_Port_Index GPIOEx Get Port Index * @{ */ #define GPIO_GET_INDEX(__GPIOx__) (((__GPIOx__) == (GPIOA))? 0UL :\ ((__GPIOx__) == (GPIOB))? 1UL :\ ((__GPIOx__) == (GPIOC))? 2UL :\ ((__GPIOx__) == (GPIOD))? 3UL :\ ((__GPIOx__) == (GPIOE))? 4UL :\ ((__GPIOx__) == (GPIOF))? 5UL : 6UL) /** * @} */ /** * @} */ /* Exported functions --------------------------------------------------------*/ /** * @} */ /** * @} */ #ifdef __cplusplus } #endif #endif /* STM32G4xx_HAL_GPIO_EX_H */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
polymurph/STM-Linux
stm32g474_blinky/Drivers/CMSIS/DSP/Examples/ARM/boot/RTE_Components.h
<reponame>polymurph/STM-Linux #ifndef RTE_COMPONENTS_H #define RTE_COMPONENTS_H #endif /* RTE_COMPONENTS_H */
polymurph/STM-Linux
stm32g474_blinky/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/RefLibs/src/Intrinsics/Intrinsics_.c
<gh_stars>10-100 #include "intrinsics.c"
polymurph/STM-Linux
stm32g474_blinky/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_opamp_ex.c
<gh_stars>10-100 /** ****************************************************************************** * @file stm32g4xx_hal_opamp_ex.c * @author MCD Application Team * @brief Extended OPAMP HAL module driver. * * This file provides firmware functions to manage the following * functionalities of the operational amplifiers (OPAMP1...OPAMP6) * peripheral: * + Extended Initialization and de-initialization functions * + Extended Peripheral Control functions * @verbatim ****************************************************************************** * @attention * * <h2><center>&copy; Copyright (c) 2019 STMicroelectronics. * All rights reserved.</center></h2> * * This software component is licensed by ST under BSD 3-Clause license, * the "License"; You may not use this file except in compliance with the * License. You may obtain a copy of the License at: * opensource.org/licenses/BSD-3-Clause * ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include "stm32g4xx_hal.h" /** @addtogroup STM32G4xx_HAL_Driver * @{ */ #ifdef HAL_OPAMP_MODULE_ENABLED /** @defgroup OPAMPEx OPAMPEx * @brief OPAMP Extended HAL module driver * @{ */ /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ /* Exported functions --------------------------------------------------------*/ /** @defgroup OPAMPEx_Exported_Functions OPAMP Extended Exported Functions * @{ */ /** @defgroup OPAMPEx_Exported_Functions_Group1 Extended Input and Output operation functions * @brief Extended Self calibration functions * @verbatim =============================================================================== ##### Extended IO operation functions ##### =============================================================================== [..] (+) OPAMP Self calibration. @endverbatim * @{ */ /** * @brief Run the self calibration of up to 6 OPAMPs in parallel. * @note Calibration is performed in the mode specified in OPAMP init * structure (mode normal or high-speed). * @param hopamp1 handle * @param hopamp2 handle * @param hopamp3 handle * @param hopamp4 handle (1) * @param hopamp5 handle (1) * @param hopamp6 handle (1) * (1) Parameter not present on STM32GBK1CB/STM32G431xx/STM32G441xx/STM32G471xx devices. * @retval HAL status * @note Updated offset trimming values (PMOS & NMOS), user trimming is enabled * @note Calibration runs about 25 ms. */ #if defined(STM32G473xx) || defined(STM32G474xx) || defined(STM32G483xx) || defined(STM32G484xx) HAL_StatusTypeDef HAL_OPAMPEx_SelfCalibrateAll(OPAMP_HandleTypeDef *hopamp1, OPAMP_HandleTypeDef *hopamp2, OPAMP_HandleTypeDef *hopamp3, OPAMP_HandleTypeDef *hopamp4, OPAMP_HandleTypeDef *hopamp5, OPAMP_HandleTypeDef *hopamp6) #elif defined(STM32GBK1CB) || defined(STM32G431xx) || defined(STM32G441xx) || defined(STM32G471xx) HAL_StatusTypeDef HAL_OPAMPEx_SelfCalibrateAll(OPAMP_HandleTypeDef *hopamp1, OPAMP_HandleTypeDef *hopamp2, OPAMP_HandleTypeDef *hopamp3) #elif defined(STM32G491xx) || defined(STM32G4A1xx) HAL_StatusTypeDef HAL_OPAMPEx_SelfCalibrateAll(OPAMP_HandleTypeDef *hopamp1, OPAMP_HandleTypeDef *hopamp2, OPAMP_HandleTypeDef *hopamp3, OPAMP_HandleTypeDef *hopamp6) #endif { uint32_t trimmingvaluen1; uint32_t trimmingvaluep1; uint32_t trimmingvaluen2; uint32_t trimmingvaluep2; uint32_t trimmingvaluen3; uint32_t trimmingvaluep3; #if defined(STM32G473xx) || defined(STM32G474xx) || defined(STM32G483xx) || defined(STM32G483xx) uint32_t trimmingvaluen4; uint32_t trimmingvaluep4; uint32_t trimmingvaluen5; uint32_t trimmingvaluep5; uint32_t trimmingvaluen6; uint32_t trimmingvaluep6; #elif defined(STM32G491xx) || defined(STM32G4A1xx) uint32_t trimmingvaluen6; uint32_t trimmingvaluep6; #endif uint32_t delta; if ((hopamp1 == NULL) || (hopamp2 == NULL) || (hopamp3 == NULL) #if defined(STM32G473xx) || defined(STM32G474xx) || defined(STM32G483xx) || defined(STM32G483xx) || (hopamp4 == NULL) || (hopamp5 == NULL) || (hopamp6 == NULL) #elif defined(STM32G491xx) || defined(STM32G4A1xx) || (hopamp6 == NULL) #endif ) { return HAL_ERROR; } else if (hopamp1->State != HAL_OPAMP_STATE_READY) { return HAL_ERROR; } else if (hopamp2->State != HAL_OPAMP_STATE_READY) { return HAL_ERROR; } else if (hopamp3->State != HAL_OPAMP_STATE_READY) { return HAL_ERROR; } #if defined(STM32G473xx) || defined(STM32G474xx) || defined(STM32G483xx) || defined(STM32G483xx) else if (hopamp4->State != HAL_OPAMP_STATE_READY) { return HAL_ERROR; } else if (hopamp5->State != HAL_OPAMP_STATE_READY) { return HAL_ERROR; } else if (hopamp6->State != HAL_OPAMP_STATE_READY) { return HAL_ERROR; } #elif defined(STM32G491xx) || defined(STM32G4A1xx) else if (hopamp6->State != HAL_OPAMP_STATE_READY) { return HAL_ERROR; } #endif else { /* Check the parameter */ assert_param(IS_OPAMP_ALL_INSTANCE(hopamp1->Instance)); assert_param(IS_OPAMP_ALL_INSTANCE(hopamp2->Instance)); assert_param(IS_OPAMP_ALL_INSTANCE(hopamp3->Instance)); #if defined(STM32G473xx) || defined(STM32G474xx) || defined(STM32G483xx) || defined(STM32G483xx) assert_param(IS_OPAMP_ALL_INSTANCE(hopamp4->Instance)); assert_param(IS_OPAMP_ALL_INSTANCE(hopamp5->Instance)); assert_param(IS_OPAMP_ALL_INSTANCE(hopamp6->Instance)); #elif defined(STM32G491xx) || defined(STM32G4A1xx) assert_param(IS_OPAMP_ALL_INSTANCE(hopamp6->Instance)); #endif /* Set Calibration mode */ /* Non-inverting input connected to calibration reference voltage. */ SET_BIT(hopamp1->Instance->CSR, OPAMP_CSR_FORCEVP); SET_BIT(hopamp2->Instance->CSR, OPAMP_CSR_FORCEVP); SET_BIT(hopamp3->Instance->CSR, OPAMP_CSR_FORCEVP); #if defined(STM32G473xx) || defined(STM32G474xx) || defined(STM32G483xx) || defined(STM32G483xx) SET_BIT(hopamp4->Instance->CSR, OPAMP_CSR_FORCEVP); SET_BIT(hopamp5->Instance->CSR, OPAMP_CSR_FORCEVP); SET_BIT(hopamp6->Instance->CSR, OPAMP_CSR_FORCEVP); #elif defined(STM32G491xx) || defined(STM32G4A1xx) SET_BIT(hopamp6->Instance->CSR, OPAMP_CSR_FORCEVP); #endif /* user trimming values are used for offset calibration */ SET_BIT(hopamp1->Instance->CSR, OPAMP_CSR_USERTRIM); SET_BIT(hopamp2->Instance->CSR, OPAMP_CSR_USERTRIM); SET_BIT(hopamp3->Instance->CSR, OPAMP_CSR_USERTRIM); #if defined(STM32G473xx) || defined(STM32G474xx) || defined(STM32G483xx) || defined(STM32G483xx) SET_BIT(hopamp4->Instance->CSR, OPAMP_CSR_USERTRIM); SET_BIT(hopamp5->Instance->CSR, OPAMP_CSR_USERTRIM); SET_BIT(hopamp6->Instance->CSR, OPAMP_CSR_USERTRIM); #elif defined(STM32G491xx) || defined(STM32G4A1xx) SET_BIT(hopamp6->Instance->CSR, OPAMP_CSR_USERTRIM); #endif /* Enable calibration */ SET_BIT(hopamp1->Instance->CSR, OPAMP_CSR_CALON); SET_BIT(hopamp2->Instance->CSR, OPAMP_CSR_CALON); SET_BIT(hopamp3->Instance->CSR, OPAMP_CSR_CALON); #if defined(STM32G473xx) || defined(STM32G474xx) || defined(STM32G483xx) || defined(STM32G483xx) SET_BIT(hopamp4->Instance->CSR, OPAMP_CSR_CALON); SET_BIT(hopamp5->Instance->CSR, OPAMP_CSR_CALON); SET_BIT(hopamp6->Instance->CSR, OPAMP_CSR_CALON); #elif defined(STM32G491xx) || defined(STM32G4A1xx) SET_BIT(hopamp6->Instance->CSR, OPAMP_CSR_CALON); #endif /* 1st calibration - N */ /* Select 90% VREF */ MODIFY_REG(hopamp1->Instance->CSR, OPAMP_CSR_CALSEL, OPAMP_VREF_90VDDA); MODIFY_REG(hopamp2->Instance->CSR, OPAMP_CSR_CALSEL, OPAMP_VREF_90VDDA); MODIFY_REG(hopamp3->Instance->CSR, OPAMP_CSR_CALSEL, OPAMP_VREF_90VDDA); #if defined(STM32G473xx) || defined(STM32G474xx) || defined(STM32G483xx) || defined(STM32G483xx) MODIFY_REG(hopamp4->Instance->CSR, OPAMP_CSR_CALSEL, OPAMP_VREF_90VDDA); MODIFY_REG(hopamp5->Instance->CSR, OPAMP_CSR_CALSEL, OPAMP_VREF_90VDDA); MODIFY_REG(hopamp6->Instance->CSR, OPAMP_CSR_CALSEL, OPAMP_VREF_90VDDA); #elif defined(STM32G491xx) || defined(STM32G4A1xx) MODIFY_REG(hopamp6->Instance->CSR, OPAMP_CSR_CALSEL, OPAMP_VREF_90VDDA); #endif /* Enable the opamps */ SET_BIT(hopamp1->Instance->CSR, OPAMP_CSR_OPAMPxEN); SET_BIT(hopamp2->Instance->CSR, OPAMP_CSR_OPAMPxEN); SET_BIT(hopamp3->Instance->CSR, OPAMP_CSR_OPAMPxEN); #if defined(STM32G473xx) || defined(STM32G474xx) || defined(STM32G483xx) || defined(STM32G483xx) SET_BIT(hopamp4->Instance->CSR, OPAMP_CSR_OPAMPxEN); SET_BIT(hopamp5->Instance->CSR, OPAMP_CSR_OPAMPxEN); SET_BIT(hopamp6->Instance->CSR, OPAMP_CSR_OPAMPxEN); #elif defined(STM32G491xx) || defined(STM32G4A1xx) SET_BIT(hopamp6->Instance->CSR, OPAMP_CSR_OPAMPxEN); #endif /* Init trimming counter */ /* Medium value */ trimmingvaluen1 = 16UL; trimmingvaluen2 = 16UL; trimmingvaluen3 = 16UL; #if defined(STM32G473xx) || defined(STM32G474xx) || defined(STM32G483xx) || defined(STM32G483xx) trimmingvaluen4 = 16UL; trimmingvaluen5 = 16UL; trimmingvaluen6 = 16UL; #elif defined(STM32G491xx) || defined(STM32G4A1xx) trimmingvaluen6 = 16UL; #endif delta = 8UL; while (delta != 0UL) { /* Set candidate trimming */ MODIFY_REG(hopamp1->Instance->CSR, OPAMP_CSR_TRIMOFFSETN, trimmingvaluen1 << OPAMP_INPUT_INVERTING); MODIFY_REG(hopamp2->Instance->CSR, OPAMP_CSR_TRIMOFFSETN, trimmingvaluen2 << OPAMP_INPUT_INVERTING); MODIFY_REG(hopamp3->Instance->CSR, OPAMP_CSR_TRIMOFFSETN, trimmingvaluen3 << OPAMP_INPUT_INVERTING); #if defined(STM32G473xx) || defined(STM32G474xx) || defined(STM32G483xx) || defined(STM32G483xx) MODIFY_REG(hopamp4->Instance->CSR, OPAMP_CSR_TRIMOFFSETN, trimmingvaluen4 << OPAMP_INPUT_INVERTING); MODIFY_REG(hopamp5->Instance->CSR, OPAMP_CSR_TRIMOFFSETN, trimmingvaluen5 << OPAMP_INPUT_INVERTING); MODIFY_REG(hopamp6->Instance->CSR, OPAMP_CSR_TRIMOFFSETN, trimmingvaluen6 << OPAMP_INPUT_INVERTING); #elif defined(STM32G491xx) || defined(STM32G4A1xx) MODIFY_REG(hopamp6->Instance->CSR, OPAMP_CSR_TRIMOFFSETN, trimmingvaluen6 << OPAMP_INPUT_INVERTING); #endif /* OFFTRIMmax delay 2 ms as per datasheet (electrical characteristics */ /* Offset trim time: during calibration, minimum time needed between */ /* two steps to have 1 mV accuracy */ HAL_Delay(2); if ((hopamp1->Instance->CSR & OPAMP_CSR_OUTCAL) != 0UL) { /* OPAMP_CSR_OUTCAL is HIGH try higher trimming */ trimmingvaluen1 += delta; } else { /* OPAMP_CSR_OUTCAL is LOW try lower trimming */ trimmingvaluen1 -= delta; } if ((hopamp2->Instance->CSR & OPAMP_CSR_OUTCAL) != 0UL) { /* OPAMP_CSR_OUTCAL is HIGH try higher trimming */ trimmingvaluen2 += delta; } else { /* OPAMP_CSR_OUTCAL is LOW try lower trimming */ trimmingvaluen2 -= delta; } if ((hopamp3->Instance->CSR & OPAMP_CSR_OUTCAL) != 0UL) { /* OPAMP_CSR_OUTCAL is HIGH try higher trimming */ trimmingvaluen3 += delta; } else { /* OPAMP_CSR_OUTCAL is LOW try lower trimming */ trimmingvaluen3 -= delta; } #if defined(STM32G473xx) || defined(STM32G474xx) || defined(STM32G483xx) || defined(STM32G483xx) if ((hopamp4->Instance->CSR & OPAMP_CSR_OUTCAL) != 0UL) { /* OPAMP_CSR_OUTCAL is HIGH try higher trimming */ trimmingvaluen4 += delta; } else { /* OPAMP_CSR_OUTCAL is LOW try lower trimming */ trimmingvaluen4 -= delta; } if ((hopamp5->Instance->CSR & OPAMP_CSR_OUTCAL) != 0UL) { /* OPAMP_CSR_OUTCAL is HIGH try higher trimming */ trimmingvaluen5 += delta; } else { /* OPAMP_CSR_OUTCAL is LOW try lower trimming */ trimmingvaluen5 -= delta; } if ((hopamp6->Instance->CSR & OPAMP_CSR_OUTCAL) != 0UL) { /* OPAMP_CSR_OUTCAL is HIGH try higher trimming */ trimmingvaluen6 += delta; } else { /* OPAMP_CSR_OUTCAL is LOW try lower trimming */ trimmingvaluen6 -= delta; } #elif defined(STM32G491xx) || defined(STM32G4A1xx) if ((hopamp6->Instance->CSR & OPAMP_CSR_OUTCAL) != 0UL) { /* OPAMP_CSR_OUTCAL is HIGH try higher trimming */ trimmingvaluen6 += delta; } else { /* OPAMP_CSR_OUTCAL is LOW try lower trimming */ trimmingvaluen6 -= delta; } #endif delta >>= 1; } /* Still need to check if righ calibration is current value or un step below */ /* Indeed the first value that causes the OUTCAL bit to change from 1 to 0 */ MODIFY_REG(hopamp1->Instance->CSR, OPAMP_CSR_TRIMOFFSETN, trimmingvaluen1 << OPAMP_INPUT_INVERTING); MODIFY_REG(hopamp2->Instance->CSR, OPAMP_CSR_TRIMOFFSETN, trimmingvaluen2 << OPAMP_INPUT_INVERTING); MODIFY_REG(hopamp3->Instance->CSR, OPAMP_CSR_TRIMOFFSETN, trimmingvaluen3 << OPAMP_INPUT_INVERTING); #if defined(STM32G473xx) || defined(STM32G474xx) || defined(STM32G483xx) || defined(STM32G483xx) MODIFY_REG(hopamp4->Instance->CSR, OPAMP_CSR_TRIMOFFSETN, trimmingvaluen4 << OPAMP_INPUT_INVERTING); MODIFY_REG(hopamp5->Instance->CSR, OPAMP_CSR_TRIMOFFSETN, trimmingvaluen5 << OPAMP_INPUT_INVERTING); MODIFY_REG(hopamp6->Instance->CSR, OPAMP_CSR_TRIMOFFSETN, trimmingvaluen6 << OPAMP_INPUT_INVERTING); #elif defined(STM32G491xx) || defined(STM32G4A1xx) MODIFY_REG(hopamp6->Instance->CSR, OPAMP_CSR_TRIMOFFSETN, trimmingvaluen6 << OPAMP_INPUT_INVERTING); #endif /* OFFTRIMmax delay 2 ms as per datasheet (electrical characteristics */ /* Offset trim time: during calibration, minimum time needed between */ /* two steps to have 1 mV accuracy */ HAL_Delay(2); if ((hopamp1->Instance->CSR & OPAMP_CSR_OUTCAL) != 0UL) { /* OPAMP_CSR_OUTCAL is actually one value more */ trimmingvaluen1++; /* Set right trimming */ MODIFY_REG(hopamp1->Instance->CSR, OPAMP_CSR_TRIMOFFSETN, trimmingvaluen1 << OPAMP_INPUT_INVERTING); } if ((hopamp2->Instance->CSR & OPAMP_CSR_OUTCAL) != 0UL) { /* OPAMP_CSR_OUTCAL is actually one value more */ trimmingvaluen2++; /* Set right trimming */ MODIFY_REG(hopamp2->Instance->CSR, OPAMP_CSR_TRIMOFFSETN, trimmingvaluen2 << OPAMP_INPUT_INVERTING); } if ((hopamp3->Instance->CSR & OPAMP_CSR_OUTCAL) != 0UL) { /* OPAMP_CSR_OUTCAL is actually one value more */ trimmingvaluen3++; /* Set right trimming */ MODIFY_REG(hopamp3->Instance->CSR, OPAMP_CSR_TRIMOFFSETN, trimmingvaluen3 << OPAMP_INPUT_INVERTING); } #if defined(STM32G473xx) || defined(STM32G474xx) || defined(STM32G483xx) || defined(STM32G483xx) if ((hopamp4->Instance->CSR & OPAMP_CSR_OUTCAL) != 0UL) { /* OPAMP_CSR_OUTCAL is actually one value more */ trimmingvaluen4++; /* Set right trimming */ MODIFY_REG(hopamp4->Instance->CSR, OPAMP_CSR_TRIMOFFSETN, trimmingvaluen4 << OPAMP_INPUT_INVERTING); } if ((hopamp5->Instance->CSR & OPAMP_CSR_OUTCAL) != 0UL) { /* OPAMP_CSR_OUTCAL is actually one value more */ trimmingvaluen5++; /* Set right trimming */ MODIFY_REG(hopamp5->Instance->CSR, OPAMP_CSR_TRIMOFFSETN, trimmingvaluen5 << OPAMP_INPUT_INVERTING); } if ((hopamp6->Instance->CSR & OPAMP_CSR_OUTCAL) != 0UL) { /* OPAMP_CSR_OUTCAL is actually one value more */ trimmingvaluen6++; /* Set right trimming */ MODIFY_REG(hopamp6->Instance->CSR, OPAMP_CSR_TRIMOFFSETN, trimmingvaluen6 << OPAMP_INPUT_INVERTING); } #elif defined(STM32G491xx) || defined(STM32G4A1xx) if ((hopamp6->Instance->CSR & OPAMP_CSR_OUTCAL) != 0UL) { /* OPAMP_CSR_OUTCAL is actually one value more */ trimmingvaluen6++; /* Set right trimming */ MODIFY_REG(hopamp6->Instance->CSR, OPAMP_CSR_TRIMOFFSETN, trimmingvaluen6 << OPAMP_INPUT_INVERTING); } #endif /* 2nd calibration - P */ /* Select 10% VREF */ MODIFY_REG(hopamp1->Instance->CSR, OPAMP_CSR_CALSEL, OPAMP_VREF_10VDDA); MODIFY_REG(hopamp2->Instance->CSR, OPAMP_CSR_CALSEL, OPAMP_VREF_10VDDA); MODIFY_REG(hopamp3->Instance->CSR, OPAMP_CSR_CALSEL, OPAMP_VREF_10VDDA); #if defined(STM32G473xx) || defined(STM32G474xx) || defined(STM32G483xx) || defined(STM32G483xx) MODIFY_REG(hopamp4->Instance->CSR, OPAMP_CSR_CALSEL, OPAMP_VREF_10VDDA); MODIFY_REG(hopamp5->Instance->CSR, OPAMP_CSR_CALSEL, OPAMP_VREF_10VDDA); MODIFY_REG(hopamp6->Instance->CSR, OPAMP_CSR_CALSEL, OPAMP_VREF_10VDDA); #elif defined(STM32G491xx) || defined(STM32G4A1xx) MODIFY_REG(hopamp6->Instance->CSR, OPAMP_CSR_CALSEL, OPAMP_VREF_10VDDA); #endif /* Init trimming counter */ /* Medium value */ trimmingvaluep1 = 16UL; trimmingvaluep2 = 16UL; trimmingvaluep3 = 16UL; #if defined(STM32G473xx) || defined(STM32G474xx) || defined(STM32G483xx) || defined(STM32G483xx) trimmingvaluep4 = 16UL; trimmingvaluep5 = 16UL; trimmingvaluep6 = 16UL; #elif defined(STM32G491xx) || defined(STM32G4A1xx) trimmingvaluep6 = 16UL; #endif delta = 8UL; while (delta != 0UL) { /* Set candidate trimming */ MODIFY_REG(hopamp1->Instance->CSR, OPAMP_CSR_TRIMOFFSETP, trimmingvaluep1 << OPAMP_INPUT_NONINVERTING); MODIFY_REG(hopamp2->Instance->CSR, OPAMP_CSR_TRIMOFFSETP, trimmingvaluep2 << OPAMP_INPUT_NONINVERTING); MODIFY_REG(hopamp3->Instance->CSR, OPAMP_CSR_TRIMOFFSETP, trimmingvaluep3 << OPAMP_INPUT_NONINVERTING); #if defined(STM32G473xx) || defined(STM32G474xx) || defined(STM32G483xx) || defined(STM32G483xx) MODIFY_REG(hopamp4->Instance->CSR, OPAMP_CSR_TRIMOFFSETP, trimmingvaluep4 << OPAMP_INPUT_NONINVERTING); MODIFY_REG(hopamp5->Instance->CSR, OPAMP_CSR_TRIMOFFSETP, trimmingvaluep5 << OPAMP_INPUT_NONINVERTING); MODIFY_REG(hopamp6->Instance->CSR, OPAMP_CSR_TRIMOFFSETP, trimmingvaluep6 << OPAMP_INPUT_NONINVERTING); #elif defined(STM32G491xx) || defined(STM32G4A1xx) MODIFY_REG(hopamp6->Instance->CSR, OPAMP_CSR_TRIMOFFSETP, trimmingvaluep6 << OPAMP_INPUT_NONINVERTING); #endif /* OFFTRIMmax delay 2 ms as per datasheet (electrical characteristics */ /* Offset trim time: during calibration, minimum time needed between */ /* two steps to have 1 mV accuracy */ HAL_Delay(2); if ((hopamp1->Instance->CSR & OPAMP_CSR_OUTCAL) != 0UL) { /* OPAMP_CSR_OUTCAL is HIGH try higher trimming */ trimmingvaluep1 += delta; } else { trimmingvaluep1 -= delta; } if ((hopamp2->Instance->CSR & OPAMP_CSR_OUTCAL) != 0UL) { /* OPAMP_CSR_OUTCAL is HIGH try higher trimming */ trimmingvaluep2 += delta; } else { trimmingvaluep2 -= delta; } if ((hopamp3->Instance->CSR & OPAMP_CSR_OUTCAL) != 0UL) { /* OPAMP_CSR_OUTCAL is HIGH try higher trimming */ trimmingvaluep3 += delta; } else { trimmingvaluep3 -= delta; } #if defined(STM32G473xx) || defined(STM32G474xx) || defined(STM32G483xx) || defined(STM32G483xx) if ((hopamp4->Instance->CSR & OPAMP_CSR_OUTCAL) != 0UL) { /* OPAMP_CSR_OUTCAL is HIGH try higher trimming */ trimmingvaluep4 += delta; } else { trimmingvaluep4 -= delta; } if ((hopamp5->Instance->CSR & OPAMP_CSR_OUTCAL) != 0UL) { /* OPAMP_CSR_OUTCAL is HIGH try higher trimming */ trimmingvaluep5 += delta; } else { trimmingvaluep5 -= delta; } if ((hopamp6->Instance->CSR & OPAMP_CSR_OUTCAL) != 0UL) { /* OPAMP_CSR_OUTCAL is HIGH try higher trimming */ trimmingvaluep6 += delta; } else { trimmingvaluep6 -= delta; } #elif defined(STM32G491xx) || defined(STM32G4A1xx) if ((hopamp6->Instance->CSR & OPAMP_CSR_OUTCAL) != 0UL) { /* OPAMP_CSR_OUTCAL is HIGH try higher trimming */ trimmingvaluep6 += delta; } else { trimmingvaluep6 -= delta; } #endif delta >>= 1; } /* Still need to check if righ calibration is current value or un step below */ /* Indeed the first value that causes the OUTCAL bit to change from 1 to 0 */ /* Set candidate trimming */ MODIFY_REG(hopamp1->Instance->CSR, OPAMP_CSR_TRIMOFFSETP, trimmingvaluep1 << OPAMP_INPUT_NONINVERTING); MODIFY_REG(hopamp2->Instance->CSR, OPAMP_CSR_TRIMOFFSETP, trimmingvaluep2 << OPAMP_INPUT_NONINVERTING); MODIFY_REG(hopamp3->Instance->CSR, OPAMP_CSR_TRIMOFFSETP, trimmingvaluep3 << OPAMP_INPUT_NONINVERTING); #if defined(STM32G473xx) || defined(STM32G474xx) || defined(STM32G483xx) || defined(STM32G483xx) MODIFY_REG(hopamp4->Instance->CSR, OPAMP_CSR_TRIMOFFSETP, trimmingvaluep4 << OPAMP_INPUT_NONINVERTING); MODIFY_REG(hopamp5->Instance->CSR, OPAMP_CSR_TRIMOFFSETP, trimmingvaluep5 << OPAMP_INPUT_NONINVERTING); MODIFY_REG(hopamp6->Instance->CSR, OPAMP_CSR_TRIMOFFSETP, trimmingvaluep6 << OPAMP_INPUT_NONINVERTING); #elif defined(STM32G491xx) || defined(STM32G4A1xx) MODIFY_REG(hopamp6->Instance->CSR, OPAMP_CSR_TRIMOFFSETP, trimmingvaluep6 << OPAMP_INPUT_NONINVERTING); #endif /* OFFTRIMmax delay 2 ms as per datasheet (electrical characteristics */ /* Offset trim time: during calibration, minimum time needed between */ /* two steps to have 1 mV accuracy */ HAL_Delay(2); if ((hopamp1->Instance->CSR & OPAMP_CSR_OUTCAL) != 0UL) { /* Trimming value is actually one value more */ trimmingvaluep1++; /* Set right trimming */ MODIFY_REG(hopamp1->Instance->CSR, OPAMP_CSR_TRIMOFFSETP, trimmingvaluep1 << OPAMP_INPUT_NONINVERTING); } if ((hopamp2->Instance->CSR & OPAMP_CSR_OUTCAL) != 0UL) { /* Trimming value is actually one value more */ trimmingvaluep2++; /* Set right trimming */ MODIFY_REG(hopamp2->Instance->CSR, OPAMP_CSR_TRIMOFFSETP, trimmingvaluep2 << OPAMP_INPUT_NONINVERTING); } if ((hopamp3->Instance->CSR & OPAMP_CSR_OUTCAL) != 0UL) { /* Trimming value is actually one value more */ trimmingvaluep3++; /* Set right trimming */ MODIFY_REG(hopamp3->Instance->CSR, OPAMP_CSR_TRIMOFFSETP, trimmingvaluep3 << OPAMP_INPUT_NONINVERTING); } #if defined(STM32G473xx) || defined(STM32G474xx) || defined(STM32G483xx) || defined(STM32G483xx) if ((hopamp4->Instance->CSR & OPAMP_CSR_OUTCAL) != 0UL) { /* Trimming value is actually one value more */ trimmingvaluep4++; /* Set right trimming */ MODIFY_REG(hopamp4->Instance->CSR, OPAMP_CSR_TRIMOFFSETP, trimmingvaluep4 << OPAMP_INPUT_NONINVERTING); } if ((hopamp5->Instance->CSR & OPAMP_CSR_OUTCAL) != 0UL) { /* Trimming value is actually one value more */ trimmingvaluep5++; /* Set right trimming */ MODIFY_REG(hopamp5->Instance->CSR, OPAMP_CSR_TRIMOFFSETP, trimmingvaluep5 << OPAMP_INPUT_NONINVERTING); } if ((hopamp6->Instance->CSR & OPAMP_CSR_OUTCAL) != 0UL) { /* Trimming value is actually one value more */ trimmingvaluep6++; /* Set right trimming */ MODIFY_REG(hopamp6->Instance->CSR, OPAMP_CSR_TRIMOFFSETP, trimmingvaluep6 << OPAMP_INPUT_NONINVERTING); } #elif defined(STM32G491xx) || defined(STM32G4A1xx) if ((hopamp6->Instance->CSR & OPAMP_CSR_OUTCAL) != 0UL) { /* Trimming value is actually one value more */ trimmingvaluep6++; /* Set right trimming */ MODIFY_REG(hopamp6->Instance->CSR, OPAMP_CSR_TRIMOFFSETP, trimmingvaluep6 << OPAMP_INPUT_NONINVERTING); } #endif /* Disable calibration */ CLEAR_BIT(hopamp1->Instance->CSR, OPAMP_CSR_CALON); CLEAR_BIT(hopamp2->Instance->CSR, OPAMP_CSR_CALON); CLEAR_BIT(hopamp3->Instance->CSR, OPAMP_CSR_CALON); #if defined(STM32G473xx) || defined(STM32G474xx) || defined(STM32G483xx) || defined(STM32G483xx) CLEAR_BIT(hopamp4->Instance->CSR, OPAMP_CSR_CALON); CLEAR_BIT(hopamp5->Instance->CSR, OPAMP_CSR_CALON); CLEAR_BIT(hopamp6->Instance->CSR, OPAMP_CSR_CALON); #elif defined(STM32G491xx) || defined(STM32G4A1xx) CLEAR_BIT(hopamp6->Instance->CSR, OPAMP_CSR_CALON); #endif /* Disable the OPAMPs */ CLEAR_BIT(hopamp1->Instance->CSR, OPAMP_CSR_OPAMPxEN); CLEAR_BIT(hopamp2->Instance->CSR, OPAMP_CSR_OPAMPxEN); CLEAR_BIT(hopamp3->Instance->CSR, OPAMP_CSR_OPAMPxEN); #if defined(STM32G473xx) || defined(STM32G474xx) || defined(STM32G483xx) || defined(STM32G483xx) CLEAR_BIT(hopamp4->Instance->CSR, OPAMP_CSR_OPAMPxEN); CLEAR_BIT(hopamp5->Instance->CSR, OPAMP_CSR_OPAMPxEN); CLEAR_BIT(hopamp6->Instance->CSR, OPAMP_CSR_OPAMPxEN); #elif defined(STM32G491xx) || defined(STM32G4A1xx) CLEAR_BIT(hopamp6->Instance->CSR, OPAMP_CSR_OPAMPxEN); #endif /* Set normal operating mode back */ CLEAR_BIT(hopamp1->Instance->CSR, OPAMP_CSR_FORCEVP); CLEAR_BIT(hopamp2->Instance->CSR, OPAMP_CSR_FORCEVP); CLEAR_BIT(hopamp3->Instance->CSR, OPAMP_CSR_FORCEVP); #if defined(STM32G473xx) || defined(STM32G474xx) || defined(STM32G483xx) || defined(STM32G483xx) CLEAR_BIT(hopamp4->Instance->CSR, OPAMP_CSR_FORCEVP); CLEAR_BIT(hopamp5->Instance->CSR, OPAMP_CSR_FORCEVP); CLEAR_BIT(hopamp6->Instance->CSR, OPAMP_CSR_FORCEVP); #elif defined(STM32G491xx) || defined(STM32G4A1xx) CLEAR_BIT(hopamp6->Instance->CSR, OPAMP_CSR_FORCEVP); #endif /* Self calibration is successful */ /* Store calibration(user timing) results in init structure. */ /* Select user timing mode */ /* Write calibration result N */ hopamp1->Init.TrimmingValueN = trimmingvaluen1; hopamp2->Init.TrimmingValueN = trimmingvaluen2; hopamp3->Init.TrimmingValueN = trimmingvaluen3; #if defined(STM32G473xx) || defined(STM32G474xx) || defined(STM32G483xx) || defined(STM32G483xx) hopamp4->Init.TrimmingValueN = trimmingvaluen4; hopamp5->Init.TrimmingValueN = trimmingvaluen5; hopamp6->Init.TrimmingValueN = trimmingvaluen6; #elif defined(STM32G491xx) || defined(STM32G4A1xx) hopamp6->Init.TrimmingValueN = trimmingvaluen6; #endif /* Write calibration result P */ hopamp1->Init.TrimmingValueP = trimmingvaluep1; hopamp2->Init.TrimmingValueP = trimmingvaluep2; hopamp3->Init.TrimmingValueP = trimmingvaluep3; #if defined(STM32G473xx) || defined(STM32G474xx) || defined(STM32G483xx) || defined(STM32G483xx) hopamp4->Init.TrimmingValueP = trimmingvaluep4; hopamp5->Init.TrimmingValueP = trimmingvaluep5; hopamp6->Init.TrimmingValueP = trimmingvaluep6; #elif defined(STM32G491xx) || defined(STM32G4A1xx) hopamp6->Init.TrimmingValueP = trimmingvaluep6; #endif /* Select user timing mode */ /* And updated with calibrated settings */ hopamp1->Init.UserTrimming = OPAMP_TRIMMING_USER; hopamp2->Init.UserTrimming = OPAMP_TRIMMING_USER; hopamp3->Init.UserTrimming = OPAMP_TRIMMING_USER; #if defined(STM32G473xx) || defined(STM32G474xx) || defined(STM32G483xx) || defined(STM32G483xx) hopamp4->Init.UserTrimming = OPAMP_TRIMMING_USER; hopamp5->Init.UserTrimming = OPAMP_TRIMMING_USER; hopamp6->Init.UserTrimming = OPAMP_TRIMMING_USER; #elif defined(STM32G491xx) || defined(STM32G4A1xx) hopamp6->Init.UserTrimming = OPAMP_TRIMMING_USER; #endif MODIFY_REG(hopamp1->Instance->CSR, OPAMP_CSR_TRIMOFFSETN, trimmingvaluen1 << OPAMP_INPUT_INVERTING); MODIFY_REG(hopamp2->Instance->CSR, OPAMP_CSR_TRIMOFFSETN, trimmingvaluen2 << OPAMP_INPUT_INVERTING); MODIFY_REG(hopamp3->Instance->CSR, OPAMP_CSR_TRIMOFFSETN, trimmingvaluen3 << OPAMP_INPUT_INVERTING); #if defined(STM32G473xx) || defined(STM32G474xx) || defined(STM32G483xx) || defined(STM32G483xx) MODIFY_REG(hopamp4->Instance->CSR, OPAMP_CSR_TRIMOFFSETN, trimmingvaluen4 << OPAMP_INPUT_INVERTING); MODIFY_REG(hopamp5->Instance->CSR, OPAMP_CSR_TRIMOFFSETN, trimmingvaluen5 << OPAMP_INPUT_INVERTING); MODIFY_REG(hopamp6->Instance->CSR, OPAMP_CSR_TRIMOFFSETN, trimmingvaluen6 << OPAMP_INPUT_INVERTING); #elif defined(STM32G491xx) || defined(STM32G4A1xx) MODIFY_REG(hopamp6->Instance->CSR, OPAMP_CSR_TRIMOFFSETN, trimmingvaluen6 << OPAMP_INPUT_INVERTING); #endif MODIFY_REG(hopamp1->Instance->CSR, OPAMP_CSR_TRIMOFFSETP, trimmingvaluep1 << OPAMP_INPUT_NONINVERTING); MODIFY_REG(hopamp2->Instance->CSR, OPAMP_CSR_TRIMOFFSETP, trimmingvaluep2 << OPAMP_INPUT_NONINVERTING); MODIFY_REG(hopamp3->Instance->CSR, OPAMP_CSR_TRIMOFFSETP, trimmingvaluep3 << OPAMP_INPUT_NONINVERTING); #if defined(STM32G473xx) || defined(STM32G474xx) || defined(STM32G483xx) || defined(STM32G483xx) MODIFY_REG(hopamp4->Instance->CSR, OPAMP_CSR_TRIMOFFSETP, trimmingvaluep4 << OPAMP_INPUT_NONINVERTING); MODIFY_REG(hopamp5->Instance->CSR, OPAMP_CSR_TRIMOFFSETP, trimmingvaluep5 << OPAMP_INPUT_NONINVERTING); MODIFY_REG(hopamp6->Instance->CSR, OPAMP_CSR_TRIMOFFSETP, trimmingvaluep6 << OPAMP_INPUT_NONINVERTING); #elif defined(STM32G491xx) || defined(STM32G4A1xx) MODIFY_REG(hopamp6->Instance->CSR, OPAMP_CSR_TRIMOFFSETP, trimmingvaluep6 << OPAMP_INPUT_NONINVERTING); #endif } return HAL_OK; } /** * @} */ /** * @} */ /** * @} */ #endif /* HAL_OPAMP_MODULE_ENABLED */ /** * @} */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
polymurph/STM-Linux
stm32g474_blinky/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/DspLibTest_FVP_A5/RTE/RTE_Components.h
<gh_stars>10-100 /* * Auto generated Run-Time-Environment Component Configuration File * *** Do not modify ! *** * * Project: DspLibTest_FVP_A5 * RTE configuration: DspLibTest_FVP_A5.rteconfig */ #ifndef RTE_COMPONENTS_H #define RTE_COMPONENTS_H /* * Define the Device Header File: */ #define CMSIS_device_header "ARMCA5.h" #define RTE_CMSIS_RTOS2 /* CMSIS-RTOS2 */ #define RTE_CMSIS_RTOS2_RTX5 /* CMSIS-RTOS2 Keil RTX5 */ #define RTE_CMSIS_RTOS2_RTX5_SOURCE /* CMSIS-RTOS2 Keil RTX5 Source */ #endif /* RTE_COMPONENTS_H */
polymurph/STM-Linux
stm32g474_blinky/Drivers/CMSIS/DSP/Source/StatisticsFunctions/StatisticsFunctions.c
<filename>stm32g474_blinky/Drivers/CMSIS/DSP/Source/StatisticsFunctions/StatisticsFunctions.c /* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: StatisticsFunctions.c * Description: Combination of all statistics function source files. * * $Date: 18. March 2019 * $Revision: V1.0.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2019 ARM Limited or its affiliates. All rights reserved. * * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the License); you may * not use this file except in compliance with the License. * You may obtain a copy of the License at * * www.apache.org/licenses/LICENSE-2.0 * * 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. */ #include "arm_max_f32.c" #include "arm_max_q15.c" #include "arm_max_q31.c" #include "arm_max_q7.c" #include "arm_mean_f32.c" #include "arm_mean_q15.c" #include "arm_mean_q31.c" #include "arm_mean_q7.c" #include "arm_min_f32.c" #include "arm_min_q15.c" #include "arm_min_q31.c" #include "arm_min_q7.c" #include "arm_power_f32.c" #include "arm_power_q15.c" #include "arm_power_q31.c" #include "arm_power_q7.c" #include "arm_rms_f32.c" #include "arm_rms_q15.c" #include "arm_rms_q31.c" #include "arm_std_f32.c" #include "arm_std_q15.c" #include "arm_std_q31.c" #include "arm_var_f32.c" #include "arm_var_q15.c" #include "arm_var_q31.c"
polymurph/STM-Linux
stm32g474_blinky/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/RefLibs/src/ControllerFunctions/ControllerFunctions.c
<gh_stars>10-100 #include "pid.c" #include "sin_cos.c"
polymurph/STM-Linux
stm32g474_blinky/Drivers/CMSIS/DSP/Source/TransformFunctions/arm_cfft_radix8_f32.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_cfft_radix8_f32.c * Description: Radix-8 Decimation in Frequency CFFT & CIFFT Floating point processing function * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the License); you may * not use this file except in compliance with the License. * You may obtain a copy of the License at * * www.apache.org/licenses/LICENSE-2.0 * * 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. */ #include "arm_math.h" /* ---------------------------------------------------------------------- * Internal helper function used by the FFTs * -------------------------------------------------------------------- */ /** brief Core function for the floating-point CFFT butterfly process. param[in,out] pSrc points to the in-place buffer of floating-point data type. param[in] fftLen length of the FFT. param[in] pCoef points to the twiddle coefficient buffer. param[in] twidCoefModifier twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. return none */ void arm_radix8_butterfly_f32( float32_t * pSrc, uint16_t fftLen, const float32_t * pCoef, uint16_t twidCoefModifier) { uint32_t ia1, ia2, ia3, ia4, ia5, ia6, ia7; uint32_t i1, i2, i3, i4, i5, i6, i7, i8; uint32_t id; uint32_t n1, n2, j; float32_t r1, r2, r3, r4, r5, r6, r7, r8; float32_t t1, t2; float32_t s1, s2, s3, s4, s5, s6, s7, s8; float32_t p1, p2, p3, p4; float32_t co2, co3, co4, co5, co6, co7, co8; float32_t si2, si3, si4, si5, si6, si7, si8; const float32_t C81 = 0.70710678118f; n2 = fftLen; do { n1 = n2; n2 = n2 >> 3; i1 = 0; do { i2 = i1 + n2; i3 = i2 + n2; i4 = i3 + n2; i5 = i4 + n2; i6 = i5 + n2; i7 = i6 + n2; i8 = i7 + n2; r1 = pSrc[2 * i1] + pSrc[2 * i5]; r5 = pSrc[2 * i1] - pSrc[2 * i5]; r2 = pSrc[2 * i2] + pSrc[2 * i6]; r6 = pSrc[2 * i2] - pSrc[2 * i6]; r3 = pSrc[2 * i3] + pSrc[2 * i7]; r7 = pSrc[2 * i3] - pSrc[2 * i7]; r4 = pSrc[2 * i4] + pSrc[2 * i8]; r8 = pSrc[2 * i4] - pSrc[2 * i8]; t1 = r1 - r3; r1 = r1 + r3; r3 = r2 - r4; r2 = r2 + r4; pSrc[2 * i1] = r1 + r2; pSrc[2 * i5] = r1 - r2; r1 = pSrc[2 * i1 + 1] + pSrc[2 * i5 + 1]; s5 = pSrc[2 * i1 + 1] - pSrc[2 * i5 + 1]; r2 = pSrc[2 * i2 + 1] + pSrc[2 * i6 + 1]; s6 = pSrc[2 * i2 + 1] - pSrc[2 * i6 + 1]; s3 = pSrc[2 * i3 + 1] + pSrc[2 * i7 + 1]; s7 = pSrc[2 * i3 + 1] - pSrc[2 * i7 + 1]; r4 = pSrc[2 * i4 + 1] + pSrc[2 * i8 + 1]; s8 = pSrc[2 * i4 + 1] - pSrc[2 * i8 + 1]; t2 = r1 - s3; r1 = r1 + s3; s3 = r2 - r4; r2 = r2 + r4; pSrc[2 * i1 + 1] = r1 + r2; pSrc[2 * i5 + 1] = r1 - r2; pSrc[2 * i3] = t1 + s3; pSrc[2 * i7] = t1 - s3; pSrc[2 * i3 + 1] = t2 - r3; pSrc[2 * i7 + 1] = t2 + r3; r1 = (r6 - r8) * C81; r6 = (r6 + r8) * C81; r2 = (s6 - s8) * C81; s6 = (s6 + s8) * C81; t1 = r5 - r1; r5 = r5 + r1; r8 = r7 - r6; r7 = r7 + r6; t2 = s5 - r2; s5 = s5 + r2; s8 = s7 - s6; s7 = s7 + s6; pSrc[2 * i2] = r5 + s7; pSrc[2 * i8] = r5 - s7; pSrc[2 * i6] = t1 + s8; pSrc[2 * i4] = t1 - s8; pSrc[2 * i2 + 1] = s5 - r7; pSrc[2 * i8 + 1] = s5 + r7; pSrc[2 * i6 + 1] = t2 - r8; pSrc[2 * i4 + 1] = t2 + r8; i1 += n1; } while (i1 < fftLen); if (n2 < 8) break; ia1 = 0; j = 1; do { /* index calculation for the coefficients */ id = ia1 + twidCoefModifier; ia1 = id; ia2 = ia1 + id; ia3 = ia2 + id; ia4 = ia3 + id; ia5 = ia4 + id; ia6 = ia5 + id; ia7 = ia6 + id; co2 = pCoef[2 * ia1]; co3 = pCoef[2 * ia2]; co4 = pCoef[2 * ia3]; co5 = pCoef[2 * ia4]; co6 = pCoef[2 * ia5]; co7 = pCoef[2 * ia6]; co8 = pCoef[2 * ia7]; si2 = pCoef[2 * ia1 + 1]; si3 = pCoef[2 * ia2 + 1]; si4 = pCoef[2 * ia3 + 1]; si5 = pCoef[2 * ia4 + 1]; si6 = pCoef[2 * ia5 + 1]; si7 = pCoef[2 * ia6 + 1]; si8 = pCoef[2 * ia7 + 1]; i1 = j; do { /* index calculation for the input */ i2 = i1 + n2; i3 = i2 + n2; i4 = i3 + n2; i5 = i4 + n2; i6 = i5 + n2; i7 = i6 + n2; i8 = i7 + n2; r1 = pSrc[2 * i1] + pSrc[2 * i5]; r5 = pSrc[2 * i1] - pSrc[2 * i5]; r2 = pSrc[2 * i2] + pSrc[2 * i6]; r6 = pSrc[2 * i2] - pSrc[2 * i6]; r3 = pSrc[2 * i3] + pSrc[2 * i7]; r7 = pSrc[2 * i3] - pSrc[2 * i7]; r4 = pSrc[2 * i4] + pSrc[2 * i8]; r8 = pSrc[2 * i4] - pSrc[2 * i8]; t1 = r1 - r3; r1 = r1 + r3; r3 = r2 - r4; r2 = r2 + r4; pSrc[2 * i1] = r1 + r2; r2 = r1 - r2; s1 = pSrc[2 * i1 + 1] + pSrc[2 * i5 + 1]; s5 = pSrc[2 * i1 + 1] - pSrc[2 * i5 + 1]; s2 = pSrc[2 * i2 + 1] + pSrc[2 * i6 + 1]; s6 = pSrc[2 * i2 + 1] - pSrc[2 * i6 + 1]; s3 = pSrc[2 * i3 + 1] + pSrc[2 * i7 + 1]; s7 = pSrc[2 * i3 + 1] - pSrc[2 * i7 + 1]; s4 = pSrc[2 * i4 + 1] + pSrc[2 * i8 + 1]; s8 = pSrc[2 * i4 + 1] - pSrc[2 * i8 + 1]; t2 = s1 - s3; s1 = s1 + s3; s3 = s2 - s4; s2 = s2 + s4; r1 = t1 + s3; t1 = t1 - s3; pSrc[2 * i1 + 1] = s1 + s2; s2 = s1 - s2; s1 = t2 - r3; t2 = t2 + r3; p1 = co5 * r2; p2 = si5 * s2; p3 = co5 * s2; p4 = si5 * r2; pSrc[2 * i5] = p1 + p2; pSrc[2 * i5 + 1] = p3 - p4; p1 = co3 * r1; p2 = si3 * s1; p3 = co3 * s1; p4 = si3 * r1; pSrc[2 * i3] = p1 + p2; pSrc[2 * i3 + 1] = p3 - p4; p1 = co7 * t1; p2 = si7 * t2; p3 = co7 * t2; p4 = si7 * t1; pSrc[2 * i7] = p1 + p2; pSrc[2 * i7 + 1] = p3 - p4; r1 = (r6 - r8) * C81; r6 = (r6 + r8) * C81; s1 = (s6 - s8) * C81; s6 = (s6 + s8) * C81; t1 = r5 - r1; r5 = r5 + r1; r8 = r7 - r6; r7 = r7 + r6; t2 = s5 - s1; s5 = s5 + s1; s8 = s7 - s6; s7 = s7 + s6; r1 = r5 + s7; r5 = r5 - s7; r6 = t1 + s8; t1 = t1 - s8; s1 = s5 - r7; s5 = s5 + r7; s6 = t2 - r8; t2 = t2 + r8; p1 = co2 * r1; p2 = si2 * s1; p3 = co2 * s1; p4 = si2 * r1; pSrc[2 * i2] = p1 + p2; pSrc[2 * i2 + 1] = p3 - p4; p1 = co8 * r5; p2 = si8 * s5; p3 = co8 * s5; p4 = si8 * r5; pSrc[2 * i8] = p1 + p2; pSrc[2 * i8 + 1] = p3 - p4; p1 = co6 * r6; p2 = si6 * s6; p3 = co6 * s6; p4 = si6 * r6; pSrc[2 * i6] = p1 + p2; pSrc[2 * i6 + 1] = p3 - p4; p1 = co4 * t1; p2 = si4 * t2; p3 = co4 * t2; p4 = si4 * t1; pSrc[2 * i4] = p1 + p2; pSrc[2 * i4 + 1] = p3 - p4; i1 += n1; } while (i1 < fftLen); j++; } while (j < n2); twidCoefModifier <<= 3; } while (n2 > 7); }
polymurph/STM-Linux
stm32g474_blinky/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/RefLibs/src/FastMathFunctions/FastMathFunctions.c
#include "cos.c" #include "sin.c" #include "sqrt.c"
polymurph/STM-Linux
maketest/Core/Inc/app_main.h
<filename>maketest/Core/Inc/app_main.h<gh_stars>0 #ifndef _APP_MAIN_ #define _APP_MAIN_ #ifdef __cplusplus extern "C" { #endif #include "main.h" #include "usart.h" #include "gpio.h" int app_main(); #ifdef __cplusplus } #endif #endif
ramalho/brainfuck
origdistro/brainfuck-2/bfi.c
#include <stdio.h> int p, r, q; char a[5000], f[5000], b, o, *s=f; void interpret(char *c) { char *d; r++; while( *c ) { //if(strchr("<>+-,.[]\n",*c))printf("%c",*c); switch(o=1,*c++) { case '<': p--; break; case '>': p++; break; case '+': a[p]++; break; case '-': a[p]--; break; case '.': putchar(a[p]); fflush(stdout); break; case ',': a[p]=getchar();fflush(stdout); break; case '[': for( b=1,d=c; b && *c; c++ ) b+=*c=='[', b-=*c==']'; if(!b) { c[-1]=0; while( a[p] ) interpret(d); c[-1]=']'; break; } case ']': puts("UNBALANCED BRACKETS"), exit(0); case '#': if(q>2) printf("%2d %2d %2d %2d %2d %2d %2d %2d %2d %2d\n%*s\n", *a,a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9],3*p+2,"^"); break; default: o=0; } if( p<0 || p>100) puts("RANGE ERROR"), exit(0); } r--; chkabort(); } main(int argc,char *argv[]) { FILE *z; q=argc; if(z=fopen(argv[1],"r")) { while( (b=getc(z))>0 ) *s++=b; *s=0; interpret(f); } }
chpublichp/masspred
tools/parjob-0.5/variable.h
<reponame>chpublichp/masspred #ifndef __VARIABLE__H__ #define __VARIABLE__H__ _EXTERN_ job_data_t Job_data; _EXTERN_ boolean_t Debug; #endif
chpublichp/masspred
tools/region_filter-0.19/type.h
#ifndef __TYPE__H__ #define __TYPE__H__ typedef enum boolean_t { FALSE = 0, TRUE = 1 } boolean_t; typedef enum model_t { MODEL_ANCHOR, MODEL_DISEMBL_1, MODEL_DISEMBL_2, MODEL_DISEMBL_3, MODEL_DISOPRED, MODEL_DISOPRED_1, MODEL_DISOPRED_2, MODEL_ISUNSTRUCT, MODEL_IUPRED_LONG, MODEL_IUPRED_SHORT, MODEL_OND, MODEL_PREDISORDER, MODEL_RONN, MODEL_VSL2, MODEL_UNKNOWN } model_t; typedef enum region_t { REGION_O, REGION_D, REGION_UNKNOWN } region_t; typedef struct profile_t { boolean_t numeric; FILE* input; FILE* output_sql; FILE* output_load; char* protein_id; char* protein_reference; char* protein_file_name; } profile_t; #define MAX_ROW_SIZE 8192 typedef char row_t[MAX_ROW_SIZE+1]; #endif
chpublichp/masspred
tools/fasta_tool-0.4/id_work.c
<reponame>chpublichp/masspred<gh_stars>0 #include "main.h" static char* id_quote(char* input, char* output, int output_size) { int input_position; int output_position; input_position = 0; output_position = 0; while(output_position < output_size-1 && input[input_position] != '\0') { if ( input[input_position] == '\'' || input[input_position] == '\"' || input[input_position] == '$' || input[input_position] == '`' || input[input_position] == '\\' ) { if(output_position >= output_size-3) break; output[output_position] = '\\'; output_position++; } if(output_position >= output_size-2) break; output[output_position] = input[input_position]; output_position++; input_position++; } output[output_position] = '\0'; return output; } _FUNCTION_DECLARATION_BEGIN_ void id_work(FILE* input_file) _FUNCTION_DECLARATION_END_ { row_t row; char* field_1; char* field_2; char* field_3; char* field_4; char* rest; char* end; row_t helper; if(fgets(row, MAX_ROW_SIZE, input_file) == NULL) ERROR("Empty input file"); if(row[0] != '>') ERROR("Missing \'>\' in first row"); field_1 = &row[1]; field_2 = strchr(field_1, '|'); field_3 = NULL; field_4 = NULL; rest = NULL; end = strchr(field_1, '\r'); if(end != NULL) *end = '\0'; end = strchr(field_1, '\n'); if(end != NULL) *end = '\0'; if(field_2 != NULL) { *field_2 = '\0'; field_2++; field_3 = strchr(field_2, '|'); if(field_3 != NULL) { *field_3 = '\0'; field_3++; field_4 = strchr(field_3, '|'); if(field_4 != NULL) { *field_4 = '\0'; field_4++; rest = strchr(field_4, '|'); if(rest != NULL) { *rest = '\0'; rest++; } } } } printf("FASTA_DB=\"%s\"\n", id_quote(field_1, helper, MAX_ROW_SIZE)); if(field_2 != NULL) printf("FASTA_ID=\"%s\"\n", id_quote(field_2, helper, MAX_ROW_SIZE)); else printf("FASTA_ID=\"\"\n"); if(field_3 != NULL ) printf("FASTA_REFERENCE_DB=\"%s\"\n", id_quote(field_3, helper, MAX_ROW_SIZE)); else printf("FASTA_REFERENCE_DB=\"\"\n"); if(field_4 != NULL) printf("FASTA_REFERENCE=\"%s\"\n", id_quote(field_4, helper, MAX_ROW_SIZE)); else printf("FASTA_REFERENCE=\"\"\n"); if(rest != NULL) printf("FASTA_REST=\"%s\"\n", id_quote(rest, helper, MAX_ROW_SIZE)); else printf("FASTA_REST=\"\"\n"); }
chpublichp/masspred
tools/hydro-0.2/hydro.c
#include <ctype.h> #include <limits.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #define DEFAULT_OUTPUT_FILE_PREFIX "hy_out" #define DEFAULT_OUTPUT_FILE_NAME_SQL_SUFFIX "sql" #define DEFAULT_OUTPUT_FILE_NAME_LOAD_SUFFIX "load" #define DEFAULT_PROTEIN_ID "" #define DEFAULT_PROTEIN_REFERENCE "" #define DEFAULT_PROTEIN_FILE_NAME "" #define DEFAULT_INPUT_FILE_NAME "-" typedef enum boolean_t { FALSE = 0, TRUE = 1 } boolean_t; #define MAX_ROW_SIZE 8192 typedef char row_t[MAX_ROW_SIZE+1]; #define INIT_AA_HYDRO 0.0 #define ERROR(format, ...) \ do \ { \ fprintf(stderr, "Error: " format "\n", ##__VA_ARGS__); \ exit(EXIT_FAILURE); \ } \ while(FALSE) \ FILE* open_sql_file(char* output_file_prefix) { char name[PATH_MAX]; FILE* file; snprintf(name, PATH_MAX, "%s.%s", output_file_prefix, DEFAULT_OUTPUT_FILE_NAME_SQL_SUFFIX); file = fopen(name, "a"); if(file == NULL) ERROR("Cannot create output file \'%s\'", name); return file; } FILE* open_load_file(char* output_file_prefix) { char name[PATH_MAX]; FILE* file; snprintf(name, PATH_MAX, "%s.%s", output_file_prefix, DEFAULT_OUTPUT_FILE_NAME_LOAD_SUFFIX); file = fopen(name, "a"); if(file == NULL) ERROR("Cannot create output file \'%s\'", name); return file; } void dump(FILE* output_sql, FILE* output_load, char* protein_id, char* protein_reference, char* protein_file_name, char aa, int position, float hydro_kd, float hydro_hw) { if(output_sql != NULL) { fprintf ( output_sql, "INSERT INTO hydro(protein_id, protein_reference, protein_file_name, position, aa, hydro_kd, hydro_hw) VALUES(\'%s\', \'%s\', \'%s\', \'%d\', \'%c\', \'%.1f\', \'%.1f\');\n", protein_id, protein_reference, protein_file_name, position, aa, hydro_kd, hydro_hw ); fflush(output_sql); } fprintf ( output_load, "%s\t%s\t%s\t%d\t%c\t%.1f\t%.1f\n", protein_id, protein_reference, protein_file_name, position, aa, hydro_kd, hydro_hw ); fflush(output_load); } float hydro_kd(char code) { static float table[] = { 1.8, 0.0, 2.5, -3.5, -3.5, 2.8, -0.4, -3.2, 4.5, 0.0, -3.9, 3.8, 1.9, -3.5, 0.0, -1.6, -3.5, -4.5, -0.8, -0.7, 0.0, 4.2, -0.9, 0.0, -1.3, 0.0 }; if(code < 'A' || code > 'Z') return INIT_AA_HYDRO; return table[code-'A']; } float hydro_hw(char code) { static float table[] = { -0.5, 0.0, -1.0, 3.0, 3.0, -2.5, 0.0, -0.5, -1.8, 0.0, 3.0, -1.8, -1.3, 0.2, 0.0, 0.0, 0.2, 3.0, 0.3, -0.4, 0.0, -1.5, -3.4, 0.0, -2.3, 0.0 }; if(code < 'A' || code > 'Z') return INIT_AA_HYDRO; return table[code-'A']; } void work(FILE* input, FILE* output_sql, FILE* output_load, char* protein_id, char* protein_reference, char* protein_file_name) { row_t row; int aa_position; int row_position; char aa; aa_position = 1; while(fgets(row, MAX_ROW_SIZE, input) != NULL) if(row[0] != '>') { row_position = 0; while(row[row_position] != '\0') { aa = toupper(row[row_position]); row_position++; if(aa >= 'A' && aa <= 'Z') { dump(output_sql, output_load, protein_id, protein_reference, protein_file_name, aa, aa_position, hydro_kd(aa), hydro_hw(aa)); aa_position++; } } } } void usage(char* name) { fprintf ( stderr, "Usage: %s [-h] [-s] [-o output_file_prefix] [-p protein_id] [-r protein_reference] [-f protein_file_name] [input_file]\n" " -h\t\tHelp\n" " -s\t\tGenerate SQL\n" " -o\t\tOutput file prefix (default \'%s\')\n" " -p\t\tProtein ID (default \'%s\')\n" " -r\t\tProtein reference (default \'%s\')\n" " -f\t\tProtein file name (default \'%s\')\n" " input_file\tInput file (default \'%s\' aka stdin)\n", name, DEFAULT_OUTPUT_FILE_PREFIX, DEFAULT_PROTEIN_ID, DEFAULT_PROTEIN_REFERENCE, DEFAULT_PROTEIN_FILE_NAME, DEFAULT_INPUT_FILE_NAME ); exit(EXIT_FAILURE); } int main(int arguments_number, char* arguments_values[]) { int option; boolean_t generate_sql; char* output_file_prefix; char* protein_id; char* protein_reference; char* protein_file_name; char* input_file_name; FILE* input; FILE* output_sql; FILE* output_load; generate_sql = FALSE; output_file_prefix = DEFAULT_OUTPUT_FILE_PREFIX; protein_id = DEFAULT_PROTEIN_ID; protein_reference = DEFAULT_PROTEIN_REFERENCE; protein_file_name = DEFAULT_PROTEIN_FILE_NAME; input_file_name = DEFAULT_INPUT_FILE_NAME; opterr = 0; while(TRUE) { option = getopt(arguments_number, arguments_values, "hso:p:r:f:"); if(option == -1) break; switch(option) { case 'h': usage(arguments_values[0]); break; case 's': generate_sql = TRUE; break; case 'o': output_file_prefix = optarg; break; case 'p': protein_id = optarg; break; case 'r': protein_reference = optarg; break; case 'f': protein_file_name = optarg; break; default: usage(arguments_values[0]); } } if(optind == arguments_number-1) input_file_name = arguments_values[optind]; else if(optind != arguments_number) usage(arguments_values[0]); if(strcmp(input_file_name, "-") == 0) input = stdin; else { input = fopen(input_file_name, "r"); if(input == NULL) ERROR("Cannot open input file \'%s\'", input_file_name); } if(generate_sql == TRUE) output_sql = open_sql_file(output_file_prefix); else output_sql = NULL; output_load = open_load_file(output_file_prefix); work(input, output_sql, output_load, protein_id, protein_reference, protein_file_name); fclose(input); if(output_sql != NULL) fclose(output_sql); fclose(output_load); return EXIT_SUCCESS; }
chpublichp/masspred
tools/region_filter-0.19/work_ronn.c
#include "main.h" _FUNCTION_DECLARATION_BEGIN_ void work_ronn(profile_t* profile) _FUNCTION_DECLARATION_END_ { char* name; row_t row; int row_number; char aa; float probability; region_t region; int region_start; int region_end; name = "RONN"; region = REGION_UNKNOWN; row_number = 1; while(fgets(row, MAX_ROW_SIZE, profile->input) != NULL) if(sscanf(row, " %c %f %*s", &aa, &probability) == 2) { if(profile->numeric == TRUE) if(probability <= 0.5) dump_numeric_o(profile, name, row_number, aa, probability); else dump_numeric_d(profile, name, row_number, aa, probability); else { if(probability <= 0.5) { if(region == REGION_D) dump_plain_d(profile, name, region_start, region_end); if(region != REGION_O) region_start = row_number; region = REGION_O; } else { if(region == REGION_O) dump_plain_o(profile, name, region_start, region_end); if(region != REGION_D) region_start = row_number; region = REGION_D; } region_end = row_number; } row_number++; } if(profile->numeric != TRUE) switch(region) { case REGION_O: dump_plain_o(profile, name, region_start, region_end); break; case REGION_D: dump_plain_d(profile, name, region_start, region_end); break; } }
chpublichp/masspred
tools/parjob-0.5/read_next_command.c
#include "main.h" static boolean_t is_empty_command(job_data_t* job_data, int index) { int i; i = 0; while(job_data->children_data[index].command[i] != '\0') { if(isspace(job_data->children_data[index].command[i]) == 0) return FALSE; } return TRUE; } boolean_t read_next_command(job_data_t* job_data, int index) { char* trim; do { if(fgets(job_data->children_data[index].command, MAX_COMMAND_SIZE, job_data->file) == NULL) return FALSE; trim = strchr(job_data->children_data[index].command, '\n'); if(trim != NULL) *trim = '\0'; trim = strchr(job_data->children_data[index].command, '#'); if(trim != NULL) *trim = '\0'; } while(is_empty_command(job_data, index) == TRUE); return TRUE; }
chpublichp/masspred
tools/parjob-0.5/start_new_child.c
<reponame>chpublichp/masspred<filename>tools/parjob-0.5/start_new_child.c #include "main.h" boolean_t start_new_child(job_data_t* job_data, char* enviroment[]) { static char* arguments_value[] = {"sh", "-c", NULL, NULL}; int i; pid_t child_pid; for(i = 0; i < job_data->size; i++) if(job_data->children_data[i].used == FALSE) { if(read_next_command(job_data, i) != TRUE) return FALSE; job_data->children_data[i].pid = fork(); if(job_data->children_data[i].pid == -1) ERROR("Cannot fork"); if(job_data->children_data[i].pid == 0) { arguments_value[2] = job_data->children_data[i].command; execve("/bin/sh", arguments_value, enviroment); ERROR("Cannot exec \'%s\'", job_data->children_data[i].command); } job_data->children_data[i].used = TRUE; DEBUG("START pid=%d command=\'%s\'", job_data->children_data[i].pid, job_data->children_data[i].command); } return TRUE; }
chpublichp/masspred
tools/parjob-0.5/main.c
#define __MAIN__C__ #include "main.h" static void usage(char* name) { fprintf ( stderr, "Usage: %s [-h] [-d] [-n number] [job_file]\n" " -h\t\tHelp\n" " -d\t\tTurn debug on (default off)\n" " -n\t\tMax number of children (default %d)\n" " job_file\tFile with command on each row (default \'%s\' aka stdin)\n", name, DEFAULT_CHILD_DATA_SIZE, DEFAULT_JOB_FILE_NAME ); exit(EXIT_FAILURE); } int main(int arguments_number, char* arguments_values[], char* arguments_enviroment[]) { int child_data_size; char* job_file_name; int option; child_data_size = DEFAULT_CHILD_DATA_SIZE; job_file_name = DEFAULT_JOB_FILE_NAME; Debug = FALSE; opterr = 0; while(TRUE) { option = getopt(arguments_number, arguments_values, "hdn:"); if(option == -1) break; switch(option) { case 'h': usage(arguments_values[0]); break; case 'd': Debug = TRUE; break; case 'n': child_data_size = atoi(optarg); if(child_data_size <= 0) usage(arguments_values[0]); break; default: usage(arguments_values[0]); } } if(optind == arguments_number-1) job_file_name = arguments_values[optind]; else if(optind != arguments_number) usage(arguments_values[0]); DEBUG("INIT"); job_data_init(&Job_data, child_data_size, job_file_name); signal(SIGCHLD, &child_dead); signal(SIGHUP, &dump); while(TRUE) { if(start_new_child(&Job_data, arguments_enviroment) != TRUE) break; sleep(1000); } wait_all_children(&Job_data); job_data_clean(&Job_data); DEBUG("DONE"); return EXIT_SUCCESS; }
chpublichp/masspred
tools/parjob-0.5/prototype.h
#ifndef __PROTOTYPE__H_ #define __PROTOTYPE__H_ void child_dead(int); void dump(int); void job_data_clean(job_data_t*); boolean_t job_data_init(job_data_t*, int, char*); boolean_t read_next_command(job_data_t*, int); boolean_t start_new_child(job_data_t*, char*[]); void wait_all_children(job_data_t*); #endif
chpublichp/masspred
tools/fasta_tool-0.4/main.h
#ifndef __MAIN__H__ #define __MAIN__H__ #define _GNU_SOURCE #include <crypt.h> #include <limits.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include "default.h" #include "type.h" #include "prototype.i" #define ERROR(format, ...) \ do \ { \ fprintf(stderr, "Error: " format "\n", ##__VA_ARGS__); \ exit(EXIT_FAILURE); \ } \ while(FALSE) \ #define _FUNCTION_DECLARATION_BEGIN_ #define _FUNCTION_DECLARATION_END_ #endif
chpublichp/masspred
tools/fasta_tool-0.4/length_work.c
#include "main.h" _FUNCTION_DECLARATION_BEGIN_ void length_work(FILE* input_file) _FUNCTION_DECLARATION_END_ { int length; row_t row; length = 0; while(fgets(row, MAX_ROW_SIZE, input_file) != NULL) { if(row[0] == '>') length++; } printf("FASTA_LENGTH=\"%d\"\n", length); }
chpublichp/masspred
tools/parjob-0.5/job_data_init.c
#include "main.h" boolean_t job_data_init(job_data_t* job_data, int size, char* job_file_name) { int i; job_data->children_data = (child_data_t*)calloc(size, sizeof(child_data_t)); if(job_data->children_data == NULL) ERROR("No free space for job data"); job_data->size = size; for(i = 0; i < size; i++) job_data->children_data[i].used = FALSE; if(strcmp(job_file_name, "-") == 0) job_data->file = stdin; else { job_data->file = fopen(job_file_name, "r"); if(job_data->file == NULL) ERROR("Cannot open file \'%s\'", job_file_name); } return TRUE; }
chpublichp/masspred
tools/region_filter-0.19/dump_plain.c
#include "main.h" _FUNCTION_DECLARATION_BEGIN_ void dump_plain(profile_t* profile, char* name, int start, int end, char* order) _FUNCTION_DECLARATION_END_ { if(profile->output_sql != NULL) { fprintf ( profile->output_sql, "INSERT INTO region(protein_id, protein_reference, protein_file_name, begin, end, order, type) VALUES(\'%s\', \'%s\', \'%s\', \'%d\', \'%d\', \'%s\', \'%s\');\n", profile->protein_id, profile->protein_reference, profile->protein_file_name, start, end, order, name ); fflush(profile->output_sql); } fprintf ( profile->output_load, "%s\t%s\t%s\t%d\t%d\t%s\t%s\n", profile->protein_id, profile->protein_reference, profile->protein_file_name, start, end, order, name ); fflush(profile->output_load); }
chpublichp/masspred
tools/region_filter-0.19/default.h
<reponame>chpublichp/masspred<filename>tools/region_filter-0.19/default.h #ifndef __DEFAULT__H__ #define __DEFAULT__H__ #define DEFAULT_OUTPUT_FILE_PREFIX "rf_out" #define DEFAULT_OUTPUT_FILE_NAME_SQL_SUFFIX "sql" #define DEFAULT_OUTPUT_FILE_NAME_LOAD_SUFFIX "load" #define DEFAULT_PROTEIN_ID "" #define DEFAULT_PROTEIN_REFERENCE "" #define DEFAULT_PROTEIN_FILE_NAME "" #define DEFAULT_INPUT_FILE_NAME "-" #define REGION_ORDER_STRING "O" #define REGION_DISORDER_STRING "D" #endif
chpublichp/masspred
tools/fasta_tool-0.4/get_work.c
<reponame>chpublichp/masspred #include "main.h" _FUNCTION_DECLARATION_BEGIN_ void get_work(FILE* input_file, int get_number) _FUNCTION_DECLARATION_END_ { int position; boolean_t found; row_t row; position = 0; found = FALSE; while(fgets(row, MAX_ROW_SIZE, input_file) != NULL) if(row[0] == '>') { position++; if(position == get_number) { found = TRUE; fputs(row, stdout); break; } } if(found == TRUE) { while(fgets(row, MAX_ROW_SIZE, input_file) != NULL) { if(row[0] == '>') break; fputs(row, stdout); } } }
chpublichp/masspred
tools/region_filter-0.19/open_file.c
<reponame>chpublichp/masspred<filename>tools/region_filter-0.19/open_file.c #include "main.h" _FUNCTION_DECLARATION_BEGIN_ FILE* open_file(char* output_file_prefix, char* output_file_suffix) _FUNCTION_DECLARATION_END_ { char name[PATH_MAX]; FILE* file; snprintf(name, PATH_MAX, "%s.%s", output_file_prefix, output_file_suffix); file = fopen(name, "a"); if(file == NULL) ERROR("Cannot create output file \'%s\'", name); return file; }
chpublichp/masspred
tools/fasta_tool-0.4/checksum_work.c
<filename>tools/fasta_tool-0.4/checksum_work.c #include "main.h" #define SALT "$1$fasta" _FUNCTION_DECLARATION_BEGIN_ void checksum_work(char* name) _FUNCTION_DECLARATION_END_ { struct crypt_data data; char* result; data.initialized = 0; result = crypt_r(name, SALT, &data); printf ( "DIR_1=\"%01x%01x\"\n" "DIR_2=\"%01x%01x\"\n", result[sizeof SALT+1]&0xf, result[sizeof SALT+2]&0xf, result[sizeof SALT+3]&0xf, result[sizeof SALT+4]&0xf ); }
chpublichp/masspred
tools/fasta_tool-0.4/default.h
<filename>tools/fasta_tool-0.4/default.h #ifndef __DEFAULT__H__ #define __DEFAULT__H__ #define DEFAULT_SPLIT_OUTPUT_DIRECTORY "." #define DEFAULT_INPUT_FILE_NAME "-" #endif
chpublichp/masspred
tools/command-0.1/fasta_stat.c
#include <stdio.h> #include <stdlib.h> #include <limits.h> #define LINE_LEN 1024 int main(void) { unsigned char first_line[LINE_LEN]; unsigned char line[LINE_LEN]; int stat[UCHAR_MAX]; int i; if(fgets(first_line, LINE_LEN, stdin) == NULL) return 1; for(i = 0; first_line[i] != '\n'; i++); first_line[i] = '\0'; for(i = 0; i < UCHAR_MAX; i++) stat[i] = 0; while(fgets(line, LINE_LEN, stdin) != NULL) for(i = 0; line[i] != '\0'; i++) stat[line[i]]++; printf ( ( ":name=\"%s\"\n" ":position=\"%s\"\n" ":db=\"%s\"\n" ":id=\"%s\"\n" ":reference_db=\"%s\"\n" ":reference=\"%s\"\n" ":first_line=\"%s\"\n" "\n" "A: %d\n" "B: %d\n" "C: %d\n" "D: %d\n" "E: %d\n" "F: %d\n" "G: %d\n" "H: %d\n" "I: %d\n" "J: %d\n" "K: %d\n" "L: %d\n" "M: %d\n" "N: %d\n" "O: %d\n" "P: %d\n" "Q: %d\n" "R: %d\n" "S: %d\n" "T: %d\n" "U: %d\n" "V: %d\n" "W: %d\n" "Y: %d\n" "Z: %d\n" "X: %d\n" "*: %d\n" "-: %d\n" ), getenv("MASSPRED_FILE_NAME"), getenv("MASSPRED_INPUT_POSITION"), getenv("MASSPRED_FASTA_DB"), getenv("MASSPRED_FASTA_ID"), getenv("MASSPRED_FASTA_REFERENCE_DB"), getenv("MASSPRED_FASTA_REFERENCE"), first_line, stat['A']+stat['a'], stat['B']+stat['b'], stat['C']+stat['c'], stat['D']+stat['d'], stat['E']+stat['e'], stat['F']+stat['f'], stat['G']+stat['g'], stat['H']+stat['h'], stat['I']+stat['i'], stat['J']+stat['j'], stat['K']+stat['k'], stat['L']+stat['l'], stat['M']+stat['m'], stat['N']+stat['n'], stat['O']+stat['o'], stat['P']+stat['p'], stat['Q']+stat['q'], stat['R']+stat['r'], stat['S']+stat['s'], stat['T']+stat['t'], stat['U']+stat['u'], stat['V']+stat['v'], stat['W']+stat['w'], stat['Y']+stat['y'], stat['Z']+stat['z'], stat['X']+stat['x'], stat['*'], stat['-'] ); return 0; }
chpublichp/masspred
tools/fasta_tool-0.4/split_work.c
#include "main.h" static FILE* split_new_output_file(char* input_file_name, char* output_directory, int output_file_number) { char input_file_name_copy[PATH_MAX]; char* slash; char* old_input_file_name; char* dot; char new_output_file_name[PATH_MAX]; FILE* new_output_file; snprintf(input_file_name_copy, PATH_MAX, "%s", input_file_name); slash = strrchr(input_file_name_copy, '/'); if(slash == NULL) old_input_file_name = input_file_name_copy; else { slash++; old_input_file_name = slash; } dot = strrchr(old_input_file_name, '.'); if(dot != NULL) *dot = '\0'; snprintf(new_output_file_name, PATH_MAX, "%s/%s_%d.faa", output_directory, old_input_file_name, output_file_number); new_output_file = fopen(new_output_file_name, "w"); if(new_output_file == NULL) ERROR("Cannot create output file \'%s\'", new_output_file_name); return new_output_file; } _FUNCTION_DECLARATION_BEGIN_ void split_work(FILE* input_file, char* input_file_name, char* output_directory) _FUNCTION_DECLARATION_END_ { FILE* output_file; int output_file_number; row_t row; output_file = NULL; output_file_number = 1; while(fgets(row, MAX_ROW_SIZE, input_file) != NULL) { if(row[0] == '>') { if(output_file != NULL) { fclose(output_file); output_file_number++; } output_file = split_new_output_file(input_file_name, output_directory, output_file_number); } if(output_file == NULL) ERROR("Bad format in input file"); fputs(row, output_file); } if(output_file != NULL) fclose(output_file); }
chpublichp/masspred
tools/parjob-0.5/main.h
<filename>tools/parjob-0.5/main.h #ifndef __MAIN__H__ #define __MAIN__H__ #include <sys/types.h> #include <sys/wait.h> #include <ctype.h> #include <errno.h> #include <signal.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #define DEFAULT_CHILD_DATA_SIZE 4 #define DEFAULT_JOB_FILE_NAME "-" typedef enum boolean_t { FALSE = 0, TRUE = 1 } boolean_t; #define MAX_COMMAND_SIZE 8192 typedef char command_t[MAX_COMMAND_SIZE+1]; typedef struct child_data_t { boolean_t used; pid_t pid; command_t command; } child_data_t; typedef struct job_data_t { int size; child_data_t* children_data; FILE* file; } job_data_t; #define DEBUG(format, ...) \ do \ { \ if(Debug == TRUE) \ fprintf(stderr, "Debug: " format "\n", ##__VA_ARGS__); \ } \ while(FALSE) \ #define ERROR(format, ...) \ do \ { \ fprintf(stderr, "Error: " format "\n", ##__VA_ARGS__); \ exit(EXIT_FAILURE); \ } \ while(FALSE) \ #undef _EXTERN_ #undef _INIT_ #ifdef __MAIN__C__ #define _EXTERN_ #define _INIT_(...) = __VA_ARGS__ #else #define _EXTERN_ extern #define _INIT_(...) #endif #include "variable.h" #include "prototype.h" #endif
chpublichp/masspred
tools/parjob-0.5/job_data_clean.c
#include "main.h" void job_data_clean(job_data_t* job_data) { free((void*)job_data->children_data); fclose(job_data->file); }
chpublichp/masspred
tools/region_filter-0.19/dump_numeric.c
<reponame>chpublichp/masspred<filename>tools/region_filter-0.19/dump_numeric.c<gh_stars>0 #include "main.h" _FUNCTION_DECLARATION_BEGIN_ void dump_numeric(profile_t* profile, char* name, int position, char aa, float value, char* order) _FUNCTION_DECLARATION_END_ { if(profile->output_sql != NULL) { fprintf ( profile->output_sql, "INSERT INTO region_numeric(protein_id, protein_reference, protein_file_name, position, aa, value, order, type) VALUES(\'%s\', \'%s\', \'%s\', \'%d\', \'%c\', \'%f\', \'%s\', \'%s\');\n", profile->protein_id, profile->protein_reference, profile->protein_file_name, position, aa, value, order, name ); fflush(profile->output_sql); } fprintf ( profile->output_load, "%s\t%s\t%s\t%d\t%c\t%f\t%s\t%s\n", profile->protein_id, profile->protein_reference, profile->protein_file_name, position, aa, value, order, name ); fflush(profile->output_load); }
chpublichp/masspred
tools/fasta_tool-0.4/main.c
<reponame>chpublichp/masspred<gh_stars>0 #include "main.h" static void usage(char* name) { fprintf ( stderr, "Usage: %s [-h] (-s dir | -i | -c | -l | -g number) [input_file]\n" " -h\t\tHelp\n" " -s\t\tSplit multi fasta format file to dir (default \'%s\')\n" " -i\t\tGet ID from single fasta format file\n" " -c\t\tGet checksum of file name\n" " -l\t\tGet number of proteins in multi fasta format file\n" " -g\t\tGet proteins from multi fasta format file on position number\n" " input_file\tInput file in fasta format (default \'%s\' aka stdin)\n", name, DEFAULT_SPLIT_OUTPUT_DIRECTORY, DEFAULT_INPUT_FILE_NAME ); exit(EXIT_FAILURE); } int main(int arguments_number, char* arguments_values[]) { model_t model; int option; char* split_output_directory; int get_number; char* input_file_name; FILE* input_file; model = MODEL_UNKNOWN; input_file_name = DEFAULT_INPUT_FILE_NAME; opterr = 0; while(TRUE) { option = getopt(arguments_number, arguments_values, "hs:iclg:"); if(option == -1) break; switch(option) { case 'h': usage(arguments_values[0]); break; case 's': model = MODEL_SPLIT; split_output_directory = optarg; break; case 'i': model = MODEL_ID; break; case 'c': model = MODEL_CHECKSUM; break; case 'l': model = MODEL_LENGTH; break; case 'g': model = MODEL_GET; get_number = atoi(optarg); break; default: usage(arguments_values[0]); } } if(optind == arguments_number-1) input_file_name = arguments_values[optind]; else if(optind != arguments_number) usage(arguments_values[0]); if(model == MODEL_UNKNOWN) usage(arguments_values[0]); if(model == MODEL_CHECKSUM) checksum_work(input_file_name); else { if(strcmp(input_file_name, "-") == 0) input_file = stdin; else { input_file = fopen(input_file_name, "r"); if(input_file == NULL) ERROR("Cannot open input file \'%s\'", input_file_name); } switch(model) { case MODEL_SPLIT: split_work(input_file, input_file_name, split_output_directory); break; case MODEL_ID: id_work(input_file); break; case MODEL_LENGTH: length_work(input_file); break; case MODEL_GET: get_work(input_file, get_number); break; } fclose(input_file); } return EXIT_SUCCESS; }
chpublichp/masspred
tools/parjob-0.5/dump.c
<reponame>chpublichp/masspred #include "main.h" void dump(int signal) { int i; for(i = 0; i < Job_data.size; i++) if(Job_data.children_data[i].used == TRUE) fprintf(stderr, "DUMP: position=%d/%d pid=%d command=\'%s\'\n", i+1, Job_data.size, Job_data.children_data[i].pid, Job_data.children_data[i].command); }
chpublichp/masspred
tools/epitope_filter-0.13/epitope_filter.c
#include <limits.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #define DEFAULT_OUTPUT_FILE_PREFIX "ef_out" #define DEFAULT_OUTPUT_FILE_NAME_SQL_SUFFIX "sql" #define DEFAULT_OUTPUT_FILE_NAME_LOAD_SUFFIX "load" #define DEFAULT_ALLELE "" #define DEFAULT_LENGTH "" #define DEFAULT_PROTEIN_ID "" #define DEFAULT_PROTEIN_REFERENCE "" #define DEFAULT_PROTEIN_FILE_NAME "" #define DEFAULT_INPUT_FILE_NAME "-" typedef enum boolean_t { FALSE = 0, TRUE = 1 } boolean_t; #define STRING_MAX_LENGTH (64+1) typedef char string_t[STRING_MAX_LENGTH]; typedef enum model_t { MODEL_NETMHC30C, MODEL_NETMHC34A, MODEL_NETMHCII22, MODEL_NETMHCPAN20C, MODEL_NETMHCPAN24A, MODEL_NETMHCPAN28A, MODEL_NETMHCIIPAN10B, MODEL_NETMHCIIPAN20B, MODEL_NETMHCIIPAN30C, MODEL_NETMHCIIPAN31A, MODEL_UNKNOWN } model_t; typedef struct profile_t { boolean_t numeric; FILE* input; FILE* output_sql; FILE* output_load; char* allele; char* length; char* protein_id; char* protein_reference; char* protein_file_name; } profile_t; #define MAX_ROW_SIZE 1024 typedef char row_t[MAX_ROW_SIZE+1]; #define ERROR(format, ...) \ do \ { \ fprintf(stderr, "Error: " format "\n", ##__VA_ARGS__); \ exit(EXIT_FAILURE); \ } \ while(FALSE) \ FILE* open_sql_file(char* output_file_prefix) { char name[PATH_MAX]; FILE* file; snprintf(name, PATH_MAX, "%s.%s", output_file_prefix, DEFAULT_OUTPUT_FILE_NAME_SQL_SUFFIX); file = fopen(name, "a"); if(file == NULL) ERROR("Cannot create output file \'%s\'", name); return file; } FILE* open_load_file(char* output_file_prefix) { char name[PATH_MAX]; FILE* file; snprintf(name, PATH_MAX, "%s.%s", output_file_prefix, DEFAULT_OUTPUT_FILE_NAME_LOAD_SUFFIX); file = fopen(name, "a"); if(file == NULL) ERROR("Cannot create output file \'%s\'", name); return file; } void dump ( profile_t* profile, char* name, int position, char* epitope, int pos, char* core, float aff_1, float aff_2, float rank, char* binding ) { string_t pos_string; string_t rank_string; string_t binding_string_sql; char* table; string_t binding_string_load; if(pos < 0) snprintf(pos_string, STRING_MAX_LENGTH, "NULL"); else snprintf(pos_string, STRING_MAX_LENGTH, "%d", pos); if(rank < 0.0) snprintf(rank_string, STRING_MAX_LENGTH, "NULL"); else snprintf(rank_string, STRING_MAX_LENGTH, "%0.2f", rank); if(profile->output_sql != NULL) { if(binding == NULL) snprintf(binding_string_sql, STRING_MAX_LENGTH, "NULL"); else snprintf(binding_string_sql, STRING_MAX_LENGTH, "\'%s\'", binding); if(profile->numeric == TRUE) table = "epitope_numeric"; else table = "epitope"; fprintf ( profile->output_sql, "INSERT INTO %s(protein_id, protein_reference, protein_file_name, position, epitope, pos, core, aff_log, aff, rank, binding, type, allele, length) VALUES(\'%s\', \'%s\', \'%s\', \'%d\', \'%s\', %s, \'%s\', \'%0.3f\', \'%0.2f\', %s, %s, \'%s\', \'%s\', \'%s\');\n", table, profile->protein_id, profile->protein_reference, profile->protein_file_name, position, epitope, pos_string, core, aff_1, aff_2, rank_string, binding_string_sql, name, profile->allele, profile->length ); fflush(profile->output_sql); } if(binding == NULL) snprintf(binding_string_load, STRING_MAX_LENGTH, "NULL"); else snprintf(binding_string_load, STRING_MAX_LENGTH, "%s", binding); fprintf ( profile->output_load, "%s\t%s\t%s\t%d\t%s\t%s\t%s\t%0.3f\t%0.2f\t%s\t%s\t%s\t%s\t%s\n", profile->protein_id, profile->protein_reference, profile->protein_file_name, position, epitope, pos_string, core, aff_1, aff_2, rank_string, binding_string_load, name, profile->allele, profile->length ); fflush(profile->output_load); } void work_netmhc30c(profile_t* profile) { char* name; row_t row; int row_number; string_t epitope; float aff_1; float aff_2; string_t bind_place; string_t bind; string_t identify; string_t hla; name = "netmhc-3.0c"; while(fgets(row, MAX_ROW_SIZE, profile->input) != NULL) if ( sscanf ( row, " %d %64[^ \t] %f %f%11[ a-zA-Z] %64[^ \t] %64s", &row_number, epitope, &aff_1, &aff_2, bind_place, identify, hla ) == 7 ) { if(sscanf(bind_place, "%s", bind) != 1) snprintf(bind, STRING_MAX_LENGTH, ""); if(strcmp(bind, "SB") == 0) dump ( profile, name, row_number+1, epitope, -1, "", aff_1, aff_2, -1.0, "SB" ); else if(strcmp(bind, "WB") == 0) dump ( profile, name, row_number+1, epitope, -1, "", aff_1, aff_2, -1.0, "WB" ); else if(profile->numeric == TRUE) dump ( profile, name, row_number+1, epitope, -1, "", aff_1, aff_2, -1.0, NULL ); } else if ( sscanf ( row, " %d %64[^ \t] %f%11[ a-zA-Z] %64[^ \t] %64s", &row_number, epitope, &aff_1, bind_place, identify, hla ) == 6 ) { if(sscanf(bind_place, "%s", bind) != 1) snprintf(bind, STRING_MAX_LENGTH, ""); if(strcmp(bind, "SB") == 0) dump ( profile, name, row_number+1, epitope, -1, "", aff_1, -1.0, -1.0, "SB" ); else if(strcmp(bind, "WB") == 0) dump ( profile, name, row_number+1, epitope, -1, "", aff_1, -1.0, -1.0, "WB" ); else if(profile->numeric == TRUE) dump ( profile, name, row_number+1, epitope, -1, "", aff_1, -1.0, -1.0, NULL ); } } void work_netmhc34a(profile_t* profile) { char* name; row_t row; int row_number; string_t epitope; float aff_1; float aff_2; string_t bind_place; string_t bind; string_t identify; string_t hla; name = "netmhc-3.4a"; while(fgets(row, MAX_ROW_SIZE, profile->input) != NULL) if ( sscanf ( row, " %d %64[^ \t] %f %f%11[ a-zA-Z] %64[^ \t] %64s", &row_number, epitope, &aff_1, &aff_2, bind_place, identify, hla ) == 7 ) { if(sscanf(bind_place, "%s", bind) != 1) snprintf(bind, STRING_MAX_LENGTH, ""); if(strcmp(bind, "SB") == 0) dump ( profile, name, row_number+1, epitope, -1, "", aff_1, aff_2, -1.0, "SB" ); else if(strcmp(bind, "WB") == 0) dump ( profile, name, row_number+1, epitope, -1, "", aff_1, aff_2, -1.0, "WB" ); else if(profile->numeric == TRUE) dump ( profile, name, row_number+1, epitope, -1, "", aff_1, aff_2, -1.0, NULL ); } } void work_netmhcii22(profile_t* profile) { char* name; row_t row; string_t hla; int row_number; string_t epitope; string_t core; float aff_1; float aff_2; string_t bind_place; string_t bind; float rank; string_t identify; name = "netmhcii-2.2"; while(fgets(row, MAX_ROW_SIZE, profile->input) != NULL) if ( sscanf ( row, " %64[^ \t] %d %64[^ \t] %64[^ \t] %f %f%11[ a-zA-Z] %f %64s", hla, &row_number, epitope, core, &aff_1, &aff_2, bind_place, &rank, identify ) == 9 ) { if(sscanf(bind_place, "%s", bind) != 1) snprintf(bind, STRING_MAX_LENGTH, ""); if(strcmp(bind, "SB") == 0) dump ( profile, name, row_number+1, epitope, -1, core, aff_1, aff_2, rank, "SB" ); else if(strcmp(bind, "WB") == 0) dump ( profile, name, row_number+1, epitope, -1, core, aff_1, aff_2, rank, "WB" ); else if(profile->numeric == TRUE) dump ( profile, name, row_number+1, epitope, -1, core, aff_1, aff_2, rank, NULL ); } } void work_netmhcpan20c(profile_t* profile) { char* name; row_t row; int row_number; string_t hla; string_t epitope; string_t identify; float aff_1; float aff_2; string_t bind_place; string_t bind; name = "netmhcpan-2.0c"; while(fgets(row, MAX_ROW_SIZE, profile->input) != NULL) if ( sscanf ( row, " %d %64[^ \t] %64[^ \t] %64[^ \t] %f %f%64[ <=a-zA-Z\n]", &row_number, hla, epitope, identify, &aff_1, &aff_2, bind_place ) == 7 ) { if(sscanf(bind_place, " <= %s", bind) != 1) snprintf(bind, STRING_MAX_LENGTH, ""); if(strcmp(bind, "SB") == 0) dump ( profile, name, row_number+1, epitope, -1, "", aff_1, aff_2, -1.0, "SB" ); else if(strcmp(bind, "WB") == 0) dump ( profile, name, row_number+1, epitope, -1, "", aff_1, aff_2, -1.0, "WB" ); else if(profile->numeric == TRUE) dump ( profile, name, row_number+1, epitope, -1, "", aff_1, aff_2, -1.0, NULL ); } } void work_netmhcpan24a(profile_t* profile) { char* name; row_t row; int row_number; string_t hla; string_t epitope; string_t identify; float aff_1; float aff_2; float rank; string_t bind_place; string_t bind; name = "netmhcpan-2.4a"; while(fgets(row, MAX_ROW_SIZE, profile->input) != NULL) if ( sscanf ( row, " %d %64[^ \t] %64[^ \t] %64[^ \t] %f %f %f%64[ <=a-zA-Z\n]", &row_number, hla, epitope, identify, &aff_1, &aff_2, &rank, bind_place ) == 8 ) { if(sscanf(bind_place, " <= %s", bind) != 1) snprintf(bind, STRING_MAX_LENGTH, ""); if(strcmp(bind, "SB") == 0) dump ( profile, name, row_number+1, epitope, -1, "", aff_1, aff_2, rank, "SB" ); else if(strcmp(bind, "WB") == 0) dump ( profile, name, row_number+1, epitope, -1, "", aff_1, aff_2, rank, "WB" ); else if(profile->numeric == TRUE) dump ( profile, name, row_number+1, epitope, -1, "", aff_1, aff_2, rank, NULL ); } } void work_netmhcpan28a(profile_t* profile) { char* name; row_t row; int row_number; string_t hla; string_t epitope; string_t identify; float aff_1; float aff_2; float rank; string_t bind_place; string_t bind; name = "netmhcpan-2.8a"; while(fgets(row, MAX_ROW_SIZE, profile->input) != NULL) if ( sscanf ( row, " %d %64[^ \t] %64[^ \t] %64[^ \t] %f %f %f%64[ <=a-zA-Z\n]", &row_number, hla, epitope, identify, &aff_1, &aff_2, &rank, bind_place ) == 8 ) { if(sscanf(bind_place, " <= %s", bind) != 1) snprintf(bind, STRING_MAX_LENGTH, ""); if(strcmp(bind, "SB") == 0) dump ( profile, name, row_number+1, epitope, -1, "", aff_1, aff_2, rank, "SB" ); else if(strcmp(bind, "WB") == 0) dump ( profile, name, row_number+1, epitope, -1, "", aff_1, aff_2, rank, "WB" ); else if(profile->numeric == TRUE) dump ( profile, name, row_number+1, epitope, -1, "", aff_1, aff_2, rank, NULL ); } } void work_netmhciipan10b(profile_t* profile) { char* name; row_t row; int row_number; string_t hla; string_t epitope; string_t identify; int pos; string_t core; float aff_1; float aff_2; string_t bind_place; string_t bind; name = "netmhciipan-1.0b"; while(fgets(row, MAX_ROW_SIZE, profile->input) != NULL) if ( sscanf ( row, " %d %64[^ \t] %64[^ \t] %64[^ \t] %d %64[^ \t] %f %f%64[ <=a-zA-Z\n]", &row_number, hla, epitope, identify, &pos, core, &aff_1, &aff_2, bind_place ) == 9 ) { if(sscanf(bind_place, " <= %s", bind) != 1) snprintf(bind, STRING_MAX_LENGTH, ""); if(strcmp(bind, "SB") == 0) dump ( profile, name, row_number+1, epitope, pos, core, aff_1, aff_2, -1.0, "SB" ); else if(strcmp(bind, "WB") == 0) dump ( profile, name, row_number+1, epitope, pos, core, aff_1, aff_2, -1.0, "WB" ); else if(profile->numeric == TRUE) dump ( profile, name, row_number+1, epitope, pos, core, aff_1, aff_2, -1.0, NULL ); } } void work_netmhciipan20b(profile_t* profile) { char* name; row_t row; int row_number; string_t hla; string_t epitope; string_t identify; int pos; string_t core; float aff_1; float aff_2; float rank; string_t bind_place; string_t bind; name = "netmhciipan-2.0b"; while(fgets(row, MAX_ROW_SIZE, profile->input) != NULL) if ( sscanf ( row, " %d %64[^ \t] %64[^ \t] %64[^ \t] %d %64[^ \t] %f %f %f%64[ <=a-zA-Z\n]", &row_number, hla, epitope, identify, &pos, core, &aff_1, &aff_2, &rank, bind_place ) == 10 ) { if(sscanf(bind_place, " <= %s", bind) != 1) snprintf(bind, STRING_MAX_LENGTH, ""); if(strcmp(bind, "SB") == 0) dump ( profile, name, row_number+1, epitope, pos, core, aff_1, aff_2, rank, "SB" ); else if(strcmp(bind, "WB") == 0) dump ( profile, name, row_number+1, epitope, pos, core, aff_1, aff_2, rank, "WB" ); else if(profile->numeric == TRUE) dump ( profile, name, row_number+1, epitope, pos, core, aff_1, aff_2, rank, NULL ); } } void work_netmhciipan30c(profile_t* profile) { char* name; row_t row; int row_number; string_t hla; string_t epitope; string_t identify; int pos; string_t core; float aff_1; float aff_2; float rank; string_t bind_place; string_t bind; name = "netmhciipan-3.0c"; while(fgets(row, MAX_ROW_SIZE, profile->input) != NULL) if ( sscanf ( row, " %d %64[^ \t] %64[^ \t] %64[^ \t] %d %64[^ \t] %f %f %f%64[ <=a-zA-Z\n]", &row_number, hla, epitope, identify, &pos, core, &aff_1, &aff_2, &rank, bind_place ) == 10 ) { if(sscanf(bind_place, " <= %s", bind) != 1) snprintf(bind, STRING_MAX_LENGTH, ""); if(strcmp(bind, "SB") == 0) dump ( profile, name, row_number+1, epitope, pos, core, aff_1, aff_2, rank, "SB" ); else if(strcmp(bind, "WB") == 0) dump ( profile, name, row_number+1, epitope, pos, core, aff_1, aff_2, rank, "WB" ); else if(profile->numeric == TRUE) dump ( profile, name, row_number+1, epitope, pos, core, aff_1, aff_2, rank, NULL ); } } void work_netmhciipan31a(profile_t* profile) { char* name; row_t row; int row_number; string_t hla; string_t epitope; string_t identify; int pos; string_t core; float core_rel; float aff_1; float aff_2; float rank; float exp_bind; string_t bind_place; string_t bind; name = "netmhciipan-3.1a"; while(fgets(row, MAX_ROW_SIZE, profile->input) != NULL) if ( sscanf ( row, " %d %64[^ \t] %64[^ \t] %64[^ \t] %d %64[^ \t] %f %f %f %f %f%64[ <=a-zA-Z\n]", &row_number, hla, epitope, identify, &pos, core, &core_rel, &aff_1, &aff_2, &rank, &exp_bind, bind_place ) == 12 ) { if(sscanf(bind_place, " <= %s", bind) != 1) snprintf(bind, STRING_MAX_LENGTH, ""); if(strcmp(bind, "SB") == 0) dump ( profile, name, row_number+1, epitope, pos, core, aff_1, aff_2, rank, "SB" ); else if(strcmp(bind, "WB") == 0) dump ( profile, name, row_number+1, epitope, pos, core, aff_1, aff_2, rank, "WB" ); else if(profile->numeric == TRUE) dump ( profile, name, row_number+1, epitope, pos, core, aff_1, aff_2, rank, NULL ); } } void usage(char* name) { fprintf ( stderr, "Usage: %s [-h] -m model [-s] [-o output_file_prefix] [-p protein_id] [-r protein_reference] [-f protein_file_name] [input_file]\n" " -h\t\tHelp\n" " -m\t\tModel:\n" "\t\'1-3.0c\' for netMHC-3.0c\n" "\t\'2-2.2\' for netMHCII-2.2\n" "\t\'pan_1-2.0c\' for netMHCpan-2.0c\n" "\t\'pan_1-2.4a\' for netMHCpan-2.4a\n" "\t\'pan_1-2.8a\' for netMHCpan-2.8a\n" "\t\'pan_2-1.0b\' for netMHCIIpan-1.0b\n" "\t\'pan_2-2.0b\' for netMHCIIpan-2.0b\n" "\t\'pan_2-3.0c\' for netMHCIIpan-3.0c\n" "\t\'pan_2-3.1a\' for netMHCIIpan-3.1a\n" " -s\t\tGenerate SQL\n" " -n\t\tGenerate numeric format\n" " -o\t\tOutput file prefix (default \'%s\')\n" " -a\t\tAllele (default \'%s\')\n" " -l\t\tLenth (default \'%s\')\n" " -p\t\tProtein ID (default \'%s\')\n" " -r\t\tProtein reference (default \'%s\')\n" " -f\t\tProtein file name (default \'%s\')\n" " input_file\tInput file (default \'%s\' aka stdin)\n", name, DEFAULT_OUTPUT_FILE_PREFIX, DEFAULT_ALLELE, DEFAULT_LENGTH, DEFAULT_PROTEIN_ID, DEFAULT_PROTEIN_REFERENCE, DEFAULT_PROTEIN_FILE_NAME, DEFAULT_INPUT_FILE_NAME ); exit(EXIT_FAILURE); } int main(int arguments_number, char* arguments_values[]) { int option; model_t model; boolean_t generate_sql; char* output_file_prefix; char* input_file_name; profile_t profile; model = MODEL_UNKNOWN; generate_sql = FALSE; profile.numeric = FALSE; output_file_prefix = DEFAULT_OUTPUT_FILE_PREFIX; profile.allele = DEFAULT_ALLELE; profile.length = DEFAULT_LENGTH; profile.protein_id = DEFAULT_PROTEIN_ID; profile.protein_reference = DEFAULT_PROTEIN_REFERENCE; profile.protein_file_name = DEFAULT_PROTEIN_FILE_NAME; input_file_name = DEFAULT_INPUT_FILE_NAME; opterr = 0; while(TRUE) { option = getopt(arguments_number, arguments_values, "hm:sno:a:l:p:r:f:"); if(option == -1) break; switch(option) { case 'h': usage(arguments_values[0]); break; case 'm': if(strcasecmp(optarg, "1-3.0c") == 0) model = MODEL_NETMHC30C; else if(strcasecmp(optarg, "1-3.4a") == 0) model = MODEL_NETMHC34A; else if(strcasecmp(optarg, "2-2.2") == 0) model = MODEL_NETMHCII22; else if(strcasecmp(optarg, "pan_1-2.0c") == 0) model = MODEL_NETMHCPAN20C; else if(strcasecmp(optarg, "pan_1-2.4a") == 0) model = MODEL_NETMHCPAN24A; else if(strcasecmp(optarg, "pan_1-2.8a") == 0) model = MODEL_NETMHCPAN28A; else if(strcasecmp(optarg, "pan_2-1.0b") == 0) model = MODEL_NETMHCIIPAN10B; else if(strcasecmp(optarg, "pan_2-2.0b") == 0) model = MODEL_NETMHCIIPAN20B; else if(strcasecmp(optarg, "pan_2-3.0c") == 0) model = MODEL_NETMHCIIPAN30C; else if(strcasecmp(optarg, "pan_2-3.1a") == 0) model = MODEL_NETMHCIIPAN31A; break; case 's': generate_sql = TRUE; break; case 'n': profile.numeric = TRUE; break; case 'o': output_file_prefix = optarg; break; case 'a': profile.allele = optarg; break; case 'l': profile.length = optarg; break; case 'p': profile.protein_id = optarg; break; case 'r': profile.protein_reference = optarg; break; case 'f': profile.protein_file_name = optarg; break; default: usage(arguments_values[0]); } } if(optind == arguments_number-1) input_file_name = arguments_values[optind]; else if(optind != arguments_number) usage(arguments_values[0]); if(model == MODEL_UNKNOWN) usage(arguments_values[0]); if(strcmp(input_file_name, "-") == 0) profile.input = stdin; else { profile.input = fopen(input_file_name, "r"); if(profile.input == NULL) ERROR("Cannot open input file \'%s\'", input_file_name); } if(generate_sql == TRUE) profile.output_sql = open_sql_file(output_file_prefix); else profile.output_sql = NULL; profile.output_load = open_load_file(output_file_prefix); switch(model) { case MODEL_NETMHC30C: work_netmhc30c(&profile); break; case MODEL_NETMHC34A: work_netmhc34a(&profile); break; case MODEL_NETMHCII22: work_netmhcii22(&profile); break; case MODEL_NETMHCPAN20C: work_netmhcpan20c(&profile); break; case MODEL_NETMHCPAN24A: work_netmhcpan24a(&profile); break; case MODEL_NETMHCPAN28A: work_netmhcpan28a(&profile); break; case MODEL_NETMHCIIPAN10B: work_netmhciipan10b(&profile); break; case MODEL_NETMHCIIPAN20B: work_netmhciipan20b(&profile); break; case MODEL_NETMHCIIPAN30C: work_netmhciipan30c(&profile); break; case MODEL_NETMHCIIPAN31A: work_netmhciipan31a(&profile); break; } fclose(profile.input); if(profile.output_sql != NULL) fclose(profile.output_sql); fclose(profile.output_load); return EXIT_SUCCESS; }
chpublichp/masspred
tools/region_fail-0.15/region_fail.c
<reponame>chpublichp/masspred #include <limits.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #define DEFAULT_OUTPUT_FILE_PREFIX "rf_fail_out" #define DEFAULT_OUTPUT_FILE_NAME_SQL_SUFFIX "sql" #define DEFAULT_OUTPUT_FILE_NAME_LOAD_SUFFIX "load" #define DEFAULT_PROTEIN_ID "" #define DEFAULT_PROTEIN_REFERENCE "" #define DEFAULT_PROTEIN_FILE_NAME "" typedef enum boolean_t { FALSE = 0, TRUE = 1 } boolean_t; typedef enum model_t { MODEL_ANCHOR, MODEL_DISEMBL, MODEL_DISOPRED, MODEL_ISUNSTRUCT, MODEL_IUPRED_LONG, MODEL_IUPRED_SHORT, MODEL_OND, MODEL_PREDISORDER, MODEL_RONN, MODEL_VSL2, MODEL_UNKNOWN } model_t; #define MAX_ROW_SIZE 1024 typedef char row_t[MAX_ROW_SIZE+1]; #define ERROR(format, ...) \ do \ { \ fprintf(stderr, "Error: " format "\n", ##__VA_ARGS__); \ exit(EXIT_FAILURE); \ } \ while(FALSE) \ FILE* open_sql_file(char* output_file_prefix) { char name[PATH_MAX]; FILE* file; snprintf(name, PATH_MAX, "%s.%s", output_file_prefix, DEFAULT_OUTPUT_FILE_NAME_SQL_SUFFIX); file = fopen(name, "a"); if(file == NULL) ERROR("Cannot create output file \'%s\'", name); return file; } FILE* open_load_file(char* output_file_prefix) { char name[PATH_MAX]; FILE* file; snprintf(name, PATH_MAX, "%s.%s", output_file_prefix, DEFAULT_OUTPUT_FILE_NAME_LOAD_SUFFIX); file = fopen(name, "a"); if(file == NULL) ERROR("Cannot create output file \'%s\'", name); return file; } void dump(FILE* output_sql, FILE* output_load, char* name, char* protein_id, char* protein_reference, char* protein_file_name) { if(output_sql != NULL) { fprintf ( output_sql, "INSERT INTO region_fail(protein_id, protein_reference, protein_file_name, type) VALUES(\'%s\', \'%s\', \'%s\', \'%s\');\n", protein_id, protein_reference, protein_file_name, name ); fflush(output_sql); } fprintf ( output_load, "%s\t%s\t%s\t%s\n", protein_id, protein_reference, protein_file_name, name ); fflush(output_load); } void usage(char* name) { fprintf ( stderr, "Usage: %s [-h] -m model [-s] [-o output_file_prefix] [-p protein_id] [-r protein_reference] [-f protein_file_name]\n" " -h\tHelp\n" " -m\tModel\n" "\t\'a\' for anchor format\n" "\t\'d\' for disopred format\n" "\t\'e\' for disembl format\n" "\t\'il\' for iupred long format\n" "\t\'is\' for iupred short format\n" "\t\'o\' for ond format\n" "\t\'p\' for predisorder format\n" "\t\'r\' for ronn format\n" "\t\'u\' for isunstruct format\n" "\t\'v\' for vsl2 format\n" " -s\tGenerate SQL\n" " -o\tOutput file prefix (default \'%s\')\n" " -p\tProtein ID (default \'%s\')\n" " -r\tProtein reference (default \'%s\')\n" " -f\tProtein file name (default \'%s\')\n", name, DEFAULT_OUTPUT_FILE_PREFIX, DEFAULT_PROTEIN_ID, DEFAULT_PROTEIN_REFERENCE, DEFAULT_PROTEIN_FILE_NAME ); exit(EXIT_FAILURE); } int main(int arguments_number, char* arguments_values[]) { int option; model_t model; boolean_t generate_sql; char* output_file_prefix; char* protein_id; char* protein_reference; char* protein_file_name; char* input_file_name; FILE* output_sql; FILE* output_load; model = MODEL_UNKNOWN; generate_sql = FALSE; output_file_prefix = DEFAULT_OUTPUT_FILE_PREFIX; protein_id = DEFAULT_PROTEIN_ID; protein_reference = DEFAULT_PROTEIN_REFERENCE; protein_file_name = DEFAULT_PROTEIN_FILE_NAME; opterr = 0; while(TRUE) { option = getopt(arguments_number, arguments_values, "hm:so:p:r:f:"); if(option == -1) break; switch(option) { case 'h': usage(arguments_values[0]); break; case 'm': switch(optarg[0]) { case 'a': model = MODEL_ANCHOR; break; case 'd': model = MODEL_DISOPRED; break; case 'e': model = MODEL_DISEMBL; break; case 'i': switch(optarg[1]) { case 'l': model = MODEL_IUPRED_LONG; break; case 's': model = MODEL_IUPRED_SHORT; break; } break; case 'o': model = MODEL_OND; break; case 'p': model = MODEL_PREDISORDER; break; case 'r': model = MODEL_RONN; break; case 'u': model = MODEL_ISUNSTRUCT; break; case 'v': model = MODEL_VSL2; break; } break; case 's': generate_sql = TRUE; break; case 'o': output_file_prefix = optarg; break; case 'p': protein_id = optarg; break; case 'r': protein_reference = optarg; break; case 'f': protein_file_name = optarg; break; default: usage(arguments_values[0]); } } if(optind != arguments_number) usage(arguments_values[0]); if(model == MODEL_UNKNOWN) usage(arguments_values[0]); if(generate_sql == TRUE) output_sql = open_sql_file(output_file_prefix); else output_sql = NULL; output_load = open_load_file(output_file_prefix); switch(model) { case MODEL_ANCHOR: dump(output_sql, output_load, "ANCHOR", protein_id, protein_reference, protein_file_name); break; case MODEL_DISEMBL: dump(output_sql, output_load, "DisEMBL", protein_id, protein_reference, protein_file_name); break; case MODEL_DISOPRED: dump(output_sql, output_load, "DISOPRED2", protein_id, protein_reference, protein_file_name); break; case MODEL_ISUNSTRUCT: dump(output_sql, output_load, "IsUnstruct", protein_id, protein_reference, protein_file_name); break; case MODEL_IUPRED_LONG: dump(output_sql, output_load, "IUPred-L", protein_id, protein_reference, protein_file_name); break; case MODEL_IUPRED_SHORT: dump(output_sql, output_load, "IUPred-S", protein_id, protein_reference, protein_file_name); break; case MODEL_OND: dump(output_sql, output_load, "OnDCRF", protein_id, protein_reference, protein_file_name); break; case MODEL_PREDISORDER: dump(output_sql, output_load, "PreDisorder", protein_id, protein_reference, protein_file_name); break; case MODEL_RONN: dump(output_sql, output_load, "RONN", protein_id, protein_reference, protein_file_name); break; case MODEL_VSL2: dump(output_sql, output_load, "VSL2b", protein_id, protein_reference, protein_file_name); break; } if(output_sql != NULL) fclose(output_sql); fclose(output_load); return EXIT_SUCCESS; }
chpublichp/masspred
tools/parjob-0.5/child_dead.c
<gh_stars>0 #include "main.h" void child_dead(int signal) { pid_t pid; int status; int i; while(TRUE) { pid = waitpid(-1, &status, WNOHANG); if(pid == -1) if(errno == ECHILD) break; else error("Cannot waitpid"); if(pid == 0) break; for(i = 0; i < Job_data.size; i++) if(Job_data.children_data[i].pid == pid) { Job_data.children_data[i].used = FALSE; if(WIFEXITED(status)) DEBUG("END pid=%d status=%d command=\'%s\'", pid, WEXITSTATUS(status), Job_data.children_data[i].command); else if(WIFSIGNALED(status)) DEBUG("END pid=%d signal=%d command=\'%s\'", pid, WTERMSIG(status), Job_data.children_data[i].command); else DEBUG("END pid=%d command=\'%s\'", pid, Job_data.children_data[i].command); break; } } }
chpublichp/masspred
tools/region_filter-0.19/work_isunstruct.c
#include "main.h" #define DUMP_SIZE 32 _FUNCTION_DECLARATION_BEGIN_ void work_isunstruct(profile_t* profile) _FUNCTION_DECLARATION_END_ { char* name; row_t row; int row_number; char aa; char status; char dump[DUMP_SIZE+1]; float probability; region_t region; int region_start; int region_end; name = "IsUnstruct"; region = REGION_UNKNOWN; while(fgets(row, MAX_ROW_SIZE, profile->input) != NULL) if(sscanf(row, " %d %c %c%" STRING(DUMP_SIZE) "[^0-9]%f %*s", &row_number, &aa, &status, dump, &probability) == 5) if(profile->numeric == TRUE) if(status == 's') dump_numeric_o(profile, name, row_number, aa, probability); else dump_numeric_d(profile, name, row_number, aa, probability); else { if(status == 's') { if(region == REGION_D) dump_plain_d(profile, name, region_start, region_end); if(region != REGION_O) region_start = row_number; region = REGION_O; } else { if(region == REGION_O) dump_plain_o(profile, name, region_start, region_end); if(region != REGION_D) region_start = row_number; region = REGION_D; } region_end = row_number; } if(profile->numeric != TRUE) switch(region) { case REGION_O: dump_plain_o(profile, name, region_start, region_end); break; case REGION_D: dump_plain_d(profile, name, region_start, region_end); break; } }
chpublichp/masspred
tools/region_filter-0.19/work_predisorder.c
#include "main.h" _FUNCTION_DECLARATION_BEGIN_ void work_predisorder(profile_t* profile) _FUNCTION_DECLARATION_END_ { char* name; row_t row_aa; row_t row_status; float probability[MAX_ROW_SIZE]; int position; int row_number; region_t region; int region_start; int region_end; if(fgets(row_aa, MAX_ROW_SIZE, profile->input) == NULL) return; if(fgets(row_status, MAX_ROW_SIZE, profile->input) == NULL) return; position = 0; while(row_status[position] != '\0') { if(row_status[position] == 'O' || row_status[position] == 'D') if(fscanf(profile->input, "%f", &probability[position]) != 1) return; position++; } name = "PreDisorder"; region = REGION_UNKNOWN; position = 0; row_number = 1; while(row_status[position] != '\0') { if(row_status[position] == 'O' || row_status[position] == 'D') { if(profile->numeric == TRUE) if(row_status[position] == 'O') dump_numeric_o(profile, name, row_number, row_aa[position], probability[position]); else dump_numeric_d(profile, name, row_number, row_aa[position], probability[position]); else { if(row_status[position] == 'O') { if(region == REGION_D) dump_plain_d(profile, name, region_start, region_end); if(region != REGION_O) region_start = row_number; region = REGION_O; } else { if(region == REGION_O) dump_plain_o(profile, name, region_start, region_end); if(region != REGION_D) region_start = row_number; region = REGION_D; } region_end = row_number; } row_number++; } position++; } if(profile->numeric != TRUE) switch(region) { case REGION_O: dump_plain_o(profile, name, region_start, region_end); break; case REGION_D: dump_plain_d(profile, name, region_start, region_end); break; } }
chpublichp/masspred
tools/fasta_tool-0.4/type.h
#ifndef __TYPE__H__ #define __TYPE__H__ typedef enum model_t { MODEL_SPLIT, MODEL_ID, MODEL_CHECKSUM, MODEL_LENGTH, MODEL_GET, MODEL_UNKNOWN } model_t; typedef enum boolean_t { FALSE = 0, TRUE = 1 } boolean_t; #define MAX_ROW_SIZE 1024 typedef char row_t[MAX_ROW_SIZE+1]; #endif