{"id":323,"date":"2017-11-23T21:05:17","date_gmt":"2017-11-23T20:05:17","guid":{"rendered":"http:\/\/mikrocontroller.bplaced.net\/wordpress\/?page_id=323"},"modified":"2017-12-30T19:31:09","modified_gmt":"2017-12-30T18:31:09","slug":"20-spi_l3gd20-library-stm32f429","status":"publish","type":"page","link":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/?page_id=323","title":{"rendered":"20-SPI_L3GD20-Library (STM32F429)"},"content":{"rendered":"<p><div id=\"nav-below\" class=\"navigation\"><div class=\"nav-previous\"><a href=\"https:\/\/mikrocontroller.bplaced.net\/wordpress\/?page_id=321\" title=\"19-LCD_Graphic-Library (STM32F429)\"><span class=\"meta-nav\">\u2190<\/span> 19-LCD_Graphic-Library (STM32F429)<\/a><\/div><\/div><!-- #nav-below --><div id=\"nav-below\" class=\"navigation\"><div class=\"nav-next\"><a href=\"https:\/\/mikrocontroller.bplaced.net\/wordpress\/?page_id=325\" title=\"21-USB_MSC_HOST-Library (STM32F429)\">21-USB_MSC_HOST-Library (STM32F429) <span class=\"meta-nav\">&rarr;<\/span><\/a><\/div><\/div><!-- #nav-below --><\/p>\n<p>Auf dem STM32F429 Discovery-Board ist ein 3Achs-Drehraten-Sensor eingebaut (L3GD20)<br \/>\nMit diesem k\u00f6nnen die Winkelgeschwindigkeiten der X-, Y-, Z-Achse gemessen werden. Der Sensor hat eine Genauigkeit von 16bit und eine umschaltbare<br \/>\nAufl\u00f6sung von +\/-250dps , +\/-500dps , +\/-2000dps<\/p>\n<p>Ich habe die Library so einfach wie m\u00f6glich gehalten und die Interrupt M\u00f6glichkeiten z.B. gar nicht mit eingebaut.<\/p>\n<p>Der Sensor h\u00e4ngt am SPI5 aus dem Grund wird die SPI5-Lib auch ben\u00f6tigt.<\/p>\n<p><strong>Beispielbild :<\/strong><\/p>\n<p><a href=\"wp-content\/uploads\/2013\/11\/l3gd20.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-2948\" src=\"wp-content\/uploads\/2013\/11\/l3gd20-179x300.jpg\" alt=\"l3gd20\" width=\"179\" height=\"300\" \/><\/a><\/p>\n<p><strong>Benutzte Pins :<\/strong><\/p>\n<pre lang=\"c\" line=\"1\">SCK an PF7\r\nMOSI an PF9\r\nMISO an PF8\r\nChipSelect an PC1<\/pre>\n<p><strong>Enumerationen :<\/strong><\/p>\n<pre lang=\"c\" line=\"1\">typedef enum {\r\n  SCALE_250 = 0,  \/\/ 250\r\n  SCALE_500,      \/\/ 500\r\n  SCALE_2000      \/\/ 2000\r\n}L3GD20_SCALE_t;<\/pre>\n<p><strong>Struktur<\/strong><\/p>\n<pre lang=\"c\" line=\"1\">typedef struct {\r\n  int16_t x_achse; \/\/ Drehrate der X-Achse\r\n  int16_t y_achse; \/\/ Drehrate der Y-Achse\r\n  int16_t z_achse; \/\/ Drehrate der Z-Achse\r\n}L3GD20_t;\r\nL3GD20_t L3GD20;<\/pre>\n<p><strong>Funktionen :<\/strong><\/p>\n<pre lang=\"c\" line=\"1\">ErrorStatus UB_L3GD20_Init(L3GD20_SCALE_t scale);\r\nvoid UB_L3GD20_Read(void);<\/pre>\n<p><strong>Beispiel :<\/strong><\/p>\n<pre lang=\"c\" line=\"1\">\/\/--------------------------------------------------------------\r\n\/\/ File     : main.c\r\n\/\/ Datum    : 07.11.2013\r\n\/\/ Version  : 1.0\r\n\/\/ Autor    : UB\r\n\/\/ EMail    : mc-4u(@)t-online.de\r\n\/\/ Web      : www.mikrocontroller-4u.de\r\n\/\/ CPU      : STM32F429\r\n\/\/ IDE      : CooCox CoIDE 1.7.4\r\n\/\/ GCC      : 4.7 2012q4\r\n\/\/ Module   : CMSIS_BOOT, M4_CMSIS_CORE\r\n\/\/ Funktion : Demo der L3GD20-Library\r\n\/\/ Hinweis  : Diese zwei Files muessen auf 8MHz stehen\r\n\/\/              \"cmsis_boot\/stm32f4xx.h\"\r\n\/\/              \"cmsis_boot\/system_stm32f4xx.c\"\r\n\/\/ In Configuration diese Define hinzuf\u00fcgen :\r\n\/\/ \"STM32F429_439xx\" , \"__ASSEMBLY__\" , \"USE_STDPERIPH_DRIVER\"\r\n\/\/--------------------------------------------------------------\r\n\r\n#include \"main.h\"\r\n#include \"stm32_ub_lcd_ili9341.h\"\r\n#include \"stm32_ub_font.h\"\r\n#include \"stm32_ub_l3gd20.h\"\r\n#include &lt;stdio.h&gt;\r\n\r\nint main(void)\r\n{\r\n  ErrorStatus check;\r\n  int16_t x,y,z;\r\n  char buf[30];\r\n\r\n  SystemInit(); \/\/ Quarz Einstellungen aktivieren\r\n\r\n  \/\/ Init vom LCD\r\n  UB_LCD_Init();\r\n  \/\/ Init der Layer\r\n  UB_LCD_LayerInit_Fullscreen();\r\n  \/\/ auf Hintergrund schalten\r\n  UB_LCD_SetLayer_1();\r\n  \/\/ Hintergrund komplett mit einer Farbe f\u00fcllen\r\n  UB_LCD_FillLayer(RGB_COL_WHITE);\r\n  \/\/ auf Vordergrund schalten\r\n  UB_LCD_SetLayer_2();\r\n  \/\/ Vordergrund komplett mit einer Farbe f\u00fcllen\r\n  UB_LCD_FillLayer(RGB_COL_GREEN);\r\n\r\n  UB_LCD_Rotate_180();\r\n\r\n  \/\/ Ueberschrift\r\n  UB_Font_DrawString(10,10,\"Demo_20 :  \",&amp;Arial_11x18,RGB_COL_WHITE,RGB_COL_RED);\r\n  UB_Font_DrawString(10,30,\"Gyro L3GD20\",&amp;Arial_11x18,RGB_COL_WHITE,RGB_COL_RED);\r\n\r\n  \/\/ init vom Drehraten-Sensor\r\n  check=UB_L3GD20_Init(SCALE_250);\r\n  if(check==ERROR) {\r\n    UB_Font_DrawString(10,70,\"Error\",&amp;Arial_11x18,RGB_COL_WHITE,RGB_COL_RED);\r\n    while(1);\r\n  }\r\n\r\n  while(1)\r\n  {\r\n    \/\/ Sensorwerte einlesen\r\n    UB_L3GD20_Read();\r\n    \/\/ X-Achse anzeigen\r\n    x=L3GD20.x_achse;\r\n    sprintf(buf,\"X=%5d\",x);\r\n    UB_Font_DrawString(10,90,buf,&amp;Arial_11x18,RGB_COL_BLACK,RGB_COL_GREEN);\r\n    \/\/ Y-Achse anzeigen\r\n    y=L3GD20.y_achse;\r\n    sprintf(buf,\"Y=%5d\",y);\r\n    UB_Font_DrawString(10,110,buf,&amp;Arial_11x18,RGB_COL_BLACK,RGB_COL_GREEN);\r\n    \/\/ Z-Achse anzeigen\r\n    z=L3GD20.z_achse;\r\n    sprintf(buf,\"Z=%5d\",z);\r\n    UB_Font_DrawString(10,130,buf,&amp;Arial_11x18,RGB_COL_BLACK,RGB_COL_GREEN);\r\n\r\n  }\r\n}\r\n<\/pre>\n<p>Hier die Library zum\u00a0<strong>Download :<\/strong><\/p>\n<p><a href=\"wp-content\/uploads\/2013\/11\/l3gd20_f429_v100.zip\">l3gd20_f429_v100<\/a><\/p>\n<p>Hier der komplette CooCox-Projektordner zum\u00a0<strong>Download :<\/strong><\/p>\n<p><a href=\"wp-content\/uploads\/2013\/11\/Demo_F429_20.zip\">Demo_F429_20<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Auf dem STM32F429 Discovery-Board ist ein 3Achs-Drehraten-Sensor eingebaut (L3GD20) Mit diesem k\u00f6nnen die Winkelgeschwindigkeiten der X-, Y-, Z-Achse gemessen werden. Der Sensor hat eine Genauigkeit von 16bit und eine umschaltbare Aufl\u00f6sung von +\/-250dps , +\/-500dps , +\/-2000dps Ich habe die &hellip; <a href=\"https:\/\/mikrocontroller.bplaced.net\/wordpress\/?page_id=323\">Weiterlesen <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"parent":160,"menu_order":20,"comment_status":"open","ping_status":"closed","template":"","meta":{"footnotes":""},"categories":[129],"tags":[9,49,102],"class_list":["post-323","page","type-page","status-publish","hentry","category-stm32f429","tag-library","tag-spi","tag-stm32f429"],"_links":{"self":[{"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=\/wp\/v2\/pages\/323","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=323"}],"version-history":[{"count":3,"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=\/wp\/v2\/pages\/323\/revisions"}],"predecessor-version":[{"id":1686,"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=\/wp\/v2\/pages\/323\/revisions\/1686"}],"up":[{"embeddable":true,"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=\/wp\/v2\/pages\/160"}],"wp:attachment":[{"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=323"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=323"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=323"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}