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 10:45:43 -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 06UHbTci022657; Thu, 30 Jul 2020 13:37:37 -0400 Received: from outgoing-exchange-5.mit.edu (OUTGOING-EXCHANGE-5.MIT.EDU [18.9.28.59]) by PCH.mit.edu (8.14.7/8.12.8) with ESMTP id 06UHbSie022654 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Jul 2020 13:37:28 -0400 Received: from oc11exedge2.exchange.mit.edu (OC11EXEDGE2.EXCHANGE.MIT.EDU [18.9.3.18]) by outgoing-exchange-5.mit.edu (8.14.7/8.12.4) with ESMTP id 06UHbEaq029031 for ; Thu, 30 Jul 2020 13:37:15 -0400 Received: from w92expo25.exchange.mit.edu (18.7.74.31) by oc11exedge2.exchange.mit.edu (18.9.3.18) with Microsoft SMTP Server (TLS) id 15.0.1293.2; Thu, 30 Jul 2020 13:36:58 -0400 Received: from oc11exhyb4.exchange.mit.edu (18.9.1.100) by w92expo25.exchange.mit.edu (18.7.74.31) with Microsoft SMTP Server (TLS) id 15.0.1365.1; Thu, 30 Jul 2020 13:37:12 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.172) 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 13:37:12 -0400 Received: from DM5PR08CA0053.namprd08.prod.outlook.com (2603:10b6:4:60::42) by BN6PR01MB2788.prod.exchangelabs.com (2603:10b6:404:d1::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3216.25; Thu, 30 Jul 2020 17:37:11 +0000 Received: from DM3NAM03FT004.eop-NAM03.prod.protection.outlook.com (2603:10b6:4:60:cafe::ef) by DM5PR08CA0053.outlook.office365.com (2603:10b6:4:60::42) 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 17:37:11 +0000 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (40.92.40.20) by DM3NAM03FT004.mail.protection.outlook.com (10.152.82.105) 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 17:37:11 +0000 Received: from BN7NAM10FT018.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e8f::41) by BN7NAM10HT245.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e8f::308) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3239.17; Thu, 30 Jul 2020 17:37:10 +0000 Received: from BYAPR02MB4055.namprd02.prod.outlook.com (2a01:111:e400:7e8f::4a) by BN7NAM10FT018.mail.protection.outlook.com (2a01:111:e400:7e8f::67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3239.17 via Frontend Transport; Thu, 30 Jul 2020 17:37:10 +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 17:37:10 +0000 From: Bob Blick To: Microcontroller discussion list - Public. Sender: "piclist-bounces@mit.edu" Date: Thu, 30 Jul 2020 10:37:10 -0700 Subject: Re: [PIC] Simple GCC question Thread-Topic: [PIC] Simple GCC question Thread-Index: AQHWZotc+nNhZovUu0iBK4Bhj1/IWakgV02AgAAINQU= 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.40.20 as permitted sender) receiver=protection.outlook.com; client-ip=40.92.40.20; helo=NAM10-BN7-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=kASwxA9/j+YWVcxgnn4pC2WGOCSUaM2F5CoOxCXbwGY=; b=CkBtlJZbypRb6HTS9pDMW5btUV14bIg6IUGs2aLVHrbs3iGqAy3s9L1ujlo4Vskk9J+6y/X3BhWMvj+P7ZzuxT8VLHljItAeXNkNSnf6B3l/UjpE4DzHsf5/6fC93eesRg6BFKDC9VMSbk78IAy4cov9KvYQFL/NKLkcnCbJzsgIKphxlxh8gA1sPjywez5XaZUZOYT8emEXnEGZr2BdBDcxbZzXQc5i+6lD7Jn2AN7oCVl5dXC0y3jUr5Mx60ZVAynWSjImkTCiydYeyoen5icEbl09laQdV2qMhvOh6J3lj9fJft1SwOEYDysaVxA9LivrPRD2een31PqkF1h6bw== authentication-results: spf=pass (sender IP is 40.92.40.20) 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 06UHbSie022654 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Hi Manu, Although the LCD will not normally be driven from interrupts, if there is a= lockup I would like it to leave an error code on the display, which would = need to be done from an interrupt. I guess to make it global without errors I will need to hardcode the ports = and pins so I get rid of the arrays that are handed to Lcd_create() Thanks, Bob =20 ________________________________________ From: piclist-bounces@mit.edu on behalf of Manu A= braham=20 Sent: Thursday, July 30, 2020 9:55 AM To: Microcontroller discussion list - Public. Subject: Re: [PIC] Simple GCC question On Thu, Jul 30, 2020 at 9:57 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_GP= IO_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); > Why I dislike opaque datatypes... Instead of copying objects to Lcd_create(), a pointer could have been used, storage could have been global, made static .. the variables appear to be for configuration purposes ? One way to do is make the lcd object global. Another way is to pass a lcd object pointer to whatever function you are calling, unless you need to access the lcd object from interrupt context. If you need access from interrupt context, the easier way is to have global storage. -- --=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 .