Here, alternative functions and classes for STM32. The program contains a class for the I2C software bus, a class for working with a watchdog timer and time delay functions based on DWT. All functions and classes use the HAL library. Functions and classes were written for the microcontroller stm32f103.
Dependents: STM32_F1XX_Alternative
AlternativeSoftwareI2C.hpp@0:2f819bf6cd99, 2017-05-24 (annotated)
- Committer:
- Yar
- Date:
- Wed May 24 19:04:12 2017 +0000
- Revision:
- 0:2f819bf6cd99
Implemented class for the I2C software bus. The class for working with I2C only supports writing data. Implemented alternative functions for time delays based on DWT. Implemented a class for working with a watchdog timer.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Yar | 0:2f819bf6cd99 | 1 | #ifndef _STM32_ALTERNATIVE_SOFTWARE_I2C_H |
Yar | 0:2f819bf6cd99 | 2 | #define _STM32_ALTERNATIVE_SOFTWARE_I2C_H |
Yar | 0:2f819bf6cd99 | 3 | |
Yar | 0:2f819bf6cd99 | 4 | #include "mbed.h" |
Yar | 0:2f819bf6cd99 | 5 | |
Yar | 0:2f819bf6cd99 | 6 | //#define I2C_SDA_PORT GPIOC |
Yar | 0:2f819bf6cd99 | 7 | //#define I2C_SCL_PORT GPIOC |
Yar | 0:2f819bf6cd99 | 8 | //#define I2C_SDA_PIN 8 |
Yar | 0:2f819bf6cd99 | 9 | //#define I2C_SCL_PIN 9 |
Yar | 0:2f819bf6cd99 | 10 | |
Yar | 0:2f819bf6cd99 | 11 | class SoftwareI2C { |
Yar | 0:2f819bf6cd99 | 12 | private: |
Yar | 0:2f819bf6cd99 | 13 | uint16_t pinSDA; |
Yar | 0:2f819bf6cd99 | 14 | uint16_t pinSCL; |
Yar | 0:2f819bf6cd99 | 15 | uint16_t TimeX; |
Yar | 0:2f819bf6cd99 | 16 | GPIO_TypeDef* I2C_SDA_PORT; |
Yar | 0:2f819bf6cd99 | 17 | GPIO_TypeDef* I2C_SCL_PORT; |
Yar | 0:2f819bf6cd99 | 18 | //void _delay_us(unsigned long delay); |
Yar | 0:2f819bf6cd99 | 19 | public: |
Yar | 0:2f819bf6cd99 | 20 | SoftwareI2C(GPIO_TypeDef* GPIOx_SCL, GPIO_TypeDef* GPIOx_SDA, uint16_t GPIO_PinScl, uint16_t GPIO_PinSda); |
Yar | 0:2f819bf6cd99 | 21 | uint8_t write(uint8_t data); |
Yar | 0:2f819bf6cd99 | 22 | void write(uint8_t address, uint8_t* data, uint8_t length); |
Yar | 0:2f819bf6cd99 | 23 | void start(void); |
Yar | 0:2f819bf6cd99 | 24 | void stop(void); |
Yar | 0:2f819bf6cd99 | 25 | }; |
Yar | 0:2f819bf6cd99 | 26 | |
Yar | 0:2f819bf6cd99 | 27 | |
Yar | 0:2f819bf6cd99 | 28 | #endif // _STM32_ALTERNATIVE_SOFTWARE_I2C_H |