Received: from PCH.mit.edu (18.7.21.50) by mail.efplus.com (192.168.0.8) with Microsoft SMTP Server (TLS) id 8.3.485.1; Thu, 30 Jul 2020 09:58:53 -0700 Received: from PCH.MIT.EDU (localhost.localdomain [127.0.0.1]) by PCH.mit.edu (8.14.7/8.12.8) with ESMTP id 06UGoUYC015084; Thu, 30 Jul 2020 12:50:43 -0400 Received: from outgoing-exchange-1.mit.edu (OUTGOING-EXCHANGE-1.MIT.EDU [18.9.28.15]) by PCH.mit.edu (8.14.7/8.12.8) with ESMTP id 06UGoTHd015079 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Jul 2020 12:50:29 -0400 Received: from w92exedge3.exchange.mit.edu (W92EXEDGE3.EXCHANGE.MIT.EDU [18.7.73.15]) by outgoing-exchange-1.mit.edu (8.14.7/8.12.4) with ESMTP id 06UGmr5e014321 for ; Thu, 30 Jul 2020 12:49:06 -0400 Received: from w92expo22.exchange.mit.edu (18.7.74.76) by w92exedge3.exchange.mit.edu (18.7.73.15) with Microsoft SMTP Server (TLS) id 15.0.1293.2; Thu, 30 Jul 2020 12:49:44 -0400 Received: from oc11exhyb4.exchange.mit.edu (18.9.1.100) by w92expo22.exchange.mit.edu (18.7.74.76) with Microsoft SMTP Server (TLS) id 15.0.1365.1; Thu, 30 Jul 2020 12:50:08 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.102) by oc11exhyb4.exchange.mit.edu (18.9.1.100) with Microsoft SMTP Server (TLS) id 15.0.1395.4 via Frontend Transport; Thu, 30 Jul 2020 12:50:07 -0400 Received: from DM6PR02CA0109.namprd02.prod.outlook.com (2603:10b6:5:1b4::11) by DM5PR01MB2572.prod.exchangelabs.com (2603:10b6:3:46::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3216.26; Thu, 30 Jul 2020 16:50:05 +0000 Received: from DM3NAM03FT021.eop-NAM03.prod.protection.outlook.com (2603:10b6:5:1b4:cafe::a4) by DM6PR02CA0109.outlook.office365.com (2603:10b6:5:1b4::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3239.16 via Frontend Transport; Thu, 30 Jul 2020 16:50:05 +0000 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (40.92.23.98) by DM3NAM03FT021.mail.protection.outlook.com (10.152.82.187) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3216.10 via Frontend Transport; Thu, 30 Jul 2020 16:50:05 +0000 Received: from MW2NAM12FT035.eop-nam12.prod.protection.outlook.com (2a01:111:e400:fc65::49) by MW2NAM12HT066.eop-nam12.prod.protection.outlook.com (2a01:111:e400:fc65::134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3239.14; Thu, 30 Jul 2020 16:50:02 +0000 Received: from BYAPR02MB4055.namprd02.prod.outlook.com (2a01:111:e400:fc65::46) by MW2NAM12FT035.mail.protection.outlook.com (2a01:111:e400:fc65::274) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3239.14 via Frontend Transport; Thu, 30 Jul 2020 16:50:02 +0000 Received: from BYAPR02MB4055.namprd02.prod.outlook.com ([fe80::e04e:e8e2:57be:7927]) by BYAPR02MB4055.namprd02.prod.outlook.com ([fe80::e04e:e8e2:57be:7927%7]) with mapi id 15.20.3216.034; Thu, 30 Jul 2020 16:50:02 +0000 From: Bob Blick To: Microcontroller discussion list - Public. Sender: "piclist-bounces@mit.edu" Date: Thu, 30 Jul 2020 09:50:02 -0700 Subject: Re: [PIC] Simple GCC question Thread-Topic: [PIC] Simple GCC question Thread-Index: AQHWZotc+nNhZovUu0iBK4Bhj1/IWakgUpsAgAAC+G8= Message-ID: References: , List-Help: List-Subscribe: , List-Unsubscribe: , In-Reply-To: Reply-To: Microcontroller discussion list - Public. Accept-Language: en-US Content-Language: en-US X-MS-Exchange-Organization-AuthAs: Anonymous X-MS-Exchange-Organization-AuthSource: TS500.efplus4.local X-MS-Has-Attach: X-Auto-Response-Suppress: All X-MS-Exchange-Organization-SenderIdResult: Pass X-MS-Exchange-Organization-PRD: mit.edu X-MS-TNEF-Correlator: acceptlanguage: en-US received-spf: Pass (protection.outlook.com: domain of outlook.com designates 40.92.23.98 as permitted sender) receiver=protection.outlook.com; client-ip=40.92.23.98; helo=NAM12-MW2-obe.outbound.protection.outlook.com; dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XVgehww7eTPm6zOscPztpuN3IeosUftYqUZfQlhzWEU=; b=tERu6MfuK0+gZkdG2ie+EjaR2jezoJ2GW9+XqooIOeLspot79SOJfIpe4H52co4AFrsIMIx7WGF8QGlX42D4TS7Wiu7wEG0e0U6JKG+IQe53L1ANKuoGglLcfAcSpiOLqJ1dSZa3A11vaSzOWt+w6R8/p3mzQxRGy7ddLn8u78MOoofqLSvT6BPqrzNN47e6+ftYv82WfEKmoBcr03fapBvR8lVsQgkZV93p0uz2N5QJosw3QQl0ChYPqn+Nhd/t9oF4d/FXeBQt4icpXbiyDFG1rBbu7wqyzEOQoHtAdmyWG5YEanruG0FnMrXdWfACnGznIH4Ivxa5Y3J0v1KdOg== authentication-results: spf=pass (sender IP is 40.92.23.98) smtp.mailfrom=outlook.com; mit.edu; dkim=pass (signature was verified) header.d=outlook.com; mit.edu; dmarc=pass action=none header.from=outlook.com; errors-to: piclist-bounces@mit.edu list-id: "Microcontroller discussion list - Public." list-post: x-beenthere: piclist@mit.edu x-mailman-version: 2.1.6 x-topics: [PIC] x-mime-autoconverted: from quoted-printable to 8bit by PCH.mit.edu id 06UGoTHd015079 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Hi Sean, Here it is: https://github.com/4ilo/HD44780-Stm32HAL Thanks, Bob ________________________________________ From: piclist-bounces@mit.edu on behalf of Sean B= reheny=20 Sent: Thursday, July 30, 2020 9:38 AM To: Microcontroller discussion list - Public. Subject: Re: [PIC] Simple GCC question Hi Bob, Do you have a link to the library you are using? I don't understand what the type of LCD_D4_GPIO_Port, etc. is. Sean On Thu, Jul 30, 2020 at 12:27 PM Bob Blick wrote: > I'm using a nice little HD44780 LCD library in an STM32 project, it works > great but I'm stuck with a variable scope problem that I can only seem to > make worse because GCC is a bit stricter than I want it to be at this > point. Sorry if the code example doesn't wordwrap properly. > > If, somewhere in main() I create an instance of the LCD like this: > Lcd_PortType ports[] =3D {LCD_D4_GPIO_Port, LCD_D5_GPIO_Port, > LCD_D6_GPIO_Port, LCD_D7_GPIO_Port}; > Lcd_PinType pins[] =3D {LCD_D4_Pin, LCD_D5_Pin, LCD_D6_Pin, LCD_D7_Pin}= ; > Lcd_HandleTypeDef lcd =3D Lcd_create(ports, pins, LCD_RS_GPIO_Port, > LCD_RS_Pin, LCD_EN_GPIO_Port, LCD_EN_Pin, LCD_4_BIT_MODE); > > then I can use it like this: > Lcd_cursor(&lcd, 1,6); > > but of course I can't do that from within another function since "lcd" > only exists in main() > > If I try to make it all global by creating lcd outside of main(), GCC > doesn't like that because initializer elements must be constants and it > doesn't consider "ports" and "pins" to be constants. > > Not being a real C programmer this has stopped me in my tracks. If I was > stuck on a deserted island I would use this library as a basis for > something with ports and pins hardcoded, but I'm hoping a real expert wou= ld > give me some gentle help, which will certainly educate me about doing > things the correct way and also get me past this little hurdle. > > Thanks, Bob --=20 http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .