X-CUBE-SPN1-20150128 example source code for one motor compiled under mbed. Tested OK on Nucleo F401. l6474.cpp is modified from original with defines in l6474_target_config.h to select the original behaviour (motor de-energised when halted), or new mode to continue powering with a (reduced) current in the coils (braking/position hold capability). On F401 avoid using mbed's InterruptIn on pins 10-15 (any port). Beware of other conflicts! L0 & F0 are included but untested.

Dependencies:   mbed

Committer:
gregeric
Date:
Fri Sep 18 09:55:03 2015 +0000
Revision:
2:d6f513e1313b
Parent:
1:75a41f0c0586
Child:
6:19c1b4a04c24
Added warnings re untested platforms.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
gregeric 0:b9444a40a999 1
gregeric 0:b9444a40a999 2 /**
gregeric 0:b9444a40a999 3 ******************************************************************************
gregeric 0:b9444a40a999 4 * @file Multi/Examples/MotionControl/IHM01A1_ExampleFor1Motor/Inc/main.h
gregeric 0:b9444a40a999 5 * @author IPC Rennes
gregeric 0:b9444a40a999 6 * @version V1.5.0
gregeric 0:b9444a40a999 7 * @date November 12, 2014
gregeric 0:b9444a40a999 8 * @brief Header for main.c module
gregeric 0:b9444a40a999 9 ******************************************************************************
gregeric 0:b9444a40a999 10 * @attention
gregeric 0:b9444a40a999 11 *
gregeric 0:b9444a40a999 12 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
gregeric 0:b9444a40a999 13 *
gregeric 0:b9444a40a999 14 * Redistribution and use in source and binary forms, with or without modification,
gregeric 0:b9444a40a999 15 * are permitted provided that the following conditions are met:
gregeric 0:b9444a40a999 16 * 1. Redistributions of source code must retain the above copyright notice,
gregeric 0:b9444a40a999 17 * this list of conditions and the following disclaimer.
gregeric 0:b9444a40a999 18 * 2. Redistributions in binary form must reproduce the above copyright notice,
gregeric 0:b9444a40a999 19 * this list of conditions and the following disclaimer in the documentation
gregeric 0:b9444a40a999 20 * and/or other materials provided with the distribution.
gregeric 0:b9444a40a999 21 * 3. Neither the name of STMicroelectronics nor the names of its contributors
gregeric 0:b9444a40a999 22 * may be used to endorse or promote products derived from this software
gregeric 0:b9444a40a999 23 * without specific prior written permission.
gregeric 0:b9444a40a999 24 *
gregeric 0:b9444a40a999 25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
gregeric 0:b9444a40a999 26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
gregeric 0:b9444a40a999 27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
gregeric 0:b9444a40a999 28 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
gregeric 0:b9444a40a999 29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
gregeric 0:b9444a40a999 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
gregeric 0:b9444a40a999 31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
gregeric 0:b9444a40a999 32 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
gregeric 0:b9444a40a999 33 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
gregeric 0:b9444a40a999 34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
gregeric 0:b9444a40a999 35 *
gregeric 0:b9444a40a999 36 ******************************************************************************
gregeric 0:b9444a40a999 37 */
gregeric 0:b9444a40a999 38
gregeric 0:b9444a40a999 39 /* Define to prevent recursive inclusion -------------------------------------*/
gregeric 0:b9444a40a999 40 #ifndef __MAIN_H
gregeric 0:b9444a40a999 41 #define __MAIN_H
gregeric 0:b9444a40a999 42
gregeric 0:b9444a40a999 43 /* Includes ------------------------------------------------------------------*/
gregeric 0:b9444a40a999 44 #include "motorcontrol.h"
gregeric 0:b9444a40a999 45 #include "l6474.h"
gregeric 0:b9444a40a999 46
gregeric 0:b9444a40a999 47 #if defined TARGET_STM32F4
gregeric 0:b9444a40a999 48 #include "stm32f4xx_nucleo_ihm01a1.h"
gregeric 0:b9444a40a999 49 #elif defined TARGET_STM32F0
gregeric 2:d6f513e1313b 50 #warning Untested platform!
gregeric 0:b9444a40a999 51 #include "stm32f0xx_nucleo_ihm01a1.h"
gregeric 0:b9444a40a999 52 #elif defined TARGET_STM32L0
gregeric 2:d6f513e1313b 53 #warning Untested platform!
gregeric 0:b9444a40a999 54 #include "stm32l0xx_nucleo_ihm01a1.h"
gregeric 0:b9444a40a999 55 #else
gregeric 0:b9444a40a999 56 #error Unknown Target: only STM32F0xx, F4xx, L0xx are supported.
gregeric 0:b9444a40a999 57 #endif
gregeric 0:b9444a40a999 58
gregeric 0:b9444a40a999 59 /* Exported types ------------------------------------------------------------*/
gregeric 0:b9444a40a999 60 /* Exported constants --------------------------------------------------------*/
gregeric 0:b9444a40a999 61 /* Exported functions ------------------------------------------------------- */
gregeric 0:b9444a40a999 62 void SystemClock_Config(void);
gregeric 0:b9444a40a999 63 void Error_Handler(uint16_t error);
gregeric 0:b9444a40a999 64
gregeric 0:b9444a40a999 65 #endif /* __MAIN_H */
gregeric 0:b9444a40a999 66
gregeric 0:b9444a40a999 67 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/