Library for Modtronix NZ32 STM32 boards, like the NZ32-SC151, NZ32-SB072, NZ32-SE411 and others
nz32s.cpp
- Committer:
- modtronix
- Date:
- 2015-08-30
- Revision:
- 3:99cb87ee1792
- Parent:
- 2:cd263c5e86f2
- Child:
- 5:e1297df8ee0d
File content as of revision 3:99cb87ee1792:
/** * File: modtronix_nz32s.cpp * * Author: Modtronix Engineering - www.modtronix.com * * Description: * * Software License Agreement: * This software has been written or modified by Modtronix Engineering. The code * may be modified and can be used free of charge for commercial and non commercial * applications. If this is modified software, any license conditions from original * software also apply. Any redistribution must include reference to 'Modtronix * Engineering' and web link(www.modtronix.com) in the file header. * * THIS SOFTWARE IS PROVIDED IN AN 'AS IS' CONDITION. NO WARRANTIES, WHETHER EXPRESS, * IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE * COMPANY SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. */ #include "mbed.h" #include <stdarg.h> #include <stdio.h> #define DEBUG_ENABLE 1 #include "mx_default_debug.h" //Includes that use debugging - Include AFTER debug defines/includes above! It uses them for debugging! #include "nz32s.h" // DEFINES //////////////////////////////////////////////////////////////////// // GLOBAL VARIABLES /////////////////////////////////////////////////////////// // Function Prototypes //////////////////////////////////////////////////////// IWDG_HandleTypeDef NZ32S::hiwdg; //Watchdog Timer /** * Reset I2C bus */ void NZ32S::i2c_reset(uint8_t busNumber, PinName sda, PinName scl) { #if defined(STM32) || defined(STM32L1) i2c_t objI2C; if (busNumber == 1) { objI2C.i2c = I2C_1; } else if (busNumber == 2) { objI2C.i2c = I2C_2; } objI2C.slave = 0; i2c_init(&objI2C, sda, scl); //i2c_reset(&objI2C); //i2c_init() above calls i2c_reset() //pc.printf("\r\nI2C1 Reset"); MX_DEBUG("\r\nI2C1 Reset"); #endif //#if defined(STM32) || defined(STM32L1) } void NZ32S::print_reset_cause(bool clearFlags) { #if defined(STM32) || defined(STM32L1) if ( __HAL_RCC_GET_FLAG(PWR_FLAG_SB)) MX_DEBUG("\r\nSystem resumed from STANDBY mode"); if ( __HAL_RCC_GET_FLAG(RCC_FLAG_SFTRST)) MX_DEBUG("\r\nSoftware Reset"); if ( __HAL_RCC_GET_FLAG(RCC_FLAG_PORRST)) MX_DEBUG("\r\nPower-On-Reset"); if ( __HAL_RCC_GET_FLAG(RCC_FLAG_PINRST)) // Always set, test other cases first MX_DEBUG("\r\nExternal Pin Reset"); if ( __HAL_RCC_GET_FLAG(RCC_FLAG_IWDGRST) != RESET) MX_DEBUG("\r\nWatchdog Reset"); if ( __HAL_RCC_GET_FLAG(RCC_FLAG_WWDGRST) != RESET) MX_DEBUG("\r\nWindow Watchdog Reset"); if ( __HAL_RCC_GET_FLAG(RCC_FLAG_LPWRRST) != RESET) MX_DEBUG("\r\nLow Power Reset"); // if ( __HAL_RCC_GET_FLAG(RCC_FLAG_BORRST) != RESET) // F4 Usually set with POR // MX_DEBUG("\r\nBrown-Out Reset"); if (clearFlags) { __HAL_RCC_CLEAR_RESET_FLAGS(); // The flags cleared after use } #endif //#if defined(STM32) || defined(STM32L1) }