mbed library sources. Supersedes mbed-src. Add PORTG support for STM32L476JG (SensorTile kit)

Dependents:   SensorTileTest

Fork of mbed-dev by mbed official

Committer:
<>
Date:
Tue Dec 20 17:27:56 2016 +0000
Revision:
153:fa9ff456f731
This updates the lib to the mbed lib v132

Who changed what in which revision?

UserRevisionLine numberNew contents of line
<> 153:fa9ff456f731 1 /* mbed Microcontroller Library
<> 153:fa9ff456f731 2 * Copyright (c) 2006-2016 ARM Limited
<> 153:fa9ff456f731 3 *
<> 153:fa9ff456f731 4 * Licensed under the Apache License, Version 2.0 (the "License");
<> 153:fa9ff456f731 5 * you may not use this file except in compliance with the License.
<> 153:fa9ff456f731 6 * You may obtain a copy of the License at
<> 153:fa9ff456f731 7 *
<> 153:fa9ff456f731 8 * http://www.apache.org/licenses/LICENSE-2.0
<> 153:fa9ff456f731 9 *
<> 153:fa9ff456f731 10 * Unless required by applicable law or agreed to in writing, software
<> 153:fa9ff456f731 11 * distributed under the License is distributed on an "AS IS" BASIS,
<> 153:fa9ff456f731 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<> 153:fa9ff456f731 13 * See the License for the specific language governing permissions and
<> 153:fa9ff456f731 14 * limitations under the License.
<> 153:fa9ff456f731 15 */
<> 153:fa9ff456f731 16 #include <stddef.h>
<> 153:fa9ff456f731 17 #include "us_ticker_api.h"
<> 153:fa9ff456f731 18 #include "PeripheralNames.h"
<> 153:fa9ff456f731 19 #include "hal_tick.h"
<> 153:fa9ff456f731 20
<> 153:fa9ff456f731 21 // A 32-bit timer is used
<> 153:fa9ff456f731 22 #if !TIM_MST_16BIT
<> 153:fa9ff456f731 23
<> 153:fa9ff456f731 24 TIM_HandleTypeDef TimMasterHandle;
<> 153:fa9ff456f731 25
<> 153:fa9ff456f731 26 static int us_ticker_inited = 0;
<> 153:fa9ff456f731 27
<> 153:fa9ff456f731 28 void us_ticker_init(void)
<> 153:fa9ff456f731 29 {
<> 153:fa9ff456f731 30 if (us_ticker_inited) return;
<> 153:fa9ff456f731 31 us_ticker_inited = 1;
<> 153:fa9ff456f731 32
<> 153:fa9ff456f731 33 TimMasterHandle.Instance = TIM_MST;
<> 153:fa9ff456f731 34
<> 153:fa9ff456f731 35 HAL_InitTick(0); // The passed value is not used
<> 153:fa9ff456f731 36 }
<> 153:fa9ff456f731 37
<> 153:fa9ff456f731 38 uint32_t us_ticker_read()
<> 153:fa9ff456f731 39 {
<> 153:fa9ff456f731 40 if (!us_ticker_inited) us_ticker_init();
<> 153:fa9ff456f731 41 return TIM_MST->CNT;
<> 153:fa9ff456f731 42 }
<> 153:fa9ff456f731 43
<> 153:fa9ff456f731 44 void us_ticker_set_interrupt(timestamp_t timestamp)
<> 153:fa9ff456f731 45 {
<> 153:fa9ff456f731 46 TimMasterHandle.Instance = TIM_MST;
<> 153:fa9ff456f731 47 // Set new output compare value
<> 153:fa9ff456f731 48 __HAL_TIM_SET_COMPARE(&TimMasterHandle, TIM_CHANNEL_1, (uint32_t)timestamp);
<> 153:fa9ff456f731 49 // Enable IT
<> 153:fa9ff456f731 50 __HAL_TIM_ENABLE_IT(&TimMasterHandle, TIM_IT_CC1);
<> 153:fa9ff456f731 51 }
<> 153:fa9ff456f731 52
<> 153:fa9ff456f731 53 void us_ticker_disable_interrupt(void)
<> 153:fa9ff456f731 54 {
<> 153:fa9ff456f731 55 TimMasterHandle.Instance = TIM_MST;
<> 153:fa9ff456f731 56 __HAL_TIM_DISABLE_IT(&TimMasterHandle, TIM_IT_CC1);
<> 153:fa9ff456f731 57 }
<> 153:fa9ff456f731 58
<> 153:fa9ff456f731 59 void us_ticker_clear_interrupt(void)
<> 153:fa9ff456f731 60 {
<> 153:fa9ff456f731 61 TimMasterHandle.Instance = TIM_MST;
<> 153:fa9ff456f731 62 __HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
<> 153:fa9ff456f731 63 }
<> 153:fa9ff456f731 64
<> 153:fa9ff456f731 65 #endif // !TIM_MST_16BIT