paparazzi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[paparazzi-commits] [4838] some architecture dependant code to implement


From: antoine drouin
Subject: [paparazzi-commits] [4838] some architecture dependant code to implement timed communications
Date: Wed, 21 Apr 2010 09:21:10 +0000

Revision: 4838
          http://svn.sv.gnu.org/viewvc/?view=rev&root=paparazzi&revision=4838
Author:   poine
Date:     2010-04-21 09:21:09 +0000 (Wed, 21 Apr 2010)
Log Message:
-----------
some architecture dependant code to implement timed communications

Added Paths:
-----------
    
paparazzi3/trunk/sw/airborne/booz/arch/stm32/actuators/booz_actuators_mkk_arch.c
    
paparazzi3/trunk/sw/airborne/booz/arch/stm32/actuators/booz_actuators_mkk_arch.h

Added: 
paparazzi3/trunk/sw/airborne/booz/arch/stm32/actuators/booz_actuators_mkk_arch.c
===================================================================
--- 
paparazzi3/trunk/sw/airborne/booz/arch/stm32/actuators/booz_actuators_mkk_arch.c
                            (rev 0)
+++ 
paparazzi3/trunk/sw/airborne/booz/arch/stm32/actuators/booz_actuators_mkk_arch.c
    2010-04-21 09:21:09 UTC (rev 4838)
@@ -0,0 +1,57 @@
+#include "actuators/booz_actuators_mkk.h"
+
+#include "i2c.h"
+
+#include <stm32/rcc.h>
+#include <stm32/misc.h>
+
+/* ---------------------------------------------------------------
+    TIM2 Configuration: Output Compare Timing Mode:
+    TIM2CLK = 36 MHz, Prescaler = 4, TIM2 counter clock = 7.2 MHz
+*/
+
+void booz_actuators_mkk_arch_init(void) {                      
+
+  /* TIM2 clock enable */
+  RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);
+
+  /* Time base configuration */                        
+  TIM_TimeBaseInitTypeDef  TIM_TimeBaseStructure;
+  TIM_TimeBaseStructure.TIM_Period = 3072;             
+  //  TIM_TimeBaseStructure.TIM_Period = 2048;         
+  TIM_TimeBaseStructure.TIM_Prescaler = 0;             
+  TIM_TimeBaseStructure.TIM_ClockDivision = 0; 
+  TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
+  TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure);      
+  /* Prescaler configuration */
+  TIM_PrescalerConfig(TIM2, 4, TIM_PSCReloadMode_Immediate);
+
+  /* Enable the TIM2 global Interrupt */               
+  NVIC_InitTypeDef NVIC_InitStructure;         
+  NVIC_InitStructure.NVIC_IRQChannel = TIM2_IRQn;      
+  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
+  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3;   
+  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;      
+  NVIC_Init(&NVIC_InitStructure);                      
+  
+  //  DEBUG5_INIT();
+
+  TIM_Cmd(TIM2, ENABLE);                                                       
                        
+
+}
+
+void tim2_irq_handler(void) {
+  //  DEBUG5_T();
+
+  /* Clear TIM2 update interrupt */
+  TIM_ClearITPendingBit(TIM2, TIM_IT_Update);
+  actuators_mkk.idx++;                                                 
+  if (actuators_mkk.idx<ACTUATORS_MKK_NB) {                            
+    DeviceBuf[0] = supervision.commands[actuators_mkk.idx];            
+    DeviceTransmit(actuators_addr[actuators_mkk.idx], 1, 
&actuators_mkk.i2c_done);
+  }                                                            
+  else {
+    actuators_mkk.status = IDLE;
+    TIM_ITConfig(TIM2, TIM_IT_Update, DISABLE);
+  }
+}

Added: 
paparazzi3/trunk/sw/airborne/booz/arch/stm32/actuators/booz_actuators_mkk_arch.h
===================================================================
--- 
paparazzi3/trunk/sw/airborne/booz/arch/stm32/actuators/booz_actuators_mkk_arch.h
                            (rev 0)
+++ 
paparazzi3/trunk/sw/airborne/booz/arch/stm32/actuators/booz_actuators_mkk_arch.h
    2010-04-21 09:21:09 UTC (rev 4838)
@@ -0,0 +1,40 @@
+/*
+ * $Id$
+ *  
+ * Copyright (C) 2009 Antoine Drouin <address@hidden>
+ *
+ * This file is part of paparazzi.
+ *
+ * paparazzi is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * paparazzi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with paparazzi; see the file COPYING.  If not, write to
+ * the Free Software Foundation, 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA. 
+ */
+
+#ifndef BOOZ_ACTUATORS_MKK_ARCH_H
+#define BOOZ_ACTUATORS_MKK_ARCH_H
+
+#include <stm32/tim.h>
+#include <stm32/gpio.h>
+
+
+
+
+#define BoozActuatorsMkkArchSend() {           \
+    /*DEBUG5_T();*/                            \
+    TIM_SetCounter(TIM2, 0);                   \
+    TIM_ClearITPendingBit(TIM2, TIM_IT_Update); \
+    TIM_ITConfig(TIM2, TIM_IT_Update, ENABLE); \
+  }
+
+#endif /* BOOZ_ACTUATORS_MKK_ARCH_H */





reply via email to

[Prev in Thread] Current Thread [Next in Thread]